Skip to content

Commit

Permalink
Support Additional Enum Lint Detection
Browse files Browse the repository at this point in the history
`sotn-lint` can now find numeric enum values within equality
expressions (`==`, `!=`), inside the condition of logical expressions,
(`if`, `while`, `?:`, etc.), within compound statements, and if the
numeric value is the starting value of a mixed numeric and enum logical
expression (e.g. `self->flags = 15 | FLAG_FOO | FLAG_BAR;`).

Resolves Xeeynamo#1795.
  • Loading branch information
hohle committed Oct 17, 2024
1 parent 1123292 commit d513ea4
Show file tree
Hide file tree
Showing 19 changed files with 190 additions and 93 deletions.
8 changes: 4 additions & 4 deletions src/dra/42398.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ void func_800E414C(void) {
RoomTeleport* temp_a1;
s32 temp_a0;

if (!(D_8003C708.flags & 0x40)) {
if (!(D_8003C708.flags & FLAG_UNK_40)) {
return;
}

Expand All @@ -1058,7 +1058,7 @@ void func_800E414C(void) {
}
PlaySfx(0x80);
D_80097928 = 1;
if (D_8003C708.flags == 0x40) {
if (D_8003C708.flags == FLAG_UNK_40) {
g_Player.D_80072EFC = 0x18;
g_Player.padSim = PAD_LEFT;
} else {
Expand All @@ -1082,7 +1082,7 @@ void func_800E414C(void) {
if (!g_UseDisk) {
break;
}
if (D_8003C708.flags == 0x40 && PLAYER.posX.i.hi < 0x78) {
if (D_8003C708.flags == FLAG_UNK_40 && PLAYER.posX.i.hi < 0x78) {
func_801073C0();
g_CdStep = CdStep_LoadInit;
g_LoadFile = CdFile_StageChr;
Expand All @@ -1102,7 +1102,7 @@ void func_800E414C(void) {
if (!g_UseDisk) {
break;
}
if (D_8003C708.flags == 0x40 && PLAYER.posX.i.hi >= 0x89) {
if (D_8003C708.flags == FLAG_UNK_40 && PLAYER.posX.i.hi >= 0x89) {
func_801073C0();
g_CdStep = CdStep_LoadInit;
g_LoadFile = CdFile_StageChr;
Expand Down
16 changes: 8 additions & 8 deletions src/dra/5087C.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ void DrawMapCursor(void) {
bool func_800F27F4(s32 arg0) {
if (arg0 == 0) {
if (g_unkGraphicsStruct.D_800973FC != 0 || D_8006BB00 != 0 ||
D_8003C708.flags & 0x60) {
D_8003C708.flags & (FLAG_UNK_40 | FLAG_UNK_20)) {
return false;
}
D_801375C8 = 1;
Expand Down Expand Up @@ -1192,10 +1192,10 @@ void RunMainEngine(void) {
g_backbufferY = 0;
func_800F14CC();
LoadRoomLayer(D_801375BC.def->tileLayoutId);
if (D_8003C708.flags & 0x20) {
if (D_8003C708.flags & FLAG_UNK_20) {
LoadGfxAsync(ANIMSET_DRA(3));
}
if (D_8003C708.flags & 0x40) {
if (D_8003C708.flags & FLAG_UNK_40) {
LoadGfxAsync(ANIMSET_DRA(4));
}
D_80097910 = g_StagesLba[g_StageId].unk18;
Expand All @@ -1206,7 +1206,7 @@ void RunMainEngine(void) {
D_80097910 = MU_METAMORPHOSIS;
#endif
}
if ((D_8003C730 == 0) && !(D_8003C708.flags & 0x20)) {
if ((D_8003C730 == 0) && !(D_8003C708.flags & FLAG_UNK_20)) {
PlaySfx(D_80097910);
}
D_80097928 = 0;
Expand Down Expand Up @@ -1504,7 +1504,7 @@ void RunMainEngine(void) {
UnMuteCd();
} else {
UnMuteCd();
if (!(D_8003C708.flags & 0x60)) {
if (!(D_8003C708.flags & (FLAG_UNK_40 | FLAG_UNK_20))) {
PlaySfx(D_80097910);
if (D_80097910 != 0) {
D_80097928 = 0;
Expand Down Expand Up @@ -1643,7 +1643,7 @@ void RunMainEngine(void) {
D_801375A0 = PLAYER.posY.val;
PLAYER.posX.i.hi = D_801375C0 + g_Tilemap.scrollX.i.hi;
PLAYER.posY.i.hi = D_801375C4 + g_Tilemap.scrollY.i.hi;
if (D_8003C708.flags & 0x60) {
if (D_8003C708.flags & (FLAG_UNK_40 | FLAG_UNK_20)) {
LoadGfxAsync(ANIMSET_DRA(1));
}
func_800EA538(2);
Expand All @@ -1661,10 +1661,10 @@ void RunMainEngine(void) {
PLAYER.posY.i.hi = (u8)PLAYER.posY.i.hi;
PLAYER.posX.i.hi = (u8)PLAYER.posX.i.hi;
LoadRoomLayer(D_801375BC.def->tileLayoutId);
if (D_8003C708.flags & 0x20) {
if (D_8003C708.flags & FLAG_UNK_20) {
LoadGfxAsync(ANIMSET_DRA(3));
}
if (D_8003C708.flags & 0x40) {
if (D_8003C708.flags & FLAG_UNK_40) {
LoadGfxAsync(ANIMSET_DRA(4));
}
g_Tilemap.x =
Expand Down
2 changes: 1 addition & 1 deletion src/dra/8D3E8.c
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,7 @@ void EntityGiantSpinningCross(Entity* self) {
prim = &g_PrimBuf[self->primIndex];
while (prim != NULL) {
prim->tpage = 0x1C;
prim->drawMode = 0x100 | DRAW_HIDE;
prim->drawMode = DRAW_UNK_100 | DRAW_HIDE;
prim = prim->next;
}
func_8011A290(self);
Expand Down
2 changes: 1 addition & 1 deletion src/ric/1AC60.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void RicInit(s16 initParam) {
g_Entities[1].primIndex = primIndex;
g_Entities[1].flags |= FLAG_HAS_PRIMS;
for (prim = &g_PrimBuf[primIndex]; prim != NULL; prim = prim->next) {
prim->drawMode = 0x102 | DRAW_HIDE;
prim->drawMode = DRAW_UNK_100 | DRAW_UNK02 | DRAW_HIDE;
}
if (D_80097C98 == 6) {
RicCreateEntFactoryFromEntity(playerPtr, FACTORY(BP_TELEPORT, 1), 0);
Expand Down
6 changes: 3 additions & 3 deletions src/ric/2C4C4.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ void RicEntitySubwpnAxe(Entity* self) {
self->ext.subwpnAxe.unk8B[sp10 + 4] = 0;
self->ext.subwpnAxe.unk8B[sp10 + 8] = 0;
} else {
prim->drawMode = 0x100 | DRAW_HIDE;
prim->drawMode = DRAW_UNK_100 | DRAW_HIDE;
}
prim = prim->next;
sp10++;
Expand Down Expand Up @@ -1139,7 +1139,7 @@ void RicEntityCrashAxe(Entity* self) {
self->ext.axeCrash.unk8B[sp10 + 4] = 0;
self->ext.axeCrash.unk8B[sp10 + 8] = 0;
} else {
prim->drawMode = 0x100 | DRAW_HIDE;
prim->drawMode = DRAW_UNK_100 | DRAW_HIDE;
}
prim = prim->next;
sp10++;
Expand Down Expand Up @@ -2411,7 +2411,7 @@ void RicEntityCrashVibhuti(Entity* self) {
}
prim = &g_PrimBuf[self->primIndex];
for (i = 0; i < 9; i++) {
if (prim->drawMode & 8) {
if (prim->drawMode & DRAW_HIDE) {
break;
}
prim = prim->next;
Expand Down
2 changes: 1 addition & 1 deletion src/ric/319C4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ void RicEntityAguneaCircle(Entity* self) {
prim->v2 = prim->v3 = 0xD0;
}
prim->priority = 0xC2;
prim->drawMode = 0x200 | DRAW_HIDE;
prim->drawMode = DRAW_UNK_200 | DRAW_HIDE;
prim = prim->next;
}
self->ext.aguneaCrash.subweaponId = PL_W_CRASH_AGUNEA;
Expand Down
2 changes: 1 addition & 1 deletion src/ric/e_giant_spinning_cross.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void RicEntityCrashCrossBeam(Entity* self) {
prim = &g_PrimBuf[self->primIndex];
while (prim != NULL) {
prim->tpage = 0x1C;
prim->drawMode = 0x100 | DRAW_HIDE;
prim->drawMode = DRAW_UNK_100 | DRAW_HIDE;
prim = prim->next;
}
self->ext.giantcross.subweaponId = PL_W_CRASH_CROSS_BEAM;
Expand Down
20 changes: 10 additions & 10 deletions src/saturn/zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,42 +175,42 @@ void func_06008588(int param_1) {

puVar5 = &DAT_0605d6c0[param_1 * 4];
puVar6 = &DAT_0605CD90[param_1];
if (puVar5->flags == 0) {
if (puVar5->tileFlags == 0) {
return;
}
if ((puVar5->flags & 1) != 0) {
if ((puVar5->tileFlags & 1) != 0) {
cnt = func_0600F96C(puVar6->unkc, &DAT_060485e0, puVar6->unk18);
DmaScroll(&DAT_060485e0, puVar6->dst0, cnt);
}
if ((puVar5->flags & 2) != 0) {
if ((puVar5->tileFlags & 2) != 0) {
cnt = func_0600F96C(puVar6->unk10, &DAT_060485e0, puVar6->unk1c);
DmaScroll(&DAT_060485e0, puVar6->dst4, cnt);
}
if ((puVar5->flags & 4) != 0) {
if ((puVar5->tileFlags & 4) != 0) {
if (DAT_060086d4 == 4) {
func_060089F0(puVar6);
} else {
func_0600871C(puVar6, &DAT_0605c680, param_1);
}
}
if ((puVar5->flags & 8) != 0) {
if ((puVar5->tileFlags & 8) != 0) {
DmaScroll(puVar5->src, puVar5->dest, puVar5->cnt);
}
if ((puVar5->flags & 0x10) != 0) {
if ((puVar5->tileFlags & 0x10) != 0) {
DmaScroll(puVar5->src, puVar5->dest, puVar5->cnt);
}
if ((puVar5->flags & 0x20) != 0) {
if ((puVar5->tileFlags & 0x20) != 0) {
DmaScroll(puVar5->src, puVar5->dest, puVar5->cnt);
}
if ((puVar5->flags & 0x40) != 0) {
if ((puVar5->tileFlags & 0x40) != 0) {
cnt = func_0600F96C(puVar6->unkc, DMA_SRC_ADDR, puVar6->unk18);
DmaScroll(DMA_SRC_ADDR, puVar6->dst0, cnt);
}
if ((puVar5->flags & 0x80) != 0) {
if ((puVar5->tileFlags & 0x80) != 0) {
cnt = func_0600F96C(puVar6->unk10, DMA_SRC_ADDR, puVar6->unk1c);
DmaScroll(DMA_SRC_ADDR, puVar6->dst4, cnt);
}
puVar5->flags = 0;
puVar5->tileFlags = 0;
puVar5->cnt = 0;
puVar5->dest = 0;
puVar5->src = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/saturn/zero.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ s32 func_0600F96C(s32, s32, s32);
void DmaScroll(s32* src, s32* dest, u32 cnt);

struct Unk0605d6c0 {
u32 flags;
u32 tileFlags;
u32 src;
u32 dest;
u32 cnt;
Expand Down
2 changes: 1 addition & 1 deletion src/servant/play_sfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void ProcessSfxState(Entity* entity) {
break;

case 5:
if ((*(s32*)&D_8003C708.flags & 0x60) != 0) {
if ((*(s32*)&D_8003C708.flags & (FLAG_UNK_40 | FLAG_UNK_20)) != 0) {
g_PlaySfxStep = 99;
DestroyEntity(entity);
return;
Expand Down
4 changes: 2 additions & 2 deletions src/servant/servant_unk0.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ s32 ServantUnk0(void) {
if (D_8003C708.flags == 0x22) {
return 1;
}
if (D_8003C708.flags == 0x20) {
if (D_8003C708.flags == FLAG_UNK_20) {
return 0;
}
return 2;
Expand All @@ -13,7 +13,7 @@ s32 ServantUnk0(void) {
return 0;
}

if (D_8003C708.flags == 0x20) {
if (D_8003C708.flags == FLAG_UNK_20) {
return 1;
}
return 2;
Expand Down
2 changes: 1 addition & 1 deletion src/st/e_red_door.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void EntityRedDoor(Entity* self) {
angle = self->ext.door.angle;
prim = &g_PrimBuf[self->primIndex];
for (; prim != NULL; i++, prim = prim->next) {
if (!(prim->drawMode & 8)) {
if (!(prim->drawMode & DRAW_HIDE)) {
if (!(self->params & 0x100)) {
if (i == 0) {
endX = prim->x0 = prim->x2 =
Expand Down
2 changes: 1 addition & 1 deletion src/st/e_skeleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void func_801C6678(Entity* self) {
self->rotY = 0x200;
self->unk6C = 0;
self->hitboxState = 0;
self->drawFlags = self->drawFlags | 0xB;
self->drawFlags |= FLAG_DRAW_UNK8 | FLAG_DRAW_ROTY | FLAG_DRAW_ROTX;
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/st/e_stage_name.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void EntityStageNamePopup(Entity* self) {
prim->g2 = 0;
prim->b2 = 0x38;
prim->priority = 0xB0;
prim->drawMode = 0x15 | DRAW_HIDE;
prim->drawMode = DRAW_TPAGE | DRAW_COLORS | DRAW_TRANSP | DRAW_HIDE;
LOW(prim->r1) = LOW(prim->r0);
LOW(prim->r3) = LOW(prim->r2);
prim = prim->next;
Expand All @@ -190,7 +190,7 @@ void EntityStageNamePopup(Entity* self) {
prim->u2 = prim->u0 = 4;
prim->u1 = prim->u3 = primIndex = 0x78; // FAKE
prim->priority = 0xC0;
prim->drawMode = 4 | DRAW_HIDE;
prim->drawMode = DRAW_COLORS | DRAW_HIDE;
LOW(prim->r1) = LOW(prim->r0);
LOW(prim->r2) = LOW(prim->r0);
LOW(prim->r3) = LOW(prim->r0);
Expand All @@ -211,7 +211,7 @@ void EntityStageNamePopup(Entity* self) {
prim->g0 = 0x78;
prim->b0 = 0xA8;
prim->priority = 0xC0;
prim->drawMode = 4 | DRAW_HIDE;
prim->drawMode = DRAW_COLORS | DRAW_HIDE;
LOW(prim->r1) = LOW(prim->r0);
LOW(prim->r2) = LOW(prim->r0);
LOW(prim->r3) = LOW(prim->r0);
Expand Down
5 changes: 4 additions & 1 deletion src/st/nz0/e_bloody_skeleton.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ void EntityBloodSkeleton(Entity* self) {
if (AnimateEntity(animation, self) == 0) {
self->hitPoints = 0;
self->hitboxState = 3;
self->flags = g_api.enemyDefs[70].flags & 0x1FFFFFFF;
self->flags =
g_api.enemyDefs[70].flags &
~(FLAG_DESTROY_IF_OUT_OF_CAMERA |
FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | FLAG_UNK_20000000);
SetStep(BLOOD_SKELETON_WALK);
}
}
Expand Down
Loading

0 comments on commit d513ea4

Please sign in to comment.