fix bug that locked unlocked campaign missions, see issue 452
authorPeriklis Ntanasis <pntanasis@gmail.com>
Wed, 01 May 2013 04:05:10 +0300
changeset 8944 ed2509832311
parent 8943 63ecf5320439
child 8945 145bf64a9579
child 8946 3e07b8ff2ae1
fix bug that locked unlocked campaign missions, see issue #452
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/backstab.lua
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/dragon.lua
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/enemy.lua
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/family.lua
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/first_blood.lua
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/journey.lua
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/queen.lua
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/shadow.lua
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/united.lua
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/backstab.lua	Wed May 01 01:27:35 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/backstab.lua	Wed May 01 04:05:10 2013 +0300
@@ -760,7 +760,9 @@
     SaveCampaignVar("M5ChiefDead", "0")
   end
   SaveCampaignVar("M5Choice", "" .. choice)
-  SaveCampaignVar("Progress", "5")
+  if progress and progress<5 then
+    SaveCampaignVar("Progress", "5")
+  end
 
   for i = 1, 7 do 
     if natives[i] == deployedHog then
@@ -814,6 +816,7 @@
 end
 
 function GetVariables()
+  progress = tonumber(GetCampaignVar("Progress"))
   m2DenseDead = tonumber(GetCampaignVar("M2DenseDead"))
   m2Choice = tonumber(GetCampaignVar("M2Choice"))
   m4DenseDead = tonumber(GetCampaignVar("M4DenseDead"))
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/dragon.lua	Wed May 01 01:27:35 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/dragon.lua	Wed May 01 04:05:10 2013 +0300
@@ -399,7 +399,9 @@
 
 function DoMissionFinished()
   AddCaption(loc("Salvation was one step closer now..."))
-  SaveCampaignVar("Progress", "6")
+  if progress and progress<6 then
+    SaveCampaignVar("Progress", "6")
+  end
   ParseCommand("teamgone " .. loc("011101001"))
   TurnTimeLeft = 0
 end
@@ -451,6 +453,7 @@
 end
 
 function GetVariables()
+  progress = tonumber(GetCampaignVar("Progress"))
   m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum"))
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/enemy.lua	Wed May 01 01:27:35 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/enemy.lua	Wed May 01 04:05:10 2013 +0300
@@ -400,7 +400,9 @@
 end
 
 function WinMission()
-  SaveCampaignVar("Progress", "9")
+  if progress and progress<9 then
+    SaveCampaignVar("Progress", "9")
+  end
   ParseCommand("teamgone " .. loc("011101001"))
   TurnTimeLeft = 0
 end
@@ -420,6 +422,7 @@
 end
 
 function GetVariables()
+  progress = tonumber(GetCampaignVar("Progress"))
   m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum"))
   m2Choice = tonumber(GetCampaignVar("M2Choice"))
   m5Choice = tonumber(GetCampaignVar("M5Choice"))
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/family.lua	Wed May 01 01:27:35 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/family.lua	Wed May 01 04:05:10 2013 +0300
@@ -284,7 +284,9 @@
 
 function DoPrincessFreed()
   AnimSay(princess, loc("Thank you, my hero!"), SAY_SAY, 0)
-  SaveCampaignVar("Progress", "7")
+  if progress and progress<7 then
+    SaveCampaignVar("Progress", "7")
+  end
   ParseCommand("teamgone " .. loc("011101001"))
   TurnTimeLeft = 0
 end
@@ -390,6 +392,7 @@
 end
 
 function GetVariables()
+  progress = tonumber(GetCampaignVar("Progress"))
   m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum"))
   m2Choice = tonumber(GetCampaignVar("M2Choice"))
   m5Choice = tonumber(GetCampaignVar("M5Choice"))
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/first_blood.lua	Wed May 01 01:27:35 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/first_blood.lua	Wed May 01 04:05:10 2013 +0300
@@ -541,7 +541,9 @@
 
 function DoCannibalKilled()
   AddAnim(cannKilledAnim)
-  SaveCampaignVar("Progress", "1")
+  if not progress then
+    SaveCampaignVar("Progress", "1")
+  end
 end
 
 function DoCannibalKilledEarly()
@@ -633,6 +635,7 @@
 end
 
 function onGameStart()
+  progress = tonumber(GetCampaignVar("Progress"))
   TurnTimeLeft = -1
   FollowGear(youngh)
 	ShowMission(loc("A Classic Fairytale"), loc("First Blood"), loc("Finish your training|Hint: Animations can be skipped with the [Precise] key."), -amSkip, 0)
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/journey.lua	Wed May 01 01:27:35 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/journey.lua	Wed May 01 04:05:10 2013 +0300
@@ -903,7 +903,9 @@
 end
 
 function DoWon()
-  SaveCampaignVar("Progress", "3")
+  if progress and progress<3 then
+    SaveCampaignVar("Progress", "3")
+  end
   AddAnim(winAnim)
   AddFunction({func = FinishWon, args = {}})
 end
@@ -974,6 +976,7 @@
 end
 
 function onGameStart()
+  progress = tonumber(GetCampaignVar("Progress"))
   m2Choice = tonumber(GetCampaignVar("M2Choice"))
   m2DenseDead = tonumber(GetCampaignVar("M2DenseDead"))
   m2RamonDead = tonumber(GetCampaignVar("M2RamonDead"))
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/queen.lua	Wed May 01 01:27:35 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/queen.lua	Wed May 01 04:05:10 2013 +0300
@@ -575,6 +575,7 @@
 end
 
 function GetVariables()
+  progress = tonumber(GetCampaignVar("Progress"))
   m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum"))
   m2Choice = tonumber(GetCampaignVar("M2Choice"))
   m5Choice = tonumber(GetCampaignVar("M5Choice"))
@@ -606,7 +607,9 @@
   SaveCampaignVar("M8PrincessLeader", princessLeader)
   SaveCampaignVar("M8EnemyFled", enemyFled)
   SaveCampaignVar("M8Scene", "" .. scene)
-  SaveCampaignVar("Progress", "8")
+  if progress and progress<8 then
+    SaveCampaignVar("Progress", "8")
+  end
 end
 
 function SetupPlace()
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/shadow.lua	Wed May 01 01:27:35 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/shadow.lua	Wed May 01 04:05:10 2013 +0300
@@ -761,7 +761,9 @@
   SaveCampaignVar("M2RamonDead", "0")
   SaveCampaignVar("M2SpikyDead", "0")
   AddFunction({func = KillCyborg, args = {}})
-  SaveCampaignVar("Progress", "2")
+  if progress and progress<2 then
+    SaveCampaignVar("Progress", "2")
+  end
   SaveCampaignVar("M2Choice", "" .. choice)
 end
 
@@ -783,7 +785,9 @@
   end
   AddAnim(refusedFinalAnim)
   AddFunction({func = KillCyborg, args = {}})
-  SaveCampaignVar("Progress", "2")
+  if progress and progress<2 then
+    SaveCampaignVar("Progress", "2")
+  end
   SaveCampaignVar("M2Choice", "" .. choice)
 end
 
@@ -791,7 +795,9 @@
   SaveCampaignVar("M2DenseDead", "1")
   SaveCampaignVar("M2RamonDead", "0")
   SaveCampaignVar("M2SpikyDead", "0")
-  SaveCampaignVar("Progress", "2")
+  if progress and progress<2 then
+    SaveCampaignVar("Progress", "2")
+  end
   SaveCampaignVar("M2Choice", "" .. choice)
   AddAnim(attackedFinalAnim)
   AddFunction({func = KillCyborg, args = {}})
@@ -854,6 +860,7 @@
 end
 
 function onGameStart()
+  progress = tonumber(GetCampaignVar("Progress"))
   HideHogs()
   AddAmmo(leaks, amSwitch, 100)
   AddAmmo(dense, amSwitch, 100)
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/united.lua	Wed May 01 01:27:35 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/united.lua	Wed May 01 04:05:10 2013 +0300
@@ -109,7 +109,9 @@
   else
     SaveCampaignVar("M4DenseDead", "0")
   end
-  SaveCampaignVar("Progress", "4")
+  if progress and progress<4 then
+    SaveCampaignVar("Progress", "4")
+  end
   ParseCommand("teamgone " .. loc("011101001"))
   TurnTimeLeft = 0
 end
@@ -416,6 +418,7 @@
 end
 
 function onGameStart()
+  progress = tonumber(GetCampaignVar("Progress"))
   GetVariables()
   SetupAmmo()
   SetupPlace()