summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorDragorn421 <Dragorn421@users.noreply.github.com>2022-02-19 03:16:19 +0100
committerGitHub <noreply@github.com>2022-02-18 21:16:19 -0500
commit67f294774bf3cfbd8d6698c0e7790900bc988e16 (patch)
tree0e312798f59509ec76cea18154967cd810136a5c /src/code
parent251d90301c2bbaaf2c46362986a321fc70712ecc (diff)
Defines for `Actor#bgCheckFlags` (#1126)
* First pass, tool assisted bgCheckFlags * Few manual bgCheckFlags * Run formatter * Remove fake bgCheckFlags 10-15 * Move existing documentation to the defines * Comment on `bgCheckFlags` and rephrase some doc * Name obvious flags, and some cleanup * Comment on flag 9 being wall-interaction-related (thanks engineer and fig) * Run formatter * `BGCHECKFLAG_7` -> `BGCHECKFLAG_GROUND_STRICT` * Touch up water-related bgcheckflags doc * `BGCHECKFLAG_9` -> `BGCHECKFLAG_PLAYER_WALL_INTERACT`
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_actor.c52
-rw-r--r--src/code/z_en_a_keep.c8
-rw-r--r--src/code/z_en_item00.c10
-rw-r--r--src/code/z_player_lib.c4
4 files changed, 37 insertions, 37 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 112ff7db8..5cdb8b293 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -188,7 +188,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx
floorHeightPtr++;
}
- if (!(actor->bgCheckFlags & 1)) {
+ if (!(actor->bgCheckFlags & BGCHECKFLAG_GROUND)) {
actor->shape.feetFloorFlags = 0;
} else if (actor->shape.feetFloorFlags == 3) {
f32 footDistY = actor->shape.feetPos[FOOT_LEFT].y - actor->shape.feetPos[FOOT_RIGHT].y;
@@ -1153,9 +1153,9 @@ s32 Actor_ActorAIsFacingAndNearActorB(Actor* actorA, Actor* actorB, f32 range, s
}
s32 func_8002E234(Actor* actor, f32 arg1, s32 arg2) {
- if ((actor->bgCheckFlags & 0x1) && (arg1 < -11.0f)) {
- actor->bgCheckFlags &= ~0x1;
- actor->bgCheckFlags |= 0x4;
+ if ((actor->bgCheckFlags & BGCHECKFLAG_GROUND) && (arg1 < -11.0f)) {
+ actor->bgCheckFlags &= ~BGCHECKFLAG_GROUND;
+ actor->bgCheckFlags |= BGCHECKFLAG_GROUND_LEAVE;
if ((actor->velocity.y < 0.0f) && (arg2 & 0x10)) {
actor->velocity.y = 0.0f;
@@ -1175,7 +1175,7 @@ s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3)
actor->floorHeight =
BgCheck_EntityRaycastFloor5(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &floorBgId, actor, arg2);
- actor->bgCheckFlags &= ~0x0086;
+ actor->bgCheckFlags &= ~(BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_GROUND_LEAVE | BGCHECKFLAG_GROUND_STRICT);
if (actor->floorHeight <= BGCHECK_Y_MIN) {
return func_8002E234(actor, BGCHECK_Y_MIN, arg3);
@@ -1185,12 +1185,12 @@ s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3)
actor->floorBgId = floorBgId;
if (floorHeightDiff >= 0.0f) { // actor is on or below the ground
- actor->bgCheckFlags |= 0x80;
+ actor->bgCheckFlags |= BGCHECKFLAG_GROUND_STRICT;
- if (actor->bgCheckFlags & 0x10) {
+ if (actor->bgCheckFlags & BGCHECKFLAG_CEILING) {
if (floorBgId != sCurCeilingBgId) {
if (floorHeightDiff > 15.0f) {
- actor->bgCheckFlags |= 0x100;
+ actor->bgCheckFlags |= BGCHECKFLAG_CRUSHED;
}
} else {
actor->world.pos.x = actor->prevPos.x;
@@ -1201,19 +1201,19 @@ s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3)
actor->world.pos.y = actor->floorHeight;
if (actor->velocity.y <= 0.0f) {
- if (!(actor->bgCheckFlags & 0x1)) {
- actor->bgCheckFlags |= 0x2;
+ if (!(actor->bgCheckFlags & BGCHECKFLAG_GROUND)) {
+ actor->bgCheckFlags |= BGCHECKFLAG_GROUND_TOUCH;
} else if ((arg3 & 0x8) && (actor->gravity < 0.0f)) {
actor->velocity.y = -4.0f;
} else {
actor->velocity.y = 0.0f;
}
- actor->bgCheckFlags |= 0x1;
+ actor->bgCheckFlags |= BGCHECKFLAG_GROUND;
func_80043334(&globalCtx->colCtx, actor, actor->floorBgId);
}
} else { // actor is above ground
- if ((actor->bgCheckFlags & 0x1) && (floorHeightDiff >= -11.0f)) {
+ if ((actor->bgCheckFlags & BGCHECKFLAG_GROUND) && (floorHeightDiff >= -11.0f)) {
func_80043334(&globalCtx->colCtx, actor, actor->floorBgId);
}
@@ -1237,7 +1237,7 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
sp74 = actor->world.pos.y - actor->prevPos.y;
- if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & 1)) {
+ if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & BGCHECKFLAG_GROUND)) {
func_800433A4(&globalCtx->colCtx, actor->floorBgId, actor);
}
@@ -1251,10 +1251,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
wallPoly = actor->wallPoly;
Math_Vec3f_Copy(&actor->world.pos, &sp64);
actor->wallYaw = Math_Atan2S(wallPoly->normal.z, wallPoly->normal.x);
- actor->bgCheckFlags |= 8;
+ actor->bgCheckFlags |= BGCHECKFLAG_WALL;
actor->wallBgId = bgId;
} else {
- actor->bgCheckFlags &= ~8;
+ actor->bgCheckFlags &= ~BGCHECKFLAG_WALL;
}
}
@@ -1265,10 +1265,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
sp64.y = actor->prevPos.y + 10.0f;
if (BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &sp58, &sp64, (ceilingCheckHeight + sp74) - 10.0f,
&sCurCeilingPoly, &sCurCeilingBgId, actor)) {
- actor->bgCheckFlags |= 0x10;
+ actor->bgCheckFlags |= BGCHECKFLAG_CEILING;
actor->world.pos.y = (sp58 + sp74) - 10.0f;
} else {
- actor->bgCheckFlags &= ~0x10;
+ actor->bgCheckFlags &= ~BGCHECKFLAG_CEILING;
}
}
@@ -1280,10 +1280,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
&waterBoxYSurface, &waterBox)) {
actor->yDistToWater = waterBoxYSurface - actor->world.pos.y;
if (actor->yDistToWater < 0.0f) {
- actor->bgCheckFlags &= ~0x60;
+ actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH);
} else {
- if (!(actor->bgCheckFlags & 0x20)) {
- actor->bgCheckFlags |= 0x40;
+ if (!(actor->bgCheckFlags & BGCHECKFLAG_WATER)) {
+ actor->bgCheckFlags |= BGCHECKFLAG_WATER_TOUCH;
if (!(flags & 0x40)) {
ripplePos.x = actor->world.pos.x;
ripplePos.y = waterBoxYSurface;
@@ -1293,10 +1293,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 8);
}
}
- actor->bgCheckFlags |= 0x20;
+ actor->bgCheckFlags |= BGCHECKFLAG_WATER;
}
} else {
- actor->bgCheckFlags &= ~0x60;
+ actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH);
actor->yDistToWater = BGCHECK_Y_MIN;
}
}
@@ -1699,7 +1699,7 @@ void Audio_PlayActorSound2(Actor* actor, u16 sfxId) {
void func_8002F850(GlobalContext* globalCtx, Actor* actor) {
s32 sfxId;
- if (actor->bgCheckFlags & 0x20) {
+ if (actor->bgCheckFlags & BGCHECKFLAG_WATER) {
if (actor->yDistToWater < 20.0f) {
sfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG;
} else {
@@ -3420,7 +3420,7 @@ s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 dista
Math_Vec3f_Copy(&actor->world.pos, &prevActorPos);
- ret = actor->bgCheckFlags & 1;
+ ret = actor->bgCheckFlags & BGCHECKFLAG_GROUND;
actor->bgCheckFlags = prevBgCheckFlags;
return ret;
@@ -3936,10 +3936,10 @@ s32 func_80035124(Actor* actor, GlobalContext* globalCtx) {
case 0:
if (Actor_HasParent(actor, globalCtx)) {
actor->params = 1;
- } else if (!(actor->bgCheckFlags & 1)) {
+ } else if (!(actor->bgCheckFlags & BGCHECKFLAG_GROUND)) {
Actor_MoveForward(actor);
Math_SmoothStepToF(&actor->speedXZ, 0.0f, 1.0f, 0.1f, 0.0f);
- } else if ((actor->bgCheckFlags & 2) && (actor->velocity.y < -4.0f)) {
+ } else if ((actor->bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) && (actor->velocity.y < -4.0f)) {
ret = 1;
} else {
actor->shape.rot.x = actor->shape.rot.z = 0;
diff --git a/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c
index 91f21648a..20aa5d4d7 100644
--- a/src/code/z_en_a_keep.c
+++ b/src/code/z_en_a_keep.c
@@ -278,18 +278,18 @@ void EnAObj_BoulderFragment(EnAObj* this, GlobalContext* globalCtx) {
this->dyna.actor.shape.rot.x += this->dyna.actor.world.rot.x >> 1;
this->dyna.actor.shape.rot.z += this->dyna.actor.world.rot.z >> 1;
- if (this->dyna.actor.speedXZ != 0.0f && this->dyna.actor.bgCheckFlags & 0x8) {
+ if (this->dyna.actor.speedXZ != 0.0f && this->dyna.actor.bgCheckFlags & BGCHECKFLAG_WALL) {
this->dyna.actor.world.rot.y =
this->dyna.actor.wallYaw - this->dyna.actor.world.rot.y + this->dyna.actor.wallYaw - 0x8000;
if (1) {}
- this->dyna.actor.bgCheckFlags &= ~0x8;
+ this->dyna.actor.bgCheckFlags &= ~BGCHECKFLAG_WALL;
}
- if (this->dyna.actor.bgCheckFlags & 0x2) {
+ if (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
if (this->dyna.actor.velocity.y < -8.0f) {
this->dyna.actor.velocity.y *= -0.6f;
this->dyna.actor.speedXZ *= 0.6f;
- this->dyna.actor.bgCheckFlags &= ~0x3;
+ this->dyna.actor.bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH);
} else {
Actor_Kill(&this->dyna.actor);
}
diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c
index 794a62659..3a122b4cc 100644
--- a/src/code/z_en_item00.c
+++ b/src/code/z_en_item00.c
@@ -597,7 +597,7 @@ void func_8001DFC8(EnItem00* this, GlobalContext* globalCtx) {
}
}
- if ((this->actor.gravity != 0.0f) && !(this->actor.bgCheckFlags & 0x0001)) {
+ if ((this->actor.gravity != 0.0f) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) {
EnItem00_SetupAction(this, func_8001E1C8);
}
}
@@ -618,14 +618,14 @@ void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx) {
&sEffectEnvColor);
}
- if (this->actor.bgCheckFlags & 0x0003) {
+ if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) {
originalVelocity = this->actor.velocity.y;
if (originalVelocity > -2.0f) {
EnItem00_SetupAction(this, func_8001DFC8);
this->actor.velocity.y = 0.0f;
} else {
this->actor.velocity.y = originalVelocity * -0.8f;
- this->actor.bgCheckFlags &= ~1;
+ this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND;
}
}
}
@@ -677,7 +677,7 @@ void func_8001E304(EnItem00* this, GlobalContext* globalCtx) {
&sEffectEnvColor);
}
- if (this->actor.bgCheckFlags & 0x0003) {
+ if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) {
EnItem00_SetupAction(this, func_8001DFC8);
this->actor.shape.rot.z = 0;
this->actor.velocity.y = 0.0f;
@@ -746,7 +746,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
this->actor.scale.y = this->actor.scale.x;
if (this->actor.gravity) {
- if (this->actor.bgCheckFlags & 0x0003) {
+ if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) {
if (*temp != globalCtx->gameplayFrames) {
D_80157D90 = globalCtx->gameplayFrames;
D_80157D94[0] = 0;
diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c
index 7dec7c8df..3571f0182 100644
--- a/src/code/z_player_lib.c
+++ b/src/code/z_player_lib.c
@@ -436,7 +436,7 @@ void func_8008EDF0(Player* this) {
}
void func_8008EE08(Player* this) {
- if ((this->actor.bgCheckFlags & 1) ||
+ if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) ||
(this->stateFlags1 & (PLAYER_STATE1_21 | PLAYER_STATE1_23 | PLAYER_STATE1_27)) ||
(!(this->stateFlags1 & (PLAYER_STATE1_18 | PLAYER_STATE1_19)) &&
((this->actor.world.pos.y - this->actor.floorHeight) < 100.0f))) {
@@ -619,7 +619,7 @@ s32 func_8008F2F8(GlobalContext* globalCtx) {
var = 0;
} else if ((this->unk_840 > 80) &&
((this->currentBoots == PLAYER_BOOTS_IRON) || (this->unk_840 >= 300))) { // Deep underwater
- var = ((this->currentBoots == PLAYER_BOOTS_IRON) && (this->actor.bgCheckFlags & 1)) ? 1 : 3;
+ var = ((this->currentBoots == PLAYER_BOOTS_IRON) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) ? 1 : 3;
} else if (this->stateFlags1 & PLAYER_STATE1_27) { // Swimming
var = 2;
} else {