mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-26 23:00:50 +00:00
ExpAI castle switch CA: fix error when stored leader has been killed
The castle switch CA stores the leader move because the evaluation is expensive. If the leader was killed in between storing and reevaluation of the CA, this would previously cause an on-screen error message and the CA to be blacklisted for the turn. This fixes #6440.
This commit is contained in:
parent
be62c98e1c
commit
fe0b375fca
@ -99,6 +99,11 @@ function ca_castle_switch:evaluation(cfg, data, filter_own, recruiting_leader)
|
||||
return 0
|
||||
end
|
||||
|
||||
-- Also need to check that the stored leader has not been killed
|
||||
if data.CS_leader and not data.CS_leader.valid then
|
||||
data.CS_leader, data.CS_leader_target = nil, nil
|
||||
end
|
||||
|
||||
local avoid_map = AH.get_avoid_map(ai, nil, true)
|
||||
|
||||
if data.CS_leader and wesnoth.sides[wesnoth.current.side].gold >= AH.get_cheapest_recruit_cost(data.CS_leader)
|
||||
|
Loading…
x
Reference in New Issue
Block a user