MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / OnSaveDocument

Method OnSaveDocument

editor/editorDoc.cpp:238–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238BOOL CEditorDoc::OnSaveDocument(LPCTSTR lpszPathName) {
239 // TODO: Add your specialized code here and/or call the base class
240 char filename[256];
241 BOOL retval;
242
243 strcpy(filename, lpszPathName);
244 if (strchr(filename, '.') == 0)
245 strcat(filename, ".d3l"); // check for extension
246
247 mprintf(0, "Saving level %s...\n", lpszPathName);
248 retval = (BOOL)EditorSaveLevel((char *)lpszPathName);
249
250 if (retval)
251 SetModifiedFlag(FALSE);
252 else
253 OutrageMessageBox("Error saving level -- Level not saved.\n\n"
254 "If you get this error trying to save a file you loaded from the network, "
255 "here's a workaround you can use to save your file:\n\n"
256 " 1. Use File/Save As to save the file with a temporary name.\n"
257 " 2. Use File/New to clear out the level.\n"
258 " 3. Load the level from the temporary file.\n"
259 " 4. Use File/Save As to save with the real name.\n\n"
260 "Matt & Samir are working on this problem.");
261
262 // If the Save was successfull, handle the Dallas coordination
263 if (retval) {
264
265 // If Dallas is up, change its filenames
266 if (theApp.m_DallasModelessDlgPtr != NULL) {
267 theApp.m_DallasModelessDlgPtr->SetAllFilenamesToThis((char *)lpszPathName);
268 }
269
270 // Copy Dallas files (if doing a 'Save As')
271 char old_filename[_MAX_PATH + 1];
272 char new_filename[_MAX_PATH + 1];
273
274 CString old_level_fname, new_level_fname;
275 old_level_fname = GetPathName();
276 new_level_fname = (char *)lpszPathName;
277
278 if (old_level_fname.IsEmpty())
279 strcpy(old_filename, "Untitled");
280 else
281 ddio_SplitPath(old_level_fname.GetBuffer(0), NULL, old_filename, NULL);
282
283 if (new_level_fname.IsEmpty())
284 strcpy(new_filename, "Untitled");
285 else
286 ddio_SplitPath(new_level_fname.GetBuffer(0), NULL, new_filename, NULL);
287
288 // Make sure names are different (ie 'Save As')
289 if (stricmp(old_filename, new_filename) != 0) {
290 CString old_file, new_file;
291
292 old_file.Format("%s.cpp", old_filename);
293 new_file.Format("%s.cpp", new_filename);
294 CopyScriptFile(old_file.GetBuffer(0), new_file.GetBuffer(0));
295

Callers

nothing calls this directly

Calls 6

EditorSaveLevelFunction · 0.85
OutrageMessageBoxFunction · 0.85
CopyScriptFileFunction · 0.85
SetAllFilenamesToThisMethod · 0.80
GetBufferMethod · 0.80
ddio_SplitPathFunction · 0.50

Tested by

no test coverage detected