2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 18:24:55 +00:00

Initial CModel implementation

This commit is contained in:
Jack Andersen
2016-03-29 13:14:14 -10:00
parent 2e028d9049
commit 6b1c435d0c
7 changed files with 243 additions and 16 deletions

View File

@@ -14,22 +14,53 @@ CFactoryFnReturn CFactoryMgr::MakeObject(const SObjectTag& tag, urde::CInputStre
return search->second(tag, in, paramXfer);
}
CFactoryFnReturn CFactoryMgr::MakeObjectFromMemory(const SObjectTag& tag, void* buf, int size,
bool CFactoryMgr::CanMakeMemory(const urde::SObjectTag& tag) const
{
auto search = m_memFactories.find(tag.type);
return search != m_memFactories.cend();
}
CFactoryFnReturn CFactoryMgr::MakeObjectFromMemory(const SObjectTag& tag, std::unique_ptr<u8[]>&& buf, int size,
bool compressed, const CVParamTransfer& paramXfer)
{
auto search = m_factories.find(tag.type);
if (search == m_factories.end())
return {};
std::unique_ptr<u8[]> localBuf = std::move(buf);
if (compressed)
auto search = m_memFactories.find(tag.type);
if (search != m_memFactories.cend())
{
CZipInputStream r(std::make_unique<athena::io::MemoryReader>(buf, size));
return search->second(tag, r, paramXfer);
if (compressed)
{
std::unique_ptr<CInputStream> compRead =
std::make_unique<athena::io::MemoryReader>(localBuf.get(), size);
u32 decompLen = compRead->readUint32Big();
CZipInputStream r(std::move(compRead));
std::unique_ptr<u8[]> decompBuf = r.readUBytes(decompLen);
return search->second(tag, std::move(decompBuf), decompLen, paramXfer);
}
else
{
return search->second(tag, std::move(localBuf), size, paramXfer);
}
}
else
{
CMemoryInStream r(buf, size);
return search->second(tag, r, paramXfer);
auto search = m_factories.find(tag.type);
if (search == m_factories.end())
return {};
if (compressed)
{
std::unique_ptr<CInputStream> compRead =
std::make_unique<athena::io::MemoryReader>(localBuf.get(), size);
u32 decompLen = compRead->readUint32Big();
CZipInputStream r(std::move(compRead));
return search->second(tag, r, paramXfer);
}
else
{
CMemoryInStream r(localBuf.get(), size);
return search->second(tag, r, paramXfer);
}
}
}