diff options
author | tron <tron@openttd.org> | 2007-02-22 08:43:02 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2007-02-22 08:43:02 +0000 |
commit | 103d119c510a83c3b0cca20328ad4d87e8159d6a (patch) | |
tree | 2048730a2bf93500bc8d9112bae1371da5ba8b87 /src | |
parent | 0d041a87cc475253176f796c156a3c49032eb415 (diff) | |
download | openttd-103d119c510a83c3b0cca20328ad4d87e8159d6a.tar.xz |
(svn r8841) -Fix
Remove {,u}intswap() and replace them by Swap()
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/default/default.cpp | 2 | ||||
-rw-r--r-- | src/clear_cmd.cpp | 4 | ||||
-rw-r--r-- | src/landscape.cpp | 4 | ||||
-rw-r--r-- | src/macros.h | 5 | ||||
-rw-r--r-- | src/newgrf_station.cpp | 4 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 4 | ||||
-rw-r--r-- | src/rail_gui.cpp | 8 | ||||
-rw-r--r-- | src/station_cmd.cpp | 4 | ||||
-rw-r--r-- | src/terraform_gui.cpp | 8 | ||||
-rw-r--r-- | src/tree_cmd.cpp | 4 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 4 | ||||
-rw-r--r-- | src/vehicle.cpp | 4 | ||||
-rw-r--r-- | src/viewport.cpp | 4 | ||||
-rw-r--r-- | src/water_cmd.cpp | 4 |
14 files changed, 29 insertions, 34 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index f8af9c333..85114276b 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -1546,7 +1546,7 @@ static bool AiCheckTrackResources(TileIndex tile, const AiDefaultBlockData *p, b w = GB(p->attr, 1, 3); h = GB(p->attr, 4, 3); - if (p->attr & 1) uintswap(w, h); + if (p->attr & 1) Swap(w, h); if (cargo & 0x80) { GetProductionAroundTiles(values, tile2, w, h, rad); diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index ef5eef730..32612dc81 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -370,8 +370,8 @@ int32 CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) ey = TileY(tile); sx = TileX(p1); sy = TileY(p1); - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); tile = TileXY(sx, sy); size_x = ex-sx+1; diff --git a/src/landscape.cpp b/src/landscape.cpp index 171e1718b..c790d9c04 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -337,8 +337,8 @@ int32 CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) ey = TileY(tile); sx = TileX(p1); sy = TileY(p1); - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); money = GetAvailableMoneyForCommand(); cost = 0; diff --git a/src/macros.h b/src/macros.h index a16d4ddb3..d48903b90 100644 --- a/src/macros.h +++ b/src/macros.h @@ -151,11 +151,6 @@ static inline int KillFirstBit2x64(int value) #define abs myabs -static inline int intxchg_(int *a, int b) { int t = *a; *a = b; return t; } -#define intswap(a,b) ((b) = intxchg_(&(a), (b))) -static inline int uintxchg_(uint *a, uint b) { uint t = *a; *a = b; return t; } -#define uintswap(a,b) ((b) = uintxchg_(&(a), (b))) - static inline uint16 ReadLE16Aligned(const void* x) { diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index f84b34ec0..9c39bc04e 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -200,8 +200,8 @@ uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, i uint32 retval = 0; if (axis == AXIS_X) { - intswap(platforms, length); - intswap(x, y); + Swap(platforms, length); + Swap(x, y); } /* Limit our sizes to 4 bits */ diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 5a978834e..18eb0f1d0 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -914,8 +914,8 @@ int32 CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) ey = TileY(tile); sx = TileX(p1); sy = TileY(p1); - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); money = GetAvailableMoneyForCommand(); cost = 0; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 36e191202..56ae23ac5 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -638,11 +638,11 @@ static void HandleStationPlacement(TileIndex start, TileIndex end) uint ey = TileY(end); uint w,h; - if (sx > ex) uintswap(sx,ex); - if (sy > ey) uintswap(sy,ey); + if (sx > ex) Swap(sx, ex); + if (sy > ey) Swap(sy, ey); w = ex - sx + 1; h = ey - sy + 1; - if (!_railstation.orientation) uintswap(w,h); + if (!_railstation.orientation) Swap(w, h); DoCommandP(TileXY(sx, sy), _railstation.orientation | (w << 8) | (h << 16), @@ -704,7 +704,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) } else { int x = _railstation.numtracks; int y = _railstation.platlength; - if (_railstation.orientation == 0) intswap(x,y); + if (_railstation.orientation == 0) Swap(x, y); if (!_remove_button_clicked) SetTileSelectSize(x, y); } diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 9cb8a9fac..da42a4447 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2133,7 +2133,7 @@ static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y) x &= 0xF; y &= 0xF; - if (DiagDirToAxis(dir) != AXIS_X) intswap(x, y); + if (DiagDirToAxis(dir) != AXIS_X) Swap(x, y); if (y == TILE_SIZE / 2) { if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x; if (x == 12) return VETSB_ENTERED_STATION | (station_id << VETS_STATION_ID_OFFSET); /* enter station */ @@ -2818,7 +2818,7 @@ static void Load_STNS(void) uint w = GB(st->trainst_w, 4, 4); uint h = GB(st->trainst_w, 0, 4); - if (GetRailStationAxis(st->train_tile) == AXIS_Y) uintswap(w, h); + if (GetRailStationAxis(st->train_tile) != AXIS_X) Swap(w, h); st->trainst_w = w; st->trainst_h = h; } diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index ca8c75255..095ec7ca4 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -40,8 +40,8 @@ static void GenerateDesertArea(TileIndex end, TileIndex start) if (_game_mode != GM_EDITOR) return; - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); size_x = (ex - sx) + 1; size_y = (ey - sy) + 1; @@ -68,8 +68,8 @@ static void GenerateRockyArea(TileIndex end, TileIndex start) if (_game_mode != GM_EDITOR) return; - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); size_x = (ex - sx) + 1; size_y = (ey - sy) + 1; diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 32754af94..3121a5b2a 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -228,8 +228,8 @@ int32 CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) ey = TileY(tile); sx = TileX(p2); sy = TileY(p2); - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); cost = 0; // total cost diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index c370f0735..ba40104a8 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -218,10 +218,10 @@ int32 CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) if (x == sx) { if (y == sy) return_cmd_error(STR_5008_CANNOT_START_AND_END_ON); direction = AXIS_Y; - if (y > sy) uintswap(y,sy); + if (y > sy) Swap(y, sy); } else if (y == sy) { direction = AXIS_X; - if (x > sx) uintswap(x,sx); + if (x > sx) Swap(x, sx); } else { return_cmd_error(STR_500A_START_AND_END_MUST_BE_IN); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ac5f93fbc..1e4ed0dcc 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -180,8 +180,8 @@ Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_c /* Make sure x1 < x2 or y1 < y2 */ if (x1 > x2 || y1 > y2) { - intswap(x1,x2); - intswap(y1,y2); + Swap(x1, x2); + Swap(y1, y2); } FOR_ALL_VEHICLES(veh) { if (without_crashed && (veh->vehstatus & VS_CRASHED) != 0) continue; diff --git a/src/viewport.cpp b/src/viewport.cpp index edba8cd94..b34e94fbf 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1881,8 +1881,8 @@ void UpdateTileSelection(void) x1 &= ~0xF; y1 &= ~0xF; - if (x1 >= x2) intswap(x1,x2); - if (y1 >= y2) intswap(y1,y2); + if (x1 >= x2) Swap(x1, x2); + if (y1 >= y2) Swap(y1, y2); _thd.new_pos.x = x1; _thd.new_pos.y = y1; _thd.new_size.x = x2 - x1 + TILE_SIZE; diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index cd42138d5..b6905ad33 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -229,8 +229,8 @@ int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - if (x < sx) intswap(x, sx); - if (y < sy) intswap(y, sy); + if (x < sx) Swap(x, sx); + if (y < sy) Swap(y, sy); size_x = (x - sx) + 1; size_y = (y - sy) + 1; |