mirror of
https://github.com/HarbourMasters/Starship
synced 2026-06-20 08:13:50 -04:00
Use array count for more things (#230)
* array count more things * fix array count error * undo array count for later --------- Co-authored-by: Alejandro Javier Asenjo Nitti <alejandro.asenjo88@gmail.com>
This commit is contained in:
@@ -422,7 +422,7 @@ void ActorAllRange_SpawnStarWolf(void) {
|
||||
Actor* actor;
|
||||
s32 i;
|
||||
|
||||
for (i = 0, actor = &gActors[4]; i < 4; i++, actor++) {
|
||||
for (i = 0, actor = &gActors[4]; i < ARRAY_COUNT(sStarWolfSpawnPos); i++, actor++) {
|
||||
if (gStarWolfTeamAlive[i] != 0) {
|
||||
Actor_Initialize(actor);
|
||||
actor->obj.status = OBJ_ACTIVE;
|
||||
|
||||
@@ -743,7 +743,7 @@ void func_beam_80038140(PlayerShot* shot) {
|
||||
sp60 = false;
|
||||
}
|
||||
if (sp60) {
|
||||
for (i = 0, effect = gEffects; i < 100; i++, effect++) {
|
||||
for (i = 0, effect = gEffects; i < ARRAY_COUNT(gEffects); i++, effect++) {
|
||||
if ((effect->obj.status >= OBJ_ACTIVE) && (effect->info.unk_19 != 0) &&
|
||||
(fabsf(shot->obj.pos.z - effect->obj.pos.z) < 200.0f) &&
|
||||
(fabsf(shot->obj.pos.x - effect->obj.pos.x) < 100.0f) &&
|
||||
@@ -914,7 +914,7 @@ void func_beam_80038140(PlayerShot* shot) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0, scenery = gScenery; i < 50; i++, scenery++) {
|
||||
for (i = 0, scenery = gScenery; i < ARRAY_COUNT(gScenery); i++, scenery++) {
|
||||
if (scenery->obj.status == OBJ_ACTIVE) {
|
||||
if ((scenery->obj.id == OBJ_SCENERY_1) || (scenery->obj.id == OBJ_SCENERY_ME_TUNNEL) ||
|
||||
(scenery->obj.id == OBJ_SCENERY_4) || (scenery->obj.id == OBJ_SCENERY_5) ||
|
||||
@@ -935,7 +935,7 @@ void func_beam_80038140(PlayerShot* shot) {
|
||||
}
|
||||
}
|
||||
if (sp60) {
|
||||
for (i = 0, sprite = gSprites; i < 40; i++, sprite++) {
|
||||
for (i = 0, sprite = gSprites; i < ARRAY_COUNT(gSprites); i++, sprite++) {
|
||||
if (sprite->obj.status == OBJ_ACTIVE) {
|
||||
if (sprite->obj.id != OBJ_SPRITE_TI_CACTUS) {
|
||||
if (func_beam_80037698(shot, sprite)) {
|
||||
@@ -949,7 +949,7 @@ void func_beam_80038140(PlayerShot* shot) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0, boss = gBosses; i < 4; i++, boss++) {
|
||||
for (i = 0, boss = gBosses; i < ARRAY_COUNT(gBosses); i++, boss++) {
|
||||
if ((boss->obj.status == OBJ_ACTIVE) && (boss->timer_05A == 0)) {
|
||||
if ((boss->obj.id == OBJ_BOSS_308) || (boss->obj.id == OBJ_BOSS_312) || (boss->obj.id == OBJ_BOSS_309) ||
|
||||
(boss->obj.id == OBJ_BOSS_313)) {
|
||||
@@ -1856,7 +1856,7 @@ void func_beam_8003C4D0(PlayerShot* shot, s32 damage) {
|
||||
Player* player;
|
||||
f32 temp_fs2 = shot->scale * 60.0f;
|
||||
|
||||
for (i = 0, scenery = gScenery; i < 50; i++, scenery++) {
|
||||
for (i = 0, scenery = gScenery; i < ARRAY_COUNT(gScenery); i++, scenery++) {
|
||||
if ((scenery->obj.status == OBJ_ACTIVE) && (scenery->obj.id == OBJ_SCENERY_56)) {
|
||||
sp68 = scenery->obj.pos.x - shot->obj.pos.x;
|
||||
sp64 = scenery->obj.pos.y - shot->obj.pos.y;
|
||||
@@ -1867,7 +1867,7 @@ void func_beam_8003C4D0(PlayerShot* shot, s32 damage) {
|
||||
scenery->dmgPart = 0;
|
||||
}
|
||||
}
|
||||
for (i = 0, sprite = gSprites; i < 40; i++, sprite++) {
|
||||
for (i = 0, sprite = gSprites; i < ARRAY_COUNT(gSprites); i++, sprite++) {
|
||||
if ((sprite->obj.status == OBJ_ACTIVE) &&
|
||||
((sprite->obj.id == OBJ_SPRITE_FO_POLE) || (sprite->obj.id == OBJ_SPRITE_TI_CACTUS) ||
|
||||
(sprite->obj.id == OBJ_SPRITE_CO_POLE) || (sprite->obj.id == OBJ_SPRITE_CO_TREE))) {
|
||||
@@ -1943,7 +1943,7 @@ void func_beam_8003C4D0(PlayerShot* shot, s32 damage) {
|
||||
func_beam_8003C008(shot);
|
||||
}
|
||||
effect = gEffects;
|
||||
for (i = 0; i < 100; i++, effect++) {
|
||||
for (i = 0; i < ARRAY_COUNT(gEffects); i++, effect++) {
|
||||
if (effect->obj.status == OBJ_ACTIVE) {
|
||||
sp68 = effect->obj.pos.x - shot->obj.pos.x;
|
||||
sp64 = effect->obj.pos.y - shot->obj.pos.y;
|
||||
|
||||
+4
-4
@@ -926,7 +926,7 @@ void Background_DrawGround(void) {
|
||||
} else {
|
||||
gGroundSurface = SURFACE_GRASS;
|
||||
gBgColor = 0x845; // 8, 8, 32
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < ARRAY_COUNT(sGroundPositions360x); i++) {
|
||||
Matrix_Push(&gGfxMatrix);
|
||||
Matrix_Translate(gGfxMatrix, sGroundPositions360x[i], 0.0f, sGroundPositions360z[i], MTXF_APPLY);
|
||||
Matrix_SetGfxMtx(&gMasterDisp);
|
||||
@@ -992,7 +992,7 @@ void Background_DrawGround(void) {
|
||||
gSPDisplayList(gMasterDisp++, D_TR_6005880);
|
||||
Matrix_Pop(&gGfxMatrix);
|
||||
} else {
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < ARRAY_COUNT(sGroundPositions360x); i++) {
|
||||
Matrix_Push(&gGfxMatrix);
|
||||
Matrix_Translate(gGfxMatrix, sGroundPositions360x[i], 0.0f, sGroundPositions360z[i], MTXF_APPLY);
|
||||
Matrix_Scale(gGfxMatrix, 1.5f, 1.0f, 1.0f, MTXF_APPLY);
|
||||
@@ -1071,7 +1071,7 @@ void Background_DrawGround(void) {
|
||||
} else {
|
||||
RCP_SetupDL_20(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < ARRAY_COUNT(sGroundPositions360x); i++) {
|
||||
Matrix_Push(&gGfxMatrix);
|
||||
Matrix_Translate(gGfxMatrix, sGroundPositions360x[i], 0.0f, sGroundPositions360z[i], MTXF_APPLY);
|
||||
Matrix_SetGfxMtx(&gMasterDisp);
|
||||
@@ -1093,7 +1093,7 @@ void Background_DrawGround(void) {
|
||||
} else {
|
||||
RCP_SetupDL_20(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < ARRAY_COUNT(sGroundPositions360x); i++) {
|
||||
Matrix_Push(&gGfxMatrix);
|
||||
Matrix_Translate(gGfxMatrix, sGroundPositions360x[i], 0.0f, sGroundPositions360z[i], MTXF_APPLY);
|
||||
Matrix_SetGfxMtx(&gMasterDisp);
|
||||
|
||||
@@ -87,7 +87,7 @@ void Boss_SpawnActor189(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 ar
|
||||
f32 arg9, s32 argA, s32 argB) {
|
||||
s32 i;
|
||||
|
||||
for (i = 59; i >= 0; i--) {
|
||||
for (i = (ARRAY_COUNT(gActors)) - 1; i >= 0; i--) {
|
||||
if (gActors[i].obj.status == OBJ_FREE) {
|
||||
Boss_SetupActor189(&gActors[i], arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, argA, argB);
|
||||
return;
|
||||
|
||||
@@ -2933,7 +2933,7 @@ void Cutscene_DrawGreatFox(void) {
|
||||
((gCurrentLevel != LEVEL_SECTOR_Z) || (gPlayer[0].state_1C8 == PLAYERSTATE_1C8_LEVEL_COMPLETE))) {
|
||||
RCP_SetupDL_49();
|
||||
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255);
|
||||
for (i = 0, var_s6_2 = D_demo_800CA0BC; i < 4; i++, var_s6_2++) {
|
||||
for (i = 0, var_s6_2 = D_demo_800CA0BC; i < ARRAY_COUNT(sp9C); i++, var_s6_2++) {
|
||||
if ((i != 1) || gGreatFoxIntact) {
|
||||
sp9C[i] = 0.0f;
|
||||
if (i < 2) {
|
||||
|
||||
@@ -632,7 +632,7 @@ void func_effect_800794CC(f32 xPos, f32 yPos, f32 zPos, f32 scale2) {
|
||||
void func_effect_8007953C(f32 xPos, f32 yPos, f32 zPos, f32 scale2) {
|
||||
s32 i;
|
||||
|
||||
for (i = 79; i >= 0; i--) {
|
||||
for (i = (ARRAY_COUNT(gEffects) - 20) - 1; i >= 0; i--) {
|
||||
if (gEffects[i].obj.status == OBJ_FREE) {
|
||||
func_effect_8007905C(&gEffects[i], xPos, yPos, zPos, scale2, 0);
|
||||
break;
|
||||
|
||||
@@ -1981,7 +1981,7 @@ void func_enmy_80067348(Actor* actor, f32 xPos, f32 yPos, f32 zPos, f32 xRot, f3
|
||||
void func_enmy_800674B4(f32 xPos, f32 yPos, f32 zPos, f32 xRot, f32 yRot, f32 arg5, f32 arg6, f32 arg7) {
|
||||
s32 i;
|
||||
|
||||
for (i = 59; i >= 50; i--) {
|
||||
for (i = ARRAY_COUNT(gActors) - 1; i >= 50; i--) {
|
||||
if (gActors[i].obj.status == OBJ_FREE) {
|
||||
func_enmy_80067348(&gActors[i], xPos, yPos, zPos, xRot, yRot, arg5, arg6, arg7);
|
||||
break;
|
||||
|
||||
@@ -412,7 +412,7 @@ void Game_Update(void) {
|
||||
gVersusStage = 0;
|
||||
gVsPointsToWin = 3;
|
||||
gBlurAlpha = 255;
|
||||
for (i = 0; i < 30; i++) {
|
||||
for (i = 0; i < ARRAY_COUNT(gLeveLClearStatus); i++) {
|
||||
gLeveLClearStatus[i] = 0;
|
||||
}
|
||||
gExpertMode = false;
|
||||
|
||||
@@ -1979,7 +1979,7 @@ void func_hud_8008A240(void) {
|
||||
}
|
||||
|
||||
if (gVersusMode == 1) {
|
||||
for (i = 0, item = gItems; i < 20; i++, item++) {
|
||||
for (i = 0, item = gItems; i < ARRAY_COUNT(gItems); i++, item++) {
|
||||
if (item->obj.status >= OBJ_ACTIVE) {
|
||||
gRadarMarks[item->index + 50].status = 1;
|
||||
gRadarMarks[item->index + 50].type = 103;
|
||||
@@ -2132,7 +2132,7 @@ s32 func_hud_8008A4DC(void) {
|
||||
D_hud_80161710--;
|
||||
}
|
||||
|
||||
for (i = 64; i >= 0; i--) {
|
||||
for (i = ARRAY_COUNT(gRadarMarks) - 1; i >= 0; i--) {
|
||||
if ((gRadarMarks[i].status == 0) || (fabsf(gRadarMarks[i].pos.x) >= (temp2 + 1000.0f)) ||
|
||||
(fabsf(gRadarMarks[i].pos.z) >= (temp2 + 1000.0f))) {
|
||||
continue;
|
||||
@@ -2458,7 +2458,7 @@ s32 func_hud_8008B774(void) {
|
||||
if ((i >= 1) && (i <= 3) &&
|
||||
((gLevelMode != LEVELMODE_ALL_RANGE) || (gCurrentLevel == LEVEL_CORNERIA) ||
|
||||
(gCurrentLevel == LEVEL_SECTOR_Y))) {
|
||||
for (i = 0; i < 60; i++) {
|
||||
for (i = 0; i < ARRAY_COUNT(gActors); i++) {
|
||||
if ((gActors[i].obj.status == OBJ_ACTIVE) && (gActors[i].iwork[12] == temp)) {
|
||||
if ((gActors[i].unk_0B4 == EVID_2) || (gActors[i].unk_0B4 == EVID_43) ||
|
||||
((gActors[i].obj.id == OBJ_ACTOR_TEAM_BOSS) &&
|
||||
@@ -3848,7 +3848,7 @@ bool func_hud_8009092C(Actor* actor) {
|
||||
|
||||
boss = &gBosses[1];
|
||||
|
||||
for (i = 1; i < 4; i++, boss++) {
|
||||
for (i = 1; i < ARRAY_COUNT(gBosses); i++, boss++) {
|
||||
if (boss->obj.status == OBJ_ACTIVE) {
|
||||
var_s5 = true;
|
||||
if (actor->aiIndex == 0) {
|
||||
|
||||
@@ -2544,7 +2544,7 @@ void Play_Init(void) {
|
||||
s32 i;
|
||||
|
||||
gArwingSpeed = 40.0f;
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < ARRAY_COUNT(gControllerRumbleEnabled); i++) {
|
||||
gControllerRumbleEnabled[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user