diff src/town_cmd.cpp @ 10360:d352cf399eb7 draft

(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.
author frosch <frosch@openttd.org>
date Sun, 23 Nov 2008 14:17:41 +0000 (2008-11-23)
parents 3f904839d38f
children 649ba332458f
line wrap: on
line diff
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -404,7 +404,7 @@
 		/* Now that construction is complete, we can add the population of the
 		 * building to the town. */
 		ChangePopulation(GetTownByTile(tile), hs->population);
-		SetHouseConstructionYear(tile, _cur_year);
+		ResetHouseAge(tile);
 	}
 	MarkTileDirtyByTile(tile);
 }
@@ -505,7 +505,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 &&
+			GetHouseAge(tile) >= hs->minimum_life &&
 			--t->time_until_rebuild == 0) {
 		t->time_until_rebuild = GB(r, 16, 8) + 192;
 
@@ -2608,6 +2608,15 @@
 	}
 }
 
+void TownsYearlyLoop()
+{
+	/* Increment house ages */
+	for (TileIndex t = 0; t < MapSize(); t++) {
+		if (!IsTileType(t, MP_HOUSE)) continue;
+		IncrementHouseAge(t);
+	}
+}
+
 void InitializeTowns()
 {
 	/* Clean the town pool and create 1 block in it */