Misc Cleanup 2 (#1260)

* more misc cleanup

* PR suggestions

* more abs alt, csId

* more cleanup, can't help it

* fix incorrect sq

* more fixes
This commit is contained in:
engineer124
2023-06-02 14:39:39 +10:00
committed by GitHub
parent 0261dc0a5c
commit 4b25b4d8e6
62 changed files with 636 additions and 423 deletions
+1 -1
View File
@@ -396,7 +396,7 @@ void Sched_HandleRetrace(SchedContext* sched) {
if (sched->curBuf->updateRate2 > 0) {
sched->curBuf->updateRate2--;
}
if (sched->curBuf->updateRate2 <= 0 && sched->pendingSwapBuf1 != NULL) {
if ((sched->curBuf->updateRate2 <= 0) && (sched->pendingSwapBuf1 != NULL)) {
Sched_RetraceUpdateFramebuffer(sched, sched->pendingSwapBuf1);
}
}
+11 -11
View File
@@ -695,7 +695,7 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS
* Tests if current scene switch flag is set.
*/
s32 Flags_GetSwitch(PlayState* play, s32 flag) {
if (flag >= 0 && flag < 0x80) {
if ((flag >= 0) && (flag < 0x80)) {
return play->actorCtx.sceneFlags.switches[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F));
}
return 0;
@@ -705,7 +705,7 @@ s32 Flags_GetSwitch(PlayState* play, s32 flag) {
* Sets current scene switch flag.
*/
void Flags_SetSwitch(PlayState* play, s32 flag) {
if (flag >= 0 && flag < 0x80) {
if ((flag >= 0) && (flag < 0x80)) {
play->actorCtx.sceneFlags.switches[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F);
}
}
@@ -714,7 +714,7 @@ void Flags_SetSwitch(PlayState* play, s32 flag) {
* Unsets current scene switch flag.
*/
void Flags_UnsetSwitch(PlayState* play, s32 flag) {
if (flag >= 0 && flag < 0x80) {
if ((flag >= 0) && (flag < 0x80)) {
play->actorCtx.sceneFlags.switches[(flag & ~0x1F) >> 5] &= ~(1 << (flag & 0x1F));
}
}
@@ -793,7 +793,7 @@ void Flags_UnsetClearTemp(PlayState* play, s32 roomNumber) {
* Tests if current scene collectible flag is set.
*/
s32 Flags_GetCollectible(PlayState* play, s32 flag) {
if (flag > 0 && flag < 0x80) {
if ((flag > 0) && (flag < 0x80)) {
return play->actorCtx.sceneFlags.collectible[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F));
}
return 0;
@@ -803,7 +803,7 @@ s32 Flags_GetCollectible(PlayState* play, s32 flag) {
* Sets current scene collectible flag.
*/
void Flags_SetCollectible(PlayState* play, s32 flag) {
if (flag > 0 && flag < 0x80) {
if ((flag > 0) && (flag < 0x80)) {
play->actorCtx.sceneFlags.collectible[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F);
}
}
@@ -3268,12 +3268,12 @@ void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) {
for (i = 0; i < numTransitionActors; transitionActorList++, i++) {
if (transitionActorList->id >= 0) {
if ((transitionActorList->sides[0].room >= 0 &&
(play->roomCtx.curRoom.num == transitionActorList->sides[0].room ||
play->roomCtx.prevRoom.num == transitionActorList->sides[0].room)) ||
(transitionActorList->sides[1].room >= 0 &&
(play->roomCtx.curRoom.num == transitionActorList->sides[1].room ||
play->roomCtx.prevRoom.num == transitionActorList->sides[1].room))) {
if (((transitionActorList->sides[0].room >= 0) &&
((play->roomCtx.curRoom.num == transitionActorList->sides[0].room) ||
(play->roomCtx.prevRoom.num == transitionActorList->sides[0].room))) ||
((transitionActorList->sides[1].room >= 0) &&
((play->roomCtx.curRoom.num == transitionActorList->sides[1].room) ||
(play->roomCtx.prevRoom.num == transitionActorList->sides[1].room)))) {
s16 rotY = DEG_TO_BINANG((transitionActorList->rotY >> 7) & 0x1FF);
if (Actor_SpawnAsChildAndCutscene(actorCtx, play, transitionActorList->id & 0x1FFF,
+4 -2
View File
@@ -1920,12 +1920,14 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul
s32 bgId;
f32 temp_f0_2;
f32 f32temp;
f32 nx2, nz2;
f32 nx2;
f32 nz2;
Vec3f checkLineNext;
Vec3f checkLinePrev;
f32 n2XZDist;
f32 n3XZDist;
f32 nx3, nz3;
f32 nx3;
f32 nz3;
s32 bccFlags;
Vec3f posIntersect2;
s32 bgId2;
+3 -2
View File
@@ -6777,8 +6777,9 @@ s32 Camera_Special5(Camera* camera) {
spA4 = BINANG_SUB(focalActorPosRot->rot.y, sp6C.yaw);
sp74.r = roData->eyeDist;
rand = Rand_ZeroOne();
sp74.yaw = BINANG_ROT180(focalActorPosRot->rot.y) +
(s16)(spA4 < 0 ? -(s16)(0x1553 + (s16)(rand * 2730.0f)) : (s16)(0x1553 + (s16)(rand * 2730.0f)));
sp74.yaw =
BINANG_ROT180(focalActorPosRot->rot.y) +
(s16)((spA4 < 0) ? -(s16)(0x1553 + (s16)(rand * 2730.0f)) : (s16)(0x1553 + (s16)(rand * 2730.0f)));
sp74.pitch = roData->pitch;
OLib_AddVecGeoToVec3f(eyeNext, &spA8.pos, &sp74);
*eye = *eyeNext;
+1 -1
View File
@@ -790,7 +790,7 @@ DamageTable sDamageTablePresets[] = {
* is out of range.
*/
DamageTable* DamageTable_Get(s32 index) {
if (index < 0 || index > ARRAY_COUNT(sDamageTablePresets) - 1) {
if ((index < 0) || (index >= ARRAY_COUNT(sDamageTablePresets))) {
return NULL;
}
+33 -35
View File
@@ -753,7 +753,7 @@ void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this,
j = 0;
for (i = 0; i < this->numElements - 1; i++) {
for (i = 0; i < this->numElements - 1; i++, j += 4) {
if (this->drawMode == 1) {
alphaRatio = (f32)this->elements[i].timer / (f32)this->elemDuration;
gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, this->altPrimColor.r, this->altPrimColor.g,
@@ -761,45 +761,43 @@ void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this,
gDPPipeSync(POLY_XLU_DISP++);
}
if (1) {} // Necessary to match
gSPVertex(POLY_XLU_DISP++, &vtx[j], 4, 0);
gSP2Triangles(POLY_XLU_DISP++, 0, 1, 3, 0, 0, 3, 2, 0);
if (this->flags & 4) {
sp1B0.x = ((f32)vtx[4 * i + 0].v.ob[0] + (f32)vtx[4 * i + 1].v.ob[0]) * 0.5f;
sp1B0.y = ((f32)vtx[4 * i + 0].v.ob[1] + (f32)vtx[4 * i + 1].v.ob[1]) * 0.5f;
sp1B0.z = ((f32)vtx[4 * i + 0].v.ob[2] + (f32)vtx[4 * i + 1].v.ob[2]) * 0.5f;
sp1A4.x = ((f32)vtx[4 * i + 2].v.ob[0] + (f32)vtx[4 * i + 3].v.ob[0]) * 0.5f;
sp1A4.y = ((f32)vtx[4 * i + 2].v.ob[1] + (f32)vtx[4 * i + 3].v.ob[1]) * 0.5f;
sp1A4.z = ((f32)vtx[4 * i + 2].v.ob[2] + (f32)vtx[4 * i + 3].v.ob[2]) * 0.5f;
Math_Vec3f_Diff(&sp1A4, &sp1B0, &sp198);
scale = sqrtf(SQXYZ(sp198));
if (fabsf(scale) > 0.0005f) {
scale = 1.0f / scale;
Math_Vec3f_Scale(&sp198, scale);
SkinMatrix_SetTranslate(&sp154, sp1B0.x, sp1B0.y, sp1B0.z);
SkinMatrix_SetRotateAroundVec(&sp114, 0x3FFF, sp198.x, sp198.y, sp198.z);
SkinMatrix_MtxFMtxFMult(&sp154, &sp114, &spD4);
SkinMatrix_SetTranslate(&sp154, -sp1B0.x, -sp1B0.y, -sp1B0.z);
SkinMatrix_MtxFMtxFMult(&spD4, &sp154, &sp94);
mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &sp94);
if (mtx == NULL) {
break;
}
gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPVertex(POLY_XLU_DISP++, &vtx[j], 4, 0);
gSP2Triangles(POLY_XLU_DISP++, 0, 1, 3, 0, 0, 3, 2, 0);
gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
}
if (!(this->flags & 4)) {
continue;
}
j += 4;
sp1B0.x = ((f32)vtx[4 * i + 0].v.ob[0] + (f32)vtx[4 * i + 1].v.ob[0]) / 2.0f;
sp1B0.y = ((f32)vtx[4 * i + 0].v.ob[1] + (f32)vtx[4 * i + 1].v.ob[1]) / 2.0f;
sp1B0.z = ((f32)vtx[4 * i + 0].v.ob[2] + (f32)vtx[4 * i + 1].v.ob[2]) / 2.0f;
sp1A4.x = ((f32)vtx[4 * i + 2].v.ob[0] + (f32)vtx[4 * i + 3].v.ob[0]) / 2.0f;
sp1A4.y = ((f32)vtx[4 * i + 2].v.ob[1] + (f32)vtx[4 * i + 3].v.ob[1]) / 2.0f;
sp1A4.z = ((f32)vtx[4 * i + 2].v.ob[2] + (f32)vtx[4 * i + 3].v.ob[2]) / 2.0f;
Math_Vec3f_Diff(&sp1A4, &sp1B0, &sp198);
scale = sqrtf(SQXYZ(sp198));
if (fabsf(scale) > 0.0005f) {
scale = 1.0f / scale;
Math_Vec3f_Scale(&sp198, scale);
SkinMatrix_SetTranslate(&sp154, sp1B0.x, sp1B0.y, sp1B0.z);
SkinMatrix_SetRotateAroundVec(&sp114, 0x3FFF, sp198.x, sp198.y, sp198.z);
SkinMatrix_MtxFMtxFMult(&sp154, &sp114, &spD4);
SkinMatrix_SetTranslate(&sp154, -sp1B0.x, -sp1B0.y, -sp1B0.z);
SkinMatrix_MtxFMtxFMult(&spD4, &sp154, &sp94);
mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &sp94);
if (mtx == NULL) {
break;
}
gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPVertex(POLY_XLU_DISP++, &vtx[j], 4, 0);
gSP2Triangles(POLY_XLU_DISP++, 0, 1, 3, 0, 0, 3, 2, 0);
gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
}
}
}
+32 -34
View File
@@ -187,33 +187,31 @@ void Effect_DrawAll(GraphicsContext* gfxCtx) {
s32 i;
for (i = 0; i < SPARK_COUNT; i++) {
if (1) {} // necessary to match
if (sEffectContext.sparks[i].status.active) {
sEffectInfoTable[EFFECT_SPARK].draw(&sEffectContext.sparks[i].effect, gfxCtx);
if (!sEffectContext.sparks[i].status.active) {
continue;
}
sEffectInfoTable[EFFECT_SPARK].draw(&sEffectContext.sparks[i].effect, gfxCtx);
}
for (i = 0; i < BLURE_COUNT; i++) {
if (1) {
if (gfxCtx) {}
} // necessary to match
if (sEffectContext.blures[i].status.active) {
sEffectInfoTable[EFFECT_BLURE1].draw(&sEffectContext.blures[i].effect, gfxCtx);
if (!sEffectContext.blures[i].status.active) {
continue;
}
sEffectInfoTable[EFFECT_BLURE1].draw(&sEffectContext.blures[i].effect, gfxCtx);
}
for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) {
if (1) {} // necessary to match
if (sEffectContext.shieldParticles[i].status.active) {
sEffectInfoTable[EFFECT_SHIELD_PARTICLE].draw(&sEffectContext.shieldParticles[i].effect, gfxCtx);
if (!sEffectContext.shieldParticles[i].status.active) {
continue;
}
sEffectInfoTable[EFFECT_SHIELD_PARTICLE].draw(&sEffectContext.shieldParticles[i].effect, gfxCtx);
}
if (1) {} // necessary to match
for (i = 0; i < TIRE_MARK_COUNT; i++) {
if (sEffectContext.tireMarks[i].status.active) {
sEffectInfoTable[EFFECT_TIRE_MARK].draw(&sEffectContext.tireMarks[i].effect, gfxCtx);
if (!sEffectContext.tireMarks[i].status.active) {
continue;
}
sEffectInfoTable[EFFECT_TIRE_MARK].draw(&sEffectContext.tireMarks[i].effect, gfxCtx);
}
}
@@ -221,38 +219,38 @@ void Effect_UpdateAll(PlayState* play) {
s32 i;
for (i = 0; i < SPARK_COUNT; i++) {
if (1) {} // necessary to match
if (sEffectContext.sparks[i].status.active) {
if (sEffectInfoTable[EFFECT_SPARK].update(&sEffectContext.sparks[i].effect) == 1) {
Effect_Destroy(play, i);
}
if (!sEffectContext.sparks[i].status.active) {
continue;
}
if (sEffectInfoTable[EFFECT_SPARK].update(&sEffectContext.sparks[i].effect) == 1) {
Effect_Destroy(play, i);
}
}
for (i = 0; i < BLURE_COUNT; i++) {
if (1) {} // necessary to match
if (sEffectContext.blures[i].status.active) {
if (sEffectInfoTable[EFFECT_BLURE1].update(&sEffectContext.blures[i].effect) == 1) {
Effect_Destroy(play, i + SPARK_COUNT);
}
if (!sEffectContext.blures[i].status.active) {
continue;
}
if (sEffectInfoTable[EFFECT_BLURE1].update(&sEffectContext.blures[i].effect) == 1) {
Effect_Destroy(play, i + SPARK_COUNT);
}
}
for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) {
if (1) {} // necessary to match
if (sEffectContext.shieldParticles[i].status.active) {
if (sEffectInfoTable[EFFECT_SHIELD_PARTICLE].update(&sEffectContext.shieldParticles[i].effect) == 1) {
Effect_Destroy(play, i + SPARK_COUNT + BLURE_COUNT);
}
if (!sEffectContext.shieldParticles[i].status.active) {
continue;
}
if (sEffectInfoTable[EFFECT_SHIELD_PARTICLE].update(&sEffectContext.shieldParticles[i].effect) == 1) {
Effect_Destroy(play, i + SPARK_COUNT + BLURE_COUNT);
}
}
for (i = 0; i < TIRE_MARK_COUNT; i++) {
if (1) {} // necessary to match
if (sEffectContext.tireMarks[i].status.active) {
if (sEffectInfoTable[EFFECT_TIRE_MARK].update(&sEffectContext.tireMarks[i].effect) == 1) {
Effect_Destroy(play, i + SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT);
}
if (!sEffectContext.tireMarks[i].status.active) {
continue;
}
if (sEffectInfoTable[EFFECT_TIRE_MARK].update(&sEffectContext.tireMarks[i].effect) == 1) {
Effect_Destroy(play, i + SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT);
}
}
}
+6 -6
View File
@@ -371,7 +371,7 @@ s16 CutsceneManager_Start(s16 csId, Actor* actor) {
Camera* retCam;
s32 csType = 0;
if ((csId < 0) || (sCutsceneMgr.csId != CS_ID_NONE)) {
if ((csId <= CS_ID_NONE) || (sCutsceneMgr.csId != CS_ID_NONE)) {
return csId;
}
@@ -437,7 +437,7 @@ s16 CutsceneManager_Start(s16 csId, Actor* actor) {
s16 CutsceneManager_Stop(s16 csId) {
ActorCutscene* csEntry;
if (csId < 0) {
if (csId <= CS_ID_NONE) {
return csId;
}
@@ -468,28 +468,28 @@ ActorCutscene* CutsceneManager_GetCutsceneEntry(s16 csId) {
}
s16 CutsceneManager_GetAdditionalCsId(s16 csId) {
if (csId < 0) {
if (csId <= CS_ID_NONE) {
return CS_ID_NONE;
}
return CutsceneManager_GetCutsceneEntryImpl(csId)->additionalCsId;
}
s16 CutsceneManager_GetLength(s16 csId) {
if (csId < 0) {
if (csId <= CS_ID_NONE) {
return -1;
}
return CutsceneManager_GetCutsceneEntryImpl(csId)->length;
}
s16 CutsceneManager_GetCutsceneScriptIndex(s16 csId) {
if (csId < 0) {
if (csId <= CS_ID_NONE) {
return -1;
}
return CutsceneManager_GetCutsceneEntryImpl(csId)->scriptIndex;
}
s16 CutsceneManager_GetCutsceneCustomValue(s16 csId) {
if (csId < 0) {
if (csId <= CS_ID_NONE) {
return -1;
}
return CutsceneManager_GetCutsceneEntryImpl(csId)->customValue;
-1
View File
@@ -3867,7 +3867,6 @@ void Interface_DrawItemButtons(PlayState* play) {
OVERLAY_DISP = Gfx_DrawTexRectIA8_DropShadow(OVERLAY_DISP, gButtonBackgroundTex, 0x20, 0x20, D_801BF9D4[0],
D_801BF9DC[0], D_801BFAF4[0], D_801BFAF4[0], D_801BF9E4[0] * 2,
D_801BF9E4[0] * 2, 100, 255, 120, interfaceCtx->bAlpha);
if (1) {}
gDPPipeSync(OVERLAY_DISP++);
// C-Left Button Color & Texture
+1 -1
View File
@@ -89,7 +89,7 @@ s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId) {
s32 i;
for (i = 0; i < objectCtx->num; i++) {
if ((objectCtx->status[i].id < 0 ? -objectCtx->status[i].id : objectCtx->status[i].id) == objectId) {
if (ABS_ALT(objectCtx->status[i].id) == objectId) {
return i;
}
}
+1 -1
View File
@@ -400,7 +400,7 @@ void AnimatedMat_DrawMain(PlayState* play, AnimatedMaterial* matAnim, f32 alphaR
if ((matAnim != NULL) && (matAnim->segment != 0)) {
do {
segment = matAnim->segment;
segmentAbs = ((segment < 0) ? -segment : segment) + 7;
segmentAbs = ABS_ALT(segment) + 7;
matAnimDrawHandlers[matAnim->type](play, segmentAbs, Lib_SegmentedToVirtual(matAnim->params));
matAnim++;
} while (segment >= 0);
+11 -9
View File
@@ -42,9 +42,6 @@ s32 Snap_RecordPictographedActors(PlayState* play) {
break;
}
//! FAKE:
if (1) {}
// Actors which may be pictographed anywhere
switch (actor->id) {
case ACTOR_EN_KAKASI:
@@ -71,15 +68,20 @@ s32 Snap_RecordPictographedActors(PlayState* play) {
case ACTOR_EN_GE2:
seen |= PICTO_SEEN_ANYWHERE;
break;
default:
break;
}
if (!seen) {
continue;
}
// If actor is recordable, run its validity function and record if valid
if (seen) {
pictoActor = (PictoActor*)actor;
if (pictoActor->validationFunc != NULL) {
if ((pictoActor->validationFunc)(play, actor) == 0) {
validCount++;
}
pictoActor = (PictoActor*)actor;
if (pictoActor->validationFunc != NULL) {
if (pictoActor->validationFunc(play, actor) == 0) {
validCount++;
}
}
}
+2 -2
View File
@@ -548,7 +548,7 @@ void Sram_GenerateRandomSaveFields(void) {
do {
randBombers = Rand_S16Offset(0, 6);
} while (randBombers <= 0 || randBombers >= 6);
} while ((randBombers <= 0) || (randBombers >= 6));
gSaveContext.save.saveInfo.bomberCode[0] = randBombers;
@@ -558,7 +558,7 @@ void Sram_GenerateRandomSaveFields(void) {
do {
randBombers = Rand_S16Offset(0, 6);
} while (randBombers <= 0 || randBombers >= 6);
} while ((randBombers <= 0) || (randBombers >= 6));
sp2A = 0;
do {