summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf.cpp4
-rw-r--r--src/table/town_land.h2
-rw-r--r--src/town.h5
-rw-r--r--src/town_cmd.cpp1
4 files changed, 9 insertions, 3 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index b4f741e87..79a19fa97 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1429,6 +1429,10 @@ static bool TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, in
}
break;
+ case 0x1F: // Minimum life span
+ FOR_EACH_OBJECT housespec[i]->minimum_life = grf_load_byte(&buf);
+ break;
+
default:
ret = true;
break;
diff --git a/src/table/town_land.h b/src/table/town_land.h
index 3469b91ac..3e5b244bb 100644
--- a/src/table/town_land.h
+++ b/src/table/town_land.h
@@ -1804,7 +1804,7 @@ assert_compile(lengthof(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4);
*/
#define MS(mnd, mxd, p, rc, bn, rr, mg, ca1, ca2, ca3, bf, ba, cg1, cg2, cg3) \
{mnd, mxd, p, rc, bn, rr, mg, {ca1, ca2, ca3}, {cg1, cg2, cg3}, bf, ba, true, \
- 0, NULL, 0, 0, {0, 0, 0, 0}, 16, NO_EXTRA_FLAG, HOUSE_NO_CLASS, 0, 2, 0, 0, NULL}
+ 0, NULL, 0, 0, {0, 0, 0, 0}, 16, NO_EXTRA_FLAG, HOUSE_NO_CLASS, 0, 2, 0, 0, 0, NULL}
/** House specifications from original data */
static const HouseSpec _original_house_specs[] = {
/**
diff --git a/src/town.h b/src/town.h
index 0924938c1..53a9258bb 100644
--- a/src/town.h
+++ b/src/town.h
@@ -164,10 +164,10 @@ struct HouseSpec {
CargoID accepts_cargo[3]; ///< 3 input cargo slots
BuildingFlags building_flags; ///< some flags that describe the house (size, stadium etc...)
HouseZones building_availability; ///< where can it be built (climates, zones)
- bool enabled; ///< the house is still avaible (by default, true.newgrf can disable it, though)
+ bool enabled; ///< the house is available to build (true by default, but can be disabled by newgrf)
/* NewHouses properties */
- HouseID substitute_id; ///< which house this one is based on
+ HouseID substitute_id; ///< which original house this one is based on
struct SpriteGroup *spritegroup; ///< pointer to the different sprites of the house
HouseID override; ///< which house this one replaces
uint16 callback_mask; ///< House callback flags
@@ -178,6 +178,7 @@ struct HouseSpec {
byte animation_frames; ///< number of animation frames
byte animation_speed; ///< amount of time between each of those frames
byte processing_time; ///< Periodic refresh multiplier
+ byte minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it
/* grf file related properties*/
uint8 local_id; ///< id defined by the grf file for this house
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 0d8ebc8ed..db9536c1c 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -424,6 +424,7 @@ static void TileLoop_Town(TileIndex tile)
if (hs->building_flags & BUILDING_HAS_1_TILE &&
HASBIT(t->flags12, TOWN_IS_FUNDED) &&
CanDeleteHouse(tile) &&
+ max(_cur_year - GetHouseConstructionYear(tile), 0) >= hs->minimum_life &&
--t->time_until_rebuild == 0) {
t->time_until_rebuild = GB(r, 16, 8) + 192;