diff --git a/code/nel/tools/pipeline/max/class_directory_3.cpp b/code/nel/tools/pipeline/max/class_directory_3.cpp index 7ed8cfdbb..a58b1793f 100644 --- a/code/nel/tools/pipeline/max/class_directory_3.cpp +++ b/code/nel/tools/pipeline/max/class_directory_3.cpp @@ -237,9 +237,11 @@ void CClassDirectory3::disown() const CClassEntry *CClassDirectory3::get(uint16 index) const { nlassert(!ChunksOwnsPointers); + nlassert(index < m_Entries.size()); return m_Entries[index]; } +// Parallel to CDllDirectory void CClassDirectory3::reset() { nlassert(!ChunksOwnsPointers); @@ -251,6 +253,7 @@ void CClassDirectory3::reset() m_ClassIdToIndex.clear(); } +// Parallel to CDllDirectory uint16 CClassDirectory3::getOrCreateIndex(const ISceneClassDesc *sceneClassDesc) { nlassert(!ChunksOwnsPointers); diff --git a/code/nel/tools/pipeline/max/dll_directory.cpp b/code/nel/tools/pipeline/max/dll_directory.cpp index 3449bfda4..86980a51e 100644 --- a/code/nel/tools/pipeline/max/dll_directory.cpp +++ b/code/nel/tools/pipeline/max/dll_directory.cpp @@ -140,15 +140,19 @@ void CDllDirectory::parse(uint16 version, TParseLevel level) switch (id) { case 0x2038: // DllEntry - 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; + 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_Entries.push_back(static_cast(it->second)); break; default: m_ChunkCache.push_back(*it); // Dummy entry to know the location @@ -222,6 +226,7 @@ void CDllDirectory::disown() CStorageContainer::disown(); m_ChunkCache.clear(); m_Entries.clear(); + m_InternalNameToIndex.clear(); // Ownership goes back to Chunks ChunksOwnsPointers = true; @@ -233,6 +238,37 @@ const CDllEntry *CDllDirectory::get(uint16 index) const return m_Entries[index]; } +// Parallel to CClassDirectory3 +void CDllDirectory::reset() +{ + nlassert(!ChunksOwnsPointers); + for (std::vector::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit) + { + delete (*subit); + } + m_Entries.clear(); + m_InternalNameToIndex.clear(); +} + +// Parallel to CClassDirectory3 +uint16 CDllDirectory::getOrCreateIndex(const IDllPluginDesc *dllPluginDesc) +{ + nlassert(!ChunksOwnsPointers); + std::map::iterator it = m_InternalNameToIndex.find(NLMISC::toLower(ucstring(dllPluginDesc->internalName()))); + + // Return existing index + if (it != m_InternalNameToIndex.end()) + return it->second; + + // Create new entry + /*CClassEntry *classEntry = new CClassEntry(sceneClassDesc); + uint16 index = m_Entries.size(); + m_ClassIdToIndex[classEntry->classId()] = index; + m_Entries.push_back(classEntry); + return index;*/ + return 0xFFFF; +} + IStorageObject *CDllDirectory::createChunkById(uint16 id, bool container) { if (container) diff --git a/code/nel/tools/pipeline/max/dll_directory.h b/code/nel/tools/pipeline/max/dll_directory.h index e02ae45a0..55fdef77d 100644 --- a/code/nel/tools/pipeline/max/dll_directory.h +++ b/code/nel/tools/pipeline/max/dll_directory.h @@ -36,6 +36,7 @@ // Project includes #include "storage_object.h" #include "storage_value.h" +#include "dll_plugin_desc.h" namespace PIPELINE { namespace MAX { @@ -63,7 +64,12 @@ public: virtual void disown(); // public + // Get a dll entry corresponding to a chunk index, pointers become invalid after reset const CDllEntry *get(uint16 index) const; + // Reset the dll directory, all dll entry pointers become invalid, use internal name and dll plugin registry + void reset(); + // Get or create the chunk index for a dll by dll plugin description + uint16 getOrCreateIndex(const IDllPluginDesc *dllPluginDesc); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -71,6 +77,7 @@ protected: private: TStorageObjectContainer m_ChunkCache; std::vector m_Entries; + std::map m_InternalNameToIndex; }; /* class CDllDirectory */ diff --git a/code/nel/tools/pipeline/max/dll_plugin_desc.cpp b/code/nel/tools/pipeline/max/dll_plugin_desc.cpp index 31bf801ba..01308a1c7 100644 --- a/code/nel/tools/pipeline/max/dll_plugin_desc.cpp +++ b/code/nel/tools/pipeline/max/dll_plugin_desc.cpp @@ -53,6 +53,8 @@ const ucchar *CDllPluginDescBuiltin::internalName() const return value.c_str(); } +const CDllPluginDescBuiltin DllPluginDescBuiltin; + const ucchar *CDllPluginDescScript::displayName() const { static const ucstring value = ucstring("Script"); @@ -65,6 +67,8 @@ const ucchar *CDllPluginDescScript::internalName() const return value.c_str(); } +const CDllPluginDescScript DllPluginDescScript; + } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max/dll_plugin_desc.h b/code/nel/tools/pipeline/max/dll_plugin_desc.h index 26bcf6ded..5fc951ef9 100644 --- a/code/nel/tools/pipeline/max/dll_plugin_desc.h +++ b/code/nel/tools/pipeline/max/dll_plugin_desc.h @@ -82,6 +82,8 @@ class CDllPluginDescBuiltin : public IDllPluginDescInternal virtual const ucchar *internalName() const; }; /* class CDllPluginDescBuiltin */ +extern const CDllPluginDescBuiltin DllPluginDescBuiltin; + /** * \brief CDllPluginDescScript * \date 2012-08-20 09:59GMT @@ -95,6 +97,8 @@ class CDllPluginDescScript : public IDllPluginDescInternal virtual const ucchar *internalName() const; }; /* class CDllPluginDescScript */ +extern const CDllPluginDescScript DllPluginDescScript; + } /* namespace MAX */ } /* namespace PIPELINE */