Add CowardMode team setting
authorWuzzy <Wuzzy2@mail.ru>
Sat, 19 Jan 2019 05:06:33 +0100
changeset 14654 c9d2a5a9f6ba
parent 14653 5132548cdb77
child 14655 b055360684bd
Add CowardMode team setting
QTfrontend/campaign.cpp
--- a/QTfrontend/campaign.cpp	Fri Jan 18 07:24:39 2019 +0100
+++ b/QTfrontend/campaign.cpp	Sat Jan 19 05:06:33 2019 +0100
@@ -57,7 +57,15 @@
     QSettings* teamfile = getCampTeamFile(campaignName, teamName);
     int progress = teamfile->value("Campaign " + campaignName + "/Progress", 0).toInt();
     int unlockedMissions = teamfile->value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt();
-    if(progress>0 && unlockedMissions==0)
+    // The CowardMode cheat unlocks all campaign missions,
+    // but as "punishment", none of them will be marked as completed.
+    // Added to make it easier to test campaigns.
+    bool cheat = teamfile->value("Team/CowardMode", false).toBool();
+    if(cheat)
+    {
+        return false;
+    }
+    else if(progress>0 && unlockedMissions==0)
     {
         QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0);
         campfile.setIniCodec("UTF-8");
@@ -79,7 +87,8 @@
 {
     QSettings* teamfile = getCampTeamFile(campaignName, teamName);
     bool won = teamfile->value("Campaign " + campaignName + "/Won", false).toBool();
-    return won;
+    bool cheat = teamfile->value("Team/CowardMode", false).toBool();
+    return won && !cheat;
 }
 
 QSettings* getCampMetaInfo()
@@ -118,13 +127,18 @@
 
     int progress = teamfile->value("Campaign " + campaignName + "/Progress", 0).toInt();
     int unlockedMissions = teamfile->value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt();
+    bool cheat = teamfile->value("Team/CowardMode", false).toBool();
 
     QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0);
     campfile.setIniCodec("UTF-8");
 
     QSettings* m_info = getCampMetaInfo();
 
-    if(progress >= 0 && unlockedMissions == 0)
+    if(cheat)
+    {
+        progress = campfile.value("MissionNum", 1).toInt();
+    }
+    if((progress >= 0 && unlockedMissions == 0) || cheat)
     {
         for(unsigned int i = progress + 1; i > 0; i--)
         {