(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.
This commit is contained in:
frosch
2008-11-23 14:17:41 +00:00
parent 2277a1ff9c
commit 3d467cabe5
6 changed files with 39 additions and 14 deletions

View File

@@ -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 */