チケット #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;
}

チケットの履歴 (4 件中 3 件表示)

2022-11-01 23:09 更新者: lexxie9952
  • 新しいチケット "pf_tools.c::pf_attack_possible bug" が作成されました
2022-11-02 10:31 更新者: cazfi
  • 担当者(未割り当て) から cazfi に更新されました
  • 解決法なし から 受領 に更新されました
  • マイルストーン(未割り当て) から 3.1.0 (完了済み) に更新されました
  • コンポーネント(未割り当て) から General に更新されました
コメント

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

2022-11-05 09:40 更新者: cazfi
  • 状況オープン から 完了 に更新されました
  • 解決法受領 から 修正済み に更新されました

編集

ログインしていません。ログインしていない状態では、コメントに記載者の記録が残りません。 » ログインする