From 27e61cbd84be6b32eaf5acafade515f501036a21 Mon Sep 17 00:00:00 2001 From: celestar Date: Thu, 30 Jun 2005 13:24:17 +0000 Subject: [PATCH] (svn r2499) -Codechange: Moved the semaphore bit from bit 2 to bit 3 in _map_hi for rails, in order to make way for pbs --- docs/landscape.html | 2 +- docs/landscape_grid.html | 2 +- openttd.c | 9 +++++++++ rail_cmd.c | 32 ++++++++++++++++++++++++++------ saveload.c | 2 +- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/docs/landscape.html b/docs/landscape.html index 2f4f6c7752..de298b09de 100644 --- a/docs/landscape.html +++ b/docs/landscape.html @@ -98,7 +98,7 @@ map5 bit 7 clear: railway track 01: pre-signals 10: exit-signals 11: combo-signals -bit 2: set = semaphore signals, clear = light signals +bit 3: set = semaphore signals, clear = light signals
  • map_owner: owner of the track diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html index df11897c43..511a25b45f 100644 --- a/docs/landscape_grid.html +++ b/docs/landscape_grid.html @@ -52,7 +52,7 @@ the array so you can quickly see what is used and what is not. XXXX XXXX XXXX XXXX OOOO OOOO
    - XXXX XXXX XXXO OOOO
    + XXXX XXXX XXOX OOOO
    XXXX    XXXX XXXX XXXX
    diff --git a/openttd.c b/openttd.c index 13a5083264..75c7c3152e 100644 --- a/openttd.c +++ b/openttd.c @@ -1410,5 +1410,14 @@ bool AfterLoadGame(uint version) } } + if (version < 0xF00) { + BEGIN_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0) { + if (IsTileType(tile, MP_RAILWAY) && HasSignals(tile) && HASBIT(_map3_hi[tile], 2)) { + CLRBIT(_map3_hi[tile], 2); + SETBIT(_map3_hi[tile], 3); + } + } END_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0); + } + return true; } diff --git a/rail_cmd.c b/rail_cmd.c index a4ea4c21bf..b1ec7ea517 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -749,7 +749,7 @@ int32 CmdBuildSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2) _map5[tile] |= RAIL_TYPE_SIGNALS; // change into signals _map2[tile] |= 0xF0; // all signals are on _map3_lo[tile] &= ~0xF0; // no signals built by default - _map3_hi[tile] = semaphore ? 4 : 0; + _map3_hi[tile] = semaphore ? 0x08 : 0; } if (p2 == 0) { @@ -792,9 +792,9 @@ int32 CmdBuildSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2) _map3_lo[tile] |= p2 & SignalOnTrack(track); // convert between signal<->semaphores when dragging if (semaphore) - SETBIT(_map3_hi[tile], 2); + SETBIT(_map3_hi[tile], 3); else - CLRBIT(_map3_hi[tile], 2); + CLRBIT(_map3_hi[tile], 3); } MarkTileDirtyByTile(tile); @@ -931,7 +931,7 @@ int32 CmdRemoveSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2) if ((_map3_lo[tile] & 0xF0) == 0) { _map5[tile] &= ~RAIL_TYPE_SIGNALS; _map2[tile] &= ~0xF0; - CLRBIT(_map3_hi[tile], 2); // remove any possible semaphores + CLRBIT(_map3_hi[tile], 3); // remove any possible semaphores } SetSignalsOnBothDir(tile, track); @@ -1118,28 +1118,48 @@ static int32 ClearTile_Track(TileIndex tile, byte flags) #include "table/track_land.h" // used for presignals -static const SpriteID _signal_base_sprites[16] = { +static const SpriteID _signal_base_sprites[32] = { 0x4FB, 0x1323, 0x1333, 0x1343, + 0x0, //PBS place, light signal + 0x0, //reserved for future use + 0x0, //reserved for future use + 0x0, //reserved for future use + // use semaphores instead of signals? 0x1353, 0x1363, 0x1373, 0x1383, + 0x0, //PBS place, semaphore + 0x0, //reserved for future use + 0x0, //reserved for future use + 0x0, //reserved for future use + // mirrored versions 0x4FB, 0x1323, 0x1333, 0x1343, + 0x0, //PBS place, semaphore + 0x0, //reserved for future use + 0x0, //reserved for future use + 0x0, //reserved for future use + 0x13C6, 0x13D6, 0x13E6, 0x13F6, + + 0x0, //PBS place, semaphore + 0x0, //reserved for future use + 0x0, //reserved for future use + 0x0, //reserved for future use }; // used to determine the side of the road for the signal @@ -1157,7 +1177,7 @@ static void DrawSignalHelper(TileInfo *ti, byte condition, uint32 image_and_pos) uint v = _signal_position[(image_and_pos & 0xF) + (otherside ? 12 : 0)]; uint x = ti->x | (v&0xF); uint y = ti->y | (v>>4); - uint sprite = _signal_base_sprites[(_map3_hi[ti->tile] & 7) + (otherside ? 8 : 0)] + (image_and_pos>>4) + ((condition != 0) ? 1 : 0); + uint sprite = _signal_base_sprites[(_map3_hi[ti->tile] & 0xF) + (otherside ? 0x10 : 0)] + (image_and_pos>>4) + ((condition != 0) ? 1 : 0); AddSortableSpriteToDraw(sprite, x, y, 1, 1, 10, GetSlopeZ(x,y)); } diff --git a/saveload.c b/saveload.c index 0ec2bc23d1..2fdfbe2d31 100644 --- a/saveload.c +++ b/saveload.c @@ -23,7 +23,7 @@ #include "saveload.h" enum { - SAVEGAME_MAJOR_VERSION = 14, + SAVEGAME_MAJOR_VERSION = 15, SAVEGAME_MINOR_VERSION = 0, SAVEGAME_LOADABLE_VERSION = (SAVEGAME_MAJOR_VERSION << 8) + SAVEGAME_MINOR_VERSION