(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.

-Cleanup: whitespace alignment of a few tables.
replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
rubidium 18 years ago
parent a7cfb80c40
commit 63687763e9

@ -1915,14 +1915,14 @@ static bool AirportFindFreeTerminal(Vehicle *v, const AirportFTAClass *Airport)
Station *st; Station *st;
/* example of more terminalgroups /* example of more terminalgroups
{0,HANGAR,NOTHING_block,1}, {0,255,TERM_GROUP1_block,0}, {0,255,TERM_GROUP2_ENTER_block,1}, {0,0,N,1}, * {0,HANGAR,NOTHING_block,1}, {0,255,TERM_GROUP1_block,0}, {0,255,TERM_GROUP2_ENTER_block,1}, {0,0,N,1},
Heading 255 denotes a group. We see 2 groups here: * Heading 255 denotes a group. We see 2 groups here:
1. group 0 -- TERM_GROUP1_block (check block) * 1. group 0 -- TERM_GROUP1_block (check block)
2. group 1 -- TERM_GROUP2_ENTER_block (check block) * 2. group 1 -- TERM_GROUP2_ENTER_block (check block)
First in line is checked first, group 0. If the block (TERM_GROUP1_block) is free, it * First in line is checked first, group 0. If the block (TERM_GROUP1_block) is free, it
looks at the corresponding terminals of that group. If no free ones are found, other * looks at the corresponding terminals of that group. If no free ones are found, other
possible groups are checked (in this case group 1, since that is after group 0). If that * possible groups are checked (in this case group 1, since that is after group 0). If that
fails, then attempt fails and plane waits * fails, then attempt fails and plane waits
*/ */
if (Airport->terminals[0] > 1) { if (Airport->terminals[0] > 1) {
st = GetStation(v->u.air.targetairport); st = GetStation(v->u.air.targetairport);

@ -1,48 +1,48 @@
/* $Id$ */ /* $Id$ */
/** @file elrail.c /** @file elrail.c
This file deals with displaying wires and pylons for electric railways. * This file deals with displaying wires and pylons for electric railways.
<h2>Basics</h2> * <h2>Basics</h2>
*
<h3>Tile Types</h3> * <h3>Tile Types</h3>
*
We have two different types of tiles in the drawing code: * We have two different types of tiles in the drawing code:
Normal Railway Tiles (NRTs) which can have more than one track on it, and * Normal Railway Tiles (NRTs) which can have more than one track on it, and
Special Railways tiles (SRTs) which have only one track (like crossings, depots * Special Railways tiles (SRTs) which have only one track (like crossings, depots
stations, etc). * stations, etc).
*
<h3>Location Categories</h3> * <h3>Location Categories</h3>
*
All tiles are categorized into three location groups (TLG): * All tiles are categorized into three location groups (TLG):
Group 0: Tiles with both an even X coordinate and an even Y coordinate * Group 0: Tiles with both an even X coordinate and an even Y coordinate
Group 1: Tiles with an even X and an odd Y coordinate * Group 1: Tiles with an even X and an odd Y coordinate
Group 2: Tiles with an odd X and an even Y coordinate * Group 2: Tiles with an odd X and an even Y coordinate
Group 3: Tiles with both an odd X and Y coordnate. * Group 3: Tiles with both an odd X and Y coordnate.
*
<h3>Pylon Points</h3> * <h3>Pylon Points</h3>
<h4>Control Points</h4> * <h4>Control Points</h4>
A Pylon Control Point (PCP) is a position where a wire (or rather two) * A Pylon Control Point (PCP) is a position where a wire (or rather two)
is mounted onto a pylon. * is mounted onto a pylon.
Each NRT does contain 4 PCPs which are bitmapped to a byte * Each NRT does contain 4 PCPs which are bitmapped to a byte
variable and are represented by the DiagDirection enum * variable and are represented by the DiagDirection enum
*
Each track ends on two PCPs and thus requires one pylon on each end. However, * Each track ends on two PCPs and thus requires one pylon on each end. However,
there is one exception: Straight-and-level tracks only have one pylon every * there is one exception: Straight-and-level tracks only have one pylon every
other tile. * other tile.
*
Now on each edge there are two PCPs: One from each adjacent tile. Both PCPs * Now on each edge there are two PCPs: One from each adjacent tile. Both PCPs
are merged using an OR operation (i. e. if one tile needs a PCP at the postion * are merged using an OR operation (i. e. if one tile needs a PCP at the postion
in question, both tiles get it). * in question, both tiles get it).
*
<h4>Position Points</h4> * <h4>Position Points</h4>
A Pylon Position Point (PPP) is a position where a pylon is located on the * A Pylon Position Point (PPP) is a position where a pylon is located on the
ground. Each PCP owns 8 in (45 degree steps) PPPs that are located around * ground. Each PCP owns 8 in (45 degree steps) PPPs that are located around
it. PPPs are represented using the Direction enum. Each track bit has PPPs * it. PPPs are represented using the Direction enum. Each track bit has PPPs
that are impossible (because the pylon would be situated on the track) and * that are impossible (because the pylon would be situated on the track) and
some that are preferred (because the pylon would be rectangular to the track). * some that are preferred (because the pylon would be rectangular to the track).
*
<img src="../../elrail_tile.png"> * <img src="../../elrail_tile.png">
<img src="../../elrail_track.png"> * <img src="../../elrail_track.png">
*
*/ */
#include "stdafx.h" #include "stdafx.h"
@ -155,8 +155,8 @@ static void AdjustTileh(TileIndex tile, Slope *tileh)
static void DrawCatenaryRailway(const TileInfo *ti) static void DrawCatenaryRailway(const TileInfo *ti)
{ {
/* Pylons are placed on a tile edge, so we need to take into account /* Pylons are placed on a tile edge, so we need to take into account
the track configuration of 2 adjacent tiles. trackconfig[0] stores the * the track configuration of 2 adjacent tiles. trackconfig[0] stores the
current tile (home tile) while [1] holds the neighbour */ * current tile (home tile) while [1] holds the neighbour */
TrackBits trackconfig[TS_END]; TrackBits trackconfig[TS_END];
bool isflat[TS_END]; bool isflat[TS_END];
/* Note that ti->tileh has already been adjusted for Foundations */ /* Note that ti->tileh has already been adjusted for Foundations */
@ -171,11 +171,11 @@ static void DrawCatenaryRailway(const TileInfo *ti)
Track t; Track t;
/* Find which rail bits are present, and select the override points. /* Find which rail bits are present, and select the override points.
We don't draw a pylon: * We don't draw a pylon:
1) INSIDE a tunnel (we wouldn't see it anyway) * 1) INSIDE a tunnel (we wouldn't see it anyway)
2) on the "far" end of a bridge head (the one that connects to bridge middle), * 2) on the "far" end of a bridge head (the one that connects to bridge middle),
because that one is drawn on the bridge. Exception is for length 0 bridges * because that one is drawn on the bridge. Exception is for length 0 bridges
which have no middle tiles */ * which have no middle tiles */
trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP); trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP);
/* If a track bit is present that is not in the main direction, the track is level */ /* If a track bit is present that is not in the main direction, the track is level */
isflat[TS_HOME] = trackconfig[TS_HOME] & (TRACK_BIT_HORZ | TRACK_BIT_VERT); isflat[TS_HOME] = trackconfig[TS_HOME] & (TRACK_BIT_HORZ | TRACK_BIT_VERT);
@ -188,7 +188,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
int k; int k;
/* Here's one of the main headaches. GetTileSlope does not correct for possibly /* Here's one of the main headaches. GetTileSlope does not correct for possibly
existing foundataions, so we do have to do that manually later on.*/ * existing foundataions, so we do have to do that manually later on.*/
tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL); tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL);
trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL); trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL);
if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = 0; if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = 0;
@ -198,7 +198,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
PPPallowed[i] = AllowedPPPonPCP[i]; PPPallowed[i] = AllowedPPPonPCP[i];
/* We cycle through all the existing tracks at a PCP and see what /* We cycle through all the existing tracks at a PCP and see what
PPPs we want to have, or may not have at all */ * PPPs we want to have, or may not have at all */
for (k = 0; k < NUM_TRACKS_AT_PCP; k++) { for (k = 0; k < NUM_TRACKS_AT_PCP; k++) {
/* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */ /* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */
if (TrackSourceTile[i][k] == TS_NEIGHBOUR && if (TrackSourceTile[i][k] == TS_NEIGHBOUR &&
@ -208,10 +208,10 @@ static void DrawCatenaryRailway(const TileInfo *ti)
} }
/* We check whether the track in question (k) is present in the tile /* We check whether the track in question (k) is present in the tile
(TrackSourceTile) */ * (TrackSourceTile) */
if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) { if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) {
/* track found, if track is in the neighbour tile, adjust the number /* track found, if track is in the neighbour tile, adjust the number
of the PCP for preferred/allowed determination*/ * of the PCP for preferred/allowed determination*/
DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i); DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i);
SETBIT(PCPstatus, i); /* This PCP is in use */ SETBIT(PCPstatus, i); /* This PCP is in use */
@ -244,7 +244,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]); AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]);
/* If we have a straight (and level) track, we want a pylon only every 2 tiles /* If we have a straight (and level) track, we want a pylon only every 2 tiles
Delete the PCP if this is the case. */ * Delete the PCP if this is the case. */
/* Level means that the slope is the same, or the track is flat */ /* Level means that the slope is the same, or the track is flat */
if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) { if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) {
for (k = 0; k < NUM_IGNORE_GROUPS; k++) for (k = 0; k < NUM_IGNORE_GROUPS; k++)
@ -252,9 +252,9 @@ static void DrawCatenaryRailway(const TileInfo *ti)
} }
/* Now decide where we draw our pylons. First try the preferred PPPs, but they may not exist. /* Now decide where we draw our pylons. First try the preferred PPPs, but they may not exist.
In that case, we try the any of the allowed ones. if they don't exist either, don't draw * In that case, we try the any of the allowed ones. if they don't exist either, don't draw
anything. Note that the preferred PPPs still contain the end-of-line markers. * anything. Note that the preferred PPPs still contain the end-of-line markers.
Remove those (simply by ANDing with allowed, since these markers are never allowed) */ * Remove those (simply by ANDing with allowed, since these markers are never allowed) */
if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i]; if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i];
if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) { if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {

@ -191,10 +191,10 @@ void StartupEngines(void)
} }
/* This sets up type for the engine /* This sets up type for the engine
It is needed if you want to ask the engine what type it is * It is needed if you want to ask the engine what type it is
It should hopefully be the same as when you ask a vehicle what it is * It should hopefully be the same as when you ask a vehicle what it is
but using this, you can ask what type an engine number is * but using this, you can ask what type an engine number is
even if it is not a vehicle (yet)*/ * even if it is not a vehicle (yet)*/
} }
AdjustAvailAircraft(); AdjustAvailAircraft();

@ -3,8 +3,7 @@
#ifndef ENGINE_H #ifndef ENGINE_H
#define ENGINE_H #define ENGINE_H
/** @file engine.h /** @file engine.h */
*/
#include "pool.h" #include "pool.h"

@ -17,17 +17,17 @@
#include "date.h" #include "date.h"
/* News system /* News system
News system is realized as a FIFO queue (in an array) * News system is realized as a FIFO queue (in an array)
The positions in the queue can't be rearranged, we only access * The positions in the queue can't be rearranged, we only access
the array elements through pointers to the elements. Once the * the array elements through pointers to the elements. Once the
array is full, the oldest entry (_oldest_news) is being overwritten * array is full, the oldest entry (_oldest_news) is being overwritten
by the newest (_latest news). * by the newest (_latest news).
*
oldest current lastest * oldest current lastest
| | | * | | |
[O------------F-------------C---------L ] * [O------------F-------------C---------L ]
| * |
forced * forced
*/ */
#define MAX_NEWS 30 #define MAX_NEWS 30
@ -524,7 +524,7 @@ void ShowLastNewsMessage(void)
/* return news by number, with 0 being the most /* return news by number, with 0 being the most
recent news. Returns INVALID_NEWS if end of queue reached. */ * recent news. Returns INVALID_NEWS if end of queue reached. */
static byte getNews(byte i) static byte getNews(byte i)
{ {
if (i >= _total_news) return INVALID_NEWS; if (i >= _total_news) return INVALID_NEWS;

@ -1068,12 +1068,12 @@ static void UpdateExclusiveRights(void)
} }
/* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete) /* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete)
could be implemented this way: * could be implemented this way:
1.) Go through all stations * 1.) Go through all stations
Build an array town_blocked[ town_id ][ player_id ] * Build an array town_blocked[ town_id ][ player_id ]
that stores if at least one station in that town is blocked for a player * that stores if at least one station in that town is blocked for a player
2.) Go through that array, if you find a town that is not blocked for * 2.) Go through that array, if you find a town that is not blocked for
one player, but for all others, then give him exclusivity. * one player, but for all others, then give him exclusivity.
*/ */
} }

@ -1,7 +1,6 @@
/* $Id$ */ /* $Id$ */
/** @file order.h /** @file order.h */
*/
#ifndef ORDER_H #ifndef ORDER_H
#define ORDER_H #define ORDER_H

@ -817,9 +817,9 @@ void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* bak)
} }
/* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the /* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the
order number is one more than the current amount of orders, and because * order number is one more than the current amount of orders, and because
in network the commands are queued before send, the second insert always * in network the commands are queued before send, the second insert always
fails in test mode. By bypassing the test-mode, that no longer is a problem. */ * fails in test mode. By bypassing the test-mode, that no longer is a problem. */
for (i = 0; bak->order[i].type != OT_NOTHING; i++) { for (i = 0; bak->order[i].type != OT_NOTHING; i++) {
if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK))
break; break;
@ -1055,10 +1055,10 @@ void DeleteVehicleOrders(Vehicle *v)
v->next_shared = NULL; v->next_shared = NULL;
/* We only need to update this-one, because if there is a third /* We only need to update this-one, because if there is a third
vehicle which shares the same order-list, nothing will change. If * vehicle which shares the same order-list, nothing will change. If
this is the last vehicle, the last line of the order-window * this is the last vehicle, the last line of the order-window
will change from Shared order list, to Order list, so it needs * will change from Shared order list, to Order list, so it needs
an update */ * an update */
InvalidateVehicleOrder(u); InvalidateVehicleOrder(u);
return; return;
} }
@ -1175,8 +1175,8 @@ static void Load_ORDR(void)
/* Update all the next pointer */ /* Update all the next pointer */
for (i = 1; i < len; ++i) { for (i = 1; i < len; ++i) {
/* The orders were built like this: /* The orders were built like this:
Vehicle one had order[0], and as long as order++.type was not * Vehicle one had order[0], and as long as order++.type was not
OT_NOTHING, it was part of the order-list of that vehicle */ * OT_NOTHING, it was part of the order-list of that vehicle */
if (GetOrder(i)->type != OT_NOTHING) if (GetOrder(i)->type != OT_NOTHING)
GetOrder(i - 1)->next = GetOrder(i); GetOrder(i - 1)->next = GetOrder(i);
} }

@ -229,8 +229,7 @@ static inline bool IsLocalPlayer(void)
void DeletePlayerWindows(PlayerID pi); void DeletePlayerWindows(PlayerID pi);
byte GetPlayerRailtypes(PlayerID p); byte GetPlayerRailtypes(PlayerID p);
/** Finds out if a Player has a certain railtype available /** Finds out if a Player has a certain railtype available */
*/
static inline bool HasRailtypeAvail(const Player *p, RailType Railtype) static inline bool HasRailtypeAvail(const Player *p, RailType Railtype)
{ {
return HASBIT(p->avail_railtypes, Railtype); return HASBIT(p->avail_railtypes, Railtype);

@ -82,7 +82,7 @@ static inline TrackBits AxisToTrackBits(Axis a)
/** These are a combination of tracks and directions. Values are 0-5 in one /** These are a combination of tracks and directions. Values are 0-5 in one
direction (corresponding to the Track enum) and 8-13 in the other direction. */ * direction (corresponding to the Track enum) and 8-13 in the other direction. */
typedef enum Trackdirs { typedef enum Trackdirs {
TRACKDIR_X_NE = 0, TRACKDIR_X_NE = 0,
TRACKDIR_Y_SE = 1, TRACKDIR_Y_SE = 1,
@ -103,7 +103,7 @@ typedef enum Trackdirs {
} Trackdir; } Trackdir;
/** These are a combination of tracks and directions. Values are 0-5 in one /** These are a combination of tracks and directions. Values are 0-5 in one
direction (corresponding to the Track enum) and 8-13 in the other direction. */ * direction (corresponding to the Track enum) and 8-13 in the other direction. */
typedef enum TrackdirBits { typedef enum TrackdirBits {
TRACKDIR_BIT_NONE = 0x0000, TRACKDIR_BIT_NONE = 0x0000,
TRACKDIR_BIT_X_NE = 0x0001, TRACKDIR_BIT_X_NE = 0x0001,

@ -586,12 +586,11 @@ int32 CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
tileh = GetTileSlope(tile, NULL); tileh = GetTileSlope(tile, NULL);
/* Prohibit construction if /* Prohibit construction if
The tile is non-flat AND * The tile is non-flat AND
1) The AI is "old-school" * 1) The AI is "old-school"
2) build-on-slopes is disabled * 2) build-on-slopes is disabled
3) the tile is steep i.e. spans two height levels * 3) the tile is steep i.e. spans two height levels
4) the exit points in the wrong direction * 4) the exit points in the wrong direction
*/ */
if (tileh != SLOPE_FLAT && ( if (tileh != SLOPE_FLAT && (
@ -777,7 +776,7 @@ static int32 CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint3
* trackdir - trackdir to build with autorail * trackdir - trackdir to build with autorail
* semaphores - semaphores or signals * semaphores - semaphores or signals
* signals - is there a signal/semaphore on the first tile, copy its style (two-way/single-way) * signals - is there a signal/semaphore on the first tile, copy its style (two-way/single-way)
and convert all others to semaphore/signal * and convert all others to semaphore/signal
* mode - 1 remove signals, 0 build signals */ * mode - 1 remove signals, 0 build signals */
signal_ctr = total_cost = 0; signal_ctr = total_cost = 0;
for (;;) { for (;;) {

@ -328,24 +328,24 @@ static inline bool GetBitAndShift(uint32 *b)
} }
/* /*
A: competitors * A: competitors
B: start time in months / 3 * B: start time in months / 3
C: town count (2 = high, 0 = low) * C: town count (2 = high, 0 = low)
D: industry count (3 = high, 0 = none) * D: industry count (3 = high, 0 = none)
E: inital loan / 1000 (in GBP) * E: inital loan / 1000 (in GBP)
F: interest rate * F: interest rate
G: running costs (0 = low, 2 = high) * G: running costs (0 = low, 2 = high)
H: construction speed of competitors (0 = very slow, 4 = very fast) * H: construction speed of competitors (0 = very slow, 4 = very fast)
I: intelligence (0-2) * I: intelligence (0-2)
J: breakdowns(0 = off, 2 = normal) * J: breakdowns (0 = off, 2 = normal)
K: subsidy multiplier (0 = 1.5, 3 = 4.0) * K: subsidy multiplier (0 = 1.5, 3 = 4.0)
L: construction cost (0-2) * L: construction cost (0-2)
M: terrain type (0 = very flat, 3 = mountainous) * M: terrain type (0 = very flat, 3 = mountainous)
N: amount of water (0 = very low, 3 = high) * N: amount of water (0 = very low, 3 = high)
O: economy (0 = steady, 1 = fluctuating) * O: economy (0 = steady, 1 = fluctuating)
P: Train reversing (0 = end of line + stations, 1 = end of line) * P: Train reversing (0 = end of line + stations, 1 = end of line)
Q: disasters * Q: disasters
R: area restructuring (0 = permissive, 2 = hostile) * R: area restructuring (0 = permissive, 2 = hostile)
*/ */
static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /* static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/ A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/
@ -987,7 +987,7 @@ static void NewgrfWndProc(Window *w, WindowEvent *e)
break; break;
} break; } break;
/* Parameter edit box not used yet #if 0 /* Parameter edit box not used yet */
case WE_TIMEOUT: case WE_TIMEOUT:
WP(w,def_d).data_2 = 0; WP(w,def_d).data_2 = 0;
SetWindowDirty(w); SetWindowDirty(w);
@ -999,7 +999,8 @@ static void NewgrfWndProc(Window *w, WindowEvent *e)
} }
break; break;
} }
*/ #endif
case WE_DESTROY: case WE_DESTROY:
_sel_grffile = NULL; _sel_grffile = NULL;
DeleteWindowById(WC_QUERY_STRING, 0); DeleteWindowById(WC_QUERY_STRING, 0);

@ -1,7 +1,6 @@
/* $Id$ */ /* $Id$ */
/** @file station_cmd.c /** @file station_cmd.c */
*/
#include "stdafx.h" #include "stdafx.h"
#include "openttd.h" #include "openttd.h"
@ -169,7 +168,7 @@ RoadStop *AllocateRoadStop(void)
} }
/* Calculate the radius of the station. Basicly it is the biggest /* Calculate the radius of the station. Basicly it is the biggest
radius that is available within the station */ * radius that is available within the station */
static uint FindCatchmentRadius(const Station* st) static uint FindCatchmentRadius(const Station* st)
{ {
uint ret = 0; uint ret = 0;
@ -783,12 +782,12 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
tileh = GetTileSlope(tile_cur, &z); tileh = GetTileSlope(tile_cur, &z);
/* Prohibit building if /* Prohibit building if
1) The tile is "steep" (i.e. stretches two height levels) * 1) The tile is "steep" (i.e. stretches two height levels)
-OR- * -OR-
2) The tile is non-flat if * 2) The tile is non-flat if
a) the player building is an "old-school" AI * a) the player building is an "old-school" AI
-OR- * -OR-
b) the build_on_slopes switch is disabled * b) the build_on_slopes switch is disabled
*/ */
if (IsSteepSlope(tileh) || if (IsSteepSlope(tileh) ||
((_is_old_ai_player || !_patches.build_on_slopes) && tileh != SLOPE_FLAT)) { ((_is_old_ai_player || !_patches.build_on_slopes) && tileh != SLOPE_FLAT)) {

@ -1,11 +1,11 @@
/* $Id$ */ /* $Id$ */
/* Rail selection types (directions): /* Rail selection types (directions):
/ \ / \ / \ / \ / \ / \ * / \ / \ / \ / \ / \ / \
/ /\ /\ \ /===\ / \ /| \ / |\ * / /\ /\ \ /===\ / \ /| \ / |\
\/ / \ \/ \ / \===/ \| / \ |/ * \/ / \ \/ \ / \===/ \| / \ |/
\ / \ / \ / \ / \ / \ / * \ / \ / \ / \ / \ / \ /
0 1 2 3 4 5 * 0 1 2 3 4 5
*/ */
// mark invalid tiles red // mark invalid tiles red

@ -1,12 +1,12 @@
/* $Id */ /* $Id */
/** @file elrail_data.h Stores all the data for overhead wire and pylon drawing. /** @file elrail_data.h Stores all the data for overhead wire and pylon drawing.
@see elrail.c */ * @see elrail.c */
#ifndef ELRAIL_DATA_H #ifndef ELRAIL_DATA_H
#define ELRAIL_DATA_H #define ELRAIL_DATA_H
/** Tile Location group. /** Tile Location group.
This defines whether the X and or Y coordinate of a tile is even */ * This defines whether the X and or Y coordinate of a tile is even */
typedef enum TLG { typedef enum TLG {
XEVEN_YEVEN = 0, XEVEN_YEVEN = 0,
XEVEN_YODD = 1, XEVEN_YODD = 1,
@ -16,8 +16,8 @@ typedef enum TLG {
} TLG; } TLG;
/** When determining the pylon configuration on the edge, two tiles are taken /** When determining the pylon configuration on the edge, two tiles are taken
into account: the tile being drawn itself (the home tile, the one in * into account: the tile being drawn itself (the home tile, the one in
ti->tile), and the neighbouring tile */ * ti->tile), and the neighbouring tile */
typedef enum { typedef enum {
TS_HOME = 0, TS_HOME = 0,
TS_NEIGHBOUR = 1, TS_NEIGHBOUR = 1,
@ -38,8 +38,8 @@ static byte AllowedPPPonPCP[DIAGDIR_END] = {
}; };
/** Which of the PPPs are inside the tile. For the two PPPs on the tile border /** Which of the PPPs are inside the tile. For the two PPPs on the tile border
the following system is used: if you rotate the PCP so that it is in the * the following system is used: if you rotate the PCP so that it is in the
north, the eastern PPP belongs to the tile. */ * north, the eastern PPP belongs to the tile. */
static byte OwnedPPPonPCP[DIAGDIR_END] = { static byte OwnedPPPonPCP[DIAGDIR_END] = {
1 << DIR_SE | 1 << DIR_S | 1 << DIR_SW | 1 << DIR_W, 1 << DIR_SE | 1 << DIR_S | 1 << DIR_SW | 1 << DIR_W,
1 << DIR_N | 1 << DIR_SW | 1 << DIR_W | 1 << DIR_NW, 1 << DIR_N | 1 << DIR_SW | 1 << DIR_W | 1 << DIR_NW,
@ -59,9 +59,9 @@ static const DiagDirection PCPpositions[TRACK_END][2] = {
#define PCP_NOT_ON_TRACK 0xFF #define PCP_NOT_ON_TRACK 0xFF
/** Preferred points of each trackbit. Those are the ones perpendicular to the /** Preferred points of each trackbit. Those are the ones perpendicular to the
track, plus the point in extension of the track (to mark end-of-track). PCPs * track, plus the point in extension of the track (to mark end-of-track). PCPs
which are not on either end of the track are fully preferred. * which are not on either end of the track are fully preferred.
@see PCPpositions */ * @see PCPpositions */
static byte PreferredPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = { static byte PreferredPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = {
{ /* X */ { /* X */
1 << DIR_NE | 1 << DIR_SE | 1 << DIR_NW, /* NE */ 1 << DIR_NE | 1 << DIR_SE | 1 << DIR_NW, /* NE */
@ -101,8 +101,8 @@ static byte PreferredPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = {
#define NUM_IGNORE_GROUPS 3 #define NUM_IGNORE_GROUPS 3
#define IGNORE_NONE 0xFF #define IGNORE_NONE 0xFF
/** In case we have a staight line, we place pylon only every two tiles, /** In case we have a staight line, we place pylon only every two tiles,
so there are certain tiles which we ignore. A straight line is found if * so there are certain tiles which we ignore. A straight line is found if
we have exactly two PPPs. */ * we have exactly two PPPs. */
static byte IgnoredPCP[NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END] = { static byte IgnoredPCP[NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END] = {
{ /* Ignore group 1, X and Y tracks */ { /* Ignore group 1, X and Y tracks */
{ /* X even, Y even */ { /* X even, Y even */
@ -196,7 +196,7 @@ static const Track TracksAtPCP[DIAGDIR_END][NUM_TRACKS_AT_PCP] = {
}; };
/* takes each of the 6 track bits from the array above and /* takes each of the 6 track bits from the array above and
assigns it to the home tile or neighbour tile */ * assigns it to the home tile or neighbour tile */
static const TileSource TrackSourceTile[DIAGDIR_END][NUM_TRACKS_AT_PCP] = { static const TileSource TrackSourceTile[DIAGDIR_END][NUM_TRACKS_AT_PCP] = {
{TS_HOME, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME }, {TS_HOME, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME },
{TS_HOME, TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_HOME }, {TS_HOME, TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_HOME },
@ -232,8 +232,8 @@ static const Direction PPPorder[DIAGDIR_END][TLG_END][DIR_END] = { /* X -
static const int8 x_pcp_offsets[DIAGDIR_END] = {0, 8, 15, 8}; static const int8 x_pcp_offsets[DIAGDIR_END] = {0, 8, 15, 8};
static const int8 y_pcp_offsets[DIAGDIR_END] = {8, 15, 8, 0}; static const int8 y_pcp_offsets[DIAGDIR_END] = {8, 15, 8, 0};
/* Geometric placement of the PPP relative to the PCP*/ /* Geometric placement of the PPP relative to the PCP*/
static const int8 x_ppp_offsets[DIR_END] = {-3, -4, -3, 0, +3, +4, +3, 0}; static const int8 x_ppp_offsets[DIR_END] = {-3, -4, -3, 0, 3, 4, 3, 0};
static const int8 y_ppp_offsets[DIR_END] = {-3, 0, +3, +4, +3, 0, -3, -4}; static const int8 y_ppp_offsets[DIR_END] = {-3, 0, 3, 4, 3, 0, -3, -4};
/* The type of pylon to draw at each PPP */ /* The type of pylon to draw at each PPP */
static const SpriteID pylons_normal[] = { static const SpriteID pylons_normal[] = {
SPR_PYLON_EW_N, SPR_PYLON_EW_N,
@ -398,11 +398,11 @@ typedef enum {
} CatenarySprite; } CatenarySprite;
/* Selects a Wire (with white and grey ends) depending on whether: /* Selects a Wire (with white and grey ends) depending on whether:
a) none (should never happen) * a) none (should never happen)
b) the first * b) the first
c) the second * c) the second
d) both * d) both
PCP exists.*/ * PCP exists.*/
static const CatenarySprite Wires[5][TRACK_END][4] = { static const CatenarySprite Wires[5][TRACK_END][4] = {
{ /* Tileh == 0 */ { /* Tileh == 0 */
{INVALID_CATENARY, WIRE_X_FLAT_NE, WIRE_X_FLAT_SW, WIRE_X_FLAT_BOTH}, {INVALID_CATENARY, WIRE_X_FLAT_NE, WIRE_X_FLAT_SW, WIRE_X_FLAT_BOTH},

@ -4,35 +4,35 @@
#define SPRITES_H #define SPRITES_H
/** @file sprites.h /** @file sprites.h
This file contails all sprite-related enums and defines. These consist mainly of * This file contails all sprite-related enums and defines. These consist mainly of
the sprite numbers and a bunch of masks and macros to handle sprites and to get * the sprite numbers and a bunch of masks and macros to handle sprites and to get
rid of all the magic numbers in the code. * rid of all the magic numbers in the code.
*
@NOTE: * @NOTE:
ALL SPRITE NUMBERS BELOW 5126 are in the main files * ALL SPRITE NUMBERS BELOW 5126 are in the main files
SPR_CANALS_BASE is in canalsw.grf * SPR_CANALS_BASE is in canalsw.grf
SPR_SLOPES_BASE is in trkfoundw.grf * SPR_SLOPES_BASE is in trkfoundw.grf
SPR_OPENTTD_BASE is in openttd.grf * SPR_OPENTTD_BASE is in openttd.grf
*
All elements which consist of two elements should * All elements which consist of two elements should
have the same name and then suffixes * have the same name and then suffixes
_GROUND and _BUILD for building-type sprites * _GROUND and _BUILD for building-type sprites
_REAR and _FRONT for transport-type sprites (tiles where vehicles are on) * _REAR and _FRONT for transport-type sprites (tiles where vehicles are on)
These sprites are split because of the Z order of the elements * These sprites are split because of the Z order of the elements
(like some parts of a bridge are behind the vehicle, while others are before) * (like some parts of a bridge are behind the vehicle, while others are before)
*
*
All sprites which are described here are referenced only one to a handful of times * All sprites which are described here are referenced only one to a handful of times
throughout the code. When introducing new sprite enums, use meaningful names. * throughout the code. When introducing new sprite enums, use meaningful names.
Don't be lazy and typing, and only use abbrevations when their meaning is clear or * Don't be lazy and typing, and only use abbrevations when their meaning is clear or
the length of the enum would get out of hand. In that case EXPLAIN THE ABBREVATION * the length of the enum would get out of hand. In that case EXPLAIN THE ABBREVATION
IN THIS FILE, and perhaps add some comments in the code where it is used. * IN THIS FILE, and perhaps add some comments in the code where it is used.
Now, don't whine about this being too much typing work if the enums are like * Now, don't whine about this being too much typing work if the enums are like
30 characters in length. If your editor doen't help you simplifying your work, * 30 characters in length. If your editor doen't help you simplifying your work,
get a proper editor. If your Operating Systems don't have any decent editors, * get a proper editor. If your Operating Systems don't have any decent editors,
get a proper Operating System. * get a proper Operating System.
*
@todo Split the "Sprites" enum into smaller chunks and document them * @todo Split the "Sprites" enum into smaller chunks and document them
*/ */
@ -226,8 +226,8 @@ enum Sprites {
/* Elrail stuff */ /* Elrail stuff */
/* Wires. First identifier is the direction of the track, second is the required placement of the pylon. /* Wires. First identifier is the direction of the track, second is the required placement of the pylon.
"short" denotes a wire that requires a pylon on each end. Third identifier is the direction of the slope * "short" denotes a wire that requires a pylon on each end. Third identifier is the direction of the slope
(in positive coordinate direction) */ * (in positive coordinate direction) */
SPR_WIRE_X_SHORT = SPR_ELRAIL_BASE + 3, SPR_WIRE_X_SHORT = SPR_ELRAIL_BASE + 3,
SPR_WIRE_Y_SHORT = SPR_ELRAIL_BASE + 4, SPR_WIRE_Y_SHORT = SPR_ELRAIL_BASE + 4,
SPR_WIRE_EW_SHORT = SPR_ELRAIL_BASE + 5, SPR_WIRE_EW_SHORT = SPR_ELRAIL_BASE + 5,
@ -561,18 +561,17 @@ enum Sprites {
/* BTSUS == Suspension bridge */ /* BTSUS == Suspension bridge */
/* TILE_* denotes the different tiles a suspension bridge /* TILE_* denotes the different tiles a suspension bridge
can have * can have
TILE_A and TILE_B are the "beginnings" and "ends" of the * TILE_A and TILE_B are the "beginnings" and "ends" of the
suspension system. they have small rectangluar endcaps * suspension system. they have small rectangluar endcaps
TILE_C and TILE_D look almost identical to TILE_A and * TILE_C and TILE_D look almost identical to TILE_A and
TILE_B, but they do not have the "endcaps". They form the * TILE_B, but they do not have the "endcaps". They form the
middle part * middle part
TILE_E is a condensed configuration of two pillars. while they * TILE_E is a condensed configuration of two pillars. while they
are usually 2 pillars apart, they only have 1 pillar separation * are usually 2 pillars apart, they only have 1 pillar separation
here * here
TILE_F is an extended configuration of pillars. they are * TILE_F is an extended configuration of pillars. they are
plugged in when pillars should be 3 tiles apart * plugged in when pillars should be 3 tiles apart
*/ */
SPR_BTSUS_ROAD_Y_REAR_TILE_A = 2453, SPR_BTSUS_ROAD_Y_REAR_TILE_A = 2453,
SPR_BTSUS_ROAD_Y_REAR_TILE_B = 2454, SPR_BTSUS_ROAD_Y_REAR_TILE_B = 2454,
@ -713,9 +712,9 @@ enum Sprites {
/* tubular bridges */ /* tubular bridges */
/* tubular bridges have 3 kinds of tiles: /* tubular bridges have 3 kinds of tiles:
a start tile (with only half a tube on the far side, marked _BEG * a start tile (with only half a tube on the far side, marked _BEG
a middle tile (full tunnel), marked _MID * a middle tile (full tunnel), marked _MID
and an end tile (half a tube on the near side, maked _END * and an end tile (half a tube on the near side, maked _END
*/ */
SPR_BTTUB_X_FRONT_BEG = 2559, SPR_BTTUB_X_FRONT_BEG = 2559,
SPR_BTTUB_X_FRONT_MID = 2660, SPR_BTTUB_X_FRONT_MID = 2660,

@ -1,7 +1,6 @@
/* $Id$ */ /* $Id$ */
/** @file town_land.h /** @file town_land.h */
*/
enum { enum {
HOUSE_TEMP_CHURCH = 0x03, HOUSE_TEMP_CHURCH = 0x03,

@ -2544,7 +2544,7 @@ static void Load_VEHS(void)
if (CheckSavegameVersion(5)) { if (CheckSavegameVersion(5)) {
/* Convert the current_order.type (which is a mix of type and flags, because /* Convert the current_order.type (which is a mix of type and flags, because
in those versions, they both were 4 bits big) to type and flags */ * in those versions, they both were 4 bits big) to type and flags */
v->current_order.flags = (v->current_order.type & 0xF0) >> 4; v->current_order.flags = (v->current_order.type & 0xF0) >> 4;
v->current_order.type = v->current_order.type & 0x0F; v->current_order.type = v->current_order.type & 0x0F;
} }
@ -2557,7 +2557,7 @@ static void Load_VEHS(void)
FOR_ALL_VEHICLES_FROM(u, v->index + 1) { FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
/* If a vehicle has the same orders, add the link to eachother /* If a vehicle has the same orders, add the link to eachother
in both vehicles */ * in both vehicles */
if (v->orders == u->orders) { if (v->orders == u->orders) {
v->next_shared = u; v->next_shared = u;
u->prev_shared = v; u->prev_shared = v;

@ -6,7 +6,7 @@
#include "fixedsizearray.hpp" #include "fixedsizearray.hpp"
/** Flexible array with size limit. Implemented as fixed size /** Flexible array with size limit. Implemented as fixed size
array of fixed size arrays */ * array of fixed size arrays */
template <class Titem_, int Tblock_size_ = 1024, int Tnum_blocks_ = Tblock_size_> template <class Titem_, int Tblock_size_ = 1024, int Tnum_blocks_ = Tblock_size_>
class CArrayT { class CArrayT {
public: public:

@ -4,15 +4,15 @@
#define AUTOCOPYPTR_HPP #define AUTOCOPYPTR_HPP
/** CAutoCopyPtrT - kind of CoW (Copy on Write) pointer. /** CAutoCopyPtrT - kind of CoW (Copy on Write) pointer.
It is non-invasive smart pointer (reference counter is held outside * It is non-invasive smart pointer (reference counter is held outside
of Tdata). * of Tdata).
When copied, its new copy shares the same underlaying structure Tdata. * When copied, its new copy shares the same underlaying structure Tdata.
When dereferenced, its behavior depends on 2 factors: * When dereferenced, its behavior depends on 2 factors:
- whether the data is shared (used by more than one pointer) * - whether the data is shared (used by more than one pointer)
- type of access (read/write) * - type of access (read/write)
When shared pointer is dereferenced for write, new clone of Tdata * When shared pointer is dereferenced for write, new clone of Tdata
is made first. * is made first.
Can't be used for polymorphic data types (interfaces). * Can't be used for polymorphic data types (interfaces).
*/ */
template <class Tdata_> template <class Tdata_>
class CAutoCopyPtrT { class CAutoCopyPtrT {

@ -11,14 +11,14 @@ FORCEINLINE void MemCpyT(Titem_* d, const Titem_* s, int num_items = 1)
/** Base class for simple binary blobs. /** Base class for simple binary blobs.
Item is byte. * Item is byte.
The word 'simple' means: * The word 'simple' means:
- no configurable allocator type (always made from heap) * - no configurable allocator type (always made from heap)
- no smart deallocation - deallocation must be called from the same * - no smart deallocation - deallocation must be called from the same
module (DLL) where the blob was allocated * module (DLL) where the blob was allocated
- no configurable allocation policy (how big blocks should be allocated) * - no configurable allocation policy (how big blocks should be allocated)
- no extra ownership policy (i.e. 'copy on write') when blob is copied * - no extra ownership policy (i.e. 'copy on write') when blob is copied
- no thread synchronization at all */ * - no thread synchronization at all */
class CBlobBaseSimple { class CBlobBaseSimple {
protected: protected:
struct CHdr { struct CHdr {
@ -78,7 +78,7 @@ public:
} }
/** Reallocate if there is no free space for num_bytes bytes. /** Reallocate if there is no free space for num_bytes bytes.
@return pointer to the new data to be added */ * @return pointer to the new data to be added */
FORCEINLINE int8* MakeRawFreeSpace(int num_bytes) FORCEINLINE int8* MakeRawFreeSpace(int num_bytes)
{ {
assert(num_bytes >= 0); assert(num_bytes >= 0);
@ -89,7 +89,7 @@ public:
} }
/** Increase RawSize() by num_bytes. /** Increase RawSize() by num_bytes.
@return pointer to the new data added */ * @return pointer to the new data added */
FORCEINLINE int8* GrowRawSize(int num_bytes) FORCEINLINE int8* GrowRawSize(int num_bytes)
{ {
int8* pNewData = MakeRawFreeSpace(num_bytes); int8* pNewData = MakeRawFreeSpace(num_bytes);

@ -5,13 +5,13 @@
/** fixed size array /** fixed size array
Upon construction it preallocates fixed size block of memory * Upon construction it preallocates fixed size block of memory
for all items, but doesn't construct them. Item's construction * for all items, but doesn't construct them. Item's construction
is delayed. */ * is delayed. */
template <class Titem_, int Tcapacity_> template <class Titem_, int Tcapacity_>
struct CFixedSizeArrayT { struct CFixedSizeArrayT {
/** the only member of fixed size array is pointer to the block /** the only member of fixed size array is pointer to the block
of C array of items. Header can be found on the offset -sizeof(CHdr). */ * of C array of items. Header can be found on the offset -sizeof(CHdr). */
Titem_ *m_items; Titem_ *m_items;
/** header for fixed size array */ /** header for fixed size array */

@ -6,8 +6,8 @@
#include "yapf.hpp" #include "yapf.hpp"
/** Track follower helper template class (can serve pathfinders and vehicle /** Track follower helper template class (can serve pathfinders and vehicle
controllers). See 6 different typedefs below for 3 different transport * controllers). See 6 different typedefs below for 3 different transport
types w/ of w/o 90-deg turns allowed */ * types w/ of w/o 90-deg turns allowed */
template <TransportType Ttr_type_, bool T90deg_turns_allowed_ = true> template <TransportType Ttr_type_, bool T90deg_turns_allowed_ = true>
struct CFollowTrackT : public FollowTrack_t struct CFollowTrackT : public FollowTrack_t
{ {
@ -38,7 +38,7 @@ struct CFollowTrackT : public FollowTrack_t
FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;} FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;}
/** main follower routine. Fills all members and return true on success. /** main follower routine. Fills all members and return true on success.
Otherwise returns false if track can't be followed. */ * Otherwise returns false if track can't be followed. */
FORCEINLINE bool Follow(TileIndex old_tile, Trackdir old_td) FORCEINLINE bool Follow(TileIndex old_tile, Trackdir old_td)
{ {
m_old_tile = old_tile; m_old_tile = old_tile;

@ -95,25 +95,25 @@ struct CHashTableSlotT
}; };
/** @class CHashTableT<Titem, Thash_bits> - simple hash table /** @class CHashTableT<Titem, Thash_bits> - simple hash table
of pointers allocated elsewhere. * of pointers allocated elsewhere.
*
Supports: Add/Find/Remove of Titems. * Supports: Add/Find/Remove of Titems.
*
Your Titem must meet some extra requirements to be CHashTableT * Your Titem must meet some extra requirements to be CHashTableT
compliant: * compliant:
- its constructor/destructor (if any) must be public * - its constructor/destructor (if any) must be public
- if the copying of item requires an extra resource management, * - if the copying of item requires an extra resource management,
you must define also copy constructor * you must define also copy constructor
- must support nested type (struct, class or typedef) Titem::Key * - must support nested type (struct, class or typedef) Titem::Key
that defines the type of key class for that item * that defines the type of key class for that item
- must support public method: * - must support public method:
const Key& GetKey() const; // return the item's key object * const Key& GetKey() const; // return the item's key object
*
In addition, the Titem::Key class must support: * In addition, the Titem::Key class must support:
- public method that calculates key's hash: * - public method that calculates key's hash:
int CalcHash() const; * int CalcHash() const;
- public 'equality' operator to compare the key with another one * - public 'equality' operator to compare the key with another one
bool operator == (const Key& other) const; * bool operator == (const Key& other) const;
*/ */
template <class Titem_, int Thash_bits_> template <class Titem_, int Thash_bits_>
class CHashTableT { class CHashTableT {
@ -125,7 +125,7 @@ public:
protected: protected:
/** each slot contains pointer to the first item in the list, /** each slot contains pointer to the first item in the list,
Titem contains pointer to the next item - GetHashNext(), SetHashNext() */ * Titem contains pointer to the next item - GetHashNext(), SetHashNext() */
typedef CHashTableSlotT<Titem_> Slot; typedef CHashTableSlotT<Titem_> Slot;
Slot* m_slots; // here we store our data (array of blobs) Slot* m_slots; // here we store our data (array of blobs)

@ -8,8 +8,8 @@
#include "binaryheap.hpp" #include "binaryheap.hpp"
/** Hash table based node list multi-container class. /** Hash table based node list multi-container class.
Implements open list, closed list and priority queue for A-star * Implements open list, closed list and priority queue for A-star
path finder. */ * path finder. */
template <class Titem_, int Thash_bits_open_, int Thash_bits_closed_> template <class Titem_, int Thash_bits_open_, int Thash_bits_closed_>
class CNodeList_HashTableT { class CNodeList_HashTableT {
public: public:

@ -6,53 +6,53 @@
#include "../debug.h" #include "../debug.h"
/** Finds the best path for given ship. /** Finds the best path for given ship.
@param v - the ship that needs to find a path * @param v the ship that needs to find a path
@param tile - the tile to find the path from (should be next tile the ship is about to enter) * @param tile the tile to find the path from (should be next tile the ship is about to enter)
@param enterdir - diagonal direction which the ship will enter this new tile from * @param enterdir diagonal direction which the ship will enter this new tile from
@param tracks - available tracks on the new tile (to choose from) * @param tracks available tracks on the new tile (to choose from)
@return - the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found * @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
*/ */
Trackdir YapfChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks); Trackdir YapfChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
/** Finds the best path for given road vehicle. /** Finds the best path for given road vehicle.
@param v - the RV that needs to find a path * @param v the RV that needs to find a path
@param tile - the tile to find the path from (should be next tile the RV is about to enter) * @param tile the tile to find the path from (should be next tile the RV is about to enter)
@param enterdir - diagonal direction which the RV will enter this new tile from * @param enterdir diagonal direction which the RV will enter this new tile from
@param tracks - available tracks on the new tile (to choose from) * @param tracks available tracks on the new tile (to choose from)
@return - the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found * @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
*/ */
Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir); Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir);
/** Finds the best path for given train. /** Finds the best path for given train.
@param v - the train that needs to find a path * @param v the train that needs to find a path
@param tile - the tile to find the path from (should be next tile the train is about to enter) * @param tile the tile to find the path from (should be next tile the train is about to enter)
@param enterdir - diagonal direction which the RV will enter this new tile from * @param enterdir diagonal direction which the RV will enter this new tile from
@param tracks - available tracks on the new tile (to choose from) * @param tracks available tracks on the new tile (to choose from)
@return - the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found * @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
*/ */
Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs); Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs);
/** Used by RV multistop feature to find the nearest road stop that has a free slot. /** Used by RV multistop feature to find the nearest road stop that has a free slot.
@param v - RV (its current tile will be the origin) * @param v RV (its current tile will be the origin)
@param tile - destination tile * @param tile destination tile
@return - distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found * @return distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found
*/ */
uint YapfRoadVehDistanceToTile(const Vehicle* v, TileIndex tile); uint YapfRoadVehDistanceToTile(const Vehicle* v, TileIndex tile);
/** Used when user sends RV to the nearest depot or if RV needs servicing. /** Used when user sends RV to the nearest depot or if RV needs servicing.
Returns the nearest depot (or NULL if depot was not found). * Returns the nearest depot (or NULL if depot was not found).
*/ */
Depot* YapfFindNearestRoadDepot(const Vehicle *v); Depot* YapfFindNearestRoadDepot(const Vehicle *v);
/** Used when user sends train to the nearest depot or if train needs servicing. /** Used when user sends train to the nearest depot or if train needs servicing.
@v - train that needs to go to some depot * @v train that needs to go to some depot
@max_distance - max distance (number of track tiles) from the current train position * @max_distance max distance (number of track tiles) from the current train position
(used also as optimization - the pathfinder can stop path finding if max_distance * (used also as optimization - the pathfinder can stop path finding if max_distance
was reached and no depot was seen) * was reached and no depot was seen)
@reverse_penalty - penalty that should be added for the path that requires reversing the train first * @reverse_penalty penalty that should be added for the path that requires reversing the train first
@depot_tile - receives the depot tile if depot was found * @depot_tile receives the depot tile if depot was found
@reversed - receives true if train needs to reversed first * @reversed receives true if train needs to reversed first
@return - the true if depot was found. * @return the true if depot was found.
*/ */
bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed); bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed);
@ -72,16 +72,16 @@ extern int _aystar_stats_closed_size;
/** Track followers. They should help whenever any new code will need to walk through /** Track followers. They should help whenever any new code will need to walk through
tracks, road or water tiles (pathfinders, signal controllers, vehicle controllers). * tracks, road or water tiles (pathfinders, signal controllers, vehicle controllers).
It is an attempt to introduce API that should simplify tasks listed above. * It is an attempt to introduce API that should simplify tasks listed above.
If you will need to use it: * If you will need to use it:
1. allocate/declare FollowTrack_t structure; * 1. allocate/declare FollowTrack_t structure;
2. call FollowTrackInit() and provide vehicle (if relevant) * 2. call FollowTrackInit() and provide vehicle (if relevant)
3. call one of 6 FollowTrackXxxx() APIs below * 3. call one of 6 FollowTrackXxxx() APIs below
4. check return value (if true then continue else stop) * 4. check return value (if true then continue else stop)
5. look at FollowTrack_t structure for the result * 5. look at FollowTrack_t structure for the result
6. optionally repeat steps 3..5 * 6. optionally repeat steps 3..5
7. in case of troubles contact KUDr * 7. in case of troubles contact KUDr
*/ */
/** Base struct for track followers. */ /** Base struct for track followers. */

@ -14,33 +14,33 @@ EXTERN_C_END
extern int _total_pf_time_us; extern int _total_pf_time_us;
/** CYapfBaseT - A-star type path finder base class. /** CYapfBaseT - A-star type path finder base class.
Derive your own pathfinder from it. You must provide the following template argument: * Derive your own pathfinder from it. You must provide the following template argument:
Types - used as collection of local types used in pathfinder * Types - used as collection of local types used in pathfinder
*
Requirements for the Types struct: * Requirements for the Types struct:
---------------------------------- * ----------------------------------
The following types must be defined in the 'Types' argument: * The following types must be defined in the 'Types' argument:
- Types::Tpf - your pathfinder derived from CYapfBaseT * - Types::Tpf - your pathfinder derived from CYapfBaseT
- Types::NodeList - open/closed node list (look at CNodeList_HashTableT) * - Types::NodeList - open/closed node list (look at CNodeList_HashTableT)
NodeList needs to have defined local type Titem - defines the pathfinder node type. * NodeList needs to have defined local type Titem - defines the pathfinder node type.
Node needs to define local type Key - the node key in the collection () * Node needs to define local type Key - the node key in the collection ()
*
For node list you can use template class CNodeList_HashTableT, for which * For node list you can use template class CNodeList_HashTableT, for which
you need to declare only your node type. Look at test_yapf.h for an example. * you need to declare only your node type. Look at test_yapf.h for an example.
*
*
Requrements to your pathfinder class derived from CYapfBaseT: * Requrements to your pathfinder class derived from CYapfBaseT:
------------------------------------------------------------- * -------------------------------------------------------------
Your pathfinder derived class needs to implement following methods: * Your pathfinder derived class needs to implement following methods:
FORCEINLINE void PfSetStartupNodes() * FORCEINLINE void PfSetStartupNodes()
FORCEINLINE void PfFollowNode(Node& org) * FORCEINLINE void PfFollowNode(Node& org)
FORCEINLINE bool PfCalcCost(Node& n) * FORCEINLINE bool PfCalcCost(Node& n)
FORCEINLINE bool PfCalcEstimate(Node& n) * FORCEINLINE bool PfCalcEstimate(Node& n)
FORCEINLINE bool PfDetectDestination(Node& n) * FORCEINLINE bool PfDetectDestination(Node& n)
*
For more details about those methods, look at the end of CYapfBaseT * For more details about those methods, look at the end of CYapfBaseT
declaration. There are some examples. For another example look at * declaration. There are some examples. For another example look at
test_yapf.h (part or unittest project). * test_yapf.h (part or unittest project).
*/ */
template <class Types> template <class Types>
class CYapfBaseT { class CYapfBaseT {
@ -105,12 +105,12 @@ public:
} }
/** Main pathfinder routine: /** Main pathfinder routine:
- set startup node(s) * - set startup node(s)
- main loop that stops if: * - main loop that stops if:
- the destination was found * - the destination was found
- or the open list is empty (no route to destination). * - or the open list is empty (no route to destination).
- or the maximum amount of loops reached - m_max_search_nodes (default = 10000) * - or the maximum amount of loops reached - m_max_search_nodes (default = 10000)
@return true if the path was found */ * @return true if the path was found */
inline bool FindPath(const Vehicle* v) inline bool FindPath(const Vehicle* v)
{ {
m_veh = v; m_veh = v;
@ -160,7 +160,7 @@ public:
} }
/** If path was found return the best node that has reached the destination. Otherwise /** If path was found return the best node that has reached the destination. Otherwise
return the best visited node (which was nearest to the destination). * return the best visited node (which was nearest to the destination).
*/ */
FORCEINLINE Node& GetBestNode() FORCEINLINE Node& GetBestNode()
{ {
@ -168,7 +168,7 @@ public:
} }
/** Calls NodeList::CreateNewNode() - allocates new node that can be filled and used /** Calls NodeList::CreateNewNode() - allocates new node that can be filled and used
as argument for AddStartupNode() or AddNewNode() * as argument for AddStartupNode() or AddNewNode()
*/ */
FORCEINLINE Node& CreateNewNode() FORCEINLINE Node& CreateNewNode()
{ {
@ -203,7 +203,7 @@ public:
} }
/** AddNewNode() - called by Tderived::PfFollowNode() for each child node. /** AddNewNode() - called by Tderived::PfFollowNode() for each child node.
Nodes are evaluated here and added into open list */ * Nodes are evaluated here and added into open list */
void AddNewNode(Node& n) void AddNewNode(Node& n)
{ {
// evaluate the node // evaluate the node

@ -4,8 +4,8 @@
/** CYapfSegmentCostCacheNoneT - the formal only yapf cost cache provider that implements /** CYapfSegmentCostCacheNoneT - the formal only yapf cost cache provider that implements
PfNodeCacheFetch() and PfNodeCacheFlush() callbacks. Used when nodes don't have CachedData * PfNodeCacheFetch() and PfNodeCacheFlush() callbacks. Used when nodes don't have CachedData
defined (they don't count with any segment cost caching). * defined (they don't count with any segment cost caching).
*/ */
template <class Types> template <class Types>
class CYapfSegmentCostCacheNoneT class CYapfSegmentCostCacheNoneT
@ -30,8 +30,8 @@ public:
/** CYapfSegmentCostCacheLocalT - the yapf cost cache provider that implements fake segment /** CYapfSegmentCostCacheLocalT - the yapf cost cache provider that implements fake segment
cost caching functionality for yapf. Used when node needs caching, but you don't want to * cost caching functionality for yapf. Used when node needs caching, but you don't want to
cache the segment costs. * cache the segment costs.
*/ */
template <class Types> template <class Types>
class CYapfSegmentCostCacheLocalT class CYapfSegmentCostCacheLocalT
@ -82,13 +82,13 @@ struct CSegmentCostCacheBase
/** CSegmentCostCacheT - template class providing hash-map and storage (heap) /** CSegmentCostCacheT - template class providing hash-map and storage (heap)
of Tsegment structures. Each rail node contains pointer to the segment * of Tsegment structures. Each rail node contains pointer to the segment
that contains cached (or non-cached) segment cost information. Nodes can * that contains cached (or non-cached) segment cost information. Nodes can
differ by key type, but they use the same segment type. Segment key should * differ by key type, but they use the same segment type. Segment key should
be always the same (TileIndex + DiagDirection) that represent the beginning * be always the same (TileIndex + DiagDirection) that represent the beginning
of the segment (origin tile and exit-dir from this tile). * of the segment (origin tile and exit-dir from this tile).
Different CYapfCachedCostT types can share the same type of CSegmentCostCacheT. * Different CYapfCachedCostT types can share the same type of CSegmentCostCacheT.
Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example */ * Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example */
template <class Tsegment> template <class Tsegment>
struct CSegmentCostCacheT struct CSegmentCostCacheT
: public CSegmentCostCacheBase : public CSegmentCostCacheBase
@ -119,8 +119,8 @@ struct CSegmentCostCacheT
}; };
/** CYapfSegmentCostCacheGlobalT - the yapf cost cache provider that adds the segment cost /** CYapfSegmentCostCacheGlobalT - the yapf cost cache provider that adds the segment cost
caching functionality to yapf. Using this class as base of your will provide the global * caching functionality to yapf. Using this class as base of your will provide the global
segment cost caching services for your Nodes. * segment cost caching services for your Nodes.
*/ */
template <class Types> template <class Types>
class CYapfSegmentCostCacheGlobalT class CYapfSegmentCostCacheGlobalT

@ -110,7 +110,7 @@ public:
}; };
/** Config struct of YAPF for ships. /** Config struct of YAPF for ships.
Defines all 6 base YAPF modules as classes providing services for CYapfBaseT. * Defines all 6 base YAPF modules as classes providing services for CYapfBaseT.
*/ */
template <class Tpf_, class Ttrack_follower, class Tnode_list> template <class Tpf_, class Ttrack_follower, class Tnode_list>
struct CYapfShip_TypesT struct CYapfShip_TypesT

Loading…
Cancel
Save