Fixed incombatibility with old save files, closes #686
parent
964d3574fd
commit
1dd230aaaf
|
@ -358,13 +358,21 @@ void CLevelParser::AddLine(CLevelParserLineUPtr line)
|
|||
}
|
||||
|
||||
CLevelParserLine* CLevelParser::Get(const std::string& command)
|
||||
{
|
||||
CLevelParserLine* line = GetIfDefined(command);
|
||||
if (line == nullptr)
|
||||
throw CLevelParserException("Command not found: " + command);
|
||||
return line;
|
||||
}
|
||||
|
||||
CLevelParserLine* CLevelParser::GetIfDefined(const std::string& command)
|
||||
{
|
||||
for (auto& line : m_lines)
|
||||
{
|
||||
if (line->GetCommand() == command)
|
||||
return line.get();
|
||||
}
|
||||
throw CLevelParserException("Command not found: " + command);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int CLevelParser::CountLines(const std::string& command)
|
||||
|
|
|
@ -88,6 +88,9 @@ public:
|
|||
//! Find first line with given command
|
||||
CLevelParserLine* Get(const std::string& command);
|
||||
|
||||
//! Find first line with given command, null if doesn't exist
|
||||
CLevelParserLine* GetIfDefined(const std::string &command);
|
||||
|
||||
//! Count lines with given command
|
||||
int CountLines(const std::string& command);
|
||||
|
||||
|
|
|
@ -451,7 +451,8 @@ std::vector<SavedScene> CPlayerProfile::GetSavedSceneList()
|
|||
{
|
||||
CLevelParser levelParser(savegameFile);
|
||||
levelParser.Load();
|
||||
int time = levelParser.Get("Created")->GetParam("date")->AsInt();
|
||||
CLevelParserLine* line = levelParser.GetIfDefined("Created");
|
||||
int time = line != nullptr ? line->GetParam("date")->AsInt() : 0;
|
||||
sortedSaveDirs[time] = SavedScene(GetSaveFile(dir), levelParser.Get("Title")->GetParam("text")->AsString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue