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...*

Feature #905090 ยป 0040-Wrap-multiplier-value-and-target-to-a-new-multiplier.patch

Marko Lindqvist, 2020-12-10 07:51 PM

View differences:

ai/default/aidata.c
if (mp_val > ppol->start) {
int new_value = 0;
pplayer->multipliers[pidx] = MAX(mp_val - ppol->step, ppol->start);
pplayer->multipliers[pidx].value = MAX(mp_val - ppol->step, ppol->start);
city_list_iterate(pplayer->cities, acity) {
auto_arrange_workers(acity);
......
if (new_value > orig_value) {
/* This is step to right direction, leave it in effect. */
pplayer->multipliers_target[pidx] = pplayer->multipliers[pidx];
pplayer->multipliers[pidx].target = pplayer->multipliers[pidx].value;
needs_back_rearrange = FALSE;
better_found = TRUE;
......
if (!better_found && mp_val < ppol->stop) {
int new_value = 0;
pplayer->multipliers[pidx] = MIN(mp_val + ppol->step, ppol->stop);
pplayer->multipliers[pidx].value = MIN(mp_val + ppol->step, ppol->stop);
city_list_iterate(pplayer->cities, acity) {
auto_arrange_workers(acity);
......
if (new_value > orig_value) {
/* This is step to right direction, leave it in effect. */
pplayer->multipliers_target[pidx] = pplayer->multipliers[pidx];
pplayer->multipliers[pidx].target = pplayer->multipliers[pidx].value;
needs_back_rearrange = FALSE;
better_found = TRUE;
......
if (!better_found) {
/* Restore original multiplier value */
pplayer->multipliers[pidx] = mp_val;
pplayer->multipliers[pidx].value = mp_val;
needs_back_rearrange = TRUE;
}
}
ai/default/aiplayer.c
{
if (pplayer->ai_common.skill_level != AI_LEVEL_AWAY) {
multipliers_iterate(pmul) {
pplayer->multipliers_target[multiplier_index(pmul)] = pmul->def;
pplayer->multipliers[multiplier_index(pmul)].target = pmul->def;
} multipliers_iterate_end;
/* Clear worker tasks, some AIs (e.g. classic) does not use those */
client/packhand.c
fc_assert(pinfo->multip_count == multiplier_count());
game.control.num_multipliers = pinfo->multip_count;
multipliers_iterate(pmul) {
pplayer->multipliers[multiplier_index(pmul)] =
pplayer->multipliers[multiplier_index(pmul)].value =
pinfo->multiplier[multiplier_index(pmul)];
pplayer->multipliers_target[multiplier_index(pmul)] =
pplayer->multipliers[multiplier_index(pmul)].target =
pinfo->multiplier_target[multiplier_index(pmul)];
} multipliers_iterate_end;
common/player.c
pplayer->rgb = NULL;
memset(pplayer->multipliers, 0, sizeof(pplayer->multipliers));
memset(pplayer->multipliers_target, 0, sizeof(pplayer->multipliers_target));
/* pplayer->server is initialised in
./server/plrhand.c:server_player_init()
......
int player_multiplier_value(const struct player *pplayer,
const struct multiplier *pmul)
{
return pplayer->multipliers[multiplier_index(pmul)];
return pplayer->multipliers[multiplier_index(pmul)].value;
}
/*******************************************************************//**
......
int player_multiplier_target_value(const struct player *pplayer,
const struct multiplier *pmul)
{
return pplayer->multipliers_target[multiplier_index(pmul)];
return pplayer->multipliers[multiplier_index(pmul)].target;
}
/*******************************************************************//**
common/player.h
#define set_as_human(plr) BV_CLR((plr)->flags, PLRF_AI)
#define set_as_ai(plr) BV_SET((plr)->flags, PLRF_AI)
struct player {
struct multiplier_value
{
/* Value currently in force. */
int value;
/* Value to be used next turn. */
int target;
};
struct player
{
struct player_slot *slot;
char name[MAX_LEN_NAME];
char username[MAX_LEN_NAME];
......
struct rgbcolor *rgb;
/* Values currently in force. */
int multipliers[MAX_NUM_MULTIPLIERS];
/* Values to be used next turn. */
int multipliers_target[MAX_NUM_MULTIPLIERS];
struct multiplier_value multipliers[MAX_NUM_MULTIPLIERS];
int history; /* National level culture - does not include culture of individual
* cities. */
server/plrhand.c
if (info_level >= INFO_FULL) {
multipliers_iterate(pmul) {
packet->multiplier[multiplier_index(pmul)] =
plr->multipliers[multiplier_index(pmul)];
plr->multipliers[multiplier_index(pmul)].value;
packet->multiplier_target[multiplier_index(pmul)] =
plr->multipliers_target[multiplier_index(pmul)];
plr->multipliers[multiplier_index(pmul)].target;
} multipliers_iterate_end;
} else {
multipliers_iterate(pmul) {
......
multipliers[i], multiplier_rule_name(pmul),
player_name(pplayer));
} else {
pplayer->multipliers_target[i] = multipliers[i];
pplayer->multipliers[i].target = multipliers[i];
}
}
}
server/savegame/savegame2.c
/* First initialise player values with ruleset defaults; this will
* cover any in the ruleset not known when the savefile was created. */
multipliers_iterate(pmul) {
pplayer->multipliers[multiplier_index(pmul)]
= pplayer->multipliers_target[multiplier_index(pmul)] = pmul->def;
pplayer->multipliers[multiplier_index(pmul)].value
= pplayer->multipliers[multiplier_index(pmul)].target = pmul->def;
} multipliers_iterate_end;
/* Now override with any values from the savefile. */
......
"was %d, clamped to %d", pslot_id,
multiplier_rule_name(pmul), val, rval);
}
pplayer->multipliers[idx] = rval;
pplayer->multipliers[idx].value = rval;
val =
secfile_lookup_int_default(loading->file,
pplayer->multipliers[idx],
pplayer->multipliers[idx].value,
"player%d.multiplier%d.target",
player_slot_index(pslot), k);
rval = (((CLIP(pmul->start, val, pmul->stop)
......
"\"%s\": was %d, clamped to %d", pslot_id,
multiplier_rule_name(pmul), val, rval);
}
pplayer->multipliers_target[idx] = rval;
pplayer->multipliers[idx].target = rval;
} /* else silently discard multiplier not in current ruleset */
}
server/savegame/savegame3.c
/* First initialise player values with ruleset defaults; this will
* cover any in the ruleset not known when the savefile was created. */
multipliers_iterate(pmul) {
pplayer->multipliers[multiplier_index(pmul)]
= pplayer->multipliers_target[multiplier_index(pmul)] = pmul->def;
pplayer->multipliers[multiplier_index(pmul)].value
= pplayer->multipliers[multiplier_index(pmul)].target = pmul->def;
} multipliers_iterate_end;
/* Now override with any values from the savefile. */
......
"was %d, clamped to %d", pslot_id,
multiplier_rule_name(pmul), val, rval);
}
pplayer->multipliers[idx] = rval;
pplayer->multipliers[idx].value = rval;
val =
secfile_lookup_int_default(loading->file,
pplayer->multipliers[idx],
pplayer->multipliers[idx].value,
"player%d.multiplier%d.target",
player_slot_index(pslot), k);
rval = (((CLIP(pmul->start, val, pmul->stop)
......
" \"%s\": was %d, clamped to %d", pslot_id,
multiplier_rule_name(pmul), val, rval);
}
pplayer->multipliers_target[idx] = rval;
pplayer->multipliers[idx].target = rval;
} /* else silently discard multiplier not in current ruleset */
}
......
i = multiplier_count();
for (k = 0; k < i; k++) {
secfile_insert_int(saving->file, plr->multipliers[k],
secfile_insert_int(saving->file, plr->multipliers[k].value,
"player%d.multiplier%d.val", plrno, k);
secfile_insert_int(saving->file, plr->multipliers_target[k],
secfile_insert_int(saving->file, plr->multipliers[k].target,
"player%d.multiplier%d.target", plrno, k);
}
server/srv_main.c
int idx = multiplier_index(pmul);
if (!multiplier_can_be_changed(pmul, pplayer)) {
if (pplayer->multipliers[idx] != pmul->def) {
if (pplayer->multipliers[idx].value != pmul->def) {
notify_player(pplayer, NULL, E_MULTIPLIER, ftc_server,
_("%s restored to the default value %d"),
multiplier_name_translation(pmul),
pmul->def);
pplayer->multipliers[idx] = pmul->def;
pplayer->multipliers[idx].value = pmul->def;
}
} else {
if (pplayer->multipliers[idx] != pplayer->multipliers_target[idx]) {
if (pplayer->multipliers[idx].value != pplayer->multipliers[idx].target) {
notify_player(pplayer, NULL, E_MULTIPLIER, ftc_server,
_("%s now at value %d"),
multiplier_name_translation(pmul),
pplayer->multipliers_target[idx]);
pplayer->multipliers[idx].target);
pplayer->multipliers[idx] =
pplayer->multipliers_target[idx];
pplayer->multipliers[idx].value =
pplayer->multipliers[idx].target;
}
}
} multipliers_iterate_end;
......
}
multipliers_iterate(pmul) {
pplayer->multipliers[multiplier_index(pmul)]
= pplayer->multipliers_target[multiplier_index(pmul)]
= pmul->def;
int midx = multiplier_index(pmul);
pplayer->multipliers[midx].value
= pplayer->multipliers[midx].target
= pmul->def;
} multipliers_iterate_end;
} players_iterate_end;
}
    (1-1/1)