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

Function saveMapDiff

plugins/dm.gameconnection/GameConnection.cpp:727–776  ·  view source on GitHub ↗

* stgatilov: Saves only entities with specified names to in-memory map patch. * This diff is intended to be consumed by TheDarkMod automation for HotReload purposes. * TODO: What about patches and brushes? */

Source from the content-addressed store, hash-verified

725 * TODO: What about patches and brushes?
726 */
727std::string saveMapDiff(const DiffEntityStatuses& entityStatuses)
728{
729 auto root = GlobalSceneGraph().root();
730
731 std::set<scene::INode*> subsetNodes;
732 root->foreachNode([&](const scene::INodePtr& node) {
733 if (entityStatuses.count(node->name()))
734 subsetNodes.insert(node.get());
735 return true;
736 });
737
738 std::ostringstream outStream;
739 outStream << "// diff " << entityStatuses.size() << std::endl;
740
741 DiffDoom3MapWriter writer(entityStatuses);
742
743 //write removal stubs (no actual spawnargs)
744 for (const auto& pNS : entityStatuses) {
745 const auto& name = pNS.first;
746 const auto& status = pNS.second;
747 assert(status.isModified()); //(don't put untouched entities into map)
748 if (status.isRemoved())
749 writer.writeRemoveEntityStub(name, outStream);
750 }
751
752 //write added/modified entities as usual
753 {
754 registry::ScopedKeyChanger progressDisabler(RKEY_MAP_SUPPRESS_LOAD_STATUS_DIALOG, true);
755
756 // Hack: disable recalculateBrushWindings for this export
757 registry::ScopedKeyChanger<std::string> guard("MapExporter_IgnoreBrushes", "yes");
758
759 // Get a scoped exporter class
760 auto exporter = GlobalMapModule().createMapExporter(writer, root, outStream);
761
762 try
763 {
764 // Pass the traversal function and the root of the subgraph to export
765 exporter->exportMap(root, scene::traverseSubset(subsetNodes));
766 // end the life of the exporter instance here to finish the scene
767 exporter.reset();
768 }
769 catch (map::FileOperation::OperationCancelled&)
770 {
771 radiant::NotificationMessage::SendInformation(_("Map export cancelled"));
772 }
773 }
774
775 return outStream.str();
776}
777
778void GameConnection::doUpdateMap()
779{

Callers 1

doUpdateMapMethod · 0.85

Calls 15

traverseSubsetFunction · 0.85
isRemovedMethod · 0.80
writeRemoveEntityStubMethod · 0.80
createMapExporterMethod · 0.80
_Function · 0.50
rootMethod · 0.45
foreachNodeMethod · 0.45
countMethod · 0.45
nameMethod · 0.45
insertMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected