mirror of
https://github.com/zeldaret/tp
synced 2026-05-23 15:01:53 -04:00
b5d3b8c059
* 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.
58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
|
|
|
#include "JSystem/JUtility/JUTNameTab.h"
|
|
#include <cstring>
|
|
|
|
JUTNameTab::JUTNameTab() {
|
|
setResource(NULL);
|
|
}
|
|
|
|
JUTNameTab::JUTNameTab(const ResNTAB* pNameTable) {
|
|
setResource(pNameTable);
|
|
}
|
|
|
|
void JUTNameTab::setResource(const ResNTAB* pNameTable) {
|
|
mNameTable = pNameTable;
|
|
|
|
if (pNameTable != NULL) {
|
|
mNameNum = pNameTable->mEntryNum;
|
|
mpStrData = (const char*)(pNameTable->mEntries + mNameNum);
|
|
} else {
|
|
mNameNum = 0;
|
|
mpStrData = 0;
|
|
}
|
|
}
|
|
|
|
s32 JUTNameTab::getIndex(const char* pName) const {
|
|
JUT_ASSERT(101, mNameTable != NULL);
|
|
|
|
const ResNTAB::Entry* pEntry = mNameTable->mEntries;
|
|
u16 keyCode = calcKeyCode(pName);
|
|
|
|
for (u16 i = 0; i < mNameNum; i++) {
|
|
if (
|
|
pEntry->mKeyCode == keyCode &&
|
|
strcmp((mNameTable->mEntries[i].mOffs + ((const char*)mNameTable)), pName) == 0
|
|
) {
|
|
return i;
|
|
}
|
|
pEntry++;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
const char* JUTNameTab::getName(u16 index) const {
|
|
JUT_ASSERT(138, mNameTable != NULL);
|
|
if (index < mNameNum)
|
|
return ((const char*)mNameTable) + mNameTable->mEntries[index].mOffs;
|
|
return NULL;
|
|
}
|
|
|
|
u16 JUTNameTab::calcKeyCode(const char* pName) const {
|
|
u32 keyCode = 0;
|
|
while (*pName)
|
|
keyCode = (keyCode * 3) + *pName++;
|
|
return keyCode;
|
|
}
|