summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-06-04 11:56:32 +0000
committertron <tron@openttd.org>2005-06-04 11:56:32 +0000
commit0c4ecbe9ece42d071a4f4e4b6d506be32030cb4c (patch)
tree172ef15bca6626b797fbf586a043a978ee884141
parent19e2b40a788cc175f35e4ca0cec0f439bd46ab76 (diff)
downloadopenttd-0c4ecbe9ece42d071a4f4e4b6d506be32030cb4c.tar.xz
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
-rw-r--r--ai.c17
-rw-r--r--ai_new.c4
-rw-r--r--aircraft_cmd.c2
-rw-r--r--aircraft_gui.c9
-rw-r--r--clear_cmd.c5
-rw-r--r--disaster_cmd.c20
-rw-r--r--openttd.c11
-rw-r--r--order_gui.c14
-rw-r--r--pathfind.c6
-rw-r--r--players.c4
-rw-r--r--rail_cmd.c21
-rw-r--r--road_cmd.c13
-rw-r--r--roadveh_cmd.c8
-rw-r--r--roadveh_gui.c7
-rw-r--r--ship_cmd.c2
-rw-r--r--ship_gui.c9
-rw-r--r--smallmap_gui.c8
-rw-r--r--station_cmd.c7
-rw-r--r--town_cmd.c15
-rw-r--r--train_cmd.c8
-rw-r--r--train_gui.c9
-rw-r--r--tree_cmd.c4
-rw-r--r--tunnelbridge_cmd.c17
-rw-r--r--unmovable_cmd.c13
-rw-r--r--water_cmd.c7
25 files changed, 118 insertions, 122 deletions
diff --git a/ai.c b/ai.c
index 6885bac33..54814a839 100644
--- a/ai.c
+++ b/ai.c
@@ -3637,8 +3637,8 @@ static void AiRemovePlayerRailOrRoad(Player *p, TileIndex tile)
byte m5;
if (IsTileType(tile, MP_RAILWAY)) {
- if (_map_owner[tile] != _current_player)
- return;
+ if (!IsTileOwner(tile, _current_player)) return;
+
m5 = _map5[tile];
if ((m5&~0x3) != 0xC0) {
is_rail_crossing:;
@@ -3696,8 +3696,7 @@ pos_3:
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
}
} else if (IsTileType(tile, MP_STREET)) {
- if (_map_owner[tile] != _current_player)
- return;
+ if (!IsTileOwner(tile, _current_player)) return;
if ( (_map5[tile]&0xF0) == 0x10)
goto is_rail_crossing;
@@ -3707,19 +3706,19 @@ pos_3:
// Check if there are any stations around.
if (IsTileType(tile + TILE_XY(-1,0), MP_STATION) &&
- _map_owner[tile + TILE_XY(-1,0)] == _current_player)
+ IsTileOwner(tile + TILE_XY(-1, 0), _current_player))
return;
if (IsTileType(tile + TILE_XY(1,0), MP_STATION) &&
- _map_owner[tile + TILE_XY(1,0)] == _current_player)
+ IsTileOwner(tile + TILE_XY(1, 0), _current_player))
return;
if (IsTileType(tile + TILE_XY(0,-1), MP_STATION) &&
- _map_owner[tile + TILE_XY(0,-1)] == _current_player)
+ IsTileOwner(tile + TILE_XY(0, -1), _current_player))
return;
if (IsTileType(tile + TILE_XY(0,1), MP_STATION) &&
- _map_owner[tile + TILE_XY(0,1)] == _current_player)
+ IsTileOwner(tile + TILE_XY(0, 1), _current_player))
return;
dir = _map5[tile] & 3;
@@ -3735,7 +3734,7 @@ pos_3:
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
byte b;
- if (_map_owner[tile] != _current_player || (_map5[tile] & 0xC6) != 0x80)
+ if (!IsTileOwner(tile, _current_player) || (_map5[tile] & 0xC6) != 0x80)
return;
m5 = 0;
diff --git a/ai_new.c b/ai_new.c
index 93b7c20ef..b10f316b3 100644
--- a/ai_new.c
+++ b/ai_new.c
@@ -763,7 +763,7 @@ static void AiNew_State_FindDepot(Player *p) {
// Its a street, test if it is a depot
if (_map5[tile + TileOffsByDir(j)] & 0x20) {
// We found a depot, is it ours? (TELL ME!!!)
- if (_map_owner[tile + TileOffsByDir(j)] == _current_player) {
+ if (IsTileOwner(tile + TileOffsByDir(j), _current_player)) {
// Now, is it pointing to the right direction.........
if ((_map5[tile + TileOffsByDir(j)] & 3) == (j ^ 2)) {
// Yeah!!!
@@ -1062,7 +1062,7 @@ static void AiNew_State_BuildDepot(Player *p) {
assert(p->ainew.state == AI_STATE_BUILD_DEPOT);
if (IsTileType(p->ainew.depot_tile, MP_STREET) && _map5[p->ainew.depot_tile] & 0x20) {
- if (_map_owner[p->ainew.depot_tile] == _current_player) {
+ if (IsTileOwner(p->ainew.depot_tile, _current_player)) {
// The depot is already builded!
p->ainew.state = AI_STATE_BUILD_VEHICLE;
return;
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 1d4b29c1a..6ca106e3a 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -178,7 +178,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// Workaround: TODO: make AI players try to build planes in a hangar instead of just an airport tile.
if (!IsAircraftHangarTile(tile) && IS_HUMAN_PLAYER(_current_player)) return CMD_ERROR;
- if (_map_owner[tile] != _current_player && IS_HUMAN_PLAYER(_current_player)) return CMD_ERROR;
+ if (!IsTileOwner(tile, _current_player) && IS_HUMAN_PLAYER(_current_player)) return CMD_ERROR;
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
diff --git a/aircraft_gui.c b/aircraft_gui.c
index f15485762..7cf0cf903 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -199,7 +199,7 @@ static void ShowBuildAircraftWindow(uint tile)
w->resize.step_height = 24;
if (tile != 0) {
- w->caption_color = _map_owner[tile];
+ w->caption_color = GetTileOwner(tile);
} else {
w->caption_color = _local_player;
}
@@ -612,7 +612,8 @@ static void DrawAircraftDepotWindow(Window *w)
tile = w->window_number;
/* setup disabled buttons */
- w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<7));
+ w->disabled_state =
+ IsTileOwner(tile, _local_player) ? 0 : ((1 << 4) | (1 << 7));
/* determine amount of items for scroller */
num = 0;
@@ -828,7 +829,7 @@ void ShowAircraftDepotWindow(uint tile)
w = AllocateWindowDescFront(&_aircraft_depot_desc, tile);
if (w) {
- w->caption_color = _map_owner[tile];
+ w->caption_color = GetTileOwner(tile);
w->vscroll.cap = 2;
w->hscroll.cap = 4;
w->resize.step_width = 74;
@@ -1013,7 +1014,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
tile = _last_built_aircraft_depot_tile;
do {
- if (_map_owner[tile] == _local_player && IsAircraftHangarTile(tile)) {
+ if (IsTileOwner(tile, _local_player) && IsAircraftHangarTile(tile)) {
ShowAircraftDepotWindow(tile);
ShowBuildAircraftWindow(tile);
return;
diff --git a/clear_cmd.c b/clear_cmd.c
index 124723fec..d9cb1b5a9 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -399,7 +399,8 @@ int32 CmdPurchaseLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
- if (IsTileType(tile, MP_UNMOVABLE) && _map5[tile] == 3 && _map_owner[tile] == _current_player)
+ if (IsTileType(tile, MP_UNMOVABLE) && _map5[tile] == 3 &&
+ IsTileOwner(tile, _current_player))
return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -837,7 +838,7 @@ static void GetTileDesc_Clear(uint tile, TileDesc *td)
if (i == 0)
i = (_map5[tile] & 3) + 8;
td->str = _clear_land_str[i - 1];
- td->owner = _map_owner[tile];
+ td->owner = GetTileOwner(tile);
}
static void ChangeTileOwner_Clear(uint tile, byte old_player, byte new_player)
diff --git a/disaster_cmd.c b/disaster_cmd.c
index a66c4c0a4..ceaeee3e9 100644
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -21,7 +21,7 @@ static void DisasterClearSquare(TileIndex tile)
switch (GetTileType(tile)) {
case MP_RAILWAY:
- if (IS_HUMAN_PLAYER(_map_owner[tile])) DoClearSquare(tile);
+ if (IS_HUMAN_PLAYER(GetTileOwner(tile))) DoClearSquare(tile);
break;
case MP_HOUSE: {
@@ -173,9 +173,8 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) &&
- IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
- IS_HUMAN_PLAYER(_map_owner[tile])) {
-
+ IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
+ IS_HUMAN_PLAYER(GetTileOwner(tile))) {
v->current_order.station = 1;
v->age = 0;
@@ -199,9 +198,8 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) &&
- IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
- IS_HUMAN_PLAYER(_map_owner[tile])) {
-
+ IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
+ IS_HUMAN_PLAYER(GetTileOwner(tile))) {
st = GetStation(_map2[tile]);
CLRBITS(st->airport_flags, RUNWAY_IN_block);
}
@@ -242,8 +240,8 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
tile = v->tile;/**/
if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) &&
- IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
- IS_HUMAN_PLAYER(_map_owner[tile])) {
+ IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
+ IS_HUMAN_PLAYER(GetTileOwner(tile))) {
st = GetStation(_map2[tile]);
SETBITS(st->airport_flags, RUNWAY_IN_block);
@@ -581,8 +579,8 @@ static void DisasterTick_4(Vehicle *v)
tile_org = tile = TILE_MASK(Random());
do {
if (IsTileType(tile, MP_RAILWAY) &&
- (_map5[tile]&~3)!=0xC0 && IS_HUMAN_PLAYER(_map_owner[tile]))
- break;
+ (_map5[tile] & ~3) != 0xC0 && IS_HUMAN_PLAYER(GetTileOwner(tile)))
+ break;
tile = TILE_MASK(tile+1);
} while (tile != tile_org);
v->dest_tile = tile;
diff --git a/openttd.c b/openttd.c
index 619c964f8..ffd159aa3 100644
--- a/openttd.c
+++ b/openttd.c
@@ -1299,7 +1299,7 @@ bool AfterLoadGame(uint version)
uint h = MapSizeY();
BEGIN_TILE_LOOP(tile_cur, w, h, tile)
- if (IsTileType(tile_cur, MP_WATER) && _map_owner[tile_cur] >= MAX_PLAYERS)
+ if (IsTileType(tile_cur, MP_WATER) && GetTileOwner(tile_cur) >= MAX_PLAYERS)
_map_owner[tile_cur] = OWNER_WATER;
END_TILE_LOOP(tile_cur, w, h, tile)
}
@@ -1393,13 +1393,14 @@ bool AfterLoadGame(uint version)
SetTileType(tile, MP_HOUSE);
} else if (IsTileType(tile, MP_STREET)) {
//XXX magic
- SetTileType(tile, MP_VOID);
_map3_hi[tile] |= (_map2[tile] << 4);
- if ( _map_owner[tile] == OWNER_TOWN)
+ if (IsTileOwner(tile, OWNER_TOWN)) {
+ SetTileType(tile, MP_VOID);
_map2[tile] = ClosestTownFromTile(tile,(uint)-1)->index;
- else
+ SetTileType(tile, MP_STREET);
+ } else {
_map2[tile] = 0;
- SetTileType(tile, MP_STREET);
+ }
}
} END_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0);
}
diff --git a/order_gui.c b/order_gui.c
index 136153794..2840740cf 100644
--- a/order_gui.c
+++ b/order_gui.c
@@ -167,7 +167,7 @@ static Order GetOrderCmdFromTile(Vehicle *v, uint tile)
if (_patches.gotodepot) {
switch (GetTileType(tile)) {
case MP_RAILWAY:
- if (v->type == VEH_Train && _map_owner[tile] == _local_player) {
+ if (v->type == VEH_Train && IsTileOwner(tile, _local_player)) {
if ((_map5[tile]&0xFC)==0xC0) {
order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS;
@@ -178,7 +178,7 @@ static Order GetOrderCmdFromTile(Vehicle *v, uint tile)
break;
case MP_STREET:
- if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && _map_owner[tile] == _local_player) {
+ if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && IsTileOwner(tile, _local_player)) {
order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS;
order.station = GetDepotByTile(tile)->index;
@@ -188,7 +188,7 @@ static Order GetOrderCmdFromTile(Vehicle *v, uint tile)
case MP_STATION:
if (v->type != VEH_Aircraft) break;
- if ( IsAircraftHangarTile(tile) && _map_owner[tile] == _local_player) {
+ if (IsAircraftHangarTile(tile) && IsTileOwner(tile, _local_player)) {
order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS | OF_NON_STOP; //XXX - whats the nonstop stuff doing here?
order.station = _map2[tile];
@@ -216,10 +216,10 @@ static Order GetOrderCmdFromTile(Vehicle *v, uint tile)
}
// check waypoint
- if (IsTileType(tile, MP_RAILWAY)
- && v->type == VEH_Train
- && _map_owner[tile] == _local_player
- && (_map5[tile]&0xFE)==0xC4) {
+ if (IsTileType(tile, MP_RAILWAY) &&
+ v->type == VEH_Train &&
+ IsTileOwner(tile, _local_player) &&
+ (_map5[tile] & 0xFE) == 0xC4) {
order.type = OT_GOTO_WAYPOINT;
order.flags = 0;
order.station = GetWaypointByTile(tile)->index;
diff --git a/pathfind.c b/pathfind.c
index c8b75ed15..99eb050a5 100644
--- a/pathfind.c
+++ b/pathfind.c
@@ -133,7 +133,7 @@ static void TPFMode2(TrackPathFinder *tpf, uint tile, int direction)
if (tpf->tracktype == TRANSPORT_RAIL) {
if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE)) {
- owner = _map_owner[tile];
+ owner = GetTileOwner(tile);
/* Check if we are on the middle of a bridge (has no owner) */
if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xC0) == 0xC0)
owner = -1;
@@ -150,7 +150,7 @@ static void TPFMode2(TrackPathFinder *tpf, uint tile, int direction)
if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE))
/* Check if we are on the middle of a bridge (has no owner) */
if (!IsTileType(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0)
- if (owner != -1 && _map_owner[tile] != owner)
+ if (owner != -1 && !IsTileOwner(tile, owner))
return;
}
@@ -296,7 +296,7 @@ static void TPFMode1(TrackPathFinder *tpf, uint tile, int direction)
/* Check if we are on a bridge (middle parts don't have an owner */
if (!IsTileType(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0)
if (!IsTileType(tile_org, MP_TUNNELBRIDGE) || (_map5[tile_org] & 0xC0) != 0xC0)
- if (_map_owner[tile_org] != _map_owner[tile])
+ if (GetTileOwner(tile_org) != GetTileOwner(tile))
return;
}
diff --git a/players.c b/players.c
index 58cc52bcb..bafddf85a 100644
--- a/players.c
+++ b/players.c
@@ -281,8 +281,10 @@ bool CheckOwnership(byte owner)
bool CheckTileOwnership(uint tile)
{
- byte owner = _map_owner[tile];
+ byte owner = GetTileOwner(tile);
+
assert(owner <= OWNER_WATER);
+
if (owner == _current_player)
return true;
_error_message = STR_013B_OWNED_BY;
diff --git a/rail_cmd.c b/rail_cmd.c
index d155e40ae..7459b37ac 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -364,7 +364,7 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
(rail_bit == 2 && m5 == 0x0A) // correct direction?
)) {
if (flags & DC_EXEC) {
- _map3_lo[tile] = _map_owner[tile];
+ _map3_lo[tile] = GetTileOwner(tile);
_map_owner[tile] = _current_player;
_map3_hi[tile] = p1;
_map5[tile] = 0x10 | (rail_bit == 1 ? 0x08 : 0x00); // level crossing
@@ -1067,7 +1067,7 @@ static int32 ClearTile_Track(TileIndex tile, byte flags)
if (m5 & RAIL_TYPE_SPECIAL)
return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
- if (_map_owner[tile] != _current_player)
+ if (!IsTileOwner(tile, _current_player))
return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER);
return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK);
@@ -1324,7 +1324,7 @@ static void DrawTile_Track(TileInfo *ti)
uint32 tracktype_offs, image;
byte m5;
- _drawtile_track_palette = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_map_owner[ti->tile]));
+ _drawtile_track_palette = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)));
tracktype_offs = (_map3_lo[ti->tile] & 0xF) * TRACKTYPE_SPRITE_PITCH;
@@ -1900,32 +1900,32 @@ static void TileLoop_Track(uint tile)
} else if (rail == RAIL_BIT_RIGHT) {
a2 = RAIL_GROUND_FENCE_VERT2;
} else {
- owner = _map_owner[tile];
+ owner = GetTileOwner(tile);
if ( (!(rail&(RAIL_BIT_DIAG2|RAIL_BIT_UPPER|RAIL_BIT_LEFT)) && (rail&RAIL_BIT_DIAG1)) || rail==(RAIL_BIT_LOWER|RAIL_BIT_RIGHT)) {
if (!IsTileType(tile + TILE_XY(0,-1), MP_RAILWAY) ||
- owner != _map_owner[tile + TILE_XY(0,-1)] ||
+ !IsTileOwner(tile + TILE_XY(0, -1), owner) ||
(_map5[tile + TILE_XY(0,-1)]==RAIL_BIT_UPPER || _map5[tile + TILE_XY(0,-1)]==RAIL_BIT_LEFT))
a2 = RAIL_GROUND_FENCE_NW;
}
if ( (!(rail&(RAIL_BIT_DIAG2|RAIL_BIT_LOWER|RAIL_BIT_RIGHT)) && (rail&RAIL_BIT_DIAG1)) || rail==(RAIL_BIT_UPPER|RAIL_BIT_LEFT)) {
if (!IsTileType(tile + TILE_XY(0,1), MP_RAILWAY) ||
- owner != _map_owner[tile + TILE_XY(0,1)] ||
+ !IsTileOwner(tile + TILE_XY(0, 1), owner) ||
(_map5[tile + TILE_XY(0,1)]==RAIL_BIT_LOWER || _map5[tile + TILE_XY(0,1)]==RAIL_BIT_RIGHT))
a2 = (a2 == RAIL_GROUND_FENCE_NW) ? RAIL_GROUND_FENCE_SENW : RAIL_GROUND_FENCE_SE;
}
if ( (!(rail&(RAIL_BIT_DIAG1|RAIL_BIT_UPPER|RAIL_BIT_RIGHT)) && (rail&RAIL_BIT_DIAG2)) || rail==(RAIL_BIT_LOWER|RAIL_BIT_LEFT)) {
if (!IsTileType(tile + TILE_XY(-1,0), MP_RAILWAY) ||
- owner != _map_owner[tile + TILE_XY(-1,0)] ||
+ !IsTileOwner(tile + TILE_XY(-1, 0), owner) ||
(_map5[tile + TILE_XY(-1,0)]==RAIL_BIT_UPPER || _map5[tile + TILE_XY(-1,0)]==RAIL_BIT_RIGHT))
a2 = RAIL_GROUND_FENCE_NE;
}
if ( (!(rail&(RAIL_BIT_DIAG1|RAIL_BIT_LOWER|RAIL_BIT_LEFT)) && (rail&RAIL_BIT_DIAG2)) || rail==(RAIL_BIT_UPPER|RAIL_BIT_RIGHT)) {
if (!IsTileType(tile + TILE_XY(1,0), MP_RAILWAY) ||
- owner != _map_owner[tile + TILE_XY(1,0)] ||
+ !IsTileOwner(tile + TILE_XY(1, 0), owner) ||
(_map5[tile + TILE_XY(1,0)]==RAIL_BIT_LOWER || _map5[tile + TILE_XY(1,0)]==RAIL_BIT_LEFT))
a2 = (a2 == RAIL_GROUND_FENCE_NE) ? RAIL_GROUND_FENCE_NESW : RAIL_GROUND_FENCE_SW;
}
@@ -1997,7 +1997,7 @@ static void ClickTile_Track(uint tile)
static void GetTileDesc_Track(TileIndex tile, TileDesc *td)
{
- td->owner = _map_owner[tile];
+ td->owner = GetTileOwner(tile);
switch (_map5[tile] & RAIL_TYPE_MASK) {
case RAIL_TYPE_NORMAL:
td->str = STR_1021_RAILROAD_TRACK;
@@ -2025,8 +2025,7 @@ static void GetTileDesc_Track(TileIndex tile, TileDesc *td)
static void ChangeTileOwner_Track(uint tile, byte old_player, byte new_player)
{
- if (_map_owner[tile] != old_player)
- return;
+ if (!IsTileOwner(tile, old_player)) return;
if (new_player != 255) {
_map_owner[tile] = new_player;
diff --git a/road_cmd.c b/road_cmd.c
index ce8659cb2..26c96bade 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -81,7 +81,7 @@ static bool CheckAllowRemoveRoad(uint tile, uint br, bool *edge_road)
if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
owner = _map3_lo[tile];
} else {
- owner = _map_owner[tile];
+ owner = GetTileOwner(tile);
}
// Only do the special processing if the road is owned
// by a town
@@ -157,7 +157,7 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
owner = _map3_lo[tile];
} else
- owner = _map_owner[tile];
+ owner = GetTileOwner(tile);
if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) {
if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space)
@@ -686,7 +686,7 @@ static int32 ClearTile_Road(uint tile, byte flags) {
byte b = m5 & 0xF;
if (! ((1 << b) & (M(1)|M(2)|M(4)|M(8))) ) {
- if ( (!(flags & DC_AI_BUILDING) || _map_owner[tile]!=OWNER_TOWN) && flags&DC_AUTO)
+ if ((!(flags & DC_AI_BUILDING) || !IsTileOwner(tile, OWNER_TOWN)) && flags & DC_AUTO)
return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST);
}
return DoCommandByTile(tile, b, 0, flags, CMD_REMOVE_ROAD);
@@ -835,7 +835,7 @@ static void DrawTile_Road(TileInfo *ti)
if (ti->tileh != 0) { DrawFoundation(ti, ti->tileh); }
ormod = 0x315;
- player = _map_owner[ti->tile];
+ player = GetTileOwner(ti->tile);
if (player < MAX_PLAYERS)
ormod = PLAYER_SPRITE_COLOR(player);
@@ -1101,7 +1101,7 @@ static void GetTileDesc_Road(uint tile, TileDesc *td)
if (i == 0)
i = ((_map3_hi[tile] & 0x70) >> 4) + 3;
td->str = _road_tile_strings[i - 1];
- td->owner = _map_owner[tile];
+ td->owner = GetTileOwner(tile);
}
static const byte _roadveh_enter_depot_unk0[4] = {
@@ -1145,8 +1145,7 @@ static void ChangeTileOwner_Road(uint tile, byte old_player, byte new_player)
_map3_lo[tile] = (new_player == 0xFF) ? OWNER_NONE : new_player;
}
- if (_map_owner[tile] != old_player)
- return;
+ if (!IsTileOwner(tile, old_player)) return;
if (new_player != 255) {
_map_owner[tile] = new_player;
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 7d469579b..ba3545e22 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -133,7 +133,7 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* The ai_new queries the vehicle cost before building the route,
* so we must check against cheaters no sooner than now. --pasky */
if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return CMD_ERROR;
- if (_map_owner[tile] != _current_player) return CMD_ERROR;
+ if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
v = AllocateVehicle();
if (v == NULL || IsOrderPoolFull())
@@ -297,7 +297,7 @@ static bool EnumRoadSignalFindDepot(uint tile, RoadFindDepotData *rfdd, int trac
if (IsTileType(tile, MP_STREET) &&
(_map5[tile] & 0xF0) == 0x20 &&
- _map_owner[tile] == rfdd->owner) {
+ IsTileOwner(tile, rfdd->owner)) {
if (length < rfdd->best_length) {
rfdd->best_length = length;
@@ -1048,11 +1048,11 @@ static int RoadFindPathToDest(Vehicle *v, uint tile, int enterdir)
}
if (IsTileType(tile, MP_STREET)) {
- if ((_map5[tile]&0xF0) == 0x20 && v->owner == _map_owner[tile])
+ if ((_map5[tile]&0xF0) == 0x20 && IsTileOwner(tile, v->owner))
/* Road crossing */
bitmask |= _road_veh_fp_ax_or[_map5[tile]&3];
} else if (IsTileType(tile, MP_STATION)) {
- if (_map_owner[tile] == OWNER_NONE || _map_owner[tile] == v->owner) {
+ if (IsTileOwner(tile, OWNER_NONE) || IsTileOwner(tile, v->owner)) {
/* Our station */
Station *st = GetStation(_map2[tile]);
byte val = _map5[tile];
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 092494154..31bb06d14 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -494,7 +494,7 @@ static void ShowBuildRoadVehWindow(TileIndex tile)
w->resize.height = w->height - 14 * 4; /* Minimum of 4 vehicles in the display */
if (tile != 0) {
- w->caption_color = _map_owner[tile];
+ w->caption_color = GetTileOwner(tile);
} else {
w->caption_color = _local_player;
}
@@ -510,7 +510,8 @@ static void DrawRoadDepotWindow(Window *w)
tile = w->window_number;
/* setup disabled buttons */
- w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<7));
+ w->disabled_state =
+ IsTileOwner(tile, _local_player) ? 0 : ((1 << 4) | (1 << 7));
/* determine amount of items for scroller */
num = 0;
@@ -734,7 +735,7 @@ void ShowRoadDepotWindow(uint tile)
w = AllocateWindowDescFront(&_road_depot_desc, tile);
if (w) {
- w->caption_color = _map_owner[w->window_number];
+ w->caption_color = GetTileOwner(w->window_number);
w->hscroll.cap = 5;
w->vscroll.cap = 3;
w->resize.step_width = 56;
diff --git a/ship_cmd.c b/ship_cmd.c
index 1db631b1e..62ec43c38 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -876,7 +876,7 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* The ai_new queries the vehicle cost before building the route,
* so we must check against cheaters no sooner than now. --pasky */
if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR;
- if (_map_owner[tile] != _current_player) return CMD_ERROR;
+ if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
v = AllocateVehicle();
if (v == NULL || IsOrderPoolFull() ||
diff --git a/ship_gui.c b/ship_gui.c
index 640361fc2..375afe857 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -428,7 +428,7 @@ static void ShowBuildShipWindow(TileIndex tile)
w->resize.step_height = 24;
if (tile != 0) {
- w->caption_color = _map_owner[tile];
+ w->caption_color = GetTileOwner(tile);
} else {
w->caption_color = _local_player;
}
@@ -588,7 +588,8 @@ static void DrawShipDepotWindow(Window *w)
tile = w->window_number;
/* setup disabled buttons */
- w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<7));
+ w->disabled_state =
+ IsTileOwner(tile, _local_player) ? 0 : ((1 << 4) | (1 << 7));
/* determine amount of items for scroller */
num = 0;
@@ -808,7 +809,7 @@ void ShowShipDepotWindow(uint tile)
w = AllocateWindowDescFront(&_ship_depot_desc,tile);
if (w) {
- w->caption_color = _map_owner[w->window_number];
+ w->caption_color = GetTileOwner(w->window_number);
w->vscroll.cap = 2;
w->hscroll.cap = 3;
w->resize.step_width = 90;
@@ -995,7 +996,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
tile = _last_built_ship_depot_tile;
do {
- if (_map_owner[tile] == _local_player && IsTileDepotType(tile, TRANSPORT_WATER)) {
+ if (IsTileOwner(tile, _local_player) && IsTileDepotType(tile, TRANSPORT_WATER)) {
ShowShipDepotWindow(tile);
ShowBuildShipWindow(tile);
return;
diff --git a/smallmap_gui.c b/smallmap_gui.c
index 46926c2ce..4a9d2be8f 100644
--- a/smallmap_gui.c
+++ b/smallmap_gui.c
@@ -496,12 +496,12 @@ static inline uint32 GetSmallMapOwnerPixels(TileIndex tile)
{
TileType t = GetTileType(tile);
- if (t == MP_HOUSE || _map_owner[tile] == OWNER_TOWN) {
- t = 0x80;
- } else if (t == MP_INDUSTRY) {
+ if (t == MP_INDUSTRY) {
t = 0xff;
+ } else if (t == MP_HOUSE || IsTileOwner(tile, OWNER_TOWN)) {
+ t = 0x80;
} else {
- t = _map_owner[tile];
+ t = GetTileOwner(tile);
}
return _owner_colors[t];
diff --git a/station_cmd.c b/station_cmd.c
index c01cb64e9..1721e38e0 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -2103,7 +2103,7 @@ static void DrawTile_Station(TileInfo *ti)
uint32 relocation = 0;
{
- uint owner = _map_owner[ti->tile];
+ uint owner = GetTileOwner(ti->tile);
image_or_modificator = 0x315 << 16; /* NOTE: possible bug in ttd here? */
if (owner < MAX_PLAYERS)
image_or_modificator = PLAYER_SPRITE_COLOR(owner);
@@ -2204,7 +2204,7 @@ static void GetTileDesc_Station(uint tile, TileDesc *td)
byte m5;
StringID str;
- td->owner = _map_owner[tile];
+ td->owner = GetTileOwner(tile);
td->build_date = GetStation(_map2[tile])->build_date;
m5 = _map5[tile];
@@ -2880,8 +2880,7 @@ void DeleteOilRig(uint tile)
static void ChangeTileOwner_Station(uint tile, byte old_player, byte new_player)
{
- if (_map_owner[tile] != old_player)
- return;
+ if (!IsTileOwner(tile, old_player)) return;
if (new_player != 255) {
Station *st = GetStation(_map2[tile]);
diff --git a/town_cmd.c b/town_cmd.c
index 711774752..cea348909 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -741,7 +741,7 @@ static int GrowTownAtRoad(Town *t, uint tile)
if (IsTileType(tile, MP_STREET)) {
/* Don't allow building over roads of other cities */
- if (_map_owner[tile] == OWNER_TOWN && GetTown(_map2[tile]) != t)
+ if (IsTileOwner(tile, OWNER_TOWN) && GetTown(_map2[tile]) != t)
_grow_town_result = -1;
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
@@ -1495,7 +1495,7 @@ void DeleteTown(Town *t)
case MP_STREET:
case MP_TUNNELBRIDGE:
- if (_map_owner[tile] == OWNER_TOWN &&
+ if (IsTileOwner(tile, OWNER_TOWN) &&
ClosestTownFromTile(tile, (uint)-1) == t)
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
break;
@@ -1837,15 +1837,12 @@ Town *ClosestTownFromTile(uint tile, uint threshold)
Town *t;
uint dist, best = threshold;
Town *best_town = NULL;
- byte owner;
// XXX - Fix this so for a given tiletype the owner of the type is in the same variable
- if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) { // rail crossing
- owner = _map3_lo[tile];
- } else
- owner = _map_owner[tile];
-
- if ((IsTileType(tile, MP_STREET) && owner == OWNER_TOWN) || IsTileType(tile, MP_HOUSE))
+ if (IsTileType(tile, MP_HOUSE) || (
+ IsTileType(tile, MP_STREET) &&
+ ((_map5[tile] & 0xF0) != 0x10 ? GetTileOwner(tile) : _map3_lo[tile]) == OWNER_TOWN
+ ))
return GetTown(_map2[tile]);
FOR_ALL_TOWNS(t) {
diff --git a/train_cmd.c b/train_cmd.c
index a718fd3dd..faf73b5ad 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -538,7 +538,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* to the player. Doesn't matter if only the cost is queried */
if (!(flags & DC_QUERY_COST)) {
if (!IsTileDepotType(tile, TRANSPORT_RAIL)) return CMD_ERROR;
- if (_map_owner[tile] != _current_player) return CMD_ERROR;
+ if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
}
_cmd_build_rail_veh_var1 = 0;
@@ -1387,7 +1387,7 @@ typedef struct TrainFindDepotData {
static bool TrainFindDepotEnumProc(uint tile, TrainFindDepotData *tfdd, int track, uint length, byte *state)
{
- if (IsTileType(tile, MP_RAILWAY) && _map_owner[tile] == tfdd->owner) {
+ if (IsTileType(tile, MP_RAILWAY) && IsTileOwner(tile, tfdd->owner)) {
if ((_map5[tile] & ~0x3) == 0xC0) {
if (length < tfdd->best_length) {
tfdd->best_length = length;
@@ -2314,7 +2314,7 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
case MP_STREET:
// tracks over roads, do owner check of tracks (_map_owner[tile])
return
- _map_owner[tile] == v->owner &&
+ IsTileOwner(tile, v->owner) &&
(v->subtype != TS_Front_Engine || (_map3_hi[tile] & 0xF) == v->u.rail.railtype);
default:
@@ -2322,7 +2322,7 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
}
return
- _map_owner[tile] == v->owner &&
+ IsTileOwner(tile, v->owner) &&
(v->subtype != TS_Front_Engine || (_map3_lo[tile] & 0xF) == v->u.rail.railtype);
}
diff --git a/train_gui.c b/train_gui.c
index 8cec32d19..fad335d32 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -271,7 +271,7 @@ static void ShowBuildTrainWindow(uint tile)
w->resize.height = w->height - 14 * 4; /* Minimum of 4 vehicles in the display */
if (tile != 0) {
- w->caption_color = _map_owner[tile];
+ w->caption_color = GetTileOwner(tile);
WP(w,buildtrain_d).railtype = _map3_lo[tile] & 0xF;
} else {
w->caption_color = _local_player;
@@ -307,7 +307,8 @@ static void DrawTrainDepotWindow(Window *w)
tile = w->window_number;
/* setup disabled buttons */
- w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<5)|(1<<8));
+ w->disabled_state =
+ IsTileOwner(tile, _local_player) ? 0 : ((1 << 4) | (1 << 5) | (1 << 8));
/* determine amount of items for scroller */
num = 0;
@@ -651,7 +652,7 @@ void ShowTrainDepotWindow(uint tile)
w = AllocateWindowDescFront(&_train_depot_desc, tile);
if (w) {
- w->caption_color = _map_owner[w->window_number];
+ w->caption_color = GetTileOwner(w->window_number);
w->vscroll.cap = 6;
w->hscroll.cap = 10;
w->resize.step_width = 29;
@@ -1345,7 +1346,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
tile = _last_built_train_depot_tile;
do {
- if (_map_owner[tile] == _local_player && IsTileDepotType(tile, TRANSPORT_RAIL)) {
+ if (IsTileOwner(tile, _local_player) && IsTileDepotType(tile, TRANSPORT_RAIL)) {
ShowTrainDepotWindow(tile);
ShowBuildTrainWindow(tile);
return;
diff --git a/tree_cmd.c b/tree_cmd.c
index 18b71c1d0..e4fe68ffc 100644
--- a/tree_cmd.c
+++ b/tree_cmd.c
@@ -195,7 +195,7 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
break;
case MP_CLEAR:
- if (_map_owner[ti.tile] != OWNER_NONE) {
+ if (!IsTileOwner(ti.tile, OWNER_NONE)) {
_error_message = STR_2804_SITE_UNSUITABLE;
continue;
}
@@ -396,7 +396,7 @@ static void GetTileDesc_Trees(uint tile, TileDesc *td)
byte b;
StringID str;
- td->owner = _map_owner[tile];
+ td->owner = GetTileOwner(tile);
b = _map3_lo[tile];
(str=STR_2810_CACTUS_PLANTS, b==0x1B) ||
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index e18c5ad18..7460f7b6e 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -628,7 +628,7 @@ static int32 DoClearTunnel(uint tile, uint32 flags)
// in scenario editor you can always destroy tunnels
if (_game_mode != GM_EDITOR && !CheckTileOwnership(tile)) {
- if (!(_patches.extra_dynamite || _cheats.magic_bulldozer.value) || _map_owner[tile] != OWNER_TOWN)
+ if (!(_patches.extra_dynamite || _cheats.magic_bulldozer.value) || !IsTileOwner(tile, OWNER_TOWN))
return CMD_ERROR;
}
@@ -640,7 +640,7 @@ static int32 DoClearTunnel(uint tile, uint32 flags)
t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty
// check if you're allowed to remove the tunnel owned by a town
// removal allowal depends on difficulty settings
- if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR ) {
+ if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
if (!CheckforTownRating(tile, flags, t, TUNNELBRIDGE_REMOVE)) {
SetDParam(0, t->index);
return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES);
@@ -656,7 +656,7 @@ static int32 DoClearTunnel(uint tile, uint32 flags)
DoClearSquare(endtile);
UpdateSignalsOnSegment(tile, _updsignals_tunnel_dir[tile_dir]);
UpdateSignalsOnSegment(endtile, _updsignals_tunnel_dir[endtile_dir]);
- if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR)
+ if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
}
return _price.clear_tunnel * (length + 1);
@@ -736,7 +736,7 @@ static int32 DoClearBridge(uint tile, uint32 flags)
// floods, scenario editor can always destroy bridges
if (_current_player != OWNER_WATER && _game_mode != GM_EDITOR && !CheckTileOwnership(tile)) {
- if (!(_patches.extra_dynamite || _cheats.magic_bulldozer.value) || _map_owner[tile] != OWNER_TOWN)
+ if (!(_patches.extra_dynamite || _cheats.magic_bulldozer.value) || !IsTileOwner(tile, OWNER_TOWN))
return CMD_ERROR;
}
@@ -763,7 +763,7 @@ static int32 DoClearBridge(uint tile, uint32 flags)
t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty
// check if you're allowed to remove the bridge owned by a town.
// removal allowal depends on difficulty settings
- if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) {
+ if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
if (!CheckforTownRating(tile, flags, t, TUNNELBRIDGE_REMOVE))
return CMD_ERROR;
}
@@ -775,7 +775,7 @@ static int32 DoClearBridge(uint tile, uint32 flags)
//checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
// you have a "Poor" (0) town rating
- if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR)
+ if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
do {
@@ -1281,7 +1281,7 @@ static void GetTileDesc_TunnelBridge(uint tile, TileDesc *td)
do tile += delta; while (_map5[tile] & 0x40);
}
}
- td->owner = _map_owner[tile];
+ td->owner = GetTileOwner(tile);
}
@@ -1370,8 +1370,7 @@ static uint32 GetTileTrackStatus_TunnelBridge(uint tile, TransportType mode)
static void ChangeTileOwner_TunnelBridge(uint tile, byte old_player, byte new_player)
{
- if (_map_owner[tile] != old_player)
- return;
+ if (!IsTileOwner(tile, old_player)) return;
if (new_player != 255) {
_map_owner[tile] = new_player;
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 00be0473f..b1a94e167 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -122,7 +122,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
// statue
DrawGroundSprite(0x58C);
- image = PLAYER_SPRITE_COLOR(_map_owner[ti->tile]);
+ image = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
image += 0x8A48;
if (_display_opt & DO_TRANS_BUILDINGS)
image = (image & 0x3FFF) | 0x3224000;
@@ -133,7 +133,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
DrawClearLandTile(ti, 0);
AddSortableSpriteToDraw(
- PLAYER_SPRITE_COLOR(_map_owner[ti->tile]) + 0x92B6,
+ PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)) + 0x92B6,
ti->x+8, ti->y+8,
1, 1,
10,
@@ -165,7 +165,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
if (ti->tileh) DrawFoundation(ti, ti->tileh);
- ormod = PLAYER_SPRITE_COLOR(_map_owner[ti->tile]);
+ ormod = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
t = &_unmovable_display_datas[ti->map5 & 0x7F];
DrawGroundSprite(t->ground_sprite | ormod);
@@ -255,7 +255,7 @@ static void GetTileDesc_Unmovable(uint tile, TileDesc *td)
int i = _map5[tile];
if (i & 0x80) i = -1;
td->str = _unmovable_tile_str[i + 1];
- td->owner = _map_owner[tile];
+ td->owner = GetTileOwner(tile);
}
static void AnimateTile_Unmovable(uint tile)
@@ -308,7 +308,7 @@ static uint32 GetTileTrackStatus_Unmovable(uint tile, TransportType mode)
static void ClickTile_Unmovable(uint tile)
{
if (_map5[tile] & 0x80) {
- ShowPlayerCompany(_map_owner[tile]);
+ ShowPlayerCompany(GetTileOwner(tile));
}
}
@@ -396,8 +396,7 @@ restart:
static void ChangeTileOwner_Unmovable(uint tile, byte old_player, byte new_player)
{
- if (_map_owner[tile] != old_player)
- return;
+ if (!IsTileOwner(tile, old_player)) return;
if (_map5[tile]==3 && new_player != 255) {
_map_owner[tile] = new_player;
diff --git a/water_cmd.c b/water_cmd.c
index b7555ec9c..5c476f8c6 100644
--- a/water_cmd.c
+++ b/water_cmd.c
@@ -421,7 +421,7 @@ static void DrawTile_Water(TileInfo *ti)
return;
}
- DrawWaterStuff(ti, _shipdepot_display_seq[ti->map5 & 0x7F], PLAYER_SPRITE_COLOR(_map_owner[ti->tile]), 0);
+ DrawWaterStuff(ti, _shipdepot_display_seq[ti->map5 & 0x7F], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0);
}
void DrawShipDepotSprite(int x, int y, int image)
@@ -465,7 +465,7 @@ static void GetTileDesc_Water(uint tile, TileDesc *td)
else
td->str = STR_3806_SHIP_DEPOT;
- td->owner = _map_owner[tile];
+ td->owner = GetTileOwner(tile);
}
static void AnimateTile_Water(uint tile)
@@ -686,8 +686,7 @@ static void ClickTile_Water(uint tile)
static void ChangeTileOwner_Water(uint tile, byte old_player, byte new_player)
{
- if (_map_owner[tile] != old_player)
- return;
+ if (!IsTileOwner(tile, old_player)) return;
if (new_player != 255) {
_map_owner[tile] = new_player;