src/newgrf_house.cpp
branchgamebalance
changeset 9913 e79cd19772dd
parent 9912 1ac8aac92385
equal deleted inserted replaced
9912:1ac8aac92385 9913:e79cd19772dd
    81  */
    81  */
    82 void IncreaseBuildingCount(Town *t, HouseID house_id)
    82 void IncreaseBuildingCount(Town *t, HouseID house_id)
    83 {
    83 {
    84 	HouseClassID class_id = GetHouseSpecs(house_id)->class_id;
    84 	HouseClassID class_id = GetHouseSpecs(house_id)->class_id;
    85 
    85 
    86 	if (!HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) return;
    86 	if (!_loaded_newgrf_features.has_newhouses) return;
    87 
    87 
    88 	/* If there are 255 buildings of this type in this town, there are also
    88 	/* If there are 255 buildings of this type in this town, there are also
    89 	 * at least that many houses of the same class in the town, and
    89 	 * at least that many houses of the same class in the town, and
    90 	 * therefore on the map as well. */
    90 	 * therefore on the map as well. */
    91 	if (t->building_counts.id_count[house_id] == 255) return;
    91 	if (t->building_counts.id_count[house_id] == 255) return;
   109  */
   109  */
   110 void DecreaseBuildingCount(Town *t, HouseID house_id)
   110 void DecreaseBuildingCount(Town *t, HouseID house_id)
   111 {
   111 {
   112 	HouseClassID class_id = GetHouseSpecs(house_id)->class_id;
   112 	HouseClassID class_id = GetHouseSpecs(house_id)->class_id;
   113 
   113 
   114 	if (!HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) return;
   114 	if (!_loaded_newgrf_features.has_newhouses) return;
   115 
   115 
   116 	if (t->building_counts.id_count[house_id] > 0) t->building_counts.id_count[house_id]--;
   116 	if (t->building_counts.id_count[house_id] > 0) t->building_counts.id_count[house_id]--;
   117 	if (_building_counts.id_count[house_id] > 0)   _building_counts.id_count[house_id]--;
   117 	if (_building_counts.id_count[house_id] > 0)   _building_counts.id_count[house_id]--;
   118 
   118 
   119 	if (class_id == HOUSE_NO_CLASS) return;
   119 	if (class_id == HOUSE_NO_CLASS) return;
   127  *
   127  *
   128  * After a savegame has been loaded, count the number of buildings on the map.
   128  * After a savegame has been loaded, count the number of buildings on the map.
   129  */
   129  */
   130 void AfterLoadCountBuildings()
   130 void AfterLoadCountBuildings()
   131 {
   131 {
   132 	if (!HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) return;
   132 	if (!_loaded_newgrf_features.has_newhouses) return;
   133 
   133 
   134 	for (TileIndex t = 0; t < MapSize(); t++) {
   134 	for (TileIndex t = 0; t < MapSize(); t++) {
   135 		if (!IsTileType(t, MP_HOUSE)) continue;
   135 		if (!IsTileType(t, MP_HOUSE)) continue;
   136 		IncreaseBuildingCount(GetTownByTile(t), GetHouseType(t));
   136 		IncreaseBuildingCount(GetTownByTile(t), GetHouseType(t));
   137 	}
   137 	}