From babbbdddb6ff400a56b9cadf86e1395f9e5b4b9b Mon Sep 17 00:00:00 2001 From: Jonathan Hohle Date: Wed, 4 Dec 2024 08:06:30 -0700 Subject: [PATCH] `Collider.effects` Lint (#1968) Linter for `Collider.effects`. --- include/game.h | 1 + src/dra/5D5BC.c | 16 +++- src/dra/692E8.c | 47 +++++----- src/dra/71830.c | 8 +- src/dra/72BB0.c | 27 +++--- src/dra/7A4D0.c | 6 +- src/dra/843B0.c | 2 +- src/dra/collider.c | 84 +++++++++-------- src/ric/1AC60.c | 5 +- src/ric/1CB04.c | 12 +-- src/ric/211D0.c | 36 +++++--- src/ric/24788.c | 6 +- src/ric/2A060.c | 2 +- src/servant/tt_000/bat.c | 4 +- src/st/np3/4D540.c | 6 +- src/st/nz0/e_spittle_bone.c | 4 +- src/st/unk_collision_func4.h | 8 +- src/weapon/w_020.c | 6 +- src/weapon/w_021.c | 10 +- .../src/bit_flag_line_transformer.rs | 3 + tools/lints/sotn-lint/src/collider_effects.rs | 92 +++++++++++++++++++ tools/lints/sotn-lint/src/enum_statement.rs | 3 +- tools/lints/sotn-lint/src/main.rs | 3 + 23 files changed, 258 insertions(+), 133 deletions(-) create mode 100644 tools/lints/sotn-lint/src/collider_effects.rs diff --git a/include/game.h b/include/game.h index 6af4bc793c..090e04e34b 100644 --- a/include/game.h +++ b/include/game.h @@ -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, diff --git a/src/dra/5D5BC.c b/src/dra/5D5BC.c index 777705cefa..97cb971748 100644 --- a/src/dra/5D5BC.c +++ b/src/dra/5D5BC.c @@ -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) { @@ -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; } @@ -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; @@ -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; diff --git a/src/dra/692E8.c b/src/dra/692E8.c index f1d255c382..07c2ecb2ba 100644 --- a/src/dra/692E8.c +++ b/src/dra/692E8.c @@ -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; } } } @@ -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; } } } @@ -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(); @@ -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; } } @@ -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; @@ -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) { @@ -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; } @@ -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; @@ -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; @@ -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) && @@ -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) & @@ -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++) { @@ -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; @@ -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; diff --git a/src/dra/71830.c b/src/dra/71830.c index 10dc90aa68..fb06f4f72b 100644 --- a/src/dra/71830.c +++ b/src/dra/71830.c @@ -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 | @@ -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; @@ -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 | @@ -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; diff --git a/src/dra/72BB0.c b/src/dra/72BB0.c index 8a468de173..1b03291f0e 100644 --- a/src/dra/72BB0.c +++ b/src/dra/72BB0.c @@ -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); @@ -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; @@ -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( @@ -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); } @@ -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; } } diff --git a/src/dra/7A4D0.c b/src/dra/7A4D0.c index f657f62452..58e9ee2005 100644 --- a/src/dra/7A4D0.c +++ b/src/dra/7A4D0.c @@ -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; } } @@ -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; } } diff --git a/src/dra/843B0.c b/src/dra/843B0.c index 688f667b18..7cc286c9ea 100644 --- a/src/dra/843B0.c +++ b/src/dra/843B0.c @@ -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; } diff --git a/src/dra/collider.c b/src/dra/collider.c index 4309455c22..70dc442588 100644 --- a/src/dra/collider.c +++ b/src/dra/collider.c @@ -68,7 +68,7 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { g_Tilemap.fg[(absX >> 4) + (absY >> 4) * g_Tilemap.hSize * new_var]; colType = g_Tilemap.tileDef->collision[colTile]; } - res->effects = 0; + res->effects = EFFECT_NONE; res->unk4 = res->unk14 = -(absX & 0xF); res->unk8 = res->unk18 = -(absY & 0xF); res->unkC = res->unk1C = res->unk14 + 0xF; @@ -98,7 +98,7 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { res->effects = EFFECT_UNK_8000 | EFFECT_SOLID | EFFECT_UNK_0002; } } else { - res->effects = 1; + res->effects = EFFECT_SOLID; } break; case COLLISION_TYPE_RIGHT_45_ANGLE: @@ -145,9 +145,9 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { temp_v0_6 = res->unk20 - res->unk1C; res->unk18 = temp_v0_6; res->unk1C = (-temp_v0_6); - res->effects = 0xC001; + res->effects = EFFECT_UNK_8000 | EFFECT_UNK_4000 | EFFECT_SOLID; } else { - res->effects = 0xC000; + res->effects = EFFECT_UNK_8000 | EFFECT_UNK_4000; } break; case 0x8C: @@ -155,9 +155,10 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { case 0x8D: if (var_a1 + res->unk1C >= res->unk20 * 2) { res->unk18 = res->unk20 - (var_a1 + res->unk1C >> 1); - res->effects = 0xD001; + res->effects = EFFECT_UNK_8000 | EFFECT_UNK_4000 | EFFECT_UNK_1000 | + EFFECT_SOLID; } else { - res->effects = 0xD000; + res->effects = EFFECT_UNK_8000 | EFFECT_UNK_4000 | EFFECT_UNK_1000; } break; case 0x9A: @@ -171,9 +172,10 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { temp_v1_7 = var_a1 + res->unk1C; if (temp_v1_7 >= temp_a0_3 * 4) { res->unk18 = temp_a0_3 - (temp_v1_7 >> 2); - res->effects = 0xE001; + res->effects = EFFECT_UNK_8000 | EFFECT_UNK_4000 | EFFECT_UNK_2000 | + EFFECT_SOLID; } else { - res->effects = 0xE000; + res->effects = EFFECT_UNK_8000 | EFFECT_UNK_4000 | EFFECT_UNK_2000; } break; case 0x85: @@ -189,12 +191,12 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { temp_a0_2 = 1; res->unk20 = res->unk20 + temp_a0_2 + sp38.unk20; } - res->effects = sp38.effects |= 3; + res->effects = sp38.effects |= EFFECT_UNK_0002 | EFFECT_SOLID; } else { - res->effects = 0x803; + res->effects = EFFECT_UNK_0800 | EFFECT_UNK_0002 | EFFECT_SOLID; } } else { - res->effects = 1; + res->effects = EFFECT_SOLID; } break; case COLLISION_TYPE_RIGHT_CEILING_45_ANGLE: @@ -203,9 +205,9 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { temp_v0_8 = temp_a0_4 - res->unk20; res->unk14 = temp_v0_8; res->unk20 = -temp_v0_8; - res->effects = 0x801; + res->effects = EFFECT_UNK_0800 | EFFECT_SOLID; } else { - res->effects = 0x800; + res->effects = EFFECT_UNK_0800; } break; case 0x8E: @@ -216,9 +218,9 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { temp_v0_9 = temp_a0_5 - res->unk20 * 2; res->unk14 = temp_v0_9; res->unk20 = -temp_v0_9 / 2; - res->effects = 0x1801; + res->effects = EFFECT_UNK_1000 | EFFECT_UNK_0800 | EFFECT_SOLID; } else { - res->effects = 0x1800; + res->effects = EFFECT_UNK_1000 | EFFECT_UNK_0800; } break; case 0x9E: @@ -237,20 +239,20 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { var_v0_2 += 3; } res->unk20 = (s32)(var_v0_2 >> 2); - res->effects = 0x2801; + res->effects = EFFECT_UNK_2000 | EFFECT_UNK_0800 | EFFECT_SOLID; } else { - res->effects = 0x2800; + res->effects = EFFECT_UNK_2000 | EFFECT_UNK_0800; } break; case COLLISION_TYPE_LEFT_CEILING_45_ANGLE: if (res->unk1C + res->unk20 >= 0xF) { - res->effects = 0x4801; + res->effects = EFFECT_UNK_4000 | EFFECT_UNK_0800 | EFFECT_SOLID; temp_v0_11 = res->unk18 + 0xF; temp_v0_11 = temp_v0_11 + res->unk14; res->unk20 = temp_v0_11; res->unk1C = (u32)temp_v0_11; } else { - res->effects = 0x4800; + res->effects = EFFECT_UNK_4000 | EFFECT_UNK_0800; } break; case 0x92: @@ -258,12 +260,13 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { case 0x93: if (var_a1 + res->unk1C + res->unk20 * 2 >= 0x1E) { temp_a0_5 = 0xF; - res->effects = 0x5801; + res->effects = EFFECT_UNK_4000 | EFFECT_UNK_1000 | EFFECT_UNK_0800 | + EFFECT_SOLID; res->unk20 = ((var_a1 + res->unk14 - temp_a0_5) >> 1) + (res->unk18 + temp_a0_5); ; } else { - res->effects = 0x5800; + res->effects = EFFECT_UNK_4000 | EFFECT_UNK_1000 | EFFECT_UNK_0800; } break; case 0xA4: @@ -275,62 +278,63 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { case 0xA7: new_var2 = 0xF; if (var_a1 + res->unk1C + res->unk20 * 4 >= 0x3C) { - res->effects = 0x6801; + res->effects = EFFECT_UNK_4000 | EFFECT_UNK_2000 | EFFECT_UNK_0800 | + EFFECT_SOLID; res->unk20 = (((var_a1 + res->unk14) - 0x2D) >> 2) + (res->unk18 + new_var2); } else { - res->effects = 0x6800; + res->effects = EFFECT_UNK_4000 | EFFECT_UNK_2000 | EFFECT_UNK_0800; } break; case 0xFF: if (res->unk20 < 8) { - res->effects = 3; + res->effects = EFFECT_UNK_0002 | EFFECT_SOLID; res->unk18 = res->unk18 + 8; } break; case 0xFE: if (res->unk20 >= 8) { - res->effects = 3; + res->effects = EFFECT_UNK_0002 | EFFECT_SOLID; res->unk20 -= 8; } break; case 0xFD: if (res->unk20 < 8) { - res->effects = 1; + res->effects = EFFECT_SOLID; res->unk18 += 8; } break; case 0xFC: if (res->unk20 >= 8) { - res->effects = 1; + res->effects = EFFECT_SOLID; res->unk20 -= 8; } break; case 0xFB: - res->effects = 4; + res->effects = EFFECT_QUICKSAND; break; case 0xFA: if (res->unk20 < 8) { if (1) { - res->effects = 4; + res->effects = EFFECT_QUICKSAND; } res->unk18 += 8; } break; case 0xF9: if (res->unk20 < 8) { - res->effects = 8; + res->effects = EFFECT_WATER; res->unk18 += 8; } break; case 0xF8: - res->effects = 0x13; + res->effects = EFFECT_MIST_ONLY | EFFECT_UNK_0002 | EFFECT_SOLID; break; case 0xF4: case 0xF5: case 0xF6: case 0xF7: - res->effects = 0x20; + res->effects = EFFECT_UNK_0020; break; case 0xEE: case 0xEF: @@ -338,44 +342,44 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) { case 0xF1: case 0xF2: case 0xF3: - res->effects = 3; + res->effects = EFFECT_UNK_0002 | EFFECT_SOLID; break; case COLLISION_TYPE_WATER: - res->effects = 8; + res->effects = EFFECT_WATER; break; case 0xEA: if (res->unk20 >= 8) { - res->effects = 8; + res->effects = EFFECT_WATER; res->unk20 -= 8; } break; case 0xE9: if (res->unk20 >= 8) { - res->effects = 4; + res->effects = EFFECT_QUICKSAND; res->unk20 -= 8; } break; case 0xE8: if (res->unk20 < 8) { - res->effects = 0x41; + res->effects = EFFECT_SOLID_FROM_ABOVE | EFFECT_SOLID; res->unk18 += 8; } break; case COLLISION_TYPE_FLAT_DROP_THROUGH: if (res->unk20 >= 8) { - res->effects = 0x41; + res->effects = EFFECT_SOLID_FROM_ABOVE | EFFECT_SOLID; res->unk20 -= 8; } break; case 0xE6: if (res->unk20 < 8) { - res->effects = 0x81; + res->effects = EFFECT_SOLID_FROM_BELOW | EFFECT_SOLID; res->unk18 += 8; } break; case 0xE5: if (res->unk20 >= 8) { - res->effects = 0x81; + res->effects = EFFECT_SOLID_FROM_BELOW | EFFECT_SOLID; res->unk20 -= 8; } break; diff --git a/src/ric/1AC60.c b/src/ric/1AC60.c index f1dd668de6..eeebc770a4 100644 --- a/src/ric/1AC60.c +++ b/src/ric/1AC60.c @@ -244,10 +244,11 @@ static void CheckStageCollision(bool arg0) { argX = PLAYER.posX.i.hi + g_RicSensorsFloor[i].x; argY = PLAYER.posY.i.hi + g_RicSensorsFloor[i].y; g_api.CheckCollision(argX, argY, &g_Player.colFloor[i], 0); - if (g_Player.timers[PL_T_7] && (g_Player.colFloor[i].effects & 0x40)) { + if (g_Player.timers[PL_T_7] && + (g_Player.colFloor[i].effects & EFFECT_SOLID_FROM_ABOVE)) { g_api.CheckCollision(argX, argY + 0xC, &collider, 0); if (!(collider.effects & EFFECT_SOLID)) { - g_Player.colFloor[i].effects = 0; + g_Player.colFloor[i].effects = EFFECT_NONE; } } } diff --git a/src/ric/1CB04.c b/src/ric/1CB04.c index 5a0e4404b3..782e62b256 100644 --- a/src/ric/1CB04.c +++ b/src/ric/1CB04.c @@ -686,7 +686,7 @@ void RicHandleHit( PLAYER.velocityX /= 2; PLAYER.velocityY = 0; PLAYER.step_s = 5; - damage.effects = 0; + damage.effects = EFFECT_NONE; damage.damageKind = 1; damage.damageTaken = g_Player.damageTaken; if (g_api.CalcPlayerDamage(&damage)) { @@ -699,14 +699,14 @@ void RicHandleHit( 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; } } @@ -728,7 +728,7 @@ void RicHandleHit( g_api.PlaySfx(SFX_WALL_DEBRIS_B); g_api.func_80102CD8(2); PLAYER.step_s = 1; - damage.effects = 0; + damage.effects = EFFECT_NONE; damage.damageKind = 1; damage.damageTaken = g_Player.damageTaken; if (g_api.CalcPlayerDamage(&damage)) { @@ -747,7 +747,7 @@ void RicHandleHit( RicCreateEntFactoryFromEntity( g_CurrentEntity, FACTORY(BP_SKID_SMOKE_2, 8), 0); } - damage.effects = 0; + damage.effects = EFFECT_NONE; damage.damageKind = 1; damage.damageTaken = g_Player.damageTaken; if (g_api.CalcPlayerDamage(&damage)) { @@ -840,7 +840,7 @@ void RicHandleBossGrab(void) { case 1: // Effectively a switch on g_Player.unk60 if (g_Player.unk60 == 3) { - damage.effects = 0; + damage.effects = EFFECT_NONE; damage.damageKind = 1; damage.damageTaken = g_Player.damageTaken; if (g_api.CalcPlayerDamage(&damage)) { diff --git a/src/ric/211D0.c b/src/ric/211D0.c index 35c13a36d4..385b5b963e 100644 --- a/src/ric/211D0.c +++ b/src/ric/211D0.c @@ -546,9 +546,12 @@ void func_8015E484(void) { &g_Player.colFloor[i], 0); } - if ((g_Player.colFloor[1].effects & 0x81) == 1 || - (g_Player.colFloor[2].effects & 0x81) == 1 || - (g_Player.colFloor[3].effects & 0x81) == 1) { + if ((g_Player.colFloor[1].effects & + (EFFECT_SOLID_FROM_BELOW | EFFECT_SOLID)) == 1 || + (g_Player.colFloor[2].effects & + (EFFECT_SOLID_FROM_BELOW | EFFECT_SOLID)) == 1 || + (g_Player.colFloor[3].effects & + (EFFECT_SOLID_FROM_BELOW | EFFECT_SOLID)) == 1) { PLAYER.velocityY = 0; PLAYER.posY.i.hi -= 1; collision = 1; @@ -573,9 +576,12 @@ void func_8015E484(void) { &g_Player.colCeiling[i], 0); } - if ((g_Player.colCeiling[1].effects & 0x41) == 1 || - (g_Player.colCeiling[2].effects & 0x41) == 1 || - (g_Player.colCeiling[3].effects & 0x41) == 1) { + if ((g_Player.colCeiling[1].effects & + (EFFECT_SOLID_FROM_ABOVE | EFFECT_SOLID)) == 1 || + (g_Player.colCeiling[2].effects & + (EFFECT_SOLID_FROM_ABOVE | EFFECT_SOLID)) == 1 || + (g_Player.colCeiling[3].effects & + (EFFECT_SOLID_FROM_ABOVE | EFFECT_SOLID)) == 1) { PLAYER.velocityY = 0; PLAYER.posY.i.hi += 1; collision = 1; @@ -702,14 +708,14 @@ void RicCheckFloor(void) { 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) { @@ -718,7 +724,7 @@ void RicCheckFloor(void) { argX = *xPosPtr + g_RicSensorsFloor[0].x; argY = *yPosPtr + g_RicSensorsFloor[0].y + 10; g_api.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; } @@ -749,7 +755,7 @@ void RicCheckFloor(void) { argX = var_a1 + (*xPosPtr + g_RicSensorsFloor[i].x); argY = *yPosPtr + g_RicSensorsFloor[i].y; g_api.CheckCollision(argX, argY, &sp10, 0); - if (sp10.effects & 1) { + if (sp10.effects & EFFECT_SOLID) { *yPosPtr += sp10.unk18; *vram_ptr |= temp_s7; return; @@ -765,7 +771,7 @@ void RicCheckFloor(void) { argX = var_a1 + (*xPosPtr + g_RicSensorsFloor[i].x); argY = *yPosPtr + g_RicSensorsFloor[i].y + g_Player.colFloor[i].unk10; g_api.CheckCollision(argX, argY, &sp10, 0); - if (sp10.effects & 1) { + if (sp10.effects & EFFECT_SOLID) { *yPosPtr += (sp10.unk18 + g_Player.colFloor[i].unk10); *vram_ptr |= temp_s7; return; @@ -863,7 +869,7 @@ void RicCheckCeiling(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) & @@ -894,7 +900,7 @@ void RicCheckCeiling(void) { argX = *xPosPtr + g_RicSensorsCeiling[0].x; argY = (*yPosPtr + g_RicSensorsCeiling[0].y) - 10; g_api.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++) { @@ -989,7 +995,7 @@ void RicCheckWallRight(void) { *xPosPtr + g_RicSensorsWall[i].x + g_Player.colWall[i].unk4 - 1; argY = *yPosPtr + g_RicSensorsWall[i].y; g_api.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; @@ -1064,7 +1070,7 @@ void RicCheckWallLeft(void) { *xPosPtr + g_RicSensorsWall[i].x + g_Player.colWall[i].unkC + 1; argY = *yPosPtr + g_RicSensorsWall[i].y; g_api.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; diff --git a/src/ric/24788.c b/src/ric/24788.c index 3ff24e90cc..d1c592bccc 100644 --- a/src/ric/24788.c +++ b/src/ric/24788.c @@ -343,7 +343,8 @@ void RicEntitySmokePuff(Entity* self) { } if (paramsHi == 4) { for (i = paramsLo * 2; i < LEN(sensors1_80154CE4); i++) { - if (g_Player.colWall[sensors1_80154CE4[i]].effects & 3) { + if (g_Player.colWall[sensors1_80154CE4[i]].effects & + (EFFECT_UNK_0002 | EFFECT_SOLID)) { break; } } @@ -362,7 +363,8 @@ void RicEntitySmokePuff(Entity* self) { } if (paramsHi == 8) { for (i = paramsLo * 2; i < LEN(sensors2_80154CF4); i++) { - if (g_Player.colWall[sensors2_80154CF4[i]].effects & 3) { + if (g_Player.colWall[sensors2_80154CF4[i]].effects & + (EFFECT_UNK_0002 | EFFECT_SOLID)) { break; } } diff --git a/src/ric/2A060.c b/src/ric/2A060.c index 18ba547d68..04539d83f9 100644 --- a/src/ric/2A060.c +++ b/src/ric/2A060.c @@ -1067,7 +1067,7 @@ s32 RicCheckHolyWaterCollision(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; } diff --git a/src/servant/tt_000/bat.c b/src/servant/tt_000/bat.c index 92f6f9744b..17628c43bd 100644 --- a/src/servant/tt_000/bat.c +++ b/src/servant/tt_000/bat.c @@ -226,13 +226,13 @@ bool Unused_CheckCollision(s16 x, s16 y, s16* outX, s16* outY) { s32 curY; g_api.CheckCollision(x, y, &s_UnusedCollider, 0); - if (s_UnusedCollider.effects & 1) { + if (s_UnusedCollider.effects & EFFECT_SOLID) { return 0; } for (curY = y - 16; curY > 0; curY -= 16) { g_api.CheckCollision(x, curY, &s_UnusedCollider, 0); - switch (s_UnusedCollider.effects & 0x801) { + switch (s_UnusedCollider.effects & (EFFECT_UNK_0800 | EFFECT_SOLID)) { case 0: break; case 1: diff --git a/src/st/np3/4D540.c b/src/st/np3/4D540.c index 0f014ec467..01a9186c58 100644 --- a/src/st/np3/4D540.c +++ b/src/st/np3/4D540.c @@ -277,10 +277,10 @@ void func_801CE04C(Entity* entity, Collider* collider) { g_api.CheckCollision( entity->posX.i.hi, (s16)(entity->posY.i.hi + collider->unk18), collider, 0); - if (collider->effects & 1) { + if (collider->effects & EFFECT_SOLID) { var_s0 = 1; - if (collider->effects & 0x8000) { - if (collider->effects & 0x4000) { + if (collider->effects & EFFECT_UNK_8000) { + if (collider->effects & EFFECT_UNK_4000) { if (g_CurrentEntity->facingLeft != 0) { var_s0 = 4; } else { diff --git a/src/st/nz0/e_spittle_bone.c b/src/st/nz0/e_spittle_bone.c index 7904bd60b0..0f42091585 100644 --- a/src/st/nz0/e_spittle_bone.c +++ b/src/st/nz0/e_spittle_bone.c @@ -229,7 +229,7 @@ void EntitySpittleBoneSpit(Entity* self) { MoveEntity(); self->velocityY += FIX(0.0625); g_api.CheckCollision(self->posX.i.hi, self->posY.i.hi, &collider, 0); - if (collider.effects != 0) { + if (collider.effects != EFFECT_NONE) { PlaySfxPositional(NA_SE_EN_SPITTLEBONE_ACID_SPLAT); EntityExplosionVariantsSpawner(self, 1, 2, 0, 0, 5, 0); self->animCurFrame = 0; @@ -291,7 +291,7 @@ void EntitySpittleBoneSpit(Entity* self) { if (LOW(prim->x3) > 0) { g_api.CheckCollision( prim->x0, (s16)(prim->y0 + 16), &collider, 0); - if (collider.effects != 0) { + if (collider.effects != EFFECT_NONE) { prim->drawMode = DRAW_HIDE; } } diff --git a/src/st/unk_collision_func4.h b/src/st/unk_collision_func4.h index 80252fb120..ae74311019 100644 --- a/src/st/unk_collision_func4.h +++ b/src/st/unk_collision_func4.h @@ -18,7 +18,7 @@ u8 UnkCollisionFunc4(s32 arg0) { g_CurrentEntity->posY.i.hi += 3; g_api.CheckCollision(g_CurrentEntity->posX.i.hi, g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { + if (collider.effects != EFFECT_NONE) { collEff = collider.effects; g_CurrentEntity->posY.i.hi += collider.unk18; g_api.CheckCollision( @@ -53,7 +53,7 @@ u8 UnkCollisionFunc4(s32 arg0) { g_CurrentEntity->posY.i.hi -= 3; g_api.CheckCollision(g_CurrentEntity->posX.i.hi, g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { + if (collider.effects != EFFECT_NONE) { collEff = collider.effects; g_CurrentEntity->posY.i.hi += collider.unk20; g_api.CheckCollision( @@ -88,7 +88,7 @@ u8 UnkCollisionFunc4(s32 arg0) { g_CurrentEntity->posX.i.hi += 3; g_api.CheckCollision(g_CurrentEntity->posX.i.hi, g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { + if (collider.effects != EFFECT_NONE) { collEff = collider.effects; g_CurrentEntity->posX.i.hi += collider.unk14; g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi - 4), @@ -122,7 +122,7 @@ u8 UnkCollisionFunc4(s32 arg0) { g_CurrentEntity->posX.i.hi -= 3; g_api.CheckCollision(g_CurrentEntity->posX.i.hi, g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { + if (collider.effects != EFFECT_NONE) { collEff = collider.effects; g_CurrentEntity->posX.i.hi += collider.unk1C; g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi + 4), diff --git a/src/weapon/w_020.c b/src/weapon/w_020.c index 85adf92c5f..fd482c51b8 100644 --- a/src/weapon/w_020.c +++ b/src/weapon/w_020.c @@ -95,7 +95,7 @@ static void EntityWeaponAttack(Entity* self) { xVar = self->posX.i.hi + xOffset; yVar = self->posY.i.hi + yOffset; g_api.CheckCollision(xVar, yVar, &sp10, 0); - if (sp10.effects & 1) { + if (sp10.effects & EFFECT_SOLID) { self->posY.i.hi += sp10.unk18; self->animFrameDuration = self->animFrameIdx = 0; self->anim = D_90000_8017A864; @@ -111,7 +111,7 @@ static void EntityWeaponAttack(Entity* self) { xVar = self->posX.i.hi + xOffset; yVar = self->posY.i.hi + yOffset; g_api.CheckCollision(xVar, yVar, &sp10, 0); - if (sp10.effects & 2) { + if (sp10.effects & EFFECT_UNK_0002) { if (xOffset < 0) { self->posX.i.hi += sp10.unkC; } else { @@ -124,7 +124,7 @@ static void EntityWeaponAttack(Entity* self) { xVar = self->posX.i.hi + xOffset; yVar = self->posY.i.hi + yOffset; g_api.CheckCollision(xVar, yVar, &sp10, 0); - if (sp10.effects & 1) { + if (sp10.effects & EFFECT_SOLID) { self->posY.i.hi += sp10.unk20 + 1; self->velocityY = FIX(1.0); self->velocityX = self->velocityX / 2; diff --git a/src/weapon/w_021.c b/src/weapon/w_021.c index ff87988884..652df2ebf2 100644 --- a/src/weapon/w_021.c +++ b/src/weapon/w_021.c @@ -296,7 +296,7 @@ static void EntityWeaponAttack(Entity* self) { self->velocityY += FIX(20.0 / 128); g_api.CheckCollision( self->posX.i.hi, (s16)(self->posY.i.hi + 8), &sp10, 0); - if (sp10.effects & 1) { + if (sp10.effects & EFFECT_SOLID) { self->posY.i.hi += sp10.unk18; // Test for peanut. Peanut should bounce. if (((self->params >> 8) & 0x7F) == 6) { @@ -321,7 +321,7 @@ static void EntityWeaponAttack(Entity* self) { } g_api.CheckCollision( (s16)(xShift + self->posX.i.hi), self->posY.i.hi, &sp10, 0); - if (sp10.effects & 2) { + if (sp10.effects & EFFECT_UNK_0002) { if (xShift < 0) { self->posX.i.hi += sp10.unkC; } else { @@ -343,7 +343,7 @@ static void EntityWeaponAttack(Entity* self) { } g_api.CheckCollision( self->posX.i.hi, (s16)(yShift + self->posY.i.hi), &sp10, 0); - if (sp10.effects & 1) { + if (sp10.effects & EFFECT_SOLID) { self->posY.i.hi += (1 + sp10.unk20); self->velocityX /= 2; self->velocityY = FIX(1); @@ -478,7 +478,7 @@ s32 func_ptr_80170004(Entity* self) { xVar = self->posX.i.hi + xShift; yVar = self->posY.i.hi + yShift; g_api.CheckCollision(xVar, yVar, &sp10, 0); - if (sp10.effects & 1) { + if (sp10.effects & EFFECT_SOLID) { self->posY.i.hi += sp10.unk18; self->ext.timer.t = 0x200; self->step++; @@ -492,7 +492,7 @@ s32 func_ptr_80170004(Entity* self) { xVar = self->posX.i.hi + xShift; yVar = self->posY.i.hi + yShift; g_api.CheckCollision(xVar, yVar, &sp10, 0); - if (sp10.effects & 2) { + if (sp10.effects & EFFECT_UNK_0002) { if (xShift < 0) { self->posX.i.hi += sp10.unkC; } else { diff --git a/tools/lints/sotn-lint/src/bit_flag_line_transformer.rs b/tools/lints/sotn-lint/src/bit_flag_line_transformer.rs index cce6c8d1ea..53f49554b9 100644 --- a/tools/lints/sotn-lint/src/bit_flag_line_transformer.rs +++ b/tools/lints/sotn-lint/src/bit_flag_line_transformer.rs @@ -144,6 +144,9 @@ impl BitFlagLineTransformer where ::Err: Debug { if field_value.count_ones() > 1 && (operator == "^" || operator == "&" || operator == "|" || + operator == "==" || operator == "!=" || + operator == "<=" || operator == ">=" || + operator == "<" || operator == ">" || invert == "~" || inverted) { rvalue = format!("({})", rvalue); } diff --git a/tools/lints/sotn-lint/src/collider_effects.rs b/tools/lints/sotn-lint/src/collider_effects.rs new file mode 100644 index 0000000000..a68b29bc2e --- /dev/null +++ b/tools/lints/sotn-lint/src/collider_effects.rs @@ -0,0 +1,92 @@ +use lazy_static::lazy_static; + +use crate::line_transformer::LineTransformer; +use crate::bit_flag_line_transformer::BitFlagLineTransformer; + +pub struct ColliderEffectsTransformer { + transformer: BitFlagLineTransformer, +} + +lazy_static! { + static ref COLLIDER_EFFECTS: [(u16, &'static str); 16] = [ + (1 << 0, "EFFECT_SOLID"), + (1 << 1, "EFFECT_UNK_0002"), + (1 << 2, "EFFECT_QUICKSAND"), + (1 << 3, "EFFECT_WATER"), + (1 << 4, "EFFECT_MIST_ONLY"), + (1 << 5, "EFFECT_UNK_0020"), + (1 << 6, "EFFECT_SOLID_FROM_ABOVE"), + (1 << 7, "EFFECT_SOLID_FROM_BELOW"), + (1 << 8, "EFFECT_UNK_0100"), + (1 << 9, "EFFECT_UNK_0200"), + (1 << 10, "EFFECT_UNK_0400"), + (1 << 11, "EFFECT_UNK_0800"), + (1 << 12, "EFFECT_UNK_1000"), + (1 << 13, "EFFECT_UNK_2000"), + (1 << 14, "EFFECT_UNK_4000"), + (1 << 15, "EFFECT_UNK_8000"), + ]; +} + +impl ColliderEffectsTransformer { + pub fn new() -> Self { + Self { + transformer: BitFlagLineTransformer::::new( + "effects", "EFFECT_NONE", &COLLIDER_EFFECTS.iter().collect()), + } + } +} + +impl LineTransformer for ColliderEffectsTransformer { + fn transform_line(&self, line: &str) -> String { + self.transformer.transform_line(line) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use once_cell::sync::Lazy; + + static FT: Lazy = Lazy::new(|| ColliderEffectsTransformer::new()); + + #[test] + fn test_draw_flags_hex() { + let input_line = "self->effects = 0x5;"; + let expected_line = "self->effects = EFFECT_QUICKSAND | EFFECT_SOLID;"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } + + #[test] + fn test_draw_flags_decimal() { + let input_line = "self->effects = 5;"; + let expected_line = "self->effects = EFFECT_QUICKSAND | EFFECT_SOLID;"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } + + #[test] + fn test_draw_flags_zero() { + let input_line = "self->effects = 0;"; + let expected_line = "self->effects = EFFECT_NONE;"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } + + #[test] + fn test_draw_flags_zero_hex() { + let input_line = "self->effects = 0x0;"; + let expected_line = "self->effects = EFFECT_NONE;"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } + + #[test] + fn test_draw_flags_flags() { + let input_line = "self->effects = EFFECT_WATER;"; + let expected_line = "self->effects = EFFECT_WATER;"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } +} diff --git a/tools/lints/sotn-lint/src/enum_statement.rs b/tools/lints/sotn-lint/src/enum_statement.rs index 7ec99b4442..a696bae28d 100644 --- a/tools/lints/sotn-lint/src/enum_statement.rs +++ b/tools/lints/sotn-lint/src/enum_statement.rs @@ -27,7 +27,8 @@ impl EnumStatementMatcher { {} # * a field name (provided by format!) \s* # * optional whitespace ( # * <2> a binary operator, one of: - (?:(?:[&|=!^~]?)=) | # * any comparison operator + (?:(?:[&|^~]?)=) | # * an assignment operator + (?:(?:[!=<>]=)|[<>]) |# * a comparison operator (?:[&|^]) # * a bitwise operator ) \s* # * optional whitespace diff --git a/tools/lints/sotn-lint/src/main.rs b/tools/lints/sotn-lint/src/main.rs index 6dc4d6b1c0..66214c846c 100644 --- a/tools/lints/sotn-lint/src/main.rs +++ b/tools/lints/sotn-lint/src/main.rs @@ -2,6 +2,7 @@ use std::fs::File; use std::io::{BufRead, BufReader, Write}; mod bit_flag_line_transformer; +mod collider_effects; mod drawflags; mod drawmodes; mod enum_line_transformer; @@ -13,6 +14,7 @@ mod player_status; mod primitive_type; mod relics; +use collider_effects::ColliderEffectsTransformer; use drawflags::DrawFlagsTransformer; use drawmodes::DrawModeTransformer; use fixed::FixedTransformer; @@ -68,6 +70,7 @@ fn process_directory(dir_path: &str) { let transformers: Vec> = vec![ Box::new(fixed_transformer), Box::new(relics_transformer), + Box::new(ColliderEffectsTransformer::new()), Box::new(draw_mode_transformer), Box::new(flags_transformer), Box::new(draw_flags_transformer),