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 #875079 ยป 0009-Merge-help-production-action-performers.patch

Sveinung Kvilhaugsvik, 2020-05-26 11:02 AM

View differences:

server/unithand.c
struct city *pcity_dest,
const struct action *paction);
static bool unit_do_recycle(struct player *pplayer,
struct unit *punit,
struct city *pcity,
const struct action *paction);
static bool do_unit_help_build_wonder(struct player *pplayer,
struct unit *punit,
struct city *pcity_dest,
const struct action *paction);
static bool unit_do_help_build(struct player *pplayer,
struct unit *punit,
struct city *pcity_dest,
const struct action *paction);
static bool unit_bombard(struct unit *punit, struct tile *ptile,
const struct action *paction);
static bool unit_nuke(struct player *pplayer, struct unit *punit,
......
break;
case ACTION_HELP_WONDER:
ACTION_STARTED_UNIT_CITY(action_type, actor_unit, pcity,
do_unit_help_build_wonder(pplayer,
actor_unit, pcity,
paction));
unit_do_help_build(pplayer,
actor_unit, pcity,
paction));
break;
case ACTION_SPY_NUKE:
case ACTION_SPY_NUKE_ESC:
......
break;
case ACTION_RECYCLE_UNIT:
ACTION_STARTED_UNIT_CITY(action_type, actor_unit, pcity,
unit_do_recycle(pplayer, actor_unit, pcity,
paction));
unit_do_help_build(pplayer, actor_unit, pcity,
paction));
break;
case ACTION_HOME_CITY:
ACTION_STARTED_UNIT_CITY(action_type, actor_unit, pcity,
......
return punit->homecity == pcity->id;
}
/**********************************************************************//**
Recycle a unit in a city.
1/2 of the shields used to build the unit is added to the city's shield
stock for the current production.
Returns TRUE iff action could be done, FALSE if it couldn't. Even if
this returns TRUE, unit may have died during the action.
**************************************************************************/
static bool unit_do_recycle(struct player *pplayer,
struct unit *punit,
struct city *pcity,
const struct action *paction)
{
int shields;
/* Sanity check: The actor still exists. */
fc_assert_ret_val(pplayer, FALSE);
fc_assert_ret_val(punit, FALSE);
/* Sanity check: The target city still exists. */
fc_assert_ret_val(pcity, FALSE);
shields = unit_shield_value(punit, unit_type_get(punit), paction);
/* Add the shields from recycling the unit to the city's current
* production. */
pcity->shield_stock += shields;
/* If we change production later at this turn. No penalty is added. */
pcity->disbanded_shields += shields;
notify_player(pplayer, city_tile(pcity), E_CARAVAN_ACTION, ftc_server,
/* TRANS: ... Ironclad ... New York */
_("Recycled your %s to help the current production in %s."),
unit_link(punit),
city_link(pcity));
send_city_info(city_owner(pcity), pcity);
/* The unit is now recycled. */
return TRUE;
}
/**********************************************************************//**
This function assumes that the target city is valid. It should only be
called after checking that the unit legally can join the target city.
......
}
/**********************************************************************//**
Handle request to help in wonder building.
Help build the current production in a city.
The amount of shields used to build the unit added to the city's shield
stock for the current production is determined by the
Unit_Shield_Value_Pct effect.
Returns TRUE iff action could be done, FALSE if it couldn't. Even if
this returns TRUE, unit may have died during the action.
**************************************************************************/
static bool do_unit_help_build_wonder(struct player *pplayer,
struct unit *punit,
struct city *pcity_dest,
const struct action *paction)
static bool unit_do_help_build(struct player *pplayer,
struct unit *punit,
struct city *pcity_dest,
const struct action *paction)
{
const char *work;
const char *prod;
int shields;
/* Sanity check: The actor still exists. */
......
shields = unit_shield_value(punit, unit_type_get(punit), paction);
pcity_dest->shield_stock += shields;
pcity_dest->caravan_shields += shields;
if (action_has_result(paction, ACTION_HELP_WONDER)) {
pcity_dest->shield_stock += shields;
pcity_dest->caravan_shields += shields;
} else {
fc_assert(action_has_result(paction, ACTION_RECYCLE_UNIT));
/* Add the shields from recycling the unit to the city's current
* production. */
pcity_dest->shield_stock += shields;
/* If we change production later at this turn. No penalty is added. */
pcity_dest->disbanded_shields += shields;
}
conn_list_do_buffer(pplayer->connections);
if (action_has_result(paction, ACTION_HELP_WONDER)) {
/* Let the player that just donated shields with "Help Wonder" know
* the result of his donation. */
prod = city_production_name_translation(pcity_dest);
} else {
fc_assert(action_has_result(paction, ACTION_RECYCLE_UNIT));
/* TRANS: Your Caravan does "Recycle Unit" to help build the
* current production in Bergen (4 surplus).
* "Recycle Unit" says "current production" rather than its name. */
prod = _("current production");
}
if (build_points_left(pcity_dest) >= 0) {
/* TRANS: Your Caravan helps build the Pyramids in Bergen (4
* remaining). You can reorder '4' and 'remaining' in the actual
* format string. */
/* TRANS: Your Caravan does "Help Wonder" to help build the
* Pyramids in Bergen (4 remaining).
* You can reorder '4' and 'remaining' in the actual format string. */
work = _("remaining");
} else {
/* TRANS: Your Caravan helps build the Pyramids in Bergen (4
* surplus). You can reorder '4' and 'surplus' in the actual
* format string. */
/* TRANS: Your Caravan does "Help Wonder" to help build the
* Pyramids in Bergen (4 surplus).
* You can reorder '4' and 'surplus' in the actual format string. */
work = _("surplus");
}
/* Let the player that just donated shields to the wonder building know
* the result of his donation. */
notify_player(pplayer, city_tile(pcity_dest), E_CARAVAN_ACTION,
ftc_server,
/* TRANS: Your Caravan helps build the Pyramids in Bergen
* (4 surplus). */
_("Your %s helps build the %s in %s (%d %s)."),
/* TRANS: Your Caravan does "Help Wonder" to help build the
* Pyramids in Bergen (4 surplus). */
_("Your %s does %s to help build the %s in %s (%d %s)."),
unit_link(punit),
city_production_name_translation(pcity_dest),
action_name_translation(paction),
prod,
city_link(pcity_dest),
abs(build_points_left(pcity_dest)),
work);
    (1-1/1)