From 0376242365c15345f7ab33edfab7408877164a92 Mon Sep 17 00:00:00 2001 From: petrie911 <69443847+petrie911@users.noreply.github.com> Date: Thu, 17 Dec 2020 16:49:41 -0600 Subject: [PATCH] Remove inline THIS-> from actors (#538) * Darkmeiro decompilation Bg_Gnd_Darkmeiro decompiled, matched, and documented. * give this a shot * fix conflict * one more try * could be useful * whoops * ZAP2 stuff * ZAP why * ZAP again * THIS * PLAYER --- .../z_bg_jya_bombchuiwa.c | 7 ++- .../ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c | 32 ++++++------- src/overlays/actors/ovl_En_Butte/z_en_butte.c | 7 ++- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 7 ++- src/overlays/actors/ovl_En_Hata/z_en_hata.c | 46 +++++++++---------- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 7 ++- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 7 ++- src/overlays/actors/ovl_En_Kz/z_en_kz.c | 15 +++--- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 12 ++--- .../actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c | 7 ++- src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c | 7 ++- .../ovl_Obj_Timeblock/z_obj_timeblock.c | 9 ++-- 12 files changed, 93 insertions(+), 70 deletions(-) diff --git a/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c b/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c index 4b9b92e0a7..c78b39031e 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c +++ b/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c @@ -80,8 +80,11 @@ void BgJyaBombchuiwa_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetHeight(thisx, 0.0f); } -void BgJyaBombchuiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyJntSph(globalCtx, &THIS->collider); +void BgJyaBombchuiwa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgJyaBombchuiwa* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); } void BgJyaBombchuiwa_Break(BgJyaBombchuiwa* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c b/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c index b8f89bdf23..840514df57 100644 --- a/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c +++ b/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c @@ -67,39 +67,39 @@ void BgPoSyokudai_Init(Actor* thisx, GlobalContext* globalCtx) { BgPoSyokudai* this = THIS; s32 pad; - Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_ProcessInitChain(thisx, sInitChain); - this->flameColor = (THIS->actor.params >> 8) & 0xFF; - this->actor.params &= 0x3F; + this->flameColor = (thisx->params >> 8) & 0xFF; + thisx->params &= 0x3F; - this->actor.colChkInfo.mass = 0xFF; + thisx->colChkInfo.mass = 0xFF; this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); - Lights_PointGlowSetInfo(&this->lightInfo, this->actor.posRot.pos.x, (s16)this->actor.posRot.pos.y + 65, - this->actor.posRot.pos.z, 0, 0, 0, 0); + Lights_PointGlowSetInfo(&this->lightInfo, thisx->posRot.pos.x, (s16)thisx->posRot.pos.y + 65, thisx->posRot.pos.z, + 0, 0, 0, 0); Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); - this->collider.dim.pos.x = this->actor.posRot.pos.x; - this->collider.dim.pos.y = this->actor.posRot.pos.y; - this->collider.dim.pos.z = this->actor.posRot.pos.z; + this->collider.dim.pos.x = thisx->posRot.pos.x; + this->collider.dim.pos.y = thisx->posRot.pos.y; + this->collider.dim.pos.z = thisx->posRot.pos.z; if (this->flameColor == POE_FLAME_PURPLE && Flags_GetSwitch(globalCtx, POE_TORCH_FLAG + POE_FLAME_GREEN) && Flags_GetSwitch(globalCtx, POE_TORCH_FLAG + POE_FLAME_BLUE) && - Flags_GetSwitch(globalCtx, POE_TORCH_FLAG + POE_FLAME_RED) && !Flags_GetSwitch(globalCtx, this->actor.params)) { + Flags_GetSwitch(globalCtx, POE_TORCH_FLAG + POE_FLAME_RED) && !Flags_GetSwitch(globalCtx, thisx->params)) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, 119.0f, 225.0f, -1566.0f, 0, 0, 0, - this->actor.params); + thisx->params); globalCtx->envCtx.unk_BF = 0x4; } else if (!Flags_GetSwitch(globalCtx, POE_TORCH_FLAG + POE_FLAME_PURPLE) && !Flags_GetSwitch(globalCtx, 0x1B)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, this->actor.posRot.pos.x, - this->actor.posRot.pos.y + 52.0f, this->actor.posRot.pos.z, 0, 0, 0, - (this->flameColor << 8) + this->actor.params + 0x1000); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PO_SISTERS, thisx->posRot.pos.x, + thisx->posRot.pos.y + 52.0f, thisx->posRot.pos.z, 0, 0, 0, + (this->flameColor << 8) + thisx->params + 0x1000); - } else if (!Flags_GetSwitch(globalCtx, this->actor.params)) { + } else if (!Flags_GetSwitch(globalCtx, thisx->params)) { if (globalCtx->envCtx.unk_BF == 0xFF) { globalCtx->envCtx.unk_BF = 4; } diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index a7a632d43a..3408e39eb8 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -163,8 +163,11 @@ void EnButte_Init(Actor* thisx, GlobalContext* globalCtx) { osSyncPrintf("(field keep 蝶)(%x)(arg_data 0x%04x)\n", this, this->actor.params); } -void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyJntSph(globalCtx, &THIS->collider); +void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnButte* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); } void func_809CD56C(EnButte* this) { diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index 0b1cce714c..6c0854920e 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -538,8 +538,11 @@ void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.initPosRot.rot.z & 1); } -void EnGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyJntSph(globalCtx, &THIS->collider); +void EnGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnGoroiwa* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); } void func_80A4D5E0(EnGoroiwa* this) { diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.c b/src/overlays/actors/ovl_En_Hata/z_en_hata.c index 6548a4b225..c0a2be3ffe 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.c @@ -67,40 +67,38 @@ void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx) { DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId); } -void EnHata_Update(Actor* thisx, GlobalContext* globalCtx) { - GlobalContext* gblCtx; - s32 target; +void EnHata_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHata* this = THIS; s32 pitch; - Vec3f sp48; + Vec3f sp48 = sVec; Vec3f sp3C; f32 sin; - sp48 = sVec; - SkelAnime_FrameUpdateMatrix(&THIS->skelAnime); - gblCtx = globalCtx; - THIS->limbs[3].y = THIS->limbs[12].y = -0x4000; - sp3C.x = gblCtx->envCtx.unk_A8; - sp3C.y = gblCtx->envCtx.unk_AA; - sp3C.z = gblCtx->envCtx.unk_AC; - if (gblCtx->envCtx.unk_B0 > 255.0f) { - gblCtx->envCtx.unk_B0 = 255.0f; + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + this->limbs[3].y = this->limbs[12].y = -0x4000; + sp3C.x = globalCtx->envCtx.unk_A8; + sp3C.y = globalCtx->envCtx.unk_AA; + sp3C.z = globalCtx->envCtx.unk_AC; + if (globalCtx->envCtx.unk_B0 > 255.0f) { + globalCtx->envCtx.unk_B0 = 255.0f; } - if (gblCtx->envCtx.unk_B0 < 0.0f) { - gblCtx->envCtx.unk_B0 = 0.0f; + if (globalCtx->envCtx.unk_B0 < 0.0f) { + globalCtx->envCtx.unk_B0 = 0.0f; } if (Math_Rand_ZeroOne() > 0.5f) { - THIS->unk_278 += 6000; + this->unk_278 += 6000; } else { - THIS->unk_278 += 3000; + this->unk_278 += 3000; } - sin = Math_Sins(THIS->unk_278) * 80.0f; + sin = Math_Sins(this->unk_278) * 80.0f; pitch = -Math_Vec3f_Pitch(&sp48, &sp3C); - target = ((s32)((0x3A98 - pitch) * (1.0f - (gblCtx->envCtx.unk_B0 / (255.0f - sin))))) + pitch; - Math_SmoothScaleMaxMinS(&THIS->limbs[4].y, target, THIS->invScale, THIS->maxStep, THIS->minStep); - THIS->limbs[13].y = THIS->limbs[4].y; - THIS->limbs[4].z = -Math_Vec3f_Yaw(&sp48, &sp3C); - THIS->limbs[13].z = THIS->limbs[4].z; - THIS->skelAnime.animPlaybackSpeed = (Math_Rand_ZeroFloat(1.25f) + 2.75f) * (gblCtx->envCtx.unk_B0 / 255.0f); + pitch = ((s32)((0x3A98 - pitch) * (1.0f - (globalCtx->envCtx.unk_B0 / (255.0f - sin))))) + pitch; + Math_SmoothScaleMaxMinS(&this->limbs[4].y, pitch, this->invScale, this->maxStep, this->minStep); + this->limbs[13].y = this->limbs[4].y; + this->limbs[4].z = -Math_Vec3f_Yaw(&sp48, &sp3C); + this->limbs[13].z = this->limbs[4].z; + this->skelAnime.animPlaybackSpeed = (Math_Rand_ZeroFloat(1.25f) + 2.75f) * (globalCtx->envCtx.unk_B0 / 255.0f); } s32 EnHata_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 0b6f39153b..9523b8462f 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -312,8 +312,11 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { EnIshi_SetupWait(this); } -void EnIshi_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &THIS->collider); +void EnIshi_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnIshi* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); } void EnIshi_SetupWait(EnIshi* this) { diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index ad5e58e811..1e0acc01ba 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -253,8 +253,11 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A9B7EC(this); } -void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &THIS->collider); +void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKusa* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); } void func_80A9B7EC(EnKusa* this) { diff --git a/src/overlays/actors/ovl_En_Kz/z_en_kz.c b/src/overlays/actors/ovl_En_Kz/z_en_kz.c index a64c0a5b2a..5ae557a681 100644 --- a/src/overlays/actors/ovl_En_Kz/z_en_kz.c +++ b/src/overlays/actors/ovl_En_Kz/z_en_kz.c @@ -454,21 +454,22 @@ void EnKz_Update(Actor* thisx, GlobalContext* globalCtx) { } s32 EnKz_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - s32 limb = limbIndex; + EnKz* this = THIS; - if (limb == 8 || limb == 9 || limb == 10) { - rot->y += Math_Sins(THIS->unk_2A6[limb]) * 200.0f; - rot->z += Math_Coss(THIS->unk_2BE[limb]) * 200.0f; + if (limbIndex == 8 || limbIndex == 9 || limbIndex == 10) { + rot->y += Math_Sins(this->unk_2A6[limbIndex]) * 200.0f; + rot->z += Math_Coss(this->unk_2BE[limbIndex]) * 200.0f; } + if (limbIndex) {} return 0; } void EnKz_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - s32 limb = limbIndex; + EnKz* this = THIS; Vec3f mult = { 2600.0f, 0.0f, 0.0f }; - if (limb == 11) { - Matrix_MultVec3f(&mult, &THIS->actor.posRot2.pos); + if (limbIndex == 11) { + Matrix_MultVec3f(&mult, &this->actor.posRot2.pos); } } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 4106e80ea8..7595c9327c 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -314,7 +314,7 @@ void func_80AE2C1C(EnRd* this, GlobalContext* globalCtx) { if ((this->unk_307 == 0) && (func_8002DB48(&this->actor, &player->actor) <= 45.0f) && (func_8002E084(&this->actor, 0x38E3))) { player->actor.freezeTimer = 0; - if (globalCtx->grabPlayer(globalCtx, &player->actor) != 0) { + if (globalCtx->grabPlayer(globalCtx, player)) { this->actor.flags &= ~1; func_80AE33F0(this); } @@ -854,9 +854,9 @@ void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnRd* this = THIS; s32 pad; - Vec3f thisPos = this->actor.posRot.pos; + EnRd* this = THIS; + Vec3f thisPos = thisx->posRot.pos; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_rd.c", 1679); @@ -869,10 +869,10 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP); func_80033C30(&thisPos, &D_80AE4958, 255, globalCtx); if (this->unk_31A != 0) { - this->actor.dmgEffectTimer++; - THIS->unk_31A--; + thisx->dmgEffectTimer++; + this->unk_31A--; if (this->unk_31A % 4 == 0) { - EffectSsEnFire_SpawnVec3s(globalCtx, &this->actor, &this->firePos[this->unk_31A >> 2], 0x4B, 0, 0, + EffectSsEnFire_SpawnVec3s(globalCtx, thisx, &this->firePos[this->unk_31A >> 2], 0x4B, 0, 0, (this->unk_31A >> 2)); } } diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index f7510b1971..5a4ed2fe5f 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -82,8 +82,11 @@ void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &THIS->collider); +void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjBombiwa* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); } void ObjBombiwa_Break(ObjBombiwa* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index 5ec20878ee..3b71d53b52 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -145,8 +145,11 @@ void ObjComb_Init(Actor* thisx, GlobalContext* globalCtx) { ObjComb_SetupWait(this); } -void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyJntSph(globalCtx, &THIS->collider); +void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjComb* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); } void ObjComb_SetupWait(ObjComb* this) { diff --git a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c index 4ff7dc55c8..bd4910e5c0 100644 --- a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c +++ b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c @@ -143,7 +143,10 @@ void ObjTimeblock_Init(Actor* thisx, GlobalContext* globalCtx) { } void ObjTimeblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { - DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, THIS->dyna.dynaPolyId); + s32 pad; + ObjTimeblock* this = THIS; + + DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId); } u8 ObjTimeblock_PlayerIsInRange(ObjTimeblock* this, GlobalContext* globalCtx) { @@ -330,8 +333,8 @@ void ObjTimeblock_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjTimeblock_Draw(Actor* thisx, GlobalContext* globalCtx) { - if (THIS->isVisible) { - Color_RGB8* primColor = &sPrimColors[THIS->dyna.actor.initPosRot.rot.z & 7]; + if (((ObjTimeblock*)thisx)->isVisible) { + Color_RGB8* primColor = &sPrimColors[thisx->initPosRot.rot.z & 7]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_timeblock.c", 762);