MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / save

Method save

radiantcore/map/Map.cpp:630–682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

628}
629
630bool Map::save(const MapFormatPtr& mapFormat)
631{
632 if (_saveInProgress) return false; // safeguard
633
634 if (_resource->isReadOnly())
635 {
636 rError() << "This map is read-only and cannot be saved." << std::endl;
637 return false;
638 }
639
640 // Check if the map file has been modified in the meantime
641 if (_resource->fileOnDiskHasBeenModifiedSinceLastSave() &&
642 !radiant::FileOverwriteConfirmation::SendAndReceiveAnswer(
643 fmt::format(_("The file {0} has been modified since it was last saved,\nperhaps by another application. "
644 "Do you really want to overwrite the file?"), _mapName), _("File modification detected")))
645 {
646 return false;
647 }
648
649 _saveInProgress = true;
650
651 emitMapEvent(MapSaving);
652
653 util::ScopeTimer timer("map save");
654
655 bool success = false;
656
657 // Save the actual map resource
658 try
659 {
660 _resource->save(mapFormat);
661
662 // Clear the modified flag
663 setModified(false);
664
665 success = true;
666 }
667 catch (IMapResource::OperationException & ex)
668 {
669 radiant::NotificationMessage::SendError(ex.what());
670 }
671
672 emitMapEvent(MapSaved);
673 OperationMessage::Send(_("Map saved"));
674
675 _saveInProgress = false;
676
677 // Redraw the views, sometimes the backbuffer containing
678 // the previous frame will remain visible
679 SceneChangeNotify();
680
681 return success;
682}
683
684void Map::createNewMap()
685{

Callers 5

renameMethod · 0.45
modelChangedMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45
assignMethod · 0.45

Calls 7

rErrorFunction · 0.85
SceneChangeNotifyFunction · 0.85
whatMethod · 0.80
formatFunction · 0.50
_Function · 0.50
isReadOnlyMethod · 0.45

Tested by

no test coverage detected