]> git.jsancho.org Git - lugaru.git/commitdiff
Handle the case where the current campaign has been deleted since last game.
authorCôme BERNIGAUD <come.bernigaud@laposte.net>
Tue, 17 Mar 2015 22:58:45 +0000 (23:58 +0100)
committerCôme BERNIGAUD <come.bernigaud@laposte.net>
Tue, 17 Mar 2015 22:58:45 +0000 (23:58 +0100)
(or if it can’t be opened for some reason)

Source/GameTick.cpp

index 6d9cbe3aef3f96529fb245bafa13a66ee7216346..b216545a8f4dcd732d770c75449f2a32458132f0 100644 (file)
@@ -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;