SotA: Synchronise the zombie recruitment dialog

This dialog works by setting variables in the postshow function,
so the code had to be moved around to ensure that those variables
were synchronised, not just the return value of the dialog.

The message about not having enough gold isn't necessary for the
replay, so that gets moved into the synchronised code too.

(cherry picked from commit 9369b520e7)
This commit is contained in:
Steve Cotton 2021-07-28 12:32:44 +02:00 committed by Steve Cotton
parent 32c107b797
commit 7d10aad57f

View file

@ -88,12 +88,17 @@ wml.variables["recruitedZombieType"] = "cancel" -- default value
if zExists==false then
gui.show_prompt("", _ "There are no corpses available.", "")
else
--TODO: this seems not to be synced.
local returned = gui.show_dialog(wml.get_child(zombie_recruit_dialog, 'resolution'), preshow, postshow)
if returned ~= -2 and sides[1].gold < recruitCost then
gui.show_prompt("", _ "You do not have enough gold to recruit that unit", "")
elseif returned ~= -2 and (sides[1].gold ) >= recruitCost then
wml.variables["recruitedZombieType"] = recruitedType
wml.variables["recruitedZombieCost"] = recruitCost
end
local result = wesnoth.sync.evaluate_single(function()
local res = gui.show_dialog(wml.get_child(zombie_recruit_dialog, 'resolution'), preshow, postshow)
if res == -2 then
return {recruitCost = 0, recruitedType = "cancel"}
end
if sides[1].gold < recruitCost then
gui.show_prompt("", _ "You do not have enough gold to recruit that unit", "")
return {recruitCost = 0, recruitedType = "cancel"}
end
return {recruitCost = recruitCost, recruitedType = recruitedType}
end)
wml.variables["recruitedZombieType"] = result.recruitedType
wml.variables["recruitedZombieCost"] = result.recruitCost
end