Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. Read more...

Bug #892050 » gold-upkeep-style-mixed-2.6-with-log.patch

Anonymous, 2020-10-20 04:55 PM

View differences:

server/cityturn.c
if (n > 0) {
struct city *cities[n];
int i = 0, r;
int nation_unit_upkeep = 0;
int nation_impr_upkeep = 0;
city_list_iterate(pplayer->cities, pcity) {
int ci;
......
}
}
/* used based on 'gold_upkeep_style', see below */
nation_unit_upkeep += city_total_unit_gold_upkeep(pcity);
nation_impr_upkeep += city_total_impr_gold_upkeep(pcity);
/* Add cities to array for later random order handling */
cities[i++] = pcity;
} city_list_iterate_end;
/* How gold upkeep is handled depends on the setting
* 'game.info.gold_upkeep_style':
* GOLD_UPKEEP_CITY: Each city tries to balance its upkeep individually
* (this is done in update_city_activity()).
* GOLD_UPKEEP_MIXED: Each city tries to balance its upkeep for
* buildings individually; the upkeep for units is
* paid by the nation.
* GOLD_UPKEEP_NATION: The nation as a whole balances the treasury. If
* the treasury is not balance units and buildings
* are sold. */
/* Iterate over cities in a random order. */
while (i > 0) {
r = fc_rand(i);
......
cities[r] = cities[--i];
}
if (pplayer->economic.gold < 0) {
switch (game.info.gold_upkeep_style) {
case GOLD_UPKEEP_CITY:
break;
case GOLD_UPKEEP_MIXED:
/* Nation pays for units. */
/* How gold upkeep is handled depends on the setting
* 'game.info.gold_upkeep_style':
* GOLD_UPKEEP_CITY: Each city tries to balance its upkeep individually
* (this is done in update_city_activity()).
* GOLD_UPKEEP_MIXED: Each city tries to balance its upkeep for
* buildings individually; the upkeep for units is
* paid by the nation.
* GOLD_UPKEEP_NATION: The nation as a whole balances the treasury. If
* the treasury is not balanced units and buildings
* are sold.
*/
if (game.info.gold_upkeep_style == GOLD_UPKEEP_CITY) {
; /* Cities already handled all upkeep costs. */
log_normal("update_city_activities: cities already handled upkeep");
} else if (game.info.gold_upkeep_style == GOLD_UPKEEP_MIXED) {
/* Nation pays for units. */
pplayer->economic.gold -= nation_unit_upkeep;
log_normal("update_city_activities: nation paid %d gold for units, treasury now %d",
nation_unit_upkeep, pplayer->economic.gold);
if (pplayer->economic.gold < 0) {
player_balance_treasury_units(pplayer);
break;
case GOLD_UPKEEP_NATION:
/* Nation pays for units and buildings. */
}
} else if (game.info.gold_upkeep_style == GOLD_UPKEEP_NATION) {
/* Nation pays for units and buildings. */
pplayer->economic.gold -= nation_unit_upkeep;
pplayer->economic.gold -= nation_impr_upkeep;
log_normal("update_city_activities: nation paid %d gold for units + %d for buildings, treasury now %d",
nation_unit_upkeep, nation_impr_upkeep, pplayer->economic.gold);
if (pplayer->economic.gold < 0) {
player_balance_treasury_units_and_buildings(pplayer);
break;
}
}
......
pcity->airlift = city_airlift_max(pcity);
update_bulbs(pplayer, pcity->prod[O_SCIENCE], FALSE);
/* Update the treasury. */
pplayer->economic.gold += pcity->prod[O_GOLD];
pplayer->economic.gold -= city_total_impr_gold_upkeep(pcity);
pplayer->economic.gold -= city_total_unit_gold_upkeep(pcity);
/* Update the treasury, paying upkeeps and checking running out
* of gold based on the ruleset setting 'game.info.gold_upkeep_style':
* GOLD_UPKEEP_CITY: Cities pay for buildings and units and deficit
* is checked right here.
* GOLD_UPKEEP_MIXED: Cities pay only for buildings; the nation pays
* for units after all cities are processed.
* GOLD_UPKEEP_NATION: The nation pays for buildings and units
* only after all cities are processed.
*
* city_support() in city.c sets pcity->usage[O_GOLD] (and hence
* ->surplus[O_GOLD]) according to the setting.
*/
pplayer->economic.gold += pcity->surplus[O_GOLD];
log_normal("update_city_activity: %s gold surplus %d, treasury now %d",
city_name_get(pcity), pcity->surplus[O_GOLD], pplayer->economic.gold);
if (pplayer->economic.gold < 0) {
/* Not enough gold - we have to sell some buildings, and if that
* is not enough, disband units with gold upkeep, taking into
* account the setting of 'game.info.gold_upkeep_style':
* GOLD_UPKEEP_CITY: Cities pay for buildings and units.
* GOLD_UPKEEP_MIXED: Cities pay only for buildings; the nation pays
* for units.
* GOLD_UPKEEP_NATION: The nation pays for buildings and units. */
switch (game.info.gold_upkeep_style) {
case GOLD_UPKEEP_CITY:
case GOLD_UPKEEP_MIXED:
if (!city_balance_treasury_buildings(pcity)
&& game.info.gold_upkeep_style == GOLD_UPKEEP_CITY) {
if (game.info.gold_upkeep_style == GOLD_UPKEEP_NATION) {
; /* This shouldn't be possible since all upkeeps are paid later. */
} else if (game.info.gold_upkeep_style == GOLD_UPKEEP_MIXED) {
/* Ran out of money while paying for buildings, try to sell buildings. */
log_normal("update_city_activity: %s selling buildings...", city_name_get(pcity));
city_balance_treasury_buildings(pcity);
} else if (game.info.gold_upkeep_style == GOLD_UPKEEP_CITY) {
/* Paid for both buildings and units, try to sell both in turn. */
log_normal("update_city_activity: %s selling buildings and units...", city_name_get(pcity));
if (! city_balance_treasury_buildings(pcity)) {
city_balance_treasury_units(pcity);
}
break;
case GOLD_UPKEEP_NATION:
break;
}
}
(4-4/5)