From fa8c723da8b3ca1265a568a3d96719a6ca538eb6 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 25 Mar 2022 17:53:19 -0700 Subject: [PATCH] Fix two small things in Bg_F40_Switch (#717) --- .../ovl_Bg_F40_Switch/z_bg_f40_switch.c | 54 +++++++++---------- .../ovl_Bg_F40_Switch/z_bg_f40_switch.h | 4 +- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c index e44cb89d6b..5278a4b738 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c @@ -52,10 +52,10 @@ void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { u32 inCsMode = Player_InCsMode(&globalCtx->state); for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { - if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->actor.actor.room && actor->update != NULL) { + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != NULL) { actorAsSwitch = (BgF40Switch*)actor; actorAsSwitch->wasPressed = actorAsSwitch->isPressed; - isPressed = DynaPolyActor_IsInSwitchPressedState(&actorAsSwitch->actor); + isPressed = DynaPolyActor_IsInSwitchPressedState(&actorAsSwitch->dyna); if (actorAsSwitch->isPressed && actorAsSwitch->actionFunc == BgF40Switch_IdlePressed) { // Switch is fully pressed - if there's nothing keeping it pressed, wait a short time before // reverting to unpressed state. @@ -73,7 +73,7 @@ void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { actorAsSwitch->isPressed = isPressed; } if (actorAsSwitch->isPressed) { - switchFlag = BGF40SWITCH_GET_SWITCHFLAG(actorAsSwitch); + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(&actorAsSwitch->dyna.actor); if (switchFlag >= 0 && switchFlag < 0x80) { pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] |= 1 << (switchFlag & 0x1F); if (!actorAsSwitch->wasPressed && actorAsSwitch->actionFunc == BgF40Switch_IdleUnpressed && @@ -85,8 +85,8 @@ void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { } } for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { - if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->actor.actor.room && actor->update != 0) { - switchFlag = BGF40SWITCH_GET_SWITCHFLAG((BgF40Switch*)actor); + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != 0) { + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(actor); if (switchFlag >= 0 && switchFlag < 0x80 && Flags_GetSwitch(globalCtx, switchFlag) && !(pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] & (1 << (switchFlag & 0x1F)))) { Flags_UnsetSwitch(globalCtx, switchFlag); @@ -107,12 +107,12 @@ static InitChainEntry sInitChain[] = { void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx) { BgF40Switch* this = THIS; - Actor_ProcessInitChain(&this->actor.actor, sInitChain); - this->actor.actor.scale.y = 0.165f; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.y = 0.165f; this->actionFunc = BgF40Switch_IdleUnpressed; - this->actor.actor.world.pos.y = this->actor.actor.home.pos.y + 1.0f; - DynaPolyActor_Init(&this->actor, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->actor, &object_f40_switch_Colheader_000118); + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f40_switch_Colheader_000118); if (!sBgF40SwitchGlobalsInitialized) { sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; sBgF40SwitchGlobalsInitialized = true; @@ -122,15 +122,15 @@ void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx) { void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgF40Switch* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->actor.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx) { - this->actor.actor.scale.y += 0.0495f; - if (this->actor.actor.scale.y >= 0.165f) { - Actor_PlaySfxAtPos(&this->actor.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + this->dyna.actor.scale.y += 0.0495f; + if (this->dyna.actor.scale.y >= 0.165f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); this->actionFunc = BgF40Switch_IdleUnpressed; - this->actor.actor.scale.y = 0.165f; + this->dyna.actor.scale.y = 0.165f; } } @@ -141,34 +141,34 @@ void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx) { } void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx) { - this->actor.actor.scale.y -= 0.0495f; - if (this->actor.actor.scale.y <= 0.0165f) { - Actor_PlaySfxAtPos(&this->actor.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); - func_8013ECE0(this->actor.actor.xyzDistToPlayerSq, 120, 20, 10); + this->dyna.actor.scale.y -= 0.0495f; + if (this->dyna.actor.scale.y <= 0.0165f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); if (this->isInitiator) { - ActorCutscene_Stop(this->actor.actor.cutscene); + ActorCutscene_Stop(this->dyna.actor.cutscene); this->isInitiator = false; } this->actionFunc = BgF40Switch_IdlePressed; - this->actor.actor.scale.y = 0.0165f; + this->dyna.actor.scale.y = 0.0165f; this->switchReleaseDelay = 6; } } void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx) { - if (!this->isInitiator || this->actor.actor.cutscene == -1) { + if (!this->isInitiator || this->dyna.actor.cutscene == -1) { this->actionFunc = BgF40Switch_Press; if (this->isInitiator) { - Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(this)); + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } - } else if (ActorCutscene_GetCanPlayNext(this->actor.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.actor.cutscene, &this->actor.actor); + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); this->actionFunc = BgF40Switch_Press; if (this->isInitiator) { - Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(this)); + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } } else { - ActorCutscene_SetIntentToPlay(this->actor.actor.cutscene); + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); } } diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h index ec2b4dfeca..8d4e64603f 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h @@ -5,12 +5,12 @@ struct BgF40Switch; -#define BGF40SWITCH_GET_SWITCHFLAG(this) (((this)->actor.actor.params & 0xFE00) >> 9) +#define BGF40SWITCH_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) typedef void (*BgF40SwitchActionFunc)(struct BgF40Switch*, GlobalContext*); typedef struct BgF40Switch { - /* 0x0000 */ DynaPolyActor actor; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it /* 0x015E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly. /* 0x015F */ s8 wasPressed; // used as temporary during update function