Changeset - r11363:6906c490a00e
[Not reviewed]
master
0 130 0
rubidium - 16 years ago 2009-03-15 00:32:18
rubidium@openttd.org
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
130 files changed with 1725 insertions and 1728 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_scanner.cpp
Show inline comments
 
@@ -554,7 +554,7 @@ bool AIScanner::HasAI(const ContentInfo 
 
 * @param md5sum whether to check the MD5 checksum
 
 * @return true iff we have an AI (library) matching.
 
 */
 
/*static */ bool AI::HasAI(const ContentInfo *ci, bool md5sum)
 
/* static */ bool AI::HasAI(const ContentInfo *ci, bool md5sum)
 
{
 
	return AI::ai_scanner->HasAI(ci, md5sum);
 
}
src/aircraft_cmd.cpp
Show inline comments
 
@@ -428,7 +428,7 @@ CommandCost CmdBuildAircraft(TileIndex t
 
		InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		if (IsLocalCompany())
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); //updates the replace Aircraft window
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Aircraft window
 

	
 
		GetCompany(_current_company)->num_engines[p1]++;
 
	}
 
@@ -1622,9 +1622,9 @@ static void AircraftEventHandler_Flying(
 
	if (apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES) &&
 
			st->airport_tile != INVALID_TILE &&
 
			(st->owner == OWNER_NONE || st->owner == v->owner)) {
 
		// {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41},
 
		// if it is an airplane, look for LANDING, for helicopter HELILANDING
 
		// it is possible to choose from multiple landing runways, so loop until a free one is found
 
		/* {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41},
 
		 * if it is an airplane, look for LANDING, for helicopter HELILANDING
 
		 * it is possible to choose from multiple landing runways, so loop until a free one is found */
 
		byte landingtype = (v->subtype == AIR_HELICOPTER) ? HELILANDING : LANDING;
 
		const AirportFTA *current = apc->layout[v->u.air.pos].next;
 
		while (current != NULL) {
src/airport.h
Show inline comments
 
@@ -69,8 +69,8 @@ enum {
 
	HELIPAD4       = 22
 
};
 

	
 
/* Movement Blocks on Airports */
 
/* blocks (eg_airport_flags) */
 
/* Movement Blocks on Airports
 
 * blocks (eg_airport_flags) */
 
static const uint64
 
	TERM1_block              = 1ULL <<  0,
 
	TERM2_block              = 1ULL <<  1,
src/airport_movement.h
Show inline comments
 
@@ -6,8 +6,8 @@
 
#define AIRPORT_MOVEMENT_H
 

	
 

	
 
// state machine input struct (from external file, etc.)
 
// Finite sTate mAchine --> FTA
 
/* state machine input struct (from external file, etc.)
 
 * Finite sTate mAchine --> FTA */
 
struct AirportFTAbuildup {
 
	byte position; // the position that an airplane is at
 
	byte heading;  // the current orders (eg. TAKEOFF, HANGAR, ENDLANDING, etc.)
 
@@ -25,7 +25,7 @@ static const AirportMovingData _airport_
 
	{   96,    0, AMED_NOSPDCLAMP | AMED_SLOWTURN,     {DIR_N} },
 
};
 

	
 
// Country Airfield (small) 4x3
 
/* Country Airfield (small) 4x3 */
 
static const AirportMovingData _airport_moving_data_country[22] = {
 
	{   53,    3, AMED_EXACTPOS,                   {DIR_SE} }, // 00 In Hangar
 
	{   53,   27, 0,                               {DIR_N} }, // 01 Taxi to right outside depot
 
@@ -51,7 +51,7 @@ static const AirportMovingData _airport_
 
	{   44,   40, AMED_HELI_LOWER,                 {DIR_N} }, // 21 Helicopter landing
 
};
 

	
 
// Commuter Airfield (small) 5x4
 
/* Commuter Airfield (small) 5x4 */
 
static const AirportMovingData _airport_moving_data_commuter[37] = {
 
	{   69,    3, AMED_EXACTPOS,                   {DIR_SE} }, // 00 In Hangar
 
	{   72,   22, 0,                               {DIR_N} }, // 01 Taxi to right outside depot
 
@@ -78,7 +78,7 @@ static const AirportMovingData _airport_
 
	{    1,    6, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 22 Fly around waiting for a landing spot (north-west)
 
	{  193,    6, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 23 Fly around waiting for a landing spot (south-west)
 
	{  225,   81, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 24 Fly around waiting for a landing spot (south)
 
	// Helicopter
 
	/* Helicopter */
 
	{   80,    0, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 25 Bufferspace before helipad
 
	{   80,    0, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 26 Bufferspace before helipad
 
	{   32,    8, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 27 Get in position for Helipad1
 
@@ -93,7 +93,7 @@ static const AirportMovingData _airport_
 
	{   56,    8, AMED_EXACTPOS,                   {DIR_N} }, // pre-helitakeoff helipad 2
 
};
 

	
 
// City Airport (large) 6x6
 
/* City Airport (large) 6x6 */
 
static const AirportMovingData _airport_moving_data_town[] = {
 
	{   85,    3, AMED_EXACTPOS,                   {DIR_SE} }, // 00 In Hangar
 
	{   85,   27, 0,                               {DIR_N} }, // 01 Taxi to right outside depot
 
@@ -111,7 +111,7 @@ static const AirportMovingData _airport_
 
	{  177,   87, AMED_HOLD       | AMED_SLOWTURN, {DIR_N} }, // 13 Fly to landing position in air
 
	{   89,   87, AMED_HOLD       | AMED_LAND,     {DIR_N} }, // 14 Going down for land
 
	{   20,   87, AMED_NOSPDCLAMP | AMED_BRAKE,    {DIR_N} }, // 15 Just landed, brake until end of runway
 
	{   20,   87, 0,                               {DIR_N} }, // 16 Just landed, turn around and taxi 1 square /* NOT USED */
 
	{   20,   87, 0,                               {DIR_N} }, // 16 Just landed, turn around and taxi 1 square // NOT USED
 
	{   36,   71, 0,                               {DIR_N} }, // 17 Taxi from runway to crossing
 
	{  160,   87, AMED_HOLD       | AMED_SLOWTURN, {DIR_N} }, // 18 Fly around waiting for a landing spot (north-east)
 
	{  140,    1, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 19 Final approach fix
 
@@ -127,7 +127,7 @@ static const AirportMovingData _airport_
 
	{  -32,  120, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 29 Initial approach fix (east)
 
};
 

	
 
// Metropolitan Airport (metropolitan) - 2 runways
 
/* Metropolitan Airport (metropolitan) - 2 runways */
 
static const AirportMovingData _airport_moving_data_metropolitan[27] = {
 
	{   85,    3, AMED_EXACTPOS,                   {DIR_SE} }, // 00 In Hangar
 
	{   85,   27, 0,                               {DIR_N} }, // 01 Taxi to right outside depot
 
@@ -158,7 +158,7 @@ static const AirportMovingData _airport_
 
	{   15,   54, AMED_HELI_LOWER,                 {DIR_N} }, // 26 Helicopter landing
 
};
 

	
 
// International Airport (international) - 2 runways, 6 terminals, dedicated helipod
 
/* International Airport (international) - 2 runways, 6 terminals, dedicated helipod */
 
static const AirportMovingData _airport_moving_data_international[51] = {
 
	{    7,   55, AMED_EXACTPOS,                   {DIR_SE} }, // 00 In Hangar 1
 
	{  100,   21, AMED_EXACTPOS,                   {DIR_SE} }, // 01 In Hangar 2
 
@@ -201,7 +201,7 @@ static const AirportMovingData _airport_
 
	{    1,    6, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 38 Fly around waiting for a landing spot (north-west)
 
	{  273,    6, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 39 Fly around waiting for a landing spot (south-west)
 
	{  305,   81, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 40 Fly around waiting for a landing spot (south)
 
	// Helicopter
 
	/* Helicopter */
 
	{  128,   80, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 41 Bufferspace before helipad
 
	{  128,   80, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 42 Bufferspace before helipad
 
	{   96,   71, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 43 Get in position for Helipad1
 
@@ -214,7 +214,7 @@ static const AirportMovingData _airport_
 
	{  104,   32, AMED_HELI_LOWER,                 {DIR_N} }, // 50 Land in HANGAR2_AREA to go to hangar
 
};
 

	
 
// Intercontinental Airport - 4 runways, 8 terminals, 2 dedicated helipads
 
/* Intercontinental Airport - 4 runways, 8 terminals, 2 dedicated helipads */
 
static const AirportMovingData _airport_moving_data_intercontinental[77] = {
 
	{    7,   87, AMED_EXACTPOS,                   {DIR_SE} }, // 00 In Hangar 1
 
	{  135,   72, AMED_EXACTPOS,                   {DIR_SE} }, // 01 In Hangar 2
 
@@ -263,7 +263,7 @@ static const AirportMovingData _airport_
 
	{ -200,   88, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 44 Fly around waiting for a landing spot (north-west)
 
	{   56, -168, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 45 Fly around waiting for a landing spot (south-west)
 
	{  312,   88, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 46 Fly around waiting for a landing spot (south)
 
	// Helicopter
 
	/* Helicopter */
 
	{   96,   40, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 47 Bufferspace before helipad
 
	{   96,   40, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 48 Bufferspace before helipad
 
	{   82,   54, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 49 Get in position for Helipad1
 
@@ -297,7 +297,7 @@ static const AirportMovingData _airport_
 
};
 

	
 

	
 
// Heliport (heliport)
 
/* Heliport (heliport) */
 
static const AirportMovingData _airport_moving_data_heliport[9] = {
 
	{    5,    9, AMED_EXACTPOS,                   {DIR_NE} }, // 0 - At heliport terminal
 
	{    2,    9, AMED_HELI_RAISE,                 {DIR_N} }, // 1 - Take off (play sound)
 
@@ -310,7 +310,7 @@ static const AirportMovingData _airport_
 
	{   70,    9, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 8 - Circle #4 (south)
 
};
 

	
 
// HeliDepot 2x2 (heliport)
 
/* HeliDepot 2x2 (heliport) */
 
static const AirportMovingData _airport_moving_data_helidepot[18] = {
 
	{   24,    4, AMED_EXACTPOS,                   {DIR_NE} }, // 0 - At depot
 
	{   24,   28, 0,                               {DIR_N} }, // 1 Taxi to right outside depot
 
@@ -332,7 +332,7 @@ static const AirportMovingData _airport_
 
	{    8,   24, AMED_SLOWTURN | AMED_EXACTPOS,   {DIR_E} }, // 17 - turn on helipad1 for takeoff
 
};
 

	
 
// HeliDepot 2x2 (heliport)
 
/* HeliDepot 2x2 (heliport) */
 
static const AirportMovingData _airport_moving_data_helistation[33] = {
 
	{    8,    3, AMED_EXACTPOS,                   {DIR_SE} }, // 00 In Hangar2
 
	{    8,   22, 0,                               {DIR_N} }, // 01 outside hangar 2
 
@@ -369,7 +369,7 @@ static const AirportMovingData _airport_
 
	{  132,  -24, AMED_NOSPDCLAMP | AMED_SLOWTURN, {DIR_N} }, // 32 Fly around waiting for a landing spot (north-east)
 
};
 

	
 
// Oilrig
 
/* Oilrig */
 
static const AirportMovingData _airport_moving_data_oilrig[9] = {
 
	{   31,    9, AMED_EXACTPOS,                   {DIR_NE} }, // 0 - At oilrig terminal
 
	{   28,    9, AMED_HELI_RAISE,                 {DIR_N} }, // 1 - Take off (play sound)
 
@@ -406,17 +406,17 @@ static const AirportFTAbuildup _airport_
 
	{  4, 255, AIRPORT_BUSY_block, 0 }, { 4, TERM2, 0, 5 }, { 4, HANGAR, 0, 1 }, { 4, TAKEOFF, 0, 6 }, { 4, HELITAKEOFF, 0, 1 },
 
	{  5, 255, AIRPORT_BUSY_block, 0 }, { 5, TERM2, TERM2_block, 3 }, { 5, 0, 0, 4 },
 
	{  6, 0, AIRPORT_BUSY_block, 7 },
 
	// takeoff
 
	/* takeoff */
 
	{  7, TAKEOFF, AIRPORT_BUSY_block, 8 },
 
	{  8, STARTTAKEOFF, NOTHING_block, 9 },
 
	{  9, ENDTAKEOFF, NOTHING_block, 0 },
 
	// landing
 
	/* landing */
 
	{ 10, FLYING, NOTHING_block, 15 }, { 10, LANDING, 0, 11 }, { 10, HELILANDING, 0, 20 },
 
	{ 11, LANDING, AIRPORT_BUSY_block, 12 },
 
	{ 12, 0, AIRPORT_BUSY_block, 13 },
 
	{ 13, ENDLANDING, AIRPORT_BUSY_block, 14 }, { 13, TERM2, 0, 5 }, { 13, 0, 0, 14 },
 
	{ 14, 0, AIRPORT_BUSY_block, 1 },
 
	// In air
 
	/* In air */
 
	{ 15, 0, NOTHING_block, 16 },
 
	{ 16, 0, NOTHING_block, 17 },
 
	{ 17, 0, NOTHING_block, 18 },
 
@@ -444,31 +444,31 @@ static const AirportFTAbuildup _airport_
 
	{  9, 255, TAXIWAY_BUSY_block, 9 }, { 9, TAKEOFF, TAXIWAY_BUSY_block, 10 }, { 9, HANGAR, TAXIWAY_BUSY_block, 10 }, { 9, TERM2, TERM2_block, 4 }, { 9, HELIPAD1, HELIPAD1_block, 6 }, { 9, HELITAKEOFF, HELIPAD1_block, 6 }, { 9, TERM1, TAXIWAY_BUSY_block, 8 }, { 9, 0, TAXIWAY_BUSY_block, 10 },
 
	{ 10, 255, TAXIWAY_BUSY_block, 10 }, { 10, TERM3, TERM3_block, 5 }, { 10, HELIPAD1, 0, 9 }, { 10, HELIPAD2, HELIPAD2_block, 7 }, { 10, HELITAKEOFF, HELIPAD2_block, 7 }, { 10, TAKEOFF, TAXIWAY_BUSY_block, 1 }, { 10, HANGAR, TAXIWAY_BUSY_block, 1 }, { 10, 0, TAXIWAY_BUSY_block, 9 },
 
	{ 11, 0, OUT_WAY_block, 12 },
 
	// takeoff
 
	/* takeoff */
 
	{ 12, TAKEOFF, RUNWAY_IN_OUT_block, 13 },
 
	{ 13, 0, RUNWAY_IN_OUT_block, 14 },
 
	{ 14, STARTTAKEOFF, RUNWAY_IN_OUT_block, 15 },
 
	{ 15, ENDTAKEOFF, NOTHING_block, 0 },
 
	// landing
 
	/* landing */
 
	{ 16, FLYING, NOTHING_block, 21 }, { 16, LANDING, IN_WAY_block, 17 }, { 16, HELILANDING, 0, 25 },
 
	{ 17, LANDING, RUNWAY_IN_OUT_block, 18 },
 
	{ 18, 0, RUNWAY_IN_OUT_block, 19 },
 
	{ 19, 0, RUNWAY_IN_OUT_block, 20 },
 
	{ 20, ENDLANDING, IN_WAY_block, 2 },
 
	// In Air
 
	/* In Air */
 
	{ 21, 0, NOTHING_block, 22 },
 
	{ 22, 0, NOTHING_block, 23 },
 
	{ 23, 0, NOTHING_block, 24 },
 
	{ 24, 0, NOTHING_block, 16 },
 
	// Helicopter -- stay in air in special place as a buffer to choose from helipads
 
	/* Helicopter -- stay in air in special place as a buffer to choose from helipads */
 
	{ 25, HELILANDING, PRE_HELIPAD_block, 26 },
 
	{ 26, HELIENDLANDING, PRE_HELIPAD_block, 26 }, { 26, HELIPAD1, 0, 27 }, { 26, HELIPAD2, 0, 28 }, { 26, HANGAR, 0, 33 },
 
	{ 27, 0, NOTHING_block, 29 }, //helipad1 approach
 
	{ 27, 0, NOTHING_block, 29 }, // helipad1 approach
 
	{ 28, 0, NOTHING_block, 30 },
 
	// landing
 
	/* landing */
 
	{ 29, 255, NOTHING_block, 0 }, { 29, HELIPAD1, HELIPAD1_block, 6 },
 
	{ 30, 255, NOTHING_block, 0 }, { 30, HELIPAD2, HELIPAD2_block, 7 },
 
	// Helicopter -- takeoff
 
	/* Helicopter -- takeoff */
 
	{ 31, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 32, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 33, 0, TAXIWAY_BUSY_block, 34 }, // need to go to hangar when waiting in air
 
@@ -492,22 +492,22 @@ static const AirportFTAbuildup _airport_
 
	{  7, 255, TAXIWAY_BUSY_block, 0 }, { 7, TERM1, TERM1_block, 2 }, { 7, TAKEOFF, OUT_WAY_block, 8 }, { 7, HELITAKEOFF, 0, 22 }, { 7, HANGAR, 0, 1 }, { 7, 0, 0, 6 },
 
	{  8, 0, OUT_WAY_block, 9 },
 
	{  9, 0, RUNWAY_IN_OUT_block, 10 },
 
	// takeoff
 
	/* takeoff */
 
	{ 10, TAKEOFF, RUNWAY_IN_OUT_block, 11 },
 
	{ 11, STARTTAKEOFF, NOTHING_block, 12 },
 
	{ 12, ENDTAKEOFF, NOTHING_block, 0 },
 
	// landing
 
	/* landing */
 
	{ 13, FLYING, NOTHING_block, 18 }, { 13, LANDING, 0, 14 }, { 13, HELILANDING, 0, 23 },
 
	{ 14, LANDING, RUNWAY_IN_OUT_block, 15 },
 
	{ 15, 0, RUNWAY_IN_OUT_block, 17 },
 
	{ 16, 0, RUNWAY_IN_OUT_block, 17 }, /* not used, left for compatibility */
 
	{ 16, 0, RUNWAY_IN_OUT_block, 17 }, // not used, left for compatibility
 
	{ 17, ENDLANDING, IN_WAY_block, 7 },
 
	// In Air
 
	/* In Air */
 
	{ 18, 0, NOTHING_block, 25 },
 
	{ 19, 0, NOTHING_block, 20 },
 
	{ 20, 0, NOTHING_block, 21 },
 
	{ 21, 0, NOTHING_block, 13 },
 
	// helicopter
 
	/* helicopter */
 
	{ 22, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 23, HELILANDING, IN_WAY_block, 24 },
 
	{ 24, HELIENDLANDING, IN_WAY_block, 17 },
 
@@ -533,23 +533,23 @@ static const AirportFTAbuildup _airport_
 
	{  7, 255, TAXIWAY_BUSY_block, 0 }, { 7, TERM1, TERM1_block, 2 }, { 7, TAKEOFF, 0, 8 }, { 7, HELITAKEOFF, 0, 23 }, { 7, HANGAR, 0, 1 }, { 7, 0, 0, 6 },
 
	{  8, 0, OUT_WAY_block, 9 },
 
	{  9, 0, RUNWAY_OUT_block, 10 },
 
	// takeoff
 
	/* takeoff */
 
	{ 10, TAKEOFF, RUNWAY_OUT_block, 11 },
 
	{ 11, STARTTAKEOFF, NOTHING_block, 12 },
 
	{ 12, ENDTAKEOFF, NOTHING_block, 0 },
 
	// landing
 
	/* landing */
 
	{ 13, FLYING, NOTHING_block, 19 }, { 13, LANDING, 0, 14 }, { 13, HELILANDING, 0, 25 },
 
	{ 14, LANDING, RUNWAY_IN_block, 15 },
 
	{ 15, 0, RUNWAY_IN_block, 16 },
 
	{ 16, 255, RUNWAY_IN_block, 0 }, { 16, ENDLANDING, IN_WAY_block, 17 },
 
	{ 17, 255, RUNWAY_OUT_block, 0 }, { 17, ENDLANDING, IN_WAY_block, 18 },
 
	{ 18, ENDLANDING, IN_WAY_block, 7 },
 
	// In Air
 
	/* In Air */
 
	{ 19, 0, NOTHING_block, 20 },
 
	{ 20, 0, NOTHING_block, 21 },
 
	{ 21, 0, NOTHING_block, 22 },
 
	{ 22, 0, NOTHING_block, 13 },
 
	// helicopter
 
	/* helicopter */
 
	{ 23, 0, NOTHING_block, 24 },
 
	{ 24, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 25, HELILANDING, IN_WAY_block, 26 },
 
@@ -590,31 +590,31 @@ static const AirportFTAbuildup _airport_
 
	{ 25, 255, TERM_GROUP1_block, 0 }, { 25, TERM3, TERM3_block, 6 }, { 25, TAKEOFF, 0, 26 }, { 25, 0, 0, 24 },
 
	{ 26, 255, TAXIWAY_BUSY_block, 0 }, { 26, TAKEOFF, 0, 27 }, { 26, 0, 0, 25 },
 
	{ 27, 0, OUT_WAY_block, 28 },
 
	// takeoff
 
	/* takeoff */
 
	{ 28, TAKEOFF, OUT_WAY_block, 29 },
 
	{ 29, 0, RUNWAY_OUT_block, 30 },
 
	{ 30, STARTTAKEOFF, NOTHING_block, 31 },
 
	{ 31, ENDTAKEOFF, NOTHING_block, 0 },
 
	// landing
 
	/* landing */
 
	{ 32, FLYING, NOTHING_block, 37 }, { 32, LANDING, 0, 33 }, { 32, HELILANDING, 0, 41 },
 
	{ 33, LANDING, RUNWAY_IN_block, 34 },
 
	{ 34, 0, RUNWAY_IN_block, 35 },
 
	{ 35, 0, RUNWAY_IN_block, 36 },
 
	{ 36, ENDLANDING, IN_WAY_block, 36 }, { 36, 255, TERM_GROUP1_block, 0 }, { 36, 255, TERM_GROUP2_ENTER1_block, 1 }, { 36, TERM4, 0, 12 }, { 36, TERM5, 0, 12 }, { 36, TERM6, 0, 12 }, { 36, 0, 0, 2 },
 
	// In Air
 
	/* In Air */
 
	{ 37, 0, NOTHING_block, 38 },
 
	{ 38, 0, NOTHING_block, 39 },
 
	{ 39, 0, NOTHING_block, 40 },
 
	{ 40, 0, NOTHING_block, 32 },
 
	// Helicopter -- stay in air in special place as a buffer to choose from helipads
 
	/* Helicopter -- stay in air in special place as a buffer to choose from helipads */
 
	{ 41, HELILANDING, PRE_HELIPAD_block, 42 },
 
	{ 42, HELIENDLANDING, PRE_HELIPAD_block, 42 }, { 42, HELIPAD1, 0, 43 }, { 42, HELIPAD2, 0, 44 }, { 42, HANGAR, 0, 49 },
 
	{ 43, 0, NOTHING_block, 45 },
 
	{ 44, 0, NOTHING_block, 46 },
 
	// landing
 
	/* landing */
 
	{ 45, 255, NOTHING_block, 0 }, { 45, HELIPAD1, HELIPAD1_block, 10 },
 
	{ 46, 255, NOTHING_block, 0 }, { 46, HELIPAD2, HELIPAD2_block, 11 },
 
	// Helicopter -- takeoff
 
	/* Helicopter -- takeoff */
 
	{ 47, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 48, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 49, 0, HANGAR2_AREA_block, 50 }, // need to go to hangar when waiting in air
 
@@ -622,7 +622,7 @@ static const AirportFTAbuildup _airport_
 
	{ MAX_ELEMENTS, 0, 0, 0 } // end marker. DO NOT REMOVE
 
};
 

	
 
// intercontinental
 
/* intercontinental */
 
static const TileIndexDiffC _airport_depots_intercontinental[] = { { 0, 5 }, { 8, 4 } };
 
static const byte _airport_terminal_intercontinental[] = { 2, 4, 4 };
 
static const byte _airport_helipad_intercontinental[] = { 1, 2 };
 
@@ -660,12 +660,12 @@ static const AirportFTAbuildup _airport_
 
	{ 29, 255, TERM_GROUP1_block, 0 }, { 29, TERM4, TERM4_block, 7 }, { 29, HANGAR, HANGAR1_AREA_block, 27 }, { 29, TAKEOFF, 0, 30 }, { 29, 0, 0, 28 },
 
	{ 30, 0, OUT_WAY_block2, 31 },
 
	{ 31, 0, OUT_WAY_block, 32 },
 
	// takeoff
 
	/* takeoff */
 
	{ 32, TAKEOFF, RUNWAY_OUT_block, 33 },
 
	{ 33, 0, RUNWAY_OUT_block, 34 },
 
	{ 34, STARTTAKEOFF, NOTHING_block, 35 },
 
	{ 35, ENDTAKEOFF, NOTHING_block, 0 },
 
	// landing
 
	/* landing */
 
	{ 36, 0, 0, 0 },
 
	{ 37, LANDING, RUNWAY_IN_block, 38 },
 
	{ 38, 0, RUNWAY_IN_block, 39 },
 
@@ -673,32 +673,32 @@ static const AirportFTAbuildup _airport_
 
	{ 40, ENDLANDING, RUNWAY_IN_block, 41 },
 
	{ 41, 0, IN_WAY_block, 42 },
 
	{ 42, 255, IN_WAY_block, 0 }, { 42, 255, TERM_GROUP1_block, 0 }, { 42, 255, TERM_GROUP1_block, 1 }, { 42, HANGAR, 0, 2 }, { 42, 0, 0, 26 },
 
	// In Air
 
	/* In Air */
 
	{ 43, 0, 0, 44 },
 
	{ 44, FLYING, 0, 45 }, { 44, HELILANDING, 0, 47 }, { 44, LANDING, 0, 69 }, { 44, 0, 0, 45 },
 
	{ 45, 0, 0, 46 },
 
	{ 46, FLYING, 0, 43 }, { 46, LANDING, 0, 76 }, { 46, 0, 0, 43 },
 
	// Helicopter -- stay in air in special place as a buffer to choose from helipads
 
	/* Helicopter -- stay in air in special place as a buffer to choose from helipads */
 
	{ 47, HELILANDING, PRE_HELIPAD_block, 48 },
 
	{ 48, HELIENDLANDING, PRE_HELIPAD_block, 48 }, { 48, HELIPAD1, 0, 49 }, { 48, HELIPAD2, 0, 50 }, { 48, HANGAR, 0, 55 },
 
	{ 49, 0, NOTHING_block, 51 },
 
	{ 50, 0, NOTHING_block, 52 },
 
	// landing
 
	/* landing */
 
	{ 51, 255, NOTHING_block, 0 }, { 51, HELIPAD1, HELIPAD1_block, 12 }, { 51, HANGAR, 0, 55 }, { 51, 0, 0, 12 },
 
	{ 52, 255, NOTHING_block, 0 }, { 52, HELIPAD2, HELIPAD2_block, 13 }, { 52, HANGAR, 0, 55 }, { 52, 0, 0, 13 },
 
	// Helicopter -- takeoff
 
	/* Helicopter -- takeoff */
 
	{ 53, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 54, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 55, 0, HANGAR2_AREA_block, 56 }, // need to go to hangar when waiting in air
 
	{ 56, 0, HANGAR2_AREA_block, 3 },
 
	// runway 2 out support
 
	/* runway 2 out support */
 
	{ 57, 255, OUT_WAY2_block, 0 }, { 57, TAKEOFF, 0, 58 }, { 57, 0, 0, 58 },
 
	{ 58, 0, OUT_WAY2_block, 59 },
 
	{ 59, TAKEOFF, RUNWAY_OUT2_block, 60 }, // takeoff
 
	{ 60, 0, RUNWAY_OUT2_block, 61 },
 
	{ 61, STARTTAKEOFF, NOTHING_block, 62 },
 
	{ 62, ENDTAKEOFF, NOTHING_block, 0 },
 
	// runway 2 in support
 
	/* runway 2 in support */
 
	{ 63, LANDING, RUNWAY_IN2_block, 64 },
 
	{ 64, 0, RUNWAY_IN2_block, 65 },
 
	{ 65, 0, RUNWAY_IN2_block, 66 },
 
@@ -717,7 +717,7 @@ static const AirportFTAbuildup _airport_
 
};
 

	
 

	
 
// heliports, oilrigs don't have depots
 
/* heliports, oilrigs don't have depots */
 
static const byte _airport_helipad_heliport_oilrig[] = { 1, 1 };
 
static const byte _airport_entries_heliport_oilrig[] = { 7, 7, 7, 7 };
 
static const AirportFTAbuildup _airport_fta_heliport_oilrig[] = {
 
@@ -726,7 +726,7 @@ static const AirportFTAbuildup _airport_
 
	{ 2, 255, AIRPORT_BUSY_block, 0 }, { 2, HELILANDING, 0, 3 }, { 2, HELITAKEOFF, 0, 1 },
 
	{ 3, HELILANDING, AIRPORT_BUSY_block, 4 },
 
	{ 4, HELIENDLANDING, AIRPORT_BUSY_block, 4 }, { 4, HELIPAD1, HELIPAD1_block, 0 }, { 4, HELITAKEOFF, 0, 2 },
 
	// In Air
 
	/* In Air */
 
	{ 5, 0, NOTHING_block, 6 },
 
	{ 6, 0, NOTHING_block, 7 },
 
	{ 7, 0, NOTHING_block, 8 },
 
@@ -734,7 +734,7 @@ static const AirportFTAbuildup _airport_
 
	{ MAX_ELEMENTS, 0, 0, 0 } // end marker. DO NOT REMOVE
 
};
 

	
 
// helidepots
 
/* helidepots */
 
static const TileIndexDiffC _airport_depots_helidepot[] = { { 1, 0 } };
 
static const byte _airport_helipad_helidepot[] = { 1, 1 };
 
static const byte _airport_entries_helidepot[] = { 4, 4, 4, 4 };
 
@@ -742,18 +742,18 @@ static const AirportFTAbuildup _airport_
 
	{  0, HANGAR, NOTHING_block, 1 },
 
	{  1, 255, HANGAR2_AREA_block, 0 }, { 1, HANGAR, 0, 0 }, { 1, HELIPAD1, HELIPAD1_block, 14 }, { 1, HELITAKEOFF, 0, 15 }, { 1, 0, 0, 0 },
 
	{  2, FLYING, NOTHING_block, 3 }, { 2, HELILANDING, PRE_HELIPAD_block, 7 }, { 2, HANGAR, 0, 12 }, { 2, HELITAKEOFF, NOTHING_block, 16 },
 
	// In Air
 
	/* In Air */
 
	{  3, 0, NOTHING_block, 4 },
 
	{  4, 0, NOTHING_block, 5 },
 
	{  5, 0, NOTHING_block, 6 },
 
	{  6, 0, NOTHING_block, 2 },
 
	// Helicopter -- stay in air in special place as a buffer to choose from helipads
 
	/* Helicopter -- stay in air in special place as a buffer to choose from helipads */
 
	{  7, HELILANDING, PRE_HELIPAD_block, 8 },
 
	{  8, HELIENDLANDING, PRE_HELIPAD_block, 8 }, { 8, HELIPAD1, 0, 9 }, { 8, HANGAR, 0, 12 }, { 8, 0, 0, 2 },
 
	{  9, 0, NOTHING_block, 10 },
 
	// landing
 
	/* landing */
 
	{ 10, 255, NOTHING_block, 10 }, { 10, HELIPAD1, HELIPAD1_block, 14 }, { 10, HANGAR, 0, 1 }, { 10, 0, 0, 14 },
 
	// Helicopter -- takeoff
 
	/* Helicopter -- takeoff */
 
	{ 11, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 12, 0, HANGAR2_AREA_block, 13 }, // need to go to hangar when waiting in air
 
	{ 13, 0, HANGAR2_AREA_block, 1 },
 
@@ -764,16 +764,16 @@ static const AirportFTAbuildup _airport_
 
	{ MAX_ELEMENTS, 0, 0, 0 } // end marker. DO NOT REMOVE
 
};
 

	
 
// helistation
 
/* helistation */
 
static const TileIndexDiffC _airport_depots_helistation[] = { { 0, 0 } };
 
static const byte _airport_helipad_helistation[] = { 1, 3 };
 
static const byte _airport_entries_helistation[] = { 25, 25, 25, 25 };
 
static const AirportFTAbuildup _airport_fta_helistation[] = {
 
	{  0, HANGAR, NOTHING_block, 8 },    { 0, HELIPAD1, 0, 1 }, { 0, HELIPAD2, 0, 1 }, { 0, HELIPAD3, 0, 1 }, { 0, HELITAKEOFF, 0, 1 }, { 0, 0, 0, 0 },
 
	{  1, 255, HANGAR2_AREA_block, 0 },  { 1, HANGAR, 0, 0 }, { 1, HELITAKEOFF, 0, 3 }, { 1, 0, 0, 4 },
 
	// landing
 
	/* landing */
 
	{  2, FLYING, NOTHING_block, 28 },   { 2, HELILANDING, 0, 15 }, { 2, 0, 0, 28 },
 
	// helicopter side
 
	/* helicopter side */
 
	{  3, HELITAKEOFF, NOTHING_block, 0 }, // helitakeoff outside hangar2
 
	{  4, 255, TAXIWAY_BUSY_block, 0 },  { 4, HANGAR, HANGAR2_AREA_block, 1 }, { 4, HELITAKEOFF, 0, 1 }, { 4, 0, 0, 5 },
 
	{  5, 255, TAXIWAY_BUSY_block, 0 },  { 5, HELIPAD1, HELIPAD1_block, 6 }, { 5, HELIPAD2, HELIPAD2_block, 7 }, { 5, HELIPAD3, HELIPAD3_block, 8 }, { 5, 0, 0, 4 },
 
@@ -786,13 +786,13 @@ static const AirportFTAbuildup _airport_
 
	{ 12, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 13, HELITAKEOFF, NOTHING_block, 0 },
 
	{ 14, HELITAKEOFF, NOTHING_block, 0 },
 
	// heli - in flight moves
 
	/* heli - in flight moves */
 
	{ 15, HELILANDING, PRE_HELIPAD_block, 16 },
 
	{ 16, HELIENDLANDING, PRE_HELIPAD_block, 16 }, { 16, HELIPAD1, 0, 17 }, { 16, HELIPAD2, 0, 18 }, { 16, HELIPAD3, 0, 19 }, { 16, HANGAR, 0, 23 },
 
	{ 17, 0, NOTHING_block, 20 },
 
	{ 18, 0, NOTHING_block, 21 },
 
	{ 19, 0, NOTHING_block, 22 },
 
	// heli landing
 
	/* heli landing */
 
	{ 20, 255, NOTHING_block, 0 }, { 20, HELIPAD1, HELIPAD1_block, 6 }, { 20, HANGAR, 0, 23 }, { 20, 0, 0, 6 },
 
	{ 21, 255, NOTHING_block, 0 }, { 21, HELIPAD2, HELIPAD2_block, 7 }, { 21, HANGAR, 0, 23 }, { 21, 0, 0, 7 },
 
	{ 22, 255, NOTHING_block, 0 }, { 22, HELIPAD3, HELIPAD3_block, 8 }, { 22, HANGAR, 0, 23 }, { 22, 0, 0, 8 },
src/autoreplace_gui.cpp
Show inline comments
 
@@ -342,7 +342,7 @@ public:
 
				this->SetDirty();
 
				break;
 

	
 
			case RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: { /* Railtype selection dropdown menu */
 
			case RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: { // Railtype selection dropdown menu
 
				const Company *c = GetCompany(_local_company);
 
				DropDownList *list = new DropDownList();
 
				for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
 
@@ -355,18 +355,18 @@ public:
 
				break;
 
			}
 

	
 
			case RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE: /* toggle renew_keep_length */
 
			case RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE: // toggle renew_keep_length
 
				DoCommandP(0, 5, GetCompany(_local_company)->renew_keep_length ? 0 : 1, CMD_SET_AUTOREPLACE);
 
				break;
 

	
 
			case RVW_WIDGET_START_REPLACE: { /* Start replacing */
 
			case RVW_WIDGET_START_REPLACE: { // Start replacing
 
				EngineID veh_from = this->sel_engine[0];
 
				EngineID veh_to = this->sel_engine[1];
 
				DoCommandP(0, 3 + (this->sel_group << 16) , veh_from + (veh_to << 16), CMD_SET_AUTOREPLACE);
 
				this->SetDirty();
 
			} break;
 

	
 
			case RVW_WIDGET_STOP_REPLACE: { /* Stop replacing */
 
			case RVW_WIDGET_STOP_REPLACE: { // Stop replacing
 
				EngineID veh_from = this->sel_engine[0];
 
				DoCommandP(0, 3 + (this->sel_group << 16), veh_from + (INVALID_ENGINE << 16), CMD_SET_AUTOREPLACE);
 
				this->SetDirty();
src/aystar.cpp
Show inline comments
 
@@ -25,36 +25,36 @@
 
int _aystar_stats_open_size;
 
int _aystar_stats_closed_size;
 

	
 
// This looks in the Hash if a node exists in ClosedList
 
//  If so, it returns the PathNode, else NULL
 
/* This looks in the Hash if a node exists in ClosedList
 
 *  If so, it returns the PathNode, else NULL */
 
static PathNode *AyStarMain_ClosedList_IsInList(AyStar *aystar, const AyStarNode *node)
 
{
 
	return (PathNode*)Hash_Get(&aystar->ClosedListHash, node->tile, node->direction);
 
}
 

	
 
// This adds a node to the ClosedList
 
//  It makes a copy of the data
 
/* This adds a node to the ClosedList
 
 *  It makes a copy of the data */
 
static void AyStarMain_ClosedList_Add(AyStar *aystar, const PathNode *node)
 
{
 
	// Add a node to the ClosedList
 
	/* Add a node to the ClosedList */
 
	PathNode *new_node = MallocT<PathNode>(1);
 
	*new_node = *node;
 
	Hash_Set(&aystar->ClosedListHash, node->node.tile, node->node.direction, new_node);
 
}
 

	
 
// Checks if a node is in the OpenList
 
//   If so, it returns the OpenListNode, else NULL
 
/* Checks if a node is in the OpenList
 
 *   If so, it returns the OpenListNode, else NULL */
 
static OpenListNode *AyStarMain_OpenList_IsInList(AyStar *aystar, const AyStarNode *node)
 
{
 
	return (OpenListNode*)Hash_Get(&aystar->OpenListHash, node->tile, node->direction);
 
}
 

	
 
// Gets the best node from OpenList
 
//  returns the best node, or NULL of none is found
 
// Also it deletes the node from the OpenList
 
/* Gets the best node from OpenList
 
 *  returns the best node, or NULL of none is found
 
 * Also it deletes the node from the OpenList */
 
static OpenListNode *AyStarMain_OpenList_Pop(AyStar *aystar)
 
{
 
	// Return the item the Queue returns.. the best next OpenList item.
 
	/* Return the item the Queue returns.. the best next OpenList item. */
 
	OpenListNode *res = (OpenListNode*)aystar->OpenListQueue.pop(&aystar->OpenListQueue);
 
	if (res != NULL) {
 
		Hash_Delete(&aystar->OpenListHash, res->path.node.tile, res->path.node.direction);
 
@@ -63,18 +63,18 @@ static OpenListNode *AyStarMain_OpenList
 
	return res;
 
}
 

	
 
// Adds a node to the OpenList
 
//  It makes a copy of node, and puts the pointer of parent in the struct
 
/* Adds a node to the OpenList
 
 *  It makes a copy of node, and puts the pointer of parent in the struct */
 
static void AyStarMain_OpenList_Add(AyStar *aystar, PathNode *parent, const AyStarNode *node, int f, int g)
 
{
 
	// Add a new Node to the OpenList
 
	/* Add a new Node to the OpenList */
 
	OpenListNode *new_node = MallocT<OpenListNode>(1);
 
	new_node->g = g;
 
	new_node->path.parent = parent;
 
	new_node->path.node = *node;
 
	Hash_Set(&aystar->OpenListHash, node->tile, node->direction, new_node);
 

	
 
	// Add it to the queue
 
	/* Add it to the queue */
 
	aystar->OpenListQueue.push(&aystar->OpenListQueue, new_node, f);
 
}
 

	
 
@@ -89,49 +89,49 @@ int AyStarMain_CheckTile(AyStar *aystar,
 
	PathNode *closedlist_parent;
 
	OpenListNode *check;
 

	
 
	// Check the new node against the ClosedList
 
	/* Check the new node against the ClosedList */
 
	if (AyStarMain_ClosedList_IsInList(aystar, current) != NULL) return AYSTAR_DONE;
 

	
 
	// Calculate the G-value for this node
 
	/* Calculate the G-value for this node */
 
	new_g = aystar->CalculateG(aystar, current, parent);
 
	// If the value was INVALID_NODE, we don't do anything with this node
 
	/* If the value was INVALID_NODE, we don't do anything with this node */
 
	if (new_g == AYSTAR_INVALID_NODE) return AYSTAR_DONE;
 

	
 
	// There should not be given any other error-code..
 
	/* There should not be given any other error-code.. */
 
	assert(new_g >= 0);
 
	// Add the parent g-value to the new g-value
 
	/* Add the parent g-value to the new g-value */
 
	new_g += parent->g;
 
	if (aystar->max_path_cost != 0 && (uint)new_g > aystar->max_path_cost) return AYSTAR_DONE;
 

	
 
	// Calculate the h-value
 
	/* Calculate the h-value */
 
	new_h = aystar->CalculateH(aystar, current, parent);
 
	// There should not be given any error-code..
 
	/* There should not be given any error-code.. */
 
	assert(new_h >= 0);
 

	
 
	// The f-value if g + h
 
	/* The f-value if g + h */
 
	new_f = new_g + new_h;
 

	
 
	// Get the pointer to the parent in the ClosedList (the currentone is to a copy of the one in the OpenList)
 
	/* Get the pointer to the parent in the ClosedList (the currentone is to a copy of the one in the OpenList) */
 
	closedlist_parent = AyStarMain_ClosedList_IsInList(aystar, &parent->path.node);
 

	
 
	// Check if this item is already in the OpenList
 
	/* Check if this item is already in the OpenList */
 
	check = AyStarMain_OpenList_IsInList(aystar, current);
 
	if (check != NULL) {
 
		uint i;
 
		// Yes, check if this g value is lower..
 
		/* Yes, check if this g value is lower.. */
 
		if (new_g > check->g) return AYSTAR_DONE;
 
		aystar->OpenListQueue.del(&aystar->OpenListQueue, check, 0);
 
		// It is lower, so change it to this item
 
		/* It is lower, so change it to this item */
 
		check->g = new_g;
 
		check->path.parent = closedlist_parent;
 
		/* Copy user data, will probably have changed */
 
		for (i = 0; i < lengthof(current->user_data); i++) {
 
			check->path.node.user_data[i] = current->user_data[i];
 
		}
 
		// Readd him in the OpenListQueue
 
		/* Readd him in the OpenListQueue */
 
		aystar->OpenListQueue.push(&aystar->OpenListQueue, check, new_f);
 
	} else {
 
		// A new node, add him to the OpenList
 
		/* A new node, add him to the OpenList */
 
		AyStarMain_OpenList_Add(aystar, closedlist_parent, current, new_f, new_g);
 
	}
 

	
 
@@ -153,12 +153,12 @@ int AyStarMain_Loop(AyStar *aystar)
 
{
 
	int i, r;
 

	
 
	// Get the best node from OpenList
 
	/* Get the best node from OpenList */
 
	OpenListNode *current = AyStarMain_OpenList_Pop(aystar);
 
	// If empty, drop an error
 
	/* If empty, drop an error */
 
	if (current == NULL) return AYSTAR_EMPTY_OPENLIST;
 

	
 
	// Check for end node and if found, return that code
 
	/* Check for end node and if found, return that code */
 
	if (aystar->EndNodeCheck(aystar, current) == AYSTAR_FOUND_END_NODE) {
 
		if (aystar->FoundEndNode != NULL)
 
			aystar->FoundEndNode(aystar, current);
 
@@ -166,26 +166,26 @@ int AyStarMain_Loop(AyStar *aystar)
 
		return AYSTAR_FOUND_END_NODE;
 
	}
 

	
 
	// Add the node to the ClosedList
 
	/* Add the node to the ClosedList */
 
	AyStarMain_ClosedList_Add(aystar, &current->path);
 

	
 
	// Load the neighbours
 
	/* Load the neighbours */
 
	aystar->GetNeighbours(aystar, current);
 

	
 
	// Go through all neighbours
 
	/* Go through all neighbours */
 
	for (i = 0; i < aystar->num_neighbours; i++) {
 
		// Check and add them to the OpenList if needed
 
		/* Check and add them to the OpenList if needed */
 
		r = aystar->checktile(aystar, &aystar->neighbours[i], current);
 
	}
 

	
 
	// Free the node
 
	/* Free the node */
 
	free(current);
 

	
 
	if (aystar->max_search_nodes != 0 && Hash_Size(&aystar->ClosedListHash) >= aystar->max_search_nodes) {
 
		/* We've expanded enough nodes */
 
		return AYSTAR_LIMIT_REACHED;
 
	} else {
 
		// Return that we are still busy
 
		/* Return that we are still busy */
 
		return AYSTAR_STILL_BUSY;
 
	}
 
}
 
@@ -211,10 +211,10 @@ void AyStarMain_Free(AyStar *aystar)
 
 */
 
void AyStarMain_Clear(AyStar *aystar)
 
{
 
	// Clean the Queue, but not the elements within. That will be done by
 
	// the hash.
 
	/* Clean the Queue, but not the elements within. That will be done by
 
	 * the hash. */
 
	aystar->OpenListQueue.clear(&aystar->OpenListQueue, false);
 
	// Clean the hashes
 
	/* Clean the hashes */
 
	clear_Hash(&aystar->OpenListHash, true);
 
	clear_Hash(&aystar->ClosedListHash, true);
 

	
 
@@ -235,8 +235,8 @@ void AyStarMain_Clear(AyStar *aystar)
 
 */
 
int AyStarMain_Main(AyStar *aystar) {
 
	int r, i = 0;
 
	// Loop through the OpenList
 
	//  Quit if result is no AYSTAR_STILL_BUSY or is more than loops_per_tick
 
	/* Loop through the OpenList
 
	 *  Quit if result is no AYSTAR_STILL_BUSY or is more than loops_per_tick */
 
	while ((r = aystar->loop(aystar)) == AYSTAR_STILL_BUSY && (aystar->loops_per_tick == 0 || ++i < aystar->loops_per_tick)) { }
 
#ifdef AYSTAR_DEBUG
 
	switch (r) {
 
@@ -279,14 +279,14 @@ void AyStarMain_AddStartNode(AyStar *ays
 

	
 
void init_AyStar(AyStar *aystar, Hash_HashProc hash, uint num_buckets)
 
{
 
	// Allocated the Hash for the OpenList and ClosedList
 
	/* Allocated the Hash for the OpenList and ClosedList */
 
	init_Hash(&aystar->OpenListHash, hash, num_buckets);
 
	init_Hash(&aystar->ClosedListHash, hash, num_buckets);
 

	
 
	// Set up our sorting queue
 
	//  BinaryHeap allocates a block of 1024 nodes
 
	//  When thatone gets full it reserves an otherone, till this number
 
	//  That is why it can stay this high
 
	/* Set up our sorting queue
 
	 *  BinaryHeap allocates a block of 1024 nodes
 
	 *  When thatone gets full it reserves an otherone, till this number
 
	 *  That is why it can stay this high */
 
	init_BinaryHeap(&aystar->OpenListQueue, 102400);
 

	
 
	aystar->addstart  = AyStarMain_AddStartNode;
src/aystar.h
Show inline comments
 
@@ -35,16 +35,16 @@ struct AyStarNode {
 
	uint user_data[2];
 
};
 

	
 
// The resulting path has nodes looking like this.
 
/* The resulting path has nodes looking like this. */
 
struct PathNode {
 
	AyStarNode node;
 
	// The parent of this item
 
	/* The parent of this item */
 
	PathNode *parent;
 
};
 

	
 
// For internal use only
 
// We do not save the h-value, because it is only needed to calculate the f-value.
 
//  h-value should _always_ be the distance left to the end-tile.
 
/* For internal use only
 
 * We do not save the h-value, because it is only needed to calculate the f-value.
 
 *  h-value should _always_ be the distance left to the end-tile. */
 
struct OpenListNode {
 
	int g;
 
	PathNode path;
 
@@ -97,7 +97,7 @@ typedef void AyStar_GetNeighbours(AyStar
 
 */
 
typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current);
 

	
 
// For internal use, see aystar.c
 
/* For internal use, see aystar.cpp */
 
typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g);
 
typedef int AyStar_Main(AyStar *aystar);
 
typedef int AyStar_Loop(AyStar *aystar);
src/blitter/32bpp_base.cpp
Show inline comments
 
@@ -128,7 +128,7 @@ void Blitter_32bppBase::ScrollBuffer(voi
 
	uint32 *dst;
 

	
 
	if (scroll_y > 0) {
 
		/*Calculate pointers */
 
		/* Calculate pointers */
 
		dst = (uint32 *)video + left + (top + height - 1) * _screen.pitch;
 
		src = dst - scroll_y * _screen.pitch;
 

	
src/blitter/8bpp_base.cpp
Show inline comments
 
@@ -132,7 +132,7 @@ void Blitter_8bppBase::ScrollBuffer(void
 
	uint8 *dst;
 

	
 
	if (scroll_y > 0) {
 
		/*Calculate pointers */
 
		/* Calculate pointers */
 
		dst = (uint8 *)video + left + (top + height - 1) * _screen.pitch;
 
		src = dst - scroll_y * _screen.pitch;
 

	
src/cmd_helper.h
Show inline comments
 
@@ -21,7 +21,7 @@ template<> struct ExtractBits<RoadBits> 
 

	
 
template<typename T, uint N, typename U> static inline T Extract(U v)
 
{
 
	// Check if there are enough bits in v
 
	/* Check if there are enough bits in v */
 
	ExtractValid<N + ExtractBits<T>::Count <= sizeof(U) * 8>();
 
	return (T)GB(v, N, ExtractBits<T>::Count);
 
}
src/command.cpp
Show inline comments
 
@@ -201,140 +201,140 @@ DEF_COMMAND(CmdAutofillTimetable);
 
 * as the value from the CMD_* enums.
 
 */
 
static const Command _command_proc_table[] = {
 
	{CmdBuildRailroadTrack,   CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_RAILROAD_TRACK */
 
	{CmdRemoveRailroadTrack,                 CMD_AUTO}, /* CMD_REMOVE_RAILROAD_TRACK */
 
	{CmdBuildSingleRail,      CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_SINGLE_RAIL */
 
	{CmdRemoveSingleRail,                    CMD_AUTO}, /* CMD_REMOVE_SINGLE_RAIL */
 
	{CmdLandscapeClear,                             0}, /* CMD_LANDSCAPE_CLEAR */
 
	{CmdBuildBridge,                         CMD_AUTO}, /* CMD_BUILD_BRIDGE */
 
	{CmdBuildRailroadStation, CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_RAILROAD_STATION */
 
	{CmdBuildTrainDepot,      CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_TRAIN_DEPOT */
 
	{CmdBuildSingleSignal,                   CMD_AUTO}, /* CMD_BUILD_SIGNALS */
 
	{CmdRemoveSingleSignal,                  CMD_AUTO}, /* CMD_REMOVE_SIGNALS */
 
	{CmdTerraformLand,       CMD_ALL_TILES | CMD_AUTO}, /* CMD_TERRAFORM_LAND */
 
	{CmdPurchaseLandArea,     CMD_NO_WATER | CMD_AUTO}, /* CMD_PURCHASE_LAND_AREA */
 
	{CmdSellLandArea,                               0}, /* CMD_SELL_LAND_AREA */
 
	{CmdBuildTunnel,                         CMD_AUTO}, /* CMD_BUILD_TUNNEL */
 
	{CmdRemoveFromRailroadStation,                  0}, /* CMD_REMOVE_FROM_RAILROAD_STATION */
 
	{CmdConvertRail,                                0}, /* CMD_CONVERT_RAILD */
 
	{CmdBuildTrainWaypoint,                         0}, /* CMD_BUILD_TRAIN_WAYPOINT */
 
	{CmdRenameWaypoint,                             0}, /* CMD_RENAME_WAYPOINT */
 
	{CmdRemoveTrainWaypoint,                        0}, /* CMD_REMOVE_TRAIN_WAYPOINT */
 
	{CmdBuildRailroadTrack,   CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_RAILROAD_TRACK
 
	{CmdRemoveRailroadTrack,                 CMD_AUTO}, // CMD_REMOVE_RAILROAD_TRACK
 
	{CmdBuildSingleRail,      CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_SINGLE_RAIL
 
	{CmdRemoveSingleRail,                    CMD_AUTO}, // CMD_REMOVE_SINGLE_RAIL
 
	{CmdLandscapeClear,                             0}, // CMD_LANDSCAPE_CLEAR
 
	{CmdBuildBridge,                         CMD_AUTO}, // CMD_BUILD_BRIDGE
 
	{CmdBuildRailroadStation, CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_RAILROAD_STATION
 
	{CmdBuildTrainDepot,      CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_TRAIN_DEPOT
 
	{CmdBuildSingleSignal,                   CMD_AUTO}, // CMD_BUILD_SIGNALS
 
	{CmdRemoveSingleSignal,                  CMD_AUTO}, // CMD_REMOVE_SIGNALS
 
	{CmdTerraformLand,       CMD_ALL_TILES | CMD_AUTO}, // CMD_TERRAFORM_LAND
 
	{CmdPurchaseLandArea,     CMD_NO_WATER | CMD_AUTO}, // CMD_PURCHASE_LAND_AREA
 
	{CmdSellLandArea,                               0}, // CMD_SELL_LAND_AREA
 
	{CmdBuildTunnel,                         CMD_AUTO}, // CMD_BUILD_TUNNEL
 
	{CmdRemoveFromRailroadStation,                  0}, // CMD_REMOVE_FROM_RAILROAD_STATION
 
	{CmdConvertRail,                                0}, // CMD_CONVERT_RAILD
 
	{CmdBuildTrainWaypoint,                         0}, // CMD_BUILD_TRAIN_WAYPOINT
 
	{CmdRenameWaypoint,                             0}, // CMD_RENAME_WAYPOINT
 
	{CmdRemoveTrainWaypoint,                        0}, // CMD_REMOVE_TRAIN_WAYPOINT
 

	
 
	{CmdBuildRoadStop,        CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_ROAD_STOP */
 
	{CmdRemoveRoadStop,                             0}, /* CMD_REMOVE_ROAD_STOP */
 
	{CmdBuildLongRoad,        CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_LONG_ROAD */
 
	{CmdRemoveLongRoad,        CMD_NO_TEST | CMD_AUTO}, /* CMD_REMOVE_LONG_ROAD; towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed. */
 
	{CmdBuildRoad,                                  0}, /* CMD_BUILD_ROAD */
 
	{CmdRemoveRoad,                                 0}, /* CMD_REMOVE_ROAD */
 
	{CmdBuildRoadDepot,       CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_ROAD_DEPOT */
 
	{CmdBuildRoadStop,        CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_ROAD_STOP
 
	{CmdRemoveRoadStop,                             0}, // CMD_REMOVE_ROAD_STOP
 
	{CmdBuildLongRoad,        CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_LONG_ROAD
 
	{CmdRemoveLongRoad,        CMD_NO_TEST | CMD_AUTO}, // CMD_REMOVE_LONG_ROAD; towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed.
 
	{CmdBuildRoad,                                  0}, // CMD_BUILD_ROAD
 
	{CmdRemoveRoad,                                 0}, // CMD_REMOVE_ROAD
 
	{CmdBuildRoadDepot,       CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_ROAD_DEPOT
 

	
 
	{CmdBuildAirport,         CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_AIRPORT */
 
	{CmdBuildDock,                           CMD_AUTO}, /* CMD_BUILD_DOCK */
 
	{CmdBuildShipDepot,                      CMD_AUTO}, /* CMD_BUILD_SHIP_DEPOT */
 
	{CmdBuildBuoy,                           CMD_AUTO}, /* CMD_BUILD_BUOY */
 
	{CmdPlantTree,                           CMD_AUTO}, /* CMD_PLANT_TREE */
 
	{CmdBuildRailVehicle,                           0}, /* CMD_BUILD_RAIL_VEHICLE */
 
	{CmdMoveRailVehicle,                            0}, /* CMD_MOVE_RAIL_VEHICLE */
 
	{CmdBuildAirport,         CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_AIRPORT
 
	{CmdBuildDock,                           CMD_AUTO}, // CMD_BUILD_DOCK
 
	{CmdBuildShipDepot,                      CMD_AUTO}, // CMD_BUILD_SHIP_DEPOT
 
	{CmdBuildBuoy,                           CMD_AUTO}, // CMD_BUILD_BUOY
 
	{CmdPlantTree,                           CMD_AUTO}, // CMD_PLANT_TREE
 
	{CmdBuildRailVehicle,                           0}, // CMD_BUILD_RAIL_VEHICLE
 
	{CmdMoveRailVehicle,                            0}, // CMD_MOVE_RAIL_VEHICLE
 

	
 
	{CmdSellRailWagon,                              0}, /* CMD_SELL_RAIL_WAGON */
 
	{CmdSendTrainToDepot,                           0}, /* CMD_SEND_TRAIN_TO_DEPOT */
 
	{CmdForceTrainProceed,                          0}, /* CMD_FORCE_TRAIN_PROCEED */
 
	{CmdReverseTrainDirection,                      0}, /* CMD_REVERSE_TRAIN_DIRECTION */
 
	{CmdSellRailWagon,                              0}, // CMD_SELL_RAIL_WAGON
 
	{CmdSendTrainToDepot,                           0}, // CMD_SEND_TRAIN_TO_DEPOT
 
	{CmdForceTrainProceed,                          0}, // CMD_FORCE_TRAIN_PROCEED
 
	{CmdReverseTrainDirection,                      0}, // CMD_REVERSE_TRAIN_DIRECTION
 

	
 
	{CmdModifyOrder,                                0}, /* CMD_MODIFY_ORDER */
 
	{CmdSkipToOrder,                                0}, /* CMD_SKIP_TO_ORDER */
 
	{CmdDeleteOrder,                                0}, /* CMD_DELETE_ORDER */
 
	{CmdInsertOrder,                                0}, /* CMD_INSERT_ORDER */
 
	{CmdModifyOrder,                                0}, // CMD_MODIFY_ORDER
 
	{CmdSkipToOrder,                                0}, // CMD_SKIP_TO_ORDER
 
	{CmdDeleteOrder,                                0}, // CMD_DELETE_ORDER
 
	{CmdInsertOrder,                                0}, // CMD_INSERT_ORDER
 

	
 
	{CmdChangeServiceInt,                           0}, /* CMD_CHANGE_SERVICE_INT */
 
	{CmdChangeServiceInt,                           0}, // CMD_CHANGE_SERVICE_INT
 

	
 
	{CmdBuildIndustry,                              0}, /* CMD_BUILD_INDUSTRY */
 
	{CmdBuildCompanyHQ,       CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_COMPANY_HQ */
 
	{CmdSetCompanyManagerFace,                      0}, /* CMD_SET_COMPANY_MANAGER_FACE */
 
	{CmdSetCompanyColour,                           0}, /* CMD_SET_COMPANY_COLOUR */
 
	{CmdBuildIndustry,                              0}, // CMD_BUILD_INDUSTRY
 
	{CmdBuildCompanyHQ,       CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_COMPANY_HQ
 
	{CmdSetCompanyManagerFace,                      0}, // CMD_SET_COMPANY_MANAGER_FACE
 
	{CmdSetCompanyColour,                           0}, // CMD_SET_COMPANY_COLOUR
 

	
 
	{CmdIncreaseLoan,                               0}, /* CMD_INCREASE_LOAN */
 
	{CmdDecreaseLoan,                               0}, /* CMD_DECREASE_LOAN */
 
	{CmdIncreaseLoan,                               0}, // CMD_INCREASE_LOAN
 
	{CmdDecreaseLoan,                               0}, // CMD_DECREASE_LOAN
 

	
 
	{CmdWantEnginePreview,                          0}, /* CMD_WANT_ENGINE_PREVIEW */
 
	{CmdWantEnginePreview,                          0}, // CMD_WANT_ENGINE_PREVIEW
 

	
 
	{CmdRenameVehicle,                              0}, /* CMD_RENAME_VEHICLE */
 
	{CmdRenameEngine,                               0}, /* CMD_RENAME_ENGINE */
 
	{CmdRenameVehicle,                              0}, // CMD_RENAME_VEHICLE
 
	{CmdRenameEngine,                               0}, // CMD_RENAME_ENGINE
 

	
 
	{CmdRenameCompany,                              0}, /* CMD_RENAME_COMPANY */
 
	{CmdRenamePresident,                            0}, /* CMD_RENAME_PRESIDENT */
 
	{CmdRenameCompany,                              0}, // CMD_RENAME_COMPANY
 
	{CmdRenamePresident,                            0}, // CMD_RENAME_PRESIDENT
 

	
 
	{CmdRenameStation,                              0}, /* CMD_RENAME_STATION */
 
	{CmdRenameStation,                              0}, // CMD_RENAME_STATION
 

	
 
	{CmdSellAircraft,                               0}, /* CMD_SELL_AIRCRAFT */
 
	{CmdSellAircraft,                               0}, // CMD_SELL_AIRCRAFT
 

	
 
	{CmdBuildAircraft,                              0}, /* CMD_BUILD_AIRCRAFT */
 
	{CmdSendAircraftToHangar,                       0}, /* CMD_SEND_AIRCRAFT_TO_HANGAR */
 
	{CmdRefitAircraft,                              0}, /* CMD_REFIT_AIRCRAFT */
 
	{CmdBuildAircraft,                              0}, // CMD_BUILD_AIRCRAFT
 
	{CmdSendAircraftToHangar,                       0}, // CMD_SEND_AIRCRAFT_TO_HANGAR
 
	{CmdRefitAircraft,                              0}, // CMD_REFIT_AIRCRAFT
 

	
 
	{CmdPlaceSign,                                  0}, /* CMD_PLACE_SIGN */
 
	{CmdRenameSign,                                 0}, /* CMD_RENAME_SIGN */
 
	{CmdPlaceSign,                                  0}, // CMD_PLACE_SIGN
 
	{CmdRenameSign,                                 0}, // CMD_RENAME_SIGN
 

	
 
	{CmdBuildRoadVeh,                               0}, /* CMD_BUILD_ROAD_VEH */
 
	{CmdSellRoadVeh,                                0}, /* CMD_SELL_ROAD_VEH */
 
	{CmdSendRoadVehToDepot,                         0}, /* CMD_SEND_ROADVEH_TO_DEPOT */
 
	{CmdTurnRoadVeh,                                0}, /* CMD_TURN_ROADVEH */
 
	{CmdRefitRoadVeh,                               0}, /* CMD_REFIT_ROAD_VEH */
 
	{CmdBuildRoadVeh,                               0}, // CMD_BUILD_ROAD_VEH
 
	{CmdSellRoadVeh,                                0}, // CMD_SELL_ROAD_VEH
 
	{CmdSendRoadVehToDepot,                         0}, // CMD_SEND_ROADVEH_TO_DEPOT
 
	{CmdTurnRoadVeh,                                0}, // CMD_TURN_ROADVEH
 
	{CmdRefitRoadVeh,                               0}, // CMD_REFIT_ROAD_VEH
 

	
 
	{CmdPause,                             CMD_SERVER}, /* CMD_PAUSE */
 
	{CmdPause,                             CMD_SERVER}, // CMD_PAUSE
 

	
 
	{CmdBuyShareInCompany,                          0}, /* CMD_BUY_SHARE_IN_COMPANY */
 
	{CmdSellShareInCompany,                         0}, /* CMD_SELL_SHARE_IN_COMPANY */
 
	{CmdBuyCompany,                                 0}, /* CMD_BUY_COMANY */
 
	{CmdBuyShareInCompany,                          0}, // CMD_BUY_SHARE_IN_COMPANY
 
	{CmdSellShareInCompany,                         0}, // CMD_SELL_SHARE_IN_COMPANY
 
	{CmdBuyCompany,                                 0}, // CMD_BUY_COMANY
 

	
 
	{CmdBuildTown,                        CMD_OFFLINE}, /* CMD_BUILD_TOWN */
 
	{CmdRenameTown,                        CMD_SERVER}, /* CMD_RENAME_TOWN */
 
	{CmdDoTownAction,                               0}, /* CMD_DO_TOWN_ACTION */
 
	{CmdBuildTown,                        CMD_OFFLINE}, // CMD_BUILD_TOWN
 
	{CmdRenameTown,                        CMD_SERVER}, // CMD_RENAME_TOWN
 
	{CmdDoTownAction,                               0}, // CMD_DO_TOWN_ACTION
 

	
 
	{CmdSellShip,                                   0}, /* CMD_SELL_SHIP */
 
	{CmdBuildShip,                                  0}, /* CMD_BUILD_SHIP */
 
	{CmdSendShipToDepot,                            0}, /* CMD_SEND_SHIP_TO_DEPOT */
 
	{CmdRefitShip,                                  0}, /* CMD_REFIT_SHIP */
 
	{CmdSellShip,                                   0}, // CMD_SELL_SHIP
 
	{CmdBuildShip,                                  0}, // CMD_BUILD_SHIP
 
	{CmdSendShipToDepot,                            0}, // CMD_SEND_SHIP_TO_DEPOT
 
	{CmdRefitShip,                                  0}, // CMD_REFIT_SHIP
 

	
 
	{CmdOrderRefit,                                 0}, /* CMD_ORDER_REFIT */
 
	{CmdCloneOrder,                                 0}, /* CMD_CLONE_ORDER */
 
	{CmdOrderRefit,                                 0}, // CMD_ORDER_REFIT
 
	{CmdCloneOrder,                                 0}, // CMD_CLONE_ORDER
 

	
 
	{CmdClearArea,                        CMD_NO_TEST}, /* CMD_CLEAR_AREA; destroying multi-tile houses makes town rating differ between test and execution */
 
	{CmdClearArea,                        CMD_NO_TEST}, // CMD_CLEAR_AREA; destroying multi-tile houses makes town rating differ between test and execution
 

	
 
	{CmdMoneyCheat,                       CMD_OFFLINE}, /* CMD_MONEY_CHEAT */
 
	{CmdBuildCanal,                          CMD_AUTO}, /* CMD_BUILD_CANAL */
 
	{CmdCompanyCtrl,                    CMD_SPECTATOR}, /* CMD_COMPANY_CTRL */
 
	{CmdMoneyCheat,                       CMD_OFFLINE}, // CMD_MONEY_CHEAT
 
	{CmdBuildCanal,                          CMD_AUTO}, // CMD_BUILD_CANAL
 
	{CmdCompanyCtrl,                    CMD_SPECTATOR}, // CMD_COMPANY_CTRL
 

	
 
	{CmdLevelLand, CMD_ALL_TILES | CMD_NO_TEST | CMD_AUTO}, /* CMD_LEVEL_LAND; test run might clear tiles multiple times, in execution that only happens once */
 
	{CmdLevelLand, CMD_ALL_TILES | CMD_NO_TEST | CMD_AUTO}, // CMD_LEVEL_LAND; test run might clear tiles multiple times, in execution that only happens once
 

	
 
	{CmdRefitRailVehicle,                           0}, /* CMD_REFIT_RAIL_VEHICLE */
 
	{CmdRestoreOrderIndex,                          0}, /* CMD_RESTORE_ORDER_INDEX */
 
	{CmdBuildLock,                           CMD_AUTO}, /* CMD_BUILD_LOCK */
 
	{CmdRefitRailVehicle,                           0}, // CMD_REFIT_RAIL_VEHICLE
 
	{CmdRestoreOrderIndex,                          0}, // CMD_RESTORE_ORDER_INDEX
 
	{CmdBuildLock,                           CMD_AUTO}, // CMD_BUILD_LOCK
 

	
 
	{CmdBuildSignalTrack,                    CMD_AUTO}, /* CMD_BUILD_SIGNAL_TRACK */
 
	{CmdRemoveSignalTrack,                   CMD_AUTO}, /* CMD_REMOVE_SIGNAL_TRACK */
 
	{CmdBuildSignalTrack,                    CMD_AUTO}, // CMD_BUILD_SIGNAL_TRACK
 
	{CmdRemoveSignalTrack,                   CMD_AUTO}, // CMD_REMOVE_SIGNAL_TRACK
 

	
 
	{CmdGiveMoney,                                  0}, /* CMD_GIVE_MONEY */
 
	{CmdChangeSetting,                     CMD_SERVER}, /* CMD_CHANGE_SETTING */
 
	{CmdSetAutoReplace,                             0}, /* CMD_SET_AUTOREPLACE */
 
	{CmdCloneVehicle,                     CMD_NO_TEST}, /* CMD_CLONE_VEHICLE; NewGRF callbacks influence building and refitting making it impossible to correctly estimate the cost */
 
	{CmdStartStopVehicle,                           0}, /* CMD_START_STOP_VEHICLE */
 
	{CmdMassStartStopVehicle,                       0}, /* CMD_MASS_START_STOP */
 
	{CmdAutoreplaceVehicle,                         0}, /* CMD_AUTOREPLACE_VEHICLE */
 
	{CmdDepotSellAllVehicles,                       0}, /* CMD_DEPOT_SELL_ALL_VEHICLES */
 
	{CmdDepotMassAutoReplace,                       0}, /* CMD_DEPOT_MASS_AUTOREPLACE */
 
	{CmdCreateGroup,                                0}, /* CMD_CREATE_GROUP */
 
	{CmdDeleteGroup,                                0}, /* CMD_DELETE_GROUP */
 
	{CmdRenameGroup,                                0}, /* CMD_RENAME_GROUP */
 
	{CmdAddVehicleGroup,                            0}, /* CMD_ADD_VEHICLE_GROUP */
 
	{CmdAddSharedVehicleGroup,                      0}, /* CMD_ADD_SHARE_VEHICLE_GROUP */
 
	{CmdRemoveAllVehiclesGroup,                     0}, /* CMD_REMOVE_ALL_VEHICLES_GROUP */
 
	{CmdSetGroupReplaceProtection,                  0}, /* CMD_SET_GROUP_REPLACE_PROTECTION */
 
	{CmdMoveOrder,                                  0}, /* CMD_MOVE_ORDER */
 
	{CmdChangeTimetable,                            0}, /* CMD_CHANGE_TIMETABLE */
 
	{CmdSetVehicleOnTime,                           0}, /* CMD_SET_VEHICLE_ON_TIME */
 
	{CmdAutofillTimetable,                          0}, /* CMD_AUTOFILL_TIMETABLE */
 
	{CmdGiveMoney,                                  0}, // CMD_GIVE_MONEY
 
	{CmdChangeSetting,                     CMD_SERVER}, // CMD_CHANGE_SETTING
 
	{CmdSetAutoReplace,                             0}, // CMD_SET_AUTOREPLACE
 
	{CmdCloneVehicle,                     CMD_NO_TEST}, // CMD_CLONE_VEHICLE; NewGRF callbacks influence building and refitting making it impossible to correctly estimate the cost
 
	{CmdStartStopVehicle,                           0}, // CMD_START_STOP_VEHICLE
 
	{CmdMassStartStopVehicle,                       0}, // CMD_MASS_START_STOP
 
	{CmdAutoreplaceVehicle,                         0}, // CMD_AUTOREPLACE_VEHICLE
 
	{CmdDepotSellAllVehicles,                       0}, // CMD_DEPOT_SELL_ALL_VEHICLES
 
	{CmdDepotMassAutoReplace,                       0}, // CMD_DEPOT_MASS_AUTOREPLACE
 
	{CmdCreateGroup,                                0}, // CMD_CREATE_GROUP
 
	{CmdDeleteGroup,                                0}, // CMD_DELETE_GROUP
 
	{CmdRenameGroup,                                0}, // CMD_RENAME_GROUP
 
	{CmdAddVehicleGroup,                            0}, // CMD_ADD_VEHICLE_GROUP
 
	{CmdAddSharedVehicleGroup,                      0}, // CMD_ADD_SHARE_VEHICLE_GROUP
 
	{CmdRemoveAllVehiclesGroup,                     0}, // CMD_REMOVE_ALL_VEHICLES_GROUP
 
	{CmdSetGroupReplaceProtection,                  0}, // CMD_SET_GROUP_REPLACE_PROTECTION
 
	{CmdMoveOrder,                                  0}, // CMD_MOVE_ORDER
 
	{CmdChangeTimetable,                            0}, // CMD_CHANGE_TIMETABLE
 
	{CmdSetVehicleOnTime,                           0}, // CMD_SET_VEHICLE_ON_TIME
 
	{CmdAutofillTimetable,                          0}, // CMD_AUTOFILL_TIMETABLE
 
};
 

	
 
/*!
src/company_cmd.cpp
Show inline comments
 
@@ -129,7 +129,7 @@ bool IsValidCompanyManagerFace(CompanyMa
 
	for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
 
		switch (cmfv) {
 
			case CMFV_MOUSTACHE:   if (!has_moustache)   continue; break;
 
			case CMFV_LIPS:        /* FALL THROUGH */
 
			case CMFV_LIPS:        // FALL THROUGH
 
			case CMFV_NOSE:        if (has_moustache)    continue; break;
 
			case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
 
			case CMFV_GLASSES:     if (!has_glasses)     continue; break;
 
@@ -718,7 +718,7 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
	InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0);
 

	
 
	switch (p1) {
 
		case 0: { /* Create a new company */
 
		case 0: { // Create a new company
 
			/* This command is only executed in a multiplayer game */
 
			if (!_networking) return CMD_ERROR;
 

	
 
@@ -816,13 +816,13 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
#endif /* ENABLE_NETWORK */
 
		} break;
 

	
 
		case 1: /* Make a new AI company */
 
		case 1: // Make a new AI company
 
			if (!(flags & DC_EXEC)) return CommandCost();
 

	
 
			DoStartupNewCompany(true);
 
			break;
 

	
 
		case 2: { /* Delete a company */
 
		case 2: { // Delete a company
 
			Company *c;
 

	
 
			if (!IsValidCompanyID((CompanyID)p2)) return CMD_ERROR;
 
@@ -851,7 +851,7 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
			AI::BroadcastNewEvent(new AIEventCompanyBankrupt(c_index));
 
		} break;
 

	
 
		case 3: { /* Merge a company (#1) into another company (#2), elimination company #1 */
 
		case 3: { // Merge a company (#1) into another company (#2), elimination company #1
 
			CompanyID cid_old = (CompanyID)GB(p2,  0, 16);
 
			CompanyID cid_new = (CompanyID)GB(p2, 16, 16);
 

	
src/company_gui.cpp
Show inline comments
 
@@ -286,7 +286,7 @@ struct CompanyFinancesWindow : Window {
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case CFW_WIDGET_TOGGLE_SIZE: {/* toggle size */
 
			case CFW_WIDGET_TOGGLE_SIZE: {// toggle size
 
				bool new_mode = !this->small;
 
				bool stickied = !!(this->flags4 & WF_STICKY);
 
				int oldtop = this->top;   ///< current top position of the window before closing it
 
@@ -299,11 +299,11 @@ struct CompanyFinancesWindow : Window {
 
			}
 
			break;
 

	
 
			case CFW_WIDGET_INCREASE_LOAN: /* increase loan */
 
			case CFW_WIDGET_INCREASE_LOAN: // increase loan
 
				DoCommandP(0, 0, _ctrl_pressed, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
 
				break;
 

	
 
			case CFW_WIDGET_REPAY_LOAN: /* repay loan */
 
			case CFW_WIDGET_REPAY_LOAN: // repay loan
 
				DoCommandP(0, 0, _ctrl_pressed, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
 
				break;
 
		}
 
@@ -550,11 +550,11 @@ public:
 
				break;
 
			}
 

	
 
			case SCLW_WIDGET_PRI_COL_DROPDOWN: /* First colour dropdown */
 
			case SCLW_WIDGET_PRI_COL_DROPDOWN: // First colour dropdown
 
				ShowColourDropDownMenu(SCLW_WIDGET_PRI_COL_DROPDOWN);
 
				break;
 

	
 
			case SCLW_WIDGET_SEC_COL_DROPDOWN: /* Second colour dropdown */
 
			case SCLW_WIDGET_SEC_COL_DROPDOWN: // Second colour dropdown
 
				ShowColourDropDownMenu(SCLW_WIDGET_SEC_COL_DROPDOWN);
 
				break;
 

	
 
@@ -667,7 +667,7 @@ void DrawCompanyManagerFace(CompanyManag
 
	for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
 
		switch (cmfv) {
 
			case CMFV_MOUSTACHE:   if (!has_moustache)   continue; break;
 
			case CMFV_LIPS:        /* FALL THROUGH */
 
			case CMFV_LIPS:        // FALL THROUGH
 
			case CMFV_NOSE:        if (has_moustache)    continue; break;
 
			case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
 
			case CMFV_GLASSES:     if (!has_glasses)     continue; break;
 
@@ -1268,7 +1268,7 @@ struct CompanyWindow : Window
 
		this->SetWidgetHiddenState(CW_WIDGET_PRESIDENT_NAME, !local);
 
		this->SetWidgetHiddenState(CW_WIDGET_COMPANY_NAME,   !local);
 
		this->widget[CW_WIDGET_BUILD_VIEW_HQ].data = (local && c->location_of_HQ == INVALID_TILE) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
 
		if (local && c->location_of_HQ != INVALID_TILE) this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
 
		if (local && c->location_of_HQ != INVALID_TILE) this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // HQ is already built.
 
		this->SetWidgetDisabledState(CW_WIDGET_BUILD_VIEW_HQ, !local && c->location_of_HQ == INVALID_TILE);
 
		this->SetWidgetHiddenState(CW_WIDGET_RELOCATE_HQ,      !local || c->location_of_HQ == INVALID_TILE);
 
		this->SetWidgetHiddenState(CW_WIDGET_BUY_SHARE,        local);
src/company_manager_face.h
Show inline comments
 
@@ -57,8 +57,8 @@ struct CompanyManagerFaceBitsInfo {
 

	
 
/** Lookup table for indices into the CompanyManagerFace, valid ranges and sprites */
 
static const CompanyManagerFaceBitsInfo _cmf_info[] = {
 
	/* Index                   off len   WM  WF  BM  BF         WM     WF     BM     BF */
 
	/* CMFV_GENDER          */ {  0, 1, {  2,  2,  2,  2 }, {     0,     0,     0,     0 } }, ///< 0 = male, 1 = female
 
	/* Index                   off len   WM  WF  BM  BF         WM     WF     BM     BF
 
	 * CMFV_GENDER          */ {  0, 1, {  2,  2,  2,  2 }, {     0,     0,     0,     0 } }, ///< 0 = male, 1 = female
 
	/* CMFV_ETHNICITY       */ {  1, 2, {  2,  2,  2,  2 }, {     0,     0,     0,     0 } }, ///< 0 = (Western-)Caucasian, 1 = African(-American)/Black
 
	/* CMFV_GEN_ETHN        */ {  0, 3, {  4,  4,  4,  4 }, {     0,     0,     0,     0 } }, ///< Shortcut to get/set gender _and_ ethnicity
 
	/* CMFV_HAS_MOUSTACHE   */ {  3, 1, {  2,  0,  2,  0 }, {     0,     0,     0,     0 } }, ///< Females do not have a moustache
src/console.cpp
Show inline comments
 
@@ -691,7 +691,7 @@ void IConsoleVarExec(const IConsoleVar *
 
	if (_stdlib_con_developer)
 
		IConsolePrintF(CC_DEBUG, "condbg: requested command is a variable");
 

	
 
	if (tokencount == 0) { /* Just print out value */
 
	if (tokencount == 0) { // Just print out value
 
		IConsoleVarPrintGetValue(var);
 
		return;
 
	}
 
@@ -784,7 +784,7 @@ void IConsoleCmdExec(const char *cmdstr)
 
		if (t_index >= lengthof(tokens) || tstream_i >= lengthof(tokenstream)) break;
 

	
 
		switch (*cmdptr) {
 
		case ' ': /* Token seperator */
 
		case ' ': // Token seperator
 
			if (!foundtoken) break;
 

	
 
			if (longtoken) {
src/console_cmds.cpp
Show inline comments
 
@@ -37,18 +37,18 @@
 
	#include "table/strings.h"
 
#endif /* ENABLE_NETWORK */
 

	
 
// ** scriptfile handling ** //
 
/* scriptfile handling */
 
static FILE *_script_file;
 
static bool _script_running;
 

	
 
// ** console command / variable defines ** //
 
/* console command / variable defines */
 
#define DEF_CONSOLE_CMD(function) static bool function(byte argc, char *argv[])
 
#define DEF_CONSOLE_HOOK(function) static bool function()
 

	
 

	
 
/* **************************** */
 
/* variable and command hooks   */
 
/* **************************** */
 
/*****************************
 
 * variable and command hooks
 
 *****************************/
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
@@ -343,7 +343,7 @@ DEF_CONSOLE_CMD(ConPrintWorkingDirectory
 
		return true;
 
	}
 

	
 
	// XXX - Workaround for broken file handling
 
	/* XXX - Workaround for broken file handling */
 
	FiosGetSavegameList(SLD_LOAD_GAME);
 
	FiosFreeSavegameList();
 

	
 
@@ -365,9 +365,9 @@ DEF_CONSOLE_CMD(ConClearBuffer)
 
}
 

	
 

	
 
// ********************************* //
 
// * Network Core Console Commands * //
 
// ********************************* //
 
/**********************************
 
 * Network Core Console Commands
 
 **********************************/
 
#ifdef ENABLE_NETWORK
 

	
 
DEF_CONSOLE_CMD(ConBan)
 
@@ -798,9 +798,9 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
/* ******************************** */
 
/*   script file console commands   */
 
/* ******************************** */
 
/*********************************
 
 *  script file console commands
 
 *********************************/
 

	
 
DEF_CONSOLE_CMD(ConExec)
 
{
 
@@ -853,9 +853,9 @@ DEF_CONSOLE_CMD(ConReturn)
 
	return true;
 
}
 

	
 
/* **************************** */
 
/*   default console commands   */
 
/* **************************** */
 
/*****************************
 
 *  default console commands
 
 ******************************/
 
extern bool CloseConsoleLogIfActive();
 

	
 
DEF_CONSOLE_CMD(ConScript)
 
@@ -1678,9 +1678,9 @@ DEF_CONSOLE_CMD(ConGamelogPrint)
 
}
 

	
 
#ifdef _DEBUG
 
/* ****************************************** */
 
/*  debug commands and variables */
 
/* ****************************************** */
 
/*******************************************
 
 *  debug commands and variables
 
 ********************************************/
 

	
 
static void IConsoleDebugLibRegister()
 
{
 
@@ -1695,9 +1695,9 @@ static void IConsoleDebugLibRegister()
 
}
 
#endif
 

	
 
/* ****************************************** */
 
/*  console command and variable registration */
 
/* ****************************************** */
 
/*******************************************
 
 * console command and variable registration
 
 ********************************************/
 

	
 
void IConsoleStdLibRegister()
 
{
 
@@ -1846,7 +1846,7 @@ void IConsoleStdLibRegister()
 
	IConsoleAliasRegister("reload_cfg",            "setting reload_cfg %+");
 
#endif /* ENABLE_NETWORK */
 

	
 
	// debugging stuff
 
	/* debugging stuff */
 
#ifdef _DEBUG
 
	IConsoleDebugLibRegister();
 
#endif
src/currency.cpp
Show inline comments
 
@@ -10,10 +10,10 @@
 

	
 
#include "table/strings.h"
 

	
 
	//   exchange rate    prefix             symbol_pos
 
	//   |  separator        |     postfix   |
 
	//   |   |    Euro year  |       |       |    name
 
	//   |   |    |          |       |       |    |
 
	/*   exchange rate    prefix             symbol_pos
 
	 *   |  separator        |     postfix   |
 
	 *   |   |    Euro year  |       |       |    name
 
	 *   |   |    |          |       |       |    | */
 
static const CurrencySpec origin_currency_specs[NUM_CURRENCY] = {
 
	{    1, ',', CF_NOEURO, "£",    "",      0,  STR_CURR_GBP    }, ///< british pounds
 
	{    2, ',', CF_NOEURO, "$",    "",      0,  STR_CURR_USD    }, ///< us dollars
src/currency.h
Show inline comments
 
@@ -37,7 +37,7 @@ struct CurrencySpec {
 

	
 
extern CurrencySpec _currency_specs[NUM_CURRENCY];
 

	
 
// XXX small hack, but makes the rest of the code a bit nicer to read
 
/* XXX small hack, but makes the rest of the code a bit nicer to read */
 
#define _custom_currency (_currency_specs[CUSTOM_CURRENCY_ID])
 
#define _currency ((const CurrencySpec*)&_currency_specs[_game_mode == GM_MENU ? _settings_newgame.locale.currency : _settings_game.locale.currency])
 

	
src/depot_gui.cpp
Show inline comments
 
@@ -371,7 +371,7 @@ struct DepotWindow : Window {
 
			DrawTrainImage(v, x + 50, y, this->sel, this->hscroll.cap - 29, 0);
 
			DrawString(x, y + 2, STR_8816, TC_FROMSTRING);
 

	
 
			/*Draw the train counter */
 
			/* Draw the train counter */
 
			i = 0;
 
			u = v;
 
			do i++; while ((u = u->Next()) != NULL); // Determine length of train
src/direction_type.h
Show inline comments
 
@@ -35,7 +35,7 @@ DECLARE_POSTFIX_INCREMENT(Direction);
 

	
 
/** Define basic enum properties */
 
template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR> {};
 
typedef TinyEnumT<Direction> DirectionByte; //typedefing-enumification of Direction
 
typedef TinyEnumT<Direction> DirectionByte; // typedefing-enumification of Direction
 

	
 

	
 
/**
 
@@ -85,7 +85,7 @@ DECLARE_POSTFIX_INCREMENT(DiagDirection)
 

	
 
/** Define basic enum properties */
 
template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR> {};
 
typedef TinyEnumT<DiagDirection> DiagDirectionByte; //typedefing-enumification of DiagDirection
 
typedef TinyEnumT<DiagDirection> DiagDirectionByte; // typedefing-enumification of DiagDirection
 

	
 

	
 
/**
src/dummy_land.cpp
Show inline comments
 
@@ -75,18 +75,18 @@ static CommandCost TerraformTile_Dummy(T
 
}
 

	
 
extern const TileTypeProcs _tile_type_dummy_procs = {
 
	DrawTile_Dummy,           /* draw_tile_proc */
 
	GetSlopeZ_Dummy,          /* get_slope_z_proc */
 
	ClearTile_Dummy,          /* clear_tile_proc */
 
	GetAcceptedCargo_Dummy,   /* get_accepted_cargo_proc */
 
	GetTileDesc_Dummy,        /* get_tile_desc_proc */
 
	GetTileTrackStatus_Dummy, /* get_tile_track_status_proc */
 
	ClickTile_Dummy,          /* click_tile_proc */
 
	AnimateTile_Dummy,        /* animate_tile_proc */
 
	TileLoop_Dummy,           /* tile_loop_clear */
 
	ChangeTileOwner_Dummy,    /* change_tile_owner_clear */
 
	NULL,                     /* get_produced_cargo_proc */
 
	NULL,                     /* vehicle_enter_tile_proc */
 
	GetFoundation_Dummy,      /* get_foundation_proc */
 
	TerraformTile_Dummy,      /* terraform_tile_proc */
 
	DrawTile_Dummy,           // draw_tile_proc
 
	GetSlopeZ_Dummy,          // get_slope_z_proc
 
	ClearTile_Dummy,          // clear_tile_proc
 
	GetAcceptedCargo_Dummy,   // get_accepted_cargo_proc
 
	GetTileDesc_Dummy,        // get_tile_desc_proc
 
	GetTileTrackStatus_Dummy, // get_tile_track_status_proc
 
	ClickTile_Dummy,          // click_tile_proc
 
	AnimateTile_Dummy,        // animate_tile_proc
 
	TileLoop_Dummy,           // tile_loop_clear
 
	ChangeTileOwner_Dummy,    // change_tile_owner_clear
 
	NULL,                     // get_produced_cargo_proc
 
	NULL,                     // vehicle_enter_tile_proc
 
	GetFoundation_Dummy,      // get_foundation_proc
 
	TerraformTile_Dummy,      // terraform_tile_proc
 
};
src/economy.cpp
Show inline comments
 
@@ -332,7 +332,7 @@ void ChangeOwnershipOfCompanyItems(Owner
 
		if (new_owner != INVALID_OWNER) {
 
			if (HasBit(t->have_ratings, old_owner)) {
 
				if (HasBit(t->have_ratings, new_owner)) {
 
					// use max of the two ratings.
 
					/* use max of the two ratings. */
 
					t->ratings[new_owner] = max(t->ratings[new_owner], t->ratings[old_owner]);
 
				} else {
 
					SetBit(t->have_ratings, new_owner);
 
@@ -1889,8 +1889,8 @@ CommandCost CmdBuyShareInCompany(TileInd
 
{
 
	CommandCost cost(EXPENSES_OTHER);
 

	
 
	/* Check if buying shares is allowed (protection against modified clients) */
 
	/* Cannot buy own shares */
 
	/* Check if buying shares is allowed (protection against modified clients)
 
	 * Cannot buy own shares */
 
	if (!IsValidCompanyID((CompanyID)p1) || !_settings_game.economy.allow_shares || _current_company == (CompanyID)p1) return CMD_ERROR;
 

	
 
	Company *c = GetCompany((CompanyID)p1);
 
@@ -1909,7 +1909,7 @@ CommandCost CmdBuyShareInCompany(TileInd
 
		OwnerByte *b = c->share_owners;
 
		int i;
 

	
 
		while (*b != COMPANY_SPECTATOR) b++; /* share owners is guaranteed to contain at least one COMPANY_SPECTATOR */
 
		while (*b != COMPANY_SPECTATOR) b++; // share owners is guaranteed to contain at least one COMPANY_SPECTATOR
 
		*b = _current_company;
 

	
 
		for (i = 0; c->share_owners[i] == _current_company;) {
 
@@ -1932,8 +1932,8 @@ CommandCost CmdBuyShareInCompany(TileInd
 
 */
 
CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	/* Check if selling shares is allowed (protection against modified clients) */
 
	/* Cannot sell own shares */
 
	/* Check if selling shares is allowed (protection against modified clients)
 
	 * Cannot sell own shares */
 
	if (!IsValidCompanyID((CompanyID)p1) || !_settings_game.economy.allow_shares || _current_company == (CompanyID)p1) return CMD_ERROR;
 

	
 
	Company *c = GetCompany((CompanyID)p1);
src/elrail.cpp
Show inline comments
 
@@ -358,8 +358,8 @@ 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. */
 
		/* Level means that the slope is the same, or the track is flat */
 
		 * 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 (uint k = 0; k < NUM_IGNORE_GROUPS; k++) {
 
				if (PPPpreferred[i] == IgnoredPCP[k][tlg][i]) ClrBit(PCPstatus, i);
 
@@ -394,13 +394,13 @@ static void DrawCatenaryRailway(const Ti
 
					if (!HasBit(OwnedPPPonPCP[i], temp)) {
 
						/* We have a neighour that will draw it, bail out */
 
						if (trackconfig[TS_NEIGHBOUR] != TRACK_BIT_NONE) break;
 
						continue; /* No neighbour, go looking for a better position */
 
						continue; // No neighbour, go looking for a better position
 
					}
 

	
 
					AddSortableSpriteToDraw(pylon_base + pylon_sprites[temp], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE,
 
						elevation, IsTransparencySet(TO_CATENARY), -1, -1);
 

	
 
					break; /* We already have drawn a pylon, bail out */
 
					break; // We already have drawn a pylon, bail out
 
				}
 
			}
 
		}
 
@@ -425,9 +425,9 @@ static void DrawCatenaryRailway(const Ti
 
				(HasBit(PCPstatus, PCPpositions[t][1]) << 1);
 

	
 
			const SortableSpriteStruct *sss;
 
			int tileh_selector = !(tileh[TS_HOME] % 3) * tileh[TS_HOME] / 3; /* tileh for the slopes, 0 otherwise */
 
			int tileh_selector = !(tileh[TS_HOME] % 3) * tileh[TS_HOME] / 3; // tileh for the slopes, 0 otherwise
 

	
 
			assert(PCPconfig != 0); /* We have a pylon on neither end of the wire, that doesn't work (since we have no sprites for that) */
 
			assert(PCPconfig != 0); // We have a pylon on neither end of the wire, that doesn't work (since we have no sprites for that)
 
			assert(!IsSteepSlope(tileh[TS_HOME]));
 
			sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]];
 

	
 
@@ -478,8 +478,8 @@ void DrawCatenaryOnBridge(const TileInfo
 

	
 
	SpriteID pylon_base = GetPylonBase(start);
 

	
 
	/* Finished with wires, draw pylons */
 
	/* every other tile needs a pylon on the northern end */
 
	/* Finished with wires, draw pylons
 
	 * every other tile needs a pylon on the northern end */
 
	if (num % 2) {
 
		DiagDirection PCPpos = (axis == AXIS_X ? DIAGDIR_NE : DIAGDIR_NW);
 
		Direction PPPpos = (axis == AXIS_X ? DIR_NW : DIR_NE);
src/fileio.cpp
Show inline comments
 
@@ -485,8 +485,8 @@ static void TarAddLink(const std::string
 
		/* Link to file. Process the link like the destination file. */
 
		_tar_filelist.insert(TarFileList::value_type(src, dest_file->second));
 
	} else {
 
		/* Destination file not found. Assume 'link to directory' */
 
		/* Append PATHSEPCHAR to 'src' and 'dest' if needed */
 
		/* Destination file not found. Assume 'link to directory'
 
		 * Append PATHSEPCHAR to 'src' and 'dest' if needed */
 
		const std::string src_path = ((*src.rbegin() == PATHSEPCHAR) ? src : src + PATHSEPCHAR);
 
		const std::string dst_path = (dest.length() == 0 ? "" : ((*dest.rbegin() == PATHSEPCHAR) ? dest : dest + PATHSEPCHAR));
 
		_tar_linklist.insert(TarLinkList::value_type(src_path, dst_path));
src/fontcache.cpp
Show inline comments
 
@@ -38,7 +38,7 @@ enum {
 
 * If no appropiate font is found, the function returns an error */
 
#ifdef WIN32
 
#include <windows.h>
 
#include <shlobj.h> // SHGetFolderPath
 
#include <shlobj.h> /* SHGetFolderPath */
 
#include "win32.h"
 

	
 
/**
 
@@ -713,7 +713,7 @@ const Sprite *GetGlyph(FontSize size, WC
 
	sprite.width = width;
 
	sprite.height = height;
 
	sprite.x_offs = slot->bitmap_left;
 
	// XXX 2 should be determined somehow... it's right for the normal face
 
	/* XXX 2 should be determined somehow... it's right for the normal face */
 
	y_adj = (size == FS_NORMAL) ? 2 : 0;
 
	sprite.y_offs = GetCharacterHeight(size) - slot->bitmap_top - y_adj;
 

	
src/genworld.h
Show inline comments
 
@@ -20,10 +20,10 @@ enum {
 

	
 
/* Modes for GenerateWorld */
 
enum GenerateWorldMode {
 
	GW_NEWGAME   = 0,    /* Generate a map for a new game */
 
	GW_EMPTY     = 1,    /* Generate an empty map (sea-level) */
 
	GW_RANDOM    = 2,    /* Generate a random map for SE */
 
	GW_HEIGHTMAP = 3,    /* Generate a newgame from a heightmap */
 
	GW_NEWGAME   = 0,    ///< Generate a map for a new game
 
	GW_EMPTY     = 1,    ///< Generate an empty map (sea-level)
 
	GW_RANDOM    = 2,    ///< Generate a random map for SE
 
	GW_HEIGHTMAP = 3,    ///< Generate a newgame from a heightmap
 
};
 

	
 
typedef void gw_done_proc();
src/industry_cmd.cpp
Show inline comments
 
@@ -1720,11 +1720,11 @@ enum {
 

	
 
static const byte _numof_industry_table[NB_DIFFICULTY_LEVEL][NB_NUMOFINDUSTRY] = {
 
	/* difficulty settings for number of industries */
 
	{0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0},   //none
 
	{0, 1, 1, 1, 1, 1, 1, 1,  1,  1,  1},   //very low
 
	{0, 1, 1, 1, 2, 2, 3, 3,  4,  4,  5},   //low
 
	{0, 1, 2, 3, 4, 5, 6, 7,  8,  9, 10},   //normal
 
	{0, 2, 3, 4, 6, 7, 8, 9, 10, 10, 10},   //high
 
	{0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0},   // none
 
	{0, 1, 1, 1, 1, 1, 1, 1,  1,  1,  1},   // very low
 
	{0, 1, 1, 1, 2, 2, 3, 3,  4,  4,  5},   // low
 
	{0, 1, 2, 3, 4, 5, 6, 7,  8,  9, 10},   // normal
 
	{0, 2, 3, 4, 6, 7, 8, 9, 10, 10, 10},   // high
 
};
 

	
 
/** This function is the one who really do the creation work
 
@@ -1848,7 +1848,7 @@ struct ProbabilityHelper {
 
 */
 
static void MaybeNewIndustry(void)
 
{
 
	Industry *ind;               //will receive the industry's creation pointer
 
	Industry *ind;               // will receive the industry's creation pointer
 
	IndustryType rndtype, j;     // Loop controlers
 
	const IndustrySpec *ind_spc;
 
	uint num = 0;
 
@@ -2377,18 +2377,18 @@ static CommandCost TerraformTile_Industr
 
}
 

	
 
extern const TileTypeProcs _tile_type_industry_procs = {
 
	DrawTile_Industry,           /* draw_tile_proc */
 
	GetSlopeZ_Industry,          /* get_slope_z_proc */
 
	ClearTile_Industry,          /* clear_tile_proc */
 
	GetAcceptedCargo_Industry,   /* get_accepted_cargo_proc */
 
	GetTileDesc_Industry,        /* get_tile_desc_proc */
 
	GetTileTrackStatus_Industry, /* get_tile_track_status_proc */
 
	ClickTile_Industry,          /* click_tile_proc */
 
	AnimateTile_Industry,        /* animate_tile_proc */
 
	TileLoop_Industry,           /* tile_loop_proc */
 
	ChangeTileOwner_Industry,    /* change_tile_owner_proc */
 
	GetProducedCargo_Industry,   /* get_produced_cargo_proc */
 
	NULL,                        /* vehicle_enter_tile_proc */
 
	GetFoundation_Industry,      /* get_foundation_proc */
 
	TerraformTile_Industry,      /* terraform_tile_proc */
 
	DrawTile_Industry,           // draw_tile_proc
 
	GetSlopeZ_Industry,          // get_slope_z_proc
 
	ClearTile_Industry,          // clear_tile_proc
 
	GetAcceptedCargo_Industry,   // get_accepted_cargo_proc
 
	GetTileDesc_Industry,        // get_tile_desc_proc
 
	GetTileTrackStatus_Industry, // get_tile_track_status_proc
 
	ClickTile_Industry,          // click_tile_proc
 
	AnimateTile_Industry,        // animate_tile_proc
 
	TileLoop_Industry,           // tile_loop_proc
 
	ChangeTileOwner_Industry,    // change_tile_owner_proc
 
	GetProducedCargo_Industry,   // get_produced_cargo_proc
 
	NULL,                        // vehicle_enter_tile_proc
 
	GetFoundation_Industry,      // get_foundation_proc
 
	TerraformTile_Industry,      // terraform_tile_proc
 
};
src/industry_gui.cpp
Show inline comments
 
@@ -382,7 +382,7 @@ public:
 
		if (--this->callback_timer == 0) {
 
			/* We have just passed another day.
 
			 * See if we need to update availability of currently selected industry */
 
			this->callback_timer = DAY_TICKS;  //restart counter
 
			this->callback_timer = DAY_TICKS; // restart counter
 

	
 
			const IndustrySpec *indsp = GetIndustrySpec(this->selected_type);
 

	
src/landscape.cpp
Show inline comments
 
@@ -675,7 +675,7 @@ void RunTileLoop()
 
		if (TileX(tile) < MapSizeX() - TILELOOP_SIZE) {
 
			tile += TILELOOP_SIZE; // no overflow
 
		} else {
 
			tile = TILE_MASK(tile - TILELOOP_SIZE * (MapSizeX() / TILELOOP_SIZE - 1) + TileDiffXY(0, TILELOOP_SIZE)); /* x would overflow, also increase y */
 
			tile = TILE_MASK(tile - TILELOOP_SIZE * (MapSizeX() / TILELOOP_SIZE - 1) + TileDiffXY(0, TILELOOP_SIZE)); // x would overflow, also increase y
 
		}
 
	} while (--count != 0);
 
	assert((tile & ~TILELOOP_ASSERTMASK) == 0);
src/main_gui.cpp
Show inline comments
 
@@ -121,8 +121,8 @@ void ShowNetworkGiveMoneyWindow(CompanyI
 
#endif /* ENABLE_NETWORK */
 

	
 

	
 
/* Zooms a viewport in a window in or out */
 
/* No button handling or what so ever */
 
/* Zooms a viewport in a window in or out
 
 * No button handling or what so ever */
 
bool DoZoomInOutWindow(int how, Window *w)
 
{
 
	ViewPort *vp;
src/misc/binaryheap.hpp
Show inline comments
 
@@ -94,9 +94,9 @@ FORCEINLINE bool CBinaryHeapT<Titem_>::P
 
{
 
	if (IsFull()) return false;
 

	
 
	// make place for new item
 
	/* make place for new item */
 
	int gap = ++m_size;
 
	// Heapify up
 
	/* Heapify up */
 
	for (int parent = gap / 2; (parent > 0) && (new_item < *m_items[parent]); gap = parent, parent /= 2)
 
		m_items[gap] = m_items[parent];
 
	m_items[gap] = &new_item;
 
@@ -109,35 +109,35 @@ FORCEINLINE void CBinaryHeapT<Titem_>::R
 
{
 
	assert(!IsEmpty());
 

	
 
	// at index 1 we have a gap now
 
	/* at index 1 we have a gap now */
 
	int gap = 1;
 

	
 
	// Heapify down:
 
	//   last item becomes a candidate for the head. Call it new_item.
 
	/* Heapify down:
 
	 *   last item becomes a candidate for the head. Call it new_item. */
 
	Titem_& new_item = *m_items[m_size--];
 

	
 
	// now we must maintain relation between parent and its children:
 
	//   parent <= any child
 
	// from head down to the tail
 
	/* now we must maintain relation between parent and its children:
 
	 *   parent <= any child
 
	 * from head down to the tail */
 
	int child  = 2; // first child is at [parent * 2]
 

	
 
	// while children are valid
 
	/* while children are valid */
 
	while (child <= m_size) {
 
		// choose the smaller child
 
		/* choose the smaller child */
 
		if (child < m_size && *m_items[child + 1] < *m_items[child])
 
			child++;
 
		// is it smaller than our parent?
 
		/* is it smaller than our parent? */
 
		if (!(*m_items[child] < new_item)) {
 
			// the smaller child is still bigger or same as parent => we are done
 
			/* the smaller child is still bigger or same as parent => we are done */
 
			break;
 
		}
 
		// if smaller child is smaller than parent, it will become new parent
 
		/* if smaller child is smaller than parent, it will become new parent */
 
		m_items[gap] = m_items[child];
 
		gap = child;
 
		// where do we have our new children?
 
		/* where do we have our new children? */
 
		child = gap * 2;
 
	}
 
	// move last item to the proper place
 
	/* move last item to the proper place */
 
	if (m_size > 0) m_items[gap] = &new_item;
 
	CheckConsistency();
 
}
 
@@ -145,45 +145,45 @@ FORCEINLINE void CBinaryHeapT<Titem_>::R
 
template <class Titem_>
 
inline void CBinaryHeapT<Titem_>::RemoveByIdx(int idx)
 
{
 
	// at position idx we have a gap now
 
	/* at position idx we have a gap now */
 
	int gap = idx;
 
	Titem_& last = *m_items[m_size];
 
	if (idx < m_size) {
 
		assert(idx >= 1);
 
		m_size--;
 
		// and the candidate item for fixing this gap is our last item 'last'
 
		// Move gap / last item up:
 
		/* and the candidate item for fixing this gap is our last item 'last'
 
		 * Move gap / last item up: */
 
		while (gap > 1)
 
		{
 
			// compare [gap] with its parent
 
			/* compare [gap] with its parent */
 
			int parent = gap / 2;
 
			if (last < *m_items[parent]) {
 
				m_items[gap] = m_items[parent];
 
				gap = parent;
 
			} else {
 
				// we don't need to continue upstairs
 
				/* we don't need to continue upstairs */
 
				break;
 
			}
 
		}
 

	
 
		// Heapify (move gap) down:
 
		/* Heapify (move gap) down: */
 
		while (true) {
 
			// where we do have our children?
 
			/* where we do have our children? */
 
			int child  = gap * 2; // first child is at [parent * 2]
 
			if (child > m_size) break;
 
			// choose the smaller child
 
			/* choose the smaller child */
 
			if (child < m_size && *m_items[child + 1] < *m_items[child])
 
				child++;
 
			// is it smaller than our parent?
 
			/* is it smaller than our parent? */
 
			if (!(*m_items[child] < last)) {
 
				// the smaller child is still bigger or same as parent => we are done
 
				/* the smaller child is still bigger or same as parent => we are done */
 
				break;
 
			}
 
			// if smaller child is smaller than parent, it will become new parent
 
			/* if smaller child is smaller than parent, it will become new parent */
 
			m_items[gap] = m_items[child];
 
			gap = child;
 
		}
 
		// move parent to the proper place
 
		/* move parent to the proper place */
 
		if (m_size > 0) m_items[gap] = &last;
 
	}
 
	else {
 
@@ -208,7 +208,7 @@ inline int CBinaryHeapT<Titem_>::FindLin
 
template <class Titem_>
 
FORCEINLINE void CBinaryHeapT<Titem_>::CheckConsistency()
 
{
 
	// enable it if you suspect binary heap doesn't work well
 
	/* enable it if you suspect binary heap doesn't work well */
 
#if 0
 
	for (int child = 2; child <= m_size; child++) {
 
		int parent = child / 2;
src/misc/blob.hpp
Show inline comments
 
@@ -250,19 +250,19 @@ public:
 
	{
 
		bsize_t old_max_size = MaxRawSize();
 
		if (old_max_size >= new_size) return;
 
		// calculate minimum block size we need to allocate
 
		/* calculate minimum block size we need to allocate */
 
		bsize_t min_alloc_size = sizeof(CHdr) + new_size + Ttail_reserve;
 
		// ask allocation policy for some reasonable block size
 
		/* ask allocation policy for some reasonable block size */
 
		bsize_t alloc_size = AllocPolicy(min_alloc_size);
 
		// allocate new block
 
		/* allocate new block */
 
		CHdr *pNewHdr = RawAlloc(alloc_size);
 
		// setup header
 
		/* setup header */
 
		pNewHdr->m_size = RawSize();
 
		pNewHdr->m_max_size = alloc_size - (sizeof(CHdr) + Ttail_reserve);
 
		// copy existing data
 
		/* copy existing data */
 
		if (RawSize() > 0)
 
			memcpy(pNewHdr + 1, ptr_u.m_pData, pNewHdr->m_size);
 
		// replace our block with new one
 
		/* replace our block with new one */
 
		CHdr *pOldHdr = &Hdr();
 
		Init(pNewHdr);
 
		if (old_max_size > 0)
 
@@ -320,7 +320,7 @@ public:
 
 *  4. Dynamically constructs only used items (as opposite of static array which constructs all items) */
 
template <class Titem_, class Tbase_ = CBlobBaseSimple>
 
class CBlobT : public Tbase_ {
 
	// make template arguments public:
 
	/* make template arguments public: */
 
public:
 
	typedef Titem_ Titem;
 
	typedef Tbase_ Tbase;
 
@@ -418,7 +418,7 @@ public:
 
		assert((Tbase::RawSize() % Titem_size) == 0);
 
		bsize_t old_size = Size();
 
		if (old_size > 0) {
 
			// destroy removed items;
 
			/* destroy removed items; */
 
			Titem *pI_last_to_destroy = Data(0);
 
			for (Titem *pI = Data(old_size - 1); pI >= pI_last_to_destroy; pI--) pI->~Titem_();
 
		}
 
@@ -445,10 +445,10 @@ public:
 
		bsize_t old_size = Size();
 
		assert(num_items <= old_size);
 
		bsize_t new_size = (num_items <= old_size) ? (old_size - num_items) : 0;
 
		// destroy removed items;
 
		/* destroy removed items; */
 
		Titem *pI_last_to_destroy = Data(new_size);
 
		for (Titem *pI = Data(old_size - 1); pI >= pI_last_to_destroy; pI--) pI->~Titem();
 
		// remove them
 
		/* remove them */
 
		Tbase::ReduceRawSize(num_items * Titem_size);
 
	}
 

	
 
@@ -482,7 +482,7 @@ public:
 
	FORCEINLINE void RemoveBySwap(bsize_t idx)
 
	{
 
		CheckIdx(idx);
 
		// destroy removed item
 
		/* destroy removed item */
 
		Titem *pRemoved = Data(idx);
 
		RemoveBySwap(pRemoved);
 
	}
 
@@ -492,14 +492,14 @@ public:
 
	{
 
		Titem *pLast = Data(Size() - 1);
 
		assert(pItem >= Data() && pItem <= pLast);
 
		// move last item to its new place
 
		/* move last item to its new place */
 
		if (pItem != pLast) {
 
			pItem->~Titem_();
 
			new (pItem) Titem_(*pLast);
 
		}
 
		// destroy the last item
 
		/* destroy the last item */
 
		pLast->~Titem_();
 
		// and reduce the raw blob size
 
		/* and reduce the raw blob size */
 
		Tbase::ReduceRawSize(Titem_size);
 
	}
 

	
src/misc/countedptr.hpp
Show inline comments
 
@@ -86,7 +86,7 @@ public:
 
template <class Tcls_>
 
FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls *pT)
 
{
 
	// if they are the same, we do nothing
 
	/* if they are the same, we do nothing */
 
	if (pT != m_pT) {
 
		if (pT) pT->AddRef();        // AddRef new pointer if any
 
		Tcls *pTold = m_pT;          // save original ptr
src/misc/crc32.hpp
Show inline comments
 
@@ -5,7 +5,7 @@
 
#ifndef  CRC32_HPP
 
#define  CRC32_HPP
 

	
 
#if 0 // reenable when needed
 
#if 0 /* reenable when needed */
 
struct CCrc32
 
{
 
	static uint32 Calc(const void *pBuffer, int nCount)
 
@@ -62,6 +62,6 @@ struct CCrc32
 
		return Table;
 
	}
 
};
 
#endif // 0
 
#endif /* 0 */
 

	
 
#endif /* CRC32_HPP */
src/misc/dbg_helpers.cpp
Show inline comments
 
@@ -65,8 +65,8 @@ CStrA TileStr(TileIndex tile)
 
	return out.Transfer();
 
}
 

	
 
/** Keep track of the last assigned type_id. Used for anti-recursion. */
 
/*static*/ size_t& DumpTarget::LastTypeId()
 
/** Keep track of the last assigned type_id. Used for anti-recursion.
 
 *static*/ size_t& DumpTarget::LastTypeId()
 
{
 
	static size_t last_type_id = 0;
 
	return last_type_id;
 
@@ -77,7 +77,7 @@ CStrA DumpTarget::GetCurrentStructName()
 
{
 
	CStrA out;
 
	if (!m_cur_struct.empty()) {
 
		// we are inside some named struct, return its name
 
		/* we are inside some named struct, return its name */
 
		out = m_cur_struct.top();
 
	}
 
	return out.Transfer();
src/misc/fixedsizearray.hpp
Show inline comments
 
@@ -23,7 +23,7 @@ struct CFixedSizeArrayT {
 
		int    m_ref_cnt;   ///< block reference counter (used by copy constructor and by destructor)
 
	};
 

	
 
	// make types and constants visible from outside
 
	/* make types and constants visible from outside */
 
	typedef Titem_ Titem; // type of array item
 

	
 
	static const int Tcapacity = Tcapacity_;     // the array capacity (maximum size)
 
@@ -33,7 +33,7 @@ struct CFixedSizeArrayT {
 
	/** Default constructor. Preallocate space for items and header, then initialize header. */
 
	CFixedSizeArrayT()
 
	{
 
		// allocate block for header + items (don't construct items)
 
		/* allocate block for header + items (don't construct items) */
 
		m_items = (Titem*)((MallocT<int8>(ThdrSize + Tcapacity * sizeof(Titem))) + ThdrSize);
 
		SizeRef() = 0; // initial number of items
 
		RefCnt() = 1; // initial reference counter
 
@@ -42,7 +42,7 @@ struct CFixedSizeArrayT {
 
	/** Copy constructor. Preallocate space for items and header, then initialize header. */
 
	CFixedSizeArrayT(const CFixedSizeArrayT<Titem_, Tcapacity_>& src)
 
	{
 
		// share block (header + items) with the source array
 
		/* share block (header + items) with the source array */
 
		m_items = src.m_items;
 
		RefCnt()++; // now we share block with the source
 
	}
 
@@ -50,11 +50,11 @@ struct CFixedSizeArrayT {
 
	/** destroy remaining items and free the memory block */
 
	~CFixedSizeArrayT()
 
	{
 
		// release one reference to the shared block
 
		/* release one reference to the shared block */
 
		if ((--RefCnt()) > 0) return; // and return if there is still some owner
 

	
 
		Clear();
 
		// free the memory block occupied by items
 
		/* free the memory block occupied by items */
 
		free(((int8*)m_items) - ThdrSize);
 
		m_items = NULL;
 
	}
 
@@ -62,11 +62,11 @@ struct CFixedSizeArrayT {
 
	/** Clear (destroy) all items */
 
	FORCEINLINE void Clear()
 
	{
 
		// walk through all allocated items backward and destroy them
 
		/* walk through all allocated items backward and destroy them */
 
		for (Titem *pItem = &m_items[Size() - 1]; pItem >= m_items; pItem--) {
 
			pItem->~Titem_();
 
		}
 
		// number of items become zero
 
		/* number of items become zero */
 
		SizeRef() = 0;
 
	}
 

	
src/misc/hashtable.hpp
Show inline comments
 
@@ -22,7 +22,7 @@ struct CHashTableSlotT
 
	{
 
		for (const Titem_ *pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
 
			if (pItem->GetKey() == key) {
 
				// we have found the item, return it
 
				/* we have found the item, return it */
 
				return pItem;
 
			}
 
		}
 
@@ -34,7 +34,7 @@ struct CHashTableSlotT
 
	{
 
		for (Titem_ *pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
 
			if (pItem->GetKey() == key) {
 
				// we have found the item, return it
 
				/* we have found the item, return it */
 
				return pItem;
 
			}
 
		}
 
@@ -74,22 +74,22 @@ struct CHashTableSlotT
 
	/** hash table slot helper - remove and return item from a slot */
 
	FORCEINLINE Titem_ *Detach(const Key& key)
 
	{
 
		// do we have any items?
 
		/* do we have any items? */
 
		if (m_pFirst == NULL) {
 
			return NULL;
 
		}
 
		// is it our first item?
 
		/* is it our first item? */
 
		if (m_pFirst->GetKey() == key) {
 
			Titem_& ret_item = *m_pFirst;
 
			m_pFirst = m_pFirst->GetHashNext();
 
			ret_item.SetHashNext(NULL);
 
			return &ret_item;
 
		}
 
		// find it in the following items
 
		/* find it in the following items */
 
		Titem_ *pPrev = m_pFirst;
 
		for (Titem_ *pItem = m_pFirst->GetHashNext(); pItem != NULL; pPrev = pItem, pItem = pItem->GetHashNext()) {
 
			if (pItem->GetKey() == key) {
 
				// we have found the item, unlink and return it
 
				/* we have found the item, unlink and return it */
 
				pPrev->SetHashNext(pItem->GetHashNext());
 
				pItem->SetHashNext(NULL);
 
				return pItem;
 
@@ -137,10 +137,10 @@ protected:
 
	int   m_num_items; // item counter
 

	
 
public:
 
	// default constructor
 
	/* default constructor */
 
	FORCEINLINE CHashTableT()
 
	{
 
		// construct all slots
 
		/* construct all slots */
 
		m_slots = new Slot[Tcapacity];
 
		m_num_items = 0;
 
	}
src/misc/strapi.hpp
Show inline comments
 
@@ -30,13 +30,13 @@ public:
 
};
 

	
 
/** ::strlen wrapper specialization for char */
 
template <> /*static*/ inline size_t CStrApiBaseT<char>::StrLen(const char *s)
 
template <> /* static */ inline size_t CStrApiBaseT<char>::StrLen(const char *s)
 
{
 
	return ::strlen(s);
 
}
 

	
 
/** ::vsprintf wrapper specialization for char */
 
template <> /*static*/ inline int CStrApiBaseT<char>::SPrintFL(char *buf, size_t count, const char *fmt, va_list args)
 
template <> /* static */ inline int CStrApiBaseT<char>::SPrintFL(char *buf, size_t count, const char *fmt, va_list args)
 
{
 
#if defined(_MSC_VER) && !defined(WINCE)
 
	return ::vsnprintf_s(buf, count, count - 1, fmt, args);
 
@@ -47,13 +47,13 @@ template <> /*static*/ inline int CStrAp
 

	
 
#if defined(HAS_WCHAR)
 
/** ::strlen wrapper specialization for wchar_t */
 
template <> /*static*/ inline size_t CStrApiBaseT<wchar_t>::StrLen(const wchar_t *s)
 
template <> /* static */ inline size_t CStrApiBaseT<wchar_t>::StrLen(const wchar_t *s)
 
{
 
	return ::wcslen(s);
 
}
 

	
 
/** ::vsprintf wrapper specialization for wchar_t */
 
template <> /*static*/ inline int CStrApiBaseT<wchar_t>::SPrintFL(wchar_t *buf, size_t count, const wchar_t *fmt, va_list args)
 
template <> /* static */ inline int CStrApiBaseT<wchar_t>::SPrintFL(wchar_t *buf, size_t count, const wchar_t *fmt, va_list args)
 
{
 
#if defined(_MSC_VER) && !defined(WINCE)
 
	return ::_vsnwprintf_s(buf, count, count - 1, fmt, args);
 
@@ -76,23 +76,23 @@ public:
 
	static int StrCmp(const Tchar *s1, const Tchar *s2);
 
};
 

	
 
template <> /*static*/ inline int CStrApiT<char, false>::StrCmp(const char *s1, const char *s2)
 
template <> /* static */ inline int CStrApiT<char, false>::StrCmp(const char *s1, const char *s2)
 
{
 
	return ::strcmp(s1, s2);
 
}
 

	
 
template <> /*static*/ inline int CStrApiT<char, true>::StrCmp(const char *s1, const char *s2)
 
template <> /* static */ inline int CStrApiT<char, true>::StrCmp(const char *s1, const char *s2)
 
{
 
	return ::_stricmp(s1, s2);
 
}
 

	
 
#if defined(HAS_WCHAR)
 
template <> /*static*/ inline int CStrApiT<wchar_t, false>::StrCmp(const wchar_t *s1, const wchar_t *s2)
 
template <> /* static */ inline int CStrApiT<wchar_t, false>::StrCmp(const wchar_t *s1, const wchar_t *s2)
 
{
 
	return ::wcscmp(s1, s2);
 
}
 

	
 
template <> /*static*/ inline int CStrApiT<wchar_t, true>::StrCmp(const wchar_t *s1, const wchar_t *s2)
 
template <> /* static */ inline int CStrApiT<wchar_t, true>::StrCmp(const wchar_t *s1, const wchar_t *s2)
 
{
 
	return ::_wcsicmp(s1, s2);
 
}
src/music.h
Show inline comments
 
@@ -15,4 +15,4 @@ struct SongSpecs {
 

	
 
extern const SongSpecs _origin_songs_specs[];
 

	
 
#endif //MUSIC_H
 
#endif /* MUSIC_H */
src/music/bemidi.cpp
Show inline comments
 
@@ -6,7 +6,7 @@
 
#include "../openttd.h"
 
#include "bemidi.h"
 

	
 
// BeOS System Includes
 
/* BeOS System Includes */
 
#include <MidiSynthFile.h>
 

	
 
static BMidiSynthFile midiSynthFile;
src/music/qtmidi.cpp
Show inline comments
 
@@ -46,14 +46,14 @@
 
#include <unistd.h>
 
#include <fcntl.h>
 

	
 
// we need to include debug.h after CoreServices because defining DEBUG will break CoreServices in OSX 10.2
 
/* we need to include debug.h after CoreServices because defining DEBUG will break CoreServices in OSX 10.2 */
 
#include "../debug.h"
 

	
 
static FMusicDriver_QtMidi iFMusicDriver_QtMidi;
 

	
 

	
 
enum {
 
	midiType = 'Midi' /**< OSType code for MIDI songs. */
 
	midiType = 'Midi' ///< OSType code for MIDI songs.
 
};
 

	
 

	
 
@@ -172,15 +172,15 @@ static void InitQuickTimeIfNeeded()
 

	
 
/** Possible states of the QuickTime music driver. */
 
enum {
 
	QT_STATE_IDLE, /**< No file loaded. */
 
	QT_STATE_PLAY, /**< File loaded, playing. */
 
	QT_STATE_STOP, /**< File loaded, stopped. */
 
	QT_STATE_IDLE, ///< No file loaded.
 
	QT_STATE_PLAY, ///< File loaded, playing.
 
	QT_STATE_STOP, ///< File loaded, stopped.
 
};
 

	
 

	
 
static Movie _quicktime_movie;                  /**< Current QuickTime @c Movie. */
 
static byte  _quicktime_volume = 127;           /**< Current volume. */
 
static int   _quicktime_state  = QT_STATE_IDLE; /**< Current player state. */
 
static Movie _quicktime_movie;                  ///< Current QuickTime @c Movie.
 
static byte  _quicktime_volume = 127;           ///< Current volume.
 
static int   _quicktime_state  = QT_STATE_IDLE; ///< Current player state.
 

	
 

	
 
/**
src/music/win32_m.cpp
Show inline comments
 
@@ -109,7 +109,7 @@ static DWORD WINAPI MidiThread(LPVOID ar
 
			_midi.playing = MidiIntPlaySong(s);
 
			s[0] = '\0';
 

	
 
			// Delay somewhat in case we don't manage to play.
 
			/* Delay somewhat in case we don't manage to play. */
 
			if (!_midi.playing) WaitForMultipleObjects(1, &_midi.wait_obj, FALSE, 5000);
 
		}
 

	
src/music_gui.cpp
Show inline comments
 
@@ -495,13 +495,13 @@ public:
 
				_left_button_clicked = false;
 
			} break;
 

	
 
			case MW_SHUFFLE: //toggle shuffle
 
			case MW_SHUFFLE: // toggle shuffle
 
				msf.shuffle ^= 1;
 
				StopMusic();
 
				SelectSongToPlay();
 
				break;
 

	
 
			case MW_PROGRAMME: //show track selection
 
			case MW_PROGRAMME: // show track selection
 
				ShowMusicTrackSelection();
 
				break;
 

	
src/namegen.cpp
Show inline comments
 
@@ -22,8 +22,8 @@ static inline uint32 SeedModChance(int s
 
	 * SeedChance() and SeedModChance(). Do not get dicouraged by the
 
	 * never-use-modulo myths, which hold true only for the linear
 
	 * congruential generators (and Random() isn't such a generator).
 
	 * --pasky */
 
	// TODO: Perhaps we should use it for all the name generators? --pasky
 
	 * --pasky
 
	 * TODO: Perhaps we should use it for all the name generators? --pasky */
 
	return (seed >> shift_by) % max;
 
}
 

	
 
@@ -361,8 +361,8 @@ static byte MakePolishTownName(char *buf
 

	
 
static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
 
{
 
	/* Probability of prefixes/suffixes */
 
	/* 0..11 prefix, 12..13 prefix+suffix, 14..17 suffix, 18..31 nothing */
 
	/* Probability of prefixes/suffixes
 
	 * 0..11 prefix, 12..13 prefix+suffix, 14..17 suffix, 18..31 nothing */
 
	int prob_tails;
 
	bool do_prefix, do_suffix, dynamic_subst;
 
	/* IDs of the respective parts */
src/network/core/core.cpp
Show inline comments
 
@@ -52,8 +52,8 @@ bool NetworkCoreInitialize()
 
			}
 
		}
 
	}
 
#endif // __AMIGA__
 
#endif // __MORPHOS__ / __AMIGA__
 
#endif /* __AMIGA__ */
 
#endif /* __MORPHOS__ / __AMIGA__ */
 

	
 
/* Let's load the network in windows */
 
#ifdef WIN32
src/network/core/host.cpp
Show inline comments
 
@@ -200,7 +200,7 @@ void NetworkFindBroadcastIPs(uint32 *bro
 
	/* Now display to the debug all the detected ips */
 
	DEBUG(net, 3, "Detected broadcast addresses:");
 
	for (int i = 0; broadcast[i] != 0; i++) {
 
		DEBUG(net, 3, "%d) %s", i, inet_ntoa(*(struct in_addr *)&broadcast[i])); //inet_ntoa(inaddr));
 
		DEBUG(net, 3, "%d) %s", i, inet_ntoa(*(struct in_addr *)&broadcast[i])); // inet_ntoa(inaddr));
 
	}
 
}
 

	
src/network/core/os_abstraction.h
Show inline comments
 
@@ -50,7 +50,7 @@ typedef unsigned long in_addr_t;
 
#	include <sys/ioctl.h>
 
#	if defined(__BEOS__) && defined(BEOS_NET_SERVER)
 
#		include <be/net/socket.h>
 
#		include <be/kernel/OS.h> // snooze()
 
#		include <be/kernel/OS.h> /* snooze() */
 
#		include <be/net/netdb.h>
 
		typedef unsigned long in_addr_t;
 
#		define INADDR_NONE INADDR_BROADCAST
 
@@ -85,7 +85,7 @@ typedef unsigned long in_addr_t;
 
#	include <errno.h>
 
#	include <sys/time.h>
 
#	include <netdb.h>
 
#endif // UNIX
 
#endif /* UNIX */
 

	
 
#ifdef __BEOS__
 
	typedef int socklen_t;
 
@@ -146,13 +146,13 @@ typedef unsigned long in_addr_t;
 
/* MorphOS and Amiga stuff */
 
#if defined(__MORPHOS__) || defined(__AMIGA__)
 
#	include <exec/types.h>
 
#	include <proto/exec.h>   // required for Open/CloseLibrary()
 
#	include <proto/exec.h>   /* required for Open/CloseLibrary() */
 
	/* MorphOS defines his network functions with UBYTE arrays while we
 
	 *  use char arrays. This gives tons of unneeded warnings */
 
#	define UBYTE char
 
#	if defined(__MORPHOS__)
 
#		include <sys/filio.h>  // FIO* defines
 
#		include <sys/sockio.h> // SIO* defines
 
#		include <sys/filio.h>  /* FIO* defines */
 
#		include <sys/sockio.h> /* SIO* defines */
 
#		include <netinet/in.h>
 
#	else /* __AMIGA__ */
 
#		include	<proto/socket.h>
 
@@ -174,7 +174,7 @@ typedef unsigned long in_addr_t;
 
	extern struct MsgPort     *TimerPort;
 
	extern struct timerequest *TimerRequest;
 
#	endif
 
#endif // __MORPHOS__ || __AMIGA__
 
#endif /* __MORPHOS__ || __AMIGA__ */
 

	
 
static inline bool SetNonBlocking(SOCKET d)
 
{
 
@@ -193,7 +193,7 @@ static inline bool SetNonBlocking(SOCKET
 
static inline bool SetNoDelay(SOCKET d)
 
{
 
	/* XXX should this be done at all? */
 
#if !defined(BEOS_NET_SERVER) // not implemented on BeOS net_server
 
#if !defined(BEOS_NET_SERVER) /* not implemented on BeOS net_server */
 
	int b = 1;
 
	/* The (const char*) cast is needed for windows */
 
	return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, (const char*)&b, sizeof(b)) == 0;
src/network/core/udp.cpp
Show inline comments
 
@@ -50,7 +50,7 @@ bool NetworkUDPSocketHandler::Listen(con
 
	if (broadcast) {
 
		/* Enable broadcast */
 
		unsigned long val = 1;
 
#ifndef BEOS_NET_SERVER // will work around this, some day; maybe.
 
#ifndef BEOS_NET_SERVER /* will work around this, some day; maybe. */
 
		setsockopt(this->sock, SOL_SOCKET, SO_BROADCAST, (char *) &val , sizeof(val));
 
#endif
 
	}
 
@@ -233,7 +233,7 @@ void NetworkUDPSocketHandler::Recv_Netwo
 
				*dst = c;
 
				dst = &c->next;
 
			}
 
		} /* Fallthrough */
 
		} // Fallthrough
 
		case 3:
 
			info->game_date      = Clamp(p->Recv_uint32(), 0, MAX_DATE);
 
			info->start_date     = Clamp(p->Recv_uint32(), 0, MAX_DATE);
src/network/network.cpp
Show inline comments
 
@@ -79,12 +79,12 @@ extern NetworkUDPSocketHandler *_udp_cli
 
extern NetworkUDPSocketHandler *_udp_server_socket; ///< udp server socket
 
extern NetworkUDPSocketHandler *_udp_master_socket; ///< udp master socket
 

	
 
// The listen socket for the server
 
/* The listen socket for the server */
 
static SOCKET _listensocket;
 

	
 
// The amount of clients connected
 
/* The amount of clients connected */
 
static byte _network_clients_connected = 0;
 
// The identifier counter for new clients (is never decreased)
 
/* The identifier counter for new clients (is never decreased) */
 
static ClientID _network_client_id = CLIENT_ID_FIRST;
 

	
 
/* Some externs / forwards */
 
@@ -149,8 +149,8 @@ NetworkClientSocket *NetworkFindClientSt
 
	return NULL;
 
}
 

	
 
// NetworkGetClientName is a server-safe function to get the name of the client
 
//  if the user did not send it yet, Client #<no> is used.
 
/* NetworkGetClientName is a server-safe function to get the name of the client
 
 *  if the user did not send it yet, Client #<no> is used. */
 
void NetworkGetClientName(char *client_name, size_t size, const NetworkClientSocket *cs)
 
{
 
	const NetworkClientInfo *ci = cs->GetInfo();
 
@@ -187,9 +187,9 @@ bool NetworkCompanyIsPassworded(CompanyI
 
	return HasBit(_network_company_passworded, company_id);
 
}
 

	
 
// This puts a text-message to the console, or in the future, the chat-box,
 
//  (to keep it all a bit more general)
 
// If 'self_send' is true, this is the client who is sending the message
 
/* This puts a text-message to the console, or in the future, the chat-box,
 
 *  (to keep it all a bit more general)
 
 * If 'self_send' is true, this is the client who is sending the message */
 
void NetworkTextMessage(NetworkAction action, ConsoleColour colour, bool self_send, const char *name, const char *str, int64 data)
 
{
 
	const int duration = 10; // Game days the messages stay visible
 
@@ -236,13 +236,13 @@ void NetworkTextMessage(NetworkAction ac
 
	NetworkAddChatMessage((TextColour)colour, duration, "%s", message);
 
}
 

	
 
// Calculate the frame-lag of a client
 
/* Calculate the frame-lag of a client */
 
uint NetworkCalculateLag(const NetworkClientSocket *cs)
 
{
 
	int lag = cs->last_frame_server - cs->last_frame;
 
	// This client has missed his ACK packet after 1 DAY_TICKS..
 
	//  so we increase his lag for every frame that passes!
 
	// The packet can be out by a max of _net_frame_freq
 
	/* This client has missed his ACK packet after 1 DAY_TICKS..
 
	 *  so we increase his lag for every frame that passes!
 
	 * The packet can be out by a max of _net_frame_freq */
 
	if (cs->last_frame_server + DAY_TICKS + _settings_client.network.frame_freq < _frame_counter)
 
		lag += _frame_counter - (cs->last_frame_server + DAY_TICKS + _settings_client.network.frame_freq);
 

	
 
@@ -250,8 +250,8 @@ uint NetworkCalculateLag(const NetworkCl
 
}
 

	
 

	
 
// There was a non-recoverable error, drop back to the main menu with a nice
 
//  error
 
/* There was a non-recoverable error, drop back to the main menu with a nice
 
 *  error */
 
static void NetworkError(StringID error_string)
 
{
 
	_switch_mode = SM_MENU;
 
@@ -267,11 +267,11 @@ static void ServerStartError(const char 
 

	
 
static void NetworkClientError(NetworkRecvStatus res, NetworkClientSocket *cs)
 
{
 
	// First, send a CLIENT_ERROR to the server, so he knows we are
 
	//  disconnection (and why!)
 
	/* First, send a CLIENT_ERROR to the server, so he knows we are
 
	 *  disconnection (and why!) */
 
	NetworkErrorCode errorno;
 

	
 
	// We just want to close the connection..
 
	/* We just want to close the connection.. */
 
	if (res == NETWORK_RECV_STATUS_CLOSE_QUERY) {
 
		cs->has_quit = true;
 
		NetworkCloseClient(cs);
 
@@ -287,7 +287,7 @@ static void NetworkClientError(NetworkRe
 
		case NETWORK_RECV_STATUS_NEWGRF_MISMATCH: errorno = NETWORK_ERROR_NEWGRF_MISMATCH; break;
 
		default:                                  errorno = NETWORK_ERROR_GENERAL; break;
 
	}
 
	// This means we fucked up and the server closed the connection
 
	/* This means we fucked up and the server closed the connection */
 
	if (res != NETWORK_RECV_STATUS_SERVER_ERROR && res != NETWORK_RECV_STATUS_SERVER_FULL &&
 
			res != NETWORK_RECV_STATUS_SERVER_BANNED) {
 
		SEND_COMMAND(PACKET_CLIENT_ERROR)(errorno);
 
@@ -388,16 +388,16 @@ void ParseConnectionString(const char **
 
	}
 
}
 

	
 
// Creates a new client from a socket
 
//   Used both by the server and the client
 
/* Creates a new client from a socket
 
 *   Used both by the server and the client */
 
static NetworkClientSocket *NetworkAllocClient(SOCKET s)
 
{
 
	if (_network_server) {
 
		// Can we handle a new client?
 
		/* Can we handle a new client? */
 
		if (_network_clients_connected >= MAX_CLIENTS) return NULL;
 
		if (_network_game_info.clients_on >= _settings_client.network.max_clients) return NULL;
 

	
 
		// Register the login
 
		/* Register the login */
 
		_network_clients_connected++;
 
	}
 

	
 
@@ -419,7 +419,7 @@ static NetworkClientSocket *NetworkAlloc
 
	return cs;
 
}
 

	
 
// Close a connection
 
/* Close a connection */
 
void NetworkCloseClient(NetworkClientSocket *cs)
 
{
 
	/*
 
@@ -434,7 +434,7 @@ void NetworkCloseClient(NetworkClientSoc
 
	DEBUG(net, 1, "Closed client connection %d", cs->client_id);
 

	
 
	if (!cs->has_quit && _network_server && cs->status > STATUS_INACTIVE) {
 
		// We did not receive a leave message from this client...
 
		/* We did not receive a leave message from this client... */
 
		char client_name[NETWORK_CLIENT_NAME_LENGTH];
 
		NetworkClientSocket *new_cs;
 

	
 
@@ -442,7 +442,7 @@ void NetworkCloseClient(NetworkClientSoc
 

	
 
		NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, NULL, STR_NETWORK_ERR_CLIENT_CONNECTION_LOST);
 

	
 
		// Inform other clients of this... strange leaving ;)
 
		/* Inform other clients of this... strange leaving ;) */
 
		FOR_ALL_CLIENT_SOCKETS(new_cs) {
 
			if (new_cs->status > STATUS_AUTH && cs != new_cs) {
 
				SEND_COMMAND(PACKET_SERVER_ERROR_QUIT)(new_cs, cs->client_id, NETWORK_ERROR_CONNECTION_LOST);
 
@@ -457,7 +457,7 @@ void NetworkCloseClient(NetworkClientSoc
 
	}
 

	
 
	if (_network_server) {
 
		// We just lost one client :(
 
		/* We just lost one client :( */
 
		if (cs->status >= STATUS_AUTH) _network_game_info.clients_on--;
 
		_network_clients_connected--;
 

	
 
@@ -470,7 +470,7 @@ void NetworkCloseClient(NetworkClientSoc
 
	CheckMinActiveClients();
 
}
 

	
 
// For the server, to accept new clients
 
/* For the server, to accept new clients */
 
static void NetworkAcceptClients()
 
{
 
	struct sockaddr_in sin;
 
@@ -478,7 +478,7 @@ static void NetworkAcceptClients()
 
	uint i;
 
	bool banned;
 

	
 
	// Should never ever happen.. is it possible??
 
	/* Should never ever happen.. is it possible?? */
 
	assert(_listensocket != INVALID_SOCKET);
 

	
 
	for (;;) {
 
@@ -534,8 +534,8 @@ static void NetworkAcceptClients()
 

	
 
		cs = NetworkAllocClient(s);
 
		if (cs == NULL) {
 
			// no more clients allowed?
 
			// Send to the client that we are full!
 
			/* no more clients allowed?
 
			 * Send to the client that we are full! */
 
			Packet p(PACKET_SERVER_FULL);
 
			p.PrepareToSend();
 

	
 
@@ -545,16 +545,16 @@ static void NetworkAcceptClients()
 
			continue;
 
		}
 

	
 
		// a new client has connected. We set him at inactive for now
 
		//  maybe he is only requesting server-info. Till he has sent a PACKET_CLIENT_MAP_OK
 
		//  the client stays inactive
 
		/* a new client has connected. We set him at inactive for now
 
		 *  maybe he is only requesting server-info. Till he has sent a PACKET_CLIENT_MAP_OK
 
		 *  the client stays inactive */
 
		cs->status = STATUS_INACTIVE;
 

	
 
		cs->GetInfo()->client_ip = sin.sin_addr.s_addr; // Save the IP of the client
 
	}
 
}
 

	
 
// Set up the listen socket for the server
 
/* Set up the listen socket for the server */
 
static bool NetworkListen()
 
{
 
	SOCKET ls;
 
@@ -570,7 +570,7 @@ static bool NetworkListen()
 

	
 
	{ // reuse the socket
 
		int reuse = 1;
 
		// The (const char*) cast is needed for windows!!
 
		/* The (const char*) cast is needed for windows!! */
 
		if (setsockopt(ls, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse, sizeof(reuse)) == -1) {
 
			ServerStartError("setsockopt() on listen socket failed");
 
			return false;
 
@@ -607,7 +607,7 @@ static void InitializeNetworkPools()
 
	_NetworkClientInfo_pool.AddBlockToPool();
 
}
 

	
 
// Close all current connections
 
/* Close all current connections */
 
static void NetworkClose()
 
{
 
	NetworkClientSocket *cs;
 
@@ -641,7 +641,7 @@ static void NetworkClose()
 
	InitializeNetworkPools();
 
}
 

	
 
// Inits the network (cleans sockets and stuff)
 
/* Inits the network (cleans sockets and stuff) */
 
static void NetworkInitialize()
 
{
 
	InitializeNetworkPools();
 
@@ -670,9 +670,9 @@ public:
 
	}
 
};
 

	
 
// Query a server to fetch his game-info
 
//  If game_info is true, only the gameinfo is fetched,
 
//   else only the client_info is fetched
 
/* Query a server to fetch his game-info
 
 *  If game_info is true, only the gameinfo is fetched,
 
 *   else only the client_info is fetched */
 
void NetworkTCPQueryServer(NetworkAddress address)
 
{
 
	if (!_network_available) return;
 
@@ -747,7 +747,7 @@ public:
 
};
 

	
 

	
 
// Used by clients, to connect to a server
 
/* Used by clients, to connect to a server */
 
void NetworkClientConnectGame(NetworkAddress address)
 
{
 
	if (!_network_available) return;
 
@@ -794,7 +794,7 @@ bool NetworkServerStart()
 
	NetworkInitialize();
 
	if (!NetworkListen()) return false;
 

	
 
	// Try to start UDP-server
 
	/* Try to start UDP-server */
 
	_network_udp_server = true;
 
	_network_udp_server = _udp_server_socket->Listen(_network_server_bind_ip, _settings_client.network.server_port, false);
 

	
 
@@ -814,9 +814,9 @@ bool NetworkServerStart()
 

	
 
	NetworkInitGameInfo();
 

	
 
	// execute server initialization script
 
	/* execute server initialization script */
 
	IConsoleCmdExec("exec scripts/on_server.scr 0");
 
	// if the server is dedicated ... add some other script
 
	/* if the server is dedicated ... add some other script */
 
	if (_network_dedicated) IConsoleCmdExec("exec scripts/on_dedicated.scr 0");
 

	
 
	_min_active_clients_paused = false;
 
@@ -829,8 +829,8 @@ bool NetworkServerStart()
 
	return true;
 
}
 

	
 
// The server is rebooting...
 
// The only difference with NetworkDisconnect, is the packets that is sent
 
/* The server is rebooting...
 
 * The only difference with NetworkDisconnect, is the packets that is sent */
 
void NetworkReboot()
 
{
 
	if (_network_server) {
 
@@ -844,7 +844,7 @@ void NetworkReboot()
 
	NetworkClose();
 
}
 

	
 
// We want to disconnect from the host/clients
 
/* We want to disconnect from the host/clients */
 
void NetworkDisconnect()
 
{
 
	if (_network_server) {
 
@@ -862,7 +862,7 @@ void NetworkDisconnect()
 
	NetworkClose();
 
}
 

	
 
// Receives something from the network
 
/* Receives something from the network */
 
static bool NetworkReceive()
 
{
 
	NetworkClientSocket *cs;
 
@@ -878,7 +878,7 @@ static bool NetworkReceive()
 
		FD_SET(cs->sock, &write_fd);
 
	}
 

	
 
	// take care of listener port
 
	/* take care of listener port */
 
	if (_network_server) FD_SET(_listensocket, &read_fd);
 

	
 
	tv.tv_sec = tv.tv_usec = 0; // don't block at all.
 
@@ -889,10 +889,10 @@ static bool NetworkReceive()
 
#endif
 
	if (n == -1 && !_network_server) NetworkError(STR_NETWORK_ERR_LOSTCONNECTION);
 

	
 
	// accept clients..
 
	/* accept clients.. */
 
	if (_network_server && FD_ISSET(_listensocket, &read_fd)) NetworkAcceptClients();
 

	
 
	// read stuff from clients
 
	/* read stuff from clients */
 
	FOR_ALL_CLIENT_SOCKETS(cs) {
 
		cs->writable = !!FD_ISSET(cs->sock, &write_fd);
 
		if (FD_ISSET(cs->sock, &read_fd)) {
 
@@ -901,13 +901,13 @@ static bool NetworkReceive()
 
			} else {
 
				NetworkRecvStatus res;
 

	
 
				// The client already was quiting!
 
				/* The client already was quiting! */
 
				if (cs->has_quit) return false;
 

	
 
				res = NetworkClient_ReadPackets(cs);
 
				if (res != NETWORK_RECV_STATUS_OKAY) {
 
					// The client made an error of which we can not recover
 
					//   close the client and drop back to main menu
 
					/* The client made an error of which we can not recover
 
					 *   close the client and drop back to main menu */
 
					NetworkClientError(res, cs);
 
					return false;
 
				}
 
@@ -917,7 +917,7 @@ static bool NetworkReceive()
 
	return true;
 
}
 

	
 
// This sends all buffered commands (if possible)
 
/* This sends all buffered commands (if possible) */
 
static void NetworkSend()
 
{
 
	NetworkClientSocket *cs;
 
@@ -926,7 +926,7 @@ static void NetworkSend()
 
			cs->Send_Packets();
 

	
 
			if (cs->status == STATUS_MAP) {
 
				// This client is in the middle of a map-send, call the function for that
 
				/* This client is in the middle of a map-send, call the function for that */
 
				SEND_COMMAND(PACKET_SERVER_MAP)(cs);
 
			}
 
		}
 
@@ -941,7 +941,7 @@ static bool NetworkDoClientLoop()
 

	
 
	StateGameLoop();
 

	
 
	// Check if we are in sync!
 
	/* Check if we are in sync! */
 
	if (_sync_frame != 0) {
 
		if (_sync_frame == _frame_counter) {
 
#ifdef NETWORK_SEND_DOUBLE_SEED
 
@@ -956,9 +956,9 @@ static bool NetworkDoClientLoop()
 
				return false;
 
			}
 

	
 
			// If this is the first time we have a sync-frame, we
 
			//   need to let the server know that we are ready and at the same
 
			//   frame as he is.. so we can start playing!
 
			/* If this is the first time we have a sync-frame, we
 
			 *   need to let the server know that we are ready and at the same
 
			 *   frame as he is.. so we can start playing! */
 
			if (_network_first_time) {
 
				_network_first_time = false;
 
				SEND_COMMAND(PACKET_CLIENT_ACK)();
 
@@ -974,7 +974,7 @@ static bool NetworkDoClientLoop()
 
	return true;
 
}
 

	
 
// We have to do some UDP checking
 
/* We have to do some UDP checking */
 
void NetworkUDPGameLoop()
 
{
 
	_network_content_client.SendReceive();
 
@@ -990,8 +990,8 @@ void NetworkUDPGameLoop()
 
	}
 
}
 

	
 
// The main loop called from ttd.c
 
//  Here we also have to do StateGameLoop if needed!
 
/* The main loop called from ttd.c
 
 *  Here we also have to do StateGameLoop if needed! */
 
void NetworkGameLoop()
 
{
 
	if (!_networking) return;
 
@@ -1031,9 +1031,9 @@ void NetworkGameLoop()
 

	
 
		bool send_frame = false;
 

	
 
		// We first increase the _frame_counter
 
		/* We first increase the _frame_counter */
 
		_frame_counter++;
 
		// Update max-frame-counter
 
		/* Update max-frame-counter */
 
		if (_frame_counter > _frame_counter_max) {
 
			_frame_counter_max = _frame_counter + _settings_client.network.frame_freq;
 
			send_frame = true;
 
@@ -1041,7 +1041,7 @@ void NetworkGameLoop()
 

	
 
		NetworkExecuteLocalCommandQueue();
 

	
 
		// Then we make the frame
 
		/* Then we make the frame */
 
		StateGameLoop();
 

	
 
		_sync_seed_1 = _random.state[0];
 
@@ -1051,15 +1051,15 @@ void NetworkGameLoop()
 

	
 
		NetworkServer_Tick(send_frame);
 
	} else {
 
		// Client
 
		/* Client */
 

	
 
		// Make sure we are at the frame were the server is (quick-frames)
 
		/* Make sure we are at the frame were the server is (quick-frames) */
 
		if (_frame_counter_server > _frame_counter) {
 
			while (_frame_counter_server > _frame_counter) {
 
				if (!NetworkDoClientLoop()) break;
 
			}
 
		} else {
 
			// Else, keep on going till _frame_counter_max
 
			/* Else, keep on going till _frame_counter_max */
 
			if (_frame_counter_max > _frame_counter) NetworkDoClientLoop();
 
		}
 
	}
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -316,8 +316,8 @@ public:
 
			*item = MAX_CLIENT_SLOTS;
 
		}
 

	
 
		/* Then, try townnames */
 
		/* Not that the following assumes all town indices are adjacent, ie no
 
		/* Then, try townnames
 
		 * Not that the following assumes all town indices are adjacent, ie no
 
		 * towns have been deleted. */
 
		if (*item <= (uint)MAX_CLIENT_SLOTS + GetMaxTownIndex()) {
 
			const Town *t;
src/network/network_client.cpp
Show inline comments
 
@@ -26,10 +26,10 @@
 

	
 
#include "table/strings.h"
 

	
 
// This file handles all the client-commands
 
/* This file handles all the client-commands */
 

	
 

	
 
// So we don't make too much typos ;)
 
/* So we don't make too much typos ;) */
 
#define MY_CLIENT GetNetworkClientSocket(0)
 

	
 
static uint32 last_ack_frame;
 
@@ -94,19 +94,19 @@ void HashCurrentCompanyPassword(const ch
 
}
 

	
 

	
 
// **********
 
// Sending functions
 
//   DEF_CLIENT_SEND_COMMAND has no parameters
 
// **********
 
/***********
 
 * Sending functions
 
 *   DEF_CLIENT_SEND_COMMAND has no parameters
 
 ************/
 

	
 
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_COMPANY_INFO)
 
{
 
	//
 
	// Packet: CLIENT_COMPANY_INFO
 
	// Function: Request company-info (in detail)
 
	// Data:
 
	//    <none>
 
	//
 
	/*
 
	 * Packet: CLIENT_COMPANY_INFO
 
	 * Function: Request company-info (in detail)
 
	 * Data:
 
	 *    <none>
 
	 */
 
	Packet *p;
 
	_network_join_status = NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO;
 
	InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 
@@ -117,16 +117,16 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_CO
 

	
 
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
 
{
 
	//
 
	// Packet: CLIENT_JOIN
 
	// Function: Try to join the server
 
	// Data:
 
	//    String: OpenTTD Revision (norev000 if no revision)
 
	//    String: Client Name (max NETWORK_NAME_LENGTH)
 
	//    uint8:  Play as Company id (1..MAX_COMPANIES)
 
	//    uint8:  Language ID
 
	//    String: Unique id to find the client back in server-listing
 
	//
 
	/*
 
	 * Packet: CLIENT_JOIN
 
	 * Function: Try to join the server
 
	 * Data:
 
	 *    String: OpenTTD Revision (norev000 if no revision)
 
	 *    String: Client Name (max NETWORK_NAME_LENGTH)
 
	 *    uint8:  Play as Company id (1..MAX_COMPANIES)
 
	 *    uint8:  Language ID
 
	 *    String: Unique id to find the client back in server-listing
 
	 */
 

	
 
	Packet *p;
 
	_network_join_status = NETWORK_JOIN_STATUS_AUTHORIZING;
 
@@ -143,11 +143,11 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JO
 

	
 
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)
 
{
 
	//
 
	// Packet: CLIENT_NEWGRFS_CHECKED
 
	// Function: Tell the server that we have the required GRFs
 
	// Data:
 
	//
 
	/*
 
	 * Packet: CLIENT_NEWGRFS_CHECKED
 
	 * Function: Tell the server that we have the required GRFs
 
	 * Data:
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_NEWGRFS_CHECKED);
 
	MY_CLIENT->Send_Packet(p);
 
@@ -155,13 +155,13 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_NE
 

	
 
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_PASSWORD)(NetworkPasswordType type, const char *password)
 
{
 
	//
 
	// Packet: CLIENT_PASSWORD
 
	// Function: Send a password to the server to authorize
 
	// Data:
 
	//    uint8:  NetworkPasswordType
 
	//    String: Password
 
	//
 
	/*
 
	 * Packet: CLIENT_PASSWORD
 
	 * Function: Send a password to the server to authorize
 
	 * Data:
 
	 *    uint8:  NetworkPasswordType
 
	 *    String: Password
 
	 */
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_PASSWORD);
 
	p->Send_uint8 (type);
 
	p->Send_string(type == NETWORK_GAME_PASSWORD ? password : GenerateCompanyPasswordHash(password));
 
@@ -170,12 +170,12 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLI
 

	
 
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_GETMAP)
 
{
 
	//
 
	// Packet: CLIENT_GETMAP
 
	// Function: Request the map from the server
 
	// Data:
 
	//    <none>
 
	//
 
	/*
 
	 * Packet: CLIENT_GETMAP
 
	 * Function: Request the map from the server
 
	 * Data:
 
	 *    <none>
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_GETMAP);
 
	MY_CLIENT->Send_Packet(p);
 
@@ -183,12 +183,12 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_GE
 

	
 
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_MAP_OK)
 
{
 
	//
 
	// Packet: CLIENT_MAP_OK
 
	// Function: Tell the server that we are done receiving/loading the map
 
	// Data:
 
	//    <none>
 
	//
 
	/*
 
	 * Packet: CLIENT_MAP_OK
 
	 * Function: Tell the server that we are done receiving/loading the map
 
	 * Data:
 
	 *    <none>
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_MAP_OK);
 
	MY_CLIENT->Send_Packet(p);
 
@@ -196,12 +196,12 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_MA
 

	
 
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_ACK)
 
{
 
	//
 
	// Packet: CLIENT_ACK
 
	// Function: Tell the server we are done with this frame
 
	// Data:
 
	//    uint32: current FrameCounter of the client
 
	//
 
	/*
 
	 * Packet: CLIENT_ACK
 
	 * Function: Tell the server we are done with this frame
 
	 * Data:
 
	 *    uint32: current FrameCounter of the client
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_ACK);
 

	
 
@@ -209,21 +209,21 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_AC
 
	MY_CLIENT->Send_Packet(p);
 
}
 

	
 
// Send a command packet to the server
 
/* Send a command packet to the server */
 
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_COMMAND)(const CommandPacket *cp)
 
{
 
	//
 
	// Packet: CLIENT_COMMAND
 
	// Function: Send a DoCommand to the Server
 
	// Data:
 
	//    uint8:  CompanyID (0..MAX_COMPANIES-1)
 
	//    uint32: CommandID (see command.h)
 
	//    uint32: P1 (free variables used in DoCommand)
 
	//    uint32: P2
 
	//    uint32: Tile
 
	//    string: text
 
	//    uint8:  CallBackID (see callback_table.c)
 
	//
 
	/*
 
	 * Packet: CLIENT_COMMAND
 
	 * Function: Send a DoCommand to the Server
 
	 * Data:
 
	 *    uint8:  CompanyID (0..MAX_COMPANIES-1)
 
	 *    uint32: CommandID (see command.h)
 
	 *    uint32: P1 (free variables used in DoCommand)
 
	 *    uint32: P2
 
	 *    uint32: Tile
 
	 *    string: text
 
	 *    uint8:  CallBackID (see callback_table.c)
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_COMMAND);
 
	MY_CLIENT->Send_Command(p, cp);
 
@@ -231,19 +231,19 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLI
 
	MY_CLIENT->Send_Packet(p);
 
}
 

	
 
// Send a chat-packet over the network
 
/* Send a chat-packet over the network */
 
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_CHAT)(NetworkAction action, DestType type, int dest, const char *msg, int64 data)
 
{
 
	//
 
	// Packet: CLIENT_CHAT
 
	// Function: Send a chat-packet to the serve
 
	// Data:
 
	//    uint8:  ActionID (see network_data.h, NetworkAction)
 
	//    uint8:  Destination Type (see network_data.h, DestType);
 
	//    uint32: Destination CompanyID/Client-identifier
 
	//    String: Message (max NETWORK_CHAT_LENGTH)
 
	//    uint64: Some arbitrary number
 
	//
 
	/*
 
	 * Packet: CLIENT_CHAT
 
	 * Function: Send a chat-packet to the serve
 
	 * Data:
 
	 *    uint8:  ActionID (see network_data.h, NetworkAction)
 
	 *    uint8:  Destination Type (see network_data.h, DestType);
 
	 *    uint32: Destination CompanyID/Client-identifier
 
	 *    String: Message (max NETWORK_CHAT_LENGTH)
 
	 *    uint64: Some arbitrary number
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_CHAT);
 

	
 
@@ -256,15 +256,15 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLI
 
	MY_CLIENT->Send_Packet(p);
 
}
 

	
 
// Send an error-packet over the network
 
/* Send an error-packet over the network */
 
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_ERROR)(NetworkErrorCode errorno)
 
{
 
	//
 
	// Packet: CLIENT_ERROR
 
	// Function: The client made an error and is quiting the game
 
	// Data:
 
	//    uint8:  ErrorID (see network_data.h, NetworkErrorCode)
 
	//
 
	/*
 
	 * Packet: CLIENT_ERROR
 
	 * Function: The client made an error and is quiting the game
 
	 * Data:
 
	 *    uint8:  ErrorID (see network_data.h, NetworkErrorCode)
 
	 */
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_ERROR);
 

	
 
	p->Send_uint8(errorno);
 
@@ -273,12 +273,12 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLI
 

	
 
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_SET_PASSWORD)(const char *password)
 
{
 
	//
 
	// Packet: PACKET_CLIENT_SET_PASSWORD
 
	// Function: Set the password for the clients current company
 
	// Data:
 
	//    String: Password
 
	//
 
	/*
 
	 * Packet: PACKET_CLIENT_SET_PASSWORD
 
	 * Function: Set the password for the clients current company
 
	 * Data:
 
	 *    String: Password
 
	 */
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_SET_PASSWORD);
 

	
 
	p->Send_string(GenerateCompanyPasswordHash(password));
 
@@ -287,26 +287,26 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLI
 

	
 
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_SET_NAME)(const char *name)
 
{
 
	//
 
	// Packet: PACKET_CLIENT_SET_NAME
 
	// Function: Gives the client a new name
 
	// Data:
 
	//    String: Name
 
	//
 
	/*
 
	 * Packet: PACKET_CLIENT_SET_NAME
 
	 * Function: Gives the client a new name
 
	 * Data:
 
	 *    String: Name
 
	 */
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_SET_NAME);
 

	
 
	p->Send_string(name);
 
	MY_CLIENT->Send_Packet(p);
 
}
 

	
 
// Send an quit-packet over the network
 
/* Send an quit-packet over the network */
 
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_QUIT)()
 
{
 
	//
 
	// Packet: CLIENT_QUIT
 
	// Function: The client is quiting the game
 
	// Data:
 
	//
 
	/*
 
	 * Packet: CLIENT_QUIT
 
	 * Function: The client is quiting the game
 
	 * Data:
 
	 */
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_QUIT);
 

	
 
	MY_CLIENT->Send_Packet(p);
 
@@ -329,17 +329,17 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLI
 
}
 

	
 

	
 
// **********
 
// Receiving functions
 
//   DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p
 
// **********
 
/***********
 
 * Receiving functions
 
 *   DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p
 
 ************/
 

	
 
extern bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir);
 
extern StringID _switch_mode_errorstr;
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_FULL)
 
{
 
	// We try to join a server which is full
 
	/* We try to join a server which is full */
 
	_switch_mode_errorstr = STR_NETWORK_ERR_SERVER_FULL;
 
	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
@@ -348,7 +348,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_BANNED)
 
{
 
	// We try to join a server where we are banned
 
	/* We try to join a server where we are banned */
 
	_switch_mode_errorstr = STR_NETWORK_ERR_SERVER_BANNED;
 
	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
@@ -391,9 +391,9 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
	return NETWORK_RECV_STATUS_CLOSE_QUERY;
 
}
 

	
 
// This packet contains info about the client (playas and name)
 
//  as client we save this in NetworkClientInfo, linked via 'client_id'
 
//  which is always an unique number on a server.
 
/* This packet contains info about the client (playas and name)
 
 *  as client we save this in NetworkClientInfo, linked via 'client_id'
 
 *  which is always an unique number on a server. */
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
 
{
 
	NetworkClientInfo *ci;
 
@@ -411,11 +411,11 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
	ci = NetworkFindClientInfoFromClientID(client_id);
 
	if (ci != NULL) {
 
		if (playas == ci->client_playas && strcmp(name, ci->client_name) != 0) {
 
			// Client name changed, display the change
 
			/* Client name changed, display the change */
 
			NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, name);
 
		} else if (playas != ci->client_playas) {
 
			// The client changed from client-player..
 
			// Do not display that for now
 
			/* The client changed from client-player..
 
			 * Do not display that for now */
 
		}
 

	
 
		ci->client_playas = playas;
 
@@ -426,7 +426,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
		return NETWORK_RECV_STATUS_OKAY;
 
	}
 

	
 
	// We don't have this client_id yet, find an empty client_id, and put the data there
 
	/* We don't have this client_id yet, find an empty client_id, and put the data there */
 
	ci = new NetworkClientInfo(client_id);
 
	ci->client_playas = playas;
 
	if (client_id == _network_own_client_id) MY_CLIENT->SetInfo(ci);
 
@@ -531,7 +531,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
	_password_game_seed = p->Recv_uint32();
 
	p->Recv_string(_password_server_unique_id, sizeof(_password_server_unique_id));
 

	
 
	// Start receiving the map
 
	/* Start receiving the map */
 
	SEND_COMMAND(PACKET_CLIENT_GETMAP)();
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
 
@@ -542,7 +542,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
	_network_join_waiting = p->Recv_uint8();
 
	InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
	// We are put on hold for receiving the map.. we need GUI for this ;)
 
	/* We are put on hold for receiving the map.. we need GUI for this ;) */
 
	DEBUG(net, 1, "The server is currently busy sending the map to someone else, please wait..." );
 
	DEBUG(net, 1, "There are %d clients in front of you", _network_join_waiting);
 

	
 
@@ -559,7 +559,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 

	
 
	if (MY_CLIENT->has_quit) return NETWORK_RECV_STATUS_CONN_LOST;
 

	
 
	// First packet, init some stuff
 
	/* First packet, init some stuff */
 
	if (maptype == MAP_PACKET_START) {
 
		file_pointer = FioFOpenFile("network_client.tmp", "wb", AUTOSAVE_DIR);;
 
		if (file_pointer == NULL) {
 
@@ -583,12 +583,12 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
		_network_join_status = NETWORK_JOIN_STATUS_DOWNLOADING;
 
		InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
		// The first packet does not contain any more data
 
		/* The first packet does not contain any more data */
 
		return NETWORK_RECV_STATUS_OKAY;
 
	}
 

	
 
	if (maptype == MAP_PACKET_NORMAL) {
 
		// We are still receiving data, put it to the file
 
		/* We are still receiving data, put it to the file */
 
		if (fwrite(p->buffer + p->pos, 1, p->size - p->pos, file_pointer) != (size_t)(p->size - p->pos)) {
 
			_switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR;
 
			return NETWORK_RECV_STATUS_SAVEGAME;
 
@@ -598,7 +598,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
		InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 
	}
 

	
 
	// Check if this was the last packet
 
	/* Check if this was the last packet */
 
	if (maptype == MAP_PACKET_END) {
 
		fclose(file_pointer);
 

	
 
@@ -614,7 +614,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
		/* If the savegame has successfully loaded, ALL windows have been removed,
 
		 * only toolbar/statusbar and gamefield are visible */
 

	
 
		// Say we received the map and loaded it correctly!
 
		/* Say we received the map and loaded it correctly! */
 
		SEND_COMMAND(PACKET_CLIENT_MAP_OK)();
 

	
 
		/* New company/spectator (invalid company) or company we want to join is not active
 
@@ -630,7 +630,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
				NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL, NULL);
 
			}
 
		} else {
 
			// take control over an existing company
 
			/* take control over an existing company */
 
			SetLocalCompany(_network_playas);
 
		}
 
	}
 
@@ -643,8 +643,8 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
	_frame_counter_server = p->Recv_uint32();
 
	_frame_counter_max = p->Recv_uint32();
 
#ifdef ENABLE_NETWORK_SYNC_EVERY_FRAME
 
	// Test if the server supports this option
 
	//  and if we are at the frame the server is
 
	/* Test if the server supports this option
 
	 *  and if we are at the frame the server is */
 
	if (p->pos < p->size) {
 
		_sync_frame = _frame_counter_server;
 
		_sync_seed_1 = p->Recv_uint32();
 
@@ -655,8 +655,8 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
#endif
 
	DEBUG(net, 5, "Received FRAME %d", _frame_counter_server);
 

	
 
	// Let the server know that we received this frame correctly
 
	//  We do this only once per day, to save some bandwidth ;)
 
	/* Let the server know that we received this frame correctly
 
	 *  We do this only once per day, to save some bandwidth ;) */
 
	if (!_network_first_time && last_ack_frame < _frame_counter) {
 
		last_ack_frame = _frame_counter + DAY_TICKS;
 
		DEBUG(net, 4, "Sent ACK at %d", _frame_counter);
 
@@ -690,8 +690,8 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
		return NETWORK_RECV_STATUS_MALFORMED_PACKET;
 
	}
 

	
 
	// The server did send us this command..
 
	//  queue it in our own queue, so we can handle it in the upcoming frame!
 
	/* The server did send us this command..
 
	 *  queue it in our own queue, so we can handle it in the upcoming frame! */
 
	NetworkAddCommandQueue(cp);
 

	
 
	return NETWORK_RECV_STATUS_OKAY;
 
@@ -776,7 +776,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 

	
 
	InvalidateWindow(WC_CLIENT_LIST, 0);
 

	
 
	// If we come here it means we could not locate the client.. strange :s
 
	/* If we come here it means we could not locate the client.. strange :s */
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
 

	
 
@@ -802,10 +802,10 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_NEWGAME)
 
{
 
	// To trottle the reconnects a bit, every clients waits
 
	//  his _local_company value before reconnecting
 
	// COMPANY_SPECTATOR is currently 255, so to avoid long wait periods
 
	//  set the max to 10.
 
	/* To trottle the reconnects a bit, every clients waits
 
	 *  his _local_company value before reconnecting
 
	 * COMPANY_SPECTATOR is currently 255, so to avoid long wait periods
 
	 *  set the max to 10. */
 
	_network_reconnect = min(_local_company + 1, 10);
 
	_switch_mode_errorstr = STR_NETWORK_SERVER_REBOOT;
 

	
 
@@ -868,69 +868,69 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
}
 

	
 

	
 
// The layout for the receive-functions by the client
 
/* The layout for the receive-functions by the client */
 
typedef NetworkRecvStatus NetworkClientPacket(Packet *p);
 

	
 
// This array matches PacketType. At an incoming
 
//  packet it is matches against this array
 
//  and that way the right function to handle that
 
//  packet is found.
 
/* This array matches PacketType. At an incoming
 
 *  packet it is matches against this array
 
 *  and that way the right function to handle that
 
 *  packet is found. */
 
static NetworkClientPacket * const _network_client_packet[] = {
 
	RECEIVE_COMMAND(PACKET_SERVER_FULL),
 
	RECEIVE_COMMAND(PACKET_SERVER_BANNED),
 
	NULL, /*PACKET_CLIENT_JOIN,*/
 
	NULL, // PACKET_CLIENT_JOIN,
 
	RECEIVE_COMMAND(PACKET_SERVER_ERROR),
 
	NULL, /*PACKET_CLIENT_COMPANY_INFO,*/
 
	NULL, // PACKET_CLIENT_COMPANY_INFO,
 
	RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO),
 
	RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO),
 
	RECEIVE_COMMAND(PACKET_SERVER_NEED_PASSWORD),
 
	NULL, /*PACKET_CLIENT_PASSWORD,*/
 
	NULL, // PACKET_CLIENT_PASSWORD,
 
	RECEIVE_COMMAND(PACKET_SERVER_WELCOME),
 
	NULL, /*PACKET_CLIENT_GETMAP,*/
 
	NULL, // PACKET_CLIENT_GETMAP,
 
	RECEIVE_COMMAND(PACKET_SERVER_WAIT),
 
	RECEIVE_COMMAND(PACKET_SERVER_MAP),
 
	NULL, /*PACKET_CLIENT_MAP_OK,*/
 
	NULL, // PACKET_CLIENT_MAP_OK,
 
	RECEIVE_COMMAND(PACKET_SERVER_JOIN),
 
	RECEIVE_COMMAND(PACKET_SERVER_FRAME),
 
	RECEIVE_COMMAND(PACKET_SERVER_SYNC),
 
	NULL, /*PACKET_CLIENT_ACK,*/
 
	NULL, /*PACKET_CLIENT_COMMAND,*/
 
	NULL, // PACKET_CLIENT_ACK,
 
	NULL, // PACKET_CLIENT_COMMAND,
 
	RECEIVE_COMMAND(PACKET_SERVER_COMMAND),
 
	NULL, /*PACKET_CLIENT_CHAT,*/
 
	NULL, // PACKET_CLIENT_CHAT,
 
	RECEIVE_COMMAND(PACKET_SERVER_CHAT),
 
	NULL, /*PACKET_CLIENT_SET_PASSWORD,*/
 
	NULL, /*PACKET_CLIENT_SET_NAME,*/
 
	NULL, /*PACKET_CLIENT_QUIT,*/
 
	NULL, /*PACKET_CLIENT_ERROR,*/
 
	NULL, // PACKET_CLIENT_SET_PASSWORD,
 
	NULL, // PACKET_CLIENT_SET_NAME,
 
	NULL, // PACKET_CLIENT_QUIT,
 
	NULL, // PACKET_CLIENT_ERROR,
 
	RECEIVE_COMMAND(PACKET_SERVER_QUIT),
 
	RECEIVE_COMMAND(PACKET_SERVER_ERROR_QUIT),
 
	RECEIVE_COMMAND(PACKET_SERVER_SHUTDOWN),
 
	RECEIVE_COMMAND(PACKET_SERVER_NEWGAME),
 
	RECEIVE_COMMAND(PACKET_SERVER_RCON),
 
	NULL, /*PACKET_CLIENT_RCON,*/
 
	NULL, // PACKET_CLIENT_RCON,
 
	RECEIVE_COMMAND(PACKET_SERVER_CHECK_NEWGRFS),
 
	NULL, /*PACKET_CLIENT_NEWGRFS_CHECKED,*/
 
	NULL, // PACKET_CLIENT_NEWGRFS_CHECKED,
 
	RECEIVE_COMMAND(PACKET_SERVER_MOVE),
 
	NULL, /* PACKET_CLIENT_MOVE */
 
	NULL, // PACKET_CLIENT_MOVE
 
	RECEIVE_COMMAND(PACKET_SERVER_COMPANY_UPDATE),
 
	RECEIVE_COMMAND(PACKET_SERVER_CONFIG_UPDATE),
 
};
 

	
 
// If this fails, check the array above with network_data.h
 
/* If this fails, check the array above with network_data.h */
 
assert_compile(lengthof(_network_client_packet) == PACKET_END);
 

	
 
// Is called after a client is connected to the server
 
/* Is called after a client is connected to the server */
 
void NetworkClient_Connected()
 
{
 
	// Set the frame-counter to 0 so nothing happens till we are ready
 
	/* Set the frame-counter to 0 so nothing happens till we are ready */
 
	_frame_counter = 0;
 
	_frame_counter_server = 0;
 
	last_ack_frame = 0;
 
	// Request the game-info
 
	/* Request the game-info */
 
	SEND_COMMAND(PACKET_CLIENT_JOIN)();
 
}
 

	
 
// Reads the packets from the socket-stream, if available
 
/* Reads the packets from the socket-stream, if available */
 
NetworkRecvStatus NetworkClient_ReadPackets(NetworkClientSocket *cs)
 
{
 
	Packet *p;
src/network/network_gui.cpp
Show inline comments
 
@@ -828,7 +828,7 @@ void ShowNetworkGameWindow()
 
		char * const *srv;
 

	
 
		first = false;
 
		// add all servers from the config file to our list
 
		/* add all servers from the config file to our list */
 
		for (srv = &_network_host_list[0]; srv != endof(_network_host_list) && *srv != NULL; srv++) {
 
			NetworkAddServer(*srv);
 
		}
 
@@ -1391,16 +1391,16 @@ NetworkCompanyInfo *GetLobbyCompanyInfo(
 
	return (lobby != NULL && company < MAX_COMPANIES) ? &lobby->company_info[company] : NULL;
 
}
 

	
 
// The window below gives information about the connected clients
 
//  and also makes able to give money to them, kick them (if server)
 
//  and stuff like that.
 
/* The window below gives information about the connected clients
 
 *  and also makes able to give money to them, kick them (if server)
 
 *  and stuff like that. */
 

	
 
extern void DrawCompanyIcon(CompanyID cid, int x, int y);
 

	
 
// Every action must be of this form
 
/* Every action must be of this form */
 
typedef void ClientList_Action_Proc(byte client_no);
 

	
 
// Max 10 actions per client
 
/* Max 10 actions per client */
 
#define MAX_CLIENTLIST_ACTION 10
 

	
 
enum {
 
@@ -1429,7 +1429,7 @@ static const WindowDesc _client_list_des
 
	_client_list_widgets,
 
};
 

	
 
// Finds the Xth client-info that is active
 
/* Finds the Xth client-info that is active */
 
static const NetworkClientInfo *NetworkFindClientInfo(byte client_no)
 
{
 
	const NetworkClientInfo *ci;
 
@@ -1442,7 +1442,7 @@ static const NetworkClientInfo *NetworkF
 
	return NULL;
 
}
 

	
 
// Here we start to define the options out of the menu
 
/* Here we start to define the options out of the menu */
 
static void ClientList_Kick(byte client_no)
 
{
 
	const NetworkClientInfo *ci = NetworkFindClientInfo(client_no);
 
@@ -1576,7 +1576,7 @@ struct NetworkClientListPopupWindow : Wi
 
	{
 
		int num = 0;
 

	
 
		// Find the amount of actions
 
		/* Find the amount of actions */
 
		for (int i = 0; i < MAX_CLIENTLIST_ACTION; i++) {
 
			if (this->action[i][0] == '\0') continue;
 
			if (this->proc[i] == NULL) continue;
 
@@ -1677,7 +1677,7 @@ struct NetworkClientListWindow : Window
 

	
 
		/* If height is changed */
 
		if (this->height != CLNWND_OFFSET + num + 1) {
 
			// XXX - magic unfortunately; (num + 2) has to be one bigger than heigh (num + 1)
 
			/* XXX - magic unfortunately; (num + 2) has to be one bigger than heigh (num + 1) */
 
			this->SetDirty();
 
			this->widget[3].bottom = this->widget[3].top + num + 2;
 
			this->height = CLNWND_OFFSET + num + 1;
 
@@ -1778,7 +1778,7 @@ void ShowNetworkNeedPassword(NetworkPass
 
	ShowQueryString(STR_EMPTY, caption, 20, 180, FindWindowById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL, QSF_NONE);
 
}
 

	
 
// Vars needed for the join-GUI
 
/* Vars needed for the join-GUI */
 
NetworkJoinStatus _network_join_status;
 
uint8 _network_join_waiting;
 
uint32 _network_join_bytes;
 
@@ -1812,7 +1812,7 @@ struct NetworkJoinStatusWindow : Window 
 
				SetDParam(1, _network_join_bytes_total);
 
				DrawStringCentered(125, 46, STR_NETWORK_CONNECTING_DOWNLOADING, TC_GREY);
 
				/* Fallthrough */
 
			default: /* Waiting is 15%, so the resting receivement of map is maximum 70% */
 
			default: // Waiting is 15%, so the resting receivement of map is maximum 70%
 
				progress = 15 + _network_join_bytes * (100 - 15) / _network_join_bytes_total;
 
		}
 

	
 
@@ -1822,7 +1822,7 @@ struct NetworkJoinStatusWindow : Window 
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		if (widget == 2) { //Disconnect button
 
		if (widget == 2) { // Disconnect button
 
			NetworkDisconnect();
 
			SwitchToMode(SM_MENU);
 
			ShowNetworkGameWindow();
src/network/network_internal.h
Show inline comments
 
@@ -100,7 +100,7 @@ extern uint32 _frame_counter;
 

	
 
extern uint32 _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients.
 

	
 
// networking settings
 
/* networking settings */
 
extern uint32 _broadcast_list[MAX_INTERFACES + 1];
 

	
 
extern uint32 _network_server_bind_ip;
 
@@ -108,7 +108,7 @@ extern uint32 _network_server_bind_ip;
 
extern uint32 _sync_seed_1, _sync_seed_2;
 
extern uint32 _sync_frame;
 
extern bool _network_first_time;
 
// Vars needed for the join-GUI
 
/* Vars needed for the join-GUI */
 
extern NetworkJoinStatus _network_join_status;
 
extern uint8 _network_join_waiting;
 
extern uint32 _network_join_bytes;
 
@@ -146,7 +146,7 @@ void NetworkAddCommandQueue(CommandPacke
 
void NetworkExecuteLocalCommandQueue();
 
void NetworkFreeLocalCommandQueue();
 

	
 
// from network.c
 
/* from network.c */
 
void NetworkCloseClient(NetworkClientSocket *cs);
 
void NetworkTextMessage(NetworkAction action, ConsoleColour colour, bool self_send, const char *name, const char *str = "", int64 data = 0);
 
void NetworkGetClientName(char *clientname, size_t size, const NetworkClientSocket *cs);
 
@@ -156,7 +156,7 @@ NetworkClientSocket *NetworkFindClientSt
 
StringID GetNetworkErrorMsg(NetworkErrorCode err);
 
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH]);
 

	
 
// Macros to make life a bit more easier
 
/* Macros to make life a bit more easier */
 
#define DEF_CLIENT_RECEIVE_COMMAND(type) NetworkRecvStatus NetworkPacketReceive_ ## type ## _command(Packet *p)
 
#define DEF_CLIENT_SEND_COMMAND(type) void NetworkPacketSend_ ## type ## _command()
 
#define DEF_CLIENT_SEND_COMMAND_PARAM(type) void NetworkPacketSend_ ## type ## _command
src/network/network_server.cpp
Show inline comments
 
@@ -26,25 +26,25 @@
 

	
 
#include "table/strings.h"
 

	
 
// This file handles all the server-commands
 
/* This file handles all the server-commands */
 

	
 
static void NetworkHandleCommandQueue(NetworkClientSocket *cs);
 

	
 
// **********
 
// Sending functions
 
//   DEF_SERVER_SEND_COMMAND has parameter: NetworkClientSocket *cs
 
// **********
 
/***********
 
 * Sending functions
 
 *   DEF_SERVER_SEND_COMMAND has parameter: NetworkClientSocket *cs
 
 ************/
 

	
 
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CLIENT_INFO)(NetworkClientSocket *cs, NetworkClientInfo *ci)
 
{
 
	//
 
	// Packet: SERVER_CLIENT_INFO
 
	// Function: Sends info about a client
 
	// Data:
 
	//    uint32:  The identifier of the client (always unique on a server. 1 = server, 0 is invalid)
 
	//    uint8:  As which company the client is playing
 
	//    String: The name of the client
 
	//
 
	/*
 
	 * Packet: SERVER_CLIENT_INFO
 
	 * Function: Sends info about a client
 
	 * Data:
 
	 *    uint32:  The identifier of the client (always unique on a server. 1 = server, 0 is invalid)
 
	 *    uint8:  As which company the client is playing
 
	 *    String: The name of the client
 
	 */
 

	
 
	if (ci->client_id != INVALID_CLIENT_ID) {
 
		Packet *p = NetworkSend_Init(PACKET_SERVER_CLIENT_INFO);
 
@@ -58,11 +58,11 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 

	
 
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
 
{
 
	//
 
	// Packet: SERVER_COMPANY_INFO
 
	// Function: Sends info about the companies
 
	// Data:
 
	//
 
	/*
 
	 * Packet: SERVER_COMPANY_INFO
 
	 * Function: Sends info about the companies
 
	 * Data:
 
	 */
 

	
 
	/* Fetch the latest version of the stats */
 
	NetworkCompanyStats company_stats[MAX_COMPANIES];
 
@@ -125,12 +125,12 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_CO
 

	
 
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkClientSocket *cs, NetworkErrorCode error)
 
{
 
	//
 
	// Packet: SERVER_ERROR
 
	// Function: The client made an error
 
	// Data:
 
	//    uint8:  ErrorID (see network_data.h, NetworkErrorCode)
 
	//
 
	/*
 
	 * Packet: SERVER_ERROR
 
	 * Function: The client made an error
 
	 * Data:
 
	 *    uint8:  ErrorID (see network_data.h, NetworkErrorCode)
 
	 */
 

	
 
	char str[100];
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_ERROR);
 
@@ -141,7 +141,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 
	StringID strid = GetNetworkErrorMsg(error);
 
	GetString(str, strid, lastof(str));
 

	
 
	// Only send when the current client was in game
 
	/* Only send when the current client was in game */
 
	if (cs->status > STATUS_AUTH) {
 
		NetworkClientSocket *new_cs;
 
		char client_name[NETWORK_CLIENT_NAME_LENGTH];
 
@@ -154,8 +154,8 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 

	
 
		FOR_ALL_CLIENT_SOCKETS(new_cs) {
 
			if (new_cs->status > STATUS_AUTH && new_cs != cs) {
 
				// Some errors we filter to a more general error. Clients don't have to know the real
 
				//  reason a joining failed.
 
				/* Some errors we filter to a more general error. Clients don't have to know the real
 
				 *  reason a joining failed. */
 
				if (error == NETWORK_ERROR_NOT_AUTHORIZED || error == NETWORK_ERROR_NOT_EXPECTED || error == NETWORK_ERROR_WRONG_REVISION)
 
					error = NETWORK_ERROR_ILLEGAL_PACKET;
 

	
 
@@ -168,24 +168,24 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 

	
 
	cs->has_quit = true;
 

	
 
	// Make sure the data get's there before we close the connection
 
	/* Make sure the data get's there before we close the connection */
 
	cs->Send_Packets();
 

	
 
	// The client made a mistake, so drop his connection now!
 
	/* The client made a mistake, so drop his connection now! */
 
	NetworkCloseClient(cs);
 
}
 

	
 
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CHECK_NEWGRFS)(NetworkClientSocket *cs)
 
{
 
	//
 
	// Packet: PACKET_SERVER_CHECK_NEWGRFS
 
	// Function: Sends info about the used GRFs to the client
 
	// Data:
 
	//      uint8:  Amount of GRFs
 
	//    And then for each GRF:
 
	//      uint32: GRF ID
 
	// 16 * uint8:  MD5 checksum of the GRF
 
	//
 
	/*
 
	 * Packet: PACKET_SERVER_CHECK_NEWGRFS
 
	 * Function: Sends info about the used GRFs to the client
 
	 * Data:
 
	 *      uint8:  Amount of GRFs
 
	 *    And then for each GRF:
 
	 *      uint32: GRF ID
 
	 * 16 * uint8:  MD5 checksum of the GRF
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_CHECK_NEWGRFS);
 
	const GRFConfig *c;
 
@@ -205,12 +205,12 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 

	
 
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_NEED_PASSWORD)(NetworkClientSocket *cs, NetworkPasswordType type)
 
{
 
	//
 
	// Packet: SERVER_NEED_PASSWORD
 
	// Function: Indication to the client that the server needs a password
 
	// Data:
 
	//    uint8:  Type of password
 
	//
 
	/*
 
	 * Packet: SERVER_NEED_PASSWORD
 
	 * Function: Indication to the client that the server needs a password
 
	 * Data:
 
	 *    uint8:  Type of password
 
	 */
 

	
 
	/* Invalid packet when status is AUTH or higher */
 
	if (cs->status >= STATUS_AUTH) return;
 
@@ -226,17 +226,17 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 

	
 
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WELCOME)
 
{
 
	//
 
	// Packet: SERVER_WELCOME
 
	// Function: The client is joined and ready to receive his map
 
	// Data:
 
	//    uint32:  Own Client identifier
 
	//
 
	/*
 
	 * Packet: SERVER_WELCOME
 
	 * Function: The client is joined and ready to receive his map
 
	 * Data:
 
	 *    uint32:  Own Client identifier
 
	 */
 

	
 
	Packet *p;
 
	NetworkClientSocket *new_cs;
 

	
 
	// Invalid packet when status is AUTH or higher
 
	/* Invalid packet when status is AUTH or higher */
 
	if (cs->status >= STATUS_AUTH) return;
 

	
 
	cs->status = STATUS_AUTH;
 
@@ -248,29 +248,29 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WE
 
	p->Send_string(_settings_client.network.network_id);
 
	cs->Send_Packet(p);
 

	
 
		// Transmit info about all the active clients
 
		/* Transmit info about all the active clients */
 
	FOR_ALL_CLIENT_SOCKETS(new_cs) {
 
		if (new_cs != cs && new_cs->status > STATUS_AUTH)
 
			SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, new_cs->GetInfo());
 
	}
 
	// Also send the info of the server
 
	/* Also send the info of the server */
 
	SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, NetworkFindClientInfoFromClientID(CLIENT_ID_SERVER));
 
}
 

	
 
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WAIT)
 
{
 
	//
 
	// Packet: PACKET_SERVER_WAIT
 
	// Function: The client can not receive the map at the moment because
 
	//             someone else is already receiving the map
 
	// Data:
 
	//    uint8:  Clients awaiting map
 
	//
 
	/*
 
	 * Packet: PACKET_SERVER_WAIT
 
	 * Function: The client can not receive the map at the moment because
 
	 *             someone else is already receiving the map
 
	 * Data:
 
	 *    uint8:  Clients awaiting map
 
	 */
 
	int waiting = 0;
 
	NetworkClientSocket *new_cs;
 
	Packet *p;
 

	
 
	// Count how many clients are waiting in the queue
 
	/* Count how many clients are waiting in the queue */
 
	FOR_ALL_CLIENT_SOCKETS(new_cs) {
 
		if (new_cs->status == STATUS_MAP_WAIT) waiting++;
 
	}
 
@@ -280,28 +280,28 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WA
 
	cs->Send_Packet(p);
 
}
 

	
 
// This sends the map to the client
 
/* This sends the map to the client */
 
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
 
{
 
	//
 
	// Packet: SERVER_MAP
 
	// Function: Sends the map to the client, or a part of it (it is splitted in
 
	//   a lot of multiple packets)
 
	// Data:
 
	//    uint8:  packet-type (MAP_PACKET_START, MAP_PACKET_NORMAL and MAP_PACKET_END)
 
	//  if MAP_PACKET_START:
 
	//    uint32: The current FrameCounter
 
	//  if MAP_PACKET_NORMAL:
 
	//    piece of the map (till max-size of packet)
 
	//  if MAP_PACKET_END:
 
	//    nothing
 
	//
 
	/*
 
	 * Packet: SERVER_MAP
 
	 * Function: Sends the map to the client, or a part of it (it is splitted in
 
	 *   a lot of multiple packets)
 
	 * Data:
 
	 *    uint8:  packet-type (MAP_PACKET_START, MAP_PACKET_NORMAL and MAP_PACKET_END)
 
	 *  if MAP_PACKET_START:
 
	 *    uint32: The current FrameCounter
 
	 *  if MAP_PACKET_NORMAL:
 
	 *    piece of the map (till max-size of packet)
 
	 *  if MAP_PACKET_END:
 
	 *    nothing
 
	 */
 

	
 
	static FILE *file_pointer;
 
	static uint sent_packets; // How many packets we did send succecfully last time
 

	
 
	if (cs->status < STATUS_AUTH) {
 
		// Illegal call, return error and ignore the packet
 
		/* Illegal call, return error and ignore the packet */
 
		SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_AUTHORIZED);
 
		return;
 
	}
 
@@ -310,7 +310,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MA
 
		const char *filename = "network_server.tmp";
 
		Packet *p;
 

	
 
		// Make a dump of the current game
 
		/* Make a dump of the current game */
 
		if (SaveOrLoad(filename, SL_SAVE, AUTOSAVE_DIR) != SL_OK) usererror("network savedump failed");
 

	
 
		file_pointer = FioFOpenFile(filename, "rb", AUTOSAVE_DIR);
 
@@ -318,7 +318,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MA
 

	
 
		if (ftell(file_pointer) == 0) usererror("network savedump failed - zero sized savegame?");
 

	
 
		// Now send the _frame_counter and how many packets are coming
 
		/* Now send the _frame_counter and how many packets are coming */
 
		p = NetworkSend_Init(PACKET_SERVER_MAP);
 
		p->Send_uint8 (MAP_PACKET_START);
 
		p->Send_uint32(_frame_counter);
 
@@ -348,49 +348,49 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MA
 
			p->size += res;
 
			cs->Send_Packet(p);
 
			if (feof(file_pointer)) {
 
				// Done reading!
 
				/* Done reading! */
 
				Packet *p = NetworkSend_Init(PACKET_SERVER_MAP);
 
				p->Send_uint8(MAP_PACKET_END);
 
				cs->Send_Packet(p);
 

	
 
				// Set the status to DONE_MAP, no we will wait for the client
 
				//  to send it is ready (maybe that happens like never ;))
 
				/* Set the status to DONE_MAP, no we will wait for the client
 
				 *  to send it is ready (maybe that happens like never ;)) */
 
				cs->status = STATUS_DONE_MAP;
 
				fclose(file_pointer);
 

	
 
				{
 
					NetworkClientSocket *new_cs;
 
					bool new_map_client = false;
 
					// Check if there is a client waiting for receiving the map
 
					//  and start sending him the map
 
					/* Check if there is a client waiting for receiving the map
 
					 *  and start sending him the map */
 
					FOR_ALL_CLIENT_SOCKETS(new_cs) {
 
						if (new_cs->status == STATUS_MAP_WAIT) {
 
							// Check if we already have a new client to send the map to
 
							/* Check if we already have a new client to send the map to */
 
							if (!new_map_client) {
 
								// If not, this client will get the map
 
								/* If not, this client will get the map */
 
								new_cs->status = STATUS_AUTH;
 
								new_map_client = true;
 
								SEND_COMMAND(PACKET_SERVER_MAP)(new_cs);
 
							} else {
 
								// Else, send the other clients how many clients are in front of them
 
								/* Else, send the other clients how many clients are in front of them */
 
								SEND_COMMAND(PACKET_SERVER_WAIT)(new_cs);
 
							}
 
						}
 
					}
 
				}
 

	
 
				// There is no more data, so break the for
 
				/* There is no more data, so break the for */
 
				break;
 
			}
 
		}
 

	
 
		// Send all packets (forced) and check if we have send it all
 
		/* Send all packets (forced) and check if we have send it all */
 
		cs->Send_Packets();
 
		if (cs->IsPacketQueueEmpty()) {
 
			// All are sent, increase the sent_packets
 
			/* All are sent, increase the sent_packets */
 
			sent_packets *= 2;
 
		} else {
 
			// Not everything is sent, decrease the sent_packets
 
			/* Not everything is sent, decrease the sent_packets */
 
			if (sent_packets > 1) sent_packets /= 2;
 
		}
 
	}
 
@@ -398,14 +398,14 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MA
 

	
 
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_JOIN)(NetworkClientSocket *cs, ClientID client_id)
 
{
 
	//
 
	// Packet: SERVER_JOIN
 
	// Function: A client is joined (all active clients receive this after a
 
	//     PACKET_CLIENT_MAP_OK) Mostly what directly follows is a
 
	//     PACKET_SERVER_CLIENT_INFO
 
	// Data:
 
	//    uint32:  Client-identifier
 
	//
 
	/*
 
	 * Packet: SERVER_JOIN
 
	 * Function: A client is joined (all active clients receive this after a
 
	 *     PACKET_CLIENT_MAP_OK) Mostly what directly follows is a
 
	 *     PACKET_SERVER_CLIENT_INFO
 
	 * Data:
 
	 *    uint32:  Client-identifier
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_JOIN);
 

	
 
@@ -417,16 +417,16 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 

	
 
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_FRAME)
 
{
 
	//
 
	// Packet: SERVER_FRAME
 
	// Function: Sends the current frame-counter to the client
 
	// Data:
 
	//    uint32: Frame Counter
 
	//    uint32: Frame Counter Max (how far may the client walk before the server?)
 
	//    [uint32: general-seed-1]
 
	//    [uint32: general-seed-2]
 
	//      (last two depends on compile-settings, and are not default settings)
 
	//
 
	/*
 
	 * Packet: SERVER_FRAME
 
	 * Function: Sends the current frame-counter to the client
 
	 * Data:
 
	 *    uint32: Frame Counter
 
	 *    uint32: Frame Counter Max (how far may the client walk before the server?)
 
	 *    [uint32: general-seed-1]
 
	 *    [uint32: general-seed-2]
 
	 *      (last two depends on compile-settings, and are not default settings)
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_FRAME);
 
	p->Send_uint32(_frame_counter);
 
@@ -442,15 +442,15 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_FR
 

	
 
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SYNC)
 
{
 
	//
 
	// Packet: SERVER_SYNC
 
	// Function: Sends a sync-check to the client
 
	// Data:
 
	//    uint32: Frame Counter
 
	//    uint32: General-seed-1
 
	//    [uint32: general-seed-2]
 
	//      (last one depends on compile-settings, and are not default settings)
 
	//
 
	/*
 
	 * Packet: SERVER_SYNC
 
	 * Function: Sends a sync-check to the client
 
	 * Data:
 
	 *    uint32: Frame Counter
 
	 *    uint32: General-seed-1
 
	 *    [uint32: general-seed-2]
 
	 *      (last one depends on compile-settings, and are not default settings)
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_SYNC);
 
	p->Send_uint32(_frame_counter);
 
@@ -464,19 +464,19 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SY
 

	
 
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_COMMAND)(NetworkClientSocket *cs, const CommandPacket *cp)
 
{
 
	//
 
	// Packet: SERVER_COMMAND
 
	// Function: Sends a DoCommand to the client
 
	// Data:
 
	//    uint8:  CompanyID (0..MAX_COMPANIES-1)
 
	//    uint32: CommandID (see command.h)
 
	//    uint32: P1 (free variables used in DoCommand)
 
	//    uint32: P2
 
	//    uint32: Tile
 
	//    string: text
 
	//    uint8:  CallBackID (see callback_table.c)
 
	//    uint32: Frame of execution
 
	//
 
	/*
 
	 * Packet: SERVER_COMMAND
 
	 * Function: Sends a DoCommand to the client
 
	 * Data:
 
	 *    uint8:  CompanyID (0..MAX_COMPANIES-1)
 
	 *    uint32: CommandID (see command.h)
 
	 *    uint32: P1 (free variables used in DoCommand)
 
	 *    uint32: P2
 
	 *    uint32: Tile
 
	 *    string: text
 
	 *    uint8:  CallBackID (see callback_table.c)
 
	 *    uint32: Frame of execution
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_COMMAND);
 

	
 
@@ -489,15 +489,15 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 

	
 
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CHAT)(NetworkClientSocket *cs, NetworkAction action, ClientID client_id, bool self_send, const char *msg, int64 data)
 
{
 
	//
 
	// Packet: SERVER_CHAT
 
	// Function: Sends a chat-packet to the client
 
	// Data:
 
	//    uint8:  ActionID (see network_data.h, NetworkAction)
 
	//    uint32: Client-identifier
 
	//    String: Message (max NETWORK_CHAT_LENGTH)
 
	//    uint64: Arbitrary data
 
	//
 
	/*
 
	 * Packet: SERVER_CHAT
 
	 * Function: Sends a chat-packet to the client
 
	 * Data:
 
	 *    uint8:  ActionID (see network_data.h, NetworkAction)
 
	 *    uint32: Client-identifier
 
	 *    String: Message (max NETWORK_CHAT_LENGTH)
 
	 *    uint64: Arbitrary data
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_CHAT);
 

	
 
@@ -512,14 +512,14 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 

	
 
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR_QUIT)(NetworkClientSocket *cs, ClientID client_id, NetworkErrorCode errorno)
 
{
 
	//
 
	// Packet: SERVER_ERROR_QUIT
 
	// Function: One of the clients made an error and is quiting the game
 
	//      This packet informs the other clients of that.
 
	// Data:
 
	//    uint32:  Client-identifier
 
	//    uint8:  ErrorID (see network_data.h, NetworkErrorCode)
 
	//
 
	/*
 
	 * Packet: SERVER_ERROR_QUIT
 
	 * Function: One of the clients made an error and is quiting the game
 
	 *      This packet informs the other clients of that.
 
	 * Data:
 
	 *    uint32:  Client-identifier
 
	 *    uint8:  ErrorID (see network_data.h, NetworkErrorCode)
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_ERROR_QUIT);
 

	
 
@@ -531,13 +531,13 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 

	
 
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_QUIT)(NetworkClientSocket *cs, ClientID client_id)
 
{
 
	//
 
	// Packet: SERVER_ERROR_QUIT
 
	// Function: A client left the game, and this packets informs the other clients
 
	//      of that.
 
	// Data:
 
	//    uint32:  Client-identifier
 
	//
 
	/*
 
	 * Packet: SERVER_ERROR_QUIT
 
	 * Function: A client left the game, and this packets informs the other clients
 
	 *      of that.
 
	 * Data:
 
	 *    uint32:  Client-identifier
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_QUIT);
 

	
 
@@ -548,12 +548,12 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 

	
 
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SHUTDOWN)
 
{
 
	//
 
	// Packet: SERVER_SHUTDOWN
 
	// Function: Let the clients know that the server is closing
 
	// Data:
 
	//     <none>
 
	//
 
	/*
 
	 * Packet: SERVER_SHUTDOWN
 
	 * Function: Let the clients know that the server is closing
 
	 * Data:
 
	 *     <none>
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_SHUTDOWN);
 
	cs->Send_Packet(p);
 
@@ -561,12 +561,12 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SH
 

	
 
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_NEWGAME)
 
{
 
	//
 
	// Packet: PACKET_SERVER_NEWGAME
 
	// Function: Let the clients know that the server is loading a new map
 
	// Data:
 
	//     <none>
 
	//
 
	/*
 
	 * Packet: PACKET_SERVER_NEWGAME
 
	 * Function: Let the clients know that the server is loading a new map
 
	 * Data:
 
	 *     <none>
 
	 */
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_NEWGAME);
 
	cs->Send_Packet(p);
 
@@ -607,10 +607,10 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_CO
 
	cs->Send_Packet(p);
 
}
 

	
 
// **********
 
// Receiving functions
 
//   DEF_SERVER_RECEIVE_COMMAND has parameter: NetworkClientSocket *cs, Packet *p
 
// **********
 
/***********
 
 * Receiving functions
 
 *   DEF_SERVER_RECEIVE_COMMAND has parameter: NetworkClientSocket *cs, Packet *p
 
 ************/
 

	
 
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMPANY_INFO)
 
{
 
@@ -656,9 +656,9 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 

	
 
	p->Recv_string(client_revision, sizeof(client_revision));
 

	
 
	// Check if the client has revision control enabled
 
	/* Check if the client has revision control enabled */
 
	if (!IsNetworkCompatibleVersion(client_revision)) {
 
		// Different revisions!!
 
		/* Different revisions!! */
 
		SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_REVISION);
 
		return;
 
	}
 
@@ -670,21 +670,21 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 

	
 
	if (cs->has_quit) return;
 

	
 
	// join another company does not affect these values
 
	/* join another company does not affect these values */
 
	switch (playas) {
 
		case COMPANY_NEW_COMPANY: /* New company */
 
		case COMPANY_NEW_COMPANY: // New company
 
			if (ActiveCompanyCount() >= _settings_client.network.max_companies) {
 
				SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_FULL);
 
				return;
 
			}
 
			break;
 
		case COMPANY_SPECTATOR: /* Spectator */
 
		case COMPANY_SPECTATOR: // Spectator
 
			if (NetworkSpectatorCount() >= _settings_client.network.max_spectators) {
 
				SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_FULL);
 
				return;
 
			}
 
			break;
 
		default: /* Join another company (companies 1-8 (index 0-7)) */
 
		default: // Join another company (companies 1-8 (index 0-7))
 
			if (!IsValidCompanyID(playas) || !IsHumanCompany(playas)) {
 
				SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_COMPANY_MISMATCH);
 
				return;
 
@@ -692,11 +692,11 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
			break;
 
	}
 

	
 
	// We need a valid name.. make it Player
 
	/* We need a valid name.. make it Player */
 
	if (StrEmpty(name)) strecpy(name, "Player", lastof(name));
 

	
 
	if (!NetworkFindName(name)) { // Change name if duplicate
 
		// We could not create a name for this client
 
		/* We could not create a name for this client */
 
		SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NAME_IN_USE);
 
		return;
 
	}
 
@@ -728,9 +728,9 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
	p->Recv_string(password, sizeof(password));
 

	
 
	if (cs->status == STATUS_AUTHORIZING && type == NETWORK_GAME_PASSWORD) {
 
		// Check game-password
 
		/* Check game-password */
 
		if (strcmp(password, _settings_client.network.server_password) != 0) {
 
			// Password is invalid
 
			/* Password is invalid */
 
			SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_PASSWORD);
 
			return;
 
		}
 
@@ -742,14 +742,14 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
			return;
 
		}
 

	
 
		// Valid password, allow user
 
		/* Valid password, allow user */
 
		SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
 
		return;
 
	} else if (cs->status == STATUS_AUTHORIZING && type == NETWORK_COMPANY_PASSWORD) {
 
		ci = cs->GetInfo();
 

	
 
		if (strcmp(password, _network_company_states[ci->client_playas].password) != 0) {
 
			// Password is invalid
 
			/* Password is invalid */
 
			SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_PASSWORD);
 
			return;
 
		}
 
@@ -767,30 +767,30 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
{
 
	NetworkClientSocket *new_cs;
 

	
 
	// The client was never joined.. so this is impossible, right?
 
	//  Ignore the packet, give the client a warning, and close his connection
 
	/* The client was never joined.. so this is impossible, right?
 
	 *  Ignore the packet, give the client a warning, and close his connection */
 
	if (cs->status < STATUS_AUTH || cs->has_quit) {
 
		SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_AUTHORIZED);
 
		return;
 
	}
 

	
 
	// Check if someone else is receiving the map
 
	/* Check if someone else is receiving the map */
 
	FOR_ALL_CLIENT_SOCKETS(new_cs) {
 
		if (new_cs->status == STATUS_MAP) {
 
			// Tell the new client to wait
 
			/* Tell the new client to wait */
 
			cs->status = STATUS_MAP_WAIT;
 
			SEND_COMMAND(PACKET_SERVER_WAIT)(cs);
 
			return;
 
		}
 
	}
 

	
 
	// We receive a request to upload the map.. give it to the client!
 
	/* We receive a request to upload the map.. give it to the client! */
 
	SEND_COMMAND(PACKET_SERVER_MAP)(cs);
 
}
 

	
 
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK)
 
{
 
	// Client has the map, now start syncing
 
	/* Client has the map, now start syncing */
 
	if (cs->status == STATUS_DONE_MAP && !cs->has_quit) {
 
		char client_name[NETWORK_CLIENT_NAME_LENGTH];
 
		NetworkClientSocket *new_cs;
 
@@ -799,15 +799,15 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 

	
 
		NetworkTextMessage(NETWORK_ACTION_JOIN, CC_DEFAULT, false, client_name);
 

	
 
		// Mark the client as pre-active, and wait for an ACK
 
		//  so we know he is done loading and in sync with us
 
		/* Mark the client as pre-active, and wait for an ACK
 
		 *  so we know he is done loading and in sync with us */
 
		cs->status = STATUS_PRE_ACTIVE;
 
		NetworkHandleCommandQueue(cs);
 
		SEND_COMMAND(PACKET_SERVER_FRAME)(cs);
 
		SEND_COMMAND(PACKET_SERVER_SYNC)(cs);
 

	
 
		// This is the frame the client receives
 
		//  we need it later on to make sure the client is not too slow
 
		/* This is the frame the client receives
 
		 *  we need it later on to make sure the client is not too slow */
 
		cs->last_frame = _frame_counter;
 
		cs->last_frame_server = _frame_counter;
 

	
 
@@ -831,7 +831,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
		/* quickly update the syncing client with company details */
 
		SEND_COMMAND(PACKET_SERVER_COMPANY_UPDATE)(cs);
 
	} else {
 
		// Wrong status for this packet, give a warning to client, and close connection
 
		/* Wrong status for this packet, give a warning to client, and close connection */
 
		SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
 
	}
 
}
 
@@ -844,8 +844,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
{
 
	NetworkClientSocket *new_cs;
 

	
 
	// The client was never joined.. so this is impossible, right?
 
	//  Ignore the packet, give the client a warning, and close his connection
 
	/* The client was never joined.. so this is impossible, right?
 
	 *  Ignore the packet, give the client a warning, and close his connection */
 
	if (cs->status < STATUS_DONE_MAP || cs->has_quit) {
 
		SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
 
		return;
 
@@ -912,19 +912,19 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
		cp.p2 = cs->client_id;
 
	}
 

	
 
	// The frame can be executed in the same frame as the next frame-packet
 
	//  That frame just before that frame is saved in _frame_counter_max
 
	/* The frame can be executed in the same frame as the next frame-packet
 
	 *  That frame just before that frame is saved in _frame_counter_max */
 
	cp.frame = _frame_counter_max + 1;
 
	cp.next  = NULL;
 

	
 
	CommandCallback *callback = cp.callback;
 

	
 
	// Queue the command for the clients (are send at the end of the frame
 
	//   if they can handle it ;))
 
	/* Queue the command for the clients (are send at the end of the frame
 
	 *   if they can handle it ;)) */
 
	FOR_ALL_CLIENT_SOCKETS(new_cs) {
 
		if (new_cs->status >= STATUS_MAP) {
 
			// Callbacks are only send back to the client who sent them in the
 
			//  first place. This filters that out.
 
			/* Callbacks are only send back to the client who sent them in the
 
			 *  first place. This filters that out. */
 
			cp.callback = (new_cs != cs) ? NULL : callback;
 
			cp.my_cmd = (new_cs == cs);
 
			NetworkAddCommandQueue(cp, new_cs);
 
@@ -938,14 +938,14 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 

	
 
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ERROR)
 
{
 
	// This packets means a client noticed an error and is reporting this
 
	//  to us. Display the error and report it to the other clients
 
	/* This packets means a client noticed an error and is reporting this
 
	 *  to us. Display the error and report it to the other clients */
 
	NetworkClientSocket *new_cs;
 
	char str[100];
 
	char client_name[NETWORK_CLIENT_NAME_LENGTH];
 
	NetworkErrorCode errorno = (NetworkErrorCode)p->Recv_uint8();
 

	
 
	// The client was never joined.. thank the client for the packet, but ignore it
 
	/* The client was never joined.. thank the client for the packet, but ignore it */
 
	if (cs->status < STATUS_DONE_MAP || cs->has_quit) {
 
		cs->has_quit = true;
 
		return;
 
@@ -971,12 +971,12 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 

	
 
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_QUIT)
 
{
 
	// The client wants to leave. Display this and report it to the other
 
	//  clients.
 
	/* The client wants to leave. Display this and report it to the other
 
	 *  clients. */
 
	NetworkClientSocket *new_cs;
 
	char client_name[NETWORK_CLIENT_NAME_LENGTH];
 

	
 
	// The client was never joined.. thank the client for the packet, but ignore it
 
	/* The client was never joined.. thank the client for the packet, but ignore it */
 
	if (cs->status < STATUS_DONE_MAP || cs->has_quit) {
 
		cs->has_quit = true;
 
		return;
 
@@ -1024,9 +1024,9 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
		IConsoleCmdExec("exec scripts/on_server_connect.scr 0");
 
	}
 

	
 
	// The client received the frame, make note of it
 
	/* The client received the frame, make note of it */
 
	cs->last_frame = frame;
 
	// With those 2 values we can calculate the lag realtime
 
	/* With those 2 values we can calculate the lag realtime */
 
	cs->last_frame_server = _frame_counter;
 
}
 

	
 
@@ -1055,7 +1055,7 @@ void NetworkServerSendChat(NetworkAction
 
			}
 
		}
 

	
 
		// Display the message locally (so you know you have sent it)
 
		/* Display the message locally (so you know you have sent it) */
 
		if (from_id != (ClientID)dest) {
 
			if (from_id == CLIENT_ID_SERVER) {
 
				ci = NetworkFindClientInfoFromClientID(from_id);
 
@@ -1074,8 +1074,8 @@ void NetworkServerSendChat(NetworkAction
 
		break;
 
	case DESTTYPE_TEAM: {
 
		bool show_local = true; // If this is false, the message is already displayed
 
														// on the client who did sent it.
 
		/* Find all clients that belong to this company */
 
														/* on the client who did sent it.
 
		 * Find all clients that belong to this company */
 
		ci_to = NULL;
 
		FOR_ALL_CLIENT_SOCKETS(cs) {
 
			ci = cs->GetInfo();
 
@@ -1097,7 +1097,7 @@ void NetworkServerSendChat(NetworkAction
 
		/* There is no such client */
 
		if (ci_to == NULL) break;
 

	
 
		// Display the message locally (so you know you have sent it)
 
		/* Display the message locally (so you know you have sent it) */
 
		if (ci != NULL && show_local) {
 
			if (from_id == CLIENT_ID_SERVER) {
 
				char name[NETWORK_NAME_LENGTH];
 
@@ -1199,7 +1199,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
	if (cs->has_quit) return;
 

	
 
	if (ci != NULL) {
 
		// Display change
 
		/* Display change */
 
		if (NetworkFindName(client_name)) {
 
			NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, client_name);
 
			strecpy(ci->client_name, client_name, lastof(ci->client_name));
 
@@ -1255,56 +1255,56 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
	NetworkServerDoMove(cs->client_id, company_id);
 
}
 

	
 
// The layout for the receive-functions by the server
 
/* The layout for the receive-functions by the server */
 
typedef void NetworkServerPacket(NetworkClientSocket *cs, Packet *p);
 

	
 

	
 
// This array matches PacketType. At an incoming
 
//  packet it is matches against this array
 
//  and that way the right function to handle that
 
//  packet is found.
 
/* This array matches PacketType. At an incoming
 
 *  packet it is matches against this array
 
 *  and that way the right function to handle that
 
 *  packet is found. */
 
static NetworkServerPacket * const _network_server_packet[] = {
 
	NULL, /*PACKET_SERVER_FULL,*/
 
	NULL, /*PACKET_SERVER_BANNED,*/
 
	NULL, // PACKET_SERVER_FULL,
 
	NULL, // PACKET_SERVER_BANNED,
 
	RECEIVE_COMMAND(PACKET_CLIENT_JOIN),
 
	NULL, /*PACKET_SERVER_ERROR,*/
 
	NULL, // PACKET_SERVER_ERROR,
 
	RECEIVE_COMMAND(PACKET_CLIENT_COMPANY_INFO),
 
	NULL, /*PACKET_SERVER_COMPANY_INFO,*/
 
	NULL, /*PACKET_SERVER_CLIENT_INFO,*/
 
	NULL, /*PACKET_SERVER_NEED_PASSWORD,*/
 
	NULL, // PACKET_SERVER_COMPANY_INFO,
 
	NULL, // PACKET_SERVER_CLIENT_INFO,
 
	NULL, // PACKET_SERVER_NEED_PASSWORD,
 
	RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD),
 
	NULL, /*PACKET_SERVER_WELCOME,*/
 
	NULL, // PACKET_SERVER_WELCOME,
 
	RECEIVE_COMMAND(PACKET_CLIENT_GETMAP),
 
	NULL, /*PACKET_SERVER_WAIT,*/
 
	NULL, /*PACKET_SERVER_MAP,*/
 
	NULL, // PACKET_SERVER_WAIT,
 
	NULL, // PACKET_SERVER_MAP,
 
	RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK),
 
	NULL, /*PACKET_SERVER_JOIN,*/
 
	NULL, /*PACKET_SERVER_FRAME,*/
 
	NULL, /*PACKET_SERVER_SYNC,*/
 
	NULL, // PACKET_SERVER_JOIN,
 
	NULL, // PACKET_SERVER_FRAME,
 
	NULL, // PACKET_SERVER_SYNC,
 
	RECEIVE_COMMAND(PACKET_CLIENT_ACK),
 
	RECEIVE_COMMAND(PACKET_CLIENT_COMMAND),
 
	NULL, /*PACKET_SERVER_COMMAND,*/
 
	NULL, // PACKET_SERVER_COMMAND,
 
	RECEIVE_COMMAND(PACKET_CLIENT_CHAT),
 
	NULL, /*PACKET_SERVER_CHAT,*/
 
	NULL, // PACKET_SERVER_CHAT,
 
	RECEIVE_COMMAND(PACKET_CLIENT_SET_PASSWORD),
 
	RECEIVE_COMMAND(PACKET_CLIENT_SET_NAME),
 
	RECEIVE_COMMAND(PACKET_CLIENT_QUIT),
 
	RECEIVE_COMMAND(PACKET_CLIENT_ERROR),
 
	NULL, /*PACKET_SERVER_QUIT,*/
 
	NULL, /*PACKET_SERVER_ERROR_QUIT,*/
 
	NULL, /*PACKET_SERVER_SHUTDOWN,*/
 
	NULL, /*PACKET_SERVER_NEWGAME,*/
 
	NULL, /*PACKET_SERVER_RCON,*/
 
	NULL, // PACKET_SERVER_QUIT,
 
	NULL, // PACKET_SERVER_ERROR_QUIT,
 
	NULL, // PACKET_SERVER_SHUTDOWN,
 
	NULL, // PACKET_SERVER_NEWGAME,
 
	NULL, // PACKET_SERVER_RCON,
 
	RECEIVE_COMMAND(PACKET_CLIENT_RCON),
 
	NULL, /*PACKET_CLIENT_CHECK_NEWGRFS,*/
 
	NULL, // PACKET_CLIENT_CHECK_NEWGRFS,
 
	RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED),
 
	NULL, /*PACKET_SERVER_MOVE,*/
 
	NULL, // PACKET_SERVER_MOVE,
 
	RECEIVE_COMMAND(PACKET_CLIENT_MOVE),
 
	NULL, /*PACKET_SERVER_COMPANY_UPDATE,*/
 
	NULL, /*PACKET_SERVER_CONFIG_UPDATE,*/
 
	NULL, // PACKET_SERVER_COMPANY_UPDATE,
 
	NULL, // PACKET_SERVER_CONFIG_UPDATE,
 
};
 

	
 
// If this fails, check the array above with network_data.h
 
/* If this fails, check the array above with network_data.h */
 
assert_compile(lengthof(_network_server_packet) == PACKET_END);
 

	
 
void NetworkSocketHandler::Send_CompanyInformation(Packet *p, const Company *c, const NetworkCompanyStats *stats)
 
@@ -1373,7 +1373,7 @@ void NetworkPopulateCompanyStats(Network
 
		stats[v->owner].num_vehicle[type]++;
 
	}
 

	
 
	// Go through all stations and count the types of stations
 
	/* Go through all stations and count the types of stations */
 
	FOR_ALL_STATIONS(s) {
 
		if (IsValidCompanyID(s->owner)) {
 
			NetworkCompanyStats *npi = &stats[s->owner];
 
@@ -1387,7 +1387,7 @@ void NetworkPopulateCompanyStats(Network
 
	}
 
}
 

	
 
// Send a packet to all clients with updated info about this client_id
 
/* Send a packet to all clients with updated info about this client_id */
 
void NetworkUpdateClientInfo(ClientID client_id)
 
{
 
	NetworkClientSocket *cs;
 
@@ -1465,8 +1465,8 @@ static void NetworkAutoCleanCompanies()
 
	}
 
}
 

	
 
// This function changes new_name to a name that is unique (by adding #1 ...)
 
//  and it returns true if that succeeded.
 
/* This function changes new_name to a name that is unique (by adding #1 ...)
 
 *  and it returns true if that succeeded. */
 
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH])
 
{
 
	bool found_name = false;
 
@@ -1530,7 +1530,7 @@ bool NetworkServerChangeClientName(Clien
 
	return true;
 
}
 

	
 
// Reads a packet from the stream
 
/* Reads a packet from the stream */
 
bool NetworkServer_ReadPackets(NetworkClientSocket *cs)
 
{
 
	Packet *p;
 
@@ -1548,7 +1548,7 @@ bool NetworkServer_ReadPackets(NetworkCl
 
	return true;
 
}
 

	
 
// Handle the local command-queue
 
/* Handle the local command-queue */
 
static void NetworkHandleCommandQueue(NetworkClientSocket *cs)
 
{
 
	CommandPacket *cp;
 
@@ -1561,7 +1561,7 @@ static void NetworkHandleCommandQueue(Ne
 
	}
 
}
 

	
 
// This is called every tick if this is a _network_server
 
/* This is called every tick if this is a _network_server */
 
void NetworkServer_Tick(bool send_frame)
 
{
 
	NetworkClientSocket *cs;
 
@@ -1576,23 +1576,23 @@ void NetworkServer_Tick(bool send_frame)
 
	}
 
#endif
 

	
 
	// Now we are done with the frame, inform the clients that they can
 
	//  do their frame!
 
	/* Now we are done with the frame, inform the clients that they can
 
	 *  do their frame! */
 
	FOR_ALL_CLIENT_SOCKETS(cs) {
 
		// Check if the speed of the client is what we can expect from a client
 
		/* Check if the speed of the client is what we can expect from a client */
 
		if (cs->status == STATUS_ACTIVE) {
 
			// 1 lag-point per day
 
			/* 1 lag-point per day */
 
			int lag = NetworkCalculateLag(cs) / DAY_TICKS;
 
			if (lag > 0) {
 
				if (lag > 3) {
 
					// Client did still not report in after 4 game-day, drop him
 
					//  (that is, the 3 of above, + 1 before any lag is counted)
 
					/* Client did still not report in after 4 game-day, drop him
 
					 *  (that is, the 3 of above, + 1 before any lag is counted) */
 
					IConsolePrintF(CC_ERROR,"Client #%d is dropped because the client did not respond for more than 4 game-days", cs->client_id);
 
					NetworkCloseClient(cs);
 
					continue;
 
				}
 

	
 
				// Report once per time we detect the lag
 
				/* Report once per time we detect the lag */
 
				if (cs->lag_test == 0) {
 
					IConsolePrintF(CC_WARNING,"[%d] Client #%d is slow, try increasing *net_frame_freq to a higher value!", _frame_counter, cs->client_id);
 
					cs->lag_test = 1;
 
@@ -1615,14 +1615,14 @@ void NetworkServer_Tick(bool send_frame)
 
		}
 

	
 
		if (cs->status >= STATUS_PRE_ACTIVE) {
 
			// Check if we can send command, and if we have anything in the queue
 
			/* Check if we can send command, and if we have anything in the queue */
 
			NetworkHandleCommandQueue(cs);
 

	
 
			// Send an updated _frame_counter_max to the client
 
			/* Send an updated _frame_counter_max to the client */
 
			if (send_frame) SEND_COMMAND(PACKET_SERVER_FRAME)(cs);
 

	
 
#ifndef ENABLE_NETWORK_SYNC_EVERY_FRAME
 
			// Send a sync-check packet
 
			/* Send a sync-check packet */
 
			if (send_sync) SEND_COMMAND(PACKET_SERVER_SYNC)(cs);
 
#endif
 
		}
src/network/network_udp.cpp
Show inline comments
 
@@ -69,7 +69,7 @@ public:
 

	
 
DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER)
 
{
 
	// Just a fail-safe.. should never happen
 
	/* Just a fail-safe.. should never happen */
 
	if (!_network_udp_server) {
 
		return;
 
	}
 
@@ -101,7 +101,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_U
 
	Packet packet(PACKET_UDP_SERVER_RESPONSE);
 
	this->Send_NetworkGameInfo(&packet, &ngi);
 

	
 
	// Let the client know that we are here
 
	/* Let the client know that we are here */
 
	this->SendPacket(&packet, client_addr);
 

	
 
	DEBUG(net, 2, "[udp] queried from '%s'", inet_ntoa(client_addr->sin_addr));
 
@@ -109,7 +109,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_U
 

	
 
DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_DETAIL_INFO)
 
{
 
	// Just a fail-safe.. should never happen
 
	/* Just a fail-safe.. should never happen */
 
	if (!_network_udp_server) return;
 

	
 
	Packet packet(PACKET_UDP_SERVER_DETAIL_INFO);
 
@@ -214,12 +214,12 @@ DEF_UDP_RECEIVE_COMMAND(Client, PACKET_U
 
{
 
	NetworkGameList *item;
 

	
 
	// Just a fail-safe.. should never happen
 
	/* Just a fail-safe.. should never happen */
 
	if (_network_udp_server) return;
 

	
 
	DEBUG(net, 4, "[udp] server response from %s:%d", inet_ntoa(client_addr->sin_addr), ntohs(client_addr->sin_port));
 

	
 
	// Find next item
 
	/* Find next item */
 
	item = NetworkGameListAddItem(inet_addr(inet_ntoa(client_addr->sin_addr)), ntohs(client_addr->sin_port));
 

	
 
	this->Recv_NetworkGameInfo(p, &item->info);
 
@@ -347,7 +347,7 @@ void ClientNetworkUDPSocketHandler::Hand
 
	SetBit(config->flags, GCF_COPY);
 
}
 

	
 
// Close UDP connection
 
/* Close UDP connection */
 
void NetworkUDPCloseAll()
 
{
 
	DEBUG(net, 1, "[udp] closed listeners");
 
@@ -362,7 +362,7 @@ void NetworkUDPCloseAll()
 
	_network_udp_broadcast = 0;
 
}
 

	
 
// Broadcast to all ips
 
/* Broadcast to all ips */
 
static void NetworkUDPBroadCast(NetworkUDPSocketHandler *socket)
 
{
 
	uint i;
 
@@ -382,7 +382,7 @@ static void NetworkUDPBroadCast(NetworkU
 
}
 

	
 

	
 
// Request the the server-list from the master server
 
/* Request the the server-list from the master server */
 
void NetworkUDPQueryMasterServer()
 
{
 
	struct sockaddr_in out_addr;
 
@@ -397,7 +397,7 @@ void NetworkUDPQueryMasterServer()
 
	out_addr.sin_port = htons(NETWORK_MASTER_SERVER_PORT);
 
	out_addr.sin_addr.s_addr = NetworkResolveHost(NETWORK_MASTER_SERVER_HOST);
 

	
 
	// packet only contains protocol version
 
	/* packet only contains protocol version */
 
	p.Send_uint8(NETWORK_MASTER_SERVER_VERSION);
 

	
 
	_udp_client_socket->SendPacket(&p, &out_addr);
 
@@ -405,13 +405,13 @@ void NetworkUDPQueryMasterServer()
 
	DEBUG(net, 2, "[udp] master server queried at %s:%d", inet_ntoa(out_addr.sin_addr), ntohs(out_addr.sin_port));
 
}
 

	
 
// Find all servers
 
/* Find all servers */
 
void NetworkUDPSearchGame()
 
{
 
	// We are still searching..
 
	/* We are still searching.. */
 
	if (_network_udp_broadcast > 0) return;
 

	
 
	// No UDP-socket yet..
 
	/* No UDP-socket yet.. */
 
	if (!_udp_client_socket->IsConnected()) {
 
		if (!_udp_client_socket->Listen(0, 0, true)) return;
 
	}
 
@@ -465,7 +465,7 @@ void NetworkUDPQueryServerThread(void *p
 

	
 
void NetworkUDPQueryServer(NetworkAddress address, bool manually)
 
{
 
	// No UDP-socket yet..
 
	/* No UDP-socket yet.. */
 
	if (!_udp_client_socket->IsConnected()) {
 
		if (!_udp_client_socket->Listen(0, 0, true)) return;
 
	}
src/newgrf.cpp
Show inline comments
 
@@ -1217,7 +1217,6 @@ static ChangeInfoResult StationChangeInf
 

	
 
					if (length == 0 || number == 0) break;
 

	
 
					//debug("l %d > %d ?", length, stat->lengths);
 
					if (length > statspec->lengths) {
 
						statspec->platforms = ReallocT(statspec->platforms, length);
 
						memset(statspec->platforms + statspec->lengths, 0, length - statspec->lengths);
 
@@ -1230,7 +1229,6 @@ static ChangeInfoResult StationChangeInf
 
					}
 
					l = length - 1; // index is zero-based
 

	
 
					//debug("p %d > %d ?", number, stat->platforms[l]);
 
					if (number > statspec->platforms[l]) {
 
						statspec->layouts[l] = ReallocT(statspec->layouts[l], number);
 
						/* We expect NULL being 0 here, but C99 guarantees that. */
 
@@ -1895,7 +1893,7 @@ static ChangeInfoResult CargoChangeInfo(
 
		CargoSpec *cs = &_cargo[cid + i];
 

	
 
		switch (prop) {
 
			case 0x08: /* Bit number of cargo */
 
			case 0x08: // Bit number of cargo
 
				cs->bitnum = grf_load_byte(&buf);
 
				if (cs->IsValid()) {
 
					cs->grffile = _cur_grffile;
 
@@ -1905,12 +1903,12 @@ static ChangeInfoResult CargoChangeInfo(
 
				}
 
				break;
 

	
 
			case 0x09: /* String ID for cargo type name */
 
			case 0x09: // String ID for cargo type name
 
				cs->name = grf_load_word(&buf);
 
				_string_to_grf_mapping[&cs->name] = _cur_grffile->grfid;
 
				break;
 

	
 
			case 0x0A: /* String for 1 unit of cargo */
 
			case 0x0A: // String for 1 unit of cargo
 
				cs->name_single = grf_load_word(&buf);
 
				_string_to_grf_mapping[&cs->name_single] = _cur_grffile->grfid;
 
				break;
 
@@ -1922,58 +1920,58 @@ static ChangeInfoResult CargoChangeInfo(
 
				_string_to_grf_mapping[&cs->units_volume] = _cur_grffile->grfid;
 
				break;
 

	
 
			case 0x0C: /* String for quantity of cargo (e.g. 10 tonnes of coal) */
 
			case 0x0C: // String for quantity of cargo (e.g. 10 tonnes of coal)
 
				cs->quantifier = grf_load_word(&buf);
 
				_string_to_grf_mapping[&cs->quantifier] = _cur_grffile->grfid;
 
				break;
 

	
 
			case 0x0D: /* String for two letter cargo abbreviation */
 
			case 0x0D: // String for two letter cargo abbreviation
 
				cs->abbrev = grf_load_word(&buf);
 
				_string_to_grf_mapping[&cs->abbrev] = _cur_grffile->grfid;
 
				break;
 

	
 
			case 0x0E: /* Sprite ID for cargo icon */
 
			case 0x0E: // Sprite ID for cargo icon
 
				cs->sprite = grf_load_word(&buf);
 
				break;
 

	
 
			case 0x0F: /* Weight of one unit of cargo */
 
			case 0x0F: // Weight of one unit of cargo
 
				cs->weight = grf_load_byte(&buf);
 
				break;
 

	
 
			case 0x10: /* Used for payment calculation */
 
			case 0x10: // Used for payment calculation
 
				cs->transit_days[0] = grf_load_byte(&buf);
 
				break;
 

	
 
			case 0x11: /* Used for payment calculation */
 
			case 0x11: // Used for payment calculation
 
				cs->transit_days[1] = grf_load_byte(&buf);
 
				break;
 

	
 
			case 0x12: /* Base cargo price */
 
			case 0x12: // Base cargo price
 
				cs->initial_payment = grf_load_dword(&buf);
 
				break;
 

	
 
			case 0x13: /* Colour for station rating bars */
 
			case 0x13: // Colour for station rating bars
 
				cs->rating_colour = MapDOSColour(grf_load_byte(&buf));
 
				break;
 

	
 
			case 0x14: /* Colour for cargo graph */
 
			case 0x14: // Colour for cargo graph
 
				cs->legend_colour = MapDOSColour(grf_load_byte(&buf));
 
				break;
 

	
 
			case 0x15: /* Freight status */
 
			case 0x15: // Freight status
 
				cs->is_freight = (grf_load_byte(&buf) != 0);
 
				break;
 

	
 
			case 0x16: /* Cargo classes */
 
			case 0x16: // Cargo classes
 
				cs->classes = grf_load_word(&buf);
 
				break;
 

	
 
			case 0x17: /* Cargo label */
 
			case 0x17: // Cargo label
 
				cs->label = grf_load_dword(&buf);
 
				cs->label = BSWAP32(cs->label);
 
				break;
 

	
 
			case 0x18: { /* Town growth substitute type */
 
			case 0x18: { // Town growth substitute type
 
				uint8 substitute_type = grf_load_byte(&buf);
 

	
 
				switch (substitute_type) {
 
@@ -1988,11 +1986,11 @@ static ChangeInfoResult CargoChangeInfo(
 
				}
 
			} break;
 

	
 
			case 0x19: /* Town growth coefficient */
 
			case 0x19: // Town growth coefficient
 
				cs->multipliertowngrowth = grf_load_word(&buf);
 
				break;
 

	
 
			case 0x1A: /* Bitmask of callbacks to use */
 
			case 0x1A: // Bitmask of callbacks to use
 
				cs->callback_mask = grf_load_byte(&buf);
 
				break;
 

	
 
@@ -2253,8 +2251,8 @@ static ChangeInfoResult IndustriesChange
 

	
 
						if (itt[k].ti.x == 0xFE && k == 0) {
 
							/* This means we have to borrow the layout from an old industry */
 
							IndustryType type = grf_load_byte(&buf);  //industry holding required layout
 
							byte laynbr = grf_load_byte(&buf);        //layout number to borrow
 
							IndustryType type = grf_load_byte(&buf);  // industry holding required layout
 
							byte laynbr = grf_load_byte(&buf);        // layout number to borrow
 

	
 
							copy_from = (IndustryTileTable*)_origin_industry_specs[type].table[laynbr];
 
							for (size = 1;; size++) {
 
@@ -2486,7 +2484,7 @@ static void FeatureChangeInfo(byte *buf,
 
		/* GSF_GLOBALVAR */    GlobalVarChangeInfo,
 
		/* GSF_INDUSTRYTILES */IndustrytilesChangeInfo,
 
		/* GSF_INDUSTRIES */   IndustriesChangeInfo,
 
		/* GSF_CARGOS */       NULL, /* Cargo is handled during reservation */
 
		/* GSF_CARGOS */       NULL, // Cargo is handled during reservation
 
		/* GSF_SOUNDFX */      SoundEffectChangeInfo,
 
	};
 

	
 
@@ -4000,8 +3998,8 @@ static void DisableStaticNewGRFInfluenci
 
	ClearTemporaryNewGRFData(GetFileByGRFID(c->grfid));
 
}
 

	
 
/* Action 0x07 */
 
/* Action 0x09 */
 
/* Action 0x07
 
 * Action 0x09 */
 
static void SkipIf(byte *buf, size_t len)
 
{
 
	/* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites>
 
@@ -4629,7 +4627,7 @@ static void ParamSet(byte *buf, size_t l
 
								src1 = PerformGRM(&_grm_engines[_engine_offsets[feature]], _engine_counts[feature], count, op, target, "vehicles");
 
								if (_skip_sprites == -1) return;
 
							} else {
 
								// GRM does not apply for dynamic engine allocation.
 
								/* GRM does not apply for dynamic engine allocation. */
 
								switch (op) {
 
									case 2:
 
									case 3:
 
@@ -5913,8 +5911,8 @@ static void FinaliseIndustriesArray()
 

	
 
/* Here we perform initial decoding of some special sprites (as are they
 
 * described at http://www.ttdpatch.net/src/newgrf.txt, but this is only a very
 
 * partial implementation yet). */
 
/* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by
 
 * partial implementation yet).
 
 * XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by
 
 * a crafted invalid GRF file. We should tell that to the user somehow, or
 
 * better make this more robust in the future. */
 
static void DecodeSpecialSprite(byte *buf, uint num, GrfLoadingStage stage)
 
@@ -5927,8 +5925,8 @@ static void DecodeSpecialSprite(byte *bu
 
	 * overwritten after action 3 associates them. But overwriting happens
 
	 * in an earlier stage than associating, so...  We just process actions
 
	 * 1 and 2 in stage 2 now, let's hope that won't get us into problems.
 
	 * --pasky */
 
	/* We need a pre-stage to set up GOTO labels of Action 0x10 because the grf
 
	 * --pasky
 
	 * We need a pre-stage to set up GOTO labels of Action 0x10 because the grf
 
	 * is not in memory and scanning the file every time would be too expensive.
 
	 * In other stages we skip action 0x10 since it's already dealt with. */
 
	static const SpecialSpriteHandler handlers[][GLS_END] = {
src/newgrf_engine.cpp
Show inline comments
 
@@ -1044,8 +1044,8 @@ static void DoTriggerVehicle(Vehicle *v,
 
	switch (trigger) {
 
		case VEHICLE_TRIGGER_NEW_CARGO:
 
			/* All vehicles in chain get ANY_NEW_CARGO trigger now.
 
			 * So we call it for the first one and they will recurse. */
 
			/* Indexing part of vehicle random bits needs to be
 
			 * So we call it for the first one and they will recurse.
 
			 * Indexing part of vehicle random bits needs to be
 
			 * same for all triggered vehicles in the chain (to get
 
			 * all the random-cargo wagons carry the same cargo,
 
			 * i.e.), so we give them all the NEW_CARGO triggered
src/newgrf_industries.cpp
Show inline comments
 
@@ -172,7 +172,7 @@ static uint32 GetCountAndDistanceOfClose
 
			GrfID = GetIndustrySpec(current->type)->grf_prop.grffile->grfid;
 
			/* Fall through */
 

	
 
		default: //use the grfid specified in register 100h
 
		default: // use the grfid specified in register 100h
 
			SetBit(param_setID, 7); // bit 7 means it is not an old type
 
			ind_index = MapNewGRFIndustryType(param_setID, GrfID);
 
			break;
 
@@ -327,7 +327,7 @@ uint32 IndustryGetVariable(const Resolve
 
		case 0x85: DEBUG(grf, 0, "NewGRFs shouldn't be doing pointer magic"); break; // not supported
 
		case 0x86: return industry->width;
 
		case 0x87: return industry->height;// xy dimensions
 
		/*  */
 

	
 
		case 0x88:
 
		case 0x89: return industry->produced_cargo[variable - 0x88];
 
		case 0x8A: return industry->produced_cargo_waiting[0];
src/newgrf_text.cpp
Show inline comments
 
@@ -179,7 +179,7 @@ char *TranslateTTDPatchCodes(uint32 grfi
 
			case 0x98: d += Utf8Encode(d, SCC_BLACK);   break;
 
			case 0x9A:
 
				switch (*str++) {
 
					case 0: /* FALL THROUGH */
 
					case 0: // FALL THROUGH
 
					case 1:
 
						d += Utf8Encode(d, SCC_NEWGRF_PRINT_QWORD_CURRENCY);
 
						break;
 
@@ -343,7 +343,7 @@ const char *GetGRFStringPtr(uint16 strin
 
	/* Remember this grfid in case the string has included text */
 
	_last_grfid = _grf_text[stringid].grfid;
 

	
 
	/*Search the list of lang-strings of this stringid for current lang */
 
	/* Search the list of lang-strings of this stringid for current lang */
 
	for (search_text = _grf_text[stringid].textholder; search_text != NULL; search_text = search_text->next) {
 
		if (search_text->langid == _currentLangID) {
 
			return search_text->text;
src/npf.cpp
Show inline comments
 
@@ -40,12 +40,12 @@ static uint NPFDistanceTrack(TileIndex t
 
	const uint dx = Delta(TileX(t0), TileX(t1));
 
	const uint dy = Delta(TileY(t0), TileY(t1));
 

	
 
	const uint straightTracks = 2 * min(dx, dy); /* The number of straight (not full length) tracks */
 
	const uint straightTracks = 2 * min(dx, dy); // The number of straight (not full length) tracks
 
	/* OPTIMISATION:
 
	 * Original: diagTracks = max(dx, dy) - min(dx,dy);
 
	 * Proof:
 
	 * (dx+dy) - straightTracks  == (min + max) - straightTracks = min + max - 2 * min = max - min */
 
	const uint diagTracks = dx + dy - straightTracks; /* The number of diagonal (full tile length) tracks. */
 
	const uint diagTracks = dx + dy - straightTracks; // The number of diagonal (full tile length) tracks.
 

	
 
	/* Don't factor out NPF_TILE_LENGTH below, this will round values and lose
 
	 * precision */
 
@@ -313,10 +313,10 @@ static int32 NPFRailPathCost(AyStar *as,
 
			break;
 

	
 
		case MP_RAILWAY:
 
			cost = _trackdir_length[trackdir]; /* Should be different for diagonal tracks */
 
			cost = _trackdir_length[trackdir]; // Should be different for diagonal tracks
 
			break;
 

	
 
		case MP_ROAD: /* Railway crossing */
 
		case MP_ROAD: // Railway crossing
 
			cost = NPF_TILE_LENGTH;
 
			break;
 

	
 
@@ -393,7 +393,7 @@ static int32 NPFRailPathCost(AyStar *as,
 
	/* Check for turns */
 
	if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction))
 
		cost += _settings_game.pf.npf.npf_rail_curve_penalty;
 
	/*TODO, with realistic acceleration, also the amount of straight track between
 
	/* TODO, with realistic acceleration, also the amount of straight track between
 
	 *      curves should be taken into account, as this affects the speed limit. */
 

	
 
	/* Check for reverse in depot */
 
@@ -442,8 +442,8 @@ static int32 NPFFindStationOrTile(AyStar
 
	/* If GetNeighbours said we could get here, we assume the station type
 
	 * is correct */
 
	if (
 
		(fstd->station_index == INVALID_STATION && tile == fstd->dest_coords) || /* We've found the tile, or */
 
		(IsTileType(tile, MP_STATION) && GetStationIndex(tile) == fstd->station_index) /* the station */
 
		(fstd->station_index == INVALID_STATION && tile == fstd->dest_coords) || // We've found the tile, or
 
		(IsTileType(tile, MP_STATION) && GetStationIndex(tile) == fstd->station_index) // the station
 
	) {
 
		return AYSTAR_FOUND_END_NODE;
 
	} else {
 
@@ -548,11 +548,11 @@ static void NPFSaveTargetData(AyStar *as
 
 */
 
static bool CanEnterTileOwnerCheck(Owner owner, TileIndex tile, DiagDirection enterdir)
 
{
 
	if (IsTileType(tile, MP_RAILWAY) ||             /* Rail tile (also rail depot) */
 
			IsRailwayStationTile(tile) ||   /* Rail station tile */
 
			IsRoadDepotTile(tile) ||        /* Road depot tile */
 
			IsStandardRoadStopTile(tile)) { /* Road station tile (but not drive-through stops) */
 
		return IsTileOwner(tile, owner); /* You need to own these tiles entirely to use them */
 
	if (IsTileType(tile, MP_RAILWAY) || // Rail tile (also rail depot)
 
			IsRailwayStationTile(tile) ||   // Rail station tile
 
			IsRoadDepotTile(tile) ||        // Road depot tile
 
			IsStandardRoadStopTile(tile)) { // Road station tile (but not drive-through stops)
 
		return IsTileOwner(tile, owner);  // You need to own these tiles entirely to use them
 
	}
 

	
 
	switch (GetTileType(tile)) {
 
@@ -560,7 +560,7 @@ static bool CanEnterTileOwnerCheck(Owner
 
			/* rail-road crossing : are we looking at the railway part? */
 
			if (IsLevelCrossing(tile) &&
 
					DiagDirToAxis(enterdir) != GetCrossingRoadAxis(tile)) {
 
				return IsTileOwner(tile, owner); /* Railway needs owner check, while the street is public */
 
				return IsTileOwner(tile, owner); // Railway needs owner check, while the street is public
 
			}
 
			break;
 

	
 
@@ -589,7 +589,7 @@ static DiagDirection GetDepotDirection(T
 
		case TRANSPORT_RAIL:  return GetRailDepotDirection(tile);
 
		case TRANSPORT_ROAD:  return GetRoadDepotDirection(tile);
 
		case TRANSPORT_WATER: return GetShipDepotDirection(tile);
 
		default: return INVALID_DIAGDIR; /* Not reached */
 
		default: return INVALID_DIAGDIR; // Not reached
 
	}
 
}
 

	
 
@@ -997,7 +997,7 @@ NPFFoundTargetData NPFRouteToDepotTrialE
 
	}
 

	
 
	/* Initialize target */
 
	target.station_index = INVALID_STATION; /* We will initialize dest_coords inside the loop below */
 
	target.station_index = INVALID_STATION; // We will initialize dest_coords inside the loop below
 
	_npf_aystar.user_target = &target;
 

	
 
	/* Initialize user_data */
 
@@ -1007,7 +1007,7 @@ NPFFoundTargetData NPFRouteToDepotTrialE
 

	
 
	/* Initialize Start Node */
 
	start.tile = tile;
 
	start.direction = trackdir; /* We will initialize user_data inside the loop below */
 
	start.direction = trackdir; // We will initialize user_data inside the loop below
 

	
 
	/* Initialize Result */
 
	_npf_aystar.user_path = &result;
 
@@ -1023,8 +1023,8 @@ NPFFoundTargetData NPFRouteToDepotTrialE
 
		if ( DistanceManhattan(tile, current->xy * NPF_TILE_LENGTH) > best_result.best_path_dist)
 
			break;
 

	
 
		/* Initialize Start Node */
 
		/* We set this in case the target is also the start tile, we will just
 
		/* Initialize Start Node
 
		 * We set this in case the target is also the start tile, we will just
 
		 * return a not found then */
 
		start.user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
 
		start.user_data[NPF_NODE_FLAGS] = 0;
src/oldpool.h
Show inline comments
 
@@ -34,9 +34,9 @@ protected:
 
	const uint max_blocks;      ///< The max amount of blocks this pool can have
 
	const uint block_size_bits; ///< The size of each block in bits
 

	
 
	/// Pointer to a function that is called after a new block is added
 
	/** Pointer to a function that is called after a new block is added */
 
	OldMemoryPoolNewBlock *new_block_proc;
 
	/// Pointer to a function that is called to clean a block
 
	/** Pointer to a function that is called to clean a block */
 
	OldMemoryPoolCleanBlock *clean_block_proc;
 

	
 
	uint current_blocks;        ///< How many blocks we have in our pool
src/openttd.cpp
Show inline comments
 
@@ -907,11 +907,11 @@ void SwitchToMode(SwitchMode new_mode)
 
	if (new_mode != SM_SAVE) AI::KillAll();
 

	
 
	switch (new_mode) {
 
		case SM_EDITOR: /* Switch to scenario editor */
 
		case SM_EDITOR: // Switch to scenario editor
 
			MakeNewEditorWorld();
 
			break;
 

	
 
		case SM_NEWGAME: /* New Game --> 'Random game' */
 
		case SM_NEWGAME: // New Game --> 'Random game'
 
#ifdef ENABLE_NETWORK
 
			if (_network_server) {
 
				snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map");
 
@@ -920,7 +920,7 @@ void SwitchToMode(SwitchMode new_mode)
 
			MakeNewGame(false);
 
			break;
 

	
 
		case SM_START_SCENARIO: /* New Game --> Choose one of the preset scenarios */
 
		case SM_START_SCENARIO: // New Game --> Choose one of the preset scenarios
 
#ifdef ENABLE_NETWORK
 
			if (_network_server) {
 
				snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded scenario)", _file_to_saveload.title);
 
@@ -929,7 +929,7 @@ void SwitchToMode(SwitchMode new_mode)
 
			StartScenario();
 
			break;
 

	
 
		case SM_LOAD: { /* Load game, Play Scenario */
 
		case SM_LOAD: { // Load game, Play Scenario
 
			ResetGRFConfig(true);
 
			ResetWindowSystem();
 

	
 
@@ -957,7 +957,7 @@ void SwitchToMode(SwitchMode new_mode)
 
			break;
 
		}
 

	
 
		case SM_START_HEIGHTMAP: /* Load a heightmap and start a new game from it */
 
		case SM_START_HEIGHTMAP: // Load a heightmap and start a new game from it
 
#ifdef ENABLE_NETWORK
 
			if (_network_server) {
 
				snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Heightmap)", _file_to_saveload.title);
 
@@ -966,14 +966,14 @@ void SwitchToMode(SwitchMode new_mode)
 
			MakeNewGame(true);
 
			break;
 

	
 
		case SM_LOAD_HEIGHTMAP: /* Load heightmap from scenario editor */
 
		case SM_LOAD_HEIGHTMAP: // Load heightmap from scenario editor
 
			SetLocalCompany(OWNER_NONE);
 

	
 
			GenerateWorld(GW_HEIGHTMAP, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
 
			MarkWholeScreenDirty();
 
			break;
 

	
 
		case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */
 
		case SM_LOAD_SCENARIO: { // Load scenario from scenario editor
 
			if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR, NO_DIRECTORY)) {
 
				SetLocalCompany(OWNER_NONE);
 
				_settings_newgame.game_creation.starting_year = _cur_year;
 
@@ -984,11 +984,11 @@ void SwitchToMode(SwitchMode new_mode)
 
			break;
 
		}
 

	
 
		case SM_MENU: /* Switch to game intro menu */
 
		case SM_MENU: // Switch to game intro menu
 
			LoadIntroGame();
 
			break;
 

	
 
		case SM_SAVE: /* Save game */
 
		case SM_SAVE: // Save game
 
			/* Make network saved games on pause compatible to singleplayer */
 
			if (_networking && _pause_game == 1) _pause_game = 2;
 
			if (SaveOrLoad(_file_to_saveload.name, SL_SAVE, NO_DIRECTORY) != SL_OK) {
 
@@ -1000,7 +1000,7 @@ void SwitchToMode(SwitchMode new_mode)
 
			if (_networking && _pause_game == 2) _pause_game = 1;
 
			break;
 

	
 
		case SM_GENRANDLAND: /* Generate random land within scenario editor */
 
		case SM_GENRANDLAND: // Generate random land within scenario editor
 
			SetLocalCompany(OWNER_NONE);
 
			GenerateWorld(GW_RANDOM, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
 
			/* XXX: set date */
src/os/macosx/G5_detector.cpp
Show inline comments
 
@@ -13,7 +13,7 @@
 
#define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
 
#endif
 

	
 
// this function is a lightly modified version of some code from Apple's developer homepage to detect G5 CPUs at runtime
 
/* this function is a lightly modified version of some code from Apple's developer homepage to detect G5 CPUs at runtime */
 
main()
 
{
 
	host_basic_info_data_t hostInfo;
src/os/macosx/macos.h
Show inline comments
 
@@ -31,8 +31,8 @@ void ShowMacDialog ( const char *title, 
 
void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression );
 
void ShowMacErrorDialog(const char *error);
 

	
 
// Since MacOS X users will never see an assert unless they started the game from a terminal
 
// we're using a custom assert(e) macro.
 
/* Since MacOS X users will never see an assert unless they started the game from a terminal
 
 * we're using a custom assert(e) macro. */
 
#undef assert
 

	
 
#ifdef NDEBUG
src/os/macosx/osx_stdafx.h
Show inline comments
 
@@ -6,7 +6,7 @@
 
#define MACOS_STDAFX_H
 

	
 
#include <CoreServices/CoreServices.h>
 
// remove the variables that CoreServices defines, but we define ourselves too
 
/* remove the variables that CoreServices defines, but we define ourselves too */
 
#undef bool
 
#undef false
 
#undef true
src/os2.cpp
Show inline comments
 
@@ -134,13 +134,13 @@ void ShowInfo(const char *str)
 
	HMQ hmq;
 
	ULONG rc;
 

	
 
	// init PM env.
 
	/* init PM env. */
 
	hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
 

	
 
	// display the box
 
	/* display the box */
 
	rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (const unsigned char *)str, (const unsigned char *)"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_INFORMATION);
 

	
 
	// terminate PM env.
 
	/* terminate PM env. */
 
	WinDestroyMsgQueue(hmq);
 
	WinTerminate(hab);
 
}
 
@@ -151,13 +151,13 @@ void ShowOSErrorBox(const char *buf, boo
 
	HMQ hmq;
 
	ULONG rc;
 

	
 
	// init PM env.
 
	/* init PM env. */
 
	hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
 

	
 
	// display the box
 
	/* display the box */
 
	rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (const unsigned char *)buf, (const unsigned char *)"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_ERROR);
 

	
 
	// terminate PM env.
 
	/* terminate PM env. */
 
	WinDestroyMsgQueue(hmq);
 
	WinTerminate(hab);
 
}
src/pathfind.cpp
Show inline comments
 
@@ -660,7 +660,7 @@ start_at:
 

	
 
			/* Check if this rail is an upwards slope. If it is, then add a penalty. */
 
			if (IsDiagonalTrackdir(track) && IsUphillTrackdir(GetTileSlope(tile, NULL), track)) {
 
				// upwards slope. add some penalty.
 
				/* upwards slope. add some penalty. */
 
				si.cur_length += 4 * DIAG_FACTOR;
 
			}
 

	
src/queue.cpp
Show inline comments
 
@@ -289,7 +289,7 @@ void init_BinaryHeap(Queue *q, uint max_
 
#endif
 
}
 

	
 
// Because we don't want anyone else to bother with our defines
 
/* Because we don't want anyone else to bother with our defines */
 
#undef BIN_HEAP_ARR
 

	
 
/*
 
@@ -502,14 +502,14 @@ void *Hash_Delete(Hash *h, uint key1, ui
 
			free(next);
 
#endif
 
		} else {
 
			/* This was the last in this bucket */
 
			/* Mark it as empty */
 
			/* This was the last in this bucket
 
			 * Mark it as empty */
 
			uint hash = h->hash(key1, key2);
 
			h->buckets_in_use[hash] = false;
 
		}
 
	} else {
 
		/* It is in another node */
 
		/* Save the value */
 
		/* It is in another node
 
		 * Save the value */
 
		result = node->value;
 
		/* Link previous and next nodes */
 
		prev->next = node->next;
src/rail.cpp
Show inline comments
 
@@ -36,10 +36,10 @@ extern const byte _signal_on_track[] = {
 
 * track entering in this direction (including those making 90 degree turns)
 
 */
 
extern const TrackdirBits _exitdir_reaches_trackdirs[] = {
 
	TRACKDIR_BIT_X_NE | TRACKDIR_BIT_LOWER_E | TRACKDIR_BIT_LEFT_N,  /* DIAGDIR_NE */
 
	TRACKDIR_BIT_Y_SE | TRACKDIR_BIT_LEFT_S  | TRACKDIR_BIT_UPPER_E, /* DIAGDIR_SE */
 
	TRACKDIR_BIT_X_SW | TRACKDIR_BIT_UPPER_W | TRACKDIR_BIT_RIGHT_S, /* DIAGDIR_SW */
 
	TRACKDIR_BIT_Y_NW | TRACKDIR_BIT_RIGHT_N | TRACKDIR_BIT_LOWER_W  /* DIAGDIR_NW */
 
	TRACKDIR_BIT_X_NE | TRACKDIR_BIT_LOWER_E | TRACKDIR_BIT_LEFT_N,  // DIAGDIR_NE
 
	TRACKDIR_BIT_Y_SE | TRACKDIR_BIT_LEFT_S  | TRACKDIR_BIT_UPPER_E, // DIAGDIR_SE
 
	TRACKDIR_BIT_X_SW | TRACKDIR_BIT_UPPER_W | TRACKDIR_BIT_RIGHT_S, // DIAGDIR_SW
 
	TRACKDIR_BIT_Y_NW | TRACKDIR_BIT_RIGHT_N | TRACKDIR_BIT_LOWER_W  // DIAGDIR_NW
 
};
 

	
 
extern const Trackdir _next_trackdir[TRACKDIR_END] = {
 
@@ -49,22 +49,22 @@ extern const Trackdir _next_trackdir[TRA
 

	
 
/* Maps a trackdir to all trackdirs that make 90 deg turns with it. */
 
extern const TrackdirBits _track_crosses_trackdirs[TRACKDIR_END] = {
 
	TRACKDIR_BIT_Y_SE     | TRACKDIR_BIT_Y_NW,                                                   /* TRACK_X     */
 
	TRACKDIR_BIT_X_NE     | TRACKDIR_BIT_X_SW,                                                   /* TRACK_Y     */
 
	TRACKDIR_BIT_RIGHT_N  | TRACKDIR_BIT_RIGHT_S  | TRACKDIR_BIT_LEFT_N  | TRACKDIR_BIT_LEFT_S,  /* TRACK_UPPER */
 
	TRACKDIR_BIT_RIGHT_N  | TRACKDIR_BIT_RIGHT_S  | TRACKDIR_BIT_LEFT_N  | TRACKDIR_BIT_LEFT_S,  /* TRACK_LOWER */
 
	TRACKDIR_BIT_UPPER_W  | TRACKDIR_BIT_UPPER_E  | TRACKDIR_BIT_LOWER_W | TRACKDIR_BIT_LOWER_E, /* TRACK_LEFT  */
 
	TRACKDIR_BIT_UPPER_W  | TRACKDIR_BIT_UPPER_E  | TRACKDIR_BIT_LOWER_W | TRACKDIR_BIT_LOWER_E  /* TRACK_RIGHT */
 
	TRACKDIR_BIT_Y_SE     | TRACKDIR_BIT_Y_NW,                                                   // TRACK_X
 
	TRACKDIR_BIT_X_NE     | TRACKDIR_BIT_X_SW,                                                   // TRACK_Y
 
	TRACKDIR_BIT_RIGHT_N  | TRACKDIR_BIT_RIGHT_S  | TRACKDIR_BIT_LEFT_N  | TRACKDIR_BIT_LEFT_S,  // TRACK_UPPER
 
	TRACKDIR_BIT_RIGHT_N  | TRACKDIR_BIT_RIGHT_S  | TRACKDIR_BIT_LEFT_N  | TRACKDIR_BIT_LEFT_S,  // TRACK_LOWER
 
	TRACKDIR_BIT_UPPER_W  | TRACKDIR_BIT_UPPER_E  | TRACKDIR_BIT_LOWER_W | TRACKDIR_BIT_LOWER_E, // TRACK_LEFT
 
	TRACKDIR_BIT_UPPER_W  | TRACKDIR_BIT_UPPER_E  | TRACKDIR_BIT_LOWER_W | TRACKDIR_BIT_LOWER_E  // TRACK_RIGHT
 
};
 

	
 
/* Maps a track to all tracks that make 90 deg turns with it. */
 
extern const TrackBits _track_crosses_tracks[] = {
 
	TRACK_BIT_Y,    /* TRACK_X     */
 
	TRACK_BIT_X,    /* TRACK_Y     */
 
	TRACK_BIT_VERT, /* TRACK_UPPER */
 
	TRACK_BIT_VERT, /* TRACK_LOWER */
 
	TRACK_BIT_HORZ, /* TRACK_LEFT  */
 
	TRACK_BIT_HORZ  /* TRACK_RIGHT */
 
	TRACK_BIT_Y,    // TRACK_X
 
	TRACK_BIT_X,    // TRACK_Y
 
	TRACK_BIT_VERT, // TRACK_UPPER
 
	TRACK_BIT_VERT, // TRACK_LOWER
 
	TRACK_BIT_HORZ, // TRACK_LEFT
 
	TRACK_BIT_HORZ  // TRACK_RIGHT
 
};
 

	
 
/* Maps a trackdir to the (4-way) direction the tile is exited when following
src/rail_cmd.cpp
Show inline comments
 
@@ -835,7 +835,7 @@ CommandCost CmdBuildSingleSignal(TileInd
 
	{
 
		/* See if this is a valid track combination for signals, (ie, no overlap) */
 
		TrackBits trackbits = GetTrackBits(tile);
 
		if (KillFirstBit(trackbits) != TRACK_BIT_NONE && /* More than one track present */
 
		if (KillFirstBit(trackbits) != TRACK_BIT_NONE && // More than one track present
 
				trackbits != TRACK_BIT_HORZ &&
 
				trackbits != TRACK_BIT_VERT) {
 
			return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK);
 
@@ -1051,7 +1051,7 @@ static CommandCost CmdSignalTrackHelper(
 

	
 
	if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR;
 

	
 
	track = TrackdirToTrack(trackdir); /* trackdir might have changed, keep track in sync */
 
	track = TrackdirToTrack(trackdir); // trackdir might have changed, keep track in sync
 
	Trackdir start_trackdir = trackdir;
 

	
 
	/* Must start on a valid track to be able to avoid loops */
 
@@ -1519,12 +1519,12 @@ static void DrawSingleSignal(TileIndex t
 
{
 
	bool side = (_settings_game.vehicle.road_side != 0) && _settings_game.construction.signal_side;
 
	static const Point SignalPositions[2][12] = {
 
		{      /* Signals on the left side */
 
		{ // Signals on the left side
 
		/*  LEFT      LEFT      RIGHT     RIGHT     UPPER     UPPER */
 
			{ 8,  5}, {14,  1}, { 1, 14}, { 9, 11}, { 1,  0}, { 3, 10},
 
		/*  LOWER     LOWER     X         X         Y         Y     */
 
			{11,  4}, {14, 14}, {11,  3}, { 4, 13}, { 3,  4}, {11, 13}
 
		}, {   /* Signals on the right side */
 
		}, { // Signals on the right side
 
		/*  LEFT      LEFT      RIGHT     RIGHT     UPPER     UPPER */
 
			{14,  1}, {12, 10}, { 4,  6}, { 1, 14}, {10,  4}, { 0,  1},
 
		/*  LOWER     LOWER     X         X         Y         Y     */
 
@@ -2458,8 +2458,8 @@ static VehicleEnterTileStatus VehicleEnt
 
	/* depot direction */
 
	dir = GetRailDepotDirection(tile);
 

	
 
	/* calculate the point where the following wagon should be activated */
 
	/* this depends on the length of the current vehicle */
 
	/* calculate the point where the following wagon should be activated
 
	 * this depends on the length of the current vehicle */
 
	length = v->u.rail.cached_veh_length;
 

	
 
	fract_coord_leave =
 
@@ -2477,7 +2477,7 @@ static VehicleEnterTileStatus VehicleEnt
 
		if (DiagDirToDir(ReverseDiagDir(dir)) == v->direction) {
 
			/* enter the depot */
 
			v->u.rail.track = TRACK_BIT_DEPOT,
 
			v->vehstatus |= VS_HIDDEN; /* hide it */
 
			v->vehstatus |= VS_HIDDEN; // hide it
 
			v->direction = ReverseDir(v->direction);
 
			if (v->Next() == NULL) VehicleEnterDepot(v);
 
			v->tile = tile;
 
@@ -2608,18 +2608,18 @@ static CommandCost TerraformTile_Track(T
 

	
 

	
 
extern const TileTypeProcs _tile_type_rail_procs = {
 
	DrawTile_Track,           /* draw_tile_proc */
 
	GetSlopeZ_Track,          /* get_slope_z_proc */
 
	ClearTile_Track,          /* clear_tile_proc */
 
	GetAcceptedCargo_Track,   /* get_accepted_cargo_proc */
 
	GetTileDesc_Track,        /* get_tile_desc_proc */
 
	GetTileTrackStatus_Track, /* get_tile_track_status_proc */
 
	ClickTile_Track,          /* click_tile_proc */
 
	AnimateTile_Track,        /* animate_tile_proc */
 
	TileLoop_Track,           /* tile_loop_clear */
 
	ChangeTileOwner_Track,    /* change_tile_owner_clear */
 
	NULL,                     /* get_produced_cargo_proc */
 
	VehicleEnter_Track,       /* vehicle_enter_tile_proc */
 
	GetFoundation_Track,      /* get_foundation_proc */
 
	TerraformTile_Track,      /* terraform_tile_proc */
 
	DrawTile_Track,           // draw_tile_proc
 
	GetSlopeZ_Track,          // get_slope_z_proc
 
	ClearTile_Track,          // clear_tile_proc
 
	GetAcceptedCargo_Track,   // get_accepted_cargo_proc
 
	GetTileDesc_Track,        // get_tile_desc_proc
 
	GetTileTrackStatus_Track, // get_tile_track_status_proc
 
	ClickTile_Track,          // click_tile_proc
 
	AnimateTile_Track,        // animate_tile_proc
 
	TileLoop_Track,           // tile_loop_clear
 
	ChangeTileOwner_Track,    // change_tile_owner_clear
 
	NULL,                     // get_produced_cargo_proc
 
	VehicleEnter_Track,       // vehicle_enter_tile_proc
 
	GetFoundation_Track,      // get_foundation_proc
 
	TerraformTile_Track,      // terraform_tile_proc
 
};
src/rail_gui.cpp
Show inline comments
 
@@ -838,7 +838,7 @@ void ShowBuildRailToolbar(RailType railt
 
	if (!IsValidCompanyID(_local_company)) return;
 
	if (!ValParamRailtype(railtype)) return;
 

	
 
	// don't recreate the window if we're clicking on a button and the window exists.
 
	/* don't recreate the window if we're clicking on a button and the window exists. */
 
	if (button < 0 || !(w = dynamic_cast<BuildRailToolbarWindow*>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL)))) {
 
		DeleteWindowByClass(WC_BUILD_TOOLBAR);
 
		_cur_railtype = railtype;
src/roadveh_cmd.cpp
Show inline comments
 
@@ -374,20 +374,20 @@ static bool EnumRoadSignalFindDepot(Tile
 
static const Depot *FindClosestRoadDepot(const Vehicle *v)
 
{
 
	switch (_settings_game.pf.pathfinder_for_roadvehs) {
 
		case VPF_YAPF: /* YAPF */
 
		case VPF_YAPF: // YAPF
 
			return YapfFindNearestRoadDepot(v);
 

	
 
		case VPF_NPF: { /* NPF */
 
		case VPF_NPF: { // NPF
 
			/* See where we are now */
 
			Trackdir trackdir = GetVehicleTrackdir(v);
 

	
 
			NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, false, v->tile, ReverseTrackdir(trackdir), false, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES, 0);
 

	
 
			if (ftd.best_bird_dist == 0) return GetDepotByTile(ftd.node.tile); /* Target found */
 
			if (ftd.best_bird_dist == 0) return GetDepotByTile(ftd.node.tile); // Target found
 
		} break;
 

	
 
		default:
 
		case VPF_OPF: { /* OPF */
 
		case VPF_OPF: { // OPF
 
			RoadFindDepotData rfdd;
 

	
 
			rfdd.owner = v->owner;
 
@@ -402,7 +402,7 @@ static const Depot *FindClosestRoadDepot
 
		} break;
 
	}
 

	
 
	return NULL; /* Target not found */
 
	return NULL; // Target not found
 
}
 

	
 
bool RoadVehicle::FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse)
 
@@ -1101,18 +1101,18 @@ static Trackdir RoadFindPathToDest(Vehic
 
	}
 

	
 
	switch (_settings_game.pf.pathfinder_for_roadvehs) {
 
		case VPF_YAPF: { /* YAPF */
 
		case VPF_YAPF: { // YAPF
 
			Trackdir trackdir = YapfChooseRoadTrack(v, tile, enterdir);
 
			if (trackdir != INVALID_TRACKDIR) return_track(trackdir);
 
			return_track(PickRandomBit(trackdirs));
 
		} break;
 

	
 
		case VPF_NPF: { /* NPF */
 
		case VPF_NPF: { // NPF
 
			NPFFindStationOrTileData fstd;
 

	
 
			NPFFillWithOrderData(&fstd, v);
 
			Trackdir trackdir = DiagDirToDiagTrackdir(enterdir);
 
			//debug("Finding path. Enterdir: %d, Trackdir: %d", enterdir, trackdir);
 
			/* debug("Finding path. Enterdir: %d, Trackdir: %d", enterdir, trackdir); */
 

	
 
			NPFFoundTargetData ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, true, &fstd, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES);
 
			if (ftd.best_trackdir == INVALID_TRACKDIR) {
 
@@ -1130,7 +1130,7 @@ static Trackdir RoadFindPathToDest(Vehic
 
		} break;
 

	
 
		default:
 
		case VPF_OPF: { /* OPF */
 
		case VPF_OPF: { // OPF
 
			DiagDirection dir;
 

	
 
			if (IsTileType(desttile, MP_ROAD)) {
src/saveload/afterload.cpp
Show inline comments
 
@@ -752,7 +752,7 @@ bool AfterLoadGame()
 
			switch (GetTileType(t)) {
 
				case MP_ROAD:
 
					if (fix_roadtypes) SetRoadTypes(t, (RoadTypes)GB(_me[t].m7, 5, 3));
 
					SB(_me[t].m7, 5, 1, GB(_m[t].m3, 7, 1)); //snow/desert
 
					SB(_me[t].m7, 5, 1, GB(_m[t].m3, 7, 1)); // snow/desert
 
					switch (GetRoadTileType(t)) {
 
						default: NOT_REACHED();
 
						case ROAD_TILE_NORMAL:
 
@@ -1009,7 +1009,7 @@ bool AfterLoadGame()
 
					}
 
					break;
 

	
 
				case MP_STATION: /* Clear PBS reservation on station */
 
				case MP_STATION: // Clear PBS reservation on station
 
					ClrBit(_m[t].m3, 6);
 
					break;
 

	
 
@@ -1182,7 +1182,7 @@ bool AfterLoadGame()
 
						 SetIndustryAnimationState(t, _m[t].m1);
 
						 break;
 

	
 
					default: /* No animation states to change */
 
					default: // No animation states to change
 
						break;
 
				}
 
			}
 
@@ -1649,15 +1649,15 @@ bool AfterLoadGame()
 
					}
 
					break;
 

	
 
				case MP_ROAD: /* Clear PBS reservation on crossing */
 
				case MP_ROAD: // Clear PBS reservation on crossing
 
					if (IsLevelCrossing(t)) SetCrossingReservation(t, false);
 
					break;
 

	
 
				case MP_STATION: /* Clear PBS reservation on station */
 
				case MP_STATION: // Clear PBS reservation on station
 
					if (IsRailwayStation(t)) SetRailwayStationReservation(t, false);
 
					break;
 

	
 
				case MP_TUNNELBRIDGE: /* Clear PBS reservation on tunnels/birdges */
 
				case MP_TUNNELBRIDGE: // Clear PBS reservation on tunnels/birdges
 
					if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) SetTunnelBridgeReservation(t, false);
 
					break;
 

	
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -1260,14 +1260,14 @@ bool LoadOldVehicle(LoadgameState *ls, i
 
			uint type = ReadByte(ls);
 
			switch (type) {
 
				default: return false;
 
				case 0x00 /*VEH_INVALID */: v = new (_current_vehicle_id) InvalidVehicle();  break;
 
				case 0x25 /* MONORAIL   */:
 
				case 0x20 /*VEH_TRAIN   */: v = new (_current_vehicle_id) Train();           break;
 
				case 0x21 /*VEH_ROAD    */: v = new (_current_vehicle_id) RoadVehicle();     break;
 
				case 0x22 /*VEH_SHIP    */: v = new (_current_vehicle_id) Ship();            break;
 
				case 0x23 /*VEH_AIRCRAFT*/: v = new (_current_vehicle_id) Aircraft();        break;
 
				case 0x24 /*VEH_EFFECT  */: v = new (_current_vehicle_id) EffectVehicle();   break;
 
				case 0x26 /*VEH_DISASTER*/: v = new (_current_vehicle_id) DisasterVehicle(); break;
 
				case 0x00 /* VEH_INVALID */: v = new (_current_vehicle_id) InvalidVehicle();  break;
 
				case 0x25 /* MONORAIL     */:
 
				case 0x20 /* VEH_TRAIN    */: v = new (_current_vehicle_id) Train();           break;
 
				case 0x21 /* VEH_ROAD     */: v = new (_current_vehicle_id) RoadVehicle();     break;
 
				case 0x22 /* VEH_SHIP     */: v = new (_current_vehicle_id) Ship();            break;
 
				case 0x23 /* VEH_AIRCRAFT */: v = new (_current_vehicle_id) Aircraft();        break;
 
				case 0x24 /* VEH_EFFECT   */: v = new (_current_vehicle_id) EffectVehicle();   break;
 
				case 0x26 /* VEH_DISASTER */: v = new (_current_vehicle_id) DisasterVehicle(); break;
 
			}
 

	
 
			if (!LoadChunk(ls, v, vehicle_chunk)) return false;
 
@@ -1336,13 +1336,13 @@ bool LoadOldVehicle(LoadgameState *ls, i
 
			/* Read the vehicle type and allocate the right vehicle */
 
			switch (ReadByte(ls)) {
 
				default: NOT_REACHED();
 
				case 0x00 /*VEH_INVALID */: v = new (_current_vehicle_id) InvalidVehicle();  break;
 
				case 0x10 /*VEH_TRAIN   */: v = new (_current_vehicle_id) Train();           break;
 
				case 0x11 /*VEH_ROAD    */: v = new (_current_vehicle_id) RoadVehicle();     break;
 
				case 0x12 /*VEH_SHIP    */: v = new (_current_vehicle_id) Ship();            break;
 
				case 0x13 /*VEH_AIRCRAFT*/: v = new (_current_vehicle_id) Aircraft();        break;
 
				case 0x14 /*VEH_EFFECT  */: v = new (_current_vehicle_id) EffectVehicle();   break;
 
				case 0x15 /*VEH_DISASTER*/: v = new (_current_vehicle_id) DisasterVehicle(); break;
 
				case 0x00 /* VEH_INVALID */: v = new (_current_vehicle_id) InvalidVehicle();  break;
 
				case 0x10 /* VEH_TRAIN   */: v = new (_current_vehicle_id) Train();           break;
 
				case 0x11 /* VEH_ROAD    */: v = new (_current_vehicle_id) RoadVehicle();     break;
 
				case 0x12 /* VEH_SHIP    */: v = new (_current_vehicle_id) Ship();            break;
 
				case 0x13 /* VEH_AIRCRAFT*/: v = new (_current_vehicle_id) Aircraft();        break;
 
				case 0x14 /* VEH_EFFECT  */: v = new (_current_vehicle_id) EffectVehicle();   break;
 
				case 0x15 /* VEH_DISASTER*/: v = new (_current_vehicle_id) DisasterVehicle(); break;
 
			}
 
			if (!LoadChunk(ls, v, vehicle_chunk)) return false;
 

	
src/saveload/saveload.cpp
Show inline comments
 
@@ -1710,7 +1710,7 @@ SaveOrLoadResult SaveOrLoad(const char *
 

	
 
		/* General tactic is to first save the game to memory, then use an available writer
 
		 * to write it to file, either in threaded mode if possible, or single-threaded */
 
		if (mode == SL_SAVE) { /* SAVE game */
 
		if (mode == SL_SAVE) { // SAVE game
 
			DEBUG(desync, 1, "save: %s\n", filename);
 
			fmt = GetSavegameFormat("memory"); // write to memory
 

	
 
@@ -1737,7 +1737,7 @@ SaveOrLoadResult SaveOrLoad(const char *
 

	
 
				return result;
 
			}
 
		} else { /* LOAD game */
 
		} else { // LOAD game
 
			assert(mode == SL_LOAD);
 
			DEBUG(desync, 1, "load: %s\n", filename);
 

	
src/saveload/saveload.h
Show inline comments
 
@@ -178,7 +178,7 @@ enum SaveLoadTypes {
 
	SL_ARR         =  2,
 
	SL_STR         =  3,
 
	SL_LST         =  4,
 
	// non-normal save-load types
 
	/* non-normal save-load types */
 
	SL_WRITEBYTE   =  8,
 
	SL_VEH_INCLUDE =  9,
 
	SL_END         = 15
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -117,26 +117,26 @@ void ConvertOldMultiheadToNew()
 

	
 
					ClrBit(u->subtype, 7);
 
					switch (u->subtype) {
 
						case 0: /* TS_Front_Engine */
 
						case 0: // TS_Front_Engine
 
							if (rvi->railveh_type == RAILVEH_MULTIHEAD) SetMultiheaded(u);
 
							SetFrontEngine(u);
 
							SetTrainEngine(u);
 
							break;
 

	
 
						case 1: /* TS_Artic_Part */
 
						case 1: // TS_Artic_Part
 
							u->subtype = 0;
 
							SetArticulatedPart(u);
 
							break;
 

	
 
						case 2: /* TS_Not_First */
 
						case 2: // TS_Not_First
 
							u->subtype = 0;
 
							if (rvi->railveh_type == RAILVEH_WAGON) {
 
								// normal wagon
 
								/* normal wagon */
 
								SetTrainWagon(u);
 
								break;
 
							}
 
							if (rvi->railveh_type == RAILVEH_MULTIHEAD && rvi->image_index == u->spritenum - 1) {
 
								// rear end of a multiheaded engine
 
								/* rear end of a multiheaded engine */
 
								SetMultiheaded(u);
 
								break;
 
							}
 
@@ -144,7 +144,7 @@ void ConvertOldMultiheadToNew()
 
							SetTrainEngine(u);
 
							break;
 

	
 
						case 4: /* TS_Free_Car */
 
						case 4: // TS_Free_Car
 
							u->subtype = 0;
 
							SetTrainWagon(u);
 
							SetFreeWagon(u);
src/screenshot.cpp
Show inline comments
 
@@ -34,9 +34,9 @@ struct ScreenshotFormat {
 
	ScreenshotHandlerProc *proc;
 
};
 

	
 
//************************************************
 
//*** SCREENSHOT CODE FOR WINDOWS BITMAP (.BMP)
 
//************************************************
 
/*************************************************
 
 **** SCREENSHOT CODE FOR WINDOWS BITMAP (.BMP)
 
 *************************************************/
 
#if defined(_MSC_VER) || defined(__WATCOMC__)
 
#pragma pack(push, 1)
 
#endif
 
@@ -153,9 +153,9 @@ static bool MakeBmpImage(const char *nam
 
	return true;
 
}
 

	
 
//********************************************************
 
//*** SCREENSHOT CODE FOR PORTABLE NETWORK GRAPHICS (.PNG)
 
//********************************************************
 
/*********************************************************
 
 **** SCREENSHOT CODE FOR PORTABLE NETWORK GRAPHICS (.PNG)
 
 *********************************************************/
 
#if defined(WITH_PNG)
 
#include <png.h>
 

	
 
@@ -276,9 +276,9 @@ static bool MakePNGImage(const char *nam
 
#endif /* WITH_PNG */
 

	
 

	
 
//************************************************
 
//*** SCREENSHOT CODE FOR ZSOFT PAINTBRUSH (.PCX)
 
//************************************************
 
/*************************************************
 
 **** SCREENSHOT CODE FOR ZSOFT PAINTBRUSH (.PCX)
 
 *************************************************/
 

	
 
struct PcxHeader {
 
	byte manufacturer;
 
@@ -423,9 +423,9 @@ static bool MakePCXImage(const char *nam
 
	return success;
 
}
 

	
 
//************************************************
 
//*** GENERIC SCREENSHOT CODE
 
//************************************************
 
/*************************************************
 
 **** GENERIC SCREENSHOT CODE
 
 *************************************************/
 

	
 
static const ScreenshotFormat _screenshot_formats[] = {
 
#if defined(WITH_PNG)
src/sdl.cpp
Show inline comments
 
@@ -14,7 +14,7 @@
 
#include <signal.h>
 

	
 
#ifdef __MORPHOS__
 
	// The system supplied definition of SIG_DFL is wrong on MorphOS
 
	/* The system supplied definition of SIG_DFL is wrong on MorphOS */
 
	#undef SIG_DFL
 
	#define SIG_DFL (void (*)(int))0
 
#endif
 
@@ -76,7 +76,7 @@ static const char *LoadSdlDLL()
 
	return NULL;
 
}
 

	
 
#endif // DYNAMICALLY_LOADED_SDL
 
#endif /* DYNAMICALLY_LOADED_SDL */
 

	
 

	
 
#ifdef UNIX
src/settings.cpp
Show inline comments
 
@@ -309,8 +309,8 @@ static const void *string_to_val(const S
 
		/* if the first attempt of conversion from string to the appropriate value fails,
 
		 * look if we have defined a converter from old value to new value. */
 
		if (r == -1 && desc->proc_cnvt != NULL) r = desc->proc_cnvt(str);
 
		if (r != -1) return (void*)r; //and here goes converted value
 
		ShowInfoF("ini: invalid value '%s' for '%s'", str, desc->name); //sorry, we failed
 
		if (r != -1) return (void*)r; // and here goes converted value
 
		ShowInfoF("ini: invalid value '%s' for '%s'", str, desc->name); // sorry, we failed
 
		return 0;
 
	}
 
	case SDT_MANYOFMANY: {
 
@@ -434,7 +434,7 @@ static void ini_load_settings(IniFile *i
 
		ptr = GetVariableAddress(object, sld);
 

	
 
		switch (sdb->cmd) {
 
		case SDT_BOOLX: /* All four are various types of (integer) numbers */
 
		case SDT_BOOLX: // All four are various types of (integer) numbers
 
		case SDT_NUMX:
 
		case SDT_ONEOFMANY:
 
		case SDT_MANYOFMANY:
 
@@ -543,7 +543,7 @@ static void ini_save_settings(IniFile *i
 
				default: NOT_REACHED();
 
				}
 
				break;
 
			default: break; /* Assume the other types are always changed */
 
			default: break; // Assume the other types are always changed
 
			}
 
		}
 

	
 
@@ -652,9 +652,9 @@ static void ini_save_setting_list(IniFil
 
	}
 
}
 

	
 
//***************************
 
// OTTD specific INI stuff
 
//***************************
 
/****************************
 
 * OTTD specific INI stuff
 
 ****************************/
 

	
 
/** Settings-macro usage:
 
 * The list might look daunting at first, but is in general easy to understand.
 
@@ -824,8 +824,8 @@ static void ini_save_setting_list(IniFil
 
#define NN SGF_NO_NETWORK
 
#define NG SGF_NEWGAME_ONLY
 

	
 
/* Begin - Callback Functions for the various settings */
 
/* virtual PositionMainToolbar function, calls the right one.*/
 
/* Begin - Callback Functions for the various settings
 
 * virtual PositionMainToolbar function, calls the right one.*/
 
static bool v_PositionMainToolbar(int32 p1)
 
{
 
	if (_game_mode != GM_MENU) PositionMainToolbar(NULL);
 
@@ -1667,7 +1667,7 @@ bool ConvertOldNewsSetting(const char *n
 
		 * So the job is now to decrypt the value of the old news config
 
		 * and give it to the two newly introduced ones*/
 

	
 
		NewsDisplay display = ND_OFF;  //default
 
		NewsDisplay display = ND_OFF; // default
 
		if (strcasecmp(value, "full") == 0) {
 
			display = ND_FULL;
 
		} else if (strcasecmp(value, "summarized") == 0) {
src/settings_gui.cpp
Show inline comments
 
@@ -255,7 +255,7 @@ struct GameOptionsWindow : Window {
 
	virtual void OnDropdownSelect(int widget, int index)
 
	{
 
		switch (widget) {
 
			case GAMEOPT_CURRENCY_BTN: /* Currency */
 
			case GAMEOPT_CURRENCY_BTN: // Currency
 
				if (index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
 
				this->opt->locale.currency = index;
 
				MarkWholeScreenDirty();
 
@@ -485,7 +485,7 @@ public:
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case GDW_SETTING_BG: { /* Difficulty settings widget, decode click */
 
			case GDW_SETTING_BG: { // Difficulty settings widget, decode click
 
				/* Don't allow clients to make any changes */
 
				if (_networking && !_network_server) return;
 

	
 
@@ -1625,7 +1625,7 @@ struct CustomCurrencyWindow : Window {
 
				_custom_currency.rate = Clamp(atoi(str), 1, UINT16_MAX);
 
				break;
 

	
 
			case CUSTCURR_SEPARATOR: /* Thousands seperator */
 
			case CUSTCURR_SEPARATOR: // Thousands seperator
 
				_custom_currency.separator = StrEmpty(str) ? ' ' : str[0];
 
				strecpy(this->separator, str, lastof(this->separator));
 
				break;
 
@@ -1638,7 +1638,7 @@ struct CustomCurrencyWindow : Window {
 
				strecpy(_custom_currency.suffix, str, lastof(_custom_currency.suffix));
 
				break;
 

	
 
			case CUSTCURR_TO_EURO: { /* Year to switch to euro */
 
			case CUSTCURR_TO_EURO: { // Year to switch to euro
 
				int val = atoi(str);
 

	
 
				_custom_currency.to_euro = (val < 2000 ? CF_NOEURO : min(val, MAX_YEAR));
src/ship_cmd.cpp
Show inline comments
 
@@ -96,13 +96,13 @@ SpriteID Ship::GetImage(Direction direct
 

	
 
static const Depot *FindClosestShipDepot(const Vehicle *v)
 
{
 
	if (_settings_game.pf.pathfinder_for_ships == VPF_NPF) { /* NPF is used */
 
	if (_settings_game.pf.pathfinder_for_ships == VPF_NPF) { // NPF is used
 
		Trackdir trackdir = GetVehicleTrackdir(v);
 
		NPFFoundTargetData ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
 

	
 
		if (ftd.best_bird_dist == 0) return GetDepotByTile(ftd.node.tile); /* Found target */
 
		if (ftd.best_bird_dist == 0) return GetDepotByTile(ftd.node.tile); // Found target
 

	
 
		return NULL; /* Did not find target */
 
		return NULL; // Did not find target
 
	}
 

	
 
	/* OPF or YAPF - find the closest depot */
 
@@ -312,7 +312,7 @@ static bool ShipAccelerate(Vehicle *v)
 

	
 
	spd = min(v->cur_speed + 1, GetVehicleProperty(v, 0x0B, v->max_speed));
 

	
 
	/*updates statusbar only if speed have changed to save CPU time */
 
	/* updates statusbar only if speed have changed to save CPU time */
 
	if (spd != v->cur_speed) {
 
		v->cur_speed = spd;
 
		if (_settings_client.gui.vehicle_speed)
 
@@ -452,12 +452,12 @@ static Track ChooseShipTrack(Vehicle *v,
 
	assert(IsValidDiagDirection(enterdir));
 

	
 
	switch (_settings_game.pf.pathfinder_for_ships) {
 
		case VPF_YAPF: { /* YAPF */
 
		case VPF_YAPF: { // YAPF
 
			Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
 
			if (trackdir != INVALID_TRACKDIR) return TrackdirToTrack(trackdir);
 
		} break;
 

	
 
		case VPF_NPF: { /* NPF */
 
		case VPF_NPF: { // NPF
 
			NPFFindStationOrTileData fstd;
 
			Trackdir trackdir = GetVehicleTrackdir(v);
 
			assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
 
@@ -470,11 +470,11 @@ static Track ChooseShipTrack(Vehicle *v,
 
			 * the direction we need to take to get there, if ftd.best_bird_dist is not 0,
 
			 * we did not find our target, but ftd.best_trackdir contains the direction leading
 
			 * to the tile closest to our target. */
 
			if (ftd.best_trackdir != 0xff) return TrackdirToTrack(ftd.best_trackdir); /* TODO: Wrapper function? */
 
			if (ftd.best_trackdir != 0xff) return TrackdirToTrack(ftd.best_trackdir); // TODO: Wrapper function?
 
		} break;
 

	
 
		default:
 
		case VPF_OPF: { /* OPF */
 
		case VPF_OPF: { // OPF
 
			TileIndex tile2 = TILE_ADD(tile, -TileOffsByDiagDir(enterdir));
 
			Track track;
 

	
 
@@ -494,7 +494,7 @@ static Track ChooseShipTrack(Vehicle *v,
 
		} break;
 
	}
 

	
 
	return INVALID_TRACK; /* We could better reverse */
 
	return INVALID_TRACK; // We could better reverse
 
}
 

	
 
static const Direction _new_vehicle_direction_table[] = {
 
@@ -896,7 +896,7 @@ CommandCost CmdRefitShip(TileIndex tile,
 
{
 
	Vehicle *v;
 
	CommandCost cost(EXPENSES_SHIP_RUN);
 
	CargoID new_cid = GB(p2, 0, 8); //gets the cargo number
 
	CargoID new_cid = GB(p2, 0, 8); // gets the cargo number
 
	byte new_subtype = GB(p2, 8, 8);
 
	uint16 capacity = CALLBACK_FAILED;
 

	
src/smallmap_gui.cpp
Show inline comments
 
@@ -596,7 +596,7 @@ public:
 
			_owner_colours[OWNER_TOWN] = MKCOLOUR(0xB4B4B4B4);
 
			_owner_colours[OWNER_NONE] = MKCOLOUR(0x54545454);
 
			_owner_colours[OWNER_WATER] = MKCOLOUR(0xCACACACA);
 
			_owner_colours[OWNER_END]   = MKCOLOUR(0x20202020); /* industry */
 
			_owner_colours[OWNER_END]   = MKCOLOUR(0x20202020); // industry
 

	
 
			/* now fill with the company colours */
 
			FOR_ALL_COMPANIES(c) {
 
@@ -646,7 +646,7 @@ public:
 
			/* distance from right edge */
 
			t = dpi->width - x;
 
			if (t < 4) {
 
				if (t <= 0) break; /* exit loop */
 
				if (t <= 0) break; // exit loop
 
				/* mask to use at the right edge */
 
				mask &= _smallmap_mask_right[t - 1];
 
			}
src/sound.cpp
Show inline comments
 
@@ -17,7 +17,7 @@ static uint _file_count;
 
static FileEntry *_files;
 
MusicFileSettings msf;
 

	
 
// Number of levels of panning per side
 
/* Number of levels of panning per side */
 
#define PANNING_LEVELS 16
 

	
 
/** The number of sounds in the original sample.cat */
src/sprite.h
Show inline comments
 
@@ -52,7 +52,7 @@ struct DrawBuildingsTileStruct {
 
	byte width;
 
	byte height;
 
	byte dz;
 
	byte draw_proc;  /* this allows to specify a special drawing procedure.*/
 
	byte draw_proc;  // this allows to specify a special drawing procedure.
 
};
 

	
 
/** Iterate through all DrawTileSeqStructs in DrawTileSprites. */
src/station.cpp
Show inline comments
 
@@ -306,8 +306,8 @@ bool StationRect::BeforeAddTile(TileInde
 
			top = bottom = y;
 
		}
 
	} else if (!PtInExtendedRect(x, y)) {
 
		/* current rect is not empty and new point is outside this rect */
 
		/* make new spread-out rectangle */
 
		/* current rect is not empty and new point is outside this rect
 
		 * make new spread-out rectangle */
 
		Rect new_rect = {min(x, left), min(y, top), max(x, right), max(y, bottom)};
 

	
 
		/* check new rect dimensions against preset max */
 
@@ -345,7 +345,7 @@ bool StationRect::BeforeAddRect(TileInde
 
 * @param bottom_a Maximal tile Y edge of the rectangle (inclusive)
 
 * @return \c true if a station tile with the given \a st_id exists in the rectangle, \c false otherwise
 
 */
 
/*static*/ bool StationRect::ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a)
 
/* static */ bool StationRect::ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a)
 
{
 
	TileIndex top_left = TileXY(left_a, top_a);
 
	int width = right_a - left_a + 1;
src/station_cmd.cpp
Show inline comments
 
@@ -243,12 +243,12 @@ static bool FindNearIndustryName(TileInd
 
static StringID GenerateStationName(Station *st, TileIndex tile, int flag)
 
{
 
	static const uint32 _gen_station_name_bits[] = {
 
		0,                                      /* 0 */
 
		1 << M(STR_SV_STNAME_AIRPORT),          /* 1 */
 
		1 << M(STR_SV_STNAME_OILFIELD),         /* 2 */
 
		1 << M(STR_SV_STNAME_DOCKS),            /* 3 */
 
		0x1FF << M(STR_SV_STNAME_BUOY_1),       /* 4 */
 
		1 << M(STR_SV_STNAME_HELIPORT),         /* 5 */
 
		0,                                      // 0
 
		1 << M(STR_SV_STNAME_AIRPORT),          // 1
 
		1 << M(STR_SV_STNAME_OILFIELD),         // 2
 
		1 << M(STR_SV_STNAME_DOCKS),            // 3
 
		0x1FF << M(STR_SV_STNAME_BUOY_1),       // 4
 
		1 << M(STR_SV_STNAME_HELIPORT),         // 5
 
	};
 

	
 
	const Town *t = st->town;
 
@@ -675,7 +675,7 @@ static void UpdateStationSignCoord(Stati
 
{
 
	const StationRect *r = &st->rect;
 

	
 
	if (r->IsEmpty()) return; /* no tiles belong to this station */
 
	if (r->IsEmpty()) return; // no tiles belong to this station
 

	
 
	/* clamp sign coord to be inside the station rect */
 
	st->xy = TileXY(ClampU(TileX(st->xy), r->left, r->right), ClampU(TileY(st->xy), r->top, r->bottom));
 
@@ -1511,7 +1511,7 @@ CommandCost CmdBuildRoadStop(TileIndex t
 
		RoadStop **currstop = FindRoadStopSpot(type, st);
 
		*currstop = road_stop;
 

	
 
		/*initialize an empty station */
 
		/* initialize an empty station */
 
		st->AddFacility((type) ? FACIL_TRUCK_STOP : FACIL_BUS_STOP, tile);
 

	
 
		st->rect.BeforeAddTile(tile, StationRect::ADD_TRY);
 
@@ -2236,7 +2236,6 @@ CommandCost CmdBuildDock(TileIndex tile,
 
		if (st->dock_tile != INVALID_TILE) return_cmd_error(STR_304C_TOO_CLOSE_TO_ANOTHER_DOCK);
 
	} else {
 
		/* allocate and initialize new station */
 
		/* allocate and initialize new station */
 
		if (!Station::CanAllocateItem()) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
 

	
 
		if (flags & DC_EXEC) {
 
@@ -2669,7 +2668,7 @@ static VehicleEnterTileStatus VehicleEnt
 
			if (y == TILE_SIZE / 2) {
 
				if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x;
 
				int stop = TILE_SIZE - (v->u.rail.cached_veh_length + 1) / 2;
 
				if (x == stop) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); /* enter station */
 
				if (x == stop) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); // enter station
 
				if (x < stop) {
 
					uint16 spd;
 

	
 
@@ -2707,8 +2706,8 @@ static VehicleEnterTileStatus VehicleEnt
 
					return VETSB_CONTINUE;
 
				}
 

	
 
				/* For normal (non drive-through) road stops */
 
				/* Check if station is busy or if there are no free bays or whether it is a articulated vehicle. */
 
				/* For normal (non drive-through) road stops
 
				 * Check if station is busy or if there are no free bays or whether it is a articulated vehicle. */
 
				if (rs->IsEntranceBusy() || !rs->HasFreeBay() || RoadVehHasArticPart(v)) return VETSB_CANNOT_ENTER;
 

	
 
				SetBit(v->u.road.state, RVS_IN_ROAD_STOP);
 
@@ -3276,18 +3275,18 @@ static CommandCost TerraformTile_Station
 

	
 

	
 
extern const TileTypeProcs _tile_type_station_procs = {
 
	DrawTile_Station,           /* draw_tile_proc */
 
	GetSlopeZ_Station,          /* get_slope_z_proc */
 
	ClearTile_Station,          /* clear_tile_proc */
 
	GetAcceptedCargo_Station,   /* get_accepted_cargo_proc */
 
	GetTileDesc_Station,        /* get_tile_desc_proc */
 
	GetTileTrackStatus_Station, /* get_tile_track_status_proc */
 
	ClickTile_Station,          /* click_tile_proc */
 
	AnimateTile_Station,        /* animate_tile_proc */
 
	TileLoop_Station,           /* tile_loop_clear */
 
	ChangeTileOwner_Station,    /* change_tile_owner_clear */
 
	NULL,                       /* get_produced_cargo_proc */
 
	VehicleEnter_Station,       /* vehicle_enter_tile_proc */
 
	GetFoundation_Station,      /* get_foundation_proc */
 
	TerraformTile_Station,      /* terraform_tile_proc */
 
	DrawTile_Station,           // draw_tile_proc
 
	GetSlopeZ_Station,          // get_slope_z_proc
 
	ClearTile_Station,          // clear_tile_proc
 
	GetAcceptedCargo_Station,   // get_accepted_cargo_proc
 
	GetTileDesc_Station,        // get_tile_desc_proc
 
	GetTileTrackStatus_Station, // get_tile_track_status_proc
 
	ClickTile_Station,          // click_tile_proc
 
	AnimateTile_Station,        // animate_tile_proc
 
	TileLoop_Station,           // tile_loop_clear
 
	ChangeTileOwner_Station,    // change_tile_owner_clear
 
	NULL,                       // get_produced_cargo_proc
 
	VehicleEnter_Station,       // vehicle_enter_tile_proc
 
	GetFoundation_Station,      // get_foundation_proc
 
	TerraformTile_Station,      // terraform_tile_proc
 
};
src/strgen/strgen.cpp
Show inline comments
 
@@ -93,12 +93,12 @@ static uint8 _lang_newgrflangid;
 
static char _genders[MAX_NUM_GENDER][16];
 
static uint _numgenders;
 

	
 
// contains the name of all cases.
 
/* contains the name of all cases. */
 
#define MAX_NUM_CASES 50
 
static char _cases[MAX_NUM_CASES][16];
 
static uint _numcases;
 

	
 
// for each plural value, this is the number of plural forms.
 
/* for each plural value, this is the number of plural forms. */
 
static const byte _plural_form_counts[] = { 2, 1, 2, 3, 3, 3, 3, 3, 4, 2 };
 

	
 
static const char *_cur_ident;
 
@@ -114,7 +114,7 @@ struct ParsedCommandStruct {
 
	const CmdStruct *cmd[32]; // ordered by param #
 
};
 

	
 
// Used when generating some advanced commands.
 
/* Used when generating some advanced commands. */
 
static ParsedCommandStruct _cur_pcs;
 
static int _cur_argidx;
 

	
 
@@ -271,11 +271,11 @@ static void EmitSetXY(char *buf, int val
 
	PutByte((byte)y);
 
}
 

	
 
// The plural specifier looks like
 
// {NUM} {PLURAL -1 passenger passengers} then it picks either passenger/passengers depending on the count in NUM
 
/* The plural specifier looks like
 
 * {NUM} {PLURAL -1 passenger passengers} then it picks either passenger/passengers depending on the count in NUM */
 

	
 
// This is encoded like
 
//  CommandByte <ARG#> <NUM> {Length of each string} {each string}
 
/* This is encoded like
 
 *  CommandByte <ARG#> <NUM> {Length of each string} {each string} */
 

	
 
bool ParseRelNum(char **buf, int *value)
 
{
 
@@ -300,7 +300,7 @@ bool ParseRelNum(char **buf, int *value)
 
	return true;
 
}
 

	
 
// Parse out the next word, or NULL
 
/* Parse out the next word, or NULL */
 
char *ParseWord(char **buf)
 
{
 
	char *s = *buf, *r;
 
@@ -310,7 +310,7 @@ char *ParseWord(char **buf)
 

	
 
	if (*s == '"') {
 
		r = ++s;
 
		// parse until next " or NUL
 
		/* parse until next " or NUL */
 
		for (;;) {
 
			if (*s == '\0') break;
 
			if (*s == '"') {
 
@@ -320,7 +320,7 @@ char *ParseWord(char **buf)
 
			s++;
 
		}
 
	} else {
 
		// proceed until whitespace or NUL
 
		/* proceed until whitespace or NUL */
 
		r = s;
 
		for (;;) {
 
			if (*s == '\0') break;
 
@@ -335,7 +335,7 @@ char *ParseWord(char **buf)
 
	return r;
 
}
 

	
 
// Forward declaration
 
/* Forward declaration */
 
static int TranslateArgumentIdx(int arg);
 

	
 
static void EmitWordList(const char * const *words, uint nw)
 
@@ -356,10 +356,10 @@ static void EmitPlural(char *buf, int va
 
	const char *words[5];
 
	int nw = 0;
 

	
 
	// Parse out the number, if one exists. Otherwise default to prev arg.
 
	/* Parse out the number, if one exists. Otherwise default to prev arg. */
 
	if (!ParseRelNum(&buf, &argidx)) argidx--;
 

	
 
	// Parse each string
 
	/* Parse each string */
 
	for (nw = 0; nw < 5; nw++) {
 
		words[nw] = ParseWord(&buf);
 
		if (words[nw] == NULL) break;
 
@@ -398,19 +398,19 @@ static void EmitGender(char *buf, int va
 
	if (buf[0] == '=') {
 
		buf++;
 

	
 
		// This is a {G=DER} command
 
		/* This is a {G=DER} command */
 
		for (nw = 0; ; nw++) {
 
			if (nw >= 8) error("G argument '%s' invalid", buf);
 
			if (strcmp(buf, _genders[nw]) == 0) break;
 
		}
 
		// now nw contains the gender index
 
		/* now nw contains the gender index */
 
		PutUtf8(SCC_GENDER_INDEX);
 
		PutByte(nw);
 
	} else {
 
		const char *words[8];
 

	
 
		// This is a {G 0 foo bar two} command.
 
		// If no relative number exists, default to +0
 
		/* This is a {G 0 foo bar two} command.
 
		 * If no relative number exists, default to +0 */
 
		if (!ParseRelNum(&buf, &argidx)) {}
 

	
 
		for (nw = 0; nw < 8; nw++) {
 
@@ -426,15 +426,15 @@ static void EmitGender(char *buf, int va
 

	
 

	
 
static const CmdStruct _cmd_structs[] = {
 
	// Update position
 
	/* Update position */
 
	{"SETX",  EmitSetX,  SCC_SETX,  0, 0},
 
	{"SETXY", EmitSetXY, SCC_SETXY, 0, 0},
 

	
 
	// Font size
 
	/* Font size */
 
	{"TINYFONT", EmitSingleChar, SCC_TINYFONT, 0, 0},
 
	{"BIGFONT",  EmitSingleChar, SCC_BIGFONT,  0, 0},
 

	
 
	// Colors
 
	/* Colors */
 
	{"BLUE",    EmitSingleChar, SCC_BLUE,    0, 0},
 
	{"SILVER",  EmitSingleChar, SCC_SILVER,  0, 0},
 
	{"GOLD",    EmitSingleChar, SCC_GOLD,    0, 0},
 
@@ -487,7 +487,7 @@ static const CmdStruct _cmd_structs[] = 
 
	{"STRING", EmitSingleChar, SCC_STRING, 1, C_CASE},
 
	{"RAW_STRING", EmitSingleChar, SCC_RAW_STRING_POINTER, 1, 0},
 

	
 
	// Numbers
 
	/* Numbers */
 
	{"COMMA", EmitSingleChar, SCC_COMMA, 1, 0}, // Number with comma
 
	{"NUM",   EmitSingleChar, SCC_NUM,   1, 0}, // Signed number
 
	{"BYTES", EmitSingleChar, SCC_BYTES, 1, 0}, // Unsigned number with "bytes", i.e. "1.02 MiB or 123 KiB"
 
@@ -565,8 +565,8 @@ static uint ResolveCaseName(const char *
 
}
 

	
 

	
 
// returns NULL on eof
 
// else returns command struct
 
/* returns NULL on eof
 
 * else returns command struct */
 
static const CmdStruct *ParseCommandString(const char **str, char *param, int *argno, int *casei)
 
{
 
	const char *s = *str, *start;
 
@@ -576,7 +576,7 @@ static const CmdStruct *ParseCommandStri
 
	*argno = -1;
 
	*casei = -1;
 

	
 
	// Scan to the next command, exit if there's no next command.
 
	/* Scan to the next command, exit if there's no next command. */
 
	for (; *s != '{'; s++) {
 
		if (*s == '\0') return NULL;
 
	}
 
@@ -590,7 +590,7 @@ static const CmdStruct *ParseCommandStri
 
		s = end + 1;
 
	}
 

	
 
	// parse command name
 
	/* parse command name */
 
	start = s;
 
	do {
 
		c = *s++;
 
@@ -620,7 +620,7 @@ static const CmdStruct *ParseCommandStri
 

	
 
	if (c != '}') {
 
		if (c == '=') s--;
 
		// copy params
 
		/* copy params */
 
		start = s;
 
		for (;;) {
 
			c = *s++;
 
@@ -714,12 +714,12 @@ static void ExtractCommandString(ParsedC
 
	memset(p, 0, sizeof(*p));
 

	
 
	for (;;) {
 
		// read until next command from a.
 
		/* read until next command from a. */
 
		const CmdStruct *ar = ParseCommandString(&s, param, &argno, &casei);
 

	
 
		if (ar == NULL) break;
 

	
 
		// Sanity checking
 
		/* Sanity checking */
 
		if (argno != -1 && ar->consumes == 0) error("Non consumer param can't have a paramindex");
 

	
 
		if (ar->consumes) {
 
@@ -767,19 +767,19 @@ static bool CheckCommandsMatch(char *a, 
 
	ExtractCommandString(&templ, b, true);
 
	ExtractCommandString(&lang, a, true);
 

	
 
	// For each string in templ, see if we find it in lang
 
	/* For each string in templ, see if we find it in lang */
 
	if (templ.np != lang.np) {
 
		strgen_warning("%s: template string and language string have a different # of commands", name);
 
		result = false;
 
	}
 

	
 
	for (i = 0; i < templ.np; i++) {
 
		// see if we find it in lang, and zero it out
 
		/* see if we find it in lang, and zero it out */
 
		bool found = false;
 
		for (j = 0; j < lang.np; j++) {
 
			if (templ.pairs[i].a == lang.pairs[j].a &&
 
					strcmp(templ.pairs[i].v, lang.pairs[j].v) == 0) {
 
				// it was found in both. zero it out from lang so we don't find it again
 
				/* it was found in both. zero it out from lang so we don't find it again */
 
				lang.pairs[j].a = NULL;
 
				found = true;
 
				break;
 
@@ -792,8 +792,8 @@ static bool CheckCommandsMatch(char *a, 
 
		}
 
	}
 

	
 
	// if we reach here, all non consumer commands match up.
 
	// Check if the non consumer commands match up also.
 
	/* if we reach here, all non consumer commands match up.
 
	 * Check if the non consumer commands match up also. */
 
	for (i = 0; i < lengthof(templ.cmd); i++) {
 
		if (TranslateCmdForCompare(templ.cmd[i]) != TranslateCmdForCompare(lang.cmd[i])) {
 
			strgen_warning("%s: Param idx #%d '%s' doesn't match with template command '%s'", name, i,
 
@@ -817,7 +817,7 @@ static void HandleString(char *str, bool
 
		return;
 
	}
 

	
 
	// Ignore comments & blank lines
 
	/* Ignore comments & blank lines */
 
	if (*str == ';' || *str == ' ' || *str == '\0') return;
 

	
 
	s = strchr(str, ':');
 
@@ -826,8 +826,8 @@ static void HandleString(char *str, bool
 
		return;
 
	}
 

	
 
	// Trim spaces.
 
	// After this str points to the command name, and s points to the command contents
 
	/* Trim spaces.
 
	 * After this str points to the command name, and s points to the command contents */
 
	for (t = s; t > str && (t[-1] == ' ' || t[-1] == '\t'); t--);
 
	*t = 0;
 
	s++;
 
@@ -842,12 +842,12 @@ static void HandleString(char *str, bool
 
		}
 
	}
 

	
 
	// Check if the string has a case..
 
	// The syntax for cases is IDENTNAME.case
 
	/* Check if the string has a case..
 
	 * The syntax for cases is IDENTNAME.case */
 
	casep = strchr(str, '.');
 
	if (casep) *casep++ = 0;
 

	
 
	// Check if this string already exists..
 
	/* Check if this string already exists.. */
 
	ent = HashFind(str);
 

	
 
	if (master) {
 
@@ -867,7 +867,7 @@ static void HandleString(char *str, bool
 
				return;
 
			}
 

	
 
			// Allocate a new LangString
 
			/* Allocate a new LangString */
 
			ent = CallocT<LangString>(1);
 
			_strings[_next_string_id] = ent;
 
			ent->index = _next_string_id++;
 
@@ -900,10 +900,10 @@ static void HandleString(char *str, bool
 
		}
 

	
 
		if (s[0] == ':' && s[1] == '\0' && casep == NULL) {
 
			// Special syntax :: means we should just inherit the master string
 
			/* Special syntax :: means we should just inherit the master string */
 
			ent->translated = strdup(ent->english);
 
		} else {
 
			// make sure that the commands match
 
			/* make sure that the commands match */
 
			if (!CheckCommandsMatch(s, ent->english, str)) return;
 

	
 
			if (casep != NULL) {
 
@@ -942,8 +942,8 @@ static void ParseFile(const char *file, 
 
	_lang_textdir = TD_LTR;
 
	_lang_winlangid = 0x0000; // neutral language code
 
	_lang_newgrflangid = 0; // standard english
 
	// TODO:!! We can't reset the cases. In case the translated strings
 
	// derive some strings from english....
 
	/* TODO:!! We can't reset the cases. In case the translated strings
 
	 * derive some strings from english.... */
 

	
 
	in = fopen(file, "r");
 
	if (in == NULL) error("Cannot open file");
 
@@ -971,7 +971,7 @@ static uint32 MyHashStr(uint32 hash, con
 
}
 

	
 

	
 
// make a hash of the file to get a unique "version number"
 
/* make a hash of the file to get a unique "version number" */
 
static void MakeHashOfStrings()
 
{
 
	uint32 hash = 0;
 
@@ -1079,10 +1079,10 @@ static void WriteStringsH(const char *fi
 
	fclose(out);
 

	
 
	if (CompareFiles("tmp.xxx", filename)) {
 
		// files are equal. tmp.xxx is not needed
 
		/* files are equal. tmp.xxx is not needed */
 
		unlink("tmp.xxx");
 
	} else {
 
		// else rename tmp.xxx into filename
 
		/* else rename tmp.xxx into filename */
 
#if defined(WIN32) || defined(WIN64)
 
		unlink(filename);
 
#endif
 
@@ -1122,7 +1122,7 @@ static void PutCommandString(const char 
 
	_cur_argidx = 0;
 

	
 
	while (*str != '\0') {
 
		// Process characters as they are until we encounter a {
 
		/* Process characters as they are until we encounter a { */
 
		if (*str != '{') {
 
			PutByte(*str++);
 
			continue;
 
@@ -1135,15 +1135,15 @@ static void PutCommandString(const char 
 
			PutByte(casei);
 
		}
 

	
 
		// For params that consume values, we need to handle the argindex properly
 
		/* For params that consume values, we need to handle the argindex properly */
 
		if (cs->consumes > 0) {
 
			// Check if we need to output a move-param command
 
			/* Check if we need to output a move-param command */
 
			if (argno != -1 && argno != _cur_argidx) {
 
				_cur_argidx = argno;
 
				PutArgidxCommand();
 
			}
 

	
 
			// Output the one from the master string... it's always accurate.
 
			/* Output the one from the master string... it's always accurate. */
 
			cs = _cur_pcs.cmd[_cur_argidx++];
 
			if (cs == NULL) {
 
				error("%s: No argument exists at position %d", _cur_ident, _cur_argidx - 1);
 
@@ -1186,7 +1186,7 @@ static void WriteLangfile(const char *fi
 
		hdr.offsets[i] = TO_LE16(n);
 
	}
 

	
 
	// see line 655: fprintf(..."\tLANGUAGE_PACK_IDENT = 0x474E414C,...)
 
	/* see line 655: fprintf(..."\tLANGUAGE_PACK_IDENT = 0x474E414C,...) */
 
	hdr.ident = TO_LE32(0x474E414C); // Big Endian value for 'LANG'
 
	hdr.version = TO_LE32(_hash);
 
	hdr.plural_form = _lang_pluralform;
 
@@ -1205,7 +1205,7 @@ static void WriteLangfile(const char *fi
 
			const Case *casep;
 
			const char *cmdp;
 

	
 
			// For undefined strings, just set that it's an empty string
 
			/* For undefined strings, just set that it's an empty string */
 
			if (ls == NULL) {
 
				WriteLength(f, 0);
 
				continue;
 
@@ -1214,7 +1214,7 @@ static void WriteLangfile(const char *fi
 
			_cur_ident = ls->name;
 
			_cur_line = ls->line;
 

	
 
			// Produce a message if a string doesn't have a translation.
 
			/* Produce a message if a string doesn't have a translation. */
 
			if (_show_todo > 0 && ls->translated == NULL) {
 
				if ((_show_todo & 2) != 0) {
 
					strgen_warning("'%s' is untranslated", ls->name);
 
@@ -1225,7 +1225,7 @@ static void WriteLangfile(const char *fi
 
				}
 
			}
 

	
 
			// Extract the strings and stuff from the english command string
 
			/* Extract the strings and stuff from the english command string */
 
			ExtractCommandString(&_cur_pcs, ls->english, false);
 

	
 
			if (ls->translated_case != NULL || ls->translated != NULL) {
 
@@ -1242,28 +1242,28 @@ static void WriteLangfile(const char *fi
 
				const Case *c;
 
				uint num;
 

	
 
				// Need to output a case-switch.
 
				// It has this format
 
				// <0x9E> <NUM CASES> <CASE1> <LEN1> <STRING1> <CASE2> <LEN2> <STRING2> <CASE3> <LEN3> <STRING3> <STRINGDEFAULT>
 
				// Each LEN is printed using 2 bytes in big endian order.
 
				/* Need to output a case-switch.
 
				 * It has this format
 
				 * <0x9E> <NUM CASES> <CASE1> <LEN1> <STRING1> <CASE2> <LEN2> <STRING2> <CASE3> <LEN3> <STRING3> <STRINGDEFAULT>
 
				 * Each LEN is printed using 2 bytes in big endian order. */
 
				PutUtf8(SCC_SWITCH_CASE);
 
				// Count the number of cases
 
				/* Count the number of cases */
 
				for (num = 0, c = casep; c; c = c->next) num++;
 
				PutByte(num);
 

	
 
				// Write each case
 
				/* Write each case */
 
				for (c = casep; c != NULL; c = c->next) {
 
					int pos;
 

	
 
					PutByte(c->caseidx);
 
					// Make some space for the 16-bit length
 
					/* Make some space for the 16-bit length */
 
					pos = _put_pos;
 
					PutByte(0);
 
					PutByte(0);
 
					// Write string
 
					/* Write string */
 
					PutCommandString(c->string);
 
					PutByte(0); // terminate with a zero
 
					// Fill in the length
 
					/* Fill in the length */
 
					_put_buf[pos + 0] = GB(_put_pos - (pos + 2), 8, 8);
 
					_put_buf[pos + 1] = GB(_put_pos - (pos + 2), 0, 8);
 
				}
src/string.cpp
Show inline comments
 
@@ -11,7 +11,7 @@
 
#include "table/control_codes.h"
 

	
 
#include <stdarg.h>
 
#include <ctype.h> // required for tolower()
 
#include <ctype.h> /* required for tolower() */
 

	
 
/**
 
 * Safer implementation of vsnprintf; same as vsnprintf except:
 
@@ -300,7 +300,7 @@ size_t Utf8Decode(WChar *c, const char *
 
		}
 
	}
 

	
 
	//DEBUG(misc, 1, "[utf8] invalid UTF-8 sequence");
 
	/* DEBUG(misc, 1, "[utf8] invalid UTF-8 sequence"); */
 
	*c = '?';
 
	return 1;
 
}
 
@@ -333,7 +333,7 @@ size_t Utf8Encode(char *buf, WChar c)
 
		return 4;
 
	}
 

	
 
	//DEBUG(misc, 1, "[utf8] can't UTF-8 encode value 0x%X", c);
 
	/* DEBUG(misc, 1, "[utf8] can't UTF-8 encode value 0x%X", c); */
 
	*buf = '?';
 
	return 1;
 
}
src/strings.cpp
Show inline comments
 
@@ -180,7 +180,7 @@ void InjectDParam(uint amount)
 
	memmove(_decode_parameters + amount, _decode_parameters, sizeof(_decode_parameters) - amount * sizeof(uint64));
 
}
 

	
 
// TODO
 
/* TODO */
 
static char *FormatCommaNumber(char *buff, int64 number, const char *last)
 
{
 
	uint64 divisor = 10000000000000000000ULL;
 
@@ -216,7 +216,7 @@ static char *FormatCommaNumber(char *buf
 
	return buff;
 
}
 

	
 
// TODO
 
/* TODO */
 
static char *FormatNoCommaNumber(char *buff, int64 number, const char *last)
 
{
 
	uint64 divisor = 10000000000000000000ULL;
 
@@ -465,7 +465,7 @@ static int DeterminePluralForm(int64 cou
 

	
 
static const char *ParseStringChoice(const char *b, uint form, char *dst, int *dstlen)
 
{
 
	//<NUM> {Length of each string} {each string}
 
	/* <NUM> {Length of each string} {each string} */
 
	uint n = (byte)*b++;
 
	uint pos, i, mylen = 0, mypos = 0;
 

	
 
@@ -1320,8 +1320,8 @@ bool ReadLanguagePack(int lang_index)
 
	return true;
 
}
 

	
 
/* Win32 implementation in win32.cpp. */
 
/* OS X implementation in os/macosx/macos.mm. */
 
/* Win32 implementation in win32.cpp.
 
 * OS X implementation in os/macosx/macos.mm. */
 
#if !(defined(WIN32) || defined(__APPLE__))
 
/** Determine the current charset based on the environment
 
 * First check some default values, after this one we passed ourselves
src/strings_type.h
Show inline comments
 
@@ -39,7 +39,7 @@ struct DynamicLanguages {
 
/** Special string constants */
 
enum SpecialStrings {
 

	
 
	// special strings for town names. the town name is generated dynamically on request.
 
	/* special strings for town names. the town name is generated dynamically on request. */
 
	SPECSTR_TOWNNAME_START     = 0x20C0,
 
	SPECSTR_TOWNNAME_ENGLISH   = SPECSTR_TOWNNAME_START,
 
	SPECSTR_TOWNNAME_FRENCH,
 
@@ -64,7 +64,7 @@ enum SpecialStrings {
 
	SPECSTR_TOWNNAME_CATALAN,
 
	SPECSTR_TOWNNAME_LAST      = SPECSTR_TOWNNAME_CATALAN,
 

	
 
	// special strings for player names on the form "TownName transport".
 
	/* special strings for player names on the form "TownName transport". */
 
	SPECSTR_PLAYERNAME_START   = 0x70EA,
 
	SPECSTR_PLAYERNAME_ENGLISH = SPECSTR_PLAYERNAME_START,
 
	SPECSTR_PLAYERNAME_FRENCH,
 
@@ -78,15 +78,15 @@ enum SpecialStrings {
 
	SPECSTR_PRESIDENT_NAME     = 0x70E7,
 
	SPECSTR_SONGNAME           = 0x70E8,
 

	
 
	// reserve MAX_LANG strings for the *.lng files
 
	/* reserve MAX_LANG strings for the *.lng files */
 
	SPECSTR_LANGUAGE_START     = 0x7100,
 
	SPECSTR_LANGUAGE_END       = SPECSTR_LANGUAGE_START + MAX_LANG - 1,
 

	
 
	// reserve 32 strings for various screen resolutions
 
	/* reserve 32 strings for various screen resolutions */
 
	SPECSTR_RESOLUTION_START   = SPECSTR_LANGUAGE_END + 1,
 
	SPECSTR_RESOLUTION_END     = SPECSTR_RESOLUTION_START + 0x1F,
 

	
 
	// reserve 32 strings for screenshot formats
 
	/* reserve 32 strings for screenshot formats */
 
	SPECSTR_SCREENSHOT_START   = SPECSTR_RESOLUTION_END + 1,
 
	SPECSTR_SCREENSHOT_END     = SPECSTR_SCREENSHOT_START + 0x1F,
 
};
src/table/sprites.h
Show inline comments
 
@@ -1086,10 +1086,10 @@ enum Sprites {
 
	SPR_CARGO_WOOD                  = 4304,
 
	SPR_CARGO_IRON_ORE              = 4305,
 
	SPR_CARGO_STEEL                 = 4306,
 
	SPR_CARGO_VALUES_GOLD           = 4307,  //shared between temperate and arctic
 
	SPR_CARGO_VALUES_GOLD           = 4307,  // shared between temperate and arctic
 
	SPR_CARGO_FRUIT                 = 4308,
 
	SPR_CARGO_COPPER_ORE            = 4309,
 
	SPR_CARGO_WATERCOLA             = 4310,  //shared between desert and toyland
 
	SPR_CARGO_WATERCOLA             = 4310,  // shared between desert and toyland
 
	SPR_CARGO_DIAMONDS              = 4311,
 
	SPR_CARGO_FOOD                  = 4312,
 
	SPR_CARGO_PAPER                 = 4313,
src/timetable_gui.cpp
Show inline comments
 
@@ -256,18 +256,18 @@ struct TimetableWindow : Window {
 
		const Vehicle *v = this->vehicle;
 

	
 
		switch (widget) {
 
			case TTV_ORDER_VIEW: /* Order view button */
 
			case TTV_ORDER_VIEW: // Order view button
 
				ShowOrdersWindow(v);
 
				break;
 

	
 
			case TTV_TIMETABLE_PANEL: { /* Main panel. */
 
			case TTV_TIMETABLE_PANEL: { // Main panel.
 
				int selected = GetOrderFromTimetableWndPt(pt.y, v);
 

	
 
				this->DeleteChildWindows();
 
				this->sel_index = (selected == INVALID_ORDER || selected == this->sel_index) ? -1 : selected;
 
			} break;
 

	
 
			case TTV_CHANGE_TIME: { /* "Wait For" button. */
 
			case TTV_CHANGE_TIME: { // "Wait For" button.
 
				int selected = this->sel_index;
 
				VehicleOrderID real = (selected + 1) / 2;
 

	
 
@@ -289,16 +289,16 @@ struct TimetableWindow : Window {
 
				ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, this, CS_NUMERAL, QSF_NONE);
 
			} break;
 

	
 
			case TTV_CLEAR_TIME: { /* Clear waiting time button. */
 
			case TTV_CLEAR_TIME: { // Clear waiting time button.
 
				uint32 p1 = PackTimetableArgs(v, this->sel_index);
 
				DoCommandP(0, p1, 0, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
 
			} break;
 

	
 
			case TTV_RESET_LATENESS: /* Reset the vehicle's late counter. */
 
			case TTV_RESET_LATENESS: // Reset the vehicle's late counter.
 
				DoCommandP(0, v->index, 0, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
 
				break;
 

	
 
			case TTV_AUTOFILL: { /* Autofill the timetable. */
 
			case TTV_AUTOFILL: { // Autofill the timetable.
 
				uint32 p2 = 0;
 
				if (!HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(p2, 0);
 
				if (_ctrl_pressed) SetBit(p2, 1);
src/toolbar_gui.cpp
Show inline comments
 
@@ -948,33 +948,33 @@ static void SplitToolbar(Window *w)
 
typedef void MenuClickedProc(int index);
 

	
 
static MenuClickedProc * const _menu_clicked_procs[] = {
 
	NULL,                 /* 0 */
 
	NULL,                 /* 1 */
 
	MenuClickSettings,    /* 2 */
 
	MenuClickSaveLoad,    /* 3 */
 
	MenuClickMap,         /* 4 */
 
	MenuClickTown,        /* 5 */
 
	MenuClickSubsidies,   /* 6 */
 
	MenuClickStations,    /* 7 */
 
	MenuClickFinances,    /* 8 */
 
	MenuClickCompany,     /* 9 */
 
	MenuClickGraphs,      /* 10 */
 
	MenuClickLeague,      /* 11 */
 
	MenuClickIndustry,    /* 12 */
 
	MenuClickShowTrains,  /* 13 */
 
	MenuClickShowRoad,    /* 14 */
 
	MenuClickShowShips,   /* 15 */
 
	MenuClickShowAir,     /* 16 */
 
	MenuClickMap,         /* 17 */
 
	NULL,                 /* 18 */
 
	MenuClickBuildRail,   /* 19 */
 
	MenuClickBuildRoad,   /* 20 */
 
	MenuClickBuildWater,  /* 21 */
 
	MenuClickBuildAir,    /* 22 */
 
	MenuClickForest,      /* 23 */
 
	MenuClickMusicWindow, /* 24 */
 
	MenuClickNewspaper,   /* 25 */
 
	MenuClickHelp,        /* 26 */
 
	NULL,                 // 0
 
	NULL,                 // 1
 
	MenuClickSettings,    // 2
 
	MenuClickSaveLoad,    // 3
 
	MenuClickMap,         // 4
 
	MenuClickTown,        // 5
 
	MenuClickSubsidies,   // 6
 
	MenuClickStations,    // 7
 
	MenuClickFinances,    // 8
 
	MenuClickCompany,     // 9
 
	MenuClickGraphs,      // 10
 
	MenuClickLeague,      // 11
 
	MenuClickIndustry,    // 12
 
	MenuClickShowTrains,  // 13
 
	MenuClickShowRoad,    // 14
 
	MenuClickShowShips,   // 15
 
	MenuClickShowAir,     // 16
 
	MenuClickMap,         // 17
 
	NULL,                 // 18
 
	MenuClickBuildRail,   // 19
 
	MenuClickBuildRoad,   // 20
 
	MenuClickBuildWater,  // 21
 
	MenuClickBuildAir,    // 22
 
	MenuClickForest,      // 23
 
	MenuClickMusicWindow, // 24
 
	MenuClickNewspaper,   // 25
 
	MenuClickHelp,        // 26
 
};
 

	
 
/* --- Toolbar handling for the 'normal' case */
src/toolbar_gui.h
Show inline comments
 
@@ -7,4 +7,4 @@
 

	
 
void AllocateToolbar();
 

	
 
#endif /*TOOLBAR_GUI_H*/
 
#endif /* TOOLBAR_GUI_H */
src/town_cmd.cpp
Show inline comments
 
@@ -1128,7 +1128,7 @@ static void GrowTownInTile(TileIndex *ti
 
			switch (t1->layout) {
 
				default: NOT_REACHED();
 

	
 
				case TL_3X3_GRID: /* Use 2x2 grid afterwards! */
 
				case TL_3X3_GRID: // Use 2x2 grid afterwards!
 
					GrowTownWithExtraHouse(t1, TileAddByDiagDir(house_tile, target_dir));
 
					/* FALL THROUGH */
 

	
 
@@ -1137,7 +1137,7 @@ static void GrowTownInTile(TileIndex *ti
 
					allow_house = (rcmd == ROAD_NONE);
 
					break;
 

	
 
				case TL_BETTER_ROADS: /* Use original afterwards! */
 
				case TL_BETTER_ROADS: // Use original afterwards!
 
					GrowTownWithExtraHouse(t1, TileAddByDiagDir(house_tile, target_dir));
 
					/* FALL THROUGH */
 

	
src/town_gui.cpp
Show inline comments
 
@@ -353,7 +353,7 @@ public:
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case TVW_CENTERVIEW: /* scroll to location */
 
			case TVW_CENTERVIEW: // scroll to location
 
				if (_ctrl_pressed) {
 
					ShowExtraViewPortWindow(this->town->xy);
 
				} else {
 
@@ -361,20 +361,20 @@ public:
 
				}
 
				break;
 

	
 
			case TVW_SHOWAUTORITY: /* town authority */
 
			case TVW_SHOWAUTORITY: // town authority
 
				ShowTownAuthorityWindow(this->window_number);
 
				break;
 

	
 
			case TVW_CHANGENAME: /* rename */
 
			case TVW_CHANGENAME: // rename
 
				SetDParam(0, this->window_number);
 
				ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, MAX_LENGTH_TOWN_NAME_BYTES, MAX_LENGTH_TOWN_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
 
				break;
 

	
 
			case TVW_EXPAND: /* expand town - only available on Scenario editor */
 
			case TVW_EXPAND: // expand town - only available on Scenario editor
 
				ExpandTown(this->town);
 
				break;
 

	
 
			case TVW_DELETE: /* delete town - only available on Scenario editor */
 
			case TVW_DELETE: // delete town - only available on Scenario editor
 
				delete this->town;
 
				break;
 
		}
 
@@ -581,7 +581,7 @@ public:
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case TDW_SORTNAME: /* Sort by Name ascending/descending */
 
			case TDW_SORTNAME: // Sort by Name ascending/descending
 
				if (this->towns.SortType() == 0) {
 
					this->towns.ToggleSortOrder();
 
				} else {
 
@@ -590,7 +590,7 @@ public:
 
				this->SetDirty();
 
				break;
 

	
 
			case TDW_SORTPOPULATION: /* Sort by Population ascending/descending */
 
			case TDW_SORTPOPULATION: // Sort by Population ascending/descending
 
				if (this->towns.SortType() == 1) {
 
					this->towns.ToggleSortOrder();
 
				} else {
 
@@ -599,7 +599,7 @@ public:
 
				this->SetDirty();
 
				break;
 

	
 
			case TDW_CENTERTOWN: { /* Click on Town Matrix */
 
			case TDW_CENTERTOWN: { // Click on Town Matrix
 
				uint16 id_v = (pt.y - 28) / 10;
 

	
 
				if (id_v >= this->vscroll.cap) return; // click out of bounds
src/town_type.h
Show inline comments
 
@@ -78,10 +78,10 @@ enum TownLayout {
 
	NUM_TLS,             ///< Number of town layouts
 
};
 

	
 
/* It needs to be 8bits, because we save and load it as such */
 
/** Define basic enum properties */
 
/** It needs to be 8bits, because we save and load it as such
 
 * Define basic enum properties */
 
template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_BEGIN, NUM_TLS, NUM_TLS> {};
 
typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout
 
typedef TinyEnumT<TownLayout> TownLayoutByte; // typedefing-enumification of TownLayout
 

	
 
enum {
 
	MAX_LENGTH_TOWN_NAME_BYTES  =  31, ///< The maximum length of a town name in bytes including '\0'
src/train_cmd.cpp
Show inline comments
 
@@ -362,7 +362,7 @@ static int GetTrainAcceleration(Vehicle 
 
	int speed = v->cur_speed * 10 / 16; // km-ish/h -> mp/h
 
	int curvecount[2] = {0, 0};
 

	
 
	/*first find the curve speed limit */
 
	/* first find the curve speed limit */
 
	int numcurve = 0;
 
	int sum = 0;
 
	int pos = 0;
 
@@ -387,7 +387,7 @@ static int GetTrainAcceleration(Vehicle 
 
			lastpos = pos;
 
		}
 

	
 
		/*if we have a 90 degree turn, fix the speed limit to 60 */
 
		/* if we have a 90 degree turn, fix the speed limit to 60 */
 
		if (dirdiff == DIRDIFF_90LEFT || dirdiff == DIRDIFF_90RIGHT) {
 
			max_speed = 61;
 
		}
 
@@ -435,7 +435,7 @@ static int GetTrainAcceleration(Vehicle 
 
	int power = v->u.rail.cached_power * 746;
 
	max_speed = min(max_speed, v->u.rail.cached_max_speed);
 

	
 
	int num = 0; //number of vehicles, change this into the number of axles later
 
	int num = 0; // number of vehicles, change this into the number of axles later
 
	int incl = 0;
 
	int drag_coeff = 20; //[1e-4]
 
	for (const Vehicle *u = v; u != NULL; u = u->Next()) {
 
@@ -445,7 +445,7 @@ static int GetTrainAcceleration(Vehicle 
 
		if (u->u.rail.track == TRACK_BIT_DEPOT) max_speed = min(max_speed, 61);
 

	
 
		if (HasBit(u->u.rail.flags, VRF_GOINGUP)) {
 
			incl += u->u.rail.cached_veh_weight * 60; //3% slope, quite a bit actually
 
			incl += u->u.rail.cached_veh_weight * 60; // 3% slope, quite a bit actually
 
		} else if (HasBit(u->u.rail.flags, VRF_GOINGDOWN)) {
 
			incl -= u->u.rail.cached_veh_weight * 60;
 
		}
 
@@ -1379,7 +1379,7 @@ CommandCost CmdSellRailWagon(TileIndex t
 

	
 
	CommandCost cost(EXPENSES_NEW_VEHICLES);
 
	switch (p2) {
 
		case 0: { /* Delete given wagon */
 
		case 0: { // Delete given wagon
 
			bool switch_engine = false;    // update second wagon to engine?
 

	
 
			/* 1. Delete the engine, if it is dualheaded also delete the matching
 
@@ -1454,7 +1454,7 @@ CommandCost CmdSellRailWagon(TileIndex t
 

	
 
			}
 
		} break;
 
		case 1: { /* Delete wagon and all wagons after it given certain criteria */
 
		case 1: { // Delete wagon and all wagons after it given certain criteria
 
			/* Start deleting every vehicle after the selected one
 
			 * If we encounter a matching rear-engine to a front-engine
 
			 * earlier in the chain (before deletion), leave it alone */
 
@@ -2129,12 +2129,12 @@ static TrainFindDepotData FindClosestTra
 
	if ((_settings_game.pf.reserve_paths || HasReservedTracks(v->tile, v->u.rail.track)) && pathfinder == VPF_NTP) pathfinder = VPF_NPF;
 

	
 
	switch (pathfinder) {
 
		case VPF_YAPF: { /* YAPF */
 
		case VPF_YAPF: { // YAPF
 
			bool found = YapfFindNearestRailDepotTwoWay(v, max_distance, NPF_INFINITE_PENALTY, &tfdd.tile, &tfdd.reverse);
 
			tfdd.best_length = found ? max_distance / 2 : UINT_MAX; // some fake distance or NOT_FOUND
 
		} break;
 

	
 
		case VPF_NPF: { /* NPF */
 
		case VPF_NPF: { // NPF
 
			const Vehicle *last = GetLastVehicleInChain(v);
 
			Trackdir trackdir = GetVehicleTrackdir(v);
 
			Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last));
 
@@ -2154,7 +2154,7 @@ static TrainFindDepotData FindClosestTra
 
		} break;
 

	
 
		default:
 
		case VPF_NTP: { /* NTP */
 
		case VPF_NTP: { // NTP
 
			/* search in the forward direction first. */
 
			DiagDirection i = TrainExitDir(v->direction, v->u.rail.track);
 
			NewTrainPathfind(v->tile, 0, v->u.rail.compatible_railtypes, i, (NTPEnumProc*)NtpCallbFindDepot, &tfdd);
 
@@ -2588,7 +2588,7 @@ static Track DoTrainPathfind(Vehicle *v,
 
	if (do_track_reservation && pathfinder == VPF_NTP) pathfinder = VPF_NPF;
 

	
 
	switch (pathfinder) {
 
		case VPF_YAPF: { /* YAPF */
 
		case VPF_YAPF: { // YAPF
 
			Trackdir trackdir = YapfChooseRailTrack(v, tile, enterdir, tracks, path_not_found, do_track_reservation, dest);
 
			if (trackdir != INVALID_TRACKDIR) {
 
				best_track = TrackdirToTrack(trackdir);
 
@@ -2597,7 +2597,7 @@ static Track DoTrainPathfind(Vehicle *v,
 
			}
 
		} break;
 

	
 
		case VPF_NPF: { /* NPF */
 
		case VPF_NPF: { // NPF
 
			void *perf = NpfBeginInterval();
 

	
 
			NPFFindStationOrTileData fstd;
 
@@ -2634,7 +2634,7 @@ static Track DoTrainPathfind(Vehicle *v,
 
		} break;
 

	
 
		default:
 
		case VPF_NTP: { /* NTP */
 
		case VPF_NTP: { // NTP
 
			void *perf = NpfBeginInterval();
 

	
 
			TrainTrackFollowerData fd;
 
@@ -3129,11 +3129,11 @@ static bool CheckReverseTrain(Vehicle *v
 
	assert(v->u.rail.track);
 

	
 
	switch (_settings_game.pf.pathfinder_for_trains) {
 
		case VPF_YAPF: /* YAPF */
 
		case VPF_YAPF: // YAPF
 
			reverse_best = YapfCheckReverseTrain(v);
 
			break;
 

	
 
		case VPF_NPF: { /* NPF */
 
		case VPF_NPF: { // NPF
 
			NPFFindStationOrTileData fstd;
 
			NPFFoundTargetData ftd;
 
			Vehicle *last = GetLastVehicleInChain(v);
 
@@ -3159,7 +3159,7 @@ static bool CheckReverseTrain(Vehicle *v
 
		} break;
 

	
 
		default:
 
		case VPF_NTP: { /* NTP */
 
		case VPF_NTP: { // NTP
 
			TrainTrackFollowerData fd;
 
			FillWithStationData(&fd, v);
 

	
 
@@ -3409,7 +3409,7 @@ struct RailtypeSlowdownParams {
 
};
 

	
 
static const RailtypeSlowdownParams _railtype_slowdown[] = {
 
	// normal accel
 
	/* normal accel */
 
	{256 / 4, 256 / 2, 256 / 4, 2}, ///< normal
 
	{256 / 4, 256 / 2, 256 / 4, 2}, ///< electrified
 
	{256 / 4, 256 / 2, 256 / 4, 2}, ///< monorail
 
@@ -4083,7 +4083,7 @@ static bool TrainApproachingLineEnd(Vehi
 
	 * for other directions, it will be 1, 3, 5, ..., 15 */
 
	switch (v->direction) {
 
		case DIR_N : x = ~x + ~y + 25; break;
 
		case DIR_NW: x = y;            /* FALLTHROUGH */
 
		case DIR_NW: x = y;            // FALLTHROUGH
 
		case DIR_NE: x = ~x + 16;      break;
 
		case DIR_E : x = ~x + y + 9;   break;
 
		case DIR_SE: x = y;            break;
src/tree_cmd.cpp
Show inline comments
 
@@ -333,7 +333,7 @@ CommandCost CmdPlantTree(TileIndex tile,
 
	/* Check the tree type. It can be random or some valid value within the current climate */
 
	if (p1 != UINT_MAX && p1 - _tree_base_by_landscape[_settings_game.game_creation.landscape] >= _tree_count_by_landscape[_settings_game.game_creation.landscape]) return CMD_ERROR;
 

	
 
	// make sure sx,sy are smaller than ex,ey
 
	/* make sure sx,sy are smaller than ex, ey */
 
	ex = TileX(tile);
 
	ey = TileY(tile);
 
	sx = TileX(p2);
 
@@ -650,18 +650,18 @@ static void TileLoop_Trees(TileIndex til
 
	SetTreeCounter(tile, 0);
 

	
 
	switch (GetTreeGrowth(tile)) {
 
		case 3: /* regular sized tree */
 
		case 3: // regular sized tree
 
			if (_settings_game.game_creation.landscape == LT_TROPIC &&
 
					GetTreeType(tile) != TREE_CACTUS &&
 
					GetTropicZone(tile) == TROPICZONE_DESERT) {
 
				AddTreeGrowth(tile, 1);
 
			} else {
 
				switch (GB(Random(), 0, 3)) {
 
					case 0: /* start destructing */
 
					case 0: // start destructing
 
						AddTreeGrowth(tile, 1);
 
						break;
 

	
 
					case 1: /* add a tree */
 
					case 1: // add a tree
 
						if (GetTreeCount(tile) < 4) {
 
							AddTreeCount(tile, 1);
 
							SetTreeGrowth(tile, 0);
 
@@ -669,7 +669,7 @@ static void TileLoop_Trees(TileIndex til
 
						}
 
						/* FALL THROUGH */
 

	
 
					case 2: { /* add a neighbouring tree */
 
					case 2: { // add a neighbouring tree
 
						TreeType treetype = GetTreeType(tile);
 

	
 
						tile += TileOffsByDir((Direction)(Random() & 7));
 
@@ -691,7 +691,7 @@ static void TileLoop_Trees(TileIndex til
 
			}
 
			break;
 

	
 
		case 6: /* final stage of tree destruction */
 
		case 6: // final stage of tree destruction
 
			if (GetTreeCount(tile) > 1) {
 
				/* more than one tree, delete it */
 
				AddTreeCount(tile, -1);
 
@@ -770,18 +770,18 @@ static CommandCost TerraformTile_Trees(T
 

	
 

	
 
extern const TileTypeProcs _tile_type_trees_procs = {
 
	DrawTile_Trees,           /* draw_tile_proc */
 
	GetSlopeZ_Trees,          /* get_slope_z_proc */
 
	ClearTile_Trees,          /* clear_tile_proc */
 
	GetAcceptedCargo_Trees,   /* get_accepted_cargo_proc */
 
	GetTileDesc_Trees,        /* get_tile_desc_proc */
 
	GetTileTrackStatus_Trees, /* get_tile_track_status_proc */
 
	ClickTile_Trees,          /* click_tile_proc */
 
	AnimateTile_Trees,        /* animate_tile_proc */
 
	TileLoop_Trees,           /* tile_loop_clear */
 
	ChangeTileOwner_Trees,    /* change_tile_owner_clear */
 
	NULL,                     /* get_produced_cargo_proc */
 
	NULL,                     /* vehicle_enter_tile_proc */
 
	GetFoundation_Trees,      /* get_foundation_proc */
 
	TerraformTile_Trees,      /* terraform_tile_proc */
 
	DrawTile_Trees,           // draw_tile_proc
 
	GetSlopeZ_Trees,          // get_slope_z_proc
 
	ClearTile_Trees,          // clear_tile_proc
 
	GetAcceptedCargo_Trees,   // get_accepted_cargo_proc
 
	GetTileDesc_Trees,        // get_tile_desc_proc
 
	GetTileTrackStatus_Trees, // get_tile_track_status_proc
 
	ClickTile_Trees,          // click_tile_proc
 
	AnimateTile_Trees,        // animate_tile_proc
 
	TileLoop_Trees,           // tile_loop_clear
 
	ChangeTileOwner_Trees,    // change_tile_owner_clear
 
	NULL,                     // get_produced_cargo_proc
 
	NULL,                     // vehicle_enter_tile_proc
 
	GetFoundation_Trees,      // get_foundation_proc
 
	TerraformTile_Trees,      // terraform_tile_proc
 
};
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1534,18 +1534,18 @@ static CommandCost TerraformTile_TunnelB
 
}
 

	
 
extern const TileTypeProcs _tile_type_tunnelbridge_procs = {
 
	DrawTile_TunnelBridge,           /* draw_tile_proc */
 
	GetSlopeZ_TunnelBridge,          /* get_slope_z_proc */
 
	ClearTile_TunnelBridge,          /* clear_tile_proc */
 
	GetAcceptedCargo_TunnelBridge,   /* get_accepted_cargo_proc */
 
	GetTileDesc_TunnelBridge,        /* get_tile_desc_proc */
 
	GetTileTrackStatus_TunnelBridge, /* get_tile_track_status_proc */
 
	ClickTile_TunnelBridge,          /* click_tile_proc */
 
	AnimateTile_TunnelBridge,        /* animate_tile_proc */
 
	TileLoop_TunnelBridge,           /* tile_loop_clear */
 
	ChangeTileOwner_TunnelBridge,    /* change_tile_owner_clear */
 
	NULL,                            /* get_produced_cargo_proc */
 
	VehicleEnter_TunnelBridge,       /* vehicle_enter_tile_proc */
 
	GetFoundation_TunnelBridge,      /* get_foundation_proc */
 
	TerraformTile_TunnelBridge,      /* terraform_tile_proc */
 
	DrawTile_TunnelBridge,           // draw_tile_proc
 
	GetSlopeZ_TunnelBridge,          // get_slope_z_proc
 
	ClearTile_TunnelBridge,          // clear_tile_proc
 
	GetAcceptedCargo_TunnelBridge,   // get_accepted_cargo_proc
 
	GetTileDesc_TunnelBridge,        // get_tile_desc_proc
 
	GetTileTrackStatus_TunnelBridge, // get_tile_track_status_proc
 
	ClickTile_TunnelBridge,          // click_tile_proc
 
	AnimateTile_TunnelBridge,        // animate_tile_proc
 
	TileLoop_TunnelBridge,           // tile_loop_clear
 
	ChangeTileOwner_TunnelBridge,    // change_tile_owner_clear
 
	NULL,                            // get_produced_cargo_proc
 
	VehicleEnter_TunnelBridge,       // vehicle_enter_tile_proc
 
	GetFoundation_TunnelBridge,      // get_foundation_proc
 
	TerraformTile_TunnelBridge,      // terraform_tile_proc
 
};
src/unix.cpp
Show inline comments
 
@@ -42,7 +42,7 @@ ULONG __stack = (1024*1024)*2; // maybe 
 

	
 
#if defined(__APPLE__)
 
	#if defined(WITH_SDL)
 
		/*the mac implementation needs this file included in the same file as main() */
 
		/* the mac implementation needs this file included in the same file as main() */
 
		#include <SDL.h>
 
	#endif
 
#endif
 
@@ -273,7 +273,7 @@ bool InsertTextBufferClipboard(Textbuf *
 
	extern struct Device      *TimerBase    = NULL;
 
	extern struct MsgPort     *TimerPort    = NULL;
 
	extern struct timerequest *TimerRequest = NULL;
 
#endif // __AMIGA__
 
#endif /* __AMIGA__ */
 

	
 
void CSleep(int milliseconds)
 
{
src/unmovable_cmd.cpp
Show inline comments
 
@@ -498,18 +498,18 @@ static CommandCost TerraformTile_Unmovab
 
}
 

	
 
extern const TileTypeProcs _tile_type_unmovable_procs = {
 
	DrawTile_Unmovable,             /* draw_tile_proc */
 
	GetSlopeZ_Unmovable,            /* get_slope_z_proc */
 
	ClearTile_Unmovable,            /* clear_tile_proc */
 
	GetAcceptedCargo_Unmovable,     /* get_accepted_cargo_proc */
 
	GetTileDesc_Unmovable,          /* get_tile_desc_proc */
 
	GetTileTrackStatus_Unmovable,   /* get_tile_track_status_proc */
 
	ClickTile_Unmovable,            /* click_tile_proc */
 
	AnimateTile_Unmovable,          /* animate_tile_proc */
 
	TileLoop_Unmovable,             /* tile_loop_clear */
 
	ChangeTileOwner_Unmovable,      /* change_tile_owner_clear */
 
	NULL,                           /* get_produced_cargo_proc */
 
	NULL,                           /* vehicle_enter_tile_proc */
 
	GetFoundation_Unmovable,        /* get_foundation_proc */
 
	TerraformTile_Unmovable,        /* terraform_tile_proc */
 
	DrawTile_Unmovable,             // draw_tile_proc
 
	GetSlopeZ_Unmovable,            // get_slope_z_proc
 
	ClearTile_Unmovable,            // clear_tile_proc
 
	GetAcceptedCargo_Unmovable,     // get_accepted_cargo_proc
 
	GetTileDesc_Unmovable,          // get_tile_desc_proc
 
	GetTileTrackStatus_Unmovable,   // get_tile_track_status_proc
 
	ClickTile_Unmovable,            // click_tile_proc
 
	AnimateTile_Unmovable,          // animate_tile_proc
 
	TileLoop_Unmovable,             // tile_loop_clear
 
	ChangeTileOwner_Unmovable,      // change_tile_owner_clear
 
	NULL,                           // get_produced_cargo_proc
 
	NULL,                           // vehicle_enter_tile_proc
 
	GetFoundation_Unmovable,        // get_foundation_proc
 
	TerraformTile_Unmovable,        // terraform_tile_proc
 
};
src/vehicle.cpp
Show inline comments
 
@@ -1197,7 +1197,7 @@ Trackdir GetVehicleTrackdir(const Vehicl
 

	
 
		case VEH_SHIP:
 
			if (v->IsInDepot())
 
				// We'll assume the ship is facing outwards
 
				/* We'll assume the ship is facing outwards */
 
				return DiagDirToDiagTrackdir(GetShipDepotDirection(v->tile));
 

	
 
			if (v->u.ship.state == TRACK_BIT_WORMHOLE) // ship on aqueduct, so just use his direction and assume a diagonal track
src/vehicle_cmd.cpp
Show inline comments
 
@@ -563,7 +563,7 @@ CommandCost CmdRenameVehicle(TileIndex t
 
 */
 
CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */
 
	uint16 serv_int = GetServiceIntervalClamped(p2); // Double check the service interval from the user-input
 

	
 
	if (serv_int != p2 || !IsValidVehicleID(p1)) return CMD_ERROR;
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -860,7 +860,7 @@ struct VehicleListWindow : public BaseVe
 
				this->widget[VLW_WIDGET_CAPTION].data  = STR_VEH_WITH_SHARED_ORDERS_LIST;
 
				break;
 

	
 
			case VLW_STANDARD: /* Company Name - standard widget setup */
 
			case VLW_STANDARD: // Company Name - standard widget setup
 
				switch (this->vehicle_type) {
 
					case VEH_TRAIN:    this->widget[VLW_WIDGET_CAPTION].data = STR_881B_TRAINS;        break;
 
					case VEH_ROAD:     this->widget[VLW_WIDGET_CAPTION].data = STR_9001_ROAD_VEHICLES; break;
 
@@ -874,7 +874,7 @@ struct VehicleListWindow : public BaseVe
 
				this->widget[VLW_WIDGET_CAPTION].data = STR_WAYPOINT_VIEWPORT_LIST;
 
				break;
 

	
 
			case VLW_STATION_LIST: /* Station Name */
 
			case VLW_STATION_LIST: // Station Name
 
				switch (this->vehicle_type) {
 
					case VEH_TRAIN:    this->widget[VLW_WIDGET_CAPTION].data = STR_SCHEDULED_TRAINS;        break;
 
					case VEH_ROAD:     this->widget[VLW_WIDGET_CAPTION].data = STR_SCHEDULED_ROAD_VEHICLES; break;
 
@@ -954,7 +954,7 @@ struct VehicleListWindow : public BaseVe
 

	
 
		/* draw the widgets */
 
		switch (window_type) {
 
			case VLW_SHARED_ORDERS: /* Shared Orders */
 
			case VLW_SHARED_ORDERS: // Shared Orders
 
				if (this->vehicles.Length() == 0) {
 
					/* We can't open this window without vehicles using this order
 
					 * and we should close the window when deleting the order      */
 
@@ -963,7 +963,7 @@ struct VehicleListWindow : public BaseVe
 
				SetDParam(0, this->vscroll.count);
 
				break;
 

	
 
			case VLW_STANDARD: /* Company Name */
 
			case VLW_STANDARD: // Company Name
 
				SetDParam(0, owner);
 
				SetDParam(1, this->vscroll.count);
 
				break;
 
@@ -973,7 +973,7 @@ struct VehicleListWindow : public BaseVe
 
				SetDParam(1, this->vscroll.count);
 
				break;
 

	
 
			case VLW_STATION_LIST: /* Station Name */
 
			case VLW_STATION_LIST: // Station Name
 
				SetDParam(0, index);
 
				SetDParam(1, this->vscroll.count);
 
				break;
 
@@ -1015,14 +1015,14 @@ struct VehicleListWindow : public BaseVe
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case VLW_WIDGET_SORT_ORDER: /* Flip sorting method ascending/descending */
 
			case VLW_WIDGET_SORT_ORDER: // Flip sorting method ascending/descending
 
				this->vehicles.ToggleSortOrder();
 
				this->SetDirty();
 
				break;
 
			case VLW_WIDGET_SORT_BY_PULLDOWN:/* Select sorting criteria dropdown menu */
 
			case VLW_WIDGET_SORT_BY_PULLDOWN:// Select sorting criteria dropdown menu
 
				ShowDropDownMenu(this, this->vehicle_sorter_names, this->vehicles.SortType(), VLW_WIDGET_SORT_BY_PULLDOWN, 0, (this->vehicle_type == VEH_TRAIN || this->vehicle_type == VEH_ROAD) ? 0 : (1 << 10));
 
				return;
 
			case VLW_WIDGET_LIST: { /* Matrix to show vehicles */
 
			case VLW_WIDGET_LIST: { // Matrix to show vehicles
 
				uint32 id_v = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / this->resize.step_height;
 
				const Vehicle *v;
 

	
 
@@ -1079,15 +1079,15 @@ struct VehicleListWindow : public BaseVe
 
				assert(this->vehicles.Length() != 0);
 

	
 
				switch (index) {
 
					case 0: /* Replace window */
 
					case 0: // Replace window
 
						ShowReplaceGroupVehicleWindow(DEFAULT_GROUP, this->vehicle_type);
 
						break;
 
					case 1: /* Send for servicing */
 
					case 1: // Send for servicing
 
						DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */,
 
							(this->window_number & VLW_MASK) | DEPOT_MASS_SEND | DEPOT_SERVICE,
 
							GetCmdSendToDepot(this->vehicle_type));
 
						break;
 
					case 2: /* Send to Depots */
 
					case 2: // Send to Depots
 
						DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */,
 
							(this->window_number & VLW_MASK) | DEPOT_MASS_SEND,
 
							GetCmdSendToDepot(this->vehicle_type));
 
@@ -1951,7 +1951,7 @@ struct VehicleViewWindow : Window {
 
				DoCommandP(v->tile, v->index, 0,
 
										_vehicle_command_translation_table[VCT_CMD_START_STOP][v->type]);
 
				break;
 
			case VVW_WIDGET_CENTER_MAIN_VIEH: {/* center main view */
 
			case VVW_WIDGET_CENTER_MAIN_VIEH: {// center main view
 
				const Window *mainwindow = FindWindowById(WC_MAIN_WINDOW, 0);
 
				/* code to allow the main window to 'follow' the vehicle if the ctrl key is pressed */
 
				if (_ctrl_pressed && mainwindow->viewport->zoom == ZOOM_LVL_NORMAL) {
src/vehicle_type.h
Show inline comments
 
@@ -46,8 +46,8 @@ enum {
 
	VPF_YAPF = 2, ///< Yet Another PathFinder
 
};
 

	
 
/* Flags to add to p2 for goto depot commands */
 
/* Note: bits 8-10 are used for VLW flags */
 
/* Flags to add to p2 for goto depot commands
 
 * Note: bits 8-10 are used for VLW flags */
 
enum DepotCommand {
 
	DEPOT_SERVICE       = (1 << 0), ///< The vehicle will leave the depot right after arrival (serivce only)
 
	DEPOT_MASS_SEND     = (1 << 1), ///< Tells that it's a mass send to depot command (type in VLW flag)
src/video/cocoa/cocoa_keys.h
Show inline comments
 
@@ -5,8 +5,8 @@
 
#ifndef COCOA_KEYS_H
 
#define COCOA_KEYS_H
 

	
 
/* From SDL_QuartzKeys.h */
 
/* These are the Macintosh key scancode constants -- from Inside Macintosh */
 
/* From SDL_QuartzKeys.h
 
 * These are the Macintosh key scancode constants -- from Inside Macintosh */
 

	
 
#define QZ_ESCAPE       0x35
 
#define QZ_F1           0x7A
src/video/dedicated_v.cpp
Show inline comments
 
@@ -44,7 +44,7 @@ static void OS2_SwitchToConsoleMode()
 

	
 
	DosGetInfoBlocks(&tib, &pib);
 

	
 
	// Change flag from PM to VIO
 
	/* Change flag from PM to VIO */
 
	pib->pib_ultype = 3;
 
}
 
#endif
 
@@ -144,14 +144,14 @@ const char *VideoDriver_Dedicated::Start
 
#if defined(WINCE)
 
	/* WinCE doesn't support console stuff */
 
#elif defined(WIN32)
 
	// For win32 we need to allocate a console (debug mode does the same)
 
	/* For win32 we need to allocate a console (debug mode does the same) */
 
	CreateConsole();
 
	CreateWindowsConsoleThread();
 
	SetConsoleTitle(_T("OpenTTD Dedicated Server"));
 
#endif
 

	
 
#ifdef __OS2__
 
	// For OS/2 we also need to switch to console mode instead of PM mode
 
	/* For OS/2 we also need to switch to console mode instead of PM mode */
 
	OS2_SwitchToConsoleMode();
 
#endif
 

	
 
@@ -252,7 +252,7 @@ void VideoDriver_Dedicated::MainLoop()
 
	signal(SIGQUIT, DedicatedSignalHandler);
 
#endif
 

	
 
	// Load the dedicated server stuff
 
	/* Load the dedicated server stuff */
 
	_is_network_server = true;
 
	_network_dedicated = true;
 
	_network_playas = COMPANY_SPECTATOR;
 
@@ -277,7 +277,7 @@ void VideoDriver_Dedicated::MainLoop()
 
		}
 
	}
 

	
 
	// Done loading, start game!
 
	/* Done loading, start game! */
 

	
 
	if (!_networking) {
 
		DEBUG(net, 0, "Dedicated server could not be started, aborting");
src/video/win32_v.cpp
Show inline comments
 
@@ -148,14 +148,14 @@ static bool AllocateDibSection(int w, in
 

	
 
static void ClientSizeChanged(int w, int h)
 
{
 
	// allocate new dib section of the new size
 
	/* allocate new dib section of the new size */
 
	if (AllocateDibSection(w, h)) {
 
		// mark all palette colors dirty
 
		/* mark all palette colors dirty */
 
		_pal_first_dirty = 0;
 
		_pal_count_dirty = 256;
 
		GameSizeChanged();
 

	
 
		// redraw screen
 
		/* redraw screen */
 
		if (_wnd.running) {
 
			_screen.dst_ptr = _wnd.buffer_bits;
 
			UpdateWindows();
 
@@ -164,8 +164,8 @@ static void ClientSizeChanged(int w, int
 
}
 

	
 
#ifdef _DEBUG
 
// Keep this function here..
 
// It allows you to redraw the screen from within the MSVC debugger
 
/* Keep this function here..
 
 * It allows you to redraw the screen from within the MSVC debugger */
 
int RedrawScreenDebug()
 
{
 
	HDC dc, dc2;
 
@@ -220,7 +220,7 @@ static bool MakeWindow(bool full_screen)
 
{
 
	_fullscreen = full_screen;
 

	
 
	// recreate window?
 
	/* recreate window? */
 
	if ((full_screen || _wnd.fullscreen) && _wnd.main_wnd) {
 
		DestroyWindow(_wnd.main_wnd);
 
		_wnd.main_wnd = 0;
 
@@ -252,7 +252,7 @@ static bool MakeWindow(bool full_screen)
 
			return false;  // the request failed
 
		}
 
	} else if (_wnd.fullscreen) {
 
		// restore display?
 
		/* restore display? */
 
		ChangeDisplaySettings(NULL, 0);
 
	}
 
#endif
 
@@ -500,21 +500,21 @@ static LRESULT CALLBACK WndProcGdi(HWND 
 
			return 0;
 
		}
 

	
 
		case WM_SYSKEYDOWN: /* user presses F10 or Alt, both activating the title-menu */
 
		case WM_SYSKEYDOWN: // user presses F10 or Alt, both activating the title-menu
 
			switch (wParam) {
 
				case VK_RETURN:
 
				case 'F': /* Full Screen on ALT + ENTER/F */
 
				case 'F': // Full Screen on ALT + ENTER/F
 
					ToggleFullScreen(!_wnd.fullscreen);
 
					return 0;
 

	
 
				case VK_MENU: /* Just ALT */
 
				case VK_MENU: // Just ALT
 
					return 0; // do nothing
 

	
 
				case VK_F10: /* F10, ignore activation of menu */
 
				case VK_F10: // F10, ignore activation of menu
 
					HandleKeypress(MapWindowsKey(wParam) << 16);
 
					return 0;
 

	
 
				default: /* ALT in combination with something else */
 
				default: // ALT in combination with something else
 
					HandleKeypress(MapWindowsKey(wParam) << 16);
 
					break;
 
			}
 
@@ -590,13 +590,13 @@ static LRESULT CALLBACK WndProcGdi(HWND 
 
		}
 
#endif
 

	
 
// needed for wheel
 
/* needed for wheel */
 
#if !defined(WM_MOUSEWHEEL)
 
# define WM_MOUSEWHEEL 0x020A
 
#endif  //WM_MOUSEWHEEL
 
#endif  /* WM_MOUSEWHEEL */
 
#if !defined(GET_WHEEL_DELTA_WPARAM)
 
# define GET_WHEEL_DELTA_WPARAM(wparam) ((short)HIWORD(wparam))
 
#endif  //GET_WHEEL_DELTA_WPARAM
 
#endif  /* GET_WHEEL_DELTA_WPARAM */
 

	
 
		case WM_MOUSEWHEEL: {
 
			int delta = GET_WHEEL_DELTA_WPARAM(wParam);
 
@@ -723,8 +723,8 @@ static void FindResolutions()
 
{
 
	uint n = 0;
 
#if defined(WINCE)
 
	/* EnumDisplaySettingsW is only supported in CE 4.2+ */
 
	/* XXX -- One might argue that we assume 4.2+ on every system. Then we can use this function safely */
 
	/* EnumDisplaySettingsW is only supported in CE 4.2+
 
	 * XXX -- One might argue that we assume 4.2+ on every system. Then we can use this function safely */
 
#else
 
	uint i;
 
	DEVMODEA dm;
 
@@ -778,7 +778,7 @@ const char *VideoDriver_Win32::Start(con
 

	
 
	DEBUG(driver, 2, "Resolution for display: %dx%d", _cur_resolution.width, _cur_resolution.height);
 

	
 
	// fullscreen uses those
 
	/* fullscreen uses those */
 
	_wnd.width_org  = _cur_resolution.width;
 
	_wnd.height_org = _cur_resolution.height;
 

	
 
@@ -858,7 +858,7 @@ void VideoDriver_Win32::MainLoop()
 
			_ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0;
 
			_shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0;
 

	
 
			// determine which directional keys are down
 
			/* determine which directional keys are down */
 
			if (_wnd.has_focus) {
 
				_dirkeys =
 
					(GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) +
src/viewport.cpp
Show inline comments
 
@@ -817,7 +817,7 @@ static bool IsPartOfAutoLine(int px, int
 
	}
 
}
 

	
 
// [direction][side]
 
/* [direction][side] */
 
static const HighLightStyle _autorail_type[6][2] = {
 
	{ HT_DIR_X,  HT_DIR_X },
 
	{ HT_DIR_Y,  HT_DIR_Y },
 
@@ -900,7 +900,7 @@ static void DrawTileSelection(const Tile
 
				}
 
			}
 
			DrawSelectionSprite(_cur_dpi->zoom <= ZOOM_LVL_DETAIL ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti, z, foundation_part);
 
		} else if (_thd.drawstyle & HT_RAIL /*&& _thd.place_mode == VHM_RAIL*/) {
 
		} else if (_thd.drawstyle & HT_RAIL /* && _thd.place_mode == VHM_RAIL*/) {
 
			/* autorail highlight piece under cursor */
 
			uint type = _thd.drawstyle & 0xF;
 
			assert(type <= 5);
 
@@ -2363,8 +2363,8 @@ static int CalcHeightdiff(HighLightStyle
 
	switch (style & HT_DRAG_MASK) {
 
		case HT_RECT: {
 
			static const TileIndexDiffC heightdiff_area_by_dir[] = {
 
				/* Start */ {1, 0}, /* Dragging east */ {0, 0}, /* Dragging south */
 
				/* End   */ {0, 1}, /* Dragging east */ {1, 1}  /* Dragging south */
 
				/* Start */ {1, 0}, /* Dragging east */ {0, 0}, // Dragging south
 
				/* End   */ {0, 1}, /* Dragging east */ {1, 1}  // Dragging south
 
			};
 

	
 
			/* In the case of an area we can determine whether we were dragging south or
 
@@ -2378,18 +2378,18 @@ static int CalcHeightdiff(HighLightStyle
 
			h0 = TileHeight(start_tile);
 
			h1 = TileHeight(end_tile);
 
			break;
 
		default: { /* All other types, this is mostly only line/autorail */
 
		default: { // All other types, this is mostly only line/autorail
 
			static const HighLightStyle flip_style_direction[] = {
 
				HT_DIR_X, HT_DIR_Y, HT_DIR_HL, HT_DIR_HU, HT_DIR_VR, HT_DIR_VL
 
			};
 
			static const TileIndexDiffC heightdiff_line_by_dir[] = {
 
				/* Start */ {1, 0}, {1, 1}, /* HT_DIR_X  */ {0, 1}, {1, 1}, /* HT_DIR_Y  */
 
				/* Start */ {1, 0}, {0, 0}, /* HT_DIR_HU */ {1, 0}, {1, 1}, /* HT_DIR_HL */
 
				/* Start */ {1, 0}, {1, 1}, /* HT_DIR_VL */ {0, 1}, {1, 1}, /* HT_DIR_VR */
 

	
 
				/* Start */ {0, 1}, {0, 0}, /* HT_DIR_X  */ {1, 0}, {0, 0}, /* HT_DIR_Y  */
 
				/* End   */ {0, 1}, {0, 0}, /* HT_DIR_HU */ {1, 1}, {0, 1}, /* HT_DIR_HL */
 
				/* End   */ {1, 0}, {0, 0}, /* HT_DIR_VL */ {0, 0}, {0, 1}, /* HT_DIR_VR */
 
				/* Start */ {1, 0}, {1, 1}, /* HT_DIR_X  */ {0, 1}, {1, 1}, // HT_DIR_Y
 
				/* Start */ {1, 0}, {0, 0}, /* HT_DIR_HU */ {1, 0}, {1, 1}, // HT_DIR_HL
 
				/* Start */ {1, 0}, {1, 1}, /* HT_DIR_VL */ {0, 1}, {1, 1}, // HT_DIR_VR
 

	
 
				/* Start */ {0, 1}, {0, 0}, /* HT_DIR_X  */ {1, 0}, {0, 0}, // HT_DIR_Y
 
				/* End   */ {0, 1}, {0, 0}, /* HT_DIR_HU */ {1, 1}, {0, 1}, // HT_DIR_HL
 
				/* End   */ {1, 0}, {0, 0}, /* HT_DIR_VL */ {0, 0}, {0, 1}, // HT_DIR_VR
 
			};
 

	
 
			distance %= 2; // we're only interested if the distance is even or uneven
 
@@ -2471,10 +2471,10 @@ static void CalcRaildirsDrawstyle(TileHi
 
		thd->selend.x = thd->selend.x & ~0xF;
 
		thd->selend.y = thd->selend.y & ~0xF;
 

	
 
		// four cases.
 
		/* four cases. */
 
		if (x > thd->selstart.x) {
 
			if (y > thd->selstart.y) {
 
				// south
 
				/* south */
 
				if (d == 0) {
 
					b = (x & 0xF) > (y & 0xF) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR;
 
				} else if (d >= 0) {
 
@@ -2486,7 +2486,7 @@ static void CalcRaildirsDrawstyle(TileHi
 
					b = HT_LINE | HT_DIR_VR;
 
				} // return px == py || px == py - 16;
 
			} else {
 
				// west
 
				/* west */
 
				if (d == 0) {
 
					b = (x & 0xF) + (y & 0xF) >= 0x10 ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU;
 
				} else if (d >= 0) {
 
@@ -2499,7 +2499,7 @@ static void CalcRaildirsDrawstyle(TileHi
 
			}
 
		} else {
 
			if (y > thd->selstart.y) {
 
				// east
 
				/* east */
 
				if (d == 0) {
 
					b = (x & 0xF) + (y & 0xF) >= 0x10 ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU;
 
				} else if (d >= 0) {
 
@@ -2511,7 +2511,7 @@ static void CalcRaildirsDrawstyle(TileHi
 
					b = HT_LINE | HT_DIR_HL;
 
				} // return px == -py || px == -py + 16;
 
			} else {
 
				// north
 
				/* north */
 
				if (d == 0) {
 
					b = (x & 0xF) > (y & 0xF) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR;
 
				} else if (d >= 0) {
 
@@ -2521,7 +2521,7 @@ static void CalcRaildirsDrawstyle(TileHi
 
				} else {
 
					y = thd->selstart.y - w;
 
					b = HT_LINE | HT_DIR_VL;
 
				} //return px == py || px == py + 16;
 
				} // return px == py || px == py + 16;
 
			}
 
		}
 
	}
 
@@ -2588,7 +2588,7 @@ void VpSelectTilesWithMethod(int x, int 
 
	sy = _thd.selstart.y;
 

	
 
	switch (method) {
 
		case VPM_X_OR_Y: /* drag in X or Y direction */
 
		case VPM_X_OR_Y: // drag in X or Y direction
 
			if (abs(sy - y) < abs(sx - x)) {
 
				y = sy;
 
				style = HT_DIR_X;
 
@@ -2597,11 +2597,11 @@ void VpSelectTilesWithMethod(int x, int 
 
				style = HT_DIR_Y;
 
			}
 
			goto calc_heightdiff_single_direction;
 
		case VPM_FIX_X: /* drag in Y direction */
 
		case VPM_FIX_X: // drag in Y direction
 
			x = sx;
 
			style = HT_DIR_Y;
 
			goto calc_heightdiff_single_direction;
 
		case VPM_FIX_Y: /* drag in X direction */
 
		case VPM_FIX_Y: // drag in X direction
 
			y = sy;
 
			style = HT_DIR_X;
 

	
 
@@ -2628,12 +2628,12 @@ calc_heightdiff_single_direction:;
 
				ShowMeasurementTooltips(measure_strings_length[index], index, params);
 
			} break;
 

	
 
		case VPM_X_AND_Y_LIMITED: { /* drag an X by Y constrained rect area */
 
		case VPM_X_AND_Y_LIMITED: { // drag an X by Y constrained rect area
 
			int limit = (_thd.sizelimit - 1) * TILE_SIZE;
 
			x = sx + Clamp(x - sx, -limit, limit);
 
			y = sy + Clamp(y - sy, -limit, limit);
 
			} /* Fallthrough */
 
		case VPM_X_AND_Y: { /* drag an X by Y area */
 
			} // Fallthrough
 
		case VPM_X_AND_Y: { // drag an X by Y area
 
			if (_settings_client.gui.measure_tooltip) {
 
				static const StringID measure_strings_area[] = {
 
					STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF
src/water_cmd.cpp
Show inline comments
 
@@ -1157,18 +1157,18 @@ static CommandCost TerraformTile_Water(T
 

	
 

	
 
extern const TileTypeProcs _tile_type_water_procs = {
 
	DrawTile_Water,           /* draw_tile_proc */
 
	GetSlopeZ_Water,          /* get_slope_z_proc */
 
	ClearTile_Water,          /* clear_tile_proc */
 
	GetAcceptedCargo_Water,   /* get_accepted_cargo_proc */
 
	GetTileDesc_Water,        /* get_tile_desc_proc */
 
	GetTileTrackStatus_Water, /* get_tile_track_status_proc */
 
	ClickTile_Water,          /* click_tile_proc */
 
	AnimateTile_Water,        /* animate_tile_proc */
 
	TileLoop_Water,           /* tile_loop_clear */
 
	ChangeTileOwner_Water,    /* change_tile_owner_clear */
 
	NULL,                     /* get_produced_cargo_proc */
 
	VehicleEnter_Water,       /* vehicle_enter_tile_proc */
 
	GetFoundation_Water,      /* get_foundation_proc */
 
	TerraformTile_Water,      /* terraform_tile_proc */
 
	DrawTile_Water,           // draw_tile_proc
 
	GetSlopeZ_Water,          // get_slope_z_proc
 
	ClearTile_Water,          // clear_tile_proc
 
	GetAcceptedCargo_Water,   // get_accepted_cargo_proc
 
	GetTileDesc_Water,        // get_tile_desc_proc
 
	GetTileTrackStatus_Water, // get_tile_track_status_proc
 
	ClickTile_Water,          // click_tile_proc
 
	AnimateTile_Water,        // animate_tile_proc
 
	TileLoop_Water,           // tile_loop_clear
 
	ChangeTileOwner_Water,    // change_tile_owner_clear
 
	NULL,                     // get_produced_cargo_proc
 
	VehicleEnter_Water,       // vehicle_enter_tile_proc
 
	GetFoundation_Water,      // get_foundation_proc
 
	TerraformTile_Water,      // terraform_tile_proc
 
};
src/waypoint_gui.cpp
Show inline comments
 
@@ -64,7 +64,7 @@ public:
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case WAYPVW_CENTERVIEW: /* scroll to location */
 
			case WAYPVW_CENTERVIEW: // scroll to location
 
				if (_ctrl_pressed) {
 
					ShowExtraViewPortWindow(this->wp->xy);
 
				} else {
 
@@ -72,12 +72,12 @@ public:
 
				}
 
				break;
 

	
 
			case WAYPVW_RENAME: /* rename */
 
			case WAYPVW_RENAME: // rename
 
				SetDParam(0, this->wp->index);
 
				ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_WAYPOINT_NAME_BYTES, MAX_LENGTH_WAYPOINT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
 
				break;
 

	
 
			case WAYPVW_SHOW_TRAINS: /* show list of trains having this waypoint in their orders*/
 
			case WAYPVW_SHOW_TRAINS: // show list of trains having this waypoint in their orders
 
				ShowVehicleListWindow(this->wp);
 
				break;
 
		}
src/widget.cpp
Show inline comments
 
@@ -426,7 +426,7 @@ void Window::DrawWidgets() const
 
			GfxFillRect(r.left, r.top + 5, r.left, r.bottom - 1, c1);
 
			GfxFillRect(r.left + 1, r.top + 6, r.left + 1, r.bottom - 2, c2);
 

	
 
			/*Line from upper right corner to bottom right corner */
 
			/* Line from upper right corner to bottom right corner */
 
			GfxFillRect(r.right - 1, r.top + 5, r.right - 1, r.bottom - 2, c1);
 
			GfxFillRect(r.right, r.top + 4, r.right, r.bottom - 1, c2);
 

	
src/win32.cpp
Show inline comments
 
@@ -15,7 +15,7 @@
 
#include <winnt.h>
 
#include <wininet.h>
 
#include <fcntl.h>
 
#include <shlobj.h> // SHGetFolderPath
 
#include <shlobj.h> /* SHGetFolderPath */
 
#include "variables.h"
 
#include "win32.h"
 
#include "core/alloc_func.hpp"
 
@@ -396,9 +396,9 @@ static INT_PTR CALLBACK CrashDialogFunc(
 
		} return TRUE;
 
		case WM_COMMAND:
 
			switch (wParam) {
 
				case 12: /* Close */
 
				case 12: // Close
 
					ExitProcess(0);
 
				case 13: /* Emergency save */
 
				case 13: // Emergency save
 
					if (DoEmergencySave(wnd)) {
 
						MessageBox(wnd, _save_succeeded, _T("Save successful"), MB_ICONINFORMATION);
 
					} else {
 
@@ -407,7 +407,7 @@ static INT_PTR CALLBACK CrashDialogFunc(
 
					break;
 
/* Disable the crash-save submit code as it's not used */
 
#if 0
 
				case 14: { /* Submit crash report */
 
				case 14: { // Submit crash report
 
					const TCHAR *s;
 

	
 
					SetCursor(LoadCursor(NULL, IDC_WAIT));
 
@@ -418,10 +418,10 @@ static INT_PTR CALLBACK CrashDialogFunc(
 
						break;
 
					}
 

	
 
					// try to submit emergency savegame
 
					/* try to submit emergency savegame */
 
					if (_did_emerg_save || DoEmergencySave(wnd)) SubmitFile(wnd, _T("crash.sav"));
 

	
 
					// try to submit the autosaved game
 
					/* try to submit the autosaved game */
 
					if (_opt.autosave) {
 
						TCHAR buf[40];
 
						_sntprintf(buf, lengthof(buf), _T("autosave%d.sav"), (_autosave_ctr - 1) & 3);
 
@@ -432,7 +432,7 @@ static INT_PTR CALLBACK CrashDialogFunc(
 
					MessageBox(wnd, _T("Crash report submitted. Thank you."), _T("Crash Report"), MB_ICONINFORMATION);
 
				} break;
 
#endif /* Disabled crash-submit procedures */
 
				case 15: /* Expand window to show crash-message */
 
				case 15: // Expand window to show crash-message
 
					_expanded ^= 1;
 
					SetWndSize(wnd, _expanded);
 
					break;
 
@@ -584,7 +584,7 @@ static LONG WINAPI ExceptionHandler(EXCE
 
		for (j = 0; j != 24; j++) {
 
			for (i = 0; i != 8; i++) {
 
				if (IsBadReadPtr(b, sizeof(uint32))) {
 
					output += seprintf(output, last, " ????????"); //OCR: WAS - , 0);
 
					output += seprintf(output, last, " ????????"); // OCR: WAS - , 0);
 
				} else {
 
					output += seprintf(output, last, " %.8X", *b);
 
				}
 
@@ -1330,7 +1330,7 @@ HRESULT OTTDSHGetFolderPath(HWND hwnd, i
 
	{
 
		DWORD ret;
 
		switch (csidl) {
 
			case CSIDL_FONTS: /* Get the system font path, eg %WINDIR%\Fonts */
 
			case CSIDL_FONTS: // Get the system font path, eg %WINDIR%\Fonts
 
				ret = GetEnvironmentVariable(_T("WINDIR"), pszPath, MAX_PATH);
 
				if (ret == 0) break;
 
				_tcsncat(pszPath, _T("\\Fonts"), MAX_PATH);
src/window.cpp
Show inline comments
 
@@ -271,9 +271,9 @@ static void DispatchLeftClickEvent(Windo
 
			/* special widget handling for buttons*/
 
			switch (wi->type) {
 
				default: NOT_REACHED();
 
				case WWT_PANEL   | WWB_PUSHBUTTON: /* WWT_PUSHBTN */
 
				case WWT_IMGBTN  | WWB_PUSHBUTTON: /* WWT_PUSHIMGBTN */
 
				case WWT_TEXTBTN | WWB_PUSHBUTTON: /* WWT_PUSHTXTBTN */
 
				case WWT_PANEL   | WWB_PUSHBUTTON: // WWT_PUSHBTN
 
				case WWT_IMGBTN  | WWB_PUSHBUTTON: // WWT_PUSHIMGBTN
 
				case WWT_TEXTBTN | WWB_PUSHBUTTON: // WWT_PUSHTXTBTN
 
					w->HandleButtonClick(widget);
 
					break;
 
			}
 
@@ -293,12 +293,12 @@ static void DispatchLeftClickEvent(Windo
 
		if (HideDropDownMenu(w) == widget) return;
 

	
 
		if (w->desc_flags & WDF_STD_BTN) {
 
			if (widget == 0) { /* 'X' */
 
			if (widget == 0) { // 'X'
 
				delete w;
 
				return;
 
			}
 

	
 
			if (widget == 1) { /* 'Title bar' */
 
			if (widget == 1) { // 'Title bar'
 
				StartWindowDrag(w);
 
				return;
 
			}
 
@@ -1634,7 +1634,7 @@ static bool HandleViewportScroll()
 
	if (w == FindWindowById(WC_MAIN_WINDOW, 0) && w->viewport->follow_vehicle != INVALID_VEHICLE) {
 
		/* If the main window is following a vehicle, then first let go of it! */
 
		const Vehicle *veh = GetVehicle(w->viewport->follow_vehicle);
 
		ScrollMainWindowTo(veh->x_pos, veh->y_pos, true); /* This also resets follow_vehicle */
 
		ScrollMainWindowTo(veh->x_pos, veh->y_pos, true); // This also resets follow_vehicle
 
		return true;
 
	}
 

	
src/yapf/follow_track.hpp
Show inline comments
 
@@ -61,7 +61,7 @@ struct CFollowTrackT
 
		assert((!IsRoadTT() || m_veh != NULL) && (!IsRailTT() || railtype_override != INVALID_RAILTYPES));
 
		m_veh_owner = o;
 
		m_pPerf = pPerf;
 
		// don't worry, all is inlined so compiler should remove unnecessary initializations
 
		/* don't worry, all is inlined so compiler should remove unnecessary initializations */
 
		m_new_tile = INVALID_TILE;
 
		m_new_td_bits = TRACKDIR_BIT_NONE;
 
		m_exitdir = INVALID_DIAGDIR;
 
@@ -166,11 +166,11 @@ protected:
 
		m_is_station = m_is_bridge = m_is_tunnel = false;
 
		m_tiles_skipped = 0;
 

	
 
		// extra handling for tunnels and bridges in our direction
 
		/* extra handling for tunnels and bridges in our direction */
 
		if (IsTileType(m_old_tile, MP_TUNNELBRIDGE)) {
 
			DiagDirection enterdir = GetTunnelBridgeDirection(m_old_tile);
 
			if (enterdir == m_exitdir) {
 
				// we are entering the tunnel / bridge
 
				/* we are entering the tunnel / bridge */
 
				if (IsTunnel(m_old_tile)) {
 
					m_is_tunnel = true;
 
					m_new_tile = GetOtherTunnelEnd(m_old_tile);
 
@@ -184,11 +184,11 @@ protected:
 
			assert(ReverseDiagDir(enterdir) == m_exitdir);
 
		}
 

	
 
		// normal or station tile, do one step
 
		/* normal or station tile, do one step */
 
		TileIndexDiff diff = TileOffsByDiagDir(m_exitdir);
 
		m_new_tile = TILE_ADD(m_old_tile, diff);
 

	
 
		// special handling for stations
 
		/* special handling for stations */
 
		if (IsRailTT() && IsRailwayStationTile(m_new_tile)) {
 
			m_is_station = true;
 
		} else if (IsRoadTT() && IsRoadStopTile(m_new_tile)) {
 
@@ -231,7 +231,7 @@ protected:
 
	/** return true if we can leave m_old_tile in m_exitdir */
 
	FORCEINLINE bool CanExitOldTile()
 
	{
 
		// road stop can be left at one direction only unless it's a drive-through stop
 
		/* road stop can be left at one direction only unless it's a drive-through stop */
 
		if (IsRoadTT() && IsStandardRoadStopTile(m_old_tile)) {
 
			DiagDirection exitdir = GetRoadStopDir(m_old_tile);
 
			if (exitdir != m_exitdir) {
 
@@ -249,7 +249,7 @@ protected:
 
			}
 
		}
 

	
 
		// road depots can be also left in one direction only
 
		/* road depots can be also left in one direction only */
 
		if (IsRoadTT() && IsDepotTypeTile(m_old_tile, TT())) {
 
			DiagDirection exitdir = GetRoadDepotDirection(m_old_tile);
 
			if (exitdir != m_exitdir) {
 
@@ -264,7 +264,7 @@ protected:
 
	FORCEINLINE bool CanEnterNewTile()
 
	{
 
		if (IsRoadTT() && IsStandardRoadStopTile(m_new_tile)) {
 
			// road stop can be entered from one direction only unless it's a drive-through stop
 
			/* road stop can be entered from one direction only unless it's a drive-through stop */
 
			DiagDirection exitdir = GetRoadStopDir(m_new_tile);
 
			if (ReverseDiagDir(exitdir) != m_exitdir) {
 
				m_err = EC_NO_WAY;
 
@@ -281,14 +281,14 @@ protected:
 
			}
 
		}
 

	
 
		// road and rail depots can also be entered from one direction only
 
		/* road and rail depots can also be entered from one direction only */
 
		if (IsRoadTT() && IsDepotTypeTile(m_new_tile, TT())) {
 
			DiagDirection exitdir = GetRoadDepotDirection(m_new_tile);
 
			if (ReverseDiagDir(exitdir) != m_exitdir) {
 
				m_err = EC_NO_WAY;
 
				return false;
 
			}
 
			// don't try to enter other company's depots
 
			/* don't try to enter other company's depots */
 
			if (GetTileOwner(m_new_tile) != m_veh_owner) {
 
				m_err = EC_OWNER;
 
				return false;
 
@@ -302,24 +302,24 @@ protected:
 
			}
 
		}
 

	
 
		// rail transport is possible only on tiles with the same owner as vehicle
 
		/* rail transport is possible only on tiles with the same owner as vehicle */
 
		if (IsRailTT() && GetTileOwner(m_new_tile) != m_veh_owner) {
 
			// different owner
 
			/* different owner */
 
			m_err = EC_NO_WAY;
 
			return false;
 
		}
 

	
 
		// rail transport is possible only on compatible rail types
 
		/* rail transport is possible only on compatible rail types */
 
		if (IsRailTT()) {
 
			RailType rail_type = GetTileRailType(m_new_tile);
 
			if (!HasBit(m_railtypes, rail_type)) {
 
				// incompatible rail type
 
				/* incompatible rail type */
 
				m_err = EC_RAIL_TYPE;
 
				return false;
 
			}
 
		}
 

	
 
		// tunnel holes and bridge ramps can be entered only from proper direction
 
		/* tunnel holes and bridge ramps can be entered only from proper direction */
 
		if (IsTileType(m_new_tile, MP_TUNNELBRIDGE)) {
 
			if (IsTunnel(m_new_tile)) {
 
				if (!m_is_tunnel) {
 
@@ -340,14 +340,14 @@ protected:
 
			}
 
		}
 

	
 
		// special handling for rail stations - get to the end of platform
 
		/* special handling for rail stations - get to the end of platform */
 
		if (IsRailTT() && m_is_station) {
 
			// entered railway station
 
			// get platform length
 
			/* entered railway station
 
			 * get platform length */
 
			uint length = GetStationByTile(m_new_tile)->GetPlatformLength(m_new_tile, TrackdirToExitdir(m_old_td));
 
			// how big step we must do to get to the last platform tile;
 
			/* how big step we must do to get to the last platform tile; */
 
			m_tiles_skipped = length - 1;
 
			// move to the platform end
 
			/* move to the platform end */
 
			TileIndexDiff diff = TileOffsByDiagDir(m_exitdir);
 
			diff *= m_tiles_skipped;
 
			m_new_tile = TILE_ADD(m_new_tile, diff);
 
@@ -360,11 +360,11 @@ protected:
 
	/** return true if we must reverse (in depots and single tram bits) */
 
	FORCEINLINE bool ForcedReverse()
 
	{
 
		// rail and road depots cause reversing
 
		/* rail and road depots cause reversing */
 
		if (!IsWaterTT() && IsDepotTypeTile(m_old_tile, TT())) {
 
			DiagDirection exitdir = IsRailTT() ? GetRailDepotDirection(m_old_tile) : GetRoadDepotDirection(m_old_tile);
 
			if (exitdir != m_exitdir) {
 
				// reverse
 
				/* reverse */
 
				m_new_tile = m_old_tile;
 
				m_new_td_bits = TrackdirToTrackdirBits(ReverseTrackdir(m_old_td));
 
				m_exitdir = exitdir;
 
@@ -374,9 +374,9 @@ protected:
 
			}
 
		}
 

	
 
		// single tram bits cause reversing
 
		/* single tram bits cause reversing */
 
		if (IsTram() && GetSingleTramBit(m_old_tile) == ReverseDiagDir(m_exitdir)) {
 
			// reverse
 
			/* reverse */
 
			m_new_tile = m_old_tile;
 
			m_new_td_bits = TrackdirToTrackdirBits(ReverseTrackdir(m_old_td));
 
			m_exitdir = ReverseDiagDir(m_exitdir);
 
@@ -392,15 +392,15 @@ protected:
 
	FORCEINLINE bool TryReverse()
 
	{
 
		if (IsRoadTT() && !IsTram()) {
 
			// if we reached the end of road, we can reverse the RV and continue moving
 
			/* if we reached the end of road, we can reverse the RV and continue moving */
 
			m_exitdir = ReverseDiagDir(m_exitdir);
 
			// new tile will be the same as old one
 
			/* new tile will be the same as old one */
 
			m_new_tile = m_old_tile;
 
			// set new trackdir bits to all reachable trackdirs
 
			/* set new trackdir bits to all reachable trackdirs */
 
			QueryNewTileTrackStatus();
 
			m_new_td_bits &= DiagdirReachesTrackdirs(m_exitdir);
 
			if (m_new_td_bits != TRACKDIR_BIT_NONE) {
 
				// we have some trackdirs reachable after reversal
 
				/* we have some trackdirs reachable after reversal */
 
				return true;
 
			}
 
		}
 
@@ -415,14 +415,14 @@ public:
 
		int min_speed = 0;
 
		int max_speed = INT_MAX; // no limit
 

	
 
		// for now we handle only on-bridge speed limit
 
		/* for now we handle only on-bridge speed limit */
 
		if (!IsWaterTT() && IsBridgeTile(m_old_tile)) {
 
			int spd = GetBridgeSpec(GetBridgeType(m_old_tile))->speed;
 
			if (IsRoadTT()) spd *= 2;
 
			if (max_speed > spd) max_speed = spd;
 
		}
 

	
 
		// if min speed was requested, return it
 
		/* if min speed was requested, return it */
 
		if (pmin_speed) *pmin_speed = min_speed;
 
		return max_speed;
 
	}
src/yapf/nodelist.hpp
Show inline comments
 
@@ -74,11 +74,11 @@ public:
 
	/** notify the nodelist, that we don't want to discard the given node */
 
	FORCEINLINE void FoundBestNode(Titem_& item)
 
	{
 
		// for now it is enough to invalidate m_new_node if it is our given node
 
		/* for now it is enough to invalidate m_new_node if it is our given node */
 
		if (&item == m_new_node) {
 
			m_new_node = NULL;
 
		}
 
		// TODO: do we need to store best nodes found in some extra list/array? Probably not now.
 
		/* TODO: do we need to store best nodes found in some extra list/array? Probably not now. */
 
	}
 

	
 
	/** insert given item as open node (into m_open and m_open_queue) */
 
@@ -86,7 +86,7 @@ public:
 
	{
 
		assert(m_closed.Find(item.GetKey()) == NULL);
 
		m_open.Push(item);
 
		// TODO: check if m_open_queue is not full
 
		/* TODO: check if m_open_queue is not full */
 
		assert(!m_open_queue.IsFull());
 
		m_open_queue.Push(item);
 
		if (&item == m_new_node) {
src/yapf/yapf_base.hpp
Show inline comments
 
@@ -70,7 +70,7 @@ public:
 
	int                  m_num_steps;          ///< this is there for debugging purposes (hope it doesn't hurt)
 

	
 
public:
 
	/// default constructor
 
	/** default constructor */
 
	FORCEINLINE CYapfBaseT()
 
		: m_pBestDestNode(NULL)
 
		, m_pBestIntermediateNode(NULL)
 
@@ -83,18 +83,18 @@ public:
 
	{
 
	}
 

	
 
	/// default destructor
 
	/** default destructor */
 
	~CYapfBaseT() {}
 

	
 
protected:
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
public:
 
	/// return current settings (can be custom - company based - but later)
 
	/** return current settings (can be custom - company based - but later) */
 
	FORCEINLINE const YAPFSettings& PfGetSettings() const
 
	{
 
		return *m_settings;
 
@@ -125,7 +125,7 @@ public:
 
				break;
 
			}
 

	
 
			// if the best open node was worse than the best path found, we can finish
 
			/* if the best open node was worse than the best path found, we can finish */
 
			if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate()) {
 
				break;
 
			}
 
@@ -187,13 +187,13 @@ public:
 
	FORCEINLINE void AddStartupNode(Node& n)
 
	{
 
		Yapf().PfNodeCacheFetch(n);
 
		// insert the new node only if it is not there
 
		/* insert the new node only if it is not there */
 
		if (m_nodes.FindOpenNode(n.m_key) == NULL) {
 
			m_nodes.InsertOpenNode(n);
 
		} else {
 
			// if we are here, it means that node is already there - how it is possible?
 
			//   probably the train is in the position that both its ends point to the same tile/exit-dir
 
			//   very unlikely, but it happened
 
			/* if we are here, it means that node is already there - how it is possible?
 
			 *   probably the train is in the position that both its ends point to the same tile/exit-dir
 
			 *   very unlikely, but it happened */
 
		}
 
	}
 

	
 
@@ -213,7 +213,7 @@ public:
 
	 *  Nodes are evaluated here and added into open list */
 
	void AddNewNode(Node &n, const TrackFollower &tf)
 
	{
 
		// evaluate the node
 
		/* evaluate the node */
 
		bool bCached = Yapf().PfNodeCacheFetch(n);
 
		if (!bCached) {
 
			m_stats_cost_calcs++;
 
@@ -229,10 +229,10 @@ public:
 

	
 
		if (bValid) bValid = Yapf().PfCalcEstimate(n);
 

	
 
		// have the cost or estimate callbacks marked this node as invalid?
 
		/* have the cost or estimate callbacks marked this node as invalid? */
 
		if (!bValid) return;
 

	
 
		// detect the destination
 
		/* detect the destination */
 
		bool bDestination = Yapf().PfDetectDestination(n);
 
		if (bDestination) {
 
			if (m_pBestDestNode == NULL || n < *m_pBestDestNode) {
 
@@ -246,43 +246,43 @@ public:
 
			m_pBestIntermediateNode = &n;
 
		}
 

	
 
		// check new node against open list
 
		/* check new node against open list */
 
		Node *openNode = m_nodes.FindOpenNode(n.GetKey());
 
		if (openNode != NULL) {
 
			// another node exists with the same key in the open list
 
			// is it better than new one?
 
			/* another node exists with the same key in the open list
 
			 * is it better than new one? */
 
			if (n.GetCostEstimate() < openNode->GetCostEstimate()) {
 
				// update the old node by value from new one
 
				/* update the old node by value from new one */
 
				m_nodes.PopOpenNode(n.GetKey());
 
				*openNode = n;
 
				// add the updated old node back to open list
 
				/* add the updated old node back to open list */
 
				m_nodes.InsertOpenNode(*openNode);
 
			}
 
			return;
 
		}
 

	
 
		// check new node against closed list
 
		/* check new node against closed list */
 
		Node *closedNode = m_nodes.FindClosedNode(n.GetKey());
 
		if (closedNode != NULL) {
 
			// another node exists with the same key in the closed list
 
			// is it better than new one?
 
			/* another node exists with the same key in the closed list
 
			 * is it better than new one? */
 
			int node_est = n.GetCostEstimate();
 
			int closed_est = closedNode->GetCostEstimate();
 
			if (node_est < closed_est) {
 
				// If this assert occurs, you have probably problem in
 
				// your Tderived::PfCalcCost() or Tderived::PfCalcEstimate().
 
				// The problem could be:
 
				//  - PfCalcEstimate() gives too large numbers
 
				//  - PfCalcCost() gives too small numbers
 
				//  - You have used negative cost penalty in some cases (cost bonus)
 
				/* If this assert occurs, you have probably problem in
 
				 * your Tderived::PfCalcCost() or Tderived::PfCalcEstimate().
 
				 * The problem could be:
 
				 *  - PfCalcEstimate() gives too large numbers
 
				 *  - PfCalcCost() gives too small numbers
 
				 *  - You have used negative cost penalty in some cases (cost bonus) */
 
				assert(0);
 

	
 
				return;
 
			}
 
			return;
 
		}
 
		// the new node is really new
 
		// add it to the open list
 
		/* the new node is really new
 
		 * add it to the open list */
 
		m_nodes.InsertOpenNode(n);
 
	}
 

	
 
@@ -297,13 +297,13 @@ public:
 
		dmp.WriteLine("m_num_steps = %d", m_num_steps);
 
	}
 

	
 
	// methods that should be implemented at derived class Types::Tpf (derived from CYapfBaseT)
 
	/* methods that should be implemented at derived class Types::Tpf (derived from CYapfBaseT) */
 

	
 
#if 0
 
	/** Example: PfSetStartupNodes() - set source (origin) nodes */
 
	FORCEINLINE void PfSetStartupNodes()
 
	{
 
		// example:
 
		/* example: */
 
		Node& n1 = *base::m_nodes.CreateNewNode();
 
		.
 
		. // setup node members here
 
@@ -327,9 +327,9 @@ public:
 
	/** Example: PfCalcCost() - set path cost from origin to the given node */
 
	FORCEINLINE bool PfCalcCost(Node& n)
 
	{
 
		// evaluate last step cost
 
		/* evaluate last step cost */
 
		int cost = ...;
 
		// set the node cost as sum of parent's cost and last step cost
 
		/* set the node cost as sum of parent's cost and last step cost */
 
		n.m_cost = n.m_parent->m_cost + cost;
 
		return true; // true if node is valid follower (i.e. no obstacle was found)
 
	}
 
@@ -337,9 +337,9 @@ public:
 
	/** Example: PfCalcEstimate() - set path cost estimate from origin to the target through given node */
 
	FORCEINLINE bool PfCalcEstimate(Node& n)
 
	{
 
		// evaluate the distance to our destination
 
		/* evaluate the distance to our destination */
 
		int distance = ...;
 
		// set estimate as sum of cost from origin + distance to the target
 
		/* set estimate as sum of cost from origin + distance to the target */
 
		n.m_estimate = n.m_cost + distance;
 
		return true; // true if node is valid (i.e. not too far away :)
 
	}
src/yapf/yapf_common.hpp
Show inline comments
 
@@ -18,21 +18,21 @@ protected:
 
	TileIndex    m_orgTile;                       ///< origin tile
 
	TrackdirBits m_orgTrackdirs;                  ///< origin trackdir mask
 

	
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
public:
 
	/// Set origin tile / trackdir mask
 
	/** Set origin tile / trackdir mask */
 
	void SetOrigin(TileIndex tile, TrackdirBits trackdirs)
 
	{
 
		m_orgTile = tile;
 
		m_orgTrackdirs = trackdirs;
 
	}
 

	
 
	/// Called when YAPF needs to place origin nodes into open list
 
	/** Called when YAPF needs to place origin nodes into open list */
 
	void PfSetStartupNodes()
 
	{
 
		bool is_choice = (KillFirstBit(m_orgTrackdirs) != TRACKDIR_BIT_NONE);
 
@@ -62,14 +62,14 @@ protected:
 
	int         m_reverse_penalty;                ///< penalty to be added for using the reversed origin
 
	bool        m_treat_first_red_two_way_signal_as_eol; ///< in some cases (leaving station) we need to handle first two-way signal differently
 

	
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
public:
 
	/// set origin (tiles, trackdirs, etc.)
 
	/** set origin (tiles, trackdirs, etc.) */
 
	void SetOrigin(TileIndex tile, Trackdir td, TileIndex tiler = INVALID_TILE, Trackdir tdr = INVALID_TRACKDIR, int reverse_penalty = 0, bool treat_first_red_two_way_signal_as_eol = true)
 
	{
 
		m_orgTile = tile;
 
@@ -80,7 +80,7 @@ public:
 
		m_treat_first_red_two_way_signal_as_eol = treat_first_red_two_way_signal_as_eol;
 
	}
 

	
 
	/// Called when YAPF needs to place origin nodes into open list
 
	/** Called when YAPF needs to place origin nodes into open list */
 
	void PfSetStartupNodes()
 
	{
 
		if (m_orgTile != INVALID_TILE && m_orgTd != INVALID_TRACKDIR) {
 
@@ -96,7 +96,7 @@ public:
 
		}
 
	}
 

	
 
	/// return true if first two-way signal should be treated as dead end
 
	/** return true if first two-way signal should be treated as dead end */
 
	FORCEINLINE bool TreatFirstRedTwoWaySignalAsEOL()
 
	{
 
		return Yapf().PfGetSettings().rail_firstred_twoway_eol && m_treat_first_red_two_way_signal_as_eol;
 
@@ -117,7 +117,7 @@ protected:
 
	TrackdirBits m_destTrackdirs;                 ///< destination trackdir mask
 

	
 
public:
 
	/// set the destination tile / more trackdirs
 
	/** set the destination tile / more trackdirs */
 
	void SetDestination(TileIndex tile, TrackdirBits trackdirs)
 
	{
 
		m_destTile = tile;
 
@@ -125,14 +125,14 @@ public:
 
	}
 

	
 
protected:
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
public:
 
	/// Called by YAPF to detect if node ends in the desired destination
 
	/** Called by YAPF to detect if node ends in the desired destination */
 
	FORCEINLINE bool PfDetectDestination(Node& n)
 
	{
 
		bool bDest = (n.m_key.m_tile == m_destTile) && ((m_destTrackdirs & TrackdirToTrackdirBits(n.GetTrackdir())) != TRACKDIR_BIT_NONE);
src/yapf/yapf_costbase.hpp
Show inline comments
 
@@ -10,14 +10,14 @@ struct CYapfCostBase {
 
	{
 
		if (IsDiagonalTrackdir(td)) {
 
			if (IsBridgeTile(tile)) {
 
				// it is bridge ramp, check if we are entering the bridge
 
				/* it is bridge ramp, check if we are entering the bridge */
 
				if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are leaving it, no penalty
 
				// we are entering the bridge
 
				/* we are entering the bridge */
 
				Slope tile_slope = GetTileSlope(tile, NULL);
 
				Axis axis = DiagDirToAxis(GetTunnelBridgeDirection(tile));
 
				return !HasBridgeFlatRamp(tile_slope, axis);
 
			} else {
 
				// not bridge ramp
 
				/* not bridge ramp */
 
				if (IsTunnelTile(tile)) return false; // tunnel entry/exit doesn't slope
 
				Slope tile_slope = GetTileSlope(tile, NULL);
 
				return IsUphillTrackdir(tile_slope, td); // slopes uphill => apply penalty
 
@@ -28,7 +28,7 @@ struct CYapfCostBase {
 
};
 

	
 
struct CostRailSettings {
 
	// look-ahead signal penalty
 
	/* look-ahead signal penalty */
 
};
 

	
 

	
src/yapf/yapf_costcache.hpp
Show inline comments
 
@@ -51,7 +51,7 @@ public:
 
protected:
 
	LocalCache      m_local_cache;
 

	
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -157,7 +157,7 @@ protected:
 

	
 
	FORCEINLINE CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {};
 

	
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -169,14 +169,14 @@ protected:
 
		static Date last_date = 0;
 
		static Cache C;
 

	
 
		// some statistics
 
		/* some statistics */
 
		if (last_date != _date) {
 
			last_date = _date;
 
			DEBUG(yapf, 2, "Pf time today: %5d ms", _total_pf_time_us / 1000);
 
			_total_pf_time_us = 0;
 
		}
 

	
 
		// delete the cache sometimes...
 
		/* delete the cache sometimes... */
 
		if (last_rail_change_counter != Cache::s_rail_change_counter) {
 
			last_rail_change_counter = Cache::s_rail_change_counter;
 
			C.Flush();
src/yapf/yapf_costrail.hpp
Show inline comments
 
@@ -69,7 +69,7 @@ protected:
 
		, m_disable_cache(false)
 
		, m_stopped_on_first_two_way_signal(false)
 
	{
 
		// pre-compute look-ahead penalties into array
 
		/* pre-compute look-ahead penalties into array */
 
		int p0 = Yapf().PfGetSettings().rail_look_ahead_signal_p0;
 
		int p1 = Yapf().PfGetSettings().rail_look_ahead_signal_p1;
 
		int p2 = Yapf().PfGetSettings().rail_look_ahead_signal_p2;
 
@@ -79,7 +79,7 @@ protected:
 
		}
 
	}
 

	
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -100,10 +100,10 @@ public:
 
		int cost = 0;
 
		if (TrackFollower::Allow90degTurns()
 
				&& ((TrackdirToTrackdirBits(td2) & (TrackdirBits)TrackdirCrossesTrackdirs(td1)) != 0)) {
 
			// 90-deg curve penalty
 
			/* 90-deg curve penalty */
 
			cost += Yapf().PfGetSettings().rail_curve90_penalty;
 
		} else if (td2 != NextTrackdir(td1)) {
 
			// 45-deg curve penalty
 
			/* 45-deg curve penalty */
 
			cost += Yapf().PfGetSettings().rail_curve45_penalty;
 
		}
 
		return cost;
 
@@ -123,7 +123,7 @@ public:
 
	FORCEINLINE int OneTileCost(TileIndex& tile, Trackdir trackdir)
 
	{
 
		int cost = 0;
 
		// set base cost
 
		/* set base cost */
 
		if (IsDiagonalTrackdir(trackdir)) {
 
			cost += YAPF_TILE_LENGTH;
 
			switch (GetTileType(tile)) {
 
@@ -138,7 +138,7 @@ public:
 
					break;
 
			}
 
		} else {
 
			// non-diagonal trackdir
 
			/* non-diagonal trackdir */
 
			cost = YAPF_TILE_CORNER_LENGTH;
 
		}
 
		return cost;
 
@@ -172,33 +172,33 @@ public:
 
	int SignalCost(Node& n, TileIndex tile, Trackdir trackdir)
 
	{
 
		int cost = 0;
 
		// if there is one-way signal in the opposite direction, then it is not our way
 
		/* if there is one-way signal in the opposite direction, then it is not our way */
 
		CPerfStart perf_cost(Yapf().m_perf_other_cost);
 
		if (IsTileType(tile, MP_RAILWAY)) {
 
			bool has_signal_against = HasSignalOnTrackdir(tile, ReverseTrackdir(trackdir));
 
			bool has_signal_along = HasSignalOnTrackdir(tile, trackdir);
 
			if (has_signal_against && !has_signal_along && IsOnewaySignal(tile, TrackdirToTrack(trackdir))) {
 
				// one-way signal in opposite direction
 
				/* one-way signal in opposite direction */
 
				n.m_segment->m_end_segment_reason |= ESRB_DEAD_END;
 
			} else {
 
				if (has_signal_along) {
 
					SignalState sig_state = GetSignalStateByTrackdir(tile, trackdir);
 
					// cache the look-ahead polynomial constant only if we didn't pass more signals than the look-ahead limit is
 
					/* cache the look-ahead polynomial constant only if we didn't pass more signals than the look-ahead limit is */
 
					int look_ahead_cost = (n.m_num_signals_passed < m_sig_look_ahead_costs.Size()) ? m_sig_look_ahead_costs.Data()[n.m_num_signals_passed] : 0;
 
					if (sig_state != SIGNAL_STATE_RED) {
 
						// green signal
 
						/* green signal */
 
						n.flags_u.flags_s.m_last_signal_was_red = false;
 
						// negative look-ahead red-signal penalties would cause problems later, so use them as positive penalties for green signal
 
						/* negative look-ahead red-signal penalties would cause problems later, so use them as positive penalties for green signal */
 
						if (look_ahead_cost < 0) {
 
							// add its negation to the cost
 
							/* add its negation to the cost */
 
							cost -= look_ahead_cost;
 
						}
 
					} else {
 
						SignalType sig_type = GetSignalType(tile, TrackdirToTrack(trackdir));
 
						// we have a red signal in our direction
 
						// was it first signal which is two-way?
 
						/* we have a red signal in our direction
 
						 * was it first signal which is two-way? */
 
						if (!IsPbsSignal(sig_type) && Yapf().TreatFirstRedTwoWaySignalAsEOL() && n.flags_u.flags_s.m_choice_seen && has_signal_against && n.m_num_signals_passed == 0) {
 
							// yes, the first signal is two-way red signal => DEAD END
 
							/* yes, the first signal is two-way red signal => DEAD END */
 
							n.m_segment->m_end_segment_reason |= ESRB_DEAD_END;
 
							Yapf().m_stopped_on_first_two_way_signal = true;
 
							return -1;
 
@@ -206,13 +206,13 @@ public:
 
						n.m_last_red_signal_type = sig_type;
 
						n.flags_u.flags_s.m_last_signal_was_red = true;
 

	
 
						// look-ahead signal penalty
 
						/* look-ahead signal penalty */
 
						if (!IsPbsSignal(sig_type) && look_ahead_cost > 0) {
 
							// add the look ahead penalty only if it is positive
 
							/* add the look ahead penalty only if it is positive */
 
							cost += look_ahead_cost;
 
						}
 

	
 
						// special signal penalties
 
						/* special signal penalties */
 
						if (n.m_num_signals_passed == 0) {
 
							switch (sig_type) {
 
								case SIGTYPE_COMBO:
 
@@ -246,10 +246,10 @@ public:
 
		assert(v->u.rail.cached_total_length != 0);
 
		int needed_platform_length = (v->u.rail.cached_total_length + TILE_SIZE - 1) / TILE_SIZE;
 
		if (platform_length > needed_platform_length) {
 
			// apply penalty for longer platform than needed
 
			/* apply penalty for longer platform than needed */
 
			cost += Yapf().PfGetSettings().rail_longer_platform_penalty;
 
		} else if (needed_platform_length > platform_length) {
 
			// apply penalty for shorter platform than needed
 
			/* apply penalty for shorter platform than needed */
 
			cost += Yapf().PfGetSettings().rail_shorter_platform_penalty;
 
		}
 
		return cost;
 
@@ -313,10 +313,10 @@ public:
 

	
 
		const Vehicle *v = Yapf().GetVehicle();
 

	
 
		// start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment
 
		/* start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment */
 
		TILE cur(n.m_key.m_tile, n.m_key.m_td);
 

	
 
		// the previous tile will be needed for transition cost calculations
 
		/* the previous tile will be needed for transition cost calculations */
 
		TILE prev = !has_parent ? TILE() : TILE(n.m_parent->GetLastTile(), n.m_parent->GetLastTrackdir());
 

	
 
		EndSegmentReasonBits end_segment_reason = ESRB_NONE;
 
@@ -529,10 +529,10 @@ no_entry_cost: // jump here at the begin
 
			/* Last-red and last-red-exit penalties. */
 
			if (n.flags_u.flags_s.m_last_signal_was_red) {
 
				if (n.m_last_red_signal_type == SIGTYPE_EXIT) {
 
					// last signal was red pre-signal-exit
 
					/* last signal was red pre-signal-exit */
 
					extra_cost += Yapf().PfGetSettings().rail_lastred_exit_penalty;
 
				} else {
 
					// last signal was red, but not exit
 
					/* last signal was red, but not exit */
 
					extra_cost += Yapf().PfGetSettings().rail_lastred_penalty;
 
				}
 
			}
 
@@ -549,7 +549,7 @@ no_entry_cost: // jump here at the begin
 
			}
 
		}
 

	
 
		// total node cost
 
		/* total node cost */
 
		n.m_cost = parent_cost + segment_entry_cost + segment_cost + extra_cost;
 

	
 
		return true;
src/yapf/yapf_destrail.hpp
Show inline comments
 
@@ -37,19 +37,19 @@ public:
 
	typedef typename Types::NodeList::Titem Node; ///< this will be our node type
 
	typedef typename Node::Key Key;               ///< key to hash tables
 

	
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
	/// Called by YAPF to detect if node ends in the desired destination
 
	/** Called by YAPF to detect if node ends in the desired destination */
 
	FORCEINLINE bool PfDetectDestination(Node& n)
 
	{
 
		return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
 
	}
 

	
 
	/// Called by YAPF to detect if node ends in the desired destination
 
	/** Called by YAPF to detect if node ends in the desired destination */
 
	FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
 
	{
 
		bool bDest = IsRailDepotTile(tile);
 
@@ -75,19 +75,19 @@ public:
 
	typedef typename Node::Key Key;               ///< key to hash tables
 
	typedef typename Types::TrackFollower TrackFollower; ///< TrackFollower. Need to typedef for gcc 2.95
 

	
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
	/// Called by YAPF to detect if node ends in the desired destination
 
	/** Called by YAPF to detect if node ends in the desired destination */
 
	FORCEINLINE bool PfDetectDestination(Node& n)
 
	{
 
		return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
 
	}
 

	
 
	/// Called by YAPF to detect if node ends in the desired destination
 
	/** Called by YAPF to detect if node ends in the desired destination */
 
	FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
 
	{
 
		return
 
@@ -118,7 +118,7 @@ protected:
 
	TrackdirBits m_destTrackdirs;
 
	StationID    m_dest_station_id;
 

	
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -160,13 +160,13 @@ public:
 
		CYapfDestinationRailBase::SetDestination(v);
 
	}
 

	
 
	/// Called by YAPF to detect if node ends in the desired destination
 
	/** Called by YAPF to detect if node ends in the desired destination */
 
	FORCEINLINE bool PfDetectDestination(Node& n)
 
	{
 
		return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
 
	}
 

	
 
	/// Called by YAPF to detect if node ends in the desired destination
 
	/** Called by YAPF to detect if node ends in the desired destination */
 
	FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
 
	{
 
		bool bDest;
src/yapf/yapf_node.hpp
Show inline comments
 
@@ -82,11 +82,11 @@ struct CYapfShipNodeT
 

	
 
};
 

	
 
// now define two major node types (that differ by key type)
 
/* now define two major node types (that differ by key type) */
 
typedef CYapfShipNodeT<CYapfNodeKeyExitDir>  CYapfShipNodeExitDir;
 
typedef CYapfShipNodeT<CYapfNodeKeyTrackDir> CYapfShipNodeTrackDir;
 

	
 
// Default NodeList types
 
/* Default NodeList types */
 
typedef CNodeList_HashTableT<CYapfShipNodeExitDir , 14, 16> CShipNodeListExitDir;
 
typedef CNodeList_HashTableT<CYapfShipNodeTrackDir, 16, 20> CShipNodeListTrackDir;
 

	
src/yapf/yapf_node_rail.hpp
Show inline comments
 
@@ -266,11 +266,11 @@ struct CYapfRailNodeT
 
	}
 
};
 

	
 
// now define two major node types (that differ by key type)
 
/* now define two major node types (that differ by key type) */
 
typedef CYapfRailNodeT<CYapfNodeKeyExitDir>  CYapfRailNodeExitDir;
 
typedef CYapfRailNodeT<CYapfNodeKeyTrackDir> CYapfRailNodeTrackDir;
 

	
 
// Default NodeList types
 
/* Default NodeList types */
 
typedef CNodeList_HashTableT<CYapfRailNodeExitDir , 10, 12> CRailNodeListExitDir;
 
typedef CNodeList_HashTableT<CYapfRailNodeTrackDir, 12, 16> CRailNodeListTrackDir;
 

	
src/yapf/yapf_node_road.hpp
Show inline comments
 
@@ -23,11 +23,11 @@ struct CYapfRoadNodeT
 
	}
 
};
 

	
 
// now define two major node types (that differ by key type)
 
/* now define two major node types (that differ by key type) */
 
typedef CYapfRoadNodeT<CYapfNodeKeyExitDir>  CYapfRoadNodeExitDir;
 
typedef CYapfRoadNodeT<CYapfNodeKeyTrackDir> CYapfRoadNodeTrackDir;
 

	
 
// Default NodeList types
 
/* Default NodeList types */
 
typedef CNodeList_HashTableT<CYapfRoadNodeExitDir , 8, 12> CRoadNodeListExitDir;
 
typedef CNodeList_HashTableT<CYapfRoadNodeTrackDir, 10, 14> CRoadNodeListTrackDir;
 

	
src/yapf/yapf_rail.cpp
Show inline comments
 
@@ -24,7 +24,7 @@ public:
 
	typedef typename Types::NodeList::Titem Node;        ///< this will be our node type
 

	
 
protected:
 
	/// to access inherited pathfinder
 
	/** to access inherited pathfinder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -171,7 +171,7 @@ public:
 
	typedef typename Node::Key Key;                      ///< key to hash tables
 

	
 
protected:
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -189,7 +189,7 @@ public:
 
		}
 
	}
 

	
 
	/// return debug report character to identify the transportation type
 
	/** return debug report character to identify the transportation type */
 
	FORCEINLINE char TransportTypeChar() const
 
	{
 
		return 't';
 
@@ -216,28 +216,28 @@ public:
 

	
 
	FORCEINLINE bool FindNearestDepotTwoWay(const Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
 
	{
 
		// set origin and destination nodes
 
		/* set origin and destination nodes */
 
		Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, true);
 
		Yapf().SetDestination(v);
 
		Yapf().SetMaxCost(YAPF_TILE_LENGTH * max_distance);
 

	
 
		// find the best path
 
		/* find the best path */
 
		bool bFound = Yapf().FindPath(v);
 
		if (!bFound) return false;
 

	
 
		// some path found
 
		// get found depot tile
 
		/* some path found
 
		 * get found depot tile */
 
		Node *n = Yapf().GetBestNode();
 
		*depot_tile = n->GetLastTile();
 

	
 
		// walk through the path back to the origin
 
		/* walk through the path back to the origin */
 
		Node *pNode = n;
 
		while (pNode->m_parent != NULL) {
 
			pNode = pNode->m_parent;
 
		}
 

	
 
		// if the origin node is our front vehicle tile/Trackdir then we didn't reverse
 
		// but we can also look at the cost (== 0 -> not reversed, == reverse_penalty -> reversed)
 
		/* if the origin node is our front vehicle tile/Trackdir then we didn't reverse
 
		 * but we can also look at the cost (== 0 -> not reversed, == reverse_penalty -> reversed) */
 
		*reversed = (pNode->m_cost != 0);
 

	
 
		return true;
 
@@ -254,7 +254,7 @@ public:
 
	typedef typename Node::Key Key;                      ///< key to hash tables
 

	
 
protected:
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -343,7 +343,7 @@ public:
 
	typedef typename Node::Key Key;                      ///< key to hash tables
 

	
 
protected:
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -361,7 +361,7 @@ public:
 
		}
 
	}
 

	
 
	/// return debug report character to identify the transportation type
 
	/** return debug report character to identify the transportation type */
 
	FORCEINLINE char TransportTypeChar() const
 
	{
 
		return 't';
 
@@ -369,7 +369,7 @@ public:
 

	
 
	static Trackdir stChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target)
 
	{
 
		// create pathfinder instance
 
		/* create pathfinder instance */
 
		Tpf pf1;
 
#if !DEBUG_YAPF_CACHE
 
		Trackdir result1 = pf1.ChooseRailTrack(v, tile, enterdir, tracks, path_not_found, reserve_track, target);
 
@@ -400,28 +400,28 @@ public:
 
	{
 
		if (target != NULL) target->tile = INVALID_TILE;
 

	
 
		// set origin and destination nodes
 
		/* set origin and destination nodes */
 
		PBSTileInfo origin = FollowTrainReservation(v);
 
		Yapf().SetOrigin(origin.tile, origin.trackdir, INVALID_TILE, INVALID_TRACKDIR, 1, true);
 
		Yapf().SetDestination(v);
 

	
 
		// find the best path
 
		/* find the best path */
 
		bool path_found = Yapf().FindPath(v);
 
		if (path_not_found != NULL) {
 
			// tell controller that the path was only 'guessed'
 
			// treat the path as found if stopped on the first two way signal(s)
 
			/* tell controller that the path was only 'guessed'
 
			 * treat the path as found if stopped on the first two way signal(s) */
 
			*path_not_found = !(path_found || Yapf().m_stopped_on_first_two_way_signal);
 
		}
 

	
 
		// if path not found - return INVALID_TRACKDIR
 
		/* if path not found - return INVALID_TRACKDIR */
 
		Trackdir next_trackdir = INVALID_TRACKDIR;
 
		Node *pNode = Yapf().GetBestNode();
 
		if (pNode != NULL) {
 
			// reserve till end of path
 
			/* reserve till end of path */
 
			this->SetReservationTarget(pNode, pNode->GetLastTile(), pNode->GetLastTrackdir());
 

	
 
			// path was found or at least suggested
 
			// walk through the path back to the origin
 
			/* path was found or at least suggested
 
			 * walk through the path back to the origin */
 
			Node *pPrev = NULL;
 
			while (pNode->m_parent != NULL) {
 
				pPrev = pNode;
 
@@ -429,7 +429,7 @@ public:
 

	
 
				this->FindSafePositionOnNode(pPrev);
 
			}
 
			// return trackdir from the best origin node (one of start nodes)
 
			/* return trackdir from the best origin node (one of start nodes) */
 
			Node& best_next_node = *pPrev;
 
			next_trackdir = best_next_node.GetTrackdir();
 

	
 
@@ -457,24 +457,24 @@ public:
 

	
 
	FORCEINLINE bool CheckReverseTrain(const Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
 
	{
 
		// create pathfinder instance
 
		// set origin and destination nodes
 
		/* create pathfinder instance
 
		 * set origin and destination nodes */
 
		Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, false);
 
		Yapf().SetDestination(v);
 

	
 
		// find the best path
 
		/* find the best path */
 
		bool bFound = Yapf().FindPath(v);
 

	
 
		if (!bFound) return false;
 

	
 
		// path was found
 
		// walk through the path back to the origin
 
		/* path was found
 
		 * walk through the path back to the origin */
 
		Node *pNode = Yapf().GetBestNode();
 
		while (pNode->m_parent != NULL) {
 
			pNode = pNode->m_parent;
 
		}
 

	
 
		// check if it was reversed origin
 
		/* check if it was reversed origin */
 
		Node& best_org_node = *pNode;
 
		bool reversed = (best_org_node.m_cost != 0);
 
		return reversed;
 
@@ -509,11 +509,11 @@ struct CYapfAnySafeTileRail2 : CYapfT<CY
 

	
 
Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target)
 
{
 
	// default is YAPF type 2
 
	/* default is YAPF type 2 */
 
	typedef Trackdir (*PfnChooseRailTrack)(const Vehicle*, TileIndex, DiagDirection, TrackBits, bool*, bool, PBSTileInfo*);
 
	PfnChooseRailTrack pfnChooseRailTrack = &CYapfRail1::stChooseRailTrack;
 

	
 
	// check if non-default YAPF type needed
 
	/* check if non-default YAPF type needed */
 
	if (_settings_game.pf.forbid_90_deg) {
 
		pfnChooseRailTrack = &CYapfRail2::stChooseRailTrack; // Trackdir, forbid 90-deg
 
	}
 
@@ -528,7 +528,7 @@ bool YapfCheckReverseTrain(const Vehicle
 
	/* last wagon */
 
	const Vehicle *last_veh = GetLastVehicleInChain(v);
 

	
 
	// get trackdirs of both ends
 
	/* get trackdirs of both ends */
 
	Trackdir td = GetVehicleTrackdir(v);
 
	Trackdir td_rev = ReverseTrackdir(GetVehicleTrackdir(last_veh));
 

	
 
@@ -570,7 +570,7 @@ bool YapfCheckReverseTrain(const Vehicle
 
	typedef bool (*PfnCheckReverseTrain)(const Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir, int);
 
	PfnCheckReverseTrain pfnCheckReverseTrain = CYapfRail1::stCheckReverseTrain;
 

	
 
	// check if non-default YAPF type needed
 
	/* check if non-default YAPF type needed */
 
	if (_settings_game.pf.forbid_90_deg) {
 
		pfnCheckReverseTrain = &CYapfRail2::stCheckReverseTrain; // Trackdir, forbid 90-deg
 
	}
 
@@ -597,7 +597,7 @@ bool YapfFindNearestRailDepotTwoWay(cons
 
	typedef bool (*PfnFindNearestDepotTwoWay)(const Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir, int, int, TileIndex*, bool*);
 
	PfnFindNearestDepotTwoWay pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail1::stFindNearestDepotTwoWay;
 

	
 
	// check if non-default YAPF type needed
 
	/* check if non-default YAPF type needed */
 
	if (_settings_game.pf.forbid_90_deg) {
 
		pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail2::stFindNearestDepotTwoWay; // Trackdir, forbid 90-deg
 
	}
src/yapf/yapf_road.cpp
Show inline comments
 
@@ -19,7 +19,7 @@ public:
 
	typedef typename Node::Key Key;    ///< key to hash tables
 

	
 
protected:
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -27,12 +27,12 @@ protected:
 

	
 
	int SlopeCost(TileIndex tile, TileIndex next_tile, Trackdir trackdir)
 
	{
 
		// height of the center of the current tile
 
		/* height of the center of the current tile */
 
		int x1 = TileX(tile) * TILE_SIZE;
 
		int y1 = TileY(tile) * TILE_SIZE;
 
		int z1 = GetSlopeZ(x1 + TILE_SIZE / 2, y1 + TILE_SIZE / 2);
 

	
 
		// height of the center of the next tile
 
		/* height of the center of the next tile */
 
		int x2 = TileX(next_tile) * TILE_SIZE;
 
		int y2 = TileY(next_tile) * TILE_SIZE;
 
		int z2 = GetSlopeZ(x2 + TILE_SIZE / 2, y2 + TILE_SIZE / 2);
 
@@ -48,7 +48,7 @@ protected:
 
	FORCEINLINE int OneTileCost(TileIndex tile, Trackdir trackdir)
 
	{
 
		int cost = 0;
 
		// set base cost
 
		/* set base cost */
 
		if (IsDiagonalTrackdir(trackdir)) {
 
			cost += YAPF_TILE_LENGTH;
 
			switch (GetTileType(tile)) {
 
@@ -69,7 +69,7 @@ protected:
 
					break;
 
			}
 
		} else {
 
			// non-diagonal trackdir
 
			/* non-diagonal trackdir */
 
			cost = YAPF_TILE_CORNER_LENGTH + Yapf().PfGetSettings().road_curve_penalty;
 
		}
 
		return cost;
 
@@ -82,57 +82,57 @@ public:
 
	FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower *tf)
 
	{
 
		int segment_cost = 0;
 
		// start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment
 
		/* start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment */
 
		TileIndex tile = n.m_key.m_tile;
 
		Trackdir trackdir = n.m_key.m_td;
 
		while (true) {
 
			// base tile cost depending on distance between edges
 
			/* base tile cost depending on distance between edges */
 
			segment_cost += Yapf().OneTileCost(tile, trackdir);
 

	
 
			const Vehicle *v = Yapf().GetVehicle();
 
			// we have reached the vehicle's destination - segment should end here to avoid target skipping
 
			/* we have reached the vehicle's destination - segment should end here to avoid target skipping */
 
			if (Yapf().PfDetectDestinationTile(tile, trackdir)) break;
 

	
 
			// stop if we have just entered the depot
 
			/* stop if we have just entered the depot */
 
			if (IsRoadDepotTile(tile) && trackdir == DiagDirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) {
 
				// next time we will reverse and leave the depot
 
				/* next time we will reverse and leave the depot */
 
				break;
 
			}
 

	
 
			// if there are no reachable trackdirs on new tile, we have end of road
 
			/* if there are no reachable trackdirs on new tile, we have end of road */
 
			TrackFollower F(Yapf().GetVehicle());
 
			if (!F.Follow(tile, trackdir)) break;
 

	
 
			// if there are more trackdirs available & reachable, we are at the end of segment
 
			/* if there are more trackdirs available & reachable, we are at the end of segment */
 
			if (KillFirstBit(F.m_new_td_bits) != TRACKDIR_BIT_NONE) break;
 

	
 
			Trackdir new_td = (Trackdir)FindFirstBit2x64(F.m_new_td_bits);
 

	
 
			// stop if RV is on simple loop with no junctions
 
			/* stop if RV is on simple loop with no junctions */
 
			if (F.m_new_tile == n.m_key.m_tile && new_td == n.m_key.m_td) return false;
 

	
 
			// if we skipped some tunnel tiles, add their cost
 
			/* if we skipped some tunnel tiles, add their cost */
 
			segment_cost += F.m_tiles_skipped * YAPF_TILE_LENGTH;
 

	
 
			// add hilly terrain penalty
 
			/* add hilly terrain penalty */
 
			segment_cost += Yapf().SlopeCost(tile, F.m_new_tile, trackdir);
 

	
 
			// add min/max speed penalties
 
			/* add min/max speed penalties */
 
			int min_speed = 0;
 
			int max_speed = F.GetSpeedLimit(&min_speed);
 
			if (max_speed < v->max_speed) segment_cost += 1 * (v->max_speed - max_speed);
 
			if (min_speed > v->max_speed) segment_cost += 10 * (min_speed - v->max_speed);
 

	
 
			// move to the next tile
 
			/* move to the next tile */
 
			tile = F.m_new_tile;
 
			trackdir = new_td;
 
		};
 

	
 
		// save end of segment back to the node
 
		/* save end of segment back to the node */
 
		n.m_segment_last_tile = tile;
 
		n.m_segment_last_td = trackdir;
 

	
 
		// save also tile cost
 
		/* save also tile cost */
 
		int parent_cost = (n.m_parent != NULL) ? n.m_parent->m_cost : 0;
 
		n.m_cost = parent_cost + segment_cost;
 
		return true;
 
@@ -149,13 +149,13 @@ public:
 
	typedef typename Types::NodeList::Titem Node;        ///< this will be our node type
 
	typedef typename Node::Key Key;                      ///< key to hash tables
 

	
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
	/// Called by YAPF to detect if node ends in the desired destination
 
	/** Called by YAPF to detect if node ends in the desired destination */
 
	FORCEINLINE bool PfDetectDestination(Node& n)
 
	{
 
		bool bDest = IsRoadDepotTile(n.m_segment_last_tile);
 
@@ -198,14 +198,14 @@ public:
 
	}
 

	
 
protected:
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
public:
 
	/// Called by YAPF to detect if node ends in the desired destination
 
	/** Called by YAPF to detect if node ends in the desired destination */
 
	FORCEINLINE bool PfDetectDestination(Node& n)
 
	{
 
		bool bDest = (n.m_segment_last_tile == m_destTile) && ((m_destTrackdirs & TrackdirToTrackdirBits(n.m_segment_last_td)) != TRACKDIR_BIT_NONE);
 
@@ -257,7 +257,7 @@ public:
 
	typedef typename Node::Key Key;                      ///< key to hash tables
 

	
 
protected:
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -276,7 +276,7 @@ public:
 
		}
 
	}
 

	
 
	/// return debug report character to identify the transportation type
 
	/** return debug report character to identify the transportation type */
 
	FORCEINLINE char TransportTypeChar() const
 
	{
 
		return 'r';
 
@@ -290,39 +290,39 @@ public:
 

	
 
	FORCEINLINE Trackdir ChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir)
 
	{
 
		// handle special case - when next tile is destination tile
 
		/* handle special case - when next tile is destination tile */
 
		if (tile == v->dest_tile) {
 
			// choose diagonal trackdir reachable from enterdir
 
			/* choose diagonal trackdir reachable from enterdir */
 
			return DiagDirToDiagTrackdir(enterdir);
 
		}
 
		// our source tile will be the next vehicle tile (should be the given one)
 
		/* our source tile will be the next vehicle tile (should be the given one) */
 
		TileIndex src_tile = tile;
 
		// get available trackdirs on the start tile
 
		/* get available trackdirs on the start tile */
 
		TrackdirBits src_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes));
 
		// select reachable trackdirs only
 
		/* select reachable trackdirs only */
 
		src_trackdirs &= DiagdirReachesTrackdirs(enterdir);
 

	
 
		// get available trackdirs on the destination tile
 
		/* get available trackdirs on the destination tile */
 
		TileIndex dest_tile = v->dest_tile;
 
		TrackdirBits dest_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes));
 

	
 
		// set origin and destination nodes
 
		/* set origin and destination nodes */
 
		Yapf().SetOrigin(src_tile, src_trackdirs);
 
		Yapf().SetDestination(dest_tile, dest_trackdirs);
 

	
 
		// find the best path
 
		/* find the best path */
 
		Yapf().FindPath(v);
 

	
 
		// if path not found - return INVALID_TRACKDIR
 
		/* if path not found - return INVALID_TRACKDIR */
 
		Trackdir next_trackdir = INVALID_TRACKDIR;
 
		Node *pNode = Yapf().GetBestNode();
 
		if (pNode != NULL) {
 
			// path was found or at least suggested
 
			// walk through the path back to its origin
 
			/* path was found or at least suggested
 
			 * walk through the path back to its origin */
 
			while (pNode->m_parent != NULL) {
 
				pNode = pNode->m_parent;
 
			}
 
			// return trackdir from the best origin node (one of start nodes)
 
			/* return trackdir from the best origin node (one of start nodes) */
 
			Node& best_next_node = *pNode;
 
			assert(best_next_node.GetTile() == tile);
 
			next_trackdir = best_next_node.GetTrackdir();
 
@@ -338,29 +338,29 @@ public:
 

	
 
	FORCEINLINE uint DistanceToTile(const Vehicle *v, TileIndex dst_tile)
 
	{
 
		// handle special case - when current tile is the destination tile
 
		/* handle special case - when current tile is the destination tile */
 
		if (dst_tile == v->tile) {
 
			// distance is zero in this case
 
			/* distance is zero in this case */
 
			return 0;
 
		}
 

	
 
		if (!SetOriginFromVehiclePos(v)) return UINT_MAX;
 

	
 
		// set destination tile, trackdir
 
		//   get available trackdirs on the destination tile
 
		/* set destination tile, trackdir
 
		 *   get available trackdirs on the destination tile */
 
		TrackdirBits dst_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes));
 
		Yapf().SetDestination(dst_tile, dst_td_bits);
 

	
 
		// if path not found - return distance = UINT_MAX
 
		/* if path not found - return distance = UINT_MAX */
 
		uint dist = UINT_MAX;
 

	
 
		// find the best path
 
		/* find the best path */
 
		if (!Yapf().FindPath(v)) return dist;
 

	
 
		Node *pNode = Yapf().GetBestNode();
 
		if (pNode != NULL) {
 
			// path was found
 
			// get the path cost estimate
 
			/* path was found
 
			 * get the path cost estimate */
 
			dist = pNode->GetCostEstimate();
 
		}
 

	
 
@@ -370,12 +370,12 @@ public:
 
	/** Return true if the valid origin (tile/trackdir) was set from the current vehicle position. */
 
	FORCEINLINE bool SetOriginFromVehiclePos(const Vehicle *v)
 
	{
 
		// set origin (tile, trackdir)
 
		/* set origin (tile, trackdir) */
 
		TileIndex src_tile = v->tile;
 
		Trackdir src_td = GetVehicleTrackdir(v);
 
		if ((TrackStatusToTrackdirBits(GetTileTrackStatus(src_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes)) & TrackdirToTrackdirBits(src_td)) == 0) {
 
			// sometimes the roadveh is not on the road (it resides on non-existing track)
 
			// how should we handle that situation?
 
			/* sometimes the roadveh is not on the road (it resides on non-existing track)
 
			 * how should we handle that situation? */
 
			return false;
 
		}
 
		Yapf().SetOrigin(src_tile, TrackdirToTrackdirBits(src_td));
 
@@ -390,15 +390,15 @@ public:
 

	
 
	FORCEINLINE Depot *FindNearestDepot(const Vehicle *v, TileIndex tile, Trackdir td)
 
	{
 
		// set origin and destination nodes
 
		/* set origin and destination nodes */
 
		Yapf().SetOrigin(tile, TrackdirToTrackdirBits(td));
 

	
 
		// find the best path
 
		/* find the best path */
 
		bool bFound = Yapf().FindPath(v);
 
		if (!bFound) return false;
 

	
 
		// some path found
 
		// get found depot tile
 
		/* some path found
 
		 * get found depot tile */
 
		Node *n = Yapf().GetBestNode();
 
		TileIndex depot_tile = n->m_segment_last_tile;
 
		assert(IsRoadDepotTile(depot_tile));
 
@@ -432,11 +432,11 @@ struct CYapfRoadAnyDepot2 : CYapfT<CYapf
 

	
 
Trackdir YapfChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir)
 
{
 
	// default is YAPF type 2
 
	/* default is YAPF type 2 */
 
	typedef Trackdir (*PfnChooseRoadTrack)(const Vehicle*, TileIndex, DiagDirection);
 
	PfnChooseRoadTrack pfnChooseRoadTrack = &CYapfRoad2::stChooseRoadTrack; // default: ExitDir, allow 90-deg
 

	
 
	// check if non-default YAPF type should be used
 
	/* check if non-default YAPF type should be used */
 
	if (_settings_game.pf.yapf.disable_node_optimization) {
 
		pfnChooseRoadTrack = &CYapfRoad1::stChooseRoadTrack; // Trackdir, allow 90-deg
 
	}
 
@@ -447,18 +447,18 @@ Trackdir YapfChooseRoadTrack(const Vehic
 

	
 
uint YapfRoadVehDistanceToTile(const Vehicle *v, TileIndex tile)
 
{
 
	// default is YAPF type 2
 
	/* default is YAPF type 2 */
 
	typedef uint (*PfnDistanceToTile)(const Vehicle*, TileIndex);
 
	PfnDistanceToTile pfnDistanceToTile = &CYapfRoad2::stDistanceToTile; // default: ExitDir, allow 90-deg
 

	
 
	// check if non-default YAPF type should be used
 
	/* check if non-default YAPF type should be used */
 
	if (_settings_game.pf.yapf.disable_node_optimization) {
 
		pfnDistanceToTile = &CYapfRoad1::stDistanceToTile; // Trackdir, allow 90-deg
 
	}
 

	
 
	// measure distance in YAPF units
 
	/* measure distance in YAPF units */
 
	uint dist = pfnDistanceToTile(v, tile);
 
	// convert distance to tiles
 
	/* convert distance to tiles */
 
	if (dist != UINT_MAX) {
 
		dist = (dist + YAPF_TILE_LENGTH - 1) / YAPF_TILE_LENGTH;
 
	}
 
@@ -474,17 +474,17 @@ Depot *YapfFindNearestRoadDepot(const Ve
 
		return NULL;
 
	}
 

	
 
	// handle the case when our vehicle is already in the depot tile
 
	/* handle the case when our vehicle is already in the depot tile */
 
	if (IsRoadDepotTile(tile)) {
 
		// only what we need to return is the Depot*
 
		/* only what we need to return is the Depot* */
 
		return GetDepotByTile(tile);
 
	}
 

	
 
	// default is YAPF type 2
 
	/* default is YAPF type 2 */
 
	typedef Depot *(*PfnFindNearestDepot)(const Vehicle*, TileIndex, Trackdir);
 
	PfnFindNearestDepot pfnFindNearestDepot = &CYapfRoadAnyDepot2::stFindNearestDepot;
 

	
 
	// check if non-default YAPF type should be used
 
	/* check if non-default YAPF type should be used */
 
	if (_settings_game.pf.yapf.disable_node_optimization) {
 
		pfnFindNearestDepot = &CYapfRoadAnyDepot1::stFindNearestDepot; // Trackdir, allow 90-deg
 
	}
src/yapf/yapf_ship.cpp
Show inline comments
 
@@ -17,7 +17,7 @@ public:
 
	typedef typename Node::Key Key;                      ///< key to hash tables
 

	
 
protected:
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -35,7 +35,7 @@ public:
 
		}
 
	}
 

	
 
	/// return debug report character to identify the transportation type
 
	/** return debug report character to identify the transportation type */
 
	FORCEINLINE char TransportTypeChar() const
 
	{
 
		return 'w';
 
@@ -43,44 +43,44 @@ public:
 

	
 
	static Trackdir ChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 
	{
 
		// handle special case - when next tile is destination tile
 
		/* handle special case - when next tile is destination tile */
 
		if (tile == v->dest_tile) {
 
			// convert tracks to trackdirs
 
			/* convert tracks to trackdirs */
 
			TrackdirBits trackdirs = (TrackdirBits)(tracks | ((int)tracks << 8));
 
			// choose any trackdir reachable from enterdir
 
			/* choose any trackdir reachable from enterdir */
 
			trackdirs &= DiagdirReachesTrackdirs(enterdir);
 
			return (Trackdir)FindFirstBit2x64(trackdirs);
 
		}
 

	
 
		// move back to the old tile/trackdir (where ship is coming from)
 
		/* move back to the old tile/trackdir (where ship is coming from) */
 
		TileIndex src_tile = TILE_ADD(tile, TileOffsByDiagDir(ReverseDiagDir(enterdir)));
 
		Trackdir trackdir = GetVehicleTrackdir(v);
 
		assert(IsValidTrackdir(trackdir));
 

	
 
		// convert origin trackdir to TrackdirBits
 
		/* convert origin trackdir to TrackdirBits */
 
		TrackdirBits trackdirs = TrackdirToTrackdirBits(trackdir);
 
		// get available trackdirs on the destination tile
 
		/* get available trackdirs on the destination tile */
 
		TrackdirBits dest_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(v->dest_tile, TRANSPORT_WATER, 0));
 

	
 
		// create pathfinder instance
 
		/* create pathfinder instance */
 
		Tpf pf;
 
		// set origin and destination nodes
 
		/* set origin and destination nodes */
 
		pf.SetOrigin(src_tile, trackdirs);
 
		pf.SetDestination(v->dest_tile, dest_trackdirs);
 
		// find best path
 
		/* find best path */
 
		pf.FindPath(v);
 

	
 
		Trackdir next_trackdir = INVALID_TRACKDIR; // this would mean "path not found"
 

	
 
		Node *pNode = pf.GetBestNode();
 
		if (pNode != NULL) {
 
			// walk through the path back to the origin
 
			/* walk through the path back to the origin */
 
			Node *pPrevNode = NULL;
 
			while (pNode->m_parent != NULL) {
 
				pPrevNode = pNode;
 
				pNode = pNode->m_parent;
 
			}
 
			// return trackdir from the best next node (direct child of origin)
 
			/* return trackdir from the best next node (direct child of origin) */
 
			Node& best_next_node = *pPrevNode;
 
			assert(best_next_node.GetTile() == tile);
 
			next_trackdir = best_next_node.GetTrackdir();
 
@@ -100,7 +100,7 @@ public:
 
	typedef typename Node::Key Key;               ///< key to hash tables
 

	
 
protected:
 
	/// to access inherited path finder
 
	/** to access inherited path finder */
 
	Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
@@ -112,9 +112,9 @@ public:
 
	 *  and stores the result into Node::m_cost member */
 
	FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower *tf)
 
	{
 
		// base tile cost depending on distance
 
		/* base tile cost depending on distance */
 
		int c = IsDiagonalTrackdir(n.GetTrackdir()) ? 10 : 7;
 
		// additional penalty for curves
 
		/* additional penalty for curves */
 
		if (n.m_parent != NULL && n.GetTrackdir() != NextTrackdir(n.m_parent->GetTrackdir())) {
 
			/* new trackdir does not match the next one when going straight */
 
			c += 10;
 
@@ -122,7 +122,7 @@ public:
 

	
 
		c += YAPF_TILE_LENGTH * tf->m_tiles_skipped;
 

	
 
		// apply it
 
		/* apply it */
 
		n.m_cost = n.m_parent->m_cost + c;
 
		return true;
 
	}
 
@@ -152,21 +152,21 @@ struct CYapfShip_TypesT
 
	typedef CYapfCostShipT<Types>             PfCost;        // cost provider
 
};
 

	
 
// YAPF type 1 - uses TileIndex/Trackdir as Node key, allows 90-deg turns
 
/* YAPF type 1 - uses TileIndex/Trackdir as Node key, allows 90-deg turns */
 
struct CYapfShip1 : CYapfT<CYapfShip_TypesT<CYapfShip1, CFollowTrackWater    , CShipNodeListTrackDir> > {};
 
// YAPF type 2 - uses TileIndex/DiagDirection as Node key, allows 90-deg turns
 
/* YAPF type 2 - uses TileIndex/DiagDirection as Node key, allows 90-deg turns */
 
struct CYapfShip2 : CYapfT<CYapfShip_TypesT<CYapfShip2, CFollowTrackWater    , CShipNodeListExitDir > > {};
 
// YAPF type 3 - uses TileIndex/Trackdir as Node key, forbids 90-deg turns
 
/* YAPF type 3 - uses TileIndex/Trackdir as Node key, forbids 90-deg turns */
 
struct CYapfShip3 : CYapfT<CYapfShip_TypesT<CYapfShip3, CFollowTrackWaterNo90, CShipNodeListTrackDir> > {};
 

	
 
/** Ship controller helper - path finder invoker */
 
Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 
{
 
	// default is YAPF type 2
 
	/* default is YAPF type 2 */
 
	typedef Trackdir (*PfnChooseShipTrack)(const Vehicle*, TileIndex, DiagDirection, TrackBits);
 
	PfnChooseShipTrack pfnChooseShipTrack = CYapfShip2::ChooseShipTrack; // default: ExitDir, allow 90-deg
 

	
 
	// check if non-default YAPF type needed
 
	/* check if non-default YAPF type needed */
 
	if (_settings_game.pf.forbid_90_deg) {
 
		pfnChooseShipTrack = &CYapfShip3::ChooseShipTrack; // Trackdir, forbid 90-deg
 
	} else if (_settings_game.pf.yapf.disable_node_optimization) {
0 comments (0 inline, 0 general)