@@ -221,13 +221,15 @@ int CEditor::Save(const char *pFilename)
221221
222222int CEditorMap::Save (class IStorage *pStorage, const char *pFileName)
223223{
224- char aBuf[256 ];
225- str_format (aBuf, sizeof (aBuf), " saving to '%s'..." , pFileName);
224+ char aFileNameTmp[IO_MAX_PATH_LENGTH];
225+ str_format (aFileNameTmp, sizeof (aFileNameTmp), " %s.%d.tmp" , pFileName, pid ());
226+ char aBuf[IO_MAX_PATH_LENGTH];
227+ str_format (aBuf, sizeof (aBuf), " saving to '%s'..." , aFileNameTmp);
226228 m_pEditor->Console ()->Print (IConsole::OUTPUT_LEVEL_STANDARD, " editor" , aBuf);
227229 CDataFileWriter df;
228- if (!df.Open (pStorage, pFileName ))
230+ if (!df.Open (pStorage, aFileNameTmp ))
229231 {
230- str_format (aBuf, sizeof (aBuf), " failed to open file '%s'..." , pFileName );
232+ str_format (aBuf, sizeof (aBuf), " failed to open file '%s'..." , aFileNameTmp );
231233 m_pEditor->Console ()->Print (IConsole::OUTPUT_LEVEL_STANDARD, " editor" , aBuf);
232234 return 0 ;
233235 }
@@ -553,6 +555,13 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
553555 df.Finish ();
554556 m_pEditor->Console ()->Print (IConsole::OUTPUT_LEVEL_ADDINFO, " editor" , " saving done" );
555557
558+ str_format (aBuf, sizeof (aBuf), " moving '%s' to '%s'" , aFileNameTmp, pFileName);
559+ m_pEditor->Console ()->Print (IConsole::OUTPUT_LEVEL_ADDINFO, " editor" , aBuf);
560+ if (!pStorage->RenameFile (aFileNameTmp, pFileName, IStorage::TYPE_SAVE))
561+ {
562+ return 0 ;
563+ }
564+
556565 // send rcon.. if we can
557566 if (m_pEditor->Client ()->RconAuthed ())
558567 {
0 commit comments