summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskidd13 <skidd13@openttd.org>2007-11-20 14:11:19 +0000
committerskidd13 <skidd13@openttd.org>2007-11-20 14:11:19 +0000
commitf92f3aec06203081ca8fadcbc5fb652e92bf8e30 (patch)
tree4c9dc0c05cd700da1675c02c334dcc834adf512c
parent3ae50673a3e1e64a6038c53570c5ee168073e038 (diff)
downloadopenttd-f92f3aec06203081ca8fadcbc5fb652e92bf8e30.tar.xz
(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
-rw-r--r--src/aircraft_cmd.cpp2
-rw-r--r--src/graph_gui.cpp4
-rw-r--r--src/helpers.hpp5
-rw-r--r--src/macros.h4
-rw-r--r--src/main_gui.cpp12
-rw-r--r--src/order_cmd.cpp10
-rw-r--r--src/player_gui.cpp2
-rw-r--r--src/rail_cmd.cpp4
-rw-r--r--src/road_map.h2
-rw-r--r--src/roadveh_cmd.cpp2
-rw-r--r--src/ship_cmd.cpp2
-rw-r--r--src/station_gui.cpp4
-rw-r--r--src/train_cmd.cpp6
-rw-r--r--src/transparency.h2
-rw-r--r--src/window.h2
15 files changed, 29 insertions, 34 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 221fdaca1..fb455d1b8 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -574,7 +574,7 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
* 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);
- TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
+ ToggleBit(v->current_order.flags, OFB_HALT_IN_DEPOT);
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
return CommandCost();
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index fb1105e62..f7e267056 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -281,7 +281,7 @@ static void GraphLegendWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
if (!IS_INT_INSIDE(e->we.click.widget, 3, 11)) return;
- TOGGLEBIT(_legend_excluded_players, e->we.click.widget - 3);
+ ToggleBit(_legend_excluded_players, e->we.click.widget - 3);
ToggleWidgetLoweredState(w, e->we.click.widget);
SetWindowDirty(w);
InvalidateWindow(WC_INCOME_GRAPH, 0);
@@ -760,7 +760,7 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
if (e->we.click.widget >= 3) {
- TOGGLEBIT(_legend_excluded_cargo, e->we.click.widget - 3);
+ ToggleBit(_legend_excluded_cargo, e->we.click.widget - 3);
ToggleWidgetLoweredState(w, e->we.click.widget);
SetWindowDirty(w);
}
diff --git a/src/helpers.hpp b/src/helpers.hpp
index e873d38ee..cb9bd1dcc 100644
--- a/src/helpers.hpp
+++ b/src/helpers.hpp
@@ -149,11 +149,6 @@ template <typename Tenum_t> struct TinyEnumT
}
};
-template <typename T> void ToggleBitT(T &t, int bit_index)
-{
- t = (T)(t ^ ((T)1 << bit_index));
-}
-
/**
* Overflow safe template for integers, i.e. integers that will never overflow
* you multiply the maximum value with 2, or add 2, or substract somethng from
diff --git a/src/macros.h b/src/macros.h
index 4ad64c032..71ecb4c1e 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -279,9 +279,9 @@ template<typename T> static inline T ClrBit(T& x, const uint8 y)
* @param y The bit position to toggle
* @return The new value of the old value with the bit toggled
*/
-template<typename T> static inline T TOGGLEBIT(T& x, const uint8 y)
+template<typename T> static inline T ToggleBit(T& x, const uint8 y)
{
- return x ^= (T)1U << y;
+ return x = (T)(x ^ (T)(1U << y));
}
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 9d55ff35b..374548127 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -167,12 +167,12 @@ static void MenuClickSettings(int index)
case 3: ShowNewGRFSettings(!_networking, true, true, &_grfconfig); return;
case 4: ShowTransparencyToolbar(); break;
- case 6: TOGGLEBIT(_display_opt, DO_SHOW_TOWN_NAMES); break;
- case 7: TOGGLEBIT(_display_opt, DO_SHOW_STATION_NAMES); break;
- case 8: TOGGLEBIT(_display_opt, DO_SHOW_SIGNS); break;
- case 9: TOGGLEBIT(_display_opt, DO_WAYPOINTS); break;
- case 10: TOGGLEBIT(_display_opt, DO_FULL_ANIMATION); break;
- case 11: TOGGLEBIT(_display_opt, DO_FULL_DETAIL); break;
+ case 6: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break;
+ case 7: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
+ case 8: ToggleBit(_display_opt, DO_SHOW_SIGNS); break;
+ case 9: ToggleBit(_display_opt, DO_WAYPOINTS); break;
+ case 10: ToggleBit(_display_opt, DO_FULL_ANIMATION); break;
+ case 11: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
case 12:
ToggleTransparency(TO_TREES);
ToggleTransparency(TO_HOUSES);
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index c342164bf..590810429 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -685,18 +685,18 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) {
switch (p2) {
case OFB_FULL_LOAD:
- TOGGLEBIT(order->flags, OFB_FULL_LOAD);
+ ToggleBit(order->flags, OFB_FULL_LOAD);
if (order->type != OT_GOTO_DEPOT) ClrBit(order->flags, OFB_UNLOAD);
break;
case OFB_UNLOAD:
- TOGGLEBIT(order->flags, OFB_UNLOAD);
+ ToggleBit(order->flags, OFB_UNLOAD);
ClrBit(order->flags, OFB_FULL_LOAD);
break;
case OFB_NON_STOP:
- TOGGLEBIT(order->flags, OFB_NON_STOP);
+ ToggleBit(order->flags, OFB_NON_STOP);
break;
case OFB_TRANSFER:
- TOGGLEBIT(order->flags, OFB_TRANSFER);
+ ToggleBit(order->flags, OFB_TRANSFER);
break;
default: NOT_REACHED();
}
@@ -720,7 +720,7 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (sel_ord == u->cur_order_index &&
u->current_order.type != OT_GOTO_DEPOT &&
HasBit(u->current_order.flags, OFB_FULL_LOAD) != HasBit(order->flags, OFB_FULL_LOAD)) {
- TOGGLEBIT(u->current_order.flags, OFB_FULL_LOAD);
+ ToggleBit(u->current_order.flags, OFB_FULL_LOAD);
}
InvalidateVehicleOrder(u);
}
diff --git a/src/player_gui.cpp b/src/player_gui.cpp
index 87a3266ac..4658d44ca 100644
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -402,7 +402,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
}
if (_ctrl_pressed) {
- TOGGLEBIT(WP(w, livery_d).sel, j);
+ ToggleBit(WP(w, livery_d).sel, j);
} else {
WP(w, livery_d).sel = 1 << j;
}
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index a25fe4853..30f67e63e 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -666,7 +666,7 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, u
tile += ToTileIndexDiff(_trackdelta[trackdir]);
/* toggle railbit for the non-diagonal tracks */
- if (!IsDiagonalTrackdir(trackdir)) ToggleBitT(trackdir, 0);
+ if (!IsDiagonalTrackdir(trackdir)) ToggleBit(trackdir, 0);
}
return (total_cost.GetCost() == 0) ? CMD_ERROR : total_cost;
@@ -1033,7 +1033,7 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1,
if (IsDiagonalTrackdir(trackdir)) {
signal_ctr++;
} else {
- ToggleBitT(trackdir, 0);
+ ToggleBit(trackdir, 0);
}
}
}
diff --git a/src/road_map.h b/src/road_map.h
index b6860a146..bf8fb0f81 100644
--- a/src/road_map.h
+++ b/src/road_map.h
@@ -218,7 +218,7 @@ static inline bool IsOnSnow(TileIndex t)
#define ToggleDesert ToggleSnow
static inline void ToggleSnow(TileIndex t)
{
- TOGGLEBIT(_m[t].m3, 7);
+ ToggleBit(_m[t].m3, 7);
}
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index dd4b3f547..c153089e0 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -482,7 +482,7 @@ CommandCost CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint3
* 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);
- TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
+ ToggleBit(v->current_order.flags, OFB_HALT_IN_DEPOT);
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
return CommandCost();
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 6983bef2f..99fe66200 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -1010,7 +1010,7 @@ CommandCost CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
* 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);
- TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
+ ToggleBit(v->current_order.flags, OFB_HALT_IN_DEPOT);
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
return CommandCost();
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index e92529375..3c8d9119c 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -400,7 +400,7 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
case STATIONLIST_WIDGET_AIRPLANE:
case STATIONLIST_WIDGET_SHIP:
if (_ctrl_pressed) {
- TOGGLEBIT(facilities, e->we.click.widget - STATIONLIST_WIDGET_TRAIN);
+ ToggleBit(facilities, e->we.click.widget - STATIONLIST_WIDGET_TRAIN);
ToggleWidgetLoweredState(w, e->we.click.widget);
} else {
for (uint i = 0; facilities != 0; i++, facilities >>= 1) {
@@ -487,7 +487,7 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
}
if (_ctrl_pressed) {
- TOGGLEBIT(_cargo_filter, c);
+ ToggleBit(_cargo_filter, c);
ToggleWidgetLoweredState(w, e->we.click.widget);
} else {
for (uint i = STATIONLIST_WIDGET_CARGOSTART; i < w->widget_count; i++) {
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 18636387e..75a431bc1 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1651,7 +1651,7 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, ui
}
if (flags & DC_EXEC) {
- TOGGLEBIT(v->u.rail.flags, VRF_REVERSE_DIRECTION);
+ ToggleBit(v->u.rail.flags, VRF_REVERSE_DIRECTION);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
}
@@ -1661,7 +1661,7 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, ui
if (flags & DC_EXEC) {
if (_patches.realistic_acceleration && v->cur_speed != 0) {
- TOGGLEBIT(v->u.rail.flags, VRF_REVERSING);
+ ToggleBit(v->u.rail.flags, VRF_REVERSING);
} else {
v->cur_speed = 0;
SetLastSpeed(v, 0);
@@ -1908,7 +1908,7 @@ CommandCost CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32
* 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);
- TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
+ ToggleBit(v->current_order.flags, OFB_HALT_IN_DEPOT);
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
return CommandCost();
diff --git a/src/transparency.h b/src/transparency.h
index 02daf7b20..fff77d70d 100644
--- a/src/transparency.h
+++ b/src/transparency.h
@@ -45,7 +45,7 @@ static inline bool IsTransparencySet(TransparencyOption to)
*/
static inline void ToggleTransparency(TransparencyOption to)
{
- TOGGLEBIT(_transparency_opt, to);
+ ToggleBit(_transparency_opt, to);
}
/** Toggle all transparency options (except signs) or restore the stored transparencies */
diff --git a/src/window.h b/src/window.h
index 00cf40b98..9a80c44be 100644
--- a/src/window.h
+++ b/src/window.h
@@ -714,7 +714,7 @@ static inline void SetWindowWidgetLoweredState(Window *w, byte widget_index, boo
static inline void ToggleWidgetLoweredState(Window *w, byte widget_index)
{
assert(widget_index < w->widget_count);
- TOGGLEBIT(w->widget[widget_index].display_flags, WIDG_LOWERED);
+ ToggleBit(w->widget[widget_index].display_flags, WIDG_LOWERED);
}
/**