changeset 7929:4d13dbed828c draft

(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
author skidd13 <skidd13@openttd.org>
date Mon, 19 Nov 2007 21:32:20 +0000
parents 4e8dfd103163
children 89b01facb974
files src/aircraft_cmd.cpp src/bridge_map.h src/console.cpp src/economy.cpp src/elrail.cpp src/gfxinit.cpp src/helpers.hpp src/macros.h src/main_gui.cpp src/misc_gui.cpp src/network/network_gui.cpp src/newgrf.cpp src/newgrf_config.cpp src/npf.h src/oldloader.cpp src/openttd.cpp src/order_cmd.cpp src/rail.h src/rail_cmd.cpp src/road_map.h src/roadveh_cmd.cpp src/ship_cmd.cpp src/signs_gui.cpp src/station.cpp src/station_cmd.cpp src/timetable_cmd.cpp src/town_cmd.cpp src/train.h src/train_cmd.cpp src/tunnelbridge_cmd.cpp src/unmovable_cmd.cpp src/viewport.cpp
diffstat 32 files changed, 93 insertions(+), 98 deletions(-) [+]
line wrap: on
line diff
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -573,7 +573,7 @@
 			 * Now we change the setting to apply the new one and let the vehicle head for the same hangar.
 			 * Note: the if is (true for requesting service == true for ordered to stop in hangar) */
 			if (flags & DC_EXEC) {
-				CLRBIT(v->current_order.flags, OFB_PART_OF_ORDERS);
+				ClrBit(v->current_order.flags, OFB_PART_OF_ORDERS);
 				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
 				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 			}
--- a/src/bridge_map.h
+++ b/src/bridge_map.h
@@ -184,7 +184,7 @@
 static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
 {
 	assert(MayHaveBridgeAbove(t));
-	CLRBIT(_m[t].m6, 6 + a);
+	ClrBit(_m[t].m6, 6 + a);
 }
 
 
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -310,7 +310,7 @@
 		case ICONSOLE_OPENED: case ICONSOLE_FULL:
 			DeleteWindowById(WC_CONSOLE, 0);
 			_iconsole_mode = ICONSOLE_CLOSED;
-			CLRBIT(_no_scroll, SCROLL_CON);
+			ClrBit(_no_scroll, SCROLL_CON);
 			break;
 	}
 
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -341,7 +341,7 @@
 
 		/* Reset the ratings for the old player */
 		t->ratings[old_player] = 500;
-		CLRBIT(t->have_ratings, old_player);
+		ClrBit(t->have_ratings, old_player);
 	}
 
 	{
@@ -1425,7 +1425,7 @@
 	_current_player = front_v->owner;
 
 	/* At this moment loading cannot be finished */
-	CLRBIT(front_v->vehicle_flags, VF_LOADING_FINISHED);
+	ClrBit(front_v->vehicle_flags, VF_LOADING_FINISHED);
 
 	/* Start unloading in at the first possible moment */
 	front_v->load_unload_time_rem = 1;
@@ -1576,7 +1576,7 @@
 			} else {
 				/* The order changed while unloading (unset unload/transfer) or the
 				 * station does not accept goods anymore. */
-				CLRBIT(v->vehicle_flags, VF_CARGO_UNLOADING);
+				ClrBit(v->vehicle_flags, VF_CARGO_UNLOADING);
 				continue;
 			}
 
@@ -1590,7 +1590,7 @@
 				completely_empty = false;
 			} else {
 				/* We have finished unloading (cargo count == 0) */
-				CLRBIT(v->vehicle_flags, VF_CARGO_UNLOADING);
+				ClrBit(v->vehicle_flags, VF_CARGO_UNLOADING);
 			}
 
 			continue;
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -307,7 +307,7 @@
 		/* Level means that the slope is the same, or the track is flat */
 		if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) {
 			for (k = 0; k < NUM_IGNORE_GROUPS; k++)
-				if (PPPpreferred[i] == IgnoredPCP[k][tlg][i]) CLRBIT(PCPstatus, i);
+				if (PPPpreferred[i] == IgnoredPCP[k][tlg][i]) ClrBit(PCPstatus, i);
 		}
 
 		/* Now decide where we draw our pylons. First try the preferred PPPs, but they may not exist.
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -375,7 +375,7 @@
 	GRFConfig *master = CallocT<GRFConfig>(1);
 	master->filename = strdup(files->openttd.filename);
 	FillGRFDetails(master, false);
-	ClrBitT(master->flags, GCF_INIT_ONLY);
+	ClrBit(master->flags, GCF_INIT_ONLY);
 	master->next = top;
 	_grfconfig = master;
 
--- a/src/helpers.hpp
+++ b/src/helpers.hpp
@@ -149,11 +149,6 @@
 	}
 };
 
-template <typename T> void ClrBitT(T &t, int bit_index)
-{
-	t = (T)(t & ~((T)1 << bit_index));
-}
-
 template <typename T> void SetBitT(T &t, int bit_index)
 {
 	t = (T)(t | ((T)1 << bit_index));
--- a/src/macros.h
+++ b/src/macros.h
@@ -263,9 +263,9 @@
  * @param y The bit position to clear
  * @return The new value of the old value with the bit cleared
  */
-template<typename T> static inline T CLRBIT(T& x, const uint8 y)
+template<typename T> static inline T ClrBit(T& x, const uint8 y)
 {
-	return x &= ~((T)1U << y);
+	return x = (T)(x & ~((T)1U << y));
 }
 
 /**
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -822,7 +822,7 @@
 	int dis = -1;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_TRAIN && IsFrontEngine(v)) CLRBIT(dis, v->owner);
+		if (v->type == VEH_TRAIN && IsFrontEngine(v)) ClrBit(dis, v->owner);
 	}
 	PopupMainPlayerToolbMenu(w, 13, dis);
 }
@@ -833,7 +833,7 @@
 	int dis = -1;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_ROAD && IsRoadVehFront(v)) CLRBIT(dis, v->owner);
+		if (v->type == VEH_ROAD && IsRoadVehFront(v)) ClrBit(dis, v->owner);
 	}
 	PopupMainPlayerToolbMenu(w, 14, dis);
 }
@@ -844,7 +844,7 @@
 	int dis = -1;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_SHIP) CLRBIT(dis, v->owner);
+		if (v->type == VEH_SHIP) ClrBit(dis, v->owner);
 	}
 	PopupMainPlayerToolbMenu(w, 15, dis);
 }
@@ -855,7 +855,7 @@
 	int dis = -1;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_AIRCRAFT) CLRBIT(dis, v->owner);
+		if (v->type == VEH_AIRCRAFT) ClrBit(dis, v->owner);
 	}
 	PopupMainPlayerToolbMenu(w, 16, dis);
 }
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -1162,7 +1162,7 @@
 				e.event = WE_ON_EDIT_TEXT_CANCEL;
 				parent->wndproc(parent, &e);
 			}
-			CLRBIT(_no_scroll, SCROLL_EDIT);
+			ClrBit(_no_scroll, SCROLL_EDIT);
 			break;
 		}
 }
@@ -1624,7 +1624,7 @@
 			DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
 		}
 		FiosFreeSavegameList();
-		CLRBIT(_no_scroll, SCROLL_SAVE);
+		ClrBit(_no_scroll, SCROLL_SAVE);
 		break;
 	case WE_RESIZE: {
 		/* Widget 2 and 3 have to go with halve speed, make it so obiwan */
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -1738,7 +1738,7 @@
 
 	case WE_DESTROY:
 		SendWindowMessage(WC_NEWS_WINDOW, 0, WE_DESTROY, 0, 0);
-		CLRBIT(_no_scroll, SCROLL_CHAT);
+		ClrBit(_no_scroll, SCROLL_CHAT);
 		break;
 	}
 }
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -949,7 +949,7 @@
 					dts->ground_pal = grf_load_word(&buf);
 					if (dts->ground_sprite == 0) continue;
 					if (HasBit(dts->ground_pal, 15)) {
-						CLRBIT(dts->ground_pal, 15);
+						ClrBit(dts->ground_pal, 15);
 						SETBIT(dts->ground_sprite, SPRITE_MODIFIER_USE_OFFSET);
 					}
 
@@ -972,16 +972,16 @@
 
 						/* Remap flags as ours collide */
 						if (HasBit(dtss->pal, 15)) {
-							CLRBIT(dtss->pal, 15);
+							ClrBit(dtss->pal, 15);
 							SETBIT(dtss->image, SPRITE_MODIFIER_USE_OFFSET);
 						}
 
 						if (HasBit(dtss->image, 15)) {
-							CLRBIT(dtss->image, 15);
+							ClrBit(dtss->image, 15);
 							SETBIT(dtss->image, PALETTE_MODIFIER_COLOR);
 						}
 						if (HasBit(dtss->image, 14)) {
-							CLRBIT(dtss->image, 14);
+							ClrBit(dtss->image, 14);
 							SETBIT(dtss->image, PALETTE_MODIFIER_TRANSPARENT);
 						}
 					}
@@ -1180,7 +1180,7 @@
 						}
 
 						/* Clear old color modifer bit */
-						CLRBIT(image, 15);
+						ClrBit(image, 15);
 
 						bridge->sprite_table[tableid][sprite].sprite = image;
 						bridge->sprite_table[tableid][sprite].pal    = pal;
@@ -1574,7 +1574,7 @@
 					cs->grfid = _cur_grffile->grfid;
 					SETBIT(_cargo_mask, cid + i);
 				} else {
-					CLRBIT(_cargo_mask, cid + i);
+					ClrBit(_cargo_mask, cid + i);
 				}
 				break;
 
@@ -2583,15 +2583,15 @@
 					group->g.layout.dts->ground_pal    = grf_load_word(&buf);
 					/* Remap transparent/colour modifier bits */
 					if (HasBit(group->g.layout.dts->ground_sprite, 14)) {
-						CLRBIT(group->g.layout.dts->ground_sprite, 14);
+						ClrBit(group->g.layout.dts->ground_sprite, 14);
 						SETBIT(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_TRANSPARENT);
 					}
 					if (HasBit(group->g.layout.dts->ground_sprite, 15)) {
-						CLRBIT(group->g.layout.dts->ground_sprite, 15);
+						ClrBit(group->g.layout.dts->ground_sprite, 15);
 						SETBIT(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_COLOR);
 					}
 					if (HasBit(group->g.layout.dts->ground_pal, 14)) {
-						CLRBIT(group->g.layout.dts->ground_pal, 14);
+						ClrBit(group->g.layout.dts->ground_pal, 14);
 						SETBIT(group->g.layout.dts->ground_sprite, SPRITE_MODIFIER_OPAQUE);
 					}
 					if (HasBit(group->g.layout.dts->ground_pal, 15)) {
@@ -2599,7 +2599,7 @@
 						 * last spriteset defined. */
 						SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground_sprite, 0, 14) * sprites;
 						SB(group->g.layout.dts->ground_sprite, 0, SPRITE_WIDTH, sprite);
-						CLRBIT(group->g.layout.dts->ground_pal, 15);
+						ClrBit(group->g.layout.dts->ground_pal, 15);
 					}
 
 					group->g.layout.dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1);
@@ -2613,15 +2613,15 @@
 						seq->delta_y = grf_load_byte(&buf);
 
 						if (HasBit(seq->image, 14)) {
-							CLRBIT(seq->image, 14);
+							ClrBit(seq->image, 14);
 							SETBIT(seq->image, PALETTE_MODIFIER_TRANSPARENT);
 						}
 						if (HasBit(seq->image, 15)) {
-							CLRBIT(seq->image, 15);
+							ClrBit(seq->image, 15);
 							SETBIT(seq->image, PALETTE_MODIFIER_COLOR);
 						}
 						if (HasBit(seq->pal, 14)) {
-							CLRBIT(seq->pal, 14);
+							ClrBit(seq->pal, 14);
 							SETBIT(seq->image, SPRITE_MODIFIER_OPAQUE);
 						}
 						if (HasBit(seq->pal, 15)) {
@@ -2629,7 +2629,7 @@
 							 * last spriteset defined. */
 							SpriteID sprite = _cur_grffile->spriteset_start + GB(seq->image, 0, 14) * sprites;
 							SB(seq->image, 0, SPRITE_WIDTH, sprite);
-							CLRBIT(seq->pal, 15);
+							ClrBit(seq->pal, 15);
 						}
 
 						if (type > 0) {
@@ -3115,7 +3115,7 @@
 	bool generic   = HasBit(lang, 7);
 	uint16 id      = generic ? grf_load_word(&buf) : grf_load_byte(&buf);
 
-	CLRBIT(lang, 7);
+	ClrBit(lang, 7);
 
 	if (feature <= GSF_AIRCRAFT && id < _vehcounts[feature]) {
 		id += _vehshifts[feature];
@@ -3257,7 +3257,7 @@
 	uint16 num = grf_load_extended(&buf);
 	uint16 skip_num = 0;
 	uint16 offset = HasBit(type, 7) ? grf_load_extended(&buf) : 0;
-	CLRBIT(type, 7); // Clear the high bit as that only indicates whether there is an offset.
+	ClrBit(type, 7); // Clear the high bit as that only indicates whether there is an offset.
 
 	switch (type) {
 		case 0x04: // Signal graphics
@@ -3874,7 +3874,7 @@
 		grfmsg(7, "GRFLoadError: Skipping non-fatal GRFLoadError in stage %d", _cur_stage);
 		return;
 	}
-	CLRBIT(severity, 7);
+	ClrBit(severity, 7);
 
 	if (severity >= lengthof(sevstr)) {
 		grfmsg(7, "GRFLoadError: Invalid severity id %d. Setting to 2 (non-fatal error).", severity);
@@ -4371,7 +4371,7 @@
 
 	if (HasBit(id, 7)) {
 		/* Final definition */
-		CLRBIT(id, 7);
+		ClrBit(id, 7);
 		bool new_scheme = _cur_grffile->grf_version >= 7;
 
 		if (!check_length(len, 1, "FeatureTownName: lang_id")) return;
@@ -4380,7 +4380,7 @@
 
 		byte nb_gen = townname->nb_gen;
 		do {
-			CLRBIT(lang, 7);
+			ClrBit(lang, 7);
 
 			if (!check_length(len, 1, "FeatureTownName: style name")) return;
 			const char *name = grf_load_string(&buf, len);
@@ -5607,7 +5607,7 @@
 			if (stage == GLS_RESERVE) {
 				SETBIT(c->flags, GCF_RESERVED);
 			} else if (stage == GLS_ACTIVATION) {
-				CLRBIT(c->flags, GCF_RESERVED);
+				ClrBit(c->flags, GCF_RESERVED);
 				ClearTemporaryNewGRFData();
 				BuildCargoTranslationMap();
 				DEBUG(sprite, 2, "LoadNewGRF: Currently %i sprites are loaded", _cur_spriteid);
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -136,7 +136,7 @@
 			if (src->error->custom_message != NULL) c->error->custom_message = strdup(src->error->custom_message);
 		}
 
-		CLRBIT(c->flags, GCF_INIT_ONLY);
+		ClrBit(c->flags, GCF_INIT_ONLY);
 		if (init_only) SETBIT(c->flags, GCF_INIT_ONLY);
 
 		*dst = c;
--- a/src/npf.h
+++ b/src/npf.h
@@ -123,7 +123,7 @@
 	if (value)
 		SETBIT(node->user_data[NPF_NODE_FLAGS], flag);
 	else
-		CLRBIT(node->user_data[NPF_NODE_FLAGS], flag);
+		ClrBit(node->user_data[NPF_NODE_FLAGS], flag);
 }
 
 #endif /* NPF_H */
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -333,7 +333,7 @@
 		if (v->type == VEH_ROAD &&
 				v->u.road.state != RVSB_IN_DEPOT &&
 				v->u.road.state != RVSB_WORMHOLE) {
-			CLRBIT(v->u.road.state, RVS_IS_STOPPING);
+			ClrBit(v->u.road.state, RVS_IS_STOPPING);
 		}
 
 		FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1536,8 +1536,8 @@
 						SB(_m[t].m2, 0, 4, tmp);
 					} else if (HasBit(_m[t].m5, 2)) {
 						/* Split waypoint and depot rail type and remove the subtype. */
-						CLRBIT(_m[t].m5, 2);
-						CLRBIT(_m[t].m5, 6);
+						ClrBit(_m[t].m5, 2);
+						ClrBit(_m[t].m5, 6);
 					}
 					break;
 
@@ -1776,23 +1776,23 @@
 
 						/* move the signal variant back */
 						SetSignalVariant(t, TRACK_X, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
-						CLRBIT(_m[t].m2, 3);
+						ClrBit(_m[t].m2, 3);
 					}
 
 					/* Clear PBS reservation on track */
 					if (!IsTileDepotType(t, TRANSPORT_RAIL)) {
 						SB(_m[t].m4, 4, 4, 0);
 					} else {
-						CLRBIT(_m[t].m3, 6);
+						ClrBit(_m[t].m3, 6);
 					}
 					break;
 
 				case MP_ROAD: /* Clear PBS reservation on crossing */
-					if (IsLevelCrossing(t)) CLRBIT(_m[t].m5, 0);
+					if (IsLevelCrossing(t)) ClrBit(_m[t].m5, 0);
 					break;
 
 				case MP_STATION: /* Clear PBS reservation on station */
-					CLRBIT(_m[t].m3, 6);
+					ClrBit(_m[t].m3, 6);
 					break;
 
 				default: break;
@@ -1939,11 +1939,11 @@
 					/* The "lift has destination" bit has been moved from
 					 * m5[7] to m7[0]. */
 					SB(_me[t].m7, 0, 1, HasBit(_m[t].m5, 7));
-					CLRBIT(_m[t].m5, 7);
+					ClrBit(_m[t].m5, 7);
 
 					/* The "lift is moving" bit has been removed, as it does
 					 * the same job as the "lift has destination" bit. */
-					CLRBIT(_m[t].m1, 7);
+					ClrBit(_m[t].m1, 7);
 
 					/* The position of the lift goes from m1[7..0] to m6[7..2],
 					 * making m1 totally free, now. The lift position does not
@@ -2039,7 +2039,7 @@
 				CargoPacket *cp = *it;
 				cp->paid_for = HasBit(v->vehicle_flags, 2);
 			}
-			CLRBIT(v->vehicle_flags, 2);
+			ClrBit(v->vehicle_flags, 2);
 			v->cargo.InvalidateCache();
 		}
 	}
@@ -2101,7 +2101,7 @@
 
 				/* The loading finished flag is *only* set when actually completely
 				 * finished. Because the vehicle is loading, it is not finished. */
-				CLRBIT(v->vehicle_flags, VF_LOADING_FINISHED);
+				ClrBit(v->vehicle_flags, VF_LOADING_FINISHED);
 			}
 		}
 	} else if (CheckSavegameVersion(59)) {
@@ -2136,7 +2136,7 @@
 				SetSignalStates(t, GB(_m[t].m2, 4, 4));
 				SetSignalVariant(t, INVALID_TRACK, GetSignalVariant(t, TRACK_X));
 				SetSignalType(t, INVALID_TRACK, GetSignalType(t, TRACK_X));
-				CLRBIT(_m[t].m2, 7);
+				ClrBit(_m[t].m2, 7);
 			}
 		}
 	}
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -686,11 +686,11 @@
 		switch (p2) {
 		case OFB_FULL_LOAD:
 			TOGGLEBIT(order->flags, OFB_FULL_LOAD);
-			if (order->type != OT_GOTO_DEPOT) CLRBIT(order->flags, OFB_UNLOAD);
+			if (order->type != OT_GOTO_DEPOT) ClrBit(order->flags, OFB_UNLOAD);
 			break;
 		case OFB_UNLOAD:
 			TOGGLEBIT(order->flags, OFB_UNLOAD);
-			CLRBIT(order->flags, OFB_FULL_LOAD);
+			ClrBit(order->flags, OFB_FULL_LOAD);
 			break;
 		case OFB_NON_STOP:
 			TOGGLEBIT(order->flags, OFB_NON_STOP);
--- a/src/rail.h
+++ b/src/rail.h
@@ -312,7 +312,7 @@
 {
 	if (*tracks != TRACK_BIT_NONE && *tracks != INVALID_TRACK_BIT) {
 		Track first = (Track)FIND_FIRST_BIT(*tracks);
-		ClrBitT(*tracks, first);
+		ClrBit(*tracks, first);
 		return first;
 	}
 	return INVALID_TRACK;
@@ -336,7 +336,7 @@
 {
 	if (*trackdirs != TRACKDIR_BIT_NONE && *trackdirs != INVALID_TRACKDIR_BIT) {
 		Trackdir first = (Trackdir)FindFirstBit2x64(*trackdirs);
-		ClrBitT(*trackdirs, first);
+		ClrBit(*trackdirs, first);
 		return first;
 	}
 	return INVALID_TRACKDIR;
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -685,7 +685,7 @@
  */
 CommandCost CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	return CmdRailTrackHelper(tile, flags, p1, CLRBIT(p2, 7));
+	return CmdRailTrackHelper(tile, flags, p1, ClrBit(p2, 7));
 }
 
 /** Build rail on a stretch of track.
@@ -895,7 +895,7 @@
 			if (IsDiagonalTrackdir(trackdir)) {
 				signal_ctr++;
 				/* Ensure signal_ctr even so X and Y pieces get signals */
-				CLRBIT(signal_ctr, 0);
+				ClrBit(signal_ctr, 0);
 			}
 			return true;
 
--- a/src/road_map.h
+++ b/src/road_map.h
@@ -194,7 +194,7 @@
 static inline void UnbarCrossing(TileIndex t)
 {
 	assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
-	CLRBIT(_m[t].m4, 5);
+	ClrBit(_m[t].m4, 5);
 }
 
 static inline void BarCrossing(TileIndex t)
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -481,7 +481,7 @@
 			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
 			 * Note: the if is (true for requesting service == true for ordered to stop in depot) */
 			if (flags & DC_EXEC) {
-				CLRBIT(v->current_order.flags, OFB_PART_OF_ORDERS);
+				ClrBit(v->current_order.flags, OFB_PART_OF_ORDERS);
 				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
 				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 			}
@@ -1657,7 +1657,7 @@
 				 * For drive-through stops, only do it if the vehicle stopped here */
 				if (IsStandardRoadStopTile(v->tile) || HasBit(v->u.road.state, RVS_IS_STOPPING)) {
 					rs->FreeBay(HasBit(v->u.road.state, RVS_USING_SECOND_BAY));
-					CLRBIT(v->u.road.state, RVS_IS_STOPPING);
+					ClrBit(v->u.road.state, RVS_IS_STOPPING);
 				}
 				if (IsStandardRoadStopTile(v->tile)) rs->SetEntranceBusy(false);
 			}
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -1009,7 +1009,7 @@
 			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
 			 * Note: the if is (true for requesting service == true for ordered to stop in depot)          */
 			if (flags & DC_EXEC) {
-				CLRBIT(v->current_order.flags, OFB_PART_OF_ORDERS);
+				ClrBit(v->current_order.flags, OFB_PART_OF_ORDERS);
 				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
 				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 			}
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -276,7 +276,7 @@
 			break;
 
 		case WE_DESTROY:
-			CLRBIT(_no_scroll, SCROLL_EDIT);
+			ClrBit(_no_scroll, SCROLL_EDIT);
 			break;
 	}
 }
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -455,7 +455,7 @@
 	uint bay_nr = 0;
 	while (!HasBit(status, bay_nr)) bay_nr++;
 
-	CLRBIT(status, bay_nr);
+	ClrBit(status, bay_nr);
 	return bay_nr;
 }
 
@@ -466,7 +466,7 @@
 void RoadStop::AllocateDriveThroughBay(uint nr)
 {
 	assert(nr < MAX_BAY_COUNT);
-	CLRBIT(status, nr);
+	ClrBit(status, nr);
 }
 
 /**
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -262,7 +262,7 @@
 				if (str <= 0x20) {
 					if (str == M(STR_SV_STNAME_FOREST))
 						str = M(STR_SV_STNAME_WOODS);
-					CLRBIT(free_names, str);
+					ClrBit(free_names, str);
 				}
 			}
 		}
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -122,7 +122,7 @@
 			/* Start autofilling the timetable, which clears all the current
 			 * timings and clears the "timetable has started" bit. */
 			SETBIT(v->vehicle_flags, VF_AUTOFILL_TIMETABLE);
-			CLRBIT(v->vehicle_flags, VF_TIMETABLE_STARTED);
+			ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
 
 			for (Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) {
 				order->wait_time = 0;
@@ -132,7 +132,7 @@
 			v->current_order.wait_time = 0;
 			v->current_order.travel_time = 0;
 		} else {
-			CLRBIT(v->vehicle_flags, VF_AUTOFILL_TIMETABLE);
+			ClrBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE);
 		}
 	}
 
@@ -173,7 +173,7 @@
 		} else if (v->cur_order_index == 0) {
 			/* Otherwise if we're at the beginning and it already has a value,
 			 * assume that autofill is finished and turn it off again. */
-			CLRBIT(v->vehicle_flags, VF_AUTOFILL_TIMETABLE);
+			ClrBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE);
 		}
  	}
 
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1849,9 +1849,9 @@
 
 	/* Clear flags for houses that only may exist once/town. */
 	if (hs->building_flags & BUILDING_IS_CHURCH) {
-		CLRBIT(t->flags12, TOWN_HAS_CHURCH);
+		ClrBit(t->flags12, TOWN_HAS_CHURCH);
 	} else if (hs->building_flags & BUILDING_IS_STADIUM) {
-		CLRBIT(t->flags12, TOWN_HAS_STADIUM);
+		ClrBit(t->flags12, TOWN_HAS_STADIUM);
 	}
 
 	/* Do the actual clearing of tiles */
@@ -2140,7 +2140,7 @@
 		}
 	}
 
-	CLRBIT(t->flags12, TOWN_IS_FUNDED);
+	ClrBit(t->flags12, TOWN_IS_FUNDED);
 	if (_patches.town_growth_rate == 0 && t->fund_buildings_months == 0) return;
 
 	/** Towns are processed every TOWN_GROWTH_FREQUENCY ticks, and this is the
--- a/src/train.h
+++ b/src/train.h
@@ -50,7 +50,7 @@
 static inline void ClearFrontEngine(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	CLRBIT(v->subtype, Train_Front);
+	ClrBit(v->subtype, Train_Front);
 }
 
 /** Check if a vehicle is an articulated part of an engine
@@ -78,7 +78,7 @@
 static inline void ClearArticulatedPart(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	CLRBIT(v->subtype, Train_Articulated_Part);
+	ClrBit(v->subtype, Train_Articulated_Part);
 }
 
 /** Check if a vehicle is a wagon
@@ -106,7 +106,7 @@
 static inline void ClearTrainWagon(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	CLRBIT(v->subtype, Train_Wagon);
+	ClrBit(v->subtype, Train_Wagon);
 }
 
 /** Check if a vehicle is an engine (can be first in a train)
@@ -134,7 +134,7 @@
 static inline void ClearTrainEngine(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	CLRBIT(v->subtype, Train_Engine);
+	ClrBit(v->subtype, Train_Engine);
 }
 
 /** Check if a vehicle is a free wagon (got no engine in front of it)
@@ -162,7 +162,7 @@
 static inline void ClearFreeWagon(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	CLRBIT(v->subtype, Train_Free_Wagon);
+	ClrBit(v->subtype, Train_Free_Wagon);
 }
 
 /** Check if a vehicle is a multiheaded engine
@@ -190,7 +190,7 @@
 static inline void ClearMultiheaded(Vehicle *v)
 {
 	assert(v->type == VEH_TRAIN);
-	CLRBIT(v->subtype, Train_Multiheaded);
+	ClrBit(v->subtype, Train_Multiheaded);
 }
 
 /** Check if an engine has an articulated part.
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -208,7 +208,7 @@
 				/* wagon is powered */
 				SETBIT(u->u.rail.flags, VRF_POWEREDWAGON); // cache 'powered' status
 			} else {
-				CLRBIT(u->u.rail.flags, VRF_POWEREDWAGON);
+				ClrBit(u->u.rail.flags, VRF_POWEREDWAGON);
 			}
 
 			/* Do not count powered wagons for the compatible railtypes, as wagons always
@@ -1458,10 +1458,10 @@
 	byte flag2 = *swap_flag2;
 
 	/* Clear the flags */
-	CLRBIT(*swap_flag1, VRF_GOINGUP);
-	CLRBIT(*swap_flag1, VRF_GOINGDOWN);
-	CLRBIT(*swap_flag2, VRF_GOINGUP);
-	CLRBIT(*swap_flag2, VRF_GOINGDOWN);
+	ClrBit(*swap_flag1, VRF_GOINGUP);
+	ClrBit(*swap_flag1, VRF_GOINGDOWN);
+	ClrBit(*swap_flag2, VRF_GOINGUP);
+	ClrBit(*swap_flag2, VRF_GOINGDOWN);
 
 	/* Reverse the rail-flags (if needed) */
 	if (HasBit(flag1, VRF_GOINGUP)) {
@@ -1620,7 +1620,7 @@
 		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 	}
 
-	CLRBIT(v->u.rail.flags, VRF_REVERSING);
+	ClrBit(v->u.rail.flags, VRF_REVERSING);
 }
 
 /** Reverse train.
@@ -1907,7 +1907,7 @@
 			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
 			 * Note: the if is (true for requesting service == true for ordered to stop in depot)          */
 			if (flags & DC_EXEC) {
-				CLRBIT(v->current_order.flags, OFB_PART_OF_ORDERS);
+				ClrBit(v->current_order.flags, OFB_PART_OF_ORDERS);
 				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
 				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 			}
@@ -2277,7 +2277,7 @@
 		/* route found, is the train marked with "path not found" flag? */
 		if (HasBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION)) {
 			/* clear the flag as the PF's problem was solved */
-			CLRBIT(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION);
+			ClrBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION);
 			/* can we also delete the "News" item somehow? */
 		}
 	}
@@ -2553,8 +2553,8 @@
 	v->z_pos = GetSlopeZ(v->x_pos, v->y_pos);
 
 	if (new_tile) {
-		CLRBIT(v->u.rail.flags, VRF_GOINGUP);
-		CLRBIT(v->u.rail.flags, VRF_GOINGDOWN);
+		ClrBit(v->u.rail.flags, VRF_GOINGUP);
+		ClrBit(v->u.rail.flags, VRF_GOINGDOWN);
 
 		if (v->u.rail.track == TRACK_BIT_X || v->u.rail.track == TRACK_BIT_Y) {
 			/* Any track that isn't TRACK_BIT_X or TRACK_BIT_Y cannot be sloped.
@@ -3538,7 +3538,7 @@
 				BEGIN_ENUM_WAGONS(u) {
 					const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
 
-					CLRBIT(u->subtype, 7);
+					ClrBit(u->subtype, 7);
 					switch (u->subtype) {
 						case 0: /* TS_Front_Engine */
 							if (rvi->railveh_type == RAILVEH_MULTIHEAD) SetMultiheaded(u);
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -1485,8 +1485,8 @@
 			}
 			if (v->type == VEH_TRAIN) {
 				v->u.rail.track = TRACK_BIT_WORMHOLE;
-				CLRBIT(v->u.rail.flags, VRF_GOINGUP);
-				CLRBIT(v->u.rail.flags, VRF_GOINGDOWN);
+				ClrBit(v->u.rail.flags, VRF_GOINGUP);
+				ClrBit(v->u.rail.flags, VRF_GOINGDOWN);
 			} else {
 				v->u.road.state = RVSB_WORMHOLE;
 			}
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -218,7 +218,7 @@
 
 	if (IsStatue(tile)) {
 		TownID town = GetStatueTownID(tile);
-		CLRBIT(GetTown(town)->statues, _current_player);
+		ClrBit(GetTown(town)->statues, _current_player);
 		InvalidateWindow(WC_TOWN_AUTHORITY, town);
 	}
 
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -163,7 +163,7 @@
 
 void DeleteWindowViewport(Window *w)
 {
-	CLRBIT(_active_viewports, w->viewport - _viewports);
+	ClrBit(_active_viewports, w->viewport - _viewports);
 	w->viewport->width = 0;
 	w->viewport = NULL;
 }