summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-06-01 11:43:36 +0000
committeralberth <alberth@openttd.org>2009-06-01 11:43:36 +0000
commitbab70a823dd810e1d4477f0c01d3a7b3e9b19ac8 (patch)
tree2668a1043fb310d44e67f4deb07871519d406a55 /src
parent5e91bf0ad20e0c60b31e190a1f02f184020238de (diff)
downloadopenttd-bab70a823dd810e1d4477f0c01d3a7b3e9b19ac8.tar.xz
(svn r16491) -Codechange: Added parentheses around bitwise operators for code style.
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_order.cpp18
-rw-r--r--src/ai/api/ai_town.cpp2
-rw-r--r--src/aircraft_cmd.cpp17
-rw-r--r--src/economy.cpp4
-rw-r--r--src/engine.cpp2
-rw-r--r--src/industry_cmd.cpp14
-rw-r--r--src/network/core/host.cpp2
-rw-r--r--src/network/network.cpp2
-rw-r--r--src/network/network_chat_gui.cpp2
-rw-r--r--src/network/network_server.cpp4
-rw-r--r--src/order_cmd.cpp4
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/road_cmd.cpp10
-rw-r--r--src/roadveh_cmd.cpp8
-rw-r--r--src/saveload/oldloader.cpp4
-rw-r--r--src/saveload/vehicle_sl.cpp2
-rw-r--r--src/signal.cpp8
-rw-r--r--src/station_cmd.cpp4
-rw-r--r--src/town_cmd.cpp2
-rw-r--r--src/train_cmd.cpp18
-rw-r--r--src/tunnelbridge_cmd.cpp2
-rw-r--r--src/unmovable_cmd.cpp2
-rw-r--r--src/vehicle.cpp2
-rw-r--r--src/vehicle_cmd.cpp4
-rw-r--r--src/video/allegro_v.cpp4
-rw-r--r--src/widget.cpp6
-rw-r--r--src/window.cpp8
27 files changed, 77 insertions, 80 deletions
diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp
index ce1e3ed46..be5b33012 100644
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -119,18 +119,18 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
{
switch (::GetOrderTypeByTile(destination)) {
case OT_GOTO_STATION:
- return ((order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_UNLOAD_FLAGS | AIOF_LOAD_FLAGS)) == 0) &&
+ return (order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_UNLOAD_FLAGS | AIOF_LOAD_FLAGS)) == 0 &&
/* Test the different mutual exclusive flags. */
- (((order_flags & AIOF_TRANSFER) == 0) || ((order_flags & AIOF_UNLOAD) == 0)) &&
- (((order_flags & AIOF_TRANSFER) == 0) || ((order_flags & AIOF_NO_UNLOAD) == 0)) &&
- (((order_flags & AIOF_UNLOAD) == 0) || ((order_flags & AIOF_NO_UNLOAD) == 0)) &&
- (((order_flags & AIOF_UNLOAD) == 0) || ((order_flags & AIOF_NO_UNLOAD) == 0)) &&
- (((order_flags & AIOF_NO_UNLOAD) == 0) || ((order_flags & AIOF_NO_LOAD) == 0)) &&
- (((order_flags & AIOF_FULL_LOAD_ANY) == 0) || ((order_flags & AIOF_NO_LOAD) == 0));
+ ((order_flags & AIOF_TRANSFER) == 0 || (order_flags & AIOF_UNLOAD) == 0) &&
+ ((order_flags & AIOF_TRANSFER) == 0 || (order_flags & AIOF_NO_UNLOAD) == 0) &&
+ ((order_flags & AIOF_UNLOAD) == 0 || (order_flags & AIOF_NO_UNLOAD) == 0) &&
+ ((order_flags & AIOF_UNLOAD) == 0 || (order_flags & AIOF_NO_UNLOAD) == 0) &&
+ ((order_flags & AIOF_NO_UNLOAD) == 0 || (order_flags & AIOF_NO_LOAD) == 0) &&
+ ((order_flags & AIOF_FULL_LOAD_ANY) == 0 || (order_flags & AIOF_NO_LOAD) == 0);
case OT_GOTO_DEPOT:
- return ((order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_DEPOT_FLAGS)) == 0) &&
- (((order_flags & AIOF_SERVICE_IF_NEEDED) == 0) || ((order_flags & AIOF_STOP_IN_DEPOT) == 0));
+ return (order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_DEPOT_FLAGS)) == 0 &&
+ ((order_flags & AIOF_SERVICE_IF_NEEDED) == 0 || (order_flags & AIOF_STOP_IN_DEPOT) == 0);
case OT_GOTO_WAYPOINT: return (order_flags & ~(AIOF_NON_STOP_FLAGS)) == 0;
default: return false;
diff --git a/src/ai/api/ai_town.cpp b/src/ai/api/ai_town.cpp
index cd75996f9..22e68234c 100644
--- a/src/ai/api/ai_town.cpp
+++ b/src/ai/api/ai_town.cpp
@@ -183,7 +183,7 @@
int num = 0;
const Station *st;
FOR_ALL_STATIONS(st) {
- if (st->town == t && st->facilities & FACIL_AIRPORT && st->airport_type != AT_OILRIG) num++;
+ if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport_type != AT_OILRIG) num++;
}
return max(0, 2 - num);
}
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 134ca6081..817895f35 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -110,10 +110,9 @@ static StationID FindNearestHangar(const Aircraft *v)
const AirportFTAClass *afc = st->Airport();
if (afc->nof_depots == 0 || (
/* don't crash the plane if we know it can't land at the airport */
- afc->flags & AirportFTAClass::SHORT_STRIP &&
- AircraftVehInfo(v->engine_type)->subtype & AIR_FAST &&
- !_cheats.no_jetcrash.value
- )) {
+ (afc->flags & AirportFTAClass::SHORT_STRIP) &&
+ (AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
+ !_cheats.no_jetcrash.value)) {
continue;
}
@@ -137,7 +136,7 @@ static bool HaveHangarInOrderList(Aircraft *v)
FOR_VEHICLE_ORDERS(v, order) {
const Station *st = Station::Get(order->station);
- if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) {
+ if (st->owner == v->owner && (st->facilities & FACIL_AIRPORT)) {
/* If an airport doesn't have a hangar, skip it */
if (st->Airport()->nof_depots != 0)
return true;
@@ -1057,7 +1056,7 @@ static bool AircraftController(Aircraft *v)
GetNewVehiclePosResult gp;
- if (dist < 4 || amd->flag & AMED_LAND) {
+ if (dist < 4 || (amd->flag & AMED_LAND)) {
/* move vehicle one pixel towards target */
gp.x = (v->x_pos != (x + amd->x)) ?
v->x_pos + ((x + amd->x > v->x_pos) ? 1 : -1) :
@@ -1334,8 +1333,8 @@ static void MaybeCrashAirplane(Aircraft *v)
/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
uint16 prob = 0x10000 / 1500;
- if (st->Airport()->flags & AirportFTAClass::SHORT_STRIP &&
- AircraftVehInfo(v->engine_type)->subtype & AIR_FAST &&
+ if ((st->Airport()->flags & AirportFTAClass::SHORT_STRIP) &&
+ (AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
!_cheats.no_jetcrash.value) {
prob = 0x10000 / 20;
}
@@ -1617,7 +1616,7 @@ static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc)
Station *st = Station::Get(v->targetairport);
/* runway busy or not allowed to use this airstation, circle */
- if (apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES) &&
+ if ((apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES)) &&
st->airport_tile != INVALID_TILE &&
(st->owner == OWNER_NONE || st->owner == v->owner)) {
/* {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41},
diff --git a/src/economy.cpp b/src/economy.cpp
index 0b9497812..b7ce214e6 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1125,7 +1125,7 @@ void VehiclePayment(Vehicle *front_v)
for (Vehicle *v = front_v; v != NULL; v = v->Next()) {
/* No cargo to unload */
- if (v->cargo_cap == 0 || v->cargo.Empty() || front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD) continue;
+ if (v->cargo_cap == 0 || v->cargo.Empty() || (front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD)) continue;
/* All cargo has already been paid for, no need to pay again */
if (!v->cargo.UnpaidCargo()) {
@@ -1280,7 +1280,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
* they were loaded, but to not force unload the vehicle when the
* station is still accepting the cargo in the vehicle. It doesn't
* accept cargo that was loaded at the same station. */
- if (u->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER) && (!accepted || v->cargo.Count() == cargo_count)) {
+ if ((u->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) && (!accepted || v->cargo.Count() == cargo_count)) {
remaining = v->cargo.MoveTo(&ge->cargo, amount_unloaded);
SetBit(ge->acceptance_pickup, GoodsEntry::PICKUP);
diff --git a/src/engine.cpp b/src/engine.cpp
index 02c3fc8e4..5e873f5a1 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -692,7 +692,7 @@ void EnginesMonthlyLoop()
Engine *e;
FOR_ALL_ENGINES(e) {
/* Age the vehicle */
- if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) {
+ if ((e->flags & ENGINE_AVAILABLE) && e->age != 0xFFFF) {
e->age++;
CalcEngineReliability(e);
}
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 46b183989..e65b13635 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1199,10 +1199,10 @@ bool IsSlopeRefused(Slope current, Slope refused)
Slope t = ComplementSlope(current);
- if (refused & SLOPE_W && (t & SLOPE_NW)) return true;
- if (refused & SLOPE_S && (t & SLOPE_NE)) return true;
- if (refused & SLOPE_E && (t & SLOPE_SW)) return true;
- if (refused & SLOPE_N && (t & SLOPE_SE)) return true;
+ if ((refused & SLOPE_W) && (t & SLOPE_NW)) return true;
+ if ((refused & SLOPE_S) && (t & SLOPE_NE)) return true;
+ if ((refused & SLOPE_E) && (t & SLOPE_SW)) return true;
+ if ((refused & SLOPE_N) && (t & SLOPE_SE)) return true;
}
return false;
@@ -1686,7 +1686,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (ind == NULL) return CMD_ERROR;
}
- if (flags & DC_EXEC && _game_mode != GM_EDITOR && ind != NULL) {
+ if ((flags & DC_EXEC) && _game_mode != GM_EDITOR && ind != NULL) {
SetDParam(0, indspec->name);
if (indspec->new_industry_text > STR_LAST_STRINGID) {
SetDParam(1, STR_TOWN);
@@ -1916,7 +1916,7 @@ static bool CheckIndustryCloseDownProtection(IndustryType type)
const IndustrySpec *indspec = GetIndustrySpec(type);
/* oil wells (or the industries with that flag set) are always allowed to closedown */
- if (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD && _settings_game.game_creation.landscape == LT_TEMPERATE) return false;
+ if ((indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) && _settings_game.game_creation.landscape == LT_TEMPERATE) return false;
return (indspec->behaviour & INDUSTRYBEH_CANCLOSE_LASTINSTANCE) == 0 && GetIndustryTypeCount(type) <= 1;
}
@@ -2174,7 +2174,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
}
}
- if (!callback_enabled && indspec->life_type & INDUSTRYLIFE_PROCESSING) {
+ if (!callback_enabled && (indspec->life_type & INDUSTRYLIFE_PROCESSING)) {
if ( (byte)(_cur_year - i->last_prod_year) >= 5 && Chance16(1, smooth_economy ? 180 : 2)) {
closeit = true;
}
diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp
index 917de0a2f..7adb64f01 100644
--- a/src/network/core/host.cpp
+++ b/src/network/core/host.cpp
@@ -173,7 +173,7 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // !G
strecpy(r.ifr_name, req->ifr_name, lastof(r.ifr_name));
if (ioctl(sock, SIOCGIFFLAGS, &r) != -1 &&
- r.ifr_flags & IFF_BROADCAST &&
+ (r.ifr_flags & IFF_BROADCAST) &&
ioctl(sock, SIOCGIFBRDADDR, &r) != -1) {
NetworkAddress addr(&r.ifr_broadaddr, sizeof(sockaddr));
if (!broadcast->Contains(addr)) *broadcast->Append() = addr;
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 266ce506d..32b1cb683 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -462,7 +462,7 @@ void NetworkCloseClient(NetworkClientSocket *cs)
}
/* When the client was PRE_ACTIVE, the server was in pause mode, so unpause */
- if (cs->status == STATUS_PRE_ACTIVE && _pause_mode & PM_PAUSED_JOIN) {
+ if (cs->status == STATUS_PRE_ACTIVE && (_pause_mode & PM_PAUSED_JOIN)) {
DoCommandP(0, PM_PAUSED_JOIN, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "", CLIENT_ID_SERVER, NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_CONNECT_FAIL);
}
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index 4284f15d7..d3fa7245c 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -96,7 +96,7 @@ void CDECL NetworkAddChatMessage(TextColour colour, uint8 duration, const char *
/* The default colour for a message is company colour. Replace this with
* white for any additional lines */
- cmsg->colour = (bufp == buf && colour & IS_PALETTE_COLOUR) ? colour : TC_WHITE;
+ cmsg->colour = (bufp == buf && (colour & IS_PALETTE_COLOUR)) ? colour : TC_WHITE;
cmsg->end_date = _date + duration;
bufp += strlen(bufp) + 1; // jump to 'next line' in the formatted string
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 8b1a5b669..d0bdb4fd4 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -866,8 +866,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
}
- if (GetCommandFlags(cp.cmd) & CMD_SERVER && ci->client_id != CLIENT_ID_SERVER) {
- IConsolePrintF(CC_ERROR, "WARNING: server only command from client %d (IP: %s), kicking...", ci->client_id, GetClientIP(ci));
+ if ((GetCommandFlags(cp.cmd) & CMD_SERVER) && ci->client_id != CLIENT_ID_SERVER) {
+ IConsolePrintF(CC_ERROR, "WARNING: server only command from: client %d (IP: %s), kicking...", ci->client_id, GetClientIP(ci));
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_KICKED);
return;
}
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 6b0d56757..37e993d41 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -1202,7 +1202,7 @@ CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
InvalidateVehicleOrder(u, 0);
/* If the vehicle already got the current depot set as current order, then update current order as well */
- if (u->cur_order_index == order_number && u->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) {
+ if (u->cur_order_index == order_number && (u->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) {
u->current_order.SetRefit(cargo, subtype);
}
}
@@ -1379,7 +1379,7 @@ void CheckOrders(const Vehicle *v)
if (v->vehstatus & VS_CRASHED) return;
/* Do nothing for stopped vehicles if setting is '1' */
- if (_settings_client.gui.order_review_system == 1 && v->vehstatus & VS_STOPPED)
+ if (_settings_client.gui.order_review_system == 1 && (v->vehstatus & VS_STOPPED))
return;
/* do nothing we we're not the first vehicle in a share-chain */
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index fa869a9ff..a17dbb6c6 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -134,7 +134,7 @@ static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags
}
/* Let's see if we may build this */
- if (flags & DC_NO_RAIL_OVERLAP || HasSignals(tile)) {
+ if ((flags & DC_NO_RAIL_OVERLAP) || HasSignals(tile)) {
/* If we are not allowed to overlap (flag is on for ai companies or we have
* signals on the tile), check that */
return future == TRACK_BIT_HORZ || future == TRACK_BIT_VERT;
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 680b8d000..dddc609c0 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -137,10 +137,10 @@ bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType
/* Get a bitmask of which neighbouring roads has a tile */
RoadBits n = ROAD_NONE;
RoadBits present = GetAnyRoadBits(tile, rt);
- if (present & ROAD_NE && GetAnyRoadBits(TILE_ADDXY(tile, -1, 0), rt) & ROAD_SW) n |= ROAD_NE;
- if (present & ROAD_SE && GetAnyRoadBits(TILE_ADDXY(tile, 0, 1), rt) & ROAD_NW) n |= ROAD_SE;
- if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile, 1, 0), rt) & ROAD_NE) n |= ROAD_SW;
- if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile, 0, -1), rt) & ROAD_SE) n |= ROAD_NW;
+ if ((present & ROAD_NE) && (GetAnyRoadBits(TILE_ADDXY(tile, -1, 0), rt) & ROAD_SW)) n |= ROAD_NE;
+ if ((present & ROAD_SE) && (GetAnyRoadBits(TILE_ADDXY(tile, 0, 1), rt) & ROAD_NW)) n |= ROAD_SE;
+ if ((present & ROAD_SW) && (GetAnyRoadBits(TILE_ADDXY(tile, 1, 0), rt) & ROAD_NE)) n |= ROAD_SW;
+ if ((present & ROAD_NW) && (GetAnyRoadBits(TILE_ADDXY(tile, 0, -1), rt) & ROAD_SE)) n |= ROAD_NW;
int rating_decrease = RATING_ROAD_DOWN_STEP_EDGE;
/* If 0 or 1 bits are set in n, or if no bits that match the bits to remove,
@@ -494,7 +494,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
/* Ignore half built tiles */
- if (flags & DC_EXEC && rt != ROADTYPE_TRAM && IsStraightRoad(existing)) {
+ if ((flags & DC_EXEC) && rt != ROADTYPE_TRAM && IsStraightRoad(existing)) {
SetDisallowedRoadDirections(tile, GetDisallowedRoadDirections(tile) ^ toggle_drd);
MarkTileDirtyByTile(tile);
}
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index d52795f9e..59166a46a 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -440,8 +440,8 @@ CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
RoadVehicle *v = RoadVehicle::GetIfValid(p1);
if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
- if (v->vehstatus & VS_STOPPED ||
- v->vehstatus & VS_CRASHED ||
+ if ((v->vehstatus & VS_STOPPED) ||
+ (v->vehstatus & VS_CRASHED) ||
v->breakdown_ctr != 0 ||
v->overtaking != 0 ||
v->state == RVSB_WORMHOLE ||
@@ -935,7 +935,7 @@ static void RoadVehCheckOvertake(RoadVehicle *v, RoadVehicle *u)
od.tile = v->tile + TileOffsByDiagDir(DirToDiagDir(v->direction));
if (CheckRoadBlockedForOvertaking(&od)) return;
- if (od.u->cur_speed == 0 || od.u->vehstatus& VS_STOPPED) {
+ if (od.u->cur_speed == 0 || (od.u->vehstatus & VS_STOPPED)) {
v->overtaking_ctr = 0x11;
v->overtaking = 0x10;
} else {
@@ -1132,7 +1132,7 @@ do_it:;
* pretend we are heading for the tile in front, we'll
* see from there */
desttile += TileOffsByDiagDir(dir);
- if (desttile == tile && trackdirs & _road_exit_dir_to_incoming_trackdirs[dir]) {
+ if (desttile == tile && (trackdirs & _road_exit_dir_to_incoming_trackdirs[dir])) {
/* If we are already in front of the
* station/depot and we can get in from here,
* we enter */
diff --git a/src/saveload/oldloader.cpp b/src/saveload/oldloader.cpp
index 25589a03c..ba26d66a2 100644
--- a/src/saveload/oldloader.cpp
+++ b/src/saveload/oldloader.cpp
@@ -105,8 +105,8 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
byte *base_ptr = (byte*)base;
for (const OldChunks *chunk = chunks; chunk->type != OC_END; chunk++) {
- if (((chunk->type & OC_TTD) && (_savegame_type == SGT_TTO)) ||
- ((chunk->type & OC_TTO) && (_savegame_type != SGT_TTO))) {
+ if (((chunk->type & OC_TTD) && _savegame_type == SGT_TTO) ||
+ ((chunk->type & OC_TTO) && _savegame_type != SGT_TTO)) {
/* TTD(P)-only chunk, but TTO savegame || TTO-only chunk, but TTD/TTDP savegame */
continue;
}
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index ae3b539e9..9c2610384 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -165,7 +165,7 @@ void UpdateOldAircraft()
* skip those */
if (IsNormalAircraft(a)) {
/* airplane in terminal stopped doesn't hurt anyone, so goto next */
- if (a->vehstatus & VS_STOPPED && a->state == 0) {
+ if ((a->vehstatus & VS_STOPPED) && a->state == 0) {
a->state = HANGAR;
continue;
}
diff --git a/src/signal.cpp b/src/signal.cpp
index 8600e5a3b..f42819894 100644
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -341,7 +341,7 @@ static SigFlags ExploreSegment(Owner owner)
}
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { // test all possible exit directions
- if (dir != enterdir && tracks & _enterdir_to_trackbits[dir]) { // any track incidating?
+ if (dir != enterdir && (tracks & _enterdir_to_trackbits[dir])) { // any track incidating?
TileIndex newtile = tile + TileOffsByDiagDir(dir); // new tile to check
DiagDirection newdir = ReverseDiagDir(dir); // direction we are entering from
if (!MaybeAddToTodoSet(newtile, newdir, tile, dir)) return flags | SF_FULL;
@@ -425,7 +425,7 @@ static void UpdateSignalsAroundSegment(SigFlags flags)
/* is it a bidir combo? - then do not count its other signal direction as exit */
if (sig == SIGTYPE_COMBO && HasSignalOnTrackdir(tile, ReverseTrackdir(trackdir))) {
/* at least one more exit */
- if (flags & SF_EXIT2 &&
+ if ((flags & SF_EXIT2) &&
/* no green exit */
(!(flags & SF_GREEN) ||
/* only one green exit, and it is this one - so all other exits are red */
@@ -433,7 +433,7 @@ static void UpdateSignalsAroundSegment(SigFlags flags)
newstate = SIGNAL_STATE_RED;
}
} else { // entry, at least one exit, no green exit
- if (IsPresignalEntry(tile, TrackdirToTrack(trackdir)) && flags & SF_EXIT && !(flags & SF_GREEN)) newstate = SIGNAL_STATE_RED;
+ if (IsPresignalEntry(tile, TrackdirToTrack(trackdir)) && (flags & SF_EXIT) && !(flags & SF_GREEN)) newstate = SIGNAL_STATE_RED;
}
}
@@ -535,7 +535,7 @@ static SigSegState UpdateSignalsInBuffer(Owner owner)
/* SIGSEG_FREE is set by default */
if (flags & SF_PBS) {
state = SIGSEG_PBS;
- } else if (flags & SF_TRAIN || (flags & SF_EXIT && !(flags & SF_GREEN)) || flags & SF_FULL) {
+ } else if ((flags & SF_TRAIN) || ((flags & SF_EXIT) && !(flags & SF_GREEN)) || (flags & SF_FULL)) {
state = SIGSEG_FULL;
}
}
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 4e5bb3c06..a4f9df11a 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -383,7 +383,7 @@ static void UpdateStationVirtCoord(Station *st)
Point pt = RemapCoords2(TileX(st->xy) * TILE_SIZE, TileY(st->xy) * TILE_SIZE);
pt.y -= 32;
- if (st->facilities & FACIL_AIRPORT && st->airport_type == AT_OILRIG) pt.y -= 16;
+ if ((st->facilities & FACIL_AIRPORT) && st->airport_type == AT_OILRIG) pt.y -= 16;
SetDParam(0, st->index);
SetDParam(1, st->facilities);
@@ -1849,7 +1849,7 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
uint num = 0;
const Station *st;
FOR_ALL_STATIONS(st) {
- if (st->town == t && st->facilities & FACIL_AIRPORT && st->airport_type != AT_OILRIG) num++;
+ if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport_type != AT_OILRIG) num++;
}
if (num >= 2) {
authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 418e7cdbd..dc42786cb 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -487,7 +487,7 @@ static void TileLoop_Town(TileIndex tile)
_current_company = OWNER_TOWN;
- if (hs->building_flags & BUILDING_HAS_1_TILE &&
+ if ((hs->building_flags & BUILDING_HAS_1_TILE) &&
HasBit(t->flags12, TOWN_IS_FUNDED) &&
CanDeleteHouse(tile) &&
GetHouseAge(tile) >= hs->minimum_life &&
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 91a4bccd2..eb75b2388 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1543,7 +1543,7 @@ CommandCost CmdSellRailWagon(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
}
/* 3. If it is still a valid train after selling, update its acceleration and cached values */
- if (flags & DC_EXEC && first != NULL) {
+ if ((flags & DC_EXEC) && first != NULL) {
NormaliseTrainConsist(first);
TrainConsistChanged(first, false);
UpdateTrainGroupID(first);
@@ -1705,7 +1705,7 @@ static Vehicle *TrainOnTileEnum(Vehicle *v, void *)
static Vehicle *TrainApproachingCrossingEnum(Vehicle *v, void *data)
{
/* not a train || not front engine || crashed */
- if (v->type != VEH_TRAIN || !IsFrontEngine(v) || v->vehstatus & VS_CRASHED) return NULL;
+ if (v->type != VEH_TRAIN || !IsFrontEngine(v) || (v->vehstatus & VS_CRASHED)) return NULL;
TileIndex tile = *(TileIndex*)data;
@@ -1974,7 +1974,7 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32
}
} else {
/* turn the whole train around */
- if (v->vehstatus & VS_CRASHED || v->breakdown_ctr != 0) return CMD_ERROR;
+ if ((v->vehstatus & VS_CRASHED) || v->breakdown_ctr != 0) return CMD_ERROR;
if (flags & DC_EXEC) {
/* Properly leave the station if we are loading and won't be loading anymore */
@@ -2257,7 +2257,7 @@ static void HandleLocomotiveSmokeCloud(const Train *v)
{
bool sound = false;
- if (v->vehstatus & VS_TRAIN_SLOWING || v->load_unload_time_rem != 0 || v->cur_speed < 2) {
+ if ((v->vehstatus & VS_TRAIN_SLOWING) || v->load_unload_time_rem != 0 || v->cur_speed < 2) {
return;
}
@@ -2353,7 +2353,7 @@ static void CheckNextTrainTile(Train *v)
if (_settings_game.pf.path_backoff_interval == 255) return;
/* Exit if we reached our destination depot or are inside a depot. */
- if ((v->tile == v->dest_tile && v->current_order.IsType(OT_GOTO_DEPOT)) || v->track & TRACK_BIT_DEPOT) return;
+ if ((v->tile == v->dest_tile && v->current_order.IsType(OT_GOTO_DEPOT)) || (v->track & TRACK_BIT_DEPOT)) return;
/* Exit if we are on a station tile and are going to stop. */
if (IsRailwayStationTile(v->tile) && v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile))) return;
/* Exit if the current order doesn't have a destination, but the train has orders. */
@@ -3305,7 +3305,7 @@ static int UpdateTrainSpeed(Train *v)
{
uint accel;
- if (v->vehstatus & VS_STOPPED || HasBit(v->flags, VRF_REVERSING) || HasBit(v->flags, VRF_TRAIN_STUCK)) {
+ if ((v->vehstatus & VS_STOPPED) || HasBit(v->flags, VRF_REVERSING) || HasBit(v->flags, VRF_TRAIN_STUCK)) {
switch (_settings_game.vehicle.train_acceleration_model) {
default: NOT_REACHED();
case TAM_ORIGINAL: accel = v->acceleration * -4; break;
@@ -3704,7 +3704,7 @@ static void TrainController(Train *v, Vehicle *nomove)
assert(chosen_track & (bits | GetReservedTrackbits(gp.new_tile)));
/* Check if it's a red signal and that force proceed is not clicked. */
- if (red_signals & chosen_track && v->force_proceed == 0) {
+ if ((red_signals & chosen_track) && v->force_proceed == 0) {
/* In front of a red signal */
Trackdir i = FindFirstTrackdir(trackdirbits);
@@ -4285,7 +4285,7 @@ static bool TrainLocoHandler(Train *v, bool mode)
}
/* exit if train is stopped */
- if (v->vehstatus & VS_STOPPED && v->cur_speed == 0) return true;
+ if ((v->vehstatus & VS_STOPPED) && v->cur_speed == 0) return true;
bool valid_order = !v->current_order.IsType(OT_NOTHING) && v->current_order.GetType() != OT_CONDITIONAL;
if (ProcessOrders(v) && CheckReverseTrain(v)) {
@@ -4350,7 +4350,7 @@ static bool TrainLocoHandler(Train *v, bool mode)
int j = UpdateTrainSpeed(v);
/* we need to invalidate the widget if we are stopping from 'Stopping 0 km/h' to 'Stopped' */
- if (v->cur_speed == 0 && v->tcache.last_speed == 0 && v->vehstatus & VS_STOPPED) {
+ if (v->cur_speed == 0 && v->tcache.last_speed == 0 && (v->vehstatus & VS_STOPPED)) {
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
}
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 11279e7e9..d883c650b 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -432,7 +432,7 @@ not_valid_below:;
}
}
- if (flags & DC_EXEC && transport_type == TRANSPORT_RAIL) {
+ if ((flags & DC_EXEC) && transport_type == TRANSPORT_RAIL) {
Track track = AxisToTrack(direction);
AddSideToSignalBuffer(tile_start, INVALID_DIAGDIR, _current_company);
YapfNotifyTrackLayoutChange(tile_start, track);
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 90423f935..4436aab06 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -273,7 +273,7 @@ static CommandCost ClearTile_Unmovable(TileIndex tile, DoCommandFlag flags)
}
/* checks if you're allowed to remove unmovable things */
- if (_game_mode != GM_EDITOR && _current_company != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) )
+ if (_game_mode != GM_EDITOR && _current_company != OWNER_WATER && ((flags & DC_AUTO) || !_cheats.magic_bulldozer.value) )
return_cmd_error(flags & DC_AUTO ? STR_ERROR_OBJECT_IN_THE_WAY : INVALID_STRING_ID);
if (IsStatue(tile)) {
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 10db2cf0b..19cd6021a 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -864,7 +864,7 @@ void CheckVehicleBreakdown(Vehicle *v)
v->reliability = rel = max((rel_old = v->reliability) - v->reliability_spd_dec, 0);
if ((rel_old >> 8) != (rel >> 8)) InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
- if (v->breakdown_ctr != 0 || v->vehstatus & VS_STOPPED ||
+ if (v->breakdown_ctr != 0 || (v->vehstatus & VS_STOPPED) ||
_settings_game.difficulty.vehicle_breakdowns < 1 ||
v->cur_speed < 5 || _game_mode == GM_MENU) {
return;
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index e579d7575..d1e5b4df3 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -67,7 +67,7 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
switch (v->type) {
case VEH_TRAIN:
- if (v->vehstatus & VS_STOPPED && ((Train *)v)->tcache.cached_power == 0) return_cmd_error(STR_TRAIN_START_NO_CATENARY);
+ if ((v->vehstatus & VS_STOPPED) && ((Train *)v)->tcache.cached_power == 0) return_cmd_error(STR_TRAIN_START_NO_CATENARY);
break;
case VEH_SHIP:
@@ -405,7 +405,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
}
} while (v->type == VEH_TRAIN && (v = GetNextVehicle((Train *)v)) != NULL);
- if (flags & DC_EXEC && v_front->type == VEH_TRAIN) {
+ if ((flags & DC_EXEC) && v_front->type == VEH_TRAIN) {
/* for trains this needs to be the front engine due to the callback function */
_new_vehicle_id = w_front->index;
}
diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp
index cbcda9f34..0e90daf90 100644
--- a/src/video/allegro_v.cpp
+++ b/src/video/allegro_v.cpp
@@ -327,7 +327,7 @@ static void PollEvent()
ClrBit(diff, button);
if (HasBit(mouse_b, button)) {
/* Pressed mouse button */
- if (_rightclick_emulate && key_shifts & KB_CTRL_FLAG) {
+ if (_rightclick_emulate && (key_shifts & KB_CTRL_FLAG)) {
button = RIGHT_BUTTON;
ClrBit(diff, RIGHT_BUTTON);
}
@@ -391,7 +391,7 @@ static void PollEvent()
if (mouse_action) HandleMouseEvents();
poll_keyboard();
- if (key_shifts & KB_ALT_FLAG && (key[KEY_ENTER] || key[KEY_F])) {
+ if ((key_shifts & KB_ALT_FLAG) && (key[KEY_ENTER] || key[KEY_F])) {
ToggleFullScreen(!_fullscreen);
} else if (keypressed()) {
HandleKeypress(ConvertAllegroKeyIntoMy());
diff --git a/src/widget.cpp b/src/widget.cpp
index 3375a3a2a..93f05dc15 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -141,12 +141,10 @@ void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y)
*/
int GetWidgetFromPos(const Window *w, int x, int y)
{
- uint index;
int found_index = -1;
- /* Go through the widgets and check if we find the widget that the coordinate is
- * inside. */
- for (index = 0; index < w->widget_count; index++) {
+ /* Go through the widgets and check if we find the widget that the coordinate is inside. */
+ for (uint index = 0; index < w->widget_count; index++) {
const Widget *wi = &w->widget[index];
if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) continue;
diff --git a/src/window.cpp b/src/window.cpp
index 66f3de3cf..077735d11 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -326,7 +326,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, bool double_click)
}
}
- if (w->desc_flags & WDF_RESIZABLE && widget_type == WWT_RESIZEBOX) {
+ if ((w->desc_flags & WDF_RESIZABLE) && widget_type == WWT_RESIZEBOX) {
/* When the resize widget is on the left size of the window
* we assume that that button is used to resize to the left. */
StartWindowSizing(w, wi->left < (w->width / 2));
@@ -334,7 +334,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, bool double_click)
return;
}
- if (w->desc_flags & WDF_STICKY_BUTTON && widget_type == WWT_STICKYBOX) {
+ if ((w->desc_flags & WDF_STICKY_BUTTON) && widget_type == WWT_STICKYBOX) {
w->flags4 ^= WF_STICKY;
w->InvalidateWidget(widget_index);
return;
@@ -1240,7 +1240,7 @@ static void DecreaseWindowCounters()
}
FOR_ALL_WINDOWS_FROM_FRONT(w) {
- if (w->flags4 & WF_TIMEOUT_MASK && !(--w->flags4 & WF_TIMEOUT_MASK)) {
+ if ((w->flags4 & WF_TIMEOUT_MASK) && !(--w->flags4 & WF_TIMEOUT_MASK)) {
w->OnTimeout();
if (w->desc_flags & WDF_UNCLICK_BUTTONS) w->RaiseButtons();
}
@@ -1551,7 +1551,7 @@ static bool HandleWindowDragging()
/* Now find the new cursor pos.. this is NOT _cursor, because we move in steps. */
_drag_delta.y += y;
- if (w->flags4 & WF_SIZING_LEFT && x != 0) {
+ if ((w->flags4 & WF_SIZING_LEFT) && x != 0) {
_drag_delta.x -= x; // x > 0 -> window gets longer -> left-edge moves to left -> subtract x to get new position.
w->SetDirty();
w->left -= x; // If dragging left edge, move left window edge in opposite direction by the same amount.