mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-10 21:00:55 -04:00
38b7156a8e
* Fix remaining <string> -> <cstring> for GCC compilation (#3114 follow-up) MWerks' <string> header transitively includes C string functions (memcpy, strlen, strcmp, etc.), but GCC/Clang's <string> is the C++ std::string header. These files all use C string functions and should include <cstring> instead. * Use std::isnan instead of isnan for GCC compilation GCC's <cmath> places isnan in the std namespace. Using the unqualified isnan fails to compile with GCC/Clang. * Fix cCcD_Src types: s32 -> u32 for bitmask fields cCcD_SrcObjCommonBase::mSPrm, cCcD_SrcObjTg::mType, and cCcD_SrcObjAt::mType are used as bitmasks (SetType/SetSPrm take u32, MskType/MskSPrm use u32, values like 0xFFFFFFFF are common in aggregate inits). Change from s32 to u32 to match usage. Also fix AT_TYPE_WOLF_ATTACK/AT_TYPE_UNK to use unsigned literals, and remove now-unnecessary (s32) casts on hex literals in collision source data. * Mark dummy() functions as static to avoid multiple definition errors These decomp artifact functions have the same name and signature across TUs, causing linker errors when building as a single binary.
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
|
|
|
#include "JSystem/JUtility/JUTResource.h"
|
|
#include "JSystem/JKernel/JKRArchive.h"
|
|
#include "JSystem/JSupport/JSUInputStream.h"
|
|
#include <cstring>
|
|
|
|
void* JUTResReference::getResource(JSUInputStream* stream, u32 resType, JKRArchive* archive) {
|
|
stream->read(mType);
|
|
stream->read(mNameLength);
|
|
stream->read(&mName, mNameLength);
|
|
|
|
if (mType == RESTYPE_Unk2 || mType == RESTYPE_Unk3 || mType == RESTYPE_Unk4) {
|
|
mName[mNameLength] = 0;
|
|
}
|
|
|
|
return getResource(resType, archive);
|
|
}
|
|
|
|
|
|
void* JUTResReference::getResource(const void* data, u32 resType, JKRArchive* archive) {
|
|
const u8* pData = (const u8*)data;
|
|
mType = pData[0];
|
|
mNameLength = pData[1];
|
|
|
|
if (mNameLength != 0) {
|
|
memcpy(&mName, &pData[2], mNameLength);
|
|
}
|
|
|
|
if (mType == RESTYPE_Unk2 || mType == RESTYPE_Unk3 || mType == RESTYPE_Unk4) {
|
|
mName[mNameLength] = 0;
|
|
}
|
|
|
|
return getResource(resType, archive);
|
|
}
|
|
|
|
void* JUTResReference::getResource(u32 resType, JKRArchive* archive) {
|
|
void* res = NULL;
|
|
switch (mType) {
|
|
case RESTYPE_Unk1:
|
|
break;
|
|
case RESTYPE_Unk2:
|
|
res = JKRGetTypeResource(resType, mName, archive);
|
|
break;
|
|
case RESTYPE_Unk3:
|
|
res = JKRGetNameResource(mName, archive);
|
|
break;
|
|
case RESTYPE_Unk4:
|
|
res = JKRGetResource(mName);
|
|
break;
|
|
}
|
|
|
|
return res;
|
|
}
|