Fix startup crash with disabled autosave, closes #705

dev-time-step
krzys-h 2016-01-28 20:36:55 +01:00
parent 223d17843e
commit f3094312b2
1 changed files with 4 additions and 1 deletions

View File

@ -5597,6 +5597,9 @@ int CRobotMain::GetAutosaveSlots()
int CRobotMain::AutosaveRotate(bool freeOne)
{
if (m_playerProfile == nullptr)
return 0;
GetLogger()->Debug("Rotate autosaves...\n");
// Find autosave dirs
auto saveDirs = CResourceManager::ListDirectories(m_playerProfile->GetSaveDir());
@ -5606,7 +5609,7 @@ int CRobotMain::AutosaveRotate(bool freeOne)
try
{
const std::string autosavePrefix = "autosave";
if (dir.substr(0, autosavePrefix.length()) == "autosave")
if (dir.substr(0, autosavePrefix.length()) == autosavePrefix)
{
int id = boost::lexical_cast<int>(dir.substr(autosavePrefix.length()));
autosaveDirs[id] = m_playerProfile->GetSaveFile(dir);