QTfrontend/game.cpp
changeset 7665 e556b44f5bd8
parent 7629 d624030abf24
child 7687 c73fd8cfa7c0
child 7713 3833741d8752
--- a/QTfrontend/game.cpp	Tue Sep 04 12:16:36 2012 +0400
+++ b/QTfrontend/game.cpp	Tue Sep 04 12:25:55 2012 +0400
@@ -431,7 +431,7 @@
     RawSendIPC(buf);
 }
 
-void HWGame::sendCampaignVar(QByteArray varToSend)
+void HWGame::sendCampaignVar(const QByteArray &varToSend)
 {
     QString varToFind(varToSend);
     QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + campaignTeam + ".hwt", QSettings::IniFormat, 0);
@@ -442,22 +442,14 @@
     RawSendIPC(command);
 }
 
-void HWGame::writeCampaignVar(QByteArray varVal)
+void HWGame::writeCampaignVar(const QByteArray & varVal)
 {
-    QString varToWrite("");
-    QString varValue("");
-    unsigned int i = 0;
-    while (i < varVal.size() && varVal.at(i) != ' ')
-    {
-      varToWrite.append(varVal.at(i));
-      i++;
-    }
-    i++;
-    while (i < varVal.size() && varVal.at(i) != '\0')
-    {
-      varValue.append(varVal.at(i));
-      i++;
-    }
+    int i = varVal.indexOf(" ");
+    if(i < 0)
+        return;
+
+    QString varToWrite = QString::fromUtf8(varVal.left(i));
+    QString varValue = QString::fromUtf8(varVal.mid(i + 1));
 
     QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + campaignTeam + ".hwt", QSettings::IniFormat, 0);
     teamfile.setIniCodec("UTF-8");