-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResourceLib] Fix ZHMArena::GetType when RL is used from a game
- Loading branch information
Showing
2 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,53 @@ | ||
#include "ZHMArenas.h" | ||
#include "ZHMTypeInfo.h" | ||
|
||
ZHMArena ZHMArenas::g_Arenas[ZHMArenaCount]; | ||
ZHMArenas::ZHMArenaInitializer ZHMArenas::g_ArenaInitializer; | ||
|
||
IZHMTypeInfo* ZHMArena::GetType(zhmptr_t p_Index) const { | ||
// Real game pointer. | ||
if (m_Id == 0) { | ||
struct STypeFunctions; | ||
class STypeID; | ||
class ZString; | ||
|
||
class IType { | ||
public: | ||
STypeFunctions* m_pTypeFunctions; | ||
uint16_t m_nTypeSize; | ||
uint16_t m_nTypeAlignment; | ||
uint16_t m_nTypeInfoFlags; | ||
char* m_pTypeName; | ||
STypeID* m_pTypeID; | ||
bool (*fromString)(void*, IType*, const ZString&); | ||
uint32_t(*toString)(void*, IType*, char*, uint32_t, const ZString&); | ||
}; | ||
|
||
class STypeID { | ||
public: | ||
inline IType* typeInfo() const | ||
{ | ||
if (m_nFlags == 1 || (!m_pType && m_pSource)) | ||
return m_pSource->m_pType; | ||
|
||
return m_pType; | ||
} | ||
|
||
public: | ||
uint16_t m_nFlags; | ||
uint16_t m_nTypeNum; | ||
IType* m_pType; | ||
STypeID* m_pSource; | ||
}; | ||
|
||
|
||
auto s_TypeId = reinterpret_cast<STypeID*>(p_Index); | ||
|
||
if (s_TypeId == nullptr || s_TypeId->typeInfo() == nullptr || s_TypeId->typeInfo()->m_pTypeName == nullptr) | ||
return nullptr; | ||
|
||
return ZHMTypeInfo::GetTypeByName(std::string(s_TypeId->typeInfo()->m_pTypeName)); | ||
} | ||
|
||
return m_TypeRegistry[p_Index]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters