* 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? */
| 725 | * TODO: What about patches and brushes? |
| 726 | */ |
| 727 | std::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 | |
| 778 | void GameConnection::doUpdateMap() |
| 779 | { |
no test coverage detected