mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-09-11 11:15:12 -04:00
b7961b7739
- Fix <string> -> <cstring> across all source files (upstream fix) - Add <cstring> to JASGadget.h, <cstdarg> to JUTDbPrint.cpp - Fix <string> -> <cstring> in JUTFont.h, d_save.h, f_ap_game.h - Fix std::isnan usage in c_cc_d.cpp - Fix cCcD_Src types: s32 -> u32 for bitmask fields (upstream fix) - Fix AT_TYPE_WOLF_ATTACK/AT_TYPE_UNK unsigned literals (upstream fix) - Remove (s32) casts on hex literals in collision data (upstream fix) - Fix 0xFFFFFFFF literal in d_a_obj_wood_statue.cpp (upstream fix) - Add braces to case 0 in d_a_e_gb.cpp to fix jump-over-init - Fix Z2AudioCS.h include path (Z2AudioLib -> Z2AudioCS) - Forward-declare Z2AudioCS in stubs.cpp to avoid revolution conflicts - Guard JASGlobalInstance specializations with __MWERKS__ in m_Do_main - Remove duplicate inline functions from d_com_inf_game.h - Mark dummy() functions as static (upstream fix) - Add JAUSectionHeap.h include to m_Do_main.cpp
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;
|
|
}
|