From 6ca2d85296f08c3ec3c6762df9a669c266c74276 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 28 Apr 2021 15:56:30 +0300 Subject: [PATCH 03/38] Define H_ASSESS_DANGER_LIMITED also in normal (non freeciv-web) builds It's still set to any AI player only in freeciv-web builds. See osdn #41939 Signed-off-by: Marko Lindqvist --- ai/default/daimilitary.c | 10 ++++++---- ai/handicaps.c | 3 +-- ai/handicaps.h | 2 -- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ai/default/daimilitary.c b/ai/default/daimilitary.c index 539924731d..a6dc1c0e88 100644 --- a/ai/default/daimilitary.c +++ b/ai/default/daimilitary.c @@ -581,10 +581,7 @@ static unsigned int assess_danger(struct ai_type *ait, struct city *pcity, if (player_is_cpuhog(pplayer)) { assess_turns = 6; } else { - assess_turns = 3; -#ifdef FREECIV_WEB assess_turns = has_handicap(pplayer, H_ASSESS_DANGER_LIMITED) ? 2 : 3; -#endif } omnimap = !has_handicap(pplayer, H_MAP); @@ -616,14 +613,19 @@ static unsigned int assess_danger(struct ai_type *ait, struct city *pcity, struct unit_type_ai *utai = utype_ai_data(utype, ait); #ifdef FREECIV_WEB + /* freeciv-web ignores danger that is far in distance, + * no matter how quickly it would reach us; even if + * that's *immediately* over a road type that allows + * unlimited movement. */ int unit_distance = real_map_distance(ptile, unit_tile(punit)); + if (unit_distance > ASSESS_DANGER_MAX_DISTANCE || (has_handicap(pplayer, H_ASSESS_DANGER_LIMITED) && unit_distance > AI_HANDICAP_DISTANCE_LIMIT)) { /* Too far away. */ continue; } -#endif +#endif /* FREECIV_WEB */ if (!utai->carries_occupiers && !utype_acts_hostile(utype)) { diff --git a/ai/handicaps.c b/ai/handicaps.c index 192ecef1c6..31b36c48fe 100644 --- a/ai/handicaps.c +++ b/ai/handicaps.c @@ -80,6 +80,7 @@ bool has_handicap(const struct player *pplayer, enum handicap_type htype) const char *handicap_desc(enum handicap_type htype, bool *inverted) { *inverted = FALSE; + switch (htype) { case H_DIPLOMAT: return _("Doesn't build offensive diplomatic units."); @@ -126,10 +127,8 @@ const char *handicap_desc(enum handicap_type htype, bool *inverted) case H_PRODCHGPEN: *inverted = TRUE; return _("Can change city production type without penalty."); -#ifdef FREECIV_WEB case H_ASSESS_DANGER_LIMITED: return _("Limits the distance to search for threatening enemy units."); -#endif case H_LAST: break; /* fall through -- should never see this */ } diff --git a/ai/handicaps.h b/ai/handicaps.h index 53697005da..46e824d1e9 100644 --- a/ai/handicaps.h +++ b/ai/handicaps.h @@ -33,9 +33,7 @@ enum handicap_type { H_CEASEFIRE, H_NOBRIBE_WF, H_PRODCHGPEN, -#ifdef FREECIV_WEB H_ASSESS_DANGER_LIMITED, -#endif H_LAST }; -- 2.30.2