(svn r8841) -Fix
authortron
Thu, 22 Feb 2007 08:43:02 +0000
changeset 6106 2898cd9417fd
parent 6105 760134e9dab6
child 6107 2a0a919dc46a
(svn r8841) -Fix

Remove {,u}intswap() and replace them by Swap()
src/ai/default/default.cpp
src/clear_cmd.cpp
src/landscape.cpp
src/macros.h
src/newgrf_station.cpp
src/rail_cmd.cpp
src/rail_gui.cpp
src/station_cmd.cpp
src/terraform_gui.cpp
src/tree_cmd.cpp
src/tunnelbridge_cmd.cpp
src/vehicle.cpp
src/viewport.cpp
src/water_cmd.cpp
--- a/src/ai/default/default.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/ai/default/default.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -1546,7 +1546,7 @@
 		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);
--- a/src/clear_cmd.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/clear_cmd.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -370,8 +370,8 @@
 	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;
--- a/src/landscape.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/landscape.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -337,8 +337,8 @@
 	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;
--- a/src/macros.h	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/macros.h	Thu Feb 22 08:43:02 2007 +0000
@@ -151,11 +151,6 @@
 
 #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)
 {
--- a/src/newgrf_station.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/newgrf_station.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -200,8 +200,8 @@
 	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 */
--- a/src/rail_cmd.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/rail_cmd.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -914,8 +914,8 @@
 	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;
--- a/src/rail_gui.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/rail_gui.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -638,11 +638,11 @@
 	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 @@
 		} 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);
 		}
--- a/src/station_cmd.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/station_cmd.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -2133,7 +2133,7 @@
 					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 @@
 			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;
 		}
--- a/src/terraform_gui.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/terraform_gui.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -40,8 +40,8 @@
 
 	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 @@
 
 	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;
 
--- a/src/tree_cmd.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/tree_cmd.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -228,8 +228,8 @@
 	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
 
--- a/src/tunnelbridge_cmd.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/tunnelbridge_cmd.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -218,10 +218,10 @@
 	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);
 	}
--- a/src/vehicle.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/vehicle.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -180,8 +180,8 @@
 
 	/* 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;
--- a/src/viewport.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/viewport.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -1881,8 +1881,8 @@
 			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;
--- a/src/water_cmd.cpp	Thu Feb 22 06:57:21 2007 +0000
+++ b/src/water_cmd.cpp	Thu Feb 22 08:43:02 2007 +0000
@@ -229,8 +229,8 @@
 
 	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;