Changeset - r11363:6906c490a00e
[Not reviewed]
master
! ! !
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
87 files changed:
Changeset was too big and was cut off... Show full diff anyway
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
 
};

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)