Skip to content

Commit

Permalink
Fix longstanding bug in economy calcs
Browse files Browse the repository at this point in the history
* Code pulled in from PR#8
* Trade items in sell markets (where the player sells to the city) were
  never counted toward economic improvement.  They will be now.
  • Loading branch information
jt-traub committed May 8, 2024
1 parent 4d54a4e commit 27235d9
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions economy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1195,27 +1195,25 @@ int ARegion::TownGrowth()
int tot = 0;
for (const auto& m : markets) {
if (Population() > m->minpop) {
if (ItemDefs[m->item].type & IT_TRADE) {
if (m->type == M_BUY) {
if (m->type == M_BUY) {
if (ItemDefs[m->item].type & IT_TRADE) {
amt += 5 * m->activity;
tot += 5 * m->maxamt;
/* regional economic improvement */
improvement += 3 * amt;
}
} else {
if (m->type == M_SELL) {
// Only food items except fish are mandatory
// for town growth - other items can
// be used in replacement
if (ItemDefs[m->item].type & IT_FOOD) {
amt += 2 * m->activity;
} else amt += m->activity;
if ((ItemDefs[m->item].type & IT_FOOD)
&& (m->item != I_FISH)) tot += 2 * m->maxamt;
if (ItemDefs[m->item].type & IT_TRADE) {
/* regional economic improvement */
improvement += 3 * amt;
}
} else { // m->type == M_SELL
// Only food items except fish are mandatory
// for town growth - other items can
// be used in replacement
if (ItemDefs[m->item].type & IT_FOOD) {
amt += 2 * m->activity;
} else amt += m->activity;
if ((ItemDefs[m->item].type & IT_FOOD) && (m->item != I_FISH))
tot += 2 * m->maxamt;
if (ItemDefs[m->item].type & IT_TRADE) {
/* regional economic improvement */
improvement += 3 * amt;
}
}
}
Expand Down

0 comments on commit 27235d9

Please sign in to comment.