summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/object_cmd.cpp18
-rw-r--r--src/object_map.h77
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/saveload/afterload.cpp2
4 files changed, 28 insertions, 71 deletions
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 431e9fe05..fb7b05286 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -295,7 +295,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
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(TileIndex tile, uint x, uint y)
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(TileIndex tile, DoCommandFlag flags)
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 tile)
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_Object(TileIndex tile, TransportType mode,
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 tile)
*/
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(TileIndex tile, Owner old_owner, Owner new_ow
{
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
index d50938942..7af58d27c 100644
--- a/src/object_map.h
+++ b/src/object_map.h
@@ -28,81 +28,38 @@ static inline ObjectType GetObjectType(TileIndex t)
}
/**
- * Get the index of which object this tile is attached to.
- * @param t the tile
- * @pre IsTileType(t, MP_OBJECT)
- * @return The ObjectID of the object.
- */
-static inline ObjectID GetObjectIndex(TileIndex t)
-{
- assert(IsTileType(t, MP_OBJECT));
- return _m[t].m2;
-}
-
-/**
- * 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.
+ * 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 and only if the tile is an 'owned land' tile.
+ * @return True if type matches.
*/
-static inline bool IsOwnedLand(TileIndex t)
+static inline bool IsObjectType(TileIndex t, ObjectType type)
{
- assert(IsTileType(t, MP_OBJECT));
- return GetObjectType(t) == OBJECT_OWNED_LAND;
+ return GetObjectType(t) == type;
}
/**
- * 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.
+ * 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 IsOwnedLandTile(TileIndex t)
+static inline bool IsObjectTypeTile(TileIndex t, ObjectType type)
{
- return IsTileType(t, MP_OBJECT) && IsOwnedLand(t);
+ return IsTileType(t, MP_OBJECT) && GetObjectType(t) == type;
}
/**
- * 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.
+ * Get the index of which object this tile is attached to.
+ * @param t the tile
* @pre IsTileType(t, MP_OBJECT)
- * @return true if and only if the tile is a statue.
+ * @return The ObjectID of the object.
*/
-static inline bool IsStatue(TileIndex t)
+static inline ObjectID GetObjectIndex(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);
+ return _m[t].m2;
}
/**
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 152f2f54c..e03889cf9 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2572,7 +2572,7 @@ static void TileLoop_Track(TileIndex tile)
/* 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
index a715c9162..4643530aa 100644
--- 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;
}
}