summaryrefslogtreecommitdiff
path: root/road_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'road_cmd.c')
-rw-r--r--road_cmd.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/road_cmd.c b/road_cmd.c
index 2b954ed23..c44b38d8a 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "openttd.h"
+#include "table/sprites.h"
#include "table/strings.h"
#include "map.h"
#include "tile.h"
@@ -11,6 +12,8 @@
#include "gfx.h"
#include "sound.h"
#include "depot.h"
+#include "pbs.h"
+#include "debug.h"
/* When true, GetTrackStatus for roads will treat roads under reconstruction
* as normal roads instead of impassable. This is used when detecting whether
@@ -246,6 +249,7 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
cost = _price.remove_road * 2;
if (flags & DC_EXEC) {
+ byte pbs_track = PBSTileReserved(tile);
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
ModifyTile(tile,
@@ -254,6 +258,8 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
_map3_hi[tile] & 0xF, /* map3_lo */
c /* map5 */
);
+ if (pbs_track != 0)
+ PBSReserveTrack(tile, FIND_FIRST_BIT(pbs_track));
}
return cost;
} else
@@ -396,6 +402,7 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
goto do_clear;
if (flags & DC_EXEC) {
+ byte pbs_track = PBSTileReserved(tile);
ModifyTile(tile,
MP_SETTYPE(MP_STREET) |
MP_MAP2 | MP_MAP3LO | MP_MAP3HI | MP_MAP5,
@@ -404,6 +411,8 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
_map3_lo[tile] & 0xF, /* map3_hi */
m5 /* map5 */
);
+ if (pbs_track != 0)
+ PBSReserveTrack(tile, FIND_FIRST_BIT(pbs_track));
}
return _price.build_road * 2;
} else if (ti.type == MP_TUNNELBRIDGE) {
@@ -826,6 +835,17 @@ static void DrawTile_Road(TileInfo *ti)
}
DrawGroundSprite(image + (_map3_hi[ti->tile] & 0xF) * 12);
+
+ 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);
+ }
+
} else {
uint32 ormod;
int player;