Changeset - r6106:0a01c2ed783b
[Not reviewed]
master
0 14 0
tron - 18 years ago 2007-02-22 08:43:02
tron@openttd.org
(svn r8841) -Fix

Remove {,u}intswap() and replace them by Swap()
14 files changed with 29 insertions and 34 deletions:
0 comments (0 inline, 0 general)
src/ai/default/default.cpp
Show inline comments
 
@@ -1543,13 +1543,13 @@ static bool AiCheckTrackResources(TileIn
 
		if (p->mode != 1) continue;
 

	
 
		tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 
		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);
 
			return values[cargo & 0x7F] != 0;
 
		} else {
 
			GetAcceptanceAroundTiles(values, tile2, w, h, rad);
src/clear_cmd.cpp
Show inline comments
 
@@ -367,14 +367,14 @@ int32 CmdLevelLand(TileIndex tile, uint3
 

	
 
	// make sure sx,sy are smaller than ex,ey
 
	ex = TileX(tile);
 
	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;
 
	size_y = ey-sy+1;
 

	
 
	money = GetAvailableMoneyForCommand();
src/landscape.cpp
Show inline comments
 
@@ -334,14 +334,14 @@ int32 CmdClearArea(TileIndex tile, uint3
 

	
 
	// make sure sx,sy are smaller than ex,ey
 
	ex = TileX(tile);
 
	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;
 

	
 
	for (x = sx; x <= ex; ++x) {
 
		for (y = sy; y <= ey; ++y) {
src/macros.h
Show inline comments
 
@@ -148,17 +148,12 @@ static inline int KillFirstBit2x64(int v
 
#define for_each_bit(_i, _b)            \
 
	for (_i = 0; _b != 0; _i++, _b >>= 1) \
 
		if (_b & 1)
 

	
 
#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)
 
{
 
	return FROM_LE16(*(const uint16*)x);
 
}
 

	
src/newgrf_station.cpp
Show inline comments
 
@@ -197,14 +197,14 @@ const StationSpec *GetCustomStationSpecB
 
 */
 
uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred)
 
{
 
	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 */
 
	platforms = min(15, platforms);
 
	length    = min(15, length);
 
	x = min(15, x);
src/rail_cmd.cpp
Show inline comments
 
@@ -911,14 +911,14 @@ int32 CmdConvertRail(TileIndex tile, uin
 

	
 
	// make sure sx,sy are smaller than ex,ey
 
	ex = TileX(tile);
 
	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;
 
	ret = 0;
 

	
 
	for (x = sx; x <= ex; ++x) {
src/rail_gui.cpp
Show inline comments
 
@@ -635,17 +635,17 @@ static void HandleStationPlacement(TileI
 
	uint sx = TileX(start);
 
	uint sy = TileY(start);
 
	uint ex = TileX(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),
 
			_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
 
			CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
 
}
 
@@ -701,13 +701,13 @@ static void StationBuildWndProc(Window *
 

	
 
		if (_railstation.dragdrop) {
 
			SetTileSelectSize(1, 1);
 
		} 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);
 
		}
 

	
 
		rad = (_patches.modified_catchment) ? CA_TRAIN : 4;
 

	
src/station_cmd.cpp
Show inline comments
 
@@ -2130,13 +2130,13 @@ static uint32 VehicleEnter_Station(Vehic
 
						v->last_station_visited != station_id) {
 
					DiagDirection dir = DirToDiagDir(v->direction);
 

	
 
					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 */
 
						if (x < 12) {
 
							uint16 spd;
 

	
 
@@ -2815,13 +2815,13 @@ static void Load_STNS(void)
 

	
 
		// this means it's an oldstyle savegame without support for nonuniform stations
 
		if (st->train_tile != 0 && st->trainst_h == 0) {
 
			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;
 
		}
 
	}
 

	
 
	/* This is to ensure all pointers are within the limits of _stations_size */
src/terraform_gui.cpp
Show inline comments
 
@@ -37,14 +37,14 @@ static void GenerateDesertArea(TileIndex
 
	int sy = TileY(start);
 
	int ex = TileX(end);
 
	int ey = TileY(end);
 

	
 
	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;
 

	
 
	_generating_world = true;
 
	BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
 
		if (GetTileType(tile) != MP_WATER) {
 
@@ -65,14 +65,14 @@ static void GenerateRockyArea(TileIndex 
 
	int sy = TileY(start);
 
	int ex = TileX(end);
 
	int ey = TileY(end);
 

	
 
	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;
 

	
 
	BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
 
		switch (GetTileType(tile)) {
 
			case MP_CLEAR:
src/tree_cmd.cpp
Show inline comments
 
@@ -225,14 +225,14 @@ int32 CmdPlantTree(TileIndex tile, uint3
 

	
 
	// make sure sx,sy are smaller than ex,ey
 
	ex = TileX(tile);
 
	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
 

	
 
	for (x = sx; x <= ex; x++) {
 
		for (y = sy; y <= ey; y++) {
 
			TileIndex tile = TileXY(x, y);
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -215,16 +215,16 @@ int32 CmdBuildBridge(TileIndex end_tile,
 
	sy = TileY(p1);
 

	
 
	/* check if valid, and make sure that (x,y) are smaller than (sx,sy) */
 
	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);
 
	}
 

	
 
	/* set and test bridge length, availability */
 
	bridge_len = sx + sy - x - y - 1;
src/vehicle.cpp
Show inline comments
 
@@ -177,14 +177,14 @@ Vehicle *FindVehicleBetween(TileIndex fr
 
	int x2 = TileX(to);
 
	int y2 = TileY(to);
 
	Vehicle *veh;
 

	
 
	/* 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;
 
		if ((veh->type == VEH_Train || veh->type == VEH_Road) && (z==0xFF || veh->z_pos == z)) {
 
			if ((veh->x_pos>>4) >= x1 && (veh->x_pos>>4) <= x2 &&
 
					(veh->y_pos>>4) >= y1 && (veh->y_pos>>4) <= y2) {
src/viewport.cpp
Show inline comments
 
@@ -1878,14 +1878,14 @@ void UpdateTileSelection(void)
 
		if (x1 != -1) {
 
			int x2 = _thd.selstart.x;
 
			int y2 = _thd.selstart.y;
 
			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;
 
			_thd.new_size.y = y2 - y1 + TILE_SIZE;
 
			_thd.new_drawstyle = _thd.next_drawstyle;
 
		}
src/water_cmd.cpp
Show inline comments
 
@@ -226,14 +226,14 @@ int32 CmdBuildCanal(TileIndex tile, uint
 
	y = TileY(tile);
 
	sx = TileX(p1);
 
	sy = TileY(p1);
 

	
 
	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;
 

	
 
	/* Outside the editor you can only drag canals, and not areas */
 
	if (_game_mode != GM_EDITOR && (sx != x && sy != y)) return CMD_ERROR;
 

	
0 comments (0 inline, 0 general)