From 653069fe0736c97093b62a12664487c3fca2b7ca Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 14 Jan 2022 07:57:44 +1000 Subject: [PATCH] Replace literal numbers with MAX_BOTS and MAX_MPCHRS constants where appropriate --- src/game/bondwalk.c | 2 + src/game/bot.c | 48 ++++++------- src/game/botmgr.c | 6 +- src/game/game_00c490.c | 6 +- src/game/game_127910.c | 2 +- src/game/game_19aa80.c | 4 +- src/game/menu/items.c | 2 +- src/game/mplayer/ingame.c | 8 +-- src/game/mplayer/mplayer.c | 70 +++++++++---------- src/game/mplayer/scenarios.c | 2 +- src/game/mplayer/scenarios/capturethecase.inc | 2 +- src/game/mplayer/scenarios/kingofthehill.inc | 2 +- src/game/mplayer/setup.c | 8 +-- src/include/bss.h | 6 +- src/include/constants.h | 4 +- src/include/types.h | 24 +++---- 16 files changed, 99 insertions(+), 97 deletions(-) diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index def57b7cb..e570f3463 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -2314,10 +2314,12 @@ void bwalkUpdateVertical(void) ground = -30000; } +#if PIRACYCHECKS if (g_Vars.currentplayer->inlift && newinlift == false) { // Exiting a lift piracyRestore(); } +#endif if (g_Vars.currentplayer->inlift && newinlift && g_Vars.currentplayer->onladder == false) { // Remaining in a lift diff --git a/src/game/bot.c b/src/game/bot.c index 8e17138eb..2834c3e12 100644 --- a/src/game/bot.c +++ b/src/game/bot.c @@ -37,7 +37,7 @@ #define PICKUPCRITERIA_CRITICAL 1 #define PICKUPCRITERIA_ANY 2 -struct chrdata *g_MpBotChrPtrs[MAX_SIMULANTS]; +struct chrdata *g_MpBotChrPtrs[MAX_BOTS]; u8 g_BotCount = 0; @@ -771,23 +771,23 @@ glabel botReset // chrSetShield(chr, 0); // chr->cmnum = 0; // chr->cmnum2 = 0; -// bgunFreeFireslot(chr->fireslot[0]); -// bgunFreeFireslot(chr->fireslot[1]); +// bgunFreeFireslot(chr->fireslots[0]); +// bgunFreeFireslot(chr->fireslots[1]); // chr->unk32c_12 = 0; -// chr->fireslot[0] = -1; -// chr->fireslot[1] = -1; +// chr->fireslots[0] = -1; +// chr->fireslots[1] = -1; // chr->firecount[0] = 0; // chr->firecount[1] = 0; // chr->weapons_held[0] = NULL; // chr->weapons_held[1] = NULL; -// chr->unk178 = 0; +// chr->weapons_held[2] = NULL; // chr->liftaction = 0; // chr->inlift = 0; -// chr->unk364 = 0; +// chr->lift = NULL; // chr->chrheight = 185; // // for (i = 0; i < 33; i++) { -// aibot->unk01c->unk00[i] = 0; +// aibot->ammoheld[i] = 0; // } // // botinvClear(chr); @@ -806,9 +806,9 @@ glabel botReset // aibot->gotoprop = NULL; // aibot->timeuntilreload60[0] = 0; // aibot->timeuntilreload60[1] = 0; -// aibot->nextbullettimer60 = 0; -// aibot->unk060 = 0; -// aibot->unk074 = -1; +// aibot->nextbullettimer60[0] = 0; +// aibot->nextbullettimer60[1] = 0; +// aibot->distmode = -1; // aibot->unk030 = 301; // aibot->throwtimer60 = 0; // aibot->burstsdone[0] = 0; @@ -823,8 +823,8 @@ glabel botReset // aibot->lastknownhill = -1; // aibot->cyclonedischarging[1] = 0; // aibot->cyclonedischarging[0] = 0; -// aibot->unk0cc = 0; -// aibot->unk0d0 = 0; +// aibot->changeguntimer60 = 0; +// aibot->distmodettl60 = 0; // aibot->forcemainloop = false; // aibot->returntodefendtimer60 = 0; // aibot->punchtimer60[HAND_LEFT] = -1; @@ -833,20 +833,20 @@ glabel botReset // aibot->reaperspeed[HAND_RIGHT] = 0; // aibot->commandtimer60 = 0; // aibot->shootdelaytimer60 = 0; -// aibot->unk120 = -1; +// aibot->targetlastseen60 = -1; // aibot->lastseenanytarget60 = -1; // aibot->targetinsight = 0; // aibot->queryplayernum = 0; // aibot->unk040 = 0; // aibot->unk06c = 0; // aibot->unk070 = 0; -// aibot->unk0e8 = 0; -// aibot->unk0e4 = 0; -// aibot->unk108 = 0; -// aibot->unk10c = 0; -// aibot->unk110 = 0; +// aibot->maulercharge[1] = 0; +// aibot->maulercharge[0] = 0; +// aibot->shotspeed.x = 0; +// aibot->shotspeed.y = 0; +// aibot->shotspeed.z = 0; // -// for (i = 0; i != 12; i++) { +// for (i = 0; i != MAX_MPCHRS; i++) { // aibot->chrnumsbydistanceasc[i] = -1; // aibot->chrdistances[i] = U32_MAX; // aibot->chrsinsight[i] = false; @@ -854,7 +854,7 @@ glabel botReset // aibot->chrrooms[i] = -1; // } // -// aibot->unk1e8 = 0; +// aibot->waypoints[0] = NULL; // aibot->unk208 = 0; // aibot->random1 = random(); // aibot->random1ttl60 = 0; @@ -864,7 +864,7 @@ glabel botReset // aibot->unk2c4 = 0; // // aibot->random2 = random(); -// aibot->aibot = random(); +// aibot->randomfrac = random() * (1.0f / U32_MAX); // aibot->unk078 = 0; // aibot->cheap = 0; // aibot->unk050 = 0; @@ -4396,7 +4396,7 @@ void botChooseGeneralTarget(struct chrdata *botchr) struct aibot *aibot = botchr->aibot; s32 i; s32 j; - bool distancesdone[12]; + bool distancesdone[MAX_MPCHRS]; s16 room = -1; struct chrdata *trychr; s32 playernum; @@ -11004,7 +11004,7 @@ void botTickUnpaused(struct chrdata *chr) } } else if (aibot->config->type == BOTTYPE_JUDGE) { // Attack the winning player - struct ranking rankings[12]; + struct ranking rankings[MAX_MPCHRS]; s32 count = mpGetPlayerRankings(rankings); s32 i; diff --git a/src/game/botmgr.c b/src/game/botmgr.c index 76a97ac12..4171d9409 100644 --- a/src/game/botmgr.c +++ b/src/game/botmgr.c @@ -18,7 +18,7 @@ void botmgrRemoveAll(void) { s32 i; - for (i = 0; i < 8; i++) { + for (i = 0; i < MAX_BOTS; i++) { g_MpBotChrPtrs[i] = NULL; } @@ -75,7 +75,7 @@ void botmgrAllocateBot(s32 chrnum, s32 aibotnum) chr->team = 1 << g_BotConfigsArray[aibotnum].base.team; chr->squadron = 0; - if (g_BotCount < 8) { + if (g_BotCount < MAX_BOTS) { g_MpBotChrPtrs[g_BotCount] = chr; g_BotCount++; @@ -217,7 +217,7 @@ void botmgrAllocateBot(s32 chrnum, s32 aibotnum) aibot->targetinsight = false; aibot->queryplayernum = 0; - for (i = 0; i < 12; i++) { + for (i = 0; i < MAX_MPCHRS; i++) { aibot->chrnumsbydistanceasc[i] = -1; aibot->chrdistances[i] = U32_MAX; aibot->chrsinsight[i] = 0; diff --git a/src/game/game_00c490.c b/src/game/game_00c490.c index 55da8c1c0..3370d83d5 100644 --- a/src/game/game_00c490.c +++ b/src/game/game_00c490.c @@ -3447,18 +3447,18 @@ void setupParseObjects(s32 stagenum) if (g_Vars.normmplayerisrunning && mpHasSimulants()) { u32 stack[4]; s32 i; - s32 slotsdone[8]; + s32 slotsdone[MAX_BOTS]; s32 chrnum = 0; s32 maxsimulants; s32 slotnum; if (mpIsFeatureUnlocked(MPFEATURE_8BOTS)) { - maxsimulants = 8; + maxsimulants = MAX_BOTS; } else { maxsimulants = 4; } - for (i = 0; i < 8; i++) { + for (i = 0; i < MAX_BOTS; i++) { slotsdone[i] = false; } diff --git a/src/game/game_127910.c b/src/game/game_127910.c index 9a54ab27e..2d12a635b 100644 --- a/src/game/game_127910.c +++ b/src/game/game_127910.c @@ -617,7 +617,7 @@ void playerAllocate(s32 index) g_Vars.players[index]->numaibuddies = 0; - for (i = 0; i < 8; i++) { + for (i = 0; i < MAX_BOTS; i++) { g_Vars.players[index]->aibuddynums[i] = 0; } diff --git a/src/game/game_19aa80.c b/src/game/game_19aa80.c index d533c0c01..e1052c7be 100644 --- a/src/game/game_19aa80.c +++ b/src/game/game_19aa80.c @@ -478,7 +478,7 @@ void mpDetermineUnlockedFeatures(void) // If the ability to have 8 simulants hasn't been unlocked, limit them to 4 if (!mpIsFeatureUnlocked(MPFEATURE_8BOTS)) { - for (k = 4; k < 8; k++) { + for (k = 4; k < MAX_BOTS; k++) { if (g_MpSetup.chrslots & (1 << (4 + k))) { mpRemoveSimulant(k); } @@ -905,7 +905,7 @@ void mpPerformSanityChecks(void) // for this number of players g_MpSetup.chrslots &= 0x000f; - for (i = 0; i != MAX_SIMULANTS; i++) { + for (i = 0; i != MAX_BOTS; i++) { g_BotConfigsArray[i].difficulty = g_MpSimulantDifficultiesPerNumPlayers[i][numplayers - 1]; if (g_BotConfigsArray[i].difficulty != BOTDIFF_DISABLED) { diff --git a/src/game/menu/items.c b/src/game/menu/items.c index 2b75c9770..177ef82df 100644 --- a/src/game/menu/items.c +++ b/src/game/menu/items.c @@ -11029,7 +11029,7 @@ Gfx *menuRenderItemPlayerStats(Gfx *gdl, struct menurendercontext *context) ypos -= data->scrolloffset; - for (i = 0; i < 12; i++) { + for (i = 0; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { struct mpchrconfig *loopmpchr = MPCHR(i); diff --git a/src/game/mplayer/ingame.c b/src/game/mplayer/ingame.c index d9d994f0a..112be74ff 100644 --- a/src/game/mplayer/ingame.c +++ b/src/game/mplayer/ingame.c @@ -39,7 +39,7 @@ s32 mpStatsForPlayerDropdownHandler(s32 operation, struct menuitem *item, union case MENUOP_GETOPTIONCOUNT: data->list.value = 0; - for (v0 = 0; v0 < 12; v0++) { + for (v0 = 0; v0 < MAX_MPCHRS; v0++) { if (g_MpSetup.chrslots & (1 << v0)) { data->list.value++; } @@ -48,7 +48,7 @@ s32 mpStatsForPlayerDropdownHandler(s32 operation, struct menuitem *item, union case MENUOP_GETOPTIONTEXT: v0 = 0; - for (a1 = 0; a1 < 12; a1++) { + for (a1 = 0; a1 < MAX_MPCHRS; a1++) { if (g_MpSetup.chrslots & (1 << a1)) { mpchr = MPCHR(a1); @@ -64,7 +64,7 @@ s32 mpStatsForPlayerDropdownHandler(s32 operation, struct menuitem *item, union case MENUOP_SET: v0 = 0; - for (a1 = 0; a1 < 12; a1++) { + for (a1 = 0; a1 < MAX_MPCHRS; a1++) { if (g_MpSetup.chrslots & (1 << a1)) { if (v0); @@ -80,7 +80,7 @@ s32 mpStatsForPlayerDropdownHandler(s32 operation, struct menuitem *item, union case MENUOP_GETOPTIONVALUE: v0 = 0; - for (v1 = 0; v1 < 12; v1++) { + for (v1 = 0; v1 < MAX_MPCHRS; v1++) { if (g_MpSetup.chrslots & (1 << v1)) { if (v0); diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index 24600d9f2..96685c61d 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -33,8 +33,8 @@ struct chrdata *g_MpAllChrPtrs[MAX_MPCHRS]; struct mpchrconfig *g_MpAllChrConfigPtrs[MAX_MPCHRS]; s32 g_MpNumChrs; u32 var800ac534; -struct mpbotconfig g_BotConfigsArray[MAX_SIMULANTS]; -u8 g_MpSimulantDifficultiesPerNumPlayers[8][4]; +struct mpbotconfig g_BotConfigsArray[MAX_BOTS]; +u8 g_MpSimulantDifficultiesPerNumPlayers[MAX_BOTS][4]; struct mpplayerconfig g_PlayerConfigsArray[6]; u8 g_AmBotCommands[16]; struct mpsetup g_MpSetup; @@ -245,7 +245,7 @@ void mpInit(void) } } - for (i = 0; i != 12; i++) { + for (i = 0; i != MAX_MPCHRS; i++) { struct mpchrconfig *mpchr = MPCHR(i); func0f187838(mpchr); @@ -487,7 +487,7 @@ void mpSetDefaultSetup(void) mpPlayerSetDefaults(i, false); } - for (i = 0; i < 8; i++) { + for (i = 0; i < MAX_BOTS; i++) { func0f1881d4(i); } @@ -636,13 +636,13 @@ void mpApplyLimits(void) s32 mpGetPlayerRankings(struct ranking *rankings) { s32 i; - s32 scores[12]; - u32 rankablescores[12]; - struct mpchrconfig *mpchrs[12]; - s32 chrnums[12]; + s32 scores[MAX_MPCHRS]; + u32 rankablescores[MAX_MPCHRS]; + struct mpchrconfig *mpchrs[MAX_MPCHRS]; + s32 chrnums[MAX_MPCHRS]; s32 count = 0; s32 numteams; - struct ranking teamrankings[12]; + struct ranking teamrankings[MAX_MPCHRS]; s32 winner; s32 loser; s32 score; @@ -658,7 +658,7 @@ s32 mpGetPlayerRankings(struct ranking *rankings) } // Populate 4 arrays with player info, sorted by highest score descending - for (i = 0; i < 12; i++) { + for (i = 0; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { mpchr = MPCHR(i); @@ -777,7 +777,7 @@ s32 mpCalculateTeamScore(s32 teamnum, s32 *result) s32 score; s32 deaths; - for (i = 0; i < 12; i++) { + for (i = 0; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { mpchr = MPCHR(i); @@ -2157,7 +2157,7 @@ void mpCalculateAwards(void) s32 numchrs; s32 numteams; - struct ranking teamrankings[12]; + struct ranking teamrankings[MAX_MPCHRS]; u32 stack[4]; playercount = PLAYERCOUNT(); @@ -2191,7 +2191,7 @@ void mpCalculateAwards(void) metrics[i].numdeaths = 0; metrics[i].numsuicides = 0; - for (j = 0; j < 12; j++) { + for (j = 0; j < MAX_MPCHRS; j++) { if (chrnum == j) { metrics[i].numsuicides += mpchr->killcounts[j]; } else { @@ -2199,7 +2199,7 @@ void mpCalculateAwards(void) } } - for (j = 0; j < 12; j++) { + for (j = 0; j < MAX_MPCHRS; j++) { struct mpchrconfig *othermpchr = MPCHR(j); metrics[i].numdeaths += othermpchr->killcounts[chrnum]; } @@ -2257,7 +2257,7 @@ void mpCalculateAwards(void) bool lost = false; if (mpplayer->base.placement == 0) { - for (j = 0; j < 12; j++) { + for (j = 0; j < MAX_MPCHRS; j++) { if (g_MpSetup.chrslots & (1 << j)) { struct mpchrconfig *othermpchr = MPCHR(j); @@ -2278,7 +2278,7 @@ void mpCalculateAwards(void) || ((g_MpSetup.options & MPOPTION_TEAMSENABLED) && numteams == mpplayer->base.placement + 1)) { bool won = false; - for (j = 0; j < 12; j++) { + for (j = 0; j < MAX_MPCHRS; j++) { if (g_MpSetup.chrslots & (1 << j)) { struct mpchrconfig *othermpchr = MPCHR(j); @@ -2460,12 +2460,12 @@ void mpCalculateAwards(void) s32 leastdeathsplayer = -1; s32 k; - for (k = 0; k < 12; k++) { + for (k = 0; k < MAX_MPCHRS; k++) { if (g_MpSetup.chrslots & (1 << k)) { s32 totalkills = 0; struct mpchrconfig *mpchr = MPCHR(k); - for (j = 0; j < 12; j++) { + for (j = 0; j < MAX_MPCHRS; j++) { // @bug: i should be k. The value of i was incremented after // the last iteration of its loop above so it'll be between // 1 and 4 inclusively depending on the number of players. @@ -4087,7 +4087,7 @@ void mpFindUnusedHeadAndBody(u8 *mpheadnum, u8 *mpbodynum) trympheadnum = random() % 75; trympbodynum = random() % 61; - for (i = 0; i < 12; i++) { + for (i = 0; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { mpchr = MPCHR(i); @@ -4892,7 +4892,7 @@ struct mpchrconfig *mpGetChrConfigBySlotNum(s32 slot) struct mpchrconfig *result = NULL; s32 i; - for (i = 0; i < 12; i++) { + for (i = 0; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { if (count == slot) { result = MPCHR(i); @@ -4913,7 +4913,7 @@ s32 mpGetChrIndexBySlotNum(s32 slot) s32 result = 0; s32 i; - for (i = 0; i < 12; i++) { + for (i = 0; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { if (count == slot) { result = i; @@ -4951,7 +4951,7 @@ u8 mpFindUnusedTeamNum(void) while (teamnum < 7 && !available) { available = true; - for (i = 0; i < 12; i++) { + for (i = 0; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { struct mpchrconfig *mpchr = MPCHR(i); @@ -4995,7 +4995,7 @@ void mpCreateBotFromProfile(s32 botnum, u8 profilenum) headnum = g_BotHeads[random() % ARRAYCOUNT(g_BotHeads)]; available = true; - for (i = 0; i < 12; i++) { + for (i = 0; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { struct mpchrconfig *mpchr = MPCHR(i); @@ -5030,7 +5030,7 @@ s32 mpGetSlotForNewBot(void) { s32 i = 0; - while (i < MAX_SIMULANTS - 1 && g_MpSetup.chrslots & (1 << (i + 4))) { + while (i < MAX_BOTS - 1 && g_MpSetup.chrslots & (1 << (i + 4))) { i++; } @@ -5056,10 +5056,10 @@ bool mpHasSimulants(void) bool mpHasUnusedBotSlots(void) { - s32 numvacant = mpIsFeatureUnlocked(MPFEATURE_8BOTS) ? 8 : 4; + s32 numvacant = mpIsFeatureUnlocked(MPFEATURE_8BOTS) ? MAX_BOTS : 4; s32 i; - for (i = 4; i < 12; i++) { + for (i = 4; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { numvacant--; } @@ -5074,11 +5074,11 @@ bool mpHasUnusedBotSlots(void) bool mpIsSimSlotEnabled(s32 slot) { - s32 numfree = 8; + s32 numfree = MAX_BOTS; s32 i; if ((g_MpSetup.chrslots & (1 << (slot + 4))) == 0) { - for (i = 0; i < 8; i++) { + for (i = 0; i < MAX_BOTS; i++) { if (g_MpSetup.chrslots & (1 << (i + 4))) { numfree--; } @@ -5131,7 +5131,7 @@ void mpGenerateBotNames(void) } // Count the number of bots using each profile (MeatSim, TurtleSim etc) - for (i = 4; i < 12; i++) { + for (i = 4; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { profilenum = mpFindBotProfile(g_BotConfigsArray[i - 4].type, g_BotConfigsArray[i - 4].difficulty); @@ -5152,7 +5152,7 @@ void mpGenerateBotNames(void) } } - for (i = 4; i < 12; i++) { + for (i = 4; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { profilenum = mpFindBotProfile(g_BotConfigsArray[i - 4].type, g_BotConfigsArray[i - 4].difficulty); @@ -5212,7 +5212,7 @@ s32 func0f18d074(s32 index) } } - for (i = 0; i < MAX_SIMULANTS; i++) { + for (i = 0; i < MAX_BOTS; i++) { if (&g_BotConfigsArray[i].base == g_MpAllChrConfigPtrs[index]) { return i + 4; } @@ -5654,7 +5654,7 @@ void mpApplyConfig(struct mpconfigfull *config) g_MpSetup.chrslots = chrslots; #endif - for (i = 0; i < 8; i++) { + for (i = 0; i < MAX_BOTS; i++) { g_BotConfigsArray[i].type = config->config.simulants[i].type; for (j = 0; j < 4; j++) { @@ -5732,7 +5732,7 @@ void mpsetupfileLoadWad(struct savebuffer *buffer) g_MpSetup.options = savebufferReadBits(buffer, 21); g_MpSetup.chrslots &= 0x000f; - for (i = 0; i < MAX_SIMULANTS; i++) { + for (i = 0; i < MAX_BOTS; i++) { g_BotConfigsArray[i].base.name[0] = '\0'; g_BotConfigsArray[i].type = savebufferReadBits(buffer, 5); g_BotConfigsArray[i].difficulty = savebufferReadBits(buffer, 3); @@ -5777,7 +5777,7 @@ void mpsetupfileSaveWad(struct savebuffer *buffer) func0f0d55a4(buffer, g_MpSetup.name); - for (i = 0; i < 8; i++) { + for (i = 0; i < MAX_BOTS; i++) { if (g_MpSetup.chrslots & (1 << (i + 4))) { numsims++; } @@ -5791,7 +5791,7 @@ void mpsetupfileSaveWad(struct savebuffer *buffer) savebufferOr(buffer, g_MpSetup.options, 21); - for (i = 0; i < 8; i++) { + for (i = 0; i < MAX_BOTS; i++) { savebufferOr(buffer, g_BotConfigsArray[i].type, 5); if (g_MpSetup.chrslots & (1 << (i + 4))) { diff --git a/src/game/mplayer/scenarios.c b/src/game/mplayer/scenarios.c index 8b4d523e0..5f89b2def 100644 --- a/src/game/mplayer/scenarios.c +++ b/src/game/mplayer/scenarios.c @@ -625,7 +625,7 @@ void scenarioCalculatePlayerScore(struct mpchrconfig *mpchr, s32 chrnum, s32 *sc } else { *score = 0; - for (i = 0; i < 12; i++) { + for (i = 0; i < MAX_MPCHRS; i++) { if (i == chrnum) { *score -= mpchr->killcounts[i]; } else if (g_MpSetup.options & MPOPTION_TEAMSENABLED) { diff --git a/src/game/mplayer/scenarios/capturethecase.inc b/src/game/mplayer/scenarios/capturethecase.inc index ba2d01943..373b0ef56 100644 --- a/src/game/mplayer/scenarios/capturethecase.inc +++ b/src/game/mplayer/scenarios/capturethecase.inc @@ -149,7 +149,7 @@ void ctcInitProps(void) teamsdone[g_ScenarioData.ctc.teamindexes[i]] = true; } - for (k = 0; k < 12; k++) { + for (k = 0; k < MAX_MPCHRS; k++) { if (g_MpSetup.chrslots & (1 << k)) { mpchr = MPCHR(k); diff --git a/src/game/mplayer/scenarios/kingofthehill.inc b/src/game/mplayer/scenarios/kingofthehill.inc index a999e7487..7a77be59b 100644 --- a/src/game/mplayer/scenarios/kingofthehill.inc +++ b/src/game/mplayer/scenarios/kingofthehill.inc @@ -138,7 +138,7 @@ void kohTick(void) char text[64]; s32 teamsinhill[8]; struct pad pad; - struct prop *chrsinhill[12]; + struct prop *chrsinhill[MAX_MPCHRS]; struct prop *prop; struct chrdata *chr; s32 padnum; diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index d1c722d1b..24740e7bc 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -1502,7 +1502,7 @@ char *mpMenuTextMpconfigMarquee(struct menuitem *item) } #if VERSION >= VERSION_NTSC_1_0 - if (scenarionum <= 5 && arenanum != -1 && numsims >= 0 && filename[0] != '\0' && numsims <= 8) { + if (scenarionum <= 5 && arenanum != -1 && numsims >= 0 && filename[0] != '\0' && numsims <= MAX_BOTS) { // "%s: Scenario: %s Arena: %s Simulants: %d" sprintf(g_StringPointer, langGet(L_MPMENU_140), filename, @@ -2114,7 +2114,7 @@ s32 menuhandlerMpClearAllSimulants(s32 operation, struct menuitem *item, union h { if (operation == MENUOP_SET) { s32 i; - for (i = 0; i < MAX_SIMULANTS; i++) { + for (i = 0; i < MAX_BOTS; i++) { mpRemoveSimulant(i); } } @@ -3528,7 +3528,7 @@ void mpConfigureQuickTeamPlayers(void) s32 i; if (g_Vars.mpquickteam != MPQUICKTEAM_NONE) { - for (i = 0; i < 8; i++) { + for (i = 0; i < MAX_BOTS; i++) { mpRemoveSimulant(i); } @@ -3692,7 +3692,7 @@ s32 menuhandlerMpNumberOfSimulants(s32 operation, struct menuitem *item, union h { switch (operation) { case MENUOP_GETOPTIONCOUNT: - data->dropdown.value = !mpIsFeatureUnlocked(MPFEATURE_8BOTS) ? 4 : 8; + data->dropdown.value = !mpIsFeatureUnlocked(MPFEATURE_8BOTS) ? 4 : MAX_BOTS; break; case MENUOP_GETOPTIONTEXT: sprintf(g_StringPointer, "%d\n", data->dropdown.value + 1); diff --git a/src/include/bss.h b/src/include/bss.h index b9edfd833..39c8b115e 100644 --- a/src/include/bss.h +++ b/src/include/bss.h @@ -284,12 +284,12 @@ extern u32 var800ac4cc; extern struct chrdata *g_MpAllChrPtrs[MAX_MPCHRS]; extern struct mpchrconfig *g_MpAllChrConfigPtrs[MAX_MPCHRS]; extern s32 g_MpNumChrs; -extern struct mpbotconfig g_BotConfigsArray[MAX_SIMULANTS]; -extern u8 g_MpSimulantDifficultiesPerNumPlayers[8][4]; +extern struct mpbotconfig g_BotConfigsArray[MAX_BOTS]; +extern u8 g_MpSimulantDifficultiesPerNumPlayers[MAX_BOTS][4]; extern struct mpplayerconfig g_PlayerConfigsArray[6]; extern u8 g_AmBotCommands[16]; extern struct mpsetup g_MpSetup; extern struct bossfile g_BossFile; -extern struct chrdata *g_MpBotChrPtrs[MAX_SIMULANTS]; +extern struct chrdata *g_MpBotChrPtrs[MAX_BOTS]; #endif diff --git a/src/include/constants.h b/src/include/constants.h index d85e69127..88cf3a9bc 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -1396,9 +1396,9 @@ #define MAX_CHRWAYPOINTS 6 #define MAX_DANGEROUSPROPS 12 #define MAX_LIFTS 10 -#define MAX_MPCHRS (4 + MAX_SIMULANTS) +#define MAX_MPCHRS (4 + MAX_BOTS) #define MAX_OBJECTIVES 10 -#define MAX_SIMULANTS 8 +#define MAX_BOTS 8 #define MAX_SPAWNPOINTS 24 #define MAX_SQUADRONS 16 #define MAX_TEAMS 8 diff --git a/src/include/types.h b/src/include/types.h index 7c8f00155..26db6d27a 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -919,11 +919,11 @@ struct aibot { /*0x124*/ s32 lastseenanytarget60; /*0x128*/ bool targetinsight; /*0x12c*/ s32 queryplayernum; - /*0x130*/ s8 chrnumsbydistanceasc[12]; - /*0x13c*/ f32 chrdistances[12]; - /*0x16c*/ u8 chrsinsight[12]; - /*0x178*/ s32 chrslastseen60[12]; - /*0x1a8*/ s16 chrrooms[12]; + /*0x130*/ s8 chrnumsbydistanceasc[MAX_MPCHRS]; + /*0x13c*/ f32 chrdistances[MAX_MPCHRS]; + /*0x16c*/ u8 chrsinsight[MAX_MPCHRS]; + /*0x178*/ s32 chrslastseen60[MAX_MPCHRS]; + /*0x1a8*/ s16 chrrooms[MAX_MPCHRS]; /*0x1c0*/ f32 unk1c0; /*0x1c4*/ f32 unk1c4; /*0x1c8*/ f32 unk1c8; @@ -2912,7 +2912,7 @@ struct player { /*0x1be0*/ f32 cachedlookahead; /*0x1be4*/ u16 lookaheadframe; /*0x1be6*/ u8 numaibuddies; - /*0x1be7*/ u8 aibuddynums[MAX_SIMULANTS]; + /*0x1be7*/ u8 aibuddynums[MAX_BOTS]; /*0x1bf0*/ bool bondexploding; /*0x1bf4*/ s32 bondnextexplode; // lvframe60 of next explosion /*0x1bf8*/ s32 bondcurexplode; // Increases by 1 on each tick even when not exploding @@ -4568,7 +4568,7 @@ struct mpchrconfig { /*0x1c*/ u16 unk1c; /*0x1e*/ s8 placement; // 0 = winner, 1 = second place etc /*0x20*/ s32 rankablescore; - /*0x24*/ s16 killcounts[12]; // per player - each index is a chrslot + /*0x24*/ s16 killcounts[MAX_MPCHRS]; // per player - each index is a chrslot /*0x3c*/ s16 numdeaths; /*0x3e*/ s16 numpoints; /*0x40*/ s16 unk40; @@ -4743,8 +4743,8 @@ struct scenariodata_htm { /*0x800ac1e0*/ s16 dlplayernum; /*0x800ac1e2*/ s16 playernuminrange; /*0x800ac1e4*/ s32 dlterminalnum; - /*0x800ac1e8*/ s32 numpoints[12]; - /*0x800ac218*/ s32 dltime240[12]; + /*0x800ac1e8*/ s32 numpoints[MAX_MPCHRS]; + /*0x800ac218*/ s32 dltime240[MAX_MPCHRS]; /*0x800ac248*/ u32 unk138; /*0x800ac24c*/ struct prop *uplink; /*0x800ac250*/ u32 unk140; @@ -4755,9 +4755,9 @@ struct scenariodata_pac { s16 unk00; u16 age240; s32 victimindex; - s16 victims[12]; // shuffled list of player numbers - s16 killcounts[12]; // indexed by player num - s16 survivalcounts[12]; // indexed by player num + s16 victims[MAX_MPCHRS]; // shuffled list of player numbers + s16 killcounts[MAX_MPCHRS]; // indexed by player num + s16 survivalcounts[MAX_MPCHRS]; // indexed by player num }; struct scenariodata_koh {