summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ai.c196
-rw-r--r--ai_build.c8
-rw-r--r--ai_pathfinder.c46
-rw-r--r--aircraft_cmd.c32
-rw-r--r--aircraft_gui.c8
-rw-r--r--airport_gui.c6
-rw-r--r--aystar.c34
-rw-r--r--aystar.h10
-rw-r--r--bridge_gui.c10
-rw-r--r--clear_cmd.c54
-rw-r--r--command.c20
-rw-r--r--command.h4
-rw-r--r--console.c38
-rw-r--r--disaster_cmd.c76
-rw-r--r--dock_gui.c6
-rw-r--r--economy.c84
-rw-r--r--economy.h2
-rw-r--r--engine.c20
-rw-r--r--engine_gui.c6
-rw-r--r--fileio.c4
-rw-r--r--gfx.c18
-rw-r--r--gfx.h6
-rw-r--r--graph_gui.c60
-rw-r--r--grfspecial.c14
-rw-r--r--hal.h2
-rw-r--r--industry_gui.c30
-rw-r--r--intro_gui.c12
-rw-r--r--macros.h8
-rw-r--r--main_gui.c82
-rw-r--r--misc_cmd.c18
-rw-r--r--misc_gui.c56
-rw-r--r--music_gui.c16
-rw-r--r--namegen.c90
-rw-r--r--network.c94
-rw-r--r--network_gui.c44
-rw-r--r--news_gui.c26
-rw-r--r--oldloader.c62
-rw-r--r--order_cmd.c48
-rw-r--r--order_gui.c22
-rw-r--r--pathfind.c80
-rw-r--r--road_gui.c20
-rw-r--r--roadveh_cmd.c102
-rw-r--r--roadveh_gui.c64
-rw-r--r--saveload.c50
-rw-r--r--screenshot.c34
-rw-r--r--sdl.c38
-rw-r--r--settings.c44
-rw-r--r--settings_gui.c54
-rw-r--r--ship_cmd.c62
-rw-r--r--ship_gui.c74
-rw-r--r--smallmap_gui.c48
-rw-r--r--sound.c22
-rw-r--r--station.h2
-rw-r--r--station_cmd.c172
-rw-r--r--station_gui.c22
-rw-r--r--stdafx.h2
-rw-r--r--strings.c42
-rw-r--r--subsidy_gui.c8
-rw-r--r--terraform_gui.c8
-rw-r--r--texteff.c8
-rw-r--r--town.h16
-rw-r--r--town_cmd.c112
-rw-r--r--town_gui.c22
-rw-r--r--train_cmd.c212
-rw-r--r--train_gui.c96
-rw-r--r--tree_cmd.c44
-rw-r--r--ttd.c68
-rw-r--r--ttd.h20
-rw-r--r--tunnelbridge_cmd.c132
-rw-r--r--unix.c42
-rw-r--r--unmovable_cmd.c50
-rw-r--r--variables.h8
-rw-r--r--vehicle.c96
-rw-r--r--vehicle.h12
-rw-r--r--vehicle_gui.c6
-rw-r--r--viewport.c176
-rw-r--r--viewport.h4
-rw-r--r--w32dm2.cpp20
-rw-r--r--water_cmd.c54
-rw-r--r--widget.c52
-rw-r--r--win32.c142
-rw-r--r--window.c2
82 files changed, 1857 insertions, 1857 deletions
diff --git a/ai.c b/ai.c
index a3dc2a173..3fce9f316 100644
--- a/ai.c
+++ b/ai.c
@@ -68,7 +68,7 @@ static void AiCase1(Player *p)
static void AiStateVehLoop(Player *p)
{
Vehicle *v;
-
+
v = p->ai.cur_veh == NULL ? _vehicles : p->ai.cur_veh+1;
for (;v != endof(_vehicles); v++) {
@@ -79,7 +79,7 @@ static void AiStateVehLoop(Player *p)
v->type == VEH_Road ||
(v->type == VEH_Aircraft && v->subtype <= 2) ||
v->type == VEH_Ship) {
-
+
/* replace engine? */
if (v->type == VEH_Train && v->engine_type < 3 &&
(_price.build_railvehicle >> 3) < p->player_money) {
@@ -115,7 +115,7 @@ static void AiStateVehLoop(Player *p)
// XXX
static const byte _rail_locos_count[3] = {
- 27, 3, 5
+ 27, 3, 5
};
extern const byte _rail_engines_start[3];
@@ -130,14 +130,14 @@ static int AiChooseTrainToBuild(byte railtype, int32 money, byte flag)
Engine *e = &_engines[i];
do {
assert(!(_rail_vehicle_info[i].flags & RVI_WAGON));
-
+
if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D)
continue;
r = DoCommandByTile(0, i, 0, 0, CMD_BUILD_RAIL_VEHICLE);
- if (r != CMD_ERROR &&
- (!(_cmd_build_rail_veh_var1&1) || !(flag&1)) &&
- r <= money &&
+ if (r != CMD_ERROR &&
+ (!(_cmd_build_rail_veh_var1&1) || !(flag&1)) &&
+ r <= money &&
_cmd_build_rail_veh_score >= best_veh_score) {
best_veh_score = _cmd_build_rail_veh_score;
best_veh_index = i;
@@ -206,7 +206,7 @@ static int32 AiGetBasePrice(Player *p)
// adjust base price when more expensive vehicles are available
if (p->ai.railtype_to_use == 1) base = (base * 3) >> 1;
else if (p->ai.railtype_to_use == 2) base *= 2;
-
+
return base;
}
@@ -266,7 +266,7 @@ static void AiHandleGotoDepot(Player *p, int cmd)
p->ai.cur_veh->next_order = OT_DUMMY;
InvalidateWindow(WC_VEHICLE_VIEW, p->ai.cur_veh->index);
}
-}
+}
static void AiRestoreVehicleOrders(Vehicle *v, BackuppedOrders *bak)
{
@@ -296,7 +296,7 @@ static void AiHandleReplaceTrain(Player *p)
if (veh != -1) {
BackupVehicleOrders(v, orderbak);
tile = v->tile;
-
+
if (DoCommandByTile(0, v->index, 2, DC_EXEC, CMD_SELL_RAIL_WAGON) != CMD_ERROR &&
DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE) != CMD_ERROR) {
veh = _new_train_id;
@@ -324,7 +324,7 @@ static void AiHandleReplaceRoadVeh(Player *p)
if (veh != -1) {
BackupVehicleOrders(v, orderbak);
tile = v->tile;
-
+
if (DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH) != CMD_ERROR &&
DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH) != CMD_ERROR) {
veh = _new_roadveh_id;
@@ -437,7 +437,7 @@ static void AiFindSubsidyIndustryRoute(FoundRoute *fr)
// initially error
fr->distance = -1;
- // Randomize subsidy index..
+ // Randomize subsidy index..
i = RandomRange(lengthof(_subsidies) * 3);
if (i >= lengthof(_subsidies))
return;
@@ -476,7 +476,7 @@ static void AiFindSubsidyPassengerRoute(FoundRoute *fr)
// initially error
fr->distance = -1;
- // Randomize subsidy index..
+ // Randomize subsidy index..
i = RandomRange(lengthof(_subsidies) * 3);
if (i >= lengthof(_subsidies))
return;
@@ -512,7 +512,7 @@ static void AiFindRandomIndustryRoute(FoundRoute *fr)
// pick a source
fr->from = i = AiFindRandomIndustry();
- if (i == NULL)
+ if (i == NULL)
return;
// pick a random produced cargo
@@ -539,7 +539,7 @@ static void AiFindRandomIndustryRoute(FoundRoute *fr)
t = AiFindRandomTown();
if (t == NULL || t->population < (uint32)(cargo == CT_FOOD ? 200 : 900))
return;
-
+
fr->to = t;
fr->distance = GetTileDist(i->xy, t->xy);
}
@@ -558,7 +558,7 @@ static void AiFindRandomPassengerRoute(FoundRoute *fr)
fr->from = source = AiFindRandomTown();
if (source == NULL || source->population < 400)
return;
-
+
fr->to = dest = AiFindRandomTown();
if (dest == NULL || source == dest || dest->population < 400)
return;
@@ -589,7 +589,7 @@ static bool AiCheckIfRouteIsGood(Player *p, FoundRoute *fr, byte bitmask)
if (to_tile == from_tile && st->xy == to_tile)
same_station++;
}
-
+
// To prevent the AI from building ten busstations in the same town, do some calculations
// For each road or airport station, we want 350 of population!
if ((bitmask == 2 || bitmask == 4) && same_station > 2 && ((Town *)(fr->from))->population < same_station * 350)
@@ -612,8 +612,8 @@ static bool AiCheckIfRouteIsGood(Player *p, FoundRoute *fr, byte bitmask)
return false;
} else {
Industry *i = (Industry*)fr->from;
-
- if (i->pct_transported[fr->cargo != i->produced_cargo[0]] > 0x99 ||
+
+ if (i->pct_transported[fr->cargo != i->produced_cargo[0]] > 0x99 ||
i->total_production[fr->cargo != i->produced_cargo[0]] == 0)
return false;
}
@@ -680,7 +680,7 @@ static void AiWantLongIndustryRoute(Player *p)
p->ai.src.cargo = fr.cargo | 0x80;
// Fill the dest field
-
+
p->ai.dst.use_tile = 0;
p->ai.dst.rand_rng = 9;
p->ai.dst.cur_building_rule = 0xFF;
@@ -751,7 +751,7 @@ static void AiWantMediumIndustryRoute(Player *p)
i = 60;
for(;;) {
-
+
// look for one from the subsidy list
AiFindSubsidyIndustryRoute(&fr);
if (IS_INT_INSIDE(fr.distance, 40, 60+1))
@@ -824,7 +824,7 @@ static void AiWantShortIndustryRoute(Player *p)
i = 60;
for(;;) {
-
+
// look for one from the subsidy list
AiFindSubsidyIndustryRoute(&fr);
if (IS_INT_INSIDE(fr.distance, 15, 40+1))
@@ -897,7 +897,7 @@ static void AiWantMailRoute(Player *p)
i = 60;
for(;;) {
-
+
// look for one from the subsidy list
AiFindSubsidyPassengerRoute(&fr);
if (IS_INT_INSIDE(fr.distance, 60, 110+1))
@@ -1003,7 +1003,7 @@ static void AiWantPassengerRoute(Player *p)
i = 60;
for(;;) {
-
+
// look for one from the subsidy list
AiFindSubsidyPassengerRoute(&fr);
if (IS_INT_INSIDE(fr.distance, 0, 55+1))
@@ -1075,7 +1075,7 @@ static void AiWantTrainRoute(Player *p)
uint16 r;
p->ai.railtype_to_use = p->max_railtype - 1;
r = (uint16)Random();
-
+
if (r > 0xD000) {
AiWantLongIndustryRoute(p);
} else if (r > 0x6000) {
@@ -1096,7 +1096,7 @@ static void AiWantLongRoadIndustryRoute(Player *p)
i = 60;
for(;;) {
-
+
// look for one from the subsidy list
AiFindSubsidyIndustryRoute(&fr);
if (IS_INT_INSIDE(fr.distance, 35, 55+1))
@@ -1157,7 +1157,7 @@ static void AiWantMediumRoadIndustryRoute(Player *p)
i = 60;
for(;;) {
-
+
// look for one from the subsidy list
AiFindSubsidyIndustryRoute(&fr);
if (IS_INT_INSIDE(fr.distance, 15, 40+1))
@@ -1218,7 +1218,7 @@ static void AiWantLongRoadPassengerRoute(Player *p)
i = 60;
for(;;) {
-
+
// look for one from the subsidy list
AiFindSubsidyPassengerRoute(&fr);
if (IS_INT_INSIDE(fr.distance, 55, 180+1))
@@ -1356,7 +1356,7 @@ static void AiWantPassengerAircraftRoute(Player *p)
i = 60;
for(;;) {
-
+
// look for one from the subsidy list
AiFindSubsidyPassengerRoute(&fr);
if (IS_INT_INSIDE(fr.distance,0,95+1))
@@ -1401,7 +1401,7 @@ static void AiWantPassengerAircraftRoute(Player *p)
p->ai.order_list_blocks[0] = 0;
p->ai.order_list_blocks[1] = 1;
p->ai.order_list_blocks[2] = 255;
-
+
p->ai.state = AIS_AIRPORT_STUFF;
p->ai.timeout_counter = 0;
}
@@ -1498,11 +1498,11 @@ static void AiStateWantNewRoute(Player *p)
i = 200;
for(;;) {
r = (uint16)Random();
-
+
if (_patches.ai_disable_veh_train && _patches.ai_disable_veh_roadveh &&
_patches.ai_disable_veh_aircraft && _patches.ai_disable_veh_ship)
return;
-
+
if (r < 0x7626) {
if (_patches.ai_disable_veh_train) continue;
AiWantTrainRoute(p);
@@ -1516,7 +1516,7 @@ static void AiStateWantNewRoute(Player *p)
if (_patches.ai_disable_veh_ship) continue;
AiWantShipRoute(p);
}
-
+
// got a route?
if (p->ai.state != AIS_WANT_NEW_ROUTE)
break;
@@ -1598,7 +1598,7 @@ clear_town_stuff:;
j = p->attr;
k = 0;
-
+
// Build the rail
for(i=0; i!=6; i++,j>>=1) {
if (j&1) {
@@ -1608,7 +1608,7 @@ clear_town_stuff:;
total_cost += r;
}
}
-
+
/* signals too? */
if (j&3) {
// Can't build signals on a road.
@@ -1643,7 +1643,7 @@ clear_town_stuff:;
// Unk
break;
}
-
+
p++;
}
@@ -1663,7 +1663,7 @@ static int AiBuildDefaultRailTrack(TileIndex tile, byte p0, byte p1, byte p2, by
const AiDefaultRailBlock *p;
for(i=0; (p = _default_rail_track_data[i]) != NULL; i++) {
- if (p->p0 == p0 && p->p1 == p1 && p->p2 == p2 && p->p3 == p3 &&
+ if (p->p0 == p0 && p->p1 == p1 && p->p2 == p2 && p->p3 == p3 &&
(p->dir == 0xFF || p->dir == dir || ((p->dir-1)&3) == dir)) {
*cost = AiDoBuildDefaultRailTrack(tile, p->data, DC_NO_TOWN_RATING);
if (*cost != CMD_ERROR && AiCheckTrackResources(tile, p->data, cargo))
@@ -1723,7 +1723,7 @@ static void AiDoTerraformLand(TileIndex tile, int dir, int unk, int mode)
} while (--unk >= 0);
slope = GetTileSlope(tile, &h);
-
+
if (slope != 0) {
if (mode > 0 || (mode == 0 && !(r&0xC))) {
// Terraform up
@@ -1731,9 +1731,9 @@ static void AiDoTerraformLand(TileIndex tile, int dir, int unk, int mode)
DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND);
} else if (h != 0) {
// Terraform down
- DoCommandByTile(tile, _terraform_down_flags[slope-1], 0,
+ DoCommandByTile(tile, _terraform_down_flags[slope-1], 0,
DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND);
- }
+ }
}
_current_player = old_player;
@@ -1850,7 +1850,7 @@ static bool AiDoFollowTrack(Player *p)
arpfd.tile2 = p->ai.cur_tile_a;
arpfd.flag = false;
arpfd.count = 0;
- FollowTrack(p->ai.cur_tile_a + _tileoffs_by_dir[p->ai.cur_dir_a], 0x2000 | TRANSPORT_RAIL, p->ai.cur_dir_a^2,
+ FollowTrack(p->ai.cur_tile_a + _tileoffs_by_dir[p->ai.cur_dir_a], 0x2000 | TRANSPORT_RAIL, p->ai.cur_dir_a^2,
(TPFEnumProc*)AiEnumFollowTrack, NULL, &arpfd);
return arpfd.count > 8;
}
@@ -1888,7 +1888,7 @@ static bool AiIsTileBanned(Player *p, TileIndex tile, byte val) {
int i;
for(i=0; i!=p->ai.banned_tile_count; i++)
- if (p->ai.banned_tiles[i] == tile &&
+ if (p->ai.banned_tiles[i] == tile &&
p->ai.banned_val[i] == val)
return true;
return false;
@@ -1924,7 +1924,7 @@ static bool AiCheckRailPathBetter(AiRailFinder *arf, const byte *p)
arf->best_ptr = p;
arf->best_tile = arf->cur_best_tile;
better = true;
- }
+ }
} else if (arf->recursive_mode > 1) {
// Mode is 2.
if (arf->best_dist != 0 || arf->cur_best_depth < arf->best_depth) {
@@ -1948,7 +1948,7 @@ static void FORCEINLINE AiCheckBuildRailBridgeHere(AiRailFinder *arf, TileIndex
bool flag;
int dir2 = p[0] & 3;
-
+
FindLandscapeHeightByTile(&arf->ti, tile);
if (arf->ti.tileh == _dir_table_1[dir2] || (arf->ti.tileh==0 && arf->ti.z!=0)) {
@@ -1969,11 +1969,11 @@ static void FORCEINLINE AiCheckBuildRailBridgeHere(AiRailFinder *arf, TileIndex
}
// Is building a (rail)bridge possible at this place (type doesn't matter)?
- if (DoCommandByTile(tile_new, tile, arf->player->ai.railtype_to_use<<8,
+ if (DoCommandByTile(tile_new, tile, arf->player->ai.railtype_to_use<<8,
DC_AUTO, CMD_BUILD_BRIDGE) == CMD_ERROR)
return;
AiBuildRailRecursive(arf, tile_new, dir2);
-
+
// At the bottom depth, check if the new path is better than the old one.
if (arf->depth == 1) {
if (AiCheckRailPathBetter(arf, p))
@@ -1986,7 +1986,7 @@ static void FORCEINLINE AiCheckBuildRailTunnelHere(AiRailFinder *arf, TileIndex
{
FindLandscapeHeightByTile(&arf->ti, tile);
- if (arf->ti.tileh == _dir_table_2[p[0]&3] && arf->ti.z!=0) {
+ if (arf->ti.tileh == _dir_table_2[p[0]&3] && arf->ti.z!=0) {
int32 cost = DoCommandByTile(tile, arf->player->ai.railtype_to_use, 0, DC_AUTO, CMD_BUILD_TUNNEL);
if (cost != CMD_ERROR && cost <= (arf->player->player_money>>4)) {
@@ -2004,7 +2004,7 @@ static void AiBuildRailRecursive(AiRailFinder *arf, TileIndex tile, int dir)
const byte *p;
tile = TILE_MASK(tile + _tileoffs_by_dir[dir]);
-
+
// Reached destination?
if (tile == arf->final_tile) {
if (arf->final_dir != (dir^2)) {
@@ -2067,7 +2067,7 @@ static void AiBuildRailRecursive(AiRailFinder *arf, TileIndex tile, int dir)
}
-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)
{
@@ -2078,7 +2078,7 @@ static void AiBuildRailConstruct(Player *p)
if (AiDoFollowTrack(p)) {
p->ai.state_counter = (Random()&0xE)+6; // Destruct this amount of blocks
p->ai.state_mode = 1; // Start destruct
-
+
// Ban this tile and don't reach it for a while.
AiBanTile(p, p->ai.cur_tile_a, FindFirstBit(GetRailTrackStatus(p->ai.cur_tile_a)));
return;
@@ -2097,7 +2097,7 @@ static void AiBuildRailConstruct(Player *p)
arf.best_depth = 0xff;
arf.cur_best_tile = 0;
arf.best_tile = 0;
- AiBuildRailRecursive(&arf, p->ai.cur_tile_a, p->ai.cur_dir_a);
+ AiBuildRailRecursive(&arf, p->ai.cur_tile_a, p->ai.cur_dir_a);
// Reached destination?
if (arf.recursive_mode == 2 && arf.cur_best_depth == 0) {
@@ -2114,19 +2114,19 @@ static void AiBuildRailConstruct(Player *p)
if (++p->ai.state_counter == 21) {
p->ai.state_counter = 40;
p->ai.state_mode = 1;
-
+
// Ban this tile
AiBanTile(p, p->ai.cur_tile_a, FindFirstBit(GetRailTrackStatus(p->ai.cur_tile_a)));
}
return;
}
-
+
p->ai.cur_tile_a += _tileoffs_by_dir[p->ai.cur_dir_a];
if (arf.best_ptr[0]&0x80) {
int i;
int32 bridge_len = GetBridgeLength(arf.bridge_end_tile, p->ai.cur_tile_a);
-
+
/* Figure out what (rail)bridge type to build
start with best bridge, then go down to worse and worse bridges
unnecessary to check for worse bridge (i=0), since AI will always build that.
@@ -2153,7 +2153,7 @@ static void AiBuildRailConstruct(Player *p)
} else {
// rail
p->ai.cur_dir_a = arf.best_ptr[1];
- DoCommandByTile(p->ai.cur_tile_a, p->ai.railtype_to_use, arf.best_ptr[0],
+ DoCommandByTile(p->ai.cur_tile_a, p->ai.railtype_to_use, arf.best_ptr[0],
DC_EXEC | DC_AUTO | DC_NO_WATER | DC_NO_RAIL_OVERLAP, CMD_BUILD_SINGLE_RAIL);
p->ai.state_counter = 0;
}
@@ -2183,7 +2183,7 @@ static bool AiRemoveTileAndGoForward(Player *p)
}
if (!(_map5[tile] & 0x40)) {
-
+
// Check if the bridge points in the right direction.
// This is not really needed the first place AiRemoveTileAndGoForward is called.
if ((_map5[tile]&1) != (p->ai.cur_dir_a&1))
@@ -2194,7 +2194,7 @@ static bool AiRemoveTileAndGoForward(Player *p)
do {
tile = TILE_MASK(tile - offs);
} while (_map5[tile] & 0x40);
-
+
tilenew = TILE_MASK(tile - offs);
// And clear the bridge.
if (DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR) == CMD_ERROR)
@@ -2217,7 +2217,7 @@ static bool AiRemoveTileAndGoForward(Player *p)
(_map5[tile]&0xC0) == 0x40) {
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_REMOVE_SIGNALS);
}
-
+
// And also remove the rail.
if (DoCommandByTile(tile, 0, bit, DC_EXEC, CMD_REMOVE_SINGLE_RAIL) == CMD_ERROR)
return false;
@@ -2226,7 +2226,7 @@ static bool AiRemoveTileAndGoForward(Player *p)
ptr = _ai_table_15[p->ai.cur_dir_a^2];
while (ptr[0] != bit) ptr+=2;
p->ai.cur_dir_a = ptr[1] ^ 2;
-
+
// And then also switch tile.
p->ai.cur_tile_a = TILE_MASK(p->ai.cur_tile_a - _tileoffs_by_dir[p->ai.cur_dir_a]);
@@ -2246,7 +2246,7 @@ static void AiBuildRailDestruct(Player *p)
if (p->ai.cur_tile_a == p->ai.start_tile_a)
return;
- AiRemoveTileAndGoForward(p);
+ AiRemoveTileAndGoForward(p);
}
@@ -2256,9 +2256,9 @@ static void AiBuildRail(Player *p)
if (p->ai.state_mode < 1) {
// Construct mode, build new rail.
- AiBuildRailConstruct(p);
+ AiBuildRailConstruct(p);
} else if (p->ai.state_mode == 1) {
-
+
// Destruct mode, destroy the rail currently built.
AiBuildRailDestruct(p);
} else if (p->ai.state_mode == 2) {
@@ -2291,7 +2291,7 @@ static void AiStateBuildRail(Player *p)
// Currently building a rail between two points?
if (p->ai.state_mode != 255) {
AiBuildRail(p);
-
+
// Alternate between edges
swap_tile(&p->ai.start_tile_a, &p->ai.start_tile_b);
swap_tile(&p->ai.cur_tile_a, &p->ai.cur_tile_b);
@@ -2425,7 +2425,7 @@ handle_nocash:
bool is_pass = (p->ai.cargo_type == CT_PASSENGERS ||
p->ai.cargo_type == CT_MAIL ||
(_opt.landscape==LT_NORMAL && p->ai.cargo_type == CT_VALUABLES));
-
+
if (!is_pass && i == 1) flags |= OF_UNLOAD;
if (p->ai.num_want_fullload != 0 && (is_pass || i == 0)) flags |= OF_FULL_LOAD;
@@ -2453,7 +2453,7 @@ static void AiStateDeleteRailBlocks(Player *p)
AiBuildRec *aib;
const AiDefaultBlockData *b;
- num = p->ai.num_build_rec;
+ num = p->ai.num_build_rec;
aib = &p->ai.src;
do {
if (aib->cur_building_rule != 255) {
@@ -2521,13 +2521,13 @@ static int32 AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData
uint c = TILE_MASK(tile+ p->tileoffs);
_cleared_town = NULL;
-
+
if (p->mode == 2) {
if (IS_TILETYPE(c, MP_STREET) &&
(_map5[c]&0xF0)==0 &&
(_map5[c]&p->attr)!=0) {
roadflag |= 2;
-
+
// all bits are already built?
if ((_map5[c]&p->attr)==p->attr)
continue;
@@ -2575,7 +2575,7 @@ clear_town_stuff:;
r = DoCommandByTile(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
if (r == CMD_ERROR) return CMD_ERROR;
}
-
+
}
}
@@ -2595,9 +2595,9 @@ static bool AiCheckBlockDistances(Player *p, TileIndex tile)
{
AiBuildRec *aib;
int num;
-
+
num = p->ai.num_build_rec;
- aib = &p->ai.src;
+ aib = &p->ai.src;
do {
if (aib->cur_building_rule != 255) {
@@ -2720,7 +2720,7 @@ static bool AiCheckRoadPathBetter(AiRoadFinder *arf, const byte *p)
if (arf->recursive_mode < 1) {
// Mode is 0. This means destination has not been found yet.
// If the found path is shorter than the current one, remember it.
- if (arf->cur_best_dist < arf->best_dist ||
+ if (arf->cur_best_dist < arf->best_dist ||
(arf->cur_best_dist == arf->best_dist && arf->cur_best_depth < arf->best_depth)) {
arf->best_depth = arf->cur_best_depth;
arf->best_dist = arf->cur_best_dist;
@@ -2728,7 +2728,7 @@ static bool AiCheckRoadPathBetter(AiRoadFinder *arf, const byte *p)
arf->best_ptr = p;
arf->best_tile = arf->cur_best_tile;
better = true;
- }
+ }
} else if (arf->recursive_mode > 1) {
// Mode is 2.
if (arf->best_dist != 0 || arf->cur_best_depth < arf->best_depth) {
@@ -2825,14 +2825,14 @@ static void FORCEINLINE AiCheckBuildRoadBridgeHere(AiRoadFinder *arf, TileIndex
bool flag;
int dir2 = p[0] & 3;
-
+
FindLandscapeHeightByTile(&arf->ti, tile);
if (arf->ti.tileh == _dir_table_1[dir2] || (arf->ti.tileh==0 && arf->ti.z!=0)) {
tile_new = tile;
// Allow bridges directly over bottom tiles
flag = arf->ti.z == 0;
for(;;) {
- if (tile_new < -_tileoffs_by_dir[dir2]) return; // Wraping around map, no bridge possible!
+ if (tile_new < -_tileoffs_by_dir[dir2]) return; // Wraping around map, no bridge possible!
tile_new = TILE_MASK(tile_new + _tileoffs_by_dir[dir2]);
FindLandscapeHeightByTile(&arf->ti, tile_new);
if (arf->ti.tileh != 0 || arf->ti.type == MP_CLEAR || arf->ti.type == MP_TREES) {
@@ -2850,7 +2850,7 @@ static void FORCEINLINE AiCheckBuildRoadBridgeHere(AiRoadFinder *arf, TileIndex
if (DoCommandByTile(tile_new, tile, 0x8000, DC_AUTO, CMD_BUILD_BRIDGE) == CMD_ERROR)
return;
AiBuildRoadRecursive(arf, tile_new, dir2);
-
+
// At the bottom depth, check if the new path is better than the old one.
if (arf->depth == 1) {
if (AiCheckRoadPathBetter(arf, p))
@@ -2863,7 +2863,7 @@ static void FORCEINLINE AiCheckBuildRoadTunnelHere(AiRoadFinder *arf, TileIndex
{
FindLandscapeHeightByTile(&arf->ti, tile);
- if (arf->ti.tileh == _dir_table_2[p[0]&3] && arf->ti.z!=0) {
+ if (arf->ti.tileh == _dir_table_2[p[0]&3] && arf->ti.z!=0) {
int32 cost = DoCommandByTile(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
if (cost != CMD_ERROR && cost <= (arf->player->player_money>>4)) {
@@ -2882,13 +2882,13 @@ static void AiBuildRoadRecursive(AiRoadFinder *arf, TileIndex tile, int dir)
const byte *p;
tile = TILE_MASK(tile + _tileoffs_by_dir[dir]);
-
+
// Reached destination?
if (tile == arf->final_tile) {
if ((arf->final_dir^2) == dir) {
arf->recursive_mode = 2;
arf->cur_best_depth = arf->depth;
- }
+ }
return;
}
@@ -2965,7 +2965,7 @@ static void AiBuildRoadConstruct(Player *p)
arf.best_depth = 0xff;
arf.cur_best_tile = 0;
arf.best_tile = 0;
- AiBuildRoadRecursive(&arf, p->ai.cur_tile_a, p->ai.cur_dir_a);
+ AiBuildRoadRecursive(&arf, p->ai.cur_tile_a, p->ai.cur_dir_a);
// Reached destination?
if (arf.recursive_mode == 2 && arf.cur_best_depth == 0) {
@@ -3003,7 +3003,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 (cost != CMD_ERROR && cost < (p->player_money >> 5))
@@ -3021,7 +3021,7 @@ do_some_terraform:
p->ai.cur_tile_a = _build_tunnel_endtile;
p->ai.state_counter = 0;
} else {
-
+
// road
if (!AiBuildRoadHelper(tile, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, arf.best_ptr[0]))
goto do_some_terraform;
@@ -3044,7 +3044,7 @@ static void AiBuildRoad(Player *p)
if (p->ai.state_mode < 1) {
// Construct mode, build new road.
- AiBuildRoadConstruct(p);
+ AiBuildRoadConstruct(p);
} else if (p->ai.state_mode == 1) {
// Destruct mode, not implemented for roads.
p->ai.state_mode = 2;
@@ -3088,7 +3088,7 @@ static void AiStateBuildRoad(Player *p)
// Currently building a road between two points?
if (p->ai.state_mode != 255) {
AiBuildRoad(p);
-
+
// Alternate between edges
swap_tile(&p->ai.start_tile_a, &p->ai.start_tile_b);
swap_tile(&p->ai.cur_tile_a, &p->ai.cur_tile_b);
@@ -3149,7 +3149,7 @@ static void AiStateBuildRoadVehicles(Player *p)
uint tile,loco_id;
int veh, i;
int32 cost;
-
+
ptr = _road_default_block_data[p->ai.src.cur_building_rule]->data;
for(;ptr->mode != 0;ptr++) {}
tile = TILE_ADD(p->ai.src.use_tile, ptr->tileoffs);
@@ -3197,7 +3197,7 @@ static void AiStateDeleteRoadBlocks(Player *p)
AiBuildRec *aib;
const AiDefaultBlockData *b;
- num = p->ai.num_build_rec;
+ num = p->ai.num_build_rec;
aib = &p->ai.src;
do {
if (aib->cur_building_rule != 255) {
@@ -3379,7 +3379,7 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
// do the following 8 times
i = 8;
do {
- // check if we can build the default
+ // check if we can build the default
aib = &p->ai.src;
j = p->ai.num_build_rec;
do {
@@ -3399,7 +3399,7 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
!IS_TILETYPE(aib->use_tile, MP_RAILWAY) &&
!IS_TILETYPE(aib->use_tile, MP_STATION)
) {
-
+
_map_type_and_height[aib->use_tile] = 0xa1;
_map5[aib->use_tile] = 0x80;
MarkTileDirtyByTile(aib->use_tile);
@@ -3460,7 +3460,7 @@ static void AiStateBuildAircraftVehicles(Player *p)
int32 cost;
int i;
uint loco_id;
-
+
ptr = _airport_default_block_data[p->ai.src.cur_building_rule];
for(;ptr->mode!=0;ptr++) {}
@@ -3523,7 +3523,7 @@ static void AiStateSellVeh(Player *p)
if (v->owner == _current_player) {
if (v->type == VEH_Train) {
-
+
if (!IsTrainDepotTile(v->tile) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) {
if ((v->next_order & OT_MASK) != OT_GOTO_DEPOT)
DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_TRAIN_GOTO_DEPOT);
@@ -3532,7 +3532,7 @@ static void AiStateSellVeh(Player *p)
// Sell whole train
DoCommandByTile(v->tile, v->index, 1, DC_EXEC, CMD_SELL_RAIL_WAGON);
-
+
} else if (v->type == VEH_Road) {
if (!IsRoadDepotTile(v->tile) || v->u.road.state != 254 || !(v->vehstatus&VS_STOPPED)) {
if ((v->next_order & OT_MASK) != OT_GOTO_DEPOT)
@@ -3613,7 +3613,7 @@ static void AiRemovePlayerRailOrRoad(Player *p, uint tile)
if ((m5&~0x3) != 0xC0) {
is_rail_crossing:;
m5 = GetRailTrackStatus(tile);
-
+
if (m5 == 0xC || m5 == 0x30)
return;
@@ -3662,7 +3662,7 @@ pos_3:
m5 &= 3;
if (GetRailTrackStatus(tile + _tileoffs_by_dir[m5]) & _depot_bits[m5])
return;
-
+
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
}
} else if (IS_TILETYPE(tile, MP_STREET)) {
@@ -3707,7 +3707,7 @@ pos_3:
if (_map_owner[tile] != _current_player || (_map5[tile] & 0xC6) != 0x80)
return;
-
+
m5 = 0;
b = _map5[tile] & 0x21;
@@ -3721,7 +3721,7 @@ pos_3:
static void AiStateRemoveTrack(Player *p)
{
int num = 1000;
-
+
do {
uint tile = ++p->ai.state_counter;
@@ -3775,7 +3775,7 @@ static AiStateAction * const _ai_actions[] = {
AiStateSellVeh,
AiStateRemoveStation,
AiStateRemoveTrack,
-
+
AiStateRemoveSingleRailTile
};
@@ -3875,10 +3875,10 @@ static void AiBuildCompanyHQ(Player *p)
}
-void AiDoGameLoop(Player *p)
+void AiDoGameLoop(Player *p)
{
_cur_ai_player = p;
-
+
if (p->bankrupt_asked != 0) {
AiHandleTakeover(p);
return;
@@ -3913,7 +3913,7 @@ void AiDoGameLoop(Player *p)
return;
}
}
- }
+ }
#if 0
{
static byte old_state = 99;
diff --git a/ai_build.c b/ai_build.c
index 2614dc9d1..f6c4f1d54 100644
--- a/ai_build.c
+++ b/ai_build.c
@@ -85,8 +85,8 @@ int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte fla
if (part < 1) part = 1;
// When we are done, stop it
if (part >= PathFinderInfo->route_length - 1) { PathFinderInfo->position = -2; return 0; }
-
-
+
+
if (PathFinderInfo->rail_or_road) {
// Tunnel code
if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) {
@@ -198,7 +198,7 @@ int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte fla
if (!EnsureNoVehicle(route[part]) && flag == DC_EXEC) part--;
PathFinderInfo->position = part;
}
-
+
return cost;
}
@@ -232,7 +232,7 @@ int AiNew_PickVehicle(Player *p) {
int AiNew_Build_Vehicle(Player *p, uint tile, byte flag) {
int i = AiNew_PickVehicle(p);
if (i == -1) return CMD_ERROR;
-
+
if (p->ainew.tbt == AI_TRAIN) {
return CMD_ERROR;
} else {
diff --git a/ai_pathfinder.c b/ai_pathfinder.c
index 03439359f..f51f34b83 100644
--- a/ai_pathfinder.c
+++ b/ai_pathfinder.c
@@ -38,7 +38,7 @@ int32 AyStar_AiPathFinder_EndNodeCheck(AyStar *aystar, OpenListNode *current) {
if (IS_TILETYPE(current->path.node.tile, MP_CLEAR) || IS_TILETYPE(current->path.node.tile, MP_TREES))
if (current->path.parent == NULL || TestCanBuildStationHere(current->path.node.tile,AiNew_GetDirection(current->path.parent->node.tile, current->path.node.tile)))
return AYSTAR_FOUND_END_NODE;
-
+
return AYSTAR_DONE;
}
@@ -103,7 +103,7 @@ AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFin
void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo) {
PathNode start_node;
uint x,y;
-
+
aystar->clear(aystar);
// Set the user_data to the PathFinderInfo
@@ -149,7 +149,7 @@ static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *curre
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
int i = 0;
PathNode *parent = &current->path;
-
+
do {
PathFinderInfo->route_extra[i] = parent->node.user_data[0];
PathFinderInfo->route[i++] = parent->node.tile;
@@ -169,16 +169,16 @@ static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *curre
static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *current) {
int i, r, dir;
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
-
+
aystar->num_neighbours = 0;
-
+
// Go through all surrounding tiles and check if they are within the limits
for (i=0;i<4;i++) {
if (GET_TILE_X(_tiles_around[i] + current->path.node.tile) > 1 && GET_TILE_X(_tiles_around[i] + current->path.node.tile) < TILE_X_MAX - 1 &&
GET_TILE_Y(_tiles_around[i] + current->path.node.tile) > 1 && GET_TILE_Y(_tiles_around[i] + current->path.node.tile) < TILE_Y_MAX - 1) {
// We also directly test if the current tile can connect to this tile..
// We do this simply by just building the tile!
-
+
// If the next step is a bridge, we have to enter it the right way
if (!PathFinderInfo->rail_or_road && AI_PATHFINDER_IS_ROAD(current->path.node.tile + _tiles_around[i])) {
if (IS_TILETYPE(current->path.node.tile + _tiles_around[i], MP_TUNNELBRIDGE)) {
@@ -198,7 +198,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
if ((_map5[current->path.node.tile] & 1) != (i & 1)) continue;
}
}
-
+
if ((AI_PATHFINDER_FLAG_BRIDGE & current->path.node.user_data[0]) != 0 ||
(AI_PATHFINDER_FLAG_TUNNEL & current->path.node.user_data[0]) != 0) {
// We are a bridge/tunnel, how cool!!
@@ -206,7 +206,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
if (i != (current->path.node.user_data[0] >> 8)) continue;
}
dir = 0;
-
+
// First, check if we have a parent
if (current->path.parent == NULL && current->path.node.user_data[0] == 0) {
// If not, this means we are at the starting station
@@ -254,16 +254,16 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
if (r == CMD_ERROR) continue;
}
}
-
+
}
-
+
// The tile can be connected
aystar->neighbours[aystar->num_neighbours].tile = _tiles_around[i] + current->path.node.tile;
aystar->neighbours[aystar->num_neighbours].user_data[0] = 0;
aystar->neighbours[aystar->num_neighbours++].direction = 0;
}
}
-
+
// Next step, check for bridges and tunnels
if (current->path.parent != NULL && current->path.node.user_data[0] == 0) {
@@ -273,9 +273,9 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
// It means we can only walk with the track, so the bridge has to be in the same direction
TileIndex tile = current->path.node.tile;
TileIndex new_tile = tile;
-
+
FindLandscapeHeightByTile(&ti, tile);
-
+
// Bridges can only be build on land that is not flat
// And if there is a road or rail blocking
if (ti.tileh != 0 ||
@@ -284,10 +284,10 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
for (;;) {
new_tile += _tiles_around[dir];
-
+
// Precheck, is the length allowed?
if (!CheckBridge_Stuff(0,GetBridgeLength(tile, new_tile))) break;
-
+
// Check if we hit the station-tile.. we don't like that!
if (TILES_BETWEEN(new_tile,PathFinderInfo->end_tile_tl,PathFinderInfo->end_tile_br)) break;
@@ -302,7 +302,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
if (aystar->num_neighbours == 11) break;
}
}
-
+
// Next, check for tunnels!
// Tunnels can only be build with tileh of 3, 6, 9 or 12, depending on the direction
// For now, we check both sides for this tile.. terraforming gives fuzzy result
@@ -334,11 +334,11 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
int r, res = 0;
TileInfo ti, parent_ti;
-
+
// Gather some information about the tile..
FindLandscapeHeightByTile(&ti, current->tile);
FindLandscapeHeightByTile(&parent_ti, parent->path.node.tile);
-
+
// Check if we hit the end-tile
if (TILES_BETWEEN(current->tile,PathFinderInfo->end_tile_tl,PathFinderInfo->end_tile_br)) {
// We are at the end-tile, check if we had a direction or something...
@@ -348,7 +348,7 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
// If it was valid, drop out.. we don't build on the endtile
return 0;
}
-
+
// Give everything a small penalty
res += AI_PATHFINDER_PENALTY;
@@ -359,7 +359,7 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
res -= AI_PATHFINDER_ROAD_ALREADY_EXISTS_BONUS;
}
}
-
+
// We should give a penalty when the tile is going up or down.. this is one way to do so!
// Too bad we have to count it from the parent.. but that is not so bad
if (parent_ti.tileh != 0 && parent->path.parent != NULL) {
@@ -380,7 +380,7 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
}
}
}
-
+
// Are we part of a tunnel?
if ((AI_PATHFINDER_FLAG_TUNNEL & current->user_data[0]) != 0) {
// Tunnels are very expensive when build on long routes..
@@ -409,7 +409,7 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
if (ti.tileh == 0)
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
}
-
+
// To prevent the AI from taking the fastest way in tiles, but not the fastest way
// in speed, we have to give a good penalty to direction changing
// This way, we get almost the fastest way in tiles, and a very good speed on the track
@@ -448,7 +448,7 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
}
}
}
-
+
// Res should never be below zero.. if so, make it zero!
if (res < 0) { res = 0; }
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index a9530636b..c0b9a73a8 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -275,8 +275,8 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// On hold for NewAI
v->u.air.pos = (!_patches.ainew_active && _is_ai_player) ? 0:MAX_ELEMENTS;
- /* When we click on hangar we know the tile (it is in var 'tile')it is on. By that we know
- its position in the array of depots the airport has.....we can search
+ /* When we click on hangar we know the tile (it is in var 'tile')it is on. By that we know
+ its position in the array of depots the airport has.....we can search
->layout for #th position of depot. Since layout must start with depots, it is simple
*/
{
@@ -542,7 +542,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
if (_patches.gotodepot && ScheduleHasDepotOrders(v->schedule_ptr))
return;
-
+
st = DEREF_STATION(v->next_order_param);
// only goto depot if the target airport has terminals (eg. it is airport)
if (st->xy != 0 && st->airport_tile != 0 && GetAirport(st->airport_type)->nofterminals != 0) {
@@ -621,7 +621,7 @@ static void HelicopterTickHandler(Vehicle *v)
if (u->vehstatus & VS_HIDDEN)
return;
- // if true, helicopter rotors do not rotate. This should only be the case if a helicopter is
+ // if true, helicopter rotors do not rotate. This should only be the case if a helicopter is
// loading/unloading at a terminal or stopped
if ((v->next_order&OT_MASK) == OT_LOADING || (v->vehstatus&VS_STOPPED)) {
if (u->cur_speed != 0) {
@@ -735,7 +735,7 @@ static bool UpdateAircraftSpeed(Vehicle *v)
v->subspeed = (t=v->subspeed) + (byte)spd;
spd = min( v->cur_speed + (spd >> 8) + (v->subspeed < t), v->max_speed);
-
+
// adjust speed for broken vehicles
if(v->vehstatus&VS_AIRCRAFT_BROKEN) spd = min(spd, 27);
@@ -875,7 +875,7 @@ static bool Aircraft_5(Vehicle *v)
// Change direction smoothly to final direction.
dirdiff = amd->direction - v->direction;
- // if distance is 0, and plane points in right direction, no point in calling
+ // if distance is 0, and plane points in right direction, no point in calling
// UpdateAircraftSpeed(). So do it only afterwards
if (dirdiff == 0) {
v->cur_speed = 0;
@@ -1061,7 +1061,7 @@ static void ProcessAircraftOrder(Vehicle *v)
if ((v->next_order & (OT_MASK|OF_UNLOAD)) != (OT_GOTO_DEPOT|OF_UNLOAD))
return;
}
-
+
if ((v->next_order & (OT_MASK|OF_UNLOAD|OF_FULL_LOAD)) == (OT_GOTO_DEPOT|OF_UNLOAD|OF_FULL_LOAD) &&
SERVICE_INTERVAL) {
v->cur_order_index++;
@@ -1217,7 +1217,7 @@ static void AircraftEnterHangar(Vehicle *v)
byte old_order;
ServiceAircraft(v);
-
+
MaybeRenewVehicle(v, EstimateAircraftCost(v->engine_type));
if ((v->next_order & OT_MASK) == OT_GOTO_DEPOT) {
@@ -1227,7 +1227,7 @@ static void AircraftEnterHangar(Vehicle *v)
v->next_order = OT_NOTHING;
if (old_order & OF_UNLOAD) { v->cur_order_index++; }
-
+
else if (old_order & OF_FULL_LOAD) { // force depot visit
v->vehstatus |= VS_STOPPED;
@@ -1692,7 +1692,7 @@ static bool FreeTerminal(Vehicle *v, byte i, byte last_terminal)
return false;
}
-static bool AirportFindFreeTerminal(Vehicle *v, const AirportFTAClass *Airport)
+static bool AirportFindFreeTerminal(Vehicle *v, const AirportFTAClass *Airport)
{
byte nofterminalspergroup, i;
AirportFTA *temp;
@@ -1703,9 +1703,9 @@ static bool AirportFindFreeTerminal(Vehicle *v, const AirportFTAClass *Airport)
Heading 255 denotes a group. We see 2 groups here:
1. group 0 -- TERM_GROUP1_block (check block)
2. group 1 -- TERM_GROUP2_ENTER_block (check block)
- First in line is checked first, group 0. If the block (TERM_GROUP1_block) is free, it
- looks at the corresponding terminals of that group. If no free ones are found, other
- possible groups are checked (in this case group 1, since that is after group 0). If that
+ First in line is checked first, group 0. If the block (TERM_GROUP1_block) is free, it
+ looks at the corresponding terminals of that group. If no free ones are found, other
+ possible groups are checked (in this case group 1, since that is after group 0). If that
fails, then attempt fails and plane waits
*/
if (Airport->nofterminalgroups > 1) {
@@ -1731,7 +1731,7 @@ static bool AirportFindFreeTerminal(Vehicle *v, const AirportFTAClass *Airport)
return FreeTerminal(v, 0, Airport->nofterminals);
}
-static bool AirportFindFreeHelipad(Vehicle *v, const AirportFTAClass *Airport)
+static bool AirportFindFreeHelipad(Vehicle *v, const AirportFTAClass *Airport)
{
Station *st;
byte nofhelipadspergroup, i;
@@ -1847,7 +1847,7 @@ void UpdateOldAircraft()
AircraftNextAirportPos_and_Order(v_oldstyle); // move it to the entry point of the airport
GetNewVehiclePos(v_oldstyle, &gp); // get the position of the plane (to be used for setting)
v_oldstyle->tile = 0; // aircraft in air is tile=0
-
+
// correct speed of helicopter-rotors
if (v_oldstyle->subtype == 0) {v_oldstyle->next->next->cur_speed = 32;}
@@ -1857,7 +1857,7 @@ void UpdateOldAircraft()
}
}
-void UpdateAirplanesOnNewStation(Station *st)
+void UpdateAirplanesOnNewStation(Station *st)
{
GetNewVehiclePosResult gp;
Vehicle *v;
diff --git a/aircraft_gui.c b/aircraft_gui.c
index df24bdd7b..ce438ab5a 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -891,7 +891,7 @@ static void MakeSortedAircraftList(byte owner)
// aircraft are stored as a cummulative index, eg 25, 41, 43. This means
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2
for (i = &_num_aircraft_sort[1]; i != endof(_num_aircraft_sort); i++) {*i += *(i-1);}
-
+
// sort by owner, then only subsort the requested owner-vehicles
qsort(_aircraft_sort, n, sizeof(_aircraft_sort[0]), GeneralOwnerSorter);
@@ -936,7 +936,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 aircraft
i = (window_number == 0) ? 0 : _num_aircraft_sort[window_number-1];
SetVScrollCount(w, _num_aircraft_sort[window_number] - i);
-
+
/* draw the widgets */
{
Player *p = DEREF_PLAYER(window_number);
@@ -980,7 +980,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
SET_DPARAM32(0, v->profit_this_year);
SET_DPARAM32(1, v->profit_last_year);
DrawString(x+19, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
-
+
if (v->string_id != STR_SV_AIRCRAFT_NAME) {
SET_DPARAM16(0, v->string_id);
DrawString(x+19, y, STR_01AB, 0);
@@ -1007,7 +1007,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
return;
case 6: { /* Matrix to show vehicles */
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG;
-
+
if (id_v >= w->vscroll.cap) { return;} // click out of bounds
id_v += w->vscroll.pos;
diff --git a/airport_gui.c b/airport_gui.c
index 6f5b1abe9..94fc4eda4 100644
--- a/airport_gui.c
+++ b/airport_gui.c
@@ -77,12 +77,12 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
if (e->click.widget-2 >= 0)
- _build_air_button_proc[e->click.widget - 2](w);
+ _build_air_button_proc[e->click.widget - 2](w);
break;
case WE_PLACE_OBJ:
_place_proc(e->place.tile);
- break;
+ break;
case WE_PLACE_DRAG: {
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata);
@@ -160,7 +160,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
// strings such as 'Size' and 'Coverage Area'
DrawStringCentered(74, 16, STR_305B_SIZE, 0);
DrawStringCentered(74, 78, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0);
- DrawStationCoverageAreaText(2, 104, (uint)-1);
+ DrawStationCoverageAreaText(2, 104, (uint)-1);
break;
}
diff --git a/aystar.c b/aystar.c
index a38dfc7a8..292bcdbe1 100644
--- a/aystar.c
+++ b/aystar.c
@@ -5,7 +5,7 @@
* For more information about AyStar (A* Algorithm), you can look at
* http://en.wikipedia.org/wiki/A-star_search_algorithm
*/
-
+
/*
* Friendly reminder:
* Call (AyStar).free() when you are done with Aystar. It reserves a lot of memory
@@ -46,7 +46,7 @@ OpenListNode *AyStarMain_OpenList_Pop(AyStar *aystar) {
OpenListNode* res = (OpenListNode*)aystar->OpenListQueue.pop(&aystar->OpenListQueue);
if (res != NULL)
Hash_Delete(&aystar->OpenListHash, res->path.node.tile, res->path.node.direction);
-
+
return res;
}
@@ -76,29 +76,29 @@ int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *pare
// Check the new node against the ClosedList
if (AyStarMain_ClosedList_IsInList(aystar, current) != NULL) return AYSTAR_DONE;
-
+
// Calculate the G-value for this node
new_g = aystar->CalculateG(aystar, current, parent);
// If the value was INVALID_NODE, we don't do anything with this node
if (new_g == AYSTAR_INVALID_NODE) return AYSTAR_DONE;
-
+
// There should not be given any other error-code..
assert(new_g >= 0);
// Add the parent g-value to the new g-value
new_g += parent->g;
if (aystar->max_path_cost != 0 && (uint)new_g > aystar->max_path_cost) return AYSTAR_DONE;
-
+
// Calculate the h-value
new_h = aystar->CalculateH(aystar, current, parent);
// There should not be given any error-code..
assert(new_h >= 0);
-
+
// The f-value if g + h
new_f = new_g + new_h;
-
+
// Get the pointer to the parent in the ClosedList (the currentone is to a copy of the one in the OpenList)
closedlist_parent = AyStarMain_ClosedList_IsInList(aystar, &parent->path.node);
-
+
// Check if this item is already in the OpenList
if ((check = AyStarMain_OpenList_IsInList(aystar, current)) != NULL) {
int i;
@@ -117,7 +117,7 @@ int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *pare
// A new node, add him to the OpenList
AyStarMain_OpenList_Add(aystar, closedlist_parent, current, new_f, new_g, 0);
}
-
+
return AYSTAR_DONE;
}
@@ -134,12 +134,12 @@ int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *pare
*/
int AyStarMain_Loop(AyStar *aystar) {
int i, r;
-
+
// Get the best node from OpenList
OpenListNode *current = AyStarMain_OpenList_Pop(aystar);
// If empty, drop an error
if (current == NULL) return AYSTAR_EMPTY_OPENLIST;
-
+
// Check for end node and if found, return that code
if (aystar->EndNodeCheck(aystar, current) == AYSTAR_FOUND_END_NODE) {
if (aystar->FoundEndNode != NULL)
@@ -147,22 +147,22 @@ int AyStarMain_Loop(AyStar *aystar) {
free(current);
return AYSTAR_FOUND_END_NODE;
}
-
+
// Add the node to the ClosedList
AyStarMain_ClosedList_Add(aystar, &current->path);
// Load the neighbours
aystar->GetNeighbours(aystar, current);
-
+
// Go through all neighbours
for (i=0;i<aystar->num_neighbours;i++) {
// Check and add them to the OpenList if needed
r = aystar->checktile(aystar, &aystar->neighbours[i], current);
}
-
+
// Free the node
free(current);
-
+
if (aystar->max_search_nodes != 0 && Hash_Size(&aystar->ClosedListHash) >= aystar->max_search_nodes)
/* We've expanded enough nodes */
return AYSTAR_LIMIT_REACHED;
@@ -228,7 +228,7 @@ int AyStarMain_Main(AyStar *aystar) {
if (r != AYSTAR_STILL_BUSY)
/* We're done, clean up */
aystar->clear(aystar);
-
+
// Check result-value
if (r == AYSTAR_FOUND_END_NODE) return AYSTAR_FOUND_END_NODE;
// Check if we have some left in the OpenList
@@ -242,7 +242,7 @@ int AyStarMain_Main(AyStar *aystar) {
* Adds a node from where to start an algorithm. Multiple nodes can be added
* if wanted. You should make sure that clear() is called before adding nodes
* if the AyStar has been used before (though the normal main loop calls
- * clear() automatically when the algorithm finishes
+ * clear() automatically when the algorithm finishes
*/
void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node) {
#ifdef AYSTAR_DEBUG
diff --git a/aystar.h b/aystar.h
index bb2cad15d..037954d32 100644
--- a/aystar.h
+++ b/aystar.h
@@ -107,7 +107,7 @@ struct AyStar {
AyStar_GetNeighbours* GetNeighbours;
AyStar_EndNodeCheck* EndNodeCheck;
AyStar_FoundEndNode* FoundEndNode;
-
+
/* These are completely untouched by AyStar, they can be accesed by
* the application specific routines to input and output data.
* user_path should typically contain data about the resulting path
@@ -117,7 +117,7 @@ struct AyStar {
void *user_path;
void *user_target;
uint user_data[10];
-
+
/* How many loops are there called before AyStarMain_Main gives
* control back to the caller. 0 = until done */
byte loops_per_tick;
@@ -125,7 +125,7 @@ struct AyStar {
* 0 = infinite */
uint max_path_cost;
/* The maximum amount of nodes that will be expanded, 0 = infinite */
- uint max_search_nodes;
+ uint max_search_nodes;
/* These should be filled with the neighbours of a tile by
* GetNeighbours */
@@ -140,7 +140,7 @@ struct AyStar {
AyStar_Free* free;
AyStar_Clear* clear;
AyStar_CheckTile* checktile;
-
+
/* These will contain the open and closed lists */
/* The actual closed list */
@@ -164,6 +164,6 @@ void AyStarMain_Clear(AyStar *aystar);
* callling init_AyStar (see the declaration of AyStar for which fields are
* internal */
void init_AyStar(AyStar* aystar, Hash_HashProc hash, uint num_buckets);
-
+
#endif
diff --git a/bridge_gui.c b/bridge_gui.c
index e6f258cff..c534dda1b 100644
--- a/bridge_gui.c
+++ b/bridge_gui.c
@@ -30,7 +30,7 @@ static void CcBuildBridge(bool success, uint tile, uint32 p1, uint32 p2)
static void BuildBridge(Window *w, int i)
{
DeleteWindow(w);
- DoCommandP(_bridge.end_tile, _bridge.start_tile, _bridge.indexes[i] | (_bridge.type << 8), CcBuildBridge,
+ DoCommandP(_bridge.end_tile, _bridge.start_tile, _bridge.indexes[i] | (_bridge.type << 8), CcBuildBridge,
CMD_BUILD_BRIDGE | CMD_AUTO | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
}
@@ -60,11 +60,11 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e)
e->keypress.cont = false;
BuildBridge(w, i);
}
-
+
break;
}
- case WE_CLICK:
+ case WE_CLICK:
if (e->click.widget == 2) {
uint ind = ((int)e->click.pt.y - 14) / 22;
if (ind < 4 && (ind += w->vscroll.pos) < (uint)_bridge.count)
@@ -136,7 +136,7 @@ void ShowBuildBridgeWindow(uint start, uint end, byte bridge_type)
// get absolute bridge length
bridge_len = GetBridgeLength(start, end);
- tot_bridge_len = bridge_len + 2;
+ tot_bridge_len = bridge_len + 2;
tot_bridge_len = CalcBridgeLenCostFactor(tot_bridge_len);
@@ -155,7 +155,7 @@ void ShowBuildBridgeWindow(uint start, uint end, byte bridge_type)
_bridge.count = j;
if (j != 0) {
- Window *w = AllocateWindowDesc((_bridge.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
+ Window *w = AllocateWindowDesc((_bridge.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
w->vscroll.cap = 4;
w->vscroll.count = (byte)j;
} else {
diff --git a/clear_cmd.c b/clear_cmd.c
index d7e742d5e..2fe056d7d 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -15,7 +15,7 @@ typedef struct TerraformerState {
int direction;
int modheight_count;
int tile_table_count;
-
+
int32 cost;
TileIndex *tile_table;
@@ -44,7 +44,7 @@ static int TerraformGetHeightOfTile(TerraformerState *ts, TileIndex tile)
{
TerraformerHeightMod *mod = ts->modheight;
int count;
-
+
for(count = ts->modheight_count; count != 0; count--, mod++) {
if (mod->tile == tile)
return mod->height;
@@ -85,10 +85,10 @@ static int TerraformProc(TerraformerState *ts, uint tile, int mode)
int32 ret;
assert(tile < TILES_X * TILES_Y);
-
+
if ((r=TerraformAllowTileProcess(ts, tile)) <= 0)
return r;
-
+
if ((_map_type_and_height[tile] >> 4) == MP_RAILWAY) {
static const byte _railway_modes[4] = {8, 0x10, 4, 0x20};
static const byte _railway_dangslopes[4] = {0xd, 0xe, 7, 0xb};
@@ -128,7 +128,7 @@ static bool TerraformTileHeight(TerraformerState *ts, uint tile, int height)
int nh;
TerraformerHeightMod *mod;
int count;
-
+
assert(tile < TILES_X * TILES_Y);
if (height < 0) {
@@ -140,11 +140,11 @@ static bool TerraformTileHeight(TerraformerState *ts, uint tile, int height)
if (height > 0xF)
return false;
-
+
nh = TerraformGetHeightOfTile(ts, tile);
if (nh < 0 || height == nh)
- return false;
-
+ return false;
+
if (TerraformProc(ts, tile, 0)<0)
return false;
@@ -227,7 +227,7 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
tile = TILE_FROM_XY(x,y);
if (p1 & 1) {
- if (!TerraformTileHeight(&ts, tile+TILE_XY(1,0),
+ if (!TerraformTileHeight(&ts, tile+TILE_XY(1,0),
(_map_type_and_height[tile+TILE_XY(1,0)]&0xF) + direction))
return CMD_ERROR;
}
@@ -254,7 +254,7 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* Check if tunnel would take damage */
int count;
TileIndex *ti = ts.tile_table;
-
+
for(count = ts.tile_table_count; count != 0; count--, ti++) {
uint z, t;
uint tile = *ti;
@@ -280,7 +280,7 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
for(count = ts.tile_table_count; count != 0; count--, ti++) {
DoCommandByTile(*ti, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}
- }
+ }
/* change the height */
{
@@ -291,10 +291,10 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
mod = ts.modheight;
for(count = ts.modheight_count; count != 0; count--, mod++) {
til = mod->tile;
-
+
// Change tile height
_map_type_and_height[til] = (_map_type_and_height[til]&~0x0F)|mod->height;
-
+
TerraformAddDirtyTileAround(&ts, til);
}
}
@@ -306,7 +306,7 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
for(count = ts.tile_table_count; count != 0; count--, ti++) {
MarkTileDirtyByTile(*ti);
}
- }
+ }
}
return ts.cost;
}
@@ -374,9 +374,9 @@ int32 CmdPurchaseLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
uint tile;
int32 cost;
-
+
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
+
tile = TILE_FROM_XY(x,y);
if (!EnsureNoVehicle(tile))
@@ -426,7 +426,7 @@ int32 ClearTile_Clear(uint tile, byte flags) {
int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
uint tile;
-
+
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
tile = TILE_FROM_XY(x,y);
@@ -464,7 +464,7 @@ void DrawHillyLandTile(TileInfo *ti)
void DrawClearLandFence(TileInfo *ti, byte img)
{
byte z = ti->z;
-
+
if (ti->tileh & 2) {
z += 8;
if (ti->tileh == 0x17)
@@ -508,7 +508,7 @@ static void DrawTile_Clear(TileInfo *ti)
DrawGroundSprite( _clear_land_sprites_3[ti->map5&3] + _tileh_to_sprite[ti->tileh]);
break;
}
-
+
DrawClearLandFence(ti, _map3_hi[ti->tile] >> 2);
}
@@ -521,7 +521,7 @@ uint GetSlopeTileh_Clear(TileInfo *ti)
static void GetAcceptedCargo_Clear(uint tile, AcceptedCargo *ac)
{
- /* unused */
+ /* unused */
}
static void AnimateTile_Clear(uint tile)
@@ -553,7 +553,7 @@ void TileLoopClearHelper(uint tile)
if ( (img_1&2) != (img_2&2) ) {
_map3_hi[tile] |= 3 << 5;
dirty = tile;
- }
+ }
} else {
if (img_1 == 1 && img_2 == 1) {
_map3_hi[tile] &= ~(3 << 5);
@@ -572,7 +572,7 @@ void TileLoopClearHelper(uint tile)
if ( (img_1&2) != (img_2&2) ) {
_map3_hi[tile] |= 3 << 2;
dirty = tile;
- }
+ }
} else {
if (img_1 == 1 && img_2 == 1) {
_map3_hi[tile] &= ~(3 << 2);
@@ -596,7 +596,7 @@ static void TileLoopClearAlps(uint tile)
m5 = _map5[tile] & 0x1C;
tmp = _map5[tile] & 3;
-
+
if (k < -8) {
/* snow_m2_down */
if (m5 != 0x10)
@@ -671,7 +671,7 @@ static void TileLoop_Clear(uint tile)
byte m5,m3;
TileLoopClearHelper(tile);
-
+
if (_opt.landscape == LT_DESERT) {
TileLoopClearDesert(tile);
} else if (_opt.landscape == LT_HILLY) {
@@ -685,7 +685,7 @@ static void TileLoop_Clear(uint tile)
if ( (m5 & 0x1C) != 0xC) {
if ( (m5 & 3) == 3)
return;
-
+
if (_game_mode != GM_EDITOR) {
m5 += 0x20;
if (m5 >= 0x20) {
@@ -727,7 +727,7 @@ void GenerateClearTile()
/* add hills */
i = (Random() & 0x3FF) | 0x400;
do {
- tile = TILE_MASK(Random());
+ tile = TILE_MASK(Random());
if (IS_TILETYPE(tile, MP_CLEAR))
_map5[tile] = (byte)((_map5[tile] & ~(3<<2)) | (1<<2));
} while (--i);
@@ -736,7 +736,7 @@ void GenerateClearTile()
i = (Random() & 0x7F) | 0x80;
do {
r = Random();
- tile = TILE_MASK(r);
+ tile = TILE_MASK(r);
if (IS_TILETYPE(tile, MP_CLEAR)) {
j = ((r >> 16) & 0xF) + 5;
for(;;) {
diff --git a/command.c b/command.c
index b50d524f9..5012c8919 100644
--- a/command.c
+++ b/command.c
@@ -305,7 +305,7 @@ static CommandProc * const _command_proc_table[] = {
int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
{
return DoCommand(GET_TILE_X(tile)*16, GET_TILE_Y(tile)*16, p1, p2, flags, procc);
-}
+}
//extern void _stdcall Sleep(int s);
@@ -314,7 +314,7 @@ int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
{
int32 res;
CommandProc *proc;
-
+
proc = _command_proc_table[procc];
if (_docommand_recursive == 0) {
@@ -383,7 +383,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
int x = GET_TILE_X(tile)*16;
int y = GET_TILE_Y(tile)*16;
- assert(_docommand_recursive == 0);
+ assert(_docommand_recursive == 0);
_error_message = INVALID_STRING_ID;
_error_message_2 = cmd >> 16;
@@ -404,9 +404,9 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
proc = _command_proc_table[cmd & 0xFF];
// this command is a notest command?
- notest =
- (cmd & 0xFF) == CMD_CLEAR_AREA ||
- (cmd & 0xFF) == CMD_CONVERT_RAIL ||
+ notest =
+ (cmd & 0xFF) == CMD_CLEAR_AREA ||
+ (cmd & 0xFF) == CMD_CONVERT_RAIL ||
(cmd & 0xFF) == CMD_LEVEL_LAND ||
(cmd & 0xFF) == CMD_TRAIN_GOTO_DEPOT;
@@ -429,7 +429,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
return false;
}
-
+
// unless the command is a notest command, check if it can be executed.
if (!notest) {
@@ -456,7 +456,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
// actually try and execute the command.
_yearly_expenses_type = 0;
res2 = proc(x,y, flags|DC_EXEC, p1, p2);
-
+
if (!notest) {
assert(res == res2); // sanity check
} else {
@@ -479,7 +479,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
}
_docommand_recursive = 0;
-
+
if (callback) callback(true, tile, p1, p2);
return true;
@@ -490,7 +490,7 @@ show_error:
callb_err:
_docommand_recursive = 0;
-
+
if (callback) callback(false, tile, p1, p2);
return false;
}
diff --git a/command.h b/command.h
index af610a383..4dc4ad911 100644
--- a/command.h
+++ b/command.h
@@ -140,7 +140,7 @@ enum {
CMD_REFIT_RAIL_VEHICLE = 106,
CMD_RESTORE_ORDER_INDEX = 107,
CMD_BUILD_LOCK = 108,
-
+
CMD_START_SCENARIO = 109,
CMD_BUILD_MANY_SIGNALS = 110,
@@ -157,7 +157,7 @@ enum {
DC_AI_BUILDING = 0x20, // special building rules for AI
DC_NO_TOWN_RATING = 0x40, // town rating does not disallow you from building
DC_FORCETEST = 0x80, // force test too.
-
+
CMD_ERROR = ((int32)0x80000000),
};
diff --git a/console.c b/console.c
index 045241e74..83a36bb36 100644
--- a/console.c
+++ b/console.c
@@ -44,7 +44,7 @@ static const WindowDesc _iconsole_window_desc = {
static _iconsole_cmd * _iconsole_cmds; // list of registred commands
static _iconsole_var * _iconsole_vars; // list of registred vars
-// ** console std lib ** //
+// ** console std lib ** //
static byte _stdlib_developer=1;
static bool _stdlib_con_developer=false;
static void IConsoleStdLibRegister();
@@ -96,7 +96,7 @@ static void IConsoleWndProc(Window *w, WindowEvent *e)
GfxFillRect(posx,posy,posx+5,posy+1,color);
_video_driver->make_dirty(posx,posy,5,1);
}
- _icursor_counter=0;
+ _icursor_counter=0;
}
break;
@@ -157,14 +157,14 @@ static void IConsoleWndProc(Window *w, WindowEvent *e)
{
IConsoleSwitch();
} else
- if (e->keypress.keycode == WKC_RETURN)
+ if (e->keypress.keycode == WKC_RETURN)
{
IConsolePrintF(_iconsole_color_commands, "] %s", _iconsole_cmdline);
IConsoleCmdBufferAdd(_iconsole_cmdline);
IConsoleCmdExec((byte *) _iconsole_cmdline);
IConsoleClearCommand();
} else
- if (e->keypress.keycode == WKC_BACKSPACE)
+ if (e->keypress.keycode == WKC_BACKSPACE)
{
if (_iconsole_cmdpos!=0) _iconsole_cmdpos--;
_iconsole_cmdline[_iconsole_cmdpos]=0;
@@ -175,10 +175,10 @@ static void IConsoleWndProc(Window *w, WindowEvent *e)
{
_iconsole_scroll=79;
_iconsole_cmdline[_iconsole_cmdpos]=e->keypress.ascii;
- if (_iconsole_cmdpos!=255) _iconsole_cmdpos++;
+ if (_iconsole_cmdpos!=255) _iconsole_cmdpos++;
SetWindowDirty(w);
_iconsole_cmdbufferpos=19;
- } else e->keypress.cont=true;
+ } else e->keypress.cont=true;
break;
}
@@ -211,9 +211,9 @@ for (i=0;i<80;i++) {
}
IConsoleStdLibRegister();
#if defined(WITH_REV)
-IConsolePrintF(13,"OpenTTD Game Console Revision 3 - %s",_openttd_revision);
+IConsolePrintF(13,"OpenTTD Game Console Revision 3 - %s",_openttd_revision);
#else
-IConsolePrint(13,"OpenTTD Game Console Revision 3");
+IConsolePrint(13,"OpenTTD Game Console Revision 3");
#endif
IConsolePrint(12,"---------------------------------");
IConsolePrint(12,"use \"help\" for more info");
@@ -386,7 +386,7 @@ void* IConsoleCmdGetAddr(byte * name) {
_iconsole_cmd * item;
item = _iconsole_cmds;
-while (item != NULL) {
+while (item != NULL) {
if (strcmp(item->name,name)==0) return item->addr;
item = item->_next;
}
@@ -455,7 +455,7 @@ _iconsole_var * IConsoleVarGet(byte * name) {
_iconsole_var * item;
item = _iconsole_vars;
-while (item != NULL) {
+while (item != NULL) {
if (strcmp(item->name,name)==0) return item;
item = item->_next;
}
@@ -733,7 +733,7 @@ tokenstream--;
if (!(*tokenstream==0)) {
c++;
tokenstream++;
- *tokenstream = 0;
+ *tokenstream = 0;
}
//** interpreting **//
@@ -790,7 +790,7 @@ if (function != NULL) {
//** executing **//
if (_stdlib_con_developer) IConsolePrintF(_iconsole_color_debug,"CONDEBUG: execution_mode: %i",execution_mode);
switch (execution_mode) {
-case 0:
+case 0:
{
// not found
IConsoleError("command or variable not found");
@@ -830,7 +830,7 @@ case 2:
else if (strcmp(tokens[1],"--")==0) {
*(bool *)var->addr=!*(bool *)var->addr;
IConsoleVarDump(var,NULL);
- }
+ }
else { IConsoleError("operation not supported"); }
}
break;
@@ -852,7 +852,7 @@ case 2:
else if (strcmp(tokens[1],"--")==0) {
(*(byte *)var->addr)--;
IConsoleVarDump(var,NULL);
- }
+ }
else { IConsoleError("operation not supported"); }
}
break;
@@ -1083,7 +1083,7 @@ case 4:
result = NULL;
}
}
-
+
}
break;
default:
@@ -1129,7 +1129,7 @@ static _iconsole_var * IConsoleStdLibPrintFC(byte argc, byte* argv[], byte argt[
}
static _iconsole_var * IConsoleStdLibScreenShot(byte argc, byte* argv[], byte argt[]) {
-
+
if (argc<2) {
_make_screenshot=1;
} else {
@@ -1201,7 +1201,7 @@ int l = 0;
if (argv[1]!=NULL) l = strlen((char *) argv[1]);
item = _iconsole_cmds;
-while (item != NULL) {
+while (item != NULL) {
if (argv[1]!=NULL) {
if (memcmp((void *) item->name, (void *) argv[1],l)==0)
@@ -1225,7 +1225,7 @@ int l = 0;
if (argv[1]!=NULL) l = strlen((char *) argv[1]);
item = _iconsole_vars;
-while (item != NULL) {
+while (item != NULL) {
if (argv[1]!=NULL) {
if (memcmp((void *) item->name, (void *) argv[1],l)==0)
@@ -1249,7 +1249,7 @@ int l = 0;
if (argv[1]!=NULL) l = strlen((char *) argv[1]);
item = _iconsole_vars;
-while (item != NULL) {
+while (item != NULL) {
if (argv[1]!=NULL) {
if (memcmp((void *) item->name, (void *) argv[1],l)==0)
diff --git a/disaster_cmd.c b/disaster_cmd.c
index 23c7e3fcb..8f9d446fc 100644
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -13,7 +13,7 @@
static void DisasterClearSquare(uint tile)
{
int type;
-
+
if (!EnsureNoVehicle(tile))
return;
@@ -107,7 +107,7 @@ static void SetDisasterVehiclePos(Vehicle *v, int x, int y, byte z)
if ( (u=v->next) != NULL) {
BeginVehicleMove(u);
-
+
u->x_pos = x;
u->y_pos = yt = y - 1 - (max(z - GetSlopeZ(x, y-1), 0) >> 3);
u->z_pos = GetSlopeZ(x,yt);
@@ -144,7 +144,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
return;
GetNewVehiclePos(v, &gp);
-
+
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
if (v->next_order == 1) {
@@ -162,7 +162,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
if (IS_TILETYPE(tile, MP_STATION) &&
IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
IS_HUMAN_PLAYER(_map_owner[tile])) {
-
+
v->next_order = 1;
v->age = 0;
@@ -176,12 +176,12 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
if (v->y_pos >= (TILES_Y+9) * 16 - 1)
DeleteDisasterVeh(v);
return;
- }
-
+ }
+
if (v->next_order > 2) {
if (++v->age <= 13320)
return;
-
+
tile = v->tile; /**/
if (IS_TILETYPE(tile, MP_STATION) &&
@@ -245,9 +245,9 @@ static void DisasterTick_UFO(Vehicle *v)
byte z;
v->u.disaster.image_override = (++v->tick_counter & 8) ? 0xF45 : 0xF44;
-
+
if (v->next_order == 0) {
-// fly around randomly
+// fly around randomly
int x = GET_TILE_X(v->dest_tile)*16;
int y = GET_TILE_Y(v->dest_tile)*16;
if (abs(x - v->x_pos) + abs(y - v->y_pos) >= 16) {
@@ -288,11 +288,11 @@ static void DisasterTick_UFO(Vehicle *v)
v->direction = GetDirectionTowards(v, u->x_pos, u->y_pos);
GetNewVehiclePos(v, &gp);
-
+
z = v->z_pos;
if (dist <= 16 && z > u->z_pos) z--;
SetDisasterVehiclePos(v, gp.x, gp.y, z);
-
+
if (z <= u->z_pos && (u->vehstatus&VS_HIDDEN)==0) {
v->age++;
if (u->u.road.crashed_ctr == 0) {
@@ -332,10 +332,10 @@ static void DestructIndustry(Industry *i)
static void DisasterTick_2(Vehicle *v)
{
GetNewVehiclePosResult gp;
-
+
v->tick_counter++;
v->u.disaster.image_override = (v->next_order == 1 && v->tick_counter&4) ? 0xF4F : 0;
-
+
GetNewVehiclePos(v, &gp);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@@ -386,7 +386,7 @@ static void DisasterTick_2(Vehicle *v)
return;
tile = TILE_FROM_XY(x,y);
- if (!IS_TILETYPE(tile, MP_INDUSTRY))
+ if (!IS_TILETYPE(tile, MP_INDUSTRY))
return;
v->dest_tile = ind = _map2[tile];
@@ -456,7 +456,7 @@ static void DisasterTick_3(Vehicle *v)
return;
tile = TILE_FROM_XY(x,y);
- if (!IS_TILETYPE(tile, MP_INDUSTRY))
+ if (!IS_TILETYPE(tile, MP_INDUSTRY))
return;
v->dest_tile = ind = _map2[tile];
@@ -546,7 +546,7 @@ static void DisasterTick_4(Vehicle *v)
InitializeDisasterVehicle(w, -6*16, v->y_pos, 0, 5, 12);
w->vehstatus |= VS_DISASTER;
} else if (v->next_order < 1) {
-
+
int x = GET_TILE_X(v->dest_tile)*16;
int y = GET_TILE_Y(v->dest_tile)*16;
if (abs(x - v->x_pos) + abs(y - v->y_pos) >= 16) {
@@ -593,7 +593,7 @@ static void DisasterTick_4b(Vehicle *v)
}
if (v->next_order == 0) {
- u = &_vehicles[v->u.disaster.unk2];
+ u = &_vehicles[v->u.disaster.unk2];
if (abs(v->x_pos - u->x_pos) > 16)
return;
v->next_order = 1;
@@ -685,7 +685,7 @@ void OnNewDay_DisasterVehicle(Vehicle *v)
typedef void DisasterInitProc();
// Zeppeliner which crashes on a small airport
-static void Disaster0_Init()
+static void Disaster0_Init()
{
Vehicle *v = ForceAllocateSpecialVehicle(), *u;
Station *st;
@@ -695,7 +695,7 @@ static void Disaster0_Init()
return;
for(st=_stations;;) {
- if (st->xy && st->airport_tile != 0 &&
+ if (st->xy && st->airport_tile != 0 &&
st->airport_type <= 1 &&
IS_HUMAN_PLAYER(st->owner)) {
x = (GET_TILE_X(st->xy) + 2) * 16;
@@ -714,12 +714,12 @@ static void Disaster0_Init()
u = ForceAllocateSpecialVehicle();
if (u != NULL) {
v->next = u;
- InitializeDisasterVehicle(u,x,0,0,3,1);
+ InitializeDisasterVehicle(u,x,0,0,3,1);
u->vehstatus |= VS_DISASTER;
}
}
-static void Disaster1_Init()
+static void Disaster1_Init()
{
Vehicle *v = ForceAllocateSpecialVehicle(), *u;
int x;
@@ -737,12 +737,12 @@ static void Disaster1_Init()
u = ForceAllocateSpecialVehicle();
if (u != NULL) {
v->next = u;
- InitializeDisasterVehicle(u,x,0,0,3,3);
+ InitializeDisasterVehicle(u,x,0,0,3,3);
u->vehstatus |= VS_DISASTER;
}
}
-static void Disaster2_Init()
+static void Disaster2_Init()
{
Industry *i, *found;
Vehicle *v,*u;
@@ -750,7 +750,7 @@ static void Disaster2_Init()
for(found=NULL,i=_industries; i != endof(_industries); i++) {
if (i->xy != 0 &&
- i->type == IT_OIL_REFINERY &&
+ i->type == IT_OIL_REFINERY &&
(found==NULL || CHANCE16(1,2))) {
found = i;
}
@@ -771,12 +771,12 @@ static void Disaster2_Init()
u = ForceAllocateSpecialVehicle();
if (u != NULL) {
v->next = u;
- InitializeDisasterVehicle(u,x,y,0,3,5);
+ InitializeDisasterVehicle(u,x,y,0,3,5);
u->vehstatus |= VS_DISASTER;
}
}
-static void Disaster3_Init()
+static void Disaster3_Init()
{
Industry *i, *found;
Vehicle *v,*u,*w;
@@ -784,7 +784,7 @@ static void Disaster3_Init()
for(found=NULL,i=_industries; i != endof(_industries); i++) {
if (i->xy != 0 &&
- i->type == IT_FACTORY &&
+ i->type == IT_FACTORY &&
(found==NULL || CHANCE16(1,2))) {
found = i;
}
@@ -805,18 +805,18 @@ static void Disaster3_Init()
u = ForceAllocateSpecialVehicle();
if (u != NULL) {
v->next = u;
- InitializeDisasterVehicle(u,x,y,0,5,7);
+ InitializeDisasterVehicle(u,x,y,0,5,7);
u->vehstatus |= VS_DISASTER;
w = ForceAllocateSpecialVehicle();
if (w != NULL) {
u->next = w;
- InitializeDisasterVehicle(w,x,y,140,5,8);
+ InitializeDisasterVehicle(w,x,y,140,5,8);
}
}
}
-static void Disaster4_Init()
+static void Disaster4_Init()
{
Vehicle *v = ForceAllocateSpecialVehicle(), *u;
int x,y;
@@ -835,13 +835,13 @@ static void Disaster4_Init()
u = ForceAllocateSpecialVehicle();
if (u != NULL) {
v->next = u;
- InitializeDisasterVehicle(u,x,y,0,7,10);
+ InitializeDisasterVehicle(u,x,y,0,7,10);
u->vehstatus |= VS_DISASTER;
}
}
// Submarine type 1
-static void Disaster5_Init()
+static void Disaster5_Init()
{
Vehicle *v = ForceAllocateSpecialVehicle();
int x,y;
@@ -862,7 +862,7 @@ static void Disaster5_Init()
}
// Submarine type 2
-static void Disaster6_Init()
+static void Disaster6_Init()
{
Vehicle *v = ForceAllocateSpecialVehicle();
int x,y;
@@ -882,20 +882,20 @@ static void Disaster6_Init()
v->age = 0;
}
-static void Disaster7_Init()
+static void Disaster7_Init()
{
Industry *i;
int maxloop = 15;
int index = Random() & 0xF;
-
+
do {
for(i=_industries; i != endof(_industries); i++) {
if (i->xy != 0 && i->type == IT_COAL_MINE && --index < 0) {
-
+
SET_DPARAM16(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 + TILE_XY(1,1), 0);
-
+
{
uint tile = i->xy;
int step = _tileoffs_by_dir[Random() & 3];
diff --git a/dock_gui.c b/dock_gui.c
index ac42552fd..2cca3dec2 100644
--- a/dock_gui.c
+++ b/dock_gui.c
@@ -129,7 +129,7 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
case WE_PLACE_OBJ:
_place_proc(e->place.tile);
- break;
+ break;
case WE_PLACE_DRAG: {
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata);
@@ -155,7 +155,7 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
w = FindWindowById(WC_BUILD_DEPOT, 0);
if (w != NULL) WP(w,def_d).close=true;
break;
-
+
case WE_PLACE_PRESIZE: {
uint tile_from, tile_to;
@@ -225,7 +225,7 @@ static void BuildDockStationWndProc(Window *w, WindowEvent *e)
CheckRedrawStationCoverage(w);
break;
}
- }
+ }
}
static const Widget _build_dock_station_widgets[] = {
diff --git a/economy.c b/economy.c
index 5504f0fab..02f196cac 100644
--- a/economy.c
+++ b/economy.c
@@ -44,11 +44,11 @@ void UpdatePlayerHouse(Player *p, uint score)
uint32 CalculateCompanyValue(Player *p) {
byte owner = p->index;
uint32 value;
-
+
{
Station *st;
uint num = 0;
-
+
FOR_ALL_STATIONS(st) {
if (st->xy != 0 && st->owner == owner) {
uint facil = st->facilities;
@@ -194,7 +194,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
{
_score_part[owner][SCORE_LOAN] = score_info[SCORE_LOAN].needed - p->current_loan;
}
-
+
// Now we calculate the score for each item..
{
int i;
@@ -210,9 +210,9 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
score += s;
total_score += score_info[i].score;
}
-
+
_score_part[owner][SCORE_TOTAL] = score;
-
+
// We always want the score scaled to SCORE_MAX (1000)
if (total_score != SCORE_MAX)
score = score * SCORE_MAX / total_score;
@@ -223,7 +223,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
UpdatePlayerHouse(p, score);
p->old_economy[0].company_value = CalculateCompanyValue(p);
}
-
+
InvalidateWindow(WC_PERFORMANCE_DETAIL, 0);
return score;
}
@@ -236,7 +236,7 @@ void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player)
if (new_player == 255) {
Subsidy *s;
-
+
for(s=_subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type != 0xff && s->age >= 12) {
Station *st = DEREF_STATION(s->to);
@@ -249,7 +249,7 @@ void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player)
// take care of rating in towns
{
Town *t;
-
+
// if a player takes over, give the ratings to that player.
if (new_player != 255) {
FOR_ALL_TOWNS(t) if (t->xy && HASBIT(t->have_ratings, old_player)) {
@@ -269,7 +269,7 @@ void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player)
CLRBIT(t->have_ratings, old_player);
}
}
-
+
{
int num_train = 0;
int num_road = 0;
@@ -353,7 +353,7 @@ static void PlayersCheckBankrupt(Player *p)
if (p->quarters_of_bankrupcy == 2) {
year_2:
- AddNewsItem( (StringID)(owner + 16),
+ AddNewsItem( (StringID)(owner + 16),
NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
} else if (p->quarters_of_bankrupcy == 3) {
@@ -396,7 +396,7 @@ void DrawNewsBankrupcy(Window *w)
{
Player *p;
- DrawNewsBorder(w);
+ DrawNewsBorder(w);
p = DEREF_PLAYER(WP(w,news_d).ni->string_id & 15);
DrawPlayerFace(p->face, p->player_color, 2, 23);
@@ -446,7 +446,7 @@ void DrawNewsBankrupcy(Window *w)
90,
STR_705D_HAS_BEEN_CLOSED_DOWN_BY,
w->width - 101);
- break;
+ break;
case 4:
DrawStringCentered(w->width>>1, 1, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED, 0);
@@ -499,7 +499,7 @@ StringID GetNewsStringBankrupcy(NewsItem *ni)
default:
NOT_REACHED();
}
-
+
/* useless, but avoids compiler warning this way */
return 0;
}
@@ -563,13 +563,13 @@ static void AddInflation()
}
_economy.max_loan_unround += BIGMULUS(_economy.max_loan_unround, inf, 16);
-
+
if (_economy.max_loan + 50000 <= _economy.max_loan_unround)
_economy.max_loan += 50000;
inf = _economy.infl_amount_pr * 54;
for(i=0; i!=NUM_CARGO; i++) {
- AddSingleInflation(
+ AddSingleInflation(
_cargo_payment_rates + i,
_cargo_payment_rates_frac + i,
inf
@@ -592,7 +592,7 @@ static void PlayersPayInterest()
_current_player = p->index;
SET_EXPENSES_TYPE(EXPENSES_LOAN_INT);
-
+
SubtractMoneyFromPlayer(BIGMULUS(p->current_loan, interest, 16));
SET_EXPENSES_TYPE(EXPENSES_OTHER);
@@ -767,28 +767,28 @@ Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode)
void DeleteSubsidyWithIndustry(byte index)
{
Subsidy *s;
-
+
for(s=_subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type != 0xFF && 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))) {
s->cargo_type = 0xFF;
}
- }
+ }
}
-void DeleteSubsidyWithStation(byte index)
+void DeleteSubsidyWithStation(byte index)
{
Subsidy *s;
bool dirty = false;
-
+
for(s=_subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type != 0xFF && s->age >= 12 &&
(s->from == index || s->to == index)) {
s->cargo_type = 0xFF;
dirty = true;
}
- }
+ }
if (dirty)
InvalidateWindow(WC_SUBSIDIES_LIST, 0);
@@ -852,7 +852,7 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
if (cargo == CT_GOODS || cargo == CT_FOOD) {
// The destination is a town
Town *t = DEREF_TOWN(RandomRange(_total_towns));
-
+
// Only want big towns
if (t->xy == 0 || t->population < 900)
return;
@@ -861,9 +861,9 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
} else {
// The destination is an industry
Industry *i2 = DEREF_INDUSTRY(RandomRange(_total_industries));
-
+
// The industry must accept the cargo
- if (i == i2 || i2->xy == 0 ||
+ if (i == i2 || i2->xy == 0 ||
(cargo != i2->accepts_cargo[0] &&
cargo != i2->accepts_cargo[1] &&
cargo != i2->accepts_cargo[2]))
@@ -873,15 +873,15 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
}
}
-static bool CheckSubsidyDuplicate(Subsidy *s)
+static bool CheckSubsidyDuplicate(Subsidy *s)
{
Subsidy *ss;
for(ss=_subsidies; ss != endof(_subsidies); ss++) {
- if (s != ss &&
-// ss->age < 12 &&
- ss->from == s->from &&
- ss->to == s->to &&
+ if (s != ss &&
+// ss->age < 12 &&
+ ss->from == s->from &&
+ ss->to == s->to &&
ss->cargo_type == s->cargo_type) {
s->cargo_type = 0xFF;
return true;
@@ -929,7 +929,7 @@ static void SubsidyMonthlyHandler()
if (++s == endof(_subsidies))
goto no_add;
}
-
+
n = 1000;
do {
FindSubsidyPassengerRoute(&fr);
@@ -1002,7 +1002,7 @@ int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, b
if (transit_days > _cargoc.transit_days_1[cargo]) {
transit_days -= _cargoc.transit_days_1[cargo];
f -= transit_days;
-
+
if (transit_days > _cargoc.transit_days_2[cargo]) {
transit_days -= _cargoc.transit_days_2[cargo];
@@ -1019,7 +1019,7 @@ int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, b
static void DeliverGoodsToIndustry(TileIndex xy, byte cargo_type, int num_pieces)
{
- Industry *ind, *best;
+ Industry *ind, *best;
int t, u;
/* Check if there's an industry close to the station that accepts
@@ -1031,7 +1031,7 @@ static void DeliverGoodsToIndustry(TileIndex xy, byte cargo_type, int num_pieces
== ind->accepts_cargo[1] || cargo_type == ind->accepts_cargo[2]) &&
ind->produced_cargo[0] != 0xFF &&
ind->produced_cargo[0] != cargo_type &&
- (t=GetTileDist(ind->xy, xy)) < u) {
+ (t=GetTileDist(ind->xy, xy)) < u) {
u = t;
best = ind;
}
@@ -1063,7 +1063,7 @@ static bool CheckSubsidised(Station *from, Station *to, byte cargo_type)
/* check if there's a new subsidy that applies.. */
for(s=_subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type == cargo_type && s->age < 12) {
-
+
/* Check distance from source */
if (cargo_type == CT_PASSENGERS || cargo_type == CT_MAIL) {
xy = DEREF_TOWN(s->from)->xy;
@@ -1072,7 +1072,7 @@ static bool CheckSubsidised(Station *from, Station *to, byte cargo_type)
}
if (GetTileDist1D(xy, from->xy) > 9)
continue;
-
+
/* Check distance from dest */
if (cargo_type == CT_PASSENGERS || cargo_type == CT_MAIL || cargo_type == CT_GOODS || cargo_type == CT_FOOD) {
xy = DEREF_TOWN(s->to)->xy;
@@ -1096,7 +1096,7 @@ static bool CheckSubsidised(Station *from, Station *to, byte cargo_type)
SET_DPARAM16(0, p->name_1);
SET_DPARAM32(1, p->name_2);
AddNewsItem(
- STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier,
+ STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier,
NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0),
pair.a, pair.b);
@@ -1138,7 +1138,7 @@ static int32 DeliverGoods(int num_pieces, byte cargo_type, byte source, byte des
// Give the goods to the industry.
DeliverGoodsToIndustry(s_to->xy, cargo_type, num_pieces);
-
+
// Determine profit
{
int t = GetTileDist(s_from->xy, s_to->xy);
@@ -1197,7 +1197,7 @@ int LoadUnloadVehicle(Vehicle *v)
for(;;) {
if (v->cargo_cap == 0)
goto next_vehicle;
-
+
ge = &st->goods[v->cargo_type];
/* unload? */
@@ -1211,7 +1211,7 @@ int LoadUnloadVehicle(Vehicle *v)
} else if (u->next_order & OF_UNLOAD) {
/* unload goods and let it wait at the station */
st->time_since_unload = 0;
-
+
if ((t=ge->waiting_acceptance & 0xFFF) == 0) {
// No goods waiting at station
ge->enroute_time = v->cargo_days;
@@ -1229,7 +1229,7 @@ int LoadUnloadVehicle(Vehicle *v)
v->cargo_count = 0;
}
}
-
+
/* don't pick up goods that we unloaded */
if (u->next_order & OF_UNLOAD)
goto next_vehicle;
@@ -1238,7 +1238,7 @@ int LoadUnloadVehicle(Vehicle *v)
ge->days_since_pickup = 0;
t = u->max_speed;
if (u->type == VEH_Road) t >>=1;
-
+
// if last speed is 0, we treat that as if no vehicle has ever visited the station.
ge->last_speed = t < 255 ? t : 255;
ge->last_age = _cur_year - v->build_year;
@@ -1252,7 +1252,7 @@ int LoadUnloadVehicle(Vehicle *v)
ge->waiting_acceptance -= cap;
unloading_time += cap;
st->time_since_load = 0;
-
+
// And record the source of the cargo, and the days in travel.
v->cargo_source = ge->enroute_from;
v->cargo_days = ge->enroute_time;
diff --git a/economy.h b/economy.h
index b8134c64a..690fc61fc 100644
--- a/economy.h
+++ b/economy.h
@@ -36,7 +36,7 @@ enum {
SCORE_TOTAL = 9, // This must always be the last entry
NUM_SCORE = 10, // How many scores are there..
-
+
SCORE_MAX = 1000, // The max score that can be in the performance history
// the scores together of score_info is allowed to be more!
};
diff --git a/engine.c b/engine.c
index 0209ab706..67c8b9239 100644
--- a/engine.c
+++ b/engine.c
@@ -124,7 +124,7 @@ void StartupEngines()
e->railtype = ei->railtype_climates >> 4;
e->flags = 0;
e->player_avail = 0;
-
+
r = Random();
e->intro_date = (uint16)((r & 0x1FF) + ei->base_intro);
if (e->intro_date <= _date) {
@@ -191,7 +191,7 @@ void SetWagonOverrideSprites(byte engine, struct SpriteSuperSet *superset,
wos->overrides_count++;
wos->overrides = realloc(wos->overrides,
wos->overrides_count * sizeof(struct WagonOverride));
-
+
wo = &wos->overrides[wos->overrides_count - 1];
wo->superset = *superset;
wo->trains = trains;
@@ -246,7 +246,7 @@ int GetCustomEngineSprite(byte engine, uint16 overriding_engine, byte cargo,
overset = GetWagonOverrideSpriteSet(engine, overriding_engine);
if (overset) superset = overset;
}
-
+
if (!superset->sprites_per_set && cargo != 29) {
// This superset is empty but perhaps there'll be a default one.
superset = &_engine_custom_sprites[engine][29];
@@ -307,7 +307,7 @@ void AcceptEnginePreview(Engine *e, int player)
SETBIT(e->player_avail, player);
p = DEREF_PLAYER(player);
-
+
UPDATE_PLAYER_RAILTYPE(e,p);
e->preview_player = 0xFF;
@@ -333,7 +333,7 @@ void EnginesDailyLoop()
e->flags &= ~ENGINE_PREVIEWING;
DeleteWindowById(WC_ENGINE_PREVIEW, i);
e->preview_player++;
- }
+ }
} else if (e->preview_player != 0xFF) {
num = e->preview_player;
mask = 0;
@@ -341,7 +341,7 @@ void EnginesDailyLoop()
best_hist = -1;
best_player = -1;
FOR_ALL_PLAYERS(p) {
- if (p->is_active && p->block_preview == 0 && !HASBIT(mask,p->index) &&
+ if (p->is_active && p->block_preview == 0 && !HASBIT(mask,p->index) &&
p->old_economy[0].performance_history > best_hist) {
best_hist = p->old_economy[0].performance_history;
best_player = p->index;
@@ -353,7 +353,7 @@ void EnginesDailyLoop()
}
mask |= (1 << best_player);
} while (--num != 0);
-
+
if (!IS_HUMAN_PLAYER(best_player)) {
/* TTDBUG: TTD has a bug here */
AcceptEnginePreview(e, best_player);
@@ -361,7 +361,7 @@ void EnginesDailyLoop()
e->flags |= ENGINE_PREVIEWING;
e->preview_wait = 20;
if (IS_INTERACTIVE_PLAYER(best_player)) {
- ShowEnginePreviewWindow(i);
+ ShowEnginePreviewWindow(i);
}
}
}
@@ -390,7 +390,7 @@ void NewVehicleAvailable(Engine *e)
FOR_ALL_PLAYERS(p) {
if (!HASBIT(e->player_avail,p->index))
continue;
-
+
for(v=_vehicles;;) {
if (v->type == VEH_Train || v->type == VEH_Road || v->type == VEH_Ship ||
(v->type == VEH_Aircraft && v->subtype <= 2)) {
@@ -466,7 +466,7 @@ int32 CmdRenameEngine(int x, int y, uint32 flags, uint32 p1, uint32 p2)
str = AllocateName((byte*)_decode_parameters, 0);
if (str == 0)
return CMD_ERROR;
-
+
if (flags & DC_EXEC) {
StringID old_str = _engine_name_strings[p1];
_engine_name_strings[p1] = str;
diff --git a/engine_gui.c b/engine_gui.c
index df496ae1f..476d7122a 100644
--- a/engine_gui.c
+++ b/engine_gui.c
@@ -88,7 +88,7 @@ static void EnginePreviewWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
switch(e->click.widget) {
case 3: DeleteWindow(w); break;
- case 4:
+ case 4:
DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW);
DeleteWindow(w);
break;
@@ -150,7 +150,7 @@ void DrawNewsNewAircraftAvail(Window *w)
DrawNewsBorder(w);
engine = WP(w,news_d).ni->string_id;
-
+
DrawStringMultiCenter(w->width >> 1, 20, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE, w->width - 2);
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10);
@@ -203,7 +203,7 @@ void DrawNewsNewShipAvail(Window *w)
DrawNewsBorder(w);
engine = WP(w,news_d).ni->string_id;
-
+
DrawStringMultiCenter(w->width >> 1, 20, STR_982C_NEW_SHIP_NOW_AVAILABLE, w->width - 2);
GfxFillRect(25, 56, w->width - 25, w->height - 2, 10);
diff --git a/fileio.c b/fileio.c
index bb34cdd43..490cdc1ba 100644
--- a/fileio.c
+++ b/fileio.c
@@ -101,7 +101,7 @@ void FioOpenFile(int slot, const char *filename)
char buf[MAX_PATH];
sprintf(buf, "%s%s", _path.data_dir, filename);
-
+
f = fopen(buf, "rb");
#if !defined(WIN32)
if (f == NULL) {
@@ -115,7 +115,7 @@ void FioOpenFile(int slot, const char *filename)
if (f == NULL)
error("Cannot open file '%s'", buf);
-
+
_fio.handles[slot] = f;
FioSeekToFile(slot << 24);
}
diff --git a/gfx.c b/gfx.c
index be4cac622..2d0616fb8 100644
--- a/gfx.c
+++ b/gfx.c
@@ -242,17 +242,17 @@ void GfxDrawLine(int x, int y, int x2, int y2, int color)
// 0 - end of string
// 1 - SETX <BYTE>
// 2 - SETXY <BYTE> <BYTE>
-// 3-7 -
+// 3-7 -
// 8 - TINYFONT
// 9 - BIGFONT
// 10 - newline
-// 11-14 -
+// 11-14 -
// 15-31 - 17 colors
enum {
ASCII_LETTERSTART = 32,
-
+
ASCII_SETX = 1,
ASCII_SETXY = 2,
@@ -510,7 +510,7 @@ check_bounds:
skip_char:;
for(;;) {
c = *string++;
- if (c < ASCII_LETTERSTART) goto skip_cont;
+ if (c < ASCII_LETTERSTART) goto skip_cont;
}
}
@@ -586,7 +586,7 @@ static void GfxBlitTileZoomIn(BlitterParams *bp)
if (bp->mode & 1) {
src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
-
+
do {
do {
done = src_o[0];
@@ -1351,7 +1351,7 @@ static void GfxMainBlitter(byte *sprite, int x, int y, int mode)
if (dpi->zoom > 0) {
start_y += bp.height &~ zoom_mask;
- bp.height &= zoom_mask;
+ bp.height &= zoom_mask;
if (bp.height == 0) return;
y&=zoom_mask;
}
@@ -1622,7 +1622,7 @@ void UndrawMouseCursor()
_screen.dst_ptr + _cursor.draw_pos.x + _cursor.draw_pos.y * _screen.pitch,
_cursor_backup,
_cursor.draw_size.x, _cursor.draw_size.y, _cursor.draw_size.x, _screen.pitch);
-
+
_video_driver->make_dirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
}
}
@@ -1920,9 +1920,9 @@ void SetAnimatedMouseCursor(const uint16 *table)
}
bool ChangeResInGame(int w, int h)
-{
+{
if ((_screen.width != w || _screen.height != h) && !_video_driver->change_resolution(w, h))
- return false;
+ return false;
_cur_resolution[0] = w;
_cur_resolution[1] = h;
diff --git a/gfx.h b/gfx.h
index 869287c58..747fdccd2 100644
--- a/gfx.h
+++ b/gfx.h
@@ -13,7 +13,7 @@ struct DrawPixelInfo {
byte *dst_ptr;
int left, top, width, height;
int pitch;
- uint16 zoom;
+ uint16 zoom;
};
@@ -47,8 +47,8 @@ int DrawString(int x, int y, uint16 str, byte color);
void DrawStringCenterUnderline(int x, int y, uint16 str, byte color);
int DoDrawString(const byte *string, int x, int y, byte color);
void DrawStringRightAligned(int x, int y, uint16 str, byte color);
-void GfxFillRect(int left, int top, int right, int bottom, int color);
-void GfxDrawLine(int left, int top, int right, int bottom, int color);
+void GfxFillRect(int left, int top, int right, int bottom, int color);
+void GfxDrawLine(int left, int top, int right, int bottom, int color);
void DrawFrameRect(int left, int top, int right, int bottom, int color, int flags);
int GetStringWidth(const byte *str);
diff --git a/graph_gui.c b/graph_gui.c
index 3c15e0adb..0562e333a 100644
--- a/graph_gui.c
+++ b/graph_gui.c
@@ -33,7 +33,7 @@ typedef struct GraphDrawer {
void DrawGraph(GraphDrawer *gw)
{
-
+
int i,j,k;
int x,y,old_x,old_y;
int color;
@@ -57,7 +57,7 @@ void DrawGraph(GraphDrawer *gw)
GfxFillRect(x, gw->top, x, bottom, color);
x += 22;
} while (--i);
-
+
/* draw the horizontal lines */
i = 9;
x = gw->left + 44;
@@ -95,7 +95,7 @@ void DrawGraph(GraphDrawer *gw)
}
} while (col_ptr++, --num_x);
} while (row_ptr+=24, --num_dataset);
-
+
/* setup scaling */
y_scaling = 0x80000000;
value = adj_height * 2;
@@ -271,10 +271,10 @@ static void SetupGraphDrawerForPlayers(GraphDrawer *gd)
int nums;
int mo,yr;
- // Exclude the players which aren't valid
+ // Exclude the players which aren't valid
FOR_ALL_PLAYERS(p) {
if (!p->is_active) CLRBIT(showbits,p->index);
- }
+ }
gd->sel = showbits;
gd->num_vert_lines = 24;
@@ -305,7 +305,7 @@ static void OperatingProfitWndProc(Window *w, WindowEvent *e)
int numd;
DrawWindowWidgets(w);
-
+
gd.left = 2;
gd.top = 18;
gd.height = 136;
@@ -314,7 +314,7 @@ static void OperatingProfitWndProc(Window *w, WindowEvent *e)
gd.color_3 = 0x10;
gd.color_2 = 0xD7;
gd.bg_line_color = 0xE;
-
+
SetupGraphDrawerForPlayers(&gd);
numd = 0;
@@ -528,13 +528,13 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
uint16 y=14;
int total_score = 0;
int color_done, color_notdone;
-
+
// Draw standard stuff
DrawWindowWidgets(w);
-
+
// The player of which we check the detail performance rating
owner = FindFirstBit(w->click_state) - 13;
-
+
// Paint the player icons
for (i=0;i<MAX_PLAYERS;i++) {
if (!DEREF_PLAYER(i)->is_active) {
@@ -550,7 +550,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
}
continue;
}
-
+
// Check if we have the player marked as inactive
if ((w->disabled_state & (1 << (i+13)))) {
// New player! Yippie :p
@@ -558,11 +558,11 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
// We need a repaint
SetWindowDirty(w);
}
-
+
if (i == owner) x = 1; else x = 0;
DrawPlayerIcon(i, i*33+11+x, 16+x);
}
-
+
// The colors used to show how the progress is going
color_done = _color_list[6].window_color_1b;
color_notdone = _color_list[4].window_color_1b;
@@ -579,44 +579,44 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
score = SCORE_MAX;
} else
total_score += score;
-
+
DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, 0);
// Draw the score
SET_DPARAM32(0, score);
DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
-
+
// Calculate the %-bar
if (val > needed) x = 50;
else if (val == 0) x = 0;
else x = ((val * 50) / needed);
-
+
// SCORE_LOAN is inversed
if (val < 0 && i == SCORE_LOAN)
x = 0;
-
+
// Draw the bar
if (x != 0)
GfxFillRect(112, y-2, x + 112, y+10, color_done);
if (x != 50)
GfxFillRect(x + 112, y-2, 50 + 112, y+10, color_notdone);
-
+
// Calculate the %
if (val > needed) x = 100;
else x = ((val * 100) / needed);
-
+
// SCORE_LOAN is inversed
if (val < 0 && i == SCORE_LOAN)
x = 0;
-
+
// Draw it
SET_DPARAM32(0, x);
DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, 0);
-
+
// SCORE_LOAN is inversed
if (i == SCORE_LOAN)
val = needed - val;
-
+
// Draw the amount we have against what is needed
// For some of them it is in currency format
SET_DPARAM32(0, val);
@@ -666,12 +666,12 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
FOR_ALL_PLAYERS(p2)
if (p2->is_active)
UpdateCompanyRatingAndValue(p2, false);
-
+
w->custom[0] = DAY_TICKS;
w->custom[1] = 5;
-
+
w->click_state = 1 << 13;
-
+
SetWindowDirty(w);
}
break;
@@ -927,7 +927,7 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
gd.month = 0xFF;
gd.unk61A = 10;
gd.unk61C = 10;
-
+
for(i=0; i!=NUM_CARGO; i++) {
gd.colors[i] = _cargo_legend_colors[i];
for(j=0; j!=20; j++) {
@@ -1031,14 +1031,14 @@ static void CompanyLeagueWndProc(Window *w, WindowEvent *e)
size_t pl_num, i;
DrawWindowWidgets(w);
-
+
pl_num=0;
FOR_ALL_PLAYERS(p) {
if (p->is_active)
plist[pl_num++] = p;
}
assert(pl_num > 0);
-
+
qsort(plist, pl_num, sizeof(Player*), _perf_hist_comp);
i = 0;
@@ -1047,12 +1047,12 @@ static void CompanyLeagueWndProc(Window *w, WindowEvent *e)
p = plist[i];
SET_DPARAM16(1, p->name_1);
SET_DPARAM32(2, p->name_2);
-
+
SET_DPARAM16(3, GetPlayerNameString(p->index, 4));
/* WARNING ugly hack!
GetPlayerNameString sets up (Player #) if the player is human in an extra DPARAM16
It seems that if player is non-human, nothing is set up, so param is 0. GetString doesn't like
- that because there is another param after it.
+ that because there is another param after it.
So we'll just shift the rating one back if player is AI and all is fine
*/
SET_DPARAM16((IS_HUMAN_PLAYER(p->index) ? 5 : 4), GetPerformanceTitleFromValue(p->old_economy[1].performance_history));
diff --git a/grfspecial.c b/grfspecial.c
index e0fc97130..7991ab6a3 100644
--- a/grfspecial.c
+++ b/grfspecial.c
@@ -465,20 +465,20 @@ static void VehicleChangeInfo(byte *buf, int len)
uint8 prop = grf_load_byte(&buf);
switch (prop) {
- case 0x00: {
+ case 0x00: {
/* Introduction date */
foreach_engine {
uint16 date = grf_load_word(&buf);
-
+
ei[i].base_intro = date;
}
break;
}
- case 0x02: {
+ case 0x02: {
/* Decay speed */
foreach_engine {
uint8 decay = grf_load_byte(&buf);
-
+
ei[i].unk2 &= 0x80;
ei[i].unk2 |= decay & 0x7f;
}
@@ -493,7 +493,7 @@ static void VehicleChangeInfo(byte *buf, int len)
}
break;
}
- case 0x04: {
+ case 0x04: {
/* Model life */
foreach_engine {
uint8 life = grf_load_byte(&buf);
@@ -512,7 +512,7 @@ static void VehicleChangeInfo(byte *buf, int len)
}
break;
}
- case 0x07: {
+ case 0x07: {
/* Loading speed */
/* Hyronymus explained me what does
* this mean and insists on having a
@@ -636,7 +636,7 @@ static void SpriteNewSuperset(byte *buf, int len)
uint8 nvar = buf[7];
//uint32 val;
uint16 def;
-
+
grfmsg(GMS_WARN, "SpriteNewSuperset(0x81): Unsupported variable %x. Using default cid.", var);
//val = (0xff << shiftnum) & andmask;
diff --git a/hal.h b/hal.h
index f7cf2312d..764e664e3 100644
--- a/hal.h
+++ b/hal.h
@@ -65,7 +65,7 @@ extern const HalVideoDriver _sdl_video_driver;
#if defined(UNIX)
extern const HalMusicDriver _extmidi_music_driver;
-#endif
+#endif
#if defined(__BEOS__)
extern const HalMusicDriver _bemidi_music_driver;
diff --git a/industry_gui.c b/industry_gui.c
index dd34a5711..cef336042 100644
--- a/industry_gui.c
+++ b/industry_gui.c
@@ -42,7 +42,7 @@ static void BuildIndustryWndProc(Window *w, WindowEvent *e)
if (DoCommandP(e->place.tile, _build_industry_types[_opt.landscape][WP(w,def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)))
ResetObjectToPlace();
break;
-
+
case WE_ABORT_PLACE_OBJ:
w->click_state = 0;
SetWindowDirty(w);
@@ -259,7 +259,7 @@ static const WindowDesc * const _industry_window_desc[2][4] = {
};
void ShowBuildIndustryWindow()
-{
+{
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt.landscape],0);
}
@@ -291,20 +291,20 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
}
DrawString(2, 107, str, 0);
}
-
+
if (i->produced_cargo[0] != 0xFF) {
DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0);
SET_DPARAM16(1, i->total_production[0]);
- SET_DPARAM16(0, _cargoc.names_long_s[i->produced_cargo[0]] + ((i->total_production[0]!=1)<<5));
+ SET_DPARAM16(0, _cargoc.names_long_s[i->produced_cargo[0]] + ((i->total_production[0]!=1)<<5));
SET_DPARAM16(2, i->pct_transported[0] * 100 >> 8);
DrawString(4, 127, STR_482B_TRANSPORTED, 0);
if (i->produced_cargo[1] != 0xFF) {
SET_DPARAM16(1, i->total_production[1]);
- SET_DPARAM16(0, _cargoc.names_long_s[i->produced_cargo[1]] + ((i->total_production[1]!=1)<<5));
+ SET_DPARAM16(0, _cargoc.names_long_s[i->produced_cargo[1]] + ((i->total_production[1]!=1)<<5));
SET_DPARAM16(2, i->pct_transported[1] * 100 >> 8);
- DrawString(4, 137, STR_482B_TRANSPORTED, 0);
+ DrawString(4, 137, STR_482B_TRANSPORTED, 0);
}
}
@@ -323,7 +323,7 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
/* passing only i->xy is not safe if industry has a weird shape like:
_ X X
X X X
- _ <--- grass, no industry, but i->xy points there (first top-left tile)!,
+ _ <--- grass, no industry, but i->xy points there (first top-left tile)!,
so passing i->xy to destroy industry will fail in called procedure
*/
//DoCommandP(i->xy, w->window_number, 0, CcPlaySound10, CMD_DESTROY_INDUSTRY | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
@@ -399,7 +399,7 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
switch (_industry_sort_order >> 1) {
/* case 0: Sort by Name (handled later) */
case 1: /* Sort by Type */
- r = i->type - j->type;
+ r = i->type - j->type;
break;
// FIXME - Production & Transported sort need to be inversed...but, WTF it does not wanna!
// FIXME - And no simple --> "if (!(_industry_sort_order & 1)) r = -r;" hack at the bottom!!
@@ -407,7 +407,7 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
if (i->produced_cargo[0] != 0xFF && j->produced_cargo[0] != 0xFF) { // both industries produce cargo?
if (i->produced_cargo[1] == 0xFF) // producing one or two things?
r = j->total_production[0] - i->total_production[0];
- else
+ else
r = (j->total_production[0] + j->total_production[1]) / 2 - (i->total_production[0] + i->total_production[1]) / 2;
} else if (i->produced_cargo[0] == 0xFF && j->produced_cargo[0] == 0xFF) // none of them producing anything, let them go to the name-sorting
r = 0;
@@ -421,7 +421,7 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
if (i->produced_cargo[0] != 0xFF && j->produced_cargo[0] != 0xFF) { // both industries produce cargo?
if (i->produced_cargo[1] == 0xFF) // producing one or two things?
r = (j->pct_transported[0] * 100 >> 8) - (i->pct_transported[0] * 100 >> 8);
- else
+ else
r = ((j->pct_transported[0] * 100 >> 8) + (j->pct_transported[1] * 100 >> 8)) / 2 - ((i->pct_transported[0] * 100 >> 8) + (i->pct_transported[1] * 100 >> 8)) / 2;
} else if (i->produced_cargo[0] == 0xFF && j->produced_cargo[0] == 0xFF) // none of them producing anything, let them go to the name-sorting
r = 0;
@@ -444,8 +444,8 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
}
r = strcmp(buf1, _bufcache);
}
-
- if (_industry_sort_order & 1) r = -r;
+
+ if (_industry_sort_order & 1) r = -r;
return r;
}
@@ -496,7 +496,7 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
if (i->produced_cargo[0] != 0xFF) {
SET_DPARAM16(3, i->total_production[0] * 100 >> 8);
SET_DPARAM16(2, _cargoc.names_long_s[i->produced_cargo[0]] + ((i->total_production[0]!=1)<<5));
-
+
if (i->produced_cargo[1] != 0xFF) {
SET_DPARAM16(5, i->total_production[1] * 100 >> 8);
SET_DPARAM16(4, _cargoc.names_long_s[i->produced_cargo[1]] + ((i->total_production[1]!=1)<<5));
@@ -541,7 +541,7 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
_industry_sort_dirty = true;
SetWindowDirty(w);
} break;
-
+
case 7: {
int y = (e->click.pt.y - 28) / 10;
byte p;
@@ -561,7 +561,7 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
case WE_4:
SetWindowDirty(w);
break;
- }
+ }
}
diff --git a/intro_gui.c b/intro_gui.c
index bed74ffbf..00ea3f105 100644
--- a/intro_gui.c
+++ b/intro_gui.c
@@ -54,7 +54,7 @@ static void SelectGameWndProc(Window *w, WindowEvent *e) {
case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
case 4: ShowPatchesSelection(); break;
case 5: DoCommandP(0, InteractiveRandom(), 0, NULL, CMD_CREATE_SCENARIO); break;
- case 6:
+ case 6:
if (_networking)
DoCommandP(0, 0, 0, NULL, CMD_SET_SINGLE_PLAYER);
break;
@@ -113,7 +113,7 @@ int32 CmdStartNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2)
DeleteWindowById(WC_SAVELOAD, 0);
break;
}
-
+
return 0;
}
@@ -216,7 +216,7 @@ static void AskAbandonGameWndProc(Window *w, WindowEvent *e) {
case WE_KEYPRESS: /* Exit game on pressing 'Enter' */
if (e->keypress.keycode == WKC_RETURN)
_exit_game = true;
- break;
+ break;
}
}
@@ -247,9 +247,9 @@ static void AskQuitGameWndProc(Window *w, WindowEvent *e) {
switch(e->event) {
case WE_PAINT:
DrawWindowWidgets(w);
- DrawStringMultiCenter(0x5A, 0x26,
- _game_mode != GM_EDITOR ? STR_0160_ARE_YOU_SURE_YOU_WANT_TO :
- STR_029B_ARE_YOU_SURE_YOU_WANT_TO,
+ DrawStringMultiCenter(0x5A, 0x26,
+ _game_mode != GM_EDITOR ? STR_0160_ARE_YOU_SURE_YOU_WANT_TO :
+ STR_029B_ARE_YOU_SURE_YOU_WANT_TO,
178);
return;
diff --git a/macros.h b/macros.h
index bd89d6803..9669431ce 100644
--- a/macros.h
+++ b/macros.h
@@ -3,7 +3,7 @@
#define MAX_INT 0x7FFFFFFF
-#ifdef min
+#ifdef min
#undef min
#endif
@@ -35,7 +35,7 @@ static INLINE bool str_eq(const byte *a, const byte *b)
}
// Will crash if strings are equal
-static INLINE bool str_is_below(byte *a, byte *b) {
+static INLINE bool str_is_below(byte *a, byte *b) {
while (*a <= *b) {
if (*a < *b) return true;
a++;
@@ -152,7 +152,7 @@ static INLINE int FindFirstBit2x64(int value)
#if TILE_X_BITS + TILE_Y_BITS <= 16
- typedef uint16 TileIndex;
+ typedef uint16 TileIndex;
typedef int16 TileIndexDiff;
#else
typedef uint32 TileIndex;
@@ -210,7 +210,7 @@ static INLINE void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a
static INLINE uint16 READ_LE_UINT16(const void *b) {
return ((byte*)b)[0] + (((byte*)b)[1] << 8);
}
-# define ADD_WORD(x) ((x) >> 8)&0xFF, (x)&0xFF
+# define ADD_WORD(x) ((x) >> 8)&0xFF, (x)&0xFF
# define ADD_DWORD(x) ((x) >> 24)&0xFF, ((x) >> 16)&0xFF, ((x) >> 8)&0xFF, (x)&0xFF
#endif
diff --git a/main_gui.c b/main_gui.c
index 3ddd5ceb1..a7a8adef4 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -36,7 +36,7 @@ static void HandleOnEditText(WindowEvent *e) {
memcpy(_decode_parameters, b, 32);
id = _rename_id;
-
+
switch(_rename_what) {
case 0:
// for empty string send "remove sign" parameter
@@ -188,7 +188,7 @@ void MenuClickCompany(int index)
{
ShowPlayerCompany(index);
}
-
+
void MenuClickGraphs(int index)
{
@@ -403,11 +403,11 @@ static void MenuWndProc(Window *w, WindowEvent *e)
SetWindowDirty(v);
return;
}
-
+
case WE_POPUPMENU_SELECT: {
int index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y);
int action_id;
-
+
if (index < 0) {
Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
@@ -417,10 +417,10 @@ static void MenuWndProc(Window *w, WindowEvent *e)
action_id = WP(w,menu_d).action_id;
DeleteWindow(w);
-
+
if (index >= 0)
_menu_clicked_procs[action_id](index);
-
+
break;
}
case WE_POPUPMENU_OVER: {
@@ -458,7 +458,7 @@ static int GetPlayerIndexFromMenu(int index)
if (--index < 0)
return p->index;
}
- }
+ }
}
return -1;
}
@@ -472,7 +472,7 @@ static void UpdatePlayerMenuHeight(Window *w)
if (p->is_active)
num++;
}
-
+
if (WP(w,menu_d).item_count != num) {
WP(w,menu_d).item_count = num;
SetWindowDirty(w);
@@ -499,25 +499,25 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e)
y = 1;
sel = WP(w,menu_d).sel_index;
chk = WP(w,menu_d).checked_items; // let this mean gray items.
-
+
FOR_ALL_PLAYERS(p) {
if (p->is_active) {
if (p->index == sel) {
GfxFillRect(x, y, x + 0xEE, y + 9, 0);
}
DrawSprite( ((p->player_color + 0x307)<<16)+0x82EB, x+2, y+1);
-
+
SET_DPARAM16(0, p->name_1);
SET_DPARAM32(1, p->name_2);
SET_DPARAM16(2, GetPlayerNameString(p->index, 3));
-
+
color = (byte)((p->index==sel) ? 0xC : 0x10);
if (chk&1) color = 14;
DrawString(x+0x13, y, STR_7021, color);
-
+
y += 10;
- }
- chk >>= 1;
+ }
+ chk >>= 1;
}
break;
}
@@ -528,7 +528,7 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e)
SetWindowDirty(v);
return;
}
-
+
case WE_POPUPMENU_SELECT: {
int index = GetPlayerIndexFromMenu(GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y));
int action_id = WP(w,menu_d).action_id;
@@ -540,7 +540,7 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e)
}
DeleteWindow(w);
-
+
if (index >= 0) {
assert(index >= 0 && index < 30);
_menu_clicked_procs[action_id](index);
@@ -576,7 +576,7 @@ static Window *PopupMainToolbMenu(Window *w, int x, int main_button, StringID ba
_menu_widgets[0].bottom = h = item_count * 10 + 1;
w = AllocateWindow(x, 0x16, 0xA0, h+1, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
w->flags4 &= ~WF_WHITE_BORDER_MASK;
-
+
WP(w,menu_d).item_count = item_count;
WP(w,menu_d).sel_index = 0;
WP(w,menu_d).main_button = main_button;
@@ -585,7 +585,7 @@ static Window *PopupMainToolbMenu(Window *w, int x, int main_button, StringID ba
WP(w,menu_d).checked_items = 0;
_popup_menu_active = true;
-
+
SndPlayFx(0x13);
return w;
@@ -594,7 +594,7 @@ static Window *PopupMainToolbMenu(Window *w, int x, int main_button, StringID ba
static Window *PopupMainPlayerToolbMenu(Window *w, int x, int main_button, int gray)
{
x += w->left;
-
+
SETBIT(w->click_state, main_button);
InvalidateWidget(w, main_button);
@@ -703,7 +703,7 @@ bool DoZoomInOutWindow(int how, Window *w)
{
ViewPort *vp;
int button;
-
+
switch(_game_mode) {
case GM_EDITOR: button = 9; break;
case GM_NORMAL: button = 17; break;
@@ -758,7 +758,7 @@ bool DoZoomInOutWindow(int how, Window *w)
else if (vp->zoom == 2) SETBIT(wt->disabled_state, button + 1);
SetWindowDirty(wt);
}
-
+
return true;
}
@@ -855,7 +855,7 @@ static void ToolbarScenDateBackward(Window *w)
if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
HandleButtonClick(w, 6);
InvalidateWidget(w, 5);
-
+
if (_date > 0x2ACE) {
SetDate(ConvertYMDToDay(_cur_year - 1, 0, 1));
}
@@ -898,7 +898,7 @@ static void ToolbarScenZoomOut(Window *w)
}
}
-void ZoomInOrOutToCursorWindow(bool in, Window *w)
+void ZoomInOrOutToCursorWindow(bool in, Window *w)
{
ViewPort * vp;
Point pt;
@@ -924,10 +924,10 @@ void ResetLandscape()
{
_random_seed_1 = InteractiveRandom();
_random_seed_2 = InteractiveRandom();
-
+
GenerateWorld(1);
MarkWholeScreenDirty();
-}
+}
static const Widget _ask_reset_landscape_widgets[] = {
{ WWT_TEXTBTN, 4, 0, 10, 0, 13, STR_00C5, STR_NULL},
@@ -961,7 +961,7 @@ static void AskResetLandscapeWndProc(Window *w, WindowEvent *e)
SndPlayFx(0x13);
_switch_mode = SM_GENRANDLAND;
}
-
+
break;
}
}
@@ -1131,7 +1131,7 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
case WE_PAINT:
// XXX: only show reset button when nothing was built
DrawWindowWidgets(w);
-
+
{
int n = _terraform_size * _terraform_size;
const int8 *coords = &_multi_terraform_coords[0][0];
@@ -1190,7 +1190,7 @@ terraform_size_common:;
case 10: /* place rocky areas */
HandlePlacePushButton(w, 10, 0xFF7, 1, PlaceProc_RockyArea);
break;
-
+
case 11: /* place lighthouse */
HandlePlacePushButton(w, 11, 0xFF8, 1, _opt.landscape == LT_DESERT ? PlaceProc_Desert : PlaceProc_LightHouse);
break;
@@ -1493,7 +1493,7 @@ static void ScenEditIndustryWndProc(Window *w, WindowEvent *e)
break;
case WE_CLICK:
- if ((button=e->click.widget) == 3) {
+ if ((button=e->click.widget) == 3) {
HandleButtonClick(w, 3);
if (!AnyTownExists()) {
@@ -1505,7 +1505,7 @@ static void ScenEditIndustryWndProc(Window *w, WindowEvent *e)
GenerateIndustries();
_generating_world = false;
}
-
+
if ((button=e->click.widget) >= 4) {
if (HandlePlacePushButton(w, button, 0xFF1, 1, NULL))
_industry_type_to_place = _industry_type_list[_opt.landscape][button - 4];
@@ -1705,7 +1705,7 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
case WKC_CTRL | WKC_ALT | 'C': if(!_networking) ShowCheatWindow(); break;
}
} break;
-
+
case WE_PLACE_OBJ: {
_place_proc(e->place.tile);
} break;
@@ -1718,12 +1718,12 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break;
case WE_MOUSELOOP:
-
+
if (((w->click_state) & 1) != (uint)!!_pause) {
w->click_state ^= (1 << 0);
SetWindowDirty(w);
}
-
+
if (((w->click_state >> 1) & 1) != (uint)!!_fast_forward) {
w->click_state ^= (1 << 1);
SetWindowDirty(w);
@@ -1900,7 +1900,7 @@ static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
}
break;
}
-
+
case WE_PLACE_OBJ: {
_place_proc(e->place.tile);
} break;
@@ -1950,7 +1950,7 @@ static bool DrawScrollingStatusText(NewsItem *ni, int pos)
str = _get_news_string_callback[ni->callback](ni);
} else {
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params));
- str = ni->string_id;
+ str = ni->string_id;
}
GetString(str_buffr, str);
@@ -1992,7 +1992,7 @@ void StatusBarWndProc(Window *w, WindowEvent *e)
DrawWindowWidgets(w);
SET_DPARAM16(0, _date);
DrawStringCentered(70, 1, ((_pause||_patches.status_long_date)?STR_00AF:STR_00AE), 0);
-
+
p = _local_player == OWNER_SPECTATOR ? NULL : DEREF_PLAYER(_local_player);
if (p) {
@@ -2092,7 +2092,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) {
DrawSprite(0x12EA, off_x+275,50); // o
DrawSprite(0x12E5, off_x+307,50); // r
DrawSprite(0x12E4, off_x+337,50); // t
-
+
DrawSprite(0x12E4, off_x+390,50); // t
DrawSprite(0x12EB, off_x+417,50); // y
DrawSprite(0x12EC, off_x+447,50); // c
@@ -2146,7 +2146,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) {
}
break;
}
-
+
case WKC_ESC: ResetObjectToPlace(); break;
case WKC_DELETE: DeleteNonVitalWindows(); break;
case 'Q' | WKC_CTRL: AskExitGame(); break;
@@ -2185,7 +2185,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) {
}
e->keypress.cont = false;
break;
-
+
}
}
@@ -2224,7 +2224,7 @@ void SetupColorsAndInitialWindow()
w = AllocateWindowDesc(&_toolb_normal_desc);
w->disabled_state = 1 << 17;
w->flags4 &= ~WF_WHITE_BORDER_MASK;
-
+
PositionMainToolbar(w); // already WC_MAIN_TOOLBAR passed (&_toolb_normal_desc)
_main_status_desc.top = height - 12;
@@ -2241,7 +2241,7 @@ void SetupColorsAndInitialWindow()
w = AllocateWindowDesc(&_toolb_scen_desc);
w->disabled_state = 1 << 9;
w->flags4 &= ~WF_WHITE_BORDER_MASK;
-
+
PositionMainToolbar(w); // already WC_MAIN_TOOLBAR passed (&_toolb_scen_desc)
break;
default:
diff --git a/misc_cmd.c b/misc_cmd.c
index 5015d37bf..f592c08ce 100644
--- a/misc_cmd.c
+++ b/misc_cmd.c
@@ -39,7 +39,7 @@ int32 CmdSetPlayerColor(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (pp->is_active && pp != p && pp->player_color == (byte)p2)
return CMD_ERROR;
}
-
+
if (flags & DC_EXEC) {
_player_colors[p1] = (byte)p2;
p->player_color = (byte)p2;
@@ -126,7 +126,7 @@ int32 CmdChangeCompanyName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
str = AllocateName((byte*)_decode_parameters, 4);
if (str == 0)
return CMD_ERROR;
-
+
if (flags & DC_EXEC) {
p = DEREF_PLAYER(p1);
old_str = p->name_1;
@@ -148,7 +148,7 @@ int32 CmdChangePresidentName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
str = AllocateName((byte*)_decode_parameters, 4);
if (str == 0)
return CMD_ERROR;
-
+
if (flags & DC_EXEC) {
p = DEREF_PLAYER(p1);
old_str = p->president_name_1;
@@ -161,13 +161,13 @@ int32 CmdChangePresidentName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
d--; do d++; while (*d);
do *d++ = b = *s++; while(d != (byte*)endof(_decode_parameters) && b != 0);
DoCommandByTile(0, p1, 0, DC_EXEC, CMD_CHANGE_COMPANY_NAME);
- }
+ }
MarkWholeScreenDirty();
} else {
DeleteName(str);
}
- return 0;
+ return 0;
}
static void UpdateSignVirtCoords(SignStruct *ss)
@@ -200,7 +200,7 @@ static void MarkSignDirty(SignStruct *ss)
int32 CmdPlaceSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
SignStruct *ss;
-
+
for(ss=_sign_list; ss != endof(_sign_list); ss++) {
if (ss->str == 0) {
if (flags & DC_EXEC) {
@@ -213,7 +213,7 @@ int32 CmdPlaceSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
_new_sign_struct = ss;
}
return 0;
- }
+ }
}
return_cmd_error(STR_2808_TOO_MANY_SIGNS);
@@ -275,7 +275,7 @@ int32 CmdResume(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 CmdMoneyCheat(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
- SET_EXPENSES_TYPE(EXPENSES_OTHER);
+ SET_EXPENSES_TYPE(EXPENSES_OTHER);
return (int32)p1;
}
@@ -290,7 +290,7 @@ int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
- return 0;
+ return 0;
}
static const byte _sign_desc[] = {
diff --git a/misc_gui.c b/misc_gui.c
index cd6d7cee7..a1a8d9f5c 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -45,7 +45,7 @@ static void LandInfoWndProc(Window *w, WindowEvent *e)
str = STR_01A4_COST_TO_CLEAR_N_A;
if (lid->costclear != CMD_ERROR) {
- SET_DPARAM32(0, lid->costclear);
+ SET_DPARAM32(0, lid->costclear);
str = STR_01A5_COST_TO_CLEAR;
}
DrawStringCentered(140, 38, str, 0);
@@ -102,7 +102,7 @@ static void LandInfoWndProc(Window *w, WindowEvent *e)
if (str != (STR_01CE_CARGO_ACCEPTED - 1))
DrawStringMultiCenter(140, 76, str, 276);
-
+
if (lid->td.build_date != 0) {
SET_DPARAM16(0,lid->td.build_date);
DrawStringCentered(140,71, STR_BUILD_DATE, 0);
@@ -136,7 +136,7 @@ static void Place_LandInfo(uint tile)
w = AllocateWindowDesc(&_land_info_desc);
WP(w,void_d).data = &lid;
-
+
lid.tile = tile;
lid.town = ClosestTownFromTile(tile, _patches.dist_local_authority);
@@ -150,13 +150,13 @@ static void Place_LandInfo(uint tile)
lid.costclear = DoCommandByTile(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
p->money64 = old_money;
UpdatePlayerMoney32(p);
-
+
// Becuase build_date is not set yet in every TileDesc, we make sure it is empty
lid.td.build_date = 0;
-
+
GetAcceptedCargo(tile, &lid.ac);
GetTileDesc(tile, &lid.td);
-
+
#if defined(_DEBUG)
DEBUG(misc, 0) ("TILE: %#x (%i,%i)", tile, GET_TILE_X(tile), GET_TILE_Y(tile));
DEBUG(misc, 0) ("TILE: %d ", tile);
@@ -273,7 +273,7 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
case 11:case 12: case 13: case 14:
if ( (uint)(wid-3) >= (uint)WP(w,tree_d).count)
return;
-
+
if (HandlePlacePushButton(w, wid, 0x7DA, 1, NULL))
_tree_to_plant = WP(w,tree_d).base + wid - 3;
break;
@@ -292,7 +292,7 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
break;
}
} break;
-
+
case WE_PLACE_OBJ:
VpStartPlaceSizing(e->place.tile, VPM_X_AND_Y_LIMITED);
VpSetPlaceSizingLimit(20);
@@ -304,7 +304,7 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
case WE_PLACE_MOUSEUP:
if (e->click.pt.x != -1) {
- DoCommandP(e->place.tile, _tree_to_plant, e->place.starttile, NULL,
+ DoCommandP(e->place.tile, _tree_to_plant, e->place.starttile, NULL,
CMD_PLANT_TREE | CMD_AUTO | CMD_MSG(STR_2805_CAN_T_PLANT_TREE_HERE));
}
break;
@@ -377,7 +377,7 @@ static const WindowDesc _build_trees_scen_desc = {
BuildTreesWndProc
};
-
+
void ShowBuildTreesToolbar()
{
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
@@ -418,7 +418,7 @@ static void ErrmsgWndProc(Window *w, WindowEvent *e)
if (w->widget != _errmsg_face_widgets) {
DrawStringMultiCenter(
120,
- (_errmsg_message_1 == INVALID_STRING_ID ? 25 : 15),
+ (_errmsg_message_1 == INVALID_STRING_ID ? 25 : 15),
_errmsg_message_2,
238);
if (_errmsg_message_1 != INVALID_STRING_ID)
@@ -433,7 +433,7 @@ static void ErrmsgWndProc(Window *w, WindowEvent *e)
DrawStringMultiCenter(
214,
- (_errmsg_message_1 == INVALID_STRING_ID ? 65 : 45),
+ (_errmsg_message_1 == INVALID_STRING_ID ? 65 : 45),
_errmsg_message_2,
238);
if (_errmsg_message_1 != INVALID_STRING_ID)
@@ -490,7 +490,7 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
_errmsg_duration = _patches.errmsg_duration;
if (!_errmsg_duration)
return;
-
+
if (_errmsg_message_1 != STR_013B_OWNED_BY || GET_DPARAMX8(_errmsg_decode_params,2) >= 8) {
if ( (x|y) != 0) {
@@ -501,11 +501,11 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
// move x pos to opposite corner
pt.x = ((pt.x - vp->virtual_left) >> vp->zoom) + vp->left;
pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - 260 : 20;
-
+
// move y pos to opposite corner
pt.y = ((pt.y - vp->virtual_top) >> vp->zoom) + vp->top;
pt.y = (pt.y < (_screen.height >> 1)) ? _screen.height - 80 : 100;
-
+
} else {
pt.x = (_screen.width - 240) >> 1;
pt.y = (_screen.height - 46) >> 1;
@@ -566,7 +566,7 @@ static void TooltipsWndProc(Window *w, WindowEvent *e)
switch(e->event) {
case WE_PAINT: {
- GfxFillRect(0, 0, w->width - 1, w->height - 1, 0);
+ GfxFillRect(0, 0, w->width - 1, w->height - 1, 0);
GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44);
DrawStringMultiCenter((w->width>>1), (w->height>>1)-5, WP(w,tooltips_d).string_id, 197);
break;
@@ -583,7 +583,7 @@ void GuiShowTooltips(StringID string_id)
Window *w;
int right,bottom;
int x,y;
-
+
if (string_id == 0)
return;
@@ -628,7 +628,7 @@ static void DrawStationCoverageText(const uint *accepts, int str_x, int str_y, u
{
int i;
byte *b;
-
+
b = _userstring;
b[0] = 0x81;
b[1] = STR_000D_ACCEPTS;
@@ -734,7 +734,7 @@ int HandleEditBoxKey(Window *w, int wid, WindowEvent *we)
count++;
width += _stringwidth_table[*p - 32];
} while (1);
-
+
if (we->keypress.keycode == WKC_BACKSPACE) {
if (count != 0) {
WP(w,querystr_d).buf[count-1] = 0;
@@ -1067,7 +1067,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
return;
file = _fios_list + y;
-
+
if ((name = FiosBrowseTo(file)) != NULL) {
if (_saveload_mode == SLD_LOAD_GAME) {
_switch_mode = SM_LOAD;
@@ -1120,7 +1120,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
_query_string_active = false;
FiosFreeSavegameList();
break;
- }
+ }
}
static const WindowDesc _load_dialog_desc = {
@@ -1226,7 +1226,7 @@ static void SelectScenarioWndProc(Window *w, WindowEvent *e) {
_savegame_sort_dirty = false;
MakeSortedSaveGameList();
}
-
+
SetVScrollCount(w, _fios_num);
DrawWindowWidgets(w);
@@ -1272,7 +1272,7 @@ static void SelectScenarioWndProc(Window *w, WindowEvent *e) {
return;
file = _fios_list + y;
-
+
if ((name = FiosBrowseTo(file)) != NULL) {
SetFiosType(file->type);
strcpy(_file_to_saveload.name, name);
@@ -1410,7 +1410,7 @@ static int32 ReadCE(const CheatEntry*ce)
default:
NOT_REACHED();
}
-
+
/* useless, but avoids compiler warning this way */
return 0;
}
@@ -1490,7 +1490,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
DrawFrameRect(x+30, y+1, x+30+9, y+9, 3, clk == i*2+2 ? 0x20 : 0);
DrawStringCentered(x+25, y+1, STR_6819, 0);
DrawStringCentered(x+35, y+1, STR_681A, 0);
-
+
val = ReadCE(ce);
// set correct string for switch climate cheat
@@ -1502,7 +1502,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
// display date for change date cheat
if(ce->str==STR_CHEAT_CHANGE_DATE)
SET_DPARAM16(0, _date);
-
+
// draw colored flag for change player cheat
if(ce->str==STR_CHEAT_CHANGE_PLAYER)
DrawPlayerIcon(_current_player, 156, y+2);
@@ -1579,7 +1579,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
WP(w,def_d).data_1 = 0;
SetWindowDirty(w);
break;
- }
+ }
}
static const WindowDesc _cheats_desc = {
240, 22, 400, 148,
@@ -1593,7 +1593,7 @@ static const WindowDesc _cheats_desc = {
void ShowCheatWindow()
{
Window *w;
-
+
DeleteWindowById(WC_CHEATS, 0);
w = AllocateWindowDesc(&_cheats_desc);
diff --git a/music_gui.c b/music_gui.c
index dc5c497e7..212fd67c8 100644
--- a/music_gui.c
+++ b/music_gui.c
@@ -44,7 +44,7 @@ static void SkipToPrevSong()
// empty playlist
if (b[0] == 0)
return;
-
+
// find the end
do p++; while (p[0] != 0);
@@ -132,7 +132,7 @@ static void PlayPlaylistSong()
_music_wnd_cursong = _cur_playlist[0];
DoPlaySong();
_song_is_active = true;
-
+
InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9);
}
@@ -190,7 +190,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
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);
DrawStringCentered(216, 45+8*6+16*2, STR_01F1_SAVE, 0);
y = 23;
@@ -203,7 +203,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
}
break;
}
-
+
case WE_CLICK:
switch(e->click.widget) {
case 3: { /* add to playlist */
@@ -321,7 +321,7 @@ static void MusicWindowWndProc(Window *w, WindowEvent *e)
DrawString(60, 38, STR_01E8_TRACK_XTITLE, 0);
-
+
for(i=0; i!=6; i++) {
DrawStringCentered(25+i*50, 59, STR_01D5_ALL+i, msf.playlist == i ? 0xC : 0x10);
}
@@ -336,14 +336,14 @@ static void MusicWindowWndProc(Window *w, WindowEvent *e)
DrawFrameRect(108, 23, 174, 26, 14, 0x20);
DrawFrameRect(214, 23, 280, 26, 14, 0x20);
- DrawFrameRect(108 + (msf.music_vol>>1),
+ DrawFrameRect(108 + (msf.music_vol>>1),
22,
111 + (msf.music_vol>>1),
28,
14,
0);
- DrawFrameRect(214 + (msf.effect_vol>>1),
+ DrawFrameRect(214 + (msf.effect_vol>>1),
22,
217 + (msf.effect_vol>>1),
28,
@@ -371,7 +371,7 @@ static void MusicWindowWndProc(Window *w, WindowEvent *e)
break;
case 6:{ // volume sliders
byte *vol,new_vol;
- int x = e->click.pt.x - 88;
+ int x = e->click.pt.x - 88;
if (x < 0)
return;
diff --git a/namegen.c b/namegen.c
index 2fa8d5f93..e762114c0 100644
--- a/namegen.c
+++ b/namegen.c
@@ -11,7 +11,7 @@ static void AppendPart(byte **buf, int num, const char *names)
while (--num>=0) {
do names++; while (names[-1]);
}
-
+
for(s=*buf; (*s++ = *names++) != 0;) {}
*buf = s - 1;
}
@@ -19,14 +19,14 @@ static void AppendPart(byte **buf, int num, const char *names)
#define MK(x) x "\x0"
#define NUM_ENGLISH_1 4
-static const char english_1[] =
+static const char english_1[] =
MK("Great ")
MK("Little ")
MK("New ")
MK("Fort ")
;
-#define NUM_ENGLISH_2 26
+#define NUM_ENGLISH_2 26
static const char english_2[] =
MK("Wr")
MK("B")
@@ -57,7 +57,7 @@ static const char english_2[] =
;
#define NUM_ENGLISH_3 8
-static const char english_3[] =
+static const char english_3[] =
MK("ar")
MK("a")
MK("e")
@@ -69,7 +69,7 @@ static const char english_3[] =
;
#define NUM_ENGLISH_4 7
-static const char english_4[] =
+static const char english_4[] =
MK("n")
MK("ning")
MK("ding")
@@ -80,7 +80,7 @@ static const char english_4[] =
;
#define NUM_ENGLISH_5 23
-static const char english_5[] =
+static const char english_5[] =
MK("ville")
MK("ham")
MK("field")
@@ -107,7 +107,7 @@ static const char english_5[] =
;
#define NUM_ENGLISH_6 9
-static const char english_6[] =
+static const char english_6[] =
MK("-on-sea")
MK(" Bay")
MK(" Market")
@@ -130,7 +130,7 @@ static byte MakeEnglishTownName(byte *buf, uint32 seed)
i = GETNUM(0, 54) - 50;
if (i >= 0)
AppendPart(&buf, i, english_1);
-
+
start = buf;
AppendPart(&buf, GETNUM(4, NUM_ENGLISH_2), english_2);
@@ -141,14 +141,14 @@ static byte MakeEnglishTownName(byte *buf, uint32 seed)
i = GETNUM(15, NUM_ENGLISH_6 + 60) - 60;
result = 0;
-
+
if (i >= 0) {
if (i <= 1) result = NG_EDGE;
AppendPart(&buf, i, english_6);
}
if (start[0]=='C' && (start[1] == 'e' || start[1] == 'i'))
- start[0] = 'K';
+ start[0] = 'K';
/* Replace certain words (routine identical to TTD now) */
@@ -167,7 +167,7 @@ static byte MakeEnglishTownName(byte *buf, uint32 seed)
}
#define NUM_AUSTRIAN_A1 6
-static const char austrian_a1[] =
+static const char austrian_a1[] =
MK("Bad ")
MK("Deutsch ")
MK("Gross ")
@@ -177,7 +177,7 @@ static const char austrian_a1[] =
;
#define NUM_AUSTRIAN_A2 42
-static const char austrian_a2[] =
+static const char austrian_a2[] =
MK("Aus")
MK("Alten")
MK("Braun")
@@ -223,7 +223,7 @@ static const char austrian_a2[] =
;
#define NUM_AUSTRIAN_A3 16
-static const char austrian_a3[] =
+static const char austrian_a3[] =
MK("see")
MK("bach")
MK("dorf")
@@ -371,8 +371,8 @@ static byte MakeAustrianTownName(byte *buf, uint32 seed)
}
#define NUM_GERMAN_1 114
-#define NUM_GERMAN_1_HARDCODED 21
-static const char german_1[] =
+#define NUM_GERMAN_1_HARDCODED 21
+static const char german_1[] =
/* hardcoded names */
MK("Berlin")
MK("Bonn")
@@ -531,14 +531,14 @@ static const char german_4[] =
MK("Elbe")
/* use "am" */
MK("Main")
-
+
;
static byte MakeGermanTownName(byte *buf, uint32 seed)
{
int i;
int ext;
-
+
ext=GETNUM(7, 28); /* Extension - Prefix / Suffix */
if ((ext==12) || (ext==19)) {
@@ -571,7 +571,7 @@ static byte MakeGermanTownName(byte *buf, uint32 seed)
}
#define NUM_SPANISH_1 86
-static const char spanish_1[] =
+static const char spanish_1[] =
MK("Caracas")
MK("Maracay")
MK("Maracaibo")
@@ -662,11 +662,11 @@ static const char spanish_1[] =
static byte MakeSpanishTownName(byte *buf, uint32 seed)
{
AppendPart(&buf, GETNUM(0, NUM_SPANISH_1), spanish_1);
- return 0;
+ return 0;
}
#define NUM_FRENCH_1 70
-static const char french_1[] =
+static const char french_1[] =
MK("Agincourt")
MK("Lille")
MK("Dinan")
@@ -684,7 +684,7 @@ static const char french_1[] =
MK("St. Tropez")
MK("Marseilles")
MK("Narbonne")
- MK("Sète")
+ MK("Sète")
MK("Aurillac")
MK("Gueret")
MK("Le Creusot")
@@ -751,7 +751,7 @@ static byte MakeAmericanTownName(byte *buf, uint32 seed)
}
#define NUM_SILLY_1 88
-static const char silly_1[] =
+static const char silly_1[] =
MK("Binky")
MK("Blubber")
MK("Bumble")
@@ -851,7 +851,7 @@ static const char silly_1[] =
;
#define NUM_SILLY_2 15
-static const char silly_2[] =
+static const char silly_2[] =
MK("ton")
MK("bury")
MK("bottom")
@@ -862,7 +862,7 @@ static const char silly_2[] =
MK("wig")
MK("wick")
MK("wood")
-
+
MK("pool")
MK("head")
MK("burg")
@@ -872,7 +872,7 @@ static const char silly_2[] =
static byte MakeSillyTownName(byte *buf, uint32 seed)
-{
+{
AppendPart(&buf, GETNUM(0, NUM_SILLY_1), silly_1);
AppendPart(&buf, GETNUM(16, NUM_SILLY_2),silly_2);
return 0;
@@ -1081,7 +1081,7 @@ static const char dutch_1[] =
MK("Klein ");
#define NUM_DUTCH_2 57
-static const char dutch_2[] =
+static const char dutch_2[] =
MK("Hoog")
MK("Laag")
MK("Klein")
@@ -1141,7 +1141,7 @@ static const char dutch_2[] =
MK("Hil");
#define NUM_DUTCH_3 20
-static const char dutch_3[] =
+static const char dutch_3[] =
MK("Drog")
MK("Nat")
MK("Valk")
@@ -1162,10 +1162,10 @@ static const char dutch_3[] =
MK("Wams")
MK("Heerhug")
MK("Koning");
-
+
#define NUM_DUTCH_4 6
-static const char dutch_4[] =
+static const char dutch_4[] =
MK("e")
MK("er")
MK("el")
@@ -1174,7 +1174,7 @@ static const char dutch_4[] =
MK("s");
#define NUM_DUTCH_5 56
-static const char dutch_5[] =
+static const char dutch_5[] =
MK("stad")
MK("vorst")
MK("dorp")
@@ -1231,13 +1231,13 @@ static const char dutch_5[] =
MK("schede")
MK("mere")
MK("end");
-
+
static byte MakeDutchTownName(byte *buf, uint32 seed)
{
int i;
i = GETNUM(0, 50 + NUM_DUTCH_1) - 50;
- if (i >= 0)
+ if (i >= 0)
AppendPart(&buf, i, dutch_1);
i = GETNUM(6, 9);
@@ -1253,7 +1253,7 @@ static byte MakeDutchTownName(byte *buf, uint32 seed)
}
#define NUM_FINNISH_1 25
-static const char finnish_1[] =
+static const char finnish_1[] =
MK("Aijala")
MK("Kisko")
MK("Espoo")
@@ -1279,9 +1279,9 @@ static const char finnish_1[] =
MK("Imatra")
MK("Tapanila")
MK("Pasila");
-
+
#define NUM_FINNISH_2a 26
-static const char finnish_2a[] =
+static const char finnish_2a[] =
MK("Hiekka")
MK("Haapa")
MK("Mylly")
@@ -1310,7 +1310,7 @@ static const char finnish_2a[] =
MK("Koivu");
#define NUM_FINNISH_2b 18
-static const char finnish_2b[] =
+static const char finnish_2b[] =
MK("harju")
MK("linna")
MK("järvi")
@@ -1576,7 +1576,7 @@ MK(" Malopolski")
MK(" Podlaski")
MK(" Lesny")
;
-static const char polish_3_f[] =
+static const char polish_3_f[] =
MK(" Wybudowanie")
MK(" Swietokrzyska")
MK(" Gorska")
@@ -1692,7 +1692,7 @@ static byte MakePolishTownName(byte *buf, uint32 seed)
}
#define NUM_CZECH_1 82
-static const char czech_1[] =
+static const char czech_1[] =
MK("As")
MK("Benesov")
MK("Beroun")
@@ -1780,7 +1780,7 @@ MK("Znojmo")
static byte MakeCzechTownName(byte *buf, uint32 seed)
{
AppendPart(&buf, GETNUM(0, NUM_CZECH_1), czech_1);
- return 0;
+ return 0;
}
@@ -1879,12 +1879,12 @@ MK("Zvolen")
static byte MakeSlovakishTownName(byte *buf, uint32 seed)
{
AppendPart(&buf, GETNUM(0, NUM_SLOVAKISH_1), slovakish_1);
- return 0;
+ return 0;
}
// Modifiers
#define NUM_HUNGARIAN_1 5
-static const char hungarian_1[] =
+static const char hungarian_1[] =
MK("Nagy-")
MK("Kis-")
MK("Felsõ-")
@@ -1893,7 +1893,7 @@ static const char hungarian_1[] =
;
#define NUM_HUNGARIAN_2 54
-static const char hungarian_2[] =
+static const char hungarian_2[] =
// River modifiers
// 1 - 10
MK("Bodrog")
@@ -1971,7 +1971,7 @@ static const char hungarian_2[] =
;
#define NUM_HUNGARIAN_3 16
-static const char hungarian_3[] =
+static const char hungarian_3[] =
MK("apáti")
MK("bába")
MK("bikk")
@@ -1991,7 +1991,7 @@ static const char hungarian_3[] =
;
#define NUM_HUNGARIAN_4 5
-static const char hungarian_4[] =
+static const char hungarian_4[] =
MK("alja")
MK("egyháza")
MK("háza")
@@ -2054,7 +2054,7 @@ static byte MakeHungarianTownName(byte *buf, uint32 seed)
AppendPart(&buf, GETNUM(3, NUM_HUNGARIAN_2), hungarian_2);
AppendPart(&buf, GETNUM(6, NUM_HUNGARIAN_3), hungarian_3);
-
+
i = GETNUM(10, NUM_HUNGARIAN_4 * 3);
if (i < NUM_HUNGARIAN_4) AppendPart(&buf, i, hungarian_4);
}
diff --git a/network.c b/network.c
index ca24ab49f..2e8801b08 100644
--- a/network.c
+++ b/network.c
@@ -232,7 +232,7 @@ static size_t _transmit_file_size;
static FILE *_recv_file;
-typedef struct NetworkGameInfo {
+typedef struct NetworkGameInfo {
char server_name[40]; // name of the game
char server_revision[8]; // server game version
byte server_lang; // langid
@@ -263,17 +263,17 @@ void CSleep(int milliseconds) {
Sleep(milliseconds);
#endif
#if defined(UNIX)
-#if !defined(__BEOS__) && !defined(__MORPHOS__) && !defined(__AMIGAOS__)
+#if !defined(__BEOS__) && !defined(__MORPHOS__) && !defined(__AMIGAOS__)
usleep(milliseconds*1000);
#endif
#ifdef __BEOS__
snooze(milliseconds*1000);
#endif
-#if defined(__MORPHOS__)
+#if defined(__MORPHOS__)
usleep(milliseconds*1000);
#endif
-#if defined(__AMIGAOS__) && !defined(__MORPHOS__)
-{
+#if defined(__AMIGAOS__) && !defined(__MORPHOS__)
+{
ULONG signals;
ULONG TimerSigBit = 1 << TimerPort->mp_SigBit;
@@ -826,7 +826,7 @@ void NetworkSendReadyPacket()
rp->packet_type = 5;
rp->packet_length = sizeof(rp);
SendBytes(c, rp, sizeof(rp));
- _network_ready_sent = true;
+ _network_ready_sent = true;
}
}
@@ -955,7 +955,7 @@ bool NetworkConnect(const char *hostname, int port)
b = 1;
setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (const char*)&b, sizeof(b));
-
+
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = NetworkResolveHost(hostname);
sin.sin_port = htons(port);
@@ -980,7 +980,7 @@ bool NetworkConnect(const char *hostname, int port)
void NetworkListen()
{
-
+
SOCKET ls;
struct sockaddr_in sin;
int port;
@@ -992,7 +992,7 @@ void NetworkListen()
ls = socket(AF_INET, SOCK_STREAM, 0);
if (ls == INVALID_SOCKET)
error("socket() on listen socket failed");
-
+
// reuse the socket
{
int reuse = 1; if (setsockopt(ls, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse, sizeof(reuse)) == -1)
@@ -1021,7 +1021,7 @@ void NetworkReceive()
int n;
fd_set read_fd, write_fd;
struct timeval tv;
-
+
FD_ZERO(&read_fd);
FD_ZERO(&write_fd);
@@ -1119,13 +1119,13 @@ void NetworkSend()
CSleep(5);
}
}
-
+
_not_packet = 0;
new_max = max(_frame_counter + (int)_network_ahead_frames, _frame_counter_max);
-
+
DEBUG(net,3) ("net: serv: sync max=%i, seed1=%i, seed2=%i",new_max,_sync_seed_1,_sync_seed_2);
-
+
sp.packet_length = sizeof(sp);
sp.packet_type = 1;
sp.frames = new_max - _frame_counter_max;
@@ -1196,7 +1196,7 @@ void NetworkClose(bool client) {
void NetworkShutdown()
{
- _networking_server = false;
+ _networking_server = false;
_networking = false;
_networking_sync = false;
_frame_counter = 0;
@@ -1255,10 +1255,10 @@ void NetworkUDPListen(bool client)
DEBUG(net, 1) ("[NET][UDP] listening on port %i", port);
udp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-
+
// this disables network
_network_available = !(udp == INVALID_SOCKET);
-
+
// set nonblocking mode for socket
{ unsigned long blocking = 1; ioctlsocket(udp, FIONBIO, &blocking); }
@@ -1268,7 +1268,7 @@ void NetworkUDPListen(bool client)
if (bind(udp, (struct sockaddr*)&sin, sizeof(sin)) != 0)
DEBUG(net, 1) ("[NET][UDP] error: bind failed on port %i", port);
-
+
// enable broadcasting
{ unsigned long val=1; setsockopt(udp, SOL_SOCKET, SO_BROADCAST, (char *) &val , sizeof(val)); }
@@ -1280,7 +1280,7 @@ void NetworkUDPListen(bool client)
}
void NetworkUDPClose(bool client) {
- if (client) {
+ if (client) {
DEBUG(net, 1) ("[NET][UDP] closed listener on port %i", _network_client_port);
closesocket(_udp_client_socket);
_udp_client_socket = INVALID_SOCKET;
@@ -1301,17 +1301,17 @@ void NetworkUDPReceive(bool client) {
int nbytes;
struct UDPPacket packet;
int packet_len;
-
+
SOCKET udp;
if (client) udp=_udp_client_socket; else udp=_udp_server_socket;
packet_len = sizeof(packet);
- client_len = sizeof(client_addr);
-
+ client_len = sizeof(client_addr);
+
nbytes = recvfrom(udp, (char *) &packet, packet_len , 0, (struct sockaddr *) &client_addr, &client_len);
if (nbytes>0) {
if (packet.command_code==packet.command_check) switch (packet.command_code) {
-
+
case NET_UDPCMD_SERVERSEARCH:
if (!client) {
packet.command_check=packet.command_code=NET_UDPCMD_SERVERINFO;
@@ -1335,7 +1335,7 @@ void NetworkUDPReceive(bool client) {
item = (NetworkGameList *) NetworkGameListAdd();
item -> ip = inet_addr(inet_ntoa(client_addr.sin_addr));
item -> port = ntohs(client_addr.sin_port);
-
+
memcpy(item,&packet.data,packet.data_len);
}
break;
@@ -1365,14 +1365,14 @@ void NetworkUDPBroadCast(bool client, struct UDPPacket packet) {
if (res==-1) DEBUG(net, 1)("udp: broadcast error: %i",GET_LAST_ERROR());
i++;
}
-
+
}
void NetworkUDPSend(bool client, struct sockaddr_in recv,struct UDPPacket packet) {
SOCKET udp;
if (client) udp=_udp_client_socket; else udp=_udp_server_socket;
-
+
sendto(udp,(char *) &packet,sizeof(packet),0,(struct sockaddr *) &recv,sizeof(recv));
}
@@ -1380,13 +1380,13 @@ void NetworkUDPSend(bool client, struct sockaddr_in recv,struct UDPPacket packet
bool NetworkUDPSearchGame(const byte ** _network_detected_serverip, unsigned short * _network_detected_serverport) {
struct UDPPacket packet;
int timeout=3000;
-
+
NetworkGameListClear();
DEBUG(net, 0) ("[NET][UDP] searching server");
*_network_detected_serverip = "255.255.255.255";
*_network_detected_serverport = 0;
-
+
packet.command_check=packet.command_code=NET_UDPCMD_SERVERSEARCH;
packet.data_len=0;
NetworkUDPBroadCast(true, packet);
@@ -1403,11 +1403,11 @@ bool NetworkUDPSearchGame(const byte ** _network_detected_serverip, unsigned sho
timeout=-1;
DEBUG(net, 0) ("[NET][UDP] server found on %s", *_network_detected_serverip);
}
-
+
}
return (*_network_detected_serverport>0);
-
+
}
@@ -1420,7 +1420,7 @@ void NetworkIPListInit() {
char hostname[250];
uint32 bcaddr;
int i=0;
-
+
gethostname(hostname,250);
DEBUG(net, 2) ("[NET][IP] init for host %s", hostname);
he=gethostbyname((char *) hostname);
@@ -1428,7 +1428,7 @@ void NetworkIPListInit() {
if (he == NULL) {
he = gethostbyname("localhost");
}
-
+
if (he == NULL) {
bcaddr = inet_addr("127.0.0.1");
he = gethostbyaddr(inet_ntoa(*(struct in_addr *) &bcaddr), sizeof(bcaddr), AF_INET);
@@ -1437,7 +1437,7 @@ void NetworkIPListInit() {
if (he == NULL) {
DEBUG(net, 2) ("[NET][IP] cannot resolve %s", hostname);
} else {
- while(he->h_addr_list[i]) {
+ while(he->h_addr_list[i]) {
bcaddr = inet_addr(inet_ntoa(*(struct in_addr *) he->h_addr_list[i]));
_network_ip_list[i]=bcaddr;
DEBUG(net, 2) ("[NET][IP] add %s",inet_ntoa(*(struct in_addr *) he->h_addr_list[i]));
@@ -1446,7 +1446,7 @@ void NetworkIPListInit() {
}
_network_ip_list[i]=0;
-
+
}
/* *************************************************** */
@@ -1468,7 +1468,7 @@ _network_client_timeout=3000;
_network_available=false;
}
}
-#else
+#else
// [morphos/amigaos] bsd-socket startup
@@ -1486,14 +1486,14 @@ _network_client_timeout=3000;
if ( (TimerRequest = (struct timerequest *) CreateIORequest(TimerPort, sizeof(struct timerequest))) ) {
if ( OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest *) TimerRequest, 0) == 0 ) {
if ( !(TimerBase = TimerRequest->tr_node.io_Device) ) {
- // free ressources...
+ // free ressources...
DEBUG(net, 3) ("[NET][Core] Couldn't initialize timer.");
_network_available=false;
}
}
}
}
- #endif
+ #endif
}
#else
@@ -1527,9 +1527,9 @@ void NetworkCoreShutdown() {
DEBUG(net, 3) ("[NET][Core] shutdown()");
#if defined(__MORPHOS__) || defined(__AMIGA__)
-{
+{
// free allocated ressources
- #if !defined(__MORPHOS__)
+ #if !defined(__MORPHOS__)
if (TimerBase) { CloseDevice((struct IORequest *) TimerRequest); }
if (TimerRequest) { DeleteIORequest(TimerRequest); }
if (TimerPort) { DeleteMsgPort(TimerPort); }
@@ -1574,9 +1574,9 @@ bool NetworkCoreConnectGame(const byte* b, unsigned short port)
if (_networking) {
NetworkLobbyShutdown();
} else {
- if (_networking_override)
+ if (_networking_override)
NetworkLobbyShutdown();
-
+
ShowErrorMessage(-1, STR_NETWORK_ERR_NOCONNECTION,0,0);
_switch_mode_errorstr = STR_NETWORK_ERR_NOCONNECTION;
}
@@ -1607,13 +1607,13 @@ void NetworkCoreDisconnect()
if (_networking_server) {
NetworkUDPClose(false);
NetworkClose(false);
- }
+ }
/* terminate client connection */
else if (_networking) {
NetworkClose(true);
}
-
+
NetworkShutdown();
}
@@ -1670,7 +1670,7 @@ void NetworkLobbyShutdown() {
void NetworkGameListClear() {
NetworkGameList * item;
-NetworkGameList * next;
+NetworkGameList * next;
DEBUG(net, 4) ("[NET][G-List] cleared server list");
@@ -1686,7 +1686,7 @@ _network_game_count=0;
char * NetworkGameListAdd() {
NetworkGameList * item;
-NetworkGameList * before;
+NetworkGameList * before;
DEBUG(net, 4) ("[NET][G-List] added server to list");
@@ -1726,7 +1726,7 @@ void NetworkGameListFromInternet() {
char * NetworkGameListItem(uint16 index) {
NetworkGameList * item;
-NetworkGameList * next;
+NetworkGameList * next;
uint16 cnt = 0;
item = _network_game_list;
@@ -1749,7 +1749,7 @@ void NetworkGameFillDefaults() {
#if defined(WITH_REV)
extern char _openttd_revision[];
#endif
-
+
DEBUG(net, 4) ("[NET][G-Info] setting defaults");
ttd_strlcpy(game->server_name,"OpenTTD Game",13);
@@ -1768,7 +1768,7 @@ void NetworkGameFillDefaults() {
game->players_max=8;
game->players_on=0;
-
+
game->server_lang=_dynlang.curr;
}
diff --git a/network_gui.c b/network_gui.c
index c00f416dd..31e26dd6d 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -23,12 +23,12 @@ static const StringID _connection_types_dropdown[] = {
};
/* Should be _network_game->players_max but since network is not yet really done
-* we'll just use some dummy here
+* we'll just use some dummy here
* network.c -->> static NetworkGameInfo _network_game;
*/
static byte _players_max;
/* Should be ??????????? (something) but since network is not yet really done
-* we'll just use some dummy here
+* we'll just use some dummy here
*/
static byte _network_connection;
@@ -36,20 +36,20 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT: {
-
+
SET_DPARAM16(0, 0x00);
SET_DPARAM16(2, STR_NETWORK_LAN + _network_connection);
DrawWindowWidgets(w);
-
+
DrawEditBox(w, 6);
-
+
DrawString(9, 43, STR_NETWORK_PLAYER_NAME, 2);
DrawString(9, 63, STR_NETWORK_SELECT_CONNECTION, 2);
DrawString(15, 82, STR_NETWORK_GAME_NAME, 2);
DrawString(238, 82, STR_NETWORK_PLAYERS, 2);
DrawString(288, 82, STR_NETWORK_MAP_SIZE, 2);
-
+
} break;
case WE_CLICK:
@@ -65,7 +65,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
case 4: { /* Connect via direct ip */
StringID str;
str = AllocateName((byte*)_decode_parameters, 0);
-
+
ShowQueryString(
str,
STR_NETWORK_ENTER_IP,
@@ -93,7 +93,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
case WE_MOUSELOOP:
if (_selected_field == 6)
HandleEditBox(w, 6);
-
+
break;
case WE_KEYPRESS:
@@ -160,11 +160,11 @@ void ShowNetworkGameWindow()
DeleteWindowById(WC_NETWORK_WINDOW, 0);
NetworkLobbyInit();
-
+
w = AllocateWindowDesc(&_network_game_window_desc);
strcpy(_edit_str_buf, "Your name");
-
+
WP(w,querystr_d).caret = 1;
WP(w,querystr_d).maxlen = MAX_QUERYSTR_LEN;
WP(w,querystr_d).maxwidth = 240;
@@ -186,7 +186,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT: {
-
+
SET_DPARAM16(7, STR_NETWORK_2_PLAYERS + _players_max);
DrawWindowWidgets(w);
@@ -194,13 +194,13 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
DrawEditBox(w, 3);
DrawEditBox(w, 4);
-
+
DrawString(10, 22, STR_NETWORK_NEW_GAME_NAME, 2);
DrawString(210, 22, STR_NETWORK_PASSWORD, 2);
DrawString(10, 43, STR_NETWORK_SELECT_MAP, 2);
DrawString(260, 63, STR_NETWORK_NUMBER_OF_PLAYERS, 2);
-
+
} break;
case WE_CLICK:
@@ -251,7 +251,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
break;
}
break;
-
+
}
}
@@ -288,10 +288,10 @@ static void ShowNetworkStartServerWindow()
{
Window *w;
DeleteWindowById(WC_NETWORK_WINDOW, 0);
-
+
w = AllocateWindowDesc(&_network_start_server_window_desc);
strcpy(_edit_str_buf, "");
-
+
WP(w,querystr_d).caret = 1;
WP(w,querystr_d).maxlen = MAX_QUERYSTR_LEN;
WP(w,querystr_d).maxwidth = 240;
@@ -303,7 +303,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT: {
-
+
SET_DPARAM16(7, STR_NETWORK_2_PLAYERS + _opt_mod_ptr->road_side);
DrawWindowWidgets(w);
@@ -312,7 +312,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
DrawEditBox(w, 5);
DrawEditBox(w, 7);
-
+
DrawString(10, 255, STR_NETWORK_COMPANY_NAME, 2);
break;
@@ -340,7 +340,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
HandleEditBox(w, 7);
break;
}
-
+
break;
case WE_KEYPRESS:
@@ -352,7 +352,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
break;
}
break;
-
+
}
}
@@ -398,11 +398,11 @@ static void ShowNetworkLobbyWindow()
{
Window *w;
DeleteWindowById(WC_NETWORK_WINDOW, 0);
-
+
w = AllocateWindowDesc(&_network_lobby_window_desc);
strcpy(_edit_str_buf, "");
-
+
WP(w,querystr_d).caret = 1;
WP(w,querystr_d).maxlen = MAX_QUERYSTR_LEN;
WP(w,querystr_d).maxwidth = 240;
diff --git a/news_gui.c b/news_gui.c
index c531a24e6..115945a90 100644
--- a/news_gui.c
+++ b/news_gui.c
@@ -12,7 +12,7 @@
News system is realized as a FIFO queue (in an array)
The positions in the queue can't be rearranged, we only access
the array elements through pointers to the elements. Once the
-array is full, the oldest entry (_oldest_news) is being overwritten
+array is full, the oldest entry (_oldest_news) is being overwritten
by the newest (_latest news).
oldest current lastest
@@ -28,7 +28,7 @@ static NewsItem _news_items[MAX_NEWS];
static byte _current_news = 255; // points to news item that should be shown next
static byte _oldest_news = 0; // points to first item in fifo queue
static byte _latest_news = 255; // points to last item in fifo queue
-static byte _forced_news = 255; // if the message being shown was forced by the user, its index is stored in _forced_news.
+static byte _forced_news = 255; // if the message being shown was forced by the user, its index is stored in _forced_news.
//forced_news is 255 otherwise. (Users can force messages through history or "last message")
static byte _total_news = 0; // total news count
@@ -80,13 +80,13 @@ void DrawNewsBorder(Window *w)
int bottom = w->height - 1;
GfxFillRect(left, top, right, bottom, 0xF);
-
+
GfxFillRect(left, top, left, bottom, 0xD7);
GfxFillRect(right, top, right, bottom, 0xD7);
GfxFillRect(left, top, right, top, 0xD7);
GfxFillRect(left, bottom, right, bottom, 0xD7);
-
- DrawString(left + 2, top + 1, STR_00C6, 0);
+
+ DrawString(left + 2, top + 1, STR_00C6, 0);
}
static void NewsWindowProc(Window *w, WindowEvent *e)
@@ -115,7 +115,7 @@ static void NewsWindowProc(Window *w, WindowEvent *e)
/* Shade the viewport into gray, or color*/
vp = w->viewport;
- GfxFillRect(vp->left - w->left, vp->top - w->top, vp->left - w->left + vp->width - 1, vp->top - w->top + vp->height - 1,
+ GfxFillRect(vp->left - w->left, vp->top - w->top, vp->left - w->left + vp->width - 1, vp->top - w->top + vp->height - 1,
ni->flags & NF_INCOLOR ? 0x4322:0x4323
);
@@ -208,7 +208,7 @@ void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b)
_forced_news = 255;
if(_total_news < MAX_NEWS) _total_news++;
-
+
// make sure our pointer isn't overflowing
_latest_news = increaseIndex(_latest_news);
@@ -431,7 +431,7 @@ void ShowLastNewsMessage()
else if(_forced_news!=0)
ShowNewsMessage(_forced_news-1);
else {
- if(_total_news != MAX_NEWS)
+ if(_total_news != MAX_NEWS)
ShowNewsMessage(_latest_news);
else
ShowNewsMessage(MAX_NEWS-1);
@@ -443,7 +443,7 @@ void ShowLastNewsMessage()
recent news. Returns 255 if end of queue reached. */
static byte getNews(byte i)
{
- if(i>=_total_news)
+ if(i>=_total_news)
return 255;
if(_latest_news < i)
@@ -459,17 +459,17 @@ static void GetNewsString(NewsItem *ni, byte *buffer)
{
StringID str;
byte *s, *d;
-
+
if (ni->display_mode == 3) {
str = _get_news_string_callback[ni->callback](ni);
} else {
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params));
- str = ni->string_id;
+ str = ni->string_id;
}
GetString(str_buffr, str);
assert(strlen(str_buffr) < sizeof(str_buffr) - 1);
-
+
s = str_buffr;
d = buffer;
@@ -611,7 +611,7 @@ static void MessageOptionsWndProc(Window *w, WindowEvent *e)
for(i=STR_0206_ARRIVAL_OF_FIRST_VEHICLE; i <= STR_020F_GENERAL_INFORMATION; i++) {
DrawString(124, y, i, 0);
y += 12;
- }
+ }
break;
}
diff --git a/oldloader.c b/oldloader.c
index 6f3630ce0..f15dc4f33 100644
--- a/oldloader.c
+++ b/oldloader.c
@@ -314,7 +314,7 @@ typedef struct {
byte owner;
uint16 tile;
uint16 cur_image;
-
+
int16 left_coord, right_coord, top_coord, bottom_coord; // NOLOAD, calculated automatically.
uint16 vehstatus;
uint16 cur_speed;
@@ -420,21 +420,21 @@ typedef struct {
uint16 age_cargo_skip_counter;
uint16 tick_counter;
uint16 cur_tileloop_tile;
-
+
OldPrice prices[49];
OldPaymentRate cargo_payment_rates[12];
-
+
byte map_owner[256*256];
byte map2[256*256];
uint16 map3[256*256];
byte map_extra[256*256/4];
-
+
OldStation stations[250];
OldIndustry industries[90];
OldPlayer players[8];
OldVehicle vehicles[850];
OldName names[500];
-
+
uint16 vehicle_position_hash[0x1000]; // NOLOAD, calculated automatically.
OldSign signs[40];
@@ -455,7 +455,7 @@ typedef struct {
uint16 cargo_sprites[12];
uint16 engine_name_strings[256];
-
+
//NOLOAD. These are calculated from InitializeLandscapeVariables
uint16 railveh_by_cargo_1[12], railveh_by_cargo_2[12], railveh_by_cargo_3[12];
uint16 roadveh_by_cargo_start[12];
@@ -486,9 +486,9 @@ typedef struct {
byte snow_line_height;
byte new_industry_randtable[32]; // NOLOAD. Not needed due to different code design.
-
+
//NOLOAD. Initialized by InitializeLandscapeVariables
- byte cargo_weights[12];
+ byte cargo_weights[12];
byte transit_days_table_1[12];
byte transit_days_table_2[12];
@@ -557,7 +557,7 @@ static byte DecodeSavegameByte()
return GetSavegameByteFromBuffer();
}
}
-
+
x = GetSavegameByteFromBuffer();
if (x >= 0) {
lss->count = x;
@@ -568,7 +568,7 @@ static byte DecodeSavegameByte()
lss->count = -x;
lss->rep_char = GetSavegameByteFromBuffer();
return lss->rep_char;
- }
+ }
}
static void LoadSavegameBytes(void *p, size_t count)
@@ -642,7 +642,7 @@ static void FixIndustry(Industry *i, OldIndustry *o, int num)
i->prod_level = o->prod_level;
i->last_mo_production[0] = o->last_mo_production[0];
i->last_mo_production[1] = o->last_mo_production[1];
-
+
i->last_mo_transported[0] = o->last_mo_transported[0];
i->last_mo_transported[1] = o->last_mo_transported[1];
i->last_mo_transported[2] = o->last_mo_transported[2];
@@ -652,7 +652,7 @@ static void FixIndustry(Industry *i, OldIndustry *o, int num)
i->total_production[0] = o->total_production[0];
i->total_production[1] = o->total_production[1];
-
+
i->total_transported[0] = i->total_transported[0];
i->total_transported[1] = i->total_transported[1];
@@ -688,7 +688,7 @@ static void FixStation(Station *s, OldStation *o, int num)
s->train_tile = o->train_tile;
s->airport_tile = o->airport_tile;
s->dock_tile = o->dock_tile;
-
+
if (o->train_tile) {
int w = (o->platforms >> 3) & 0x7;
int h = (o->platforms & 0x7);
@@ -696,7 +696,7 @@ static void FixStation(Station *s, OldStation *o, int num)
s->trainst_w = w;
s->trainst_h = h;
}
-
+
s->string_id = RemapOldStringID(o->string_id);
s->had_vehicle_of_type = o->had_vehicle_of_type;
FixGoodsEntry(s->goods, o->goods, lengthof(o->goods));
@@ -727,7 +727,7 @@ static void FixVehicle(Vehicle *n, OldVehicle *o, int num)
do {
n->type = o->type;
n->subtype = o->subtype;
-
+
if (o->schedule_ptr == 0xFFFFFFFF || o->schedule_ptr == 0) {
n->schedule_ptr = NULL;
} else {
@@ -758,7 +758,7 @@ static void FixVehicle(Vehicle *n, OldVehicle *o, int num)
n->owner = o->owner;
n->tile = o->tile;
n->cur_image = o->cur_image;
-
+
n->vehstatus = o->vehstatus;
n->cur_speed = o->cur_speed;
n->subspeed = o->subspeed;
@@ -787,7 +787,7 @@ static void FixVehicle(Vehicle *n, OldVehicle *o, int num)
n->next = o->next_in_chain == 0xffff ? NULL : &_vehicles[o->next_in_chain];
n->value = o->value;
n->string_id = RemapOldStringID(o->string_id);
-
+
switch(o->type) {
case VEH_Train:
n->u.rail.track = o->u.rail.track;
@@ -864,7 +864,7 @@ static void FixPlayer(Player *n, OldPlayer *o, int num, byte town_name_type)
{
int i, j;
int x = 0;
-
+
do {
n->name_1 = RemapOldStringID(o->name_1);
n->name_2 = o->name_2;
@@ -882,15 +882,15 @@ static void FixPlayer(Player *n, OldPlayer *o, int num, byte town_name_type)
if (o->name_1 != 0)
n->is_active = true;
-
+
n->face = o->face;
n->president_name_1 = o->pres_name_1;
n->president_name_2 = o->pres_name_2;
-
+
n->money64 = n->player_money = o->money;
n->current_loan = o->loan;
-
- // Correct money for scenario loading.
+
+ // Correct money for scenario loading.
// It's always 893288 pounds (and no loan), if not corrected
if(o->money==0xda168)
n->money64 = n->player_money = n->current_loan =100000;
@@ -905,7 +905,7 @@ static void FixPlayer(Player *n, OldPlayer *o, int num, byte town_name_type)
n->bankrupt_value = o->bankrupt_value;
n->bankrupt_timeout = o->bankrupt_timeout;
n->cargo_types = o->cargo_types;
-
+
for(i=0; i!=3; i++)
for(j=0; j!=13; j++)
n->yearly_expenses[i][j] = o->expenses[i].cost[j];
@@ -916,7 +916,7 @@ static void FixPlayer(Player *n, OldPlayer *o, int num, byte town_name_type)
n->last_build_coordinate = o->last_build_coordinate;
n->num_valid_stat_ent = o->num_valid_stat_ent;
- /* Not good, since AI doesn't have a vehicle assigned as
+ /* Not good, since AI doesn't have a vehicle assigned as
* in p->ai.cur_veh and thus will crash on certain actions.
* Best is to set state to AiStateVehLoop (2)
* n->ai.state = o->ai_state;
@@ -927,18 +927,18 @@ static void FixPlayer(Player *n, OldPlayer *o, int num, byte town_name_type)
n->ai.timeout_counter = o->ai_timeout_counter;
n->ai.banned_tile_count = o->ai_banned_tile_count;
n->ai.railtype_to_use = o->ai_railtype_to_use;
-
+
FixAiBuildRec(&n->ai.src, &o->ai_src);
FixAiBuildRec(&n->ai.dst, &o->ai_dst);
FixAiBuildRec(&n->ai.mid1, &o->ai_mid1);
FixAiBuildRec(&n->ai.mid2, &o->ai_mid2);
-
+
n->ai.cargo_type = o->ai_cargo_type;
n->ai.num_wagons = o->ai_num_wagons;
n->ai.num_build_rec = o->ai_num_build_rec;
n->ai.num_loco_to_build = o->ai_num_loco_to_build;
n->ai.num_want_fullload = o->ai_num_want_fullload;
-
+
for(i=0; i!=9; i++) n->ai.wagon_list[i] = o->ai_wagonlist[i];
memcpy(n->ai.order_list_blocks, o->ai_order_list_blocks, 20);
n->ai.start_tile_a = o->ai_start_tile_a;
@@ -949,7 +949,7 @@ static void FixPlayer(Player *n, OldPlayer *o, int num, byte town_name_type)
n->ai.start_dir_b = o->ai_start_dir_b;
n->ai.cur_dir_a = o->ai_cur_dir_a;
n->ai.cur_dir_b = o->ai_cur_dir_b;
-
+
for(i=0; i!=16; i++) {
n->ai.banned_tiles[i] = o->banned_tiles[i].tile;
n->ai.banned_val[i] = o->banned_tiles[i].data;
@@ -1081,7 +1081,7 @@ bool LoadOldSaveGame(const char *file)
for(i=0; i!=256*256; i++) {
if (IS_TILETYPE(i, MP_RAILWAY) && (_map5[i] & 0xC0) == 0x40) {
// this byte is always zero in real ttd.
- if (_map3_hi[i]) {
+ if (_map3_hi[i]) {
// convert ttdpatch presignal format to openttd presignal format.
_map3_hi[i] = (_map3_hi[i] >> 1) & 7;
}
@@ -1098,7 +1098,7 @@ bool LoadOldSaveGame(const char *file)
FixDepot(_depots, m->depots, lengthof(m->depots));
FixVehicle(_vehicles, m->vehicles, lengthof(m->vehicles));
FixSubsidy(_subsidies, m->subsidies, lengthof(m->subsidies));
-
+
FixPlayer(_players, m->players, lengthof(m->players), m->town_name_type);
FixName(m->names, lengthof(m->names));
FixSign(_sign_list, m->signs, lengthof(m->signs));
@@ -1154,7 +1154,7 @@ bool LoadOldSaveGame(const char *file)
_cargo_payment_rates[i] = -(int32)m->cargo_payment_rates[i].price;
_cargo_payment_rates_frac[i] = m->cargo_payment_rates[i].frac;
}
-
+
free(m);
fclose(lss.fin);
return true;
diff --git a/order_cmd.c b/order_cmd.c
index 25e114b54..3496e9c72 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -23,7 +23,7 @@ int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// for ships, make sure that the station is not too far away from the previous destination.
if (v->type == VEH_Ship && IS_HUMAN_PLAYER(v->owner) &&
sel != 0 && ((t=v->schedule_ptr[sel-1])&OT_MASK) == OT_GOTO_STATION) {
-
+
int dist = GetTileDist(DEREF_STATION(t >> 8)->xy, DEREF_STATION(p2 >> 8)->xy);
if (dist >= 130)
return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO);
@@ -39,7 +39,7 @@ int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
s1[0] = (uint16)p2;
s1 = v->schedule_ptr;
-
+
FOR_ALL_VEHICLES(u) {
if (u->type != 0 && u->schedule_ptr != NULL) {
if (s1 < u->schedule_ptr) {
@@ -69,10 +69,10 @@ static int32 DecloneOrder(Vehicle *dst, uint32 flags)
if (flags & DC_EXEC) {
DeleteVehicleSchedule(dst);
-
+
dst->num_orders = 0;
*(dst->schedule_ptr = _ptr_to_next_order++) = 0;
-
+
InvalidateWindow(WC_VEHICLE_ORDERS, dst->index);
}
return 0;
@@ -92,7 +92,7 @@ int32 CmdDeleteOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) {
uint16 *s1;
-
+
s1 = &v->schedule_ptr[sel];
// copy all orders to get rid of the hole
@@ -119,7 +119,7 @@ int32 CmdDeleteOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
}
}
-
+
return 0;
}
@@ -133,7 +133,7 @@ int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
byte b = v->cur_order_index + 1;
if (b >= v->num_orders) b = 0;
v->cur_order_index = b;
-
+
if (v->type == VEH_Train)
v->u.rail.days_since_order_progr = 0;
}
@@ -160,7 +160,7 @@ int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return CMD_ERROR;
sched = &v->schedule_ptr[sel];
- if (!((*sched & OT_MASK) == OT_GOTO_STATION ||
+ if (!((*sched & OT_MASK) == OT_GOTO_STATION ||
((*sched & OT_MASK) == OT_GOTO_DEPOT && (p2>>8) != 1)))
return CMD_ERROR;
@@ -185,9 +185,9 @@ int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (v->schedule_ptr == sched)
InvalidateWindow(WC_VEHICLE_ORDERS, v->index);
}
-
+
}
-
+
return 0;
}
@@ -204,12 +204,12 @@ int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *dst = &_vehicles[p1 & 0xFFFF];
-
+
if (!(dst->type && dst->owner == _current_player))
return CMD_ERROR;
switch(p2) {
-
+
// share vehicle orders?
case 0: {
Vehicle *src = &_vehicles[p1 >> 16];
@@ -217,7 +217,7 @@ int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// sanity checks
if (!(src->owner == _current_player && dst->type == src->type && dst != src))
return CMD_ERROR;
-
+
// let's see what happens with road vehicles
if (src->type == VEH_Road) {
if (src->cargo_type != dst->cargo_type && (src->cargo_type == CT_PASSENGERS || dst->cargo_type == CT_PASSENGERS))
@@ -243,14 +243,14 @@ int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// sanity checks
if (!(src->owner == _current_player && dst->type == src->type && dst != src))
return CMD_ERROR;
-
+
// let's see what happens with road vehicles
if (src->type == VEH_Road) {
uint16 ord;
int i;
Station *st;
TileIndex required_dst;
-
+
for (i=0; (ord = src->schedule_ptr[i]) != 0; i++) {
if ( ( ord & OT_MASK ) == OT_GOTO_STATION ) {
st = DEREF_STATION(ord >> 8);
@@ -292,7 +292,7 @@ void BackupVehicleOrders(Vehicle *v, BackuppedOrders *bak)
bak->orderindex = v->cur_order_index;
bak->service_interval = v->service_interval;
-
+
if ((v->string_id & 0xF800) != 0x7800) {
bak->name[0] = 0;
} else {
@@ -306,7 +306,7 @@ void BackupVehicleOrders(Vehicle *v, BackuppedOrders *bak)
os[1] = u->index;
return;
}
-
+
sched = v->schedule_ptr;
do {
ord = *sched++;
@@ -325,7 +325,7 @@ void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *bak)
}
DoCommandP(0, v->index, bak->orderindex|(bak->service_interval<<16) , NULL, CMD_RESTORE_ORDER_INDEX | CMD_ASYNC);
-
+
os = bak->order;
if (os[0] == 0xFFFF) {
DoCommandP(0, v->index | os[1]<<16, 0, NULL, CMD_CLONE_ORDER);
@@ -359,7 +359,7 @@ int CheckOrders(Vehicle *v)
{
if (!_patches.order_review_system) //User doesn't want things to be checked
return 0;
-
+
if ( (_patches.order_review_system == 1) && (v->vehstatus & VS_STOPPED) )
return 0;
@@ -401,17 +401,17 @@ int CheckOrders(Vehicle *v)
if ( (v->schedule_ptr[0] == v->schedule_ptr[i-2]) && ( i-2 != 0 ) ) {
problem_type = 2;
}
-
+
if (n_st < 2) problem_type = 0;
-
+
if (!required_tile) problem_type = 3;
SET_DPARAM16(0, v->unitnumber);
-
+
message = (STR_TRAIN_HAS_TOO_FEW_ORDERS) + (((v->type) - VEH_Train) << 2) + problem_type;
-
+
if (problem_type < 0) return 0;
-
+
AddNewsItem(
message,
NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
diff --git a/order_gui.c b/order_gui.c
index f5640c824..54ef8bbe1 100644
--- a/order_gui.c
+++ b/order_gui.c
@@ -58,7 +58,7 @@ static void DrawOrdersWindow(Window *w)
SetVScrollCount(w, num+1);
sel = OrderGetSel(w);
-
+
SET_DPARAM16(2,STR_8827_FULL_LOAD);
switch(v->schedule_ptr[sel] & 0x1F) {
case OT_GOTO_STATION:
@@ -70,7 +70,7 @@ static void DrawOrdersWindow(Window *w)
default:
SETBIT(w->disabled_state, 6); /* nonstop */
SETBIT(w->disabled_state, 8); /* full load */
- SETBIT(w->disabled_state, 9); /* unload */
+ SETBIT(w->disabled_state, 9); /* unload */
}
SET_DPARAM16(0, v->string_id);
@@ -82,11 +82,11 @@ static void DrawOrdersWindow(Window *w)
i = 0;
for(;;) {
str = ((byte)v->cur_order_index == i) ? STR_8805 : STR_8804;
-
+
ord = v->schedule_ptr[i];
if ( (uint)(i - w->vscroll.pos) < 6) {
-
+
if (ord == 0) {
str = shared_schedule ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
} else {
@@ -149,7 +149,7 @@ static void *FindVehicleCallb(Vehicle *v, FindVehS *f)
{
if (v->tile != f->tile || v->owner != f->owner || v->vehstatus & VS_HIDDEN ) return NULL;
return v;
-}
+}
Vehicle *GetVehicleOnTile(TileIndex tile, byte owner)
{
@@ -231,7 +231,7 @@ static bool HandleOrderVehClick(Vehicle *v, Vehicle *u, Window *w)
// v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet
// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
if (v->num_orders != 0 && _ctrl_pressed == 0) {return false;}
-
+
if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? 0 : 1, NULL,
_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
WP(w,order_d).sel = -1;
@@ -245,7 +245,7 @@ static void OrdersPlaceObj(Vehicle *v, uint tile, Window *w)
{
uint cmd;
Vehicle *u;
-
+
// check if we're clicking on a vehicle first.. clone orders in that case.
u = CheckMouseOverVehicle();
if (u && HandleOrderVehClick(v, u, w))
@@ -273,7 +273,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
Vehicle *v = &_vehicles[w->window_number];
int mode;
switch(e->click.widget) {
- case 2: {/* orders list */
+ case 2: {/* orders list */
int sel;
sel = (e->click.pt.y - 15) / 10;
@@ -298,7 +298,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
if (xy)
ScrollMainWindowToTile(xy);
-
+
return;
}
@@ -383,7 +383,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
HandleOrderVehClick(&_vehicles[w->window_number], v, w);
}
} break;
-
+
}
}
@@ -556,7 +556,7 @@ void ShowOrdersWindow(Vehicle *v)
DeleteWindowById(WC_VEHICLE_ORDERS, veh);
DeleteWindowById(WC_VEHICLE_DETAILS, veh);
-
+
_alloc_wnd_parent_num = veh;
w = AllocateWindowDesc(
_order_window_desc[(v->type - VEH_Train)*2 + (v->owner != _local_player)]);
diff --git a/pathfind.c b/pathfind.c
index 1a39aa376..9a566a273 100644
--- a/pathfind.c
+++ b/pathfind.c
@@ -37,7 +37,7 @@ static bool TPFSetTileBit(TrackPathFinder *tpf, uint tile, int dir)
return true;
} else {
/* two tiles with the same hash, need to make a link */
-
+
/* allocate a link. if out of links, handle this by returning
* that a tile was already visisted. */
if (tpf->num_links_left == 0)
@@ -51,7 +51,7 @@ static bool TPFSetTileBit(TrackPathFinder *tpf, uint tile, int dir)
tpf->hash_tile[hash] = PATHFIND_GET_LINK_OFFS(tpf, link);
link->flags = tpf->hash_head[hash];
- tpf->hash_head[hash] = 0xFFFF; /* multi link */
+ tpf->hash_head[hash] = 0xFFFF; /* multi link */
link->next = 0xFFFF;
}
@@ -59,7 +59,7 @@ static bool TPFSetTileBit(TrackPathFinder *tpf, uint tile, int dir)
/* a linked list of many tiles,
* find the one corresponding to the tile, if it exists.
* otherwise make a new link */
-
+
offs = tpf->hash_tile[hash];
do {
link = PATHFIND_GET_LINK_PTR(tpf, offs);
@@ -74,7 +74,7 @@ static bool TPFSetTileBit(TrackPathFinder *tpf, uint tile, int dir)
}
} while ((offs=link->next) != 0xFFFF);
}
-
+
/* get here if we need to add a new link to link,
* first, allocate a new link, in the same way as before */
if (tpf->num_links_left == 0)
@@ -130,12 +130,12 @@ void TPFMode2(TrackPathFinder *tpf, uint tile, int direction)
// This addition will sometimes overflow by a single tile.
// The use of TILE_MASK here makes sure that we still point at a valid
- // tile, and then this tile will be in the sentinel row/col, so GetTileTrackStatus will fail.
+ // tile, and then this tile will be in the sentinel row/col, so GetTileTrackStatus will fail.
tile = TILE_MASK(tile + _tileoffs_by_dir[direction]);
if (++tpf->rd.cur_length > 50)
return;
-
+
bits = GetTileTrackStatus(tile, tpf->tracktype);
bits = (byte)((bits | (bits >> 8)) & _bits_mask[direction]);
if (bits == 0)
@@ -161,7 +161,7 @@ void TPFMode2(TrackPathFinder *tpf, uint tile, int direction)
// Change direction 4 times only
if ((byte)i != tpf->rd.pft_var6) {
if(++tpf->rd.depth > 4) {
- tpf->rd = rd;
+ tpf->rd = rd;
return;
}
tpf->rd.pft_var6 = (byte)i;
@@ -169,7 +169,7 @@ void TPFMode2(TrackPathFinder *tpf, uint tile, int direction)
continue_here:;
tpf->the_dir = HASBIT(_otherdir_mask[direction],i) ? (i+8) : i;
-
+
#ifdef DEBUG_TILE_PUSH
dbg_push_tile(tile, tpf->the_dir);
#endif
@@ -265,7 +265,7 @@ void TPFMode1(TrackPathFinder *tpf, uint tile, int direction)
if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0)==0) {
if ((_map5[tile] & 3) != direction || ((_map5[tile]>>1)&6) != tpf->tracktype)
return;
- tile = SkipToEndOfTunnel(tpf, tile, direction);
+ tile = SkipToEndOfTunnel(tpf, tile, direction);
}
tile += _tileoffs_by_dir[direction];
tpf->rd.cur_length++;
@@ -286,7 +286,7 @@ void TPFMode1(TrackPathFinder *tpf, uint tile, int direction)
tpf->the_dir = (_otherdir_mask[direction] & (byte)(1 << i)) ? (i+8) : i;
rd = tpf->rd;
-
+
#ifdef DEBUG_TILE_PUSH
dbg_push_tile(tile, tpf->the_dir);
#endif
@@ -304,12 +304,12 @@ void TPFMode1(TrackPathFinder *tpf, uint tile, int direction)
/* the next is only used when signals are checked.
* seems to go in 2 directions simultaneously */
-
+
/* if i can get rid of this, tail end recursion can be used to minimize
- * stack space dramatically. */
+ * stack space dramatically. */
if (tpf->hasbit_13)
return;
-
+
tile = tile_org;
direction ^= 2;
@@ -327,7 +327,7 @@ void TPFMode1(TrackPathFinder *tpf, uint tile, int direction)
do {
i = FIND_FIRST_BIT(bits);
bits = KILL_FIRST_BIT(bits);
-
+
tpf->the_dir = (_otherdir_mask[direction] & (byte)(1 << i)) ? (i+8) : i;
rd = tpf->rd;
if (TPFSetTileBit(tpf, tile, tpf->the_dir) &&
@@ -344,16 +344,16 @@ void FollowTrack(uint tile, uint16 flags, byte direction, TPFEnumProc *enum_proc
assert(direction < 4);
- /* initialize path finder variables */
+ /* initialize path finder variables */
tpf->userdata = data;
- tpf->enum_proc = enum_proc;
+ tpf->enum_proc = enum_proc;
tpf->new_link = tpf->links;
tpf->num_links_left = 0x400;
tpf->rd.cur_length = 0;
tpf->rd.depth = 0;
tpf->rd.pft_var6 = 0;
-
+
tpf->var2 = HASBIT(flags, 15) ? 0x43 : 0xFF; /* 0x8000 */
tpf->disable_tile_hash = HASBIT(flags, 12) != 0; /* 0x1000 */
@@ -362,10 +362,10 @@ void FollowTrack(uint tile, uint16 flags, byte direction, TPFEnumProc *enum_proc
tpf->tracktype = (byte)flags;
- if (HASBIT(flags, 11)) {
+ if (HASBIT(flags, 11)) {
tpf->rd.pft_var6 = 0xFF;
tpf->enum_proc(tile, data, 0, 0, 0);
- TPFMode2(tpf, tile, direction);
+ TPFMode2(tpf, tile, direction);
} else {
/* clear the hash_heads */
memset(tpf->hash_head, 0, sizeof(tpf->hash_head));
@@ -373,7 +373,7 @@ void FollowTrack(uint tile, uint16 flags, byte direction, TPFEnumProc *enum_proc
}
if (after_proc != NULL)
- after_proc(tpf);
+ after_proc(tpf);
}
typedef struct {
@@ -439,10 +439,10 @@ static void INLINE HeapifyUp(NewTrackPathFinder *tpf)
{
StackedItem si;
int i = ++tpf->nstack;
-
+
while (i != 1 && ARR(i).cur_length < ARR(i>>1).cur_length) {
// the child element is larger than the parent item.
- // swap the child item and the parent item.
+ // swap the child item and the parent item.
si = ARR(i); ARR(i) = ARR(i>>1); ARR(i>>1) = si;
i>>=1;
}
@@ -462,13 +462,13 @@ static void INLINE HeapifyDown(NewTrackPathFinder *tpf)
while ((j=i*2) <= n) {
// figure out which is smaller of the children.
- if (j != n && ARR(j).cur_length > ARR(j+1).cur_length)
+ if (j != n && ARR(j).cur_length > ARR(j+1).cur_length)
j++; // right item is smaller
assert(i <= n && j <= n);
if (ARR(i).cur_length <= ARR(j).cur_length)
break; // base elem smaller than smallest, done!
-
+
// swap parent with the child
si = ARR(i); ARR(i) = ARR(j); ARR(j) = si;
i = j;
@@ -484,7 +484,7 @@ static bool NtpVisit(NewTrackPathFinder *tpf, uint tile, uint dir, uint length)
HashLink *link, *new_link;
assert(length < 1024);
-
+
hash = PATHFIND_HASH_TILE(tile);
// never visited before?
@@ -496,10 +496,10 @@ static bool NtpVisit(NewTrackPathFinder *tpf, uint tile, uint dir, uint length)
if (head != 0xffff) {
if ( (TileIndex)tile == tpf->hash_tile[hash] && (head & 0x3) == dir ) {
-
+
// longer length
if (length >= (head >> 2)) return false;
-
+
tpf->hash_head[hash] = dir | (length << 2);
return true;
}
@@ -517,13 +517,13 @@ static bool NtpVisit(NewTrackPathFinder *tpf, uint tile, uint dir, uint length)
tpf->hash_tile[hash] = NTP_GET_LINK_OFFS(tpf, link);
link->typelength = tpf->hash_head[hash];
- tpf->hash_head[hash] = 0xFFFF; /* multi link */
+ tpf->hash_head[hash] = 0xFFFF; /* multi link */
link->next = 0xFFFF;
} else {
// a linked list of many tiles,
// find the one corresponding to the tile, if it exists.
// otherwise make a new link
-
+
uint offs = tpf->hash_tile[hash];
do {
link = NTP_GET_LINK_PTR(tpf, offs);
@@ -534,7 +534,7 @@ static bool NtpVisit(NewTrackPathFinder *tpf, uint tile, uint dir, uint length)
}
} while ((offs=link->next) != 0xFFFF);
}
-
+
/* get here if we need to add a new link to link,
* first, allocate a new link, in the same way as before */
if (tpf->num_links_left == 0)
@@ -613,7 +613,7 @@ restart:
for(;;) {
tile += _tileoffs_by_dir[direction];
-
+
// too long search length? bail out.
if (++si.cur_length >= tpf->maxlength)
goto popnext;
@@ -628,7 +628,7 @@ restart:
// regular rail tile, determine the tracks that are actually reachable.
bits &= _bits_mask[direction];
if (bits == 0) goto popnext; // no tracks there? stop searching.
-
+
// complex tile?, let the generic handler handle that..
if (KILL_FIRST_BIT(bits) != 0) break;
@@ -656,16 +656,16 @@ restart:
// too high recursion depth.. bail out..
if (si.depth >= _patches.pf_maxdepth)
goto popnext;
-
+
si.depth++; // increase recursion depth.
// see if this tile was already visited..?
if (NtpVisit(tpf, tile, direction, si.cur_length)) {
- // push all possible alternatives
+ // push all possible alternatives
si.tile = tile;
do {
si.track = _new_track[FIND_FIRST_BIT(bits)][direction];
-
+
// out of stack items, bail out?
if (tpf->nstack >= lengthof(tpf->stack))
break;
@@ -678,11 +678,11 @@ restart:
// also randomize the order in which we search through them.
if (si.depth == 1) {
uint32 r = Random();
- assert(tpf->nstack == 2 || tpf->nstack == 3);
- if (r&1) swap_byte(&tpf->stack[0].track, &tpf->stack[1].track);
+ assert(tpf->nstack == 2 || tpf->nstack == 3);
+ if (r&1) swap_byte(&tpf->stack[0].track, &tpf->stack[1].track);
if (tpf->nstack != 2) {
byte t = tpf->stack[2].track;
- if (r&2) swap_byte(&tpf->stack[0].track, &t);
+ if (r&2) swap_byte(&tpf->stack[0].track, &t);
if (r&4) swap_byte(&tpf->stack[1].track, &t);
tpf->stack[2].first_track = tpf->stack[2].track = t;
}
@@ -702,7 +702,7 @@ popnext:
!NtpCheck(tpf, tile, _tpf_prev_direction[si.track], si.cur_length) || // already have better path to that tile?
tpf->enum_proc(tile, tpf->userdata, si.track, si.cur_length, &si.state)
);
-
+
direction = _tpf_new_direction[si.track];
goto restart;
}
@@ -718,7 +718,7 @@ void NewTrainPathfind(uint tile, byte direction, TPFEnumProc *enum_proc, void *d
tpf = alloca(sizeof(NewTrackPathFinder));
tpf->userdata = data;
- tpf->enum_proc = enum_proc;
+ tpf->enum_proc = enum_proc;
tpf->tracktype = 0;
tpf->maxlength = _patches.pf_maxlength;
tpf->nstack = 0;
diff --git a/road_gui.c b/road_gui.c
index a51dd16fd..0488e0308 100644
--- a/road_gui.c
+++ b/road_gui.c
@@ -128,17 +128,17 @@ static void BuildRoadClick_Raise(Window *w)
static void BuildRoadClick_Depot(Window *w)
{
- if (HandlePlacePushButton(w, 7, 0x511, 1, PlaceRoad_Depot)) ShowRoadDepotPicker();
+ if (HandlePlacePushButton(w, 7, 0x511, 1, PlaceRoad_Depot)) ShowRoadDepotPicker();
}
static void BuildRoadClick_BusStation(Window *w)
{
- if (HandlePlacePushButton(w, 8, 0xAA5, 1, PlaceRoad_BusStation)) ShowBusStationPicker();
+ if (HandlePlacePushButton(w, 8, 0xAA5, 1, PlaceRoad_BusStation)) ShowBusStationPicker();
}
static void BuildRoadClick_TruckStation(Window *w)
{
- if (HandlePlacePushButton(w, 9, 0xAA6, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker();
+ if (HandlePlacePushButton(w, 9, 0xAA6, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker();
}
static void BuildRoadClick_Bridge(Window *w)
@@ -244,7 +244,7 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) {
} else {
sel_method = VPM_X_OR_Y;
}
-
+
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, sel_method);
return;
}
@@ -257,8 +257,8 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) {
ResetObjectToPlace();
ShowBuildBridgeWindow(start_tile, end_tile, 0x80);
} else if (e->place.userdata != 4) {
- DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound1D,
- _remove_button_clicked ?
+ DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound1D,
+ _remove_button_clicked ?
CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) :
CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE));
} else {
@@ -363,9 +363,9 @@ static void BuildRoadDepotWndProc(Window *w, WindowEvent *e) {
SndPlayFx(0x13);
SetWindowDirty(w);
break;
- }
+ }
} break;
-
+
case WE_MOUSELOOP:
if (WP(w,def_d).close)
DeleteWindow(w);
@@ -445,7 +445,7 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e) {
break;
}
} break;
-
+
case WE_MOUSELOOP: {
if (WP(w,def_d).close) {
DeleteWindow(w);
@@ -454,7 +454,7 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e) {
CheckRedrawStationCoverage(w);
} break;
- }
+ }
}
static const Widget _bus_station_picker_widgets[] = {
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 9267b462b..c93ab2ee4 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -38,7 +38,7 @@ static const byte _roadveh_spritenum[88] = {
0, 17, 17, 34, 51, 51, 51, 1,
18, 35, 2, 19, 36, 57, 57, 57,
3, 20, 37, 4, 21, 38, 5, 22,
-
+
39, 6, 23, 40, 7, 24, 41, 8,
25, 42, 9, 26, 43, 10, 27, 44,
11, 28, 45, 12, 29, 46, 13, 30,
@@ -47,7 +47,7 @@ static const byte _roadveh_spritenum[88] = {
33, 50, 52, 52, 52, 53, 53, 53,
54, 54, 54, 55, 55, 55, 56, 56,
56, 58, 58, 58, 59, 59, 59, 60,
- 60, 60, 61, 61, 61, 62, 62, 62,
+ 60, 60, 61, 61, 61, 62, 62, 62,
};
const byte _roadveh_speed[88] = {
@@ -164,7 +164,7 @@ int GetRoadVehImage(Vehicle *v, byte direction)
img = _engine_original_sprites[v->engine_type];
}
#endif
-
+
image = direction + _roadveh_images[img];
if (v->cargo_count >= (v->cargo_cap >> 1))
image += _roadveh_full_adder[img];
@@ -186,7 +186,7 @@ void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw)
SET_DPARAM16(4, _roadveh_capacity[engine]);
SET_DPARAM16(3, _cargoc.names_long_p[_roadveh_cargo_type[engine]]);
-
+
DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
}
@@ -202,7 +202,7 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
byte unit_num;
uint tile = TILE_FROM_XY(x,y);
Engine *e;
-
+
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
cost = EstimateRoadVehCost(p1);
@@ -256,7 +256,7 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->reliability_spd_dec = e->reliability_spd_dec;
v->max_age = e->lifelength * 366;
_new_roadveh_id = v->index;
-
+
v->string_id = STR_SV_ROADVEH_NAME;
*(v->schedule_ptr = _ptr_to_next_order++) = 0;
@@ -303,7 +303,7 @@ int32 CmdSellRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Vehicle *v;
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
+
v = &_vehicles[p1];
if (v->type != VEH_Road || !CheckOwnership(v->owner))
@@ -311,7 +311,7 @@ int32 CmdSellRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!IsRoadDepotTile(v->tile) || v->u.road.state != 254 || !(v->vehstatus&VS_STOPPED))
return_cmd_error(STR_9013_MUST_BE_STOPPED_INSIDE);
-
+
if (flags & DC_EXEC) {
// Invalidate depot
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
@@ -321,7 +321,7 @@ int32 CmdSellRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
DeleteVehicle(v);
}
-
+
return -(int32)v->value;
}
@@ -351,7 +351,7 @@ static bool EnumRoadSignalFindDepot(uint tile, RoadFindDepotData *rfdd, int trac
if (IS_TILETYPE(tile, MP_STREET) &&
(_map5[tile] & 0xF0) == 0x20 &&
_map_owner[tile] == rfdd->owner) {
-
+
if (length < rfdd->best_length) {
rfdd->best_length = length;
rfdd->tile = tile;
@@ -365,7 +365,7 @@ static int FindClosestRoadDepot(Vehicle *v)
uint tile = v->tile;
int i;
RoadFindDepotData rfdd;
-
+
if (v->u.road.state == 255) { tile = GetVehicleOutOfTunnelTile(v); }
rfdd.owner = v->owner;
@@ -409,7 +409,7 @@ int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->dest_tile = _depots[depot].xy;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
}
-
+
return 0;
}
@@ -430,10 +430,10 @@ int32 CmdTurnRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
_error_message = STR_EMPTY;
return CMD_ERROR;
}
-
+
if (flags & DC_EXEC) {
v->u.road.reverse_ctr = 180;
- }
+ }
return 0;
}
@@ -495,10 +495,10 @@ static void ClearCrashedStation(Vehicle *v)
// mark station as not busy
bb &= ~0x80;
-
+
// free parking bay
bb |= (v->u.road.state&0x02)?2:1;
-
+
*b = bb;
}
@@ -506,17 +506,17 @@ static void RoadVehDelete(Vehicle *v)
{
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
-
+
_vehicle_sort_dirty[VEHROAD] = true; // delete bus/truck (eg. crash for example)
InvalidateWindow(WC_ROADVEH_LIST, v->owner);
InvalidateWindow(WC_COMPANY, v->owner);
if(IS_TILETYPE(v->tile, MP_STATION))
ClearCrashedStation(v);
-
+
BeginVehicleMove(v);
EndVehicleMove(v);
-
+
DeleteVehicle(v);
}
@@ -531,7 +531,7 @@ static byte SetRoadVehPosition(Vehicle *v, int x, int y)
old_z = v->z_pos;
v->z_pos = new_z;
-
+
VehiclePositionChanged(v);
EndVehicleMove(v);
return old_z;
@@ -621,10 +621,10 @@ static void HandleBrokenRoadVeh(Vehicle *v)
if (v->breakdowns_since_last_service != 255)
v->breakdowns_since_last_service++;
-
+
InvalidateWindow(WC_VEHICLE_VIEW, v->index);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
-
+
SndPlayVehicleFx((_opt.landscape != LT_CANDY) ? 0xD : 0x34, v);
if (!(v->vehstatus & VS_HIDDEN)) {
@@ -693,7 +693,7 @@ static void HandleRoadVehLoading(Vehicle *v)
{
if (v->next_order == OT_NOTHING)
return;
-
+
if (v->next_order != OT_DUMMY) {
if ((v->next_order&OT_MASK) != OT_LOADING)
return;
@@ -709,7 +709,7 @@ static void HandleRoadVehLoading(Vehicle *v)
}
return;
}
-
+
{
byte b = v->next_order;
v->next_order = OT_LEAVESTATION;
@@ -737,16 +737,16 @@ typedef struct RoadVehFindData {
void *EnumCheckRoadVehClose(Vehicle *v, RoadVehFindData *rvf)
{
- static const short _dists[] = {
+ static const short _dists[] = {
-4, -8, -4, -1, 4, 8, 4, 1,
-4, -1, 4, 8, 4, 1, -4, -8,
};
-
+
short x_diff = v->x_pos - rvf->x;
short y_diff = v->y_pos - rvf->y;
- if (rvf->veh == v ||
- v->type != VEH_Road ||
+ if (rvf->veh == v ||
+ v->type != VEH_Road ||
v->u.road.state == 254 ||
myabs(v->z_pos - rvf->veh->z_pos) > 6 ||
v->direction != rvf->dir ||
@@ -766,13 +766,13 @@ static Vehicle *RoadVehFindCloseTo(Vehicle *v, int x, int y, byte dir)
if (v->u.road.reverse_ctr != 0)
return NULL;
-
+
rvf.x = x;
rvf.y = y;
rvf.dir = dir;
rvf.veh = v;
u = VehicleFromPos(TILE_FROM_XY(x,y), &rvf, (VehicleFromPosProc*)EnumCheckRoadVehClose);
-
+
// This code protects a roadvehicle from being blocked for ever
// If more then 1480 / 74 days a road vehicle is blocked, it will
// drive just through it. The ultimate backup-code of TTD.
@@ -784,7 +784,7 @@ static Vehicle *RoadVehFindCloseTo(Vehicle *v, int x, int y, byte dir)
if (++v->u.road.unk2 > 1480)
return NULL;
-
+
return u;
}
@@ -825,13 +825,13 @@ static bool RoadVehAccelerate(Vehicle *v)
{
uint spd = v->cur_speed + 1 + ((v->u.road.overtaking != 0)?1:0);
byte t;
-
+
// Clamp
spd = min(spd, v->max_speed);
//updates statusbar only if speed have changed to save CPU time
if (spd != v->cur_speed) {
- v->cur_speed = spd;
+ v->cur_speed = spd;
if (_patches.vehicle_speed)
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
}
@@ -858,7 +858,7 @@ static byte RoadVehGetNewDirection(Vehicle *v, int x, int y)
1, 0, 5, 0,
2, 3, 4
};
-
+
x = x - v->x_pos + 1;
y = y - v->y_pos + 1;
@@ -878,7 +878,7 @@ static byte RoadVehGetSlidingDirection(Vehicle *v, int x, int y)
if (b==d) return d;
if (b==((d-1)&7)) return d;
if (b==((d-2)&7)) return d;
- return (d+2)&7;
+ return (d+2)&7;
}
typedef struct OvertakeData {
@@ -890,11 +890,11 @@ typedef struct OvertakeData {
void *EnumFindVehToOvertake(Vehicle *v, OvertakeData *od)
{
if (v->tile != (TileIndex)od->tile ||
- v->type != VEH_Road ||
- v == od->u ||
+ v->type != VEH_Road ||
+ v == od->u ||
v == od->v)
return NULL;
- return v;
+ return v;
}
static bool FindRoadVehToOvertake(OvertakeData *od)
@@ -1078,7 +1078,7 @@ do_it:;
if (desttile == tile && bitmask&_road_pf_table_3[m5&3]) {
return_track(FindFirstBit2x64(bitmask&_road_pf_table_3[m5&3]));
}
- }
+ }
}
// do pathfind
frd.dest = desttile;
@@ -1107,7 +1107,7 @@ found_best_track:;
if (HASBIT(signal, best_track))
return -1;
- return best_track;
+ return best_track;
}
typedef struct RoadDriveEntry {
@@ -1173,13 +1173,13 @@ static void RoadVehEventHandler(Vehicle *v)
byte rd2;
v->cur_speed = 0;
-
+
dir = _map5[v->tile]&3;
v->direction = dir*2+1;
rd2 = _roadveh_data_2[dir];
rdp = _road_drive_data[(_opt.road_side<<4) + rd2];
-
+
x = GET_TILE_X(v->tile)*16 + (rdp[6].x&0xF);
y = GET_TILE_Y(v->tile)*16 + (rdp[6].y&0xF);
@@ -1193,7 +1193,7 @@ static void RoadVehEventHandler(Vehicle *v)
v->vehstatus &= ~VS_HIDDEN;
v->u.road.state = rd2;
v->u.road.frame = 6;
-
+
v->cur_image = GetRoadVehImage(v, v->direction);
UpdateRoadVehDeltaXY(v);
SetRoadVehPosition(v,x,y);
@@ -1223,7 +1223,7 @@ static void RoadVehEventHandler(Vehicle *v)
if (IS_TILETYPE(gp.new_tile, MP_TUNNELBRIDGE) &&
(_map5[gp.new_tile]&0xF0) == 0 &&
(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y)&4)) {
-
+
//new_dir = RoadGetNewDirection(v, gp.x, gp.y)
v->cur_image = GetRoadVehImage(v, v->direction);
UpdateRoadVehDeltaXY(v);
@@ -1353,7 +1353,7 @@ again:
x = (v->x_pos&~15)+(rd.x&15);
y = (v->y_pos&~15)+(rd.y&15);
-
+
new_dir = RoadVehGetSlidingDirection(v, x, y);
if (!IS_BYTE_INSIDE(v->u.road.state, 0x20, 0x30) && (u=RoadVehFindCloseTo(v, x, y, new_dir)) != NULL) {
@@ -1383,7 +1383,7 @@ again:
if ( (v->next_order&OT_MASK) != OT_LEAVESTATION &&
(v->next_order&OT_MASK) != OT_GOTO_DEPOT) {
-
+
*b &= ~0x80;
v->last_station_visited = _map2[v->tile];
@@ -1393,7 +1393,7 @@ again:
old_order = v->next_order;
v->next_order = OT_LOADING;
- if ((old_order & OT_MASK) == OT_GOTO_STATION &&
+ if ((old_order & OT_MASK) == OT_GOTO_STATION &&
v->next_order_param == v->last_station_visited) {
v->next_order = OT_LOADING | OF_NON_STOP | (old_order & (OF_FULL_LOAD|OF_UNLOAD));
}
@@ -1449,10 +1449,10 @@ void RoadVehEnterDepot(Vehicle *v)
MaybeRenewVehicle(v, EstimateRoadVehCost(v->engine_type));
-
+
if ((v->next_order&OT_MASK) == OT_GOTO_DEPOT) {
InvalidateWindow(WC_VEHICLE_VIEW, v->index);
-
+
t = v->next_order;
v->next_order = OT_DUMMY;
@@ -1504,7 +1504,7 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
if (_patches.gotodepot && ScheduleHasDepotOrders(v->schedule_ptr))
return;
-
+
// Don't interfere with a depot visit scheduled by the user, or a
// depot visit by the order list.
if ((v->next_order & OT_MASK) == OT_GOTO_DEPOT &&
@@ -1527,7 +1527,7 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
v->next_order = OT_GOTO_DEPOT | OF_NON_STOP;
v->next_order_param = (byte)i;
v->dest_tile = (&_depots[i])->xy;
- InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+ InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
}
void OnNewDay_RoadVeh(Vehicle *v)
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 21b8b568d..3ac65a3e3 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -51,7 +51,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
StringID str;
SET_DPARAM16(1, year);
-
+
str = STR_0199_YEAR;
if (year != 1) {
str++;
@@ -97,7 +97,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
SET_DPARAM16(1, 1920 + v->build_year);
SET_DPARAM32(2, v->value);
DrawString(34, 57, STR_9011_BUILT_VALUE, 0);
-
+
SET_DPARAM16(0, _cargoc.names_long_p[v->cargo_type]);
SET_DPARAM16(1, v->cargo_cap);
DrawString(34, 67, STR_9012_CAPACITY, 0);
@@ -180,7 +180,7 @@ static void ShowRoadVehDetailsWindow(Vehicle *v)
VehicleID veh = v->index;
DeleteWindowById(WC_VEHICLE_ORDERS, veh);
DeleteWindowById(WC_VEHICLE_DETAILS, veh);
- _alloc_wnd_parent_num = veh;
+ _alloc_wnd_parent_num = veh;
w = AllocateWindowDesc(&_roadveh_details_desc);
w->window_number = veh;
w->caption_color = v->owner;
@@ -242,13 +242,13 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e)
DrawStringCentered(125, 105, str, 0);
DrawWindowViewport(w);
} break;
-
+
case WE_CLICK: {
Vehicle *v = &_vehicles[w->window_number];
switch(e->click.widget) {
case 4: /* start stop */
- DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE));
+ DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE));
break;
case 5: /* center main view */
ScrollMainWindowTo(v->x_pos, v->y_pos);
@@ -267,11 +267,11 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e)
break;
}
} break;
-
+
case WE_DESTROY:
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
- break;
+ break;
}
}
@@ -348,7 +348,7 @@ static void DrawNewRoadVehWindow(Window *w)
DrawRoadVehEngine(x+29, y+6, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
y += 14;
}
- sel--;
+ sel--;
}
} while (++engine_id, ++e,--num);
@@ -362,12 +362,12 @@ static void DrawNewRoadVehWindow(Window *w)
SET_DPARAM16(4, _roadveh_capacity[selected_id - ROAD_ENGINES_INDEX]);
SET_DPARAM16(3, _cargoc.names_long_p[_roadveh_cargo_type[selected_id - ROAD_ENGINES_INDEX]]);
- e = &_engines[selected_id];
+ e = &_engines[selected_id];
SET_DPARAM16(6, e->lifelength);
SET_DPARAM8(7, e->reliability * 100 >> 16);
ConvertDayToYMD(&ymd, e->intro_date);
SET_DPARAM16(5, ymd.year + 1920);
-
+
DrawString(2, 127, STR_9008_COST_SPEED_RUNNING_COST, 0);
}
}
@@ -419,7 +419,7 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e)
160,
w->window_class,
w->window_number);
- break;
+ break;
}
break;
@@ -436,8 +436,8 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e)
memcpy(_decode_parameters, b, 32);
DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_9037_CAN_T_RENAME_ROAD_VEHICLE));
} break;
-
- }
+
+ }
}
static const Widget _new_road_veh_widgets[] = {
@@ -468,7 +468,7 @@ static void ShowBuildRoadVehWindow(TileIndex tile)
w = AllocateWindowDesc(&_new_road_veh_desc);
w->window_number = tile;
w->vscroll.cap = 8;
-
+
if (tile != 0) {
w->caption_color = _map_owner[tile];
} else {
@@ -509,17 +509,17 @@ static void DrawRoadDepotWindow(Window *w)
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_Road &&
- v->u.road.state == 254 &&
+ v->u.road.state == 254 &&
v->tile == (TileIndex)tile &&
--num < 0 && num >= -15) {
DrawRoadVehImage(v, x+24, y, WP(w,traindepot_d).sel);
-
+
SET_DPARAM16(0, v->unitnumber);
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0);
DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x + 16, y);
-
+
if ((x+=56) == 2+56*5) {
x = 2;
y += 14;
@@ -534,7 +534,7 @@ static int GetVehicleFromRoadDepotWndPt(Window *w, int x, int y, Vehicle **veh)
TileIndex tile;
Vehicle *v;
int pos;
-
+
xt = x / 56;
xm = x % 56;
if (xt >= 5)
@@ -549,7 +549,7 @@ static int GetVehicleFromRoadDepotWndPt(Window *w, int x, int y, Vehicle **veh)
tile = w->window_number;
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_Road &&
- v->u.road.state == 254 &&
+ v->u.road.state == 254 &&
v->tile == (TileIndex)tile &&
--pos < 0) {
*veh = v;
@@ -611,7 +611,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
case 2:
RoadDepotClickVeh(w, e->click.pt.x, e->click.pt.y);
break;
-
+
case 5:
ShowBuildRoadVehWindow(w->window_number);
break;
@@ -621,7 +621,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
break;
}
} break;
-
+
case WE_DESTROY:
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number);
break;
@@ -641,12 +641,12 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
ShowRoadVehViewWindow(v);
}
} break;
-
+
case 3:
if (!HASBIT(w->disabled_state, 3) &&
WP(w,traindepot_d).sel != INVALID_VEHICLE) {
Vehicle *v;
-
+
HandleButtonClick(w, 3);
v = &_vehicles[WP(w,traindepot_d).sel];
@@ -654,7 +654,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
_backup_orders_tile = v->tile;
BackupVehicleOrders(v, _backup_orders_data);
-
+
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_ROAD_VEH | CMD_MSG(STR_9014_CAN_T_SELL_ROAD_VEHICLE)))
_backup_orders_tile = 0;
}
@@ -693,7 +693,7 @@ static const WindowDesc _road_depot_desc = {
void ShowRoadDepotWindow(uint tile)
{
Window *w;
-
+
w = AllocateWindowDescFront(&_road_depot_desc, tile);
if (w) {
w->caption_color = _map_owner[w->window_number];
@@ -730,7 +730,7 @@ static void MakeSortedRoadList(byte owner)
// roads are stored as a cummulative index, eg 25, 41, 43. This means
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2
for (i = &_num_road_sort[1]; i != endof(_num_road_sort); i++) {*i += *(i-1);}
-
+
// sort by owner, then only subsort the requested owner-vehicles
qsort(_road_sort, n, sizeof(_road_sort[0]), GeneralOwnerSorter);
@@ -775,7 +775,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 roads
i = (window_number == 0) ? 0 : _num_road_sort[window_number-1];
SetVScrollCount(w, _num_road_sort[window_number] - i);
-
+
/* draw the widgets */
{
Player *p = DEREF_PLAYER(window_number);
@@ -818,7 +818,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
SET_DPARAM32(0, v->profit_this_year);
SET_DPARAM32(1, v->profit_last_year);
DrawString(x + 24, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
-
+
if (v->string_id != STR_SV_ROADVEH_NAME) {
SET_DPARAM16(0, v->string_id);
DrawString(x+24, y, STR_01AB, 0);
@@ -843,7 +843,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
return;
case 6: { /* Matrix to show vehicles */
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
-
+
if (id_v >= w->vscroll.cap) { return;} // click out of bounds
id_v += w->vscroll.pos;
@@ -868,15 +868,15 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
tile = _last_built_road_depot_tile;
do {
- if (_map_owner[tile] == _local_player && IsRoadDepotTile(tile)) {
+ if (_map_owner[tile] == _local_player && IsRoadDepotTile(tile)) {
ShowRoadDepotWindow(tile);
ShowBuildRoadVehWindow(tile);
return;
}
-
+
tile = TILE_MASK(tile + 1);
} while(tile != _last_built_road_depot_tile);
-
+
ShowBuildRoadVehWindow(0);
} break;
}
diff --git a/saveload.c b/saveload.c
index 139d86d63..87d4878a4 100644
--- a/saveload.c
+++ b/saveload.c
@@ -88,7 +88,7 @@ static void SlWriteFill()
_sl.offs_base += len;
if (len) _sl.write_bytes(len);
}
-
+
// setup next buffer
_sl.bufp = _sl.buf;
_sl.bufe = _sl.buf + _sl.bufsize;
@@ -203,7 +203,7 @@ int SlIterateArray()
{
int ind;
static uint32 next_offs;
-
+
// Must be at end of current block.
assert(next_offs == 0 || SlGetOffs() == next_offs);
@@ -224,7 +224,7 @@ int SlIterateArray()
DEBUG(misc, 0) ("SlIterateArray: error\n");
return -1; // error
}
-
+
if (len != 0)
return ind;
}
@@ -300,7 +300,7 @@ uint SlGetFieldLength()
static void SlSaveLoadConv(void *ptr, uint conv)
{
int64 x = 0;
-
+
if (_sl.save) {
// Read a value from the struct. These ARE endian safe.
switch((conv >> 4)&0xf) {
@@ -310,7 +310,7 @@ static void SlSaveLoadConv(void *ptr, uint conv)
case SLE_VAR_U16>>4: x = *(uint16*)ptr; break;
case SLE_VAR_I32>>4: x = *(int32*)ptr; break;
case SLE_VAR_U32>>4: x = *(uint32*)ptr; break;
- case SLE_VAR_I64>>4: x = *(int64*)ptr; break;
+ case SLE_VAR_I64>>4: x = *(int64*)ptr; break;
case SLE_VAR_U64>>4: x = *(uint64*)ptr; break;
case SLE_VAR_NULL>>4: x = 0; break;
default:
@@ -333,7 +333,7 @@ static void SlSaveLoadConv(void *ptr, uint conv)
NOT_REACHED();
}
} else {
-
+
// Read a value from the file
switch(conv & 0xF) {
case SLE_FILE_I8: x = (int8)SlReadByte(); break;
@@ -441,7 +441,7 @@ static size_t SlCalcObjLength(void *object, const void *desc)
switch(cmd&3) {
// Normal variable
- case 0: length += SlCalcConvLen(conv, NULL);break;
+ case 0: length += SlCalcConvLen(conv, NULL);break;
// Reference
case 1: length += 2; break;
// Array
@@ -509,7 +509,7 @@ void SlObject(void *object, const void *desc)
case 2: SlArray(ptr, *d++, conv); break;
default:NOT_REACHED();
}
-
+
// Write byte.
} else if (cmd == 8) {
if (_sl.save) {
@@ -592,7 +592,7 @@ static void SlLoadChunk(const ChunkHandler *ch)
_sl.block_mode = m;
_sl.obj_len = 0;
-
+
switch(m) {
case CH_ARRAY:
_sl.array_index = 0;
@@ -641,7 +641,7 @@ static void SlSaveChunk(const ChunkHandler *ch)
_tmp_proc_1 = proc;
proc = SlStubSaveProc;
}
-
+
_sl.block_mode = ch->flags & CH_TYPE_MASK;
switch(ch->flags & CH_TYPE_MASK) {
case CH_RIFF:
@@ -674,7 +674,7 @@ void SlSaveChunks()
for(chsc=_sl.chs;(ch=*chsc++) != NULL;) {
while(true) {
if (((ch->flags >> CH_PRI_SHL) & (CH_NUM_PRI_LEVELS - 1)) == p)
- SlSaveChunk(ch);
+ SlSaveChunk(ch);
if (ch->flags & CH_LAST)
break;
ch++;
@@ -741,7 +741,7 @@ static uint ReadLZO()
// Check if size is bad
((uint32*)out)[0] = size = tmp[1];
-
+
if (_sl.version != 0) {
tmp[0] = TO_BE32(tmp[0]);
size = TO_BE32(size);
@@ -754,7 +754,7 @@ static uint ReadLZO()
// Verify checksum
if (tmp[0] != lzo_adler32(0, out, size + sizeof(uint32))) SlError("bad checksum");
-
+
// Decompress
lzo1x_decompress(out + sizeof(uint32)*1, size, _sl.buf, &len, NULL);
return len;
@@ -767,7 +767,7 @@ static void WriteLZO(uint size)
byte out[LZO_SIZE + LZO_SIZE / 64 + 16 + 3 + 8];
byte wrkmem[sizeof(byte*)*4096];
uint outlen;
-
+
lzo1x_1_compress(_sl.buf, size, out + sizeof(uint32)*2, &outlen, wrkmem);
((uint32*)out)[1] = TO_BE32(outlen);
((uint32*)out)[0] = TO_BE32(lzo_adler32(0, out + sizeof(uint32), outlen + sizeof(uint32)));
@@ -821,7 +821,7 @@ static bool InitReadZlib()
{
memset(&_z, 0, sizeof(_z));
if (inflateInit(&_z) != Z_OK) return false;
-
+
_sl.bufsize = 4096;
_sl.buf = (byte*)malloc(4096 + 4096); // also contains fread buffer
return true;
@@ -845,7 +845,7 @@ static uint ReadZlib()
if (r == Z_STREAM_END)
break;
- if (r != Z_OK)
+ if (r != Z_OK)
SlError("inflate() failed");
} while (_z.avail_out);
@@ -1020,7 +1020,7 @@ int SaveOrLoad(const char *filename, int mode)
uint32 hdr[2];
const SaveLoadFormat *fmt;
uint version;
-
+
// old style load
if (mode == SL_OLD_LOAD) {
InitializeGame();
@@ -1028,11 +1028,11 @@ int SaveOrLoad(const char *filename, int mode)
AfterLoadGame(0);
return SL_OK;
}
-
+
_sl.fh = fopen(filename, mode?"wb":"rb");
if (_sl.fh == NULL)
return SL_ERROR;
-
+
_sl.bufe = _sl.bufp = NULL;
_sl.offs_base = 0;
_sl.int_to_ref_proc = IntToReference;
@@ -1060,23 +1060,23 @@ int SaveOrLoad(const char *filename, int mode)
}
}
- // we first initialize here to avoid: "warning: variable `version' might
+ // we first initialize here to avoid: "warning: variable `version' might
// be clobbered by `longjmp' or `vfork'"
version = 0;
if (mode != SL_LOAD) {
fmt = GetSavegameFormat(_savegame_format);
-
+
_sl.write_bytes = fmt->writer;
_sl.excpt_uninit = fmt->uninit_write;
if (!fmt->init_write()) goto init_err;
-
+
hdr[0] = fmt->tag;
hdr[1] = TO_BE32((SAVEGAME_MAJOR_VERSION<<16) + (SAVEGAME_MINOR_VERSION << 8));
if (fwrite(hdr, sizeof(hdr), 1, _sl.fh) != 1) SlError("file write failed");
-
+
_sl.version = SAVEGAME_MAJOR_VERSION;
-
+
BeforeSaveGame();
SlSaveChunks();
SlWriteFill(); // flush the save buffer
@@ -1104,7 +1104,7 @@ init_err:
if (fmt->tag == hdr[0]) {
// check version number
version = TO_BE32(hdr[1]) >> 8;
-
+
// incompatible version?
if (version > SAVEGAME_LOADABLE_VERSION) goto read_err;
_sl.version = (version>>8);
diff --git a/screenshot.c b/screenshot.c
index a7b8bf655..c352844e5 100644
--- a/screenshot.c
+++ b/screenshot.c
@@ -23,7 +23,7 @@ typedef struct {
#pragma pack(push, 1)
#endif
-typedef struct BitmapFileHeader {
+typedef struct BitmapFileHeader {
uint16 type;
uint32 size;
uint32 reserved;
@@ -113,12 +113,12 @@ static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *user
// determine # lines
n = min(h, maxlines);
h -= n;
-
+
// render the pixels
callb(userdata, buff, h, padw, n);
-
- // write each line
- while (n)
+
+ // write each line
+ while (n)
fwrite(buff + (--n) * padw, 1, padw, f);
} while (h);
@@ -182,10 +182,10 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
}
png_init_io(png_ptr, f);
-
+
png_set_filter(png_ptr, 0, PNG_FILTER_NONE);
- png_set_IHDR(png_ptr, info_ptr, w, h, pixelformat, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
+ png_set_IHDR(png_ptr, info_ptr, w, h, pixelformat, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
// convert the palette to the .PNG format.
@@ -215,7 +215,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
do {
// determine # lines to write
n = min(h - y, maxlines);
-
+
// render the pixels into the buffer
callb(userdata, buff, y, w, n);
y += n;
@@ -272,7 +272,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
if (f == NULL) return false;
memset(&pcx, 0, sizeof(pcx));
-
+
// setup pcx header
pcx.manufacturer = 10;
pcx.version = 5;
@@ -287,7 +287,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
pcx.cpal = TO_LE16(1);
pcx.width = pcx.pitch = TO_LE16(w);
pcx.height = TO_LE16(h);
-
+
// write pcx header
fwrite(&pcx, sizeof(pcx), 1, f);
@@ -302,7 +302,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
do {
// determine # lines to write
uint n = min(h - y, maxlines), i;
-
+
// render the pixels into the buffer
callb(userdata, buff, y, w, n);
y += n;
@@ -314,7 +314,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
byte runchar = buff[0];
uint left = w - 1;
- // for each pixel...
+ // for each pixel...
while (left) {
byte ch = *bufp++;
if (ch != runchar || runcount >= 0x3f) {
@@ -334,7 +334,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
} while (y != h);
// write 8-bit color palette
- fputc(12, f);
+ fputc(12, f);
fwrite(palette, 256*3, 1, f);
fclose(f);
@@ -404,8 +404,8 @@ void LargeWorldCallback(void *userdata, byte *buf, uint y, uint pitch, uint n)
while (vp->width - left != 0) {
wx = min(vp->width - left, 1600);
left += wx;
-
- ViewportDoDraw(vp,
+
+ ViewportDoDraw(vp,
((left - wx - vp->left) << vp->zoom) + vp->virtual_left,
((y - vp->top) << vp->zoom) + vp->virtual_top,
((left - vp->left) << vp->zoom) + vp->virtual_left,
@@ -437,7 +437,7 @@ static char *MakeScreenshotName(const char *ext)
serial = 0;
for(;;) {
- snprintf(filename, sizeof(filename), "%s%s", _path.personal_dir, _screenshot_name);
+ snprintf(filename, sizeof(filename), "%s%s", _path.personal_dir, _screenshot_name);
if (!FileExists(filename))
break;
sprintf(base, " #%d.%s", ++serial, ext);
@@ -451,7 +451,7 @@ extern byte _cur_palette[768];
bool MakeScreenshot()
{
const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format;
- return sf->proc(MakeScreenshotName(sf->extension), CurrentScreenCallback, NULL, _screen.width, _screen.height, 8, _cur_palette);
+ return sf->proc(MakeScreenshotName(sf->extension), CurrentScreenCallback, NULL, _screen.width, _screen.height, 8, _cur_palette);
}
bool MakeWorldScreenshot(int left, int top, int width, int height, int zoom)
diff --git a/sdl.c b/sdl.c
index 4aeb8ba1b..56c16add2 100644
--- a/sdl.c
+++ b/sdl.c
@@ -23,7 +23,7 @@ static bool _all_modes;
static SDL_Rect _dirty_rects[MAX_DIRTY_RECTS];
static int _num_dirty_rects;
-#define SDL_CALL
+#define SDL_CALL
#if defined(DYNAMICALLY_LOADED_SDL) && defined(WIN32)
@@ -60,7 +60,7 @@ typedef struct {
} SDLProcs;
#define M(x) x "\0"
-static const char sdl_files[] =
+static const char sdl_files[] =
M("sdl.dll")
M("SDL_Init")
M("SDL_InitSubSystem")
@@ -97,7 +97,7 @@ static SDLProcs _proc;
static char *LoadSdlDLL()
{
- if (_proc.SDL_Init != NULL)
+ if (_proc.SDL_Init != NULL)
return NULL;
if (!LoadLibraryList((void**)&_proc, sdl_files))
return "Unable to load sdl.dll";
@@ -247,7 +247,7 @@ static void GetVideoModes(void) {
for(i = 0; modes[i]; i++) {
int w = modes[i]->w;
int h = modes[i]->h;
- if (IS_INT_INSIDE(w, 640, MAX_SCREEN_WIDTH+1) &&
+ if (IS_INT_INSIDE(w, 640, MAX_SCREEN_WIDTH+1) &&
IS_INT_INSIDE(h, 480, MAX_SCREEN_HEIGHT+1) &&
w%8 == 0 && h%8 == 0) { // disable screen resolutions which are not multiples of 8
int j;
@@ -363,7 +363,7 @@ static const VkMapping _vk_mapping[] = {
AS(SDLK_KP_PLUS, WKC_NUM_PLUS),
AS(SDLK_KP_ENTER, WKC_NUM_ENTER),
AS(SDLK_KP_PERIOD, WKC_NUM_DECIMAL),
- {0, 0, 0}
+ {0, 0, 0}
};
static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
@@ -376,7 +376,7 @@ static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
from = map->vk_from;
if (from == 0) {
key = 0;
- break;
+ break;
}
if ((uint)(key - from) <= map->vk_count) {
key = key - from + map->map_to;
@@ -444,7 +444,7 @@ static int PollEvent() {
_right_button_down = true;
_right_button_clicked = true;
}
-#if !defined(WIN32)
+#if !defined(WIN32)
else if (ev.button.button == SDL_BUTTON_WHEELUP) {
_cursor.wheel--;
} else if (ev.button.button == SDL_BUTTON_WHEELDOWN) {
@@ -479,17 +479,17 @@ static int PollEvent() {
_pressed_key = ConvertSdlKeyIntoMy(&ev.key.keysym);
}
break;
-
+
case SDL_VIDEORESIZE: {
int w, h;
w = ev.resize.w;
h = ev.resize.h;
-
+
w = clamp(w & ~0x7, 64, MAX_SCREEN_WIDTH);
h = clamp(h & ~0x7, 64, MAX_SCREEN_HEIGHT);
-
+
ChangeResInGame(w, h);
-
+
break;
}
}
@@ -529,14 +529,14 @@ static int SdlVideoMainLoop()
while (true) {
InteractiveRandom(); // randomness
-
+
while ((i=PollEvent()) == -1) {}
if (i>=0) return i;
if (_exit_game) return ML_QUIT;
mod = SDL_CALL SDL_GetModState();
- keys = SDL_CALL SDL_GetKeyState(&numkeys);
+ keys = SDL_CALL SDL_GetKeyState(&numkeys);
#if defined(_DEBUG)
if (_shift_pressed) {
#else
@@ -556,12 +556,12 @@ static int SdlVideoMainLoop()
_ctrl_pressed = !!(mod & (KMOD_LCTRL | KMOD_RCTRL));
_shift_pressed = !!(mod & (KMOD_LSHIFT | KMOD_RSHIFT));
-
+
// determine which directional keys are down
- _dirkeys =
- (keys[SDLK_LEFT] ? 1 : 0) +
- (keys[SDLK_UP] ? 2 : 0) +
- (keys[SDLK_RIGHT] ? 4 : 0) +
+ _dirkeys =
+ (keys[SDLK_LEFT] ? 1 : 0) +
+ (keys[SDLK_UP] ? 2 : 0) +
+ (keys[SDLK_RIGHT] ? 4 : 0) +
(keys[SDLK_DOWN] ? 8 : 0);
GameLoop();
@@ -607,7 +607,7 @@ static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
static char *SdlSoundStart(char **parm)
{
SDL_AudioSpec spec;
-
+
{char *s;if ((s = SdlOpen(SDL_INIT_AUDIO)) != NULL) return s;}
spec.freq = GetDriverParamInt(parm, "hz", 11025);
spec.format = AUDIO_S16SYS;
diff --git a/settings.c b/settings.c
index 84eecc1a2..6a0823d46 100644
--- a/settings.c
+++ b/settings.c
@@ -50,7 +50,7 @@ static MemoryPool *pool_new(uint minsize)
{
MemoryPool *p;
if (minsize < 4096 - 12) minsize = 4096 - 12;
-
+
p = malloc(sizeof(MemoryPool) - 1 + minsize);
p->pos = 0;
p->size = minsize;
@@ -78,7 +78,7 @@ static void *pool_alloc(MemoryPool **pool, uint size)
MemoryPool *n = pool_new(size);
*pool = n;
n->next = p;
- p = n;
+ p = n;
}
pos = p->pos;
@@ -188,7 +188,7 @@ static IniFile *ini_load(const char *filename)
// for each line in the file
while (fgets(buffer, sizeof(buffer), in)) {
-
+
// trim whitespace from the left side
for(s=buffer; *s == ' ' || *s == '\t'; s++);
@@ -230,7 +230,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++) {}
-
+
// it's an item in an existing group
item = ini_item_alloc(group, s, t-s);
if (comment_size) {
@@ -285,7 +285,7 @@ static IniItem *ini_getitem(IniGroup *group, const char *name, bool create)
for(item = group->item; item; item = item->next)
if (!strcmp(item->name, name))
return item;
-
+
if (!create) return NULL;
// otherwise make a new one
@@ -299,7 +299,7 @@ static bool ini_save(const char *filename, IniFile *ini)
FILE *f;
IniGroup *group;
IniItem *item;
-
+
f = fopen(filename, "w");
if (f == NULL) return false;
@@ -328,7 +328,7 @@ struct SettingDesc {
void *def;
void *ptr;
void *b;
-
+
};
static int lookup_oneofmany(const char *many, const char *one, int onelen)
@@ -341,7 +341,7 @@ static int lookup_oneofmany(const char *many, const char *one, int onelen)
// check if it's an integer
if (*one >= '0' && *one <= '9')
return strtoul(one, NULL, 0);
-
+
idx = 0;
for(;;) {
// find end of item
@@ -400,7 +400,7 @@ static bool load_intlist(const char *str, void *array, int nelems, int type)
{
int items[64];
int i,nitems;
-
+
if (str == NULL) {
memset(items, 0, sizeof(items));
nitems = nelems;
@@ -522,7 +522,7 @@ static void *string_to_val(const SettingDesc *desc, const char *str)
return (void*)false;
ShowInfoF("ini: invalid setting value '%s' for '%s'", str, desc->name);
break;
-
+
case SDT_STRING:
case SDT_STRINGBUF:
case SDT_INTLIST:
@@ -549,14 +549,14 @@ static void load_setting_desc(IniFile *ini, const SettingDesc *desc, void *grpna
s = desc->name;
group = group_def;
}
-
+
item = ini_getitem(group, s, false);
if (!item) {
p = desc->def;
} else {
p = string_to_val(desc, item->value);
}
-
+
// get ptr to array
ptr = desc->ptr;
if ( (uint32)ptr < 0x10000)
@@ -600,7 +600,7 @@ static void load_setting_desc(IniFile *ini, const SettingDesc *desc, void *grpna
default:
NOT_REACHED();
}
- }
+ }
}
static void save_setting_desc(IniFile *ini, const SettingDesc *desc, void *grpname, void *base)
@@ -615,7 +615,7 @@ static void save_setting_desc(IniFile *ini, const SettingDesc *desc, void *grpna
for (;desc->name;desc++) {
if (desc->flags & SDT_NOSAVE)
continue;
-
+
// group override?
s = strchr(desc->name, '.');
if (s) {
@@ -627,16 +627,16 @@ static void save_setting_desc(IniFile *ini, const SettingDesc *desc, void *grpna
s = desc->name;
group = group_def;
}
-
+
item = ini_getitem(group, s, true);
// get ptr to array
ptr = desc->ptr;
if ( (uint32)ptr < 0x10000)
ptr = (byte*)base + (uint32)ptr;
-
+
if (item->value != NULL) {
- // check if the value is the same as the old value
+ // check if the value is the same as the old value
p = string_to_val(desc, item->value);
switch(desc->flags & 0xF) {
@@ -658,7 +658,7 @@ static void save_setting_desc(IniFile *ini, const SettingDesc *desc, void *grpna
case SDT_INT32 >> 4:
case SDT_UINT32 >> 4:
if (*(uint32*)ptr == (uint32)p)
- continue;
+ continue;
break;
default:
NOT_REACHED();
@@ -717,7 +717,7 @@ static void save_setting_desc(IniFile *ini, const SettingDesc *desc, void *grpna
}
// the value is different, that means we have to write it to the ini
item->value = pool_strdup(&ini->pool, buf, strlen(buf));
- }
+ }
}
//***************************
@@ -826,7 +826,7 @@ static const SettingDesc patch_settings[] = {
{"nonuniform_stations", SDT_BOOL, (void*)false, (void*)offsetof(Patches, nonuniform_stations), NULL},
{"always_small_airport",SDT_BOOL, (void*)false, (void*)offsetof(Patches, always_small_airport), NULL},
{"realistic_acceleration",SDT_BOOL, (void*)false, (void*)offsetof(Patches, realistic_acceleration), NULL},
-
+
{"toolbar_pos", SDT_UINT8, (void*)0, (void*)offsetof(Patches, toolbar_pos), NULL},
{"max_trains", SDT_UINT8, (void*)80, (void*)offsetof(Patches, max_trains), NULL},
@@ -848,7 +848,7 @@ static const SettingDesc patch_settings[] = {
{"pf_maxlength", SDT_UINT16, (void*)512, (void*)offsetof(Patches, pf_maxlength), NULL},
{"pf_maxdepth", SDT_UINT8, (void*)16, (void*)offsetof(Patches, pf_maxdepth), NULL},
-
+
{"ai_disable_veh_train",SDT_BOOL, (void*)false, (void*)offsetof(Patches, ai_disable_veh_train), NULL},
{"ai_disable_veh_roadveh",SDT_BOOL, (void*)false, (void*)offsetof(Patches, ai_disable_veh_roadveh), NULL},
{"ai_disable_veh_aircraft",SDT_BOOL,(void*)false, (void*)offsetof(Patches, ai_disable_veh_aircraft),NULL},
@@ -875,7 +875,7 @@ static const SettingDesc patch_settings[] = {
{"wait_oneway_signal", SDT_UINT8, (void*)15, (void*)offsetof(Patches, wait_oneway_signal), NULL},
{"wait_twoway_signal", SDT_UINT8, (void*)41, (void*)offsetof(Patches, wait_twoway_signal), NULL},
-
+
{"ainew_active", SDT_BOOL, (void*)false, (void*)offsetof(Patches, ainew_active), NULL},
{"drag_signals_density",SDT_UINT8, (void*)4, (void*)offsetof(Patches, drag_signals_density), NULL},
diff --git a/settings_gui.c b/settings_gui.c
index 83173aaca..75e141319 100644
--- a/settings_gui.c
+++ b/settings_gui.c
@@ -117,11 +117,11 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
// setup screenshot format dropdown
ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, e->click.widget, 0);
return;
-
+
}
break;
- case WE_DROPDOWN_SELECT:
+ case WE_DROPDOWN_SELECT:
switch(e->dropdown.button) {
case 20:
if (e->dropdown.index == 0) {
@@ -220,7 +220,7 @@ static const Widget _game_options_widgets[] = {
{ WWT_CLOSEBOX, 14, 130, 349, 202, 213, STR_02C0_SAVE_CUSTOM_NAMES_TO_DISK, STR_02C2_SAVE_CUSTOMIZED_VEHICLE},
{ WWT_FRAME, 14, 190, 359, 104, 139, STR_OPTIONS_LANG, STR_NULL},
-{ WWT_6, 14, 200, 349, 118, 129, STR_OPTIONS_LANG_CBO, STR_OPTIONS_LANG_TIP},
+{ WWT_6, 14, 200, 349, 118, 129, STR_OPTIONS_LANG_CBO, STR_OPTIONS_LANG_TIP},
{ WWT_CLOSEBOX, 14, 338, 348, 119, 128, STR_0225, STR_OPTIONS_LANG_TIP},
{ WWT_FRAME, 14, 10, 179, 146, 181, STR_OPTIONS_RES, STR_NULL},
{ WWT_6, 14, 20, 169, 160, 171, STR_OPTIONS_RES_CBO, STR_OPTIONS_RES_TIP},
@@ -354,7 +354,7 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
uint btn, dis;
int val;
const GameSettingData *info;
-
+
x = e->click.pt.x - 5;
if (!IS_INT_INSIDE(x, 0, 21))
return;
@@ -470,7 +470,7 @@ void ShowGameDifficulty()
*/
memcpy(&_opt_mod_temp, _opt_mod_ptr, sizeof(GameOptions));
AllocateWindowDesc(&_game_difficulty_desc);
-}
+}
void ShowHighscoreTable(int tbl)
{
@@ -490,7 +490,7 @@ int32 AiNew_PatchActive_Warning(int32 p1)
{
if (p1 == 1)
ShowErrorMessage(-1, TEMP_AI_ACTIVATED, 0, 0);
-
+
return 0;
}
@@ -511,14 +511,14 @@ int32 CheckInterval(int32 p1)
{
bool warning;
if (p1) {
- warning = ( (IS_INT_INSIDE(_patches.servint_trains, 5, 90+1) || _patches.servint_trains == 0) &&
+ warning = ( (IS_INT_INSIDE(_patches.servint_trains, 5, 90+1) || _patches.servint_trains == 0) &&
(IS_INT_INSIDE(_patches.servint_roadveh, 5, 90+1) || _patches.servint_roadveh == 0) &&
- (IS_INT_INSIDE(_patches.servint_aircraft, 5, 90+1) || _patches.servint_aircraft == 0) &&
+ (IS_INT_INSIDE(_patches.servint_aircraft, 5, 90+1) || _patches.servint_aircraft == 0) &&
(IS_INT_INSIDE(_patches.servint_ships, 5, 90+1) || _patches.servint_ships == 0) );
} else {
- warning = ( (IS_INT_INSIDE(_patches.servint_trains, 30, 800+1) || _patches.servint_trains == 0) &&
+ warning = ( (IS_INT_INSIDE(_patches.servint_trains, 30, 800+1) || _patches.servint_trains == 0) &&
(IS_INT_INSIDE(_patches.servint_roadveh, 30, 800+1) || _patches.servint_roadveh == 0) &&
- (IS_INT_INSIDE(_patches.servint_aircraft, 30, 800+1) || _patches.servint_aircraft == 0) &&
+ (IS_INT_INSIDE(_patches.servint_aircraft, 30, 800+1) || _patches.servint_aircraft == 0) &&
(IS_INT_INSIDE(_patches.servint_ships, 30, 800+1) || _patches.servint_ships == 0) );
}
@@ -560,7 +560,7 @@ static const PatchEntry _patches_ui[] = {
{PE_BOOL, 0, STR_CONFIG_PATCHES_AUTOSCROLL, &_patches.autoscroll, 0, 0, 0, NULL},
{PE_UINT8, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION, &_patches.errmsg_duration, 0, 20, 1, NULL},
-
+
{PE_UINT8, PF_MULTISTRING, STR_CONFIG_PATCHES_TOOLBAR_POS, &_patches.toolbar_pos, 0, 2, 1, &v_PositionMainToolbar},
{PE_BOOL, 0, STR_CONFIG_PATCHES_INVISIBLE_TREES, &_patches.invisible_trees, 0, 1, 1, &InvisibleTreesActive},
};
@@ -570,7 +570,7 @@ static const PatchEntry _patches_construction[] = {
{PE_BOOL, 0, STR_CONFIG_PATCHES_EXTRADYNAMITE, &_patches.extra_dynamite, 0, 0, 0, NULL},
{PE_BOOL, 0, STR_CONFIG_PATCHES_LONGBRIDGES, &_patches.longbridges, 0, 0, 0, NULL},
{PE_BOOL, 0, STR_CONFIG_PATCHES_SIGNALSIDE, &_patches.signal_side, 0, 0, 0, NULL},
-
+
{PE_BOOL, 0, STR_CONFIG_PATCHES_SMALL_AIRPORTS, &_patches.always_small_airport, 0, 0, 0, NULL},
{PE_UINT8, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY, &_patches.drag_signals_density, 1, 20, 1, NULL},
@@ -622,7 +622,7 @@ static const PatchEntry _patches_economy[] = {
{PE_BOOL, 0, STR_CONFIG_PATCHES_SAMEINDCLOSE, &_patches.same_industry_close, 0, 0, 0, NULL},
{PE_BOOL, 0, STR_CONFIG_PATCHES_BRIBE, &_patches.bribe, 0, 0, 0, NULL},
{PE_UINT8, 0, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT, &_patches.snow_line_height, 2, 13, 1, NULL},
-
+
{PE_INT32, PF_NOCOMMA, STR_CONFIG_PATCHES_COLORED_NEWS_DATE, &_patches.colored_news_date, 1900, 2200, 5, NULL},
{PE_INT32, PF_NOCOMMA, STR_CONFIG_PATCHES_STARTING_DATE, &_patches.starting_date, 1920,2100, 1, NULL},
@@ -666,7 +666,7 @@ static int32 ReadPE(const PatchEntry*pe)
default:
NOT_REACHED();
}
-
+
/* useless, but avoids compiler warning this way */
return 0;
}
@@ -682,36 +682,36 @@ static void WritePE(const PatchEntry *pe, int32 val)
switch(pe->type) {
case PE_BOOL: *(bool*)pe->variable = (bool)val; break;
- case PE_UINT8: if ((uint8)val > (uint8)pe->max)
+ case PE_UINT8: if ((uint8)val > (uint8)pe->max)
*(uint8*)pe->variable = (uint8)pe->max;
else if ((uint8)val < (uint8)pe->min)
*(uint8*)pe->variable = (uint8)pe->min;
else
- *(uint8*)pe->variable = (uint8)val;
+ *(uint8*)pe->variable = (uint8)val;
break;
- case PE_INT16: if ((int16)val > (int16)pe->max)
+ case PE_INT16: if ((int16)val > (int16)pe->max)
*(int16*)pe->variable = (int16)pe->max;
else if ((int16)val < (int16)pe->min)
*(int16*)pe->variable = (int16)pe->min;
else
- *(int16*)pe->variable = (int16)val;
+ *(int16*)pe->variable = (int16)val;
break;
- case PE_UINT16: if ((uint16)val > (uint16)pe->max)
+ case PE_UINT16: if ((uint16)val > (uint16)pe->max)
*(uint16*)pe->variable = (uint16)pe->max;
else if ((uint16)val < (uint16)pe->min)
*(uint16*)pe->variable = (uint16)pe->min;
else
- *(uint16*)pe->variable = (uint16)val;
+ *(uint16*)pe->variable = (uint16)val;
break;
- case PE_INT32: if ((int32)val > (int32)pe->max)
+ case PE_INT32: if ((int32)val > (int32)pe->max)
*(int32*)pe->variable = (int32)pe->max;
else if ((int32)val < (int32)pe->min)
*(int32*)pe->variable = (int32)pe->min;
else
- *(int32*)pe->variable = val;
+ *(int32*)pe->variable = val;
break;
case PE_CURRENCY: val /= GetCurrentCurrencyRate();
@@ -791,7 +791,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
y = e->click.pt.y - 46 - 1;
if (y < 0) return;
-
+
btn = y / 11;
if (y % 11 > 9) return;
@@ -836,13 +836,13 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
if (val < pe->min) val = pe->min;
}
}
-
+
if (val != oval) {
WP(w,def_d).data_2 = btn * 2 + 1 + ((x>=10) ? 1 : 0);
w->flags4 |= 5 << WF_TIMEOUT_SHL;
_left_button_clicked = false;
}
- break;
+ break;
}
if (val != oval) {
WritePE(pe, val);
@@ -858,7 +858,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, WC_GAME_OPTIONS, 0);
}
}
-
+
break;
}
case 4: case 5: case 6: case 7: case 8: case 9:
@@ -878,7 +878,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
if (*e->edittext.str) {
const PatchPage *page = &_patches_page[WP(w,def_d).data_1];
const PatchEntry *pe = &page->entries[WP(w,def_d).data_3];
- WritePE(pe, atoi(e->edittext.str));
+ WritePE(pe, atoi(e->edittext.str));
SetWindowDirty(w);
if (pe->click_proc != NULL) // call callback function
diff --git a/ship_cmd.c b/ship_cmd.c
index 96ae9e25f..6dba5721c 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -93,7 +93,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
if (v->vehstatus & VS_STOPPED)
return;
-
+
if ((v->next_order & (OT_MASK | OF_FULL_LOAD)) == (OT_GOTO_DEPOT | OF_FULL_LOAD))
return;
@@ -113,7 +113,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
v->next_order = OT_GOTO_DEPOT | OF_NON_STOP;
v->next_order_param = (byte)i;
v->dest_tile = (&_depots[i])->xy;
- InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+ InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
}
void OnNewDay_Ship(Vehicle *v)
@@ -128,11 +128,11 @@ void OnNewDay_Ship(Vehicle *v)
CheckIfShipNeedsService(v);
CheckOrders(v);
-
+
if (v->vehstatus & VS_STOPPED)
return;
-
+
cost = ship_vehicle_info(v->engine_type).running_cost * _price.ship_running / 364;
v->profit_this_year -= cost >> 8;
@@ -152,10 +152,10 @@ static void HandleBrokenShip(Vehicle *v)
if (v->breakdowns_since_last_service != 255)
v->breakdowns_since_last_service++;
-
+
InvalidateWindow(WC_VEHICLE_VIEW, v->index);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
-
+
SndPlayVehicleFx((_opt.landscape != LT_CANDY) ? 0xE : 0x3A, v);
if (!(v->vehstatus & VS_HIDDEN)) {
@@ -231,7 +231,7 @@ static void ProcessShipOrder(Vehicle *v)
if ((order & OT_MASK) == OT_GOTO_STATION) {
if ( (byte)(order >> 8) == v->last_station_visited)
v->last_station_visited = 0xFF;
-
+
st = DEREF_STATION(order >> 8);
if (st->dock_tile != 0) {
v->dest_tile = TILE_ADD(st->dock_tile, _dock_offs[_map5[st->dock_tile]-0x4B]);
@@ -248,7 +248,7 @@ static void HandleShipLoading(Vehicle *v)
{
if (v->next_order == OT_NOTHING)
return;
-
+
if (v->next_order != OT_DUMMY) {
if ((v->next_order&OT_MASK) != OT_LOADING)
return;
@@ -265,7 +265,7 @@ static void HandleShipLoading(Vehicle *v)
return;
}
PlayShipSound(v);
-
+
{
byte b = v->next_order;
v->next_order = OT_LEAVESTATION;
@@ -352,7 +352,7 @@ static bool ShipAccelerate(Vehicle *v)
//updates statusbar only if speed have changed to save CPU time
if (spd != v->cur_speed) {
- v->cur_speed = spd;
+ v->cur_speed = spd;
if (_patches.vehicle_speed)
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
}
@@ -384,7 +384,7 @@ static void ShipEnterDepot(Vehicle *v)
v->vehstatus |= VS_HIDDEN;
v->cur_speed = 0;
RecalcShipStuff(v);
-
+
v->date_of_last_service = _date;
v->breakdowns_since_last_service = 0;
v->reliability = _engines[v->engine_type].reliability;
@@ -394,7 +394,7 @@ static void ShipEnterDepot(Vehicle *v)
if ((v->next_order&OT_MASK) == OT_GOTO_DEPOT) {
InvalidateWindow(WC_VEHICLE_VIEW, v->index);
-
+
t = v->next_order;
v->next_order = OT_DUMMY;
@@ -444,7 +444,7 @@ static bool ShipTrackFollower(uint tile, PathFindShip *pfs, int track, uint leng
// Found dest?
if (tile == pfs->dest_coords) {
pfs->best_bird_dist = 0;
-
+
// if (length < pfs->best_length)
// dbg_store_path();
@@ -456,7 +456,7 @@ static bool ShipTrackFollower(uint tile, PathFindShip *pfs, int track, uint leng
if (tile != pfs->skiptile) {
pfs->best_bird_dist = minu(pfs->best_bird_dist, GetTileDist1Db(pfs->dest_coords, tile));
}
-
+
return false;
}
@@ -488,12 +488,12 @@ static uint FindShipTrack(Vehicle *v, uint tile, int dir, uint bits, uint skipti
do {
i = FIND_FIRST_BIT(bits);
bits = KILL_FIRST_BIT(bits);
-
+
pfs.best_bird_dist = (uint)-1;
pfs.best_length = (uint)-1;
FollowTrack(tile, 0x3800 | TRANSPORT_WATER, _ship_search_directions[i][dir], (TPFEnumProc*)ShipTrackFollower, NULL, &pfs);
-
+
if (best_track >= 0) {
if (pfs.best_bird_dist != 0) {
/* neither reached the destination, pick the one with the smallest bird dist */
@@ -503,8 +503,8 @@ static uint FindShipTrack(Vehicle *v, uint tile, int dir, uint bits, uint skipti
if (pfs.best_length > best_length) goto bad;
if (pfs.best_length < best_length) goto good;
}
-
- /* if we reach this position, there's two paths of equal value so far.
+
+ /* if we reach this position, there's two paths of equal value so far.
* pick one randomly. */
r = (byte)Random();
if (_pick_shiptrack_table[i] == ship_dir) r += 80;
@@ -554,7 +554,7 @@ static const byte _new_vehicle_direction_table[11] = {
static int ShipGetNewDirectionFromTiles(uint new_tile, uint old_tile)
{
- uint offs = (GET_TILE_Y(new_tile) - GET_TILE_Y(old_tile) + 1) * 4 +
+ uint offs = (GET_TILE_Y(new_tile) - GET_TILE_Y(old_tile) + 1) * 4 +
GET_TILE_X(new_tile) - GET_TILE_X(old_tile) + 1;
assert(offs < 11 && offs != 3 && offs != 7);
return _new_vehicle_direction_table[offs];
@@ -707,7 +707,7 @@ static void ShipController(Vehicle *v)
goto reverse_direction;
b = _ship_subcoord[dir][track];
-
+
gp.x = (gp.x&~0xF) | b[0];
gp.y = (gp.y&~0xF) | b[1];
@@ -794,7 +794,7 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
uint unit_num;
uint tile = TILE_FROM_XY(x,y);
Engine *e;
-
+
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
value = EstimateShipCost(p1);
@@ -802,10 +802,10 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return value;
v = AllocateVehicle();
- if (v == NULL || _ptr_to_next_order >= endof(_order_array) ||
+ if (v == NULL || _ptr_to_next_order >= endof(_order_array) ||
(unit_num = GetFreeUnitNumber(VEH_Ship)) > _patches.max_ships)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
-
+
if (flags & DC_EXEC) {
v->unitnumber = unit_num;
@@ -823,12 +823,12 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->x_offs = -3;
v->y_offs = -3;
v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
-
+
v->spritenum = ship_vehicle_info(p1).image_index;
v->cargo_type = ship_vehicle_info(p1).cargo_type;
v->cargo_cap = ship_vehicle_info(p1).capacity;
v->value = value;
-
+
v->last_station_visited = 255;
v->max_speed = ship_vehicle_info(p1).max_speed;
v->engine_type = (byte)p1;
@@ -856,7 +856,7 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
InvalidateWindow(WC_SHIPS_LIST, v->owner);
InvalidateWindow(WC_COMPANY, v->owner);
}
-
+
return value;
}
@@ -865,7 +865,7 @@ int32 CmdSellShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Vehicle *v;
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
-
+
v = &_vehicles[p1];
if (!CheckOwnership(v->owner))
@@ -873,7 +873,7 @@ int32 CmdSellShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!IsShipDepotTile(v->tile) || v->u.road.state != 0x80 || !(v->vehstatus&VS_STOPPED))
return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
-
+
if (flags & DC_EXEC) {
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
_vehicle_sort_dirty[VEHSHIP] = true; // sell a ship
@@ -882,7 +882,7 @@ int32 CmdSellShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
DeleteVehicle(v);
}
-
+
return -(int32)v->value;
}
@@ -919,7 +919,7 @@ int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) {
if (v->next_order&OF_UNLOAD) {v->cur_order_index++;}
v->next_order = OT_DUMMY;
- InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
+ InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
}
} else {
depot = FindClosestShipDepot(v);
@@ -963,7 +963,7 @@ int32 CmdRefitShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 cost;
SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
-
+
v = &_vehicles[p1];
if (!CheckOwnership(v->owner))
return CMD_ERROR;
diff --git a/ship_gui.c b/ship_gui.c
index 0b95ba503..6862f3024 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -26,7 +26,7 @@ static void ShipRefitWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT: {
- Vehicle *v = &_vehicles[w->window_number];
+ Vehicle *v = &_vehicles[w->window_number];
const byte *b;
int sel;
int x,y;
@@ -38,7 +38,7 @@ static void ShipRefitWndProc(Window *w, WindowEvent *e)
DrawWindowWidgets(w);
DrawString(1, 15, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, 0);
-
+
cargo = -1;
x = 6;
y = 25;
@@ -103,7 +103,7 @@ static void ShipRefitWndProc(Window *w, WindowEvent *e)
} break;
case 4: /* refit button */
if (WP(w,refit_d).cargo != 0xFF) {
- Vehicle *v = &_vehicles[w->window_number];
+ Vehicle *v = &_vehicles[w->window_number];
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP)))
DeleteWindow(w);
}
@@ -136,8 +136,8 @@ static void ShowShipRefitWindow(Vehicle *v)
Window *w;
DeleteWindowById(WC_VEHICLE_REFIT, v->index);
-
- _alloc_wnd_parent_num = v->index;
+
+ _alloc_wnd_parent_num = v->index;
w = AllocateWindowDesc(&_ship_refit_desc);
w->window_number = v->index;
w->caption_color = v->owner;
@@ -166,7 +166,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
StringID str;
SET_DPARAM16(1, year);
-
+
str = STR_0199_YEAR;
if (year != 1) {
str++;
@@ -212,7 +212,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
SET_DPARAM16(0, GetCustomEngineName(v->engine_type));
SET_DPARAM32(2, v->value);
DrawString(74, 57, STR_9816_BUILT_VALUE, 0);
-
+
SET_DPARAM16(0, _cargoc.names_long_p[v->cargo_type]);
SET_DPARAM16(1, v->cargo_cap);
DrawString(74, 67, STR_9817_CAPACITY, 0);
@@ -295,7 +295,7 @@ static void ShowShipDetailsWindow(Vehicle *v)
VehicleID veh = v->index;
DeleteWindowById(WC_VEHICLE_ORDERS, veh);
DeleteWindowById(WC_VEHICLE_DETAILS, veh);
- _alloc_wnd_parent_num = veh;
+ _alloc_wnd_parent_num = veh;
w = AllocateWindowDesc(&_ship_details_desc);
w->window_number = veh;
w->caption_color = v->owner;
@@ -314,7 +314,7 @@ static void CcBuildShip(bool success, uint tile, uint32 p1, uint32 p2)
ShowShipViewWindow(v);
}
-static void NewShipWndProc(Window *w, WindowEvent *e)
+static void NewShipWndProc(Window *w, WindowEvent *e)
{
YearMonthDay ymd;
switch(e->event) {
@@ -354,7 +354,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
DrawShipEngine(x+35, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
y += 24;
}
- sel--;
+ sel--;
}
} while (++engine_id, ++e,--num);
@@ -370,12 +370,12 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
SET_DPARAM16(4, ship_vehicle_info(selected_id).refittable ? STR_9842_REFITTABLE : STR_EMPTY);
SET_DPARAM32(5, ship_vehicle_info(selected_id).running_cost * _price.ship_running >> 8);
- e = &_engines[selected_id];
+ e = &_engines[selected_id];
SET_DPARAM16(7, e->lifelength);
SET_DPARAM8(8, e->reliability * 100 >> 16);
ConvertDayToYMD(&ymd, e->intro_date);
SET_DPARAM16(6, ymd.year + 1920);
-
+
DrawString(2, 111, STR_980A_COST_SPEED_CAPACITY_RUNNING, 0);
}
}
@@ -456,13 +456,13 @@ static void ShowBuildShipWindow(TileIndex tile)
w = AllocateWindowDesc(&_new_ship_desc);
w->window_number = tile;
w->vscroll.cap = 4;
-
+
if (tile != 0) {
w->caption_color = _map_owner[tile];
} else {
w->caption_color = _local_player;
}
-
+
}
@@ -479,7 +479,7 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
v->u.ship.state == 0x80 &&
IsShipDepotTile(v->tile))
disabled = 0;
-
+
if (v->owner != _local_player)
disabled |= 1<<7 | 1<<6;
w->disabled_state = disabled;
@@ -535,13 +535,13 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
switch(e->click.widget) {
case 4: /* start stop */
- DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP));
+ DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP));
break;
case 5: /* center main view */
ScrollMainWindowTo(v->x_pos, v->y_pos);
break;
case 6: /* goto hangar */
- DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT));
+ DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT));
break;
case 7: /* refit */
ShowShipRefitWindow(v);
@@ -557,7 +557,7 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
case WE_DESTROY:
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);
- DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
+ DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
break;
}
@@ -641,17 +641,17 @@ static void DrawShipDepotWindow(Window *w)
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_Ship &&
- v->u.ship.state == 0x80 &&
+ v->u.ship.state == 0x80 &&
v->tile == (TileIndex)tile &&
--num < 0 && num >= -6) {
DrawShipImage(v, x+19, y, WP(w,traindepot_d).sel);
-
+
SET_DPARAM16(0, v->unitnumber);
DrawString(x, y, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0);
DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x, y + 9);
-
+
if ((x+=90) == 2+90*3) {
x = 2;
y += 24;
@@ -666,7 +666,7 @@ static int GetVehicleFromShipDepotWndPt(Window *w, int x, int y, Vehicle **veh)
TileIndex tile;
Vehicle *v;
int pos;
-
+
xt = x / 90;
xm = x % 90;
if (xt >= 5)
@@ -682,7 +682,7 @@ static int GetVehicleFromShipDepotWndPt(Window *w, int x, int y, Vehicle **veh)
tile = w->window_number;
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_Ship &&
- v->vehstatus&VS_HIDDEN &&
+ v->vehstatus&VS_HIDDEN &&
v->tile == (TileIndex)tile &&
--pos < 0) {
*veh = v;
@@ -695,7 +695,7 @@ static int GetVehicleFromShipDepotWndPt(Window *w, int x, int y, Vehicle **veh)
}
return 1; /* outside */
-
+
}
static void ShipDepotClick(Window *w, int x, int y)
@@ -714,7 +714,7 @@ static void ShipDepotClick(Window *w, int x, int y)
if (v != NULL) {
WP(w,traindepot_d).sel = v->index;
SetWindowDirty(w);
- SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) +
+ SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) +
GetShipImage(v, 6), 4, w);
}
break;
@@ -743,7 +743,7 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) {
case 2:
ShipDepotClick(w, e->click.pt.x, e->click.pt.y);
break;
-
+
case 5:
ShowBuildShipWindow(w->window_number);
break;
@@ -773,12 +773,12 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) {
ShowShipViewWindow(v);
}
} break;
-
+
case 3:
if (!HASBIT(w->disabled_state, 3) &&
WP(w,traindepot_d).sel != INVALID_VEHICLE) {
Vehicle *v;
-
+
HandleButtonClick(w, 3);
v = &_vehicles[WP(w,traindepot_d).sel];
@@ -786,7 +786,7 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) {
_backup_orders_tile = v->tile;
BackupVehicleOrders(v, _backup_orders_data);
-
+
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_SHIP | CMD_MSG(STR_980C_CAN_T_SELL_SHIP)))
_backup_orders_tile = 0;
}
@@ -854,7 +854,7 @@ static void DrawSmallShipSchedule(Vehicle *v, int x, int y) {
if ((ord & OT_MASK) == OT_GOTO_STATION) {
st = DEREF_STATION(ord >> 8);
-
+
if (!(st->had_vehicle_of_type & HVOT_BUOY)) {
SET_DPARAM16(0, ord >> 8);
DrawString(x, y, STR_A036, 0);
@@ -894,7 +894,7 @@ static void MakeSortedShiptList(byte owner)
// ships are stored as a cummulative index, eg 25, 41, 43. This means
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2
for (i = &_num_ship_sort[1]; i != endof(_num_ship_sort); i++) {*i += *(i-1);}
-
+
// sort by owner, then only subsort the requested owner-vehicles
qsort(_ship_sort, n, sizeof(_ship_sort[0]), GeneralOwnerSorter);
@@ -939,7 +939,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 ships
i = (window_number == 0) ? 0 : _num_ship_sort[window_number-1];
SetVScrollCount(w, _num_ship_sort[window_number] - i);
-
+
/* draw the widgets */
{
Player *p = DEREF_PLAYER(window_number);
@@ -982,7 +982,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
SET_DPARAM32(0, v->profit_this_year);
SET_DPARAM32(1, v->profit_last_year);
DrawString(x + 12, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
-
+
if (v->string_id != STR_SV_SHIP_NAME) {
SET_DPARAM16(0, v->string_id);
DrawString(x+12, y, STR_01AB, 0);
@@ -1010,7 +1010,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
return;
case 6: { /* Matrix to show vehicles */
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG;
-
+
if (id_v >= w->vscroll.cap) { return;} // click out of bounds
id_v += w->vscroll.pos;
@@ -1035,15 +1035,15 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
tile = _last_built_ship_depot_tile;
do {
- if (_map_owner[tile] == _local_player && IsShipDepotTile(tile)) {
+ if (_map_owner[tile] == _local_player && IsShipDepotTile(tile)) {
ShowShipDepotWindow(tile);
ShowBuildShipWindow(tile);
return;
}
-
+
tile = TILE_MASK(tile + 1);
} while(tile != _last_built_ship_depot_tile);
-
+
ShowBuildShipWindow(0);
} break;
}
diff --git a/smallmap_gui.c b/smallmap_gui.c
index 66b6ffaed..6cdf6b89e 100644
--- a/smallmap_gui.c
+++ b/smallmap_gui.c
@@ -78,7 +78,7 @@ static const uint16 _legend_land_contours[] = {
MK(0x5E,STR_00F2_300M),
MK(0x1F,STR_00F3_400M),
MK(0x27,STR_00F4_500M),
-
+
MS(0xD7,STR_00EB_ROADS),
MK(0x0A,STR_00EC_RAILROADS),
MK(0x98,STR_00ED_STATIONS_AIRPORTS_DOCKS),
@@ -509,7 +509,7 @@ static uint32 INLINE GetSmallMapVegetationPixels(uint tile)
if (i >= 0) i = (i >> 2);
bits = _vegetation_clear_bits[i + 4];
} else if (t == MP_INDUSTRY) {
- bits = IS_BYTE_INSIDE(_map5[tile], 0x10, 0x12) ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5);
+ bits = IS_BYTE_INSIDE(_map5[tile], 0x10, 0x12) ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5);
} else if (t == MP_TREES) {
bits = MKCOLOR(0x54575754);
if ((_map2[tile] & 0x30) == 0x20)
@@ -550,7 +550,7 @@ static uint32 INLINE GetSmallMapOwnerPixels(uint tile)
t = GET_TILETYPE(tile);
if (t == MP_HOUSE || _map_owner[tile] == OWNER_TOWN) {
- t = 0x80;
+ t = 0x80;
} else if (t == MP_INDUSTRY) {
t = 0xff;
} else {
@@ -641,10 +641,10 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town
/* setup owners ptr */
_owner_colors = tbl = alloca(256 * sizeof(*_owner_colors));
-
+
/* clear the town colors */
memset(tbl + 128, 0xB4, 128 * sizeof(*_owner_colors));
-
+
/* fill with some special colors */
tbl[0x10] = MKCOLOR(0x54545454);
tbl[0x11] = MKCOLOR(0xCACACACA);
@@ -655,7 +655,7 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town
if (p->is_active) {
tbl[p->index] = dup_byte32(GetSpritePtr(0x307 + p->player_color)[0xCB]);
}
- }
+ }
}
tile_x = (int)WP(w,smallmap_d).scroll_x >> 4;
@@ -712,7 +712,7 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town
proc(ptr, tile_x, tile_y, dpi->pitch*2, reps, mask);
}
-skip_column:
+skip_column:
if (y == 0) {
tile_y++;
y++;
@@ -736,7 +736,7 @@ skip_column:
if (v->type != 0 && v->type != 0x14 && (v->vehstatus & (VS_HIDDEN|VS_UNCLICKABLE)) == 0) {
// Remap into flat coordinates.
Point pt = RemapCoords(
- (int)(v->x_pos - WP(w,smallmap_d).scroll_x) >> 4,
+ (int)(v->x_pos - WP(w,smallmap_d).scroll_x) >> 4,
(int)(v->y_pos - WP(w,smallmap_d).scroll_y) >> 4,
0);
x = pt.x;
@@ -765,11 +765,11 @@ skip_column:
continue;
skip = true;
}
-
+
// Calculate pointer to pixel and the color
ptr = dpi->dst_ptr + y * dpi->pitch + x;
color = (type == 1) ? _vehicle_type_colors[v->type-0x10] : 0xF;
-
+
// And draw either one or two pixels depending on clipping
ptr[0] = color;
if (!skip)
@@ -789,11 +789,11 @@ skip_column:
0);
x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1);
y = pt.y;
-
+
// Check if the town sign is within bounds
if (x + t->sign.width_2 > dpi->left &&
x < dpi->left + dpi->width &&
- y + 6 > dpi->top &&
+ y + 6 > dpi->top &&
y < dpi->top + dpi->height) {
// And draw it.
SET_DPARAM16(0, t->index);
@@ -801,7 +801,7 @@ skip_column:
}
}
}
- }
+ }
// Draw map indicators
{
@@ -809,7 +809,7 @@ skip_column:
// Find main viewport.
vp = FindWindowById(WC_MAIN_WINDOW,0)->viewport;
-
+
pt = RemapCoords(
WP(w,smallmap_d).scroll_x,
WP(w,smallmap_d).scroll_y,
@@ -846,7 +846,7 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e)
/* draw the window */
SET_DPARAM16(0, STR_00E5_CONTOURS + _smallmap_type);
DrawWindowWidgets(w);
-
+
/* draw the legend */
tbl = _legend_table[(_smallmap_type != 2) ? _smallmap_type : (_opt.landscape + IND_OFFS)];
x = 4;
@@ -877,7 +877,7 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e)
case WE_CLICK:
switch(e->click.widget) {
case 2: {/* big/small size */
- // const Widget *wi = w->widget;
+ // const Widget *wi = w->widget;
DeleteWindow(w);
SndPlayFx(0x13);
{
@@ -903,7 +903,7 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e)
case 5: /* show land contours */
case 6: /* show vehicles */
case 7: /* show industries */
- case 8: /* show transport routes */
+ case 8: /* show transport routes */
case 9: /* show vegetation */
case 10: /* show land owners */
w->click_state &= ~(1<<5|1<<6|1<<7|1<<8|1<<9|1<<10);
@@ -978,7 +978,7 @@ static void DoShowSmallMap(int big)
int x,y;
_smallmap_size = big;
-
+
w = AllocateWindowDescFront(_smallmap_descs[big], 0);
if (w) {
w->click_state = (1<<5) << _smallmap_type | _smallmap_show_towns << 11;
@@ -1039,7 +1039,7 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
// set this view to same location. Based on the center, adjusting for zoom
WP(w2,vp_d).scrollpos_x = x - (w2->viewport->virtual_width - (294 <<vp->zoom) )/2;
- WP(w2,vp_d).scrollpos_y = y - (w2->viewport->virtual_height - (214 << vp->zoom) )/2;
+ WP(w2,vp_d).scrollpos_y = y - (w2->viewport->virtual_height - (214 << vp->zoom) )/2;
} break;
case 7: { /* inverse location button (move this view to same spot as main view) */
Window * w2 = FindWindowById(WC_MAIN_WINDOW, 0);
@@ -1047,9 +1047,9 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
int y = WP(w2,vp_d).scrollpos_y;
WP(w,vp_d).scrollpos_x = x + (w2->viewport->virtual_width - (294 <<vp->zoom) )/2;
- WP(w,vp_d).scrollpos_y = y + (w2->viewport->virtual_height - (214 << vp->zoom) )/2;
+ WP(w,vp_d).scrollpos_y = y + (w2->viewport->virtual_height - (214 << vp->zoom) )/2;
} break;
- }
+ }
} break;
}
}
@@ -1066,7 +1066,7 @@ void ShowExtraViewPortWindow()
{
Window *w, *v;
int i = 0;
-
+
// find next free window number for extra viewport
while (FindWindowById(WC_EXTRA_VIEW_PORT,i) ) {
i++;
@@ -1078,8 +1078,8 @@ void ShowExtraViewPortWindow()
// disable zoom in button
w->disabled_state = 1 << 4;
// the main window with the main view
- v = FindWindowById(WC_MAIN_WINDOW, 0);
- // New viewport start ats (zero,zero)
+ v = FindWindowById(WC_MAIN_WINDOW, 0);
+ // New viewport start ats (zero,zero)
AssignWindowViewport(w, 3, 17, 294, 214, 0 , 0);
// center on same place as main window (zoom is maximum, no adjustment needed)
diff --git a/sound.c b/sound.c
index 46407dff0..fe42639ef 100644
--- a/sound.c
+++ b/sound.c
@@ -73,7 +73,7 @@ static void mix_int8_to_int16(MixerChannel *sc, int16 *buffer, uint samples)
volume_left = sc->volume_left;
volume_right = sc->volume_right;
- if (frac_speed == 0x10000) {
+ if (frac_speed == 0x10000) {
// Special case when frac_speed is 0x10000
do {
buffer[0]+= *b * volume_left >> 8;
@@ -110,10 +110,10 @@ void MxMixSamples(Mixer *mx, void *buffer, uint samples)
{
int i;
MixerChannel *mc;
-
+
// Clear the buffer
memset(buffer, 0, sizeof(int16)*2*samples);
-
+
// Mix each channel
for(i=0,mc=mx->channels; i!=lengthof(mx->channels); i++,mc++) {
if (mc->active) {
@@ -154,7 +154,7 @@ static void MxSetChannelRawSrc(MixerChannel *mc, void *mem, uint size, uint rate
// adjust the magnitude to prevent overflow
while (size & 0xFFFF0000)
size >>= 1, rate = (rate >> 1) + 1;
-
+
mc->samples_left = size * mc->mx->play_rate / rate;
}
@@ -180,7 +180,7 @@ static void MxOpenBankFile(Mixer *mx, const char *filename)
fe->file_offset = FioReadDword();
fe->file_size = FioReadDword();
}
-
+
fe = mx->files;
for(i=0; i!=count; i++,fe++) {
FioSeekTo(fe->file_offset, SEEK_SET);
@@ -221,7 +221,7 @@ static bool MxSetBankSource(MixerChannel *mc, uint bank)
if (fe->file_size == 0)
return false;
-
+
mem = malloc(fe->file_size);
FioSeekToFile(fe->file_offset);
FioReadBlock(mem, fe->file_size);
@@ -229,7 +229,7 @@ static bool MxSetBankSource(MixerChannel *mc, uint bank)
for(i=0; i!=fe->file_size; i++) {
((byte*)mem)[i] ^= 0x80;
}
-
+
assert(fe->bits_per_sample == 8 && fe->channels == 1 && fe->file_size != 0 && fe->rate != 0);
MxSetChannelRawSrc(mc, mem, fe->file_size, fe->rate, MX_AUTOFREE | MX_UNSIGNED);
@@ -302,10 +302,10 @@ void SndPlayScreenCoordFx(int sound, int x, int y)
if ((vp=w->viewport) &&
IS_INSIDE_1D(x, vp->virtual_left, vp->virtual_width) &&
IS_INSIDE_1D(y, vp->virtual_top, vp->virtual_height)) {
-
+
left = ((x - vp->virtual_left) >> vp->zoom) + vp->left;
StartSound(
- _sound_idx[sound],
+ _sound_idx[sound],
clamp(left / 71, 0, 8),
(_sound_base_vol[sound] * msf.effect_vol * _vol_factor_by_zoom[vp->zoom]) >> 15
);
@@ -334,8 +334,8 @@ void SndPlayVehicleFx(int sound, Vehicle *v)
void SndPlayFx(int sound)
{
StartSound(
- _sound_idx[sound],
- 4,
+ _sound_idx[sound],
+ 4,
(_sound_base_vol[sound] * msf.effect_vol) >> 7
);
}
diff --git a/station.h b/station.h
index d4e2061b6..e221318ad 100644
--- a/station.h
+++ b/station.h
@@ -28,7 +28,7 @@ struct Station {
ViewportSign sign;
uint16 had_vehicle_of_type;
-
+
byte time_since_load;
byte time_since_unload;
byte delete_ctr;
diff --git a/station_cmd.c b/station_cmd.c
index c34aeb620..05959fb3c 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -126,7 +126,7 @@ static Station *AllocateStation()
return NULL;
}
- i = a_free->index;
+ i = a_free->index;
memset(a_free, 0, sizeof(Station));
a_free->index = i;
return a_free;
@@ -143,7 +143,7 @@ static int CountMapSquareAround(uint tile, byte type, byte min, byte max) {
TILE_XY(-6,1), 1, 1, 1, 1, 1, 1,
TILE_XY(-6,1), 1, 1, 1, 1, 1, 1,
0,
- };
+ };
int j;
const TileIndexDiff *p = _count_square_table;
int num = 0;
@@ -189,9 +189,9 @@ static bool GenerateStationName(Station *st, uint tile, int flag)
CLRBIT(free_names, str);
}
}
- }
+ }
}
-
+
/* check default names */
tmp = free_names & _gen_station_name_bits[flag];
if (tmp != 0) {
@@ -255,9 +255,9 @@ static bool GenerateStationName(Station *st, uint tile, int flag)
~( (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)) ),
};
-
- free_names &= _direction_and_table[
- (GET_TILE_X(tile) < GET_TILE_X(t->xy)) +
+
+ free_names &= _direction_and_table[
+ (GET_TILE_X(tile) < GET_TILE_X(t->xy)) +
(GET_TILE_Y(tile) < GET_TILE_Y(t->xy))*2];
}
@@ -335,7 +335,7 @@ void UpdateAllStationVirtCoord()
Station *st;
FOR_ALL_STATIONS(st) {
if (st->xy != 0)
- UpdateStationVirtCoord(st);
+ UpdateStationVirtCoord(st);
}
}
@@ -488,7 +488,7 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
}
span[4] = st->airport_tile;
if (st->airport_tile != 0) {
- span[5] = st->airport_tile + TILE_XY(_airport_size_x[st->airport_type]-1, _airport_size_y[st->airport_type]-1);
+ span[5] = st->airport_tile + TILE_XY(_airport_size_x[st->airport_type]-1, _airport_size_y[st->airport_type]-1);
}
span[6] = st->dock_tile;
@@ -529,7 +529,7 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
new_acc = GetAcceptanceMask(st);
if (old_acc == new_acc)
return;
-
+
// show a message to report that the acceptance was changed?
if (show_msg && st->owner == _local_player && st->facilities) {
uint32 accept=0, reject=0; /* these contain two string ids each */
@@ -537,7 +537,7 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
do {
if (new_acc & 1) {
- if (!(old_acc & 1)) accept = (accept << 16) | *str;
+ if (!(old_acc & 1)) accept = (accept << 16) | *str;
} else {
if (old_acc & 1) reject = (reject << 16) | *str;
}
@@ -595,7 +595,7 @@ int32 CheckFlatLandBelow(uint tile, uint w, uint h, uint flags, uint invalid_dir
cost += _price.terraform;
flat_z += 8;
}
-
+
// get corresponding flat level and make sure that all parts of the station have the same level.
if (allowed_z == -1) {
// first tile
@@ -605,7 +605,7 @@ int32 CheckFlatLandBelow(uint tile, uint w, uint h, uint flags, uint invalid_dir
return CMD_ERROR;
}
- // if station is set, then we have special handling to allow building on top of already existing stations.
+ // if station is set, then we have special handling to allow building on top of already existing stations.
// so station points to -1 if we can build on any station. or it points to a station if we're only allowed to build
// on exactly that station.
if (station && IS_TILETYPE(tile_cur, MP_STATION)) {
@@ -795,7 +795,7 @@ int32 CmdBuildRailroadStation(int x_org, int y_org, uint32 flags, uint32 p1, uin
st = AllocateStation();
if (st == NULL)
return CMD_ERROR;
-
+
st->town = ClosestTownFromTile(tile_org, (uint)-1);
if (_current_player < MAX_PLAYERS && flags&DC_EXEC)
SETBIT(st->town->have_ratings, _current_player);
@@ -819,20 +819,20 @@ int32 CmdBuildRailroadStation(int x_org, int y_org, uint32 flags, uint32 p1, uin
st->trainst_w = finalvalues[1];
st->trainst_h = finalvalues[2];
-
+
st->build_date = _date;
-
+
tile_delta = direction ? TILE_XY(0,1) : TILE_XY(1,0);
-
+
layout_ptr = alloca(numtracks * plat_len);
GetStationLayout(layout_ptr, numtracks, plat_len);
-
+
do {
int tile = tile_org;
int w = plat_len;
do {
- ModifyTile(tile,
+ ModifyTile(tile,
MP_SETTYPE(MP_STATION) | MP_MAPOWNER_CURRENT |
MP_MAP2 | MP_MAP5 | MP_MAP3LO | MP_MAP3HI_CLEAR,
station_index, /* map2 parameter */
@@ -866,7 +866,7 @@ static void MakeRailwayStationAreaSmaller(Station *st)
uint i;
restart:
-
+
// too small?
if (w != 0 && h != 0) {
// check the left side, x = constant, y changes
@@ -966,7 +966,7 @@ static int32 RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
tile = st->train_tile;
w = st->trainst_w;
h = st->trainst_h;
-
+
assert(w != 0 && h != 0);
/* cost is area * constant */
@@ -996,7 +996,7 @@ static int32 RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
UpdateStationVirtCoordDirty(st);
DeleteStationIfEmpty(st);
}
-
+
return cost;
}
@@ -1056,7 +1056,7 @@ int32 CmdBuildBusStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (st != NULL) {
if (st->owner != OWNER_NONE && st->owner != _current_player)
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
-
+
if (!CheckStationSpreadOut(st, tile, 1, 1))
return CMD_ERROR;
@@ -1091,10 +1091,10 @@ int32 CmdBuildBusStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
st->facilities |= FACIL_BUS_STOP;
st->bus_stop_status = 3;
st->owner = _current_player;
-
+
st->build_date = _date;
- ModifyTile(tile,
+ ModifyTile(tile,
MP_SETTYPE(MP_STATION) | MP_MAPOWNER_CURRENT |
MP_MAP2 | MP_MAP5 | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,
st->index, /* map2 parameter */
@@ -1117,7 +1117,7 @@ static int32 RemoveBusStation(Station *st, uint32 flags)
return CMD_ERROR;
tile = st->bus_tile;
-
+
if (!EnsureNoVehicle(tile))
return CMD_ERROR;
@@ -1131,7 +1131,7 @@ static int32 RemoveBusStation(Station *st, uint32 flags)
DeleteStationIfEmpty(st);
}
- return _price.remove_bus_station;
+ return _price.remove_bus_station;
}
@@ -1168,7 +1168,7 @@ int32 CmdBuildTruckStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (st != NULL) {
if (st->owner != OWNER_NONE && st->owner != _current_player)
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
-
+
if (!CheckStationSpreadOut(st, tile, 1, 1))
return CMD_ERROR;
@@ -1206,8 +1206,8 @@ int32 CmdBuildTruckStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
st->build_date = _date;
- ModifyTile(tile,
- MP_SETTYPE(MP_STATION) | MP_MAPOWNER_CURRENT |
+ ModifyTile(tile,
+ MP_SETTYPE(MP_STATION) | MP_MAPOWNER_CURRENT |
MP_MAP2 | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR | MP_MAP5,
st->index, /* map2 parameter */
p1 + 0x43 /* map5 parameter */
@@ -1227,7 +1227,7 @@ static int32 RemoveTruckStation(Station *st, uint32 flags)
if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
return CMD_ERROR;
-
+
tile = st->lorry_tile;
if (!EnsureNoVehicle(tile))
@@ -1235,7 +1235,7 @@ static int32 RemoveTruckStation(Station *st, uint32 flags)
if (flags & DC_EXEC) {
DoClearSquare(tile);
-
+
st->lorry_tile = 0;
st->facilities &= ~FACIL_TRUCK_STOP;
@@ -1243,7 +1243,7 @@ static int32 RemoveTruckStation(Station *st, uint32 flags)
DeleteStationIfEmpty(st);
}
- return _price.remove_truck_station;
+ return _price.remove_truck_station;
}
// FIXME -- need to move to its corresponding Airport variable
@@ -1294,7 +1294,7 @@ static const byte * const _airport_map5_tiles[] = {
_airport_map5_tiles_country, // Country Airfield (small)
_airport_map5_tiles_town, // City Airport (large)
_airport_map5_tiles_heliport, // Heliport
- _airport_map5_tiles_metropolitan, // Metropolitain Airport (large)
+ _airport_map5_tiles_metropolitan, // Metropolitain Airport (large)
_airport_map5_tiles_international, // International Airport (xlarge)
};
@@ -1309,12 +1309,12 @@ int32 CmdBuildAirport(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Station *st;
int32 cost;
int w,h;
- bool airport_upgrade = true;
+ bool airport_upgrade = true;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
tile = TILE_FROM_XY(x,y);
-
+
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile))
return CMD_ERROR;
@@ -1353,7 +1353,7 @@ int32 CmdBuildAirport(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (st != NULL) {
if (st->owner != OWNER_NONE && st->owner != _current_player)
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
-
+
if (!CheckStationSpreadOut(st, tile, 1, 1))
return CMD_ERROR;
@@ -1397,7 +1397,7 @@ int32 CmdBuildAirport(int x, int y, uint32 flags, uint32 p1, uint32 p2)
st->facilities |= FACIL_AIRPORT;
st->airport_type = (byte)p1;
st->airport_flags = 0;
-
+
st->build_date = _date;
/* if airport was demolished while planes were en-route to it, the positions can no longer
@@ -1407,11 +1407,11 @@ int32 CmdBuildAirport(int x, int y, uint32 flags, uint32 p1, uint32 p2)
2. airport is added to existing station (unfortunately unavoideable)
*/
if (airport_upgrade) {UpdateAirplanesOnNewStation(st);}
-
+
{
const byte *b = _airport_map5_tiles[p1];
BEGIN_TILE_LOOP(tile_cur,w,h,tile)
- ModifyTile(tile_cur,
+ ModifyTile(tile_cur,
MP_SETTYPE(MP_STATION) | MP_MAPOWNER_CURRENT |
MP_MAP2 | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR | MP_MAP5,
st->index, *b++);
@@ -1467,7 +1467,7 @@ END_TILE_LOOP(tile_cur, w,h,tile)
return cost;
}
-/* Build a buoy
+/* Build a buoy
* p1,p2 unused
*/
@@ -1499,7 +1499,7 @@ int32 CmdBuildBuoy(int x, int y, uint32 flags, uint32 p1, uint32 p2)
st->facilities |= FACIL_DOCK;
st->had_vehicle_of_type |= HVOT_BUOY;
st->owner = OWNER_NONE;
-
+
st->build_date = _date;
ModifyTile(ti.tile,
@@ -1511,7 +1511,7 @@ int32 CmdBuildBuoy(int x, int y, uint32 flags, uint32 p1, uint32 p2)
);
UpdateStationVirtCoordDirty(st);
-
+
UpdateStationAcceptance(st, false);
InvalidateWindow(WC_STATION_LIST, st->owner);
}
@@ -1538,7 +1538,7 @@ static int32 RemoveBuoy(Station *st, uint32 flags)
st->facilities &= ~FACIL_DOCK;
st->had_vehicle_of_type &= ~HVOT_BUOY;
- ModifyTile(tile,
+ ModifyTile(tile,
MP_SETTYPE(MP_WATER) |
MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR,
OWNER_WATER, /* map_owner */
@@ -1602,13 +1602,13 @@ int32 CmdBuildDock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
FindLandscapeHeightByTile(&ti, tile_cur);
if (ti.tileh != 0 || ti.type != MP_WATER)
return_cmd_error(STR_304B_SITE_UNSUITABLE);
-
+
/* middle */
- st = GetStationAround(tile + _dock_tileoffs_chkaround[direction],
+ st = GetStationAround(tile + _dock_tileoffs_chkaround[direction],
_dock_w_chk[direction], _dock_h_chk[direction], -1);
if (st == CHECK_STATIONS_ERR)
return CMD_ERROR;
-
+
/* Find a station close to us */
if (st == NULL) {
st = GetClosestStationFromTile(tile, 8, _current_player);
@@ -1618,7 +1618,7 @@ int32 CmdBuildDock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (st != NULL) {
if (st->owner != OWNER_NONE && st->owner != _current_player)
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
-
+
if (!CheckStationSpreadOut(st, tile, 1, 1))
return CMD_ERROR;
@@ -1650,23 +1650,23 @@ int32 CmdBuildDock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!st->facilities) st->xy = tile;
st->facilities |= FACIL_DOCK;
st->owner = _current_player;
-
+
st->build_date = _date;
- ModifyTile(tile,
- MP_SETTYPE(MP_STATION) | MP_MAPOWNER_CURRENT |
+ ModifyTile(tile,
+ MP_SETTYPE(MP_STATION) | MP_MAPOWNER_CURRENT |
MP_MAP2 | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR |
MP_MAP5,
st->index,
direction + 0x4C);
- ModifyTile(tile + _tileoffs_by_dir[direction],
- MP_SETTYPE(MP_STATION) | MP_MAPOWNER_CURRENT |
+ ModifyTile(tile + _tileoffs_by_dir[direction],
+ MP_SETTYPE(MP_STATION) | MP_MAPOWNER_CURRENT |
MP_MAP2 | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR |
MP_MAP5,
st->index,
(direction&1) + 0x50);
-
+
UpdateStationVirtCoordDirty(st);
UpdateStationAcceptance(st, false);
InvalidateWindow(WC_STATION_LIST, st->owner);
@@ -1747,13 +1747,13 @@ static void DrawTile_Station(TileInfo *ti)
t += sizeof(uint32);
if (image & 0x8000)
image |= image_or_modificator;
- DrawGroundSprite(image + base_img);
+ DrawGroundSprite(image + base_img);
for(dtss = (DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
if ((byte)dtss->delta_z != 0x80) {
image = dtss->image + base_img;
if (_display_opt & DO_TRANS_BUILDINGS) {
- if (image&0x8000) image |= image_or_modificator;
+ if (image&0x8000) image |= image_or_modificator;
} else {
image = (image & 0x3FFF) | 0x03224000;
}
@@ -1763,7 +1763,7 @@ static void DrawTile_Station(TileInfo *ti)
image = *(uint32*)&dtss->height + base_img; /* endian ok */
if (_display_opt & DO_TRANS_BUILDINGS) {
- if (image&0x8000) image |= image_or_modificator;
+ if (image&0x8000) image |= image_or_modificator;
} else {
image = (image & 0x3FFF) | 0x03224000;
}
@@ -1852,7 +1852,7 @@ static uint32 GetTileTrackStatus_Station(uint tile, TransportType mode) {
(IS_BYTE_INSIDE(i, 0x47, 0x4B) && (_patches.roadveh_queue || st->bus_stop_status&3)) ) {
/* This is a bus/truck stop, and there is free space
* (or we allow queueing) */
-
+
/* We reverse the dir because it points out of the
* exit, and we want to get in. Maybe we should return
* both dirs here? */
@@ -1878,7 +1878,7 @@ static void TileLoop_Station(uint tile)
// 0x3A - flag small airport (58)
if (_map5[tile] == 39 || _map5[tile] == 58 || _map5[tile] == 90 || _map5[tile] == 102)
AddAnimatedTile(tile);
-
+
// treat a bouy tile as water.
else if (_map5[tile] == 0x52)
TileLoop_Water(tile);
@@ -1900,7 +1900,7 @@ static void AnimateTile_Station(uint tile)
if (m5 >= 39 && m5 <= 50) { // turning radar (39 - 50)
if (_tick_counter & 3)
return;
-
+
if (++m5 == 50+1)
m5 = 39;
@@ -1910,14 +1910,14 @@ static void AnimateTile_Station(uint tile)
} else if (m5 >= 90 && m5 <= 113) { // turning radar with ground under it (different fences) (90 - 101 | 102 - 113)
if (_tick_counter & 3)
return;
-
+
m5++;
-
+
if (m5 == 101+1) {m5 = 90;} // radar with fences in south
else if (m5 == 113+1) {m5 = 102;} // radar with fences in north
_map5[tile] = m5;
- MarkTileDirtyByTile(tile);
+ MarkTileDirtyByTile(tile);
//added - end
} else if (m5 >= 0x3A && m5 <= 0x3D) { // windsack (58 - 61)
if (_tick_counter & 1)
@@ -1925,7 +1925,7 @@ static void AnimateTile_Station(uint tile)
if (++m5 == 0x3D+1)
m5 = 0x3A;
-
+
_map5[tile] = m5;
MarkTileDirtyByTile(tile);
}
@@ -1957,17 +1957,17 @@ static uint32 VehicleEnter_Station(Vehicle *v, uint tile, int x, int y)
uint16 spd;
if (v->type == VEH_Train) {
- if (IS_BYTE_INSIDE(_map5[tile], 0, 8) && v->subtype == 0 &&
+ if (IS_BYTE_INSIDE(_map5[tile], 0, 8) && v->subtype == 0 &&
!IsTrainStationTile(tile + _tileoffs_by_dir[v->direction >> 1])) {
-
+
station_id = _map2[tile];
- if ((!(v->next_order & OF_NON_STOP) && !_patches.new_nonstop) ||
+ if ((!(v->next_order & OF_NON_STOP) && !_patches.new_nonstop) ||
(((v->next_order & OT_MASK) == OT_GOTO_STATION && v->next_order_param == station_id))) {
if (!(_patches.new_nonstop && (v->next_order & OF_NON_STOP)) && v->next_order != OT_LEAVESTATION && v->last_station_visited != station_id) {
x &= 0xF;
y &= 0xF;
-
+
dir = v->direction & 6;
if (dir & 2) intswap(x,y);
if (y == 8) {
@@ -1983,7 +1983,7 @@ static uint32 VehicleEnter_Station(Vehicle *v, uint tile, int x, int y)
}
}
}
- }
+ }
}
} else if (v->type == VEH_Road) {
if (v->u.road.state < 16 && (v->u.road.state&4)==0 && v->u.road.frame==0) {
@@ -2015,7 +2015,7 @@ static uint32 VehicleEnter_Station(Vehicle *v, uint tile, int x, int y)
}
}
}
-
+
return 0;
}
@@ -2041,7 +2041,7 @@ void DeleteAllPlayerStations()
FOR_ALL_STATIONS(st) {
if (st->xy && st->owner < MAX_PLAYERS)
- DeleteStation(st);
+ DeleteStation(st);
}
}
@@ -2111,7 +2111,7 @@ static void UpdateStationRating(Station *st)
(rating += 45, days > 3) ||
(rating += 35, true);
}
-
+
{
waiting = ge->waiting_acceptance & 0xFFF;
(rating -= 90, waiting > 1500) ||
@@ -2127,7 +2127,7 @@ static void UpdateStationRating(Station *st)
// only modify rating in steps of -2, -1, 0, 1 or 2
ge->rating = rating = or + clamp(clamp(rating, 0, 255) - or, -2, 2);
-
+
// if rating is <= 64 and more than 200 items waiting, remove some random amount of goods from the station
if (rating <= 64 && waiting >= 200) {
int dec = Random() & 0x1F;
@@ -2150,7 +2150,7 @@ static void UpdateStationRating(Station *st)
}
}
} while (++ge != endof(st->goods));
-
+
index = st->index;
if (waiting_changed)
@@ -2223,8 +2223,8 @@ void ModifyStationRatingAround(TileIndex tile, byte owner, int amount, uint radi
static void UpdateStationWaiting(Station *st, int type, uint amount)
{
- st->goods[type].waiting_acceptance =
- (st->goods[type].waiting_acceptance & ~0xFFF) +
+ st->goods[type].waiting_acceptance =
+ (st->goods[type].waiting_acceptance & ~0xFFF) +
min(0xFFF, (st->goods[type].waiting_acceptance & 0xFFF) + amount);
st->goods[type].enroute_time = 0;
@@ -2240,7 +2240,7 @@ int32 CmdRenameStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
str = AllocateName((byte*)_decode_parameters, 6);
if (str == 0)
return CMD_ERROR;
-
+
if (flags & DC_EXEC) {
st = DEREF_STATION(p1);
old_str = st->string_id;
@@ -2282,11 +2282,11 @@ uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount)
st = DEREF_STATION(st_index);
if ((st->had_vehicle_of_type & HVOT_BUOY) == 0 &&
( !st->town->exclusive_counter || (st->town->exclusivity == st->owner) ) && // check exclusive transport rights
- st->goods[type].rating != 0 &&
+ st->goods[type].rating != 0 &&
(!_patches.selectgoods || st->goods[type].last_speed) && // if last_speed is 0, no vehicle has been there.
((st->facilities & (byte)~FACIL_BUS_STOP)!=0 || type==CT_PASSENGERS) && // if we have other fac. than a bus stop, or the cargo is passengers
((st->facilities & (byte)~FACIL_TRUCK_STOP)!=0 || type!=CT_PASSENGERS)) { // if we have other fac. than a cargo bay or the cargo is not passengers
-
+
around[i] = st_index;
around_ptr[i] = st;
}
@@ -2320,10 +2320,10 @@ uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount)
st1 = around_ptr[i];
} else if (around_ptr[i]->goods[type].rating >= best_rating2) {
best_rating2 = around_ptr[i]->goods[type].rating;
- st2 = around_ptr[i];
+ st2 = around_ptr[i];
}
}
-
+
assert(st1 != NULL);
assert(st2 != NULL);
assert(best_rating != 0 || best_rating2 != 0);
@@ -2338,7 +2338,7 @@ uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount)
if (t != 0) {
moved = (t * best_rating >> 8) + 1;
amount -= t;
- UpdateStationWaiting(st1, type, moved);
+ UpdateStationWaiting(st1, type, moved);
}
assert(amount >= 0);
@@ -2398,7 +2398,7 @@ void BuildOilRig(uint tile)
UpdateStationVirtCoordDirty(st);
UpdateStationAcceptance(st, false);
- return;
+ return;
}
}
}
@@ -2456,10 +2456,10 @@ static int32 ClearTile_Station(uint tile, byte flags) {
// original airports < 67, new airports between 83 - 114
if (m5 < 0x43 || ( m5 >= 83 && m5 <= 114) )
return RemoveAirport(st, flags);
-
+
if (m5 < 0x47)
return RemoveTruckStation(st, flags);
-
+
if (m5 < 0x4B)
return RemoveBusStation(st, flags);
@@ -2527,7 +2527,7 @@ static const byte _station_desc[] = {
SLE_VAR(Station,airport_type, SLE_UINT8),
SLE_VAR(Station,truck_stop_status, SLE_UINT8),
SLE_VAR(Station,bus_stop_status, SLE_UINT8),
-
+
// blocked_months was stored here in savegame format 0 - 4.0
SLE_CONDVAR(Station,blocked_months_obsolete, SLE_UINT8, 0, 4),
diff --git a/station_gui.c b/station_gui.c
index 8582b83b3..5337a5349 100644
--- a/station_gui.c
+++ b/station_gui.c
@@ -16,7 +16,7 @@ static void StationsWndShowStationRating(int x, int y, int type, uint acceptance
if (acceptance > 575)
acceptance = 575;
-
+
acceptance = (acceptance + 7) >> 3;
/* draw cargo */
@@ -31,12 +31,12 @@ static void StationsWndShowStationRating(int x, int y, int type, uint acceptance
}
x -= (acceptance>>3);
-
+
DrawString(x+1, y, _cargoc.names_short[type], 0x10);
/* draw green/red ratings bar */
GfxFillRect(x+1, y+8, x+7, y+8, 0xB8);
-
+
rating = (rating >> 5);
if (rating != 0) {
@@ -110,7 +110,7 @@ static void MakeSortedStationList(byte owner)
}
qsort(firstelement, n, sizeof(_station_sort[0]), StationNameSorter);
-
+
DEBUG(misc, 1) ("Resorting Stations list...");
}
@@ -151,7 +151,7 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
DrawString(xb, y, STR_304A_NONE, 0);
return;
}
-
+
i += w->vscroll.pos; // offset from sorted station list of current player
assert(i < _num_station_sort[window_number]); // at least one station must exist
@@ -318,7 +318,7 @@ static void DrawStationViewWindow(Window *w)
uint waiting = (st->goods[i].waiting_acceptance & 0xFFF);
if (waiting == 0)
continue;
-
+
num = (waiting + 5) / 10;
if (num != 0) {
int cur_x = x;
@@ -352,7 +352,7 @@ static void DrawStationViewWindow(Window *w)
}
}
} while (pos > -5 && ++i != 12);
-
+
if (w->widget == _station_view_widgets) {
b = _userstring;
b[0] = 0x81;
@@ -368,7 +368,7 @@ static void DrawStationViewWindow(Window *w)
b += 5;
}
}
-
+
if (b == (byte*)&_userstring[3]) {
b[0] = 0x81;
b[1] = STR_00D0_NOTHING;
@@ -380,7 +380,7 @@ static void DrawStationViewWindow(Window *w)
DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245);
} else {
-
+
DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0);
y = 77;
@@ -412,7 +412,7 @@ static void StationViewWndProc(Window *w, WindowEvent *e)
case 7:
SetWindowDirty(w);
-
+
/* toggle height/widget set */
w->height ^= (210 ^ 110);
*(uint32*)&w->widget ^= (uint32)_station_view_expanded_widgets ^ (uint32)_station_view_widgets;
@@ -438,7 +438,7 @@ static void StationViewWndProc(Window *w, WindowEvent *e)
st = DEREF_STATION(w->window_number);
DoCommandP(st->xy, w->window_number, 0, NULL, CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION));
- } break;
+ } break;
}
}
diff --git a/stdafx.h b/stdafx.h
index 6e1034b2f..fd2c655c9 100644
--- a/stdafx.h
+++ b/stdafx.h
@@ -119,7 +119,7 @@ static uint32 INLINE TO_LE32(uint32 x) { return BSWAP32(x); }
static uint16 INLINE TO_LE16(uint16 x) { return BSWAP16(x); }
# define TO_BE32(x) x
# define TO_BE16(x) x
-#define TO_BE32X(x) x
+#define TO_BE32X(x) x
#else
# define TO_LE32(x) x
# define TO_LE16(x) x
diff --git a/strings.c b/strings.c
index da6038c70..28e85b09e 100644
--- a/strings.c
+++ b/strings.c
@@ -68,7 +68,7 @@ static const CurrencySpec _currency_specs[] = {
{ 3, ',', CF_TOEURO_2002, "NLG ", "" },
{ 2730,',', CF_TOEURO_2002, "ITL ", "" },
{ 13, '.', 0, "", " kr" },
- { 5, ' ', 0, "", " rur" },
+ { 5, ' ', 0, "", " rur" },
{ 50, ',', 0, "", " Kc" },
{ 130, '.', 0, "", " kr" },
{ 11, '.', 0, "", " kr" },
@@ -171,9 +171,9 @@ byte *GetString(byte *buffr, uint16 string)
return DecodeString(buffr, GetStringPtr(string));
}
-void InjectDparam(int amount)
+void InjectDparam(int amount)
{
- memmove(_decode_parameters + amount, _decode_parameters, sizeof(_decode_parameters) - amount * sizeof(uint32));
+ memmove(_decode_parameters + amount, _decode_parameters, sizeof(_decode_parameters) - amount * sizeof(uint32));
}
@@ -301,7 +301,7 @@ static byte *FormatYmdString(byte *buff, uint16 number)
ConvertDayToYMD(&ymd, number);
for(src = GetStringPtr(ymd.day+STR_01AC_1ST-1); (*buff++=*src++) != 0;) {}
-
+
buff[-1] = ' ';
memcpy(buff, GetStringPtr(STR_0162_JAN + ymd.month), 4);
buff[3] = ' ';
@@ -338,7 +338,7 @@ static byte *FormatGenericCurrency(byte *buff, const CurrencySpec *spec, int64 n
// convert from negative
if (number < 0) { *buff++ = '-'; number = -number; }
-
+
// add pre part
s = spec->pre;
while (s != spec->pre + lengthof(spec->pre) && (c=*s++)) *buff++ = c;
@@ -352,13 +352,13 @@ static byte *FormatGenericCurrency(byte *buff, const CurrencySpec *spec, int64 n
} else if (number >= 1000000) {
number = (number + 500) / 1000;
compact = 'k';
- }
+ }
}
-
+
// convert to ascii number and add commas
p = buf;
j = 4;
- do {
+ do {
if (--j == 0) { *p++ = spec->separator; j = 3; }
*p++ = '0' + number % 10;
} while (number /= 10);
@@ -427,8 +427,8 @@ static byte *DecodeString(byte *buff, const byte *str)
}
break;
}
-
- // 0x85 is used as escape character..
+
+ // 0x85 is used as escape character..
case 0x85:
switch(*str++) {
case 0:
@@ -453,7 +453,7 @@ static byte *DecodeString(byte *buff, const byte *str)
// liquid type of cargo is multiplied by 100 to get correct amount
buff = FormatCommaNumber(buff, GetParamInt16() * multiplier );
s = GetStringPtr(cargo_str);
-
+
memcpy(buff++, " ", 1);
while (*s) *buff++ = *s++;
break;
@@ -476,7 +476,7 @@ static byte *DecodeString(byte *buff, const byte *str)
while (*s) *buff++ = *s++;
break;
}
-
+
case 0x88: // {STRING}
buff = GetString(buff, (uint16)GetParamUint16());
break;
@@ -515,7 +515,7 @@ static byte *DecodeString(byte *buff, const byte *str)
}
case 0x9C: { // {CURRENCY64}
- buff = FormatGenericCurrency(buff, &_currency_specs[_opt.currency], GetParamInt64(), false);
+ buff = FormatGenericCurrency(buff, &_currency_specs[_opt.currency], GetParamInt64(), false);
break;
}
@@ -567,7 +567,7 @@ static byte *StationGetSpecialString(byte *buff)
static byte *GetSpecialTownNameString(byte *buff, int ind) {
uint32 x = GetParamInt32();
-
+
_town_name_generators[ind](buff, x);
while (*buff != 0) buff++;
@@ -669,7 +669,7 @@ static byte *GenPlayerName_4(byte *buff)
if (i < sizeof(_initial_name_letters)) {
buff[0] = _initial_name_letters[i];
buff[1] = '.';
- buff += 2;
+ buff += 2;
}
base = 0;
@@ -712,7 +712,7 @@ static const char * const _song_names[] = {
static byte *GetSpecialPlayerNameString(byte *buff, int ind)
{
switch(ind) {
-
+
// not used
case 1: {
int i = GetParamInt32() & 0xFFFF;
@@ -789,14 +789,14 @@ bool ReadLanguagePack(int lang_index) {
free(lang);
}
if (lang_pack == NULL) return false;
- if (len < sizeof(LanguagePackHeader) ||
+ if (len < sizeof(LanguagePackHeader) ||
HDR->ident != TO_LE32(LANGUAGE_PACK_IDENT) ||
HDR->version != TO_LE32(LANGUAGE_PACK_VERSION)) {
free(lang_pack);
return false;
}
#undef HDR
-
+
#if defined(TTD_BIG_ENDIAN)
for(i=0; i!=32; i++) {
((LanguagePackHeader*)lang_pack)->offsets[i] = READ_LE_UINT16(&((LanguagePackHeader*)lang_pack)->offsets[i]);
@@ -855,7 +855,7 @@ void InitializeLanguagePacks()
char *s = str_fmt("%s%s", _path.lang_dir, files[i]);
in = fopen(s, "rb");
free(s);
- if (!in ||
+ if (!in ||
(j = fread(&hdr, sizeof(hdr), 1, in), fclose(in), j) != 1 ||
hdr.ident != TO_LE32(LANGUAGE_PACK_IDENT) ||
hdr.version != TO_LE32(LANGUAGE_PACK_VERSION)) {
@@ -865,7 +865,7 @@ void InitializeLanguagePacks()
dl->ent[m].file = files[i];
dl->ent[m].name = strdup(hdr.name);
-
+
if (!strcmp(hdr.name, "English")) def = m;
m++;
@@ -873,7 +873,7 @@ void InitializeLanguagePacks()
if (m == 0)
error(n == 0 ? "No available language packs" : "Invalid version of language packs");
-
+
dl->num = m;
for(i=0; i!=dl->num; i++)
dl->dropdown[i] = SPECSTR_LANGUAGE_START + i;
diff --git a/subsidy_gui.c b/subsidy_gui.c
index 4e14aab67..ddb294561 100644
--- a/subsidy_gui.c
+++ b/subsidy_gui.c
@@ -10,7 +10,7 @@
#include "economy.h"
static void HandleSubsidyClick(int y)
-{
+{
Subsidy *s;
int num,offs;
TileIndex xy;
@@ -42,7 +42,7 @@ static void HandleSubsidyClick(int y)
}
}
return;
-
+
handle_click:
/* determine from coordinate for subsidy and try to scroll to it */
@@ -53,7 +53,7 @@ handle_click:
xy = DEREF_TOWN(offs)->xy;
} else {
xy = _industries[offs].xy;
-
+
}
if (!ScrollMainWindowToTile(xy)) {
/* otherwise determine to coordinate for subsidy and scroll to it */
@@ -90,7 +90,7 @@ static void DrawSubsidiesWindow(Window *w)
if (s->cargo_type != 0xFF && s->age < 12) {
SetupSubsidyDecodeParam(s, 1);
x2 = DrawString(x+2, y, STR_2027_FROM_TO, 0);
-
+
SET_DPARAM16(0, _date - ymd.day + 384 - s->age * 32);
DrawString(x2, y, STR_2028_BY, 0);
y += 10;
diff --git a/terraform_gui.c b/terraform_gui.c
index 95fd27b78..8971e978a 100644
--- a/terraform_gui.c
+++ b/terraform_gui.c
@@ -21,9 +21,9 @@ static void CcTerraform(bool success, uint tile, uint32 p1, uint32 p2)
static void GenericRaiseLowerLand(uint tile, int mode)
{
if (mode) {
- DoCommandP(tile, 8, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE));
+ DoCommandP(tile, 8, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE));
} else {
- DoCommandP(tile, 8, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE));
+ DoCommandP(tile, 8, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE));
}
}
@@ -94,7 +94,7 @@ static void TerraformClick_BuyLand(Window *w)
static void TerraformClick_Trees(Window *w)
{
- if (HandlePlacePushButton(w, 8, 0, 1, PlaceProc_PlantTree)) ShowBuildTreesToolbar();
+ if (HandlePlacePushButton(w, 8, 0, 1, PlaceProc_PlantTree)) ShowBuildTreesToolbar();
}
static void TerraformClick_PlaceSign(Window *w)
@@ -159,7 +159,7 @@ static void TerraformToolbWndProc(Window *w, WindowEvent *e)
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
} else if (e->place.userdata == VPM_X_AND_Y_LIMITED) {
// if (e->click.pt.x != -1) {
-// DoCommandP(e->place.tile, _tree_to_plant, e->place.starttile, NULL,
+// DoCommandP(e->place.tile, _tree_to_plant, e->place.starttile, NULL,
// CMD_PLANT_TREE | CMD_AUTO | CMD_MSG(STR_2805_CAN_T_PLANT_TREE_HERE));
} else {
assert(true);
diff --git a/texteff.c b/texteff.c
index e68d2d707..9aa8488a8 100644
--- a/texteff.c
+++ b/texteff.c
@@ -33,7 +33,7 @@ void AddTextEffect(StringID msg, int x, int y, uint16 duration)
if (_game_mode == GM_MENU)
return;
-
+
for (te = _text_effect_list; te->string_id != 0xFFFF; ) {
if (++te == endof(_text_effect_list))
return;
@@ -115,7 +115,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
continue;
AddStringToDraw(te->x, te->y, (StringID)(te->string_id-1), te->params_1, te->params_2);
}
-
+
}
}
@@ -131,7 +131,7 @@ void DeleteAnimatedTile(uint tile)
endof(_animated_tile_list)[-1] = 0;
MarkTileDirtyByTile(tile);
return;
- }
+ }
}
}
@@ -145,7 +145,7 @@ bool AddAnimatedTile(uint tile)
MarkTileDirtyByTile(tile);
return true;
}
- }
+ }
return false;
}
diff --git a/town.h b/town.h
index f3bdbe419..3fca8d9f4 100644
--- a/town.h
+++ b/town.h
@@ -9,14 +9,14 @@ struct Town {
// Current population of people and amount of houses.
uint16 num_houses;
uint32 population;
-
+
// Town name
uint16 townnametype;
uint32 townnameparts;
-
- // NOSAVE: Location of name sign, UpdateTownVirtCoord updates this.
+
+ // NOSAVE: Location of name sign, UpdateTownVirtCoord updates this.
ViewportSign sign;
-
+
// Makes sure we don't build certain house types twice.
byte flags12;
@@ -32,7 +32,7 @@ struct Town {
uint8 exclusivity; // which player has exslusivity
uint8 exclusive_counter; // months till the exclusivity expires
int16 ratings[MAX_PLAYERS];
-
+
// Maximum amount of passengers and mail that can be transported.
uint16 max_pass;
uint16 max_mail;
@@ -52,17 +52,17 @@ struct Town {
uint16 act_water;
uint16 new_act_food;
uint16 new_act_water;
-
+
// Time until we rebuild a house.
byte time_until_rebuild;
// When to grow town next time.
byte grow_counter;
- byte growth_rate;
+ byte growth_rate;
// Fund buildings program in action?
byte fund_buildings_months;
-
+
// Fund road reconstruction in action?
byte road_build_months;
diff --git a/town_cmd.c b/town_cmd.c
index 6ed0b6151..ee5de74f3 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -76,8 +76,8 @@ static void DrawTile_Town(TileInfo *ti)
if ((image = dcts->sprite_2) != 0) {
if (!(_display_opt & DO_TRANS_BUILDINGS))
image = (image & 0x3FFF) | 0x3224000;
-
- AddSortableSpriteToDraw(image,
+
+ AddSortableSpriteToDraw(image,
ti->x | (dcts->subtile_xy>>4),
ti->y | (dcts->subtile_xy&0xF),
(dcts->width_height>>4)+1,
@@ -100,7 +100,7 @@ static uint GetSlopeZ_Town(TileInfo *ti)
{
uint z = GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
if (ti->tileh != 0) z = (z & ~7) + 4;
- return (uint16) z;
+ return (uint16) z;
}
static uint GetSlopeTileh_Town(TileInfo *ti)
@@ -140,7 +140,7 @@ static void AnimateTile_Town(uint tile)
_map_owner[tile] &= 0x7F;
DeleteAnimatedTile(tile);
}
-
+
MarkTileDirtyByTile(tile);
}
@@ -169,9 +169,9 @@ static void ChangePopulation(Town *t, int mod)
static void MakeSingleHouseBigger(uint tile)
{
byte b;
-
+
assert(IS_TILETYPE(tile, MP_HOUSE));
-
+
b = _map5[tile];
if (b & 0x80)
return;
@@ -185,14 +185,14 @@ static void MakeSingleHouseBigger(uint tile)
if ( (_map3_lo[tile] & 0xC0) == 0xC0) {
Town *t = ClosestTownFromTile(tile, (uint)-1);
- ChangePopulation(t, _housetype_population[_map2[tile]]);
+ ChangePopulation(t, _housetype_population[_map2[tile]]);
}
MarkTileDirtyByTile(tile);
}
static void MakeTownHouseBigger(uint tile)
{
- uint flags = _house_more_flags[_map2[tile]];
+ uint flags = _house_more_flags[_map2[tile]];
if (flags & 8) MakeSingleHouseBigger(TILE_ADDXY(tile, 0, 0));
if (flags & 4) MakeSingleHouseBigger(TILE_ADDXY(tile, 0, 1));
if (flags & 2) MakeSingleHouseBigger(TILE_ADDXY(tile, 1, 0));
@@ -245,7 +245,7 @@ static void TileLoop_Town(uint tile)
_current_player = OWNER_TOWN;
ClearTownHouse(t, tile);
-
+
// rebuild with another house?
if ( (byte) (r >> 8) >= 12) {
DoBuildTownHouse(t, tile);
@@ -274,12 +274,12 @@ static int32 ClearTile_Town(uint tile, byte flags)
rating = _housetype_remove_ratingmod[house];
_cleared_town_rating += rating;
_cleared_town = t = ClosestTownFromTile(tile, (uint)-1);
-
+
if (_current_player < MAX_PLAYERS) {
if (rating > t->ratings[_current_player] && !(flags & DC_NO_TOWN_RATING) && !_cheats.magic_bulldozer.value) {
SET_DPARAM16(0, t->index);
return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES);
- }
+ }
}
if (flags & DC_EXEC) {
@@ -293,7 +293,7 @@ static int32 ClearTile_Town(uint tile, byte flags)
static void GetAcceptedCargo_Town(uint tile, AcceptedCargo *ac)
{
int type = _map2[tile];
-
+
ac->type_1 = CT_PASSENGERS;
ac->amount_1 = _housetype_cargo_passengers[type];
@@ -336,7 +336,7 @@ static const TileIndexDiff _roadblock_tileadd[4+3] = {
TILE_XY(1,0),
TILE_XY(0,1),
TILE_XY(-1,0),
-
+
// Store the first 3 elements again.
// Lets us rotate without using &3.
TILE_XY(0,-1),
@@ -352,7 +352,7 @@ static void TownTickHandler(Town *t)
if (GrowTown(t)) {
i = t->growth_rate;
} else {
- i = 0;
+ i = 0;
}
}
t->grow_counter = i;
@@ -400,7 +400,7 @@ static bool IsRoadAllowedHere(uint tile, int dir)
// If this assertion fails, it might be because the world contains
// land at the edges. This is not ok.
TILE_ASSERT(tile);
-
+
for(;;) {
// Check if there already is a road at this point?
if (GetRoadBitsByTile(tile) == 0) {
@@ -421,11 +421,11 @@ static bool IsRoadAllowedHere(uint tile, int dir)
HASBIT(GetTownRoadMask(TILE_ADD(tile, _roadblock_tileadd[dir+1] + _roadblock_tileadd[dir+2])), dir) ||
HASBIT(GetTownRoadMask(TILE_ADD(tile, _roadblock_tileadd[dir+3] + _roadblock_tileadd[dir+2])), dir))
return false;
-
+
// Otherwise allow
return true;
}
-
+
// If the tile is not a slope in the right direction, then
// maybe terraform some.
if ((k = (dir&1)?0xC:0x9) != slope && (k^0xF) != slope) {
@@ -447,7 +447,7 @@ static bool IsRoadAllowedHere(uint tile, int dir)
static bool TerraformTownTile(uint tile, int edges, int dir)
{
int32 r;
-
+
TILE_ASSERT(tile);
r = DoCommandByTile(tile, edges, dir, DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND);
@@ -491,7 +491,7 @@ static void GrowTownInTile(uint *tile_ptr, uint mask, int block, Town *t1)
if (mask == 0) {
// Tile has no road. First reset the status counter
- // to say that this is the last iteration.
+ // to say that this is the last iteration.
_grow_town_result = 0;
// Then check if the tile we are at belongs to the town,
@@ -520,7 +520,7 @@ static void GrowTownInTile(uint *tile_ptr, uint mask, int block, Town *t1)
// return if the road we're trying to build is curved.
if ( a != (b^2))
return;
-
+
// Return if neither side of the new road is a house
if (!IS_TILETYPE(TILE_ADD(tile,_roadblock_tileadd[a+1]), MP_HOUSE) &&
!IS_TILETYPE(TILE_ADD(tile,_roadblock_tileadd[a+3]), MP_HOUSE))
@@ -544,7 +544,7 @@ static void GrowTownInTile(uint *tile_ptr, uint mask, int block, Town *t1)
*tile_ptr = flotr.tile;
return;
}
-
+
// For any other kind of tunnel/bridge, bail out.
if (IS_TILETYPE(tile, MP_TUNNELBRIDGE))
return;
@@ -557,7 +557,7 @@ static void GrowTownInTile(uint *tile_ptr, uint mask, int block, Town *t1)
// This is the tile we will reach if we extend to this direction.
tmptile = TILE_ADD(tile,_roadblock_tileadd[i]);
-
+
// Don't do it if it reaches to water.
if (IS_WATER_TILE(tmptile))
return;
@@ -569,7 +569,7 @@ static void GrowTownInTile(uint *tile_ptr, uint mask, int block, Town *t1)
return;
}
- // Build a house at the edge. 60% chance or
+ // Build a house at the edge. 60% chance or
// always ok if no road allowed.
if (!IsRoadAllowedHere(tmptile, i) || CHANCE16(6,10)) {
// But not if there already is a house there.
@@ -722,7 +722,7 @@ bool GrowTown(Town *t)
return GrowTownAtRoad(t, tile);
}
offs = *ptr++;
-
+
tile = TILE_ADD(tile, offs);
} while (offs);
@@ -732,7 +732,7 @@ bool GrowTown(Town *t)
ptr = _town_coord_mod;
do {
FindLandscapeHeightByTile(&ti, tile);
-
+
// Only work with plain land that not already has a house with map5=0
if (ti.tileh == 0 && !(ti.type==MP_HOUSE && ti.map5==0)) {
if (DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) {
@@ -800,7 +800,7 @@ restart:
SET_DPARAM32(0, r);
GetString(buf1, t1->townnametype);
-
+
// Check size and width
if (strlen(buf1) >= 31 || GetStringWidth(buf1) > 130)
continue;
@@ -814,7 +814,7 @@ restart:
}
}
t1->townnameparts = r;
-
+
return;
}
}
@@ -868,7 +868,7 @@ static void DoCreateTown(Town *t, TileIndex tile)
t->statues = 0;
CreateTownName(t);
-
+
UpdateTownVirtCoord(t);
_town_sort_dirty = true;
@@ -906,7 +906,7 @@ int32 CmdBuildTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
uint tile = TILE_FROM_XY(x,y);
TileInfo ti;
Town *t;
-
+
SET_EXPENSES_TYPE(EXPENSES_OTHER);
// Check if too close to the edge of map
@@ -925,7 +925,7 @@ int32 CmdBuildTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// Allocate town struct
t = AllocateTown();
if (t == NULL)
- return_cmd_error(STR_023A_TOO_MANY_TOWNS);
+ return_cmd_error(STR_023A_TOO_MANY_TOWNS);
// Create the town
if (flags & DC_EXEC) {
@@ -959,7 +959,7 @@ Town *CreateRandomTown()
// Check not too close to a town
if (IsCloseToTown(tile, 20))
continue;
-
+
// Allocate a town struct
t = AllocateTown();
if (t == NULL)
@@ -1042,7 +1042,7 @@ static bool CheckFree2x2Area(Town *t1, uint tile)
tile += _tile_add[i];
t = ClosestTownFromTile(tile, (uint)-1);
- if (t1 != t)
+ if (t1 != t)
return false;
if (GetTileSlope(tile, NULL))
@@ -1063,7 +1063,7 @@ static void DoBuildTownHouse(Town *t, uint tile)
uint slope;
int z;
uint oneof;
-
+
// Above snow?
slope = GetTileSlope(tile, &z);
@@ -1110,7 +1110,7 @@ static void DoBuildTownHouse(Town *t, uint tile)
// Make sure there is no slope?
if (_housetype_extra_flags[house]&0x12 && slope)
continue;
-
+
if (_housetype_extra_flags[house]&0x10) {
if (CheckFree2x2Area(t,tile) ||
CheckFree2x2Area(t,(tile+=TILE_XY(-1,0))) ||
@@ -1121,7 +1121,7 @@ static void DoBuildTownHouse(Town *t, uint tile)
} else if (_housetype_extra_flags[house]&4) {
if (CheckBuildHouseMode(t, tile+TILE_XY(1,0), slope, 0))
break;
-
+
if (CheckBuildHouseMode(t, tile+TILE_XY(-1,0), slope, 1)) {
tile += TILE_XY(-1,0);
break;
@@ -1143,7 +1143,7 @@ static void DoBuildTownHouse(Town *t, uint tile)
// Special houses that there can be only one of.
t->flags12 |= oneof;
-
+
{
int m3lo,m5,eflags;
@@ -1152,21 +1152,21 @@ static void DoBuildTownHouse(Town *t, uint tile)
m5 = 0;
if (_generating_world) {
uint32 r = Random();
-
+
// Value for map3lo
m3lo = 0xC0;
if ((byte)r >= 220) m3lo &= (r>>8);
if (m3lo == 0xC0)
ChangePopulation(t, _housetype_population[house]);
-
+
// Initial value for map5.
m5 = (r >> 16) & 0x3F;
}
-
+
assert(IS_TILETYPE(tile, MP_CLEAR));
- ModifyTile(tile,
+ ModifyTile(tile,
MP_SETTYPE(MP_HOUSE) | MP_MAP2 | MP_MAP3LO | MP_MAP3HI_CLEAR | MP_MAP5 | MP_MAPOWNER,
house, /* map2 */
m3lo, /* map3_lo */
@@ -1216,7 +1216,7 @@ static void DoBuildTownHouse(Town *t, uint tile)
static bool BuildTownHouse(Town *t, uint tile)
{
int32 r;
-
+
// make sure it's possible
if (!EnsureNoVehicle(tile)) return false;
if (GetTileSlope(tile, NULL) & 0x10) return false;
@@ -1258,7 +1258,7 @@ static void ClearTownHouse(Town *t, uint tile) {
tile += TILE_XY(-1,-1);
}
}
-
+
// Remove population from the town if the
// house is finished.
if ((~_map3_lo[tile] & 0xC0) == 0) {
@@ -1273,7 +1273,7 @@ static void ClearTownHouse(Town *t, uint tile) {
t->flags12 &= ~2;
if (house == 0x14 || house == 0x20)
t->flags12 &= ~4;
-
+
// Do the actual clearing of tiles
eflags = _housetype_extra_flags[house];
DoClearTownHouseHelper(tile);
@@ -1286,7 +1286,7 @@ int32 CmdRenameTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
StringID str;
Town *t = DEREF_TOWN(p1);
-
+
str = AllocateName((byte*)_decode_parameters, 4);
if (str == 0)
return CMD_ERROR;
@@ -1349,7 +1349,7 @@ void ExpandTown(Town *t)
int amount, n;
_generating_world = true;
-
+
amount = ((int)Random()&3) + 3;
t->num_houses += amount;
UpdateTownRadius(t);
@@ -1374,7 +1374,7 @@ static void TownActionAdvertise(Town *t, int action)
{
static const byte _advertising_amount[3] = {0x40, 0x70, 0xA0};
static const byte _advertising_radius[3] = {10,15,20};
- ModifyStationRatingAround(t->xy, _current_player,
+ ModifyStationRatingAround(t->xy, _current_player,
_advertising_amount[action],
_advertising_radius[action]);
}
@@ -1384,14 +1384,14 @@ static void TownActionRoadRebuild(Town *t, int action)
Player *p;
t->road_build_months = 6;
-
+
SET_DPARAM16(0, t->index);
p = DEREF_PLAYER(_current_player);
SET_DPARAM16(1, p->name_1);
SET_DPARAM32(2, p->name_2);
- AddNewsItem(STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING,
+ AddNewsItem(STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING,
NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_GENERAL, 0), t->xy, 0);
}
@@ -1429,7 +1429,7 @@ static void TownActionBuildStatue(Town *t, int action)
// Layouted as an outward spiral
static const TileIndexDiff _statue_tiles[] = {
TILE_XY(-1,0), TILE_XY(0,1), TILE_XY(1,0), TILE_XY(1,0),
- TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(-1,0), TILE_XY(-1,0),
+ TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(-1,0), TILE_XY(-1,0),
TILE_XY(-1,0), TILE_XY(0,1), TILE_XY(0,1), TILE_XY(0,1),
TILE_XY(1,0), TILE_XY(1,0), TILE_XY(1,0), TILE_XY(1,0),
TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1),
@@ -1437,7 +1437,7 @@ static void TownActionBuildStatue(Town *t, int action)
TILE_XY(-1,0), TILE_XY(0,1), TILE_XY(0,1), TILE_XY(0,1),
TILE_XY(0,1), TILE_XY(0,1), TILE_XY(1,0), TILE_XY(1,0),
TILE_XY(1,0), TILE_XY(1,0), TILE_XY(1,0), TILE_XY(1,0),
- TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1),
+ TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1),
TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(-1,0), TILE_XY(-1,0),
TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0),
TILE_XY(-1,0), TILE_XY(0,1), TILE_XY(0,1), TILE_XY(0,1),
@@ -1445,7 +1445,7 @@ static void TownActionBuildStatue(Town *t, int action)
TILE_XY(1,0), TILE_XY(1,0), TILE_XY(1,0), TILE_XY(1,0),
TILE_XY(1,0), TILE_XY(1,0), TILE_XY(1,0), TILE_XY(1,0),
TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1),
- TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1),
+ TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1), TILE_XY(0,-1),
TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0),
TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0), TILE_XY(-1,0),
0,
@@ -1657,7 +1657,7 @@ Town *ClosestTownFromTile(uint tile, uint threshold)
Town *t;
uint dist, best = threshold;
Town *best_town = NULL;
-
+
FOR_ALL_TOWNS(t) {
if (t->xy != 0) {
dist = GetTileDist(tile, t->xy);
@@ -1680,9 +1680,9 @@ void ChangeTownRating(Town *t, int add, int max)
return;
SETBIT(t->have_ratings, _current_player);
-
+
rating = t->ratings[_current_player];
-
+
if (add < 0) {
if (rating > max) {
rating += add;
@@ -1714,7 +1714,7 @@ bool CheckforTownRating(uint tile, uint32 flags, Town *t, byte type)
return true;
/* check if you're allowed to remove the street/bridge/tunnel/industry
- * owned by a town no removal if rating is lower than ... depends now on
+ * owned by a town no removal if rating is lower than ... depends now on
* difficulty setting. Minimum town rating selected by difficulty level
*/
modemod = _default_rating_settings[_opt_mod_ptr->diff.town_council_tolerance][type];
@@ -1785,7 +1785,7 @@ const TileTypeProcs _tile_type_town_procs = {
// Save and load of towns.
static const byte _town_desc[] = {
SLE_VAR(Town,xy, SLE_UINT16),
-
+
SLE_CONDVAR(Town,population, SLE_FILE_U16 | SLE_VAR_U32, 0, 2),
SLE_CONDVAR(Town,population, SLE_UINT32, 3, 255),
diff --git a/town_gui.c b/town_gui.c
index 98d88fdca..975878a60 100644
--- a/town_gui.c
+++ b/town_gui.c
@@ -84,7 +84,7 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e)
uint buttons;
int numact;
Town *t = DEREF_TOWN(w->window_number);
-
+
switch(e->event) {
case WE_PAINT:
buttons = GetMaskOfTownActions(&numact, t);
@@ -129,7 +129,7 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e)
/* WARNING ugly hack!
GetPlayerNameString sets up (Player #) if the player is human in an extra DPARAM16
It seems that if player is non-human, nothing is set up, so param is 0. GetString doesn't like
- that because there is another param after it.
+ that because there is another param after it.
So we'll just shift the rating one back if player is AI and all is fine
*/
SET_DPARAM16((IS_HUMAN_PLAYER(p->index) ? 4 : 3), str);
@@ -167,7 +167,7 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e)
DrawStringMultiLine(2, 159, STR_204D_INITIATE_A_SMALL_LOCAL + i, 313);
}
}
-
+
break;
case WE_CLICK:
@@ -225,11 +225,11 @@ static void TownViewWndProc(Window *w, WindowEvent *e)
case WE_PAINT:
SET_DPARAM16(0, t->index);
DrawWindowWidgets(w);
-
+
SET_DPARAM32(0, t->population);
SET_DPARAM32(1, t->num_houses);
DrawString(2,107,STR_2006_POPULATION,0);
-
+
SET_DPARAM16(0, t->act_pass);
SET_DPARAM16(1, t->max_pass);
DrawString(2,117,STR_200D_PASSENGERS_LAST_MONTH_MAX,0);
@@ -237,7 +237,7 @@ static void TownViewWndProc(Window *w, WindowEvent *e)
SET_DPARAM16(0, t->act_mail);
SET_DPARAM16(1, t->max_mail);
DrawString(2,127,STR_200E_MAIL_LAST_MONTH_MAX,0);
-
+
DrawWindowViewport(w);
break;
@@ -411,7 +411,7 @@ static void TownDirectoryWndProc(Window *w, WindowEvent *e)
DrawWindowWidgets(w);
DoDrawString(_town_sort_order & 1 ? "\xAA" : "\xA0", (_town_sort_order <= 1) ? 88 : 187, 15, 0x10);
-
+
{
Town *t;
int n = 0;
@@ -447,7 +447,7 @@ static void TownDirectoryWndProc(Window *w, WindowEvent *e)
_town_sort_dirty = true;
SetWindowDirty(w);
} break;
-
+
case 4: { /* Click on Town Matrix */
uint16 id_v = (e->click.pt.y - 28) / 10;
@@ -460,17 +460,17 @@ static void TownDirectoryWndProc(Window *w, WindowEvent *e)
{
Town *t = DEREF_TOWN(_town_sort[id_v]);
assert(t->xy);
-
+
ScrollMainWindowToTile(t->xy);
}
} break;
}
break;
-
+
case WE_4:
SetWindowDirty(w);
break;
- }
+ }
}
static const WindowDesc _town_directory_desc = {
diff --git a/train_cmd.c b/train_cmd.c
index 4c2f52d2a..909294b79 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -22,7 +22,7 @@ static const byte _vehicle_initial_y_fract[4] = {8,4,8,10};
static const byte _state_dir_table[4] = { 0x20, 8, 0x10, 4 };
static const byte _signal_onedir[14] = {
- 0x80, 0x80, 0x80, 0x20, 0x40, 0x10, 0, 0,
+ 0x80, 0x80, 0x80, 0x20, 0x40, 0x10, 0, 0,
0x40, 0x40, 0x40, 0x10, 0x80, 0x20
};
@@ -41,7 +41,7 @@ void UpdateTrainAcceleration(Vehicle *v)
// compute stuff like max speed, power, and weight.
do {
const RailVehicleInfo *rvi = &_rail_vehicle_info[u->engine_type];
-
+
// power is sum of the power for all engines
power += rvi->power;
@@ -53,7 +53,7 @@ void UpdateTrainAcceleration(Vehicle *v)
weight += (_cargoc.weights[u->cargo_type] * u->cargo_count) >> 4;
} while ( (u=u->next) != NULL);
-
+
// these are shown in the UI
v->u.rail.cached_weight = weight;
v->u.rail.cached_power = power;
@@ -123,15 +123,15 @@ static int GetRealisticAcceleration(Vehicle *v)
if (te > te2) te = te2;
f += te;
}
-
+
// add air resistance
{
float cx = 1.0f; // NOT DONE
-
+
// air resistance is doubled in tunnels.
if (v->vehstatus == 0x40) cx *= 2;
- f -= cx * spd * spd * (F_KPH_MS * F_KPH_MS * 0.001f);
+ f -= cx * spd * spd * (F_KPH_MS * F_KPH_MS * 0.001f);
}
// after this f contains the acceleration.
@@ -158,7 +158,7 @@ int GetTrainImage(Vehicle *v, byte direction)
if (base) return base;
img = _engine_original_sprites[v->engine_type];
}
-
+
base = _engine_sprite_base[img] + ((direction + _engine_sprite_add[img]) & _engine_sprite_and[img]);
if (v->cargo_count >= (v->cargo_cap >> 1))
@@ -169,7 +169,7 @@ int GetTrainImage(Vehicle *v, byte direction)
void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod)
{
const RailVehicleInfo *rvi = &_rail_vehicle_info[engine];
-
+
int img = rvi->image_index;
uint32 image = 0;
@@ -190,7 +190,7 @@ void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod)
if (!image) img = _engine_original_sprites[engine];
}
if (!image) {
- image = ((6 + _engine_sprite_add[img+1]) & _engine_sprite_and[img+1]) + _engine_sprite_base[img+1];
+ image = ((6 + _engine_sprite_add[img+1]) & _engine_sprite_and[img+1]) + _engine_sprite_base[img+1];
}
}
DrawSprite(image | image_ormod, x, y);
@@ -208,7 +208,7 @@ void DrawTrainEngineInfo(int engine, int x, int y, int maxw)
SET_DPARAM16(1, rvi->weight << multihead);
SET_DPARAM32(4, (rvi->running_cost_base * _price.running_rail[rvi->engclass] >> 8) << multihead);
-
+
cap = rvi->capacity;
SET_DPARAM16(5, STR_8838_N_A);
if (cap != 0) {
@@ -264,7 +264,7 @@ int32 CmdBuildRailWagon(uint engine, uint tile, uint32 flags)
v->direction = (byte)(dir*2+1);
v->tile = (TileIndex)tile;
-
+
x = GET_TILE_X(tile)*16 | _vehicle_initial_x_fract[dir];
y = GET_TILE_Y(tile)*16 | _vehicle_initial_y_fract[dir];
@@ -294,11 +294,11 @@ int32 CmdBuildRailWagon(uint engine, uint tile, uint32 flags)
e = &_engines[engine];
v->u.rail.railtype = e->railtype;
-
+
v->build_year = _cur_year;
v->type = VEH_Train;
v->cur_image = 0xAC2;
-
+
_new_wagon_id = v->index;
VehiclePositionChanged(v);
@@ -380,12 +380,12 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
uint tile;
_cmd_build_rail_veh_var1 = 0;
-
+
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
tile = TILE_FROM_XY(x,y);
rvi = &_rail_vehicle_info[p1];
-
+
if (rvi->flags & RVI_WAGON) {
return CmdBuildRailWagon(p1, tile, flags);
}
@@ -434,14 +434,14 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->dest_tile = 0;
// v->profit_last_year = 0;
// v->profit_this_year = 0;
-
+
v->engine_type = (byte)p1;
e = &_engines[p1];
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
v->max_age = e->lifelength * 366;
-
+
v->string_id = STR_SV_TRAIN_NAME;
// v->cur_speed = 0;
// v->subspeed = 0;
@@ -449,11 +449,11 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
_new_train_id = v->index;
// v->cur_order_index = 0;
// v->num_orders = 0;
-
+
*(v->schedule_ptr = _ptr_to_next_order++) = 0;
// v->next_in_chain = 0xffff;
// v->next = NULL;
-
+
v->service_interval = _patches.servint_trains;
// v->breakdown_ctr = 0;
// v->breakdowns_since_last_service = 0;
@@ -503,7 +503,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
_cmd_build_rail_veh_var1 = _railveh_unk1[p1];
_cmd_build_rail_veh_score = _railveh_score[p1];
- return value;
+ return value;
}
@@ -524,7 +524,7 @@ int CheckStoppedInDepot(Vehicle *v)
{
int count;
TileIndex tile = v->tile;
-
+
/* check if stopped in a depot */
if (!IsTrainDepotTile(tile) || v->cur_speed != 0) {
errmsg:
@@ -535,7 +535,7 @@ errmsg:
count = 0;
do {
count++;
- if (v->u.rail.track != 0x80 || v->tile != (TileIndex)tile ||
+ if (v->u.rail.track != 0x80 || v->tile != (TileIndex)tile ||
(v->subtype==0 && !(v->vehstatus&VS_STOPPED)))
goto errmsg;
} while ( (v=v->next) != NULL);
@@ -599,7 +599,7 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
&& is_firsthead_sprite(src->spritenum);
// if nothing is selected as destination, try and find a matching vehicle to drag to.
- if (((int32)p1 >> 16) == -1) {
+ if (((int32)p1 >> 16) == -1) {
dst = NULL;
if (!is_loco) dst = FindGoodVehiclePos(src);
} else {
@@ -609,7 +609,7 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// don't move the same vehicle..
if (src == dst)
return 0;
-
+
/* the player must be the owner */
if (!CheckOwnership(src->owner) || (dst!=NULL && !CheckOwnership(dst->owner)))
return CMD_ERROR;
@@ -618,7 +618,7 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
src_head = GetFirstVehicleInChain(src);
dst_head = NULL;
if (dst != NULL) dst_head = GetFirstVehicleInChain(dst);
-
+
/* check if all vehicles in the source train are stopped */
if (CheckStoppedInDepot(src_head) < 0)
return CMD_ERROR;
@@ -695,7 +695,7 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
DeleteWindowById(WC_VEHICLE_VIEW, src->index);
DeleteVehicleSchedule(src);
}
-
+
src->subtype = 2;
src->unitnumber = 0; // doesn't occupy a unitnumber anymore.
@@ -785,7 +785,7 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2)
last = NULL;
}
}
-
+
// make sure the vehicle is stopped in the depot
if (CheckStoppedInDepot(first) < 0)
return CMD_ERROR;
@@ -801,7 +801,7 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// when selling an attached locomotive. we need to delete its window.
if (v->subtype == 0) {
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
-
+
// rearrange all vehicles that follow to separate lines.
if (p2 == 2) {
Vehicle *u,*tmp;
@@ -809,7 +809,7 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2)
while (u != last) {
tmp = u;
u = u->next;
- DoCommandByTile(tmp->tile, tmp->index | ((-1)<<16), 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
+ DoCommandByTile(tmp->tile, tmp->index | ((-1)<<16), 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
}
}
}
@@ -834,7 +834,7 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2)
cost -= last->value;
DeleteVehicle(last);
}
-
+
// an attached train changed?
if (first && first->subtype == 0) {
UpdateTrainAcceleration(first);
@@ -884,7 +884,7 @@ static void UpdateVarsAfterSwap(Vehicle *v)
EndVehicleMove(v);
}
-static void SetLastSpeed(Vehicle *v, int spd) {
+static void SetLastSpeed(Vehicle *v, int spd) {
int old = v->u.rail.last_speed;
if (spd != old) {
v->u.rail.last_speed = spd;
@@ -908,7 +908,7 @@ static void ReverseTrainSwapVeh(Vehicle *v, int l, int r)
b->vehstatus = (b->vehstatus & ~VS_HIDDEN) | (a->vehstatus&VS_HIDDEN);
a->vehstatus = tmp;
}
-
+
/* swap variables */
swap_byte(&a->u.rail.track, &b->u.rail.track);
swap_byte(&a->direction, &b->direction);
@@ -916,7 +916,7 @@ static void ReverseTrainSwapVeh(Vehicle *v, int l, int r)
/* toggle direction */
if (!(a->u.rail.track & 0x80)) a->direction ^= 4;
if (!(b->u.rail.track & 0x80)) b->direction ^= 4;
-
+
/* swap more variables */
swap_int16(&a->x_pos, &b->x_pos);
swap_int16(&a->y_pos, &b->y_pos);
@@ -928,7 +928,7 @@ static void ReverseTrainSwapVeh(Vehicle *v, int l, int r)
UpdateVarsAfterSwap(b);
} else {
if (!(a->u.rail.track & 0x80)) a->direction ^= 4;
- UpdateVarsAfterSwap(a);
+ UpdateVarsAfterSwap(a);
}
}
@@ -996,7 +996,7 @@ int32 CmdForceTrainProceed(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC)
v->u.rail.force_proceed = 0x50;
-
+
return 0;
}
@@ -1027,7 +1027,7 @@ int32 CmdRefitRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->cargo_type = (byte)p2;
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
}
- }
+ }
} while ( (v=v->next) != NULL);
_returned_refit_amount = num;
@@ -1082,7 +1082,7 @@ static uint FindClosestTrainDepot(Vehicle *v)
return tile;
if (v->u.rail.track == 0x40) { tile = GetVehicleOutOfTunnelTile(v); }
-
+
tfdd.owner = v->owner;
tfdd.best_length = (uint)-1;
@@ -1107,7 +1107,7 @@ static uint FindClosestTrainDepot(Vehicle *v)
if (tfdd.best_length != (uint)-1)
return tfdd.tile;
}
-
+
return (uint)-1;
}
@@ -1122,7 +1122,7 @@ int32 CmdTrainGotoDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->u.rail.days_since_order_progr = 0;
v->cur_order_index++;
}
-
+
v->next_order = OT_DUMMY;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
}
@@ -1139,7 +1139,7 @@ int32 CmdTrainGotoDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->next_order_param = GetDepotByTile(depot_tile);
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
}
-
+
return 0;
}
@@ -1157,7 +1157,7 @@ int32 CmdChangeTrainServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->service_interval = (uint16)p2;
InvalidateWindowWidget(WC_VEHICLE_DETAILS, v->index, 8);
}
-
+
return 0;
}
@@ -1193,7 +1193,7 @@ static void HandleLocomotiveSmokeCloud(Vehicle *v)
case 0:
// steam smoke.
if ( (v->tick_counter&0xF) == 0 && !IsTrainDepotTile(v->tile) && !IsTunnelTile(v->tile)) {
- CreateEffectVehicleRel(v,
+ CreateEffectVehicleRel(v,
(_vehicle_smoke_pos[v->direction]),
(_vehicle_smoke_pos[v->direction+8]),
10,
@@ -1257,14 +1257,14 @@ static bool CheckTrainStayInDepot(Vehicle *v)
}
TrainPlayLeaveStationSound(v);
-
+
v->u.rail.track = 1;
if (v->direction & 2)
v->u.rail.track = 2;
-
+
v->vehstatus &= ~VS_HIDDEN;
v->cur_speed = 0;
-
+
UpdateTrainDeltaXY(v, v->direction);
v->cur_image = GetTrainImage(v, v->direction);
VehiclePositionChanged(v);
@@ -1324,7 +1324,7 @@ static bool TrainTrackFollower(uint tile, TrainTrackFollowerData *ttfd, int trac
// we've actually found the destination already. no point searching in directions longer than this.
if (ttfd->best_track_dist != (uint)-1)
return length >= ttfd->best_track_dist;
-
+
// didn't find station
dist = GetTileDist(tile, ttfd->dest_coords);
if (dist < ttfd->best_bird_dist) {
@@ -1374,7 +1374,7 @@ static const byte _pick_track_table[6] = {1, 3, 2, 2, 0, 0};
/* choose a track */
static byte ChooseTrainTrack(Vehicle *v, uint tile, int direction, byte trackbits)
-{
+{
TrainTrackFollowerData fd;
int bits = trackbits;
uint best_track;
@@ -1420,7 +1420,7 @@ static byte ChooseTrainTrack(Vehicle *v, uint tile, int direction, byte trackbit
fd.best_bird_dist = (uint)-1;
fd.best_track_dist = (uint)-1;
-
+
NewTrainPathfind(tile, _search_directions[i][direction], (TPFEnumProc*)TrainTrackFollower, &fd, NULL);
if (best_track != -1) {
if (best_track_dist == -1) {
@@ -1430,7 +1430,7 @@ static byte ChooseTrainTrack(Vehicle *v, uint tile, int direction, byte trackbit
if (fd.best_bird_dist < best_bird_dist) goto good;
} else {
/* we found the destination for the first time */
- goto good;
+ goto good;
}
} else {
if (fd.best_track_dist == -1) {
@@ -1442,13 +1442,13 @@ static byte ChooseTrainTrack(Vehicle *v, uint tile, int direction, byte trackbit
if (fd.best_track_dist < best_track_dist) goto good;
}
}
-
- /* if we reach this position, there's two paths of equal value so far.
+
+ /* if we reach this position, there's two paths of equal value so far.
* pick one randomly. */
r = (byte)Random();
if (_pick_track_table[i] == train_dir) r += 80;
if (_pick_track_table[best_track] == train_dir) r -= 80;
-
+
if (r <= 127) goto bad;
}
good:;
@@ -1508,7 +1508,7 @@ static bool CheckReverseTrain(Vehicle *v)
if (fd.best_bird_dist < best_bird_dist) goto good;
} else {
/* we found the destination for the first time */
- goto good;
+ goto good;
}
} else {
if (fd.best_bird_dist != 0) {
@@ -1520,8 +1520,8 @@ static bool CheckReverseTrain(Vehicle *v)
if (fd.best_track_dist < best_track_dist) goto good;
}
}
-
- /* if we reach this position, there's two paths of equal value so far.
+
+ /* if we reach this position, there's two paths of equal value so far.
* pick one randomly. */
r = (byte)Random();
if (_pick_track_table[i] == (v->direction & 3)) r += 80;
@@ -1549,7 +1549,7 @@ static bool ProcessTrainOrder(Vehicle *v)
// These are un-interruptible
if ((v->next_order & OT_MASK) >= OT_GOTO_DEPOT && (v->next_order & OT_MASK) <= OT_LEAVESTATION) {
-
+
// Let a depot order in the schedule interrupt.
if ((v->next_order & (OT_MASK|OF_UNLOAD)) != (OT_GOTO_DEPOT|OF_UNLOAD))
return false;
@@ -1565,9 +1565,9 @@ static bool ProcessTrainOrder(Vehicle *v)
v->cur_order_index++;
}
- // check if we've reached a non-stop station while TTDPatch nonstop is enabled..
- if (_patches.new_nonstop && (v->next_order & OF_NON_STOP) && v->next_order_param == _map2[v->tile]) {
- v->cur_order_index++;
+ // check if we've reached a non-stop station while TTDPatch nonstop is enabled..
+ if (_patches.new_nonstop && (v->next_order & OF_NON_STOP) && v->next_order_param == _map2[v->tile]) {
+ v->cur_order_index++;
}
// Get the current order
@@ -1623,7 +1623,7 @@ static void HandleTrainLoading(Vehicle *v, bool mode)
{
if (v->next_order == OT_NOTHING)
return;
-
+
if (v->next_order != OT_DUMMY) {
if ((v->next_order&OT_MASK) != OT_LOADING)
return;
@@ -1643,19 +1643,19 @@ static void HandleTrainLoading(Vehicle *v, bool mode)
if (LoadUnloadVehicle(v)) {
InvalidateWindow(WC_TRAINS_LIST, v->owner);
MarkTrainDirty(v);
-
+
// need to update acceleration since the goods on the train changed.
UpdateTrainAcceleration(v);
}
return;
}
-
+
TrainPlayLeaveStationSound(v);
-
+
{
byte b = v->next_order;
v->next_order = OT_LEAVESTATION;
-
+
// If this was not the final order, don't remove it from the list.
if (!(b & OF_NON_STOP))
return;
@@ -1735,7 +1735,7 @@ static void TrainEnterStation(Vehicle *v, int station)
static byte AfterSetTrainPos(Vehicle *v)
{
byte new_z, old_z;
-
+
// need this hint so it returns the right z coordinate on bridges.
_get_z_hint = v->z_pos;
new_z = GetSlopeZ(v->x_pos, v->y_pos);
@@ -1763,7 +1763,7 @@ static const byte _new_vehicle_direction_table[11] = {
static int GetNewVehicleDirectionByTile(uint new_tile, uint old_tile)
{
- uint offs = (GET_TILE_Y(new_tile) - GET_TILE_Y(old_tile) + 1) * 4 +
+ uint offs = (GET_TILE_Y(new_tile) - GET_TILE_Y(old_tile) + 1) * 4 +
GET_TILE_X(new_tile) - GET_TILE_X(old_tile) + 1;
assert(offs < 11);
return _new_vehicle_direction_table[offs];
@@ -1812,7 +1812,7 @@ static bool CheckCompatibleRail(Vehicle *v, uint tile)
// correct Z position of a train going under a bridge on slopes
if (CORRECT_Z(ti.tileh))
ti.z += 8;
-
+
if(v->z_pos != ti.z) // train is going over bridge
return true;
}
@@ -1822,7 +1822,7 @@ static bool CheckCompatibleRail(Vehicle *v, uint tile)
if (_map_owner[tile] != v->owner ||
(v->subtype == 0 && (_map3_lo[tile] & 0xF) != v->u.rail.railtype))
return false;
-
+
return true;
}
@@ -1910,7 +1910,7 @@ static void SetVehicleCrashed(Vehicle *v)
return;
v->u.rail.crash_anim_pos++;
-
+
u = v;
BEGIN_ENUM_WAGONS(v)
v->vehstatus |= VS_CRASHED;
@@ -1921,7 +1921,7 @@ static void SetVehicleCrashed(Vehicle *v)
static int CountPassengersInTrain(Vehicle *v)
{
- int num = 0;
+ int num = 0;
BEGIN_ENUM_WAGONS(v)
if (v->cargo_type == 0) num += v->cargo_count;
END_ENUM_WAGONS(v)
@@ -1943,8 +1943,8 @@ static void CheckTrainCollision(Vehicle *v)
/* can't collide in depot */
if (v->u.rail.track == 0x80)
return;
-
- if ( !(v->u.rail.track == 0x40) )
+
+ if ( !(v->u.rail.track == 0x40) )
assert((uint)TILE_FROM_XY(v->x_pos, v->y_pos) == v->tile);
tcc.v = v;
@@ -1954,27 +1954,27 @@ static void CheckTrainCollision(Vehicle *v)
realcoll = coll = VehicleFromPos(TILE_FROM_XY(v->x_pos, v->y_pos), &tcc, (VehicleFromPosProc*)FindTrainCollideEnum);
if (coll == NULL)
return;
-
-
+
+
coll = GetFirstVehicleInChain(coll);
-
+
/* it can't collide with its own wagons */
if ( (v == coll) || ( (v->u.rail.track & 0x40) && ( (v->direction & 2) != (realcoll->direction & 2) ) ) )
return;
- //two drivers + passangers killed in train v
+ //two drivers + passangers killed in train v
num = 2 + CountPassengersInTrain(v);
- if(!(coll->vehstatus&VS_CRASHED))
+ if(!(coll->vehstatus&VS_CRASHED))
//two drivers + passangers killed in train coll (if it was not crashed already)
num += 2 + CountPassengersInTrain(coll);
SetVehicleCrashed(v);
if (coll->subtype == 0)
SetVehicleCrashed(coll);
-
-
+
+
SET_DPARAM16(0, num);
-
+
AddNewsItem(STR_8868_TRAIN_CRASH_DIE_IN_FIREBALL,
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
v->index,
@@ -2009,7 +2009,7 @@ static void TrainController(Vehicle *v)
/* For every vehicle after and including the given vehicle */
for(;;) {
BeginVehicleMove(v);
-
+
if (v->u.rail.track != 0x40) {
/* Not inside tunnel */
if (GetNewVehiclePos(v, &gp)) {
@@ -2039,7 +2039,7 @@ static void TrainController(Vehicle *v)
/* Determine what direction we're entering the new tile from */
dir = GetNewVehicleDirectionByTile(gp.new_tile, gp.old_tile);
assert(dir==1 || dir==3 || dir==5 || dir==7);
-
+
/* Get the status of the tracks in the new tile and mask
* away the bits that aren't reachable. */
ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL) & _reachable_tracks[dir >> 1];
@@ -2065,7 +2065,7 @@ static void TrainController(Vehicle *v)
if ( (tracks>>16)&chosen_track && v->u.rail.force_proceed == 0) goto red_light;
} else {
static byte _matching_tracks[8] = {0x30, 1, 0xC, 2, 0x30, 1, 0xC, 2};
-
+
/* The wagon is active, simply follow the prev vehicle. */
chosen_track = (byte)(_matching_tracks[GetDirectionToVehicle(prev, gp.x, gp.y)] & tracks);
}
@@ -2080,7 +2080,7 @@ static void TrainController(Vehicle *v)
gp.y = (gp.y & ~0xF) | b[1];
chosen_dir = b[2];
}
-
+
/* Call the landscape function and tell it that the vehicle entered the tile */
r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
if (r&0x8)
@@ -2100,7 +2100,7 @@ static void TrainController(Vehicle *v)
* (above) or the last vehicle moves. */
if (v->next == NULL)
TrainMovedChangeSignals(gp.old_tile, (dir>>1) ^ 2);
-
+
if (prev == NULL) {
AffectSpeedByDirChange(v, chosen_dir);
}
@@ -2110,7 +2110,7 @@ static void TrainController(Vehicle *v)
} else {
/* in tunnel */
GetNewVehiclePos(v, &gp);
-
+
if (IS_TILETYPE(gp.new_tile, MP_TUNNELBRIDGE) &&
!(_map5[gp.new_tile] & 0xF0)) {
r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
@@ -2136,7 +2136,7 @@ common:;
/* update the Z position of the vehicle */
old_z = AfterSetTrainPos(v);
-
+
if (prev == NULL) {
/* This is the first vehicle in the train */
AffectSpeedByZChange(v, old_z);
@@ -2162,7 +2162,7 @@ red_light: {
/* find the first set bit in ts. need to do it in 2 steps, since
* FIND_FIRST_BIT only handles 6 bits at a time. */
i = FindFirstBit2x64(ts);
-
+
if (!(_map3_lo[gp.new_tile] & _signal_otherdir[i])) {
v->cur_speed = 0;
v->subspeed = 0;
@@ -2181,7 +2181,7 @@ red_light: {
}
}
}
-
+
reverse_train_direction:
v->load_unload_time_rem = 0;
v->cur_speed = 0;
@@ -2216,7 +2216,7 @@ static void DeleteLastWagon(Vehicle *v)
if (!((t=v->u.rail.track) & 0xC0)) {
SetSignalsOnBothDir(v->tile, FIND_FIRST_BIT(t));
}
-
+
if (v->u.rail.track == 0x40) {
int length;
TileIndex endtile = CheckTunnelBusy(v->tile, &length);
@@ -2232,10 +2232,10 @@ static void DeleteLastWagon(Vehicle *v)
static void ChangeTrainDirRandomly(Vehicle *v)
{
static int8 _random_dir_change[4] = { -1, 0, 0, 1};
-
+
do {
//I need to buffer the train direction
- if (!v->u.rail.track & 0x40)
+ if (!v->u.rail.track & 0x40)
v->direction = (v->direction + _random_dir_change[Random()&3]) & 7;
if (!(v->vehstatus & VS_HIDDEN)) {
BeginVehicleMove(v);
@@ -2251,7 +2251,7 @@ static void HandleCrashedTrain(Vehicle *v)
int state = ++v->u.rail.crash_anim_pos, index;
uint32 r;
Vehicle *u;
-
+
if ( (state == 4) && (v->u.rail.track != 0x40) ) {
CreateEffectVehicleRel(v, 4, 4, 8, EV_CRASHED_SMOKE);
}
@@ -2290,10 +2290,10 @@ static void HandleBrokenTrain(Vehicle *v)
if (v->breakdowns_since_last_service != 255)
v->breakdowns_since_last_service++;
-
+
InvalidateWindow(WC_VEHICLE_VIEW, v->index);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
-
+
SndPlayVehicleFx((_opt.landscape != LT_CANDY) ? 0xE : 0x3A, v);
if (!(v->vehstatus & VS_HIDDEN)) {
@@ -2324,7 +2324,7 @@ static void TrainCheckIfLineEnds(Vehicle *v)
if ((uint)(t=v->breakdown_ctr) > 1) {
v->vehstatus |= VS_TRAIN_SLOWING;
-
+
t = _breakdown_speeds[ ((~t) >> 4) & 0xF];
if ((uint16)t <= v->cur_speed)
v->cur_speed = t;
@@ -2342,7 +2342,7 @@ static void TrainCheckIfLineEnds(Vehicle *v)
if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) &&
(_map5[tile] & 0xF0) == 0 && (byte)((_map5[tile] & 3)*2+1) == v->direction)
return;
-
+
// depot?
if (IS_TILETYPE(tile, MP_RAILWAY) && (_map5[tile] & 0xFC) == 0xC0)
return;
@@ -2356,11 +2356,11 @@ static void TrainCheckIfLineEnds(Vehicle *v)
tile += _tileoffs_by_dir[t];
// determine the track status on the next tile.
ts = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _reachable_tracks[t];
-
+
/* Calc position within the current tile ?? */
x = v->x_pos & 0xF;
y = v->y_pos & 0xF;
-
+
switch(v->direction) {
case 0:
x = (~x) + (~y) + 24;
@@ -2488,7 +2488,7 @@ void Train_Tick(Vehicle *v)
if (v->subtype == 0) {
TrainLocoHandler(v, false);
-
+
// make sure vehicle wasn't deleted.
if (v->type == VEH_Train && v->subtype == 0)
TrainLocoHandler(v, true);
@@ -2519,7 +2519,7 @@ void TrainEnterDepot(Vehicle *v, uint tile)
if ((v->next_order&OT_MASK) == OT_GOTO_DEPOT) {
InvalidateWindow(WC_VEHICLE_VIEW, v->index);
-
+
t = v->next_order;
v->next_order = OT_DUMMY;
@@ -2557,7 +2557,7 @@ static void CheckIfTrainNeedsService(Vehicle *v)
if (_patches.gotodepot && ScheduleHasDepotOrders(v->schedule_ptr))
return;
-
+
// Don't interfere with a depot visit scheduled by the user, or a
// depot visit by the order list.
if ((v->next_order & OT_MASK) == OT_GOTO_DEPOT &&
@@ -2607,9 +2607,9 @@ void OnNewDay_Train(Vehicle *v)
if (v->subtype == 0) {
CheckVehicleBreakdown(v);
AgeVehicle(v);
-
+
CheckIfTrainNeedsService(v);
-
+
// check if train hasn't advanced in its order list for a set number of days
if (_patches.lost_train_days && v->num_orders && !(v->vehstatus & VS_STOPPED) && ++v->u.rail.days_since_order_progr >= _patches.lost_train_days && v->owner == _local_player) {
v->u.rail.days_since_order_progr = 0;
@@ -2622,7 +2622,7 @@ void OnNewDay_Train(Vehicle *v)
}
CheckOrders(v);
-
+
/* update destination */
if ((v->next_order & OT_MASK) == OT_GOTO_STATION &&
(tile=DEREF_STATION(v->next_order_param)->train_tile) != 0)
@@ -2649,7 +2649,7 @@ void TrainsYearlyLoop()
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_Train && v->subtype == 0) {
-
+
// show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list)
if (_patches.train_income_warn && v->owner == _local_player && v->age >= 730 && v->profit_this_year < 0) {
SET_DPARAM32(1, v->profit_this_year);
diff --git a/train_gui.c b/train_gui.c
index 430df6040..e51d20dd0 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -63,7 +63,7 @@ static void CcBuildLoco(bool success, uint tile, uint32 p1, uint32 p2)
if (!success)
return;
-
+
v = &_vehicles[_new_train_id];
if (tile == _backup_orders_tile) {
_backup_orders_tile = 0;
@@ -76,7 +76,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT:
-
+
if (w->window_number == 0)
SETBIT(w->disabled_state, 5);
@@ -93,7 +93,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
SET_DPARAM16(0, WP(w,buildtrain_d).railtype + STR_881C_NEW_RAIL_VEHICLES);
DrawWindowWidgets(w);
-
+
{
int num = _rail_engines_count[WP(w,buildtrain_d).railtype];
Engine *e = _rail_engines[WP(w,buildtrain_d).railtype];
@@ -112,7 +112,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
DrawTrainEngine(x+29, y+6, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
y += 14;
}
- sel--;
+ sel--;
}
} while (++engine_id, ++e,--num);
@@ -132,15 +132,15 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
SET_DPARAM16(3, rvi->power << multihead);
SET_DPARAM16(1, rvi->weight << multihead);
SET_DPARAM32(4, (rvi->running_cost_base * _price.running_rail[rvi->engclass] >> 8) << multihead);
-
+
SET_DPARAM16(5, STR_8838_N_A);
if (rvi->capacity != 0) {
SET_DPARAM16(6, rvi->capacity << multihead);
SET_DPARAM16(5, _cargoc.names_long_p[rvi->cargo_type]);
}
- e = &_engines[selected_id];
-
+ e = &_engines[selected_id];
+
SET_DPARAM16(8, e->lifelength);
SET_DPARAM8(9, e->reliability * 100 >> 16);
ConvertDayToYMD(&ymd, e->intro_date);
@@ -207,7 +207,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
} break;
}
}
-
+
static const Widget _new_rail_vehicle_widgets[] = {
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, 14, 11, 227, 0, 13, STR_0315, STR_018C_WINDOW_TITLE_DRAG_THIS},
@@ -236,7 +236,7 @@ static void ShowBuildTrainWindow(uint tile)
w = AllocateWindowDesc(&_new_rail_vehicle_desc);
w->window_number = tile;
w->vscroll.cap = 8;
-
+
if (tile != 0) {
w->caption_color = _map_owner[tile];
WP(w,buildtrain_d).railtype = _map3_lo[tile] & 0xF;
@@ -296,7 +296,7 @@ static void DrawTrainDepotWindow(Window *w)
}
SetVScrollCount(w, num);
SetHScrollCount(w, hnum);
-
+
/* locate the depot struct */
for(d=_depots; d->xy != (TileIndex)tile; d++) {}
@@ -312,7 +312,7 @@ static void DrawTrainDepotWindow(Window *w)
if (v->type == VEH_Train &&
v->subtype == 0 &&
v->tile == (TileIndex)tile &&
- v->u.rail.track == 0x80 &&
+ v->u.rail.track == 0x80 &&
--num < 0 && num >= -6) {
DrawTrainImage(v, x+21, y, 10, w->hscroll.pos, WP(w,traindepot_d).sel);
@@ -331,7 +331,7 @@ static void DrawTrainDepotWindow(Window *w)
if (v->type == VEH_Train &&
v->subtype == 4 &&
v->tile == (TileIndex)tile &&
- v->u.rail.track == 0x80 &&
+ v->u.rail.track == 0x80 &&
--num < 0 && num >= -6) {
DrawTrainImage(v, x+50, y, 9, 0, WP(w,traindepot_d).sel);
@@ -395,20 +395,20 @@ static int GetVehicleFromTrainDepotWndPt(Window *w, int x, int y, GetDepotVehicl
/* didn't find anything, get out */
return 0;
-found_it:
+found_it:
d->head = d->wagon = v;
/* either pressed the flag or the number, but only when it's a loco */
if (area_x < 0 && v->subtype==0)
return area_x;
-
+
/* find the vehicle in this row that was clicked */
while (--area_x >= 0) {
v = v->next;
if (v == NULL) break;
}
- d->wagon = v;
+ d->wagon = v;
return 0;
}
@@ -447,7 +447,7 @@ static void TrainDepotClickTrain(Window *w, int x, int y)
// share / copy orders
if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = gdvp.head; return; }
-
+
v = gdvp.wagon;
switch(mode) {
@@ -482,10 +482,10 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
case WE_CLICK: {
switch(e->click.widget) {
- case 6:
+ case 6:
ShowBuildTrainWindow(w->window_number);
break;
- case 7:
+ case 7:
ScrollMainWindowToTile(w->window_number);
break;
case 2:
@@ -513,7 +513,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
return;
v = &_vehicles[WP(w,traindepot_d).sel];
-
+
WP(w,traindepot_d).sel = INVALID_VEHICLE;
SetWindowDirty(w);
@@ -538,14 +538,14 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
WP(w,traindepot_d).sel = INVALID_VEHICLE;
SetWindowDirty(w);
- if (GetVehicleFromTrainDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &gdvp) == 0 &&
+ if (GetVehicleFromTrainDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &gdvp) == 0 &&
sel != INVALID_VEHICLE) {
if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
} else if (gdvp.head != NULL && gdvp.head->subtype==0) {
ShowTrainViewWindow(gdvp.head);
}
- }
+ }
} break;
default:
@@ -722,11 +722,11 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
Vehicle *v;
StringID str;
- v = &_vehicles[w->window_number];
-
+ v = &_vehicles[w->window_number];
+
w->disabled_state = (v->owner == _local_player) ? 0 : 0x1C0;
-
-
+
+
/* draw widgets & caption */
SET_DPARAM16(0, v->string_id);
SET_DPARAM16(1, v->unitnumber);
@@ -734,7 +734,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
/* draw the flag */
DrawSprite( (v->vehstatus&VS_STOPPED) ? 0xC12 : 0xC13, 2, 123);
-
+
if (v->u.rail.crash_anim_pos != 0) {
str = STR_8863_CRASHED;
} else if (v->breakdown_ctr == 1) {
@@ -772,7 +772,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
SET_DPARAM16(1, v->u.rail.last_speed * 10 >> 4);
break;
}
-
+
default:
if (v->num_orders == 0) {
str = STR_NO_ORDERS + _patches.vehicle_speed;
@@ -792,20 +792,20 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
Vehicle *v = &_vehicles[w->window_number];
switch(wid) {
- case 4: /* start/stop train */
- DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN));
+ case 4: /* start/stop train */
+ DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN));
break;
case 5: /* center main view */
ScrollMainWindowTo(v->x_pos, v->y_pos);
break;
case 6: /* goto depot */
- DoCommandP(v->tile, v->index, 0, NULL, CMD_TRAIN_GOTO_DEPOT | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT));
+ DoCommandP(v->tile, v->index, 0, NULL, CMD_TRAIN_GOTO_DEPOT | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT));
break;
case 7: /* force proceed */
- DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL));
+ DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL));
break;
case 8: /* reverse direction */
- DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION));
+ DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION));
break;
case 9: /* show train orders */
ShowOrdersWindow(v);
@@ -828,7 +828,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
Vehicle *v;
uint32 h;
- v = &_vehicles[w->window_number];
+ v = &_vehicles[w->window_number];
assert(v->type == VEH_Train);
h = CheckStoppedInDepot(v) >= 0 ? (1 << 8) : (1 << 11);
if (h != w->hidden_state) {
@@ -893,7 +893,7 @@ static void TrainDetailsInfoTab(Vehicle *v, int x, int y)
SET_DPARAM16(0, GetCustomEngineName(v->engine_type));
SET_DPARAM32(1, v->value);
DrawString(x, y, STR_882D_VALUE, 0x10);
- }
+ }
}
static void TrainDetailsCapacityTab(Vehicle *v, int x, int y)
@@ -927,7 +927,7 @@ static void DrawTrainDetailsWindow(Window *w)
// det_tab == 3 <-- Total Cargo tab
if (det_tab == 3) // reset tot_cargo array to 0 values
memset(tot_cargo, 0, sizeof(tot_cargo));
-
+
u = v = &_vehicles[w->window_number];
do {
if (det_tab != 3)
@@ -964,9 +964,9 @@ static void DrawTrainDetailsWindow(Window *w)
num = v->age / 366;
SET_DPARAM16(1, num);
-
+
x = 2;
-
+
str = STR_0199_YEAR;
if (num != 1) {
str += STR_019A_YEARS - STR_0199_YEAR;
@@ -975,7 +975,7 @@ static void DrawTrainDetailsWindow(Window *w)
}
SET_DPARAM16(0, str);
SET_DPARAM16(2, v->max_age / 366);
- SET_DPARAM32(3, GetTrainRunningCost(v) >> 8);
+ SET_DPARAM32(3, GetTrainRunningCost(v) >> 8);
DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0);
SET_DPARAM16(2, v->max_speed * 10 >> 4);
@@ -998,7 +998,7 @@ static void DrawTrainDetailsWindow(Window *w)
x = 1;
y = 57;
sel = w->vscroll.pos;
-
+
// draw the first 3 details tabs
if (det_tab != 3) {
for(;;) {
@@ -1058,7 +1058,7 @@ do_change_service_int:
mod = _patches.servint_ispercent ? clamp(mod, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(mod, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS+1);
if (mod == v->service_interval)
return;
-
+
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_TRAIN_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
break;
/* details buttons*/
@@ -1127,7 +1127,7 @@ void ShowTrainDetailsWindow(Vehicle *v)
DeleteWindowById(WC_VEHICLE_ORDERS, veh);
DeleteWindowById(WC_VEHICLE_DETAILS, veh);
- _alloc_wnd_parent_num = veh;
+ _alloc_wnd_parent_num = veh;
w = AllocateWindowDesc(&_train_details_desc);
w->window_number = veh;
@@ -1163,7 +1163,7 @@ static void MakeSortedTrainList(byte owner)
// trains are stored as a cummulative index, eg 25, 41, 43. This means
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2
for (i = &_num_train_sort[1]; i != endof(_num_train_sort); i++) {*i += *(i-1);}
-
+
// sort by owner, then only subsort the requested owner-vehicles
qsort(_train_sort, n, sizeof(_train_sort[0]), GeneralOwnerSorter);
@@ -1208,7 +1208,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 trains
i = (window_number == 0) ? 0 : _num_train_sort[window_number-1];
SetVScrollCount(w, _num_train_sort[window_number] - i);
-
+
/* draw the widgets */
{
Player *p = DEREF_PLAYER(window_number);
@@ -1251,7 +1251,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
SET_DPARAM32(0, v->profit_this_year);
SET_DPARAM32(1, v->profit_last_year);
DrawString(x + 21, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
-
+
if (v->string_id != STR_SV_TRAIN_NAME) {
SET_DPARAM16(0, v->string_id);
DrawString(x+21, y, STR_01AB, 0);
@@ -1276,7 +1276,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
return;
case 6: { /* Matrix to show vehicles */
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
-
+
if (id_v >= w->vscroll.cap) { return;} // click out of bounds
id_v += w->vscroll.pos;
@@ -1301,15 +1301,15 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
tile = _last_built_train_depot_tile;
do {
- if (_map_owner[tile] == _local_player && IsTrainDepotTile(tile)) {
+ if (_map_owner[tile] == _local_player && IsTrainDepotTile(tile)) {
ShowTrainDepotWindow(tile);
ShowBuildTrainWindow(tile);
return;
}
-
+
tile = TILE_MASK(tile + 1);
} while(tile != _last_built_train_depot_tile);
-
+
ShowBuildTrainWindow(0);
} break;
}
diff --git a/tree_cmd.c b/tree_cmd.c
index 9d77a1ff1..229941dbe 100644
--- a/tree_cmd.c
+++ b/tree_cmd.c
@@ -18,7 +18,7 @@ static int GetRandomTreeType(uint tile, uint seed)
return (seed >> 6) + 28;
} else if (i == 1) {
if (seed > 12)
- return -1;
+ return -1;
return 27;
} else {
return (seed * 7 >> 8) + 20;
@@ -144,7 +144,7 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
int32 cost;
int sx,sy,x,y;
int treetype;
-
+
SET_EXPENSES_TYPE(EXPENSES_OTHER);
// make sure sx,sy are smaller than ex,ey
@@ -152,7 +152,7 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
sy = GET_TILE_Y(p2)*16;
if (ex < sx) intswap(ex, sx);
if (ey < sy) intswap(ey, sy);
-
+
cost = 0; // total cost
for(x=sx; x<=ex; x+=16) {
@@ -174,7 +174,7 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
}
// 2x as expensive to add more trees to an existing tile
cost += _price.build_trees * 2;
- } else {
+ } else {
// don't allow building on rocks
if (ti.type != MP_CLEAR || _map_owner[ti.tile] != OWNER_NONE || (ti.map5 & 0x1C) == 8) {
_error_message = STR_2804_SITE_UNSUITABLE;
@@ -204,9 +204,9 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
treetype = GetRandomTreeType(ti.tile, Random()>>24);
if (treetype==-1) treetype=27;
}
-
+
ModifyTile(ti.tile,
- MP_SETTYPE(MP_TREES) |
+ MP_SETTYPE(MP_TREES) |
MP_MAP2 | MP_MAP3LO | MP_MAP3HI_CLEAR | MP_MAP5,
m2, /* map2 */
treetype, /* map3lo */
@@ -221,7 +221,7 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
}
}
}
-
+
if (cost == 0) return CMD_ERROR;
return cost;
}
@@ -276,12 +276,12 @@ static void DrawTile_Trees(TileInfo *ti)
d = _tree_layout_xy[(tmp & 0x30) >> 4];
index = ((tmp>>6)&3) + (_map3_lo[ti->tile]<<2);
-
+
/* different tree styles above one of the grounds */
if ((m2 & 0xB0) == 0xA0 && index >= 48 && index < 80)
index += 164 - 48;
-
- assert(index < lengthof(_tree_layout_sprite));
+
+ assert(index < lengthof(_tree_layout_sprite));
s = _tree_layout_sprite[index];
}
@@ -342,7 +342,7 @@ static int32 ClearTile_Trees(uint tile, byte flags) {
if (flags & DC_EXEC && _current_player < MAX_PLAYERS) {
Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
- if (t != NULL)
+ if (t != NULL)
ChangeTownRating(t, -35, -1000);
}
@@ -372,7 +372,7 @@ static void GetTileDesc_Trees(uint tile, TileDesc *td)
(str=STR_2810_CACTUS_PLANTS, b==0x1B) ||
(str=STR_280F_RAINFOREST, IS_BYTE_INSIDE(b, 0x14, 0x1A+1)) ||
(str=STR_280E_TREES, true);
- td->str = str;
+ td->str = str;
}
static void AnimateTile_Trees(uint tile)
@@ -420,7 +420,7 @@ static void TileLoopTreesAlps(uint tile)
m2 = 0;
} else if (k == -8) {
/* snow_m1 */
- m2 = 0x20;
+ m2 = 0x20;
if (tmp == m2)
return;
} else if (k < 8) {
@@ -492,7 +492,7 @@ static void TileLoop_Trees(uint tile)
case 0: /* start destructing */
m5++;
break;
-
+
case 1: /* add a tree */
if (m5 < 0xC0) {
m5 = (m5 + 0x40) & ~7;
@@ -502,7 +502,7 @@ static void TileLoop_Trees(uint tile)
case 2: { /* add a neighbouring tree */
byte m3 = _map3_lo[tile];
-
+
tile += _tileloop_trees_dir[Random() & 7];
if (!IS_TILETYPE(tile, MP_CLEAR))
@@ -525,7 +525,7 @@ static void TileLoop_Trees(uint tile)
m5 = 0;
break;
- }
+ }
default:
return;
@@ -566,14 +566,14 @@ void OnTick_Trees()
int tree;
/* place a tree at a random rainforest spot */
- if (_opt.landscape == LT_DESERT &&
+ if (_opt.landscape == LT_DESERT &&
(r=Random(),tile=TILE_MASK(r),GetMapExtraBits(tile)==2) &&
IS_TILETYPE(tile, MP_CLEAR) &&
(m=_map5[tile]&0x1C, m<=4) &&
(tree=GetRandomTreeType(tile, r>>24)) >= 0) {
-
+
ModifyTile(tile,
- MP_SETTYPE(MP_TREES) |
+ MP_SETTYPE(MP_TREES) |
MP_MAP2 | MP_MAP3LO | MP_MAP3HI | MP_MAP5,
(m == 4 ? 0x10 : 0),
tree,
@@ -585,7 +585,7 @@ void OnTick_Trees()
// byte underflow
if (--_trees_tick_ctr)
return;
-
+
/* place a tree at a random spot */
r = Random();
tile = TILE_MASK(r);
@@ -593,7 +593,7 @@ void OnTick_Trees()
(m=_map5[tile]&0x1C, m==0 || m==4 || m==0x10) &&
(tree=GetRandomTreeType(tile, r>>24)) >= 0) {
int m2;
-
+
if (m == 0) {
m2 = 0;
} else if (m == 4) {
@@ -603,7 +603,7 @@ void OnTick_Trees()
}
ModifyTile(tile,
- MP_SETTYPE(MP_TREES) |
+ MP_SETTYPE(MP_TREES) |
MP_MAP2 | MP_MAP3LO | MP_MAP3HI | MP_MAP5,
m2,
tree,
diff --git a/ttd.c b/ttd.c
index ff59e645e..a5ef2271f 100644
--- a/ttd.c
+++ b/ttd.c
@@ -59,7 +59,7 @@ void CDECL error(const char *s, ...) {
va_start(va, s);
vsprintf(buf, s, va);
va_end(va);
-
+
ShowOSErrorBox(buf);
if (_video_driver)
_video_driver->stop();
@@ -145,7 +145,7 @@ static int NullVideoMainLoop() {
static bool NullVideoChangeRes(int w, int h) { return false; }
-
+
const HalVideoDriver _null_video_driver = {
NullVideoStart,
NullVideoStop,
@@ -298,7 +298,7 @@ static void showhelp()
const DriverDesc *dd;
int i;
- p = strecpy(buf,
+ p = strecpy(buf,
"Command line options:\n"
" -v drv = Set video driver (see below)\n"
" -s drv = Set sound driver (see below)\n"
@@ -313,7 +313,7 @@ static void showhelp()
" -G seed= Set random seed\n"
);
- for(i=0; i!=lengthof(_driver_classes); i++,dc++) {
+ for(i=0; i!=lengthof(_driver_classes); i++,dc++) {
p += sprintf(p, "List of %s drivers:\n", dc->name);
dd = dc->descs;
do {
@@ -427,7 +427,7 @@ void SetDebugString(const char *s)
if (*s >= '0' && *s <= '9') {
v = strtoul(s, &end, 0);
s = end;
-
+
_debug_spritecache_level = v;
_debug_misc_level = v;
_debug_grf_level = v;
@@ -460,7 +460,7 @@ void SetDebugString(const char *s)
v = strtoul(s, &end, 0);
s = end;
if (p) *p = v;
- }
+ }
}
void ParseResolution(int res[2], char *s)
@@ -473,7 +473,7 @@ void ParseResolution(int res[2], char *s)
res[0] = (strtoul(s, NULL, 0) + 7) & ~7;
res[1] = (strtoul(t+1, NULL, 0) + 7) & ~7;
-}
+}
int ttd_main(int argc, char* argv[])
{
@@ -500,10 +500,10 @@ int ttd_main(int argc, char* argv[])
case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break;
case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break;
case 'n': {
- network = 1;
+ network = 1;
_networking_override=true;
if (mgo.opt) {
- network_conn = mgo.opt;
+ network_conn = mgo.opt;
network++;
}
else
@@ -525,7 +525,7 @@ int ttd_main(int argc, char* argv[])
} break;
case 'e': _switch_mode = SM_EDITOR; break;
case 'i': _ignore_wrong_grf = true; break;
- case 'g':
+ case 'g':
if (mgo.opt) {
strcpy(_file_to_saveload.name, mgo.opt);
_switch_mode = SM_LOAD;
@@ -568,10 +568,10 @@ int ttd_main(int argc, char* argv[])
// initialize airport state machines
InitializeAirports();
-
+
// Sample catalogue
DEBUG(misc, 1) ("Loading sound effects...");
- MxInitialize(11025, "sample.cat");
+ MxInitialize(11025, "sample.cat");
// This must be done early, since functions use the InvalidateWindow* calls
InitWindowSystem();
@@ -588,7 +588,7 @@ int ttd_main(int argc, char* argv[])
// Default difficulty level
_opt_mod_ptr = &_new_opt;
-
+
// ugly hack, if diff_level is 9, it means we got no setting from the config file, so we load the default settings.
if (_opt_mod_ptr->diff_level == 9)
SetDifficultyLevel(0, _opt_mod_ptr);
@@ -646,7 +646,7 @@ void LoadIntroGame()
_opt_mod_ptr = &_new_opt;
GfxLoadSprites();
LoadStringWidthTable();
-
+
// Setup main window
InitWindowSystem();
SetupColorsAndInitialWindow();
@@ -655,7 +655,7 @@ void LoadIntroGame()
sprintf(filename, "%sopntitle.dat", _path.data_dir);
if (SaveOrLoad(filename, SL_LOAD) != SL_OK)
GenerateWorld(1); // if failed loading, make empty world.
-
+
_opt.currency = _new_opt.currency;
_pause = 0;
@@ -687,7 +687,7 @@ void MakeNewGame()
// Create a single player
DoStartupNewPlayer(false);
-
+
_local_player = 0;
MarkWholeScreenDirty();
@@ -700,7 +700,7 @@ void MakeNewEditorWorld()
// Copy in game options
_opt_mod_ptr = &_opt;
memcpy(&_opt, &_new_opt, sizeof(_opt));
-
+
GfxLoadSprites();
// Re-init the windowing system
@@ -758,7 +758,7 @@ void StartScenario()
// and in AfterLoad a player is started when it is
// a scenario.. so we do not need it here.
// DoStartupNewPlayer(false);
-
+
_local_player = 0;
MarkWholeScreenDirty();
@@ -781,7 +781,7 @@ bool SafeSaveOrLoad(const char *filename, int mode, int newgm)
return false;
} else if (r != SL_OK) {
_game_mode = ogm;
- return false;
+ return false;
} else
return true;
}
@@ -789,7 +789,7 @@ bool SafeSaveOrLoad(const char *filename, int mode, int newgm)
static void SwitchMode(int new_mode)
{
_in_state_game_loop = true;
-
+
switch(new_mode) {
case SM_EDITOR: // Switch to scenario editor
MakeNewEditorWorld();
@@ -842,7 +842,7 @@ normal_load:
case SM_MENU: // Switch to game menu
-
+
if ((_networking) && (!_networking_override)) NetworkCoreDisconnect();
_networking_override=false;
@@ -863,8 +863,8 @@ normal_load:
MarkWholeScreenDirty();
break;
}
-
- if (_switch_mode_errorstr!=INVALID_STRING_ID)
+
+ if (_switch_mode_errorstr!=INVALID_STRING_ID)
ShowErrorMessage(INVALID_STRING_ID,_switch_mode_errorstr,0,0);
_in_state_game_loop = false;
@@ -885,10 +885,10 @@ void StateGameLoop()
_sync_seed_2 = _random_seed_2;
if (_networking) disable_computer=true;
- if (_savedump_path[0] && (uint)_frame_counter >= _savedump_first && (uint)(_frame_counter -_savedump_first) % _savedump_freq == 0 ) {
- char buf[100];
- sprintf(buf, "%s%.5d.sav", _savedump_path, _frame_counter);
- SaveOrLoad(buf, SL_SAVE);
+ if (_savedump_path[0] && (uint)_frame_counter >= _savedump_first && (uint)(_frame_counter -_savedump_first) % _savedump_freq == 0 ) {
+ char buf[100];
+ sprintf(buf, "%s%.5d.sav", _savedump_path, _frame_counter);
+ SaveOrLoad(buf, SL_SAVE);
if ((uint)_frame_counter >= _savedump_last) exit(1);
}
@@ -917,7 +917,7 @@ void StateGameLoop()
static void DoAutosave()
{
char buf[200];
-
+
if (_patches.keep_all_autosave && _local_player != OWNER_SPECTATOR) {
Player *p;
char *s;
@@ -1063,7 +1063,7 @@ void UpdateExclusiveRights()
FOR_ALL_TOWNS(t) if (t->xy != 0) {
t->exclusivity=(byte)-1;
}
-
+
/* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete)
could be implemented this way:
1.) Go through all stations
@@ -1090,7 +1090,7 @@ bool AfterLoadGame(uint version)
if (version <= 0x400) {
UpdateExclusiveRights();
}
-
+
// convert road side to my format.
if (_opt.road_side) _opt.road_side = 1;
@@ -1102,7 +1102,7 @@ bool AfterLoadGame(uint version)
// reinit the landscape variables (landscape might have changed)
InitializeLandscapeVariables(true);
-
+
// Update all vehicles
AfterLoadVehicles();
// in version 2.2 of the savegame, we have new airports
@@ -1131,7 +1131,7 @@ bool AfterLoadGame(uint version)
WP(w,vp_d).scrollpos_x = _saved_scrollpos_x;
WP(w,vp_d).scrollpos_y = _saved_scrollpos_y;
-
+
vp = w->viewport;
vp->zoom = _saved_scrollpos_zoom;
vp->virtual_width = vp->width << vp->zoom;
@@ -1143,8 +1143,8 @@ bool AfterLoadGame(uint version)
if (version <= 0x400) {
CheckIsPlayerActive();
}
-
- // If Load Scenario / New (Scenario) Game is used,
+
+ // If Load Scenario / New (Scenario) Game is used,
// a player does not exist yet. So create one here.
if (!_players[0].is_active)
DoStartupNewPlayer(false);
diff --git a/ttd.h b/ttd.h
index 6426eb506..2c8348586 100644
--- a/ttd.h
+++ b/ttd.h
@@ -9,7 +9,7 @@
#endif
// use this on non static functions
-#define PUBLIC
+#define PUBLIC
typedef struct Rect {
int left,top,right,bottom;
@@ -34,10 +34,10 @@ typedef struct YearMonthDay {
/* --- 1 Day is 74 ticks ---
* The game's internal structure is dictated by ticks. The date counter (date_fract) is an integer of
-* uint16 type, so it can have a max value of 65536. Every tick this variable (date_fract) is
-* increased by 885. When it overflows, the new day loop is called.
+* uint16 type, so it can have a max value of 65536. Every tick this variable (date_fract) is
+* increased by 885. When it overflows, the new day loop is called.
* * this that means 1 day is : 65536 / 885 = 74 ticks
-* * 1 tick is approximately 27ms.
+* * 1 tick is approximately 27ms.
* * 1 day is thus about 2 seconds (74*27 = 1998) on a machine that can run OpenTTD normally
*/
#define DAY_TICKS 74
@@ -196,7 +196,7 @@ typedef struct Prices {
int32 aircraft_running;
int32 roadveh_running;
int32 ship_running;
- int32 build_industry;
+ int32 build_industry;
} Prices;
#define GAME_DIFFICULTY_NUM 18
@@ -267,12 +267,12 @@ typedef void GetTileDescProc(uint tile, TileDesc *td);
* tracks = (byte)(ts | ts >>8)
* This effectively converts the present part of the result (ccdd) to a
* track bitmask, which disregards directions. Normally, this is the same as just
- * doing (byte)ts I think, although I am not really sure
+ * doing (byte)ts I think, although I am not really sure
*
* A trackdir is combination of a track and a dir, where the lower three bits
* are a track, the fourth bit is the direction. these give 12 (or 14)
* possible options: 0-5 and 8-13, so we need 14 bits for a trackdir bitmask
- * above.
+ * above.
*/
typedef uint32 GetTileTrackStatusProc(uint tile, TransportType mode);
typedef void GetProducedCargoProc(uint tile, byte *b);
@@ -316,7 +316,7 @@ enum {
MP_MAP5 = 1<<3,
MP_MAPOWNER_CURRENT = 1<<4,
MP_MAPOWNER = 1<<5,
-
+
MP_TYPE_MASK = 0xF << 8,
MP_MAP2_CLEAR = 1 << 12,
@@ -466,7 +466,7 @@ enum {
// special string constants
enum SpecialStrings {
-
+
// special strings for town names. the town name is generated dynamically on request.
SPECSTR_TOWNNAME_START = 0x20C0,
SPECSTR_TOWNNAME_ENGLISH = SPECSTR_TOWNNAME_START,
@@ -493,7 +493,7 @@ enum SpecialStrings {
SPECSTR_PLAYERNAME_AMERICAN,
SPECSTR_PLAYERNAME_LATIN,
SPECSTR_PLAYERNAME_SILLY,
- SPECSTR_PLAYERNAME_LAST = SPECSTR_PLAYERNAME_SILLY,
+ SPECSTR_PLAYERNAME_LAST = SPECSTR_PLAYERNAME_SILLY,
SPECSTR_ANDCO_NAME = 0x70E6,
SPECSTR_PRESIDENT_NAME = 0x70E7,
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 2ded3e90c..0e8139c75 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -17,7 +17,7 @@ static const byte _bridge_minlen[MAX_BRIDGES] = {
};
static const byte _bridge_maxlen[MAX_BRIDGES] = {
- 16, 2, 5, 10, 16, 16, 7, 8, 9, 2, 16, 32, 32,
+ 16, 2, 5, 10, 16, 16, 7, 8, 9, 2, 16, 32, 32,
};
const uint16 _bridge_type_price_mod[MAX_BRIDGES] = {
@@ -31,8 +31,8 @@ const uint16 _bridge_speeds[MAX_BRIDGES] = {
const PalSpriteID _bridge_sprites[MAX_BRIDGES] = {
0x0A24, 0x31E8A26, 0x0A25, 0x3208A22,
0x0A22, 0x3218A22, 0x0A23, 0x31C8A23,
- 0x31E8A23, 0x0A27, 0x0A28, 0x3218A28,
- 0x3238A28,
+ 0x31E8A23, 0x0A27, 0x0A28, 0x3218A28,
+ 0x3238A28,
};
const StringID _bridge_material[MAX_BRIDGES] = {
@@ -88,11 +88,11 @@ static uint32 CheckBridgeSlope(uint direction, uint tileh, bool is_start_tile)
- no extra cost
- direction X: tiles 0,12
- direction Y: tiles 0, 9
- */
+ */
if ((direction?0x201:0x1001) & (1 << tileh))
return 0;
-
- // disallow certain start tiles to avoid certain crooked bridges
+
+ // disallow certain start tiles to avoid certain crooked bridges
if (tileh == 2)
return CMD_ERROR;
@@ -106,7 +106,7 @@ static uint32 CheckBridgeSlope(uint direction, uint tileh, bool is_start_tile)
if ((direction?0x41:0x9) & (1 << tileh))
return 0;
- // disallow certain end tiles to avoid certain crooked bridges
+ // disallow certain end tiles to avoid certain crooked bridges
if (tileh == 8)
return CMD_ERROR;
@@ -116,7 +116,7 @@ static uint32 CheckBridgeSlope(uint direction, uint tileh, bool is_start_tile)
* start-tile: X 2,1 Y 2,4 (2 was disabled before)
* end-tile: X 8,4 Y 8,1 (8 was disabled before)
*/
- if ( (tileh == 1 && (is_start_tile != (bool)direction)) ||
+ if ( (tileh == 1 && (is_start_tile != (bool)direction)) ||
(tileh == 4 && (is_start_tile == (bool)direction)) )
return CMD_ERROR;
@@ -135,7 +135,7 @@ uint32 GetBridgeLength(TileIndex begin, TileIndex end)
y1 = GET_TILE_Y(begin);
x2 = GET_TILE_X(end);
y2 = GET_TILE_Y(end);
-
+
return abs((x2 + y2 - x1 - y1)) - 1;
}
@@ -156,7 +156,7 @@ bool CheckBridge_Stuff(byte bridge_type, int bridge_len)
return true;
}
-/* Build a Bridge
+/* Build a Bridge
* x,y - end tile coord
* p1 - packed start tile coords (~ dx)
* p2&0xFF - bridge type (hi bh)
@@ -174,11 +174,11 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 cost, terraformcost, ret;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
+
/* unpack parameters */
bridge_type = p2 & 0xFF;
railtype = (byte)(p2 >> 8);
-
+
// type of bridge
if (railtype & 0x80) {
railtype = 0;
@@ -238,9 +238,9 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
cost = ret;
terraformcost = CheckBridgeSlope(direction, ti_start.tileh, true); // true - bridge-start-tile, false - bridge-end-tile
-
+
// towns are not allowed to use bridges on slopes.
- if (terraformcost == CMD_ERROR ||
+ if (terraformcost == CMD_ERROR ||
(terraformcost && ((!_patches.ainew_active && _is_ai_player) || _current_player == OWNER_TOWN || !_patches.build_on_slopes)))
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
@@ -250,11 +250,11 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if ((ret=DoCommandByTile(ti_end.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR)) == CMD_ERROR)
return CMD_ERROR;
cost += ret;
-
+
terraformcost = CheckBridgeSlope(direction, ti_end.tileh, false); // false - end tile slope check
// towns are not allowed to use bridges on slopes.
- if (terraformcost == CMD_ERROR ||
+ if (terraformcost == CMD_ERROR ||
(terraformcost && ((!_patches.ainew_active && _is_ai_player) || _current_player == OWNER_TOWN || !_patches.build_on_slopes)))
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
@@ -299,7 +299,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (ti.tileh != 0 && ti.z >= ti_start.z)
return CMD_ERROR;
- // Find ship below
+ // Find ship below
if ( ti.type == MP_WATER && !EnsureNoVehicle(ti.tile) )
{
_error_message = STR_980E_SHIP_IN_THE_WAY;
@@ -339,26 +339,26 @@ not_valid_below:;
_map_type_and_height[ti.tile] |= MP_TUNNELBRIDGE << 4;
//bridges pieces sequence (middle parts)
- // bridge len 1: 0
+ // bridge len 1: 0
// bridge len 2: 0 1
// bridge len 3: 0 4 1
// bridge len 4: 0 2 3 1
// bridge len 5: 0 2 5 3 1
// bridge len 6: 0 2 3 2 3 1
// bridge len 7: 0 2 3 4 2 3 1
- // #0 - alwats as first, #1 - always as last (if len>1)
+ // #0 - alwats as first, #1 - always as last (if len>1)
// #2,#3 are to pair in order
// for odd bridges: #5 is going in the bridge middle if on even position, #4 on odd (counting from 0)
if(i==0) //first tile
- m5 = 0;
+ m5 = 0;
else if (i==bridge_len-1) //last tile
m5 = 1;
else if(i==odd_middle_part) //we are on the middle of odd bridge: #5 on even pos, #4 on odd
m5 = 5 - (i%2);
else {
// generate #2 and #3 in turns [i%2==0], after the middle of odd bridge
- // this sequence swaps [... XOR (i>odd_middle_part)],
+ // this sequence swaps [... XOR (i>odd_middle_part)],
// for even bridges XOR does not apply as odd_middle_part==bridge_len
m5 = 2 + ((i%2==0)^(i>odd_middle_part));
}
@@ -377,7 +377,7 @@ not_valid_below:;
It's unnecessary to execute this command every time for every bridge. So it is done only
and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated
*/
- if (!(flags & DC_QUERY_COST)) {
+ if (!(flags & DC_QUERY_COST)) {
bridge_len += 2; // begin and end tiles/ramps
if (_current_player < MAX_PLAYERS && !(_is_ai_player && !_patches.ainew_active))
@@ -575,7 +575,7 @@ int32 CmdBuildTunnel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC && DoBuildTunnel(x,y,tiorg.x,tiorg.y,flags&~DC_EXEC,excavated_tile) == CMD_ERROR)
return CMD_ERROR;
-
+
return DoBuildTunnel(x,y,tiorg.x, tiorg.y,flags,excavated_tile);
}
@@ -588,14 +588,14 @@ uint CheckTunnelBusy(uint tile, int *length)
int delta = _tileoffs_by_dir[m5 & 3], len = 0;
uint starttile = tile;
Vehicle *v;
-
+
do { tile += delta; len++; } while (!IS_TILETYPE(tile, MP_TUNNELBRIDGE) || _map5[tile]&0xF0 || (byte)(_map5[tile] ^ 2) != m5 || GetTileZ(tile) != z);
if ((v=FindVehicleBetween(starttile, tile, z)) != NULL) {
_error_message = v->type == VEH_Train ? STR_5000_TRAIN_IN_TUNNEL : STR_5001_ROAD_VEHICLE_IN_TUNNEL;
return (uint)-1;
}
-
+
if (length) *length = len;
return tile;
}
@@ -618,7 +618,7 @@ static int32 DoClearTunnel(uint tile, uint32 flags)
if (endtile == (uint)-1) return CMD_ERROR;
_build_tunnel_endtile = endtile;
-
+
t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty
// check if you're allowed to remove the tunnel owned by a town
// removal allowal depends on difficulty settings
@@ -638,7 +638,7 @@ static int32 DoClearTunnel(uint tile, uint32 flags)
DoClearSquare(endtile);
UpdateSignalsOnSegment(tile, _updsignals_tunnel_dir[tile_dir]);
UpdateSignalsOnSegment(endtile, _updsignals_tunnel_dir[endtile_dir]);
- if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR)
+ if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR)
ChangeTownRating(t, -250, 0);
}
return _price.clear_tunnel * (length + 1);
@@ -676,7 +676,7 @@ static int32 DoClearBridge(uint tile, uint32 flags)
Vehicle *v;
Town *t;
int direction;
-
+
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
direction = _map5[tile]&1;
@@ -688,7 +688,7 @@ static int32 DoClearBridge(uint tile, uint32 flags)
// check if we own the tile below the bridge..
if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile)) ))
return CMD_ERROR;
-
+
cost = (_map5[tile] & 8) ? _price.remove_road * 2 : _price.remove_rail;
if (flags & DC_EXEC) {
@@ -697,11 +697,11 @@ static int32 DoClearBridge(uint tile, uint32 flags)
MarkTileDirtyByTile(tile);
}
return cost;
-
+
/* delete canal under bridge */
} else if(_map5[tile]==0xC8 && GET_TILEHEIGHT(tile)!=0) {
int32 cost;
-
+
// check for vehicles under bridge
if ( !EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile)) )
return CMD_ERROR;
@@ -732,7 +732,7 @@ static int32 DoClearBridge(uint tile, uint32 flags)
tile += direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
endtile -= direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
if ((v=FindVehicleBetween(tile, endtile, GET_TILEHEIGHT(tile) + 8)) != NULL) {
- VehicleInTheWayErrMsg(v);
+ VehicleInTheWayErrMsg(v);
return CMD_ERROR;
}
@@ -740,12 +740,12 @@ static int32 DoClearBridge(uint tile, uint32 flags)
tile -= direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
endtile += direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
-
+
t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty
- // check if you're allowed to remove the bridge owned by a town.
+ // check if you're allowed to remove the bridge owned by a town.
// removal allowal depends on difficulty settings
if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) {
- if (!CheckforTownRating(tile, flags, t, TUNNELBRIDGE_REMOVE))
+ if (!CheckforTownRating(tile, flags, t, TUNNELBRIDGE_REMOVE))
return CMD_ERROR;
}
@@ -756,8 +756,8 @@ static int32 DoClearBridge(uint tile, uint32 flags)
//checks if the owner is town then decrease town rating by 250 until
// you have a "Poor" (0) town rating
- if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR)
- ChangeTownRating(t, -250, 0);
+ if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR)
+ ChangeTownRating(t, -250, 0);
do {
m5 = _map5[c];
@@ -787,7 +787,7 @@ clear_it:;
SetSignalsOnBothDir(tile, direction);
SetSignalsOnBothDir(endtile, direction);
-
+
}
return ((((endtile - tile) >> (direction?8:0))&0xFF)+1) * _price.clear_bridge;
@@ -826,7 +826,7 @@ int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec)
if (!CheckTileOwnership(tile)) return CMD_ERROR;
if ( (uint)(_map3_lo[tile] & 0xF) == totype) return CMD_ERROR;
-
+
endtile = CheckTunnelBusy(tile, &length);
if (endtile == (uint)-1) return CMD_ERROR;
@@ -861,7 +861,7 @@ int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec)
starttile = tile = FindEdgesOfBridge(tile, &endtile);
// Make sure there's no vehicle on the bridge
if ((v=FindVehicleBetween(tile, endtile, 0xff)) != NULL) {
- VehicleInTheWayErrMsg(v);
+ VehicleInTheWayErrMsg(v);
return CMD_ERROR;
}
@@ -881,7 +881,7 @@ int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec)
} while (tile <= endtile);
return cost;
- } else
+ } else
return CMD_ERROR;
}
@@ -906,7 +906,7 @@ uint GetBridgeHeight(const TileInfo *ti)
FindLandscapeHeightByTile(&ti_end, tile);
if (HASBIT(1 << 7, ti_end.tileh))
z_correction += 8;
-
+
// return the height there (the height of the NORTH CORNER)
return GET_TILEHEIGHT(tile) + z_correction;
}
@@ -973,7 +973,7 @@ uint GetBridgeFoundation(uint tileh, byte direction) {
return tileh;
// inclined sloped building
- if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) &&
+ if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) &&
( direction == 0 || (i++, direction == 1)) )
return i + 15;
@@ -986,8 +986,8 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
uint tmp;
const uint32 *b;
bool ice = _map3_hi[ti->tile] & 0x80;
-
- // draw tunnel?
+
+ // draw tunnel?
if ( (byte)(ti->map5&0xF0) == 0) {
/* railway type */
image = (_map3_lo[ti->tile] & 0xF) * 8;
@@ -1018,11 +1018,11 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
tmp = (ti->map5&3) + (tmp*2);
if (!(ti->map5 & 0x40)) { // bridge ramps
-
+
if (!(BRIDGE_NO_FOUNDATION & (1 << ti->tileh))) { // no foundations for 0, 3, 6, 9, 12
int f = GetBridgeFoundation(ti->tileh, ti->map5 & 0x1); // pass direction
if (f) DrawFoundation(ti, f);
-
+
// default sloped sprites..
if (ti->tileh != 0) image = _track_sloped_sprites[ti->tileh - 1] + 0x3F3;
}
@@ -1033,8 +1033,8 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
b += (tmp&1); // direction
if (ti->tileh == 0) b += 4; // sloped "entrance" ?
if (ti->map5 & 0x20) b += 2; // which side
-
- image = *b;
+
+ image = *b;
if (!ice) {
DrawClearLandTile(ti, 3);
@@ -1062,7 +1062,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
if (ti->map5 & 8 && ti->z != 0) DrawCanalWater(ti->tile);
} else {
// draw transport route under bridge
-
+
// draw foundation?
if (ti->tileh) {
int f = _bridge_foundations[ti->map5&1][ti->tileh];
@@ -1087,7 +1087,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
b = _bridge_sprite_table[_map2[ti->tile]>>4][_map2[ti->tile]&0xF] + tmp * 4;
z = GetBridgeHeight(ti) + 5;
-
+
// draw rail
image = b[0];
if (!(_display_opt & DO_TRANS_BUILDINGS)) image = (image & 0x3FFF) | 0x03224000;
@@ -1106,7 +1106,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
y += 12;
if (image&0x3FFF) AddSortableSpriteToDraw(image, x,y, 16, 1, 0x28, z);
}
-
+
if (ti->z + 5 == z ) {
// draw poles below for small bridges
image = b[2];
@@ -1136,7 +1136,7 @@ static uint GetSlopeZ_TunnelBridge(TileInfo *ti) {
if ( (ti->map5 & 0xF0) == 0)
return z;
- // bridge?
+ // bridge?
if ( ti->map5 & 0x80 ) {
// bridge ending?
if (!(ti->map5 & 0x40)) {
@@ -1154,18 +1154,18 @@ static uint GetSlopeZ_TunnelBridge(TileInfo *ti) {
// ramp in opposite dir
return (z + ((x^0xF)>>1));
}
-
+
// bridge middle part
} else {
// build on slopes?
if (ti->tileh) z+=8;
// keep the same elevation because we're on the bridge?
- if (_get_z_hint >= z + 8)
+ if (_get_z_hint >= z + 8)
return _get_z_hint;
-
+
// actually on the bridge, but not yet in the shared area.
- if (!IS_INT_INSIDE(x, 5, 10+1))
+ if (!IS_INT_INSIDE(x, 5, 10+1))
return GetBridgeHeight(ti) + 8;
// in the shared area, assume that we're below the bridge, cause otherwise the hint would've caught it.
@@ -1174,11 +1174,11 @@ static uint GetSlopeZ_TunnelBridge(TileInfo *ti) {
uint f = _bridge_foundations[ti->map5&1][ti->tileh];
// make sure that the slope is not inclined foundation
if (IS_BYTE_INSIDE(f, 1, 15)) return z;
-
+
// change foundation type?
if (f) ti->tileh = _inclined_tileh[f - 15];
}
-
+
// no transport route, fallback to default
}
}
@@ -1282,7 +1282,7 @@ static void TileLoop_TunnelBridge(uint tile)
} else if (_opt.landscape == LT_DESERT) {
if (GetMapExtraBits(tile) == 1 && !(_map3_hi[tile]&0x80)) {
_map3_hi[tile] |= 0x80;
- MarkTileDirtyByTile(tile);
+ MarkTileDirtyByTile(tile);
}
}
@@ -1303,7 +1303,7 @@ static uint32 GetTileTrackStatus_TunnelBridge(uint tile, TransportType mode)
if ((m5 & 0xF0) == 0) {
/* This is a tunnel */
- if (((m5 & 0xC) >> 2) == mode) {
+ if (((m5 & 0xC) >> 2) == mode) {
/* Tranport in the tunnel is compatible */
return m5&1 ? 0x202 : 0x101;
}
@@ -1321,7 +1321,7 @@ static uint32 GetTileTrackStatus_TunnelBridge(uint tile, TransportType mode)
if ((m5 &= 0x18) != 8)
/* Clear ground */
return result;
- else
+ else
if (mode != TRANSPORT_WATER)
return result;
} else {
@@ -1347,7 +1347,7 @@ static void ChangeTileOwner_TunnelBridge(uint tile, byte old_player, byte new_pl
{
if (_map_owner[tile] != old_player)
return;
-
+
if (new_player != 255) {
_map_owner[tile] = new_player;
} else {
@@ -1394,7 +1394,7 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, uint tile, int x, int y)
if (v->type == VEH_Train) {
fc = (x&0xF)+(y<<4);
-
+
dir = _map5[tile] & 3;
vdir = v->direction >> 1;
@@ -1428,10 +1428,10 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, uint tile, int x, int y)
if (v->u.road.state != 0xFF && dir == vdir) {
if (fc == _tunnel_fractcoord_4[dir] ||
fc == _tunnel_fractcoord_5[dir]) {
-
+
v->tile = tile;
v->u.road.state = 0xFF;
- v->vehstatus |= VS_HIDDEN;
+ v->vehstatus |= VS_HIDDEN;
return 4;
} else {
return 0;
diff --git a/unix.c b/unix.c
index f9f7eeccd..361d7d511 100644
--- a/unix.c
+++ b/unix.c
@@ -44,7 +44,7 @@ int compare_FiosItems (const void *a, const void *b) {
if (_savegame_sort_order < 2) // sort by date
r = da->mtime < db->mtime ? -1 : 1;
- else
+ else
r = strcmp(da->title[0] ? da->title : da->name, db->title[0] ? db->title : db->name);
if (_savegame_sort_order & 1) r = -r;
@@ -71,7 +71,7 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
_fios_path = _fios_scn_path;
else
_fios_path = _fios_save_path;
-
+
// Parent directory, only if not in root already.
if (_fios_path[1] != 0) {
fios = FiosAlloc();
@@ -263,11 +263,11 @@ char *FiosBrowseTo(const FiosItem *item)
case FIOS_TYPE_OLDFILE:
sprintf(str_buffr, "%s/%s.%s", _fios_path, item->name, _old_extensions[item->old_extension]);
return str_buffr;
-
+
case FIOS_TYPE_SCENARIO:
sprintf(str_buffr, "%s/%s.scn", path, item->name);
return str_buffr;
-
+
case FIOS_TYPE_OLD_SCENARIO:
sprintf(str_buffr, "%s/%s.%s", path, item->name, _old_extensions[item->old_extension]);
return str_buffr;
@@ -291,14 +291,14 @@ StringID FiosGetDescText(char **path)
{
uint64 tot = (uint64)s.f_bsize * s.f_bavail;
SET_DPARAM32(0, (uint32)(tot >> 20));
- return STR_4005_BYTES_FREE;
+ return STR_4005_BYTES_FREE;
}
else
return STR_4006_UNABLE_TO_READ_DRIVE;
}
#else
SET_DPARAM32(0, 0);
- return STR_4005_BYTES_FREE;
+ return STR_4005_BYTES_FREE;
#endif
}
@@ -348,14 +348,14 @@ const DriverDesc _music_driver_descs[] = {
#endif
#ifdef __BEOS__
{ "bemidi", "BeOS MIDI Driver", &_bemidi_music_driver, 1},
-#endif
+#endif
{ "null", "Null Music Driver", &_null_music_driver, 1},
{ NULL, NULL, NULL, 0}
};
bool FileExists(const char *filename)
{
- return access(filename, 0) == 0;
+ return access(filename, 0) == 0;
}
static int LanguageCompareFunc(const void *a, const void *b)
@@ -380,7 +380,7 @@ int GetLanguageList(char **languages, int max)
}
closedir(dir);
}
-
+
qsort(languages, num, sizeof(char*), LanguageCompareFunc);
return num;
}
@@ -403,7 +403,7 @@ void ShowInfo(const char *str)
void ShowOSErrorBox(const char *buf)
{
fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf);
-
+
#if defined(__APPLE__)
// this opens the crash log opener script
system("./Crash_Log_Opener.app");
@@ -435,25 +435,25 @@ void DeterminePaths()
#if defined(USE_HOMEDIR)
{
- char *homedir;
+ char *homedir;
homedir = getenv("HOME");
-
+
if(!homedir) {
struct passwd *pw = getpwuid(getuid());
if (pw) homedir = pw->pw_dir;
}
-
+
_path.personal_dir = str_fmt("%s" PATHSEP "%s", homedir, PERSONAL_DIR);
}
-
+
#else /* not defined(USE_HOMEDIR) */
_path.personal_dir = malloc( MAX_PATH );
strcpy(_path.personal_dir, PERSONAL_DIR);
-
+
// check if absolute or relative path
s = strchr(_path.personal_dir, '/');
-
+
// add absolute path
if (s==NULL || _path.personal_dir != s) {
getcwd(_path.personal_dir, MAX_PATH);
@@ -461,23 +461,23 @@ void DeterminePaths()
*s++ = '/';
strcpy(s, PERSONAL_DIR);
}
-
+
#endif /* defined(USE_HOMEDIR) */
s = strchr(_path.personal_dir, 0);
-
+
// append a / ?
if (s[-1] != '/') { s[0] = '/'; s[1] = 0; }
-
+
_path.save_dir = str_fmt("%ssave", _path.personal_dir);
_path.autosave_dir = str_fmt("%s/autosave", _path.save_dir);
_path.scenario_dir = str_fmt("%sscenario", _path.personal_dir);
_path.gm_dir = str_fmt("%sgm/", _path.game_data_dir);
_path.data_dir = str_fmt("%sdata/", _path.game_data_dir);
_path.lang_dir = str_fmt("%slang/", _path.game_data_dir);
-
+
_config_file = str_fmt("%sopenttd.cfg", _path.personal_dir);
-
+
// make (auto)save and scenario folder
mkdir(_path.save_dir, 0755);
mkdir(_path.autosave_dir, 0755);
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 0ce02e199..a181cbf06 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -31,10 +31,10 @@ typedef struct DrawTileSeqStruct {
static void DrawTile_Unmovable(TileInfo *ti)
{
uint32 image, ormod;
-
+
if (!(ti->map5 & 0x80)) {
if (ti->map5 == 2) {
-
+
// statue
DrawGroundSprite(0x58C);
@@ -44,32 +44,32 @@ static void DrawTile_Unmovable(TileInfo *ti)
image = (image & 0x3FFF) | 0x3224000;
AddSortableSpriteToDraw(image, ti->x, ti->y, 16, 16, 25, ti->z);
} else if (ti->map5 == 3) {
-
+
// "owned by" sign
DrawClearLandTile(ti, 0);
-
+
AddSortableSpriteToDraw(
PLAYER_SPRITE_COLOR(_map_owner[ti->tile]) + 0x92B6,
ti->x+8, ti->y+8,
- 1, 1,
- 10,
+ 1, 1,
+ 10,
GetSlopeZ(ti->x+8, ti->y+8)
);
} else {
// lighthouse or transmitter
-
+
const DrawTileUnmovableStruct *dtus;
if (ti->tileh) DrawFoundation(ti, ti->tileh);
DrawClearLandTile(ti, 2);
-
- dtus = &_draw_tile_unmovable_data[ti->map5];
+
+ dtus = &_draw_tile_unmovable_data[ti->map5];
image = dtus->image;
if (!(_display_opt & DO_TRANS_BUILDINGS))
image = (image & 0x3FFF) | 0x3224000;
-
- AddSortableSpriteToDraw(image,
+
+ AddSortableSpriteToDraw(image,
ti->x | dtus->subcoord_x,
ti->y | dtus->subcoord_y,
dtus->width, dtus->height,
@@ -87,7 +87,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
DrawGroundSprite(*(uint16*)t | ormod);
t += sizeof(uint16);
-
+
for(dtss = (DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
image = dtss->image;
if (_display_opt & DO_TRANS_BUILDINGS) {
@@ -101,12 +101,12 @@ static void DrawTile_Unmovable(TileInfo *ti)
}
}
-static uint GetSlopeZ_Unmovable(TileInfo *ti)
+static uint GetSlopeZ_Unmovable(TileInfo *ti)
{
return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
}
-static uint GetSlopeTileh_Unmovable(TileInfo *ti)
+static uint GetSlopeTileh_Unmovable(TileInfo *ti)
{
return 0;
}
@@ -114,12 +114,12 @@ static uint GetSlopeTileh_Unmovable(TileInfo *ti)
static int32 ClearTile_Unmovable(uint tile, byte flags)
{
byte m5 = _map5[tile];
-
+
if (m5 & 0x80) {
- if (_current_player == OWNER_WATER)
+ if (_current_player == OWNER_WATER)
return DoCommandByTile(tile, OWNER_WATER, 0, DC_EXEC, CMD_DESTROY_COMPANY_HQ);
return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN);
- }
+ }
if (m5 == 3) // company owned land
return DoCommandByTile(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
@@ -127,8 +127,8 @@ static int32 ClearTile_Unmovable(uint tile, byte flags)
// checks if you're allowed to remove unmovable things
if (_game_mode != GM_EDITOR && _current_player != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) )
return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
-
- if (flags & DC_EXEC) {
+
+ if (flags & DC_EXEC) {
DoClearSquare(tile);
}
@@ -171,7 +171,7 @@ static const StringID _unmovable_tile_str[] = {
STR_5802_LIGHTHOUSE,
STR_2016_STATUE,
STR_5805_COMPANY_OWNED_LAND,
-};
+};
static void GetTileDesc_Unmovable(uint tile, TileDesc *td)
{
@@ -289,7 +289,7 @@ void GenerateUnmovables()
if (_opt.landscape == LT_DESERT)
return;
-
+
/* add lighthouses */
i = (Random()&3) + 7;
do {
@@ -297,7 +297,7 @@ restart:
r = Random();
dir = r >> 30;
r = r%((dir==0 || dir== 2)?TILE_Y_MAX:TILE_X_MAX);
- tile =
+ tile =
(dir==0)?TILE_XY(0,r):0 + // left
(dir==1)?TILE_XY(r,0):0 + // top
(dir==2)?TILE_XY(TILE_X_MAX,r):0 + // right
@@ -308,7 +308,7 @@ restart:
goto restart;
tile = TILE_MASK(tile + _tile_add[dir]);
} while (!(IS_TILETYPE(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
-
+
assert(tile == TILE_MASK(tile));
_map_type_and_height[tile] |= MP_UNMOVABLE << 4;
@@ -328,7 +328,7 @@ int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Player *p = DEREF_PLAYER(_current_player);
int score;
int32 cost = 0;
-
+
if (CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL) == CMD_ERROR)
return CMD_ERROR;
@@ -404,7 +404,7 @@ static void ChangeTileOwner_Unmovable(uint tile, byte old_player, byte new_playe
{
if (_map_owner[tile] != old_player)
return;
-
+
if (_map5[tile]==3 && new_player != 255) {
_map_owner[tile] = new_player;
} else {
diff --git a/variables.h b/variables.h
index f3ef039d7..9441fce88 100644
--- a/variables.h
+++ b/variables.h
@@ -110,7 +110,7 @@ typedef struct Patches {
bool always_small_airport; // always allow small airports
bool realistic_acceleration; // realistic acceleration for trains
bool invisible_trees; // don't show trees when buildings are transparent
-
+
uint8 toolbar_pos; // position of toolbars, 0=left, 1=center, 2=right
byte max_trains; //max trains in game per player (these are 8bit because the unitnumber field can't hold more)
@@ -132,7 +132,7 @@ typedef struct Patches {
byte pf_maxdepth; // maximum recursion depth when searching for a train route for new pathfinder
uint16 pf_maxlength; // maximum length when searching for a train route for new pathfinder
-
+
bool bridge_pillars; // show bridge pillars for high bridges
bool ai_disable_veh_train; // disable types for AI
@@ -169,7 +169,7 @@ typedef struct Cheat {
} Cheat;
-// WARNING! Do _not_ remove entries in Cheats struct or change the order
+// WARNING! Do _not_ remove entries in Cheats struct or change the order
// of the existing ones! Would break downward compatibility.
// Only add new entries at the end of the struct!
@@ -187,7 +187,7 @@ typedef struct Cheats {
VARDEF Cheats _cheats;
typedef struct Paths {
- char *personal_dir; // includes cfg file and save folder
+ char *personal_dir; // includes cfg file and save folder
char *game_data_dir; // includes data, gm, lang
char *data_dir;
char *gm_dir;
diff --git a/vehicle.c b/vehicle.c
index 5d9c55b3c..e8f82d6a4 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -30,10 +30,10 @@ static void *EnsureNoVehicleProc(Vehicle *v, void *data)
{
if (v->tile != (TileIndex)(int)data || v->type == VEH_Disaster)
return NULL;
-
- VehicleInTheWayErrMsg(v);
+
+ VehicleInTheWayErrMsg(v);
return (void*)1;
-}
+}
bool EnsureNoVehicle(TileIndex tile)
{
@@ -169,7 +169,7 @@ static Vehicle *InitializeVehicle(Vehicle *v)
Vehicle *ForceAllocateSpecialVehicle()
{
Vehicle *v;
- for(v=_vehicles + NUM_NORMAL_VEHICLES;
+ for(v=_vehicles + NUM_NORMAL_VEHICLES;
v!=&_vehicles[NUM_NORMAL_VEHICLES+NUM_SPECIAL_VEHICLES]; v++) {
if (v->type == 0)
return InitializeVehicle(v);
@@ -227,7 +227,7 @@ void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
while (veh != INVALID_VEHICLE) {
Vehicle *v = &_vehicles[veh];
void *a;
-
+
if ((a = proc(v, data)) != NULL)
return a;
veh = v->next_hash;
@@ -259,7 +259,7 @@ void UpdateVehiclePosHash(Vehicle *v, int x, int 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)];
-
+
if (old_hash == new_hash)
return;
@@ -295,7 +295,7 @@ void InitializeVehicles()
memset(&_vehicles, 0, sizeof(_vehicles));
memset(&_checkpoints, 0, sizeof(_checkpoints));
memset(&_depots, 0, sizeof(_depots));
-
+
// setup indexes..
i = 0;
FOR_ALL_VEHICLES(v)
@@ -334,7 +334,7 @@ Vehicle *GetFirstVehicleInChain(Vehicle *v)
if (++v == endof(_vehicles))
return u;
}
- }
+ }
}
int CountVehiclesInChain(Vehicle *v)
@@ -358,13 +358,13 @@ Depot *AllocateDepot()
}
}
- if (free_dep == NULL ||
+ if (free_dep == NULL ||
(num_free < 30 && IS_HUMAN_PLAYER(_current_player))) {
_error_message = STR_1009_TOO_MANY_DEPOTS;
return NULL;
}
- return free_dep;
+ return free_dep;
}
Checkpoint *AllocateCheckpoint()
@@ -443,7 +443,7 @@ void DeleteCommandFromVehicleSchedule(uint cmd)
FOR_ALL_VEHICLES(v) {
if (v->type != 0 && v->schedule_ptr != NULL) {
-
+
// clear last station visited
if (v->last_station_visited == (cmd>>8) && (cmd & OT_MASK) == OT_GOTO_STATION)
v->last_station_visited = 0xFF;
@@ -459,7 +459,7 @@ void DeleteCommandFromVehicleSchedule(uint cmd)
sched = v->schedule_ptr;
while ((order=*sched++) != 0) {
if ( (order & (OT_MASK|0xFF00)) == cmd) {
- sched[-1] = OT_DUMMY;
+ sched[-1] = OT_DUMMY;
need_invalidate = true;
}
}
@@ -538,7 +538,7 @@ void CallVehicleTicks()
static bool CanFillVehicle_FullLoadAny(Vehicle *v)
{
uint32 full = 0, not_full = 0;
-
+
// patch should return "true" to continue loading, i.e. when there is no cargo type that is fully loaded.
do {
//Should never happen, but just in case future additions change this
@@ -559,7 +559,7 @@ bool CanFillVehicle(Vehicle *v)
byte *t = &_map_type_and_height[v->tile];
if (t[0] >> 4 == MP_STATION ||
- (v->type == VEH_Ship &&
+ (v->type == VEH_Ship &&
(t[TILE_XY(1,0)] >> 4 == MP_STATION ||
t[TILE_XY(-1,0)] >> 4 == MP_STATION ||
t[TILE_XY(0,1)] >> 4 == MP_STATION ||
@@ -581,14 +581,14 @@ bool CanFillVehicle(Vehicle *v)
static void DoDrawVehicle(Vehicle *v)
{
uint32 image = v->cur_image;
-
+
if (v->vehstatus & VS_DISASTER) {
image |= 0x3224000;
} else if (v->vehstatus & VS_DEFPAL) {
image |= (v->vehstatus & VS_CRASHED) ? 0x3248000 : SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner));
- }
+ }
- AddSortableSpriteToDraw(image, v->x_pos + v->x_offs, v->y_pos + v->y_offs,
+ AddSortableSpriteToDraw(image, v->x_pos + v->x_offs, v->y_pos + v->y_offs,
v->sprite_width, v->sprite_height, v->z_height, v->z_pos);
}
@@ -610,12 +610,12 @@ void ViewportAddVehicles(DrawPixelInfo *dpi)
veh = _vehicle_position_hash[ (x+y)&0xFFFF ];
while (veh != INVALID_VEHICLE) {
v = &_vehicles[veh];
-
- if (!(v->vehstatus & VS_HIDDEN) &&
+
+ if (!(v->vehstatus & VS_HIDDEN) &&
dpi->left <= v->right_coord &&
dpi->top <= v->bottom_coord &&
dpi->left + dpi->width >= v->left_coord &&
- dpi->top + dpi->height >= v->top_coord) {
+ dpi->top + dpi->height >= v->top_coord) {
DoDrawVehicle(v);
}
veh = v->next_hash;
@@ -647,7 +647,7 @@ static void EffectTick_0(Vehicle *v)
if (--v->progress & 0x80) {
BeginVehicleMove(v);
-
+
tile = TILE_FROM_XY(v->x_pos, v->y_pos);
if (!IS_TILETYPE(tile, MP_INDUSTRY)) {
EndVehicleMove(v);
@@ -673,11 +673,11 @@ static void EffectInit_1(Vehicle *v)
static void EffectTick_1(Vehicle *v)
{
bool moved;
-
+
BeginVehicleMove(v);
-
+
moved = false;
-
+
if ((++v->progress & 7) == 0) {
v->z_pos++;
moved = true;
@@ -753,11 +753,11 @@ static void EffectInit_4(Vehicle *v)
static void EffectTick_4(Vehicle *v)
{
bool moved;
-
+
BeginVehicleMove(v);
-
+
moved = false;
-
+
if ((++v->progress & 3) == 0) {
v->z_pos++;
moved = true;
@@ -1095,8 +1095,8 @@ again:
EndVehicleMove(v);
DeleteVehicle(v);
return;
- }
-
+ }
+
if (*b == 0x81) {
if (v->z_pos > 180 || CHANCE16(1,96)) {
v->spritenum = 5;
@@ -1104,8 +1104,8 @@ again:
}
et = 0;
goto again;
- }
-
+ }
+
if (*b == 0x82) {
uint tile;
@@ -1163,7 +1163,7 @@ static EffectTickProc * const _effect_tick_procs[] = {
Vehicle *CreateEffectVehicle(int x, int y, int z, int type)
{
Vehicle *v;
-
+
v = ForceAllocateSpecialVehicle();
if (v != NULL) {
v->type = VEH_Special;
@@ -1213,10 +1213,10 @@ Vehicle *CheckClickOnVehicle(ViewPort *vp, int x, int y)
y = (y << vp->zoom) + vp->virtual_top;
FOR_ALL_VEHICLES(v) {
- if (v->type != 0 && (v->vehstatus & (VS_HIDDEN|VS_UNCLICKABLE)) == 0 &&
+ if (v->type != 0 && (v->vehstatus & (VS_HIDDEN|VS_UNCLICKABLE)) == 0 &&
x >= v->left_coord && x <= v->right_coord &&
y >= v->top_coord && y <= v->bottom_coord) {
-
+
dist = max(
myabs( ((v->left_coord + v->right_coord)>>1) - x ),
myabs( ((v->top_coord + v->bottom_coord)>>1) - y )
@@ -1275,7 +1275,7 @@ void CheckVehicleBreakdown(Vehicle *v)
/* calculate reliability value to use in comparison */
rel = v->reliability;
if (v->type == VEH_Ship) rel += 0x6666;
-
+
/* disabled breakdowns? */
if (_opt.diff.vehicle_breakdowns < 1)
return;
@@ -1320,8 +1320,8 @@ void AgeVehicle(Vehicle *v)
age = v->age - v->max_age;
if (age == 366*0 || age == 366*1 || age == 366*2 || age == 366*3 || age == 366*4)
- v->reliability_spd_dec <<= 1;
-
+ v->reliability_spd_dec <<= 1;
+
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (age == -366) {
@@ -1343,7 +1343,7 @@ void MaybeRenewVehicle(Vehicle *v, int32 build_cost)
// It can be any value between -12 and 12.
if (!_patches.autorenew || v->age - v->max_age < (_patches.autorenew_months * 30))
return;
-
+
if (DEREF_PLAYER(v->owner)->money64 < _patches.autorenew_money + build_cost - v->value) {
if (v->owner == _local_player) {
int message;
@@ -1361,7 +1361,7 @@ void MaybeRenewVehicle(Vehicle *v, int32 build_cost)
}
return;
}
-
+
// Withdraw the money from the right player ;)
_current_player = v->owner;
@@ -1376,7 +1376,7 @@ void MaybeRenewVehicle(Vehicle *v, int32 build_cost)
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
SubtractMoneyFromPlayer(build_cost - v->value);
v->value = build_cost;
-
+
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
}
@@ -1394,7 +1394,7 @@ int32 CmdNameVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
str = AllocateName((byte*)_decode_parameters, 2);
if (str == 0)
return CMD_ERROR;
-
+
if (flags & DC_EXEC) {
StringID old_str = v->string_id;
v->string_id = str;
@@ -1490,10 +1490,10 @@ byte GetDirectionTowards(Vehicle *v, int x, int y)
* bit 0x8 set, the vehicle could not and did not enter the tile. Are there
* other bits that can be set? */
uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y)
-{
+{
uint old_tile = v->tile;
uint32 result = _tile_type_procs[GET_TILETYPE(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
-
+
/* When vehicle_enter_tile_proc returns 8, that apparently means that
* we cannot enter the tile at all. In that case, don't call
* leave_tile. */
@@ -1513,7 +1513,7 @@ uint GetFreeUnitNumber(byte type)
restart:
unit_num++;
FOR_ALL_VEHICLES(u) {
- if (u->type == type && u->owner == _current_player &&
+ if (u->type == type && u->owner == _current_player &&
unit_num == u->unitnumber)
goto restart;
}
@@ -1524,7 +1524,7 @@ restart:
// Save and load of vehicles
const byte _common_veh_desc[] = {
SLE_VAR(Vehicle,subtype, SLE_UINT8),
-
+
SLE_VAR(Vehicle,next_in_chain_old, SLE_UINT16),
SLE_VAR(Vehicle,string_id, SLE_STRINGID),
SLE_VAR(Vehicle,unitnumber, SLE_UINT8),
@@ -1589,7 +1589,7 @@ const byte _common_veh_desc[] = {
// reserve extra space in savegame here. (currently 16 bytes)
SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 2, 2, 255),
-
+
SLE_END()
};
@@ -1646,7 +1646,7 @@ static const byte _aircraft_desc[] = {
SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleAir,pos), SLE_UINT8),
SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleAir,targetairport), SLE_UINT8),
SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleAir,state), SLE_UINT8),
-
+
SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleAir,previous_pos), SLE_UINT8, 2, 255),
// reserve extra space in savegame here. (currently 15 bytes)
@@ -1659,7 +1659,7 @@ static const byte _special_desc[] = {
SLE_WRITEBYTE(Vehicle,type,VEH_Special, 4),
SLE_VAR(Vehicle,subtype, SLE_UINT8),
-
+
SLE_VAR(Vehicle,tile, SLE_UINT16),
SLE_VAR(Vehicle,x_pos, SLE_INT16),
diff --git a/vehicle.h b/vehicle.h
index 8061992ce..0c4cfcb3d 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -6,8 +6,8 @@
typedef struct VehicleRail {
uint16 last_speed; // NOSAVE: only used in UI
uint16 crash_anim_pos;
- uint16 days_since_order_progr;
-
+ uint16 days_since_order_progr;
+
uint16 cached_weight; // cached power and weight for the vehicle.
uint32 cached_power; // no need to save those, they are recomputed on load.
@@ -69,7 +69,7 @@ struct WorldSprite {
// screen coordinates
int16 left, top, right, bottom;
-
+
// world coordinates
int16 x;
int16 y;
@@ -126,7 +126,7 @@ struct Vehicle {
byte vehstatus; // Status
byte last_station_visited;
-
+
byte cargo_type; // type of cargo this vehicle is carrying
byte cargo_days; // how many days have the pieces been in transit
byte cargo_source;// source of cargo
@@ -162,7 +162,7 @@ struct Vehicle {
byte build_year;
uint16 load_unload_time_rem;
-
+
int32 profit_this_year;
int32 profit_last_year;
uint32 value;
@@ -379,7 +379,7 @@ enum {
NUM_NORMAL_VEHICLES = 2048,
NUM_SPECIAL_VEHICLES = 512,
NUM_VEHICLES = NUM_NORMAL_VEHICLES + NUM_SPECIAL_VEHICLES
-};
+};
VARDEF Vehicle _vehicles[NUM_VEHICLES];
diff --git a/vehicle_gui.c b/vehicle_gui.c
index dd8cd1f52..ed5fc1666 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -96,7 +96,7 @@ int CDECL VehicleNameSorter(const void *a, const void *b)
}
r = strcmp(buf1, _bufcache); // sort by name
-
+
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
r = va->unitnumber - vb->unitnumber;
@@ -120,7 +120,7 @@ int CDECL VehicleProfitThisYearSorter(const void *a, const void *b)
const Vehicle *va = DEREF_VEHICLE((*(const SortStruct*)a).index);
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
int r = va->profit_this_year - vb->profit_this_year;
-
+
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
r = va->unitnumber - vb->unitnumber;
@@ -191,4 +191,4 @@ int CDECL VehicleMaxSpeedSorter(const void *a, const void *b)
r = va->unitnumber - vb->unitnumber;
return (_internal_sort_order & 1) ? -r : r;
-} \ No newline at end of file
+}
diff --git a/viewport.c b/viewport.c
index 60a637671..2968a737d 100644
--- a/viewport.c
+++ b/viewport.c
@@ -48,9 +48,9 @@ typedef struct ParentSpriteToDraw {
typedef struct ViewportDrawer {
DrawPixelInfo dpi;
-
+
byte *spritelist_mem, *eof_spritelist_mem;
-
+
StringSpriteToDraw **last_string, *first_string;
TileSpriteToDraw **last_tile, *first_tile;
@@ -79,7 +79,7 @@ Point MapXYZToViewport(ViewPort *vp, uint x, uint y, uint z)
return p;
}
-void AssignWindowViewport(Window *w, int x, int y,
+void AssignWindowViewport(Window *w, int x, int y,
int width, int height, uint32 follow_flags, byte zoom)
{
ViewPort *vp;
@@ -98,7 +98,7 @@ void AssignWindowViewport(Window *w, int x, int y,
vp->top = y + w->top;
vp->width = width;
vp->height = height;
-
+
vp->zoom = zoom;
vp->virtual_width = width << zoom;
@@ -133,7 +133,7 @@ static void DoSetViewportPosition(Window *w, int left, int top, int width, int h
w->left+w->width > left &&
top + height > w->top &&
w->top+w->height > top) {
-
+
if (left < w->left) {
DoSetViewportPosition(w, left, top, w->left - left, height);
DoSetViewportPosition(w, left + (w->left - left), top, width - (w->left - left), height);
@@ -234,7 +234,7 @@ void SetViewportPosition(Window *w, int x, int y)
height += top;
top = 0;
}
-
+
if ( (i=(top + height - _screen.height)) >= 0) {
height -= i;
}
@@ -285,7 +285,7 @@ Point TranslateXYToTileCoord(ViewPort *vp, int x, int y) {
pt.x = a+z;
pt.y = b+z;
-
+
if ((uint)pt.x >= TILE_X_MAX*16 || (uint)pt.y >= TILE_Y_MAX*16) {
pt.x = pt.y = -1;
}
@@ -294,12 +294,12 @@ Point TranslateXYToTileCoord(ViewPort *vp, int x, int y) {
}
static Point GetTileFromScreenXY(int x, int y)
-{
+{
Window *w;
ViewPort *vp;
Point pt;
-
- if ( (w = FindWindowFromPt(x, y)) != NULL &&
+
+ if ( (w = FindWindowFromPt(x, y)) != NULL &&
(vp = IsPtInWindowViewport(w, x, y)) != NULL)
return TranslateXYToTileCoord(vp, x, y);
@@ -335,7 +335,7 @@ void DrawGroundSpriteAt(uint32 image, int16 x, int16 y, byte z)
{
ViewportDrawer *vd = _cur_vd;
TileSpriteToDraw *ts;
-
+
assert( (image & 0x3fff) < NUM_SPRITES);
ts = (TileSpriteToDraw*)vd->spritelist_mem;
@@ -345,14 +345,14 @@ void DrawGroundSpriteAt(uint32 image, int16 x, int16 y, byte z)
}
vd->spritelist_mem += sizeof(TileSpriteToDraw);
-
+
ts->image = image;
ts->next = NULL;
ts->x = x;
ts->y = y;
ts->z = z;
*vd->last_tile = ts;
- vd->last_tile = &ts->next;
+ vd->last_tile = &ts->next;
}
void DrawGroundSprite(uint32 image)
@@ -384,7 +384,7 @@ static void AddCombinedSprite(uint32 image, int x, int y, byte z)
sd = GetSpriteDimension(image & 0x3FFF);
- if ((t = pt.x + sd->xoffs) >= vd->dpi.left + vd->dpi.width ||
+ if ((t = pt.x + sd->xoffs) >= vd->dpi.left + vd->dpi.width ||
(t + sd->xsize) <= vd->dpi.left ||
(t = pt.y + sd->yoffs) >= vd->dpi.top + vd->dpi.height ||
(t + sd->ysize) <= vd->dpi.top)
@@ -417,16 +417,16 @@ void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz,
}
if (vd->parent_list >= vd->eof_parent_list) {
// This can happen rarely, mostly when you zoom out completely
- // and have a lot of stuff that moves (and is added to the
+ // and have a lot of stuff that moves (and is added to the
// sort-list, this function). To solve it, increase
// parent_list somewhere below to a higher number.
// This can not really hurt you, it just gives some black
// spots on the screen ;)
DEBUG(misc, 0) ("Out of sprite mem (parent_list)\n");
return;
- }
-
- vd->spritelist_mem += sizeof(ParentSpriteToDraw);
+ }
+
+ vd->spritelist_mem += sizeof(ParentSpriteToDraw);
ps->image = image;
ps->tile_x = x;
@@ -441,7 +441,7 @@ void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz,
pt = RemapCoords(x, y, z);
sd = GetSpriteDimension(image & 0x3FFF);
- if ((ps->left = (pt.x += sd->xoffs)) >= vd->dpi.left + vd->dpi.width ||
+ if ((ps->left = (pt.x += sd->xoffs)) >= vd->dpi.left + vd->dpi.width ||
(ps->right = (pt.x + sd->xsize)) <= vd->dpi.left ||
(ps->top = (pt.y += sd->yoffs)) >= vd->dpi.top + vd->dpi.height ||
(ps->bottom = (pt.y + sd->ysize)) <= vd->dpi.top) {
@@ -473,7 +473,7 @@ void AddChildSpriteScreen(uint32 image, int x, int y)
{
ViewportDrawer *vd = _cur_vd;
ChildScreenSpriteToDraw *cs;
-
+
assert( (image & 0x3fff) < NUM_SPRITES);
cs = (ChildScreenSpriteToDraw*) vd->spritelist_mem;
@@ -484,8 +484,8 @@ void AddChildSpriteScreen(uint32 image, int x, int y)
if (vd->last_child == NULL)
return;
-
- vd->spritelist_mem += sizeof(ChildScreenSpriteToDraw);
+
+ vd->spritelist_mem += sizeof(ChildScreenSpriteToDraw);
*vd->last_child = cs;
vd->last_child = &cs->next;
@@ -602,7 +602,7 @@ static bool IsPartOfAutoLine(int px, int py)
default:
NOT_REACHED();
}
-
+
/* useless, but avoids compiler warning this way */
return 0;
}
@@ -615,7 +615,7 @@ static void DrawTileSelection(const TileInfo *ti)
#ifdef DEBUG_TILE_PUSH
dbg_draw_pushed(ti);
#endif
-
+
// Draw a red error square?
if (thd->redsq != 0 && thd->redsq == (TileIndex)ti->tile) {
DrawSelectionSprite(0x030382F0 | _tileh_to_sprite[ti->tileh], ti);
@@ -636,8 +636,8 @@ static void DrawTileSelection(const TileInfo *ti)
// Figure out the Z coordinate for the single dot.
byte z = ti->z;
if (ti->tileh & 8) {
- z += 8;
- if (!(ti->tileh & 2) && (ti->tileh & 0x10)) {
+ z += 8;
+ if (!(ti->tileh & 2) && (ti->tileh & 0x10)) {
z += 8;
}
}
@@ -689,14 +689,14 @@ void ViewportAddLandscape()
assert(width > 0);
assert(height > 0);
-
+
direction = false;
do {
int width_cur = width;
int x_cur = x;
int y_cur = y;
-
+
do {
FindLandscapeHeight(&ti, x_cur, y_cur);
#if !defined(NEW_ROTATION)
@@ -708,11 +708,11 @@ void ViewportAddLandscape()
#endif
_added_tile_sprite = false;
_offset_ground_sprites = false;
-
+
DrawTile(&ti);
DrawTileSelection(&ti);
} while (--width_cur);
-
+
#if !defined(NEW_ROTATION)
if ( (direction^=1) != 0)
y += 0x10;
@@ -724,7 +724,7 @@ void ViewportAddLandscape()
else
y -= 0x10;
#endif
- } while (--height);
+ } while (--height);
}
@@ -748,7 +748,7 @@ void ViewportAddTownNames(DrawPixelInfo *dpi)
top < t->sign.top + 12 &&
right > t->sign.left &&
left < t->sign.left + t->sign.width_1) {
-
+
AddStringToDraw(t->sign.left + 1, t->sign.top + 1, STR_2001, t->townnametype, t->townnameparts);
}
}
@@ -762,9 +762,9 @@ void ViewportAddTownNames(DrawPixelInfo *dpi)
top < t->sign.top + 24 &&
right > t->sign.left &&
left < t->sign.left + t->sign.width_1*2) {
-
+
AddStringToDraw(t->sign.left + 1, t->sign.top + 1, STR_2001, t->townnametype, t->townnameparts);
- }
+ }
}
} else {
right += 4;
@@ -777,10 +777,10 @@ void ViewportAddTownNames(DrawPixelInfo *dpi)
top < t->sign.top + 24 &&
right > t->sign.left &&
left < t->sign.left + t->sign.width_2*4) {
-
+
AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_2002, t->townnametype, t->townnameparts);
AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_2003, t->townnametype, t->townnameparts);
- }
+ }
}
}
}
@@ -806,7 +806,7 @@ void ViewportAddStationNames(DrawPixelInfo *dpi)
top < st->sign.top + 12 &&
right > st->sign.left &&
left < st->sign.left + st->sign.width_1) {
-
+
sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305C_0, st->index, st->facilities);
if (sstd != NULL) {
sstd->color = (st->owner == OWNER_NONE || !st->facilities) ? 0xE : _player_colors[st->owner];
@@ -824,7 +824,7 @@ void ViewportAddStationNames(DrawPixelInfo *dpi)
top < st->sign.top + 24 &&
right > st->sign.left &&
left < st->sign.left + st->sign.width_1*2) {
-
+
sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305C_0, st->index, st->facilities);
if (sstd != NULL) {
sstd->color = (st->owner == OWNER_NONE || !st->facilities) ? 0xE : _player_colors[st->owner];
@@ -845,7 +845,7 @@ void ViewportAddStationNames(DrawPixelInfo *dpi)
top < st->sign.top + 24 &&
right > st->sign.left &&
left < st->sign.left + st->sign.width_2*4) {
-
+
sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305D_0, st->index, st->facilities);
if (sstd != NULL) {
sstd->color = (st->owner == OWNER_NONE || !st->facilities) ? 0xE : _player_colors[st->owner];
@@ -877,14 +877,14 @@ void ViewportAddSigns(DrawPixelInfo *dpi)
top < ss->sign.top + 12 &&
right > ss->sign.left &&
left < ss->sign.left + ss->sign.width_1) {
-
+
sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0);
if (sstd != NULL) {
sstd->width = ss->sign.width_1;
sstd->color = 14;
}
}
- }
+ }
} else if (dpi->zoom == 1) {
right += 2;
bottom += 2;
@@ -894,14 +894,14 @@ void ViewportAddSigns(DrawPixelInfo *dpi)
top < ss->sign.top + 24 &&
right > ss->sign.left &&
left < ss->sign.left + ss->sign.width_1*2) {
-
+
sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0);
if (sstd != NULL) {
sstd->width = ss->sign.width_1;
sstd->color = 14;
}
}
- }
+ }
} else {
right += 4;
bottom += 5;
@@ -912,14 +912,14 @@ void ViewportAddSigns(DrawPixelInfo *dpi)
top < ss->sign.top + 24 &&
right > ss->sign.left &&
left < ss->sign.left + ss->sign.width_2*4) {
-
+
sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2807, ss->str, 0);
if (sstd != NULL) {
sstd->width = ss->sign.width_2 | 0x8000;
sstd->color = 14;
}
}
- }
+ }
}
}
@@ -945,14 +945,14 @@ void ViewportAddCheckpoints(DrawPixelInfo *dpi)
top < cp->sign.top + 12 &&
right > cp->sign.left &&
left < cp->sign.left + cp->sign.width_1) {
-
+
sstd=AddStringToDraw(cp->sign.left + 1, cp->sign.top + 1, STR_CHECKPOINT_VIEWPORT, cp - _checkpoints, 0);
if (sstd != NULL) {
sstd->width = cp->sign.width_1;
sstd->color = (cp->deleted ? 0xE : 11);
}
}
- }
+ }
} else if (dpi->zoom == 1) {
right += 2;
bottom += 2;
@@ -962,14 +962,14 @@ void ViewportAddCheckpoints(DrawPixelInfo *dpi)
top < cp->sign.top + 24 &&
right > cp->sign.left &&
left < cp->sign.left + cp->sign.width_1*2) {
-
+
sstd=AddStringToDraw(cp->sign.left + 1, cp->sign.top + 1, STR_CHECKPOINT_VIEWPORT, cp - _checkpoints, 0);
if (sstd != NULL) {
sstd->width = cp->sign.width_1;
sstd->color = (cp->deleted ? 0xE : 11);
}
}
- }
+ }
} else {
right += 4;
bottom += 5;
@@ -980,14 +980,14 @@ void ViewportAddCheckpoints(DrawPixelInfo *dpi)
top < cp->sign.top + 24 &&
right > cp->sign.left &&
left < cp->sign.left + cp->sign.width_2*4) {
-
+
sstd=AddStringToDraw(cp->sign.left + 1, cp->sign.top + 1, STR_CHECKPOINT_VIEWPORT_TINY, cp - _checkpoints, 0);
if (sstd != NULL) {
sstd->width = cp->sign.width_2 | 0x8000;
sstd->color = (cp->deleted ? 0xE : 11);
}
}
- }
+ }
}
}
@@ -1011,7 +1011,7 @@ void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str)
void ViewportDrawTileSprites(TileSpriteToDraw *ts)
-{
+{
do {
Point pt = RemapCoords(ts->x, ts->y, ts->z);
DrawSprite(ts->image, pt.x, pt.y);
@@ -1026,7 +1026,7 @@ void ViewportSortParentSprites(ParentSpriteToDraw **psd)
if (!(ps->unk16 & 1)) {
ps->unk16 |= 1;
psd2 = psd;
-
+
while ( (ps2=*++psd2) != NULL) {
if (ps2->unk16 & 1)
continue;
@@ -1075,7 +1075,7 @@ void ViewportDrawStrings(DrawPixelInfo *dpi, StringSpriteToDraw *ss)
{
DrawPixelInfo dp;
byte zoom;
-
+
_cur_dpi = &dp;
dp = *dpi;
@@ -1090,7 +1090,7 @@ void ViewportDrawStrings(DrawPixelInfo *dpi, StringSpriteToDraw *ss)
do {
if (ss->width != 0) {
int x, y, w, bottom;
-
+
x = (ss->x >> zoom) - 1;
y = (ss->y >> zoom) - 1;
@@ -1172,7 +1172,7 @@ void ViewportDoDraw(ViewPort *vp, int left, int top, int right, int bottom)
vd.first_string = NULL;
vd.last_tile = &vd.first_tile;
vd.first_tile = NULL;
-
+
ViewportAddLandscape();
#if !defined(NEW_ROTATION)
ViewportAddVehicles(&vd.dpi);
@@ -1196,10 +1196,10 @@ void ViewportDoDraw(ViewPort *vp, int left, int top, int right, int bottom)
ViewportSortParentSprites(parent_list);
ViewportDrawParentSprites(parent_list);
-
+
if (vd.first_string != NULL)
ViewportDrawStrings(&vd.dpi, vd.first_string);
-
+
_cur_dpi = old_dpi;
}
@@ -1218,7 +1218,7 @@ static void ViewportDrawChk(ViewPort *vp, int left, int top, int right, int bott
ViewportDrawChk(vp, t, top, right, bottom);
}
} else {
- ViewportDoDraw(vp,
+ ViewportDoDraw(vp,
((left - vp->left) << vp->zoom) + vp->virtual_left,
((top - vp->top) << vp->zoom) + vp->virtual_top,
((right - vp->left) << vp->zoom) + vp->virtual_left,
@@ -1285,7 +1285,7 @@ void UpdateViewportPosition(Window *w)
t = x;
x = y - t;
y = y + t;
-
+
// check if inside bounds?
t = (-130) << vp->zoom;
err = 0;
@@ -1301,7 +1301,7 @@ void UpdateViewportPosition(Window *w)
if (err != 0) {
/* coordinate remap */
Point pt = RemapCoords(x, y, 0);
- t = (-1) << vp->zoom;
+ t = (-1) << vp->zoom;
WP(w,vp_d).scrollpos_x = pt.x & t;
WP(w,vp_d).scrollpos_y = pt.y & t;
}
@@ -1373,7 +1373,7 @@ void MarkTileDirty(int x, int y)
pt.x - 31 + 67,
pt.y - 122 + 154
);
-}
+}
void SetSelectionTilesDirty()
{
@@ -1417,8 +1417,8 @@ static bool CheckClickOnTown(ViewPort *vp, int x, int y)
if (vp->zoom < 1) {
x = x - vp->left + vp->virtual_left;
- y = y - vp->top + vp->virtual_top;
-
+ y = y - vp->top + vp->virtual_top;
+
FOR_ALL_TOWNS(t) {
if (t->xy &&
y >= t->sign.top &&
@@ -1431,7 +1431,7 @@ static bool CheckClickOnTown(ViewPort *vp, int x, int y)
}
} else if (vp->zoom == 1) {
x = (x - vp->left + 1) * 2 + vp->virtual_left;
- y = (y - vp->top + 1) * 2 + vp->virtual_top;
+ y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_TOWNS(t) {
if (t->xy &&
y >= t->sign.top &&
@@ -1444,7 +1444,7 @@ static bool CheckClickOnTown(ViewPort *vp, int x, int y)
}
} else {
x = (x - vp->left + 3) * 4 + vp->virtual_left;
- y = (y - vp->top + 3) * 4 + vp->virtual_top;
+ y = (y - vp->top + 3) * 4 + vp->virtual_top;
FOR_ALL_TOWNS(t) {
if (t->xy &&
y >= t->sign.top &&
@@ -1469,7 +1469,7 @@ static bool CheckClickOnStation(ViewPort *vp, int x, int y)
if (vp->zoom < 1) {
x = x - vp->left + vp->virtual_left;
- y = y - vp->top + vp->virtual_top;
+ y = y - vp->top + vp->virtual_top;
FOR_ALL_STATIONS(st) {
if (st->xy &&
@@ -1483,7 +1483,7 @@ static bool CheckClickOnStation(ViewPort *vp, int x, int y)
}
} else if (vp->zoom == 1) {
x = (x - vp->left + 1) * 2 + vp->virtual_left;
- y = (y - vp->top + 1) * 2 + vp->virtual_top;
+ y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_STATIONS(st) {
if (st->xy &&
y >= st->sign.top &&
@@ -1496,7 +1496,7 @@ static bool CheckClickOnStation(ViewPort *vp, int x, int y)
}
} else {
x = (x - vp->left + 3) * 4 + vp->virtual_left;
- y = (y - vp->top + 3) * 4 + vp->virtual_top;
+ y = (y - vp->top + 3) * 4 + vp->virtual_top;
FOR_ALL_STATIONS(st) {
if (st->xy &&
y >= st->sign.top &&
@@ -1521,7 +1521,7 @@ static bool CheckClickOnSign(ViewPort *vp, int x, int y)
if (vp->zoom < 1) {
x = x - vp->left + vp->virtual_left;
- y = y - vp->top + vp->virtual_top;
+ y = y - vp->top + vp->virtual_top;
for(ss = _sign_list; ss != endof(_sign_list); ss++) {
if (ss->str &&
@@ -1535,7 +1535,7 @@ static bool CheckClickOnSign(ViewPort *vp, int x, int y)
}
} else if (vp->zoom == 1) {
x = (x - vp->left + 1) * 2 + vp->virtual_left;
- y = (y - vp->top + 1) * 2 + vp->virtual_top;
+ y = (y - vp->top + 1) * 2 + vp->virtual_top;
for(ss = _sign_list; ss != endof(_sign_list); ss++) {
if (ss->str &&
y >= ss->sign.top &&
@@ -1548,7 +1548,7 @@ static bool CheckClickOnSign(ViewPort *vp, int x, int y)
}
} else {
x = (x - vp->left + 3) * 4 + vp->virtual_left;
- y = (y - vp->top + 3) * 4 + vp->virtual_top;
+ y = (y - vp->top + 3) * 4 + vp->virtual_top;
for(ss = _sign_list; ss != endof(_sign_list); ss++) {
if (ss->str &&
y >= ss->sign.top &&
@@ -1573,7 +1573,7 @@ static bool CheckClickOnCheckpoint(ViewPort *vp, int x, int y)
if (vp->zoom < 1) {
x = x - vp->left + vp->virtual_left;
- y = y - vp->top + vp->virtual_top;
+ y = y - vp->top + vp->virtual_top;
for(cp = _checkpoints; cp != endof(_checkpoints); cp++) {
if (cp->xy &&
@@ -1587,7 +1587,7 @@ static bool CheckClickOnCheckpoint(ViewPort *vp, int x, int y)
}
} else if (vp->zoom == 1) {
x = (x - vp->left + 1) * 2 + vp->virtual_left;
- y = (y - vp->top + 1) * 2 + vp->virtual_top;
+ y = (y - vp->top + 1) * 2 + vp->virtual_top;
for(cp = _checkpoints; cp != endof(_checkpoints); cp++) {
if (cp->xy &&
y >= cp->sign.top &&
@@ -1600,7 +1600,7 @@ static bool CheckClickOnCheckpoint(ViewPort *vp, int x, int y)
}
} else {
x = (x - vp->left + 3) * 4 + vp->virtual_left;
- y = (y - vp->top + 3) * 4 + vp->virtual_top;
+ y = (y - vp->top + 3) * 4 + vp->virtual_top;
for(cp = _checkpoints; cp != endof(_checkpoints); cp++) {
if (cp->xy &&
y >= cp->sign.top &&
@@ -1691,7 +1691,7 @@ void PlaceObject()
Point pt;
Window *w;
WindowEvent e;
-
+
pt = GetTileBelowCursor();
if (pt.x == -1)
return;
@@ -1808,7 +1808,7 @@ void UpdateTileSelection()
int y2 = thd->selstart.y;
x1 &= ~0xF;
y1 &= ~0xF;
-
+
if (x1 >= x2) intswap(x1,x2);
if (y1 >= y2) intswap(y1,y2);
thd->new_pos.x = x1;
@@ -1834,10 +1834,10 @@ void UpdateTileSelection()
}
}
- if (thd->drawstyle != thd->new_drawstyle ||
- thd->pos.x != thd->new_pos.x || thd->pos.y != thd->new_pos.y ||
+ if (thd->drawstyle != thd->new_drawstyle ||
+ thd->pos.x != thd->new_pos.x || thd->pos.y != thd->new_pos.y ||
thd->size.x != thd->new_size.x || thd->size.y != thd->new_size.y) {
-
+
// clear the old selection?
if (thd->drawstyle) SetSelectionTilesDirty();
@@ -1898,7 +1898,7 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y)
int d;
bool b;
uint w,h;
-
+
w = myabs((x & ~0xF) - thd->selstart.x) + 16;
h = myabs((y & ~0xF) - thd->selstart.y) + 16;
@@ -2002,7 +2002,7 @@ bool VpHandlePlaceSizingDrag()
{
Window *w;
WindowEvent e;
-
+
if (_special_mouse_mode != WSM_SIZING)
return true;
@@ -2024,9 +2024,9 @@ bool VpHandlePlaceSizingDrag()
// mouse button released..
// keep the selected tool, but reset it to the original mode.
- _special_mouse_mode = WSM_NONE;
+ _special_mouse_mode = WSM_NONE;
_thd.place_mode = (_thd.next_drawstyle == HT_RECT || _thd.next_drawstyle & HT_LINE) ? 1 : 2;
-
+
SetTileSelectSize(1, 1);
// and call the mouseup event.
@@ -2035,7 +2035,7 @@ bool VpHandlePlaceSizingDrag()
e.place.tile = TILE_FROM_XY(e.place.pt.x, e.place.pt.y);
e.place.starttile = TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y);
w->wndproc(w, &e);
-
+
return false;
}
@@ -2057,9 +2057,9 @@ void SetObjectToPlace(int icon, byte mode, byte window_class, uint16 window_num)
if (w != NULL)
CallWindowEventNP(w, WE_ABORT_PLACE_OBJ);
}
-
+
SetTileSelectSize(1, 1);
-
+
thd->make_square_red = false;
if (mode == 4) {
@@ -2075,7 +2075,7 @@ void SetObjectToPlace(int icon, byte mode, byte window_class, uint16 window_num)
if (mode == 3)
VpStartPreSizing();
-
+
if ( (int)icon < 0)
SetAnimatedMouseCursor(_animcursors[~icon]);
else
diff --git a/viewport.h b/viewport.h
index 737c7912b..6e1c0e65f 100644
--- a/viewport.h
+++ b/viewport.h
@@ -8,12 +8,12 @@ struct ViewPort {
int virtual_left, virtual_top; // virtual coordinates
int virtual_width, virtual_height; // these are just width << zoom, height << zoom
- byte zoom;
+ byte zoom;
};
/* viewport.c */
Point MapXYZToViewport(ViewPort *vp, uint x, uint y, uint z);
-void AssignWindowViewport(Window *w, int x, int y,
+void AssignWindowViewport(Window *w, int x, int y,
int width, int height, uint32 follow_flags, byte zoom);
void SetViewportPosition(Window *w, int x, int y);
ViewPort *IsPtInWindowViewport(Window *w, int x, int y);
diff --git a/w32dm2.cpp b/w32dm2.cpp
index eac3fe41c..b32182bcd 100644
--- a/w32dm2.cpp
+++ b/w32dm2.cpp
@@ -65,7 +65,7 @@ IDirectMusicPerformance *performance = NULL;
IDirectMusicSegment *segment = NULL;
// the loader bject can load many types of DMusic related files
-IDirectMusicLoader *loader = NULL;
+IDirectMusicLoader *loader = NULL;
// whether we've initialized COM or not (when deciding whether to shut down)
int COMInitialized = 0;
@@ -81,7 +81,7 @@ struct ProcPtrs {
};
#define M(x) x "\0"
-static const char ole_files[] =
+static const char ole_files[] =
M("ole32.dll")
M("CoCreateInstance")
M("CoInitialize")
@@ -95,7 +95,7 @@ static ProcPtrs _proc;
static bool LoadOleDLL()
{
- if (_proc.CoCreateInstance != NULL)
+ if (_proc.CoCreateInstance != NULL)
return true;
if (!LoadLibraryList((void**)&_proc, ole_files))
return false;
@@ -151,7 +151,7 @@ bool InitDirectMusic (void)
// midi file for our demo. Again, we need to use CoCreateInstance
// and pass the appropriate ID parameters
if (FAILED(_proc.CoCreateInstance((REFCLSID)CLSID_DirectMusicLoader,
- NULL, CLSCTX_INPROC,
+ NULL, CLSCTX_INPROC,
(REFIID)IID_IDirectMusicLoader,
(LPVOID *)&loader))) {
MSGBOX("Failed to create loader object");
@@ -163,7 +163,7 @@ bool InitDirectMusic (void)
return true;
}
-// Releases memory used by all of the initialized
+// Releases memory used by all of the initialized
// DirectMusic objects in the program
void ReleaseSegment (void)
{
@@ -174,8 +174,8 @@ void ReleaseSegment (void)
}
void ShutdownDirectMusic (void)
{
- // release everything but the segment, which the performance
- // will release automatically (and it'll crash if it's been
+ // release everything but the segment, which the performance
+ // will release automatically (and it'll crash if it's been
// released already)
if (NULL != loader) {
@@ -196,7 +196,7 @@ void ShutdownDirectMusic (void)
}
}
-// Load MIDI file for playing
+// Load MIDI file for playing
bool LoadMIDI (char *directory, char *filename)
{
DMUS_OBJECTDESC obj_desc;
@@ -229,8 +229,8 @@ bool LoadMIDI (char *directory, char *filename)
ReleaseSegment();
// and make a new segment
- if (FAILED(loader->GetObject(&obj_desc,
- (REFIID)IID_IDirectMusicSegment,
+ if (FAILED(loader->GetObject(&obj_desc,
+ (REFIID)IID_IDirectMusicSegment,
(LPVOID *) &segment))) {
MSGBOX("LoadMIDI: Get object failed");
return FALSE;
diff --git a/water_cmd.c b/water_cmd.c
index d96be9840..0b9297869 100644
--- a/water_cmd.c
+++ b/water_cmd.c
@@ -27,7 +27,7 @@ bool IsClearWaterTile(uint tile)
int32 CmdBuildShipDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
uint tile, tile2;
-
+
int32 cost, ret;
Depot *dep;
@@ -49,7 +49,7 @@ int32 CmdBuildShipDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
ret = DoCommandByTile(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (ret == CMD_ERROR)
return CMD_ERROR;
-
+
// pretend that we're not making land from the water even though we actually are.
cost = 0;
@@ -62,12 +62,12 @@ int32 CmdBuildShipDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
_last_built_ship_depot_tile = tile;
dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
- ModifyTile(tile,
+ ModifyTile(tile,
MP_SETTYPE(MP_WATER) | MP_MAPOWNER_CURRENT | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,
(0x80 + p1*2)
);
-
- ModifyTile(tile2,
+
+ ModifyTile(tile2,
MP_SETTYPE(MP_WATER) | MP_MAPOWNER_CURRENT | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,
(0x81 + p1*2)
);
@@ -101,8 +101,8 @@ static int32 RemoveShipDepot(uint tile, uint32 flags)
// Kill the entry from the depot table
for(d=_depots; d->xy != tile; d++) {}
d->xy = 0;
-
- DeleteWindowById(WC_VEHICLE_DEPOT, tile);
+
+ DeleteWindowById(WC_VEHICLE_DEPOT, tile);
}
return _price.remove_ship_depot;
@@ -117,7 +117,7 @@ static int32 DoBuildShiplift(uint tile, int dir, uint32 flags)
// middle tile
ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (ret == CMD_ERROR) return CMD_ERROR;
-
+
delta = _tileoffs_by_dir[dir];
// lower tile
ret = DoCommandByTile(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -151,7 +151,7 @@ static int32 RemoveShiplift(uint tile, uint32 flags)
DoClearSquare(tile + delta);
DoClearSquare(tile - delta);
}
-
+
return _price.clear_water * 2;
}
@@ -168,7 +168,7 @@ int32 CmdBuildLock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
uint tile = TILE_FROM_XY(x,y);
int32 ret;
uint th;
- th = GetTileSlope(tile, NULL);
+ th = GetTileSlope(tile, NULL);
if (th==3 || th==6 || th==9 || th==12) {
static const byte _shiplift_dirs[16] = {0,0,0,2,0,0,1,0,0,3,0,0,0};
@@ -194,7 +194,7 @@ int32 CmdBuildCanal(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// move in which direction?
delta = (GET_TILE_X(tile) == GET_TILE_X(endtile)) ? TILE_XY(0,1) : TILE_XY(1,0);
if (endtile < tile) delta = -delta;
-
+
cost = 0;
for(;;) {
ret = 0;
@@ -277,7 +277,7 @@ static int32 ClearTile_Water(uint tile, byte flags) {
DoClearSquare(tile);
return _price.clear_water;
}
- if (flags & DC_EXEC)
+ if (flags & DC_EXEC)
DoClearSquare(tile);
return _price.purchase_land;
} else
@@ -290,7 +290,7 @@ static int32 ClearTile_Water(uint tile, byte flags) {
TILE_XY(-1, 0),TILE_XY(0, 1),TILE_XY(1, 0),TILE_XY(0, -1), // lower
TILE_XY(1, 0),TILE_XY(0, -1),TILE_XY(-1, 0),TILE_XY(0, 1), // upper
};
-
+
if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
// don't allow water to delete it.
if (_current_player == OWNER_WATER) return CMD_ERROR;
@@ -316,9 +316,9 @@ static bool IsWateredTile(uint tile)
{
byte m5 = _map5[tile];
if (IS_TILETYPE(tile, MP_WATER)) {
- return m5 != 1;
+ return m5 != 1;
} else if (IS_TILETYPE(tile, MP_STATION)) {
- // returns true if it is a dock-station (m5 inside values is m5<75 all stations,
+ // returns true if it is a dock-station (m5 inside values is m5<75 all stations,
// 83<=m5<=114 new airports
return !(m5 < 75 || (m5 >= 83 && m5 <= 114));
} else if (IS_TILETYPE(tile, MP_TUNNELBRIDGE)) {
@@ -331,13 +331,13 @@ static bool IsWateredTile(uint tile)
void DrawCanalWater(uint tile)
{
uint wa;
-
+
// determine the edges around with water.
wa = IsWateredTile(TILE_ADDXY(tile, -1, 0)) << 0;
wa += IsWateredTile(TILE_ADDXY(tile, 0, 1)) << 1;
wa += IsWateredTile(TILE_ADDXY(tile, 1, 0)) << 2;
wa += IsWateredTile(TILE_ADDXY(tile, 0, -1)) << 3;
-
+
if (!(wa & 1)) DrawGroundSprite(SPR_CANALS_BASE + 57);
if (!(wa & 2)) DrawGroundSprite(SPR_CANALS_BASE + 58);
if (!(wa & 4)) DrawGroundSprite(SPR_CANALS_BASE + 59);
@@ -383,9 +383,9 @@ static void DrawWaterStuff(TileInfo *ti, const byte *t, uint32 palette, uint bas
const WaterDrawTileStruct *wdts;
uint32 image;
- DrawGroundSprite(*(uint16*)t);
+ DrawGroundSprite(*(uint16*)t);
t += sizeof(uint16);
-
+
for(wdts = (WaterDrawTileStruct *)t; (byte)wdts->delta_x != 0x80; wdts++) {
image = wdts->image + base;
if (_display_opt & DO_TRANS_BUILDINGS) {
@@ -431,7 +431,7 @@ void DrawShipDepotSprite(int x, int y, int image)
t = _shipdepot_display_seq[image];
DrawSprite(*(uint16*)t, x, y);
t += sizeof(uint16);
-
+
for(wdts = (WaterDrawTileStruct *)t; (byte)wdts->delta_x != 0x80; wdts++) {
Point pt = RemapCoords(wdts->delta_x, wdts->delta_y, wdts->delta_z);
DrawSprite(wdts->image + PLAYER_SPRITE_COLOR(_local_player), x + pt.x, y + pt.y);
@@ -440,12 +440,12 @@ void DrawShipDepotSprite(int x, int y, int image)
uint GetSlopeZ_Water(TileInfo *ti)
-{
+{
return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
}
uint GetSlopeTileh_Water(TileInfo *ti)
-{
+{
return ti->tileh;
}
@@ -534,7 +534,7 @@ static void FloodVehicle(Vehicle *v)
_vehicle_sort_dirty[VEHROAD] = true;
InvalidateWindow(WC_ROADVEH_LIST, v->owner);
}
-
+
else if (v->type == VEH_Train) {
v = GetFirstVehicleInChain(v);
u = v;
@@ -549,13 +549,13 @@ static void FloodVehicle(Vehicle *v)
v = u;
v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast
_vehicle_sort_dirty[VEHTRAIN] = true;
- InvalidateWindow(WC_TRAINS_LIST, v->owner);
+ InvalidateWindow(WC_TRAINS_LIST, v->owner);
} else
return;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
-
+
SET_DPARAM16(0, pass);
AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED,
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
@@ -621,7 +621,7 @@ static uint32 GetTileTrackStatus_Water(uint tile, TransportType mode)
}
if ( (m5 & 0x10) == 0x10) {
- //
+ //
b = _shiplift_tracks[m5 & 0xF];
return b + (b<<8);
}
@@ -638,7 +638,7 @@ extern void ShowShipDepotWindow(uint tile);
static void ClickTile_Water(uint tile)
{
byte m5 = _map5[tile] - 0x80;
-
+
if (IS_BYTE_INSIDE(m5, 0, 3+1)) {
if (m5 & 1)
tile += (m5==1) ? TILE_XY(-1,0) : TILE_XY(0,-1);
diff --git a/widget.c b/widget.c
index e5b1300dd..49313e26f 100644
--- a/widget.c
+++ b/widget.c
@@ -11,7 +11,7 @@ static Point HandleScrollbarHittest(Scrollbar *sb, int top, int bottom)
top += 10;
bottom -= 9;
-
+
height = (bottom - top);
pos = sb->pos;
@@ -19,7 +19,7 @@ static Point HandleScrollbarHittest(Scrollbar *sb, int top, int bottom)
cap = sb->cap;
if (count != 0) top += height * pos / count;
-
+
if (cap > count) cap = count;
if (count != 0)
bottom -= (count - pos - cap) * height / count;
@@ -61,7 +61,7 @@ void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y)
pos = x;
sb = &w->hscroll;
}
-
+
if (pos <= mi+9) {
// Pressing the upper button?
if (!_demo_mode) {
@@ -76,7 +76,7 @@ void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y)
// Pressing the lower button?
if (!_demo_mode) {
w->flags4 |= WF_SCROLL_DOWN;
-
+
if (_scroller_click_timeout == 0) {
_scroller_click_timeout = 6;
if ((byte)(sb->pos + sb->cap) < sb->count)
@@ -85,14 +85,14 @@ void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y)
_left_button_clicked = false;
}
} else {
- //
+ //
Point pt = HandleScrollbarHittest(sb, mi, ma);
if (pos < pt.x) {
sb->pos = max(sb->pos - sb->cap, 0);
} else if (pos > pt.y) {
sb->pos = min(
- sb->pos + sb->cap,
+ sb->pos + sb->cap,
max(sb->count - sb->cap, 0)
);
} else {
@@ -147,9 +147,9 @@ void DrawWindowWidgets(Window *w)
Rect r;
uint32 dparam_backup[10];
uint32 cur_click, cur_disabled, cur_hidden;
-
+
if (w->desc_flags & WDF_RESTORE_DPARAM) COPY_OUT_DPARAM(dparam_backup, 0, lengthof(dparam_backup));
-
+
wi = w->widget;
cur_click = w->click_state;
@@ -190,7 +190,7 @@ void DrawWindowWidgets(Window *w)
StringID str = wi->unkA;
if ((wi->type&WWT_MASK) == WWT_4 && (cur_click&1)) str++;
-
+
DrawStringCentered((r.left + r.right+1)>>1, ((r.top+r.bottom + 1)>>1) - 5, str, 0);
goto restore_dparam;
}
@@ -207,13 +207,13 @@ void DrawWindowWidgets(Window *w)
}
case WWT_MATRIX: {
- int c, d, ctr;
+ int c, d, ctr;
int x, amt1, amt2;
int color;
-
+
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color,
(cur_click & 1) ? 0x20 : 0);
-
+
c = (wi->unkA&0xFF);
amt1 = (wi->right - wi->left + 1) / c;
@@ -221,7 +221,7 @@ void DrawWindowWidgets(Window *w)
amt2 = (wi->bottom - wi->top + 1) / d;
color = _color_list[wi->color&0xF].window_color_bgb;
-
+
x = r.left;
for(ctr=c; --ctr; ) {
x += amt1;
@@ -248,7 +248,7 @@ void DrawWindowWidgets(Window *w)
GfxFillRect(r.left+1, x, r.right-1, x, color);
}
- goto draw_default;
+ goto draw_default;
}
// vertical scrollbar
@@ -276,7 +276,7 @@ void DrawWindowWidgets(Window *w)
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2);
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1);
GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2);
-
+
pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom);
DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == WF_SCROLL_MIDDLE ? 0x20 : 0);
break;
@@ -350,7 +350,7 @@ void DrawWindowWidgets(Window *w)
case WWT_CAPTION: {
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0x10);
DrawFrameRect(r.left+1, r.top+1, r.right-1, r.bottom-1, wi->color, (w->caption_color == 0xFF) ? 0x60 : 0x70);
-
+
if (w->caption_color != 0xFF) {
GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _color_list[_player_colors[w->caption_color]].window_color_1b);
}
@@ -365,7 +365,7 @@ draw_default:;
}
}
} while (cur_click>>=1, cur_disabled>>=1, cur_hidden >>= 1, (++wi)->type != WWT_LAST);
-
+
if (w->flags4 & WF_WHITE_BORDER_MASK) {
//DrawFrameRect(w->left, w->top, w->left + w->width-1, w->top+w->height-1, 0xF, 0x10);
@@ -396,7 +396,7 @@ static int GetDropdownItem(Window *w)
if (GetWidgetFromPos(w, _cursor.pos.x - w->left, _cursor.pos.y - w->top) < 0)
return -1;
-
+
y = _cursor.pos.y - w->top - 2;
if (y < 0)
@@ -433,7 +433,7 @@ void DropdownMenuWndProc(Window *w, WindowEvent *e)
DrawString(x+2, y, _dropdown_items[i], sel==0 ? 12 : 16);
if (dis & 1) {
- GfxFillRect(x, y, x+w->width-3, y + 9, 0x8000 +
+ GfxFillRect(x, y, x+w->width-3, y + 9, 0x8000 +
_color_list[_dropdown_menu_widgets[0].color].window_color_bga);
}
} else {
@@ -491,7 +491,7 @@ void DropdownMenuWndProc(Window *w, WindowEvent *e)
SetWindowDirty(w);
}
} break;
-
+
case WE_DESTROY: {
Window *w2 = FindWindowById(_dropdown_windowclass, _dropdown_windownum);
if (w2 != NULL) {
@@ -510,7 +510,7 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
const Widget *wi;
Window *w2;
uint32 old_click_state = w->click_state;
-
+
_dropdown_disabled = disabled_mask;
cls = w->window_class;
@@ -524,7 +524,7 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
SETBIT(w->click_state, button);
InvalidateWidget(w, button);
-
+
for(i=0;strings[i] != INVALID_STRING_ID;i++);
if (i == 0)
return;
@@ -532,11 +532,11 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
_dropdown_items = strings;
_dropdown_item_count = i;
_dropdown_selindex = selected;
-
+
_dropdown_windowclass = w->window_class;
_dropdown_windownum = w->window_number;
_dropdown_button = button;
-
+
_dropdown_var1 = 0;
_dropdown_var2 = 1;
@@ -547,8 +547,8 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
w2 = AllocateWindow(
w->left + wi[-1].left + 1,
w->top + wi->bottom + 2,
- (_dropdown_menu_widgets[0].right=t1=wi->right - wi[-1].left, t1 + 1),
- (_dropdown_menu_widgets[0].bottom=t2=i*10+3, t2+1),
+ (_dropdown_menu_widgets[0].right=t1=wi->right - wi[-1].left, t1 + 1),
+ (_dropdown_menu_widgets[0].bottom=t2=i*10+3, t2+1),
DropdownMenuWndProc,
0x3F,
_dropdown_menu_widgets);
diff --git a/win32.c b/win32.c
index e16a84676..545dcdb74 100644
--- a/win32.c
+++ b/win32.c
@@ -51,7 +51,7 @@ static void MakePalette()
pal->palVersion = 0x300;
pal->palNumEntries = 256;
-
+
for(i=0,b=_cur_palette; i!=256;i++,b+=3) {
pal->palPalEntry[i].peRed = b[0];
pal->palPalEntry[i].peGreen = b[1];
@@ -60,7 +60,7 @@ static void MakePalette()
}
_wnd.gdi_palette = CreatePalette(pal);
- if (_wnd.gdi_palette == NULL)
+ if (_wnd.gdi_palette == NULL)
error("CreatePalette failed!\n");
}
@@ -133,7 +133,7 @@ static const VkMapping _vk_mapping[] = {
AS(VK_SUBTRACT, WKC_NUM_MINUS),
AS(VK_ADD, WKC_NUM_PLUS),
AS(VK_DECIMAL, WKC_NUM_DECIMAL),
- {0}
+ {0}
};
static uint MapWindowsKey(uint key)
@@ -162,14 +162,14 @@ static bool AllocateDibSection(int w, int h);
static void ClientSizeChanged(int w, int h)
{
if (_wnd.double_size) { w >>= 1; h >>= 1; }
-
+
// allocate new dib section of the new size
if (AllocateDibSection(w, h)) {
// mark all palette colors dirty
_pal_first_dirty = 0;
_pal_last_dirty = 255;
GameSizeChanged();
-
+
// redraw screen
if (_wnd.running) {
_screen.dst_ptr = _wnd.buffer_bits;
@@ -191,12 +191,12 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
dc2 = CreateCompatibleDC(dc);
old_bmp = SelectObject(dc2, _wnd.dib_sect);
old_palette = SelectPalette(dc, _wnd.gdi_palette, FALSE);
-
+
if (_pal_last_dirty != -1) {
UpdatePalette(dc2, _pal_first_dirty, _pal_last_dirty - _pal_first_dirty + 1);
_pal_last_dirty = -1;
}
-
+
BitBlt(dc, 0, 0, _wnd.width, _wnd.height, dc2, 0, 0, SRCCOPY);
SelectPalette(dc, old_palette, TRUE);
SelectObject(dc2, old_bmp);
@@ -219,7 +219,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
InvalidateRect(hwnd, NULL, FALSE);
return 0;
}
-
+
case WM_CLOSE:
AskExitGame();
return 0;
@@ -255,7 +255,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
x >>= 1;
y >>= 1;
}
-
+
if (_cursor.fix_at) {
int dx = x - _cursor.pos.x;
int dy = y - _cursor.pos.y;
@@ -285,7 +285,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
}
case WM_KEYDOWN:
- {
+ {
// this is the rewritten ascii input function
// it disables windows deadkey handling --> more linux like :D
unsigned short w = 0;
@@ -304,7 +304,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
ClientSizeChanged(_wnd.width, _wnd.height);
MarkWholeScreenDirty();
}
- break;
+ break;
case WM_SYSKEYDOWN:
@@ -334,7 +334,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
SetRect(&r2, 0, 0, 0, 0);
AdjustWindowRect(&r2, GetWindowLong(hwnd, GWL_STYLE), FALSE);
-
+
w = r->right - r->left - (r2.right - r2.left);
h = r->bottom - r->top - (r2.bottom - r2.top);
if (_wnd.double_size) { w >>= 1; h >>= 1; }
@@ -389,7 +389,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
#endif //GET_WHEEL_DELTA_WPARAM
case WM_MOUSEWHEEL: {
- int delta = GET_WHEEL_DELTA_WPARAM(wParam);
+ int delta = GET_WHEEL_DELTA_WPARAM(wParam);
if (delta < 0) {
_cursor.wheel++;
} else if (delta > 0) {
@@ -433,13 +433,13 @@ static void MakeWindow(bool full_screen)
_fullscreen = full_screen;
_wnd.double_size = _double_size && !full_screen;
-
+
// recreate window?
if ((full_screen|_wnd.fullscreen) && _wnd.main_wnd) {
DestroyWindow(_wnd.main_wnd);
_wnd.main_wnd = 0;
}
-
+
if (full_screen) {
DEVMODE settings;
memset(&settings, 0, sizeof(DEVMODE));
@@ -467,7 +467,7 @@ static void MakeWindow(bool full_screen)
RECT r;
uint style;
int x, y, w, h;
-
+
if ((_wnd.fullscreen=full_screen) != false) {
style = WS_POPUP | WS_VISIBLE;
SetRect(&r, 0, 0, _wnd.width_org, _wnd.height_org);
@@ -510,11 +510,11 @@ static bool AllocateDibSection(int w, int h)
free(_wnd.alloced_bits);
_wnd.alloced_bits = NULL;
}
-
+
bi = alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256);
memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256);
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-
+
{
if (_wnd.double_size) {
_wnd.alloced_bits = _wnd.buffer_bits = (byte*)malloc(w * h);
@@ -525,7 +525,7 @@ static bool AllocateDibSection(int w, int h)
bi->bmiHeader.biWidth = _wnd.width = w;
bi->bmiHeader.biHeight = -(_wnd.height = h);
}
-
+
bi->bmiHeader.biPlanes = 1;
bi->bmiHeader.biBitCount = 8;
bi->bmiHeader.biCompression = BI_RGB;
@@ -539,7 +539,7 @@ static bool AllocateDibSection(int w, int h)
error("CreateDIBSection failed");
ReleaseDC(0, dc);
- if (!_wnd.double_size)
+ if (!_wnd.double_size)
_wnd.buffer_bits = _wnd.bitmap_bits;
return true;
@@ -562,7 +562,7 @@ static void FindResolutions()
DEVMODE dm;
while (EnumDisplaySettings(NULL, i++, &dm)) {
- if (dm.dmBitsPerPel == 8 &&
+ if (dm.dmBitsPerPel == 8 &&
IS_INT_INSIDE(dm.dmPelsWidth, 640, MAX_SCREEN_WIDTH+1) &&
IS_INT_INSIDE(dm.dmPelsHeight, 480, MAX_SCREEN_HEIGHT+1) &&
(n == 0 || _resolutions[n-1][0] != dm.dmPelsWidth || _resolutions[n-1][1] != dm.dmPelsHeight)) {
@@ -625,7 +625,7 @@ static void filter(int left, int top, int width, int height)
while (height) {
for(i=0; i!=width; i++) {
- d[i*2] = d[i*2+1] = d[i*2+p*2] = d[i*2+1+p*2] = s[i];
+ d[i*2] = d[i*2+1] = d[i*2+p*2] = d[i*2+1+p*2] = s[i];
}
s += p;
d += p * 4;
@@ -676,7 +676,7 @@ static int Win32GdiMainLoop()
} else if (_fast_forward&2) {
_fast_forward = 0;
}
-
+
cur_ticks=GetTickCount();
if ((_fast_forward && !_pause) || cur_ticks > next_tick)
@@ -687,15 +687,15 @@ static int Win32GdiMainLoop()
_ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0;
_shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0;
_dbg_screen_rect = _wnd.has_focus && GetAsyncKeyState(VK_CAPITAL)<0;
-
+
// determine which directional keys are down
- _dirkeys =
- (GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) +
- (GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
- (GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
+ _dirkeys =
+ (GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) +
+ (GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
+ (GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0);
- GameLoop();
+ GameLoop();
_cursor.delta.x = _cursor.delta.y = 0;
if (_force_full_redraw)
@@ -718,9 +718,9 @@ static bool Win32GdiChangeRes(int w, int h)
{
_wnd.width = _wnd.width_org = w;
_wnd.height = _wnd.height_org = h;
-
+
MakeWindow(_wnd.fullscreen);
-
+
return true;
}
@@ -823,15 +823,15 @@ static DWORD WINAPI MidiThread(LPVOID arg)
if ((vol=_midi.new_vol) != -1) {
_midi.new_vol = -1;
MidiIntSetVolume(vol);
-
+
}
if ((s=_midi.start_song)[0]) {
_midi.playing = MidiIntPlaySong(s);
s[0] = 0;
-
+
// Delay somewhat in case we don't manage to play.
if (!_midi.playing) {
- Sleep(5000);
+ Sleep(5000);
}
}
if (_midi.stop_song != false && _midi.playing) {
@@ -893,7 +893,7 @@ static void FillHeaders()
WAVEHDR *hdr;
for(hdr=_wave_hdr; hdr != endof(_wave_hdr); hdr++) {
if (!(hdr->dwFlags & WHDR_INQUEUE)) {
- MxMixSamples(_mixer, hdr->lpData, hdr->dwBufferLength >> 2);
+ MxMixSamples(_mixer, hdr->lpData, hdr->dwBufferLength >> 2);
if (waveOutWrite(_waveout, hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR)
error("waveOutWrite failed");
}
@@ -914,7 +914,7 @@ static char *Win32SoundStart(char **parm)
{
WAVEFORMATEX wfex;
int hz;
-
+
_bufsize = GetDriverParamInt(parm, "bufsize", 1024);
hz = GetDriverParamInt(parm, "hz", 11025);
wfex.wFormatTag = WAVE_FORMAT_PCM;
@@ -1007,7 +1007,7 @@ static uint32 *_crc_table;
static void MakeCRCTable(uint32 *table) {
uint32 crc, poly = 0xEDB88320L;
int i, j;
-
+
_crc_table = table;
for (i=0; i!=256; i++) {
@@ -1051,7 +1051,7 @@ static void GetFileInfo(DebugFileInfo *dfi, const char *filename)
}
dfi->size = filesize;
dfi->crc32 = crc ^ (uint32)-1;
-
+
if (GetFileTime(file, NULL, NULL, &write_time)) {
FileTimeToSystemTime(&write_time, &dfi->file_time);
}
@@ -1108,14 +1108,14 @@ static char *PrintModuleList(char *output)
return output;
}
-static const char _crash_desc[] =
+static const char _crash_desc[] =
"A serious fault condition occured in the game. The game will shut down.\n"
"Press \"Submit report\" to send crash information to the developers. "
"This will greatly help debugging. The information contained in the report is "
"displayed below.\n"
"Press \"Emergency save\" to attempt saving the game.";
-static const char _save_succeeded[] =
+static const char _save_succeeded[] =
"Emergency save succeeded.\nBe aware that critical parts of the internal game state "
"may have become corrupted. The saved game is not guaranteed to work.";
@@ -1132,7 +1132,7 @@ typedef struct {
} WinInetProcs;
#define M(x) x "\0"
-static const char wininet_files[] =
+static const char wininet_files[] =
M("wininet.dll")
M("InternetOpenA")
M("InternetConnectA")
@@ -1153,7 +1153,7 @@ static char *SubmitCrashReport(HWND wnd, void *msg, size_t msglen, const char *a
DWORD code, len;
static char buf[100];
char buff[100];
-
+
if (_wininet.InternetOpen == NULL && !LoadLibraryList((void**)&_wininet, wininet_files)) return "can't load wininet.dll";
inet = _wininet.InternetOpen("TTD", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
@@ -1171,7 +1171,7 @@ static char *SubmitCrashReport(HWND wnd, void *msg, size_t msglen, const char *a
len = sizeof(code);
if (!_wininet.HttpQueryInfo(http, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &code, &len, 0)) { err = "httpqueryinfo failed"; goto error4; }
-
+
if (code != 200) {
int l = sprintf(buf, "Server said: %d ", code);
len = sizeof(buf) - l;
@@ -1201,13 +1201,13 @@ static void SubmitFile(HWND wnd, const char *file)
size = GetFileSize(h, NULL);
if (size > 500000) goto error1;
-
+
mem = malloc(size);
if (mem == NULL) goto error1;
if (!ReadFile(h, mem, size, &read, NULL) || read != size) goto error2;
- SubmitCrashReport(wnd, mem, size, file);
+ SubmitCrashReport(wnd, mem, size, file);
error2:
free(mem);
@@ -1223,16 +1223,16 @@ static void SetWndSize(HWND wnd, int mode)
int offs;
GetWindowRect(wnd, &r);
-
+
SetDlgItemText(wnd, 15, _expand_texts[mode == 1]);
-
+
if (mode >= 0) {
GetWindowRect(GetDlgItem(wnd, 11), &r2);
offs = r2.bottom - r2.top + 10;
if (!mode) offs=-offs;
SetWindowPos(wnd, HWND_TOPMOST, 0, 0, r.right - r.left, r.bottom - r.top + offs, SWP_NOMOVE | SWP_NOZORDER);
} else {
- SetWindowPos(wnd, HWND_TOPMOST,
+ SetWindowPos(wnd, HWND_TOPMOST,
(GetSystemMetrics(SM_CXSCREEN) - (r.right - r.left)) >> 1,
(GetSystemMetrics(SM_CYSCREEN) - (r.bottom - r.top)) >> 1,
0, 0, SWP_NOSIZE);
@@ -1273,7 +1273,7 @@ static BOOL CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM lPar
}
case 14: { // Submit crash report
char *s;
-
+
SetCursor(LoadCursor(NULL, IDC_WAIT));
s = SubmitCrashReport(wnd, _crash_msg, strlen(_crash_msg), "");
@@ -1281,7 +1281,7 @@ static BOOL CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM lPar
MessageBoxA(wnd, s, "Error", MB_ICONSTOP);
break;
}
-
+
// try to submit emergency savegame
if (_did_emerg_save || DoEmergencySave(wnd)) {
SubmitFile(wnd, "crash.sav");
@@ -1324,7 +1324,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
if (had_exception) { ExitProcess(0); }
had_exception = true;
-
+
_ident = GetTickCount(); // something pretty unique
MakeCRCTable(alloca(256 * sizeof(uint32)));
@@ -1333,7 +1333,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
{
SYSTEMTIME time;
GetLocalTime(&time);
- output += sprintf(output,
+ output += sprintf(output,
"*** OpenTTD Crash Report ***\r\n"
"Date: %d-%.2d-%.2d %.2d:%.2d:%.2d\r\n"
"Build: %s built on " __TIMESTAMP__ "\r\n",
@@ -1436,7 +1436,7 @@ static void Win32InitializeExceptions()
_asm {
mov _safe_esp,esp
}
-
+
SetUnhandledExceptionFilter(ExceptionHandler);
}
#endif
@@ -1459,7 +1459,7 @@ static FiosItem *FiosAlloc()
static HANDLE MyFindFirstFile(char *path, char *file, WIN32_FIND_DATA *fd)
{
char paths[MAX_PATH];
-
+
sprintf(paths, "%s\\%s", path, file);
return FindFirstFile(paths, fd);
}
@@ -1471,7 +1471,7 @@ int CDECL compare_FiosItems (const void *a, const void *b) {
if (_savegame_sort_order < 2) // sort by date
r = da->mtime < db->mtime ? -1 : 1;
- else
+ else
r = stricmp(da->title[0] ? da->title : da->name, db->title[0] ? db->title : db->name);
if (_savegame_sort_order & 1) r = -r;
@@ -1503,7 +1503,7 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
fios->type = FIOS_TYPE_PARENT;
strcpy(fios->title, ".. (Parent directory)");
}
-
+
// Show subdirectories first
h = MyFindFirstFile(_fios_path, "*.*", &fd);
@@ -1695,7 +1695,7 @@ char *FiosBrowseTo(const FiosItem *item)
case FIOS_TYPE_DRIVE:
sprintf(path, "%c:\\", item->title[0]);
break;
-
+
case FIOS_TYPE_PARENT:
// Skip drive part
path += 3;
@@ -1713,7 +1713,7 @@ char *FiosBrowseTo(const FiosItem *item)
while (*++path);
// Add backslash?
if (path[-1] != '\\') *path++ = '\\';
-
+
strcpy(path, item->name);
break;
@@ -1752,7 +1752,7 @@ StringID FiosGetDescText(char **path)
if (GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) {
uint32 tot = ((spc*bps)*(uint64)nfc) >> 20;
SET_DPARAM32(0, tot);
- return STR_4005_BYTES_FREE;
+ return STR_4005_BYTES_FREE;
} else {
return STR_4006_UNABLE_TO_READ_DRIVE;
}
@@ -1848,7 +1848,7 @@ static int ParseCommandLine(char *line, char **argv, int max_argc)
// end?
if (*line == 0)
break;
-
+
// special handling when quoted
if (*line == '"') {
argv[n++] = ++line;
@@ -1863,7 +1863,7 @@ static int ParseCommandLine(char *line, char **argv, int max_argc)
line++;
}
}
- *line++ = 0;
+ *line++ = 0;
} while (n != max_argc);
return n;
@@ -1890,12 +1890,12 @@ void CreateConsole()
_has_console = true;
AllocConsole();
-
+
hand = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hand, &coninfo);
coninfo.dwSize.Y = 500;
SetConsoleScreenBufferSize(hand, coninfo.dwSize);
-
+
// redirect unbuffered STDIN, STDOUT, STDERR to the console
#if !defined(__CYGWIN__)
*stdout = *_fdopen( _open_osfhandle((long)hand, _O_TEXT), "w" );
@@ -1905,11 +1905,11 @@ void CreateConsole()
// open_osfhandle is not in cygwin
*stdout = *fdopen(1, "w" );
*stdin = *fdopen(0, "w" );
- *stderr = *fdopen(2, "w" );
+ *stderr = *fdopen(2, "w" );
#endif
-
- setvbuf( stdin, NULL, _IONBF, 0 );
- setvbuf( stdout, NULL, _IONBF, 0 );
+
+ setvbuf( stdin, NULL, _IONBF, 0 );
+ setvbuf( stdout, NULL, _IONBF, 0 );
setvbuf( stderr, NULL, _IONBF, 0 );
}
@@ -1919,10 +1919,10 @@ void ShowInfo(const char *str)
puts(str);
else {
bool old;
-
+
ReleaseCapture();
_left_button_clicked =_left_button_down = false;
-
+
old = MyShowCursor(true);
if (MessageBoxA(GetActiveWindow(), str, "OpenTTD", MB_ICONINFORMATION | MB_OKCANCEL) == IDCANCEL) {
CreateConsole();
@@ -1960,7 +1960,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLin
argc = ParseCommandLine(GetCommandLine(), argv, lengthof(argv));
#if defined(WIN32_EXCEPTION_TRACKER)
- {
+ {
Win32InitializeExceptions();
}
#endif
@@ -1985,7 +1985,7 @@ void DeterminePaths()
_path.personal_dir = _path.game_data_dir = cfg = malloc(MAX_PATH);
GetCurrentDirectory(MAX_PATH - 1, cfg);
-
+
s = strchr(cfg, 0);
if (s[-1] != '\\') { s[0] = '\\'; s[1] = 0; }
diff --git a/window.c b/window.c
index 575e3fb2d..92dd93b57 100644
--- a/window.c
+++ b/window.c
@@ -1021,7 +1021,7 @@ void MouseLoop()
return;
// only allow zooming in-out in main window, or in viewports
- if ( mousewheel && !(w->flags4 & WF_DISABLE_VP_SCROLL) &&
+ if ( mousewheel && !(w->flags4 & WF_DISABLE_VP_SCROLL) &&
(w->window_class == WC_MAIN_WINDOW || w->window_class == WC_EXTRA_VIEW_PORT) ) {
ZoomInOrOutToCursorWindow(mousewheel < 0,w);
}