]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameTick.cpp
Fix crash due to wrong iterator type
[lugaru.git] / Source / GameTick.cpp
index 6d9cbe3aef3f96529fb245bafa13a66ee7216346..48b34b90c1d8c72ab84f9515ee11ad18936ddea2 100644 (file)
@@ -200,7 +200,7 @@ public:
         is >> mapname;
         is.ignore(256, ':');
         is >> description;
-        for (unsigned pos = description.find('_'); pos != string::npos; pos = description.find('_', pos)) {
+        for (size_t pos = description.find('_'); pos != string::npos; pos = description.find('_', pos)) {
             description.replace(pos, 1, 1, ' ');
         }
         is.ignore(256, ':');
@@ -1609,6 +1609,15 @@ void LoadCampaign()
     if (!accountactive)
         return;
     ifstream ipstream(ConvertFileName((":Data:Campaigns:" + accountactive->getCurrentCampaign() + ".txt").c_str()));
+    if (!ipstream.good()) {
+        if (accountactive->getCurrentCampaign() == "main") {
+            cerr << "Could not found main campaign!" << endl;
+            return;
+        }
+        cerr << "Could not found campaign \"" << accountactive->getCurrentCampaign() << "\", falling back to main." << endl;
+        accountactive->setCurrentCampaign("main");
+        return LoadCampaign();
+    }
     ipstream.ignore(256, ':');
     int numlevels;
     ipstream >> numlevels;