Project

General

Profile

Feature #622 » 0077-Unhardcode-wld.map-from-action_prob_vs_tile.patch

main, S3_2 - Marko Lindqvist, 05/16/2024 02:36 AM

View differences:

client/control.c
break;
case ATK_TILE:
if ((ptile = unit_tile(punit))
&& action_prob_possible(action_prob_vs_tile(punit, act, ptile, NULL))) {
&& action_prob_possible(action_prob_vs_tile(nmap, punit, act,
ptile, NULL))) {
request_do_action(act, punit->id, ptile->index, 0, "");
}
break;
common/actions.c
Get the actor unit's probability of successfully performing the chosen
action on the target tile.
**************************************************************************/
struct act_prob action_prob_vs_tile(const struct unit *actor_unit,
struct act_prob action_prob_vs_tile(const struct civ_map *nmap,
const struct unit *actor_unit,
const action_id act_id,
const struct tile *target_tile,
const struct extra_type *target_extra)
{
const struct civ_map *nmap = &(wld.map);
return action_prob_vs_tile_full(nmap, actor_unit,
unit_home(actor_unit),
unit_tile(actor_unit),
......
break;
case ATK_TILE:
if (tgt_tile) {
prob = action_prob_vs_tile(act_unit, paction->id, tgt_tile, extra_tgt);
prob = action_prob_vs_tile(nmap, act_unit, paction->id, tgt_tile, extra_tgt);
}
break;
case ATK_EXTRAS:
common/actions.h
const action_id act_id,
const struct tile* victims);
struct act_prob action_prob_vs_tile(const struct unit *actor,
struct act_prob action_prob_vs_tile(const struct civ_map *nmap,
const struct unit *actor,
const action_id act_id,
const struct tile *victims,
const struct extra_type *target_extra);
common/unit.c
return action_prob_possible(action_prob_vs_city(nmap, punit,
ACTION_JOIN_CITY, tgt_city));
} else {
return action_prob_possible(action_prob_vs_tile(punit,
return action_prob_possible(action_prob_vs_tile(nmap, punit,
ACTION_FOUND_CITY, unit_tile(punit), NULL));
}
}
server/actiontools.c
switch (action_id_get_target_kind(act)) {
case ATK_TILE:
prob = action_prob_vs_tile(actor, act, target, target_extra);
prob = action_prob_vs_tile(nmap, actor, act, target, target_extra);
break;
case ATK_EXTRAS:
prob = action_prob_vs_extras(actor, act, target, target_extra);
......
const struct extra_type *tgt_extra,
bool accept_all_actions)
{
const struct civ_map *nmap = &(wld.map);
if (actor == NULL || tgt_tile == NULL || tgt_extra == NULL) {
/* Can't do any actions if actor or target are missing. */
return FALSE;
......
switch (action_id_get_target_kind(act)) {
case ATK_TILE:
if (action_prob_possible(action_prob_vs_tile(actor, act,
if (action_prob_possible(action_prob_vs_tile(nmap, actor, act,
tgt_tile, tgt_extra))) {
/* The actor unit may be able to do this action to the target
* extra. */
......
struct unit *actor_unit)
{
const struct tile *tgt_tile = unit_tile(actor_unit);
const struct civ_map *nmap = &(wld.map);
fc_assert_ret_val(paction->target_complexity == ACT_TGT_COMPL_FLEXIBLE,
NO_TARGET);
......
}
}
extra_type_re_active_iterate(tgt_extra) {
if (action_prob_possible(action_prob_vs_tile(actor_unit, paction->id,
if (action_prob_possible(action_prob_vs_tile(nmap, actor_unit, paction->id,
tgt_tile, tgt_extra))) {
/* The actor unit may be able to do this action to the target
* extra. */
......
if (tgt_tile
&& is_action_enabled_unit_on_tile(nmap, act, actor,
tgt_tile, target_extra)) {
current = action_prob_vs_tile(actor, act, tgt_tile, target_extra);
current = action_prob_vs_tile(nmap, actor, act, tgt_tile, target_extra);
}
break;
case ATK_EXTRAS:
server/cityhand.c
void handle_city_name_suggestion_req(struct player *pplayer, int unit_id)
{
struct unit *punit = player_unit_by_number(pplayer, unit_id);
const struct civ_map *nmap = &(wld.map);
if (NULL == punit) {
/* Probably died or bribed. */
......
return;
}
if (action_prob_possible(action_prob_vs_tile(punit, ACTION_FOUND_CITY,
if (action_prob_possible(action_prob_vs_tile(nmap, punit, ACTION_FOUND_CITY,
unit_tile(punit), NULL))) {
log_verbose("handle_city_name_suggest_req(unit_pos (%d, %d))",
TILE_XY(unit_tile(punit)));
server/unithand.c
case ATK_TILE:
if (target_tile) {
/* Calculate the probabilities. */
probabilities[act] = action_prob_vs_tile(actor_unit, act,
probabilities[act] = action_prob_vs_tile(nmap, actor_unit, act,
target_tile, target_extra);
} else {
/* No target to act against. */
server/unittools.c
tgt_id = dst_tile->index;
break;
case ATK_TILE:
prob = action_prob_vs_tile(punit, order.action,
prob = action_prob_vs_tile(nmap, punit, order.action,
dst_tile, pextra);
tgt_id = dst_tile->index;
break;
(1-1/2)