summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-02-09 16:21:03 +0000
committerrubidium <rubidium@openttd.org>2007-02-09 16:21:03 +0000
commitb0d4ece2ad2d1033d91f25aa21553eac4924442c (patch)
tree1ce756be5536229554315f3e1708c522249e81d7
parent7299a42729e8545fc439b360a9886a397b20f134 (diff)
downloadopenttd-b0d4ece2ad2d1033d91f25aa21553eac4924442c.tar.xz
(svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
-rw-r--r--src/town.h2
-rw-r--r--src/town_map.h33
2 files changed, 20 insertions, 15 deletions
diff --git a/src/town.h b/src/town.h
index 3cf060f69..b59bf505a 100644
--- a/src/town.h
+++ b/src/town.h
@@ -218,6 +218,8 @@ static inline void DeleteTown(Town *t)
t->xy = 0;
}
+Town* CalcClosestTownFromTile(TileIndex tile, uint threshold);
+
#define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? GetTown(t->index + 1U) : NULL) if (IsValidTown(t))
#define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0)
diff --git a/src/town_map.h b/src/town_map.h
index bc546cd10..fe4bee33e 100644
--- a/src/town_map.h
+++ b/src/town_map.h
@@ -7,12 +7,6 @@
#include "town.h"
-static inline int GetHouseType(TileIndex t)
-{
- assert(IsTileType(t, MP_HOUSE));
- return _m[t].m4;
-}
-
static inline TownID GetTownIndex(TileIndex t)
{
assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_STREET)); // XXX incomplete
@@ -23,6 +17,7 @@ static inline TownID GetTownIndex(TileIndex t)
* Set the town index for a road or house tile.
* @param tile the tile
* @param index the index of the town
+ * @pre IsTileType(t, MP_STREET) || IsTileType(t, MP_HOUSE)
*/
static inline void SetTownIndex(TileIndex t, TownID index)
{
@@ -30,6 +25,23 @@ static inline void SetTownIndex(TileIndex t, TownID index)
_m[t].m2 = index;
}
+/**
+ * Gets the town associated with the house or road tile
+ * @param t the tile to get the town of
+ * @return the town
+ */
+static inline Town* GetTownByTile(TileIndex t)
+{
+ return GetTown(GetTownIndex(t));
+}
+
+
+static inline int GetHouseType(TileIndex t)
+{
+ assert(IsTileType(t, MP_HOUSE));
+ return _m[t].m4;
+}
+
static inline bool LiftHasDestination(TileIndex t)
{
return HASBIT(_m[t].m5, 7);
@@ -75,15 +87,6 @@ static inline void SetLiftPosition(TileIndex t, byte pos)
SB(_m[t].m1, 0, 7, pos);
}
-static inline Town* GetTownByTile(TileIndex t)
-{
- return GetTown(GetTownIndex(t));
-}
-
-
-Town* CalcClosestTownFromTile(TileIndex tile, uint threshold);
-
-
static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, byte type)
{
assert(IsTileType(t, MP_CLEAR));