(svn r9823) -Feature: Add support for house property 1F - minimum life span.
authormaedhros
Thu, 10 May 2007 16:03:06 +0000
changeset 7101 ff1b42bfd622
parent 7100 71b59286f5ec
child 7102 ea95244a6027
(svn r9823) -Feature: Add support for house property 1F - minimum life span.
src/newgrf.cpp
src/table/town_land.h
src/town.h
src/town_cmd.cpp
--- a/src/newgrf.cpp	Thu May 10 09:21:22 2007 +0000
+++ b/src/newgrf.cpp	Thu May 10 16:03:06 2007 +0000
@@ -1429,6 +1429,10 @@
 			}
 			break;
 
+		case 0x1F: // Minimum life span
+			FOR_EACH_OBJECT housespec[i]->minimum_life = grf_load_byte(&buf);
+			break;
+
 		default:
 			ret = true;
 			break;
--- a/src/table/town_land.h	Thu May 10 09:21:22 2007 +0000
+++ b/src/table/town_land.h	Thu May 10 16:03:06 2007 +0000
@@ -1804,7 +1804,7 @@
  */
 #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[] = {
 	/**
--- a/src/town.h	Thu May 10 09:21:22 2007 +0000
+++ b/src/town.h	Thu May 10 16:03:06 2007 +0000
@@ -164,10 +164,10 @@
 	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 @@
 	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
--- a/src/town_cmd.cpp	Thu May 10 09:21:22 2007 +0000
+++ b/src/town_cmd.cpp	Thu May 10 16:03:06 2007 +0000
@@ -424,6 +424,7 @@
 	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;