summaryrefslogtreecommitdiff
path: root/src/town_cmd.cpp
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_cmd.cpp
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_cmd.cpp')
-rw-r--r--src/town_cmd.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index a2411f7ce..19cc2ec05 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -404,7 +404,7 @@ static void MakeSingleHouseBigger(TileIndex tile)
/* 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 @@ 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 &&
+ GetHouseAge(tile) >= hs->minimum_life &&
--t->time_until_rebuild == 0) {
t->time_until_rebuild = GB(r, 16, 8) + 192;
@@ -2608,6 +2608,15 @@ void TownsMonthlyLoop()
}
}
+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 */