summaryrefslogtreecommitdiff
path: root/road_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 /road_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 '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;