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.
This commit is contained in:
parent
3d50320369
commit
9369b520e7
1 changed files with 13 additions and 8 deletions
|
@ -87,12 +87,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
|
||||
|
|
Loading…
Add table
Reference in a new issue