Editor: Fix crash when trying to save scenario into itself

ipv6
Lukas Werling 2016-12-19 23:14:19 +01:00
parent ae6cdc6619
commit f9305a1526
3 changed files with 10 additions and 0 deletions

View File

@ -87,6 +87,7 @@ IDS_CNS_PLRQUITNET=%s (%s) löschen
IDS_CNS_PROPERTIES=Eigenschaften
IDS_CNS_REMOVE=Entfernen
IDS_CNS_SAVEASERROR=Fehler beim Speichern des Szenarios nach %s.
IDS_CNS_RECURSIVESAVEASERROR=Speichern in das existierende Szenario ist nicht möglich. Bitte neuen Pfad wählen.
IDS_CNS_SAVERROR=Fehler beim Speichern des Szenarios.
IDS_CNS_SCENARIOFILE=OpenClonk Szenariendatei
IDS_CNS_SCENARIOSAVED=Szenario gespeichert.

View File

@ -87,6 +87,7 @@ IDS_CNS_PLRQUITNET=Remove %s (%s)
IDS_CNS_PROPERTIES=Properties
IDS_CNS_REMOVE=Remove
IDS_CNS_SAVEASERROR=Error while saving the scenario to %s.
IDS_CNS_RECURSIVESAVEASERROR=Cannot save into the existing scenario. Please choose another path.
IDS_CNS_SAVERROR=Error while saving the scenario.
IDS_CNS_SCENARIOFILE=OpenClonk scenario file
IDS_CNS_SCENARIOSAVED=Scenario saved.

View File

@ -178,6 +178,14 @@ bool C4Console::SaveScenario(const char * path, bool export_packed)
}
else if (path)
{
// When trying to save into a subfolder of the existing scenario, the copy function
// below will try to recursively copy everything until it blows the stack. There is
// really no good reason to do this, so we just disallow it here.
if (SEqual2(path, Game.ScenarioFilename))
{
Message(LoadResStr("IDS_CNS_RECURSIVESAVEASERROR"));
return false;
}
// Open new scenario file
// Close current scenario file to allow re-opening at new path
Game.ScenarioFile.Close();