diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -295,7 +295,7 @@ CommandCost CmdBuildObject(TileIndex til case OBJECT_OWNED_LAND: if (IsTileType(tile, MP_OBJECT) && IsTileOwner(tile, _current_company) && - IsOwnedLand(tile)) { + IsObjectType(tile, OBJECT_OWNED_LAND)) { return_cmd_error(STR_ERROR_YOU_ALREADY_OWN_IT); } break; @@ -396,7 +396,7 @@ static void DrawTile_Object(TileInfo *ti static int GetSlopePixelZ_Object(TileIndex tile, uint x, uint y) { - if (IsOwnedLand(tile)) { + if (IsObjectType(tile, OBJECT_OWNED_LAND)) { int z; Slope tileh = GetTilePixelSlope(tile, &z); @@ -408,7 +408,7 @@ static int GetSlopePixelZ_Object(TileInd static Foundation GetFoundation_Object(TileIndex tile, Slope tileh) { - return IsOwnedLand(tile) ? FOUNDATION_NONE : FlatteningFoundation(tileh); + return IsObjectType(tile, OBJECT_OWNED_LAND) ? FOUNDATION_NONE : FlatteningFoundation(tileh); } /** @@ -525,7 +525,7 @@ static CommandCost ClearTile_Object(Tile static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted) { - if (!IsCompanyHQ(tile)) return; + if (!IsObjectType(tile, OBJECT_HQ)) return; /* HQ accepts passenger and mail; but we have to divide the values * between 4 tiles it occupies! */ @@ -570,7 +570,7 @@ static void TileLoop_Object(TileIndex ti if (IsTileOnWater(tile)) TileLoop_Water(tile); - if (!IsCompanyHQ(tile)) return; + if (!IsObjectType(tile, OBJECT_HQ)) return; /* HQ accepts passenger and mail; but we have to divide the values * between 4 tiles it occupies! */ @@ -607,7 +607,7 @@ static TrackStatus GetTileTrackStatus_Ob static bool ClickTile_Object(TileIndex tile) { - if (!IsCompanyHQ(tile)) return false; + if (!IsObjectType(tile, OBJECT_HQ)) return false; ShowCompany(GetTileOwner(tile)); return true; @@ -626,7 +626,7 @@ static void AnimateTile_Object(TileIndex */ static bool HasTransmitter(TileIndex tile, void *user) { - return IsTransmitterTile(tile); + return IsObjectTypeTile(tile, OBJECT_TRANSMITTER); } void GenerateObjects() @@ -713,9 +713,9 @@ static void ChangeTileOwner_Object(TileI { if (!IsTileOwner(tile, old_owner)) return; - if (IsOwnedLand(tile) && new_owner != INVALID_OWNER) { + if (IsObjectType(tile, OBJECT_OWNED_LAND) && new_owner != INVALID_OWNER) { SetTileOwner(tile, new_owner); - } else if (IsStatueTile(tile)) { + } else if (IsObjectType(tile, OBJECT_STATUE)) { Town *t = Object::GetByTile(tile)->town; ClrBit(t->statues, old_owner); if (new_owner != INVALID_OWNER && !HasBit(t->statues, new_owner)) { diff --git a/src/object_map.h b/src/object_map.h --- a/src/object_map.h +++ b/src/object_map.h @@ -28,6 +28,29 @@ static inline ObjectType GetObjectType(T } /** + * Check whether the object on a tile is of a specific type. + * @param t Tile to test. + * @param type Type to test. + * @pre IsTileType(t, MP_OBJECT) + * @return True if type matches. + */ +static inline bool IsObjectType(TileIndex t, ObjectType type) +{ + return GetObjectType(t) == type; +} + +/** + * Check whether a tile is a object tile of a specific type. + * @param t Tile to test. + * @param type Type to test. + * @return True if type matches. + */ +static inline bool IsObjectTypeTile(TileIndex t, ObjectType type) +{ + return IsTileType(t, MP_OBJECT) && GetObjectType(t) == type; +} + +/** * Get the index of which object this tile is attached to. * @param t the tile * @pre IsTileType(t, MP_OBJECT) @@ -40,72 +63,6 @@ static inline ObjectID GetObjectIndex(Ti } /** - * Does the given tile have a transmitter? - * @param t the tile to inspect. - * @return true if and only if the tile has a transmitter. - */ -static inline bool IsTransmitterTile(TileIndex t) -{ - return IsTileType(t, MP_OBJECT) && GetObjectType(t) == OBJECT_TRANSMITTER; -} - -/** - * Is this object tile an 'owned land' tile? - * @param t the tile to inspect. - * @pre IsTileType(t, MP_OBJECT) - * @return true if and only if the tile is an 'owned land' tile. - */ -static inline bool IsOwnedLand(TileIndex t) -{ - assert(IsTileType(t, MP_OBJECT)); - return GetObjectType(t) == OBJECT_OWNED_LAND; -} - -/** - * Is the given tile (pre-)owned by someone (the little flags)? - * @param t the tile to inspect. - * @return true if and only if the tile is an 'owned land' tile. - */ -static inline bool IsOwnedLandTile(TileIndex t) -{ - return IsTileType(t, MP_OBJECT) && IsOwnedLand(t); -} - -/** - * Is this object tile a HQ tile? - * @param t the tile to inspect. - * @pre IsTileType(t, MP_OBJECT) - * @return true if and only if the tile is a HQ tile. - */ -static inline bool IsCompanyHQ(TileIndex t) -{ - assert(IsTileType(t, MP_OBJECT)); - return _m[t].m5 == OBJECT_HQ; -} - -/** - * Is this object tile a statue? - * @param t the tile to inspect. - * @pre IsTileType(t, MP_OBJECT) - * @return true if and only if the tile is a statue. - */ -static inline bool IsStatue(TileIndex t) -{ - assert(IsTileType(t, MP_OBJECT)); - return GetObjectType(t) == OBJECT_STATUE; -} - -/** - * Is the given tile a statue? - * @param t the tile to inspect. - * @return true if and only if the tile is a statue. - */ -static inline bool IsStatueTile(TileIndex t) -{ - return IsTileType(t, MP_OBJECT) && IsStatue(t); -} - -/** * Get the random bits of this tile. * @param t The tile to get the bits for. * @pre IsTileType(t, MP_OBJECT) diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -2572,7 +2572,7 @@ static void TileLoop_Track(TileIndex til /* Show fences if it's a house, industry, object, road, tunnelbridge or not owned by us. */ if (!IsValidTile(tile2) || IsTileType(tile2, MP_HOUSE) || IsTileType(tile2, MP_INDUSTRY) || - IsTileType(tile2, MP_ROAD) || (IsTileType(tile2, MP_OBJECT) && !IsOwnedLand(tile2)) || IsTileType(tile2, MP_TUNNELBRIDGE) || !IsTileOwner(tile2, owner)) { + IsTileType(tile2, MP_ROAD) || (IsTileType(tile2, MP_OBJECT) && !IsObjectType(tile2, OBJECT_OWNED_LAND)) || IsTileType(tile2, MP_TUNNELBRIDGE) || !IsTileOwner(tile2, owner)) { fences |= 1 << d; } } diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1444,7 +1444,7 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(52)) { for (TileIndex t = 0; t < map_size; t++) { - if (IsStatueTile(t)) { + if (IsTileType(t, MP_OBJECT) && GetObjectType(t) == OBJECT_STATUE) { _m[t].m2 = CalcClosestTownFromTile(t)->index; } }