- Fix a bug with story mode not able to find (unzipped) campaigns

This commit is contained in:
wagic.the.homebrew
2011-08-22 12:33:39 +00:00
parent 164ca240b3
commit 0bc6352d62
3 changed files with 17 additions and 3 deletions

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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;
}