(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
--- a/src/aircraft_cmd.cpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/aircraft_cmd.cpp Tue Nov 20 14:11:19 2007 +0000
@@ -574,7 +574,7 @@
* 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();
--- a/src/graph_gui.cpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/graph_gui.cpp Tue Nov 20 14:11:19 2007 +0000
@@ -281,7 +281,7 @@
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 @@
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);
}
--- a/src/helpers.hpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/helpers.hpp Tue Nov 20 14:11:19 2007 +0000
@@ -149,11 +149,6 @@
}
};
-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
--- a/src/macros.h Tue Nov 20 13:35:54 2007 +0000
+++ b/src/macros.h Tue Nov 20 14:11:19 2007 +0000
@@ -279,9 +279,9 @@
* @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));
}
--- a/src/main_gui.cpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/main_gui.cpp Tue Nov 20 14:11:19 2007 +0000
@@ -167,12 +167,12 @@
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);
--- a/src/order_cmd.cpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/order_cmd.cpp Tue Nov 20 14:11:19 2007 +0000
@@ -685,18 +685,18 @@
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 @@
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);
}
--- a/src/player_gui.cpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/player_gui.cpp Tue Nov 20 14:11:19 2007 +0000
@@ -402,7 +402,7 @@
}
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;
}
--- a/src/rail_cmd.cpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/rail_cmd.cpp Tue Nov 20 14:11:19 2007 +0000
@@ -666,7 +666,7 @@
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 @@
if (IsDiagonalTrackdir(trackdir)) {
signal_ctr++;
} else {
- ToggleBitT(trackdir, 0);
+ ToggleBit(trackdir, 0);
}
}
}
--- a/src/road_map.h Tue Nov 20 13:35:54 2007 +0000
+++ b/src/road_map.h Tue Nov 20 14:11:19 2007 +0000
@@ -218,7 +218,7 @@
#define ToggleDesert ToggleSnow
static inline void ToggleSnow(TileIndex t)
{
- TOGGLEBIT(_m[t].m3, 7);
+ ToggleBit(_m[t].m3, 7);
}
--- a/src/roadveh_cmd.cpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/roadveh_cmd.cpp Tue Nov 20 14:11:19 2007 +0000
@@ -482,7 +482,7 @@
* 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();
--- a/src/ship_cmd.cpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/ship_cmd.cpp Tue Nov 20 14:11:19 2007 +0000
@@ -1010,7 +1010,7 @@
* 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();
--- a/src/station_gui.cpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/station_gui.cpp Tue Nov 20 14:11:19 2007 +0000
@@ -400,7 +400,7 @@
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 @@
}
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++) {
--- a/src/train_cmd.cpp Tue Nov 20 13:35:54 2007 +0000
+++ b/src/train_cmd.cpp Tue Nov 20 14:11:19 2007 +0000
@@ -1651,7 +1651,7 @@
}
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 @@
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 @@
* 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();
--- a/src/transparency.h Tue Nov 20 13:35:54 2007 +0000
+++ b/src/transparency.h Tue Nov 20 14:11:19 2007 +0000
@@ -45,7 +45,7 @@
*/
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 */
--- a/src/window.h Tue Nov 20 13:35:54 2007 +0000
+++ b/src/window.h Tue Nov 20 14:11:19 2007 +0000
@@ -714,7 +714,7 @@
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);
}
/**