mirror of
https://github.com/zeldaret/tp
synced 2026-07-05 21:49:11 -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.
90 lines
1.6 KiB
C++
90 lines
1.6 KiB
C++
#ifndef JASGADGET_H
|
|
#define JASGADGET_H
|
|
|
|
#include "JSystem/JUtility/JUTAssert.h"
|
|
#include <cstring>
|
|
|
|
#ifdef __MWERKS__
|
|
#define JAS_GLOBAL_INSTANCE_INIT
|
|
#else
|
|
#define JAS_GLOBAL_INSTANCE_INIT {}
|
|
#endif
|
|
|
|
/**
|
|
* @ingroup jsystem-jaudio
|
|
*
|
|
*/
|
|
template<class T>
|
|
class JASGlobalInstance {
|
|
public:
|
|
JASGlobalInstance(T* inst) {
|
|
sInstance = inst;
|
|
}
|
|
|
|
JASGlobalInstance(bool setInstance) {
|
|
if (setInstance) {
|
|
JUT_ASSERT(186, sInstance == NULL);
|
|
sInstance = (T*)this;
|
|
}
|
|
}
|
|
|
|
~JASGlobalInstance() {
|
|
if (sInstance == (T*)this) {
|
|
sInstance = NULL;
|
|
}
|
|
}
|
|
|
|
static T* getInstance() { return sInstance; }
|
|
|
|
static T* sInstance;
|
|
};
|
|
|
|
/**
|
|
* @ingroup jsystem-jaudio
|
|
*
|
|
*/
|
|
template<class T>
|
|
class JASPtrTable {
|
|
public:
|
|
JASPtrTable(T** param_0, u32 size) {
|
|
mTable = param_0;
|
|
mSize = size;
|
|
memset(mTable, 0, size * 4);
|
|
}
|
|
T* get(u32 index) {
|
|
if (index >= mSize) {
|
|
return NULL;
|
|
}
|
|
return mTable[index];
|
|
}
|
|
T* get(u32 index) const {
|
|
if (index >= mSize) {
|
|
return NULL;
|
|
}
|
|
return mTable[index];
|
|
}
|
|
void set(u32 index, T* value) {
|
|
JUT_ASSERT(229, index < mSize);
|
|
mTable[index] = value;
|
|
}
|
|
|
|
private:
|
|
/* 0x00 */ T** mTable;
|
|
/* 0x04 */ u32 mSize;
|
|
};
|
|
|
|
/**
|
|
* @ingroup jsystem-jaudio
|
|
*
|
|
*/
|
|
template<class T, size_t N>
|
|
class JASPtrArray : public JASPtrTable<T> {
|
|
public:
|
|
JASPtrArray() : JASPtrTable<T>(mArray, N) {}
|
|
|
|
private:
|
|
/* 0x08 */ T* mArray[N];
|
|
};
|
|
|
|
#endif /* JASGADGET_H */
|