summaryrefslogtreecommitdiff
path: root/tunnelbridge_cmd.c
diff options
context:
space:
mode:
authorhackykid <hackykid@openttd.org>2005-07-04 14:58:55 +0000
committerhackykid <hackykid@openttd.org>2005-07-04 14:58:55 +0000
commit60ddaf95f0b52a09fad18ea05b2b9db4509d0511 (patch)
treec0f8f7ba8535ff0f5e9fd8581b36c737ac10e0b1 /tunnelbridge_cmd.c
parentb872cf7f7bd6fdcc8b09903130cb961c004ad5de (diff)
downloadopenttd-60ddaf95f0b52a09fad18ea05b2b9db4509d0511.tar.xz
(svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
- Feature: [pbs] Implement autoplacement of pbs blocks, when a block has an entry and an exit pbs signal, covert the entire block to pbs. Can be turned off in the patch settings. - Feature: [pbs] Allow showing of reserved status by making the tracks darker, when the pbs debug level is at least 1.
Diffstat (limited to 'tunnelbridge_cmd.c')
-rw-r--r--tunnelbridge_cmd.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 36924686c..0ae9bb5c6 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -10,6 +10,8 @@
#include "player.h"
#include "town.h"
#include "sound.h"
+#include "pbs.h"
+#include "debug.h"
extern void DrawCanalWater(TileIndex tile);
@@ -770,6 +772,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
byte m5;
uint c = tile;
uint16 new_data;
+ byte pbs;
//checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
// you have a "Poor" (0) town rating
@@ -778,6 +781,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
do {
m5 = _map5[c];
+ pbs = PBSTileReserved(c);
if (m5 & 0x40) {
if (m5 & 0x20) {
@@ -791,6 +795,9 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
SetTileType(c, new_data >> 12);
_map5[c] = (byte)new_data;
_map2[c] = 0;
+ _map3_hi[c] &= 0x0F;
+ if (direction ? HASBIT(pbs,0) : HASBIT(pbs,1))
+ PBSReserveTrack(c, direction ? 0 : 1);
MarkTileDirtyByTile(c);
@@ -1144,6 +1151,16 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
}
}
}
+
+ if (_debug_pbs_level >= 1) {
+ byte pbs = PBSTileReserved(ti->tile);
+ if (pbs & TRACK_BIT_DIAG1) DrawGroundSprite(0x3ED | PALETTE_CRASH);
+ if (pbs & TRACK_BIT_DIAG2) DrawGroundSprite(0x3EE | PALETTE_CRASH);
+ if (pbs & TRACK_BIT_UPPER) DrawGroundSprite(0x3EF | PALETTE_CRASH);
+ if (pbs & TRACK_BIT_LOWER) DrawGroundSprite(0x3F0 | PALETTE_CRASH);
+ if (pbs & TRACK_BIT_LEFT) DrawGroundSprite(0x3F2 | PALETTE_CRASH);
+ if (pbs & TRACK_BIT_RIGHT) DrawGroundSprite(0x3F1 | PALETTE_CRASH);
+ }
}
static uint GetSlopeZ_TunnelBridge(TileInfo *ti) {
@@ -1426,6 +1443,8 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y
return 0;
}
if (fc == _tunnel_fractcoord_2[dir]) {
+ if (v->next == NULL)
+ PBSClearTrack(v->tile, FIND_FIRST_BIT(v->u.rail.track));
v->tile = tile;
v->u.rail.track = 0x40;
v->vehstatus |= VS_HIDDEN;