Changeset - r4549:76b9213799ac
[Not reviewed]
master
0 59 0
rubidium - 18 years ago 2006-09-04 20:40:33
rubidium@openttd.org
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
-Cleanup: whitespace alignment of a few tables.
29 files changed with 345 insertions and 351 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -1915,14 +1915,14 @@ static bool AirportFindFreeTerminal(Vehi
 
	Station *st;
 

	
 
	/* 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},
 
		Heading 255 denotes a group. We see 2 groups here:
 
		1. group 0 -- TERM_GROUP1_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
 
		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
 
		fails, then attempt fails and plane waits
 
	 * {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:
 
	 * 1. group 0 -- TERM_GROUP1_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
 
	 * 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
 
	 * fails, then attempt fails and plane waits
 
	*/
 
	if (Airport->terminals[0] > 1) {
 
		st = GetStation(v->u.air.targetairport);
elrail.c
Show inline comments
 
/* $Id$ */
 
/** @file elrail.c
 
  This file deals with displaying wires and pylons for electric railways.
 
<h2>Basics</h2>
 

	
 
<h3>Tile Types</h3>
 

	
 
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
 
Special Railways tiles (SRTs) which have only one track (like crossings, depots
 
stations, etc).
 

	
 
<h3>Location Categories</h3>
 

	
 
All tiles are categorized into three location groups (TLG):
 
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 2: Tiles with an odd X and an even Y coordinate
 
Group 3: Tiles with both an odd X and Y coordnate.
 

	
 
<h3>Pylon Points</h3>
 
<h4>Control Points</h4>
 
A Pylon Control Point (PCP) is a position where a wire (or rather two)
 
is mounted onto a pylon.
 
Each NRT does contain 4 PCPs which are bitmapped to a byte
 
variable and are represented by the DiagDirection enum
 

	
 
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
 
other tile.
 

	
 
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
 
in question, both tiles get it).
 

	
 
<h4>Position Points</h4>
 
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
 
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
 
some that are preferred (because the pylon would be rectangular to the track).
 

	
 
<img src="../../elrail_tile.png">
 
<img src="../../elrail_track.png">
 

	
 
 * This file deals with displaying wires and pylons for electric railways.
 
 * <h2>Basics</h2>
 
 *
 
 * <h3>Tile Types</h3>
 
 *
 
 * 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
 
 * Special Railways tiles (SRTs) which have only one track (like crossings, depots
 
 * stations, etc).
 
 *
 
 * <h3>Location Categories</h3>
 
 *
 
 * All tiles are categorized into three location groups (TLG):
 
 * 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 2: Tiles with an odd X and an even Y coordinate
 
 * Group 3: Tiles with both an odd X and Y coordnate.
 
 *
 
 * <h3>Pylon Points</h3>
 
 * <h4>Control Points</h4>
 
 * A Pylon Control Point (PCP) is a position where a wire (or rather two)
 
 * is mounted onto a pylon.
 
 * Each NRT does contain 4 PCPs which are bitmapped to a byte
 
 * variable and are represented by the DiagDirection enum
 
 *
 
 * 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
 
 * other tile.
 
 *
 
 * 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
 
 * in question, both tiles get it).
 
 *
 
 * <h4>Position Points</h4>
 
 * 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
 
 * 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
 
 * some that are preferred (because the pylon would be rectangular to the track).
 
 *
 
 * <img src="../../elrail_tile.png">
 
 * <img src="../../elrail_track.png">
 
 *
 
  */
 

	
 
#include "stdafx.h"
 
@@ -155,8 +155,8 @@ static void AdjustTileh(TileIndex tile, 
 
static void DrawCatenaryRailway(const TileInfo *ti)
 
{
 
	/* 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
 
	   current tile (home tile) while [1] holds the neighbour */
 
	 * the track configuration of 2 adjacent tiles. trackconfig[0] stores the
 
	 * current tile (home tile) while [1] holds the neighbour */
 
	TrackBits trackconfig[TS_END];
 
	bool isflat[TS_END];
 
	/* Note that ti->tileh has already been adjusted for Foundations */
 
@@ -171,11 +171,11 @@ static void DrawCatenaryRailway(const Ti
 
	Track t;
 

	
 
	/* Find which rail bits are present, and select the override points.
 
	   We don't draw a pylon:
 
	   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),
 
	      because that one is drawn on the bridge. Exception is for length 0 bridges
 
	      which have no middle tiles */
 
	 * We don't draw a pylon:
 
	 * 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),
 
	 *    because that one is drawn on the bridge. Exception is for length 0 bridges
 
	 *    which have no middle tiles */
 
	trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP);
 
	/* 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);
 
@@ -188,7 +188,7 @@ static void DrawCatenaryRailway(const Ti
 
		int k;
 

	
 
		/* 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);
 
		trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL);
 
		if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = 0;
 
@@ -198,7 +198,7 @@ static void DrawCatenaryRailway(const Ti
 
		PPPallowed[i] = AllowedPPPonPCP[i];
 

	
 
		/* 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++) {
 
			/* 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 &&
 
@@ -208,10 +208,10 @@ static void DrawCatenaryRailway(const Ti
 
			}
 

	
 
			/* We check whether the track in question (k) is present in the tile
 
			   (TrackSourceTile) */
 
			 * (TrackSourceTile) */
 
			if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) {
 
				/* 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);
 
				SETBIT(PCPstatus, i); /* This PCP is in use */
 

	
 
@@ -244,7 +244,7 @@ static void DrawCatenaryRailway(const Ti
 
		AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]);
 

	
 
		/* 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 */
 
		if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) {
 
			for (k = 0; k < NUM_IGNORE_GROUPS; k++)
 
@@ -252,9 +252,9 @@ static void DrawCatenaryRailway(const Ti
 
		}
 

	
 
		/* 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
 
		   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) */
 
		 * 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.
 
		 * 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] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {
engine.c
Show inline comments
 
@@ -191,10 +191,10 @@ void StartupEngines(void)
 
		}
 

	
 
		/* This sets up type for the engine
 
		   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
 
		   but using this, you can ask what type an engine number is
 
		   even if it is not a vehicle (yet)*/
 
		 * 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
 
		 * but using this, you can ask what type an engine number is
 
		 * even if it is not a vehicle (yet)*/
 
	}
 

	
 
	AdjustAvailAircraft();
engine.h
Show inline comments
 
@@ -3,8 +3,7 @@
 
#ifndef ENGINE_H
 
#define ENGINE_H
 

	
 
/** @file engine.h
 
  */
 
/** @file engine.h */
 

	
 
#include "pool.h"
 

	
news_gui.c
Show inline comments
 
@@ -17,17 +17,17 @@
 
#include "date.h"
 

	
 
/* News system
 
News system is realized as a FIFO queue (in an array)
 
The positions in the queue can't be rearranged, we only access
 
the array elements through pointers to the elements. Once the
 
array is full, the oldest entry (_oldest_news) is being overwritten
 
by the newest (_latest news).
 

	
 
oldest                   current   lastest
 
 |                          |         |
 
[O------------F-------------C---------L           ]
 
              |
 
           forced
 
 * News system is realized as a FIFO queue (in an array)
 
 * The positions in the queue can't be rearranged, we only access
 
 * the array elements through pointers to the elements. Once the
 
 * array is full, the oldest entry (_oldest_news) is being overwritten
 
 * by the newest (_latest news).
 
 *
 
 * oldest                   current   lastest
 
 *  |                          |         |
 
 * [O------------F-------------C---------L           ]
 
 *               |
 
 *            forced
 
*/
 

	
 
#define MAX_NEWS 30
 
@@ -524,7 +524,7 @@ void ShowLastNewsMessage(void)
 

	
 

	
 
/* 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)
 
{
 
	if (i >= _total_news) return INVALID_NEWS;
openttd.c
Show inline comments
 
@@ -1068,12 +1068,12 @@ static void UpdateExclusiveRights(void)
 
	}
 

	
 
	/* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete)
 
			could be implemented this way:
 
			1.) Go through all stations
 
					Build an array town_blocked[ town_id ][ player_id ]
 
				 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
 
					one player, but for all others, then give him exclusivity.
 
	 *   could be implemented this way:
 
	 * 1.) Go through all stations
 
	 *     Build an array town_blocked[ town_id ][ player_id ]
 
	 *     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
 
	 *     one player, but for all others, then give him exclusivity.
 
	*/
 
}
 

	
order.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file order.h
 
  */
 
/** @file order.h */
 

	
 
#ifndef ORDER_H
 
#define ORDER_H
order_cmd.c
Show inline comments
 
@@ -817,9 +817,9 @@ void RestoreVehicleOrders(const Vehicle*
 
	}
 

	
 
	/* 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
 
	    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. */
 
	 *  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
 
	 *  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++) {
 
		if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK))
 
			break;
 
@@ -1055,10 +1055,10 @@ void DeleteVehicleOrders(Vehicle *v)
 
		v->next_shared = NULL;
 

	
 
		/* We only need to update this-one, because if there is a third
 
		    vehicle which shares the same order-list, nothing will change. If
 
		    this is the last vehicle, the last line of the order-window
 
		    will change from Shared order list, to Order list, so it needs
 
		    an update */
 
		 *  vehicle which shares the same order-list, nothing will change. If
 
		 *  this is the last vehicle, the last line of the order-window
 
		 *  will change from Shared order list, to Order list, so it needs
 
		 *  an update */
 
		InvalidateVehicleOrder(u);
 
		return;
 
	}
 
@@ -1175,8 +1175,8 @@ static void Load_ORDR(void)
 
		/* Update all the next pointer */
 
		for (i = 1; i < len; ++i) {
 
			/* The orders were built like this:
 
			     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 */
 
			 *   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 */
 
			if (GetOrder(i)->type != OT_NOTHING)
 
				GetOrder(i - 1)->next = GetOrder(i);
 
		}
player.h
Show inline comments
 
@@ -229,8 +229,7 @@ static inline bool IsLocalPlayer(void)
 
void DeletePlayerWindows(PlayerID pi);
 
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)
 
{
 
	return HASBIT(p->avail_railtypes, Railtype);
rail.h
Show inline comments
 
@@ -82,7 +82,7 @@ static inline TrackBits AxisToTrackBits(
 

	
 

	
 
/** 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 {
 
	TRACKDIR_X_NE     =  0,
 
	TRACKDIR_Y_SE     =  1,
 
@@ -103,7 +103,7 @@ typedef enum Trackdirs {
 
} Trackdir;
 

	
 
/** 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 {
 
	TRACKDIR_BIT_NONE     = 0x0000,
 
	TRACKDIR_BIT_X_NE     = 0x0001,
rail_cmd.c
Show inline comments
 
@@ -586,12 +586,11 @@ int32 CmdBuildTrainDepot(TileIndex tile,
 
	tileh = GetTileSlope(tile, NULL);
 

	
 
	/* Prohibit construction if
 
		The tile is non-flat AND
 
		1) The AI is "old-school"
 
		2) build-on-slopes is disabled
 
		3) the tile is steep i.e. spans two height levels
 
		4) the exit points in the wrong direction
 

	
 
	 * The tile is non-flat AND
 
	 * 1) The AI is "old-school"
 
	 * 2) build-on-slopes is disabled
 
	 * 3) the tile is steep i.e. spans two height levels
 
	 * 4) the exit points in the wrong direction
 
	*/
 

	
 
	if (tileh != SLOPE_FLAT && (
 
@@ -777,7 +776,7 @@ static int32 CmdSignalTrackHelper(TileIn
 
	 * trackdir   - trackdir to build with autorail
 
	 * semaphores - semaphores or signals
 
	 * 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 */
 
	signal_ctr = total_cost = 0;
 
	for (;;) {
settings_gui.c
Show inline comments
 
@@ -328,24 +328,24 @@ static inline bool GetBitAndShift(uint32
 
}
 

	
 
/*
 
	A: competitors
 
	B: start time in months / 3
 
	C: town count (2 = high, 0 = low)
 
	D: industry count (3 = high, 0 = none)
 
	E: inital loan / 1000 (in GBP)
 
	F: interest rate
 
	G: running costs (0 = low, 2 = high)
 
	H: construction speed of competitors (0 = very slow, 4 = very fast)
 
	I: intelligence (0-2)
 
	J: breakdowns(0 = off, 2 = normal)
 
	K: subsidy multiplier (0 = 1.5, 3 = 4.0)
 
	L: construction cost (0-2)
 
	M: terrain type (0 = very flat, 3 = mountainous)
 
	N: amount of water (0 = very low, 3 = high)
 
	O: economy (0 = steady, 1 = fluctuating)
 
	P: Train reversing (0 = end of line + stations, 1 = end of line)
 
	Q: disasters
 
	R: area restructuring (0 = permissive, 2 = hostile)
 
 * A: competitors
 
 * B: start time in months / 3
 
 * C: town count (2 = high, 0 = low)
 
 * D: industry count (3 = high, 0 = none)
 
 * E: inital loan / 1000 (in GBP)
 
 * F: interest rate
 
 * G: running costs (0 = low, 2 = high)
 
 * H: construction speed of competitors (0 = very slow, 4 = very fast)
 
 * I: intelligence (0-2)
 
 * J: breakdowns (0 = off, 2 = normal)
 
 * K: subsidy multiplier (0 = 1.5, 3 = 4.0)
 
 * L: construction cost (0-2)
 
 * M: terrain type (0 = very flat, 3 = mountainous)
 
 * N: amount of water (0 = very low, 3 = high)
 
 * O: economy (0 = steady, 1 = fluctuating)
 
 * P: Train reversing (0 = end of line + stations, 1 = end of line)
 
 * Q: disasters
 
 * R: area restructuring (0 = permissive, 2 = hostile)
 
*/
 
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*/
 
@@ -987,7 +987,7 @@ static void NewgrfWndProc(Window *w, Win
 
			break;
 
		} break;
 

	
 
/* Parameter edit box not used yet
 
#if 0 /* Parameter edit box not used yet */
 
	case WE_TIMEOUT:
 
		WP(w,def_d).data_2 = 0;
 
		SetWindowDirty(w);
 
@@ -999,7 +999,8 @@ static void NewgrfWndProc(Window *w, Win
 
		}
 
		break;
 
	}
 
*/
 
#endif
 

	
 
	case WE_DESTROY:
 
		_sel_grffile = NULL;
 
		DeleteWindowById(WC_QUERY_STRING, 0);
station_cmd.c
Show inline comments
 
/* $Id$ */
 

	
 
/** @file station_cmd.c
 
  */
 
/** @file station_cmd.c */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
@@ -169,7 +168,7 @@ RoadStop *AllocateRoadStop(void)
 
}
 

	
 
/* 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)
 
{
 
	uint ret = 0;
 
@@ -783,12 +782,12 @@ int32 CheckFlatLandBelow(TileIndex tile,
 
		tileh = GetTileSlope(tile_cur, &z);
 

	
 
		/* Prohibit building if
 
			1) The tile is "steep" (i.e. stretches two height levels)
 
			-OR-
 
			2) The tile is non-flat if
 
				a) the player building is an "old-school" AI
 
				-OR-
 
				b) the build_on_slopes switch is disabled
 
		 *   1) The tile is "steep" (i.e. stretches two height levels)
 
		 * -OR-
 
		 *   2) The tile is non-flat if
 
		 *     a) the player building is an "old-school" AI
 
		 *   -OR-
 
		 *     b) the build_on_slopes switch is disabled
 
		*/
 
		if (IsSteepSlope(tileh) ||
 
				((_is_old_ai_player || !_patches.build_on_slopes) && tileh != SLOPE_FLAT)) {
table/autorail.h
Show inline comments
 
/* $Id$ */
 

	
 
/* Rail selection types (directions):
 
 / \    / \    / \    / \   / \   / \
 
/  /\  /\  \  /===\  /   \ /|  \ /  |\
 
\/  /  \  \/  \   /  \===/ \|  / \  |/
 
 \ /    \ /    \ /    \ /   \ /   \ /
 
  0      1      2      3     4     5
 
 *  / \    / \    / \    / \   / \   / \
 
 * /  /\  /\  \  /===\  /   \ /|  \ /  |\
 
 * \/  /  \  \/  \   /  \===/ \|  / \  |/
 
 *  \ /    \ /    \ /    \ /   \ /   \ /
 
 *   0      1      2      3     4     5
 
*/
 

	
 
// mark invalid tiles red
table/elrail_data.h
Show inline comments
 
/* $Id */
 
/** @file elrail_data.h Stores all the data for overhead wire and pylon drawing.
 
  @see elrail.c */
 
 *  @see elrail.c */
 

	
 
#ifndef ELRAIL_DATA_H
 
#define ELRAIL_DATA_H
 

	
 
/** 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 {
 
	XEVEN_YEVEN = 0,
 
	XEVEN_YODD  = 1,
 
@@ -16,8 +16,8 @@ typedef enum TLG {
 
} TLG;
 

	
 
/** 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
 
  ti->tile), and the neighbouring tile */
 
 * into account: the tile being drawn itself (the home tile, the one in
 
 * ti->tile), and the neighbouring tile */
 
typedef enum {
 
	TS_HOME      = 0,
 
	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
 
  the following system is used: if you rotate the PCP so that it is in the
 
  north, the eastern PPP belongs to the tile. */
 
 * the following system is used: if you rotate the PCP so that it is in the
 
 * north, the eastern PPP belongs to the tile. */
 
static byte OwnedPPPonPCP[DIAGDIR_END] = {
 
	1 << DIR_SE | 1 << DIR_S  | 1 << DIR_SW | 1 << DIR_W,
 
	1 << DIR_N  | 1 << DIR_SW | 1 << DIR_W  | 1 << DIR_NW,
 
@@ -59,9 +59,9 @@ static const DiagDirection PCPpositions[
 

	
 
#define PCP_NOT_ON_TRACK 0xFF
 
/** 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
 
  which are not on either end of the track are fully preferred.
 
  @see PCPpositions */
 
 * 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.
 
 * @see PCPpositions */
 
static byte PreferredPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = {
 
	{    /* X */
 
		1 << DIR_NE | 1 << DIR_SE | 1 << DIR_NW, /* NE */
 
@@ -101,8 +101,8 @@ static byte PreferredPPPofTrackAtPCP[TRA
 
#define NUM_IGNORE_GROUPS 3
 
#define IGNORE_NONE 0xFF
 
/** 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
 
  we have exactly two PPPs. */
 
 * so there are certain tiles which we ignore. A straight line is found if
 
 * we have exactly two PPPs. */
 
static byte IgnoredPCP[NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END] = {
 
	{   /* Ignore group 1, X and Y tracks */
 
		{     /* X even, Y even */
 
@@ -196,7 +196,7 @@ static const Track TracksAtPCP[DIAGDIR_E
 
};
 

	
 
/* 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] = {
 
	{TS_HOME, TS_NEIGHBOUR, TS_HOME     , TS_NEIGHBOUR, 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_
 
static const int8 x_pcp_offsets[DIAGDIR_END] = {0,  8, 15, 8};
 
static const int8 y_pcp_offsets[DIAGDIR_END] = {8, 15,  8, 0};
 
/* 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 y_ppp_offsets[DIR_END] = {-3,  0, +3, +4, +3,  0, -3, -4};
 
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};
 
/* The type of pylon to draw at each PPP */
 
static const SpriteID pylons_normal[] = {
 
	SPR_PYLON_EW_N,
 
@@ -398,11 +398,11 @@ typedef enum {
 
} CatenarySprite;
 

	
 
/* Selects a Wire (with white and grey ends) depending on whether:
 
   a) none (should never happen)
 
   b) the first
 
   c) the second
 
   d) both
 
   PCP exists.*/
 
 * a) none (should never happen)
 
 * b) the first
 
 * c) the second
 
 * d) both
 
 * PCP exists.*/
 
static const CatenarySprite Wires[5][TRACK_END][4] = {
 
	{ /* Tileh == 0 */
 
		{INVALID_CATENARY, WIRE_X_FLAT_NE,   WIRE_X_FLAT_SW,   WIRE_X_FLAT_BOTH},
table/sprites.h
Show inline comments
 
@@ -4,35 +4,35 @@
 
#define SPRITES_H
 

	
 
/** @file sprites.h
 
	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
 
	rid of all the magic numbers in the code.
 

	
 
@NOTE:
 
	ALL SPRITE NUMBERS BELOW 5126 are in the main files
 
	SPR_CANALS_BASE is in canalsw.grf
 
	SPR_SLOPES_BASE is in trkfoundw.grf
 
	SPR_OPENTTD_BASE is in openttd.grf
 

	
 
	All elements which consist of two elements should
 
	have the same name and then suffixes
 
		_GROUND and _BUILD for building-type sprites
 
		_REAR and _FRONT for transport-type sprites (tiles where vehicles are on)
 
	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)
 

	
 

	
 
	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.
 
	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
 
	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
 
	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 Operating System.
 

	
 
	@todo Split the "Sprites" enum into smaller chunks and document them
 
 * 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
 
 * rid of all the magic numbers in the code.
 
 *
 
 * @NOTE:
 
 * ALL SPRITE NUMBERS BELOW 5126 are in the main files
 
 * SPR_CANALS_BASE is in canalsw.grf
 
 * SPR_SLOPES_BASE is in trkfoundw.grf
 
 * SPR_OPENTTD_BASE is in openttd.grf
 
 *
 
 * All elements which consist of two elements should
 
 * have the same name and then suffixes
 
 *   _GROUND and _BUILD for building-type sprites
 
 *   _REAR and _FRONT for transport-type sprites (tiles where vehicles are on)
 
 * 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)
 
 *
 
 *
 
 * 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.
 
 * 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
 
 * 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
 
 * 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 Operating System.
 
 *
 
 * @todo Split the "Sprites" enum into smaller chunks and document them
 
*/
 

	
 

	
 
@@ -226,8 +226,8 @@ enum Sprites {
 

	
 
	/* Elrail stuff */
 
	/* 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
 
	   (in positive coordinate direction) */
 
	 * "short" denotes a wire that requires a pylon on each end. Third identifier is the direction of the slope
 
	 * (in positive coordinate direction) */
 
	SPR_WIRE_X_SHORT = SPR_ELRAIL_BASE + 3,
 
	SPR_WIRE_Y_SHORT = SPR_ELRAIL_BASE + 4,
 
	SPR_WIRE_EW_SHORT = SPR_ELRAIL_BASE + 5,
 
@@ -561,18 +561,17 @@ enum Sprites {
 

	
 
	/* BTSUS == Suspension bridge */
 
	/* TILE_* denotes the different tiles a suspension bridge
 
		can have
 
		TILE_A and TILE_B are the "beginnings" and "ends" of the
 
			suspension system. they have small rectangluar endcaps
 
		TILE_C and TILE_D look almost identical to TILE_A and
 
			TILE_B, but they do not have the "endcaps". They form the
 
			middle part
 
		TILE_E is a condensed configuration of two pillars. while they
 
			are usually 2 pillars apart, they only have 1 pillar separation
 
			here
 
		TILE_F is an extended configuration of pillars. they are
 
			plugged in when pillars should be 3 tiles apart
 

	
 
	 * can have
 
	 * TILE_A and TILE_B are the "beginnings" and "ends" of the
 
	 *   suspension system. they have small rectangluar endcaps
 
	 * TILE_C and TILE_D look almost identical to TILE_A and
 
	 *   TILE_B, but they do not have the "endcaps". They form the
 
	 *   middle part
 
	 * TILE_E is a condensed configuration of two pillars. while they
 
	 *   are usually 2 pillars apart, they only have 1 pillar separation
 
	 *   here
 
	 * TILE_F is an extended configuration of pillars. they are
 
	 *   plugged in when pillars should be 3 tiles apart
 
	*/
 
	SPR_BTSUS_ROAD_Y_REAR_TILE_A  = 2453,
 
	SPR_BTSUS_ROAD_Y_REAR_TILE_B  = 2454,
 
@@ -713,9 +712,9 @@ enum Sprites {
 

	
 
	/* tubular bridges */
 
	/* tubular bridges have 3 kinds of tiles:
 
			a start tile (with only half a tube on the far side, marked _BEG
 
			a middle tile (full tunnel), marked _MID
 
			and an end tile (half a tube on the near side, maked _END
 
	 *  a start tile (with only half a tube on the far side, marked _BEG
 
	 *  a middle tile (full tunnel), marked _MID
 
	 *  and an end tile (half a tube on the near side, maked _END
 
	*/
 
	SPR_BTTUB_X_FRONT_BEG       = 2559,
 
	SPR_BTTUB_X_FRONT_MID       = 2660,
table/town_land.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file town_land.h
 
 */
 
/** @file town_land.h */
 

	
 
enum {
 
	HOUSE_TEMP_CHURCH    = 0x03,
vehicle.c
Show inline comments
 
@@ -2544,7 +2544,7 @@ static void Load_VEHS(void)
 

	
 
		if (CheckSavegameVersion(5)) {
 
			/* 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.type  =  v->current_order.type & 0x0F;
 
		}
 
@@ -2557,7 +2557,7 @@ static void Load_VEHS(void)
 

	
 
			FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
 
				/* If a vehicle has the same orders, add the link to eachother
 
				    in both vehicles */
 
				 *  in both vehicles */
 
				if (v->orders == u->orders) {
 
					v->next_shared = u;
 
					u->prev_shared = v;
yapf/array.hpp
Show inline comments
 
@@ -6,7 +6,7 @@
 
#include "fixedsizearray.hpp"
 

	
 
/** 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_>
 
class CArrayT {
 
public:
yapf/autocopyptr.hpp
Show inline comments
 
@@ -4,15 +4,15 @@
 
#define  AUTOCOPYPTR_HPP
 

	
 
/** CAutoCopyPtrT - kind of CoW (Copy on Write) pointer.
 
		It is non-invasive smart pointer (reference counter is held outside
 
		of Tdata).
 
		When copied, its new copy shares the same underlaying structure Tdata.
 
		When dereferenced, its behavior depends on 2 factors:
 
		   - whether the data is shared (used by more than one pointer)
 
		   - type of access (read/write)
 
		  When shared pointer is dereferenced for write, new clone of Tdata
 
		is made first.
 
		Can't be used for polymorphic data types (interfaces).
 
 *  It is non-invasive smart pointer (reference counter is held outside
 
 *  of Tdata).
 
 *  When copied, its new copy shares the same underlaying structure Tdata.
 
 *  When dereferenced, its behavior depends on 2 factors:
 
 *     - whether the data is shared (used by more than one pointer)
 
 *     - type of access (read/write)
 
 *    When shared pointer is dereferenced for write, new clone of Tdata
 
 *  is made first.
 
 *  Can't be used for polymorphic data types (interfaces).
 
*/
 
template <class Tdata_>
 
class CAutoCopyPtrT {
yapf/blob.hpp
Show inline comments
 
@@ -11,14 +11,14 @@ FORCEINLINE void MemCpyT(Titem_* d, cons
 

	
 

	
 
/** Base class for simple binary blobs.
 
    Item is byte.
 
		The word 'simple' means:
 
		  - no configurable allocator type (always made from heap)
 
			- no smart deallocation - deallocation must be called from the same
 
			    module (DLL) where the blob was 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 thread synchronization at all */
 
 *  Item is byte.
 
 *  The word 'simple' means:
 
 *    - no configurable allocator type (always made from heap)
 
 *    - no smart deallocation - deallocation must be called from the same
 
 *        module (DLL) where the blob was 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 thread synchronization at all */
 
class CBlobBaseSimple {
 
protected:
 
	struct CHdr {
 
@@ -78,7 +78,7 @@ public:
 
	}
 

	
 
	/** 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)
 
	{
 
		assert(num_bytes >= 0);
 
@@ -89,7 +89,7 @@ public:
 
	}
 

	
 
	/** 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)
 
	{
 
		int8* pNewData = MakeRawFreeSpace(num_bytes);
yapf/fixedsizearray.hpp
Show inline comments
 
@@ -5,13 +5,13 @@
 

	
 

	
 
/** fixed size array
 
    Upon construction it preallocates fixed size block of memory
 
		for all items, but doesn't construct them. Item's construction
 
		is delayed. */
 
 *  Upon construction it preallocates fixed size block of memory
 
 *  for all items, but doesn't construct them. Item's construction
 
 *  is delayed. */
 
template <class Titem_, int Tcapacity_>
 
struct CFixedSizeArrayT {
 
	/** 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;
 

	
 
	/** header for fixed size array */
yapf/follow_track.hpp
Show inline comments
 
@@ -6,8 +6,8 @@
 
#include "yapf.hpp"
 

	
 
/** Track follower helper template class (can serve pathfinders and vehicle
 
    controllers). See 6 different typedefs below for 3 different transport
 
    types w/ of w/o 90-deg turns allowed */
 
 *  controllers). See 6 different typedefs below for 3 different transport
 
 *  types w/ of w/o 90-deg turns allowed */
 
template <TransportType Ttr_type_, bool T90deg_turns_allowed_ = true>
 
struct CFollowTrackT : public FollowTrack_t
 
{
 
@@ -38,7 +38,7 @@ struct CFollowTrackT : public FollowTrac
 
	FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;}
 

	
 
	/** 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)
 
	{
 
		m_old_tile = old_tile;
yapf/hashtable.hpp
Show inline comments
 
@@ -95,25 +95,25 @@ struct CHashTableSlotT
 
};
 

	
 
/** @class CHashTableT<Titem, Thash_bits> - simple hash table
 
    of pointers allocated elsewhere.
 

	
 
    Supports: Add/Find/Remove of Titems.
 

	
 
    Your Titem must meet some extra requirements to be CHashTableT
 
    compliant:
 
      - its constructor/destructor (if any) must be public
 
      - if the copying of item requires an extra resource management,
 
          you must define also copy constructor
 
      - must support nested type (struct, class or typedef) Titem::Key
 
          that defines the type of key class for that item
 
      - must support public method:
 
          const Key& GetKey() const; // return the item's key object
 

	
 
		In addition, the Titem::Key class must support:
 
      - public method that calculates key's hash:
 
          int CalcHash() const;
 
			- public 'equality' operator to compare the key with another one
 
					bool operator == (const Key& other) const;
 
 *  of pointers allocated elsewhere.
 
 *
 
 *  Supports: Add/Find/Remove of Titems.
 
 *
 
 *  Your Titem must meet some extra requirements to be CHashTableT
 
 *  compliant:
 
 *    - its constructor/destructor (if any) must be public
 
 *    - if the copying of item requires an extra resource management,
 
 *        you must define also copy constructor
 
 *    - must support nested type (struct, class or typedef) Titem::Key
 
 *        that defines the type of key class for that item
 
 *    - must support public method:
 
 *        const Key& GetKey() const; // return the item's key object
 
 *
 
 *  In addition, the Titem::Key class must support:
 
 *    - public method that calculates key's hash:
 
 *        int CalcHash() const;
 
 *    - public 'equality' operator to compare the key with another one
 
 *        bool operator == (const Key& other) const;
 
*/
 
template <class Titem_, int Thash_bits_>
 
class CHashTableT {
 
@@ -125,7 +125,7 @@ public:
 

	
 
protected:
 
	/** 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;
 

	
 
	Slot*  m_slots;     // here we store our data (array of blobs)
yapf/nodelist.hpp
Show inline comments
 
@@ -8,8 +8,8 @@
 
#include "binaryheap.hpp"
 

	
 
/** Hash table based node list multi-container class.
 
    Implements open list, closed list and priority queue for A-star
 
    path finder. */
 
 *  Implements open list, closed list and priority queue for A-star
 
 *  path finder. */
 
template <class Titem_, int Thash_bits_open_, int Thash_bits_closed_>
 
class CNodeList_HashTableT {
 
public:
yapf/yapf.h
Show inline comments
 
@@ -6,53 +6,53 @@
 
#include "../debug.h"
 

	
 
/** Finds the best path for given ship.
 
	@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 enterdir - diagonal direction which the ship will enter this new tile 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
 
 * @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 enterdir diagonal direction which the ship will enter this new tile 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
 
 */
 
Trackdir YapfChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
 

	
 
/** Finds the best path for given road vehicle.
 
	@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 enterdir - diagonal direction which the RV will enter this new tile 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
 
 * @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 enterdir diagonal direction which the RV will enter this new tile 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
 
*/
 
Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir);
 

	
 
/** Finds the best path for given train.
 
	@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 enterdir - diagonal direction which the RV will enter this new tile 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
 
 * @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 enterdir diagonal direction which the RV will enter this new tile 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
 
*/
 
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.
 
	@param v      - RV (its current tile will be the origin)
 
	@param tile   - destination tile
 
	@return       - distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found
 
 * @param v      RV (its current tile will be the origin)
 
 * @param tile   destination tile
 
 * @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);
 

	
 
/** 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);
 

	
 
/** Used when user sends train to the nearest depot or if train needs servicing.
 
	@v            - train that needs to go to some depot
 
	@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
 
	                  was reached and no depot was seen)
 
	@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
 
	@reversed     - receives true if train needs to reversed first
 
	@return       - the true if depot was found.
 
 * @v            train that needs to go to some depot
 
 * @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
 
 *                  was reached and no depot was seen)
 
 * @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
 
 * @reversed     receives true if train needs to reversed first
 
 * @return       the true if depot was found.
 
*/
 
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
 
tracks, road or water tiles (pathfinders, signal controllers, vehicle controllers).
 
It is an attempt to introduce API that should simplify tasks listed above.
 
If you will need to use it:
 
	1. allocate/declare FollowTrack_t structure;
 
	2. call FollowTrackInit() and provide vehicle (if relevant)
 
	3. call one of 6 FollowTrackXxxx() APIs below
 
	4. check return value (if true then continue else stop)
 
	5. look at FollowTrack_t structure for the result
 
	6. optionally repeat steps 3..5
 
	7. in case of troubles contact KUDr
 
 * tracks, road or water tiles (pathfinders, signal controllers, vehicle controllers).
 
 * It is an attempt to introduce API that should simplify tasks listed above.
 
 * If you will need to use it:
 
 *   1. allocate/declare FollowTrack_t structure;
 
 *   2. call FollowTrackInit() and provide vehicle (if relevant)
 
 *   3. call one of 6 FollowTrackXxxx() APIs below
 
 *   4. check return value (if true then continue else stop)
 
 *   5. look at FollowTrack_t structure for the result
 
 *   6. optionally repeat steps 3..5
 
 *   7. in case of troubles contact KUDr
 
*/
 

	
 
/** Base struct for track followers. */
yapf/yapf_base.hpp
Show inline comments
 
@@ -14,33 +14,33 @@ EXTERN_C_END
 
extern int _total_pf_time_us;
 

	
 
/** CYapfBaseT - A-star type path finder base class.
 
		Derive your own pathfinder from it. You must provide the following template argument:
 
			Types      - used as collection of local types used in pathfinder
 

	
 
		Requirements for the Types struct:
 
		----------------------------------
 
		The following types must be defined in the 'Types' argument:
 
			- Types::Tpf - your pathfinder derived from CYapfBaseT
 
			- Types::NodeList - open/closed node list (look at CNodeList_HashTableT)
 
		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 ()
 

	
 
		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.
 

	
 

	
 
		Requrements to your pathfinder class derived from CYapfBaseT:
 
		-------------------------------------------------------------
 
		Your pathfinder derived class needs to implement following methods:
 
			FORCEINLINE void PfSetStartupNodes()
 
			FORCEINLINE void PfFollowNode(Node& org)
 
			FORCEINLINE bool PfCalcCost(Node& n)
 
			FORCEINLINE bool PfCalcEstimate(Node& n)
 
			FORCEINLINE bool PfDetectDestination(Node& n)
 

	
 
		For more details about those methods, look at the end of CYapfBaseT
 
		declaration. There are some examples. For another example look at
 
		test_yapf.h (part or unittest project).
 
 *  Derive your own pathfinder from it. You must provide the following template argument:
 
 *    Types      - used as collection of local types used in pathfinder
 
 *
 
 * Requirements for the Types struct:
 
 *  ----------------------------------
 
 *  The following types must be defined in the 'Types' argument:
 
 *    - Types::Tpf - your pathfinder derived from CYapfBaseT
 
 *    - Types::NodeList - open/closed node list (look at CNodeList_HashTableT)
 
 *  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 ()
 
 *
 
 *  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.
 
 *
 
 *
 
 *  Requrements to your pathfinder class derived from CYapfBaseT:
 
 *  -------------------------------------------------------------
 
 *  Your pathfinder derived class needs to implement following methods:
 
 *    FORCEINLINE void PfSetStartupNodes()
 
 *    FORCEINLINE void PfFollowNode(Node& org)
 
 *    FORCEINLINE bool PfCalcCost(Node& n)
 
 *    FORCEINLINE bool PfCalcEstimate(Node& n)
 
 *    FORCEINLINE bool PfDetectDestination(Node& n)
 
 *
 
 *  For more details about those methods, look at the end of CYapfBaseT
 
 *  declaration. There are some examples. For another example look at
 
 *  test_yapf.h (part or unittest project).
 
*/
 
template <class Types>
 
class CYapfBaseT {
 
@@ -105,12 +105,12 @@ public:
 
	}
 

	
 
	/** Main pathfinder routine:
 
			 - set startup node(s)
 
			 - main loop that stops if:
 
					- the destination was found
 
					- or the open list is empty (no route to destination).
 
					- or the maximum amount of loops reached - m_max_search_nodes (default = 10000)
 
			@return true if the path was found */
 
	 *   - set startup node(s)
 
	 *   - main loop that stops if:
 
	 *      - the destination was found
 
	 *      - or the open list is empty (no route to destination).
 
	 *      - or the maximum amount of loops reached - m_max_search_nodes (default = 10000)
 
	 * @return true if the path was found */
 
	inline bool FindPath(const Vehicle* v)
 
	{
 
		m_veh = v;
 
@@ -160,7 +160,7 @@ public:
 
	}
 

	
 
	/** 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()
 
	{
 
@@ -168,7 +168,7 @@ public:
 
	}
 

	
 
	/** 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()
 
	{
 
@@ -203,7 +203,7 @@ public:
 
	}
 

	
 
	/** 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)
 
	{
 
		// evaluate the node
yapf/yapf_costcache.hpp
Show inline comments
 
@@ -4,8 +4,8 @@
 

	
 

	
 
/** CYapfSegmentCostCacheNoneT - the formal only yapf cost cache provider that implements
 
PfNodeCacheFetch() and PfNodeCacheFlush() callbacks. Used when nodes don't have CachedData
 
defined (they don't count with any segment cost caching).
 
 * PfNodeCacheFetch() and PfNodeCacheFlush() callbacks. Used when nodes don't have CachedData
 
 * defined (they don't count with any segment cost caching).
 
*/
 
template <class Types>
 
class CYapfSegmentCostCacheNoneT
 
@@ -30,8 +30,8 @@ public:
 

	
 

	
 
/** 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
 
cache the segment costs.
 
 * cost caching functionality for yapf. Used when node needs caching, but you don't want to
 
 * cache the segment costs.
 
*/
 
template <class Types>
 
class CYapfSegmentCostCacheLocalT
 
@@ -82,13 +82,13 @@ struct CSegmentCostCacheBase
 

	
 

	
 
/** CSegmentCostCacheT - template class providing hash-map and storage (heap)
 
    of Tsegment structures. Each rail node contains pointer to the segment
 
    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
 
    be always the same (TileIndex + DiagDirection) that represent the beginning
 
    of the segment (origin tile and exit-dir from this tile).
 
    Different CYapfCachedCostT types can share the same type of CSegmentCostCacheT.
 
    Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example */
 
 *  of Tsegment structures. Each rail node contains pointer to the segment
 
 *  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
 
 *  be always the same (TileIndex + DiagDirection) that represent the beginning
 
 *  of the segment (origin tile and exit-dir from this tile).
 
 *  Different CYapfCachedCostT types can share the same type of CSegmentCostCacheT.
 
 *  Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example */
 
template <class Tsegment>
 
struct CSegmentCostCacheT
 
	: public CSegmentCostCacheBase
 
@@ -119,8 +119,8 @@ struct CSegmentCostCacheT
 
};
 

	
 
/** 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
 
		segment cost caching services for your Nodes.
 
 *  caching functionality to yapf. Using this class as base of your will provide the global
 
 *  segment cost caching services for your Nodes.
 
*/
 
template <class Types>
 
class CYapfSegmentCostCacheGlobalT
yapf/yapf_ship.cpp
Show inline comments
 
@@ -110,7 +110,7 @@ public:
 
};
 

	
 
/** 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>
 
struct CYapfShip_TypesT
0 comments (0 inline, 0 general)