Skip to content

Commit 4bc3d56

Browse files
committed
refactor: highest_population moved from building common class
1 parent 5a2f986 commit 4bc3d56

7 files changed

+8
-8
lines changed

src/building/building.h

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ class building {
174174
short percentage_houses_covered;
175175
short house_population;
176176
short distance_from_entry;
177-
short house_highest_population;
178177
short house_unreachable_ticks;
179178
tile2i road_access;
180179
short figure_spawn_delay;

src/building/building_debug_properties.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void game_debug_show_properties_object(pcstr prefix, building *b) {
3131
game_debug_show_property("house_population", b->house_population);
3232
//game_debug_show_property("house_population_room", b->house_population_room);
3333
game_debug_show_property("distance_from_entry", b->distance_from_entry);
34-
game_debug_show_property("house_highest_population", b->house_highest_population);
34+
//game_debug_show_property("house_highest_population", b->house_highest_population);
3535
game_debug_show_property("house_unreachable_ticks", b->house_unreachable_ticks);
3636
game_debug_show_property("road_access", b->road_access);
3737
game_debug_show_property("figure_spawn_delay", b->figure_spawn_delay);

src/building/building_house.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ void building_house::bind_dynamic(io_buffer *iob, size_t version) {
197197
iob->bind(BIND_SIGNATURE_UINT8, &d.house_happiness);
198198
iob->bind(BIND_SIGNATURE_UINT8, &d.is_merged);
199199
iob->bind(BIND_SIGNATURE_UINT8, &d.criminal_active);
200+
iob->bind(BIND_SIGNATURE_INT16, &d.highest_population);
200201
}
201202

202203
int building_house::get_fire_risk(int value) const {

src/building/building_house.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ class building_house : public building_impl {
1818

1919
struct runtime_data_t {
2020
e_house_level level;
21-
uint8_t is_merged;
2221
uint16_t foods[8];
2322
uint16_t inventory[8];
23+
uint16_t highest_population;
24+
uint8_t is_merged;
2425
uint8_t booth_juggler;
2526
uint8_t bandstand_juggler;
2627
uint8_t bandstand_musician;

src/city/city_buildings.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ io_buffer *iob_buildings = new io_buffer([] (io_buffer *iob, size_t version) {
251251
iob->bind(BIND_SIGNATURE_INT16, &b->house_population);
252252
iob->bind____skip(2);
253253
iob->bind(BIND_SIGNATURE_INT16, &b->distance_from_entry);
254-
iob->bind(BIND_SIGNATURE_INT16, &b->house_highest_population);
254+
iob->bind____skip(2);
255255

256256
iob->bind(BIND_SIGNATURE_INT16, &b->house_unreachable_ticks);
257257
iob->bind(BIND_SIGNATURE_TILE2I, b->road_access);

src/city/city_house_population.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ void city_t::house_population_update_room() {
8686
}
8787

8888
city_population_add_capacity(house->house_population(), max_pop);
89-
if (house->house_population() > house->base.house_highest_population) {
90-
house->base.house_highest_population = house->house_population();
91-
}
89+
auto &housed = house->runtime_data();
90+
housed.highest_population = std::max<short>(housed.highest_population, house->house_population());
9291
}
9392
}
9493
}

src/figuretype/figure_market_buyer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void distribute_market_resources(building* b, building* market) {
163163
level++;
164164
}
165165

166-
int max_food_stocks = 4 * b->house_highest_population;
166+
int max_food_stocks = 4 * housed.highest_population;
167167
int food_types_stored_max = 0;
168168
for (int i = INVENTORY_MIN_FOOD; i < INVENTORY_MAX_FOOD; i++) {
169169
if (housed.foods[i] >= max_food_stocks)

0 commit comments

Comments
 (0)