From 4a828fa91e4cf0594f14b48cc769f3334f3760f7 Mon Sep 17 00:00:00 2001 From: Will Date: Tue, 20 Feb 2024 12:02:20 -0500 Subject: [PATCH] RObj work (#1276) * Change JObjRefThis to appropriate call of iref_INC which does a null check itself * Fix match of HSD_RObjResolveRefs * Match HSD_RObjSetConstraintObj --- src/sysdolphin/baselib/jobj.h | 4 +--- src/sysdolphin/baselib/object.h | 6 ++++-- src/sysdolphin/baselib/robj.c | 12 +++++------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/sysdolphin/baselib/jobj.h b/src/sysdolphin/baselib/jobj.h index 68c07a2c36..107bffee6c 100644 --- a/src/sysdolphin/baselib/jobj.h +++ b/src/sysdolphin/baselib/jobj.h @@ -468,9 +468,7 @@ static inline void HSD_JObjRef(HSD_JObj* jobj) static inline void HSD_JObjRefThis(HSD_JObj* jobj) { - if (jobj != NULL) { - iref_INC(jobj); - } + iref_INC(jobj); } void HSD_JObjResolveRefs(HSD_JObj* jobj, HSD_Joint* joint); diff --git a/src/sysdolphin/baselib/object.h b/src/sysdolphin/baselib/object.h index 2ebdf14965..811fb92316 100644 --- a/src/sysdolphin/baselib/object.h +++ b/src/sysdolphin/baselib/object.h @@ -115,8 +115,10 @@ static inline void ref_INC(void* o) static inline void iref_INC(void* o) { - HSD_OBJ(o)->ref_count_individual++; - HSD_ASSERT(158, HSD_OBJ(o)->ref_count_individual != 0); + if (o != NULL) { + HSD_OBJ(o)->ref_count_individual++; + HSD_ASSERT(158, HSD_OBJ(o)->ref_count_individual != 0); + } } #endif diff --git a/src/sysdolphin/baselib/robj.c b/src/sysdolphin/baselib/robj.c index d4cc65b70c..006e831a5a 100644 --- a/src/sysdolphin/baselib/robj.c +++ b/src/sysdolphin/baselib/robj.c @@ -447,9 +447,7 @@ void HSD_RObjResolveRefs(HSD_RObj* robj, HSD_RObjDesc* desc) HSD_JObjUnrefThis(robj->u.jobj); robj->u.jobj = HSD_IDGetData((u32) desc->u.joint, NULL); HSD_ASSERT(883, robj->u.jobj); - if (robj->u.jobj != NULL) { - iref_INC(robj->u.jobj); - } + iref_INC(robj->u.jobj); break; case 0x0: HSD_RvalueResolveRefsAll(robj->u.exp.rvalue, desc->u.exp->rvalue); @@ -663,12 +661,12 @@ void HSD_RvalueResolveRefsAll(HSD_Rvalue* rvalue, HSD_RvalueList* list) } } -static inline void ref_JObj(HSD_RObj* robj, HSD_JObj* o) +static inline void ref_JObj(HSD_RObj* robj, void* o) { - // HSD_JObj* jobj; bool isDesc; - if (isDesc = hsdObjIsDescendantOf(&o->object, &hsdJObj.parent.parent), + if (isDesc = hsdObjIsDescendantOf(&((HSD_JObj*) o)->object, + &hsdJObj.parent.parent), isDesc != 0) { robj->u.jobj = o; @@ -681,7 +679,7 @@ static inline void ref_JObj(HSD_RObj* robj, HSD_JObj* o) void HSD_RObjSetConstraintObj(HSD_RObj* robj, void* obj) { - // HSD_JObj* jobj; + bool isDesc; if (robj != NULL) { if (robj->u.jobj != NULL) {