Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't access items in empty cache #2332

Merged
merged 4 commits into from
Sep 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions common/city.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2247,6 +2247,10 @@ void add_specialist_output(
// This is more than just an optimization. For governors that forbid
// specialists, the cache may not be filled.
if (count > 0) {
// If there is a cache it must not be empty.
fc_assert_action(!pcsoutputs || !pcsoutputs->empty(),
pcsoutputs = nullptr);

output_type_iterate(stat_index)
{
int amount = pcsoutputs
Expand Down Expand Up @@ -2870,6 +2874,9 @@ void set_city_production(struct city *pcity,
trade_routes_iterate_end;
pcity->prod[O_GOLD] += get_city_tithes_bonus(pcity);

// If there is a cache it must not be empty.
fc_assert_action(!pcwaste || !pcwaste->empty(), pcwaste = nullptr);

/* Account for waste. Note that waste is calculated before tax income is
* calculated, so if you had "science waste" it would not include taxed
* science. However waste is calculated after the bonuses are multiplied
Expand Down
Loading