diff options
-rw-r--r-- | functions.h | 2 | ||||
-rw-r--r-- | map.h | 5 | ||||
-rw-r--r-- | openttd.h | 2 | ||||
-rw-r--r-- | player.h | 2 | ||||
-rw-r--r-- | players.c | 8 | ||||
-rw-r--r-- | road_cmd.c | 8 | ||||
-rw-r--r-- | road_map.h | 2 | ||||
-rw-r--r-- | tunnelbridge_cmd.c | 2 |
8 files changed, 15 insertions, 16 deletions
diff --git a/functions.h b/functions.h index 3a6ae3825..ab91f0734 100644 --- a/functions.h +++ b/functions.h @@ -52,7 +52,7 @@ void TileLoop_Water(TileIndex tile); bool CheckPlayerHasMoney(int32 cost); void SubtractMoneyFromPlayer(int32 cost); void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost); -bool CheckOwnership(PlayerID owner); +bool CheckOwnership(Owner owner); bool CheckTileOwnership(TileIndex tile); StringID GetPlayerNameString(PlayerID player, uint index); @@ -67,12 +67,13 @@ static inline TileIndex TileVirtXY(uint x, uint y) return (y >> 4 << MapLogX()) + (x >> 4); } -typedef enum Owner { +typedef byte Owner; +enum Owners { OWNER_TOWN = 0x0F, // a town owns the tile OWNER_NONE = 0x10, // nobody owns the tile OWNER_WATER = 0x11, // "water" owns the tile OWNER_END = 0x12, -} Owner; +}; enum { INVALID_TILE = (TileIndex)-1 @@ -292,7 +292,7 @@ typedef uint AcceptedCargo[NUM_CARGO]; typedef struct TileDesc { StringID str; - byte owner; + Owner owner; Date build_date; uint32 dparam[2]; } TileDesc; @@ -202,7 +202,7 @@ typedef struct Player { uint16 GetDrawStringPlayerColor(PlayerID player); void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player); -void GetNameOfOwner(PlayerID owner, TileIndex tile); +void GetNameOfOwner(Owner owner, TileIndex tile); int64 CalculateCompanyValue(const Player* p); void InvalidatePlayerWindows(const Player* p); void UpdatePlayerMoney32(Player *p); @@ -259,7 +259,7 @@ void UpdatePlayerMoney32(Player *p) } } -void GetNameOfOwner(PlayerID owner, TileIndex tile) +void GetNameOfOwner(Owner owner, TileIndex tile) { SetDParam(2, owner); @@ -283,7 +283,7 @@ void GetNameOfOwner(PlayerID owner, TileIndex tile) bool CheckOwnership(PlayerID owner) { - assert(owner <= OWNER_WATER); + assert(owner < OWNER_END); if (owner == _current_player) return true; _error_message = STR_013B_OWNED_BY; @@ -293,9 +293,9 @@ bool CheckOwnership(PlayerID owner) bool CheckTileOwnership(TileIndex tile) { - PlayerID owner = GetTileOwner(tile); + Owner owner = GetTileOwner(tile); - assert(owner <= OWNER_WATER); + assert(owner < OWNER_END); if (owner == _current_player) return true; _error_message = STR_013B_OWNED_BY; diff --git a/road_cmd.c b/road_cmd.c index f1009300b..6ec8ef07f 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -39,7 +39,7 @@ static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_roa { RoadBits present; RoadBits n; - byte owner; + Owner owner; *edge_road = true; if (_game_mode == GM_EDITOR) return true; @@ -51,9 +51,7 @@ static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_roa // Only do the special processing if the road is owned // by a town - if (owner != OWNER_TOWN) { - return owner == OWNER_NONE || CheckOwnership(owner); - } + if (owner != OWNER_TOWN) return (owner == OWNER_NONE) || CheckOwnership(owner); if (_cheats.magic_bulldozer.value) return true; @@ -94,7 +92,7 @@ int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) // cost for removing inner/edge -roads static const uint16 road_remove_cost[2] = {50, 18}; - PlayerID owner; + Owner owner; Town *t; /* true if the roadpiece was always removeable, * false if it was a center piece. Affects town ratings drop */ diff --git a/road_map.h b/road_map.h index 07670f97c..258c41e3b 100644 --- a/road_map.h +++ b/road_map.h @@ -178,7 +178,7 @@ RoadBits GetAnyRoadBits(TileIndex); TrackBits GetAnyRoadTrackBits(TileIndex tile); -static inline void MakeRoadNormal(TileIndex t, Owner owner, RoadBits bits, uint town) +static inline void MakeRoadNormal(TileIndex t, Owner owner, RoadBits bits, TownID town) { SetTileType(t, MP_STREET); SetTileOwner(t, owner); diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index 70fbd7a17..769ab29c4 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -708,7 +708,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags) if (GetTransportTypeUnderBridge(c) == TRANSPORT_RAIL) { MakeRailNormal(c, GetTileOwner(c), GetRailBitsUnderBridge(c), GetRailType(c)); } else { - uint town = IsTileOwner(c, OWNER_TOWN) ? ClosestTownFromTile(c, (uint)-1)->index : 0; + TownID town = IsTileOwner(c, OWNER_TOWN) ? ClosestTownFromTile(c, (uint)-1)->index : 0; MakeRoadNormal(c, GetTileOwner(c), GetRoadBitsUnderBridge(c), town); } MarkTileDirtyByTile(c); |