summaryrefslogtreecommitdiff
path: root/src/town_map.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-11-23 14:17:41 +0000
committerfrosch <frosch@openttd.org>2008-11-23 14:17:41 +0000
commit3d467cabe5ff086a76ecee1c9ae91da3f3caf35d (patch)
treef40e12e3b8552cbd2e88bf34163d9d6bd7504306 /src/town_map.h
parent2277a1ff9ccd2e5a5acca1e815f628f054c84491 (diff)
downloadopenttd-3d467cabe5ff086a76ecee1c9ae91da3f3caf35d.tar.xz
(svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
Note: Savegames from r13437 to now are broken and have a age of 255 years for a lot houses.
Diffstat (limited to 'src/town_map.h')
-rw-r--r--src/town_map.h27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/town_map.h b/src/town_map.h
index e5f55c12b..b0653a1cd 100644
--- a/src/town_map.h
+++ b/src/town_map.h
@@ -6,8 +6,6 @@
#define TOWN_MAP_H
#include "town.h"
-#include "date_type.h"
-#include "date_func.h"
#include "tile_map.h"
/**
@@ -266,27 +264,38 @@ static inline void IncHouseConstructionTick(TileIndex t)
}
/**
- * Set the year that this house was constructed.
+ * Sets the age of the house to zero.
+ * Needs to be called after the house is completed. During construction stages the map space is used otherwise.
* @param t the tile of this house
- * @param year the year to set
* @pre IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)
*/
-static inline void SetHouseConstructionYear(TileIndex t, Year year)
+static inline void ResetHouseAge(TileIndex t)
{
assert(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t));
- _m[t].m5 = Clamp(year - GetHouseSpecs(GetHouseType(t))->min_year, 0, 0xFF);
+ _m[t].m5 = 0;
}
/**
- * Get the year that this house was constructed.
+ * Increments the age of the house.
+ * @param t the tile of this house
+ * @pre IsTileType(t, MP_HOUSE)
+ */
+static inline void IncrementHouseAge(TileIndex t)
+{
+ assert(IsTileType(t, MP_HOUSE));
+ if (IsHouseCompleted(t) && _m[t].m5 < 0xFF) _m[t].m5++;
+}
+
+/**
+ * Get the age of the house
* @param t the tile of this house
* @pre IsTileType(t, MP_HOUSE)
* @return year
*/
-static inline Year GetHouseConstructionYear(TileIndex t)
+static inline Year GetHouseAge(TileIndex t)
{
assert(IsTileType(t, MP_HOUSE));
- return IsHouseCompleted(t) ? _m[t].m5 + GetHouseSpecs(GetHouseType(t))->min_year : _cur_year;
+ return IsHouseCompleted(t) ? _m[t].m5 : 0;
}
/**