diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index a21b9a6ca5..343cf05887 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -158,12 +158,11 @@ void UpdateCompanyHQ(TileIndex tile, uint score) { if (tile == INVALID_TILE) return; - byte val; - (val = 0, score < 170) || - (val++, score < 350) || - (val++, score < 520) || - (val++, score < 720) || - (val++, true); + byte val = 0; + if (score >= 170) val++; + if (score >= 350) val++; + if (score >= 520) val++; + if (score >= 720) val++; while (GetCompanyHQSize(tile) < val) { IncreaseCompanyHQSize(tile); diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 1d5e595950..d4f60a6ec3 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -989,11 +989,13 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) if (IsInfraUsageAllowed(v->type, v->owner, st->owner)) { byte facil; - (facil = FACIL_DOCK, v->type == VEH_SHIP) || - (facil = FACIL_TRAIN, v->type == VEH_TRAIN) || - (facil = FACIL_AIRPORT, v->type == VEH_AIRCRAFT) || - (facil = FACIL_BUS_STOP, v->type == VEH_ROAD && RoadVehicle::From(v)->IsBus()) || - (facil = FACIL_TRUCK_STOP, 1); + switch (v->type) { + case VEH_SHIP: facil = FACIL_DOCK; break; + case VEH_TRAIN: facil = FACIL_TRAIN; break; + case VEH_AIRCRAFT: facil = FACIL_AIRPORT; break; + case VEH_ROAD: facil = RoadVehicle::From(v)->IsBus() ? FACIL_BUS_STOP : FACIL_TRUCK_STOP; break; + default: NOT_REACHED(); + } if (st->facilities & facil) { order.MakeGoToStation(st_index); if (_ctrl_pressed) order.SetLoadType(OLF_FULL_LOAD_ANY); diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 0b566134b8..4fffb0e7c7 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -2798,23 +2798,30 @@ void DrawTrackBits(TileInfo *ti, TrackBits track, RailType rt, RailGroundType rg image = _track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.track_y; } else { /* track on flat ground */ - (image = rti->base_sprites.track_y, track == TRACK_BIT_Y) || - (image++, track == TRACK_BIT_X) || - (image++, track == TRACK_BIT_UPPER) || - (image++, track == TRACK_BIT_LOWER) || - (image++, track == TRACK_BIT_RIGHT) || - (image++, track == TRACK_BIT_LEFT) || - (image++, track == TRACK_BIT_CROSS) || + switch (track) { + /* single track, select combined track + ground sprite*/ + case TRACK_BIT_Y: image = rti->base_sprites.track_y; break; + case TRACK_BIT_X: image = rti->base_sprites.track_y + 1; break; + case TRACK_BIT_UPPER: image = rti->base_sprites.track_y + 2; break; + case TRACK_BIT_LOWER: image = rti->base_sprites.track_y + 3; break; + case TRACK_BIT_RIGHT: image = rti->base_sprites.track_y + 4; break; + case TRACK_BIT_LEFT: image = rti->base_sprites.track_y + 5; break; + case TRACK_BIT_CROSS: image = rti->base_sprites.track_y + 6; break; - (image = rti->base_sprites.track_ns, track == TRACK_BIT_HORZ) || - (image++, track == TRACK_BIT_VERT) || + /* double diagonal track, select combined track + ground sprite*/ + case TRACK_BIT_HORZ: image = rti->base_sprites.track_ns; break; + case TRACK_BIT_VERT: image = rti->base_sprites.track_ns + 1; break; - (junction = true, false) || - (image = rti->base_sprites.ground, (track & TRACK_BIT_3WAY_NE) == 0) || - (image++, (track & TRACK_BIT_3WAY_SW) == 0) || - (image++, (track & TRACK_BIT_3WAY_NW) == 0) || - (image++, (track & TRACK_BIT_3WAY_SE) == 0) || - (image++, true); + /* junction, select only ground sprite, handle track sprite later */ + default: + junction = true; + if ((track & TRACK_BIT_3WAY_NE) == 0) { image = rti->base_sprites.ground; break; } + if ((track & TRACK_BIT_3WAY_SW) == 0) { image = rti->base_sprites.ground + 1; break; } + if ((track & TRACK_BIT_3WAY_NW) == 0) { image = rti->base_sprites.ground + 2; break; } + if ((track & TRACK_BIT_3WAY_SE) == 0) { image = rti->base_sprites.ground + 3; break; } + image = rti->base_sprites.ground + 4; + break; + } } switch (rgt) { diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 18d4c95776..9a9eecb369 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3620,27 +3620,25 @@ static void UpdateStationRating(Station *st) } } if (ge->last_vehicle_type == VEH_SHIP) waittime >>= 2; - (waittime > 21) || - (rating += 25, waittime > 12) || - (rating += 25, waittime > 6) || - (rating += 45, waittime > 3) || - (rating += 35, true); + if (waittime <= 21) rating += 25; + if (waittime <= 12) rating += 25; + if (waittime <= 6) rating += 45; + if (waittime <= 3) rating += 35; - (rating -= 90, ge->max_waiting_cargo > 1500) || - (rating += 55, ge->max_waiting_cargo > 1000) || - (rating += 35, ge->max_waiting_cargo > 600) || - (rating += 10, ge->max_waiting_cargo > 300) || - (rating += 20, ge->max_waiting_cargo > 100) || - (rating += 10, true); + rating -= 90; + if (ge->max_waiting_cargo <= 1500) rating += 55; + if (ge->max_waiting_cargo <= 1000) rating += 35; + if (ge->max_waiting_cargo <= 600) rating += 10; + if (ge->max_waiting_cargo <= 300) rating += 20; + if (ge->max_waiting_cargo <= 100) rating += 10; } if (Company::IsValidID(st->owner) && HasBit(st->town->statues, st->owner)) rating += 26; byte age = ge->last_age; - (age >= 3) || - (rating += 10, age >= 2) || - (rating += 10, age >= 1) || - (rating += 13, true); + if (age < 3) rating += 10; + if (age < 2) rating += 10; + if (age < 1) rating += 13; { int or_ = ge->rating; // old rating @@ -4045,16 +4043,16 @@ static void AddNearbyStationsByCatchment(TileIndex tile, StationList *stations, * Find all stations around a rectangular producer (industry, house, headquarter, ...) * * @param location The location/area of the producer - * @param stations The list to store the stations in + * @param[out] stations The list to store the stations in * @param use_nearby Use nearby station list of industry/town associated with location.tile */ -void FindStationsAroundTiles(const TileArea &location, StationList *stations, bool use_nearby) +void FindStationsAroundTiles(const TileArea &location, StationList * const stations, bool use_nearby) { if (use_nearby) { /* Industries and towns maintain a list of nearby stations */ if (IsTileType(location.tile, MP_INDUSTRY)) { /* Industry nearby stations are already filtered by catchment. */ - stations = &Industry::GetByTile(location.tile)->stations_near; + *stations = Industry::GetByTile(location.tile)->stations_near; return; } else if (IsTileType(location.tile, MP_HOUSE)) { /* Town nearby stations need to be filtered per tile. */ diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index b6a0f6ce71..476a37e456 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -531,7 +531,7 @@ static void ChangePopulation(Town *t, int mod) { t->cache.population += mod; InvalidateWindowData(WC_TOWN_VIEW, t->index); // Cargo requirements may appear/vanish for small populations - t->UpdateVirtCoord(); + if (_settings_client.gui.population_in_label) t->UpdateVirtCoord(); InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1); } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 46acb72db8..484c32ebee 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -160,15 +160,14 @@ public: SetDParam(1, c->index); int r = this->town->ratings[c->index]; - StringID str; - (str = STR_CARGO_RATING_APPALLING, r <= RATING_APPALLING) || // Apalling - (str++, r <= RATING_VERYPOOR) || // Very Poor - (str++, r <= RATING_POOR) || // Poor - (str++, r <= RATING_MEDIOCRE) || // Mediocore - (str++, r <= RATING_GOOD) || // Good - (str++, r <= RATING_VERYGOOD) || // Very Good - (str++, r <= RATING_EXCELLENT) || // Excellent - (str++, true); // Outstanding + StringID str = STR_CARGO_RATING_APPALLING; + if (r > RATING_APPALLING) str++; + if (r > RATING_VERYPOOR) str++; + if (r > RATING_POOR) str++; + if (r > RATING_MEDIOCRE) str++; + if (r > RATING_GOOD) str++; + if (r > RATING_VERYGOOD) str++; + if (r > RATING_EXCELLENT) str++; SetDParam(2, str); if (this->town->exclusivity == c->index) {