待辦事項 #46024

pf_tools.c::pf_attack_possible bug

啟用日期: 2022-11-01 23:09 最後更新: 2022-11-05 09:40

回報者:
負責人:
類型:
狀態:
關閉
元件:
里程碑:
優先權:
5 - 中
嚴重程度:
5 - 中
處理結果:
修正
檔案:
1

細節

1. Did not incorporate server changes such as UTYF_NEVER_PROTECTS, which results in AI thinking unprotected tiles can't be attacked, and bugs the goto-pathing of dumb clients who must use server side goto. 2. Did not enact the rule that unreachable units inside cities are reachable.

FIXED VERSION is below:

/************************************************************************//**
  Can we attack 'ptile'? At this point, it assumes there are non-allied
  units on the tile.
****************************************************************************/
static inline bool pf_attack_possible(const struct tile *ptile,
                                      enum known_type known,
                                      const struct pf_parameter *param)
{
  bool non_allied_city;
  bool attack_any;

  if (!can_attack_non_native(param->utype)
      && !is_native_tile(param->utype, ptile)) {
    return FALSE;
  }

  if (TILE_KNOWN_SEEN != known) {
    /* We cannot see units, let's assume we can attack. */
    return TRUE;
  }

  non_allied_city = is_non_allied_city_tile(ptile, param->owner);
  attack_any = FALSE;

  unit_list_iterate(ptile->units, punit) {
    /* Any non-hostile unit will fail the whole stack*/
    if (!pplayers_at_war(unit_owner(punit), param->owner)) {
      return FALSE;
    }

    /* Hostile unit reachability test. */
    if (BV_ISSET(param->utype->targets, uclass_index(unit_class_get(punit)))
        || tile_has_native_base(ptile, unit_type_get(punit))
        || non_allied_city) {
      attack_any = TRUE;
    } else if (game.info.unreachable_protects) {
      /* We get here if punit is unreachable to utype */
      if (!utype_has_flag(unit_type_get(punit), UTYF_NEVER_PROTECTS)) {
        return FALSE;
      }
      /* NB: if there are UTYF_NEVER_PROTECTS units on the tile, 'attack_any'
         has to get set TRUE at least once to enable an attack to the tile,
         which is exactly correct behaviour. */
    }
  } unit_list_iterate_end;

  return attack_any;
}

Ticket History (3/4 Histories)

2022-11-01 23:09 Updated by: lexxie9952
  • New Ticket "pf_tools.c::pf_attack_possible bug" created
2022-11-02 10:31 Updated by: cazfi
  • 負責人 Update from (無) to cazfi
  • 處理結果 Update from to Accepted
  • 里程碑 Update from (無) to 3.1.0 (closed)
  • 元件 Update from (無) to General
評語

Attached as a patch, so one can see what are the changes made here.

2022-11-05 09:40 Updated by: cazfi
  • 狀態 Update from 開啟 to 關閉
  • 處理結果 Update from Accepted to 修正

編輯

Please login to add comment to this ticket » 登入