changeset 12082:d092f17a921d draft

(svn r16491) -Codechange: Added parentheses around bitwise operators for code style.
author alberth <alberth@openttd.org>
date Mon, 01 Jun 2009 11:43:36 +0000
parents f617f25c0cc1
children 8becf4c44755
files src/ai/api/ai_order.cpp src/ai/api/ai_town.cpp src/aircraft_cmd.cpp src/economy.cpp src/engine.cpp src/industry_cmd.cpp src/network/core/host.cpp src/network/network.cpp src/network/network_chat_gui.cpp src/network/network_server.cpp src/order_cmd.cpp src/rail_cmd.cpp src/road_cmd.cpp src/roadveh_cmd.cpp src/saveload/oldloader.cpp src/saveload/vehicle_sl.cpp src/signal.cpp src/station_cmd.cpp src/town_cmd.cpp src/train_cmd.cpp src/tunnelbridge_cmd.cpp src/unmovable_cmd.cpp src/vehicle.cpp src/vehicle_cmd.cpp src/video/allegro_v.cpp src/widget.cpp src/window.cpp
diffstat 27 files changed, 77 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -119,18 +119,18 @@
 {
 	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;
--- 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);
 }
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -110,10 +110,9 @@
 		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 @@
 
 	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 @@
 
 		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 @@
 
 	/* 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 @@
 	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},
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1125,7 +1125,7 @@
 
 	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 @@
 			 * 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);
 
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -692,7 +692,7 @@
 		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);
 			}
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1199,10 +1199,10 @@
 
 		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 @@
 		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 @@
 	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 @@
 		}
 	}
 
-	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;
 		}
--- a/src/network/core/host.cpp
+++ b/src/network/core/host.cpp
@@ -173,7 +173,7 @@
 
 			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;
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -462,7 +462,7 @@
 	}
 
 	/* 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);
 	}
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -96,7 +96,7 @@
 
 		/* 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
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -866,8 +866,8 @@
 	}
 
 
-	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;
 	}
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -1202,7 +1202,7 @@
 			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 @@
 	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 */
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -134,7 +134,7 @@
 	}
 
 	/* 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;
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -137,10 +137,10 @@
 	/* 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 @@
 							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);
 							}
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -440,8 +440,8 @@
 	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 @@
 	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 @@
 					 * 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 */
--- a/src/saveload/oldloader.cpp
+++ b/src/saveload/oldloader.cpp
@@ -105,8 +105,8 @@
 	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;
 		}
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -165,7 +165,7 @@
 		 * 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;
 			}
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -341,7 +341,7 @@
 				}
 
 				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 @@
 			/* 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 @@
 					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 @@
 			/* 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;
 			}
 		}
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -383,7 +383,7 @@
 	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 @@
 		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;
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -487,7 +487,7 @@
 
 	_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 &&
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1543,7 +1543,7 @@
 			}
 
 			/* 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 *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 @@
 		}
 	} 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 @@
 {
 	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 @@
 	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 @@
 {
 	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 @@
 					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 @@
 	}
 
 	/* 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 @@
 	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);
 	}
 
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -432,7 +432,7 @@
 		}
 	}
 
-	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);
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -273,7 +273,7 @@
 	}
 
 	/* 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)) {
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -864,7 +864,7 @@
 	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;
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -67,7 +67,7 @@
 
 	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 @@
 		}
 	} 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;
 	}
--- a/src/video/allegro_v.cpp
+++ b/src/video/allegro_v.cpp
@@ -327,7 +327,7 @@
 			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 @@
 	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());
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -141,12 +141,10 @@
  */
 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;
 
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -326,7 +326,7 @@
 			}
 		}
 
-		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 @@
 			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 @@
 	}
 
 	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 @@
 
 			/* 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.