summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clear_cmd.c2
-rw-r--r--disaster_cmd.c2
-rw-r--r--economy.c50
-rw-r--r--engine.c5
-rw-r--r--industry_gui.c15
-rw-r--r--landscape.c12
-rw-r--r--main_gui.c6
-rw-r--r--misc.c34
-rw-r--r--npf.c90
-rw-r--r--npf.h1
-rw-r--r--oldloader.c50
-rw-r--r--openttd.c33
-rw-r--r--order_cmd.c3
-rw-r--r--rail.h19
-rw-r--r--rail_cmd.c85
-rw-r--r--road_cmd.c6
-rw-r--r--roadveh_cmd.c109
-rw-r--r--smallmap_gui.c50
-rw-r--r--station_cmd.c30
-rw-r--r--strings.c5
-rw-r--r--table/sprites.h1
-rw-r--r--town_cmd.c32
-rw-r--r--train_cmd.c7
-rw-r--r--train_gui.c18
-rw-r--r--tunnelbridge_cmd.c30
-rw-r--r--unmovable_cmd.c15
-rw-r--r--vehicle.c1
-rw-r--r--vehicle_gui.c16
-rw-r--r--water_cmd.c54
-rw-r--r--window.c3
30 files changed, 379 insertions, 405 deletions
diff --git a/clear_cmd.c b/clear_cmd.c
index 52dd174f7..8c36a7bd7 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -778,7 +778,7 @@ void GenerateClearTile(void)
tile = RandomTileSeed(r);
if (IsTileType(tile, MP_CLEAR)) {
uint j = GB(r, 16, 4) + 5;
- for(;;) {
+ for (;;) {
TileIndex tile_new;
SB(_m[tile].m5, 2, 2, 2);
diff --git a/disaster_cmd.c b/disaster_cmd.c
index aea364ae1..4f3ea40cc 100644
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -246,7 +246,6 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
IsTileType(tile, MP_STATION) &&
IS_BYTE_INSIDE(_m[tile].m5, 8, 0x43) &&
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
-
st = GetStation(_m[tile].m2);
SETBITS(st->airport_flags, RUNWAY_IN_block);
}
@@ -905,7 +904,6 @@ static void Disaster7_Init(void)
for (m = 0; m < 15; m++) {
FOR_ALL_INDUSTRIES(i) {
if (i->xy != 0 && i->type == IT_COAL_MINE && --index < 0) {
-
SetDParam(0, i->town->index);
AddNewsItem(STR_B005_COAL_MINE_SUBSIDENCE_LEAVES,
NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy + TileDiffXY(1, 1), 0);
diff --git a/economy.c b/economy.c
index 725b33c35..988af93d8 100644
--- a/economy.c
+++ b/economy.c
@@ -337,7 +337,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
}
FOR_ALL_VEHICLES(v) {
- if (v->owner == old_player && IS_BYTE_INSIDE(v->type, VEH_Train, VEH_Aircraft+1) ) {
+ if (v->owner == old_player && IS_BYTE_INSIDE(v->type, VEH_Train, VEH_Aircraft + 1)) {
if (new_player == OWNER_SPECTATOR) {
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
@@ -1169,26 +1169,25 @@ static bool CheckSubsidised(Station *from, Station *to, byte cargo_type)
Player *p;
// check if there is an already existing subsidy that applies to us
- for(s=_subsidies; s != endof(_subsidies); s++) {
+ for (s = _subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type == cargo_type &&
s->age >= 12 &&
s->from == from->index &&
- s->to == to->index)
+ s->to == to->index) {
return true;
+ }
}
/* check if there's a new subsidy that applies.. */
- for(s=_subsidies; s != endof(_subsidies); s++) {
+ 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 = GetTown(s->from)->xy;
} else {
xy = (GetIndustry(s->from))->xy;
}
- if (DistanceMax(xy, from->xy) > 9)
- continue;
+ if (DistanceMax(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) {
@@ -1196,9 +1195,7 @@ static bool CheckSubsidised(Station *from, Station *to, byte cargo_type)
} else {
xy = (GetIndustry(s->to))->xy;
}
-
- if (DistanceMax(xy, to->xy) > 9)
- continue;
+ if (DistanceMax(xy, to->xy) > 9) continue;
/* Found a subsidy, change the values to indicate that it's in use */
s->age = 12;
@@ -1215,7 +1212,8 @@ static bool CheckSubsidised(Station *from, Station *to, byte cargo_type)
AddNewsItem(
STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier,
NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0),
- pair.a, pair.b);
+ pair.a, pair.b
+ );
InvalidateWindow(WC_SUBSIDIES_LIST, 0);
return true;
@@ -1281,7 +1279,8 @@ static int32 DeliverGoods(int num_pieces, byte cargo_type, uint16 source, uint16
* already loading the same cargo type
* v = vehicle to load, u = GetFirstInChain(v)
*/
-static bool LoadWait(const Vehicle *v, const Vehicle *u) {
+static bool LoadWait(const Vehicle* v, const Vehicle* u)
+{
const Vehicle *w;
const Vehicle *x;
bool has_any_cargo = false;
@@ -1291,8 +1290,9 @@ static bool LoadWait(const Vehicle *v, const Vehicle *u) {
for (w = u; w != NULL; w = w->next) {
if (w->cargo_count != 0) {
if (v->cargo_type == w->cargo_type &&
- u->last_station_visited == w->cargo_source)
+ u->last_station_visited == w->cargo_source) {
return false;
+ }
has_any_cargo = true;
}
}
@@ -1308,13 +1308,15 @@ static bool LoadWait(const Vehicle *v, const Vehicle *u) {
bool other_has_same_type = false;
for (w = x; w != NULL; w = w->next) {
- if (w->cargo_count < w->cargo_cap && v->cargo_type == w->cargo_type)
+ if (w->cargo_count < w->cargo_cap && v->cargo_type == w->cargo_type) {
has_space_for_same_type = true;
+ }
if (w->cargo_count != 0) {
if (v->cargo_type == w->cargo_type &&
- u->last_station_visited == w->cargo_source)
+ u->last_station_visited == w->cargo_source) {
other_has_same_type = true;
+ }
other_has_any_cargo = true;
}
}
@@ -1375,14 +1377,13 @@ int LoadUnloadVehicle(Vehicle *v)
st->time_since_unload = 0;
v_profit = GetTransportedGoodsIncome(
- v->cargo_count,
- DistanceManhattan(GetStation(v->cargo_source)->xy, GetStation(last_visited)->xy),
- v->cargo_days,
- v->cargo_type) * 3 / 2;
+ v->cargo_count,
+ DistanceManhattan(GetStation(v->cargo_source)->xy, GetStation(last_visited)->xy),
+ v->cargo_days,
+ v->cargo_type) * 3 / 2;
v_profit_total += v_profit;
-
unloading_time += v->cargo_count;
t = GB(ge->waiting_acceptance, 0, 12);
if (t == 0) {
@@ -1404,8 +1405,7 @@ int LoadUnloadVehicle(Vehicle *v)
v->cargo_count = 0;
}
- if (v->cargo_count != 0)
- completely_empty = false;
+ if (v->cargo_count != 0) completely_empty = false;
}
/* don't pick up goods that we unloaded */
@@ -1466,8 +1466,9 @@ int LoadUnloadVehicle(Vehicle *v)
v = u;
- if (v_profit_total > 0)
+ if (v_profit_total > 0) {
ShowFeederIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, v_profit_total);
+ }
if (v->type == VEH_Train) {
// Each platform tile is worth 2 rail vehicles.
@@ -1487,8 +1488,7 @@ int LoadUnloadVehicle(Vehicle *v)
if (result != 0) {
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
- if (result & 2)
- InvalidateWindow(WC_STATION_VIEW, last_visited);
+ if (result & 2) InvalidateWindow(WC_STATION_VIEW, last_visited);
if (profit != 0) {
v->profit_this_year += profit;
diff --git a/engine.c b/engine.c
index ef916d5c7..0ed802637 100644
--- a/engine.c
+++ b/engine.c
@@ -922,13 +922,12 @@ void EnginesDailyLoop(void)
int32 CmdWantEnginePreview(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Engine *e;
- if (!IsEngineIndex(p1)) return CMD_ERROR;
+ if (!IsEngineIndex(p1)) return CMD_ERROR;
e = GetEngine(p1);
if (GetBestPlayer(e->preview_player) != _current_player) return CMD_ERROR;
- if (flags & DC_EXEC)
- AcceptEnginePreview(e, _current_player);
+ if (flags & DC_EXEC) AcceptEnginePreview(e, _current_player);
return 0;
}
diff --git a/industry_gui.c b/industry_gui.c
index 24decb00c..3fd0be363 100644
--- a/industry_gui.c
+++ b/industry_gui.c
@@ -26,7 +26,7 @@ extern void DrawArrowButtons(int x, int y, int state);
static void BuildIndustryWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT:
DrawWindowWidgets(w);
if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) {
@@ -278,7 +278,7 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
// WP(w,vp2_d).data_2 is for the clickline
// WP(w,vp2_d).data_3 is for the click pos (left or right)
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
const Industry *i;
StringID str;
@@ -319,8 +319,9 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
SetDParam(2, i->pct_transported[1] * 100 >> 8);
DrawString(4 + (NEED_ALTERB ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
// Let's put out those buttons..
- if (NEED_ALTERB)
- DrawArrowButtons(5, 137, (WP(w,vp2_d).data_2 == 2 ? WP(w,vp2_d).data_3 : 0));
+ if (NEED_ALTERB) {
+ DrawArrowButtons(5, 137, (WP(w,vp2_d).data_2 == 2 ? WP(w,vp2_d).data_3 : 0));
+ }
}
}
@@ -563,7 +564,7 @@ static void MakeSortedIndustryList(void)
static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
{
- switch(e->event) {
+ switch (e->event) {
case WE_PAINT: {
int n;
uint p;
@@ -604,8 +605,7 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
DrawString(4, 28+n*10, STR_INDUSTRYDIR_ITEM_NOPROD, 0);
}
p++;
- if (++n == w->vscroll.cap)
- break;
+ if (++n == w->vscroll.cap) break;
}
} break;
@@ -672,7 +672,6 @@ static const WindowDesc _industry_directory_desc = {
};
-
void ShowIndustryDirectory(void)
{
/* Industry List */
diff --git a/landscape.c b/landscape.c
index 839b5dbd4..689be3dab 100644
--- a/landscape.c
+++ b/landscape.c
@@ -175,7 +175,7 @@ uint GetPartialZ(int x, int y, int corners)
return z;
}
-uint GetSlopeZ(int x, int y)
+uint GetSlopeZ(int x, int y)
{
TileInfo ti;
@@ -487,8 +487,7 @@ static void GenerateTerrain(int type, int flag)
y = (r >> MapLogX()) & MapMaxY();
- if (x < 2 || y < 2)
- return;
+ if (x < 2 || y < 2) return;
direction = GB(r, 22, 2);
if (direction & 1) {
@@ -524,11 +523,8 @@ static void GenerateTerrain(int type, int flag)
}
}
- if (x + w >= MapMaxX() - 1)
- return;
-
- if (y + h >= MapMaxY() - 1)
- return;
+ if (x + w >= MapMaxX() - 1) return;
+ if (y + h >= MapMaxY() - 1) return;
tile = &_m[TileXY(x, y)];
diff --git a/main_gui.c b/main_gui.c
index 066492711..e36645cb4 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -2214,9 +2214,9 @@ static void StatusBarWndProc(Window *w, WindowEvent *e)
if (w->message.msg) { // true when saving is active
DrawStringCentered(320, 1, STR_SAVING_GAME, 0);
} else if (_do_autosave) {
- DrawStringCentered(320, 1, STR_032F_AUTOSAVE, 0);
+ DrawStringCentered(320, 1, STR_032F_AUTOSAVE, 0);
} else if (_pause) {
- DrawStringCentered(320, 1, STR_0319_PAUSED, 0);
+ DrawStringCentered(320, 1, STR_0319_PAUSED, 0);
} else if (WP(w,def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
// Draw the scrolling news text
if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1))
@@ -2226,7 +2226,7 @@ static void StatusBarWndProc(Window *w, WindowEvent *e)
// This is the default text
SetDParam(0, p->name_1);
SetDParam(1, p->name_2);
- DrawStringCentered(320, 1, STR_02BA, 0);
+ DrawStringCentered(320, 1, STR_02BA, 0);
}
}
diff --git a/misc.c b/misc.c
index 61819cf5d..cc3f08e35 100644
--- a/misc.c
+++ b/misc.c
@@ -140,7 +140,7 @@ void InitializeGame(int mode, uint size_x, uint size_y)
if ((mode & IG_DATE_RESET) == IG_DATE_RESET) {
uint starting = ConvertIntDate(_patches.starting_date);
- if ( starting == (uint)-1) starting = 10958;
+ if (starting == (uint)-1) starting = 10958;
SetDate(starting);
}
@@ -377,10 +377,11 @@ uint ConvertIntDate(uint date)
day = date % 100; date /= 100;
month = date % 100 - 1;
year = date / 100 - 1920;
- } else if (IS_INT_INSIDE(date, 2091, 65536))
+ } else if (IS_INT_INSIDE(date, 2091, 65536)) {
return date;
- else
+ } else {
return (uint)-1;
+ }
// invalid ranges?
if (month >= 12 || !IS_INT_INSIDE(day, 1, 31+1)) return (uint)-1;
@@ -419,7 +420,7 @@ void InitializeLandscapeVariables(bool only_constants)
memcpy(_cargoc.ai_roadveh_start, lpd->road_veh_by_cargo_start,sizeof(lpd->road_veh_by_cargo_start));
memcpy(_cargoc.ai_roadveh_count, lpd->road_veh_by_cargo_count,sizeof(lpd->road_veh_by_cargo_count));
- for(i=0; i!=NUM_CARGO; i++) {
+ for (i = 0; i != NUM_CARGO; i++) {
_cargoc.sprites[i] = lpd->sprites[i];
str = lpd->names[i];
@@ -490,9 +491,9 @@ static void RunVehicleDayProc(uint daytick)
uint i, total = _vehicle_pool.total_items;
for (i = daytick; i < total; i += DAY_TICKS) {
- Vehicle *v = GetVehicle(i);
- if (v->type != 0)
- _on_new_vehicle_day_proc[v->type - 0x10](v);
+ Vehicle* v = GetVehicle(i);
+
+ if (v->type != 0) _on_new_vehicle_day_proc[v->type - 0x10](v);
}
}
@@ -511,8 +512,7 @@ void IncreaseDate(void)
_tick_counter++;
_date_fract++;
- if (_date_fract < DAY_TICKS)
- return;
+ if (_date_fract < DAY_TICKS) return;
_date_fract = 0;
/* yeah, increse day counter and call various daily loops */
@@ -547,8 +547,7 @@ void IncreaseDate(void)
IndustryMonthlyLoop();
StationMonthlyLoop();
#ifdef ENABLE_NETWORK
- if (_network_server)
- NetworkServerMonthlyLoop();
+ if (_network_server) NetworkServerMonthlyLoop();
#endif /* ENABLE_NETWORK */
}
@@ -565,8 +564,7 @@ void IncreaseDate(void)
AircraftYearlyLoop();
ShipsYearlyLoop();
#ifdef ENABLE_NETWORK
- if (_network_server)
- NetworkServerYearlyLoop();
+ if (_network_server) NetworkServerYearlyLoop();
#endif /* ENABLE_NETWORK */
/* check if we reached end of the game (31 dec 2050) */
@@ -574,7 +572,8 @@ void IncreaseDate(void)
ShowEndGameChart();
/* check if we reached 2090 (MAX_YEAR_END_REAL), that's the maximum year. */
} else if (_cur_year == (MAX_YEAR_END + 1)) {
- Vehicle *v;
+ Vehicle* v;
+
_cur_year = MAX_YEAR_END;
_date = 62093;
FOR_ALL_VEHICLES(v) {
@@ -586,8 +585,7 @@ void IncreaseDate(void)
InitTextMessage();
}
- if (_patches.auto_euro)
- CheckSwitchToEuro();
+ if (_patches.auto_euro) CheckSwitchToEuro();
/* XXX: check if year 2050 was reached */
}
@@ -970,8 +968,8 @@ static void Save_CHTS(void)
Cheat* cht = (Cheat*) &_cheats;
Cheat* cht_last = &cht[count];
- SlSetLength(count*2);
- for(; cht != cht_last; cht++) {
+ SlSetLength(count * 2);
+ for (; cht != cht_last; cht++) {
SlWriteByte(cht->been_used);
SlWriteByte(cht->value);
}
diff --git a/npf.c b/npf.c
index a2bb43476..c759bb7a1 100644
--- a/npf.c
+++ b/npf.c
@@ -47,6 +47,7 @@ static uint NPFDistanceTrack(TileIndex t0, TileIndex t1)
return diagTracks * NPF_TILE_LENGTH + straightTracks * NPF_TILE_LENGTH * STRAIGHT_TRACK_LENGTH;
}
+
#if 0
static uint NTPHash(uint key1, uint key2)
{
@@ -70,7 +71,7 @@ static uint NPFHash(uint key1, uint key2)
assert(IsValidTrackdir(key2));
assert(IsValidTile(key1));
- return ((((part1 << NPF_HASH_HALFBITS) | part2)) + (NPF_HASH_SIZE * key2 / TRACKDIR_END)) % NPF_HASH_SIZE;
+ return ((part1 << NPF_HASH_HALFBITS | part2) + (NPF_HASH_SIZE * key2 / TRACKDIR_END)) % NPF_HASH_SIZE;
}
static int32 NPFCalcZero(AyStar* as, AyStarNode* current, OpenListNode* parent)
@@ -116,15 +117,16 @@ static int32 NPFCalcStationOrTileHeuristic(AyStar* as, AyStarNode* current, Open
uint dist;
// for train-stations, we are going to aim for the closest station tile
- if ((as->user_data[NPF_TYPE] == TRANSPORT_RAIL) && (fstd->station_index != -1))
+ if (as->user_data[NPF_TYPE] == TRANSPORT_RAIL && fstd->station_index != -1)
to = CalcClosestStationTile(fstd->station_index, from);
- if (as->user_data[NPF_TYPE] == TRANSPORT_ROAD)
+ if (as->user_data[NPF_TYPE] == TRANSPORT_ROAD) {
/* Since roads only have diagonal pieces, we use manhattan distance here */
dist = DistanceManhattan(from, to) * NPF_TILE_LENGTH;
- else
+ } else {
/* Ships and trains can also go diagonal, so the minimum distance is shorter */
dist = NPFDistanceTrack(from, to);
+ }
DEBUG(npf, 4)("Calculating H for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), dist);
@@ -135,6 +137,7 @@ static int32 NPFCalcStationOrTileHeuristic(AyStar* as, AyStarNode* current, Open
return dist;
}
+
/* Fills AyStarNode.user_data[NPF_TRACKDIRCHOICE] with the chosen direction to
* get here, either getting it from the current choice or from the parent's
* choice */
@@ -147,11 +150,9 @@ static void NPFFillTrackdirChoice(AyStarNode* current, OpenListNode* parent)
current->user_data[NPF_TRACKDIR_CHOICE] = trackdir;
DEBUG(npf, 6)("Saving trackdir: %#x", trackdir);
} else {
- /* We've already made the decision, so just save our parent's
- * decision */
+ /* We've already made the decision, so just save our parent's decision */
current->user_data[NPF_TRACKDIR_CHOICE] = parent->path.node.user_data[NPF_TRACKDIR_CHOICE];
}
-
}
/* Will return the cost of the tunnel. If it is an entry, it will return the
@@ -191,7 +192,7 @@ static uint NPFSlopeCost(AyStarNode* current)
/* get the height of the center of the next tile */
z2 = GetSlopeZ(x+TILE_HEIGHT, y+TILE_HEIGHT);
- if ((z2 - z1) > 1) {
+ if (z2 - z1 > 1) {
/* Slope up */
return _patches.npf_rail_slope_penalty;
}
@@ -263,12 +264,14 @@ static int32 NPFRoadPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare
}
cost = NPF_TILE_LENGTH;
break;
+
case MP_STREET:
cost = NPF_TILE_LENGTH;
/* Increase the cost for level crossings */
if (IsLevelCrossing(tile))
cost += _patches.npf_crossing_penalty;
break;
+
default:
break;
}
@@ -307,22 +310,25 @@ static int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare
}
/* Fall through if above if is false, it is a bridge
* then. We treat that as ordinary rail */
+
case MP_RAILWAY:
cost = _trackdir_length[trackdir]; /* Should be different for diagonal tracks */
break;
+
case MP_STREET: /* Railway crossing */
cost = NPF_TILE_LENGTH;
break;
+
case MP_STATION:
- /* We give a station tile a penalty. Logically we would only
- * want to give station tiles that are not our destination
- * this penalty. This would discourage trains to drive through
- * busy stations. But, we can just give any station tile a
- * penalty, because every possible route will get this penalty
- * exactly once, on its end tile (if it's a station) and it
- * will therefore not make a difference. */
+ /* We give a station tile a penalty. Logically we would only want to give
+ * station tiles that are not our destination this penalty. This would
+ * discourage trains to drive through busy stations. But, we can just
+ * give any station tile a penalty, because every possible route will get
+ * this penalty exactly once, on its end tile (if it's a station) and it
+ * will therefore not make a difference. */
cost = NPF_TILE_LENGTH + _patches.npf_rail_station_penalty;
break;
+
default:
break;
}
@@ -340,11 +346,12 @@ static int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare
/* Is this a presignal exit or combo? */
SignalType sigtype = GetSignalType(tile, TrackdirToTrack(trackdir));
- if (sigtype == SIGTYPE_EXIT || sigtype == SIGTYPE_COMBO)
+ if (sigtype == SIGTYPE_EXIT || sigtype == SIGTYPE_COMBO) {
/* Penalise exit and combo signals differently (heavier) */
cost += _patches.npf_rail_firstred_exit_penalty;
- else
+ } else {
cost += _patches.npf_rail_firstred_penalty;
+ }
}
/* Record the state of this signal */
NPFSetFlag(current, NPF_FLAG_LAST_SIGNAL_RED, true);
@@ -372,14 +379,12 @@ static int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare
//TODO, with realistic acceleration, also the amount of straight track between
// curves should be taken into account, as this affects the speed limit.
-
/* Check for reverse in depot */
if (IsTileDepotType(tile, TRANSPORT_RAIL) && as->EndNodeCheck(as, &new_node) != AYSTAR_FOUND_END_NODE) {
/* Penalise any depot tile that is not the last tile in the path. This
* _should_ penalise every occurence of reversing in a depot (and only
* that) */
cost += _patches.npf_rail_depot_reverse_penalty;
-
}
/* Check for occupied track */
@@ -397,10 +402,11 @@ static int32 NPFFindDepot(AyStar* as, OpenListNode *current)
/* It's not worth caching the result with NPF_FLAG_IS_TARGET here as below,
* since checking the cache not that much faster than the actual check */
- if (IsTileDepotType(tile, as->user_data[NPF_TYPE]))
+ if (IsTileDepotType(tile, as->user_data[NPF_TYPE])) {
return AYSTAR_FOUND_END_NODE;
- else
+ } else {
return AYSTAR_DONE;
+ }
}
/* Will find a station identified using the NPFFindStationOrTileData */
@@ -446,14 +452,13 @@ static void NPFSaveTargetData(AyStar* as, OpenListNode* current)
*/
static bool VehicleMayEnterTile(Owner owner, TileIndex tile, DiagDirection enterdir)
{
- if (
- IsTileType(tile, MP_RAILWAY) /* Rail tile (also rail depot) */
- || IsTrainStationTile(tile) /* Rail station tile */
- || IsTileDepotType(tile, TRANSPORT_ROAD) /* Road depot tile */
- || IsRoadStationTile(tile) /* Road station tile */
- || IsTileDepotType(tile, TRANSPORT_WATER) /* Water depot tile */
- )
+ if (IsTileType(tile, MP_RAILWAY) || /* Rail tile (also rail depot) */
+ IsTrainStationTile(tile) || /* Rail station tile */
+ IsTileDepotType(tile, TRANSPORT_ROAD) || /* Road depot tile */
+ IsRoadStationTile(tile) || /* Road station tile */
+ IsTileDepotType(tile, TRANSPORT_WATER)) { /* Water depot tile */
return IsTileOwner(tile, owner); /* You need to own these tiles entirely to use them */
+ }
switch (GetTileType(tile)) {
case MP_STREET:
@@ -461,6 +466,7 @@ static bool VehicleMayEnterTile(Owner owner, TileIndex tile, DiagDirection enter
if (IsLevelCrossing(tile) && GetCrossingTransportType(tile, TrackdirToTrack(DiagdirToDiagTrackdir(enterdir))) == TRANSPORT_RAIL)
return IsTileOwner(tile, owner); /* Railway needs owner check, while the street is public */
break;
+
case MP_TUNNELBRIDGE:
#if 0
/* OPTIMISATION: If we are on the middle of a bridge, we will not do the cpu
@@ -475,13 +481,13 @@ static bool VehicleMayEnterTile(Owner owner, TileIndex tile, DiagDirection enter
}
/* if we were on a railway middle part, we are now at a railway bridge ending */
#endif
- if (
- (_m[tile].m5 & 0xFC) == 0 /* railway tunnel */
- || (_m[tile].m5 & 0xC6) == 0x80 /* railway bridge ending */
- || ((_m[tile].m5 & 0xF8) == 0xE0 && GB(_m[tile].m5, 0, 1) != (enterdir & 0x1)) /* railway under bridge */
- )
+ if ((_m[tile].m5 & 0xFC) == 0 || /* railway tunnel */
+ (_m[tile].m5 & 0xC6) == 0x80 || /* railway bridge ending */
+ ((_m[tile].m5 & 0xF8) == 0xE0 && GB(_m[tile].m5, 0, 1) != (enterdir & 0x1))) { /* railway under bridge */
return IsTileOwner(tile, owner);
+ }
break;
+
default:
break;
}
@@ -510,7 +516,8 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
DEBUG(npf, 4)("Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile);
/* Find dest tile */
- if (IsTileType(src_tile, MP_TUNNELBRIDGE) && GB(_m[src_tile].m5, 4, 4) == 0 &&
+ if (IsTileType(src_tile, MP_TUNNELBRIDGE) &&
+ GB(_m[src_tile].m5, 4, 4) == 0 &&
(DiagDirection)GB(_m[src_tile].m5, 0, 2) == src_exitdir) {
/* This is a tunnel. We know this tunnel is our type,
* otherwise we wouldn't have got here. It is also facing us,
@@ -525,16 +532,17 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
DiagDirection exitdir;
/* Find out the exit direction first */
- if (IsRoadStationTile(src_tile))
+ if (IsRoadStationTile(src_tile)) {
exitdir = GetRoadStationDir(src_tile);
- else /* Train or road depot. Direction is stored the same for both, in map5 */
+ } else { /* Train or road depot. Direction is stored the same for both, in map5 */
exitdir = GetDepotDirection(src_tile, type);
+ }
/* Let's see if were headed the right way into the depot, and reverse
* otherwise (only for trains, since only with trains you can
* (sometimes) reach tiles after reversing that you couldn't reach
* without reversing. */
- if (src_trackdir == DiagdirToDiagTrackdir(ReverseDiagdir(exitdir)) && type == TRANSPORT_RAIL)
+ if (src_trackdir == DiagdirToDiagTrackdir(ReverseDiagdir(exitdir)) && type == TRANSPORT_RAIL) {
/* We are headed inwards. We can only reverse here, so we'll not
* consider this direction, but jump ahead to the reverse direction.
* It would be nicer to return one neighbour here (the reverse
@@ -543,6 +551,7 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
* the code layout is cleaner this way, we will just pretend we are
* reversed already */
src_trackdir = ReverseTrackdir(src_trackdir);
+ }
}
/* This a normal tile, a bridge, a tunnel exit, etc. */
dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDir(TrackdirToExitdir(src_trackdir)));
@@ -577,10 +586,11 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
if (type != TRANSPORT_WATER && (IsRoadStationTile(dst_tile) || IsTileDepotType(dst_tile, type))){
/* Road stations and road and train depots return 0 on GTTS, so we have to do this by hand... */
DiagDirection exitdir;
- if (IsRoadStationTile(dst_tile))
+ if (IsRoadStationTile(dst_tile)) {
exitdir = GetRoadStationDir(dst_tile);
- else /* Road or train depot */
+ } else { /* Road or train depot */
exitdir = GetDepotDirection(dst_tile, type);
+ }
/* Find the trackdirs that are available for a depot or station with this
* orientation. They are only "inwards", since we are reaching this tile
* from some other tile. This prevents vehicles driving into depots from
@@ -862,7 +872,7 @@ void NPFFillWithOrderData(NPFFindStationOrTileData* fstd, Vehicle* v)
* dest_tile, not just any stop of that station.
* So only for train orders to stations we fill fstd->station_index, for all
* others only dest_coords */
- if ((v->current_order.type) == OT_GOTO_STATION && v->type == VEH_Train) {
+ if (v->current_order.type == OT_GOTO_STATION && v->type == VEH_Train) {
fstd->station_index = v->current_order.station;
/* Let's take the closest tile of the station as our target for trains */
fstd->dest_coords = CalcClosestStationTile(v->current_order.station, v->tile);
diff --git a/npf.h b/npf.h
index 743a439e9..380f29fa3 100644
--- a/npf.h
+++ b/npf.h
@@ -64,6 +64,7 @@ typedef struct NPFFoundTargetData { /* Meant to be stored in AyStar.userpath */
* station for the given transport type. See the declaration of
* NPFFoundTargetData above for the meaning of the result. */
NPFFoundTargetData NPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailType railtype);
+
/* Will search as above, but with two start nodes, the second being the
* reverse. Look at the NPF_FLAG_REVERSE flag in the result node to see which
* direction was taken (NPFGetBit(result.node, NPF_FLAG_REVERSE)) */
diff --git a/oldloader.c b/oldloader.c
index 81a7fc4e8..57b9f5ec5 100644
--- a/oldloader.c
+++ b/oldloader.c
@@ -178,16 +178,15 @@ static bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
case OC_CHUNK:
/* Call function, with 'i' as parameter to tell which item we
- are going to read */
- if (!chunk->proc(ls, i))
- return false;
+ * are going to read */
+ if (!chunk->proc(ls, i)) return false;
break;
case OC_ASSERT:
DEBUG(oldloader, 4)("[OldLoader] Assert point: %x / %x", ls->total_read, chunk->offset + _bump_assert_value);
- if (ls->total_read != chunk->offset + _bump_assert_value)
+ if (ls->total_read != chunk->offset + _bump_assert_value) {
ls->failed = true;
-
+ }
break;
}
@@ -345,8 +344,7 @@ static void FixOldTowns(void)
/* Convert town-names if needed */
FOR_ALL_TOWNS(town) {
- if (town->xy == 0)
- continue;
+ if (town->xy == 0) continue;
if (IS_INT_INSIDE(town->townnametype, 0x20C1, 0x20C3)) {
town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _opt.town_name;
@@ -393,26 +391,22 @@ static void FixOldStations(void)
static void FixOldVehicles(void)
{
/* Check for shared orders, and link them correctly */
- {
- Vehicle *v;
+ Vehicle* v;
- FOR_ALL_VEHICLES(v) {
- Vehicle *u;
+ FOR_ALL_VEHICLES(v) {
+ Vehicle* u;
- if (v->type == 0)
- continue;
+ if (v->type == 0) continue;
- FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
- if (u->type == 0)
- continue;
+ FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
+ if (u->type == 0) continue;
- /* If a vehicle has the same orders, add the link to eachother
- in both vehicles */
- if (v->orders == u->orders) {
- v->next_shared = u;
- u->prev_shared = v;
- break;
- }
+ /* If a vehicle has the same orders, add the link to eachother
+ * in both vehicles */
+ if (v->orders == u->orders) {
+ v->next_shared = u;
+ u->prev_shared = v;
+ break;
}
}
}
@@ -461,8 +455,7 @@ static void ReadTTDPatchFlags(void)
{
int i;
- if (_read_ttdpatch_flags)
- return;
+ if (_read_ttdpatch_flags) return;
_read_ttdpatch_flags = true;
@@ -470,8 +463,7 @@ static void ReadTTDPatchFlags(void)
_old_vehicle_multipler = _old_map3[0];
/* Somehow.... there was an error in some savegames, so 0 becomes 1
and 1 becomes 2. The rest of the values are okay */
- if (_old_vehicle_multipler < 2)
- _old_vehicle_multipler++;
+ if (_old_vehicle_multipler < 2) _old_vehicle_multipler++;
/* TTDPatch incraeses the Vehicle-part in the middle of the game,
so if the multipler is anything else but 1, the assert fails..
@@ -1025,6 +1017,7 @@ static const OldChunks player_chunk[] = {
OCL_END()
};
+
static bool LoadOldPlayer(LoadgameState *ls, int num)
{
Player *p = GetPlayer(num);
@@ -1340,8 +1333,7 @@ static const OldChunks engine_chunk[] = {
};
static bool LoadOldEngine(LoadgameState *ls, int num)
{
- if (!LoadChunk(ls, GetEngine(num), engine_chunk))
- return false;
+ if (!LoadChunk(ls, GetEngine(num), engine_chunk)) return false;
/* Make sure wagons are marked as do-not-age */
if ((num >= 27 && num < 54) || (num >= 57 && num < 84) || (num >= 89 && num < 116))
diff --git a/openttd.c b/openttd.c
index e393b6c0a..602e619cd 100644
--- a/openttd.c
+++ b/openttd.c
@@ -335,7 +335,7 @@ int ttd_main(int argc, char* argv[])
MyGetOptInit(&mgo, argc-1, argv+1, optformat);
while ((i = MyGetOpt(&mgo)) != -1) {
- switch(i) {
+ switch (i) {
case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break;
case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break;
case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break;
@@ -412,8 +412,7 @@ int ttd_main(int argc, char* argv[])
if (resolution[0]) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
if (startdate != (uint)-1) _patches.starting_date = startdate;
- if (_dedicated_forks && !dedicated)
- _dedicated_forks = false;
+ if (_dedicated_forks && !dedicated) _dedicated_forks = false;
// enumerate language files
InitializeLanguagePacks();
@@ -455,8 +454,7 @@ int ttd_main(int argc, char* argv[])
_opt_ptr = &_opt_newgame;
/* XXX - ugly hack, if diff_level is 9, it means we got no setting from the config file */
- if (_opt_newgame.diff_level == 9)
- SetDifficultyLevel(0, &_opt_newgame);
+ if (_opt_newgame.diff_level == 9) SetDifficultyLevel(0, &_opt_newgame);
// initialize the ingame console
IConsoleInit();
@@ -466,7 +464,7 @@ int ttd_main(int argc, char* argv[])
GenerateWorld(GW_EMPTY, 64, 64); // Make the viewport initialization happy
#ifdef ENABLE_NETWORK
- if ((network) && (_network_available)) {
+ if (network && _network_available) {
if (network_conn != NULL) {
const char *port = NULL;
const char *player = NULL;
@@ -732,17 +730,19 @@ void SwitchMode(int new_mode)
case SM_NEWGAME: /* New Game --> 'Random game' */
#ifdef ENABLE_NETWORK
- if (_network_server)
+ if (_network_server) {
snprintf(_network_game_info.map_name, NETWORK_NAME_LENGTH, "Random Map");
+ }
#endif /* ENABLE_NETWORK */
MakeNewGame();
break;
case SM_START_SCENARIO: /* New Game --> Choose one of the preset scenarios */
- #ifdef ENABLE_NETWORK
- if (_network_server)
- snprintf(_network_game_info.map_name, NETWORK_NAME_LENGTH, "%s (Loaded scenario)", _file_to_saveload.title);
- #endif /* ENABLE_NETWORK */
+#ifdef ENABLE_NETWORK
+ if (_network_server) {
+ snprintf(_network_game_info.map_name, NETWORK_NAME_LENGTH, "%s (Loaded scenario)", _file_to_saveload.title);
+ }
+#endif /* ENABLE_NETWORK */
StartScenario();
break;
@@ -756,8 +756,9 @@ void SwitchMode(int new_mode)
_local_player = 0;
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // decrease pause counter (was increased from opening load dialog)
#ifdef ENABLE_NETWORK
- if (_network_server)
+ if (_network_server) {
snprintf(_network_game_info.map_name, NETWORK_NAME_LENGTH, "%s (Loaded game)", _file_to_saveload.title);
+ }
#endif /* ENABLE_NETWORK */
}
break;
@@ -785,7 +786,6 @@ void SwitchMode(int new_mode)
break;
}
-
case SM_MENU: /* Switch to game intro menu */
LoadIntroGame();
break;
@@ -799,15 +799,16 @@ void SwitchMode(int new_mode)
break;
case SM_GENRANDLAND: /* Generate random land within scenario editor */
- GenerateWorld(GW_RANDOM, 1<<_patches.map_x, 1<<_patches.map_y);
+ GenerateWorld(GW_RANDOM, 1 << _patches.map_x, 1 << _patches.map_y);
// XXX: set date
_local_player = OWNER_NONE;
MarkWholeScreenDirty();
break;
}
- if (_switch_mode_errorstr != INVALID_STRING_ID)
- ShowErrorMessage(INVALID_STRING_ID,_switch_mode_errorstr,0,0);
+ if (_switch_mode_errorstr != INVALID_STRING_ID) {
+ ShowErrorMessage(INVALID_STRING_ID, _switch_mode_errorstr, 0, 0);
+ }
}
diff --git a/order_cmd.c b/order_cmd.c
index 9248d1519..5ab21ce76 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -650,8 +650,7 @@ int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* Link this vehicle in the shared-list */
dst->next_shared = src->next_shared;
dst->prev_shared = src;
- if (src->next_shared != NULL)
- src->next_shared->prev_shared = dst;
+ if (src->next_shared != NULL) src->next_shared->prev_shared = dst;
src->next_shared = dst;
InvalidateVehicleOrder(dst);
diff --git a/rail.h b/rail.h
index c2dfbf207..c6700eb0e 100644
--- a/rail.h
+++ b/rail.h
@@ -497,7 +497,9 @@ static inline bool IsDiagonalTrackdir(Trackdir trackdir) { return IsDiagonalTrac
static inline bool HasSignalOnTrack(TileIndex tile, Track track)
{
assert(IsValidTrack(track));
- return ((GetRailTileType(tile) == RAIL_TYPE_SIGNALS) && ((_m[tile].m3 & SignalOnTrack(track)) != 0));
+ return
+ GetRailTileType(tile) == RAIL_TYPE_SIGNALS &&
+ (_m[tile].m3 & SignalOnTrack(track)) != 0;
}
/**
@@ -510,7 +512,9 @@ static inline bool HasSignalOnTrack(TileIndex tile, Track track)
static inline bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
{
assert (IsValidTrackdir(trackdir));
- return (GetRailTileType(tile) == RAIL_TYPE_SIGNALS) && (_m[tile].m3 & SignalAlongTrackdir(trackdir));
+ return
+ GetRailTileType(tile) == RAIL_TYPE_SIGNALS &&
+ _m[tile].m3 & SignalAlongTrackdir(trackdir);
}
/**
@@ -523,7 +527,8 @@ static inline SignalState GetSignalState(TileIndex tile, Trackdir trackdir)
{
assert(IsValidTrackdir(trackdir));
assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)));
- return ((_m[tile].m2 & SignalAlongTrackdir(trackdir))?SIGNAL_STATE_GREEN:SIGNAL_STATE_RED);
+ return _m[tile].m2 & SignalAlongTrackdir(trackdir) ?
+ SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
}
/**
@@ -552,7 +557,7 @@ static inline SignalType GetSignalType(TileIndex tile, Track track)
static inline bool HasSemaphores(TileIndex tile, Track track)
{
assert(IsValidTrack(track));
- return (_m[tile].m4 & SIG_SEMAPHORE_MASK);
+ return _m[tile].m4 & SIG_SEMAPHORE_MASK;
}
/**
@@ -580,8 +585,7 @@ static inline bool IsLevelCrossing(TileIndex tile)
static inline TransportType GetCrossingTransportType(TileIndex tile, Track track)
{
/* XXX: Nicer way to write this? */
- switch(track)
- {
+ switch (track) {
/* When map5 bit 3 is set, the road runs in the y direction (DIAG2) */
case TRACK_DIAG1:
return (HASBIT(_m[tile].m5, 3) ? TRANSPORT_RAIL : TRANSPORT_ROAD);
@@ -627,8 +631,7 @@ static inline bool IsCompatibleRail(RailType enginetype, RailType tiletype)
static inline bool TracksOverlap(TrackBits bits)
{
/* With no, or only one track, there is no overlap */
- if (bits == 0 || KILL_FIRST_BIT(bits) == 0)
- return false;
+ if (bits == 0 || KILL_FIRST_BIT(bits) == 0) return false;
/* We know that there are at least two tracks present. When there are more
* than 2 tracks, they will surely overlap. When there are two, they will
* always overlap unless they are lower & upper or right & left. */
diff --git a/rail_cmd.c b/rail_cmd.c
index 842ace82d..33316a772 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -216,10 +216,19 @@ uint GetRailFoundation(uint tileh, uint bits)
if ((~_valid_tileh_slopes[1][tileh] & bits) == 0)
return tileh;
- if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) && (bits == TRACK_BIT_DIAG1 || (i++, bits == TRACK_BIT_DIAG2)))
+ if ((
+ (i = 0, tileh == 1) ||
+ (i += 2, tileh == 2) ||
+ (i += 2, tileh == 4) ||
+ (i += 2, tileh == 8)
+ ) && (
+ bits == TRACK_BIT_DIAG1 ||
+ (i++, bits == TRACK_BIT_DIAG2)
+ )) {
return i + 15;
-
- return 0;
+ } else {
+ return 0;
+ }
}
@@ -526,8 +535,12 @@ static int32 ValidateAutoDrag(Trackdir *trackdir, int x, int y, int ex, int ey)
}
// validate the direction
- while (((trdx <= 0) && (dx > 0)) || ((trdx >= 0) && (dx < 0)) ||
- ((trdy <= 0) && (dy > 0)) || ((trdy >= 0) && (dy < 0))) {
+ while (
+ (trdx <= 0 && dx > 0) ||
+ (trdx >= 0 && dx < 0) ||
+ (trdy <= 0 && dy > 0) ||
+ (trdy >= 0 && dy < 0)
+ ) {
if (!HASBIT(*trackdir, 3)) { // first direction is invalid, try the other
SETBIT(*trackdir, 3); // reverse the direction
trdx = -trdx;
@@ -541,7 +554,7 @@ static int32 ValidateAutoDrag(Trackdir *trackdir, int x, int y, int ex, int ey)
if (!IsDiagonalTrackdir(*trackdir)) {
trdx = _railbit.xinc[*trackdir];
trdy = _railbit.yinc[*trackdir];
- if ((abs(dx) != abs(dy)) && (abs(dx) + abs(trdy) != abs(dy) + abs(trdx)))
+ if (abs(dx) != abs(dy) && abs(dx) + abs(trdy) != abs(dy) + abs(trdx))
return CMD_ERROR;
}
@@ -680,8 +693,7 @@ int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
d->xy = tile;
d->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
- SetSignalsOnBothDir(tile, (p2&1) ? 2 : 1);
-
+ SetSignalsOnBothDir(tile, (p2 & 1) ? 2 : 1);
}
return cost + _price.build_train_depot;
@@ -892,7 +904,7 @@ static int32 CmdSignalTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32
if (!IsDiagonalTrackdir(trackdir)) trackdir ^= 1;
}
- return (error) ? CMD_ERROR : total_cost;
+ return error ? CMD_ERROR : total_cost;
}
/** Build signals on a stretch of track.
@@ -1071,12 +1083,12 @@ static int32 ClearTile_Track(TileIndex tile, byte flags)
switch (GetRailTileType(tile)) {
/* XXX: Why the fuck do we remove these thow signals first? */
case RAIL_TYPE_SIGNALS:
- if(HasSignalOnTrack(tile, TRACK_DIAG1)) {
+ if (HasSignalOnTrack(tile, TRACK_DIAG1)) {
ret = DoCommandByTile(tile, TRACK_DIAG1, 0, flags, CMD_REMOVE_SIGNALS);
if (CmdFailed(ret)) return CMD_ERROR;
cost += ret;
}
- if(HasSignalOnTrack(tile, TRACK_LOWER)) {
+ if (HasSignalOnTrack(tile, TRACK_LOWER)) {
ret = DoCommandByTile(tile, TRACK_LOWER, 0, flags, CMD_REMOVE_SIGNALS);
if (CmdFailed(ret)) return CMD_ERROR;
cost += ret;
@@ -1152,9 +1164,9 @@ static const SpriteID _signal_base_sprites[16] = {
// used to determine the side of the road for the signal
static const byte _signal_position[24] = {
/* original: left side position */
- 0x58,0x1E,0xE1,0xB9,0x01,0xA3,0x4B,0xEE,0x3B,0xD4,0x43,0xBD,
+ 0x58, 0x1E, 0xE1, 0xB9, 0x01, 0xA3, 0x4B, 0xEE, 0x3B, 0xD4, 0x43, 0xBD,
/* patch: ride side position */
- 0x1E,0xAC,0x64,0xE1,0x4A,0x10,0xEE,0xC5,0xDB,0x34,0x4D,0xB3
+ 0x1E, 0xAC, 0x64, 0xE1, 0x4A, 0x10, 0xEE, 0xC5, 0xDB, 0x34, 0x4D, 0xB3
};
static void DrawSignalHelper(const TileInfo *ti, byte condition, uint32 image_and_pos)
@@ -1176,7 +1188,7 @@ static void DrawTrackFence_NW(const TileInfo *ti)
uint32 image = 0x515;
if (ti->tileh != 0) image = (ti->tileh & 2) ? 0x519 : 0x51B;
AddSortableSpriteToDraw(image | _drawtile_track_palette,
- ti->x, ti->y+1, 16, 1, 4, ti->z);
+ ti->x, ti->y + 1, 16, 1, 4, ti->z);
}
static void DrawTrackFence_SE(const TileInfo *ti)
@@ -1184,7 +1196,7 @@ static void DrawTrackFence_SE(const TileInfo *ti)
uint32 image = 0x515;
if (ti->tileh != 0) image = (ti->tileh & 2) ? 0x519 : 0x51B;
AddSortableSpriteToDraw(image | _drawtile_track_palette,
- ti->x, ti->y+15, 16, 1, 4, ti->z);
+ ti->x, ti->y + 15, 16, 1, 4, ti->z);
}
static void DrawTrackFence_NW_SE(const TileInfo *ti)
@@ -1198,7 +1210,7 @@ static void DrawTrackFence_NE(const TileInfo *ti)
uint32 image = 0x516;
if (ti->tileh != 0) image = (ti->tileh & 2) ? 0x51A : 0x51C;
AddSortableSpriteToDraw(image | _drawtile_track_palette,
- ti->x+1, ti->y, 1, 16, 4, ti->z);
+ ti->x + 1, ti->y, 1, 16, 4, ti->z);
}
static void DrawTrackFence_SW(const TileInfo *ti)
@@ -1206,7 +1218,7 @@ static void DrawTrackFence_SW(const TileInfo *ti)
uint32 image = 0x516;
if (ti->tileh != 0) image = (ti->tileh & 2) ? 0x51A : 0x51C;
AddSortableSpriteToDraw(image | _drawtile_track_palette,
- ti->x+15, ti->y, 1, 16, 4, ti->z);
+ ti->x + 15, ti->y, 1, 16, 4, ti->z);
}
static void DrawTrackFence_NE_SW(const TileInfo *ti)
@@ -1277,10 +1289,11 @@ static DetailedTrackProc* const _detailed_track_proc[] = {
DetTrackDrawProc_Null,
};
-static void DrawSpecialBuilding(uint32 image, uint32 offset,
- const TileInfo* ti,
- byte x, byte y, byte z,
- byte xsize, byte ysize, byte zsize)
+static void DrawSpecialBuilding(
+ uint32 image, uint32 offset,
+ const TileInfo* ti,
+ byte x, byte y, byte z,
+ byte xsize, byte ysize, byte zsize)
{
if (image & PALETTE_MODIFIER_COLOR) image |= _drawtile_track_palette;
image += offset;
@@ -1475,7 +1488,8 @@ static void DrawTile_Track(TileInfo *ti)
// adjust ground tile for desert
// (don't adjust for arctic depots, because snow in depots looks weird)
// type >= 4 means waypoints
- if ((_m[ti->tile].m4 & RAIL_MAP2LO_GROUND_MASK) == RAIL_GROUND_ICE_DESERT && (_opt.landscape == LT_DESERT || type >= 4)) {
+ if ((_m[ti->tile].m4 & RAIL_MAP2LO_GROUND_MASK) == RAIL_GROUND_ICE_DESERT &&
+ (_opt.landscape == LT_DESERT || type >= 4)) {
if (image != SPR_FLAT_GRASS_TILE) {
image += rti->snow_offset; // tile with tracks
} else {
@@ -1486,9 +1500,11 @@ static void DrawTile_Track(TileInfo *ti)
DrawGroundSprite(image);
for (; drss->image != 0; drss++) {
- DrawSpecialBuilding(drss->image, type < 4 ? rti->total_offset : 0, ti,
- drss->subcoord_x, drss->subcoord_y, 0,
- drss->width, drss->height, 0x17);
+ DrawSpecialBuilding(
+ drss->image, type < 4 ? rti->total_offset : 0, ti,
+ drss->subcoord_x, drss->subcoord_y, 0,
+ drss->width, drss->height, 0x17
+ );
}
}
}
@@ -1693,7 +1709,7 @@ static void SetSignalsAfterProc(TrackPathFinder *tpf)
return;
}
/* Goto the next item */
- } while ((offs=link->next) != 0xFFFF);
+ } while ((offs = link->next) != 0xFFFF);
}
}
}
@@ -1725,7 +1741,7 @@ static void ChangeSignalStates(SetSignalsData *ssd)
int ex = ssd->presignal_exits, exfree = ssd->presignal_exits_free;
// subtract for dual combo signals so they don't count themselves
- if (_m[tile].m4&2 && HasSignalOnTrackdir(tile, ssd->bit[i])) {
+ if (_m[tile].m4 & 2 && HasSignalOnTrackdir(tile, ssd->bit[i])) {
ex--;
if (GetSignalState(tile, ssd->bit[i]) != SIGNAL_STATE_RED) exfree--;
}
@@ -1738,16 +1754,14 @@ static void ChangeSignalStates(SetSignalsData *ssd)
if (ssd->stop) {
make_red:
// turn red
- if ( (bit&m2) == 0 )
- continue;
+ if ((bit & m2) == 0) continue;
} else {
// turn green
- if ( (bit&m2) != 0 )
- continue;
+ if ((bit & m2) != 0) continue;
}
/* Update signals on the other side of this exit-combo signal; it changed. */
- if (_m[tile].m4 & 2 ) {
+ if (_m[tile].m4 & 2) {
if (ssd->cur_stack != NUM_SSD_STACK) {
ssd->next_tile[ssd->cur_stack] = tile;
ssd->next_dir[ssd->cur_stack] = _dir_from_track[ssd->bit[i]];
@@ -1772,7 +1786,7 @@ bool UpdateSignalsOnSegment(TileIndex tile, byte direction)
ssd.cur_stack = 0;
direction >>= 1;
- for(;;) {
+ for (;;) {
// go through one segment and update all signals pointing into that segment.
ssd.cur = ssd.presignal_exits = ssd.presignal_exits_free = 0;
ssd.has_presignal = false;
@@ -1812,6 +1826,7 @@ static uint GetSlopeZ_Track(const TileInfo* ti)
if (ti->tileh != 0) {
if ((ti->map5 & 0x80) == 0) {
uint f = GetRailFoundation(ti->tileh, ti->map5 & 0x3F);
+
if (f != 0) {
if (f < 15) {
// leveled foundation
@@ -1824,7 +1839,7 @@ static uint GetSlopeZ_Track(const TileInfo* ti)
// depot or waypoint
return z + 8;
}
- return GetPartialZ(ti->x&0xF, ti->y&0xF, th) + z;
+ return GetPartialZ(ti->x & 0xF, ti->y & 0xF, th) + z;
}
return z;
}
@@ -2123,7 +2138,7 @@ static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
} else if (fract_coord_leave == fract_coord) {
if (_leave_directions[dir] == v->direction) {
/* leave the depot? */
- if ((v=v->next) != NULL) {
+ if ((v = v->next) != NULL) {
v->vehstatus &= ~VS_HIDDEN;
v->u.rail.track = _depot_track_mask[dir];
assert(v->u.rail.track);
diff --git a/road_cmd.c b/road_cmd.c
index 5de592401..d11689eea 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -39,14 +39,14 @@ static bool HasTileRoadAt(TileIndex tile, int i)
b = (b&8)?5:10;
} else if ((b & 0xF0) == 0x20) {
return (~b & 3) == i;
- } else
+ } else {
return false;
+ }
break;
case MP_STATION:
b = _m[tile].m5;
- if (!IS_BYTE_INSIDE(b, 0x43, 0x43+8))
- return false;
+ if (!IS_BYTE_INSIDE(b, 0x43, 0x43 + 8)) return false;
return ((~(b - 0x43) & 3) == i);
case MP_TUNNELBRIDGE:
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index e75055427..4f7abea20 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -499,7 +499,7 @@ static void RoadVehIsCrashed(Vehicle *v)
if (v->u.road.crashed_ctr == 2) {
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
} else if (v->u.road.crashed_ctr <= 45) {
- if ((v->tick_counter&7)==0)
+ if ((v->tick_counter & 7) == 0)
RoadVehSetRandomDirection(v);
} else if (v->u.road.crashed_ctr >= 2220) {
RoadVehDelete(v);
@@ -526,11 +526,10 @@ static void RoadVehCrash(Vehicle *v)
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
pass = 1;
- if (v->cargo_type == 0)
- pass += v->cargo_count;
+ if (v->cargo_type == 0) pass += v->cargo_count;
v->cargo_count = 0;
- SetDParam(0, pass);
+ SetDParam(0, pass);
AddNewsItem(
(pass == 1) ?
STR_9031_ROAD_VEHICLE_CRASH_DRIVER : STR_9032_ROAD_VEHICLE_CRASH_DIE,
@@ -546,14 +545,11 @@ static void RoadVehCheckTrainCrash(Vehicle *v)
{
TileIndex tile;
- if (v->u.road.state == 255)
- return;
+ if (v->u.road.state == 255) return;
tile = v->tile;
- // Make sure it's a road/rail crossing
- if (!IsTileType(tile, MP_STREET) || !IsLevelCrossing(tile))
- return;
+ if (!IsTileType(tile, MP_STREET) || !IsLevelCrossing(tile)) return;
if (VehicleFromPos(tile, v, (VehicleFromPosProc*)EnumCheckRoadVehCrashTrain) != NULL)
RoadVehCrash(v);
@@ -621,11 +617,11 @@ static void ProcessRoadVehOrder(Vehicle *v)
if (order->type == v->current_order.type &&
order->flags == v->current_order.flags &&
- order->station == v->current_order.station)
+ order->station == v->current_order.station) {
return;
+ }
v->current_order = *order;
-
v->dest_tile = 0;
if (order->type == OT_GOTO_STATION) {
@@ -799,7 +795,7 @@ static void RoadVehArrivesAt(const Vehicle* v, Station* st)
static bool RoadVehAccelerate(Vehicle *v)
{
- uint spd = v->cur_speed + 1 + ((v->u.road.overtaking != 0)?1:0);
+ uint spd = v->cur_speed + 1 + (v->u.road.overtaking != 0 ? 1 : 0);
byte t;
// Clamp
@@ -808,19 +804,17 @@ static bool RoadVehAccelerate(Vehicle *v)
//updates statusbar only if speed have changed to save CPU time
if (spd != v->cur_speed) {
v->cur_speed = spd;
- if (_patches.vehicle_speed)
+ if (_patches.vehicle_speed) {
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
+ }
}
// Decrease somewhat when turning
- if (!(v->direction&1))
- spd = spd * 3 >> 2;
+ if (!(v->direction & 1)) spd = spd * 3 >> 2;
- if (spd == 0)
- return false;
+ if (spd == 0) return false;
- if ((byte)++spd == 0)
- return true;
+ if ((byte)++spd == 0) return true;
v->progress = (t = v->progress) - (byte)spd;
@@ -890,9 +884,10 @@ static void RoadVehCheckOvertake(Vehicle *v, Vehicle *u)
od.u = u;
if (u->max_speed >= v->max_speed &&
- !(u->vehstatus&VS_STOPPED) &&
- u->cur_speed != 0)
- return;
+ !(u->vehstatus & VS_STOPPED) &&
+ u->cur_speed != 0) {
+ return;
+ }
if (v->direction != u->direction || !(v->direction&1))
return;
@@ -901,30 +896,23 @@ static void RoadVehCheckOvertake(Vehicle *v, Vehicle *u)
return;
tt = GetTileTrackStatus(v->tile, TRANSPORT_ROAD) & 0x3F;
- if ((tt & 3) == 0)
- return;
- if ((tt & 0x3C) != 0)
- return;
+ if ((tt & 3) == 0) return;
+ if ((tt & 0x3C) != 0) return;
- if (tt == 3) {
- tt = (v->direction&2)?2:1;
- }
+ if (tt == 3) tt = (v->direction & 2) ? 2 : 1;
od.tilebits = tt;
od.tile = v->tile;
- if (FindRoadVehToOvertake(&od))
- return;
+ if (FindRoadVehToOvertake(&od)) return;
od.tile = v->tile + TileOffsByDir(v->direction >> 1);
- if (FindRoadVehToOvertake(&od))
- return;
+ if (FindRoadVehToOvertake(&od)) return;
if (od.u->cur_speed == 0 || od.u->vehstatus&VS_STOPPED) {
v->u.road.overtaking_ctr = 0x11;
v->u.road.overtaking = 0x10;
} else {
-// if (FindRoadVehToOvertake(&od))
-// return;
+// if (FindRoadVehToOvertake(&od)) return;
v->u.road.overtaking_ctr = 0;
v->u.road.overtaking = 0x10;
}
@@ -951,8 +939,7 @@ static int PickRandomBit(uint bits)
uint i;
do {
- if (b & 1)
- num++;
+ if (b & 1) num++;
} while (b >>= 1);
num = RandomRange(num);
@@ -1189,15 +1176,12 @@ static void RoadVehController(Vehicle *v)
v->breakdown_ctr--;
}
- // exit if vehicle is stopped
- if (v->vehstatus & VS_STOPPED)
- return;
+ if (v->vehstatus & VS_STOPPED) return;
ProcessRoadVehOrder(v);
HandleRoadVehLoading(v);
- if (v->current_order.type == OT_LOADING)
- return;
+ if (v->current_order.type == OT_LOADING) return;
if (v->u.road.state == 254) {
int dir;
@@ -1215,8 +1199,7 @@ static void RoadVehController(Vehicle *v)
x = TileX(v->tile) * 16 + (rdp[6].x & 0xF);
y = TileY(v->tile) * 16 + (rdp[6].y & 0xF);
- if (RoadVehFindCloseTo(v,x,y,v->direction))
- return;
+ if (RoadVehFindCloseTo(v,x,y,v->direction)) return;
VehicleServiceInDepot(v);
@@ -1236,8 +1219,7 @@ static void RoadVehController(Vehicle *v)
return;
}
- if (!RoadVehAccelerate(v))
- return;
+ if (!RoadVehAccelerate(v)) return;
if (v->u.road.overtaking != 0) {
if (++v->u.road.overtaking_ctr >= 35)
@@ -1612,8 +1594,9 @@ void OnNewDay_RoadVeh(Vehicle *v)
st = GetStation(v->current_order.station);
//Current slot has expired
- if ( (v->u.road.slot_age++ <= 0) && (v->u.road.slot != NULL))
+ if (v->u.road.slot_age++ <= 0 && v->u.road.slot != NULL) {
ClearSlot(v, v->u.road.slot);
+ }
//We do not have a slot, so make one
if (v->u.road.slot == NULL) {
@@ -1624,7 +1607,7 @@ void OnNewDay_RoadVeh(Vehicle *v)
//first we need to find out how far our stations are away.
DEBUG(ms, 2) ("Multistop: Attempting to obtain a slot for vehicle %d at station %d (0x%x)", v->unitnumber, st->index, st->xy);
- for(; rs != NULL; rs = rs->next) {
+ for (; rs != NULL; rs = rs->next) {
// Only consider those with at least a free slot.
if (!(rs->slot[0] == INVALID_SLOT || rs->slot[1] == INVALID_SLOT))
continue;
@@ -1635,23 +1618,19 @@ void OnNewDay_RoadVeh(Vehicle *v)
// Check if the station is located BEHIND the vehicle..
// In that case, add penalty.
- switch(v->direction) {
- case 1: // going north east,x position decreasing
- if (v->x_pos <= (int32)TileX(rs->xy) * 16 + 15)
- dist += 6;
- break;
- case 3: // Going south east, y position increasing
- if (v->y_pos >= (int32)TileY(rs->xy) * 16)
- dist += 6;
- break;
- case 5: // Going south west, x position increasing
- if (v->x_pos >= (int32)TileX(rs->xy) * 16)
- dist += 6;
- break;
- case 7: // Going north west, y position decrasing.
- if (v->y_pos <= (int32)TileY(rs->xy) * 16 + 15)
- dist += 6;
- break;
+ switch (v->direction) {
+ case 1: // going north east,x position decreasing
+ if (v->x_pos <= (int32)TileX(rs->xy) * 16 + 15) dist += 6;
+ break;
+ case 3: // Going south east, y position increasing
+ if (v->y_pos >= (int32)TileY(rs->xy) * 16) dist += 6;
+ break;
+ case 5: // Going south west, x position increasing
+ if (v->x_pos >= (int32)TileX(rs->xy) * 16) dist += 6;
+ break;
+ case 7: // Going north west, y position decrasing.
+ if (v->y_pos <= (int32)TileY(rs->xy) * 16 + 15) dist += 6;
+ break;
}
// Remember the one with the shortest distance
diff --git a/smallmap_gui.c b/smallmap_gui.c
index 2cad09a72..4e1761a61 100644
--- a/smallmap_gui.c
+++ b/smallmap_gui.c
@@ -491,10 +491,11 @@ static inline uint32 GetSmallMapVegetationPixels(TileIndex tile)
break;
case MP_TREES:
- if ((_m[tile].m2 & 0x30) == 0x20)
+ if ((_m[tile].m2 & 0x30) == 0x20) {
bits = (_opt.landscape == LT_HILLY) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2);
- else
+ } else {
bits = MKCOLOR(0x54575754);
+ }
break;
default:
@@ -561,14 +562,14 @@ static inline uint32 dup_byte32(byte b) {
static void DrawVertMapIndicator(int x, int y, int x2, int y2)
{
- GfxFillRect(x, y, x2, y + 3, 69);
- GfxFillRect(x, y2 - 3, x2, y2, 69);
+ GfxFillRect(x, y, x2, y + 3, 69);
+ GfxFillRect(x, y2 - 3, x2, y2, 69);
}
static void DrawHorizMapIndicator(int x, int y, int x2, int y2)
{
- GfxFillRect(x, y, x + 3, y2, 69);
- GfxFillRect(x2 - 3, y, x2, y2, 69);
+ GfxFillRect(x, y, x + 3, y2, 69);
+ GfxFillRect(x2 - 3, y, x2, y2, 69);
}
/**
@@ -612,9 +613,10 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town
/* now fill with the player colors */
FOR_ALL_PLAYERS(p) {
- if (p->is_active)
+ if (p->is_active) {
_owner_colors[p->index] =
dup_byte32(GetNonSprite(775 + p->player_color)[0xCB]); // XXX - magic pixel
+ }
}
}
@@ -661,8 +663,7 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town
/* distance from right edge */
t = dpi->width - x;
if (t < 4) {
- if (t <= 0)
- break; /* exit loop */
+ if (t <= 0) break; /* exit loop */
/* mask to use at the right edge */
mask &= _smallmap_mask_right[t - 1];
}
@@ -718,13 +719,11 @@ skip_column:
if (x < 0) {
// if x+1 is 0, that means we're on the very left edge,
// and should thus only draw a single pixel
- if (++x != 0)
- continue;
+ if (++x != 0) continue;
skip = true;
} else if (x >= dpi->width - 1) {
// Check if we're at the very right edge, and if so draw only a single pixel
- if (x != dpi->width - 1)
- continue;
+ if (x != dpi->width - 1) continue;
skip = true;
}
@@ -734,8 +733,7 @@ skip_column:
// And draw either one or two pixels depending on clipping
ptr[0] = color;
- if (!skip)
- ptr[1] = color;
+ if (!skip) ptr[1] = color;
}
}
}
@@ -811,10 +809,10 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e)
x = 4;
y_org = w->height - 44 - 11;
y = y_org;
- while (true) {
- GfxFillRect(x, y+1, x+8, y + 5, 0);
- GfxFillRect(x+1, y+2, x+7, y + 4, (byte)tbl[0]);
- DrawString(x+11, y, tbl[1], 0);
+ for (;;) {
+ GfxFillRect(x, y + 1, x + 8, y + 5, 0);
+ GfxFillRect(x + 1, y + 2, x + 7, y + 4, (byte)tbl[0]);
+ DrawString(x + 11, y, tbl[1], 0);
tbl += 2;
y += 6;
@@ -873,8 +871,7 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e)
case WE_RCLICK:
if (e->click.widget == 4) {
- if (_scrolling_viewport)
- return;
+ if (_scrolling_viewport) return;
_scrolling_viewport = true;
_cursor.delta.x = 0;
_cursor.delta.y = 0;
@@ -883,8 +880,7 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e)
case WE_MOUSELOOP:
/* update the window every now and then */
- if ((++w->vscroll.pos & 0x1F) == 0)
- SetWindowDirty(w);
+ if ((++w->vscroll.pos & 0x1F) == 0) SetWindowDirty(w);
break;
}
}
@@ -911,10 +907,10 @@ void ShowSmallMap(void)
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
- x = (((vp->virtual_width - (220*32)) / 2) + vp->virtual_left) / 4;
- y = ((((vp->virtual_height- (120*32)) / 2) + vp->virtual_top ) / 2) - 32;
- WP(w,smallmap_d).scroll_x = (y-x) & ~0xF;
- WP(w,smallmap_d).scroll_y = (x+y) & ~0xF;
+ x = ((vp->virtual_width - 220 * 32) / 2 + vp->virtual_left) / 4;
+ y = ((vp->virtual_height - 120 * 32) / 2 + vp->virtual_top ) / 2 - 32;
+ WP(w,smallmap_d).scroll_x = (y - x) & ~0xF;
+ WP(w,smallmap_d).scroll_y = (x + y) & ~0xF;
WP(w,smallmap_d).subscroll = 0;
}
}
diff --git a/station_cmd.c b/station_cmd.c
index c4cc83576..d95770560 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -1210,7 +1210,6 @@ static const RealSpriteGroup *ResolveStationSpriteGroup(const SpriteGroup *spg,
if ((dsg->variable >> 6) == 0) {
/* General property */
value = GetDeterministicSpriteValue(dsg->variable);
-
} else {
if (st == NULL) {
/* We are in a build dialog of something,
@@ -1268,7 +1267,6 @@ uint32 GetCustomStationRelocation(const StationSpec *spec, const Station *st, by
if (rsg->sprites_per_set != 0) {
if (rsg->loading_count != 0) return rsg->loading[0]->g.result.result;
-
if (rsg->loaded_count != 0) return rsg->loaded[0]->g.result.result;
}
@@ -1414,18 +1412,20 @@ int32 CmdBuildRoadStop(int x, int y, uint32 flags, uint32 p1, uint32 p2)
//give us a road stop in the list, and check if something went wrong
road_stop = AllocateRoadStop();
- if (road_stop == NULL)
- return_cmd_error( (type) ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS);
+ if (road_stop == NULL) {
+ return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS);
+ }
- if ( st != NULL && (GetNumRoadStops(st, RS_BUS) + GetNumRoadStops(st, RS_TRUCK) >= ROAD_STOP_LIMIT))
- return_cmd_error( (type) ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS);
+ if (st != NULL && GetNumRoadStops(st, RS_BUS) + GetNumRoadStops(st, RS_TRUCK) >= ROAD_STOP_LIMIT) {
+ return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS);
+ }
if (st != NULL) {
- if (st->owner != OWNER_NONE && st->owner != _current_player)
+ 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;
+ if (!CheckStationSpreadOut(st, tile, 1, 1)) return CMD_ERROR;
FindRoadStationSpot(type, st, &currstop, &prev);
} else {
@@ -1438,8 +1438,9 @@ int32 CmdBuildRoadStop(int x, int y, uint32 flags, uint32 p1, uint32 p2)
FindRoadStationSpot(type, st, &currstop, &prev);
- if (_current_player < MAX_PLAYERS && flags&DC_EXEC)
+ if (_current_player < MAX_PLAYERS && flags & DC_EXEC) {
SETBIT(t->have_ratings, _current_player);
+ }
st->sign.width_1 = 0;
@@ -1486,8 +1487,9 @@ static int32 RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
RoadStop *cur_stop;
bool is_truck = _m[tile].m5 < 0x47;
- if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
+ if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) {
return CMD_ERROR;
+ }
if (is_truck) { // truck stop
primary_stop = &st->truck_stops;
@@ -1499,8 +1501,7 @@ static int32 RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
assert(cur_stop != NULL);
- if (!EnsureNoVehicle(tile))
- return CMD_ERROR;
+ if (!EnsureNoVehicle(tile)) return CMD_ERROR;
if (flags & DC_EXEC) {
uint i;
@@ -1671,8 +1672,7 @@ int32 CmdBuildAirport(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!GenerateStationName(st, tile, (p1 == AT_HELIPORT) ? 5 : 1))
return CMD_ERROR;
- if (flags & DC_EXEC)
- StationInitialize(st, tile);
+ if (flags & DC_EXEC) StationInitialize(st, tile);
}
cost += _price.build_airport * w * h;
diff --git a/strings.c b/strings.c
index 4db8d29ac..581829389 100644
--- a/strings.c
+++ b/strings.c
@@ -983,10 +983,11 @@ StringID RemapOldStringID(StringID s)
case 0xA02F: return STR_SV_AIRCRAFT_NAME;
default:
- if (IS_INT_INSIDE(s, 0x300F, 0x3030))
+ if (IS_INT_INSIDE(s, 0x300F, 0x3030)) {
return s - 0x300F + STR_SV_STNAME;
- else
+ } else {
return s;
+ }
}
}
diff --git a/table/sprites.h b/table/sprites.h
index 6f506374f..c29ffddf1 100644
--- a/table/sprites.h
+++ b/table/sprites.h
@@ -1027,6 +1027,7 @@ typedef enum CursorSprites {
SPR_CURSOR_AUTOMAGLEV = SPR_OPENTTD_BASE + 6,
SPR_CURSOR_WAYPOINT = SPR_OPENTTD_BASE + 7,
+
SPR_CURSOR_RAIL_DEPOT = 1296,
SPR_CURSOR_MONO_DEPOT = SPR_OPENTTD_BASE + 11,
SPR_CURSOR_MAGLEV_DEPOT = SPR_OPENTTD_BASE + 12,
diff --git a/town_cmd.c b/town_cmd.c
index 77ac02b9a..e674a4855 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -1070,8 +1070,7 @@ Town *CreateRandomTown(uint attempts)
do {
// Generate a tile index not too close from the edge
tile = RandomTile();
- if (DistanceFromEdge(tile) < 20)
- continue;
+ if (DistanceFromEdge(tile) < 20) continue;
// Make sure the tile is plain
FindLandscapeHeightByTile(&ti, tile);
@@ -1079,17 +1078,14 @@ Town *CreateRandomTown(uint attempts)
continue;
// Check not too close to a town
- if (IsCloseToTown(tile, 20))
- continue;
+ if (IsCloseToTown(tile, 20)) continue;
// Get a unique name for the town.
- if (!CreateTownName(&townnameparts))
- break;
+ if (!CreateTownName(&townnameparts)) break;
// Allocate a town struct
t = AllocateTown();
- if (t == NULL)
- break;
+ if (t == NULL) break;
DoCreateTown(t, tile, townnameparts);
return t;
@@ -1247,36 +1243,36 @@ static void DoBuildTownHouse(Town *t, TileIndex tile)
break;
}
- if (t->flags12 & oneof)
- continue;
+ if (t->flags12 & oneof) continue;
// Make sure there is no slope?
- if (_housetype_extra_flags[house]&0x12 && slope)
- continue;
+ if (_housetype_extra_flags[house] & 0x12 && slope) continue;
- if (_housetype_extra_flags[house]&0x10) {
+ if (_housetype_extra_flags[house] & 0x10) {
if (CheckFree2x2Area(t, tile) ||
CheckFree2x2Area(t, (tile += TileDiffXY(-1, 0))) ||
CheckFree2x2Area(t, (tile += TileDiffXY( 0, -1))) ||
- CheckFree2x2Area(t, (tile += TileDiffXY( 1, 0))))
+ CheckFree2x2Area(t, (tile += TileDiffXY( 1, 0)))) {
break;
- tile += TileDiffXY(0,1);
- } else if (_housetype_extra_flags[house]&4) {
+ }
+ tile += TileDiffXY(0, 1);
+ } else if (_housetype_extra_flags[house] & 4) {
if (CheckBuildHouseMode(t, tile + TileDiffXY(1, 0), slope, 0)) break;
if (CheckBuildHouseMode(t, tile + TileDiffXY(-1, 0), slope, 1)) {
tile += TileDiffXY(-1, 0);
break;
}
- } else if (_housetype_extra_flags[house]&8) {
+ } else if (_housetype_extra_flags[house] & 8) {
if (CheckBuildHouseMode(t, tile + TileDiffXY(0, 1), slope, 2)) break;
if (CheckBuildHouseMode(t, tile + TileDiffXY(0, -1), slope, 3)) {
tile += TileDiffXY(0, -1);
break;
}
- } else
+ } else {
break;
+ }
}
}
diff --git a/train_cmd.c b/train_cmd.c
index ba350753d..2e11c1654 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1551,6 +1551,7 @@ static void AdvanceWagons(Vehicle *v, bool before)
}
}
+
static void ReverseTrainDirection(Vehicle *v)
{
int l = 0, r = -1;
@@ -1559,7 +1560,6 @@ static void ReverseTrainDirection(Vehicle *v)
if (IsTileDepotType(v->tile, TRANSPORT_RAIL))
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
-
/* Check if we were approaching a rail/road-crossing */
{
TileIndex tile = v->tile;
@@ -2013,12 +2013,11 @@ typedef struct TrainTrackFollowerData {
static bool NtpCallbFindStation(TileIndex tile, TrainTrackFollowerData *ttfd, int track, uint length)
{
// heading for nowhere?
- if (ttfd->dest_coords == 0)
- return false;
+ if (ttfd->dest_coords == 0) return false;
// did we reach the final station?
if ((ttfd->station_index == INVALID_STATION && tile == ttfd->dest_coords) ||
- (IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_m[tile].m5, 0, 8) && _m[tile].m2 == ttfd->station_index)) {
+ (IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_m[tile].m5, 0, 8) && _m[tile].m2 == ttfd->station_index)) {
/* We do not check for dest_coords if we have a station_index,
* because in that case the dest_coords are just an
* approximation of where the station is */
diff --git a/train_gui.c b/train_gui.c
index cf44b3d94..49c28ac6a 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -475,8 +475,7 @@ static int GetVehicleFromTrainDepotWndPt(const Window *w, int x, int y, GetDepot
x = x - 23;
row = (y - 14) / 14;
- if ( (uint) row >= w->vscroll.cap)
- return 1; /* means err */
+ if ((uint)row >= w->vscroll.cap) return 1; /* means err */
row += w->vscroll.pos;
@@ -487,8 +486,8 @@ static int GetVehicleFromTrainDepotWndPt(const Window *w, int x, int y, GetDepot
v->tile == w->window_number &&
v->u.rail.track == 0x80 &&
--row < 0) {
- skip = w->hscroll.pos;
- goto found_it;
+ skip = w->hscroll.pos;
+ goto found_it;
}
}
@@ -500,8 +499,9 @@ static int GetVehicleFromTrainDepotWndPt(const Window *w, int x, int y, GetDepot
IsFreeWagon(v) &&
v->tile == w->window_number &&
v->u.rail.track == 0x80 &&
- --row < 0)
- goto found_it;
+ --row < 0) {
+ goto found_it;
+ }
}
d->head = NULL;
@@ -514,8 +514,7 @@ found_it:
d->head = d->wagon = v;
/* either pressed the flag or the number, but only when it's a loco */
- if (x < 0 && IsFrontEngine(v))
- return (x >= -10) ? -2 : -1;
+ if (x < 0 && IsFrontEngine(v)) return (x >= -10) ? -2 : -1;
// skip vehicles that are scrolled off the left side
while (skip--) v = v->next;
@@ -1483,7 +1482,8 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
tile = _last_built_train_depot_tile;
do {
- if (IsTileDepotType(tile, TRANSPORT_RAIL) && IsTileOwner(tile, _local_player)) {
+ if (IsTileDepotType(tile, TRANSPORT_RAIL) &&
+ IsTileOwner(tile, _local_player)) {
ShowTrainDepotWindow(tile);
ShowBuildTrainWindow(tile);
return;
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index fe6dae18d..2c1a50c40 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -247,12 +247,15 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!CheckBridge_Stuff(bridge_type, bridge_len)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE);
/* retrieve landscape height and ensure it's on land */
- if (
- ((FindLandscapeHeight(&ti_end, sx, sy),
- ti_end.type == MP_WATER) && ti_end.map5 == 0) ||
- ((FindLandscapeHeight(&ti_start, x, y),
- ti_start.type == MP_WATER) && ti_start.map5 == 0))
+ if ((
+ FindLandscapeHeight(&ti_end, sx, sy),
+ ti_end.type == MP_WATER && ti_end.map5 == 0
+ ) || (
+ FindLandscapeHeight(&ti_start, x, y),
+ ti_start.type == MP_WATER && ti_start.map5 == 0
+ )) {
return_cmd_error(STR_02A0_ENDS_OF_BRIDGE_MUST_BOTH);
+ }
if (BRIDGE_FULL_LEVELED_FOUNDATION & (1 << ti_start.tileh)) {
ti_start.z += 8;
@@ -1464,11 +1467,10 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y
if (GB(_m[tile].m5, 4, 4) == 0) {
z = GetSlopeZ(x, y) - v->z_pos;
- if (myabs(z) > 2)
- return 8;
+ if (myabs(z) > 2) return 8;
if (v->type == VEH_Train) {
- fc = (x&0xF)+(y<<4);
+ fc = (x & 0xF) + (y << 4);
dir = GB(_m[tile].m5, 0, 2);
vdir = v->direction >> 1;
@@ -1496,7 +1498,7 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y
return 4;
}
} else if (v->type == VEH_Road) {
- fc = (x&0xF)+(y<<4);
+ fc = (x & 0xF) + (y << 4);
dir = GB(_m[tile].m5, 0, 2);
vdir = v->direction >> 1;
@@ -1504,7 +1506,6 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex 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;
@@ -1514,10 +1515,11 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y
}
}
- if (dir == (vdir^2) && (
- /* We're at the tunnel exit ?? */
- fc == _tunnel_fractcoord_6[dir] ||
- fc == _tunnel_fractcoord_7[dir]) &&
+ if (dir == (vdir ^ 2) && (
+ /* We're at the tunnel exit ?? */
+ fc == _tunnel_fractcoord_6[dir] ||
+ fc == _tunnel_fractcoord_7[dir]
+ ) &&
z == 0) {
v->tile = tile;
v->u.road.state = _road_exit_tunnel_state[dir];
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 5697f456c..4c9a33c5e 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -336,8 +336,7 @@ void GenerateUnmovables(void)
int dir;
uint h;
- if (_opt.landscape == LT_CANDY)
- return;
+ if (_opt.landscape == LT_CANDY) return;
/* add radio tower */
i = ScaleByMapSize(1000);
@@ -345,18 +344,15 @@ void GenerateUnmovables(void)
do {
tile = RandomTile();
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) {
- if(!checkRadioTowerNearby(tile))
- continue;
+ if (!checkRadioTowerNearby(tile)) continue;
SetTileType(tile, MP_UNMOVABLE);
_m[tile].m5 = 0;
SetTileOwner(tile, OWNER_NONE);
- if (--j == 0)
- break;
+ if (--j == 0) break;
}
} while (--i);
- if (_opt.landscape == LT_DESERT)
- return;
+ if (_opt.landscape == LT_DESERT) return;
/* add lighthouses */
i = ScaleByMapSize1D((Random() & 3) + 7);
@@ -372,8 +368,7 @@ restart:
(dir == 3) ? TileXY(r, MapMaxY()) : 0; // bottom
j = 20;
do {
- if (--j == 0)
- goto restart;
+ if (--j == 0) goto restart;
tile = TILE_MASK(tile + ToTileIndexDiff(_tile_add[dir]));
} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
diff --git a/vehicle.c b/vehicle.c
index 5c8a275de..d0eccc5cf 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -397,7 +397,6 @@ void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
}
-
static void UpdateVehiclePosHash(Vehicle* v, int x, int y)
{
VehicleID *old_hash, *new_hash;
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 14a77130e..2b6eb2f65 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -114,8 +114,9 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
if (!(vl->flags & VL_REBUILD)) return;
sort_list = malloc(GetVehiclePoolSize() * sizeof(sort_list[0]));
- if (sort_list == NULL)
+ if (sort_list == NULL) {
error("Could not allocate memory for the vehicle-sorting-list");
+ }
DEBUG(misc, 1) ("Building vehicle list for player %d station %d...",
owner, station);
@@ -124,8 +125,9 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
if (v->type == type && (
- (type == VEH_Train && IsFrontEngine(v)) ||
- (type != VEH_Train && v->subtype <= subtype))) {
+ (type == VEH_Train && IsFrontEngine(v)) ||
+ (type != VEH_Train && v->subtype <= subtype)
+ )) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
@@ -142,8 +144,9 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
if (v->type == type && v->owner == owner && (
- (type == VEH_Train && IsFrontEngine(v)) ||
- (type != VEH_Train && v->subtype <= subtype))) {
+ (type == VEH_Train && IsFrontEngine(v)) ||
+ (type != VEH_Train && v->subtype <= subtype)
+ )) {
sort_list[n].index = v->index;
sort_list[n].owner = v->owner;
++n;
@@ -153,8 +156,9 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
free(vl->sort_list);
vl->sort_list = malloc(n * sizeof(vl->sort_list[0]));
- if (n != 0 && vl->sort_list == NULL)
+ if (n != 0 && vl->sort_list == NULL) {
error("Could not allocate memory for the vehicle-sorting-list");
+ }
vl->list_length = n;
for (i = 0; i < n; ++i) vl->sort_list[i] = sort_list[i];
diff --git a/water_cmd.c b/water_cmd.c
index 7c95061cd..8825714f2 100644
--- a/water_cmd.c
+++ b/water_cmd.c
@@ -105,16 +105,12 @@ static int32 RemoveShipDepot(TileIndex tile, uint32 flags)
{
TileIndex tile2;
- if (!CheckTileOwnership(tile))
- return CMD_ERROR;
-
- if (!EnsureNoVehicle(tile))
- return CMD_ERROR;
+ if (!CheckTileOwnership(tile)) return CMD_ERROR;
+ if (!EnsureNoVehicle(tile)) return CMD_ERROR;
tile2 = tile + ((_m[tile].m5 & 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
- if (!EnsureNoVehicle(tile2))
- return CMD_ERROR;
+ if (!EnsureNoVehicle(tile2)) return CMD_ERROR;
if (flags & DC_EXEC) {
/* Kill the depot */
@@ -286,8 +282,7 @@ static int32 ClearTile_Water(TileIndex tile, byte flags)
return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER);
// Make sure no vehicle is on the tile
- if (!EnsureNoVehicle(tile))
- return CMD_ERROR;
+ if (!EnsureNoVehicle(tile)) return CMD_ERROR;
// Make sure it's not an edge tile.
if (!(IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) &&
@@ -295,8 +290,7 @@ static int32 ClearTile_Water(TileIndex tile, byte flags)
return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
if (m5 == 0) {
- if (flags & DC_EXEC)
- DoClearSquare(tile);
+ if (flags & DC_EXEC) DoClearSquare(tile);
return _price.clear_water;
} else if (m5 == 1) {
slope = GetTileSlope(tile,NULL);
@@ -336,7 +330,7 @@ static int32 ClearTile_Water(TileIndex tile, byte flags)
default: return CMD_ERROR;
}
- return RemoveShipDepot(tile,flags);
+ return RemoveShipDepot(tile, flags);
}
}
@@ -480,16 +474,17 @@ static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac)
static void GetTileDesc_Water(TileIndex tile, TileDesc *td)
{
- if (_m[tile].m5 == 0 && TilePixelHeight(tile) == 0)
+ if (_m[tile].m5 == 0 && TilePixelHeight(tile) == 0) {
td->str = STR_3804_WATER;
- else if (_m[tile].m5 == 0)
+ } else if (_m[tile].m5 == 0) {
td->str = STR_LANDINFO_CANAL;
- else if (_m[tile].m5 == 1)
+ } else if (_m[tile].m5 == 1) {
td->str = STR_3805_COAST_OR_RIVERBANK;
- else if ((_m[tile].m5&0xF0) == 0x10)
+ } else if ((_m[tile].m5 & 0xF0) == 0x10) {
td->str = STR_LANDINFO_LOCK;
- else
+ } else {
td->str = STR_3806_SHIP_DEPOT;
+ }
td->owner = GetTileOwner(tile);
}
@@ -554,8 +549,7 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
} else {
if (IsTileType(target, MP_TUNNELBRIDGE)) {
byte m5 = _m[target].m5;
- if ((m5 & 0xF8) == 0xC8 || (m5 & 0xF8) == 0xF0)
- return;
+ if ((m5 & 0xF8) == 0xC8 || (m5 & 0xF8) == 0xF0) return;
if ((m5 & 0xC0) == 0xC0) {
ModifyTile(target, MP_MAPOWNER | MP_MAP5, OWNER_WATER, (m5 & ~0x38) | 0x8);
@@ -650,8 +644,9 @@ void TileLoop_Water(TileIndex tile)
_current_player = OWNER_NONE;
// edges
- if (TileX(tile) == 0 && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) //NE
+ if (TileX(tile) == 0 && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { //NE
TileLoopWaterHelper(tile, _tile_loop_offs_array[2]);
+ }
if (TileX(tile) == MapSizeX() - 2 && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { //SW
TileLoopWaterHelper(tile, _tile_loop_offs_array[0]);
@@ -675,29 +670,26 @@ static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode)
uint m5;
uint b;
- if (mode != TRANSPORT_WATER)
- return 0;
+ if (mode != TRANSPORT_WATER) return 0;
m5 = _m[tile].m5;
- if (m5 == 0)
- return 0x3F3F;
+ if (m5 == 0) return 0x3F3F;
if (m5 == 1) {
- b = _coast_tracks[GetTileSlope(tile, NULL)&0xF];
- return b + (b<<8);
+ b = _coast_tracks[GetTileSlope(tile, NULL) & 0xF];
+ return b + (b << 8);
}
- if ( (m5 & 0x10) == 0x10) {
+ if ((m5 & 0x10) == 0x10) {
//
b = _shiplift_tracks[m5 & 0xF];
- return b + (b<<8);
+ return b + (b << 8);
}
- if (!(m5 & 0x80))
- return 0;
+ if (!(m5 & 0x80)) return 0;
b = _shipdepot_tracks[m5 & 0x7F];
- return b + (b<<8);
+ return b + (b << 8);
}
extern void ShowShipDepotWindow(TileIndex tile);
diff --git a/window.c b/window.c
index a1f6b4973..be2444137 100644
--- a/window.c
+++ b/window.c
@@ -1371,11 +1371,10 @@ static void MouseLoop(int click, int mousewheel)
x = _cursor.pos.x;
y = _cursor.pos.y;
-
if (click == 0 && mousewheel == 0) {
if (_patches.autoscroll && _game_mode != GM_MENU) {
w = FindWindowFromPt(x, y);
- if (w == NULL || w->flags4 & WF_DISABLE_VP_SCROLL ) return;
+ if (w == NULL || w->flags4 & WF_DISABLE_VP_SCROLL) return;
vp = IsPtInWindowViewport(w, x, y);
if (vp) {
x -= vp->left;