Files
tp/src/JSystem/JParticle/JPAResourceManager.cpp
T
Luke Street b5d3b8c059 Another round of GCC fixes (#3115)
* 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.
2026-02-28 13:35:07 -08:00

75 lines
1.9 KiB
C++

#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JParticle/JPAResourceManager.h"
#include "JSystem/JParticle/JPADynamicsBlock.h"
#include "JSystem/JParticle/JPAResource.h"
#include <cstring>
struct JPAResourceLoader {
JPAResourceLoader(u8 const*, JPAResourceManager*);
};
JPAResourceManager::JPAResourceManager(void const* p_jpc, JKRHeap* pHeap) {
pResAry = NULL;
pTexAry = NULL;
resMaxNum = 0;
resRegNum = 0;
texMaxNum = 0;
texRegNum = 0;
mpHeap = pHeap;
JUT_ASSERT(49, (p_jpc != 0) && (pHeap != 0));
JPAResourceLoader loader((u8 const*)p_jpc, this);
}
JPAResource* JPAResourceManager::getResource(u16 usrIdx) const {
for (u16 i = 0; i < resRegNum; i++)
if (pResAry[i]->getUsrIdx() == usrIdx)
return pResAry[i];
return NULL;
}
bool JPAResourceManager::checkUserIndexDuplication(u16 usrIdx) const {
for (s32 i = 0; i < resRegNum; i++)
if (pResAry[i]->getUsrIdx() == usrIdx)
return true;
return false;
}
const ResTIMG* JPAResourceManager::swapTexture(ResTIMG const* img, char const* swapName) {
const ResTIMG* ret = NULL;
JUTTexture* tex = NULL;
for (s32 i = 0; i < texRegNum; i++) {
if (strcmp(swapName, pTexAry[i]->getName()) == 0) {
tex = pTexAry[i]->getJUTTexture();
ret = tex->getTexInfo();
tex->storeTIMG(img, (u8)0);
break;
}
}
return ret;
}
void JPAResourceManager::registRes(JPAResource* res) {
JUT_ASSERT(151, resRegNum < resMaxNum);
pResAry[resRegNum] = res;
resRegNum++;
}
void JPAResourceManager::registTex(JPATexture* tex) {
JUT_ASSERT(166, texRegNum < texMaxNum);
pTexAry[texRegNum] = tex;
texRegNum++;
}
u32 JPAResourceManager::getResUserWork(u16 usrIdx) const {
u32 ret = 0;
JPAResource* res = getResource(usrIdx);
if (res != NULL)
ret = res->getDyn()->getResUserWork();
return ret;
}