From 3677c111408fcf81a108567fadcfba3bbafdbe31 Mon Sep 17 00:00:00 2001 From: fig02 Date: Sun, 20 Oct 2024 23:19:14 -0400 Subject: [PATCH] Document `ACTOR_FLAG_CAN_PRESS_SWITCHES` (#2275) * document switch activation * format * activate -> press * fix comment --- include/z64actor.h | 7 ++++--- include/z64bgcheck.h | 4 ++-- src/code/code_800430A0.c | 4 ++-- src/code/code_80043480.c | 8 ++++---- src/code/z_player_call.c | 2 +- src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c | 4 ++-- src/overlays/actors/ovl_En_Am/z_en_am.c | 2 +- src/overlays/actors/ovl_En_Ru1/z_en_ru1.c | 2 +- src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c | 2 +- src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c | 4 ++-- src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c | 6 +++--- 11 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/z64actor.h b/include/z64actor.h index 6318ff9422..a1df8ef7e0 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -196,8 +196,9 @@ typedef struct ActorShape { // This flag allows a given actor to be an exception. #define ACTOR_FLAG_UPDATE_DURING_OCARINA (1 << 25) -// -#define ACTOR_FLAG_26 (1 << 26) +// Actor can press and hold down switches. +// See usages of `DynaPolyActor_SetSwitchPressed` and `DynaPolyActor_IsSwitchPressed` for more context on how switches work. +#define ACTOR_FLAG_CAN_PRESS_SWITCHES (1 << 26) // Player is not able to lock onto the actor. // Navi will still be able to hover over the actor, assuming `ACTOR_FLAG_ATTENTION_ENABLED` is set. @@ -311,7 +312,7 @@ if neither of the above are set : blue #define DYNA_INTERACT_ACTOR_ON_TOP (1 << 0) // There is an actor standing on the collision of the dynapoly actor #define DYNA_INTERACT_PLAYER_ON_TOP (1 << 1) // The player actor is standing on the collision of the dynapoly actor #define DYNA_INTERACT_PLAYER_ABOVE (1 << 2) // The player is directly above the collision of the dynapoly actor (any distance above) -#define DYNA_INTERACT_3 (1 << 3) // Like the ACTOR_ON_TOP flag but only actors with ACTOR_FLAG_26 +#define DYNA_INTERACT_ACTOR_SWITCH_PRESSED (1 << 3) // An actor that is capable of pressing switches is on top of the dynapoly actor typedef struct DynaPolyActor { /* 0x000 */ struct Actor actor; diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 5dd5eeab75..6412741962 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -481,11 +481,11 @@ void DynaPolyActor_UnsetAllInteractFlags(struct DynaPolyActor* dynaActor); void DynaPolyActor_SetActorOnTop(struct DynaPolyActor* dynaActor); void DynaPoly_SetPlayerOnTop(CollisionContext* colCtx, s32 floorBgId); void DynaPoly_SetPlayerAbove(CollisionContext* colCtx, s32 floorBgId); -void func_80043538(struct DynaPolyActor* dynaActor); +void DynaPolyActor_SetSwitchPressed(struct DynaPolyActor* dynaActor); s32 DynaPolyActor_IsActorOnTop(struct DynaPolyActor* dynaActor); s32 DynaPolyActor_IsPlayerOnTop(struct DynaPolyActor* dynaActor); s32 DynaPolyActor_IsPlayerAbove(struct DynaPolyActor* dynaActor); -s32 func_800435B4(struct DynaPolyActor* dynaActor); +s32 DynaPolyActor_IsSwitchPressed(struct DynaPolyActor* dynaActor); s32 func_800435D8(struct PlayState* play, struct DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4); #endif diff --git a/src/code/code_800430A0.c b/src/code/code_800430A0.c index 64c1eee817..90ae85187a 100644 --- a/src/code/code_800430A0.c +++ b/src/code/code_800430A0.c @@ -76,8 +76,8 @@ void func_80043334(CollisionContext* colCtx, Actor* actor, s32 bgId) { if (dynaActor != NULL) { DynaPolyActor_SetActorOnTop(dynaActor); - if (CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_26)) { - func_80043538(dynaActor); + if (CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_CAN_PRESS_SWITCHES)) { + DynaPolyActor_SetSwitchPressed(dynaActor); } } } diff --git a/src/code/code_80043480.c b/src/code/code_80043480.c index 83ca32149f..1a4d9f58d5 100644 --- a/src/code/code_80043480.c +++ b/src/code/code_80043480.c @@ -44,8 +44,8 @@ void DynaPoly_SetPlayerAbove(CollisionContext* colCtx, s32 floorBgId) { } } -void func_80043538(DynaPolyActor* dynaActor) { - dynaActor->interactFlags |= DYNA_INTERACT_3; +void DynaPolyActor_SetSwitchPressed(DynaPolyActor* dynaActor) { + dynaActor->interactFlags |= DYNA_INTERACT_ACTOR_SWITCH_PRESSED; } s32 DynaPolyActor_IsActorOnTop(DynaPolyActor* dynaActor) { @@ -72,8 +72,8 @@ s32 DynaPolyActor_IsPlayerAbove(DynaPolyActor* dynaActor) { } } -s32 func_800435B4(DynaPolyActor* dynaActor) { - if (dynaActor->interactFlags & DYNA_INTERACT_3) { +s32 DynaPolyActor_IsSwitchPressed(DynaPolyActor* dynaActor) { + if (dynaActor->interactFlags & DYNA_INTERACT_ACTOR_SWITCH_PRESSED) { return true; } else { return false; diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index 6859e5731f..d6a473120e 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.c @@ -2,7 +2,7 @@ #define FLAGS \ (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_4 | ACTOR_FLAG_5 | \ - ACTOR_FLAG_UPDATE_DURING_OCARINA | ACTOR_FLAG_26) + ACTOR_FLAG_UPDATE_DURING_OCARINA | ACTOR_FLAG_CAN_PRESS_SWITCHES) #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ "ntsc-1.2:128 pal-1.1:128" diff --git a/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c b/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c index e370341932..fb0310acbe 100644 --- a/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c +++ b/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c @@ -251,7 +251,7 @@ void func_8086D5C4(BgBdanSwitch* this) { void func_8086D5E0(BgBdanSwitch* this, PlayState* play) { switch (PARAMS_GET_U(this->dyna.actor.params, 0, 8)) { case BLUE: - if (func_800435B4(&this->dyna)) { + if (DynaPolyActor_IsSwitchPressed(&this->dyna)) { func_8086D67C(this); func_8086D4B4(this, play); } @@ -290,7 +290,7 @@ void func_8086D730(BgBdanSwitch* this) { void func_8086D754(BgBdanSwitch* this, PlayState* play) { switch (PARAMS_GET_U(this->dyna.actor.params, 0, 8)) { case BLUE: - if (!func_800435B4(&this->dyna)) { + if (!DynaPolyActor_IsSwitchPressed(&this->dyna)) { if (this->unk_1D8 <= 0) { func_8086D7FC(this); func_8086D548(this, play); diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 8fa4faae0d..9b552cc5ac 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -8,7 +8,7 @@ #include "assets/objects/object_am/object_am.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_4 | ACTOR_FLAG_26) +#define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_4 | ACTOR_FLAG_CAN_PRESS_SWITCHES) void EnAm_Init(Actor* thisx, PlayState* play); void EnAm_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index fc5a5a441c..79687c6dfd 100644 --- a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -10,7 +10,7 @@ #include "versions.h" #include "overlays/actors/ovl_Demo_Effect/z_demo_effect.h" -#define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_4 | ACTOR_FLAG_26) +#define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_4 | ACTOR_FLAG_CAN_PRESS_SWITCHES) void EnRu1_Init(Actor* thisx, PlayState* play); void EnRu1_Destroy(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c index f3b101e48e..0e41cff338 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -8,7 +8,7 @@ #include "assets/objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" -#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_26) +#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_CAN_PRESS_SWITCHES) void ObjKibako_Init(Actor* thisx, PlayState* play); void ObjKibako_Destroy(Actor* thisx, PlayState* play2); diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index 45c60f74fb..381bd44e84 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -491,7 +491,7 @@ void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play) { dynaPolyActor = DynaPoly_GetActor(&play->colCtx, bgId); if (dynaPolyActor != NULL) { DynaPolyActor_SetActorOnTop(dynaPolyActor); - func_80043538(dynaPolyActor); + DynaPolyActor_SetSwitchPressed(dynaPolyActor); if ((this->timer <= 0) && (fabsf(this->dyna.unk_150) > 0.001f)) { if (ObjOshihiki_StrongEnough(this) && ObjOshihiki_NoSwitchPress(this, dynaPolyActor, play) && @@ -520,7 +520,7 @@ void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play) { if ((dynaPolyActor != NULL) && (dynaPolyActor->transformFlags & DYNA_TRANSFORM_POS)) { DynaPolyActor_SetActorOnTop(dynaPolyActor); - func_80043538(dynaPolyActor); + DynaPolyActor_SetSwitchPressed(dynaPolyActor); this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; } else { ObjOshihiki_SetupFall(this, play); diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index 1d4dc9ae00..96244eca8a 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -410,14 +410,14 @@ void ObjSwitch_FloorUp(ObjSwitch* this, PlayState* play) { break; case OBJSWITCH_SUBTYPE_HOLD: - if (func_800435B4(&this->dyna)) { + if (DynaPolyActor_IsSwitchPressed(&this->dyna)) { ObjSwitch_FloorPressInit(this); ObjSwitch_SetOn(this, play); } break; case OBJSWITCH_SUBTYPE_HOLD_INVERTED: - if (func_800435B4(&this->dyna)) { + if (DynaPolyActor_IsSwitchPressed(&this->dyna)) { ObjSwitch_FloorPressInit(this); ObjSwitch_SetOff(this, play); } @@ -467,7 +467,7 @@ void ObjSwitch_FloorDown(ObjSwitch* this, PlayState* play) { case OBJSWITCH_SUBTYPE_HOLD: case OBJSWITCH_SUBTYPE_HOLD_INVERTED: - if (!func_800435B4(&this->dyna) && !Player_InCsMode(play)) { + if (!DynaPolyActor_IsSwitchPressed(&this->dyna) && !Player_InCsMode(play)) { if (this->releaseTimer <= 0) { ObjSwitch_FloorReleaseInit(this); if (OBJSWITCH_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_HOLD) {