diff --git a/radiant/layers/LayerInfoFileModule.cpp b/radiant/layers/LayerInfoFileModule.cpp index 4ea886629c..fd644c4a73 100644 --- a/radiant/layers/LayerInfoFileModule.cpp +++ b/radiant/layers/LayerInfoFileModule.cpp @@ -31,12 +31,21 @@ std::string LayerInfoFileModule::getName() return "Layer Mapping"; } -void LayerInfoFileModule::onInfoFileSaveStart() +void LayerInfoFileModule::clear() { _layerInfoCount = 0; _output.str(std::string()); _output.clear(); + _layerNameBuffer.str(std::string()); _layerNameBuffer.clear(); + + _layerNames.clear(); + _layerMappings.clear(); +} + +void LayerInfoFileModule::onInfoFileSaveStart() +{ + clear(); } void LayerInfoFileModule::onBeginSaveMap(const scene::IMapRootNodePtr& root) @@ -115,15 +124,12 @@ void LayerInfoFileModule::writeBlocks(std::ostream& stream) void LayerInfoFileModule::onInfoFileSaveFinished() { - _layerInfoCount = 0; - _output.str(std::string()); - _output.clear(); + clear(); } void LayerInfoFileModule::onInfoFileLoadStart() { - _layerNames.clear(); - _layerMappings.clear(); + clear(); } bool LayerInfoFileModule::canParseBlock(const std::string& blockName) @@ -279,8 +285,7 @@ void LayerInfoFileModule::applyInfoToScene(const IMapRootNodePtr& root, const ma void LayerInfoFileModule::onInfoFileLoadFinished() { - _layerNames.clear(); - _layerMappings.clear(); + clear(); } } diff --git a/radiant/layers/LayerInfoFileModule.h b/radiant/layers/LayerInfoFileModule.h index ef5b7c6fb1..e3603d6ec5 100644 --- a/radiant/layers/LayerInfoFileModule.h +++ b/radiant/layers/LayerInfoFileModule.h @@ -48,7 +48,7 @@ class LayerInfoFileModule : private: void saveNode(const INodePtr& node); - void writeLayerNames(std::ostream& stream); + void clear(); void parseLayerNames(parser::DefTokeniser& tok); void parseNodeToLayerMapping(parser::DefTokeniser& tok); diff --git a/radiant/map/MapPropertyInfoFileModule.cpp b/radiant/map/MapPropertyInfoFileModule.cpp index 955edff637..641ba21088 100644 --- a/radiant/map/MapPropertyInfoFileModule.cpp +++ b/radiant/map/MapPropertyInfoFileModule.cpp @@ -18,8 +18,15 @@ std::string MapPropertyInfoFileModule::getName() return "Map Properties"; } +void MapPropertyInfoFileModule::clear() +{ + _store.clearProperties(); +} + void MapPropertyInfoFileModule::onInfoFileSaveStart() -{} +{ + clear(); +} void MapPropertyInfoFileModule::onBeginSaveMap(const scene::IMapRootNodePtr& root) { @@ -62,12 +69,12 @@ void MapPropertyInfoFileModule::writeBlocks(std::ostream& stream) void MapPropertyInfoFileModule::onInfoFileSaveFinished() { - _store.clearProperties(); + clear(); } void MapPropertyInfoFileModule::onInfoFileLoadStart() { - _store.clearProperties(); + clear(); } bool MapPropertyInfoFileModule::canParseBlock(const std::string& blockName) @@ -123,6 +130,7 @@ void MapPropertyInfoFileModule::applyInfoToScene(const scene::IMapRootNodePtr& r void MapPropertyInfoFileModule::onInfoFileLoadFinished() { rMessage() << "[InfoFile]: Parsed " << _store.getPropertyCount() << " map properties." << std::endl; + clear(); } } diff --git a/radiant/map/MapPropertyInfoFileModule.h b/radiant/map/MapPropertyInfoFileModule.h index 94bbdad213..d70ae1d9dc 100644 --- a/radiant/map/MapPropertyInfoFileModule.h +++ b/radiant/map/MapPropertyInfoFileModule.h @@ -32,6 +32,9 @@ class MapPropertyInfoFileModule : void parseBlock(const std::string& blockName, parser::DefTokeniser& tok) override; void applyInfoToScene(const scene::IMapRootNodePtr& root, const NodeIndexMap& nodeMap) override; void onInfoFileLoadFinished() override; + +private: + void clear(); }; } diff --git a/radiant/selection/group/SelectionGroupInfoFileModule.cpp b/radiant/selection/group/SelectionGroupInfoFileModule.cpp index cf26158c34..676b69a493 100644 --- a/radiant/selection/group/SelectionGroupInfoFileModule.cpp +++ b/radiant/selection/group/SelectionGroupInfoFileModule.cpp @@ -28,14 +28,23 @@ std::string SelectionGroupInfoFileModule::getName() return "Selection Groups"; } -void SelectionGroupInfoFileModule::onInfoFileSaveStart() +void SelectionGroupInfoFileModule::clear() { + _groupInfo.clear(); + _nodeMapping.clear(); + _output.str(std::string()); _output.clear(); + _selectionGroupBuffer.str(std::string()); _selectionGroupBuffer.clear(); _nodeInfoCount = 0; } +void SelectionGroupInfoFileModule::onInfoFileSaveStart() +{ + clear(); +} + void SelectionGroupInfoFileModule::onBeginSaveMap(const scene::IMapRootNodePtr& root) { // Selection Group output @@ -151,15 +160,12 @@ void SelectionGroupInfoFileModule::writeBlocks(std::ostream& stream) void SelectionGroupInfoFileModule::onInfoFileSaveFinished() { - _output.str(std::string()); - _output.clear(); - _nodeInfoCount = 0; + clear(); } void SelectionGroupInfoFileModule::onInfoFileLoadStart() { - _groupInfo.clear(); - _nodeMapping.clear(); + clear(); } bool SelectionGroupInfoFileModule::canParseBlock(const std::string& blockName) @@ -346,8 +352,7 @@ void SelectionGroupInfoFileModule::applyInfoToScene(const scene::IMapRootNodePtr void SelectionGroupInfoFileModule::onInfoFileLoadFinished() { - _groupInfo.clear(); - _nodeMapping.clear(); + clear(); } } diff --git a/radiant/selection/group/SelectionGroupInfoFileModule.h b/radiant/selection/group/SelectionGroupInfoFileModule.h index d7e9f382b5..f0b7b81829 100644 --- a/radiant/selection/group/SelectionGroupInfoFileModule.h +++ b/radiant/selection/group/SelectionGroupInfoFileModule.h @@ -57,6 +57,7 @@ class SelectionGroupInfoFileModule : void saveNode(const scene::INodePtr& node, std::size_t entityNum, std::size_t primitiveNum); void parseSelectionGroups(parser::DefTokeniser& tok); void parseNodeMappings(parser::DefTokeniser& tok); + void clear(); }; } diff --git a/radiant/selection/selectionset/SelectionSetInfoFileModule.cpp b/radiant/selection/selectionset/SelectionSetInfoFileModule.cpp index d7b26484bb..6965fbca03 100644 --- a/radiant/selection/selectionset/SelectionSetInfoFileModule.cpp +++ b/radiant/selection/selectionset/SelectionSetInfoFileModule.cpp @@ -21,6 +21,12 @@ std::string SelectionSetInfoFileModule::getName() return "Selection Set Mapping"; } +void SelectionSetInfoFileModule::clear() +{ + _importInfo.clear(); + _exportInfo.clear(); +} + void SelectionSetInfoFileModule::onBeginSaveMap(const scene::IMapRootNodePtr& root) { // Visit all selection sets and assemble the info into the structures @@ -39,7 +45,7 @@ void SelectionSetInfoFileModule::onFinishSaveMap(const scene::IMapRootNodePtr& r void SelectionSetInfoFileModule::onInfoFileSaveStart() { - _exportInfo.clear(); + clear(); } void SelectionSetInfoFileModule::onSavePrimitive(const scene::INodePtr& node, std::size_t entityNum, std::size_t primitiveNum) @@ -107,12 +113,12 @@ void SelectionSetInfoFileModule::writeBlocks(std::ostream& stream) void SelectionSetInfoFileModule::onInfoFileSaveFinished() { - _exportInfo.clear(); + clear(); } void SelectionSetInfoFileModule::onInfoFileLoadStart() { - _importInfo.clear(); + clear(); } bool SelectionSetInfoFileModule::canParseBlock(const std::string& blockName) @@ -228,7 +234,7 @@ void SelectionSetInfoFileModule::applyInfoToScene(const scene::IMapRootNodePtr& void SelectionSetInfoFileModule::onInfoFileLoadFinished() { - _importInfo.clear(); + clear(); } } diff --git a/radiant/selection/selectionset/SelectionSetInfoFileModule.h b/radiant/selection/selectionset/SelectionSetInfoFileModule.h index 09bce96d60..75ccc57000 100644 --- a/radiant/selection/selectionset/SelectionSetInfoFileModule.h +++ b/radiant/selection/selectionset/SelectionSetInfoFileModule.h @@ -58,6 +58,9 @@ class SelectionSetInfoFileModule : void parseBlock(const std::string& blockName, parser::DefTokeniser& tok) override; void applyInfoToScene(const scene::IMapRootNodePtr& root, const map::NodeIndexMap& nodeMap) override; void onInfoFileLoadFinished() override; + +private: + void clear(); }; }