mirror of https://github.com/OpenTTD/OpenTTD
(svn r3986) Add [GS]etCrossingRoadOwner
parent
9f3aa9057d
commit
75a9419f04
|
@ -1002,7 +1002,9 @@ static void ConvertTownOwner(void)
|
||||||
|
|
||||||
for (tile = 0; tile != MapSize(); tile++) {
|
for (tile = 0; tile != MapSize(); tile++) {
|
||||||
if (IsTileType(tile, MP_STREET)) {
|
if (IsTileType(tile, MP_STREET)) {
|
||||||
if (IsLevelCrossing(tile) && _m[tile].m3 & 0x80) _m[tile].m3 = OWNER_TOWN;
|
if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) & 0x80) {
|
||||||
|
SetCrossingRoadOwner(tile, OWNER_TOWN);
|
||||||
|
}
|
||||||
|
|
||||||
if (_m[tile].m1 & 0x80) SetTileOwner(tile, OWNER_TOWN);
|
if (_m[tile].m1 & 0x80) SetTileOwner(tile, OWNER_TOWN);
|
||||||
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||||
|
|
|
@ -417,7 +417,7 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
MakeRoadNormal(tile, _m[tile].m3, GetCrossingRoadBits(tile), _m[tile].m2);
|
MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), _m[tile].m2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
14
road_cmd.c
14
road_cmd.c
|
@ -34,9 +34,8 @@ static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_roa
|
||||||
// Only do the special processing for actual players.
|
// Only do the special processing for actual players.
|
||||||
if (_current_player >= MAX_PLAYERS) return true;
|
if (_current_player >= MAX_PLAYERS) return true;
|
||||||
|
|
||||||
// A railway crossing has the road owner in the map3_lo byte.
|
|
||||||
if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) {
|
if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) {
|
||||||
owner = _m[tile].m3;
|
owner = GetCrossingRoadOwner(tile);
|
||||||
} else {
|
} else {
|
||||||
owner = GetTileOwner(tile);
|
owner = GetTileOwner(tile);
|
||||||
}
|
}
|
||||||
|
@ -106,9 +105,7 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (!IsTileType(tile, MP_STREET) && !IsTileType(tile, MP_TUNNELBRIDGE)) return CMD_ERROR;
|
if (!IsTileType(tile, MP_STREET) && !IsTileType(tile, MP_TUNNELBRIDGE)) return CMD_ERROR;
|
||||||
|
|
||||||
// owner for railroad crossing is stored somewhere else
|
owner = IsLevelCrossing(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile);
|
||||||
// XXX - Fix this so for a given tiletype the owner of the type is in the same variable
|
|
||||||
owner = IsLevelCrossing(tile) ? _m[tile].m3 : GetTileOwner(tile);
|
|
||||||
|
|
||||||
if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) {
|
if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) {
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space)
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space)
|
||||||
|
@ -1127,9 +1124,8 @@ static void VehicleLeave_Road(Vehicle *v, TileIndex tile, int x, int y)
|
||||||
|
|
||||||
static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
|
static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
|
||||||
{
|
{
|
||||||
// road/rail crossing where the road is owned by the current player?
|
if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) == old_player) {
|
||||||
if (old_player == _m[tile].m3 && IsLevelCrossing(tile)) {
|
SetCrossingRoadOwner(tile, new_player == OWNER_SPECTATOR ? OWNER_NONE : new_player);
|
||||||
_m[tile].m3 = (new_player == OWNER_SPECTATOR) ? OWNER_NONE : new_player;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsTileOwner(tile, old_player)) return;
|
if (!IsTileOwner(tile, old_player)) return;
|
||||||
|
@ -1143,7 +1139,7 @@ static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID n
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROAD_CROSSING:
|
case ROAD_CROSSING:
|
||||||
MakeRoadNormal(tile, _m[tile].m3, GetCrossingRoadBits(tile), _m[tile].m2);
|
MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), _m[tile].m2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
12
road_map.h
12
road_map.h
|
@ -55,6 +55,18 @@ static inline TrackBits GetCrossingRailBits(TileIndex tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO swap owner of road and rail
|
||||||
|
static inline Owner GetCrossingRoadOwner(TileIndex t)
|
||||||
|
{
|
||||||
|
return (Owner)_m[t].m3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void SetCrossingRoadOwner(TileIndex t, Owner o)
|
||||||
|
{
|
||||||
|
_m[t].m3 = o;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef enum RoadType {
|
typedef enum RoadType {
|
||||||
ROAD_NORMAL,
|
ROAD_NORMAL,
|
||||||
ROAD_CROSSING,
|
ROAD_CROSSING,
|
||||||
|
|
|
@ -1828,10 +1828,9 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold)
|
||||||
uint dist, best = threshold;
|
uint dist, best = threshold;
|
||||||
Town *best_town = NULL;
|
Town *best_town = NULL;
|
||||||
|
|
||||||
// XXX - Fix this so for a given tiletype the owner of the type is in the same variable
|
|
||||||
if (IsTileType(tile, MP_HOUSE) || (
|
if (IsTileType(tile, MP_HOUSE) || (
|
||||||
IsTileType(tile, MP_STREET) &&
|
IsTileType(tile, MP_STREET) &&
|
||||||
(IsLevelCrossing(tile) ? _m[tile].m3 : GetTileOwner(tile)) == OWNER_TOWN
|
(IsLevelCrossing(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile)) == OWNER_TOWN
|
||||||
))
|
))
|
||||||
return GetTown(_m[tile].m2);
|
return GetTown(_m[tile].m2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue