diff options
Diffstat (limited to '')
-rw-r--r-- | src/modelinfo/BaseModelInfo.cpp | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/src/modelinfo/BaseModelInfo.cpp b/src/modelinfo/BaseModelInfo.cpp index fd13dfb5..7cb72009 100644 --- a/src/modelinfo/BaseModelInfo.cpp +++ b/src/modelinfo/BaseModelInfo.cpp @@ -7,6 +7,10 @@ #include "BaseModelInfo.h" #include "ModelInfo.h" #include "KeyGen.h" +#include "Streaming.h" +#include "smallHeap.h" + +// LCS: file done except for TODO CBaseModelInfo::CBaseModelInfo(ModelInfoType type) { @@ -18,7 +22,11 @@ CBaseModelInfo::CBaseModelInfo(ModelInfoType type) m_type = type; m_num2dEffects = 0; m_bOwnsColModel = false; + m_nameKey = 0; + m_unk1 = 0; + m_unk2 = 0; m_name = new char[MAX_MODEL_NAME]; + *(int32*)m_name = 0; } void @@ -26,6 +34,7 @@ CBaseModelInfo::Shutdown(void) { DeleteCollisionModel(); DeleteRwObject(); + DeleteChunk(); m_2dEffectsID = -1; m_num2dEffects = 0; m_txdSlot = -1; @@ -34,11 +43,11 @@ CBaseModelInfo::Shutdown(void) void CBaseModelInfo::DeleteCollisionModel(void) { - if(m_colModel && m_bOwnsColModel){ + if(!gUseChunkFiles && m_colModel && m_bOwnsColModel){ if(m_colModel) delete m_colModel; - m_colModel = nil; } + m_colModel = nil; } void @@ -51,15 +60,17 @@ CBaseModelInfo::AddRef(void) void CBaseModelInfo::RemoveRef(void) { - m_refCount--; - RemoveTexDictionaryRef(); + if(m_refCount > 0){ + m_refCount--; + RemoveTexDictionaryRef(); + } } void CBaseModelInfo::SetTexDictionary(const char *name) { int slot = CTxdStore::FindTxdSlot(name); - if(slot < 0) + if(slot == -1) slot = CTxdStore::AddTxdSlot(name); m_txdSlot = slot; } @@ -71,12 +82,24 @@ CBaseModelInfo::AddTexDictionaryRef(void) } void +CBaseModelInfo::AddTexDictionaryRefGu(void) +{ + CTxdStore::AddRefGu(m_txdSlot); +} + +void CBaseModelInfo::RemoveTexDictionaryRef(void) { CTxdStore::RemoveRef(m_txdSlot); } void +CBaseModelInfo::RemoveTexDictionaryRefGu(void) +{ + CTxdStore::RemoveRefGu(m_txdSlot); +} + +void CBaseModelInfo::Init2dEffects(void) { m_2dEffectsID = -1; @@ -110,4 +133,25 @@ CBaseModelInfo::SetModelName(const char *name) m_nameKey = CKeyGen::GetUppercaseKey(name); if (!gUseChunkFiles) strcpy(m_name, name); -}
\ No newline at end of file +} + +void +CBaseModelInfo::DeleteChunk(void) +{ + // BUG? what if we're not using chunks? + if(m_chunk){ + CStreaming::UnregisterPointer(&m_chunk, 2); + cSmallHeap::msInstance.Free(m_chunk); + m_chunk = nil; + } +} + +void +CBaseModelInfo::Write(base::cRelocatableChunkWriter &writer) +{ + m_chunk = nil; + RcWriteThis(writer); + if(m_colModel){ + assert(0 && "TODO"); + } +} |