Project

General

Profile

Feature #97 ยป 0020-Move-action_get_act_time-to-actres.c-under-name-actr.patch

Marko Lindqvist, 12/30/2023 01:11 PM

View differences:

common/actions.c
return paction->id + L_LAST;
}
/**********************************************************************//**
Returns the unit activity time (work) this action takes (requires) or
ACT_TIME_INSTANTANEOUS if the action happens at once.
See update_unit_activity() and tile_activity_time()
**************************************************************************/
int action_get_act_time(const struct action *paction,
const struct unit *actor_unit,
const struct tile *tgt_tile,
const struct extra_type *tgt_extra)
{
enum unit_activity pactivity = actres_activity_result(paction->result);
if (pactivity == ACTIVITY_LAST) {
/* Happens instantaneously, not at turn change. */
return ACT_TIME_INSTANTANEOUS;
}
switch (pactivity) {
case ACTIVITY_PILLAGE:
case ACTIVITY_CLEAN:
case ACTIVITY_BASE:
case ACTIVITY_GEN_ROAD:
case ACTIVITY_IRRIGATE:
case ACTIVITY_MINE:
case ACTIVITY_CULTIVATE:
case ACTIVITY_PLANT:
case ACTIVITY_TRANSFORM:
return tile_activity_time(pactivity, tgt_tile, tgt_extra);
case ACTIVITY_FORTIFYING:
return 1;
case ACTIVITY_CONVERT:
return unit_type_get(actor_unit)->convert_time * ACTIVITY_FACTOR;
case ACTIVITY_EXPLORE:
case ACTIVITY_IDLE:
case ACTIVITY_FORTIFIED:
case ACTIVITY_SENTRY:
case ACTIVITY_GOTO:
case ACTIVITY_LAST:
/* Should not happen. Caught by the assertion below. */
break;
}
fc_assert(FALSE);
return ACT_TIME_INSTANTANEOUS;
}
/**********************************************************************//**
Create a new action enabler.
**************************************************************************/
common/actions.h
#define action_id_requires_details(act_id) \
action_requires_details(action_by_number(act_id))
int action_get_act_time(const struct action *paction,
const struct unit *actor_unit,
const struct tile *tgt_tile,
const struct extra_type *tgt_extra) \
fc__attribute((nonnull (1)));
#define action_id_get_act_time(act_id, actor_unit, tgt_tile, tgt_extra) \
action_get_act_time(action_by_number(act_id), \
#define action_id_get_act_time(act_id, actor_unit, tgt_tile, tgt_extra) \
actres_get_act_time(action_by_number(act_id)->result, \
actor_unit, tgt_tile, tgt_extra)
bool action_id_is_rare_pop_up(action_id act_id);
common/actres.c
return act_results[result].activity;
}
/**********************************************************************//**
Returns the unit activity time (work) this action takes (requires) or
ACT_TIME_INSTANTANEOUS if the action happens at once.
See update_unit_activity() and tile_activity_time()
**************************************************************************/
int actres_get_act_time(enum action_result result,
const struct unit *actor_unit,
const struct tile *tgt_tile,
const struct extra_type *tgt_extra)
{
enum unit_activity pactivity = actres_activity_result(result);
if (pactivity == ACTIVITY_LAST) {
/* Happens instantaneously, not at turn change. */
return ACT_TIME_INSTANTANEOUS;
}
switch (pactivity) {
case ACTIVITY_PILLAGE:
case ACTIVITY_CLEAN:
case ACTIVITY_BASE:
case ACTIVITY_GEN_ROAD:
case ACTIVITY_IRRIGATE:
case ACTIVITY_MINE:
case ACTIVITY_CULTIVATE:
case ACTIVITY_PLANT:
case ACTIVITY_TRANSFORM:
return tile_activity_time(pactivity, tgt_tile, tgt_extra);
case ACTIVITY_FORTIFYING:
return 1;
case ACTIVITY_CONVERT:
return unit_type_get(actor_unit)->convert_time * ACTIVITY_FACTOR;
case ACTIVITY_EXPLORE:
case ACTIVITY_IDLE:
case ACTIVITY_FORTIFIED:
case ACTIVITY_SENTRY:
case ACTIVITY_GOTO:
case ACTIVITY_LAST:
/* Should not happen. Caught by the assertion below. */
break;
}
fc_assert(FALSE);
return ACT_TIME_INSTANTANEOUS;
}
/**********************************************************************//**
Map actres to initial odds type.
common/actres.h
enum action_battle_kind actres_get_battle_kind(enum action_result result);
bool actres_is_hostile(enum action_result result);
enum unit_activity actres_activity_result(enum action_result result);
int actres_get_act_time(enum action_result result,
const struct unit *actor_unit,
const struct tile *tgt_tile,
const struct extra_type *tgt_extra);
enum dice_roll_type actres_dice_type(enum action_result result);
bool actres_creates_extra(enum action_result result,
const struct extra_type *pextra);
    (1-1/1)