summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-02-01 07:36:15 +0000
committertron <tron@openttd.org>2006-02-01 07:36:15 +0000
commit84fb96fe85e75b038b527471428189170021f8b7 (patch)
treea7d69d6390e8880d090f15560161694c3ce6126d
parent22dc05faf2219f6e3803f9cbff92249823bb11eb (diff)
downloadopenttd-84fb96fe85e75b038b527471428189170021f8b7.tar.xz
(svn r3511) More whitespace ([FS#46] by Rubidium)
-rw-r--r--ai/default/default.c76
-rw-r--r--aircraft_cmd.c2
-rw-r--r--aircraft_gui.c18
-rw-r--r--bridge_gui.c2
-rw-r--r--clear_cmd.c4
-rw-r--r--depot.h2
-rw-r--r--disaster_cmd.c2
-rw-r--r--dock_gui.c2
-rw-r--r--economy.c17
-rw-r--r--fileio.c14
-rw-r--r--gfx.c22
-rw-r--r--graph_gui.c38
-rw-r--r--industry_cmd.c6
-rw-r--r--industry_gui.c6
-rw-r--r--landscape.c2
-rw-r--r--macros.h6
-rw-r--r--main_gui.c8
-rw-r--r--mersenne.c10
-rw-r--r--misc.c5
-rw-r--r--misc_gui.c11
-rw-r--r--music_gui.c6
-rw-r--r--network.c4
-rw-r--r--network_gui.c4
-rw-r--r--network_server.c2
-rw-r--r--npf.c2
-rw-r--r--order_gui.c4
-rw-r--r--pathfind.c10
-rw-r--r--player.h2
-rw-r--r--player_gui.c22
-rw-r--r--players.c32
-rw-r--r--rail_cmd.c4
-rw-r--r--rail_gui.c6
-rw-r--r--road_cmd.c8
-rw-r--r--road_gui.c2
-rw-r--r--roadveh_cmd.c2
-rw-r--r--roadveh_gui.c16
-rw-r--r--saveload.c8
-rw-r--r--settings.c51
-rw-r--r--settings_gui.c6
-rw-r--r--ship_gui.c14
-rw-r--r--smallmap_gui.c2
-rw-r--r--station_cmd.c2
-rw-r--r--strgen/strgen.c66
-rw-r--r--strings.c5
-rw-r--r--terraform_gui.c2
-rw-r--r--town_cmd.c19
-rw-r--r--town_gui.c2
-rw-r--r--train_cmd.c10
-rw-r--r--train_gui.c24
-rw-r--r--tree_cmd.c2
-rw-r--r--tunnelbridge_cmd.c16
-rw-r--r--unix.c2
-rw-r--r--vehicle.c9
-rw-r--r--video/sdl_v.c4
-rw-r--r--video/win32_v.c2
-rw-r--r--viewport.c6
-rw-r--r--widget.c2
-rw-r--r--win32.c6
-rw-r--r--window.c2
59 files changed, 321 insertions, 320 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index 8daaf239e..c183caafc 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -655,7 +655,7 @@ static void AiWantLongIndustryRoute(Player *p)
FoundRoute fr;
i = 60;
- for(;;) {
+ for (;;) {
// look for one from the subsidy list
AiFindSubsidyIndustryRoute(&fr);
if (IS_INT_INSIDE(fr.distance, 60, 90+1))
@@ -761,7 +761,7 @@ static void AiWantMediumIndustryRoute(Player *p)
FoundRoute fr;
i = 60;
- for(;;) {
+ for (;;) {
// look for one from the subsidy list
AiFindSubsidyIndustryRoute(&fr);
@@ -833,7 +833,7 @@ static void AiWantShortIndustryRoute(Player *p)
FoundRoute fr;
i = 60;
- for(;;) {
+ for (;;) {
// look for one from the subsidy list
AiFindSubsidyIndustryRoute(&fr);
@@ -905,7 +905,7 @@ static void AiWantMailRoute(Player *p)
FoundRoute fr;
i = 60;
- for(;;) {
+ for (;;) {
// look for one from the subsidy list
AiFindSubsidyPassengerRoute(&fr);
@@ -1010,7 +1010,7 @@ static void AiWantPassengerRoute(Player *p)
FoundRoute fr;
i = 60;
- for(;;) {
+ for (;;) {
// look for one from the subsidy list
AiFindSubsidyPassengerRoute(&fr);
@@ -1102,7 +1102,7 @@ static void AiWantLongRoadIndustryRoute(Player *p)
FoundRoute fr;
i = 60;
- for(;;) {
+ for (;;) {
// look for one from the subsidy list
AiFindSubsidyIndustryRoute(&fr);
@@ -1162,7 +1162,7 @@ static void AiWantMediumRoadIndustryRoute(Player *p)
FoundRoute fr;
i = 60;
- for(;;) {
+ for (;;) {
// look for one from the subsidy list
AiFindSubsidyIndustryRoute(&fr);
@@ -1222,7 +1222,7 @@ static void AiWantLongRoadPassengerRoute(Player *p)
FoundRoute fr;
i = 60;
- for(;;) {
+ for (;;) {
// look for one from the subsidy list
AiFindSubsidyPassengerRoute(&fr);
@@ -1285,7 +1285,7 @@ static void AiWantPassengerRouteInsideTown(Player *p)
Town *t;
i = 60;
- for(;;) {
+ for (;;) {
// Find a town big enough
t = AiFindRandomTown();
if (t != NULL && t->population >= 700)
@@ -1357,7 +1357,7 @@ static void AiWantPassengerAircraftRoute(Player *p)
int i;
i = 60;
- for(;;) {
+ for (;;) {
// look for one from the subsidy list
AiFindSubsidyPassengerRoute(&fr);
@@ -1416,7 +1416,7 @@ static void AiWantOilRigAircraftRoute(Player *p)
Industry *in;
i = 60;
- for(;;) {
+ for (;;) {
// Find a town
t = AiFindRandomTown();
if (t != NULL) {
@@ -1498,7 +1498,7 @@ static void AiStateWantNewRoute(Player *p)
}
i = 200;
- for(;;) {
+ for (;;) {
r = (uint16)Random();
if (_patches.ai_disable_veh_train && _patches.ai_disable_veh_roadveh &&
@@ -1536,7 +1536,7 @@ static bool AiCheckTrackResources(TileIndex tile, const AiDefaultBlockData *p, b
uint values[NUM_CARGO];
int rad;
- for(;p->mode != 4;p++) if (p->mode == 1) {
+ for (;p->mode != 4;p++) if (p->mode == 1) {
TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
uint w;
uint h;
@@ -1576,7 +1576,7 @@ static int32 AiDoBuildDefaultRailTrack(TileIndex tile, const AiDefaultBlockData
int rating = 0;
int i,j,k;
- for(;;) {
+ for (;;) {
// This will seldomly overflow for valid reasons. Mask it to be on the safe side.
uint c = TILE_MASK(tile + ToTileIndexDiff(p->tileoffs));
@@ -1965,7 +1965,7 @@ static inline void AiCheckBuildRailBridgeHere(AiRailFinder *arf, TileIndex tile,
tile_new = tile;
// Allow bridges directly over bottom tiles
flag = arf->ti.z == 0;
- for(;;) {
+ for (;;) {
if ((TileIndexDiff)tile_new < -TileOffsByDir(dir2)) return; // Wraping around map, no bridge possible!
tile_new = TILE_MASK(tile_new + TileOffsByDir(dir2));
FindLandscapeHeightByTile(&arf->ti, tile_new);
@@ -2118,7 +2118,7 @@ static void AiBuildRailConstruct(Player *p)
// Didn't find anything to build?
if (arf.best_ptr == NULL) {
// Terraform some
- for(i=0; i!=5; i++)
+ for (i=0; i!=5; i++)
AiDoTerraformLand(p->ai.cur_tile_a, p->ai.cur_dir_a, 3, 0);
if (++p->ai.state_counter == 21) {
@@ -2169,7 +2169,7 @@ static void AiBuildRailConstruct(Player *p)
}
if (arf.best_tile != 0) {
- for(i=0; i!=2; i++)
+ for (i=0; i!=2; i++)
AiDoTerraformLand(arf.best_tile, arf.best_dir, 3, 0);
}
}
@@ -2274,7 +2274,7 @@ static void AiBuildRail(Player *p)
} else if (p->ai.state_mode == 2) {
// Terraform some and then try building again.
- for(i=0; i!=4; i++)
+ for (i=0; i!=4; i++)
AiDoTerraformLand(p->ai.cur_tile_a, p->ai.cur_dir_a, 3, 0);
if (++p->ai.state_counter == 4) {
@@ -2314,7 +2314,7 @@ static void AiStateBuildRail(Player *p)
num = p->ai.num_build_rec;
aib = &p->ai.src;
- for(;;) {
+ for (;;) {
cmd = aib->buildcmd_a;
aib->buildcmd_a = 255;
if (cmd != 255) break;
@@ -2382,7 +2382,7 @@ static void AiStateBuildRailVeh(Player *p)
tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
cargo = p->ai.cargo_type;
- for(i=0;;) {
+ for (i=0;;) {
if (p->ai.wagon_list[i] == INVALID_VEHICLE) {
veh = _cargoc.ai_railwagon[p->ai.railtype_to_use][cargo];
cost = DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE);
@@ -2403,7 +2403,7 @@ static void AiStateBuildRailVeh(Player *p)
handle_nocash:
// after a while, if AI still doesn't have cash, get out of this block by selling the wagons.
if (++p->ai.state_counter == 1000) {
- for(i=0; p->ai.wagon_list[i] != INVALID_VEHICLE; i++) {
+ for (i=0; p->ai.wagon_list[i] != INVALID_VEHICLE; i++) {
cost = DoCommandByTile(tile, p->ai.wagon_list[i], 0, DC_EXEC, CMD_SELL_RAIL_WAGON);
assert(!CmdFailed(cost));
}
@@ -2426,11 +2426,11 @@ handle_nocash:
}
// Move the wagons onto the train
- for(i=0; p->ai.wagon_list[i] != INVALID_VEHICLE; i++) {
+ for (i=0; p->ai.wagon_list[i] != INVALID_VEHICLE; i++) {
DoCommandByTile(tile, p->ai.wagon_list[i] | (loco_id << 16), 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
}
- for(i=0; p->ai.order_list_blocks[i] != 0xFF; i++) {
+ for (i=0; p->ai.order_list_blocks[i] != 0xFF; i++) {
AiBuildRec *aib = (&p->ai.src) + p->ai.order_list_blocks[i];
bool is_pass = (p->ai.cargo_type == CT_PASSENGERS ||
p->ai.cargo_type == CT_MAIL ||
@@ -2495,7 +2495,7 @@ static bool AiCheckRoadResources(TileIndex tile, const AiDefaultBlockData *p, by
rad = 4;
}
- for(;;p++) {
+ for (;;p++) {
if (p->mode == 4) {
return true;
} else if (p->mode == 1) {
@@ -2523,7 +2523,7 @@ static int AiFindBestDefaultRoadBlock(TileIndex tile, byte direction, byte cargo
_want_road_truck_station = (cargo & 0x7F) != CT_PASSENGERS;
- for(i=0; (p = _road_default_block_data[i]) != NULL; i++) {
+ for (i=0; (p = _road_default_block_data[i]) != NULL; i++) {
if (p->dir == direction) {
*cost = AiDoBuildDefaultRoadBlock(tile, p->data, 0);
if (!CmdFailed(*cost) && AiCheckRoadResources(tile, p->data, cargo))
@@ -2542,7 +2542,7 @@ static int32 AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData
int rating = 0;
int roadflag = 0;
- for(;p->mode != 4;p++) {
+ for (;p->mode != 4;p++) {
uint c = TILE_MASK(tile + ToTileIndexDiff(p->tileoffs));
_cleared_town = NULL;
@@ -2855,7 +2855,7 @@ static inline void AiCheckBuildRoadBridgeHere(AiRoadFinder *arf, TileIndex tile,
tile_new = tile;
// Allow bridges directly over bottom tiles
flag = arf->ti.z == 0;
- for(;;) {
+ for (;;) {
if ((TileIndexDiff)tile_new < -TileOffsByDir(dir2)) return; // Wraping around map, no bridge possible!
tile_new = TILE_MASK(tile_new + TileOffsByDir(dir2));
FindLandscapeHeightByTile(&arf->ti, tile_new);
@@ -2999,7 +2999,7 @@ static void AiBuildRoadConstruct(Player *p)
if (arf.best_ptr == NULL) {
// Terraform some
do_some_terraform:
- for(i=0; i!=5; i++)
+ for (i=0; i!=5; i++)
AiDoTerraformLand(p->ai.cur_tile_a, p->ai.cur_dir_a, 3, 0);
if (++p->ai.state_counter == 21) {
@@ -3025,7 +3025,7 @@ do_some_terraform:
unnecessary to check for worse bridge (i=0), since AI will always build that.
AI is so fucked up that fixing this small thing will probably not solve a thing
*/
- for(i = 10; i != 0; i--) {
+ for (i = 10; i != 0; i--) {
if (CheckBridge_Stuff(i, bridge_len)) {
int32 cost = DoCommandByTile(tile, p->ai.cur_tile_a, i + (0x80 << 8), DC_AUTO, CMD_BUILD_BRIDGE);
if (!CmdFailed(cost) && cost < (p->player_money >> 5))
@@ -3054,7 +3054,7 @@ do_some_terraform:
}
if (arf.best_tile != 0) {
- for(i=0; i!=2; i++)
+ for (i=0; i!=2; i++)
AiDoTerraformLand(arf.best_tile, arf.best_dir, 3, 0);
}
}
@@ -3074,7 +3074,7 @@ static void AiBuildRoad(Player *p)
} else if (p->ai.state_mode == 2) {
// Terraform some and then try building again.
- for(i=0; i!=4; i++)
+ for (i=0; i!=4; i++)
AiDoTerraformLand(p->ai.cur_tile_a, p->ai.cur_dir_a, 3, 0);
if (++p->ai.state_counter == 4) {
@@ -3124,7 +3124,7 @@ static void AiStateBuildRoad(Player *p)
num = p->ai.num_build_rec;
aib = &p->ai.src;
- for(;;) {
+ for (;;) {
cmd = aib->buildcmd_a;
aib->buildcmd_a = 255;
if (cmd != 255) break;
@@ -3173,7 +3173,7 @@ static void AiStateBuildRoadVehicles(Player *p)
int i;
ptr = _road_default_block_data[p->ai.src.cur_building_rule]->data;
- for(;ptr->mode != 0;ptr++) {}
+ for (;ptr->mode != 0;ptr++) {}
tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
veh = AiChooseRoadVehToBuild(p->ai.cargo_type, p->player_money, tile);
@@ -3336,7 +3336,7 @@ static int32 AiDoBuildDefaultAirportBlock(TileIndex tile, const AiDefaultBlockDa
{
int32 total_cost = 0, ret;
- for(;p->mode == 0;p++) {
+ for (;p->mode == 0;p++) {
if (!HASBIT(_avail_aircraft, p->attr))
return CMD_ERROR;
ret = DoCommandByTile(TILE_MASK(tile + ToTileIndexDiff(p->tileoffs)), p->attr,0,flag | DC_AUTO | DC_NO_WATER,CMD_BUILD_AIRPORT);
@@ -3359,7 +3359,7 @@ static bool AiCheckAirportResources(TileIndex tile, const AiDefaultBlockData *p,
rad = 4;
}
- for(;p->mode==0;p++) {
+ for (;p->mode==0;p++) {
TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
w = _airport_size_x[p->attr];
@@ -3379,7 +3379,7 @@ static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli,
{
int i;
const AiDefaultBlockData *p;
- for(i=0; (p = _airport_default_block_data[i]) != NULL; i++) {
+ for (i=0; (p = _airport_default_block_data[i]) != NULL; i++) {
// If we are doing a helicopter service, avoid building
// airports where they can't land.
if (heli && GetAirport(p->attr)->acc_planes == AIRCRAFT_ONLY)
@@ -3490,7 +3490,7 @@ static void AiStateBuildAircraftVehicles(Player *p)
uint loco_id;
ptr = _airport_default_block_data[p->ai.src.cur_building_rule];
- for(;ptr->mode!=0;ptr++) {}
+ for (;ptr->mode!=0;ptr++) {}
tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
@@ -3503,7 +3503,7 @@ static void AiStateBuildAircraftVehicles(Player *p)
if (CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) return;
loco_id = _new_aircraft_id;
- for(i=0; p->ai.order_list_blocks[i] != 0xFF; i++) {
+ for (i=0; p->ai.order_list_blocks[i] != 0xFF; i++) {
AiBuildRec *aib = (&p->ai.src) + p->ai.order_list_blocks[i];
bool is_pass = (p->ai.cargo_type == CT_PASSENGERS || p->ai.cargo_type == CT_MAIL);
Order order;
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 5a5392c6b..71aa8006b 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -1836,7 +1836,7 @@ static bool AirportFindFreeHelipad(Vehicle *v, const AirportFTAClass *Airport)
//at what terminal does the group start?
//that means, sum up all terminals of
//groups with lower number
- for(i = 1; i < target_group; i++)
+ for (i = 1; i < target_group; i++)
group_start += Airport->helipads[i];
group_end = group_start + Airport->helipads[target_group];
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 4bb83c1c4..ed6ceb376 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -141,7 +141,7 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 2: { /* listbox */
uint i = (e->click.pt.y - 14) / 24;
if (i < w->vscroll.cap) {
@@ -255,7 +255,7 @@ static void AircraftRefitWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 2: { /* listbox */
int y = e->click.pt.y - 25;
if (y >= 0) {
@@ -496,7 +496,7 @@ bool CheckStoppedInHangar(const Vehicle* v); /* XXX extern function declaration
static void AircraftViewWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
const Vehicle* v = GetVehicle(w->window_number);
uint32 disabled = 1 << 8;
@@ -774,13 +774,13 @@ static void ClonePlaceObj(TileIndex tile, const Window* w)
static void AircraftDepotWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
DrawAircraftDepotWindow(w);
break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 5: /* click aircraft */
AircraftDepotClickAircraft(w, e->click.pt.x, e->click.pt.y);
break;
@@ -834,7 +834,7 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e)
break;
case WE_DRAGDROP:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 5: {
Vehicle *v;
VehicleID sel = WP(w,traindepot_d).sel;
@@ -985,7 +985,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
PlayerID owner = GB(w->window_number, 0, 8);
vehiclelist_d *vl = &WP(w, vehiclelist_d);
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
int x = 2;
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
@@ -1056,7 +1056,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK: {
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: /* Flip sorting method ascending/descending */
vl->flags ^= VL_DESC;
vl->flags |= VL_RESORT;
@@ -1103,7 +1103,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
}
tile = TILE_MASK(tile + 1);
- } while(tile != _last_built_aircraft_depot_tile);
+ } while (tile != _last_built_aircraft_depot_tile);
ShowBuildAircraftWindow(0);
} break;
diff --git a/bridge_gui.c b/bridge_gui.c
index 78a4fa995..a2a04550c 100644
--- a/bridge_gui.c
+++ b/bridge_gui.c
@@ -40,7 +40,7 @@ static void BuildBridge(Window *w, int i)
static void BuildBridgeWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
uint i;
diff --git a/clear_cmd.c b/clear_cmd.c
index 8c36a7bd7..126c4e6cc 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -68,7 +68,7 @@ static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
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;
}
@@ -190,7 +190,7 @@ static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height
{ 0, -2}
};
- for(ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
+ for (ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
tile += ToTileIndexDiff(*ttm);
r = TerraformGetHeightOfTile(ts, tile);
diff --git a/depot.h b/depot.h
index 85ef54d9d..7d1416f8b 100644
--- a/depot.h
+++ b/depot.h
@@ -75,7 +75,7 @@ static inline bool IsValidDepot(const Depot* depot)
*/
static inline bool IsTileDepotType(TileIndex tile, TransportType type)
{
- switch(type)
+ switch (type)
{
case TRANSPORT_RAIL:
return IsTileType(tile, MP_RAILWAY) && (_m[tile].m5 & 0xFC) == 0xC0;
diff --git a/disaster_cmd.c b/disaster_cmd.c
index 4f3ea40cc..39e97c1b2 100644
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -620,7 +620,7 @@ static void DisasterTick_4b(Vehicle *v)
DeleteDisasterVeh(u);
- for(i=0; i!=80; i++) {
+ for (i = 0; i != 80; i++) {
uint32 r = Random();
CreateEffectVehicleAbove(
GB(r, 0, 6) + v->x_pos - 32,
diff --git a/dock_gui.c b/dock_gui.c
index 14eb90ee9..4f5e47d43 100644
--- a/dock_gui.c
+++ b/dock_gui.c
@@ -115,7 +115,7 @@ static OnButtonClick * const _build_docks_button_proc[] = {
static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
DrawWindowWidgets(w);
break;
diff --git a/economy.c b/economy.c
index 988af93d8..69db3633b 100644
--- a/economy.c
+++ b/economy.c
@@ -505,7 +505,7 @@ void DrawNewsBankrupcy(Window *w)
DrawStringMultiCenter(49, 148, STR_7058_PRESIDENT, 94);
- switch(WP(w,news_d).ni->string_id >> 4) {
+ switch (WP(w,news_d).ni->string_id >> 4) {
case 1:
DrawStringCentered(w->width>>1, 1, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE, 0);
@@ -806,7 +806,7 @@ void StartupEconomy(void)
assert(sizeof(_price) == NUM_PRICES * sizeof(int32));
- for(i=0; i!=NUM_PRICES; i++) {
+ for (i = 0; i != NUM_PRICES; i++) {
int32 price = _price_base[i];
if (_price_category[i] != 0) {
uint mod = _price_category[i] == 1 ? _opt.diff.vehicle_costs : _opt.diff.construction_cost;
@@ -883,7 +883,7 @@ void DeleteSubsidyWithIndustry(uint16 index)
{
Subsidy *s;
- for(s=_subsidies; s != endof(_subsidies); s++) {
+ for (s = _subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type != CT_INVALID && s->age < 12 &&
s->cargo_type != CT_PASSENGERS && s->cargo_type != CT_MAIL &&
(index == s->from || (s->cargo_type!=CT_GOODS && s->cargo_type!=CT_FOOD && index==s->to))) {
@@ -897,7 +897,7 @@ void DeleteSubsidyWithStation(uint16 index)
Subsidy *s;
bool dirty = false;
- for(s=_subsidies; s != endof(_subsidies); s++) {
+ for (s = _subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type != CT_INVALID && s->age >= 12 &&
(s->from == index || s->to == index)) {
s->cargo_type = CT_INVALID;
@@ -1014,9 +1014,8 @@ static void SubsidyMonthlyHandler(void)
FoundRoute fr;
bool modified = false;
- for(s=_subsidies; s != endof(_subsidies); s++) {
- if (s->cargo_type == CT_INVALID)
- continue;
+ for (s = _subsidies; s != endof(_subsidies); s++) {
+ if (s->cargo_type == CT_INVALID) continue;
if (s->age == 12-1) {
pair = SetupSubsidyDecodeParam(s, 1);
@@ -1090,7 +1089,7 @@ static void Save_SUBS(void)
int i;
Subsidy *s;
- for(i=0; i!=lengthof(_subsidies); i++) {
+ for (i = 0; i != lengthof(_subsidies); i++) {
s = &_subsidies[i];
if (s->cargo_type != CT_INVALID) {
SlSetArrayIndex(i);
@@ -1537,7 +1536,7 @@ static void DoAcquireCompany(Player *p)
}
value = CalculateCompanyValue(p) >> 2;
- for(i=0; i!=4; i++) {
+ for (i = 0; i != 4; i++) {
if (p->share_owners[i] != OWNER_SPECTATOR) {
owner = GetPlayer(p->share_owners[i]);
owner->money64 += value;
diff --git a/fileio.c b/fileio.c
index d0013cf1f..fd1008d15 100644
--- a/fileio.c
+++ b/fileio.c
@@ -59,7 +59,7 @@ byte FioReadByte(void)
void FioSkipBytes(int n)
{
- for(;;) {
+ for (;;) {
int m = min(_fio.buffer_end - _fio.buffer, n);
_fio.buffer += m;
n -= m;
@@ -117,7 +117,7 @@ bool FiosCheckFileExists(const char *filename)
if (f == NULL) {
char *s;
// Make lower case and try again
- for(s=buf + strlen(_path.data_dir) - 1; *s != 0; s++)
+ for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++)
*s = tolower(*s);
f = fopen(buf, "rb");
@@ -125,7 +125,7 @@ bool FiosCheckFileExists(const char *filename)
// tries in the 2nd data directory
if (f == NULL) {
sprintf(buf, "%s%s", _path.second_data_dir, filename);
- for(s=buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
+ for (s = buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
*s = tolower(*s);
f = fopen(buf, "rb");
}
@@ -153,7 +153,7 @@ FILE *FioFOpenFile(const char *filename)
if (f == NULL) {
char *s;
// Make lower case and try again
- for(s=buf + strlen(_path.data_dir) - 1; *s != 0; s++)
+ for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++)
*s = tolower(*s);
f = fopen(buf, "rb");
@@ -161,7 +161,7 @@ FILE *FioFOpenFile(const char *filename)
// tries in the 2nd data directory
if (f == NULL) {
sprintf(buf, "%s%s", _path.second_data_dir, filename);
- for(s=buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
+ for (s = buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
*s = tolower(*s);
f = fopen(buf, "rb");
}
@@ -184,7 +184,7 @@ void FioOpenFile(int slot, const char *filename)
if (f == NULL) {
char *s;
// Make lower case and try again
- for(s=buf + strlen(_path.data_dir) - 1; *s != 0; s++)
+ for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++)
*s = tolower(*s);
f = fopen(buf, "rb");
@@ -192,7 +192,7 @@ void FioOpenFile(int slot, const char *filename)
// tries in the 2nd data directory
if (f == NULL) {
sprintf(buf, "%s%s", _path.second_data_dir, filename);
- for(s=buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
+ for (s = buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
*s = tolower(*s);
f = fopen(buf, "rb");
}
diff --git a/gfx.c b/gfx.c
index 7cf3f2dbb..3ff96716b 100644
--- a/gfx.c
+++ b/gfx.c
@@ -402,11 +402,11 @@ static uint32 FormatStringLinebreaks(char *str, int maxw)
char *last_space;
byte c;
- for(;;) {
+ for (;;) {
w = 0;
last_space = NULL;
- for(;;) {
+ for (;;) {
c = *str++;
if (c == ASCII_LETTERSTART) last_space = str;
@@ -457,12 +457,12 @@ void DrawStringMultiCenter(int x, int y, StringID str, int maxw)
src = buffer;
- for(;;) {
+ for (;;) {
w = GetStringWidth(src);
DoDrawString(src, x - (w>>1), y, 0xFE);
_stringwidth_base = _stringwidth_out;
- for(;;) {
+ for (;;) {
c = *src++;
if (c == 0) {
y += mt;
@@ -501,11 +501,11 @@ void DrawStringMultiLine(int x, int y, StringID str, int maxw)
src = buffer;
- for(;;) {
+ for (;;) {
DoDrawString(src, x, y, 0xFE);
_stringwidth_base = _stringwidth_out;
- for(;;) {
+ for (;;) {
c = *src++;
if (c == 0) {
y += mt;
@@ -608,13 +608,13 @@ switch_color:;
check_bounds:
if (y + 19 <= dpi->top || dpi->top + dpi->height <= y) {
skip_char:;
- for(;;) {
+ for (;;) {
c = *string++;
if (c < ASCII_LETTERSTART) goto skip_cont;
}
}
- for(;;) {
+ for (;;) {
c = *string++;
skip_cont:;
if (c == 0) {
@@ -1106,7 +1106,7 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
if (bp->mode & 1) {
src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
- for(;;) {
+ for (;;) {
do {
done = src_o[0];
num = done & 0x7F;
@@ -1175,7 +1175,7 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
}
} else if (bp->mode & 2) {
src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
- for(;;) {
+ for (;;) {
do {
done = src_o[0];
num = done & 0x7F;
@@ -1240,7 +1240,7 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
}
} else {
src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
- for(;;) {
+ for (;;) {
do {
done = src_o[0];
num = done & 0x7F;
diff --git a/graph_gui.c b/graph_gui.c
index 02ee830c8..06760b08f 100644
--- a/graph_gui.c
+++ b/graph_gui.c
@@ -221,7 +221,7 @@ static void GraphLegendWndProc(Window *w, WindowEvent *e)
{
const Player* p;
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
FOR_ALL_PLAYERS(p) {
if (!p->is_active) SETBIT(_legend_excludebits, p->index);
@@ -320,7 +320,7 @@ static void SetupGraphDrawerForPlayers(GraphDrawer *gd)
static void OperatingProfitWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
GraphDrawer gd;
const Player* p;
@@ -344,7 +344,7 @@ static void OperatingProfitWndProc(Window *w, WindowEvent *e)
FOR_ALL_PLAYERS(p) {
if (p->is_active) {
gd.colors[numd] = _color_list[p->player_color].window_color_bgb;
- for(j=gd.num_on_x_axis,i=0; --j >= 0;) {
+ for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)(p->old_economy[j].income + p->old_economy[j].expenses);
i++;
}
@@ -394,7 +394,7 @@ void ShowOperatingProfitGraph(void)
static void IncomeGraphWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
GraphDrawer gd;
const Player* p;
@@ -417,7 +417,7 @@ static void IncomeGraphWndProc(Window *w, WindowEvent *e)
FOR_ALL_PLAYERS(p) {
if (p->is_active) {
gd.colors[numd] = _color_list[p->player_color].window_color_bgb;
- for(j=gd.num_on_x_axis,i=0; --j >= 0;) {
+ for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].income;
i++;
}
@@ -467,7 +467,7 @@ void ShowIncomeGraph(void)
static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
GraphDrawer gd;
const Player* p;
@@ -490,7 +490,7 @@ static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e)
FOR_ALL_PLAYERS(p) {
if (p->is_active) {
gd.colors[numd] = _color_list[p->player_color].window_color_bgb;
- for(j=gd.num_on_x_axis,i=0; --j >= 0;) {
+ for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].delivered_cargo;
i++;
}
@@ -540,7 +540,7 @@ void ShowDeliveredCargoGraph(void)
static void PerformanceHistoryWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
GraphDrawer gd;
const Player* p;
@@ -563,7 +563,7 @@ static void PerformanceHistoryWndProc(Window *w, WindowEvent *e)
FOR_ALL_PLAYERS(p) {
if (p->is_active) {
gd.colors[numd] = _color_list[p->player_color].window_color_bgb;
- for(j=gd.num_on_x_axis,i=0; --j >= 0;) {
+ for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].performance_history;
i++;
}
@@ -616,7 +616,7 @@ void ShowPerformanceHistoryGraph(void)
static void CompanyValueGraphWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
GraphDrawer gd;
const Player* p;
@@ -639,7 +639,7 @@ static void CompanyValueGraphWndProc(Window *w, WindowEvent *e)
FOR_ALL_PLAYERS(p) {
if (p->is_active) {
gd.colors[numd] = _color_list[p->player_color].window_color_bgb;
- for(j=gd.num_on_x_axis,i=0; --j >= 0;) {
+ for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].company_value;
i++;
}
@@ -691,7 +691,7 @@ static const byte _cargo_legend_colors[12] = {152, 32, 15, 174, 208, 194, 191, 8
static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
int i, j, x, y;
GraphDrawer gd;
@@ -703,7 +703,7 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
x = 495;
y = 25;
- for(i=0; i!=NUM_CARGO; i++) {
+ for (i = 0; i != NUM_CARGO; i++) {
GfxFillRect(x, y, x+8, y+5, 0);
GfxFillRect(x+1, y+1, x+7, y+4, _cargo_legend_colors[i]);
SetDParam(0, _cargoc.names_s[i]);
@@ -726,10 +726,10 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
gd.unk61A = 10;
gd.unk61C = 10;
- for(i=0; i!=NUM_CARGO; i++) {
+ for (i = 0; i != NUM_CARGO; i++) {
gd.colors[i] = _cargo_legend_colors[i];
- for(j=0; j!=20; j++) {
- gd.cost[i][j] = (uint64)GetTransportedGoodsIncome(10, 20, j*6+6,i);
+ for (j = 0; j != 20; j++) {
+ gd.cost[i][j] = (uint64)GetTransportedGoodsIncome(10, 20, j * 6 + 6, i);
}
}
@@ -740,7 +740,7 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK: {
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: case 4: case 5: case 6:
case 7: case 8: case 9: case 10:
case 11: case 12: case 13: case 14:
@@ -882,7 +882,7 @@ void ShowCompanyLeagueTable(void)
static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
int val, needed, score, i;
byte owner, x;
@@ -1134,7 +1134,7 @@ static void GlobalSortSignList(void)
error("Could not allocate memory for the sign-sorting-list");
FOR_ALL_SIGNS(ss) {
- if(ss->str != STR_NULL) {
+ if (ss->str != STR_NULL) {
_sign_sort[n++] = ss->index;
_num_sign_sort++;
}
diff --git a/industry_cmd.c b/industry_cmd.c
index 4883e2078..b74c9233f 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -505,12 +505,12 @@ static void AnimateTile_Industry(TileIndex tile)
{
byte m,n;
- switch(_m[tile].m5) {
+ switch (_m[tile].m5) {
case 174:
if ((_tick_counter & 1) == 0) {
m = _m[tile].m3 + 1;
- switch(m & 7) {
+ switch (m & 7) {
case 2: SndPlayTileFx(SND_2D_RIP_2, tile); break;
case 6: SndPlayTileFx(SND_29_RIP, tile); break;
}
@@ -685,7 +685,7 @@ static void MakeIndustryTileBigger(TileIndex tile, byte size)
if (!(_m[tile].m1 & 0x80))
return;
- switch(_m[tile].m5) {
+ switch (_m[tile].m5) {
case 8:
MakeIndustryTileBiggerCase8(tile);
break;
diff --git a/industry_gui.c b/industry_gui.c
index 3fd0be363..338afc470 100644
--- a/industry_gui.c
+++ b/industry_gui.c
@@ -332,7 +332,7 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
case WE_CLICK: {
Industry *i;
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 5: {
int line;
int x;
@@ -550,7 +550,7 @@ static void MakeSortedIndustryList(void)
error("Could not allocate memory for the industry-sorting-list");
FOR_ALL_INDUSTRIES(i) {
- if(i->xy)
+ if (i->xy)
_industry_sort[n++] = i->index;
}
_num_industry_sort = n;
@@ -610,7 +610,7 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: {
_industry_sort_order = _industry_sort_order==0 ? 1 : 0;
_industry_sort_dirty = true;
diff --git a/landscape.c b/landscape.c
index 689be3dab..13b89d3ef 100644
--- a/landscape.c
+++ b/landscape.c
@@ -84,7 +84,7 @@ uint GetPartialZ(int x, int y, int corners)
{
int z = 0;
- switch(corners) {
+ switch (corners) {
case 1:
if (x - y >= 0)
z = (x - y) >> 1;
diff --git a/macros.h b/macros.h
index b9faad6b2..e3192c8b3 100644
--- a/macros.h
+++ b/macros.h
@@ -120,9 +120,9 @@ static inline int KillFirstBit2x64(int value)
#define CHANCE16I(a,b,v) ((uint16)(v) <= (uint16)((65536 * a) / b))
-#define for_each_bit(_i,_b) \
- for(_i=0; _b!=0; _i++,_b>>=1) \
- if (_b&1)
+#define for_each_bit(_i, _b) \
+ for (_i = 0; _b != 0; _i++, _b >>= 1) \
+ if (_b & 1)
#define abs myabs
diff --git a/main_gui.c b/main_gui.c
index e36645cb4..25cd8bd87 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -1687,7 +1687,7 @@ static void ScenEditIndustryWndProc(Window *w, WindowEvent *e)
{
int button;
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
DrawWindowWidgets(w);
break;
@@ -1850,7 +1850,7 @@ static ToolbarButtonProc* const _toolbar_button_procs[] = {
static void MainToolbarWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
// Draw brown-red toolbar bg.
@@ -2057,7 +2057,7 @@ static ToolbarButtonProc* const _scen_toolbar_button_procs[] = {
static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
/* XXX look for better place for these */
if (_date <= MinDate) {
@@ -2286,7 +2286,7 @@ extern void UpdateAllStationVirtCoord(void);
static void MainWindowWndProc(Window *w, WindowEvent *e) {
int off_x;
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
DrawWindowViewport(w);
if (_game_mode == GM_MENU) {
diff --git a/mersenne.c b/mersenne.c
index 0c0ceb719..bc4cb949a 100644
--- a/mersenne.c
+++ b/mersenne.c
@@ -25,7 +25,7 @@ void SeedMT(uint32 seed)
register uint32 x = (seed | 1U) & 0xFFFFFFFFU, *s = _mt_state;
register int j;
- for(_mt_left=0, *s++=x, j=N; --j;
+ for (_mt_left=0, *s++=x, j=N; --j;
*s++ = (x*=69069U) & 0xFFFFFFFFU);
}
@@ -35,15 +35,15 @@ static uint32 ReloadMT(void)
register uint32 *p0=_mt_state, *p2=_mt_state+2, *pM=_mt_state+M, s0, s1;
register int j;
- if(_mt_left < -1)
+ if (_mt_left < -1)
SeedMT(4357U);
_mt_left=N-1, _mt_next=_mt_state+1;
- for(s0=_mt_state[0], s1=_mt_state[1], j=N-M+1; --j; s0=s1, s1=*p2++)
+ for (s0=_mt_state[0], s1=_mt_state[1], j=N-M+1; --j; s0=s1, s1=*p2++)
*p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
- for(pM=_mt_state, j=M; --j; s0=s1, s1=*p2++)
+ for (pM=_mt_state, j=M; --j; s0=s1, s1=*p2++)
*p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
s1=_mt_state[0], *p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
@@ -58,7 +58,7 @@ uint32 RandomMT(void)
{
uint32 y;
- if(--_mt_left < 0)
+ if (--_mt_left < 0)
return ReloadMT();
y = *_mt_next++;
diff --git a/misc.c b/misc.c
index cc3f08e35..d5c9025c4 100644
--- a/misc.c
+++ b/misc.c
@@ -223,8 +223,7 @@ void GenerateWorld(int mode, uint size_x, uint size_y)
// No need to run the tile loop in the scenario editor.
if (mode != GW_EMPTY) {
- for(i=0x500; i!=0; i--)
- RunTileLoop();
+ for (i = 0x500; i != 0; i--) RunTileLoop();
}
ResetObjectToPlace();
@@ -980,7 +979,7 @@ static void Load_CHTS(void)
Cheat* cht = (Cheat*) &_cheats;
uint count = SlGetFieldLength()/2;
- for(; count; count--, cht++)
+ for (; count; count--, cht++)
{
cht->been_used = (byte)SlReadByte();
cht->value = (byte)SlReadByte();
diff --git a/misc_gui.c b/misc_gui.c
index c2e19b2d6..c9d27e90b 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -548,7 +548,7 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
if ( (x|y) != 0) {
pt = RemapCoords2(x, y);
- for(w=_windows; w->window_class != WC_MAIN_WINDOW; w++) {}
+ for (w = _windows; w->window_class != WC_MAIN_WINDOW; w++) {}
vp = w->viewport;
// move x pos to opposite corner
@@ -567,7 +567,7 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
} else {
if ( (x|y) != 0) {
pt = RemapCoords2(x, y);
- for(w=_windows; w->window_class != WC_MAIN_WINDOW; w++) {}
+ for (w = _windows; w->window_class != WC_MAIN_WINDOW; w++) {}
vp = w->viewport;
pt.x = clamp(((pt.x - vp->virtual_left) >> vp->zoom) + vp->left - (334/2), 0, _screen.width - 334);
pt.y = clamp(((pt.y - vp->virtual_top) >> vp->zoom) + vp->top - (137/2), 22, _screen.height - 137);
@@ -967,7 +967,7 @@ static void QueryStringWndProc(Window *w, WindowEvent *e)
break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: DeleteWindow(w); break;
case 4:
press_ok:;
@@ -1376,8 +1376,9 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
break;
case WE_DESTROY:
// pause is only used in single-player, non-editor mode, non menu mode
- if(!_networking && (_game_mode != GM_EDITOR) && (_game_mode != GM_MENU))
+ if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
+ }
FiosFreeSavegameList();
CLRBIT(_no_scroll, SCROLL_SAVE);
break;
@@ -1534,7 +1535,7 @@ static void SelectScenarioWndProc(Window* w, WindowEvent* e)
break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: /* Sort scenario names by name */
_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
diff --git a/music_gui.c b/music_gui.c
index 4da6c64d5..bdd1c550c 100644
--- a/music_gui.c
+++ b/music_gui.c
@@ -203,7 +203,7 @@ void MusicLoop(void)
static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
const byte* p;
uint i;
@@ -321,7 +321,7 @@ static void ShowMusicTrackSelection(void)
static void MusicWindowWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
uint i;
StringID str;
@@ -393,7 +393,7 @@ static void MusicWindowWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 2: // skip to prev
if (!_song_is_active)
return;
diff --git a/network.c b/network.c
index b535e7a7a..b500c46c1 100644
--- a/network.c
+++ b/network.c
@@ -237,7 +237,7 @@ static void NetworkClientError(byte res, NetworkClientState *cs) {
return;
}
- switch(res) {
+ switch (res) {
case NETWORK_RECV_STATUS_DESYNC: errorno = NETWORK_ERROR_DESYNC; break;
case NETWORK_RECV_STATUS_SAVEGAME: errorno = NETWORK_ERROR_SAVEGAME_FAILED; break;
default: errorno = NETWORK_ERROR_GENERAL;
@@ -1168,7 +1168,7 @@ static void NetworkHandleLocalQueue(void)
// Just a safety check, to be removed in the future.
// Make sure that no older command appears towards the end of the queue
// In that case we missed executing it. This will never happen.
- for(cp = _local_command_queue; cp; cp = cp->next) {
+ for (cp = _local_command_queue; cp; cp = cp->next) {
assert(_frame_counter < cp->frame);
}
diff --git a/network_gui.c b/network_gui.c
index 9e988f063..1204b8638 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -447,7 +447,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
} break;
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
- switch(e->dropdown.button) {
+ switch (e->dropdown.button) {
case 5:
_network_lan_internet = e->dropdown.index;
break;
@@ -700,7 +700,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
break;
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
- switch(e->dropdown.button) {
+ switch (e->dropdown.button) {
case 8: _network_advertise = (e->dropdown.index != 0); break;
case 10: _network_game_info.clients_max = e->dropdown.index; break;
case 12: _network_game_info.companies_max = e->dropdown.index; break;
diff --git a/network_server.c b/network_server.c
index a8172f48f..095922c10 100644
--- a/network_server.c
+++ b/network_server.c
@@ -1474,7 +1474,7 @@ bool NetworkServer_ReadPackets(NetworkClientState *cs)
{
Packet *p;
NetworkRecvStatus res;
- while((p = NetworkRecv_Packet(cs, &res)) != NULL) {
+ while ((p = NetworkRecv_Packet(cs, &res)) != NULL) {
byte type = NetworkRecv_uint8(cs, p);
if (type < PACKET_END && _network_server_packet[type] != NULL && !cs->quited)
_network_server_packet[type](cs, p);
diff --git a/npf.c b/npf.c
index c759bb7a1..ad0fbccbd 100644
--- a/npf.c
+++ b/npf.c
@@ -209,7 +209,7 @@ static void NPFMarkTile(TileIndex tile)
return;
#else
if (_debug_npf_level >= 1)
- switch(GetTileType(tile)) {
+ switch (GetTileType(tile)) {
case MP_RAILWAY:
/* DEBUG: mark visited tiles by mowing the grass under them
* ;-) */
diff --git a/order_gui.c b/order_gui.c
index 50c45b16b..35351a30f 100644
--- a/order_gui.c
+++ b/order_gui.c
@@ -392,7 +392,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
case WE_CLICK: {
Vehicle *v = GetVehicle(w->window_number);
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 2: { /* orders list */
int sel;
sel = (e->click.pt.y - 15) / 10;
@@ -460,7 +460,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
Vehicle *v = GetVehicle(w->window_number);
uint i;
- for(i = 0; i < lengthof(_order_keycodes); i++) {
+ for (i = 0; i < lengthof(_order_keycodes); i++) {
if (e->keypress.keycode == _order_keycodes[i]) {
e->keypress.cont = false;
//see if the button is disabled
diff --git a/pathfind.c b/pathfind.c
index 9552129bc..8107fc5ed 100644
--- a/pathfind.c
+++ b/pathfind.c
@@ -185,7 +185,7 @@ static void TPFMode2(TrackPathFinder *tpf, TileIndex tile, int direction)
// Change direction 4 times only
if ((byte)i != tpf->rd.pft_var6) {
- if(++tpf->rd.depth > 4) {
+ if (++tpf->rd.depth > 4) {
tpf->rd = rd;
return;
}
@@ -222,7 +222,7 @@ FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, uint direction)
z = GetSlopeZ(x+8, y+8);
- for(;;) {
+ for (;;) {
flotr.length++;
x += _get_tunlen_inc[direction];
@@ -609,7 +609,7 @@ static bool NtpCheck(NewTrackPathFinder *tpf, TileIndex tile, uint dir, uint len
// else it's a linked list of many tiles
offs = tpf->hash_tile[hash];
- for(;;) {
+ for (;;) {
link = NTP_GET_LINK_PTR(tpf, offs);
if (tile == link->tile && (uint)(link->typelength & 0x3) == dir) {
assert( (uint)(link->typelength >> 2) <= length);
@@ -690,7 +690,7 @@ static void NTPEnum(NewTrackPathFinder *tpf, TileIndex tile, uint direction)
si.first_track = 0xFF;
goto start_at;
- for(;;) {
+ for (;;) {
// Get the next item to search from from the priority queue
do {
if (tpf->nstack == 0)
@@ -734,7 +734,7 @@ start_at:
// This is a special loop used to go through
// a rail net and find the first intersection
tile_org = tile;
- for(;;) {
+ for (;;) {
assert(direction <= 3);
tile += TileOffsByDir(direction);
diff --git a/player.h b/player.h
index 00150ecbb..32fab10a6 100644
--- a/player.h
+++ b/player.h
@@ -201,7 +201,7 @@ void GetNameOfOwner(PlayerID owner, TileIndex tile);
int64 CalculateCompanyValue(const Player* p);
void InvalidatePlayerWindows(const Player* p);
void UpdatePlayerMoney32(Player *p);
-#define FOR_ALL_PLAYERS(p) for(p=_players; p != endof(_players); p++)
+#define FOR_ALL_PLAYERS(p) for (p = _players; p != endof(_players); p++)
VARDEF PlayerID _local_player;
VARDEF PlayerID _current_player;
diff --git a/player_gui.c b/player_gui.c
index 44755f768..d86e4871f 100644
--- a/player_gui.c
+++ b/player_gui.c
@@ -35,7 +35,7 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode)
if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status
/* draw categories */
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);
DrawStringRightAligned(111, 27 + 10*13 + 2, STR_7020_TOTAL, 0);
@@ -49,7 +49,7 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode)
SetDParam(0, year + 1920);
DrawStringCenterUnderline(x-17, 15, STR_7010, 0);
sum = 0;
- for(i=0; i!=13; i++) {
+ for (i = 0; i != 13; i++) {
/* draw one row in the price column */
cost = (*tbl)[i];
if (cost != 0) {
@@ -148,7 +148,7 @@ static const Widget _player_finances_small_widgets[] = {
static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
PlayerID player = w->window_number;
const Player* p = GetPlayer(player);
@@ -165,7 +165,7 @@ static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 2: {/* toggle size */
byte mode = (byte)WP(w,def_d).data_1;
bool stickied = !!(w->flags4 & WF_STICKY);
@@ -246,7 +246,7 @@ void ShowPlayerFinances(PlayerID player)
static void SelectPlayerColorWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
const Player* p;
uint used_colors = 0;
@@ -268,7 +268,7 @@ static void SelectPlayerColorWndProc(Window *w, WindowEvent *e)
y = 17;
pos = w->vscroll.pos;
- for(i=0; i!=16; i++) {
+ for (i = 0; i != 16; i++) {
if (!(used_colors & 1) && --pos < 0 && pos >= -8) {
DrawString(x + 30, y, STR_00D1_DARK_BLUE + i, 2);
DrawSprite((i << 16) + 0x3078C1A, x + 14, y + 4);
@@ -289,7 +289,7 @@ static void SelectPlayerColorWndProc(Window *w, WindowEvent *e)
item += w->vscroll.pos;
used_colors = WP(w,def_d).data_1;
- for(i=0; i!=16; i++) {
+ for (i = 0; i != 16; i++) {
if (!(used_colors & 1) && --item < 0) {
DoCommandP(0, 0, i, NULL, CMD_SET_PLAYER_COLOR);
DeleteWindow(w);
@@ -320,7 +320,7 @@ static const WindowDesc _select_player_color_desc = {
static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
Player *p;
w->click_state = (w->click_state & ~(1<<5|1<<6)) | ((1<<5) << WP(w,facesel_d).gender);
@@ -330,7 +330,7 @@ static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: DeleteWindow(w); break;
case 4: /* ok click */
DoCommandP(0, 0, WP(w,facesel_d).face, NULL, CMD_SET_PLAYER_FACE);
@@ -695,7 +695,7 @@ void ShowPlayerCompany(PlayerID player)
static void BuyCompanyWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
Player *p = GetPlayer(w->window_number);
SetDParam(0, p->name_1);
@@ -712,7 +712,7 @@ static void BuyCompanyWndProc(Window *w, WindowEvent *e)
}
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3:
DeleteWindow(w);
break;
diff --git a/players.c b/players.c
index 9221a8bc2..a006a6a79 100644
--- a/players.c
+++ b/players.c
@@ -376,8 +376,7 @@ static byte GeneratePlayerColor(void)
Player *p;
// Initialize array
- for(i=0; i!=16; i++)
- colors[i] = i;
+ for (i = 0; i != 16; i++) colors[i] = i;
// And randomize it
n = 100;
@@ -389,9 +388,9 @@ static byte GeneratePlayerColor(void)
// Bubble sort it according to the values in table 1
i = 16;
do {
- for(j=0; j!=15; j++) {
- if (_color_sort[colors[j]] < _color_sort[colors[j+1]]) {
- COLOR_SWAP(j,j+1);
+ for (j = 0; j != 15; j++) {
+ if (_color_sort[colors[j]] < _color_sort[colors[j + 1]]) {
+ COLOR_SWAP(j, j + 1);
}
}
} while (--i);
@@ -399,12 +398,12 @@ static byte GeneratePlayerColor(void)
// Move the colors that look similar to each player's color to the side
FOR_ALL_PLAYERS(p) if (p->is_active) {
pcolor = p->player_color;
- for(i=0; i!=16; i++) if (colors[i] == pcolor) {
+ for (i=0; i!=16; i++) if (colors[i] == pcolor) {
colors[i] = 0xFF;
t2 = _color_similar_1[pcolor];
if (t2 == 0xFF) break;
- for(i=0; i!=15; i++) {
+ for (i=0; i!=15; i++) {
if (colors[i] == t2) {
do COLOR_SWAP(i,i+1); while (++i != 15);
break;
@@ -413,9 +412,9 @@ static byte GeneratePlayerColor(void)
t2 = _color_similar_2[pcolor];
if (t2 == 0xFF) break;
- for(i=0; i!=15; i++) {
+ for (i = 0; i != 15; i++) {
if (colors[i] == t2) {
- do COLOR_SWAP(i,i+1); while (++i != 15);
+ do COLOR_SWAP(i, i + 1); while (++i != 15);
break;
}
}
@@ -425,7 +424,7 @@ static byte GeneratePlayerColor(void)
// Return the first available color
i = 0;
- for(;;) {
+ for (;;) {
if (colors[i] != 0xFF)
return colors[i];
i++;
@@ -437,7 +436,7 @@ static void GeneratePresidentName(Player *p)
Player *pp;
char buffer[100], buffer2[40];
- for(;;) {
+ for (;;) {
restart:;
p->president_name_2 = Random();
@@ -551,7 +550,7 @@ void InitializePlayers(void)
{
int i;
memset(_players, 0, sizeof(_players));
- for(i = 0; i != MAX_PLAYERS; i++)
+ for (i = 0; i != MAX_PLAYERS; i++)
_players[i].index=i;
_cur_player_tick_index = 0;
}
@@ -729,7 +728,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (new_engine_type != INVALID_ENGINE) {
/* First we make sure that it's a valid type the user requested
* check that it's an engine that is in the engine array */
- if(!IsEngineIndex(new_engine_type))
+ if (!IsEngineIndex(new_engine_type))
return CMD_ERROR;
// check that the new vehicle type is the same as the original one
@@ -1253,7 +1252,8 @@ static const SaveLoad _player_ai_build_rec_desc[] = {
SLE_END()
};
-static void SaveLoad_PLYR(Player *p) {
+static void SaveLoad_PLYR(Player* p)
+{
int i;
SlObject(p, _player_desc);
@@ -1261,7 +1261,7 @@ static void SaveLoad_PLYR(Player *p) {
// Write AI?
if (!IS_HUMAN_PLAYER(p->index)) {
SlObject(&p->ai, _player_ai_desc);
- for(i=0; i!=p->ai.num_build_rec; i++)
+ for (i = 0; i != p->ai.num_build_rec; i++)
SlObject(&p->ai.src + i, _player_ai_build_rec_desc);
}
@@ -1271,7 +1271,7 @@ static void SaveLoad_PLYR(Player *p) {
// Write old economy entries.
{
PlayerEconomyEntry *pe;
- for(i=p->num_valid_stat_ent,pe=p->old_economy; i!=0; i--,pe++)
+ for (i = p->num_valid_stat_ent, pe = p->old_economy; i != 0; i--, pe++)
SlObject(pe, _player_economy_desc);
}
}
diff --git a/rail_cmd.c b/rail_cmd.c
index 33316a772..f40551d49 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -422,7 +422,7 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!IsTileType(tile, MP_TUNNELBRIDGE) && !EnsureNoVehicle(tile))
return CMD_ERROR;
- switch(GetTileType(tile))
+ switch (GetTileType(tile))
{
case MP_TUNNELBRIDGE:
if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile)))
@@ -592,7 +592,7 @@ static int32 CmdRailTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 p2
if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, TileVirtXY(x, y));
- for(;;) {
+ for (;;) {
ret = DoCommand(x, y, railtype, TrackdirToTrack(trackdir), flags, (mode == 0) ? CMD_BUILD_SINGLE_RAIL : CMD_REMOVE_SINGLE_RAIL);
if (CmdFailed(ret)) {
diff --git a/rail_gui.c b/rail_gui.c
index 846d7016d..16b764f9a 100644
--- a/rail_gui.c
+++ b/rail_gui.c
@@ -141,7 +141,7 @@ void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceRail_Station(TileIndex tile)
{
- if(_remove_button_clicked)
+ if (_remove_button_clicked)
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
else if (_railstation.dragdrop) {
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED);
@@ -631,7 +631,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e)
int x = _railstation.numtracks;
int y = _railstation.platlength;
if (_railstation.orientation == 0) intswap(x,y);
- if(!_remove_button_clicked)
+ if (!_remove_button_clicked)
SetTileSelectSize(x, y);
}
@@ -768,7 +768,7 @@ static void ShowStationBuilder(void)
static void BuildTrainDepotWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
RailType r;
diff --git a/road_cmd.c b/road_cmd.c
index d11689eea..8bbd33c97 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -222,8 +222,8 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
t2 = c;
cost = 0;
do {
- if (t2&1) cost += _price.remove_road;
- } while(t2>>=1);
+ if (t2 & 1) cost += _price.remove_road;
+ } while (t2 >>= 1);
if (flags & DC_EXEC) {
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
@@ -386,7 +386,7 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (IsSteepTileh(ti.tileh)) // very steep tile
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
- if(!_valid_tileh_slopes_road[2][ti.tileh]) // prevent certain slopes
+ if (!_valid_tileh_slopes_road[2][ti.tileh]) // prevent certain slopes
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
if (ti.map5 == 2) {
@@ -890,7 +890,7 @@ void DrawRoadDepotSprite(int x, int y, int image)
DrawSprite(dtss++->image, x, y);
- for(; dtss->image != 0; dtss++) {
+ for (; dtss->image != 0; dtss++) {
Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0);
image = dtss->image;
diff --git a/road_gui.c b/road_gui.c
index 4fc159bb6..83bb81688 100644
--- a/road_gui.c
+++ b/road_gui.c
@@ -405,7 +405,7 @@ static void ShowRoadDepotPicker(void)
static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
int image;
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 4f7abea20..515faac57 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -321,7 +321,7 @@ static Depot *FindClosestRoadDepot(Vehicle *v)
rfdd.best_length = (uint)-1;
/* search in all directions */
- for(i=0; i!=4; i++)
+ for (i = 0; i != 4; i++)
FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, i, (TPFEnumProc*)EnumRoadSignalFindDepot, NULL, &rfdd);
if (rfdd.best_length == (uint)-1)
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 3040e05d7..6d58567e3 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -230,7 +230,7 @@ void CcCloneRoadVeh(bool success, uint tile, uint32 p1, uint32 p2)
static void RoadVehViewWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
Vehicle *v = GetVehicle(w->window_number);
StringID str;
@@ -447,7 +447,7 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e)
break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 2: { /* listbox */
uint i = (e->click.pt.y - 14) / 14;
if (i < w->vscroll.cap) {
@@ -679,13 +679,13 @@ static void ClonePlaceObj(TileIndex tile, const Window* w)
static void RoadDepotWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
DrawRoadDepotWindow(w);
break;
case WE_CLICK: {
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 5:
RoadDepotClickVeh(w, e->click.pt.x, e->click.pt.y);
break;
@@ -739,7 +739,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
break;
case WE_DRAGDROP:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 5: {
Vehicle *v;
VehicleID sel = WP(w,traindepot_d).sel;
@@ -869,7 +869,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
PlayerID owner = GB(w->window_number, 0, 8);
vehiclelist_d *vl = &WP(w, vehiclelist_d);
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
int x = 2;
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
@@ -938,7 +938,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK: {
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: /* Flip sorting method ascending/descending */
vl->flags ^= VL_DESC;
vl->flags |= VL_RESORT;
@@ -984,7 +984,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
}
tile = TILE_MASK(tile + 1);
- } while(tile != _last_built_road_depot_tile);
+ } while (tile != _last_built_road_depot_tile);
ShowBuildRoadVehWindow(0);
} break;
diff --git a/saveload.c b/saveload.c
index 5e0988a60..f521ff7d6 100644
--- a/saveload.c
+++ b/saveload.c
@@ -778,11 +778,9 @@ static const ChunkHandler *SlFindChunkHandler(uint32 id)
const ChunkHandler *ch;
const ChunkHandler *const *chsc;
for (chsc = _sl.chs; (ch=*chsc++) != NULL;) {
- while(true) {
- if (ch->id == id)
- return ch;
- if (ch->flags & CH_LAST)
- break;
+ for (;;) {
+ if (ch->id == id) return ch;
+ if (ch->flags & CH_LAST) break;
ch++;
}
}
diff --git a/settings.c b/settings.c
index bb01b4137..564fad6b9 100644
--- a/settings.c
+++ b/settings.c
@@ -177,7 +177,7 @@ static IniFile *ini_load(const char *filename)
while (fgets(buffer, sizeof(buffer), in)) {
// trim whitespace from the left side
- for(s=buffer; s[0] == ' ' || s[0] == '\t'; s++);
+ for (s = buffer; s[0] == ' ' || s[0] == '\t'; s++);
// trim whitespace from right side.
e = s + strlen(s);
@@ -216,7 +216,7 @@ static IniFile *ini_load(const char *filename)
}
} else if (group) {
// find end of keyname
- for(t=s; *t != 0 && *t != '=' && *t != '\t' && *t != ' '; t++) {}
+ for (t=s; *t != 0 && *t != '=' && *t != '\t' && *t != ' '; t++) {}
// it's an item in an existing group
item = ini_item_alloc(group, s, t-s);
@@ -226,7 +226,7 @@ static IniFile *ini_load(const char *filename)
}
// for list items, the name and value are the same:
- if( group->type == IGT_LIST ) {
+ if (group->type == IGT_LIST) {
item->value = item->name;
continue;
}
@@ -236,10 +236,10 @@ static IniFile *ini_load(const char *filename)
// remove starting quotation marks
- if(*t=='\"') t++;
+ if (*t == '\"') t++;
// remove ending quotation marks
e = t + strlen(t);
- if(e>t && e[-1] =='\"') e--;
+ if (e > t && e[-1] =='\"') e--;
*e = 0;
item->value = pool_strdup(&ini->pool, t, e - t);
@@ -268,7 +268,7 @@ static IniGroup *ini_getgroup(IniFile *ini, const char *name, int len)
if (len == -1) len = strlen(name);
// does it exist already?
- for(group = ini->group; group; group = group->next)
+ for (group = ini->group; group; group = group->next)
if (!memcmp(group->name, name, len) && group->name[len] == 0)
return group;
@@ -284,7 +284,7 @@ static IniItem *ini_getitem(IniGroup *group, const char *name, bool create)
IniItem *item;
uint len = strlen(name);
- for(item = group->item; item; item = item->next)
+ for (item = group->item; item; item = item->next)
if (!strcmp(item->name, name))
return item;
@@ -310,7 +310,7 @@ static bool ini_save(const char *filename, IniFile *ini)
fprintf(f, "[%s]\n", group->name);
for (item = group->item; item != NULL; item = item->next) {
if (item->comment) fputs(item->comment, f);
- if(group->type==IGT_LIST)
+ if (group->type == IGT_LIST)
fprintf(f, "%s\n", item->value ? item->value : "");
else
fprintf(f, "%s = %s\n", item->name, item->value ? item->value : "");
@@ -339,7 +339,7 @@ static int lookup_oneofmany(const char *many, const char *one, int onelen)
return strtoul(one, NULL, 0);
idx = 0;
- for(;;) {
+ for (;;) {
// find end of item
s = many;
while (*s != '|' && *s != 0) s++;
@@ -356,7 +356,7 @@ static uint32 lookup_manyofmany(const char *many, const char *str)
int r;
uint32 res = 0;
- for(;;) {
+ for (;;) {
// skip "whitespace"
while (*str == ' ' || *str == '\t' || *str == '|') str++;
if (*str == 0) break;
@@ -379,7 +379,7 @@ static int parse_intlist(const char *p, int *items, int maxitems)
int n = 0, v;
char *end;
- for(;;) {
+ for (;;) {
v = strtol(p, &end, 0);
if (p == end || n == maxitems) return -1;
p = end;
@@ -406,18 +406,18 @@ static bool load_intlist(const char *str, void *array, int nelems, int type)
return false;
}
- switch(type) {
+ switch (type) {
case SDT_INT8 >> 4:
case SDT_UINT8 >> 4:
- for(i=0; i!=nitems; i++) ((byte*)array)[i] = items[i];
+ for (i = 0; i != nitems; i++) ((byte*)array)[i] = items[i];
break;
case SDT_INT16 >> 4:
case SDT_UINT16 >> 4:
- for(i=0; i!=nitems; i++) ((uint16*)array)[i] = items[i];
+ for (i = 0; i != nitems; i++) ((uint16*)array)[i] = items[i];
break;
case SDT_INT32 >> 4:
case SDT_UINT32 >> 4:
- for(i=0; i!=nitems; i++) ((uint32*)array)[i] = items[i];
+ for (i = 0; i != nitems; i++) ((uint32*)array)[i] = items[i];
break;
default:
NOT_REACHED();
@@ -430,8 +430,9 @@ static void make_intlist(char *buf, void *array, int nelems, int type)
{
int i, v = 0;
byte *p = (byte*)array;
- for(i=0; i!=nelems; i++) {
- switch(type) {
+
+ for (i = 0; i != nelems; i++) {
+ switch (type) {
case SDT_INT8 >> 4: v = *(int8*)p; p += 1; break;
case SDT_UINT8 >> 4:v = *(byte*)p; p += 1; break;
case SDT_INT16 >> 4:v = *(int16*)p; p += 2; break;
@@ -494,7 +495,7 @@ static const void *string_to_val(const SettingDesc *desc, const char *str)
unsigned long val;
char *end;
- switch(desc->flags & 0xF) {
+ switch (desc->flags & 0xF) {
case SDT_INTX:
val = strtoul(str, &end, 0);
if (*end != 0) ShowInfoF("ini: trailing characters at end of setting '%s'", desc->name);
@@ -558,13 +559,13 @@ static void load_setting_desc(IniFile *ini, const SettingDesc *desc, const void
// get ptr to array
ptr = desc->ptr;
- switch(desc->flags & 0xF) {
+ switch (desc->flags & 0xF) {
// all these are stored in the same way
case SDT_INTX:
case SDT_ONEOFMANY:
case SDT_MANYOFMANY:
case SDT_BOOLX:
- switch(desc->flags >> 4 & 7) {
+ switch (desc->flags >> 4 & 7) {
case SDT_INT8 >> 4:
case SDT_UINT8 >> 4:
*(byte*)ptr = (byte)(unsigned long)p;
@@ -640,12 +641,12 @@ static void save_setting_desc(IniFile *ini, const SettingDesc *desc, const void
// check if the value is the same as the old value
p = string_to_val(desc, item->value);
- switch(desc->flags & 0xF) {
+ switch (desc->flags & 0xF) {
case SDT_INTX:
case SDT_ONEOFMANY:
case SDT_MANYOFMANY:
case SDT_BOOLX:
- switch(desc->flags >> 4 & 7) {
+ switch (desc->flags >> 4 & 7) {
case SDT_INT8 >> 4:
case SDT_UINT8 >> 4:
if (*(byte*)ptr == (byte)(unsigned long)p)
@@ -674,12 +675,12 @@ static void save_setting_desc(IniFile *ini, const SettingDesc *desc, const void
}
}
- switch(desc->flags & 0xF) {
+ switch (desc->flags & 0xF) {
case SDT_INTX:
case SDT_ONEOFMANY:
case SDT_MANYOFMANY:
case SDT_BOOLX:
- switch(desc->flags >> 4 & 7) {
+ switch (desc->flags >> 4 & 7) {
case SDT_INT8 >> 4: i = *(int8*)ptr; break;
case SDT_UINT8 >> 4:i = *(byte*)ptr; break;
case SDT_INT16 >> 4:i = *(int16*)ptr; break;
@@ -689,7 +690,7 @@ static void save_setting_desc(IniFile *ini, const SettingDesc *desc, const void
default:
NOT_REACHED();
}
- switch(desc->flags & 0xF) {
+ switch (desc->flags & 0xF) {
case SDT_INTX:
sprintf(buf, "%u", i);
break;
diff --git a/settings_gui.c b/settings_gui.c
index 93cfaf85b..6c67a96e5 100644
--- a/settings_gui.c
+++ b/settings_gui.c
@@ -899,7 +899,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
}
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: {
int x,y;
uint btn;
@@ -926,7 +926,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
if (x < 21) { // clicked on the icon on the left side. Either scroller or bool on/off
int32 val = ReadPE(pe), oval = val;
- switch(pe->type) {
+ switch (pe->type) {
case PE_BOOL:
val ^= 1;
break;
@@ -1216,7 +1216,7 @@ static void NewgrfWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: { // select a grf file
int y = (e->click.pt.y - NEWGRF_WND_PROC_OFFSET_TOP_WIDGET) / NEWGRF_WND_PROC_ROWSIZE;
diff --git a/ship_gui.c b/ship_gui.c
index 19aaa1153..f8f154ed1 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -369,7 +369,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 2: { /* listbox */
uint i = (e->click.pt.y - 14) / 24;
if (i < w->vscroll.cap) {
@@ -460,7 +460,7 @@ static void ShowBuildShipWindow(TileIndex tile)
static void ShipViewWndProc(Window *w, WindowEvent *e) {
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
Vehicle *v = GetVehicle(w->window_number);
uint32 disabled = 1<<8;
@@ -763,7 +763,7 @@ static void ShipDepotWndProc(Window* w, WindowEvent* e)
break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 5:
ShipDepotClick(w, e->click.pt.x, e->click.pt.y);
break;
@@ -817,7 +817,7 @@ static void ShipDepotWndProc(Window* w, WindowEvent* e)
break;
case WE_DRAGDROP:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 5: {
Vehicle *v;
VehicleID sel = WP(w,traindepot_d).sel;
@@ -970,7 +970,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
PlayerID owner = GB(w->window_number, 0, 8);
vehiclelist_d *vl = &WP(w, vehiclelist_d);
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
int x = 2;
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
@@ -1041,7 +1041,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK: {
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: /* Flip sorting method ascending/descending */
vl->flags ^= VL_DESC;
vl->flags |= VL_RESORT;
@@ -1085,7 +1085,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
}
tile = TILE_MASK(tile + 1);
- } while(tile != _last_built_ship_depot_tile);
+ } while (tile != _last_built_ship_depot_tile);
ShowBuildShipWindow(0);
} break;
diff --git a/smallmap_gui.c b/smallmap_gui.c
index 4e1761a61..60a19d5cc 100644
--- a/smallmap_gui.c
+++ b/smallmap_gui.c
@@ -646,7 +646,7 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town
x = - dx - 4;
y = 0;
- for(;;) {
+ for (;;) {
uint32 mask;
int reps;
int t;
diff --git a/station_cmd.c b/station_cmd.c
index d95770560..84d553db0 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -2706,7 +2706,7 @@ uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount)
st2 = st1 = NULL;
best_rating = best_rating2 = 0;
- for( i = 0; i != 8 && around[i] != INVALID_STATION; i++) {
+ for (i = 0; i != 8 && around[i] != INVALID_STATION; i++) {
if (around_ptr[i]->goods[type].rating >= best_rating) {
best_rating2 = best_rating;
st2 = st1;
diff --git a/strgen/strgen.c b/strgen/strgen.c
index 45846d45e..b86df8756 100644
--- a/strgen/strgen.c
+++ b/strgen/strgen.c
@@ -116,7 +116,7 @@ static int _cur_argidx;
static uint HashStr(const char *s)
{
uint hash = 0;
- for(; *s; s++)
+ for (; *s; s++)
hash = ((hash << 3) | (hash >> 29)) ^ *s;
return hash % HASH_SIZE;
}
@@ -270,7 +270,7 @@ char *ParseWord(char **buf)
if (*s == '"') {
r = ++s;
// parse until next " or NUL
- for(;;) {
+ for (;;) {
if (*s == 0)
break;
if (*s == '"') {
@@ -282,7 +282,7 @@ char *ParseWord(char **buf)
} else {
// proceed until whitespace or NUL
r = s;
- for(;;) {
+ for (;;) {
if (*s == 0)
break;
if (*s == ' ' || *s == '\t') {
@@ -304,10 +304,9 @@ static void EmitWordList(char **words, int nw)
int i,j;
PutByte(nw);
- for(i=0; i<nw; i++)
- PutByte(strlen(words[i]));
- for(i=0; i<nw; i++) {
- for(j=0; words[i][j]; j++)
+ for (i = 0; i < nw; i++) PutByte(strlen(words[i]));
+ for (i = 0; i < nw; i++) {
+ for (j = 0; words[i][j]; j++)
PutByte(words[i][j]);
}
}
@@ -341,7 +340,7 @@ static void EmitPlural(char *buf, int value)
if (nw > _plural_form_counts[_lang_pluralform]) {
nw = _plural_form_counts[_lang_pluralform];
} else {
- for(; nw < _plural_form_counts[_lang_pluralform]; nw++) {
+ for (; nw < _plural_form_counts[_lang_pluralform]; nw++) {
words[nw] = words[nw - 1];
}
}
@@ -364,9 +363,8 @@ static void EmitGender(char *buf, int value)
buf++;
// This is a {G=DER} command
- for(nw=0; ;nw++) {
- if (nw >= 8)
- Fatal("G argument '%s' invalid", buf);
+ for (nw = 0; ; nw++) {
+ if (nw >= 8) Fatal("G argument '%s' invalid", buf);
if (!strcmp(buf, _genders[nw]))
break;
}
@@ -379,7 +377,7 @@ static void EmitGender(char *buf, int value)
// If no relative number exists, default to +0
if (!ParseRelNum(&buf, &argidx)) {}
- for(nw=0; nw<8; nw++) {
+ for (nw = 0; nw < 8; nw++) {
words[nw] = ParseWord(&buf);
if (!words[nw])
break;
@@ -507,7 +505,7 @@ static const CmdStruct *FindCmd(const char *s, int len)
{
int i;
const CmdStruct *cs = _cmd_structs;
- for(i=0; i != lengthof(_cmd_structs); i++, cs++) {
+ for (i=0; i != lengthof(_cmd_structs); i++, cs++) {
if (!strncmp(cs->cmd, s, len) && cs->cmd[len] == '\0')
return cs;
}
@@ -517,7 +515,7 @@ static const CmdStruct *FindCmd(const char *s, int len)
static int ResolveCaseName(const char *str, int len)
{
int i;
- for(i=0; i<MAX_NUM_CASES; i++)
+ for (i = 0; i < MAX_NUM_CASES; i++)
if (!memcmp(_cases[i], str, len) && _cases[i][len] == 0)
return i + 1;
Fatal("Invalid case-name '%s'", str);
@@ -536,7 +534,7 @@ static const CmdStruct *ParseCommandString(const char **str, char *param, int *a
*casei = -1;
// Scan to the next command, exit if there's no next command.
- for(; *s != '{'; s++) {
+ for (; *s != '{'; s++) {
if (*s == '\0')
return NULL;
}
@@ -583,7 +581,7 @@ static const CmdStruct *ParseCommandString(const char **str, char *param, int *a
if (c == '=') s--;
// copy params
start = s;
- for(;;) {
+ for (;;) {
c = *s++;
if (c == '}') break;
if (c == '\0') {
@@ -619,7 +617,7 @@ static void HandlePragma(char *str)
Fatal("Invalid pluralform %d", _lang_pluralform);
} else if (!memcmp(str, "gender ", 7)) {
char *buf = str + 7, *s;
- for(;;) {
+ for (;;) {
s = ParseWord(&buf);
if (!s) break;
if (_numgenders >= MAX_NUM_GENDER) Fatal("Too many genders, max %d", MAX_NUM_GENDER);
@@ -628,7 +626,7 @@ static void HandlePragma(char *str)
}
} else if (!memcmp(str, "case ", 5)) {
char *buf = str + 5, *s;
- for(;;) {
+ for (;;) {
s = ParseWord(&buf);
if (!s) break;
if (_numcases >= MAX_NUM_CASES) Fatal("Too many cases, max %d", MAX_NUM_CASES);
@@ -650,7 +648,7 @@ static void ExtractCommandString(ParsedCommandStruct *p, char *s, bool warnings)
memset(p, 0, sizeof(*p));
- for(;;) {
+ for (;;) {
// read until next command from a.
ar = ParseCommandString((const char **)&s, param, &argno, &casei);
if (ar == NULL)
@@ -710,10 +708,10 @@ static bool CheckCommandsMatch(char *a, char *b, const char *name)
result = false;
}
- for(i = 0; i < templ.np; i++) {
+ for (i = 0; i < templ.np; i++) {
// see if we find it in lang, and zero it out
bool found = false;
- for(j = 0; j < lang.np; j++) {
+ for (j = 0; j < lang.np; j++) {
if (templ.pairs[i].a == lang.pairs[j].a &&
!strcmp(templ.pairs[i].v, lang.pairs[j].v)) {
// it was found in both. zero it out from lang so we don't find it again
@@ -731,7 +729,7 @@ static bool CheckCommandsMatch(char *a, char *b, const char *name)
// if we reach here, all non consumer commands match up.
// Check if the non consumer commands match up also.
- for(i = 0; i < lengthof(templ.cmd); i++) {
+ for (i = 0; i < lengthof(templ.cmd); i++) {
if (TranslateCmdForCompare(templ.cmd[i]) != TranslateCmdForCompare(lang.cmd[i])) {
Warning("%s: Param idx #%d '%s' doesn't match with template command '%s'", name, i,
!lang.cmd[i] ? "<empty>" : lang.cmd[i]->cmd,
@@ -767,7 +765,7 @@ static void HandleString(char *str, bool master)
// Trim spaces.
// After this str points to the command name, and s points to the command contents
- for(t = s; t > str && (t[-1]==' ' || t[-1]=='\t'); t--);
+ for (t = s; t > str && (t[-1] ==' ' || t[-1] == '\t'); t--);
*t = 0;
s++;
@@ -884,7 +882,7 @@ static void ParseFile(const char *file, bool english)
static uint32 MyHashStr(uint32 hash, const char *s)
{
- for(; *s; s++) {
+ for (; *s; s++) {
hash = ((hash << 3) | (hash >> 29)) ^ *s;
if (hash & 1) hash = (hash>>1) ^ 0xDEADBEEF; else hash >>= 1;
}
@@ -904,7 +902,7 @@ static void MakeHashOfStrings(void)
int argno;
int casei;
- for(i = 0; i != 65536; i++) {
+ for (i = 0; i != 65536; i++) {
if ((ls=_strings[i]) != NULL) {
s = ls->name;
hash ^= i * 0x717239;
@@ -929,7 +927,7 @@ static int CountInUse(int grp)
{
int i;
- for(i = 0x800; --i >= 0;) {
+ for (i = 0x800; --i >= 0;) {
if (_strings[(grp<<11)+i] != NULL)
break;
}
@@ -983,7 +981,7 @@ static void WriteStringsH(const char *filename)
lastgrp = 0;
- for(i = 0; i != 65536; i++) {
+ for (i = 0; i != 65536; i++) {
if (_strings[i]) {
if (lastgrp != (i >> 11)) {
lastgrp = (i >> 11);
@@ -1025,7 +1023,7 @@ static int TranslateArgumentIdx(int argidx)
if (argidx < 0 || argidx >= lengthof(_cur_pcs.cmd))
Fatal("invalid argidx %d", argidx);
- for(i = sum = 0; i < argidx; i++) {
+ for (i = sum = 0; i < argidx; i++) {
const CmdStruct *cs = _cur_pcs.cmd[i];
sum += cs ? cs->consumes : 1;
}
@@ -1105,7 +1103,7 @@ static void WriteLangfile(const char *filename, int show_todo)
if (f == NULL) Fatal("can't open %s", filename);
memset(&hdr, 0, sizeof(hdr));
- for(i = 0; i != 32; i++) {
+ for (i = 0; i != 32; i++) {
int n = CountInUse(i);
in_use[i] = n;
hdr.offsets[i] = TO_LE16(n);
@@ -1121,8 +1119,8 @@ static void WriteLangfile(const char *filename, int show_todo)
fwrite(&hdr, sizeof(hdr), 1, f);
- for(i = 0; i != 32; i++) {
- for(j = 0; j != in_use[i]; j++) {
+ for (i = 0; i != 32; i++) {
+ for (j = 0; j != in_use[i]; j++) {
LangString *ls = _strings[(i<<11)+j];
Case *casep;
@@ -1143,7 +1141,7 @@ static void WriteLangfile(const char *filename, int show_todo)
Warning("'%s' is untranslated", ls->name);
} else {
const char *s = "<TODO> ";
- while(*s) PutByte(*s++);
+ while (*s) PutByte(*s++);
}
}
@@ -1169,11 +1167,11 @@ static void WriteLangfile(const char *filename, int show_todo)
// Each LEN is printed using 2 bytes in big endian order.
PutByte(0x9E);
// Count the number of cases
- for(num=0,c=casep; c; c=c->next) num++;
+ for (num = 0, c = casep; c; c = c->next) num++;
PutByte(num);
// Write each case
- for(c=casep; c; c=c->next) {
+ for (c = casep; c; c = c->next) {
int pos;
PutByte(c->caseidx);
// Make some space for the 16-bit length
diff --git a/strings.c b/strings.c
index 581829389..e28ec25dd 100644
--- a/strings.c
+++ b/strings.c
@@ -402,7 +402,7 @@ static int DeterminePluralForm(int32 n)
// The absolute value determines plurality
if (n < 0) n = -n;
- switch(_langpack->plural_form) {
+ switch (_langpack->plural_form) {
// Two forms, singular used for one only
// Used in:
// Danish, Dutch, English, German, Norwegian, Swedish, Estonian, Finnish,
@@ -466,7 +466,8 @@ static const char *ParseStringChoice(const char *b, uint form, char *dst, int *d
//<NUM> {Length of each string} {each string}
uint n = (byte)*b++;
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++;
if (i == form) {
mypos = pos;
diff --git a/terraform_gui.c b/terraform_gui.c
index 91ddac0dc..106a59c2c 100644
--- a/terraform_gui.c
+++ b/terraform_gui.c
@@ -205,7 +205,7 @@ static OnButtonClick * const _terraform_button_proc[] = {
static void TerraformToolbWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
DrawWindowWidgets(w);
break;
diff --git a/town_cmd.c b/town_cmd.c
index e674a4855..fdf1e6a41 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -593,7 +593,7 @@ static void GrowTownInTile(TileIndex *tile_ptr, uint mask, int block, Town *t1)
if (CHANCE16(1, 4)) {
do {
a = GB(Random(), 0, 2);
- } while(a == b);
+ } while (a == b);
}
if (!IsRoadAllowedHere(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[a])), a)) {
@@ -702,7 +702,7 @@ build_road_and_exit:
// obviously, if building any bridge would fail, there is no need to try other bridge-types
return;
}
- } while(--j != 0);
+ } while (--j != 0);
}
}
#undef IS_WATER_TILE
@@ -889,7 +889,7 @@ static bool CreateTownName(uint32 *townnameparts)
assert(townnameparts);
- for(;;) {
+ for (;;) {
restart:
r = Random();
@@ -956,7 +956,7 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts)
t->act_food = 0;
t->act_water = 0;
- for(i = 0; i != MAX_PLAYERS; i++)
+ for (i = 0; i != MAX_PLAYERS; i++)
t->ratings[i] = 500;
t->have_ratings = 0;
@@ -1170,11 +1170,10 @@ static bool CheckFree2x2Area(Town *t1, TileIndex tile)
{1 - 1, 1 - 0}
};
- for(i=0; i!=4; i++) {
+ for (i = 0; i != 4; i++) {
tile += ToTileIndexDiff(_tile_add[i]);
- if (GetTileSlope(tile, NULL))
- return false;
+ if (GetTileSlope(tile, NULL)) return false;
if (CmdFailed(DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_FORCETEST, CMD_LANDSCAPE_CLEAR)))
return false;
@@ -1214,12 +1213,12 @@ static void DoBuildTownHouse(Town *t, TileIndex tile)
int num = 0;
// Generate a list of all possible houses that can be built.
- for(i=0; i!=lengthof(_housetype_flags); i++) {
+ for (i=0; i!=lengthof(_housetype_flags); i++) {
if ((~_housetype_flags[i] & bitmask) == 0)
houses[num++] = (byte)i;
}
- for(;;) {
+ for (;;) {
house = houses[RandomRange(num)];
if (_cur_year < _housetype_years[house].min || _cur_year > _housetype_years[house].max)
@@ -1919,7 +1918,7 @@ void TownsMonthlyLoop(void)
t->road_build_months--;
if (t->exclusive_counter != 0)
- if(--t->exclusive_counter==0)
+ if (--t->exclusive_counter == 0)
t->exclusivity = (byte)-1;
UpdateTownGrowRate(t);
diff --git a/town_gui.c b/town_gui.c
index 2574ed320..587f80449 100644
--- a/town_gui.c
+++ b/town_gui.c
@@ -466,7 +466,7 @@ static void TownDirectoryWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: { /* Sort by Name ascending/descending */
_town_sort_order = (_town_sort_order == 0) ? 1 : 0;
_town_sort_dirty = true;
diff --git a/train_cmd.c b/train_cmd.c
index 2e11c1654..1de6dcebb 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -894,11 +894,11 @@ static void NormaliseTrainConsist(Vehicle *v)
assert(IsFrontEngine(v));
- for(; v != NULL; v = GetNextVehicle(v)) {
+ for (; v != NULL; v = GetNextVehicle(v)) {
if (!IsMultiheaded(v) || !IsTrainEngine(v)) continue;
/* make sure that there are no free cars before next engine */
- for(u = v; u->next != NULL && !IsTrainEngine(u->next); u = u->next);
+ for (u = v; u->next != NULL && !IsTrainEngine(u->next); u = u->next);
if (u == v->u.rail.other_multiheaded_part) continue;
AddWagonToConsist(v->u.rail.other_multiheaded_part, u);
@@ -974,7 +974,7 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* we need to make sure that we didn't place it between a pair of multiheaded engines */
Vehicle *u, *engine = NULL;
- for(u = dst_head; u != NULL; u = u->next) {
+ for (u = dst_head; u != NULL; u = u->next) {
if (IsTrainEngine(u) && IsMultiheaded(u) && u->u.rail.other_multiheaded_part != NULL) {
engine = u;
}
@@ -2214,7 +2214,7 @@ static bool CheckReverseTrain(Vehicle *v)
reverse_best = false;
}
} else {
- while(true) {
+ for (;;) {
fd.best_bird_dist = (uint)-1;
fd.best_track_dist = (uint)-1;
@@ -3536,7 +3536,7 @@ void ConnectMultiheadedTrains(void)
{
Vehicle *w;
- for(w = u->next; w != NULL && (w->engine_type != u->engine_type || w->u.rail.other_multiheaded_part != NULL); w = GetNextVehicle(w));
+ for (w = u->next; w != NULL && (w->engine_type != u->engine_type || w->u.rail.other_multiheaded_part != NULL); w = GetNextVehicle(w));
if (w != NULL) {
/* we found a car to partner with this engine. Now we will make sure it face the right way */
if (IsTrainEngine(w)) {
diff --git a/train_gui.c b/train_gui.c
index 49c28ac6a..4fc4f264f 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -194,7 +194,7 @@ static void engine_drawing_loop(int *x, int *y, int *pos, int *sel,
static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
if (w->window_number == 0)
@@ -250,7 +250,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
break;
case WE_CLICK: {
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 2: {
uint i = (e->click.pt.y - 14) / 14;
if (i < w->vscroll.cap) {
@@ -570,7 +570,7 @@ static void TrainDepotClickTrain(Window *w, int x, int y)
v = gdvp.wagon;
- switch(mode) {
+ switch (mode) {
case 0: { // start dragging of vehicle
VehicleID sel = WP(w, traindepot_d).sel;
@@ -627,13 +627,13 @@ static void ClonePlaceObj(TileIndex tile, const Window* w)
static void TrainDepotWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
DrawTrainDepotWindow(w);
break;
case WE_CLICK: {
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 8:
ResetObjectToPlace();
ShowBuildTrainWindow(w->window_number);
@@ -686,7 +686,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
break;
case WE_DRAGDROP: {
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 4: case 5: {
Vehicle *v;
int sell_cmd;
@@ -824,7 +824,7 @@ static void RailVehicleRefitWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK:
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 2: { /* listbox */
int y = e->click.pt.y - 25;
if (y >= 0) {
@@ -985,7 +985,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
int wid = e->click.widget;
Vehicle *v = GetVehicle(w->window_number);
- switch(wid) {
+ switch (wid) {
case 5: /* start/stop train */
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN));
break;
@@ -1197,7 +1197,7 @@ static void DrawTrainDetailsWindow(Window *w)
// draw the first 3 details tabs
if (det_tab != 3) {
x = 1;
- for(;;) {
+ for (;;) {
if (--sel < 0 && sel >= -6) {
int dx = 0;
u = v;
@@ -1372,7 +1372,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
PlayerID owner = GB(w->window_number, 0, 8);
vehiclelist_d *vl = &WP(w, vehiclelist_d);
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
int x = 2;
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
@@ -1442,7 +1442,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
}
case WE_CLICK: {
- switch(e->click.widget) {
+ switch (e->click.widget) {
case 3: /* Flip sorting method ascending/descending */
vl->flags ^= VL_DESC;
vl->flags |= VL_RESORT;
@@ -1490,7 +1490,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
}
tile = TILE_MASK(tile + 1);
- } while(tile != _last_built_train_depot_tile);
+ } while (tile != _last_built_train_depot_tile);
ShowBuildTrainWindow(0);
} break;
diff --git a/tree_cmd.c b/tree_cmd.c
index 2863061cb..19cfab66b 100644
--- a/tree_cmd.c
+++ b/tree_cmd.c
@@ -315,7 +315,7 @@ static void DrawTile_Trees(TileInfo *ti)
} while (i);
/* draw them in a sorted way */
- for(;;) {
+ for (;;) {
byte min = 0xFF;
TreeListEnt *tep = NULL;
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 2c1a50c40..19fb0330d 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -693,7 +693,7 @@ static TileIndex FindEdgesOfBridge(TileIndex tile, TileIndex *endtile)
TileIndex start;
// find start of bridge
- for(;;) {
+ for (;;) {
if (IsTileType(tile, MP_TUNNELBRIDGE) && (_m[tile].m5 & 0xE0) == 0x80)
break;
tile += direction ? TileDiffXY(0, -1) : TileDiffXY(-1, 0);
@@ -702,7 +702,7 @@ static TileIndex FindEdgesOfBridge(TileIndex tile, TileIndex *endtile)
start = tile;
// find end of bridge
- for(;;) {
+ for (;;) {
if (IsTileType(tile, MP_TUNNELBRIDGE) && (_m[tile].m5 & 0xE0) == 0xA0)
break;
tile += direction ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
@@ -1007,9 +1007,15 @@ static void DrawBridgePillars(const TileInfo *ti, int x, int y, int z)
if (!(ti->tileh & p[3])) back_height += 8;
}
- for(; z>=front_height || z>=back_height; z=z-8) {
- if (z>=front_height) AddSortableSpriteToDraw(image, x,y, p[4], p[5], 0x28, z); // front facing pillar
- if (z>=back_height && z<i-8) AddSortableSpriteToDraw(image, x - p[6], y - p[7], p[4], p[5], 0x28, z); // back facing pillar
+ for (; z >= front_height || z >= back_height; z = z - 8) {
+ if (z >= front_height) {
+ // front facing pillar
+ AddSortableSpriteToDraw(image, x,y, p[4], p[5], 0x28, z);
+ }
+ if (z >= back_height && z < i - 8) {
+ // back facing pillar
+ AddSortableSpriteToDraw(image, x - p[6], y - p[7], p[4], p[5], 0x28, z);
+ }
}
}
}
diff --git a/unix.c b/unix.c
index 192337ef3..2d82ed2ff 100644
--- a/unix.c
+++ b/unix.c
@@ -461,7 +461,7 @@ int CDECL main(int argc, char* argv[])
#ifdef WITH_COCOA
cocoaSetupAutoreleasePool();
/* This is passed if we are launched by double-clicking */
- if(argc >= 2 && strncmp (argv[1], "-psn", 4) == 0) {
+ if (argc >= 2 && strncmp (argv[1], "-psn", 4) == 0) {
argv[1] = NULL;
argc = 1;
cocoaSetWorkingDirectory();
diff --git a/vehicle.c b/vehicle.c
index d0eccc5cf..ffd513a33 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -341,7 +341,7 @@ bool AllocateVehicles(Vehicle **vl, int num)
Vehicle *v;
VehicleID counter = 0;
- for(i = 0; i != num; i++) {
+ for (i = 0; i != num; i++) {
v = AllocateSingleVehicle(&counter);
if (v == NULL) {
return false;
@@ -715,9 +715,9 @@ void ViewportAddVehicles(DrawPixelInfo *dpi)
y = ((dpi->top - 70) & 0xFC0);
y2 = ((dpi->top + dpi->height) & 0xFC0);
- for(;;) {
+ for (;;) {
xb = x;
- for(;;) {
+ for (;;) {
veh = _vehicle_position_hash[(x + y) & 0xFFFF];
while (veh != INVALID_VEHICLE) {
v = GetVehicle(veh);
@@ -1945,8 +1945,7 @@ Trackdir GetVehicleTrackdir(const Vehicle* v)
{
if (v->vehstatus & VS_CRASHED) return 0xFF;
- switch(v->type)
- {
+ switch (v->type) {
case VEH_Train:
if (v->u.rail.track == 0x80) /* We'll assume the train is facing outwards */
return DiagdirToDiagTrackdir(GetDepotDirection(v->tile, TRANSPORT_RAIL)); /* Train in depot */
diff --git a/video/sdl_v.c b/video/sdl_v.c
index 93ff90bbc..3b27c7ad6 100644
--- a/video/sdl_v.c
+++ b/video/sdl_v.c
@@ -140,7 +140,7 @@ static int GetAvailableVideoMode(int *w, int *h)
// is the wanted mode among the available modes?
for (i = 0; i != _num_resolutions; i++) {
- if(*w == _resolutions[i][0] && *h == _resolutions[i][1])
+ if (*w == _resolutions[i][0] && *h == _resolutions[i][1])
return 1;
}
@@ -348,7 +348,7 @@ static int PollEvent(void)
case SDL_QUIT:
// do not ask to quit on the main screen
if (_game_mode != GM_MENU) {
- if(_patches.autosave_on_exit) {
+ if (_patches.autosave_on_exit) {
DoExitSave();
return 0;
} else
diff --git a/video/win32_v.c b/video/win32_v.c
index 87533a551..989d7ff4a 100644
--- a/video/win32_v.c
+++ b/video/win32_v.c
@@ -709,7 +709,7 @@ static void Win32GdiMainLoop(void)
_wnd.running = true;
- while(true) {
+ for (;;) {
while (PeekMessage(&mesg, NULL, 0, 0, PM_REMOVE)) {
InteractiveRandom(); // randomness
TranslateMessage(&mesg);
diff --git a/viewport.c b/viewport.c
index acf158b58..7d88bb33a 100644
--- a/viewport.c
+++ b/viewport.c
@@ -571,7 +571,7 @@ void DebugMarkTile(TileIndex tile) {
void DebugClearMarkedTiles()
{
uint size = MapSize(), i;
- for(i=0; i!=size; i++) {
+ for (i = 0; i != size; i++) {
if (_m[i].extra & 0x80) {
_m[i].extra &= ~0x80;
MarkTileDirtyByTile(i);
@@ -598,7 +598,7 @@ static bool IsPartOfAutoLine(int px, int py)
px -= _thd.selstart.x;
py -= _thd.selstart.y;
- switch(_thd.drawstyle) {
+ switch (_thd.drawstyle) {
case HT_LINE | HT_DIR_X: return py == 0; // x direction
case HT_LINE | HT_DIR_Y: return px == 0; // y direction
case HT_LINE | HT_DIR_HU: return px == -py || px == -py - 16; // horizontal upper
@@ -1954,7 +1954,7 @@ static byte Check2x1AutoRail(int mode)
int fxmy = _tile_fract_coords.x - _tile_fract_coords.y;
int sxmy = (_thd.selend.x & 0xF) - (_thd.selend.y & 0xF);
- switch(mode) {
+ switch (mode) {
case 0: // end piece is lower right
if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return 3; }
if (fxmy < -3 && sxmy > 3) {/* DoRailroadTrack(0); */return 5; }
diff --git a/widget.c b/widget.c
index b6b64352b..ac722f501 100644
--- a/widget.c
+++ b/widget.c
@@ -477,7 +477,7 @@ static void DropdownMenuWndProc(Window *w, WindowEvent *e)
{
int item;
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
int x,y,i,sel;
diff --git a/win32.c b/win32.c
index 05218884f..9e01aed96 100644
--- a/win32.c
+++ b/win32.c
@@ -141,7 +141,7 @@ static void GetFileInfo(DebugFileInfo *dfi, const char *filename)
file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, 0);
if (file != INVALID_HANDLE_VALUE) {
- while(true) {
+ for (;;) {
if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 ||
numread == 0)
break;
@@ -359,7 +359,7 @@ static bool DoEmergencySave(HWND wnd)
static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
SetDlgItemText(wnd, 10, _crash_desc);
SetDlgItemText(wnd, 11, _crash_msg);
@@ -367,7 +367,7 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM l
SetWndSize(wnd, -1);
return TRUE;
case WM_COMMAND:
- switch(wParam) {
+ switch (wParam) {
case 12: // Close
ExitProcess(0);
case 13: { // Emergency save
diff --git a/window.c b/window.c
index be2444137..8a44832ff 100644
--- a/window.c
+++ b/window.c
@@ -48,7 +48,7 @@ static void DispatchLeftClickEvent(Window* w, int x, int y)
if (wi->type & 0xE0) {
/* special widget handling for buttons*/
- switch(wi->type) {
+ switch (wi->type) {
case WWT_IMGBTN | WWB_PUSHBUTTON: /* WWT_PUSHIMGBTN */
case WWT_TEXTBTN | WWB_PUSHBUTTON: /* WWT_PUSHTXTBTN */
HandleButtonClick(w, e.click.widget);