summaryrefslogtreecommitdiff
path: root/tunnelbridge_cmd.c
diff options
context:
space:
mode:
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;