It seems that at the current state it is necessary to protect sending stats/ending game from multiple execution,
as that can happen if you e.g. fail a mission more than once in the same tick (e.g. destroying two essential crates at the same time)
Otherwise you can get a blank / stuck frontend (e.g. when using deagle to shoot the two last crates at the same time)!
the best approach might be to never call the function that sends stats and ends game from any event handler directly, but instead have a flag 'isFailed' that is set to true when any of the possible fails happen and to check that flag every tick to send stats and end game if true
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua Fri Dec 06 22:48:30 2013 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua Fri Dec 06 23:53:35 2013 +0100
@@ -393,20 +393,24 @@
end
-------------- ACTIONS ------------------
+ended = false
function heroDeath(gear)
- SendStat(siGameResult, loc("Hog Solo lost, try again!"))
- SendStat(siCustomAchievement, loc("To win the game, Hog Solo has to get the bottom crates and come back to the surface"))
- SendStat(siCustomAchievement, loc("You can use the other 2 hogs to assist you"))
- SendStat(siCustomAchievement, loc("Do not destroy the crates"))
- if tookPartInBattle then
- SendStat(siCustomAchievement, loc("You'll have to eliminate the Strawberry Assassins at the end"))
- else
- SendStat(siCustomAchievement, loc("You'll have to eliminate Captain Lime at the end"))
- SendStat(siCustomAchievement, loc("Don't eliminate Captain Lime before collecting the last crate!"))
+ if not ended then
+ SendStat(siGameResult, loc("Hog Solo lost, try again!"))
+ SendStat(siCustomAchievement, loc("To win the game, Hog Solo has to get the bottom crates and come back to the surface"))
+ SendStat(siCustomAchievement, loc("You can use the other 2 hogs to assist you"))
+ SendStat(siCustomAchievement, loc("Do not destroy the crates"))
+ if tookPartInBattle then
+ SendStat(siCustomAchievement, loc("You'll have to eliminate the Strawberry Assassins at the end"))
+ else
+ SendStat(siCustomAchievement, loc("You'll have to eliminate Captain Lime at the end"))
+ SendStat(siCustomAchievement, loc("Don't eliminate Captain Lime before collecting the last crate!"))
+ end
+ SendStat(siPlayerKills,'0',teamA.name)
+ EndGame()
+ ended = true
end
- SendStat(siPlayerKills,'0',teamA.name)
- EndGame()
end
function deviceCrates(gear)