@@ -82,6 +82,7 @@ Editor::Editor(CopyBuffer& copybuffer) :
8282 map.name = sname + " .otbm" ;
8383 map.spawnfile = sname + " -spawn.xml" ;
8484 map.housefile = sname + " -house.xml" ;
85+ map.waypointfile = sname + " -waypoint.xml" ;
8586 map.description = " No map description available." ;
8687 map.unnamed = true ;
8788
@@ -199,6 +200,8 @@ void Editor::saveMap(FileName filename, bool showdialog)
199200 map.spawnfile = nstr (_name.GetFullName ());
200201 _name.SetName (filename.GetName () + " -house" );
201202 map.housefile = nstr (_name.GetFullName ());
203+ _name.SetName (filename.GetName () + " -waypoint" );
204+ map.waypointfile = nstr (_name.GetFullName ());
202205
203206 map.unnamed = false ;
204207 }
@@ -210,7 +213,7 @@ void Editor::saveMap(FileName filename, bool showdialog)
210213
211214 // Make temporary backups
212215 // converter.Assign(wxstr(savefile));
213- std::string backup_otbm, backup_house, backup_spawn;
216+ std::string backup_otbm, backup_house, backup_spawn, backup_waypoint ;
214217
215218 if (converter.GetExt () == " otgz" ) {
216219 save_otgz = true ;
@@ -239,6 +242,13 @@ void Editor::saveMap(FileName filename, bool showdialog)
239242 std::remove (backup_spawn.c_str ());
240243 std::rename ((map_path + map.spawnfile ).c_str (), backup_spawn.c_str ());
241244 }
245+
246+ converter.SetFullName (wxstr (map.waypointfile ));
247+ if (converter.FileExists ()) {
248+ backup_waypoint = map_path + nstr (converter.GetName ()) + " .xml~" ;
249+ std::remove (backup_waypoint.c_str ());
250+ std::rename ((map_path + map.waypointfile ).c_str (), backup_waypoint.c_str ());
251+ }
242252 }
243253
244254 // Save the map
@@ -289,6 +299,12 @@ void Editor::saveMap(FileName filename, bool showdialog)
289299 std::rename (backup_spawn.c_str (), std::string (spawn_filename + " .xml" ).c_str ());
290300 }
291301
302+ if (!backup_waypoint.empty ()) {
303+ converter.SetFullName (wxstr (map.waypointfile ));
304+ std::string waypoint_filename = map_path + nstr (converter.GetName ());
305+ std::rename (backup_waypoint.c_str (), std::string (waypoint_filename + " .xml" ).c_str ());
306+ }
307+
292308 // Display the error
293309 g_gui.PopupDialog (" Error" , " Could not save, unable to open target for writing." , wxOK);
294310 }
@@ -340,6 +356,12 @@ void Editor::saveMap(FileName filename, bool showdialog)
340356 std::string spawn_filename = map_path + nstr (converter.GetName ());
341357 std::rename (backup_spawn.c_str (), std::string (spawn_filename + " ." + date.str () + " .xml" ).c_str ());
342358 }
359+
360+ if (!backup_waypoint.empty ()) {
361+ converter.SetFullName (wxstr (map.spawnfile ));
362+ std::string waypoint_filename = map_path + nstr (converter.GetName ());
363+ std::rename (backup_waypoint.c_str (), std::string (waypoint_filename + " ." + date.str () + " .xml" ).c_str ());
364+ }
343365 } else {
344366 // Delete the temporary files
345367 std::remove (backup_otbm.c_str ());
0 commit comments