Skip to content

Commit

Permalink
Collider.effects Lint (#1968)
Browse files Browse the repository at this point in the history
Linter for `Collider.effects`.
  • Loading branch information
hohle authored Dec 4, 2024
1 parent 80cdbaf commit babbbdd
Show file tree
Hide file tree
Showing 23 changed files with 258 additions and 133 deletions.
1 change: 1 addition & 0 deletions include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,7 @@ typedef struct {
} AbbreviatedOverlay;

typedef enum {
EFFECT_NONE = 0,
EFFECT_SOLID = 1 << 0,
EFFECT_UNK_0002 = 1 << 1,
EFFECT_QUICKSAND = 1 << 2,
Expand Down
16 changes: 11 additions & 5 deletions src/dra/5D5BC.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,10 @@ s32 HandleDamage(DamageParam* damage, s32 arg1, s32 amount, s32 arg3) {
amount /= 2;
}
if (g_Status.D_80097C2C & damage->effects) {
if (!(g_Status.D_80097C2C & damage->effects & 0x200)) {
if (!(g_Status.D_80097C2C & damage->effects & EFFECT_UNK_0200)) {
return 0;
}
damage->effects &= ~0x200;
damage->effects &= ~EFFECT_UNK_0200;
}

if (g_Status.D_80097C2E & damage->effects) {
Expand Down Expand Up @@ -664,7 +664,11 @@ s32 HandleDamage(DamageParam* damage, s32 arg1, s32 amount, s32 arg3) {
// have special behavior. Also, not possible to equip two. This may be
// a new discovery of a property of the item. Worth further analysis.
itemCount = CheckEquipmentItemCount(ITEM_BALLROOM_MASK, EQUIP_HEAD);
if (itemCount != 0 && (damage->effects & 0xF980)) {
if (itemCount != 0 &&
(damage->effects &
(EFFECT_UNK_8000 | EFFECT_UNK_4000 | EFFECT_UNK_2000 |
EFFECT_UNK_1000 | EFFECT_UNK_0800 | EFFECT_UNK_0100 |
EFFECT_SOLID_FROM_BELOW))) {
if (itemCount == 1) {
amount -= amount / 5;
}
Expand All @@ -675,7 +679,7 @@ s32 HandleDamage(DamageParam* damage, s32 arg1, s32 amount, s32 arg3) {
if (g_Player.status & PLAYER_STATUS_STONE) {
damage->damageTaken = g_Status.hpMax / 8;
ret = 8;
} else if (damage->effects & 0x200) {
} else if (damage->effects & EFFECT_UNK_0200) {
damage->damageTaken = amount - (g_Status.defenseEquip * 2);
if (damage->damageTaken <= 0) {
damage->damageTaken = 0;
Expand Down Expand Up @@ -716,7 +720,9 @@ s32 HandleDamage(DamageParam* damage, s32 arg1, s32 amount, s32 arg3) {
}
ret = 3;
} else {
if (g_Status.defenseEquip > 99 && !(damage->effects & 0x180) &&
if (g_Status.defenseEquip > 99 &&
!(damage->effects &
(EFFECT_UNK_0100 | EFFECT_SOLID_FROM_BELOW)) &&
!(g_Player.status & PLAYER_STATUS_STONE)) {
damage->damageKind = 0;
ret = 1;
Expand Down
47 changes: 24 additions & 23 deletions src/dra/692E8.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,16 @@ static void CheckStageCollision(s32 isTransformed) {
g_Player.colFloor[i].effects & EFFECT_SOLID_FROM_ABOVE) {
CheckCollision(x, y + 12, &sp10, 0);
if (!(sp10.effects & EFFECT_SOLID)) {
g_Player.colFloor[i].effects = 0;
g_Player.colFloor[i].effects = EFFECT_NONE;
}
}
if (mist && g_Player.colFloor[i].effects & EFFECT_MIST_ONLY) {
g_Player.colFloor[i].effects = 0;
g_Player.colFloor[i].effects = EFFECT_NONE;
}
if (PLAYER.step == Player_MorphBat || PLAYER.step == Player_MorphMist) {
if (g_Player.colFloor[i].effects &
(EFFECT_SOLID_FROM_ABOVE | EFFECT_SOLID_FROM_BELOW)) {
g_Player.colFloor[i].effects = 0;
g_Player.colFloor[i].effects = EFFECT_NONE;
}
}
}
Expand All @@ -419,12 +419,12 @@ static void CheckStageCollision(s32 isTransformed) {
y = PLAYER.posY.i.hi + g_SensorsCeiling[i].y;
CheckCollision(x, y, &g_Player.colCeiling[i], 0);
if (mist && g_Player.colCeiling[i].effects & EFFECT_MIST_ONLY) {
g_Player.colCeiling[i].effects = 0;
g_Player.colCeiling[i].effects = EFFECT_NONE;
}
if (PLAYER.step == Player_MorphBat || PLAYER.step == Player_MorphMist) {
if (g_Player.colCeiling[i].effects &
(EFFECT_SOLID_FROM_ABOVE | EFFECT_SOLID_FROM_BELOW)) {
g_Player.colCeiling[i].effects = 0;
g_Player.colCeiling[i].effects = EFFECT_NONE;
}
}
}
Expand All @@ -441,7 +441,7 @@ static void CheckStageCollision(s32 isTransformed) {
y = PLAYER.posY.i.hi + g_SensorsWall[i].y;
CheckCollision(x, y, &g_Player.colWall[i], 0);
if (mist && g_Player.colWall[i].effects & EFFECT_MIST_ONLY) {
g_Player.colWall[i].effects = 0;
g_Player.colWall[i].effects = EFFECT_NONE;
}
}
CheckWallRight();
Expand All @@ -456,9 +456,9 @@ static void CheckStageCollision(s32 isTransformed) {
if (*pl_vram & 0x8000) {
*pl_vram |= 0x20;
}
if (!(g_Player.colFloor[1].effects & 1) ||
!(g_Player.colFloor[2].effects & 1) ||
!(g_Player.colFloor[3].effects & 1)) {
if (!(g_Player.colFloor[1].effects & EFFECT_SOLID) ||
!(g_Player.colFloor[2].effects & EFFECT_SOLID) ||
!(g_Player.colFloor[3].effects & EFFECT_SOLID)) {
*pl_vram |= 0x20;
}
}
Expand Down Expand Up @@ -1471,13 +1471,14 @@ static void CheckFloor(void) {
argY += (g_Player.colFloor[i].unk18 - 1);
CheckCollision(argX, argY, &sp10, 0);
if ((g_Player.status & PLAYER_STATUS_MIST_FORM) &&
(sp10.effects & 0x10)) {
sp10.effects &= ~3;
(sp10.effects & EFFECT_MIST_ONLY)) {
sp10.effects &= ~(EFFECT_UNK_0002 | EFFECT_SOLID);
}
var_s1 = sp10.effects;
if (!(sp10.effects & EFFECT_SOLID)) {
if (((g_Player.colFloor[i].effects != 1) &&
(g_Player.colFloor[i].effects != 0x41)) ||
if (((g_Player.colFloor[i].effects != EFFECT_SOLID) &&
(g_Player.colFloor[i].effects !=
(EFFECT_SOLID_FROM_ABOVE | EFFECT_SOLID))) ||
(PLAYER.velocityY >= 0)) {
if (var_s2 & EFFECT_UNK_0800) {
*yPosPtr += var_s5 + g_Player.colFloor[i].unk8;
Expand Down Expand Up @@ -1527,14 +1528,14 @@ static void CheckFloor(void) {
*yPosPtr += var_s5 + g_Player.colFloor[i].unk18;
return;
}
if (g_Player.colFloor[1].effects & 4) {
if (g_Player.colFloor[1].effects & EFFECT_QUICKSAND) {
*vram_ptr |= 0x11;
if ((g_Timer & 3) == 0) {
(*yPosPtr)++;
}
return;
}
if (g_Player.colFloor[1].effects & 8) {
if (g_Player.colFloor[1].effects & EFFECT_WATER) {
*vram_ptr |= 0x80;
}
if (PLAYER.velocityY < 0) {
Expand All @@ -1543,7 +1544,7 @@ static void CheckFloor(void) {
argX = *xPosPtr + g_SensorsFloor[0].x;
argY = *yPosPtr + g_SensorsFloor[0].y + 10;
CheckCollision(argX, argY, &sp10, 0);
if ((sp10.effects & (EFFECT_UNK_8000 | EFFECT_SOLID)) != 0) {
if ((sp10.effects & (EFFECT_UNK_8000 | EFFECT_SOLID)) != EFFECT_NONE) {
return;
}

Expand Down Expand Up @@ -1572,7 +1573,7 @@ static void CheckFloor(void) {
argX = var_s6 + (*xPosPtr + g_SensorsFloor[i].x);
argY = *yPosPtr + g_SensorsFloor[i].y;
CheckCollision(argX, argY, &sp10, 0);
if (sp10.effects & 1) {
if (sp10.effects & EFFECT_SOLID) {
*yPosPtr += sp10.unk18;
*vram_ptr |= sp30;
return;
Expand All @@ -1588,7 +1589,7 @@ static void CheckFloor(void) {
argX = var_s6 + (*xPosPtr + g_SensorsFloor[i].x);
argY = *yPosPtr + g_SensorsFloor[i].y + g_Player.colFloor[i].unk10;
CheckCollision(argX, argY, &sp10, 0);
if (sp10.effects & 1) {
if (sp10.effects & EFFECT_SOLID) {
*yPosPtr += (sp10.unk18 + g_Player.colFloor[i].unk10);
*vram_ptr |= sp30;
return;
Expand Down Expand Up @@ -1647,7 +1648,7 @@ static void CheckCeiling(void) {
}
collidereffects = collider.effects;
if (!(collidereffects & 1)) {
if ((g_Player.colCeiling[i].effects != 1) ||
if ((g_Player.colCeiling[i].effects != EFFECT_SOLID) ||
(PLAYER.velocityY <= 0)) {
*vram_ptr |= 2;
if (!(*vram_ptr & 1) &&
Expand Down Expand Up @@ -1693,7 +1694,7 @@ static void CheckCeiling(void) {
g_Player.colFloor[3].unk8 = g_Player.colFloor[3].unk10;
}
}
if ((collidereffects & EFFECT_UNK_0800) == 0) {
if ((collidereffects & EFFECT_UNK_0800) == EFFECT_NONE) {
*vram_ptr |=
(EFFECT_UNK_0800 | EFFECT_UNK_0002 |
((collidereffects >> 4) &
Expand Down Expand Up @@ -1722,7 +1723,7 @@ static void CheckCeiling(void) {
argX = *xPosPtr + g_SensorsCeiling[0].x;
argY = (*yPosPtr + g_SensorsCeiling[0].y) - 10;
CheckCollision(argX, argY, &collider, 0);
if ((collider.effects & EFFECT_SOLID) != 0) {
if ((collider.effects & EFFECT_SOLID) != EFFECT_NONE) {
return;
}
for (i = 2; i < NUM_HORIZONTAL_SENSORS; i++) {
Expand Down Expand Up @@ -1823,7 +1824,7 @@ static void CheckWallRight(void) {
argX = *xPosPtr + g_SensorsWall[i].x + g_Player.colWall[i].unk4 - 1;
argY = *yPosPtr + g_SensorsWall[i].y;
CheckCollision(argX, argY, &collider, 0);
if ((collider.effects & EFFECT_SOLID) == 0) {
if ((collider.effects & EFFECT_SOLID) == EFFECT_NONE) {
*vram_ptr |= 4;
*xPosPtr += g_Player.colWall[i].unk4;
return;
Expand Down Expand Up @@ -1905,7 +1906,7 @@ static void CheckWallLeft(void) {
argX = *xPosPtr + g_SensorsWall[i].x + g_Player.colWall[i].unkC + 1;
argY = *yPosPtr + g_SensorsWall[i].y;
CheckCollision(argX, argY, &collider, 0);
if ((collider.effects & EFFECT_SOLID) == 0) {
if ((collider.effects & EFFECT_SOLID) == EFFECT_NONE) {
*vram_ptr |= 8;
*xPosPtr += g_Player.colWall[i].unkC;
return;
Expand Down
8 changes: 4 additions & 4 deletions src/dra/71830.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bool func_80111DE8(bool mistReset) {
CheckCollision(
PLAYER.posX.i.hi + 9, PLAYER.posY.i.hi + yOffset - 1, &collider1, 0);
if (mistReset && (collider1.effects & EFFECT_MIST_ONLY)) {
collider1.effects = 0;
collider1.effects = EFFECT_NONE;
}
filtered_effects =
collider1.effects & (EFFECT_UNK_8000 | EFFECT_UNK_4000 |
Expand All @@ -162,7 +162,7 @@ bool func_80111DE8(bool mistReset) {
CheckCollision(colliderXOffset + playerX + 8,
PLAYER.posY.i.hi + yOffset - 1, &collider2, 0);
if (mistReset && (collider2.effects & EFFECT_MIST_ONLY)) {
collider1.effects = 0;
collider1.effects = EFFECT_NONE;
}
if (!(collider2.effects & EFFECT_SOLID)) {
PLAYER.posX.i.hi += collider1.unk4;
Expand All @@ -173,7 +173,7 @@ bool func_80111DE8(bool mistReset) {
CheckCollision(
PLAYER.posX.i.hi - 9, PLAYER.posY.i.hi + yOffset - 1, &collider1, 0);
if (mistReset && (collider1.effects & EFFECT_MIST_ONLY)) {
collider1.effects = 0;
collider1.effects = EFFECT_NONE;
}
filtered_effects =
collider1.effects & (EFFECT_UNK_8000 | EFFECT_UNK_4000 |
Expand All @@ -193,7 +193,7 @@ bool func_80111DE8(bool mistReset) {
CheckCollision(colliderXOffset + playerX - 8,
PLAYER.posY.i.hi + yOffset - 1, &collider2, 0);
if (mistReset && (collider2.effects & EFFECT_MIST_ONLY)) {
collider1.effects = 0;
collider1.effects = EFFECT_NONE;
}
if (!(collider2.effects & EFFECT_SOLID)) {
PLAYER.posX.i.hi += collider1.unkC;
Expand Down
27 changes: 15 additions & 12 deletions src/dra/72BB0.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ s32 func_80113D7C(s16 damageAmount) {
}
step = PLAYER.step;
temp_s1 = PLAYER.step_s;
damage.effects = 0;
damage.effects = EFFECT_NONE;
damage.damageKind = 0;
SetPlayerStep(Player_Kill);
func_80115394(&damage, step, temp_s1);
Expand Down Expand Up @@ -792,21 +792,21 @@ void AlucardHandleDamage(DamageParam* damage, s16 arg1, s16 arg2) {
g_Player.unk40 = 0x8166;
g_Player.timers[2] = 6;
PlaySfx(g_SfxPainGrunts[sfxIndex]);
if (damage->effects & 0x100) {
if (damage->effects & EFFECT_UNK_0100) {
g_Player.timers[1] =
GetStatusAilmentTimer(STATUS_AILMENT_CURSE, 0x400);
g_Player.unk40 = 0x8165;
CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(47, 2), 0);
CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(44, 0x17), 0);
PlaySfx(SFX_VO_ALU_WHAT);
} else if (damage->effects & 0x80) {
} else if (damage->effects & EFFECT_SOLID_FROM_BELOW) {
g_Player.timers[0] =
GetStatusAilmentTimer(STATUS_AILMENT_POISON, 0xFFF);
g_Player.unk40 = 0x8164;
CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(44, 0x16), 0);
CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(47, 1), 0);
PlaySfx(SFX_VO_ALU_WHAT);
} else if (damage->effects & 0x8000) {
} else if (damage->effects & EFFECT_UNK_8000) {
PlaySfx(SFX_FM_EXPLODE_SWISHES);
CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(44, 0x45), 0);
g_Player.unk40 = 0x8160;
Expand All @@ -818,32 +818,32 @@ void AlucardHandleDamage(DamageParam* damage, s16 arg1, s16 arg2) {
CreateEntFactoryFromEntity(g_CurrentEntity, 18, 0);
g_Player.timers[2] = 16;
}
} else if (damage->effects & 0x4000) {
} else if (damage->effects & EFFECT_UNK_4000) {
CreateEntFactoryFromEntity(g_CurrentEntity, 45, 0);
CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(44, 0x46), 0);
g_Player.timers[2] = 24;
g_Player.unk40 = 0x8102;
} else if (damage->effects & 0x2000) {
} else if (damage->effects & EFFECT_UNK_2000) {
CreateEntFactoryFromEntity(g_CurrentEntity, 46, 0);
g_Player.timers[2] = 12;
g_Player.unk40 = 0x8169;
PLAYER.ext.player.anim = 0x2E;
} else {
if (damage->effects & 0x1000) {
if (damage->effects & EFFECT_UNK_1000) {
CreateEntFactoryFromEntity(g_CurrentEntity, 119, 0);
CreateEntFactoryFromEntity(
g_CurrentEntity, FACTORY(44, 0x68), 0);
g_Player.timers[2] = 8;
g_Player.unk40 = 0x8168;
}
if (damage->effects & 0x800) {
if (damage->effects & EFFECT_UNK_0800) {
CreateEntFactoryFromEntity(g_CurrentEntity, 113, 0);
CreateEntFactoryFromEntity(
g_CurrentEntity, FACTORY(44, 0x62), 0);
g_Player.timers[2] = 16;
g_Player.unk40 = 0x8164;
}
if (damage->effects & 0x40) {
if (damage->effects & EFFECT_SOLID_FROM_ABOVE) {
PlaySfx(SFX_WEAPON_STAB_B);
g_Player.unk40 = 0x8166;
CreateEntFactoryFromEntity(
Expand All @@ -857,7 +857,10 @@ void AlucardHandleDamage(DamageParam* damage, s16 arg1, s16 arg2) {
g_CurrentEntity, FACTORY(20, 5), 0);
g_Player.timers[2] = 16;
}
} else if (!(damage->effects & 0xFAC0)) {
} else if (!(damage->effects &
(EFFECT_UNK_8000 | EFFECT_UNK_4000 | EFFECT_UNK_2000 |
EFFECT_UNK_1000 | EFFECT_UNK_0800 | EFFECT_UNK_0200 |
EFFECT_SOLID_FROM_BELOW | EFFECT_SOLID_FROM_ABOVE))) {
CreateEntFactoryFromEntity(
g_CurrentEntity, FACTORY(44, 0x58), 0);
}
Expand Down Expand Up @@ -899,14 +902,14 @@ void AlucardHandleDamage(DamageParam* damage, s16 arg1, s16 arg2) {
if ((g_StageId != STAGE_BO6) && (g_StageId != STAGE_RBO6) &&
(g_StageId != STAGE_DRE)) {
for (i = 2; i < NUM_VERTICAL_SENSORS; i++) {
if (g_Player.colWall[i].effects & 2) {
if (g_Player.colWall[i].effects & EFFECT_UNK_0002) {
break;
}
}
if (i == NUM_VERTICAL_SENSORS) {
for (i = NUM_VERTICAL_SENSORS + 2; i < NUM_VERTICAL_SENSORS * 2;
i++) {
if (g_Player.colWall[i].effects & 2) {
if (g_Player.colWall[i].effects & EFFECT_UNK_0002) {
break;
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/dra/7A4D0.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,8 @@ void func_8011B5A4(Entity* self) {
}
if (paramsHi == 4) {
for (i = paramsLo * 2; i < LEN(D_800AD5E0); i++) {
if (g_Player.colWall[D_800AD5E0[i]].effects & 3) {
if (g_Player.colWall[D_800AD5E0[i]].effects &
(EFFECT_UNK_0002 | EFFECT_SOLID)) {
break;
}
}
Expand All @@ -621,7 +622,8 @@ void func_8011B5A4(Entity* self) {
}
if (paramsHi == 8) { /* switch 1 */
for (i = paramsLo * 2; i < LEN(D_800AD5F0); i++) {
if (g_Player.colWall[D_800AD5F0[i]].effects & 3) {
if (g_Player.colWall[D_800AD5F0[i]].effects &
(EFFECT_UNK_0002 | EFFECT_SOLID)) {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dra/843B0.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ s32 CheckHolyWaterCollision(s32 baseY, s32 baseX) {
if ((colRes1 & colSet1) == EFFECT_SOLID ||
(colRes1 & colSet1) == (EFFECT_UNK_0800 | EFFECT_SOLID)) {
colRes2 = res2.effects & colSetNo800;
if (!((s16)res2.effects & 1)) {
if (!((s16)res2.effects & EFFECT_SOLID)) {
g_CurrentEntity->posY.i.hi = y;
return 1;
}
Expand Down
Loading

0 comments on commit babbbdd

Please sign in to comment.