- Fix a bug with story mode not able to find (unzipped) campaigns
This commit is contained in:
@@ -98,5 +98,6 @@ bool fileExists(const char * filename);
|
||||
bool FileExists(const string & filename);
|
||||
|
||||
std::string buildFilePath(const vector<string> & folders, const string & filename);
|
||||
std::string ensureFolder(const string & folderName);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -26,11 +26,12 @@ void GameStateStory::loadStoriesMenu(const char * root)
|
||||
|
||||
for (size_t i = 0; i < subFolders.size(); ++i)
|
||||
{
|
||||
string filename = root + subFolders[i] + "story.xml";
|
||||
string subfolder = ensureFolder(subFolders[i]);
|
||||
string filename = root + subfolder + "story.xml";
|
||||
if (FileExists(filename))
|
||||
{
|
||||
subFolders[i].resize(subFolders[i].length() - 1); //remove trailing slash
|
||||
stories.push_back(subFolders[i]);
|
||||
subfolder.resize(subfolder.length() - 1); //remove trailing slash
|
||||
stories.push_back(subfolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -367,4 +367,16 @@ std::string buildFilePath(const vector<string> & folders, const string & filenam
|
||||
result.append(filename);
|
||||
return result;
|
||||
|
||||
}
|
||||
std::string ensureFolder(const std::string & folderName)
|
||||
{
|
||||
if (!folderName.size())
|
||||
return "";
|
||||
|
||||
string result = folderName;
|
||||
if (result[result.length()-1] != '/')
|
||||
{
|
||||
result.append("/");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user