From 60ddaf95f0b52a09fad18ea05b2b9db4509d0511 Mon Sep 17 00:00:00 2001 From: hackykid Date: Mon, 4 Jul 2005 14:58:55 +0000 Subject: (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. --- Makefile | 1 + ai_pathfinder.c | 2 + aystar.c | 4 + aystar.h | 6 ++ data/nsignalsw.grf | Bin 0 -> 50012 bytes data/signalsw.grf | Bin 22939 -> 0 bytes debug.c | 2 + debug.h | 1 + docs/landscape.html | 22 ++-- lang/english.txt | 1 + npf.c | 234 +++++++++++++++++++++++++++++++++++++++--- npf.h | 14 ++- pbs.c | 291 ++++++++++++++++++++++++++++++++++++++++++++++++++++ pbs.h | 82 +++++++++++++++ rail.c | 9 ++ rail.h | 25 ++++- rail_cmd.c | 137 ++++++++++++++++++------- road_cmd.c | 20 ++++ roadveh_cmd.c | 4 +- settings.c | 1 + settings_gui.c | 1 + ship_cmd.c | 2 +- station_cmd.c | 22 +++- table/files.h | 4 +- table/sprites.h | 2 +- train_cmd.c | 218 +++++++++++++++++++++++++++++++++++++-- tunnelbridge_cmd.c | 19 ++++ variables.h | 1 + vehicle.c | 5 +- vehicle.h | 2 + 30 files changed, 1053 insertions(+), 79 deletions(-) create mode 100644 data/nsignalsw.grf delete mode 100644 data/signalsw.grf create mode 100644 pbs.c create mode 100644 pbs.h diff --git a/Makefile b/Makefile index be76e3d74..c1e20799c 100644 --- a/Makefile +++ b/Makefile @@ -651,6 +651,7 @@ C_SOURCES += order_cmd.c C_SOURCES += order_gui.c C_SOURCES += openttd.c C_SOURCES += pathfind.c +C_SOURCES += pbs.c C_SOURCES += player_gui.c C_SOURCES += players.c C_SOURCES += pool.c diff --git a/ai_pathfinder.c b/ai_pathfinder.c index a3ddda982..f26cead73 100644 --- a/ai_pathfinder.c +++ b/ai_pathfinder.c @@ -97,6 +97,8 @@ AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFin result->FoundEndNode = AyStar_AiPathFinder_FoundEndNode; result->GetNeighbours = AyStar_AiPathFinder_GetNeighbours; + result->BeforeExit = NULL; + result->free = AyStar_AiPathFinder_Free; // Set some information diff --git a/aystar.c b/aystar.c index e2f9109fe..785746185 100644 --- a/aystar.c +++ b/aystar.c @@ -230,6 +230,10 @@ int AyStarMain_Main(AyStar *aystar) { else if (r == AYSTAR_LIMIT_REACHED) printf("[AyStar] Exceeded search_nodes, no path found\n"); #endif + + if (aystar->BeforeExit != NULL) + aystar->BeforeExit(aystar); + if (r != AYSTAR_STILL_BUSY) /* We're done, clean up */ aystar->clear(aystar); diff --git a/aystar.h b/aystar.h index adda33aba..52c93e911 100644 --- a/aystar.h +++ b/aystar.h @@ -96,6 +96,11 @@ typedef void AyStar_GetNeighbours(AyStar *aystar, OpenListNode *current); */ typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current); +/* + * Is called when aystar ends it pathfinding, but before cleanup. + */ +typedef void AyStar_BeforeExit(AyStar *aystar); + // For internal use, see aystar.c typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode* start_node, uint g); typedef int AyStar_Main(AyStar *aystar); @@ -115,6 +120,7 @@ struct AyStar { AyStar_GetNeighbours* GetNeighbours; AyStar_EndNodeCheck* EndNodeCheck; AyStar_FoundEndNode* FoundEndNode; + AyStar_BeforeExit* BeforeExit; /* These are completely untouched by AyStar, they can be accesed by * the application specific routines to input and output data. diff --git a/data/nsignalsw.grf b/data/nsignalsw.grf new file mode 100644 index 000000000..03dee7863 Binary files /dev/null and b/data/nsignalsw.grf differ diff --git a/data/signalsw.grf b/data/signalsw.grf deleted file mode 100644 index ca78876d0..000000000 Binary files a/data/signalsw.grf and /dev/null differ diff --git a/debug.c b/debug.c index 3230c96d7..fe36348fc 100644 --- a/debug.c +++ b/debug.c @@ -14,6 +14,7 @@ int _debug_ms_level; int _debug_net_level; int _debug_spritecache_level; int _debug_oldloader_level; +int _debug_pbs_level; int _debug_npf_level; @@ -44,6 +45,7 @@ typedef struct DebugLevel { DEBUG_LEVEL(net), DEBUG_LEVEL(spritecache), DEBUG_LEVEL(oldloader), + DEBUG_LEVEL(pbs), DEBUG_LEVEL(npf) }; #undef DEBUG_LEVEL diff --git a/debug.h b/debug.h index 44237feca..320e1d5de 100644 --- a/debug.h +++ b/debug.h @@ -14,6 +14,7 @@ extern int _debug_net_level; extern int _debug_spritecache_level; extern int _debug_oldloader_level; + extern int _debug_pbs_level; extern int _debug_npf_level; #endif diff --git a/docs/landscape.html b/docs/landscape.html index de298b09d..7bbed0a5e 100644 --- a/docs/landscape.html +++ b/docs/landscape.html @@ -93,11 +93,12 @@ map5 bit 7 clear: railway track
  • map2 bits 7..4: bit clear = signal shows red; same bits as in map3_lo
  • OpenTTD bits in map3_hi: - - - - - + + + + + +
    bits 1..0: type of signal:
    00: normal signals
    01: pre-signals
    10: exit-signals
    11: combo-signals
    bits 2..0: type of signal:
    000: normal signals
    001: pre-signals
    010: exit-signals
    011: combo-signals
    100: PBS signals
    bit 3: set = semaphore signals, clear = light signals
  • @@ -120,7 +121,11 @@ map5 bit 7 clear: railway track C  on snow or desert
  • map3_lo bits 0..3 = track type: 0 - conventional railway, 1 - monorail, 2 - maglev -
  • +
  • map3_lo bits 4..7 = Pbs reserved status: + + + +
    bits 4..6  'Track'number of reserved track + 1, if this is zero it means nothing is reserved on this tile
    bit 7  If this is set, then the opposite track ('Track'number^1) is also reserved
  • map5 bits 7 and 6 set: railway depot / checkpoints @@ -157,6 +163,7 @@ map5 bit 4 set, bits 7..5 clear: level crossing @@ -542,6 +550,8 @@ map5 bits 7..4 clear: tunnel entrance/exit
  • map_owner: owner of the tunnel
  • map3_lo bits 3..0 = track type for railway tunnel, must be 0 for road tunnel
  • map3_hi bit 7 set = on snow or desert
  • +
  • map3hi bit 0 set = track with 'Track'number 0 is reserved by pbs
  • +
  • map3hi bit 1 set = track with 'Track'number 1 is reserved by pbs
  • map5 bit 7 set: bridge