diff --git a/code/nel/tools/pipeline/max/builtin/animatable.cpp b/code/nel/tools/pipeline/max/builtin/animatable.cpp index af860395c..57339a0d7 100644 --- a/code/nel/tools/pipeline/max/builtin/animatable.cpp +++ b/code/nel/tools/pipeline/max/builtin/animatable.cpp @@ -65,9 +65,9 @@ const TSClassId CAnimatable::SuperClassId = 0x77a60fbd; /* Not official, please const CAnimatableClassDesc AnimatableClassDesc(&DllPluginDescBuiltin); const CAnimatableSuperClassDesc AnimatableSuperClassDesc(&AnimatableClassDesc); -void CAnimatable::parse(uint16 version, TParseLevel level) +void CAnimatable::parse(uint16 version) { - CSceneClass::parse(version, level); + CSceneClass::parse(version); if (!m_ChunksOwnsPointers) { m_AppData = static_cast(getChunk(PMBS_APP_DATA_CHUNK_ID)); diff --git a/code/nel/tools/pipeline/max/builtin/animatable.h b/code/nel/tools/pipeline/max/builtin/animatable.h index 6ac27ad2e..b7038c074 100644 --- a/code/nel/tools/pipeline/max/builtin/animatable.h +++ b/code/nel/tools/pipeline/max/builtin/animatable.h @@ -67,7 +67,7 @@ public: static const TSClassId SuperClassId; // inherited - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/builtin/builtin.cpp b/code/nel/tools/pipeline/max/builtin/builtin.cpp index 4cc483739..aca908055 100644 --- a/code/nel/tools/pipeline/max/builtin/builtin.cpp +++ b/code/nel/tools/pipeline/max/builtin/builtin.cpp @@ -44,6 +44,7 @@ #include "i_node.h" #include "node_impl.h" +#include "root_node.h" // using namespace std; // using namespace NLMISC; @@ -228,6 +229,7 @@ void CBuiltin::registerClasses(CSceneClassRegistry *registry) { registry->add(&NodeClassDesc); registry->add(&NodeImplClassDesc); + registry->add(&RootNodeClassDesc); } // unimplemented diff --git a/code/nel/tools/pipeline/max/builtin/i_node.cpp b/code/nel/tools/pipeline/max/builtin/i_node.cpp index 944fb8b56..c0ef7c9c1 100644 --- a/code/nel/tools/pipeline/max/builtin/i_node.cpp +++ b/code/nel/tools/pipeline/max/builtin/i_node.cpp @@ -60,9 +60,9 @@ const TSClassId INode::SuperClassId = 0x00000001; const CNodeClassDesc NodeClassDesc(&DllPluginDescBuiltin); const CNodeSuperClassDesc NodeSuperClassDesc(&NodeClassDesc); -void INode::parse(uint16 version, TParseLevel level) +void INode::parse(uint16 version) { - CReferenceTarget::parse(version, level); + CReferenceTarget::parse(version); } void INode::clean() @@ -99,6 +99,28 @@ const ISceneClassDesc *INode::classDesc() const void INode::toStringLocal(std::ostream &ostream, const std::string &pad) const { CReferenceTarget::toStringLocal(ostream, pad); + // Children: IMPLICIT { } - print the implied connected children +} + +INode *INode::parent() +{ + nlerror("Unkown node class, cannot get parent node"); + return NULL; +} + +void INode::setParent(INode *node) +{ + nlerror("Unkown node class, cannot set parent node"); +} + +void INode::addChild(INode *node) +{ + m_Children.insert(node); +} + +void INode::removeChild(INode *node) +{ + m_Children.erase(node); } IStorageObject *INode::createChunkById(uint16 id, bool container) diff --git a/code/nel/tools/pipeline/max/builtin/i_node.h b/code/nel/tools/pipeline/max/builtin/i_node.h index fbf83adde..696b40d44 100644 --- a/code/nel/tools/pipeline/max/builtin/i_node.h +++ b/code/nel/tools/pipeline/max/builtin/i_node.h @@ -60,7 +60,7 @@ public: static const TSClassId SuperClassId; // inherited - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -69,10 +69,21 @@ public: virtual const ISceneClassDesc *classDesc() const; virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; + // node interface + virtual INode *parent(); + virtual void setParent(INode *node); + virtual void addChild(INode *node); + virtual void removeChild(INode *node); // does not delete + /// The children that are linked to this node by the parent tag + inline const std::set &children() const { return m_Children; } + protected: // inherited virtual IStorageObject *createChunkById(uint16 id, bool container); +protected: + std::set m_Children; + }; /* class INode */ typedef CSceneClassDesc CNodeClassDesc; diff --git a/code/nel/tools/pipeline/max/builtin/node_impl.cpp b/code/nel/tools/pipeline/max/builtin/node_impl.cpp index a16a65a08..8ab93fa84 100644 --- a/code/nel/tools/pipeline/max/builtin/node_impl.cpp +++ b/code/nel/tools/pipeline/max/builtin/node_impl.cpp @@ -58,9 +58,9 @@ const NLMISC::CClassId CNodeImpl::ClassId = NLMISC::CClassId(0x00000001, 0x00000 const TSClassId CNodeImpl::SuperClassId = INode::SuperClassId; const CNodeImplClassDesc NodeImplClassDesc(&DllPluginDescBuiltin); -void CNodeImpl::parse(uint16 version, TParseLevel level) +void CNodeImpl::parse(uint16 version) { - INode::parse(version, level); + INode::parse(version); } void CNodeImpl::clean() diff --git a/code/nel/tools/pipeline/max/builtin/node_impl.h b/code/nel/tools/pipeline/max/builtin/node_impl.h index bf7184f18..e81dba57d 100644 --- a/code/nel/tools/pipeline/max/builtin/node_impl.h +++ b/code/nel/tools/pipeline/max/builtin/node_impl.h @@ -59,7 +59,7 @@ public: static const TSClassId SuperClassId; // inherited - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/builtin/reference_maker.cpp b/code/nel/tools/pipeline/max/builtin/reference_maker.cpp index 7a97b291a..965a60c3a 100644 --- a/code/nel/tools/pipeline/max/builtin/reference_maker.cpp +++ b/code/nel/tools/pipeline/max/builtin/reference_maker.cpp @@ -86,9 +86,9 @@ const TSClassId CReferenceMaker::SuperClassId = 0x00000100; const CReferenceMakerClassDesc ReferenceMakerClassDesc(&DllPluginDescBuiltin); const CReferenceMakerSuperClassDesc ReferenceMakerSuperClassDesc(&ReferenceMakerClassDesc); -void CReferenceMaker::parse(uint16 version, TParseLevel level) +void CReferenceMaker::parse(uint16 version) { - CAnimatable::parse(version, level); + CAnimatable::parse(version); if (!m_ChunksOwnsPointers) { CStorageArray *references2034 = static_cast *>(getChunk(PMB_REFERENCES_2034_CHUNK_ID)); diff --git a/code/nel/tools/pipeline/max/builtin/reference_maker.h b/code/nel/tools/pipeline/max/builtin/reference_maker.h index e56f38a61..5dad15167 100644 --- a/code/nel/tools/pipeline/max/builtin/reference_maker.h +++ b/code/nel/tools/pipeline/max/builtin/reference_maker.h @@ -61,7 +61,7 @@ public: static const TSClassId SuperClassId; // inherited - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/builtin/reference_target.cpp b/code/nel/tools/pipeline/max/builtin/reference_target.cpp index e19a10710..02caa1307 100644 --- a/code/nel/tools/pipeline/max/builtin/reference_target.cpp +++ b/code/nel/tools/pipeline/max/builtin/reference_target.cpp @@ -60,9 +60,9 @@ const TSClassId CReferenceTarget::SuperClassId = 0x00000200; const CReferenceTargetClassDesc ReferenceTargetClassDesc(&DllPluginDescBuiltin); const CReferenceTargetSuperClassDesc ReferenceTargetSuperClassDesc(&ReferenceTargetClassDesc); -void CReferenceTarget::parse(uint16 version, TParseLevel level) +void CReferenceTarget::parse(uint16 version) { - CReferenceMaker::parse(version, level); + CReferenceMaker::parse(version); } void CReferenceTarget::clean() diff --git a/code/nel/tools/pipeline/max/builtin/reference_target.h b/code/nel/tools/pipeline/max/builtin/reference_target.h index b6daa94de..290624ec0 100644 --- a/code/nel/tools/pipeline/max/builtin/reference_target.h +++ b/code/nel/tools/pipeline/max/builtin/reference_target.h @@ -61,7 +61,7 @@ public: static const TSClassId SuperClassId; // inherited - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/builtin/root_node.cpp b/code/nel/tools/pipeline/max/builtin/root_node.cpp new file mode 100644 index 000000000..bbb972f8d --- /dev/null +++ b/code/nel/tools/pipeline/max/builtin/root_node.cpp @@ -0,0 +1,111 @@ +/** + * \file root_node.cpp + * \brief CRootNode + * \date 2012-08-22 19:45GMT + * \author Jan Boon (Kaetemi) + * CRootNode + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE PIPELINE. + * RYZOM CORE PIPELINE is free software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * RYZOM CORE PIPELINE is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE PIPELINE. If not, see + * . + */ + +#include +#include "root_node.h" + +// STL includes + +// NeL includes +// #include + +// Project includes + +using namespace std; +// using namespace NLMISC; + +namespace PIPELINE { +namespace MAX { +namespace BUILTIN { + +CRootNode::CRootNode(CScene *scene) : INode(scene) +{ + +} + +CRootNode::~CRootNode() +{ + +} + +const ucstring CRootNode::DisplayName = ucstring("RootNode"); +const char *CRootNode::InternalName = "RootNode"; +const NLMISC::CClassId CRootNode::ClassId = NLMISC::CClassId(0x00000002, 0x00000000); +const TSClassId CRootNode::SuperClassId = INode::SuperClassId; +const CRootNodeClassDesc RootNodeClassDesc(&DllPluginDescBuiltin); + +void CRootNode::parse(uint16 version) +{ + INode::parse(version); +} + +void CRootNode::clean() +{ + INode::clean(); +} + +void CRootNode::build(uint16 version) +{ + INode::build(version); +} + +void CRootNode::disown() +{ + INode::disown(); +} + +void CRootNode::init() +{ + INode::init(); +} + +bool CRootNode::inherits(const NLMISC::CClassId classId) const +{ + if (classId == classDesc()->classId()) return true; + return INode::inherits(classId); +} + +const ISceneClassDesc *CRootNode::classDesc() const +{ + return &RootNodeClassDesc; +} + +void CRootNode::toStringLocal(std::ostream &ostream, const std::string &pad) const +{ + INode::toStringLocal(ostream, pad); +} + +IStorageObject *CRootNode::createChunkById(uint16 id, bool container) +{ + return INode::createChunkById(id, container); +} + +} /* namespace BUILTIN */ +} /* namespace MAX */ +} /* namespace PIPELINE */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/max/builtin/root_node.h b/code/nel/tools/pipeline/max/builtin/root_node.h new file mode 100644 index 000000000..c3f9ac030 --- /dev/null +++ b/code/nel/tools/pipeline/max/builtin/root_node.h @@ -0,0 +1,86 @@ +/** + * \file root_node.h + * \brief CRootNode + * \date 2012-08-22 19:45GMT + * \author Jan Boon (Kaetemi) + * CRootNode + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE PIPELINE. + * RYZOM CORE PIPELINE is free software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * RYZOM CORE PIPELINE is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE PIPELINE. If not, see + * . + */ + +#ifndef PIPELINE_ROOT_NODE_H +#define PIPELINE_ROOT_NODE_H +#include + +// STL includes + +// NeL includes + +// Project includes +#include "i_node.h" + +namespace PIPELINE { +namespace MAX { +namespace BUILTIN { + +/** + * \brief CRootNode + * \date 2012-08-22 20:01GMT + * \author Jan Boon (Kaetemi) + * CRootNode + */ +class CRootNode : public INode +{ +public: + CRootNode(CScene *scene); + virtual ~CRootNode(); + + // class desc + static const ucstring DisplayName; + static const char *InternalName; + static const NLMISC::CClassId ClassId; + static const TSClassId SuperClassId; + + // inherited + virtual void parse(uint16 version); + virtual void clean(); + virtual void build(uint16 version); + virtual void disown(); + virtual void init(); + virtual bool inherits(const NLMISC::CClassId classId) const; + virtual const ISceneClassDesc *classDesc() const; + virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; + +protected: + // inherited + virtual IStorageObject *createChunkById(uint16 id, bool container); + +}; /* class CRootNode */ + +typedef CSceneClassDesc CRootNodeClassDesc; +extern const CRootNodeClassDesc RootNodeClassDesc; + +} /* namespace BUILTIN */ +} /* namespace MAX */ +} /* namespace PIPELINE */ + +#endif /* #ifndef PIPELINE_ROOT_NODE_H */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/max/builtin/scene_impl.cpp b/code/nel/tools/pipeline/max/builtin/scene_impl.cpp index 75717d8a3..b6309589f 100644 --- a/code/nel/tools/pipeline/max/builtin/scene_impl.cpp +++ b/code/nel/tools/pipeline/max/builtin/scene_impl.cpp @@ -58,9 +58,9 @@ const NLMISC::CClassId CSceneImpl::ClassId = NLMISC::CClassId(0x00002222, 0x0000 const TSClassId CSceneImpl::SuperClassId = CReferenceMaker::SuperClassId; const CSceneImplClassDesc SceneImplClassDesc(&DllPluginDescBuiltin); -void CSceneImpl::parse(uint16 version_, TParseLevel level) +void CSceneImpl::parse(uint16 version) { - CReferenceMaker::parse(version_, level); + CReferenceMaker::parse(version); nlassert(m_MaterialEditor); nlassert(m_MtlBaseLib); nlassert(m_Sound); @@ -72,7 +72,7 @@ void CSceneImpl::parse(uint16 version_, TParseLevel level) nlassert(m_RenderEffects); nlassert(m_ShadowMap); nlassert(m_LayerManager); - if (version() > Version3) nlassert(m_TrackSetList); + if (version > Version3) nlassert(m_TrackSetList); } void CSceneImpl::clean() @@ -139,6 +139,10 @@ CReferenceMaker *CSceneImpl::getReference(uint index) const return m_LayerManager; case 11: return m_TrackSetList; + default: + if (index > 0) + nlerror("Invalid index %i", index); + return NULL; } } @@ -182,6 +186,9 @@ void CSceneImpl::setReference(uint index, CReferenceMaker *reference) case 11: m_TrackSetList = reference; break; + default: + nlerror("Unknown reference index %i entry (%s, 0x%x)", index, (uint32)(uint64)(void *)reference, reference->classDesc()->classId().toString().c_str(), reference->classDesc()->superClassId()); + break; } } diff --git a/code/nel/tools/pipeline/max/builtin/scene_impl.h b/code/nel/tools/pipeline/max/builtin/scene_impl.h index c0f2192f5..235282e51 100644 --- a/code/nel/tools/pipeline/max/builtin/scene_impl.h +++ b/code/nel/tools/pipeline/max/builtin/scene_impl.h @@ -59,7 +59,7 @@ public: static const TSClassId SuperClassId; // inherited - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/builtin/storage/app_data.cpp b/code/nel/tools/pipeline/max/builtin/storage/app_data.cpp index 846084145..46eea8733 100644 --- a/code/nel/tools/pipeline/max/builtin/storage/app_data.cpp +++ b/code/nel/tools/pipeline/max/builtin/storage/app_data.cpp @@ -149,7 +149,7 @@ void CAppData::toString(std::ostream &ostream, const std::string &pad) const } } -void CAppData::parse(uint16 version, TParseLevel level) +void CAppData::parse(uint16 version) { /*if (level & PARSE_BUILTIN) {*/ @@ -157,7 +157,7 @@ void CAppData::parse(uint16 version, TParseLevel level) if (!m_ChunksOwnsPointers) { nlerror("Already parsed"); return; } // First parse all the child nodes - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); // Verify if (m_Chunks.size() < 2) { nlwarning("Bad container size %i", m_Chunks.size()); disown(); return; } @@ -390,9 +390,9 @@ void CAppDataEntry::toString(std::ostream &ostream, const std::string &pad) cons } } -void CAppDataEntry::parse(uint16 version, TParseLevel level) +void CAppDataEntry::parse(uint16 version) { - // CStorageContainer::parse(version, level); + // CStorageContainer::parse(version); // if (!m_ChunksOwnsPointers) { nlwarning("Already parsed"); return; } if (m_Chunks.size() != 2) { nlwarning("Bad container size"); disown(); return; } diff --git a/code/nel/tools/pipeline/max/builtin/storage/app_data.h b/code/nel/tools/pipeline/max/builtin/storage/app_data.h index 5c7191fa7..833a464d0 100644 --- a/code/nel/tools/pipeline/max/builtin/storage/app_data.h +++ b/code/nel/tools/pipeline/max/builtin/storage/app_data.h @@ -76,7 +76,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -149,7 +149,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/class_data.cpp b/code/nel/tools/pipeline/max/class_data.cpp index d85647058..ce9f06938 100644 --- a/code/nel/tools/pipeline/max/class_data.cpp +++ b/code/nel/tools/pipeline/max/class_data.cpp @@ -65,9 +65,9 @@ void CClassData::toString(std::ostream &ostream, const std::string &pad) const CStorageContainer::toString(ostream, pad); } -void CClassData::parse(uint16 version, TParseLevel level) +void CClassData::parse(uint16 version) { - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); } void CClassData::clean() @@ -122,9 +122,9 @@ void CClassDataEntry::toString(std::ostream &ostream, const std::string &pad) co CStorageContainer::toString(ostream, pad); } -void CClassDataEntry::parse(uint16 version, TParseLevel level) +void CClassDataEntry::parse(uint16 version) { - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); } void CClassDataEntry::clean() diff --git a/code/nel/tools/pipeline/max/class_data.h b/code/nel/tools/pipeline/max/class_data.h index 1d6d5aa52..0b11b9ede 100644 --- a/code/nel/tools/pipeline/max/class_data.h +++ b/code/nel/tools/pipeline/max/class_data.h @@ -56,7 +56,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -81,7 +81,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/class_directory_3.cpp b/code/nel/tools/pipeline/max/class_directory_3.cpp index a9e9c255c..8507e8065 100644 --- a/code/nel/tools/pipeline/max/class_directory_3.cpp +++ b/code/nel/tools/pipeline/max/class_directory_3.cpp @@ -120,52 +120,49 @@ void CClassDirectory3::toString(std::ostream &ostream, const std::string &pad) c } // Parallel to CDllDirectory -void CClassDirectory3::parse(uint16 version, TParseLevel level) +void CClassDirectory3::parse(uint16 version) { - if (level & PARSE_INTERNAL) - { - // Ensure not yet parsed - nlassert(m_ChunkCache.empty()); - nlassert(m_Entries.empty()); + // Ensure not yet parsed + nlassert(m_ChunkCache.empty()); + nlassert(m_Entries.empty()); - // Parse entries first - CStorageContainer::parse(version, level); + // Parse entries first + CStorageContainer::parse(version); - // Initialize - uint16 lastCached = 0xFFFF; - bool parsedDllEntry = false; + // Initialize + uint16 lastCached = 0xFFFF; + bool parsedDllEntry = false; - // Parse chunks - for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) + // Parse chunks + for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) + { + uint16 id = it->first; + switch (id) { - uint16 id = it->first; - switch (id) + case 0x2040: // ClassEntry { - case 0x2040: // ClassEntry + if (parsedDllEntry && (lastCached != id)) + throw EStorageParse(); // There were chunks inbetween + if (!parsedDllEntry) { - if (parsedDllEntry && (lastCached != id)) - throw EStorageParse(); // There were chunks inbetween - if (!parsedDllEntry) - { - m_ChunkCache.push_back(TStorageObjectWithId(id, NULL)); // Dummy entry to know the location - lastCached = id; - parsedDllEntry = true; - } - CClassEntry *classEntry = static_cast(it->second); - m_ClassIdToIndex[classEntry->classId()] = m_Entries.size(); - m_Entries.push_back(classEntry); - break; + m_ChunkCache.push_back(TStorageObjectWithId(id, NULL)); // Dummy entry to know the location + lastCached = id; + parsedDllEntry = true; } - default: - m_ChunkCache.push_back(*it); // Dummy entry to know the location - lastCached = id; + CClassEntry *classEntry = static_cast(it->second); + m_ClassIdToIndex[classEntry->classId()] = m_Entries.size(); + m_Entries.push_back(classEntry); break; } + default: + m_ChunkCache.push_back(*it); // Dummy entry to know the location + lastCached = id; + break; } - - // Now ownership of the pointers lies in m_ChunkCache and m_Entries - m_ChunksOwnsPointers = false; } + + // Now ownership of the pointers lies in m_ChunkCache and m_Entries + m_ChunksOwnsPointers = false; } // Parallel to CDllDirectory @@ -337,9 +334,9 @@ void CClassEntry::toString(std::ostream &ostream, const std::string &pad) const } } -void CClassEntry::parse(uint16 version, TParseLevel level) +void CClassEntry::parse(uint16 version) { - // CStorageContainer::parse(version, level); + // CStorageContainer::parse(version); nlassert(m_ChunksOwnsPointers); nlassert(m_Chunks.size() == 2); TStorageObjectContainer::iterator it = m_Chunks.begin(); diff --git a/code/nel/tools/pipeline/max/class_directory_3.h b/code/nel/tools/pipeline/max/class_directory_3.h index 954ad3164..b12f8e5a9 100644 --- a/code/nel/tools/pipeline/max/class_directory_3.h +++ b/code/nel/tools/pipeline/max/class_directory_3.h @@ -66,7 +66,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -131,7 +131,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/config.cpp b/code/nel/tools/pipeline/max/config.cpp index 3b1cb6ad4..54565e851 100644 --- a/code/nel/tools/pipeline/max/config.cpp +++ b/code/nel/tools/pipeline/max/config.cpp @@ -66,9 +66,9 @@ void CConfig::toString(std::ostream &ostream, const std::string &pad) const CStorageContainer::toString(ostream, pad); } -void CConfig::parse(uint16 version, TParseLevel level) +void CConfig::parse(uint16 version) { - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); } void CConfig::clean() @@ -133,9 +133,9 @@ void CConfig20a0::toString(std::ostream &ostream, const std::string &pad) const CStorageContainer::toString(ostream, pad); } -void CConfig20a0::parse(uint16 version, TParseLevel level) +void CConfig20a0::parse(uint16 version) { - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); } void CConfig20a0::clean() @@ -198,9 +198,9 @@ void CConfig20a0Entry::toString(std::ostream &ostream, const std::string &pad) c CStorageContainer::toString(ostream, pad); } -void CConfig20a0Entry::parse(uint16 version, TParseLevel level) +void CConfig20a0Entry::parse(uint16 version) { - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); } void CConfig20a0Entry::clean() @@ -290,9 +290,9 @@ void CConfigScript::toString(std::ostream &ostream, const std::string &pad) cons CStorageContainer::toString(ostream, pad); } -void CConfigScript::parse(uint16 version, TParseLevel level) +void CConfigScript::parse(uint16 version) { - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); } void CConfigScript::clean() @@ -347,9 +347,9 @@ void CConfigScriptEntry::toString(std::ostream &ostream, const std::string &pad) CStorageContainer::toString(ostream, pad); } -void CConfigScriptEntry::parse(uint16 version, TParseLevel level) +void CConfigScriptEntry::parse(uint16 version) { - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); } void CConfigScriptEntry::clean() @@ -445,9 +445,9 @@ void CConfigScriptMetaContainer::toString(std::ostream &ostream, const std::stri CStorageContainer::toString(ostream, pad); } -void CConfigScriptMetaContainer::parse(uint16 version, TParseLevel level) +void CConfigScriptMetaContainer::parse(uint16 version) { - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); } void CConfigScriptMetaContainer::clean() diff --git a/code/nel/tools/pipeline/max/config.h b/code/nel/tools/pipeline/max/config.h index 2db26c338..14031fd02 100644 --- a/code/nel/tools/pipeline/max/config.h +++ b/code/nel/tools/pipeline/max/config.h @@ -56,7 +56,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -81,7 +81,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -106,7 +106,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -131,7 +131,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -156,7 +156,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -205,7 +205,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/dll_directory.cpp b/code/nel/tools/pipeline/max/dll_directory.cpp index 8aa00d2bb..275b73da5 100644 --- a/code/nel/tools/pipeline/max/dll_directory.cpp +++ b/code/nel/tools/pipeline/max/dll_directory.cpp @@ -118,53 +118,50 @@ void CDllDirectory::toString(std::ostream &ostream, const std::string &pad) cons } // Parallel to CClassDirectory3 -void CDllDirectory::parse(uint16 version, TParseLevel level) +void CDllDirectory::parse(uint16 version) { - if (level & PARSE_INTERNAL) - { - // Ensure not yet parsed - nlassert(m_ChunkCache.empty()); - nlassert(m_Entries.empty()); + // Ensure not yet parsed + nlassert(m_ChunkCache.empty()); + nlassert(m_Entries.empty()); - // Parse entries first - CStorageContainer::parse(version, level); + // Parse entries first + CStorageContainer::parse(version); - // Initialize - addInternalIndices(); - uint16 lastCached = 0xFFFF; - bool parsedDllEntry = false; + // Initialize + addInternalIndices(); + uint16 lastCached = 0xFFFF; + bool parsedDllEntry = false; - // Parse chunks - for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) + // Parse chunks + for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) + { + uint16 id = it->first; + switch (id) { - uint16 id = it->first; - switch (id) + case 0x2038: // DllEntry { - case 0x2038: // DllEntry + if (parsedDllEntry && (lastCached != id)) + throw EStorageParse(); // There were chunks inbetween + if (!parsedDllEntry) { - if (parsedDllEntry && (lastCached != id)) - throw EStorageParse(); // There were chunks inbetween - if (!parsedDllEntry) - { - m_ChunkCache.push_back(TStorageObjectWithId(id, NULL)); // Dummy entry to know the location - lastCached = id; - parsedDllEntry = true; - } - CDllEntry *dllEntry = static_cast(it->second); - m_InternalNameToIndex[NLMISC::toLower(dllEntry->dllFilename())] = m_Entries.size(); - m_Entries.push_back(dllEntry); + m_ChunkCache.push_back(TStorageObjectWithId(id, NULL)); // Dummy entry to know the location + lastCached = id; + parsedDllEntry = true; } - break; - default: - m_ChunkCache.push_back(*it); // Dummy entry to know the location - lastCached = id; - break; + CDllEntry *dllEntry = static_cast(it->second); + m_InternalNameToIndex[NLMISC::toLower(dllEntry->dllFilename())] = m_Entries.size(); + m_Entries.push_back(dllEntry); } + break; + default: + m_ChunkCache.push_back(*it); // Dummy entry to know the location + lastCached = id; + break; } - - // Now ownership of the pointers lies in m_ChunkCache and m_Entries - m_ChunksOwnsPointers = false; } + + // Now ownership of the pointers lies in m_ChunkCache and m_Entries + m_ChunksOwnsPointers = false; } // Parallel to CClassDirectory3 @@ -363,9 +360,9 @@ void CDllEntry::toString(std::ostream &ostream, const std::string &pad) const } } -void CDllEntry::parse(uint16 version, TParseLevel level) +void CDllEntry::parse(uint16 version) { - // CStorageContainer::parse(version, level); + // CStorageContainer::parse(version); nlassert(m_ChunksOwnsPointers); nlassert(m_Chunks.size() == 2); TStorageObjectContainer::iterator it = m_Chunks.begin(); diff --git a/code/nel/tools/pipeline/max/dll_directory.h b/code/nel/tools/pipeline/max/dll_directory.h index 998fc51f6..36716d7ba 100644 --- a/code/nel/tools/pipeline/max/dll_directory.h +++ b/code/nel/tools/pipeline/max/dll_directory.h @@ -57,7 +57,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -94,7 +94,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/scene.cpp b/code/nel/tools/pipeline/max/scene.cpp index a7b7a20fd..71086dd04 100644 --- a/code/nel/tools/pipeline/max/scene.cpp +++ b/code/nel/tools/pipeline/max/scene.cpp @@ -72,9 +72,9 @@ void CScene::toString(std::ostream &ostream, const std::string &pad) const CStorageContainer::toString(ostream, pad); } -void CScene::parse(uint16 version, TParseLevel level) +void CScene::parse(uint16 version) { - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); nlassert(m_Chunks.size() == 1); } @@ -140,7 +140,7 @@ void CSceneClassContainer::toString(std::ostream &ostream, const std::string &pa CStorageContainer::toString(ostream, pad); } -void CSceneClassContainer::parse(uint16 version, TParseLevel level) +void CSceneClassContainer::parse(uint16 version) { // Temporary 'readonly' implementation, not modifying m_Chunks! m_StorageObjectByIndex.resize(m_Chunks.size()); @@ -154,7 +154,7 @@ void CSceneClassContainer::parse(uint16 version, TParseLevel level) nlassert(builtinScene); m_BuiltinScene = dynamic_cast(builtinScene); nlassert(m_BuiltinScene); - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); } void CSceneClassContainer::clean() diff --git a/code/nel/tools/pipeline/max/scene.h b/code/nel/tools/pipeline/max/scene.h index faf27ef47..1d62d35c8 100644 --- a/code/nel/tools/pipeline/max/scene.h +++ b/code/nel/tools/pipeline/max/scene.h @@ -71,7 +71,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); @@ -105,7 +105,7 @@ public: // inherited virtual std::string className() const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const; - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); virtual void clean(); virtual void build(uint16 version); virtual void disown(); diff --git a/code/nel/tools/pipeline/max/scene_class.cpp b/code/nel/tools/pipeline/max/scene_class.cpp index cb88f4f01..18a302d94 100644 --- a/code/nel/tools/pipeline/max/scene_class.cpp +++ b/code/nel/tools/pipeline/max/scene_class.cpp @@ -125,13 +125,13 @@ void CSceneClass::toString(std::ostream &ostream, const std::string &pad) const } } -void CSceneClass::parse(uint16 version, TParseLevel level) +void CSceneClass::parse(uint16 version) { // Cannot be parsed yet if (!m_ChunksOwnsPointers) { nlerror("Already parsed"); return; } // Already parsed, illegal to call twice // Parse all child chunks - CStorageContainer::parse(version, level); + CStorageContainer::parse(version); // Orphanize all child chunk m_OrphanedChunks.insert(m_OrphanedChunks.end(), m_Chunks.begin(), m_Chunks.end()); diff --git a/code/nel/tools/pipeline/max/scene_class.h b/code/nel/tools/pipeline/max/scene_class.h index 9a5ff2f2d..a6f67583f 100644 --- a/code/nel/tools/pipeline/max/scene_class.h +++ b/code/nel/tools/pipeline/max/scene_class.h @@ -82,7 +82,7 @@ public: //! \name Inherited functions called through the storage loading and saving system //@{ /// Override this to read a chunk from the chunks stream. Call the parent's parse function first. Get the necessary chunks implemented by your class using getChunk. See the getChunk function for further information. In case of failure, call disown. If m_ChunksOwnsPointers is true, the parsing has failed, warnings have already been printed, and nothing should happen. Chunks are already parsed when you get them from getChunk - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); /// Override this if the chunks you are using are not needed after they have been parsed. You may delete any chunks you own. Call the parent's clean first. You must call clean on any chunks you own if they implement this function virtual void clean(); /// Override this to write a chunk to the chunks stream. If you create a new chunk, the creating class owns it, and should delete it when clean is called. You no longer own any created chunks when disown has been called. Use putChunk to add the chunk. Call the parent's build first. The putChunk function calls build on added chunks diff --git a/code/nel/tools/pipeline/max/storage_object.cpp b/code/nel/tools/pipeline/max/storage_object.cpp index 5377d352f..b1c0f2463 100644 --- a/code/nel/tools/pipeline/max/storage_object.cpp +++ b/code/nel/tools/pipeline/max/storage_object.cpp @@ -194,14 +194,14 @@ void CStorageContainer::toString(std::ostream &ostream, const std::string &pad) ostream << "} "; } -void CStorageContainer::parse(uint16 version, TParseLevel level) +void CStorageContainer::parse(uint16 version) { nlassert(m_ChunksOwnsPointers); // Can only use this when m_Chunks still has ownership. for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { if (it->second->isContainer()) { - static_cast(it->second)->parse(version, level); + static_cast(it->second)->parse(version); } } } diff --git a/code/nel/tools/pipeline/max/storage_object.h b/code/nel/tools/pipeline/max/storage_object.h index 1acd5ded6..ef9b18209 100644 --- a/code/nel/tools/pipeline/max/storage_object.h +++ b/code/nel/tools/pipeline/max/storage_object.h @@ -112,7 +112,7 @@ public: // virtual // Parse this class with given version and parse level filter - virtual void parse(uint16 version, TParseLevel level); + virtual void parse(uint16 version); // Clean up built data or duplicate unparsed source data, call after serializing build and after parse virtual void clean(); // Build the storage structure needed to store the parsed data back diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index 9e7f7a4cc..e4df139f1 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -110,7 +110,7 @@ int main(int argc, char **argv) g_object_unref(input); //dllDirectory.toString(std::cout); //std::cout << "\n"; - dllDirectory.parse(PIPELINE::MAX::VersionUnknown, PIPELINE::MAX::PARSE_INTERNAL); // parse the structure to readable data + dllDirectory.parse(PIPELINE::MAX::VersionUnknown); // parse the structure to readable data dllDirectory.clean(); // cleanup unused file structure dllDirectory.toString(std::cout); std::cout << "\n"; @@ -132,7 +132,7 @@ int main(int argc, char **argv) g_object_unref(input); //classDirectory3.toString(std::cout); //std::cout << "\n"; - classDirectory3.parse(PIPELINE::MAX::VersionUnknown, PIPELINE::MAX::PARSE_INTERNAL); // parse the structure to readable data + classDirectory3.parse(PIPELINE::MAX::VersionUnknown); // parse the structure to readable data classDirectory3.clean(); // cleanup unused file structure classDirectory3.toString(std::cout); std::cout << "\n"; @@ -155,9 +155,7 @@ int main(int argc, char **argv) g_object_unref(input); //classDirectory3.toString(std::cout); //std::cout << "\n"; - scene.parse(PIPELINE::MAX::VersionUnknown, (PIPELINE::MAX::TParseLevel)( - PIPELINE::MAX::PARSE_INTERNAL - | PIPELINE::MAX::PARSE_BUILTIN)); // parse the structure to readable data + scene.parse(PIPELINE::MAX::VersionUnknown); // parse the structure to readable data scene.clean(); // cleanup unused file structure // TEST -> nldebug("BUILD"); @@ -165,9 +163,7 @@ int main(int argc, char **argv) nldebug("DISOWN"); scene.disown(); nldebug("PARSE"); - scene.parse(PIPELINE::MAX::VersionUnknown, (PIPELINE::MAX::TParseLevel)( - PIPELINE::MAX::PARSE_INTERNAL - | PIPELINE::MAX::PARSE_BUILTIN)); // parse the structure to readable data + scene.parse(PIPELINE::MAX::VersionUnknown); // parse the structure to readable data nldebug("CLEAN"); scene.clean(); // cleanup unused file structure // <- TEST