summaryrefslogtreecommitdiff
path: root/town_map.h
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-03-31 08:18:14 +0000
committercelestar <celestar@openttd.org>2006-03-31 08:18:14 +0000
commit633d9fb8eb4c8bd020855afc14b8ec4ea8341a07 (patch)
treef8e65989afbaa23d0cb6429f4a25bc7b6fd67bec /town_map.h
parentcefece9f3c7180b0408fd66cd93f2c6d1ccb5fb2 (diff)
downloadopenttd-633d9fb8eb4c8bd020855afc14b8ec4ea8341a07.tar.xz
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
Diffstat (limited to 'town_map.h')
-rw-r--r--town_map.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/town_map.h b/town_map.h
index 48d3ad94b..b673722bf 100644
--- a/town_map.h
+++ b/town_map.h
@@ -18,3 +18,31 @@ static inline Town* GetTownByTile(TileIndex t)
{
return GetTown(GetTownIndex(t));
}
+
+static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, byte type)
+{
+ assert(IsTileType(t, MP_CLEAR));
+
+ SetTileType(t, MP_HOUSE);
+ _m[t].m1 = 0;
+ _m[t].m2 = tid;
+ SB(_m[t].m3, 6, 2, stage);
+ _m[t].m4 = type;
+ SB(_m[t].m5, 0, 2, counter);
+
+ MarkTileDirtyByTile(t);
+}
+
+enum {
+ TWO_BY_TWO_BIT = 2, ///< House is two tiles in X and Y directions
+ ONE_BY_TWO_BIT = 1, ///< House is two tiles in Y direction
+ TWO_BY_ONE_BIT = 0, ///< House is two tiles in X direction
+};
+
+static inline void MakeTownHouse(TileIndex t, TownID tid, byte counter, byte stage, byte size, byte type)
+{
+ MakeHouseTile(t, tid, counter, stage, type);
+ if (HASBIT(size, TWO_BY_TWO_BIT) || HASBIT(size, ONE_BY_TWO_BIT)) MakeHouseTile(t + TileDiffXY(0, 1), tid, counter, stage, ++type);
+ if (HASBIT(size, TWO_BY_TWO_BIT) || HASBIT(size, TWO_BY_ONE_BIT)) MakeHouseTile(t + TileDiffXY(1, 0), tid, counter, stage, ++type);
+ if (HASBIT(size, TWO_BY_TWO_BIT)) MakeHouseTile(t + TileDiffXY(1, 1), tid, counter, stage, ++type);
+}