src/newgrf_house.cpp
changeset 8787 3cf49b620b77
parent 8760 ce0891c412ce
child 8954 ca1d17502817
--- a/src/newgrf_house.cpp	Mon Jan 14 20:52:43 2008 +0000
+++ b/src/newgrf_house.cpp	Tue Jan 15 00:03:48 2008 +0000
@@ -33,8 +33,12 @@
 
 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 @@
 			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 @@
 	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;