(svn r27270) [1.5] -Backport from trunk:

- Fix: Duplicate frees due to pool item classes not having copy constructors [FS#6285] (r27243)
- Fix: Crash when no AIs were installed due to improper handling of non-ASCII characters by the string pointer lexer [FS#6272] (r27233)
- Fix: Compilation on DragonflyBSD [FS#6274] (r27224, r27223)
- Fix: Use the current maximum speed as limited by bridges, orders etc. for all vehicle types alike when considering increased smoke emissions of vehicles [FS#6278] (r27222)
- Fix: Multi-value keys in the desktop entry shall end with a trailing separator (r27221)
- Fix: Draw path reservation on the whole bridge, not only on the bridge heads (r27209)
- Fix: Draw correct overlay sprites for path reservations on bridges and tunnels (r27208)
This commit is contained in:
frosch
2015-05-08 17:23:55 +00:00
committed by Sergii Pylypenko
parent 9fa342727b
commit 960600af4f
8 changed files with 150 additions and 79 deletions

View File

@@ -1261,10 +1261,28 @@ struct BufState{
WChar buf_lexfeed(SQUserPointer file)
{
BufState *buf=(BufState*)file;
if(buf->size<(buf->ptr+1))
return 0;
return buf->buf[buf->ptr++];
/* Convert an UTF-8 character into a WChar */
BufState *buf = (BufState *)file;
const char *p = &buf->buf[buf->ptr];
if (buf->size < buf->ptr + 1) return 0;
/* Read the first character, and get the length based on UTF-8 specs. If invalid, bail out. */
uint len = Utf8EncodedCharLen(*p);
if (len == 0) {
buf->ptr++;
return -1;
}
/* Read the remaining bits. */
if (buf->size < buf->ptr + len) return 0;
buf->ptr += len;
/* Convert the character, and when definitely invalid, bail out as well. */
WChar c;
if (Utf8Decode(&c, p) != len) return -1;
return c;
}
SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror) {

View File

@@ -85,7 +85,11 @@ bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations)
if (_settings_client.gui.show_track_reservation) {
/* show the reserved rail if needed */
MarkTileDirtyByTile(tile);
if (IsBridgeTile(tile)) {
MarkBridgeDirty(tile);
} else {
MarkTileDirtyByTile(tile);
}
}
switch (GetTileType(tile)) {
@@ -141,7 +145,11 @@ void UnreserveRailTrack(TileIndex tile, Track t)
assert((GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & TrackToTrackBits(t)) != 0);
if (_settings_client.gui.show_track_reservation) {
MarkTileDirtyByTile(tile);
if (IsBridgeTile(tile)) {
MarkBridgeDirty(tile);
} else {
MarkTileDirtyByTile(tile);
}
}
switch (GetTileType(tile)) {

View File

@@ -48,21 +48,39 @@ static const SaveLoad _engine_desc[] = {
SLE_END()
};
static std::vector<Engine> _temp_engine;
static std::vector<Engine*> _temp_engine;
/**
* Allocate an Engine structure, but not using the pools.
* The allocated Engine must be freed using FreeEngine;
* @return Allocated engine.
*/
static Engine* CallocEngine()
{
uint8 *zero = CallocT<uint8>(sizeof(Engine));
Engine *engine = new (zero) Engine();
return engine;
}
/**
* Deallocate an Engine constructed by CallocEngine.
* @param e Engine to free.
*/
static void FreeEngine(Engine *e)
{
if (e != NULL) {
e->~Engine();
free(e);
}
}
Engine *GetTempDataEngine(EngineID index)
{
if (index < _temp_engine.size()) {
return &_temp_engine[index];
return _temp_engine[index];
} else if (index == _temp_engine.size()) {
uint8 zero[sizeof(Engine)];
memset(zero, 0, sizeof(zero));
Engine *engine = new (zero) Engine();
/* Adding 'engine' to the vector makes a shallow copy, so we do not want to destruct 'engine' */
_temp_engine.push_back(*engine);
return &_temp_engine[index];
_temp_engine.push_back(CallocEngine());
return _temp_engine[index];
} else {
NOT_REACHED();
}
@@ -127,6 +145,9 @@ void CopyTempEngineData()
}
/* Get rid of temporary data */
for (std::vector<Engine*>::iterator it = _temp_engine.begin(); it != _temp_engine.end(); ++it) {
FreeEngine(*it);
}
_temp_engine.clear();
}

View File

@@ -2216,8 +2216,12 @@ static void ClearPathReservation(const Train *v, TileIndex tile, Trackdir track_
SetTunnelBridgeReservation(end, false);
if (_settings_client.gui.show_track_reservation) {
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(end);
if (IsBridge(tile)) {
MarkBridgeDirty(tile);
} else {
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(end);
}
}
}
}

View File

@@ -1210,7 +1210,12 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
/* PBS debugging, draw reserved tracks darker */
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasTunnelBridgeReservation(ti->tile)) {
DrawGroundSprite(DiagDirToAxis(tunnelbridge_direction) == AXIS_X ? rti->base_sprites.single_x : rti->base_sprites.single_y, PALETTE_CRASH);
if (rti->UsesOverlay()) {
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY);
DrawGroundSprite(overlay + RTO_X + DiagDirToAxis(tunnelbridge_direction), PALETTE_CRASH);
} else {
DrawGroundSprite(DiagDirToAxis(tunnelbridge_direction) == AXIS_X ? rti->base_sprites.single_x : rti->base_sprites.single_y, PALETTE_CRASH);
}
}
if (HasCatenaryDrawn(GetRailType(ti->tile))) {
@@ -1320,11 +1325,20 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
}
/* PBS debugging, draw reserved tracks darker */
if (_game_mode != GM_MENU &&_settings_client.gui.show_track_reservation && HasTunnelBridgeReservation(ti->tile)) {
if (HasBridgeFlatRamp(ti->tileh, DiagDirToAxis(tunnelbridge_direction))) {
AddSortableSpriteToDraw(DiagDirToAxis(tunnelbridge_direction) == AXIS_X ? rti->base_sprites.single_x : rti->base_sprites.single_y, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + 8);
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasTunnelBridgeReservation(ti->tile)) {
if (rti->UsesOverlay()) {
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY);
if (HasBridgeFlatRamp(ti->tileh, DiagDirToAxis(tunnelbridge_direction))) {
AddSortableSpriteToDraw(overlay + RTO_X + DiagDirToAxis(tunnelbridge_direction), PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + 8);
} else {
AddSortableSpriteToDraw(overlay + RTO_SLOPE_NE + tunnelbridge_direction, PALETTE_CRASH, ti->x, ti->y, 16, 16, 8, ti->z);
}
} else {
AddSortableSpriteToDraw(rti->base_sprites.single_sloped + tunnelbridge_direction, PALETTE_CRASH, ti->x, ti->y, 16, 16, 8, ti->z);
if (HasBridgeFlatRamp(ti->tileh, DiagDirToAxis(tunnelbridge_direction))) {
AddSortableSpriteToDraw(DiagDirToAxis(tunnelbridge_direction) == AXIS_X ? rti->base_sprites.single_x : rti->base_sprites.single_y, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + 8);
} else {
AddSortableSpriteToDraw(rti->base_sprites.single_sloped + tunnelbridge_direction, PALETTE_CRASH, ti->x, ti->y, 16, 16, 8, ti->z);
}
}
}
@@ -1467,6 +1481,16 @@ void DrawBridgeMiddle(const TileInfo *ti)
AddSortableSpriteToDraw(surface + axis, PAL_NONE, x, y, 16, 16, 0, bridge_z, IsTransparencySet(TO_BRIDGES));
}
}
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && !IsInvisibilitySet(TO_BRIDGES) && HasTunnelBridgeReservation(rampnorth)) {
if (rti->UsesOverlay()) {
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY);
AddSortableSpriteToDraw(overlay + RTO_X + axis, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, bridge_z, IsTransparencySet(TO_BRIDGES));
} else {
AddSortableSpriteToDraw(axis == AXIS_X ? rti->base_sprites.single_x : rti->base_sprites.single_y, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, bridge_z, IsTransparencySet(TO_BRIDGES));
}
}
EndSpriteCombine();
if (HasCatenaryDrawn(GetRailType(rampsouth))) {

View File

@@ -2414,7 +2414,9 @@ void Vehicle::ShowVisualEffect() const
return;
}
uint max_speed = this->vcache.cached_max_speed;
/* Use the speed as limited by underground and orders. */
uint max_speed = this->GetCurrentMaxSpeed();
if (this->type == VEH_TRAIN) {
const Train *t = Train::From(this);
/* For trains, do not show any smoke when:
@@ -2423,14 +2425,10 @@ void Vehicle::ShowVisualEffect() const
*/
if (HasBit(t->flags, VRF_REVERSING) ||
(IsRailStationTile(t->tile) && t->IsFrontEngine() && t->current_order.ShouldStopAtStation(t, GetStationIndex(t->tile)) &&
t->cur_speed >= t->Train::GetCurrentMaxSpeed())) {
t->cur_speed >= max_speed)) {
return;
}
max_speed = min(max_speed, t->gcache.cached_max_track_speed);
max_speed = min(max_speed, this->current_order.GetMaxSpeed());
}
if (this->type == VEH_ROAD || this->type == VEH_SHIP) max_speed = min(max_speed, this->current_order.GetMaxSpeed() * 2);
const Vehicle *v = this;