Changeset - r1902:cfc758cf1057
[Not reviewed]
master
0 11 0
tron - 19 years ago 2005-06-04 12:13:24
tron@openttd.org
(svn r2408) Introduce SetTileOwner() and use it
11 files changed with 37 insertions and 29 deletions:
0 comments (0 inline, 0 general)
landscape.c
Show inline comments
 
@@ -451,7 +451,7 @@ void ConvertGroundTilesIntoWaterTiles(vo
 
		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h == 0) {
 
			SetTileType(tile, MP_WATER);
 
			_map5[tile] = 0;
 
			_map_owner[tile] = OWNER_WATER;
 
			SetTileOwner(tile, OWNER_WATER);
 
		}
 
	}
 
}
openttd.c
Show inline comments
 
@@ -1188,11 +1188,9 @@ static void ConvertTownOwner(void)
 
			if ((_map5[tile] & 0xF0) == 0x10 && _map3_lo[tile] & 0x80)
 
				_map3_lo[tile] = OWNER_TOWN;
 

	
 
			if (_map_owner[tile] & 0x80)
 
				_map_owner[tile] = OWNER_TOWN;
 
			if (_map_owner[tile] & 0x80) SetTileOwner(tile, OWNER_TOWN);
 
		} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
			if (_map_owner[tile] & 0x80)
 
				_map_owner[tile] = OWNER_TOWN;
 
			if (_map_owner[tile] & 0x80) SetTileOwner(tile, OWNER_TOWN);
 
		}
 
	}
 
}
 
@@ -1300,7 +1298,7 @@ bool AfterLoadGame(uint version)
 

	
 
		BEGIN_TILE_LOOP(tile_cur, w, h, tile)
 
			if (IsTileType(tile_cur, MP_WATER) && GetTileOwner(tile_cur) >= MAX_PLAYERS)
 
				_map_owner[tile_cur] = OWNER_WATER;
 
				SetTileOwner(tile_cur, OWNER_WATER);
 
		END_TILE_LOOP(tile_cur, w, h, tile)
 
	}
 

	
rail_cmd.c
Show inline comments
 
@@ -316,7 +316,7 @@ int32 CmdBuildSingleRail(int x, int y, u
 
					cost += ret;
 

	
 
					if (flags & DC_EXEC) {
 
						_map_owner[tile] = _current_player;
 
						SetTileOwner(tile, _current_player);
 
						_map3_lo[tile] &= ~0x0F;
 
						_map3_lo[tile] |= p1;
 
						_map5[tile] = (m5 & 0xC7) | 0x20; // railroad under bridge
 
@@ -365,7 +365,7 @@ int32 CmdBuildSingleRail(int x, int y, u
 
					)) {
 
				if (flags & DC_EXEC) {
 
					_map3_lo[tile] = GetTileOwner(tile);
 
					_map_owner[tile] = _current_player;
 
					SetTileOwner(tile, _current_player);
 
					_map3_hi[tile] = p1;
 
					_map5[tile] = 0x10 | (rail_bit == 1 ? 0x08 : 0x00); // level crossing
 
				}
 
@@ -387,7 +387,7 @@ int32 CmdBuildSingleRail(int x, int y, u
 

	
 
			if (flags & DC_EXEC) {
 
				SetTileType(tile, MP_RAILWAY);
 
				_map_owner[tile] = _current_player;
 
				SetTileOwner(tile, _current_player);
 
				_map2[tile] = 0; // Bare land
 
				_map3_lo[tile] = p1; // No signals, rail type
 
				_map5[tile] = rail_bit;
 
@@ -461,7 +461,7 @@ int32 CmdRemoveSingleRail(int x, int y, 
 
		if (!(flags & DC_EXEC))
 
			return _price.remove_rail;
 

	
 
		_map_owner[tile] = OWNER_NONE;
 
		SetTileOwner(tile, OWNER_NONE);
 
		_map5[tile] = ti.map5 & 0xC7;
 
	} else if (ti.type == MP_STREET) {
 
		byte m5;
 
@@ -485,7 +485,7 @@ int32 CmdRemoveSingleRail(int x, int y, 
 
			return _price.remove_rail;
 

	
 
		_map5[tile] = m5;
 
		_map_owner[tile] = _map3_lo[tile];
 
		SetTileOwner(tile, _map3_lo[tile]);
 
		_map2[tile] = 0;
 
	} else {
 
		assert(ti.type == MP_RAILWAY);
 
@@ -2028,7 +2028,7 @@ static void ChangeTileOwner_Track(uint t
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != 255) {
 
		_map_owner[tile] = new_player;
 
		SetTileOwner(tile, new_player);
 
	}	else {
 
		DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
	}
road_cmd.c
Show inline comments
 
@@ -195,7 +195,7 @@ int32 CmdRemoveRoad(int x, int y, uint32
 
		if (flags & DC_EXEC) {
 
			ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
 
			_map5[tile] = ti.map5 & 0xC7;
 
			_map_owner[tile] = OWNER_NONE;
 
			SetTileOwner(tile, OWNER_NONE);
 
			MarkTileDirtyByTile(tile);
 
		}
 
		return cost;
 
@@ -470,7 +470,7 @@ do_clear:;
 
			SetTileType(tile, MP_STREET);
 
			_map5[tile] = 0;
 
			_map2[tile] = p2;
 
			_map_owner[tile] = _current_player;
 
			SetTileOwner(tile, _current_player);
 
		}
 

	
 
		_map5[tile] |= (byte)pieces;
 
@@ -1148,14 +1148,14 @@ static void ChangeTileOwner_Road(uint ti
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != 255) {
 
		_map_owner[tile] = new_player;
 
		SetTileOwner(tile, new_player);
 
	}	else {
 
		b = _map5[tile]&0xF0;
 
		if (b == 0) {
 
			_map_owner[tile] = OWNER_NONE;
 
			SetTileOwner(tile, OWNER_NONE);
 
		} else if (b == 0x10) {
 
			_map5[tile] = (_map5[tile]&8) ? 0x5 : 0xA;
 
			_map_owner[tile] = _map3_lo[tile];
 
			SetTileOwner(tile, _map3_lo[tile]);
 
			_map3_lo[tile] = 0;
 
			_map3_hi[tile] &= 0x80;
 
		} else {
station_cmd.c
Show inline comments
 
@@ -2827,7 +2827,7 @@ void BuildOilRig(uint tile)
 

	
 
			SetTileType(tile, MP_STATION);
 
			_map5[tile] = 0x4B;
 
			_map_owner[tile] = OWNER_NONE;
 
			SetTileOwner(tile, OWNER_NONE);
 
			_map3_lo[tile] = 0;
 
			_map3_hi[tile] = 0;
 
			_map2[tile] = st->index;
 
@@ -2884,7 +2884,7 @@ static void ChangeTileOwner_Station(uint
 

	
 
	if (new_player != 255) {
 
		Station *st = GetStation(_map2[tile]);
 
		_map_owner[tile] = new_player;
 
		SetTileOwner(tile, new_player);
 
		st->owner = new_player;
 
		_global_station_sort_dirty = true; // transfer ownership of station to another player
 
		InvalidateWindowClasses(WC_STATION_LIST);
tile.h
Show inline comments
 
@@ -88,6 +88,16 @@ static inline Owner GetTileOwner(TileInd
 
	return _map_owner[tile];
 
}
 

	
 
static inline void SetTileOwner(TileIndex tile, Owner owner)
 
{
 
	assert(tile < MapSize());
 
	assert(!IsTileType(tile, MP_HOUSE));
 
	assert(!IsTileType(tile, MP_VOID));
 
	assert(!IsTileType(tile, MP_INDUSTRY));
 

	
 
	_map_owner[tile] = owner;
 
}
 

	
 
static inline bool IsTileOwner(TileIndex tile, Owner owner)
 
{
 
	return GetTileOwner(tile) == owner;
town_cmd.c
Show inline comments
 
@@ -746,7 +746,7 @@ static int GrowTownAtRoad(Town *t, uint 
 
			else if (_game_mode == GM_EDITOR) {
 
				/* If we are in the SE, and this road-piece has no town owner yet, it just found an
 
				*  owner :) (happy happy happy road now) */
 
				_map_owner[tile] = OWNER_TOWN;
 
				SetTileOwner(tile, OWNER_TOWN);
 
				_map2[tile] = t->index;
 
			}
 
		}
tree_cmd.c
Show inline comments
 
@@ -580,7 +580,7 @@ static void TileLoop_Trees(uint tile)
 
				if ((m2&0x30) != 0x20) // if not on snow/desert, then on rough land
 
					m5 = 7;
 
			}
 
			_map_owner[tile] = OWNER_NONE;
 
			SetTileOwner(tile, OWNER_NONE);
 
		}
 
	} else {
 
		/* in the middle of a transition, change to next */
tunnelbridge_cmd.c
Show inline comments
 
@@ -711,7 +711,7 @@ static int32 DoClearBridge(uint tile, ui
 

	
 
		if (flags & DC_EXEC) {
 
			_map5[tile] = _map5[tile] & ~0x38;
 
			_map_owner[tile] = OWNER_NONE;
 
			SetTileOwner(tile, OWNER_NONE);
 
			MarkTileDirtyByTile(tile);
 
		}
 
		return cost;
 
@@ -726,7 +726,7 @@ static int32 DoClearBridge(uint tile, ui
 
		cost = _price.clear_water;
 
		if (flags & DC_EXEC) {
 
			_map5[tile] = _map5[tile] & ~0x38;
 
			_map_owner[tile] = OWNER_NONE;
 
			SetTileOwner(tile, OWNER_NONE);
 
			MarkTileDirtyByTile(tile);
 
		}
 
		return cost;
 
@@ -1373,7 +1373,7 @@ static void ChangeTileOwner_TunnelBridge
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != 255) {
 
		_map_owner[tile] = new_player;
 
		SetTileOwner(tile, new_player);
 
	}	else {
 
		if((_map5[tile] & 0xC0)==0xC0) {
 
			// the stuff BELOW the middle part is owned by the deleted player.
 
@@ -1382,7 +1382,7 @@ static void ChangeTileOwner_TunnelBridge
 
				_map5[tile] &= ~(1 << 5 | 1 << 4 | 1 << 3); // no transport route under bridge anymore..
 
			} else {
 
				// for road, change the owner of the road to local authority
 
				_map_owner[tile] = OWNER_NONE;
 
				SetTileOwner(tile, OWNER_NONE);
 
			}
 
		} else {
 
			DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
unmovable_cmd.c
Show inline comments
 
@@ -358,7 +358,7 @@ void GenerateUnmovables(void)
 
				continue;
 
			SetTileType(tile, MP_UNMOVABLE);
 
			_map5[tile] = 0;
 
			_map_owner[tile] = OWNER_NONE;
 
			SetTileOwner(tile, OWNER_NONE);
 
			if (--j == 0)
 
				break;
 
		}
 
@@ -390,7 +390,7 @@ restart:
 

	
 
		SetTileType(tile, MP_UNMOVABLE);
 
		_map5[tile] = 1;
 
		_map_owner[tile] = OWNER_NONE;
 
		SetTileOwner(tile, OWNER_NONE);
 
	} while (--i);
 
}
 

	
 
@@ -399,7 +399,7 @@ static void ChangeTileOwner_Unmovable(ui
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (_map5[tile]==3 && new_player != 255) {
 
		_map_owner[tile] = new_player;
 
		SetTileOwner(tile, new_player);
 
	}	else {
 
		DoClearSquare(tile);
 
	}
water_cmd.c
Show inline comments
 
@@ -689,7 +689,7 @@ static void ChangeTileOwner_Water(uint t
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != 255) {
 
		_map_owner[tile] = new_player;
 
		SetTileOwner(tile, new_player);
 
	} else {
 
		DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
	}
0 comments (0 inline, 0 general)