summaryrefslogtreecommitdiff
path: root/src/newgrf_house.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-01-15 00:03:48 +0000
committerglx <glx@openttd.org>2008-01-15 00:03:48 +0000
commit8c138523731f38af4143fc3a447ed5ee29cf5035 (patch)
tree68bebae8ed01133ddb97ffa1562a072aa5c791c7 /src/newgrf_house.cpp
parent1bcca5aae2fca73b227bda44f21f5509a03b17b9 (diff)
downloadopenttd-8c138523731f38af4143fc3a447ed5ee29cf5035.tar.xz
(svn r11855) -Fix [FS#1335]: recompute town population when removing a 'newhouses' grf, or when loading a game with missing 'newhouses' grfs
Diffstat (limited to 'src/newgrf_house.cpp')
-rw-r--r--src/newgrf_house.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index 5f7adedf8..31aa4e972 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -33,8 +33,12 @@ HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, HOUSE_MAX, INVALID_HOUSE_ID);
void CheckHouseIDs()
{
+ Town *town;
InitializeBuildingCounts();
+ /* Reset town population */
+ FOR_ALL_TOWNS(town) town->population = 0;
+
for (TileIndex t = 0; t < MapSize(); t++) {
HouseID house_id;
@@ -47,7 +51,9 @@ void CheckHouseIDs()
house_id = _house_mngr.GetSubstituteID(house_id);
SetHouseType(t, house_id);
}
- IncreaseBuildingCount(GetTownByTile(t), house_id);
+ town = GetTownByTile(t);
+ IncreaseBuildingCount(town, house_id);
+ if (IsHouseCompleted(t)) town->population += GetHouseSpecs(house_id)->population;
}
}
@@ -122,22 +128,6 @@ void DecreaseBuildingCount(Town *t, HouseID house_id)
if (_building_counts.class_count[class_id] > 0) _building_counts.class_count[class_id]--;
}
-/**
- * AfterLoadCountBuildings()
- *
- * After a savegame has been loaded, count the number of buildings on the map.
- */
-void AfterLoadCountBuildings()
-{
- if (!_loaded_newgrf_features.has_newhouses) return;
-
- for (TileIndex t = 0; t < MapSize(); t++) {
- if (!IsTileType(t, MP_HOUSE)) continue;
- IncreaseBuildingCount(GetTownByTile(t), GetHouseType(t));
- }
-}
-
-
static uint32 HouseGetRandomBits(const ResolverObject *object)
{
const TileIndex tile = object->u.house.tile;