mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-08 20:24:47 -04:00
process class inheritance vtable fix
This commit is contained in:
@@ -240,8 +240,14 @@ struct cull_box {
|
||||
/* 0xC */ Vec max;
|
||||
};
|
||||
|
||||
#if __MWERKS__
|
||||
class fopAc_ac_c {
|
||||
public:
|
||||
/* 0x000 */ leafdraw_class base;
|
||||
#else
|
||||
class fopAc_ac_c : public leafdraw_class {
|
||||
public:
|
||||
#endif
|
||||
/* 0x0C0 */ int actor_type;
|
||||
/* 0x0C4 */ create_tag_class actor_tag;
|
||||
/* 0x0D8 */ create_tag_class draw_tag;
|
||||
@@ -284,8 +290,16 @@ public:
|
||||
/* 0x566 */ s8 field_0x566;
|
||||
/* 0x567 */ s8 field_0x567;
|
||||
|
||||
#if !__MWERKS__
|
||||
s8 actor_last_base_field;
|
||||
#endif
|
||||
|
||||
fopAc_ac_c();
|
||||
#if !__MWERKS__
|
||||
~fopAc_ac_c() override;
|
||||
#else
|
||||
~fopAc_ac_c();
|
||||
#endif
|
||||
|
||||
static u32 getStopStatus() { return stopStatus; }
|
||||
static void setStopStatus(u32 status) { stopStatus = status; }
|
||||
|
||||
@@ -17,20 +17,25 @@
|
||||
// Modern compilers will zero the parent struct in default constructors.
|
||||
// So instead of adding default constructors to everything,
|
||||
// we'll just save & restore that data.
|
||||
#define fopAcM_ct_placement_copy_length offsetof(fopAc_ac_c, actor_last_base_field) - offsetof(fopAc_ac_c, type)
|
||||
|
||||
#define fopAcM_ct_placement(ptr, ClassName) \
|
||||
fopAc_ac_c copy; \
|
||||
memcpy(©, &(ptr)->base, sizeof(fopAc_ac_c)); \
|
||||
memcpy(©.type, &(ptr)->type, fopAcM_ct_placement_copy_length); \
|
||||
new (ptr) ClassName() ; \
|
||||
memcpy(&(ptr)->base, ©, sizeof(fopAc_ac_c));
|
||||
memcpy(&(ptr)->type, ©.type, fopAcM_ct_placement_copy_length);
|
||||
#else
|
||||
#define fopAcM_ct_placement(ptr, ClassName) new (ptr) ClassName()
|
||||
#endif
|
||||
|
||||
#define fopAcM_ct(ptr, ClassName) \
|
||||
if ((ptr)->layer_tag.layer == NULL) { OSPanic(__FILE__, __LINE__, "UH OH"); } \
|
||||
if (!fopAcM_CheckCondition(ptr, fopAcCnd_INIT_e)) { \
|
||||
fopAcM_ct_placement(ptr, ClassName); \
|
||||
fopAcM_OnCondition(ptr, fopAcCnd_INIT_e); \
|
||||
}
|
||||
} \
|
||||
if ((ptr)->layer_tag.layer == NULL) { OSPanic(__FILE__, __LINE__, "Oh come on"); }
|
||||
|
||||
|
||||
#define fopAcM_RegisterDeleteID(i_this, actor_name_str) \
|
||||
("Delete -> " actor_name_str "(id=%d)\n", fopAcM_GetID(i_this))
|
||||
|
||||
@@ -20,7 +20,7 @@ typedef struct state_class {
|
||||
} state_class;
|
||||
|
||||
typedef struct base_process_class {
|
||||
/* 0x00 */ int type;
|
||||
/* 0x00 */ int type; // DUSK NOTE: fopAcM_ct_placement relies on this being the *very* first field!
|
||||
/* 0x04 */ fpc_ProcID id;
|
||||
/* 0x08 */ s16 name;
|
||||
/* 0x0A */ s8 unk_0xA;
|
||||
@@ -37,6 +37,14 @@ typedef struct base_process_class {
|
||||
/* 0xAC */ void* append;
|
||||
/* 0xB0 */ u32 parameters;
|
||||
/* 0xB4 */ int subtype;
|
||||
#if !__MWERKS__
|
||||
// MSVC places vtables at the start of a class, *even* if that class inherits from something
|
||||
// without vtable. This breaks everything.
|
||||
// TO avoid issues with pointer casting, we make base_process_class also have a vtable and
|
||||
// ensure we're using inheritance on it.
|
||||
|
||||
virtual ~base_process_class();
|
||||
#endif
|
||||
} base_process_class; // Size: 0xB8
|
||||
|
||||
BOOL fpcBs_Is_JustOfType(int i_typeA, int i_typeB);
|
||||
|
||||
@@ -13,8 +13,16 @@ typedef struct leafdraw_method_class {
|
||||
/* 0x10 */ process_method_func draw_method;
|
||||
} leafdraw_method_class;
|
||||
|
||||
#if __MWERKS__
|
||||
#define LEAFDRAW_BASE(val) (val)->base
|
||||
|
||||
typedef struct leafdraw_class {
|
||||
/* 0x00 */ base_process_class base;
|
||||
#else
|
||||
#define LEAFDRAW_BASE(val) (*(base_process_class*)val)
|
||||
|
||||
typedef struct leafdraw_class : base_process_class {
|
||||
#endif
|
||||
/* 0xB8 */ leafdraw_method_class* leaf_methods;
|
||||
/* 0xBC */ s8 unk_0xBC;
|
||||
/* 0xBD */ u8 unk_0xBD;
|
||||
|
||||
Reference in New Issue
Block a user