unbreak various parts of campaign variable loading/saving
authorsheepluva
Mon, 25 Nov 2013 22:09:42 +0100 (2013-11-25)
changeset 9718 563a34cd8398
parent 9717 b8b7ef99a084
child 9719 cbdef918d087
unbreak various parts of campaign variable loading/saving
QTfrontend/game.cpp
hedgewars/uScript.pas
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua
--- a/QTfrontend/game.cpp	Mon Nov 25 10:12:18 2013 +0100
+++ b/QTfrontend/game.cpp	Mon Nov 25 22:09:42 2013 +0100
@@ -506,7 +506,7 @@
 
 void HWGame::sendCampaignVar(const QByteArray &varToSend)
 {
-    QString varToFind(varToSend);
+    QString varToFind = QString::fromUtf8(varToSend);
     QSettings teamfile(QString("physfs://Teams/%1.hwt").arg(campaignTeam), QSettings::IniFormat, 0);
     teamfile.setIniCodec("UTF-8");
     QString varValue = teamfile.value("Campaign " + campaign + "/" + varToFind, "").toString();
--- a/hedgewars/uScript.pas	Mon Nov 25 10:12:18 2013 +0100
+++ b/hedgewars/uScript.pas	Mon Nov 25 22:09:42 2013 +0100
@@ -1791,7 +1791,7 @@
     if (lua_gettop(L) <> 1) then
         LuaError('Lua: Wrong number of parameters passed to GetCampaignVar!')
     else
-        SendIPCAndWaitReply('V?' + lua_tostring(L, 1));
+        SendIPCAndWaitReply('V?' + lua_tostring(L, 1) + #0);
     lua_pushstring(L, str2pchar(CampaignVariable));
     lc_getcampaignvar := 1;
 end;
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua	Mon Nov 25 10:12:18 2013 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua	Mon Nov 25 22:09:42 2013 +0100
@@ -5,9 +5,10 @@
 	if tonumber(GetCampaignVar("MainMissionsStatus")) then
 		status = GetCampaignVar("MainMissionsStatus")
 	end
-	if i == 1 then
-		status = "1"..status:sub(planetNum+1)
-	elseif i == status:len() then
+
+	if planetNum == 1 then
+		status = "1"..status:sub(2)
+	elseif planetNum == status:len() then
 		status = status:sub(1,planetNum-1).."1"
 	else
 		status = status:sub(1,planetNum-1).."1"..status:sub(planetNum+1)
@@ -79,9 +80,9 @@
 	if tonumber(GetCampaignVar("SideMissionsBonuses")) then
 		bonus = GetCampaignVar("SideMissionsBonuses")
 	end
-	if i == 1 then
-		bonus = times..bonus:sub(index+1)
-	elseif i == bonus:len() then
+	if index == 1 then
+		bonus = times..bonus:sub(2)
+	elseif index == bonus:len() then
 		bonus = bonus:sub(1,index-1)..times
 	else
 		bonus = bonus:sub(1,index-1)..times..bonus:sub(index+1)