@@ -198,6 +198,7 @@ void building_house::bind_dynamic(io_buffer *iob, size_t version) {
198
198
iob->bind (BIND_SIGNATURE_UINT8, &d.is_merged );
199
199
iob->bind (BIND_SIGNATURE_UINT8, &d.criminal_active );
200
200
iob->bind (BIND_SIGNATURE_INT16, &d.highest_population );
201
+ iob->bind (BIND_SIGNATURE_INT16, &d.population );
201
202
}
202
203
203
204
int building_house::get_fire_risk (int value) const {
@@ -217,7 +218,7 @@ bvariant building_house::get_property(const xstring &domain, const xstring &name
217
218
218
219
void building_house::create_vacant_lot (tile2i tile, int image_id) {
219
220
building* b = building_create (BUILDING_HOUSE_VACANT_LOT, tile, 0 );
220
- b-> house_population = 0 ;
221
+
221
222
b->distance_from_entry = 0 ;
222
223
map_building_tiles_add (b->id , b->tile , 1 , image_id, TERRAIN_BUILDING);
223
224
}
@@ -270,7 +271,7 @@ void building_house::add_population(int num_people) {
270
271
}
271
272
272
273
auto &d = runtime_data ();
273
- base. house_population += num_people;
274
+ d. population += num_people;
274
275
city_population_add (num_people);
275
276
base.remove_figure (2 );
276
277
}
@@ -313,10 +314,10 @@ int16_t building_house::population_room() const {
313
314
}
314
315
315
316
void building_house::change_to_vacant_lot () {
316
- base. house_population = 0 ;
317
+ auto &d = runtime_data () ;
317
318
base.type = BUILDING_HOUSE_VACANT_LOT;
318
319
319
- auto &d = runtime_data () ;
320
+ d. population = 0 ;
320
321
d.level = (e_house_level)(base.type - BUILDING_HOUSE_VACANT_LOT);
321
322
const house_model &model = static_cast <const house_model&>(params ());
322
323
int vacant_lot_id = model.anim [" house" ].first_img ();
@@ -336,7 +337,7 @@ void building_house::change_to_vacant_lot() {
336
337
}
337
338
338
339
bool building_house::is_vacant_lot () const {
339
- return base. house_population == 0 ;
340
+ return house_population () == 0 ;
340
341
}
341
342
342
343
static void prepare_for_merge (int building_id, int num_tiles) {
@@ -354,10 +355,10 @@ static void prepare_for_merge(int building_id, int num_tiles) {
354
355
if (house && house->id () != building_id && house->base .house_size ) {
355
356
g_merge_data.population += house->house_population ();
356
357
for (int inv = 0 ; inv < INVENTORY_MAX; inv++) {
357
- auto &d = house->runtime_data ();
358
- g_merge_data.inventory [inv] += d .inventory [inv];
359
- g_merge_data.foods [inv] += d .foods [inv];
360
- house-> base . house_population = 0 ;
358
+ auto &housed = house->runtime_data ();
359
+ g_merge_data.inventory [inv] += housed .inventory [inv];
360
+ g_merge_data.foods [inv] += housed .foods [inv];
361
+ housed. population = 0 ;
361
362
house->base .state = BUILDING_STATE_DELETED_BY_GAME;
362
363
}
363
364
}
@@ -368,10 +369,10 @@ static void prepare_for_merge(int building_id, int num_tiles) {
368
369
void building_house::merge_impl () {
369
370
prepare_for_merge (id (), 4 );
370
371
372
+ auto &d = runtime_data ();
371
373
base.size = base.house_size = 2 ;
372
- base. house_population += g_merge_data.population ;
374
+ d. population += g_merge_data.population ;
373
375
374
- auto &d = runtime_data ();
375
376
for (int i = 0 ; i < INVENTORY_MAX; i++) {
376
377
d.foods [i] += g_merge_data.foods [i];
377
378
d.inventory [i] += g_merge_data.inventory [i];
@@ -673,9 +674,9 @@ e_house_progress building_house::check_evolve_desirability() {
673
674
674
675
static void create_house_tile (e_building_type type, tile2i tile, int image_id, int population, custom_span<int > inventory, custom_span<int > foods) {
675
676
auto house = building_create (type, tile, 0 )->dcast_house ();
676
- house->base .house_population = population;
677
677
678
678
auto &housed = house->runtime_data ();
679
+ housed.population = population;
679
680
for (int i = 0 ; i < INVENTORY_MAX; i++) {
680
681
housed.foods [i] = foods[i];
681
682
housed.inventory [i] = inventory[i];
@@ -698,8 +699,8 @@ static void split_size2(building* b, e_building_type new_type) {
698
699
foods_remainder[i] = housed.foods [i] % 4 ;
699
700
}
700
701
701
- int population_per_tile = b-> house_population / 4 ;
702
- int population_remainder = b-> house_population % 4 ;
702
+ int population_per_tile = housed. population / 4 ;
703
+ int population_remainder = housed. population % 4 ;
703
704
704
705
map_building_tiles_remove (b->id , b->tile );
705
706
@@ -708,7 +709,7 @@ static void split_size2(building* b, e_building_type new_type) {
708
709
housed.level = (e_house_level)(b->type - BUILDING_HOUSE_VACANT_LOT);
709
710
b->size = b->house_size = 1 ;
710
711
housed.is_merged = false ;
711
- b-> house_population = population_per_tile + population_remainder;
712
+ housed. population = population_per_tile + population_remainder;
712
713
for (int i = 0 ; i < INVENTORY_MAX; i++) {
713
714
housed.inventory [i] = inventory_per_tile[i] + inventory_remainder[i];
714
715
housed.foods [i] = foods_per_tile[i] + foods_remainder[i];
@@ -738,8 +739,8 @@ static void split_size3(building* b) {
738
739
foods_remainder[i] = housed.foods [i] % 9 ;
739
740
}
740
741
741
- int population_per_tile = b-> house_population / 9 ;
742
- int population_remainder = b-> house_population % 9 ;
742
+ int population_per_tile = housed. population / 9 ;
743
+ int population_remainder = housed. population % 9 ;
743
744
744
745
map_building_tiles_remove (b->id , b->tile );
745
746
@@ -748,7 +749,7 @@ static void split_size3(building* b) {
748
749
housed.level = (e_house_level)(b->type - BUILDING_HOUSE_VACANT_LOT);
749
750
b->size = b->house_size = 1 ;
750
751
housed.is_merged = false ;
751
- b-> house_population = population_per_tile + population_remainder;
752
+ housed. population = population_per_tile + population_remainder;
752
753
for (int i = 0 ; i < INVENTORY_MAX; i++) {
753
754
housed.inventory [i] = inventory_per_tile[i] + inventory_remainder[i];
754
755
housed.foods [i] = foods_per_tile[i] + foods_remainder[i];
@@ -811,7 +812,7 @@ void building_house_common_manor::devolve_to_fancy_residence() {
811
812
housed.level = (e_house_level)(base.type - BUILDING_HOUSE_VACANT_LOT);
812
813
base.size = base.house_size = 2 ;
813
814
housed.is_merged = false ;
814
- base. house_population = population_per_tile + population_remainder;
815
+ housed. population = population_per_tile + population_remainder;
815
816
for (int i = 0 ; i < INVENTORY_MAX; i++) {
816
817
housed.inventory [i] = inventory_per_tile[i] + inventory_remainder[i];
817
818
housed.foods [i] = foods_per_tile[i] + foods_remainder[i];
@@ -854,7 +855,7 @@ void building_house_modest_estate::devolve_to_statel_manor() {
854
855
housed.level = (e_house_level)(base.type - BUILDING_HOUSE_VACANT_LOT);
855
856
base.size = base.house_size = 3 ;
856
857
housed.is_merged = false ;
857
- base. house_population = population_per_tile + population_remainder;
858
+ housed. population = population_per_tile + population_remainder;
858
859
for (int i = 0 ; i < INVENTORY_MAX; i++) {
859
860
housed.inventory [i] = inventory_per_tile[i] + inventory_remainder[i];
860
861
}
@@ -910,6 +911,10 @@ void building_house::on_create(int orientation) {
910
911
d.health = 100 ;
911
912
d.house_happiness = 50 ;
912
913
d.level = (e_house_level)(type () - BUILDING_HOUSE_VACANT_LOT);
914
+
915
+ if (d.level == 0 ) {
916
+ d.population = 0 ;
917
+ }
913
918
}
914
919
915
920
void building_house::on_place_checks () {
@@ -1050,7 +1055,7 @@ void building_house_spacious_apartment::expand_to_common_residence() {
1050
1055
base.type = BUILDING_HOUSE_COMMON_RESIDENCE;
1051
1056
housed.level = HOUSE_COMMON_RESIDENCE;
1052
1057
base.size = base.house_size = 2 ;
1053
- base. house_population += g_merge_data.population ;
1058
+ housed. population += g_merge_data.population ;
1054
1059
for (int i = 0 ; i < INVENTORY_MAX; i++) {
1055
1060
housed.foods [i] += g_merge_data.foods [i];
1056
1061
housed.inventory [i] += g_merge_data.inventory [i];
@@ -1122,7 +1127,7 @@ void building_house_fancy_residence::expand_to_common_manor() {
1122
1127
housed.level = HOUSE_COMMON_MANOR;
1123
1128
base.size = 3 ;
1124
1129
base.house_size = 3 ;
1125
- base. house_population += g_merge_data.population ;
1130
+ housed. population += g_merge_data.population ;
1126
1131
1127
1132
for (int i = 0 ; i < INVENTORY_MAX; i++) {
1128
1133
housed.foods [i] += g_merge_data.foods [i];
@@ -1193,8 +1198,9 @@ void building_house_stately_manor::expand_to_modest_estate() {
1193
1198
1194
1199
base.type = BUILDING_HOUSE_MODEST_ESTATE;
1195
1200
housed.level = HOUSE_MODEST_ESTATE;
1196
- base.size = base.house_size = 4 ;
1197
- base.house_population += g_merge_data.population ;
1201
+ base.size = 4 ;
1202
+ base.house_size = 4 ;
1203
+ housed.population += g_merge_data.population ;
1198
1204
for (int i = 0 ; i < INVENTORY_MAX; i++) {
1199
1205
housed.foods [i] += g_merge_data.foods [i];
1200
1206
housed.inventory [i] += g_merge_data.inventory [i];
0 commit comments