1
0
Fork 0

(svn r9672) -Cleanup: lots of coding style fixes around operands.

release/0.6
rubidium 2007-04-18 22:10:36 +00:00
parent 41cf2fa69b
commit 80c259f64f
62 changed files with 1051 additions and 1051 deletions

View File

@ -77,8 +77,8 @@ static inline bool AI_AllowNewAI()
return true; return true;
} }
#define AI_CHANCE16(a,b) ((uint16) AI_Random() <= (uint16)((65536 * a) / b)) #define AI_CHANCE16(a, b) ((uint16) AI_Random() <= (uint16)((65536 * a) / b))
#define AI_CHANCE16R(a,b,r) ((uint16)(r = AI_Random()) <= (uint16)((65536 * a) / b)) #define AI_CHANCE16R(a, b, r) ((uint16)(r = AI_Random()) <= (uint16)((65536 * a) / b))
/** /**
* The random-function that should be used by ALL AIs. * The random-function that should be used by ALL AIs.

View File

@ -516,7 +516,7 @@ static void AiFindSubsidyPassengerRoute(FoundRoute *fr)
{ {
uint i; uint i;
const Subsidy* s; const Subsidy* s;
Town *from,*to; Town *from, *to;
// initially error // initially error
fr->distance = -1; fr->distance = -1;
@ -1561,7 +1561,7 @@ static bool AiCheckTrackResources(TileIndex tile, const AiDefaultBlockData *p, b
return false; return false;
if (cargo != CT_MAIL) if (cargo != CT_MAIL)
return true; return true;
return !!((values[cargo]>>1) & ~7); return !!((values[cargo] >> 1) & ~7);
} }
} }
@ -1574,7 +1574,7 @@ static int32 AiDoBuildDefaultRailTrack(TileIndex tile, const AiDefaultBlockData*
int32 total_cost = 0; int32 total_cost = 0;
Town *t = NULL; Town *t = NULL;
int rating = 0; int rating = 0;
int i,j,k; int i, j, k;
for (;;) { for (;;) {
// This will seldomly overflow for valid reasons. Mask it to be on the safe side. // This will seldomly overflow for valid reasons. Mask it to be on the safe side.
@ -1588,7 +1588,7 @@ static int32 AiDoBuildDefaultRailTrack(TileIndex tile, const AiDefaultBlockData*
ret = DoCommand(c, railtype, p->attr, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_TRAIN_DEPOT); ret = DoCommand(c, railtype, p->attr, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_TRAIN_DEPOT);
} else { } else {
// Station // Station
ret = DoCommand(c, (p->attr&1) | (p->attr>>4)<<8 | (p->attr>>1&7)<<16, railtype, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_RAILROAD_STATION); ret = DoCommand(c, (p->attr & 1) | (p->attr >> 4) << 8 | (p->attr >> 1 & 7) << 16, railtype, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_RAILROAD_STATION);
} }
if (CmdFailed(ret)) return CMD_ERROR; if (CmdFailed(ret)) return CMD_ERROR;
@ -1610,7 +1610,7 @@ clear_town_stuff:;
// Build the rail // Build the rail
for (i = 0; i != 6; i++, j >>= 1) { for (i = 0; i != 6; i++, j >>= 1) {
if (j&1) { if (j & 1) {
k = i; k = i;
ret = DoCommand(c, railtype, i, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL); ret = DoCommand(c, railtype, i, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL);
if (CmdFailed(ret)) return CMD_ERROR; if (CmdFailed(ret)) return CMD_ERROR;
@ -1642,7 +1642,7 @@ clear_town_stuff:;
total_cost += ret + _price.build_rail; total_cost += ret + _price.build_rail;
if (flag & DC_EXEC) { if (flag & DC_EXEC) {
DoCommand(c, railtype, p->attr&1, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_SINGLE_RAIL); DoCommand(c, railtype, p->attr & 1, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_SINGLE_RAIL);
} }
goto clear_town_stuff; goto clear_town_stuff;
@ -1784,7 +1784,7 @@ static void AiStateBuildDefaultRailBlocks(Player *p)
if (rule == -1) { if (rule == -1) {
// cannot build, terraform after a while // cannot build, terraform after a while
if (p->ai.state_counter >= 600) { if (p->ai.state_counter >= 600) {
AiDoTerraformLand(aib->use_tile, Random()&3, 3, (int8)p->ai.state_mode); AiDoTerraformLand(aib->use_tile, Random() & 3, 3, (int8)p->ai.state_mode);
} }
// also try the other terraform direction // also try the other terraform direction
if (++p->ai.state_counter >= 1000) { if (++p->ai.state_counter >= 1000) {
@ -1804,7 +1804,7 @@ static void AiStateBuildDefaultRailBlocks(Player *p)
); );
assert(!CmdFailed(r)); assert(!CmdFailed(r));
} }
} while (++aib,--j); } while (++aib, --j);
} }
// check if we're done with all of them // check if we're done with all of them
@ -1812,7 +1812,7 @@ static void AiStateBuildDefaultRailBlocks(Player *p)
j = p->ai.num_build_rec; j = p->ai.num_build_rec;
do { do {
if (aib->cur_building_rule == 255) return; if (aib->cur_building_rule == 255) return;
} while (++aib,--j); } while (++aib, --j);
// yep, all are done. switch state to the rail building state. // yep, all are done. switch state to the rail building state.
p->ai.state = AIS_BUILD_RAIL; p->ai.state = AIS_BUILD_RAIL;
@ -1857,7 +1857,7 @@ static bool AiDoFollowTrack(const Player* p)
arpfd.tile2 = p->ai.cur_tile_a; arpfd.tile2 = p->ai.cur_tile_a;
arpfd.flag = false; arpfd.flag = false;
arpfd.count = 0; arpfd.count = 0;
FollowTrack(p->ai.cur_tile_a + TileOffsByDiagDir(p->ai.cur_dir_a), 0x2000 | TRANSPORT_RAIL, (DiagDirection)(p->ai.cur_dir_a^2), FollowTrack(p->ai.cur_tile_a + TileOffsByDiagDir(p->ai.cur_dir_a), 0x2000 | TRANSPORT_RAIL, (DiagDirection)(p->ai.cur_dir_a ^ 2),
(TPFEnumProc*)AiEnumFollowTrack, NULL, &arpfd); (TPFEnumProc*)AiEnumFollowTrack, NULL, &arpfd);
return arpfd.count > 8; return arpfd.count > 8;
} }
@ -2001,8 +2001,8 @@ static inline void AiCheckBuildRailTunnelHere(AiRailFinder *arf, TileIndex tile,
if (GetTileSlope(tile, &z) == _dir_table_2[p[0] & 3] && z != 0) { if (GetTileSlope(tile, &z) == _dir_table_2[p[0] & 3] && z != 0) {
int32 cost = DoCommand(tile, arf->player->ai.railtype_to_use, 0, DC_AUTO, CMD_BUILD_TUNNEL); int32 cost = DoCommand(tile, arf->player->ai.railtype_to_use, 0, DC_AUTO, CMD_BUILD_TUNNEL);
if (!CmdFailed(cost) && cost <= (arf->player->player_money>>4)) { if (!CmdFailed(cost) && cost <= (arf->player->player_money >> 4)) {
AiBuildRailRecursive(arf, _build_tunnel_endtile, p[0]&3); AiBuildRailRecursive(arf, _build_tunnel_endtile, p[0] & 3);
if (arf->depth == 1) AiCheckRailPathBetter(arf, p); if (arf->depth == 1) AiCheckRailPathBetter(arf, p);
} }
} }
@ -2017,7 +2017,7 @@ static void AiBuildRailRecursive(AiRailFinder *arf, TileIndex tile, int dir)
// Reached destination? // Reached destination?
if (tile == arf->final_tile) { if (tile == arf->final_tile) {
if (arf->final_dir != (dir^2)) { if (arf->final_dir != (dir ^ 2)) {
if (arf->recursive_mode != 2) arf->recursive_mode = 1; if (arf->recursive_mode != 2) arf->recursive_mode = 1;
} else if (arf->recursive_mode != 2) { } else if (arf->recursive_mode != 2) {
arf->recursive_mode = 2; arf->recursive_mode = 2;
@ -2063,17 +2063,17 @@ static void AiBuildRailRecursive(AiRailFinder *arf, TileIndex tile, int dir)
if (arf->depth == 1) AiCheckRailPathBetter(arf, p); if (arf->depth == 1) AiCheckRailPathBetter(arf, p);
p += 2; p += 2;
} while (!(p[0]&0x80)); } while (!(p[0] & 0x80));
} }
AiCheckBuildRailBridgeHere(arf, tile, p); AiCheckBuildRailBridgeHere(arf, tile, p);
AiCheckBuildRailTunnelHere(arf, tile, p+1); AiCheckBuildRailTunnelHere(arf, tile, p + 1);
arf->depth--; arf->depth--;
} }
static const byte _dir_table_3[]= {0x25, 0x2A, 0x19, 0x16}; static const byte _dir_table_3[] = {0x25, 0x2A, 0x19, 0x16};
static void AiBuildRailConstruct(Player *p) static void AiBuildRailConstruct(Player *p)
{ {
@ -2324,23 +2324,23 @@ static void AiStateBuildRail(Player *p)
} }
// Find first edge to build from. // Find first edge to build from.
tile = AiGetEdgeOfDefaultRailBlock(aib->cur_building_rule, aib->use_tile, cmd&3, &dir); tile = AiGetEdgeOfDefaultRailBlock(aib->cur_building_rule, aib->use_tile, cmd & 3, &dir);
p->ai.start_tile_a = tile; p->ai.start_tile_a = tile;
p->ai.cur_tile_a = tile; p->ai.cur_tile_a = tile;
p->ai.start_dir_a = dir; p->ai.start_dir_a = dir;
p->ai.cur_dir_a = dir; p->ai.cur_dir_a = dir;
DoCommand(TILE_MASK(tile + TileOffsByDiagDir(dir)), 0, (dir&1)?1:0, DC_EXEC, CMD_REMOVE_SINGLE_RAIL); DoCommand(TILE_MASK(tile + TileOffsByDiagDir(dir)), 0, (dir & 1) ? 1 : 0, DC_EXEC, CMD_REMOVE_SINGLE_RAIL);
assert(TILE_MASK(tile) != 0xFF00); assert(TILE_MASK(tile) != 0xFF00);
// Find second edge to build to // Find second edge to build to
aib = (&p->ai.src) + ((cmd >> 4)&0xF); aib = (&p->ai.src) + ((cmd >> 4) & 0xF);
tile = AiGetEdgeOfDefaultRailBlock(aib->cur_building_rule, aib->use_tile, (cmd>>2)&3, &dir); tile = AiGetEdgeOfDefaultRailBlock(aib->cur_building_rule, aib->use_tile, (cmd >> 2) & 3, &dir);
p->ai.start_tile_b = tile; p->ai.start_tile_b = tile;
p->ai.cur_tile_b = tile; p->ai.cur_tile_b = tile;
p->ai.start_dir_b = dir; p->ai.start_dir_b = dir;
p->ai.cur_dir_b = dir; p->ai.cur_dir_b = dir;
DoCommand(TILE_MASK(tile + TileOffsByDiagDir(dir)), 0, (dir&1)?1:0, DC_EXEC, CMD_REMOVE_SINGLE_RAIL); DoCommand(TILE_MASK(tile + TileOffsByDiagDir(dir)), 0, (dir & 1) ? 1 : 0, DC_EXEC, CMD_REMOVE_SINGLE_RAIL);
assert(TILE_MASK(tile) != 0xFF00); assert(TILE_MASK(tile) != 0xFF00);
@ -2503,7 +2503,7 @@ static void AiStateDeleteRailBlocks(Player *p)
for (b = _default_rail_track_data[aib->cur_building_rule]->data; b->mode != 4; b++) { for (b = _default_rail_track_data[aib->cur_building_rule]->data; b->mode != 4; b++) {
DoCommand(TILE_ADD(aib->use_tile, ToTileIndexDiff(b->tileoffs)), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); DoCommand(TILE_ADD(aib->use_tile, ToTileIndexDiff(b->tileoffs)), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
} }
} while (++aib,--num); } while (++aib, --num);
p->ai.state = AIS_0; p->ai.state = AIS_0;
} }
@ -2682,14 +2682,14 @@ static void AiStateBuildDefaultRoadBlocks(Player *p)
if (rule == -1) { if (rule == -1) {
// cannot build, terraform after a while // cannot build, terraform after a while
if (p->ai.state_counter >= 600) { if (p->ai.state_counter >= 600) {
AiDoTerraformLand(aib->use_tile, Random()&3, 3, (int8)p->ai.state_mode); AiDoTerraformLand(aib->use_tile, Random() & 3, 3, (int8)p->ai.state_mode);
} }
// also try the other terraform direction // also try the other terraform direction
if (++p->ai.state_counter >= 1000) { if (++p->ai.state_counter >= 1000) {
p->ai.state_counter = 0; p->ai.state_counter = 0;
p->ai.state_mode = -p->ai.state_mode; p->ai.state_mode = -p->ai.state_mode;
} }
} else if (CheckPlayerHasMoney(cost) && AiCheckBlockDistances(p,aib->use_tile)) { } else if (CheckPlayerHasMoney(cost) && AiCheckBlockDistances(p, aib->use_tile)) {
int32 r; int32 r;
// player has money, build it. // player has money, build it.
@ -2702,7 +2702,7 @@ static void AiStateBuildDefaultRoadBlocks(Player *p)
); );
assert(!CmdFailed(r)); assert(!CmdFailed(r));
} }
} while (++aib,--j); } while (++aib, --j);
} }
// check if we're done with all of them // check if we're done with all of them
@ -2710,7 +2710,7 @@ static void AiStateBuildDefaultRoadBlocks(Player *p)
j = p->ai.num_build_rec; j = p->ai.num_build_rec;
do { do {
if (aib->cur_building_rule == 255) return; if (aib->cur_building_rule == 255) return;
} while (++aib,--j); } while (++aib, --j);
// yep, all are done. switch state to the rail building state. // yep, all are done. switch state to the rail building state.
p->ai.state = AIS_BUILD_ROAD; p->ai.state = AIS_BUILD_ROAD;
@ -2901,8 +2901,8 @@ static inline void AiCheckBuildRoadTunnelHere(AiRoadFinder *arf, TileIndex tile,
if (GetTileSlope(tile, &z) == _dir_table_2[p[0] & 3] && z != 0) { if (GetTileSlope(tile, &z) == _dir_table_2[p[0] & 3] && z != 0) {
int32 cost = DoCommand(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL); int32 cost = DoCommand(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
if (!CmdFailed(cost) && cost <= (arf->player->player_money>>4)) { if (!CmdFailed(cost) && cost <= (arf->player->player_money >> 4)) {
AiBuildRoadRecursive(arf, _build_tunnel_endtile, p[0]&3); AiBuildRoadRecursive(arf, _build_tunnel_endtile, p[0] & 3);
if (arf->depth == 1) AiCheckRoadPathBetter(arf, p); if (arf->depth == 1) AiCheckRoadPathBetter(arf, p);
} }
} }
@ -2918,7 +2918,7 @@ static void AiBuildRoadRecursive(AiRoadFinder *arf, TileIndex tile, int dir)
// Reached destination? // Reached destination?
if (tile == arf->final_tile) { if (tile == arf->final_tile) {
if ((arf->final_dir^2) == dir) { if ((arf->final_dir ^ 2) == dir) {
arf->recursive_mode = 2; arf->recursive_mode = 2;
arf->cur_best_depth = arf->depth; arf->cur_best_depth = arf->depth;
} }
@ -2962,7 +2962,7 @@ static void AiBuildRoadRecursive(AiRoadFinder *arf, TileIndex tile, int dir)
} }
AiCheckBuildRoadBridgeHere(arf, tile, p); AiCheckBuildRoadBridgeHere(arf, tile, p);
AiCheckBuildRoadTunnelHere(arf, tile, p+1); AiCheckBuildRoadTunnelHere(arf, tile, p + 1);
arf->depth--; arf->depth--;
} }
@ -3020,7 +3020,7 @@ do_some_terraform:
tile = TILE_MASK(p->ai.cur_tile_a + TileOffsByDiagDir(p->ai.cur_dir_a)); tile = TILE_MASK(p->ai.cur_tile_a + TileOffsByDiagDir(p->ai.cur_dir_a));
if (arf.best_ptr[0]&0x80) { if (arf.best_ptr[0] & 0x80) {
int i; int i;
int32 bridge_len; int32 bridge_len;
p->ai.cur_tile_a = arf.bridge_end_tile; p->ai.cur_tile_a = arf.bridge_end_tile;
@ -3042,7 +3042,7 @@ do_some_terraform:
DoCommand(tile, p->ai.cur_tile_a, i + (0x80 << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE); DoCommand(tile, p->ai.cur_tile_a, i + (0x80 << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
p->ai.state_counter = 0; p->ai.state_counter = 0;
} else if (arf.best_ptr[0]&0x40) { } else if (arf.best_ptr[0] & 0x40) {
// tunnel // tunnel
DoCommand(tile, 0x200, 0, DC_AUTO | DC_EXEC, CMD_BUILD_TUNNEL); DoCommand(tile, 0x200, 0, DC_AUTO | DC_EXEC, CMD_BUILD_TUNNEL);
p->ai.cur_tile_a = _build_tunnel_endtile; p->ai.cur_tile_a = _build_tunnel_endtile;
@ -3148,7 +3148,7 @@ static void AiStateBuildRoad(Player *p)
p->ai.cur_dir_a = dir; p->ai.cur_dir_a = dir;
// Find second edge to build to // Find second edge to build to
aib = (&p->ai.src) + (cmd&0xF); aib = (&p->ai.src) + (cmd & 0xF);
tile = AiGetRoadBlockEdge(aib->cur_building_rule, aib->use_tile, &dir); tile = AiGetRoadBlockEdge(aib->cur_building_rule, aib->use_tile, &dir);
p->ai.start_tile_b = tile; p->ai.start_tile_b = tile;
p->ai.cur_tile_b = tile; p->ai.cur_tile_b = tile;
@ -3239,7 +3239,7 @@ static void AiStateDeleteRoadBlocks(Player *p)
if (b->mode > 1) continue; if (b->mode > 1) continue;
DoCommand(TILE_ADD(aib->use_tile, ToTileIndexDiff(b->tileoffs)), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); DoCommand(TILE_ADD(aib->use_tile, ToTileIndexDiff(b->tileoffs)), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
} }
} while (++aib,--num); } while (++aib, --num);
p->ai.state = AIS_0; p->ai.state = AIS_0;
} }
@ -3326,7 +3326,7 @@ static int32 AiDoBuildDefaultAirportBlock(TileIndex tile, const AiDefaultBlockDa
for (; p->mode == 0; p++) { for (; p->mode == 0; p++) {
if (!HASBIT(avail_airports, p->attr)) return CMD_ERROR; if (!HASBIT(avail_airports, p->attr)) return CMD_ERROR;
ret = DoCommand(TILE_MASK(tile + ToTileIndexDiff(p->tileoffs)), p->attr,0,flag | DC_AUTO | DC_NO_WATER,CMD_BUILD_AIRPORT); ret = DoCommand(TILE_MASK(tile + ToTileIndexDiff(p->tileoffs)), p->attr, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_AIRPORT);
if (CmdFailed(ret)) return CMD_ERROR; if (CmdFailed(ret)) return CMD_ERROR;
total_cost += ret; total_cost += ret;
} }
@ -3408,14 +3408,14 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
if (rule == -1) { if (rule == -1) {
// cannot build, terraform after a while // cannot build, terraform after a while
if (p->ai.state_counter >= 600) { if (p->ai.state_counter >= 600) {
AiDoTerraformLand(aib->use_tile, Random()&3, 3, (int8)p->ai.state_mode); AiDoTerraformLand(aib->use_tile, Random() & 3, 3, (int8)p->ai.state_mode);
} }
// also try the other terraform direction // also try the other terraform direction
if (++p->ai.state_counter >= 1000) { if (++p->ai.state_counter >= 1000) {
p->ai.state_counter = 0; p->ai.state_counter = 0;
p->ai.state_mode = -p->ai.state_mode; p->ai.state_mode = -p->ai.state_mode;
} }
} else if (CheckPlayerHasMoney(cost) && AiCheckBlockDistances(p,aib->use_tile)) { } else if (CheckPlayerHasMoney(cost) && AiCheckBlockDistances(p, aib->use_tile)) {
// player has money, build it. // player has money, build it.
int32 r; int32 r;
@ -3428,7 +3428,7 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
); );
assert(!CmdFailed(r)); assert(!CmdFailed(r));
} }
} while (++aib,--j); } while (++aib, --j);
} while (--i); } while (--i);
// check if we're done with all of them // check if we're done with all of them
@ -3436,7 +3436,7 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
j = p->ai.num_build_rec; j = p->ai.num_build_rec;
do { do {
if (aib->cur_building_rule == 255) return; if (aib->cur_building_rule == 255) return;
} while (++aib,--j); } while (++aib, --j);
// yep, all are done. switch state. // yep, all are done. switch state.
p->ai.state = AIS_BUILD_AIRCRAFT_VEHICLES; p->ai.state = AIS_BUILD_AIRCRAFT_VEHICLES;
@ -3650,7 +3650,7 @@ pos_3:
} }
} }
} else { } else {
static const byte _depot_bits[] = {0x19,0x16,0x25,0x2A}; static const byte _depot_bits[] = {0x19, 0x16, 0x25, 0x2A};
DiagDirection dir = GetRailDepotDirection(tile); DiagDirection dir = GetRailDepotDirection(tile);
@ -3795,13 +3795,13 @@ static void AiHandleTakeover(Player *p)
// Ask the guy with the highest performance hist. // Ask the guy with the highest performance hist.
FOR_ALL_PLAYERS(pp) { FOR_ALL_PLAYERS(pp) {
if (pp->is_active && if (pp->is_active &&
!(asked&1) && !(asked & 1) &&
pp->bankrupt_asked == 0 && pp->bankrupt_asked == 0 &&
best_val < pp->old_economy[1].performance_history) { best_val < pp->old_economy[1].performance_history) {
best_val = pp->old_economy[1].performance_history; best_val = pp->old_economy[1].performance_history;
best_pl = pp; best_pl = pp;
} }
asked>>=1; asked >>= 1;
} }
// Asked all players? // Asked all players?
@ -3843,7 +3843,7 @@ static void AiAdjustLoan(const Player* p)
// Increase loan // Increase loan
if (p->current_loan < _economy.max_loan && if (p->current_loan < _economy.max_loan &&
p->num_valid_stat_ent >= 2 && p->num_valid_stat_ent >= 2 &&
-(p->old_economy[0].expenses+p->old_economy[1].expenses) < base * 60) { -(p->old_economy[0].expenses + p->old_economy[1].expenses) < base * 60) {
DoCommand(0, 0, 0, DC_EXEC, CMD_INCREASE_LOAN); DoCommand(0, 0, 0, DC_EXEC, CMD_INCREASE_LOAN);
} }
} }
@ -3872,7 +3872,7 @@ void AiDoGameLoop(Player *p)
// to the patch-setting // to the patch-setting
// Also, it takes into account the setting if the service-interval is in days // Also, it takes into account the setting if the service-interval is in days
// or in % // or in %
_ai_service_interval = _patches.servint_ispercent?80:180; _ai_service_interval = _patches.servint_ispercent ? 80 : 180;
if (IsHumanPlayer(_current_player)) return; if (IsHumanPlayer(_current_player)) return;
@ -3883,7 +3883,7 @@ void AiDoGameLoop(Player *p)
{ {
static byte old_state = 99; static byte old_state = 99;
static bool hasdots = false; static bool hasdots = false;
char *_ai_state_names[]={ char *_ai_state_names[] = {
"AiCase0", "AiCase0",
"AiCase1", "AiCase1",
"AiStateVehLoop", "AiStateVehLoop",

View File

@ -123,7 +123,7 @@ int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte fla
} }
// Bridge code // Bridge code
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) { if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
cost += AiNew_Build_Bridge(p, route[part], route[part-1], flag); cost += AiNew_Build_Bridge(p, route[part], route[part - 1], flag);
PathFinderInfo->position++; PathFinderInfo->position++;
// TODO: problems! // TODO: problems!
if (CmdFailed(cost)) { if (CmdFailed(cost)) {
@ -173,7 +173,7 @@ int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte fla
} }
// Bridge code // Bridge code
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) { if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
cost += AiNew_Build_Bridge(p, route[part], route[part+1], flag); cost += AiNew_Build_Bridge(p, route[part], route[part + 1], flag);
PathFinderInfo->position++; PathFinderInfo->position++;
// TODO: problems! // TODO: problems!
if (CmdFailed(cost)) { if (CmdFailed(cost)) {

View File

@ -220,9 +220,9 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
// Check if the rating in a city is high enough // Check if the rating in a city is high enough
// If not, take a chance if we want to continue // If not, take a chance if we want to continue
if (t->ratings[_current_player] < 0 && AI_CHANCE16(1,4)) return false; if (t->ratings[_current_player] < 0 && AI_CHANCE16(1, 4)) return false;
if (t->max_pass - t->act_pass < AI_CHECKCITY_NEEDED_CARGO && !AI_CHANCE16(1,AI_CHECKCITY_CITY_CHANCE)) return false; if (t->max_pass - t->act_pass < AI_CHECKCITY_NEEDED_CARGO && !AI_CHANCE16(1, AI_CHECKCITY_CITY_CHANCE)) return false;
// Check if we have build a station in this town the last 6 months // Check if we have build a station in this town the last 6 months
// else we don't do it. This is done, because stat updates can be slow // else we don't do it. This is done, because stat updates can be slow
@ -275,7 +275,7 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
int count = 0; int count = 0;
int j = 0; int j = 0;
if (i->town != NULL && i->town->ratings[_current_player] < 0 && AI_CHANCE16(1,4)) return false; if (i->town != NULL && i->town->ratings[_current_player] < 0 && AI_CHANCE16(1, 4)) return false;
// No limits on delevering stations! // No limits on delevering stations!
// Or for industry that does not give anything yet // Or for industry that does not give anything yet
@ -642,8 +642,8 @@ static void AiNew_State_FindStation(Player *p)
int r; int r;
uint best; uint best;
uint accepts[NUM_CARGO]; uint accepts[NUM_CARGO];
TileIndex found_spot[AI_FINDSTATION_TILE_RANGE*AI_FINDSTATION_TILE_RANGE*4]; TileIndex found_spot[AI_FINDSTATION_TILE_RANGE*AI_FINDSTATION_TILE_RANGE * 4];
uint found_best[AI_FINDSTATION_TILE_RANGE*AI_FINDSTATION_TILE_RANGE*4]; uint found_best[AI_FINDSTATION_TILE_RANGE*AI_FINDSTATION_TILE_RANGE * 4];
// To find a good spot we scan a range from the center, a get the point // To find a good spot we scan a range from the center, a get the point
// where we get the most cargo and where it is buildable. // where we get the most cargo and where it is buildable.
// TODO: also check for station of myself and make sure we are not // TODO: also check for station of myself and make sure we are not
@ -961,13 +961,13 @@ static void AiNew_State_VerifyRoute(Player *p)
// Now we can build the route, check the direction of the stations! // Now we can build the route, check the direction of the stations!
if (p->ainew.from_direction == AI_PATHFINDER_NO_DIRECTION) { if (p->ainew.from_direction == AI_PATHFINDER_NO_DIRECTION) {
p->ainew.from_direction = AiNew_GetDirection(p->ainew.path_info.route[p->ainew.path_info.route_length-1], p->ainew.path_info.route[p->ainew.path_info.route_length-2]); p->ainew.from_direction = AiNew_GetDirection(p->ainew.path_info.route[p->ainew.path_info.route_length - 1], p->ainew.path_info.route[p->ainew.path_info.route_length - 2]);
} }
if (p->ainew.to_direction == AI_PATHFINDER_NO_DIRECTION) { if (p->ainew.to_direction == AI_PATHFINDER_NO_DIRECTION) {
p->ainew.to_direction = AiNew_GetDirection(p->ainew.path_info.route[0], p->ainew.path_info.route[1]); p->ainew.to_direction = AiNew_GetDirection(p->ainew.path_info.route[0], p->ainew.path_info.route[1]);
} }
if (p->ainew.from_tile == AI_STATION_RANGE) if (p->ainew.from_tile == AI_STATION_RANGE)
p->ainew.from_tile = p->ainew.path_info.route[p->ainew.path_info.route_length-1]; p->ainew.from_tile = p->ainew.path_info.route[p->ainew.path_info.route_length - 1];
if (p->ainew.to_tile == AI_STATION_RANGE) if (p->ainew.to_tile == AI_STATION_RANGE)
p->ainew.to_tile = p->ainew.path_info.route[0]; p->ainew.to_tile = p->ainew.path_info.route[0];

View File

@ -105,7 +105,7 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
w = FindWindowById(WC_BUILD_STATION, 0); w = FindWindowById(WC_BUILD_STATION, 0);
if (w != 0) if (w != 0)
WP(w,def_d).close = true; WP(w, def_d).close = true;
break; break;
case WE_DESTROY: case WE_DESTROY:
@ -155,7 +155,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
uint32 avail_airports; uint32 avail_airports;
const AirportFTAClass *airport; const AirportFTAClass *airport;
if (WP(w,def_d).close) return; if (WP(w, def_d).close) return;
avail_airports = GetValidAirports(); avail_airports = GetValidAirports();
@ -207,7 +207,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
} break; } break;
case WE_MOUSELOOP: { case WE_MOUSELOOP: {
if (WP(w,def_d).close) { if (WP(w, def_d).close) {
DeleteWindow(w); DeleteWindow(w);
return; return;
} }
@ -216,7 +216,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
} break; } break;
case WE_DESTROY: case WE_DESTROY:
if (!WP(w,def_d).close) ResetObjectToPlace(); if (!WP(w, def_d).close) ResetObjectToPlace();
break; break;
} }
} }

View File

@ -137,7 +137,7 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type)
/* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */ /* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */
if (v->cargo_type == new_cargo_type) return CT_NO_REFIT; if (v->cargo_type == new_cargo_type) return CT_NO_REFIT;
if (CanRefitTo(engine_type, v->cargo_type)) return v->cargo_type; if (CanRefitTo(engine_type, v->cargo_type)) return v->cargo_type;
} while ((v=v->next) != NULL); } while ((v = v->next) != NULL);
return CT_NO_REFIT; // We failed to find a cargo type on the old vehicle and we will not refit the new one return CT_NO_REFIT; // We failed to find a cargo type on the old vehicle and we will not refit the new one
} }

View File

@ -312,19 +312,19 @@ static EngList_SortTypeFunction * const _sorter[][9] = {{
&TrainEngineRunningCostSorter, &TrainEngineRunningCostSorter,
&TrainEnginePowerVsRunningCostSorter, &TrainEnginePowerVsRunningCostSorter,
&EngineReliabilitySorter, &EngineReliabilitySorter,
},{ }, {
/* Road vehicles */ /* Road vehicles */
&EngineNumberSorter, &EngineNumberSorter,
&EngineIntroDateSorter, &EngineIntroDateSorter,
&EngineNameSorter, &EngineNameSorter,
&EngineReliabilitySorter, &EngineReliabilitySorter,
},{ }, {
/* Ships */ /* Ships */
&EngineNumberSorter, &EngineNumberSorter,
&EngineIntroDateSorter, &EngineIntroDateSorter,
&EngineNameSorter, &EngineNameSorter,
&EngineReliabilitySorter, &EngineReliabilitySorter,
},{ }, {
/* Aircraft */ /* Aircraft */
&EngineNumberSorter, &EngineNumberSorter,
&AircraftEngineCostSorter, &AircraftEngineCostSorter,
@ -348,21 +348,21 @@ static const StringID _sort_listing[][10] = {{
STR_ENGINE_SORT_POWER_VS_RUNNING_COST, STR_ENGINE_SORT_POWER_VS_RUNNING_COST,
STR_SORT_BY_RELIABILITY, STR_SORT_BY_RELIABILITY,
INVALID_STRING_ID INVALID_STRING_ID
},{ }, {
/* Road vehicles */ /* Road vehicles */
STR_ENGINE_SORT_ENGINE_ID, STR_ENGINE_SORT_ENGINE_ID,
STR_ENGINE_SORT_INTRO_DATE, STR_ENGINE_SORT_INTRO_DATE,
STR_SORT_BY_DROPDOWN_NAME, STR_SORT_BY_DROPDOWN_NAME,
STR_SORT_BY_RELIABILITY, STR_SORT_BY_RELIABILITY,
INVALID_STRING_ID INVALID_STRING_ID
},{ }, {
/* Ships */ /* Ships */
STR_ENGINE_SORT_ENGINE_ID, STR_ENGINE_SORT_ENGINE_ID,
STR_ENGINE_SORT_INTRO_DATE, STR_ENGINE_SORT_INTRO_DATE,
STR_SORT_BY_DROPDOWN_NAME, STR_SORT_BY_DROPDOWN_NAME,
STR_SORT_BY_RELIABILITY, STR_SORT_BY_RELIABILITY,
INVALID_STRING_ID INVALID_STRING_ID
},{ }, {
/* Aircraft */ /* Aircraft */
STR_ENGINE_SORT_ENGINE_ID, STR_ENGINE_SORT_ENGINE_ID,
STR_ENGINE_SORT_COST, STR_ENGINE_SORT_COST,
@ -392,7 +392,7 @@ static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const
/* Wagon speed limit, displayed if above zero */ /* Wagon speed limit, displayed if above zero */
if (rvi->max_speed > 0 && _patches.wagon_speed_limits) { if (rvi->max_speed > 0 && _patches.wagon_speed_limits) {
SetDParam(0, rvi->max_speed * 10 / 16); SetDParam(0, rvi->max_speed * 10 / 16);
DrawString(x,y, STR_PURCHASE_INFO_SPEED, 0); DrawString(x, y, STR_PURCHASE_INFO_SPEED, 0);
y += 10; y += 10;
} }
return y; return y;
@ -406,13 +406,13 @@ static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, cons
/* Purchase Cost - Engine weight */ /* Purchase Cost - Engine weight */
SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5); SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5);
SetDParam(1, rvi->weight << multihead); SetDParam(1, rvi->weight << multihead);
DrawString(x,y, STR_PURCHASE_INFO_COST_WEIGHT, 0); DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, 0);
y += 10; y += 10;
/* Max speed - Engine power */ /* Max speed - Engine power */
SetDParam(0, rvi->max_speed * 10 / 16); SetDParam(0, rvi->max_speed * 10 / 16);
SetDParam(1, rvi->power << multihead); SetDParam(1, rvi->power << multihead);
DrawString(x,y, STR_PURCHASE_INFO_SPEED_POWER, 0); DrawString(x, y, STR_PURCHASE_INFO_SPEED_POWER, 0);
y += 10; y += 10;
/* Max tractive effort - not applicable if old acceleration or maglev */ /* Max tractive effort - not applicable if old acceleration or maglev */
@ -424,14 +424,14 @@ static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, cons
/* Running cost */ /* Running cost */
SetDParam(0, (rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8) << multihead); SetDParam(0, (rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8) << multihead);
DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
y += 10; y += 10;
/* Powered wagons power - Powered wagons extra weight */ /* Powered wagons power - Powered wagons extra weight */
if (rvi->pow_wag_power != 0) { if (rvi->pow_wag_power != 0) {
SetDParam(0, rvi->pow_wag_power); SetDParam(0, rvi->pow_wag_power);
SetDParam(1, rvi->pow_wag_weight); SetDParam(1, rvi->pow_wag_weight);
DrawString(x,y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT, 0); DrawString(x, y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT, 0);
y += 10; y += 10;
}; };
@ -444,7 +444,7 @@ static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const R
bool refittable = (_engine_info[engine_number].refit_mask != 0); bool refittable = (_engine_info[engine_number].refit_mask != 0);
/* Purchase cost - Max speed */ /* Purchase cost - Max speed */
SetDParam(0, rvi->base_cost * (_price.roadveh_base>>3)>>5); SetDParam(0, rvi->base_cost * (_price.roadveh_base >> 3) >> 5);
SetDParam(1, rvi->max_speed * 10 / 32); SetDParam(1, rvi->max_speed * 10 / 32);
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0);
y += 10; y += 10;
@ -468,21 +468,21 @@ static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const R
static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi) static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi)
{ {
/* Purchase cost - Max speed */ /* Purchase cost - Max speed */
SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5); SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5);
SetDParam(1, svi->max_speed * 10 / 32); SetDParam(1, svi->max_speed * 10 / 32);
DrawString(x,y, STR_PURCHASE_INFO_COST_SPEED, 0); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0);
y += 10; y += 10;
/* Cargo type + capacity */ /* Cargo type + capacity */
SetDParam(0, svi->cargo_type); SetDParam(0, svi->cargo_type);
SetDParam(1, svi->capacity); SetDParam(1, svi->capacity);
SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY); SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY);
DrawString(x,y, STR_PURCHASE_INFO_CAPACITY, 0); DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
y += 10; y += 10;
/* Running cost */ /* Running cost */
SetDParam(0, svi->running_cost * _price.ship_running >> 8); SetDParam(0, svi->running_cost * _price.ship_running >> 8);
DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
y += 10; y += 10;
return y; return y;
@ -494,7 +494,7 @@ static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const
CargoID cargo; CargoID cargo;
/* Purchase cost - Max speed */ /* Purchase cost - Max speed */
SetDParam(0, avi->base_cost * (_price.aircraft_base>>3)>>5); SetDParam(0, avi->base_cost * (_price.aircraft_base >> 3) >> 5);
SetDParam(1, avi->max_speed * 10 / 16); SetDParam(1, avi->max_speed * 10 / 16);
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0);
y += 10; y += 10;
@ -560,7 +560,7 @@ int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
SetDParam(1, (rvi->capacity * (CountArticulatedParts(engine_number) + 1)) << multihead); SetDParam(1, (rvi->capacity * (CountArticulatedParts(engine_number) + 1)) << multihead);
SetDParam(2, refitable ? STR_9842_REFITTABLE : STR_EMPTY); SetDParam(2, refitable ? STR_9842_REFITTABLE : STR_EMPTY);
} }
DrawString(x,y, STR_PURCHASE_INFO_CAPACITY, 0); DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
y += 10; y += 10;
} }
break; break;
@ -1001,7 +1001,7 @@ void ShowBuildVehicleWindow(TileIndex tile, byte type)
switch (type) { switch (type) {
case VEH_TRAIN: case VEH_TRAIN:
WP(w,buildvehicle_d).filter.railtype = (tile == 0) ? RAILTYPE_END : GetRailType(tile); WP(w, buildvehicle_d).filter.railtype = (tile == 0) ? RAILTYPE_END : GetRailType(tile);
ResizeWindow(w, 0, 16); ResizeWindow(w, 0, 16);
break; break;
case VEH_ROAD: case VEH_ROAD:

View File

@ -79,7 +79,7 @@ static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
if (count >= 625) return; if (count >= 625) return;
for (t = ts->tile_table; count != 0; count--,t++) { for (t = ts->tile_table; count != 0; count--, t++) {
if (*t == tile) return; if (*t == tile) return;
} }
@ -141,7 +141,7 @@ static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode)
} }
} }
ret = DoCommand(tile, 0,0, ts->flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR); ret = DoCommand(tile, 0, 0, ts->flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) { if (CmdFailed(ret)) {
_terraform_err_tile = tile; _terraform_err_tile = tile;
@ -215,8 +215,8 @@ static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height
tile += ToTileIndexDiff(*ttm); tile += ToTileIndexDiff(*ttm);
r = TerraformGetHeightOfTile(ts, tile); r = TerraformGetHeightOfTile(ts, tile);
if (r != height && r-direction != height && r+direction != height) { if (r != height && r - direction != height && r + direction != height) {
if (!TerraformTileHeight(ts, tile, r+direction)) if (!TerraformTileHeight(ts, tile, r + direction))
return false; return false;
} }
} }
@ -382,8 +382,8 @@ int32 CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (ey < sy) Swap(ey, sy); if (ey < sy) Swap(ey, sy);
tile = TileXY(sx, sy); tile = TileXY(sx, sy);
size_x = ex-sx+1; size_x = ex - sx + 1;
size_y = ey-sy+1; size_y = ey - sy + 1;
money = GetAvailableMoneyForCommand(); money = GetAvailableMoneyForCommand();
cost = 0; cost = 0;

View File

@ -407,7 +407,7 @@ int32 GetAvailableMoneyForCommand()
* the callback is called when the command succeeded or failed. */ * the callback is called when the command succeeded or failed. */
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd) bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd)
{ {
int32 res = 0,res2; int32 res = 0, res2;
CommandProc *proc; CommandProc *proc;
uint32 flags; uint32 flags;
bool notest; bool notest;
@ -544,7 +544,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
if (res2 != 0) ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2); if (res2 != 0) ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2);
if (_additional_cash_required) { if (_additional_cash_required) {
SetDParam(0, _additional_cash_required); SetDParam(0, _additional_cash_required);
ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, error_part1, x,y); ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, error_part1, x, y);
if (res2 == 0) goto callb_err; if (res2 == 0) goto callb_err;
} }
} }
@ -558,7 +558,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
show_error: show_error:
/* show error message if the command fails? */ /* show error message if the command fails? */
if (IsLocalPlayer() && error_part1 != 0) { if (IsLocalPlayer() && error_part1 != 0) {
ShowErrorMessage(_error_message, error_part1, x,y); ShowErrorMessage(_error_message, error_part1, x, y);
} }
callb_err: callb_err:

View File

@ -158,7 +158,7 @@ enum {
CMD_ERROR = ((int32)0x80000000), CMD_ERROR = ((int32)0x80000000),
}; };
#define CMD_MSG(x) ((x)<<16) #define CMD_MSG(x) ((x) << 16)
enum { enum {
CMD_AUTO = 0x0200, CMD_AUTO = 0x0200,

View File

@ -233,7 +233,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
SetDParam(0, GetStationIndex(tile)); SetDParam(0, GetStationIndex(tile));
AddNewsItem(STR_B000_ZEPPELIN_DISASTER_AT, AddNewsItem(STR_B000_ZEPPELIN_DISASTER_AT,
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0), NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
v->index, v->index,
0); 0);
} }
@ -263,7 +263,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
x = v->x_pos; x = v->x_pos;
y = v->y_pos; y = v->y_pos;
z = GetSlopeZ(x,y); z = GetSlopeZ(x, y);
if (z < v->z_pos) z = v->z_pos - 1; if (z < v->z_pos) z = v->z_pos - 1;
SetDisasterVehiclePos(v, x, y, z); SetDisasterVehiclePos(v, x, y, z);
@ -359,14 +359,14 @@ static void DisasterTick_Ufo(Vehicle *v)
if (dist <= TILE_SIZE && z > u->z_pos) z--; if (dist <= TILE_SIZE && z > u->z_pos) z--;
SetDisasterVehiclePos(v, gp.x, gp.y, z); SetDisasterVehiclePos(v, gp.x, gp.y, z);
if (z <= u->z_pos && (u->vehstatus & VS_HIDDEN)==0) { if (z <= u->z_pos && (u->vehstatus & VS_HIDDEN) == 0) {
v->age++; v->age++;
if (u->u.road.crashed_ctr == 0) { if (u->u.road.crashed_ctr == 0) {
u->u.road.crashed_ctr++; u->u.road.crashed_ctr++;
u->vehstatus |= VS_CRASHED; u->vehstatus |= VS_CRASHED;
AddNewsItem(STR_B001_ROAD_VEHICLE_DESTROYED, AddNewsItem(STR_B001_ROAD_VEHICLE_DESTROYED,
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0), NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
u->index, u->index,
0); 0);
} }
@ -441,7 +441,7 @@ static void DisasterTick_Airplane(Vehicle *v)
DestructIndustry(i); DestructIndustry(i);
SetDParam(0, i->town->index); SetDParam(0, i->town->index);
AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0); AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0), i->xy, 0);
SndPlayTileFx(SND_12_EXPLOSION, i->xy); SndPlayTileFx(SND_12_EXPLOSION, i->xy);
} }
} else if (v->current_order.dest == 0) { } else if (v->current_order.dest == 0) {
@ -514,7 +514,7 @@ static void DisasterTick_Helicopter(Vehicle *v)
DestructIndustry(i); DestructIndustry(i);
SetDParam(0, i->town->index); SetDParam(0, i->town->index);
AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0); AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0), i->xy, 0);
SndPlayTileFx(SND_12_EXPLOSION, i->xy); SndPlayTileFx(SND_12_EXPLOSION, i->xy);
} }
} else if (v->current_order.dest == 0) { } else if (v->current_order.dest == 0) {
@ -600,7 +600,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v)
t = ClosestTownFromTile(v->dest_tile, (uint)-1); t = ClosestTownFromTile(v->dest_tile, (uint)-1);
SetDParam(0, t->index); SetDParam(0, t->index);
AddNewsItem(STR_B004_UFO_LANDS_NEAR, AddNewsItem(STR_B004_UFO_LANDS_NEAR,
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_ACCIDENT, 0), NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0),
v->tile, v->tile,
0); 0);
@ -951,7 +951,7 @@ static void Disaster_Small_Submarine_Init()
static void Disaster_Big_Submarine_Init() static void Disaster_Big_Submarine_Init()
{ {
Vehicle *v = ForceAllocateSpecialVehicle(); Vehicle *v = ForceAllocateSpecialVehicle();
int x,y; int x, y;
Direction dir; Direction dir;
uint32 r; uint32 r;
@ -986,7 +986,7 @@ static void Disaster_CoalMine_Init()
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) { if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
SetDParam(0, i->town->index); SetDParam(0, i->town->index);
AddNewsItem(STR_B005_COAL_MINE_SUBSIDENCE_LEAVES, AddNewsItem(STR_B005_COAL_MINE_SUBSIDENCE_LEAVES,
NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy + TileDiffXY(1, 1), 0); NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0), i->xy + TileDiffXY(1, 1), 0);
{ {
TileIndex tile = i->xy; TileIndex tile = i->xy;

View File

@ -165,10 +165,10 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
RaiseWindowButtons(w); RaiseWindowButtons(w);
w = FindWindowById(WC_BUILD_STATION, 0); w = FindWindowById(WC_BUILD_STATION, 0);
if (w != NULL) WP(w,def_d).close = true; if (w != NULL) WP(w, def_d).close = true;
w = FindWindowById(WC_BUILD_DEPOT, 0); w = FindWindowById(WC_BUILD_DEPOT, 0);
if (w != NULL) WP(w,def_d).close = true; if (w != NULL) WP(w, def_d).close = true;
break; break;
case WE_PLACE_PRESIZE: { case WE_PLACE_PRESIZE: {
@ -233,7 +233,7 @@ static void BuildDockStationWndProc(Window *w, WindowEvent *e)
case WE_PAINT: { case WE_PAINT: {
int rad; int rad;
if (WP(w,def_d).close) return; if (WP(w, def_d).close) return;
DrawWindowWidgets(w); DrawWindowWidgets(w);
rad = (_patches.modified_catchment) ? CA_DOCK : 4; rad = (_patches.modified_catchment) ? CA_DOCK : 4;
@ -258,7 +258,7 @@ static void BuildDockStationWndProc(Window *w, WindowEvent *e)
break; break;
case WE_MOUSELOOP: case WE_MOUSELOOP:
if (WP(w,def_d).close) { if (WP(w, def_d).close) {
DeleteWindow(w); DeleteWindow(w);
return; return;
} }
@ -267,7 +267,7 @@ static void BuildDockStationWndProc(Window *w, WindowEvent *e)
break; break;
case WE_DESTROY: case WE_DESTROY:
if (!WP(w,def_d).close) ResetObjectToPlace(); if (!WP(w, def_d).close) ResetObjectToPlace();
break; break;
} }
} }
@ -333,11 +333,11 @@ static void BuildDocksDepotWndProc(Window *w, WindowEvent *e)
} break; } break;
case WE_MOUSELOOP: case WE_MOUSELOOP:
if (WP(w,def_d).close) DeleteWindow(w); if (WP(w, def_d).close) DeleteWindow(w);
break; break;
case WE_DESTROY: case WE_DESTROY:
if (!WP(w,def_d).close) ResetObjectToPlace(); if (!WP(w, def_d).close) ResetObjectToPlace();
break; break;
} }
} }

View File

@ -201,7 +201,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int color)
static void GfxSetPixel(int x, int y, int color) static void GfxSetPixel(int x, int y, int color)
{ {
const DrawPixelInfo* dpi = _cur_dpi; const DrawPixelInfo* dpi = _cur_dpi;
if ((x-=dpi->left) < 0 || x>=dpi->width || (y-=dpi->top)<0 || y>=dpi->height) if ((x -= dpi->left) < 0 || x >= dpi->width || (y -= dpi->top)<0 || y >= dpi->height)
return; return;
dpi->dst_ptr[y * dpi->pitch + x] = color; dpi->dst_ptr[y * dpi->pitch + x] = color;
} }
@ -461,7 +461,7 @@ uint32 FormatStringLinebreaks(char *str, int maxw)
switch (c) { switch (c) {
case '\0': return num + (size << 16); break; case '\0': return num + (size << 16); break;
case SCC_SETX: str++; break; case SCC_SETX: str++; break;
case SCC_SETXY: str +=2; break; case SCC_SETXY: str += 2; break;
case SCC_TINYFONT: size = FS_SMALL; break; case SCC_TINYFONT: size = FS_SMALL; break;
case SCC_BIGFONT: size = FS_LARGE; break; case SCC_BIGFONT: size = FS_LARGE; break;
case '\n': goto end_of_inner_loop; case '\n': goto end_of_inner_loop;
@ -509,7 +509,7 @@ void DrawStringMultiCenter(int x, int y, StringID str, int maxw)
for (;;) { for (;;) {
w = GetStringBoundingBox(src).width; w = GetStringBoundingBox(src).width;
DoDrawString(src, x - (w>>1), y, 0xFE); DoDrawString(src, x - (w >> 1), y, 0xFE);
_cur_fontsize = _last_fontsize; _cur_fontsize = _last_fontsize;
for (;;) { for (;;) {
@ -524,7 +524,7 @@ void DrawStringMultiCenter(int x, int y, StringID str, int maxw)
} else if (c == SCC_SETX) { } else if (c == SCC_SETX) {
src++; src++;
} else if (c == SCC_SETXY) { } else if (c == SCC_SETXY) {
src+=2; src += 2;
} }
} }
} }
@ -574,7 +574,7 @@ uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh)
} else if (c == SCC_SETX) { } else if (c == SCC_SETX) {
src++; src++;
} else if (c == SCC_SETXY) { } else if (c == SCC_SETXY) {
src+=2; src += 2;
} }
} }
} }
@ -643,7 +643,7 @@ int DoDrawString(const char *string, int x, int y, uint16 real_color)
if (color != 0xFE) { if (color != 0xFE) {
if (x >= dpi->left + dpi->width || if (x >= dpi->left + dpi->width ||
x + _screen.width*2 <= dpi->left || x + _screen.width * 2 <= dpi->left ||
y >= dpi->top + dpi->height || y >= dpi->top + dpi->height ||
y + _screen.height <= dpi->top) y + _screen.height <= dpi->top)
return x; return x;

View File

@ -222,7 +222,7 @@ static void DrawGraph(const GraphDrawer *gw)
y = gw->top + x_axis_offset - (x_axis_offset * datapoint) / highest_value; y = gw->top + x_axis_offset - (x_axis_offset * datapoint) / highest_value;
/* Draw the point. */ /* Draw the point. */
GfxFillRect(x-1, y-1, x+1, y+1, color); GfxFillRect(x - 1, y - 1, x + 1, y + 1, color);
/* Draw the line connected to the previous point. */ /* Draw the line connected to the previous point. */
if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, color); if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, color);
@ -268,7 +268,7 @@ static void GraphLegendWndProc(Window *w, WindowEvent *e)
FOR_ALL_PLAYERS(p) { FOR_ALL_PLAYERS(p) {
if (!p->is_active) continue; if (!p->is_active) continue;
DrawPlayerIcon(p->index, 4, 18+p->index*12); DrawPlayerIcon(p->index, 4, 18 + p->index * 12);
SetDParam(0, p->name_1); SetDParam(0, p->name_1);
SetDParam(1, p->name_2); SetDParam(1, p->name_2);
@ -330,7 +330,7 @@ static void SetupGraphDrawerForPlayers(GraphDrawer *gd)
const Player* p; const Player* p;
uint excluded_players = _legend_excluded_players; uint excluded_players = _legend_excluded_players;
byte nums; byte nums;
int mo,yr; int mo, yr;
/* Exclude the players which aren't valid */ /* Exclude the players which aren't valid */
FOR_ALL_PLAYERS(p) { FOR_ALL_PLAYERS(p) {
@ -908,7 +908,7 @@ static const WindowDesc _company_league_desc = {
void ShowCompanyLeagueTable() void ShowCompanyLeagueTable()
{ {
AllocateWindowDescFront(&_company_league_desc,0); AllocateWindowDescFront(&_company_league_desc, 0);
} }
/*****************************/ /*****************************/

View File

@ -69,7 +69,7 @@ IndustryType GetIndustryType(TileIndex tile)
for (iloop = IT_COAL_MINE; iloop < IT_END; iloop += 1) { for (iloop = IT_COAL_MINE; iloop < IT_END; iloop += 1) {
if (IS_BYTE_INSIDE(this_type, industry_gfx_Solver[iloop].MinGfx, if (IS_BYTE_INSIDE(this_type, industry_gfx_Solver[iloop].MinGfx,
industry_gfx_Solver[iloop].MaxGfx+1)) { industry_gfx_Solver[iloop].MaxGfx + 1)) {
return iloop; return iloop;
} }
} }
@ -496,7 +496,7 @@ static void AnimateTile_Industry(TileIndex tile)
case GFX_OILWELL_ANIMATED_2: case GFX_OILWELL_ANIMATED_2:
case GFX_OILWELL_ANIMATED_3: case GFX_OILWELL_ANIMATED_3:
if ((_tick_counter & 7) == 0) { if ((_tick_counter & 7) == 0) {
bool b = CHANCE16(1,7); bool b = CHANCE16(1, 7);
IndustryGfx gfx = GetIndustryGfx(tile); IndustryGfx gfx = GetIndustryGfx(tile);
m = GetIndustryAnimationState(tile) + 1; m = GetIndustryAnimationState(tile) + 1;
@ -705,7 +705,7 @@ static void TileLoop_Industry(TileIndex tile)
break; break;
case GFX_POWERPLANT_SPARKS: case GFX_POWERPLANT_SPARKS:
if (CHANCE16(1,3)) { if (CHANCE16(1, 3)) {
SndPlayTileFx(SND_0C_ELECTRIC_SPARK, tile); SndPlayTileFx(SND_0C_ELECTRIC_SPARK, tile);
AddAnimatedTile(tile); AddAnimatedTile(tile);
} }
@ -964,7 +964,7 @@ static void ProduceIndustryGoods(Industry *i)
/* play a sound? */ /* play a sound? */
if ((i->counter & 0x3F) == 0) { if ((i->counter & 0x3F) == 0) {
if (CHANCE16R(1,14,r) && (num=_industry_sounds[i->type][0]) != 0) { if (CHANCE16R(1, 14, r) && (num = _industry_sounds[i->type][0]) != 0) {
SndPlayTileFx( SndPlayTileFx(
(SoundFx)(_industry_sounds[i->type][1] + (((r >> 16) * num) >> 16)), (SoundFx)(_industry_sounds[i->type][1] + (((r >> 16) * num) >> 16)),
i->xy); i->xy);
@ -1668,7 +1668,7 @@ static void ExtChangeIndustryProduction(Industry *i)
SetDParam(1, i->index); SetDParam(1, i->index);
AddNewsItem( AddNewsItem(
percent >= 0 ? STR_INDUSTRY_PROD_GOUP : STR_INDUSTRY_PROD_GODOWN, percent >= 0 ? STR_INDUSTRY_PROD_GOUP : STR_INDUSTRY_PROD_GODOWN,
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_ECONOMY, 0), NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ECONOMY, 0),
i->xy + TileDiffXY(1, 1), 0 i->xy + TileDiffXY(1, 1), 0
); );
} }
@ -1682,7 +1682,7 @@ static void ExtChangeIndustryProduction(Industry *i)
SetDParam(0, i->index); SetDParam(0, i->index);
AddNewsItem( AddNewsItem(
indspec->closure_text, indspec->closure_text,
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_OPENCLOSE, 0), NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, 0),
i->xy + TileDiffXY(1, 1), 0 i->xy + TileDiffXY(1, 1), 0
); );
} }
@ -1698,7 +1698,7 @@ static void UpdateIndustryStatistics(Industry *i)
pct = 0; pct = 0;
if (i->last_mo_production[0] != 0) { if (i->last_mo_production[0] != 0) {
i->last_prod_year = _cur_year; i->last_prod_year = _cur_year;
pct = min(i->last_mo_transported[0] * 256 / i->last_mo_production[0],255); pct = min(i->last_mo_transported[0] * 256 / i->last_mo_production[0], 255);
} }
i->pct_transported[0] = pct; i->pct_transported[0] = pct;
@ -1714,7 +1714,7 @@ static void UpdateIndustryStatistics(Industry *i)
pct = 0; pct = 0;
if (i->last_mo_production[1] != 0) { if (i->last_mo_production[1] != 0) {
i->last_prod_year = _cur_year; i->last_prod_year = _cur_year;
pct = min(i->last_mo_transported[1] * 256 / i->last_mo_production[1],255); pct = min(i->last_mo_transported[1] * 256 / i->last_mo_production[1], 255);
} }
i->pct_transported[1] = pct; i->pct_transported[1] = pct;
@ -1791,7 +1791,7 @@ static void MaybeNewIndustry(void)
SetDParam(0, ind_spc->name); SetDParam(0, ind_spc->name);
SetDParam(1, ind->town->index); SetDParam(1, ind->town->index);
AddNewsItem(ind_spc->new_industry_text, AddNewsItem(ind_spc->new_industry_text,
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_OPENCLOSE, 0), ind->xy, 0); NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, 0), ind->xy, 0);
} }
static void ChangeIndustryProduction(Industry *i) static void ChangeIndustryProduction(Industry *i)
@ -1810,9 +1810,9 @@ static void ChangeIndustryProduction(Industry *i)
if ((indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) && _opt.landscape == LT_TEMPERATE) if ((indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) && _opt.landscape == LT_TEMPERATE)
only_decrease = true; only_decrease = true;
if (only_decrease || CHANCE16(1,3)) { if (only_decrease || CHANCE16(1, 3)) {
/* If you transport > 60%, 66% chance we increase, else 33% chance we increase */ /* If you transport > 60%, 66% chance we increase, else 33% chance we increase */
if (!only_decrease && (i->pct_transported[0] > 153) != CHANCE16(1,3)) { if (!only_decrease && (i->pct_transported[0] > 153) != CHANCE16(1, 3)) {
/* Increase production */ /* Increase production */
if (i->prod_level != 0x80) { if (i->prod_level != 0x80) {
byte b; byte b;
@ -1849,7 +1849,7 @@ static void ChangeIndustryProduction(Industry *i)
case INDUSTRYLIFE_CLOSABLE: case INDUSTRYLIFE_CLOSABLE:
/* maybe close */ /* maybe close */
if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1,2)) { if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1, 2)) {
i->prod_level = 0; i->prod_level = 0;
str = indspec->closure_text; str = indspec->closure_text;
} }
@ -1858,7 +1858,7 @@ static void ChangeIndustryProduction(Industry *i)
if (str != STR_NULL) { if (str != STR_NULL) {
SetDParam(0, i->index); SetDParam(0, i->index);
AddNewsItem(str, NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, str == indspec->closure_text ? NT_OPENCLOSE : NT_ECONOMY, 0), i->xy + TileDiffXY(1, 1), 0); AddNewsItem(str, NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, str == indspec->closure_text ? NT_OPENCLOSE : NT_ECONOMY, 0), i->xy + TileDiffXY(1, 1), 0);
} }
} }

View File

@ -37,7 +37,7 @@ static void BuildIndustryWndProc(Window *w, WindowEvent *e)
case WE_PAINT: case WE_PAINT:
DrawWindowWidgets(w); DrawWindowWidgets(w);
if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) { if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) {
int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1]; int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w, def_d).data_1];
SetDParam(0, (_price.build_industry >> 5) * GetIndustrySpec(ind_type)->cost_multiplier); SetDParam(0, (_price.build_industry >> 5) * GetIndustrySpec(ind_type)->cost_multiplier);
DrawStringCentered(85, w->height - 21, STR_482F_COST, 0); DrawStringCentered(85, w->height - 21, STR_482F_COST, 0);
@ -48,12 +48,12 @@ static void BuildIndustryWndProc(Window *w, WindowEvent *e)
int wid = e->we.click.widget; int wid = e->we.click.widget;
if (wid >= 3) { if (wid >= 3) {
if (HandlePlacePushButton(w, wid, SPR_CURSOR_INDUSTRY, 1, NULL)) if (HandlePlacePushButton(w, wid, SPR_CURSOR_INDUSTRY, 1, NULL))
WP(w,def_d).data_1 = wid - 3; WP(w, def_d).data_1 = wid - 3;
} }
} break; } break;
case WE_PLACE_OBJ: case WE_PLACE_OBJ:
if (DoCommandP(e->we.place.tile, _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY))) if (DoCommandP(e->we.place.tile, _build_industry_types[_opt_ptr->landscape][WP(w, def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)))
ResetObjectToPlace(); ResetObjectToPlace();
break; break;
@ -274,7 +274,7 @@ static const WindowDesc * const _industry_window_desc[2][4] = {
void ShowBuildIndustryWindow() void ShowBuildIndustryWindow()
{ {
if (!IsValidPlayer(_current_player)) return; if (!IsValidPlayer(_current_player)) return;
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0); AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape], 0);
} }
static inline bool isProductionMinimum(const Industry *i, int pt) { static inline bool isProductionMinimum(const Industry *i, int pt) {
@ -330,7 +330,7 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0); DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0);
/* Let's put out those buttons.. */ /* Let's put out those buttons.. */
if (IsProductionAlterable(i)) { if (IsProductionAlterable(i)) {
DrawArrowButtons(5, 127, 3, (WP(w,vp2_d).data_2 == 1) ? WP(w,vp2_d).data_3 : 0, DrawArrowButtons(5, 127, 3, (WP(w, vp2_d).data_2 == 1) ? WP(w, vp2_d).data_3 : 0,
!isProductionMinimum(i, 0), !isProductionMaximum(i, 0)); !isProductionMinimum(i, 0), !isProductionMaximum(i, 0));
} }
@ -341,7 +341,7 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0); DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
/* Let's put out those buttons.. */ /* Let's put out those buttons.. */
if (IsProductionAlterable(i)) { if (IsProductionAlterable(i)) {
DrawArrowButtons(5, 137, 3, (WP(w,vp2_d).data_2 == 2) ? WP(w,vp2_d).data_3 : 0, DrawArrowButtons(5, 137, 3, (WP(w, vp2_d).data_2 == 2) ? WP(w, vp2_d).data_3 : 0,
!isProductionMinimum(i, 1), !isProductionMaximum(i, 1)); !isProductionMinimum(i, 1), !isProductionMaximum(i, 1));
} }
} }
@ -379,11 +379,11 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
UpdateIndustryProduction(i); UpdateIndustryProduction(i);
SetWindowDirty(w); SetWindowDirty(w);
w->flags4 |= 5 << WF_TIMEOUT_SHL; w->flags4 |= 5 << WF_TIMEOUT_SHL;
WP(w,vp2_d).data_2 = line+1; WP(w, vp2_d).data_2 = line + 1;
WP(w,vp2_d).data_3 = (x < 15 ? 1 : 2); WP(w, vp2_d).data_3 = (x < 15 ? 1 : 2);
} else if (IS_INT_INSIDE(x, 34, 160)) { } else if (IS_INT_INSIDE(x, 34, 160)) {
/* clicked the text */ /* clicked the text */
WP(w,vp2_d).data_1 = line; WP(w, vp2_d).data_1 = line;
SetDParam(0, i->production_rate[line] * 8); SetDParam(0, i->production_rate[line] * 8);
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_GAME_PRODUCTION, 10, 100, w, CS_ALPHANUMERAL); ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_GAME_PRODUCTION, 10, 100, w, CS_ALPHANUMERAL);
} }
@ -397,15 +397,15 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
} }
break; break;
case WE_TIMEOUT: case WE_TIMEOUT:
WP(w,vp2_d).data_2 = 0; WP(w, vp2_d).data_2 = 0;
WP(w,vp2_d).data_3 = 0; WP(w, vp2_d).data_3 = 0;
SetWindowDirty(w); SetWindowDirty(w);
break; break;
case WE_ON_EDIT_TEXT: case WE_ON_EDIT_TEXT:
if (e->we.edittext.str[0] != '\0') { if (e->we.edittext.str[0] != '\0') {
Industry* i = GetIndustry(w->window_number); Industry* i = GetIndustry(w->window_number);
int line = WP(w,vp2_d).data_1; int line = WP(w, vp2_d).data_1;
i->production_rate[line] = clampu(atoi(e->we.edittext.str), 0, 255); i->production_rate[line] = clampu(atoi(e->we.edittext.str), 0, 255);
UpdateIndustryProduction(i); UpdateIndustryProduction(i);
@ -449,9 +449,9 @@ void ShowIndustryViewWindow(int industry)
if (w != NULL) { if (w != NULL) {
w->flags4 |= WF_DISABLE_VP_SCROLL; w->flags4 |= WF_DISABLE_VP_SCROLL;
WP(w,vp2_d).data_1 = 0; WP(w, vp2_d).data_1 = 0;
WP(w,vp2_d).data_2 = 0; WP(w, vp2_d).data_2 = 0;
WP(w,vp2_d).data_3 = 0; WP(w, vp2_d).data_3 = 0;
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetIndustry(w->window_number)->xy + TileDiffXY(1, 1), 1); AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetIndustry(w->window_number)->xy + TileDiffXY(1, 1), 1);
} }
} }
@ -599,7 +599,7 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
SetVScrollCount(w, _num_industry_sort); SetVScrollCount(w, _num_industry_sort);
DrawWindowWidgets(w); DrawWindowWidgets(w);
DoDrawString(_industry_sort_order & 1 ? DOWNARROW : UPARROW, _indicator_positions[_industry_sort_order>>1], 15, 0x10); DoDrawString(_industry_sort_order & 1 ? DOWNARROW : UPARROW, _indicator_positions[_industry_sort_order >> 1], 15, 0x10);
p = w->vscroll.pos; p = w->vscroll.pos;
n = 0; n = 0;
@ -617,13 +617,13 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
SetDParam(4, i->total_production[1]); SetDParam(4, i->total_production[1]);
SetDParam(5, i->pct_transported[0] * 100 >> 8); SetDParam(5, i->pct_transported[0] * 100 >> 8);
SetDParam(6, i->pct_transported[1] * 100 >> 8); SetDParam(6, i->pct_transported[1] * 100 >> 8);
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_TWO, 0); DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_TWO, 0);
} else { } else {
SetDParam(3, i->pct_transported[0] * 100 >> 8); SetDParam(3, i->pct_transported[0] * 100 >> 8);
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM, 0); DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM, 0);
} }
} else { } else {
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_NOPROD, 0); DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_NOPROD, 0);
} }
p++; p++;
if (++n == w->vscroll.cap) break; if (++n == w->vscroll.cap) break;
@ -633,25 +633,25 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
case WE_CLICK: case WE_CLICK:
switch (e->we.click.widget) { switch (e->we.click.widget) {
case 3: { case 3: {
_industry_sort_order = _industry_sort_order==0 ? 1 : 0; _industry_sort_order = _industry_sort_order == 0 ? 1 : 0;
_industry_sort_dirty = true; _industry_sort_dirty = true;
SetWindowDirty(w); SetWindowDirty(w);
} break; } break;
case 4: { case 4: {
_industry_sort_order = _industry_sort_order==2 ? 3 : 2; _industry_sort_order = _industry_sort_order == 2 ? 3 : 2;
_industry_sort_dirty = true; _industry_sort_dirty = true;
SetWindowDirty(w); SetWindowDirty(w);
} break; } break;
case 5: { case 5: {
_industry_sort_order = _industry_sort_order==4 ? 5 : 4; _industry_sort_order = _industry_sort_order == 4 ? 5 : 4;
_industry_sort_dirty = true; _industry_sort_dirty = true;
SetWindowDirty(w); SetWindowDirty(w);
} break; } break;
case 6: { case 6: {
_industry_sort_order = _industry_sort_order==6 ? 7 : 6; _industry_sort_order = _industry_sort_order == 6 ? 7 : 6;
_industry_sort_dirty = true; _industry_sort_dirty = true;
SetWindowDirty(w); SetWindowDirty(w);
} break; } break;

View File

@ -76,13 +76,13 @@ uint GetPartialZ(int x, int y, Slope corners)
break; break;
case SLOPE_S: case SLOPE_S:
y^=0xF; y ^= 0xF;
if ( (x - y) >= 0) if ( (x - y) >= 0)
z = (x - y) >> 1; z = (x - y) >> 1;
break; break;
case SLOPE_SW: case SLOPE_SW:
z = (x>>1) + 1; z = (x >> 1) + 1;
break; break;
case SLOPE_E: case SLOPE_E:
@ -97,12 +97,12 @@ uint GetPartialZ(int x, int y, Slope corners)
break; break;
case SLOPE_SE: case SLOPE_SE:
z = (y>>1) + 1; z = (y >> 1) + 1;
break; break;
case SLOPE_WSE: case SLOPE_WSE:
z = 8; z = 8;
y^=0xF; y ^= 0xF;
if (x - y < 0) if (x - y < 0)
z += (x - y) >> 1; z += (x - y) >> 1;
break; break;
@ -114,7 +114,7 @@ uint GetPartialZ(int x, int y, Slope corners)
break; break;
case SLOPE_NW: case SLOPE_NW:
z = (y^0xF)>>1; z = (y ^ 0xF) >> 1;
break; break;
case SLOPE_NWS: case SLOPE_NWS:
@ -124,7 +124,7 @@ uint GetPartialZ(int x, int y, Slope corners)
break; break;
case SLOPE_NE: case SLOPE_NE:
z = (x^0xF)>>1; z = (x ^ 0xF) >> 1;
break; break;
case SLOPE_ENW: case SLOPE_ENW:
@ -141,19 +141,19 @@ uint GetPartialZ(int x, int y, Slope corners)
break; break;
case SLOPE_STEEP_S: case SLOPE_STEEP_S:
z = 1 + ((x+y)>>1); z = 1 + ((x + y) >> 1);
break; break;
case SLOPE_STEEP_W: case SLOPE_STEEP_W:
z = 1 + ((x+(y^0xF))>>1); z = 1 + ((x + (y ^ 0xF)) >> 1);
break; break;
case SLOPE_STEEP_N: case SLOPE_STEEP_N:
z = 1 + (((x^0xF)+(y^0xF))>>1); z = 1 + (((x ^ 0xF) + (y ^ 0xF)) >> 1);
break; break;
case SLOPE_STEEP_E: case SLOPE_STEEP_E:
z = 1 + (((x^0xF)+(y^0xF))>>1); z = 1 + (((x ^ 0xF) + (y ^ 0xF)) >> 1);
break; break;
default: break; default: break;
@ -385,8 +385,8 @@ int32 CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
int32 cost, ret, money; int32 cost, ret, money;
int ex; int ex;
int ey; int ey;
int sx,sy; int sx, sy;
int x,y; int x, y;
bool success = false; bool success = false;
if (p1 >= MapSize()) return CMD_ERROR; if (p1 >= MapSize()) return CMD_ERROR;
@ -435,7 +435,7 @@ int32 CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
#define TILELOOP_BITS 4 #define TILELOOP_BITS 4
#define TILELOOP_SIZE (1 << TILELOOP_BITS) #define TILELOOP_SIZE (1 << TILELOOP_BITS)
#define TILELOOP_ASSERTMASK ((TILELOOP_SIZE-1) + ((TILELOOP_SIZE-1) << MapLogX())) #define TILELOOP_ASSERTMASK ((TILELOOP_SIZE - 1) + ((TILELOOP_SIZE - 1) << MapLogX()))
#define TILELOOP_CHKMASK (((1 << (MapLogX() - TILELOOP_BITS))-1) << TILELOOP_BITS) #define TILELOOP_CHKMASK (((1 << (MapLogX() - TILELOOP_BITS))-1) << TILELOOP_BITS)
void RunTileLoop() void RunTileLoop()

View File

@ -82,9 +82,9 @@ template<typename T> static inline T TOGGLEBIT(T& x, int y)
/* checking more bits. Maybe unneccessary, but easy to use */ /* checking more bits. Maybe unneccessary, but easy to use */
#define HASBITS(x,y) ((x) & (y)) #define HASBITS(x, y) ((x) & (y))
#define SETBITS(x,y) ((x) |= (y)) #define SETBITS(x, y) ((x) |= (y))
#define CLRBITS(x,y) ((x) &= ~(y)) #define CLRBITS(x, y) ((x) &= ~(y))
#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START) #define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner])) #define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))
@ -98,7 +98,7 @@ extern const byte _ffb_64[128];
/* Returns x with the first bit that is not zero, counted from the left, set /* Returns x with the first bit that is not zero, counted from the left, set
* to zero. So, 10110100 returns 10110000, 00000001 returns 00000000, etc. * to zero. So, 10110100 returns 10110000, 00000001 returns 00000000, etc.
*/ */
#define KILL_FIRST_BIT(x) _ffb_64[(x)+64] #define KILL_FIRST_BIT(x) _ffb_64[(x) + 64]
static inline int FindFirstBit2x64(int value) static inline int FindFirstBit2x64(int value)
{ {
@ -133,13 +133,13 @@ static inline int KillFirstBit2x64(int value)
#define HAS_SINGLE_BIT(a) ( ((a) & ((a) - 1)) == 0) #define HAS_SINGLE_BIT(a) ( ((a) & ((a) - 1)) == 0)
/* [min,max), strictly less than */ /* [min,max), strictly less than */
#define IS_BYTE_INSIDE(a,min,max) ((byte)((a)-(min)) < (byte)((max)-(min))) #define IS_BYTE_INSIDE(a, min, max) ((byte)((a) - (min)) < (byte)((max) - (min)))
#define IS_INT_INSIDE(a,min,max) ((uint)((a)-(min)) < (uint)((max)-(min))) #define IS_INT_INSIDE(a, min, max) ((uint)((a) - (min)) < (uint)((max) - (min)))
#define CHANCE16(a,b) ((uint16)Random() <= (uint16)((65536 * (a)) / (b))) #define CHANCE16(a, b) ((uint16)Random() <= (uint16)((65536 * (a)) / (b)))
#define CHANCE16R(a,b,r) ((uint16)(r=Random()) <= (uint16)((65536 * (a)) / (b))) #define CHANCE16R(a, b, r) ((uint16)(r = Random()) <= (uint16)((65536 * (a)) / (b)))
#define CHANCE16I(a,b,v) ((uint16)(v) <= (uint16)((65536 * (a)) / (b))) #define CHANCE16I(a, b, v) ((uint16)(v) <= (uint16)((65536 * (a)) / (b)))
#define for_each_bit(_i, _b) \ #define for_each_bit(_i, _b) \

View File

@ -86,9 +86,9 @@ TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
#endif #endif
} }
assert(TileXY(x,y) == TILE_MASK(tile + add)); assert(TileXY(x, y) == TILE_MASK(tile + add));
return TileXY(x,y); return TileXY(x, y);
} }
#endif #endif
@ -98,7 +98,7 @@ uint ScaleByMapSize(uint n)
/* First shift by 12 to prevent integer overflow for large values of n. /* First shift by 12 to prevent integer overflow for large values of n.
* >>12 is safe since the min mapsize is 64x64 * >>12 is safe since the min mapsize is 64x64
* Add (1<<4)-1 to round upwards. */ * Add (1<<4)-1 to round upwards. */
return (n * (MapSize() >> 12) + (1<<4) - 1) >> 4; return (n * (MapSize() >> 12) + (1 << 4) - 1) >> 4;
} }
@ -109,7 +109,7 @@ uint ScaleByMapSize1D(uint n)
* Note, not actually taking the full circumference into account, * Note, not actually taking the full circumference into account,
* just half of it. * just half of it.
* (1<<9) - 1 is there to scale upwards. */ * (1<<9) - 1 is there to scale upwards. */
return (n * (MapSizeX() + MapSizeY()) + (1<<9) - 1) >> 9; return (n * (MapSizeX() + MapSizeY()) + (1 << 9) - 1) >> 9;
} }

View File

@ -147,7 +147,7 @@ uint DistanceMaxPlusManhattan(TileIndex, TileIndex); ///< Max + Manhattan
uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the map uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the map
#define BEGIN_TILE_LOOP(var,w,h,tile) \ #define BEGIN_TILE_LOOP(var, w, h, tile) \
{ \ { \
int h_cur = h; \ int h_cur = h; \
uint var = tile; \ uint var = tile; \
@ -155,7 +155,7 @@ uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the ma
int w_cur = w; \ int w_cur = w; \
do { do {
#define END_TILE_LOOP(var,w,h,tile) \ #define END_TILE_LOOP(var, w, h, tile) \
} while (++var, --w_cur != 0); \ } while (++var, --w_cur != 0); \
} while (var += TileDiffXY(0, 1) - (w), --h_cur != 0); \ } while (var += TileDiffXY(0, 1) - (w), --h_cur != 0); \
} }

View File

@ -286,7 +286,7 @@ static void Load_NAME()
int index; int index;
while ((index = SlIterateArray()) != -1) { while ((index = SlIterateArray()) != -1) {
SlArray(_name_array[index],SlGetFieldLength(),SLE_UINT8); SlArray(_name_array[index], SlGetFieldLength(), SLE_UINT8);
} }
} }

View File

@ -1457,7 +1457,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
} }
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
DrawEditBox(w, &WP(w,querystr_d), 10); DrawEditBox(w, &WP(w, querystr_d), 10);
} }
break; break;
} }
@ -1550,7 +1550,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) break; if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) break;
if (IsWindowWidgetLowered(w, 11)) { // Delete button clicked if (IsWindowWidgetLowered(w, 11)) { // Delete button clicked
if (!FiosDelete(WP(w,querystr_d).text.buf)) { if (!FiosDelete(WP(w, querystr_d).text.buf)) {
ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0); ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0);
} else { } else {
BuildFileList(); BuildFileList();
@ -1562,7 +1562,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
SetWindowDirty(w); SetWindowDirty(w);
} else if (IsWindowWidgetLowered(w, 12)) { // Save button clicked } else if (IsWindowWidgetLowered(w, 12)) { // Save button clicked
_switch_mode = SM_SAVE; _switch_mode = SM_SAVE;
FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).text.buf, sizeof(_file_to_saveload.name)); FiosMakeSavegameName(_file_to_saveload.name, WP(w, querystr_d).text.buf, sizeof(_file_to_saveload.name));
/* In the editor set up the vehicle engines correctly (date might have changed) */ /* In the editor set up the vehicle engines correctly (date might have changed) */
if (_game_mode == GM_EDITOR) StartupEngines(); if (_game_mode == GM_EDITOR) StartupEngines();

View File

@ -207,8 +207,8 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
LowerWindowWidget(w, 4); LowerWindowWidget(w, 4);
DrawWindowWidgets(w); DrawWindowWidgets(w);
GfxFillRect(3, 23, 3+177,23+191,0); GfxFillRect(3, 23, 3 + 177, 23 + 191, 0);
GfxFillRect(251, 23, 251+177,23+191,0); GfxFillRect(251, 23, 251 + 177, 23 + 191, 0);
DrawStringCentered(92, 15, STR_01EE_TRACK_INDEX, 0); DrawStringCentered(92, 15, STR_01EE_TRACK_INDEX, 0);
@ -219,14 +219,14 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
SetDParam(0, i); SetDParam(0, i);
SetDParam(2, i); SetDParam(2, i);
SetDParam(1, SPECSTR_SONGNAME); SetDParam(1, SPECSTR_SONGNAME);
DrawString(4, 23+(i-1)*6, (i < 10) ? STR_01EC_0 : STR_01ED, 0); DrawString(4, 23 + (i - 1) * 6, (i < 10) ? STR_01EC_0 : STR_01ED, 0);
} }
for (i = 0; i != 6; i++) { for (i = 0; i != 6; i++) {
DrawStringCentered(216, 45 + i * 8, STR_01D5_ALL + i, (i == msf.playlist) ? 0xC : 0x10); DrawStringCentered(216, 45 + i * 8, STR_01D5_ALL + i, (i == msf.playlist) ? 0xC : 0x10);
} }
DrawStringCentered(216, 45+8*6+16, STR_01F0_CLEAR, 0); DrawStringCentered(216, 45 + 8 * 6 + 16, STR_01F0_CLEAR, 0);
#if 0 #if 0
DrawStringCentered(216, 45 + 8 * 6 + 16 * 2, STR_01F1_SAVE, 0); DrawStringCentered(216, 45 + 8 * 6 + 16 * 2, STR_01F1_SAVE, 0);
#endif #endif

View File

@ -90,7 +90,7 @@ static byte MakeEnglishAdditionalTownName(char *buf, uint32 seed, const char *la
/* optional first segment */ /* optional first segment */
i = SeedChanceBias(0, lengthof(name_additional_english_prefix), seed, 50); i = SeedChanceBias(0, lengthof(name_additional_english_prefix), seed, 50);
if (i >= 0) if (i >= 0)
strecat(buf,name_additional_english_prefix[i], last); strecat(buf, name_additional_english_prefix[i], last);
if (SeedChance(3, 20, seed) >= 14) { if (SeedChance(3, 20, seed) >= 14) {
strecat(buf, name_additional_english_1a[SeedChance(6, lengthof(name_additional_english_1a), seed)], last); strecat(buf, name_additional_english_1a[SeedChance(6, lengthof(name_additional_english_1a), seed)], last);
@ -176,13 +176,13 @@ static byte MakeGermanTownName(char *buf, uint32 seed, const char *last)
/* optional prefix */ /* optional prefix */
if (seed_derivative == 12 || seed_derivative == 19) { if (seed_derivative == 12 || seed_derivative == 19) {
i = SeedChance(2, lengthof(name_german_pre), seed); i = SeedChance(2, lengthof(name_german_pre), seed);
strecat(buf,name_german_pre[i], last); strecat(buf, name_german_pre[i], last);
} }
/* mandatory middle segments including option of hardcoded name */ /* mandatory middle segments including option of hardcoded name */
i = SeedChance(3, lengthof(name_german_real) + lengthof(name_german_1), seed); i = SeedChance(3, lengthof(name_german_real) + lengthof(name_german_1), seed);
if (i < lengthof(name_german_real)) { if (i < lengthof(name_german_real)) {
strecat(buf,name_german_real[i], last); strecat(buf, name_german_real[i], last);
} else { } else {
strecat(buf, name_german_1[i - lengthof(name_german_real)], last); strecat(buf, name_german_1[i - lengthof(name_german_real)], last);
@ -679,7 +679,7 @@ static byte MakeItalianTownName(char *buf, uint32 seed, const char *last)
if (SeedModChance(3, 3, seed) == 0) { if (SeedModChance(3, 3, seed) == 0) {
strecat(buf, name_italian_2[SeedModChance(11, lengthof(name_italian_2), seed)], last); strecat(buf, name_italian_2[SeedModChance(11, lengthof(name_italian_2), seed)], last);
strecat(buf,mascul_femin_italian[i], last); strecat(buf, mascul_femin_italian[i], last);
} else { } else {
strecat(buf, name_italian_2i[SeedModChance(16, lengthof(name_italian_2i), seed)], last); strecat(buf, name_italian_2i[SeedModChance(16, lengthof(name_italian_2i), seed)], last);
} }

View File

@ -161,7 +161,7 @@ typedef unsigned long in_addr_t;
/* Make the names compatible */ /* Make the names compatible */
# define closesocket(s) CloseSocket(s) # define closesocket(s) CloseSocket(s)
# define GET_LAST_ERROR() Errno() # define GET_LAST_ERROR() Errno()
# define ioctlsocket(s,request,status) IoctlSocket((LONG)s,(ULONG)request,(char*)status) # define ioctlsocket(s, request, status) IoctlSocket((LONG)s, (ULONG)request, (char*)status)
# define ioctl ioctlsocket # define ioctl ioctlsocket
typedef unsigned int in_addr_t; typedef unsigned int in_addr_t;

View File

@ -789,7 +789,7 @@ static void ShowNetworkStartServerWindow()
_saveload_mode = SLD_NEW_GAME; _saveload_mode = SLD_NEW_GAME;
BuildFileList(); BuildFileList();
w->vscroll.cap = 12; w->vscroll.cap = 12;
w->vscroll.count = _fios_num+1; w->vscroll.count = _fios_num + 1;
WP(w, network_ql_d).q.afilter = CS_ALPHANUMERAL; WP(w, network_ql_d).q.afilter = CS_ALPHANUMERAL;
InitializeTextBuffer(&WP(w, network_ql_d).q.text, _edit_str_buf, lengthof(_edit_str_buf), 160); InitializeTextBuffer(&WP(w, network_ql_d).q.text, _edit_str_buf, lengthof(_edit_str_buf), 160);

View File

@ -1523,7 +1523,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i
uint32 tempfix = grf_load_dword(&buf); uint32 tempfix = grf_load_dword(&buf);
if (curidx < NUM_CURRENCY) { if (curidx < NUM_CURRENCY) {
memcpy(&_currency_specs[curidx].suffix,&tempfix,4); memcpy(&_currency_specs[curidx].suffix, &tempfix, 4);
_currency_specs[curidx].suffix[4] = 0; _currency_specs[curidx].suffix[4] = 0;
} else { } else {
grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx);
@ -2796,7 +2796,7 @@ static void FeatureNewName(byte *buf, int len)
case GSF_CANAL : case GSF_CANAL :
case GSF_BRIDGE : case GSF_BRIDGE :
AddGRFString(_cur_spriteid, id, lang, name); AddGRFString(_cur_spriteid, id, lang, name);
switch (GB(id, 8,8)) { switch (GB(id, 8, 8)) {
case 0xC9: // House name case 0xC9: // House name
default: default:
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id);

View File

@ -24,7 +24,7 @@ typedef bool ValidationProc ( uint data_a, uint data_b );
typedef void DrawNewsCallbackProc(Window *w); typedef void DrawNewsCallbackProc(Window *w);
typedef StringID GetNewsStringCallbackProc(const NewsItem *ni); typedef StringID GetNewsStringCallbackProc(const NewsItem *ni);
#define NEWS_FLAGS(mode,flag,type,cb) ((cb)<<24 | (type)<<16 | (flag)<<8 | (mode)) #define NEWS_FLAGS(mode, flag, type, cb) ((cb) << 24 | (type) << 16 | (flag) << 8 | (mode))
void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b); void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b);
void NewsLoop(); void NewsLoop();
void DrawNewsBorder(const Window *w); void DrawNewsBorder(const Window *w);

View File

@ -149,7 +149,7 @@ static byte ReadByte(LoadgameState *ls)
/* Old savegames have a nice compression algorithm (RLE) /* Old savegames have a nice compression algorithm (RLE)
which means that we have a chunk, which starts with a length which means that we have a chunk, which starts with a length
byte. If that byte is negative, we have to repeat the next byte byte. If that byte is negative, we have to repeat the next byte
that many times (+1). Else, we need to read that amount of bytes. that many times ( + 1). Else, we need to read that amount of bytes.
Works pretty good if you have many zero's behind eachother */ Works pretty good if you have many zero's behind eachother */
if (ls->chunk_size == 0) { if (ls->chunk_size == 0) {
@ -433,7 +433,7 @@ static const OldChunks town_chunk[] = {
OCL_SVAR( OC_UINT16, Town, ratings[7] ), OCL_SVAR( OC_UINT16, Town, ratings[7] ),
/* XXX - This is pretty odd.. we read 32bit, but only write 8bit.. sure there is /* XXX - This is pretty odd.. we read 32bit, but only write 8bit.. sure there is
nothing changed?? */ nothing changed ? ? */
OCL_SVAR( OC_FILE_U32 | OC_VAR_U8, Town, have_ratings ), OCL_SVAR( OC_FILE_U32 | OC_VAR_U8, Town, have_ratings ),
OCL_SVAR( OC_FILE_U32 | OC_VAR_U8, Town, statues ), OCL_SVAR( OC_FILE_U32 | OC_VAR_U8, Town, statues ),
OCL_SVAR( OC_UINT16, Town, num_houses ), OCL_SVAR( OC_UINT16, Town, num_houses ),
@ -1219,8 +1219,8 @@ static bool LoadOldVehicle(LoadgameState *ls, int num)
static const OldChunks sign_chunk[] = { static const OldChunks sign_chunk[] = {
OCL_SVAR( OC_UINT16, Sign, str ), OCL_SVAR( OC_UINT16, Sign, str ),
OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,Sign, x ), OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Sign, x ),
OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,Sign, y ), OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Sign, y ),
OCL_SVAR( OC_FILE_U16 | OC_VAR_I8, Sign, z ), OCL_SVAR( OC_FILE_U16 | OC_VAR_I8, Sign, z ),
OCL_NULL( 6 ), ///< Width of sign, no longer in use OCL_NULL( 6 ), ///< Width of sign, no longer in use

View File

@ -348,7 +348,7 @@ int ttd_main(int argc, char *argv[])
int i; int i;
const char *optformat; const char *optformat;
char musicdriver[32], sounddriver[32], videodriver[32]; char musicdriver[32], sounddriver[32], videodriver[32];
int resolution[2] = {0,0}; int resolution[2] = {0, 0};
Year startyear = INVALID_YEAR; Year startyear = INVALID_YEAR;
uint generation_seed = GENERATE_NEW_SEED; uint generation_seed = GENERATE_NEW_SEED;
bool save_config = true; bool save_config = true;
@ -379,7 +379,7 @@ int ttd_main(int argc, char *argv[])
#endif #endif
; ;
MyGetOptData mgo(argc-1, argv+1, optformat); MyGetOptData mgo(argc - 1, argv + 1, optformat);
while ((i = MyGetOpt(&mgo)) != -1) { while ((i = MyGetOpt(&mgo)) != -1) {
switch (i) { switch (i) {

View File

@ -821,7 +821,7 @@ start_at:
} }
/* If we reach here, the tile has exactly one track, and this /* If we reach here, the tile has exactly one track, and this
track is reachable => Rail segment continues */ track is reachable = > Rail segment continues */
track = _new_trackdir[FIND_FIRST_BIT(bits)][direction]; track = _new_trackdir[FIND_FIRST_BIT(bits)][direction];
assert(track != INVALID_TRACKDIR); assert(track != INVALID_TRACKDIR);

View File

@ -29,7 +29,7 @@ static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_sti
static void DrawPlayerEconomyStats(const Player *p, byte mode) static void DrawPlayerEconomyStats(const Player *p, byte mode)
{ {
int x,y,i,j,year; int x, y, i, j, year;
const int64 (*tbl)[13]; const int64 (*tbl)[13];
int64 sum, cost; int64 sum, cost;
StringID str; StringID str;
@ -38,8 +38,8 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode)
/* draw categories */ /* draw categories */
DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, 0); DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, 0);
for (i = 0; i != 13; i++) for (i = 0; i != 13; i++)
DrawString(2, 27 + i*10, STR_7011_CONSTRUCTION + i, 0); DrawString(2, 27 + i * 10, STR_7011_CONSTRUCTION + i, 0);
DrawStringRightAligned(111, 27 + 10*13 + 2, STR_7020_TOTAL, 0); DrawStringRightAligned(111, 27 + 10 * 13 + 2, STR_7020_TOTAL, 0);
/* draw the price columns */ /* draw the price columns */
year = _cur_year - 2; year = _cur_year - 2;
@ -60,16 +60,16 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode)
str = STR_701E; str = STR_701E;
if (cost < 0) { cost = -cost; str++; } if (cost < 0) { cost = -cost; str++; }
SetDParam64(0, cost); SetDParam64(0, cost);
DrawStringRightAligned(x, 27+i*10, str, 0); DrawStringRightAligned(x, 27 + i * 10, str, 0);
} }
} }
str = STR_701E; str = STR_701E;
if (sum < 0) { sum = -sum; str++; } if (sum < 0) { sum = -sum; str++; }
SetDParam64(0, sum); SetDParam64(0, sum);
DrawStringRightAligned(x, 27 + 13*10 + 2, str, 0); DrawStringRightAligned(x, 27 + 13 * 10 + 2, str, 0);
GfxFillRect(x - 75, 27 + 10*13, x, 27 + 10*13, 215); GfxFillRect(x - 75, 27 + 10 * 13, x, 27 + 10 * 13, 215);
x += 95; x += 95;
} }
year++; year++;
@ -80,7 +80,7 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode)
/* draw max loan aligned to loan below (y += 10) */ /* draw max loan aligned to loan below (y += 10) */
SetDParam64(0, (uint64)_economy.max_loan); SetDParam64(0, (uint64)_economy.max_loan);
DrawString(202, y+10, STR_MAX_LOAN, 0); DrawString(202, y + 10, STR_MAX_LOAN, 0);
} else { } else {
y = 15; y = 15;
} }
@ -97,7 +97,7 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode)
y += 12; y += 12;
GfxFillRect(182 - 75, y-2, 182, y-2, 215); GfxFillRect(182 - 75, y - 2, 182, y - 2, 215);
SetDParam64(0, p->money64 - p->current_loan); SetDParam64(0, p->money64 - p->current_loan);
DrawStringRightAligned(182, y, STR_7028, 0); DrawStringRightAligned(182, y, STR_7028, 0);
@ -166,13 +166,13 @@ static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
SetDParam(4, 10000); SetDParam(4, 10000);
DrawWindowWidgets(w); DrawWindowWidgets(w);
DrawPlayerEconomyStats(p, (byte)WP(w,def_d).data_1); DrawPlayerEconomyStats(p, (byte)WP(w, def_d).data_1);
} break; } break;
case WE_CLICK: case WE_CLICK:
switch (e->we.click.widget) { switch (e->we.click.widget) {
case 2: {/* toggle size */ case 2: {/* toggle size */
byte mode = (byte)WP(w,def_d).data_1; byte mode = (byte)WP(w, def_d).data_1;
bool stickied = !!(w->flags4 & WF_STICKY); bool stickied = !!(w->flags4 & WF_STICKY);
PlayerID player = (PlayerID)w->window_number; PlayerID player = (PlayerID)w->window_number;
DeleteWindow(w); DeleteWindow(w);
@ -239,7 +239,7 @@ static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_sti
w = AllocateWindowDescFront(desc_table[mode], player); w = AllocateWindowDescFront(desc_table[mode], player);
if (w != NULL) { if (w != NULL) {
w->caption_color = w->window_number; w->caption_color = w->window_number;
WP(w,def_d).data_1 = mode; WP(w, def_d).data_1 = mode;
if (show_stickied) w->flags4 |= WF_STICKY; if (show_stickied) w->flags4 |= WF_STICKY;
} }
} }
@ -554,14 +554,14 @@ static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e)
LowerWindowWidget(w, WP(w, facesel_d).gender + 5); LowerWindowWidget(w, WP(w, facesel_d).gender + 5);
DrawWindowWidgets(w); DrawWindowWidgets(w);
p = GetPlayer((PlayerID)w->window_number); p = GetPlayer((PlayerID)w->window_number);
DrawPlayerFace(WP(w,facesel_d).face, p->player_color, 2, 16); DrawPlayerFace(WP(w, facesel_d).face, p->player_color, 2, 16);
} break; } break;
case WE_CLICK: case WE_CLICK:
switch (e->we.click.widget) { switch (e->we.click.widget) {
case 3: DeleteWindow(w); break; case 3: DeleteWindow(w); break;
case 4: /* ok click */ case 4: /* ok click */
DoCommandP(0, 0, WP(w,facesel_d).face, NULL, CMD_SET_PLAYER_FACE); DoCommandP(0, 0, WP(w, facesel_d).face, NULL, CMD_SET_PLAYER_FACE);
DeleteWindow(w); DeleteWindow(w);
break; break;
case 5: /* male click */ case 5: /* male click */
@ -572,7 +572,7 @@ static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e)
SetWindowDirty(w); SetWindowDirty(w);
break; break;
case 7: case 7:
WP(w,facesel_d).face = ConvertFromOldPlayerFace((WP(w, facesel_d).gender << 31) + GB(InteractiveRandom(), 0, 31)); WP(w, facesel_d).face = ConvertFromOldPlayerFace((WP(w, facesel_d).gender << 31) + GB(InteractiveRandom(), 0, 31));
SetWindowDirty(w); SetWindowDirty(w);
break; break;
} }
@ -656,8 +656,8 @@ static void DrawPlayerVehiclesAmount(PlayerID player)
} }
} }
if (train+road+air+ship == 0) { if (train + road + air + ship == 0) {
DrawString(x+70, y, STR_7042_NONE, 0); DrawString(x + 70, y, STR_7042_NONE, 0);
} else { } else {
if (train != 0) { if (train != 0) {
SetDParam(0, train); SetDParam(0, train);
@ -762,7 +762,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
DrawPlayerVehiclesAmount((PlayerID)w->window_number); DrawPlayerVehiclesAmount((PlayerID)w->window_number);
DrawString(110,48, STR_7006_COLOR_SCHEME, 0); DrawString(110, 48, STR_7006_COLOR_SCHEME, 0);
/* Draw company-colour bus */ /* Draw company-colour bus */
DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 49); DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 49);
@ -786,8 +786,8 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
Window *wf = AllocateWindowDescFront(&_select_player_face_desc, w->window_number); Window *wf = AllocateWindowDescFront(&_select_player_face_desc, w->window_number);
if (wf != NULL) { if (wf != NULL) {
wf->caption_color = w->window_number; wf->caption_color = w->window_number;
WP(wf,facesel_d).face = GetPlayer((PlayerID)wf->window_number)->face; WP(wf, facesel_d).face = GetPlayer((PlayerID)wf->window_number)->face;
WP(wf,facesel_d).gender = 0; WP(wf, facesel_d).gender = 0;
} }
break; break;
} }
@ -796,8 +796,8 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
Window *wf = AllocateWindowDescFront(_have_2cc ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number); Window *wf = AllocateWindowDescFront(_have_2cc ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
if (wf != NULL) { if (wf != NULL) {
wf->caption_color = wf->window_number; wf->caption_color = wf->window_number;
WP(wf,livery_d).livery_class = LC_OTHER; WP(wf, livery_d).livery_class = LC_OTHER;
WP(wf,livery_d).sel = 1; WP(wf, livery_d).sel = 1;
LowerWindowWidget(wf, 2); LowerWindowWidget(wf, 2);
} }
break; break;
@ -813,7 +813,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
case PCW_WIDGET_COMPANY_NAME: { case PCW_WIDGET_COMPANY_NAME: {
Player *p = GetPlayer((PlayerID)w->window_number); Player *p = GetPlayer((PlayerID)w->window_number);
WP(w,def_d).byte_1 = 1; WP(w, def_d).byte_1 = 1;
SetDParam(0, p->name_2); SetDParam(0, p->name_2);
ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w, CS_ALPHANUMERAL); ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w, CS_ALPHANUMERAL);
break; break;
@ -852,7 +852,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
case PCW_WIDGET_COMPANY_PASSWORD: case PCW_WIDGET_COMPANY_PASSWORD:
if (w->window_number == _local_player) { if (w->window_number == _local_player) {
WP(w,def_d).byte_1 = 2; WP(w, def_d).byte_1 = 2;
ShowQueryString(BindCString(_network_player_info[_local_player].password), ShowQueryString(BindCString(_network_player_info[_local_player].password),
STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w, CS_ALPHANUMERAL); STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w, CS_ALPHANUMERAL);
} }
@ -885,10 +885,10 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
char *b = e->we.edittext.str; char *b = e->we.edittext.str;
/* empty string is allowed for password */ /* empty string is allowed for password */
if (*b == '\0' && WP(w,def_d).byte_1 != 2) return; if (*b == '\0' && WP(w, def_d).byte_1 != 2) return;
_cmd_text = b; _cmd_text = b;
switch (WP(w,def_d).byte_1) { switch (WP(w, def_d).byte_1) {
case 0: /* Change president name */ case 0: /* Change president name */
DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT)); DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
break; break;

View File

@ -68,8 +68,8 @@ extern const TrackBits _track_crosses_tracks[] = {
/* Maps a trackdir to the (4-way) direction the tile is exited when following /* Maps a trackdir to the (4-way) direction the tile is exited when following
* that trackdir */ * that trackdir */
extern const DiagDirection _trackdir_to_exitdir[] = { extern const DiagDirection _trackdir_to_exitdir[] = {
DIAGDIR_NE,DIAGDIR_SE,DIAGDIR_NE,DIAGDIR_SE,DIAGDIR_SW,DIAGDIR_SE, DIAGDIR_NE,DIAGDIR_NE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_NE,
DIAGDIR_SW,DIAGDIR_NW,DIAGDIR_NW,DIAGDIR_SW,DIAGDIR_NW,DIAGDIR_NE, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE,
}; };
extern const Trackdir _track_exitdir_to_trackdir[][DIAGDIR_END] = { extern const Trackdir _track_exitdir_to_trackdir[][DIAGDIR_END] = {

View File

@ -60,10 +60,10 @@ bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *ed
/* Get a bitmask of which neighbouring roads has a tile */ /* Get a bitmask of which neighbouring roads has a tile */
n = ROAD_NONE; n = ROAD_NONE;
present = GetAnyRoadBits(tile); present = GetAnyRoadBits(tile);
if (present & ROAD_NE && GetAnyRoadBits(TILE_ADDXY(tile,-1, 0)) & ROAD_SW) n |= ROAD_NE; if (present & ROAD_NE && GetAnyRoadBits(TILE_ADDXY(tile, -1, 0)) & ROAD_SW) n |= ROAD_NE;
if (present & ROAD_SE && GetAnyRoadBits(TILE_ADDXY(tile, 0, 1)) & ROAD_NW) n |= ROAD_SE; if (present & ROAD_SE && GetAnyRoadBits(TILE_ADDXY(tile, 0, 1)) & ROAD_NW) n |= ROAD_SE;
if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile, 1, 0)) & ROAD_NE) n |= ROAD_SW; if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile, 1, 0)) & ROAD_NE) n |= ROAD_SW;
if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile, 0,-1)) & ROAD_SE) n |= ROAD_NW; if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile, 0, -1)) & ROAD_SE) n |= ROAD_NW;
/* If 0 or 1 bits are set in n, or if no bits that match the bits to remove, /* If 0 or 1 bits are set in n, or if no bits that match the bits to remove,
* then allow it */ * then allow it */
@ -431,7 +431,7 @@ int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
TileIndex t = start_tile; TileIndex t = start_tile;
start_tile = end_tile; start_tile = end_tile;
end_tile = t; end_tile = t;
p2 ^= IS_INT_INSIDE(p2&3, 1, 3) ? 3 : 0; p2 ^= IS_INT_INSIDE(p2 & 3, 1, 3) ? 3 : 0;
} }
cost = 0; cost = 0;

View File

@ -257,11 +257,11 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
InvalidateWidget(w, RTW_REMOVE); InvalidateWidget(w, RTW_REMOVE);
w = FindWindowById(WC_BUS_STATION, 0); w = FindWindowById(WC_BUS_STATION, 0);
if (w != NULL) WP(w,def_d).close = true; if (w != NULL) WP(w, def_d).close = true;
w = FindWindowById(WC_TRUCK_STATION, 0); w = FindWindowById(WC_TRUCK_STATION, 0);
if (w != NULL) WP(w,def_d).close = true; if (w != NULL) WP(w, def_d).close = true;
w = FindWindowById(WC_BUILD_DEPOT, 0); w = FindWindowById(WC_BUILD_DEPOT, 0);
if (w != NULL) WP(w,def_d).close = true; if (w != NULL) WP(w, def_d).close = true;
break; break;
case WE_PLACE_DRAG: { case WE_PLACE_DRAG: {
@ -414,11 +414,11 @@ static void BuildRoadDepotWndProc(Window *w, WindowEvent *e)
} break; } break;
case WE_MOUSELOOP: case WE_MOUSELOOP:
if (WP(w,def_d).close) DeleteWindow(w); if (WP(w, def_d).close) DeleteWindow(w);
break; break;
case WE_DESTROY: case WE_DESTROY:
if (!WP(w,def_d).close) ResetObjectToPlace(); if (!WP(w, def_d).close) ResetObjectToPlace();
break; break;
} }
} }
@ -458,7 +458,7 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
case WE_PAINT: { case WE_PAINT: {
int image; int image;
if (WP(w,def_d).close) return; if (WP(w, def_d).close) return;
DrawWindowWidgets(w); DrawWindowWidgets(w);
@ -472,9 +472,9 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE : GFX_TRUCK_BASE; image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE : GFX_TRUCK_BASE;
StationPickerDrawSprite(103, 35, RAILTYPE_BEGIN, image); StationPickerDrawSprite(103, 35, RAILTYPE_BEGIN, image);
StationPickerDrawSprite(103, 85, RAILTYPE_BEGIN, image+1); StationPickerDrawSprite(103, 85, RAILTYPE_BEGIN, image + 1);
StationPickerDrawSprite(35, 85, RAILTYPE_BEGIN, image+2); StationPickerDrawSprite(35, 85, RAILTYPE_BEGIN, image + 2);
StationPickerDrawSprite(35, 35, RAILTYPE_BEGIN, image+3); StationPickerDrawSprite(35, 35, RAILTYPE_BEGIN, image + 3);
image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT; image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT;
@ -482,7 +482,7 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
StationPickerDrawSprite(171, 85, RAILTYPE_BEGIN, image + 1); StationPickerDrawSprite(171, 85, RAILTYPE_BEGIN, image + 1);
DrawStationCoverageAreaText(2, 146, DrawStationCoverageAreaText(2, 146,
((w->window_class == WC_BUS_STATION) ? (1<<CT_PASSENGERS) : ~(1<<CT_PASSENGERS)), ((w->window_class == WC_BUS_STATION) ? (1 << CT_PASSENGERS) : ~(1 << CT_PASSENGERS)),
3); 3);
} break; } break;
@ -507,7 +507,7 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
} break; } break;
case WE_MOUSELOOP: { case WE_MOUSELOOP: {
if (WP(w,def_d).close) { if (WP(w, def_d).close) {
DeleteWindow(w); DeleteWindow(w);
return; return;
} }
@ -516,7 +516,7 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
} break; } break;
case WE_DESTROY: case WE_DESTROY:
if (!WP(w,def_d).close) ResetObjectToPlace(); if (!WP(w, def_d).close) ResetObjectToPlace();
break; break;
} }
} }

View File

@ -168,11 +168,11 @@ int32 CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2; y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
v->x_pos = x; v->x_pos = x;
v->y_pos = y; v->y_pos = y;
v->z_pos = GetSlopeZ(x,y); v->z_pos = GetSlopeZ(x, y);
v->z_height = 6; v->z_height = 6;
v->u.road.state = RVSB_IN_DEPOT; v->u.road.state = RVSB_IN_DEPOT;
v->vehstatus = VS_HIDDEN|VS_STOPPED|VS_DEFPAL; v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
v->spritenum = rvi->image_index; v->spritenum = rvi->image_index;
v->cargo_type = rvi->cargo_type; v->cargo_type = rvi->cargo_type;

View File

@ -251,14 +251,14 @@ static void SlWriteSimpleGamma(uint i)
if (i >= (1 << 14)) { if (i >= (1 << 14)) {
if (i >= (1 << 21)) { if (i >= (1 << 21)) {
assert(i < (1 << 28)); assert(i < (1 << 28));
SlWriteByte((byte)0xE0 | (i>>24)); SlWriteByte((byte)0xE0 | (i >> 24));
SlWriteByte((byte)(i>>16)); SlWriteByte((byte)(i >> 16));
} else { } else {
SlWriteByte((byte)0xC0 | (i>>16)); SlWriteByte((byte)0xC0 | (i >> 16));
} }
SlWriteByte((byte)(i>>8)); SlWriteByte((byte)(i >> 8));
} else { } else {
SlWriteByte((byte)(0x80 | (i>>8))); SlWriteByte((byte)(0x80 | (i >> 8)));
} }
} }
SlWriteByte(i); SlWriteByte(i);
@ -925,7 +925,7 @@ static const ChunkHandler *SlFindChunkHandler(uint32 id)
{ {
const ChunkHandler *ch; const ChunkHandler *ch;
const ChunkHandler *const *chsc; const ChunkHandler *const *chsc;
for (chsc = _sl.chs; (ch=*chsc++) != NULL;) { for (chsc = _sl.chs; (ch = *chsc++) != NULL;) {
for (;;) { for (;;) {
if (ch->id == id) return ch; if (ch->id == id) return ch;
if (ch->flags & CH_LAST) break; if (ch->flags & CH_LAST) break;
@ -1030,7 +1030,7 @@ static void WriteNoComp(uint size)
static bool InitNoComp() static bool InitNoComp()
{ {
_sl.bufsize = LZO_SIZE; _sl.bufsize = LZO_SIZE;
_sl.buf = _sl.buf_ori =(byte*)malloc(LZO_SIZE); _sl.buf = _sl.buf_ori = (byte*)malloc(LZO_SIZE);
return true; return true;
} }

View File

@ -268,7 +268,7 @@ struct PcxHeader {
uint32 unused; uint32 unused;
uint16 xmax, ymax; uint16 xmax, ymax;
uint16 hdpi, vdpi; uint16 hdpi, vdpi;
byte pal_small[16*3]; byte pal_small[16 * 3];
byte reserved; byte reserved;
byte planes; byte planes;
uint16 pitch; uint16 pitch;

View File

@ -1140,15 +1140,15 @@ static int32 CheckInterval(int32 p1)
const Patches *ptc = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches; const Patches *ptc = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
if (p1) { if (p1) {
warning = ( (IS_INT_INSIDE(ptc->servint_trains, 5, 90+1) || ptc->servint_trains == 0) && warning = ( (IS_INT_INSIDE(ptc->servint_trains, 5, 90 + 1) || ptc->servint_trains == 0) &&
(IS_INT_INSIDE(ptc->servint_roadveh, 5, 90+1) || ptc->servint_roadveh == 0) && (IS_INT_INSIDE(ptc->servint_roadveh, 5, 90 + 1) || ptc->servint_roadveh == 0) &&
(IS_INT_INSIDE(ptc->servint_aircraft, 5, 90+1) || ptc->servint_aircraft == 0) && (IS_INT_INSIDE(ptc->servint_aircraft, 5, 90 + 1) || ptc->servint_aircraft == 0) &&
(IS_INT_INSIDE(ptc->servint_ships, 5, 90+1) || ptc->servint_ships == 0) ); (IS_INT_INSIDE(ptc->servint_ships, 5, 90 + 1) || ptc->servint_ships == 0) );
} else { } else {
warning = ( (IS_INT_INSIDE(ptc->servint_trains, 30, 800+1) || ptc->servint_trains == 0) && warning = ( (IS_INT_INSIDE(ptc->servint_trains, 30, 800 + 1) || ptc->servint_trains == 0) &&
(IS_INT_INSIDE(ptc->servint_roadveh, 30, 800+1) || ptc->servint_roadveh == 0) && (IS_INT_INSIDE(ptc->servint_roadveh, 30, 800 + 1) || ptc->servint_roadveh == 0) &&
(IS_INT_INSIDE(ptc->servint_aircraft, 30, 800+1) || ptc->servint_aircraft == 0) && (IS_INT_INSIDE(ptc->servint_aircraft, 30, 800 + 1) || ptc->servint_aircraft == 0) &&
(IS_INT_INSIDE(ptc->servint_ships, 30, 800+1) || ptc->servint_ships == 0) ); (IS_INT_INSIDE(ptc->servint_ships, 30, 800 + 1) || ptc->servint_ships == 0) );
} }
if (!warning) if (!warning)
@ -1280,7 +1280,7 @@ static const SettingDesc _gameopt_settings[] = {
* and why not byte for example? */ * and why not byte for example? */
SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 0, 3), SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 0, 3),
SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 4, SL_MAX_VERSION), SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 4, SL_MAX_VERSION),
SDT_VAR(GameOptions, diff_level,SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL), SDT_VAR(GameOptions, diff_level, SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL),
SDT_OMANY(GameOptions, currency, SLE_UINT8, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL), SDT_OMANY(GameOptions, currency, SLE_UINT8, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
SDT_OMANY(GameOptions, units, SLE_UINT8, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL), SDT_OMANY(GameOptions, units, SLE_UINT8, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
SDT_OMANY(GameOptions, town_name, SLE_UINT8, 0, 0, 0, 20, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL), SDT_OMANY(GameOptions, town_name, SLE_UINT8, 0, 0, 0, 20, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
@ -1527,7 +1527,7 @@ const SettingDesc _patch_settings[] = {
static const SettingDesc _currency_settings[] = { static const SettingDesc _currency_settings[] = {
SDT_VAR(CurrencySpec, rate, SLE_UINT16, S, 0, 1, 0, 100, 0, STR_NULL, NULL), SDT_VAR(CurrencySpec, rate, SLE_UINT16, S, 0, 1, 0, 100, 0, STR_NULL, NULL),
SDT_CHR(CurrencySpec, separator, S, 0, ".", STR_NULL, NULL), SDT_CHR(CurrencySpec, separator, S, 0, ".", STR_NULL, NULL),
SDT_VAR(CurrencySpec, to_euro, SLE_INT32, S, 0, 0, 0,3000, 0, STR_NULL, NULL), SDT_VAR(CurrencySpec, to_euro, SLE_INT32, S, 0, 0, 0, 3000, 0, STR_NULL, NULL),
SDT_STR(CurrencySpec, prefix, SLE_STRBQ, S, 0, NULL, STR_NULL, NULL), SDT_STR(CurrencySpec, prefix, SLE_STRBQ, S, 0, NULL, STR_NULL, NULL),
SDT_STR(CurrencySpec, suffix, SLE_STRBQ, S, 0, " credits", STR_NULL, NULL), SDT_STR(CurrencySpec, suffix, SLE_STRBQ, S, 0, " credits", STR_NULL, NULL),
SDT_END() SDT_END()

View File

@ -551,7 +551,7 @@ static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Tra
* direction in which we are entering the tile */ * direction in which we are entering the tile */
static Track ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) static Track ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
{ {
assert(enterdir>=0 && enterdir<=3); assert(enterdir >= 0 && enterdir <= 3);
if (_patches.yapf.ship_use_yapf) { if (_patches.yapf.ship_use_yapf) {
Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks); Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
@ -654,11 +654,11 @@ static const byte _ship_subcoord[4][6][3] = {
}, },
{ {
{ 0, 0, 0}, { 0, 0, 0},
{ 8,15, 7}, { 8, 15, 7},
{ 0, 0, 0}, { 0, 0, 0},
{ 8,15, 6}, { 8, 15, 6},
{ 0, 0, 0}, { 0, 0, 0},
{ 7,15, 0}, { 7, 15, 0},
} }
}; };
@ -880,7 +880,7 @@ int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2; y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
v->x_pos = x; v->x_pos = x;
v->y_pos = y; v->y_pos = y;
v->z_pos = GetSlopeZ(x,y); v->z_pos = GetSlopeZ(x, y);
v->z_height = 6; v->z_height = 6;
v->sprite_width = 6; v->sprite_width = 6;

View File

@ -78,7 +78,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
{ {
SetDParam(0, v->service_interval); SetDParam(0, v->service_interval);
SetDParam(1, v->date_of_last_service); SetDParam(1, v->date_of_last_service);
DrawString(13, 102, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); DrawString(13, 102, _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0);
} }
DrawShipImage(v, 3, 57, INVALID_VEHICLE); DrawShipImage(v, 3, 57, INVALID_VEHICLE);
@ -120,7 +120,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
mod = _ctrl_pressed? 5 : 10; mod = _ctrl_pressed? 5 : 10;
goto do_change_service_int; goto do_change_service_int;
case 6: /* decrease int */ case 6: /* decrease int */
mod = _ctrl_pressed?- 5 : -10; mod = _ctrl_pressed ? - 5 : -10;
do_change_service_int: do_change_service_int:
v = GetVehicle(w->window_number); v = GetVehicle(w->window_number);
@ -157,7 +157,7 @@ static const Widget _ship_details_widgets[] = {
static const WindowDesc _ship_details_desc = { static const WindowDesc _ship_details_desc = {
WDP_AUTO, WDP_AUTO, 405, 113, WDP_AUTO, WDP_AUTO, 405, 113,
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
_ship_details_widgets, _ship_details_widgets,
ShipDetailsWndProc ShipDetailsWndProc
@ -326,7 +326,7 @@ static const Widget _ship_view_widgets[] = {
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_SEND_SHIP_TODEPOT, STR_982A_SEND_SHIP_TO_DEPOT}, { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_SEND_SHIP_TODEPOT, STR_982A_SEND_SHIP_TO_DEPOT},
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, SPR_REFIT_VEHICLE, STR_983A_REFIT_CARGO_SHIP_TO_CARRY}, { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, SPR_REFIT_VEHICLE, STR_983A_REFIT_CARGO_SHIP_TO_CARRY},
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, SPR_SHOW_ORDERS, STR_9828_SHOW_SHIP_S_ORDERS}, { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, SPR_SHOW_ORDERS, STR_9828_SHOW_SHIP_S_ORDERS},
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, SPR_SHOW_VEHICLE_DETAILS,STR_982B_SHOW_SHIP_DETAILS}, { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, SPR_SHOW_VEHICLE_DETAILS, STR_982B_SHOW_SHIP_DETAILS},
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_SHIP, STR_CLONE_SHIP_INFO}, { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_SHIP, STR_CLONE_SHIP_INFO},
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL }, { WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL },
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL }, { WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL },

View File

@ -136,7 +136,7 @@ int32 CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
si->x = x; si->x = x;
si->y = y; si->y = y;
si->owner = _current_player; // owner of the sign; just eyecandy si->owner = _current_player; // owner of the sign; just eyecandy
si->z = GetSlopeZ(x,y); si->z = GetSlopeZ(x, y);
UpdateSignVirtCoords(si); UpdateSignVirtCoords(si);
MarkSignDirty(si); MarkSignDirty(si);
InvalidateWindow(WC_SIGN_LIST, 0); InvalidateWindow(WC_SIGN_LIST, 0);

View File

@ -199,7 +199,7 @@ static bool GenerateStationName(Station *st, TileIndex tile, int flag)
Station *s; Station *s;
FOR_ALL_STATIONS(s) { FOR_ALL_STATIONS(s) {
if (s != st && s->town==t) { if (s != st && s->town == t) {
uint str = M(s->string_id); uint str = M(s->string_id);
if (str <= 0x20) { if (str <= 0x20) {
if (str == M(STR_SV_STNAME_FOREST)) if (str == M(STR_SV_STNAME_FOREST))
@ -230,7 +230,7 @@ static bool GenerateStationName(Station *st, TileIndex tile, int flag)
} }
/* check close enough to town to get central as name? */ /* check close enough to town to get central as name? */
if (DistanceMax(tile,t->xy) < 8) { if (DistanceMax(tile, t->xy) < 8) {
found = M(STR_SV_STNAME); found = M(STR_SV_STNAME);
if (HASBIT(free_names, M(STR_SV_STNAME))) goto done; if (HASBIT(free_names, M(STR_SV_STNAME))) goto done;
@ -272,10 +272,10 @@ static bool GenerateStationName(Station *st, TileIndex tile, int flag)
/* check direction compared to town */ /* check direction compared to town */
{ {
static const int8 _direction_and_table[] = { static const int8 _direction_and_table[] = {
~( (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_EAST)) | (1<<M(STR_SV_STNAME_NORTH)) ), ~( (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_NORTH)) ), ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_EAST)) | (1<<M(STR_SV_STNAME_NORTH)) ), ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_EAST)) ), ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ),
}; };
free_names &= _direction_and_table[ free_names &= _direction_and_table[
@ -283,7 +283,7 @@ static bool GenerateStationName(Station *st, TileIndex tile, int flag)
(TileY(tile) < TileY(t->xy)) * 2]; (TileY(tile) < TileY(t->xy)) * 2];
} }
tmp = free_names & ((1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<6)|(1<<7)|(1<<12)|(1<<26)|(1<<27)|(1<<28)|(1<<29)|(1<<30)); tmp = free_names & ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 26) | (1 << 27) | (1 << 28) | (1 << 29) | (1 << 30));
if (tmp == 0) { if (tmp == 0) {
_error_message = STR_3007_TOO_MANY_STATIONS_LOADING; _error_message = STR_3007_TOO_MANY_STATIONS_LOADING;
return false; return false;
@ -368,7 +368,7 @@ static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *c
} }
SetDParam(0, st->index); SetDParam(0, st->index);
AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0); AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT | NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0);
} }
// Get a list of the cargo types being produced around the tile. // Get a list of the cargo types being produced around the tile.
@ -646,10 +646,10 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
int flat_z = z; int flat_z = z;
if (tileh != SLOPE_FLAT) { if (tileh != SLOPE_FLAT) {
// need to check so the entrance to the station is not pointing at a slope. // need to check so the entrance to the station is not pointing at a slope.
if ((invalid_dirs&1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) || if ((invalid_dirs & 1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) ||
(invalid_dirs&2 && !(tileh & SLOPE_SE) && h_cur == 1) || (invalid_dirs & 2 && !(tileh & SLOPE_SE) && h_cur == 1) ||
(invalid_dirs&4 && !(tileh & SLOPE_SW) && w_cur == 1) || (invalid_dirs & 4 && !(tileh & SLOPE_SW) && w_cur == 1) ||
(invalid_dirs&8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) { (invalid_dirs & 8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) {
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
} }
cost += _price.terraform; cost += _price.terraform;
@ -748,7 +748,7 @@ static inline byte *CreateSingle(byte *layout, int n)
{ {
int i = n; int i = n;
do *layout++ = 0; while (--i); do *layout++ = 0; while (--i);
layout[((n-1) >> 1)-n] = 2; layout[((n - 1) >> 1) - n] = 2;
return layout; return layout;
} }
@ -757,8 +757,8 @@ static inline byte *CreateMulti(byte *layout, int n, byte b)
int i = n; int i = n;
do *layout++ = b; while (--i); do *layout++ = b; while (--i);
if (n > 4) { if (n > 4) {
layout[0-n] = 0; layout[0 - n] = 0;
layout[n-1-n] = 0; layout[n - 1 - n] = 0;
} }
return layout; return layout;
} }
@ -1623,7 +1623,7 @@ static int32 RemoveAirport(Station *st, uint32 flags)
DeleteAnimatedTile(tile_cur); DeleteAnimatedTile(tile_cur);
DoClearSquare(tile_cur); DoClearSquare(tile_cur);
} }
} END_TILE_LOOP(tile_cur, w,h,tile) } END_TILE_LOOP(tile_cur, w, h, tile)
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
for (uint i = 0; i < afc->nof_depots; ++i) { for (uint i = 0; i < afc->nof_depots; ++i) {

View File

@ -730,7 +730,7 @@ static bool CheckCommandsMatch(char *a, char *b, const char *name)
{ {
ParsedCommandStruct templ; ParsedCommandStruct templ;
ParsedCommandStruct lang; ParsedCommandStruct lang;
int i,j; int i, j;
bool result = true; bool result = true;
ExtractCommandString(&templ, b, true); ExtractCommandString(&templ, b, true);
@ -914,7 +914,7 @@ static void ParseFile(const char *file, bool english)
in = fopen(file, "r"); in = fopen(file, "r");
if (in == NULL) fatal("Cannot open file"); if (in == NULL) fatal("Cannot open file");
_cur_line = 1; _cur_line = 1;
while (fgets(buf, sizeof(buf),in) != NULL) { while (fgets(buf, sizeof(buf), in) != NULL) {
rstrip(buf); rstrip(buf);
HandleString(buf, english); HandleString(buf, english);
_cur_line++; _cur_line++;

View File

@ -63,7 +63,7 @@ static inline int64 GetInt64(const int32 **argv)
assert(argv); assert(argv);
result = (uint32)(*argv)[0] + ((uint64)(uint32)(*argv)[1] << 32); result = (uint32)(*argv)[0] + ((uint64)(uint32)(*argv)[1] << 32);
(*argv)+=2; (*argv) += 2;
return result; return result;
} }
@ -421,37 +421,37 @@ static int DeterminePluralForm(int32 n)
* Used in: * Used in:
* Latvian */ * Latvian */
case 3: case 3:
return n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2; return n%10 == 1 && n%100 != 11 ? 0 : n != 0 ? 1 : 2;
/* Three forms, special case for one and two /* Three forms, special case for one and two
* Used in: * Used in:
* Gaelige (Irish) */ * Gaelige (Irish) */
case 4: case 4:
return n==1 ? 0 : n==2 ? 1 : 2; return n == 1 ? 0 : n == 2 ? 1 : 2;
/* Three forms, special case for numbers ending in 1[2-9] /* Three forms, special case for numbers ending in 1[2-9]
* Used in: * Used in:
* Lithuanian */ * Lithuanian */
case 5: case 5:
return n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2; return n%10 == 1 && n%100 != 11 ? 0 : n%10 >= 2 && (n%100<10 || n%100 >= 20) ? 1 : 2;
/* Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4] /* Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
* Used in: * Used in:
* Croatian, Czech, Russian, Slovak, Ukrainian */ * Croatian, Czech, Russian, Slovak, Ukrainian */
case 6: case 6:
return n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2; return n%10 == 1 && n%100 != 11 ? 0 : n%10 >= 2 && n%10 <= 4 && (n%100<10 || n%100 >= 20) ? 1 : 2;
/* Three forms, special case for one and some numbers ending in 2, 3, or 4 /* Three forms, special case for one and some numbers ending in 2, 3, or 4
* Used in: * Used in:
* Polish */ * Polish */
case 7: case 7:
return n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2; return n == 1 ? 0 : n%10 >= 2 && n%10 <= 4 && (n%100<10 || n%100 >= 20) ? 1 : 2;
/* Four forms, special case for one and all numbers ending in 02, 03, or 04 /* Four forms, special case for one and all numbers ending in 02, 03, or 04
* Used in: * Used in:
* Slovenian */ * Slovenian */
case 8: case 8:
return n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3; return n%100 == 1 ? 0 : n%100 == 2 ? 1 : n%100 == 3 || n%100 == 4 ? 2 : 3;
} }
} }
@ -459,7 +459,7 @@ static const char *ParseStringChoice(const char *b, uint form, char *dst, int *d
{ {
//<NUM> {Length of each string} {each string} //<NUM> {Length of each string} {each string}
uint n = (byte)*b++; uint n = (byte)*b++;
uint pos,i, mylen=0,mypos=0; uint pos, i, mylen = 0, mypos = 0;
for (i = pos = 0; i != n; i++) { for (i = pos = 0; i != n; i++) {
uint len = (byte)*b++; uint len = (byte)*b++;

View File

@ -21,7 +21,7 @@ struct AiDefaultRoadBlock {
}; };
#define MKHDR(a,b,c,d,e) a,b,c,d,e, #define MKHDR(a, b, c, d, e) a, b, c, d, e,
#define MKDEPOT(a, b, c) {0, a, {b, c}} #define MKDEPOT(a, b, c) {0, a, {b, c}}
#define MKSTATION(a, b, c) {1, a, {b, c}} #define MKSTATION(a, b, c) {1, a, {b, c}}
#define MKRAIL(a, b, c) {2, a, {b, c}} #define MKRAIL(a, b, c) {2, a, {b, c}}
@ -424,17 +424,17 @@ static const AiDefaultRailBlock * const _default_rail_track_data[] = {
#undef MKHDR #undef MKHDR
#define MKHDR(a) a,{ #define MKHDR(a) a, {
static const AiDefaultBlockData _roaddata_ai_0_data[] = { static const AiDefaultBlockData _roaddata_ai_0_data[] = {
MKDEPOT(2, -1,1), MKDEPOT(2, -1, 1),
MKSTATION(0x2, -1,0), MKSTATION(0x2, -1, 0),
MKRAIL(0xC, 0,0), MKRAIL(0xC, 0, 0),
MKRAIL(0x9, 0,1), MKRAIL(0x9, 0, 1),
MKCLRRAIL(0, 0,-1), MKCLRRAIL(0, 0, -1),
MKCLRRAIL(0, 1,0), MKCLRRAIL(0, 1, 0),
MKCLRRAIL(0, 1,1), MKCLRRAIL(0, 1, 1),
MKCLRRAIL(0, 0,2), MKCLRRAIL(0, 0, 2),
MKEND MKEND
}; };
@ -443,14 +443,14 @@ static const AiDefaultRoadBlock _roaddata_ai_0 = {
}; };
static const AiDefaultBlockData _roaddata_ai_1_data[] = { static const AiDefaultBlockData _roaddata_ai_1_data[] = {
MKDEPOT(1, 0,-1), MKDEPOT(1, 0, -1),
MKSTATION(0x1, 1,-1), MKSTATION(0x1, 1, -1),
MKRAIL(0x3, 0,0), MKRAIL(0x3, 0, 0),
MKRAIL(0x9, 1,0), MKRAIL(0x9, 1, 0),
MKCLRRAIL(0, -1,0), MKCLRRAIL(0, -1, 0),
MKCLRRAIL(0, 0,1), MKCLRRAIL(0, 0, 1),
MKCLRRAIL(0, 1,1), MKCLRRAIL(0, 1, 1),
MKCLRRAIL(0, 2,0), MKCLRRAIL(0, 2, 0),
MKEND MKEND
}; };
@ -459,14 +459,14 @@ static const AiDefaultRoadBlock _roaddata_ai_1 = {
}; };
static const AiDefaultBlockData _roaddata_ai_2_data[] = { static const AiDefaultBlockData _roaddata_ai_2_data[] = {
MKDEPOT(3, 1,1), MKDEPOT(3, 1, 1),
MKSTATION(0x3, 0,1), MKSTATION(0x3, 0, 1),
MKRAIL(0x6, 0,0), MKRAIL(0x6, 0, 0),
MKRAIL(0xC, 1,0), MKRAIL(0xC, 1, 0),
MKCLRRAIL(0, -1,0), MKCLRRAIL(0, -1, 0),
MKCLRRAIL(0, 0,-1), MKCLRRAIL(0, 0, -1),
MKCLRRAIL(0, 1,-1), MKCLRRAIL(0, 1, -1),
MKCLRRAIL(0, 2,0), MKCLRRAIL(0, 2, 0),
MKEND MKEND
}; };
@ -475,14 +475,14 @@ static const AiDefaultRoadBlock _roaddata_ai_2 = {
}; };
static const AiDefaultBlockData _roaddata_ai_3_data[] = { static const AiDefaultBlockData _roaddata_ai_3_data[] = {
MKDEPOT(0, 1,0), MKDEPOT(0, 1, 0),
MKSTATION(0x0, 1,1), MKSTATION(0x0, 1, 1),
MKRAIL(0x6, 0,0), MKRAIL(0x6, 0, 0),
MKRAIL(0x3, 0,1), MKRAIL(0x3, 0, 1),
MKCLRRAIL(0, 0,-1), MKCLRRAIL(0, 0, -1),
MKCLRRAIL(0, -1,0), MKCLRRAIL(0, -1, 0),
MKCLRRAIL(0, -1,1), MKCLRRAIL(0, -1, 1),
MKCLRRAIL(0, 0,2), MKCLRRAIL(0, 0, 2),
MKEND MKEND
}; };
@ -491,11 +491,11 @@ static const AiDefaultRoadBlock _roaddata_ai_3 = {
}; };
static const AiDefaultBlockData _roaddata_ai_4_data[] = { static const AiDefaultBlockData _roaddata_ai_4_data[] = {
MKSTATION(0x2, -1,0), MKSTATION(0x2, -1, 0),
MKRAIL(0x8, 0,0), MKRAIL(0x8, 0, 0),
MKCLRRAIL(0, 0,-1), MKCLRRAIL(0, 0, -1),
MKCLRRAIL(0, 1,0), MKCLRRAIL(0, 1, 0),
MKCLRRAIL(0, 0,1), MKCLRRAIL(0, 0, 1),
MKEND MKEND
}; };
@ -504,11 +504,11 @@ static const AiDefaultRoadBlock _roaddata_ai_4 = {
}; };
static const AiDefaultBlockData _roaddata_ai_5_data[] = { static const AiDefaultBlockData _roaddata_ai_5_data[] = {
MKSTATION(0x3, 0,1), MKSTATION(0x3, 0, 1),
MKRAIL(0x4, 0,0), MKRAIL(0x4, 0, 0),
MKCLRRAIL(0, -1,0), MKCLRRAIL(0, -1, 0),
MKCLRRAIL(0, 0,-1), MKCLRRAIL(0, 0, -1),
MKCLRRAIL(0, 1,0), MKCLRRAIL(0, 1, 0),
MKEND MKEND
}; };
@ -517,11 +517,11 @@ static const AiDefaultRoadBlock _roaddata_ai_5 = {
}; };
static const AiDefaultBlockData _roaddata_ai_6_data[] = { static const AiDefaultBlockData _roaddata_ai_6_data[] = {
MKSTATION(0x0, 1,1), MKSTATION(0x0, 1, 1),
MKRAIL(0x2, 0,1), MKRAIL(0x2, 0, 1),
MKCLRRAIL(0, 0,0), MKCLRRAIL(0, 0, 0),
MKCLRRAIL(0, -1,0), MKCLRRAIL(0, -1, 0),
MKCLRRAIL(0, 0,2), MKCLRRAIL(0, 0, 2),
MKEND MKEND
}; };
@ -530,11 +530,11 @@ static const AiDefaultRoadBlock _roaddata_ai_6 = {
}; };
static const AiDefaultBlockData _roaddata_ai_7_data[] = { static const AiDefaultBlockData _roaddata_ai_7_data[] = {
MKSTATION(0x1, 1,-1), MKSTATION(0x1, 1, -1),
MKRAIL(0x1, 1,0), MKRAIL(0x1, 1, 0),
MKCLRRAIL(0, 0,0), MKCLRRAIL(0, 0, 0),
MKCLRRAIL(0, 1,1), MKCLRRAIL(0, 1, 1),
MKCLRRAIL(0, 2,0), MKCLRRAIL(0, 2, 0),
MKEND MKEND
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1931,7 +1931,7 @@ static const char *name_czech_suffix[] = {
static const char *name_romanian_real[]= { static const char *name_romanian_real[] = {
"Adjud", "Adjud",
"Alba Iulia", "Alba Iulia",
"Alexandria", "Alexandria",

View File

@ -34,7 +34,7 @@ static const DrawTileSeqStruct _station_display_datas_4[] = {
{ 0, 0, 0, 16, 5, 7, SPR_RAIL_PLATFORM_PILLARS_X_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 0, 0, 0, 16, 5, 7, SPR_RAIL_PLATFORM_PILLARS_X_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0,(byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT }, { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END() TILE_SEQ_END()
}; };
@ -42,7 +42,7 @@ static const DrawTileSeqStruct _station_display_datas_5[] = {
{ 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0,(byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT }, { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END() TILE_SEQ_END()
}; };
@ -50,7 +50,7 @@ static const DrawTileSeqStruct _station_display_datas_6[] = {
{ 0, 0, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 0, 0, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_PILLARS_X_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_PILLARS_X_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0,(byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT }, { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END() TILE_SEQ_END()
}; };
@ -58,7 +58,7 @@ static const DrawTileSeqStruct _station_display_datas_7[] = {
{ 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE }, { 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0,(byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT }, { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END() TILE_SEQ_END()
}; };

View File

@ -25,7 +25,7 @@ static const TreePos _tree_layout_xy[][4] = {
{ { 3, 9 }, { 8, 2 }, { 9, 9 }, { 1, 5 } } { { 3, 9 }, { 8, 2 }, { 9, 9 }, { 1, 5 } }
}; };
static const PalSpriteID _tree_layout_sprite[164+(79-48+1)][4] = { static const PalSpriteID _tree_layout_sprite[164 + (79 - 48 + 1)][4] = {
{ { 0x652, PAL_NONE }, { 0x659, PAL_NONE }, { 0x660, PAL_NONE }, { 0x667, PAL_NONE } }, /* 0 */ { { 0x652, PAL_NONE }, { 0x659, PAL_NONE }, { 0x660, PAL_NONE }, { 0x667, PAL_NONE } }, /* 0 */
{ { 0x652, PAL_NONE }, { 0x667, PAL_NONE }, { 0x66e, PAL_NONE }, { 0x675, PAL_NONE } }, /* 1 */ { { 0x652, PAL_NONE }, { 0x667, PAL_NONE }, { 0x66e, PAL_NONE }, { 0x675, PAL_NONE } }, /* 1 */
{ { 0x652, PAL_NONE }, { 0x66e, PAL_NONE }, { 0x659, PAL_NONE }, { 0x675, PAL_NONE } }, /* 2 */ { { 0x652, PAL_NONE }, { 0x66e, PAL_NONE }, { 0x659, PAL_NONE }, { 0x675, PAL_NONE } }, /* 2 */

View File

@ -273,7 +273,7 @@ static const Widget _terraform_widgets[] = {
}; };
static const WindowDesc _terraform_desc = { static const WindowDesc _terraform_desc = {
WDP_ALIGN_TBR, 22+36, 158, 36, WDP_ALIGN_TBR, 22 + 36, 158, 36,
WC_SCEN_LAND_GEN, WC_NONE, WC_SCEN_LAND_GEN, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
_terraform_widgets, _terraform_widgets,

View File

@ -246,9 +246,9 @@ static bool IsCloseToTown(TileIndex tile, uint dist)
static void MarkTownSignDirty(Town *t) static void MarkTownSignDirty(Town *t)
{ {
MarkAllViewportsDirty( MarkAllViewportsDirty(
t->sign.left-6, t->sign.left - 6,
t->sign.top-3, t->sign.top - 3,
t->sign.left+t->sign.width_1*4+12, t->sign.left + t->sign.width_1 * 4 + 12,
t->sign.top + 45 t->sign.top + 45
); );
} }
@ -530,10 +530,10 @@ static bool IsRoadAllowedHere(TileIndex tile, int dir)
no_slope: no_slope:
/* Tile has no slope /* Tile has no slope
* Disallow the road if any neighboring tile has a road. */ * Disallow the road if any neighboring tile has a road. */
if (HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+1]))), dir^2) || if (HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir + 1]))), dir ^ 2) ||
HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+3]))), dir^2) || HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir + 3]))), dir ^ 2) ||
HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+1]) + ToTileIndexDiff(_roadblock_tileadd[dir+2]))), dir) || HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir + 1]) + ToTileIndexDiff(_roadblock_tileadd[dir + 2]))), dir) ||
HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+3]) + ToTileIndexDiff(_roadblock_tileadd[dir+2]))), dir)) HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir + 3]) + ToTileIndexDiff(_roadblock_tileadd[dir + 2]))), dir))
return false; return false;
/* Otherwise allow */ /* Otherwise allow */
@ -644,7 +644,7 @@ static void GrowTownInTile(TileIndex* tile_ptr, RoadBits mask, int block, Town*
} }
rcmd = (RoadBits)((1 << a) + (1 << b)); rcmd = (RoadBits)((1 << a) + (1 << b));
} else if (block < 5 && !HASBIT(mask,block^2)) { } else if (block < 5 && !HASBIT(mask, block ^ 2)) {
/* Continue building on a partial road. /* Continue building on a partial road.
* Always OK. */ * Always OK. */
_grow_town_result = 0; _grow_town_result = 0;
@ -771,7 +771,7 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
/* Select a random bit from the blockmask, walk a step /* Select a random bit from the blockmask, walk a step
* and continue the search from there. */ * and continue the search from there. */
do block = Random() & 3; while (!HASBIT(mask,block)); do block = Random() & 3; while (!HASBIT(mask, block));
tile += ToTileIndexDiff(_roadblock_tileadd[block]); tile += ToTileIndexDiff(_roadblock_tileadd[block]);
if (IsTileType(tile, MP_STREET)) { if (IsTileType(tile, MP_STREET)) {

View File

@ -2988,7 +2988,7 @@ static void TrainController(Vehicle *v, bool update_image)
} else if (HasSignalOnTrackdir(gp.new_tile, i)) { } else if (HasSignalOnTrackdir(gp.new_tile, i)) {
v->cur_speed = 0; v->cur_speed = 0;
v->subspeed = 0; v->subspeed = 0;
v->progress = 255-10; v->progress = 255 - 10;
if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) { if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) {
TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir); TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir);
VehicleAtSignalData vasd; VehicleAtSignalData vasd;

View File

@ -317,7 +317,7 @@ int32 CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
struct TreeListEnt { struct TreeListEnt {
SpriteID image; SpriteID image;
SpriteID pal; SpriteID pal;
byte x,y; byte x, y;
}; };
static void DrawTile_Trees(TileInfo *ti) static void DrawTile_Trees(TileInfo *ti)

View File

@ -390,8 +390,8 @@ void SetDParamStr(uint n, const char *str);
StringID BindCString(const char *str); StringID BindCString(const char *str);
#define COPY_IN_DPARAM(offs,src,num) memcpy(_decode_parameters + offs, src, sizeof(uint32) * (num)) #define COPY_IN_DPARAM(offs, src, num) memcpy(_decode_parameters + offs, src, sizeof(uint32) * (num))
#define COPY_OUT_DPARAM(dst,offs,num) memcpy(dst,_decode_parameters + offs, sizeof(uint32) * (num)) #define COPY_OUT_DPARAM(dst, offs, num) memcpy(dst, _decode_parameters + offs, sizeof(uint32) * (num))
#define SET_EXPENSES_TYPE(x) _yearly_expenses_type = x; #define SET_EXPENSES_TYPE(x) _yearly_expenses_type = x;

View File

@ -188,9 +188,9 @@ Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_c
} }
FOR_ALL_VEHICLES(veh) { FOR_ALL_VEHICLES(veh) {
if (without_crashed && (veh->vehstatus & VS_CRASHED) != 0) continue; if (without_crashed && (veh->vehstatus & VS_CRASHED) != 0) continue;
if ((veh->type == VEH_TRAIN || veh->type == VEH_ROAD) && (z==0xFF || veh->z_pos == z)) { if ((veh->type == VEH_TRAIN || veh->type == VEH_ROAD) && (z == 0xFF || veh->z_pos == z)) {
if ((veh->x_pos>>4) >= x1 && (veh->x_pos>>4) <= x2 && if ((veh->x_pos >> 4) >= x1 && (veh->x_pos >> 4) <= x2 &&
(veh->y_pos>>4) >= y1 && (veh->y_pos>>4) <= y2) { (veh->y_pos >> 4) >= y1 && (veh->y_pos >> 4) <= y2) {
return veh; return veh;
} }
} }
@ -421,7 +421,7 @@ static void UpdateVehiclePosHash(Vehicle* v, int x, int y)
int old_x = v->left_coord; int old_x = v->left_coord;
int old_y = v->top_coord; int old_y = v->top_coord;
new_hash = (x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(x,y)]; new_hash = (x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(x, y)];
old_hash = (old_x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(old_x, old_y)]; old_hash = (old_x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(old_x, old_y)];
if (old_hash == new_hash) return; if (old_hash == new_hash) return;

View File

@ -343,16 +343,16 @@ static void VehicleRefitWndProc(Window *w, WindowEvent *e)
SetDParam(1, v->unitnumber); SetDParam(1, v->unitnumber);
DrawWindowWidgets(w); DrawWindowWidgets(w);
WP(w,refit_d).cargo = DrawVehicleRefitWindow(WP(w, refit_d).list, WP(w, refit_d).sel, w->vscroll.pos, w->vscroll.cap, w->resize.step_height); WP(w, refit_d).cargo = DrawVehicleRefitWindow(WP(w, refit_d).list, WP(w, refit_d).sel, w->vscroll.pos, w->vscroll.cap, w->resize.step_height);
if (WP(w,refit_d).cargo != NULL) { if (WP(w, refit_d).cargo != NULL) {
int32 cost; int32 cost;
cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8, cost = DoCommand(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8,
DC_QUERY_COST, GetCmdRefitVeh(GetVehicle(w->window_number)->type)); DC_QUERY_COST, GetCmdRefitVeh(GetVehicle(w->window_number)->type));
if (!CmdFailed(cost)) { if (!CmdFailed(cost)) {
SetDParam(0, WP(w,refit_d).cargo->cargo); SetDParam(0, WP(w, refit_d).cargo->cargo);
SetDParam(1, _returned_refit_capacity); SetDParam(1, _returned_refit_capacity);
SetDParam(2, cost); SetDParam(2, cost);
DrawString(2, w->widget[5].top + 1, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0); DrawString(2, w->widget[5].top + 1, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0);
@ -365,12 +365,12 @@ static void VehicleRefitWndProc(Window *w, WindowEvent *e)
case 3: { // listbox case 3: { // listbox
int y = e->we.click.pt.y - w->widget[3].top; int y = e->we.click.pt.y - w->widget[3].top;
if (y >= 0) { if (y >= 0) {
WP(w,refit_d).sel = (y / (int)w->resize.step_height) + w->vscroll.pos; WP(w, refit_d).sel = (y / (int)w->resize.step_height) + w->vscroll.pos;
SetWindowDirty(w); SetWindowDirty(w);
} }
} break; } break;
case 6: // refit button case 6: // refit button
if (WP(w,refit_d).cargo != NULL) { if (WP(w, refit_d).cargo != NULL) {
const Vehicle *v = GetVehicle(w->window_number); const Vehicle *v = GetVehicle(w->window_number);
if (WP(w, refit_d).order == INVALID_VEH_ORDER_ID) { if (WP(w, refit_d).order == INVALID_VEH_ORDER_ID) {
@ -382,9 +382,9 @@ static void VehicleRefitWndProc(Window *w, WindowEvent *e)
case VEH_SHIP: command = CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP); break; case VEH_SHIP: command = CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP); break;
case VEH_AIRCRAFT: command = CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT); break; case VEH_AIRCRAFT: command = CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT); break;
} }
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8, NULL, command)) DeleteWindow(w); if (DoCommandP(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8, NULL, command)) DeleteWindow(w);
} else { } else {
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8 | WP(w, refit_d).order << 16, NULL, CMD_ORDER_REFIT)) DeleteWindow(w); if (DoCommandP(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8 | WP(w, refit_d).order << 16, NULL, CMD_ORDER_REFIT)) DeleteWindow(w);
} }
} }
break; break;
@ -418,7 +418,7 @@ static const Widget _vehicle_refit_widgets[] = {
static const WindowDesc _vehicle_refit_desc = { static const WindowDesc _vehicle_refit_desc = {
WDP_AUTO, WDP_AUTO, 240, 174, WDP_AUTO, WDP_AUTO, 240, 174,
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW, WC_VEHICLE_REFIT, WC_VEHICLE_VIEW,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
_vehicle_refit_widgets, _vehicle_refit_widgets,
VehicleRefitWndProc, VehicleRefitWndProc,
@ -426,7 +426,7 @@ static const WindowDesc _vehicle_refit_desc = {
/** Show the refit window for a vehicle /** Show the refit window for a vehicle
* @param *v The vehicle to show the refit window for * @param *v The vehicle to show the refit window for
* @param order of the vehicle (?) * @param order of the vehicle ( ? )
*/ */
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order) void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order)
{ {

View File

@ -45,7 +45,7 @@ static void MakePalette()
LOGPALETTE *pal; LOGPALETTE *pal;
uint i; uint i;
pal = (LOGPALETTE*)alloca(sizeof(LOGPALETTE) + (256-1) * sizeof(PALETTEENTRY)); pal = (LOGPALETTE*)alloca(sizeof(LOGPALETTE) + (256 - 1) * sizeof(PALETTEENTRY));
pal->palVersion = 0x300; pal->palVersion = 0x300;
pal->palNumEntries = 256; pal->palNumEntries = 256;
@ -653,8 +653,8 @@ static bool AllocateDibSection(int w, int h)
_wnd.alloced_bits = NULL; _wnd.alloced_bits = NULL;
} }
bi = (BITMAPINFO*)alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256); bi = (BITMAPINFO*)alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256);
memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256); memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256);
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
if (_wnd.double_size) { if (_wnd.double_size) {

View File

@ -2050,7 +2050,7 @@ static bool SwapDirection(HighLightStyle style, TileIndex start_tile, TileIndex
* To correctly get the height difference we need the direction we are dragging * To correctly get the height difference we need the direction we are dragging
* in, as well as with what kind of tool we are dragging. For example a horizontal * in, as well as with what kind of tool we are dragging. For example a horizontal
* autorail tool that starts in bottom and ends at the top of a tile will need the * autorail tool that starts in bottom and ends at the top of a tile will need the
* maximum of SW,S and SE,N corners respectively. This is handled by the lookup table below * maximum of SW, S and SE, N corners respectively. This is handled by the lookup table below
* See _tileoffs_by_dir in map.c for the direction enums if you can't figure out * See _tileoffs_by_dir in map.c for the direction enums if you can't figure out
* the values yourself. * the values yourself.
* @param style HightlightStyle of drag. This includes direction and style (autorail, rect, etc.) * @param style HightlightStyle of drag. This includes direction and style (autorail, rect, etc.)
@ -2395,7 +2395,7 @@ bool VpHandlePlaceSizingDrag()
e.we.place.userdata = _thd.userdata; e.we.place.userdata = _thd.userdata;
/* stop drag mode if the window has been closed */ /* stop drag mode if the window has been closed */
w = FindWindowById(_thd.window_class,_thd.window_number); w = FindWindowById(_thd.window_class, _thd.window_number);
if (w == NULL) { if (w == NULL) {
ResetObjectToPlace(); ResetObjectToPlace();
return false; return false;

View File

@ -651,7 +651,7 @@ static void FloodVehicle(Vehicle *v)
SetDParam(0, pass); SetDParam(0, pass);
AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED, AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED,
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0), NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
v->index, v->index,
0); 0);
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);

View File

@ -335,7 +335,7 @@ static const TCHAR * const _expand_texts[] = {_T("S&how report >>"), _T("&Hide r
static void SetWndSize(HWND wnd, int mode) static void SetWndSize(HWND wnd, int mode)
{ {
RECT r,r2; RECT r, r2;
int offs; int offs;
GetWindowRect(wnd, &r); GetWindowRect(wnd, &r);
@ -368,7 +368,7 @@ static bool DoEmergencySave(HWND wnd)
return b; return b;
} }
static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM lParam) static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
switch (msg) { switch (msg) {
case WM_INITDIALOG: { case WM_INITDIALOG: {
@ -549,7 +549,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
} }
{ {
int i,j; int i, j;
#ifdef _M_AMD64 #ifdef _M_AMD64
uint32 *b = (uint32*)ep->ContextRecord->Rsp; uint32 *b = (uint32*)ep->ContextRecord->Rsp;
#else #else
@ -557,7 +557,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
#endif #endif
for (j = 0; j != 24; j++) { for (j = 0; j != 24; j++) {
for (i = 0; i != 8; i++) { for (i = 0; i != 8; i++) {
if (IsBadReadPtr(b,sizeof(uint32))) { if (IsBadReadPtr(b, sizeof(uint32))) {
output += sprintf(output, " ????????"); //OCR: WAS - , 0); output += sprintf(output, " ????????"); //OCR: WAS - , 0);
} else { } else {
output += sprintf(output, " %.8X", *b); output += sprintf(output, " %.8X", *b);

View File

@ -235,25 +235,25 @@ static void DrawOverlappedWindow(Window* const *wz, int left, int top, int right
bottom > v->top && bottom > v->top &&
left < v->left + v->width && left < v->left + v->width &&
top < v->top + v->height) { top < v->top + v->height) {
if (left < (x=v->left)) { if (left < (x = v->left)) {
DrawOverlappedWindow(wz, left, top, x, bottom); DrawOverlappedWindow(wz, left, top, x, bottom);
DrawOverlappedWindow(wz, x, top, right, bottom); DrawOverlappedWindow(wz, x, top, right, bottom);
return; return;
} }
if (right > (x=v->left + v->width)) { if (right > (x = v->left + v->width)) {
DrawOverlappedWindow(wz, left, top, x, bottom); DrawOverlappedWindow(wz, left, top, x, bottom);
DrawOverlappedWindow(wz, x, top, right, bottom); DrawOverlappedWindow(wz, x, top, right, bottom);
return; return;
} }
if (top < (x=v->top)) { if (top < (x = v->top)) {
DrawOverlappedWindow(wz, left, top, right, x); DrawOverlappedWindow(wz, left, top, right, x);
DrawOverlappedWindow(wz, left, x, right, bottom); DrawOverlappedWindow(wz, left, x, right, bottom);
return; return;
} }
if (bottom > (x=v->top + v->height)) { if (bottom > (x = v->top + v->height)) {
DrawOverlappedWindow(wz, left, top, right, x); DrawOverlappedWindow(wz, left, top, right, x);
DrawOverlappedWindow(wz, left, x, right, bottom); DrawOverlappedWindow(wz, left, x, right, bottom);
return; return;