From: Côme BERNIGAUD Date: Tue, 17 Mar 2015 22:58:45 +0000 (+0100) Subject: Handle the case where the current campaign has been deleted since last game. X-Git-Url: https://git.jsancho.org/?p=lugaru.git;a=commitdiff_plain;h=84199f8777017744bf9e2a039ae625850dab624e Handle the case where the current campaign has been deleted since last game. (or if it can’t be opened for some reason) --- diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 6d9cbe3..b216545 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -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;