From 5fd3d7f2752379823ec5ee3b49cba479d6c1ba8f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 21 Aug 2012 17:19:21 +0200 Subject: [PATCH] Changed: #1440 Stricter code --HG-- branch : build_pipeline_v3 --- .../tools/pipeline/max/builtin/app_data.cpp | 76 +++++++++---------- .../tools/pipeline/max/class_directory_3.cpp | 56 +++++++------- code/nel/tools/pipeline/max/dll_directory.cpp | 56 +++++++------- code/nel/tools/pipeline/max/scene.cpp | 12 +-- .../pipeline/max/scene_class_unknown.cpp | 6 +- .../nel/tools/pipeline/max/storage_object.cpp | 38 +++++----- code/nel/tools/pipeline/max/storage_object.h | 37 +++------ code/nel/tools/pipeline/max_dump/main.cpp | 4 +- 8 files changed, 133 insertions(+), 152 deletions(-) diff --git a/code/nel/tools/pipeline/max/builtin/app_data.cpp b/code/nel/tools/pipeline/max/builtin/app_data.cpp index 53ee427fd..74ef6192d 100644 --- a/code/nel/tools/pipeline/max/builtin/app_data.cpp +++ b/code/nel/tools/pipeline/max/builtin/app_data.cpp @@ -128,7 +128,7 @@ std::string CAppData::getClassName() void CAppData::toString(std::ostream &ostream, const std::string &pad) { - if (ChunksOwnsPointers) + if (m_ChunksOwnsPointers) { CStorageContainer::toString(ostream, pad); } @@ -155,16 +155,16 @@ void CAppData::parse(uint16 version, TParseLevel level) CStorageContainer::parse(version, level); // Verify - if (Chunks.size() < 2) { nlwarning("Bad container size %i", Chunks.size()); disown(); return; } + if (m_Chunks.size() < 2) { nlwarning("Bad container size %i", m_Chunks.size()); disown(); return; } // Header - TStorageObjectContainer::iterator it = Chunks.begin(); + TStorageObjectContainer::iterator it = m_Chunks.begin(); if (it->first != NLMAXFILE_APP_DATA_HEADER_CHUNK_ID) { nlwarning("Bad id %x, expected %x", (uint32)it->first, NLMAXFILE_APP_DATA_HEADER_CHUNK_ID); disown(); return; } uint32 headerSize = static_cast *>(it->second)->Value; ++it; // Entries - for (TStorageObjectContainer::iterator end = Chunks.end(); it != end; ++it) + for (TStorageObjectContainer::iterator end = m_Chunks.end(); it != end; ++it) { if (it->first != NLMAXFILE_APP_DATA_ENTRY_CHUNK_ID) { nlwarning("Bad id %x, expected %x", (uint32)it->first, NLMAXFILE_APP_DATA_ENTRY_CHUNK_ID); disown(); return; } CAppDataEntry *entry = static_cast(it->second); @@ -177,33 +177,33 @@ void CAppData::parse(uint16 version, TParseLevel level) if (m_Entries.size() != headerSize) { nlwarning("Entry count %i does not match header %i", m_Entries.size(), headerSize); disown(); return; } // Take local ownership - ChunksOwnsPointers = false; + m_ChunksOwnsPointers = false; } } void CAppData::clean() { - if (ChunksOwnsPointers) { nldebug("Not parsed"); return; } // Must have local ownership - if (Chunks.size() == 0) { nlwarning("Bad container size"); return; } // Already cleaned - if (Chunks.begin()->first != NLMAXFILE_APP_DATA_HEADER_CHUNK_ID) { nlerror("Bad id %x, expected %x", (uint32)Chunks.begin()->first, NLMAXFILE_APP_DATA_HEADER_CHUNK_ID); return; } // Cannot happen, because we won't have local ownership if parsing failed - delete Chunks.begin()->second; // Delete the header chunk, since we own it - Chunks.clear(); // Clear the remaining chunks + if (m_ChunksOwnsPointers) { nldebug("Not parsed"); return; } // Must have local ownership + if (m_Chunks.size() == 0) { nlwarning("Bad container size"); return; } // Already cleaned + if (m_Chunks.begin()->first != NLMAXFILE_APP_DATA_HEADER_CHUNK_ID) { nlerror("Bad id %x, expected %x", (uint32)m_Chunks.begin()->first, NLMAXFILE_APP_DATA_HEADER_CHUNK_ID); return; } // Cannot happen, because we won't have local ownership if parsing failed + delete m_Chunks.begin()->second; // Delete the header chunk, since we own it + m_Chunks.clear(); // Clear the remaining chunks } void CAppData::build(uint16 version) { // Must be clean first - if (!ChunksOwnsPointers && Chunks.size() != 0) { nlerror("Not cleaned"); return; } - if (Chunks.size() != 0) { nldebug("Not parsed"); return; } + if (!m_ChunksOwnsPointers && m_Chunks.size() != 0) { nlerror("Not cleaned"); return; } + if (m_Chunks.size() != 0) { nldebug("Not parsed"); return; } // Set up the header in the chunks container - CStorageValue *headerSize = new CStorageValue(); // Owned locally, not by Chunks + CStorageValue *headerSize = new CStorageValue(); // Owned locally, not by m_Chunks headerSize->Value = m_Entries.size(); - Chunks.push_back(TStorageObjectWithId(NLMAXFILE_APP_DATA_HEADER_CHUNK_ID, headerSize)); + m_Chunks.push_back(TStorageObjectWithId(NLMAXFILE_APP_DATA_HEADER_CHUNK_ID, headerSize)); // Set up the entries for (TMap::iterator it = m_Entries.begin(), end = m_Entries.end(); it != end; ++it) - Chunks.push_back(TStorageObjectWithId(NLMAXFILE_APP_DATA_ENTRY_CHUNK_ID, it->second)); + m_Chunks.push_back(TStorageObjectWithId(NLMAXFILE_APP_DATA_ENTRY_CHUNK_ID, it->second)); // Build all the child chunks CStorageContainer::build(version); @@ -211,30 +211,30 @@ void CAppData::build(uint16 version) void CAppData::disown() { - if (ChunksOwnsPointers) { nldebug("Not parsed"); } - if (!ChunksOwnsPointers && (Chunks.size() != (m_Entries.size() + 1))) { nlerror("Not built"); return; } // If chunks is not the owner, built chunks must match the parsed data - // NOTE: Chunks must be valid at this point! + if (m_ChunksOwnsPointers) { nldebug("Not parsed"); } + if (!m_ChunksOwnsPointers && (m_Chunks.size() != (m_Entries.size() + 1))) { nlerror("Not built"); return; } // If chunks is not the owner, built chunks must match the parsed data + // NOTE: m_Chunks must be valid at this point! // Disown all the child chunks CStorageContainer::disown(); // Disown locally m_Entries.clear(); // Give ownership back - ChunksOwnsPointers = true; + m_ChunksOwnsPointers = true; } void CAppData::init() { // Cannot be init yet - if (!ChunksOwnsPointers) { nlerror("Already parsed"); return; } - if (Chunks.size() != 0) { nlerror("Already built or serialized"); return; } + if (!m_ChunksOwnsPointers) { nlerror("Already parsed"); return; } + if (m_Chunks.size() != 0) { nlerror("Already built or serialized"); return; } // We own this - ChunksOwnsPointers = false; + m_ChunksOwnsPointers = false; } const uint8 *CAppData::read(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 &size) const { - if (ChunksOwnsPointers) { nlwarning("Not parsed"); return NULL; } + if (m_ChunksOwnsPointers) { nlwarning("Not parsed"); return NULL; } TKey key(classId, superClassId, subId); TMap::const_iterator it = m_Entries.find(key); if (it == m_Entries.end()) { nldebug("Trying to read non-existant key, this is allowed, returning NULL"); return NULL; } @@ -244,7 +244,7 @@ const uint8 *CAppData::read(NLMISC::CClassId classId, TSClassId superClassId, ui uint8 *CAppData::lock(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 capacity) { - if (ChunksOwnsPointers) { nlwarning("Not parsed"); return NULL; } + if (m_ChunksOwnsPointers) { nlwarning("Not parsed"); return NULL; } TKey key(classId, superClassId, subId); TMap::const_iterator it = m_Entries.find(key); CAppDataEntry *appDataEntry; @@ -267,7 +267,7 @@ uint8 *CAppData::lock(NLMISC::CClassId classId, TSClassId superClassId, uint32 s void CAppData::unlock(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 size) { - if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; } + if (m_ChunksOwnsPointers) { nlwarning("Not parsed"); return; } TKey key(classId, superClassId, subId); TMap::const_iterator it = m_Entries.find(key); if (it == m_Entries.end()) { nlerror("Unlocking non-existant key"); return; } @@ -288,7 +288,7 @@ void CAppData::fill(NLMISC::CClassId classId, TSClassId superClassId, uint32 sub void CAppData::erase(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId) { - if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; } + if (m_ChunksOwnsPointers) { nlwarning("Not parsed"); return; } TKey key(classId, superClassId, subId); TMap::const_iterator it = m_Entries.find(key); if (it == m_Entries.end()) { nldebug("Trying to erase non-existant key, this is allowed, doing nothing"); return; } @@ -371,7 +371,7 @@ void CAppDataEntry::toString(std::ostream &ostream, const std::string &pad) { if (m_Key && m_Value) { - ostream << "(" << getClassName() << ") [" << Chunks.size() << "] PARSED { "; + ostream << "(" << getClassName() << ") [" << m_Chunks.size() << "] PARSED { "; std::string padpad = pad + "\t"; ostream << "\n" << pad << "Key: "; m_Key->toString(ostream, padpad); @@ -388,10 +388,10 @@ void CAppDataEntry::toString(std::ostream &ostream, const std::string &pad) void CAppDataEntry::parse(uint16 version, TParseLevel level) { // CStorageContainer::parse(version, level); - // if (!ChunksOwnsPointers) { nlwarning("Already parsed"); return; } - if (Chunks.size() != 2) { nlwarning("Bad container size"); disown(); return; } + // if (!m_ChunksOwnsPointers) { nlwarning("Already parsed"); return; } + if (m_Chunks.size() != 2) { nlwarning("Bad container size"); disown(); return; } - TStorageObjectContainer::iterator it = Chunks.begin(); + TStorageObjectContainer::iterator it = m_Chunks.begin(); if (it->first != NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID) { nlwarning("Bad id %x, expected %x", (uint32)it->first, NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID); disown(); return; } m_Key = static_cast(it->second); @@ -399,22 +399,22 @@ void CAppDataEntry::parse(uint16 version, TParseLevel level) if (it->first != NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID) { nlwarning("Bad id %x, expected %x", (uint32)it->first, NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID); disown(); return; } m_Value = static_cast(it->second); - // ChunksOwnsPointers = false; - nlassert(ChunksOwnsPointers); // Never set false here + // m_ChunksOwnsPointers = false; + nlassert(m_ChunksOwnsPointers); // Never set false here } void CAppDataEntry::clean() { nlassert(false); // CStorageContainer::clean(); - // if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; } + // if (m_ChunksOwnsPointers) { nlwarning("Not parsed"); return; } // Nothing to do here! } void CAppDataEntry::build(uint16 version) { nlassert(false); - // if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; } + // if (m_ChunksOwnsPointers) { nlwarning("Not parsed"); return; } // Nothing to do here! // CStorageContainer::build(version); } @@ -422,18 +422,18 @@ void CAppDataEntry::build(uint16 version) void CAppDataEntry::disown() { // CStorageContainer::disown(); - if (Chunks.size() != 2) { nlerror("Not built"); return; } // Built chunks must match the parsed data + if (m_Chunks.size() != 2) { nlerror("Not built"); return; } // Built chunks must match the parsed data m_Key = NULL; m_Value = NULL; } void CAppDataEntry::init() { - nlassert(Chunks.size() == 0); + nlassert(m_Chunks.size() == 0); m_Key = new CAppDataEntryKey(); - Chunks.push_back(TStorageObjectWithId(NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID, m_Key)); + m_Chunks.push_back(TStorageObjectWithId(NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID, m_Key)); m_Value = new CStorageRaw(); - Chunks.push_back(TStorageObjectWithId(NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID, m_Value)); + m_Chunks.push_back(TStorageObjectWithId(NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID, m_Value)); } CAppDataEntryKey *CAppDataEntry::key() diff --git a/code/nel/tools/pipeline/max/class_directory_3.cpp b/code/nel/tools/pipeline/max/class_directory_3.cpp index e64ea3550..2bf567671 100644 --- a/code/nel/tools/pipeline/max/class_directory_3.cpp +++ b/code/nel/tools/pipeline/max/class_directory_3.cpp @@ -55,8 +55,8 @@ CClassDirectory3::CClassDirectory3(CDllDirectory *dllDirectory) : m_DllDirectory // Parallel to CDllDirectory CClassDirectory3::~CClassDirectory3() { - // Delete m_ChunkCache and m_Entries when !ChunksOwnsPointers - if (!ChunksOwnsPointers) + // Delete m_ChunkCache and m_Entries when !m_ChunksOwnsPointers + if (!m_ChunksOwnsPointers) { for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it) { @@ -80,13 +80,13 @@ std::string CClassDirectory3::getClassName() // Parallel to CDllDirectory void CClassDirectory3::toString(std::ostream &ostream, const std::string &pad) { - if (ChunksOwnsPointers) + if (m_ChunksOwnsPointers) { CStorageContainer::toString(ostream, pad); } else { - ostream << "(" << getClassName() << ") [" << Chunks.size() << "] PARSED { "; + ostream << "(" << getClassName() << ") [" << m_Chunks.size() << "] PARSED { "; std::string padpad = pad + "\t"; sint i = 0; for (TStorageObjectContainer::const_iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it) @@ -136,7 +136,7 @@ void CClassDirectory3::parse(uint16 version, TParseLevel level) bool parsedDllEntry = false; // Parse chunks - for (TStorageObjectContainer::iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { uint16 id = it->first; switch (id) @@ -164,7 +164,7 @@ void CClassDirectory3::parse(uint16 version, TParseLevel level) } // Now ownership of the pointers lies in m_ChunkCache and m_Entries - ChunksOwnsPointers = false; + m_ChunksOwnsPointers = false; } } @@ -172,10 +172,10 @@ void CClassDirectory3::parse(uint16 version, TParseLevel level) void CClassDirectory3::clean() { // Ensure parsed - nlassert(!ChunksOwnsPointers); + nlassert(!m_ChunksOwnsPointers); - // Clear Chunks - Chunks.clear(); + // Clear m_Chunks + m_Chunks.clear(); // Clean chunks for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it) @@ -195,12 +195,12 @@ void CClassDirectory3::clean() void CClassDirectory3::build(uint16 version) { // Ensure parsed - nlassert(!ChunksOwnsPointers); + nlassert(!m_ChunksOwnsPointers); // Initialize - nlassert(Chunks.empty()); + nlassert(m_Chunks.empty()); - // Set up the Chunks list, when (CClassEntry::ID, NULL) is found write out all of the entries. + // Set up the m_Chunks list, when (CClassEntry::ID, NULL) is found write out all of the entries. for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it) { uint16 id = it->first; @@ -208,15 +208,15 @@ void CClassDirectory3::build(uint16 version) { case 0x2040: // ClassEntry for (std::vector::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit) - Chunks.push_back(TStorageObjectWithId(id, (*subit))); + m_Chunks.push_back(TStorageObjectWithId(id, (*subit))); break; default: - Chunks.push_back(*it); + m_Chunks.push_back(*it); break; } } - // Build the entries last (after Chunks is built) + // Build the entries last (after m_Chunks is built) CStorageContainer::build(version); // NOTE: Ownership remains with m_ChunkCache and m_Entries @@ -230,14 +230,14 @@ void CClassDirectory3::disown() m_Entries.clear(); m_ClassIdToIndex.clear(); - // Ownership goes back to Chunks - ChunksOwnsPointers = true; + // Ownership goes back to m_Chunks + m_ChunksOwnsPointers = true; } // Parallel to CDllDirectory const CClassEntry *CClassDirectory3::get(uint16 index) const { - nlassert(!ChunksOwnsPointers); + nlassert(!m_ChunksOwnsPointers); nlassert(index < m_Entries.size()); return m_Entries[index]; } @@ -245,7 +245,7 @@ const CClassEntry *CClassDirectory3::get(uint16 index) const // Parallel to CDllDirectory void CClassDirectory3::reset() { - nlassert(!ChunksOwnsPointers); + nlassert(!m_ChunksOwnsPointers); for (std::vector::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit) { delete (*subit); @@ -257,7 +257,7 @@ void CClassDirectory3::reset() // Parallel to CDllDirectory uint16 CClassDirectory3::getOrCreateIndex(const ISceneClassDesc *sceneClassDesc) { - nlassert(!ChunksOwnsPointers); + nlassert(!m_ChunksOwnsPointers); std::map::iterator it = m_ClassIdToIndex.find(sceneClassDesc->classId()); // Return existing index @@ -302,8 +302,8 @@ CClassEntry::CClassEntry() : m_Header(NULL), m_Name(NULL) CClassEntry::CClassEntry(CDllDirectory *dllDirectory, const ISceneClassDesc *sceneClassDesc) : m_Header(new CClassEntryHeader()), m_Name(new CStorageValue()) { - Chunks.push_back(TStorageObjectWithId(0x2060, m_Header)); - Chunks.push_back(TStorageObjectWithId(0x2042, m_Name)); + m_Chunks.push_back(TStorageObjectWithId(0x2060, m_Header)); + m_Chunks.push_back(TStorageObjectWithId(0x2042, m_Name)); m_Header->DllIndex = dllDirectory->getOrCreateIndex(sceneClassDesc->dllPluginDesc()); m_Header->ClassId = sceneClassDesc->classId(); m_Header->SuperClassId = sceneClassDesc->superClassId(); @@ -324,7 +324,7 @@ void CClassEntry::toString(std::ostream &ostream, const std::string &pad) { if (m_Header && m_Name) { - ostream << "(" << getClassName() << ") [" << Chunks.size() << "] PARSED { "; + ostream << "(" << getClassName() << ") [" << m_Chunks.size() << "] PARSED { "; std::string padpad = pad + "\t"; ostream << "\n" << pad << "Header: "; m_Header->toString(ostream, padpad); @@ -340,9 +340,9 @@ void CClassEntry::toString(std::ostream &ostream, const std::string &pad) void CClassEntry::parse(uint16 version, TParseLevel level) { // CStorageContainer::parse(version, level); - nlassert(ChunksOwnsPointers); - nlassert(Chunks.size() == 2); - TStorageObjectContainer::iterator it = Chunks.begin(); + nlassert(m_ChunksOwnsPointers); + nlassert(m_Chunks.size() == 2); + TStorageObjectContainer::iterator it = m_Chunks.begin(); nlassert(it->first == 0x2060); // ClassEntryHeader m_Header = static_cast(it->second); ++it; @@ -353,7 +353,7 @@ void CClassEntry::parse(uint16 version, TParseLevel level) void CClassEntry::clean() { - // Nothing to do here! (Chunks retains ownership) + // Nothing to do here! (m_Chunks retains ownership) // CStorageContainer::clean(); } @@ -368,7 +368,7 @@ void CClassEntry::disown() // CStorageContainer::disown(); m_Header = NULL; m_Name = NULL; - nlassert(ChunksOwnsPointers); + nlassert(m_ChunksOwnsPointers); } IStorageObject *CClassEntry::createChunkById(uint16 id, bool container) diff --git a/code/nel/tools/pipeline/max/dll_directory.cpp b/code/nel/tools/pipeline/max/dll_directory.cpp index ad2d799bd..a74d7ec53 100644 --- a/code/nel/tools/pipeline/max/dll_directory.cpp +++ b/code/nel/tools/pipeline/max/dll_directory.cpp @@ -54,8 +54,8 @@ CDllDirectory::CDllDirectory() : m_DllEntryBuiltin(&DllPluginDescBuiltin), m_Dll // Parallel to CClassDirectory3 CDllDirectory::~CDllDirectory() { - // Delete m_ChunkCache and m_Entries when !ChunksOwnsPointers - if (!ChunksOwnsPointers) + // Delete m_ChunkCache and m_Entries when !m_ChunksOwnsPointers + if (!m_ChunksOwnsPointers) { for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it) { @@ -78,13 +78,13 @@ std::string CDllDirectory::getClassName() // Parallel to CClassDirectory3 void CDllDirectory::toString(std::ostream &ostream, const std::string &pad) { - if (ChunksOwnsPointers) + if (m_ChunksOwnsPointers) { CStorageContainer::toString(ostream, pad); } else { - ostream << "(" << getClassName() << ") [" << Chunks.size() << "] PARSED { "; + ostream << "(" << getClassName() << ") [" << m_Chunks.size() << "] PARSED { "; std::string padpad = pad + "\t"; sint i = 0; for (TStorageObjectContainer::const_iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it) @@ -135,7 +135,7 @@ void CDllDirectory::parse(uint16 version, TParseLevel level) bool parsedDllEntry = false; // Parse chunks - for (TStorageObjectContainer::iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { uint16 id = it->first; switch (id) @@ -163,7 +163,7 @@ void CDllDirectory::parse(uint16 version, TParseLevel level) } // Now ownership of the pointers lies in m_ChunkCache and m_Entries - ChunksOwnsPointers = false; + m_ChunksOwnsPointers = false; } } @@ -171,10 +171,10 @@ void CDllDirectory::parse(uint16 version, TParseLevel level) void CDllDirectory::clean() { // Ensure parsed - nlassert(!ChunksOwnsPointers); + nlassert(!m_ChunksOwnsPointers); - // Clear Chunks - Chunks.clear(); + // Clear m_Chunks + m_Chunks.clear(); // Clean chunks for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it) @@ -194,12 +194,12 @@ void CDllDirectory::clean() void CDllDirectory::build(uint16 version) { // Ensure parsed - nlassert(!ChunksOwnsPointers); + nlassert(!m_ChunksOwnsPointers); // Initialize - nlassert(Chunks.empty()); + nlassert(m_Chunks.empty()); - // Set up the Chunks list, when (CDllEntry::ID, NULL) is found write out all of the entries. + // Set up the m_Chunks list, when (CDllEntry::ID, NULL) is found write out all of the entries. for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it) { uint16 id = it->first; @@ -207,15 +207,15 @@ void CDllDirectory::build(uint16 version) { case 0x2038: // DllEntry for (std::vector::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit) - Chunks.push_back(TStorageObjectWithId(id, (*subit))); + m_Chunks.push_back(TStorageObjectWithId(id, (*subit))); break; default: - Chunks.push_back(*it); + m_Chunks.push_back(*it); break; } } - // Build the entries last (after Chunks is built) + // Build the entries last (after m_Chunks is built) CStorageContainer::build(version); // NOTE: Ownership remains with m_ChunkCache and m_Entries @@ -229,14 +229,14 @@ void CDllDirectory::disown() m_Entries.clear(); m_InternalNameToIndex.clear(); - // Ownership goes back to Chunks - ChunksOwnsPointers = true; + // Ownership goes back to m_Chunks + m_ChunksOwnsPointers = true; } // Parallel to CClassDirectory3 const CDllEntry *CDllDirectory::get(sint32 index) const { - nlassert(!ChunksOwnsPointers); + nlassert(!m_ChunksOwnsPointers); if (index < 0) { // Handle internal dummy values @@ -262,7 +262,7 @@ const CDllEntry *CDllDirectory::get(sint32 index) const // Parallel to CClassDirectory3 void CDllDirectory::reset() { - nlassert(!ChunksOwnsPointers); + nlassert(!m_ChunksOwnsPointers); for (std::vector::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit) { delete (*subit); @@ -275,7 +275,7 @@ void CDllDirectory::reset() // Parallel to CClassDirectory3 sint32 CDllDirectory::getOrCreateIndex(const IDllPluginDescInternal *dllPluginDesc) { - nlassert(!ChunksOwnsPointers); + nlassert(!m_ChunksOwnsPointers); std::map::iterator it = m_InternalNameToIndex.find(NLMISC::toLower(ucstring(dllPluginDesc->internalName()))); // Return existing index @@ -331,8 +331,8 @@ CDllEntry::CDllEntry() : m_DllDescription(NULL), m_DllFilename(NULL) CDllEntry::CDllEntry(const IDllPluginDescInternal *dllPluginDesc) : m_DllDescription(new CStorageValue()), m_DllFilename(new CStorageValue()) { - Chunks.push_back(TStorageObjectWithId(0x2039, m_DllDescription)); - Chunks.push_back(TStorageObjectWithId(0x2037, m_DllFilename)); + m_Chunks.push_back(TStorageObjectWithId(0x2039, m_DllDescription)); + m_Chunks.push_back(TStorageObjectWithId(0x2037, m_DllFilename)); m_DllDescription->Value = dllPluginDesc->displayName(); m_DllFilename->Value = dllPluginDesc->internalName(); } @@ -351,7 +351,7 @@ void CDllEntry::toString(std::ostream &ostream, const std::string &pad) { if (m_DllDescription && m_DllFilename) { - ostream << "(" << getClassName() << ") [" << Chunks.size() << "] PARSED { "; + ostream << "(" << getClassName() << ") [" << m_Chunks.size() << "] PARSED { "; std::string padpad = pad + "\t"; ostream << "\n" << pad << "DllDescription: " << m_DllDescription->Value.toUtf8(); ostream << "\n" << pad << "DllFilename: " << m_DllFilename->Value.toUtf8(); @@ -366,9 +366,9 @@ void CDllEntry::toString(std::ostream &ostream, const std::string &pad) void CDllEntry::parse(uint16 version, TParseLevel level) { // CStorageContainer::parse(version, level); - nlassert(ChunksOwnsPointers); - nlassert(Chunks.size() == 2); - TStorageObjectContainer::iterator it = Chunks.begin(); + nlassert(m_ChunksOwnsPointers); + nlassert(m_Chunks.size() == 2); + TStorageObjectContainer::iterator it = m_Chunks.begin(); nlassert(it->first == 0x2039); // DllDescription m_DllDescription = static_cast *>(it->second); ++it; @@ -379,7 +379,7 @@ void CDllEntry::parse(uint16 version, TParseLevel level) void CDllEntry::clean() { - // Nothing to do here! (Chunks retains ownership) + // Nothing to do here! (m_Chunks retains ownership) // CStorageContainer::clean(); } @@ -394,7 +394,7 @@ void CDllEntry::disown() // CStorageContainer::disown(); m_DllDescription = NULL; m_DllFilename = NULL; - nlassert(ChunksOwnsPointers); + nlassert(m_ChunksOwnsPointers); } IStorageObject *CDllEntry::createChunkById(uint16 id, bool container) diff --git a/code/nel/tools/pipeline/max/scene.cpp b/code/nel/tools/pipeline/max/scene.cpp index 1ba4fb29e..a0b8277b2 100644 --- a/code/nel/tools/pipeline/max/scene.cpp +++ b/code/nel/tools/pipeline/max/scene.cpp @@ -73,7 +73,7 @@ void CScene::toString(std::ostream &ostream, const std::string &pad) void CScene::parse(uint16 version, TParseLevel level) { CStorageContainer::parse(version, level); - nlassert(Chunks.size() == 1); + nlassert(m_Chunks.size() == 1); } void CScene::clean() @@ -83,7 +83,7 @@ void CScene::clean() void CScene::build(uint16 version) { - nlassert(Chunks.size() == 1); + nlassert(m_Chunks.size() == 1); CStorageContainer::build(this->version()); } @@ -94,14 +94,14 @@ void CScene::disown() uint16 CScene::version() { - nlassert(Chunks.size() == 1); - return Chunks.begin()->first; + nlassert(m_Chunks.size() == 1); + return m_Chunks.begin()->first; } CSceneClassContainer *CScene::container() { - nlassert(Chunks.size() == 1); - return static_cast(Chunks.begin()->second); + nlassert(m_Chunks.size() == 1); + return static_cast(m_Chunks.begin()->second); } IStorageObject *CScene::createChunkById(uint16 id, bool container) diff --git a/code/nel/tools/pipeline/max/scene_class_unknown.cpp b/code/nel/tools/pipeline/max/scene_class_unknown.cpp index c3c5e1362..36cfdcd4c 100644 --- a/code/nel/tools/pipeline/max/scene_class_unknown.cpp +++ b/code/nel/tools/pipeline/max/scene_class_unknown.cpp @@ -121,11 +121,11 @@ CSceneClassUnknown::~CSceneClassUnknown() void CSceneClassUnknown::toString(std::ostream &ostream, const std::string &pad) { - nlassert(ChunksOwnsPointers); - ostream << "(" << getClassName() << ": " << ucstring(getClassDesc()->displayName()).toUtf8() << ", " << getClassDesc()->classId().toString() << ", " << ucstring(getClassDesc()->dllPluginDesc()->internalName()).toUtf8() << ") [" << Chunks.size() << "] { "; + nlassert(m_ChunksOwnsPointers); + ostream << "(" << getClassName() << ": " << ucstring(getClassDesc()->displayName()).toUtf8() << ", " << getClassDesc()->classId().toString() << ", " << ucstring(getClassDesc()->dllPluginDesc()->internalName()).toUtf8() << ") [" << m_Chunks.size() << "] { "; std::string padpad = pad + "\t"; sint i = 0; - for (TStorageObjectContainer::const_iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { std::stringstream ss; ss << std::hex << std::setfill('0'); diff --git a/code/nel/tools/pipeline/max/storage_object.cpp b/code/nel/tools/pipeline/max/storage_object.cpp index bb97c65cd..4c30a709c 100644 --- a/code/nel/tools/pipeline/max/storage_object.cpp +++ b/code/nel/tools/pipeline/max/storage_object.cpp @@ -86,21 +86,21 @@ bool IStorageObject::isContainer() const //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -CStorageContainer::CStorageContainer() : ChunksOwnsPointers(true) +CStorageContainer::CStorageContainer() : m_ChunksOwnsPointers(true) { } CStorageContainer::~CStorageContainer() { - if (ChunksOwnsPointers) + if (m_ChunksOwnsPointers) { - for (TStorageObjectContainer::iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { delete it->second; } } - Chunks.clear(); + m_Chunks.clear(); } std::string CStorageContainer::getClassName() // why is this not const in IClassable? @@ -112,8 +112,8 @@ void CStorageContainer::serial(NLMISC::IStream &stream) { if (stream.isReading()) { - nlassert(ChunksOwnsPointers); - nlassert(Chunks.empty()); + nlassert(m_ChunksOwnsPointers); + nlassert(m_Chunks.empty()); } if (stream.getPos() == 0) { @@ -178,11 +178,11 @@ void CStorageContainer::toString(std::ostream &ostream, const std::string &pad) // Blahblah: (Container) { // Moo: (Foo) "What" } // only increase pad when multi-lining sub-items - nlassert(ChunksOwnsPointers); - ostream << "(" << getClassName() << ") [" << Chunks.size() << "] { "; + nlassert(m_ChunksOwnsPointers); + ostream << "(" << getClassName() << ") [" << m_Chunks.size() << "] { "; std::string padpad = pad + "\t"; sint i = 0; - for (TStorageObjectContainer::const_iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { std::stringstream ss; ss << std::hex << std::setfill('0'); @@ -196,7 +196,7 @@ void CStorageContainer::toString(std::ostream &ostream, const std::string &pad) void CStorageContainer::parse(uint16 version, TParseLevel level) { - for (TStorageObjectContainer::const_iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { if (it->second->isContainer()) { @@ -207,8 +207,8 @@ void CStorageContainer::parse(uint16 version, TParseLevel level) void CStorageContainer::clean() { - nlassert(ChunksOwnsPointers); // Can only use the default when Chunks retains ownership. - for (TStorageObjectContainer::const_iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + nlassert(m_ChunksOwnsPointers); // Can only use the default when m_Chunks retains ownership. + for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { if (it->second->isContainer()) { @@ -219,7 +219,7 @@ void CStorageContainer::clean() void CStorageContainer::build(uint16 version) { - for (TStorageObjectContainer::const_iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { if (it->second->isContainer()) { @@ -230,7 +230,7 @@ void CStorageContainer::build(uint16 version) void CStorageContainer::disown() { - for (TStorageObjectContainer::const_iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { if (it->second->isContainer()) { @@ -251,8 +251,8 @@ void CStorageContainer::serial(CStorageChunks &chunks) #ifdef NL_DEBUG_STORAGE nldebug("Reading container chunk"); #endif - nlassert(ChunksOwnsPointers); - nlassert(Chunks.empty()); + nlassert(m_ChunksOwnsPointers); + nlassert(m_Chunks.empty()); while (chunks.enterChunk()) { uint16 id = chunks.getChunkId(); @@ -261,10 +261,10 @@ void CStorageContainer::serial(CStorageChunks &chunks) storageObject->setSize(chunks.getChunkSize()); if (storageObject->isContainer()) static_cast(storageObject)->serial(chunks); else storageObject->serial(chunks.stream()); - Chunks.push_back(TStorageObjectWithId(id, storageObject)); + m_Chunks.push_back(TStorageObjectWithId(id, storageObject)); if (chunks.leaveChunk()) // bytes were skipped while reading throw EStorage(); - /*TStorageObjectContainer::iterator soit = Chunks.end(); + /*TStorageObjectContainer::iterator soit = m_Chunks.end(); --soit; serialized(soit, cont);*/ } @@ -274,7 +274,7 @@ void CStorageContainer::serial(CStorageChunks &chunks) #ifdef NL_DEBUG_STORAGE nldebug("Writing container chunk"); #endif - for (TStorageObjectContainer::iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) { chunks.enterChunk(it->first, it->second->isContainer()); IStorageObject *storageObject = it->second; diff --git a/code/nel/tools/pipeline/max/storage_object.h b/code/nel/tools/pipeline/max/storage_object.h index e14b886c4..344b93b48 100644 --- a/code/nel/tools/pipeline/max/storage_object.h +++ b/code/nel/tools/pipeline/max/storage_object.h @@ -92,11 +92,12 @@ public: typedef std::pair TStorageObjectWithId; typedef std::list TStorageObjectContainer; typedef TStorageObjectContainer::iterator TStorageObjectIterator; - TStorageObjectContainer Chunks; + typedef TStorageObjectContainer::const_iterator TStorageObjectConstIt; protected: // protected data - bool ChunksOwnsPointers; + TStorageObjectContainer m_Chunks; + bool m_ChunksOwnsPointers; public: CStorageContainer(); @@ -114,9 +115,13 @@ public: virtual void clean(); // Build the storage structure needed to store the parsed data back virtual void build(uint16 version); - // Give ownership of the chunks back to the Chunks, must call build first, call instead of clean, reduces the parse level back to 0 + // Give ownership of the chunks back to the m_Chunks, must call build first, call instead of clean, reduces the parse level back to 0 virtual void disown(); +public: + // read access + inline const TStorageObjectContainer &chunks() const { return m_Chunks; } + public: // should be protected but that doesn't compile, nice c++! // inherited virtual bool isContainer() const; @@ -126,6 +131,7 @@ protected: virtual void serial(CStorageChunks &chunks); // Create a storage object by id, override to provide custom serialization virtual IStorageObject *createChunkById(uint16 id, bool container); + }; // CStorageRaw : serializes raw data, use for unknown data @@ -150,33 +156,8 @@ public: // should be protected but that doesn't compile, nice c++! virtual void setSize(sint32 size); // Gets the size when writing, return false if unknown virtual bool getSize(sint32 &size) const; -}; -/* -// CStorageUCString : serializes an ucstring chunk -class CStorageUCString : public ucstring, public IStorageObject -{ -public: - virtual void serial(CStorageStream *stream); - virtual void dump(const std::string &pad); -}; -// CStorageString : serializes a string chunk -class CStorageString : public std::string, public IStorageObject -{ -public: - virtual void serial(CStorageStream *stream); - virtual void dump(const std::string &pad); -}; - -template -class CStorageValue : public IStorageObject -{ -public: - T Value; - virtual void serial(CStorageStream *stream); - virtual void dump(const std::string &pad); }; -*/ } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index 1ab6a3b05..a368c395a 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -172,10 +172,10 @@ int main(int argc, char **argv) #define NEL3D_APPDATA_ENV_FX (84682543) PIPELINE::MAX::CSceneClassContainer *ssc = scene.container(); - for (PIPELINE::MAX::CStorageContainer::TStorageObjectIterator it = ssc->Chunks.begin(), end = ssc->Chunks.end(); it != end; ++it) + for (PIPELINE::MAX::CStorageContainer::TStorageObjectConstIt it = ssc->chunks().begin(), end = ssc->chunks().end(); it != end; ++it) { PIPELINE::MAX::CStorageContainer *subc = static_cast(it->second); - for (PIPELINE::MAX::CStorageContainer::TStorageObjectIterator subit = subc->Chunks.begin(), subend = subc->Chunks.end(); subit != subend; ++subit) + for (PIPELINE::MAX::CStorageContainer::TStorageObjectConstIt subit = subc->chunks().begin(), subend = subc->chunks().end(); subit != subend; ++subit) { PIPELINE::MAX::IStorageObject *storageChunk = subit->second; PIPELINE::MAX::CAppData *appData = dynamic_cast(storageChunk);