diff --git a/src/game/bg.c b/src/game/bg.c index 0b71bbdf4..2a3bab3dc 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -1604,7 +1604,7 @@ void bgReset(s32 stagenum) // Copy 0x40 bytes from a random location in ROM to a random // location in RAM. The write address can be anywhere in the // boot segment or in the lib segment up to modelRenderNodeDl. - dmaExec((void *)(PHYS_TO_K0(0x1000) + (random() & 0x1fff8)), random() & 0x1fffe, 0x40); + dmaExec((void *)(PHYS_TO_K0(0x1000) + (rngRandom() & 0x1fff8)), rngRandom() & 0x1fffe, 0x40); } } #endif diff --git a/src/game/body.c b/src/game/body.c index 5d272d3d7..058f1e4a6 100644 --- a/src/game/body.c +++ b/src/game/body.c @@ -299,7 +299,7 @@ struct model *bodyAllocateModel(s32 bodynum, s32 headnum, u32 spawnflags) if (spawnflags & SPAWNFLAG_FORCESUNGLASSES) { sunglasses = true; } else if (spawnflags & SPAWNFLAG_MAYBESUNGLASSES) { - sunglasses = random() % 2 == 0; + sunglasses = rngRandom() % 2 == 0; } if (spawnflags & SPAWNFLAG_FIXEDHEIGHT) { @@ -325,7 +325,7 @@ s32 bodyChooseHead(s32 bodynum) g_ActiveMaleHeadsIndex = 0; } } else if (bodynum == BODY_FEM_GUARD) { - head = g_FemGuardHeads[random() % 3]; + head = g_FemGuardHeads[rngRandom() % 3]; } else { head = g_ActiveFemaleHeads[g_ActiveFemaleHeadsIndex++]; @@ -493,10 +493,10 @@ void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex) if (packed->tude != 4) { chr->tude = packed->tude; } else { - chr->tude = random() % 4; + chr->tude = rngRandom() % 4; } - chr->voicebox = random() % 3; + chr->voicebox = rngRandom() % 3; if (!g_HeadsAndBodies[chr->bodynum].ismale) { chr->voicebox = VOICEBOX_FEMALE; @@ -519,7 +519,7 @@ void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex) chr->flags |= CHRFLAG0_AIVSAI; } - if (random() % 5 == 0) { + if (rngRandom() % 5 == 0) { // Make chr punch slower chr->flags2 |= CHRFLAG1_ADJUSTPUNCHSPEED; } @@ -596,8 +596,8 @@ struct prop *bodyAllocateEyespy(struct pad *pad, RoomNum room) chr->team = 0; chr->squadron = 0; chr->maxdamage = 2; - chr->tude = random() & 3; - chr->voicebox = random() % 3; + chr->tude = rngRandom() & 3; + chr->voicebox = rngRandom() % 3; chr->naturalanim = 0; chr->myspecial = 0; chr->yvisang = 0; diff --git a/src/game/bodyreset.c b/src/game/bodyreset.c index 18b0a9973..0c98493db 100644 --- a/src/game/bodyreset.c +++ b/src/game/bodyreset.c @@ -26,7 +26,7 @@ void bodiesReset(s32 stagenum) g_HeadsAndBodies[i].modeldef = NULL; } - var80062c80 = random() % g_NumBondBodies; + var80062c80 = rngRandom() % g_NumBondBodies; var80062b14 = 0; var80062b18 = 0; @@ -67,7 +67,7 @@ void bodiesReset(s32 stagenum) for (i = 0; i < g_NumActiveHeadsPerGender; i++) { do { done = true; - g_ActiveMaleHeads[i] = headsavailablelist[random() % headsavailablelen]; + g_ActiveMaleHeads[i] = headsavailablelist[rngRandom() % headsavailablelen]; if (headsavailablelen > g_NumActiveHeadsPerGender) { for (j = 0; j < i; j++) { @@ -97,7 +97,7 @@ void bodiesReset(s32 stagenum) for (i = 0; i < g_NumActiveHeadsPerGender; i++) { do { done = true; - g_ActiveFemaleHeads[i] = headsavailablelist[random() % headsavailablelen]; + g_ActiveFemaleHeads[i] = headsavailablelist[rngRandom() % headsavailablelen]; if (headsavailablelen > g_NumActiveHeadsPerGender) { for (j = 0; j < i; j++) { diff --git a/src/game/bondgun.c b/src/game/bondgun.c index a42c1f734..96de5c52a 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -898,7 +898,7 @@ void bgunStartAnimation(struct guncmd *cmd, s32 handnum, struct hand *hand) if (cmd->type != GUNCMD_PLAYANIMATION) { struct guncmd *loopcmd = cmd; s32 done = false; - u32 rand = random() % 100; + u32 rand = rngRandom() % 100; while (loopcmd->type != GUNCMD_END) { if (bgun0f098884(loopcmd, &hand->gset) && !done) { @@ -7220,7 +7220,7 @@ void bgunUpdateMagnum(struct hand *hand, s32 handnum, struct modeldef *modeldef, if (modeldef != NULL) { for (i = 0; i < hand->unk0cc8_04; i++) { - struct modelnode *node = modelGetPart(modeldef, 0x0a + random() % 6); + struct modelnode *node = modelGetPart(modeldef, 0x0a + rngRandom() % 6); if (node) { s32 index = modelFindNodeMtxIndex(node, 0); @@ -11264,8 +11264,8 @@ struct sndstate **bgunAllocateAudioHandle(void) void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum) { #if VERSION >= VERSION_NTSC_1_0 - u32 rand1 = random(); - u32 rand2 = random(); + u32 rand1 = rngRandom(); + u32 rand2 = rngRandom(); struct sndstate **handle; if (g_Vars.lvupdate240 <= 0) { @@ -11344,8 +11344,8 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum) if (texturenum == 10000) { soundnum = SFX_SHIELD_DAMAGE; } else if (gset->weaponnum == WEAPON_LASER) { - if (gset->weaponfunc == FUNC_PRIMARY || ((gset->unk063a % 4) == 0 && (random() % 2))) { - if ((random() % 2) == 0) { + if (gset->weaponfunc == FUNC_PRIMARY || ((gset->unk063a % 4) == 0 && (rngRandom() % 2))) { + if ((rngRandom() % 2) == 0) { soundnum = SFX_CLOAK_ON; } else { soundnum = SFX_CLOAK_OFF; @@ -11409,8 +11409,8 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum) } } #else - u32 rand1 = random(); - u32 rand2 = random(); + u32 rand1 = rngRandom(); + u32 rand2 = rngRandom(); struct sndstate **handle; if (g_Vars.lvupdate240 <= 0) { @@ -11483,7 +11483,7 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum) soundnum = SFX_SHIELD_DAMAGE; } else if (gset->weaponnum == WEAPON_LASER) { if (gset->weaponfunc == FUNC_PRIMARY || (gset->unk063a % 8) == 0) { - if ((random() % 2) == 0) { + if ((rngRandom() % 2) == 0) { soundnum = SFX_CLOAK_ON; } else { soundnum = SFX_CLOAK_OFF; @@ -11561,8 +11561,8 @@ void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum, { #if VERSION >= VERSION_NTSC_1_0 struct sndstate **handle; - u32 rand1 = random(); - u32 rand2 = random(); + u32 rand1 = rngRandom(); + u32 rand2 = rngRandom(); bool playdefault; s16 soundnum; bool overridden; @@ -11585,7 +11585,7 @@ void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum, if (gset->weaponnum == WEAPON_LASER) { playdefault = false; - if (gset->weaponfunc == FUNC_PRIMARY || ((gset->unk063a % 4) == 0 && (random() % 2))) { + if (gset->weaponfunc == FUNC_PRIMARY || ((gset->unk063a % 4) == 0 && (rngRandom() % 2))) { // Laser sounds s16 sounds[] = {SFX_CLOAK_ON, SFX_CLOAK_OFF}; soundnum = sounds[rand1 % ARRAYCOUNT(sounds)]; @@ -11660,8 +11660,8 @@ void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum, } #else struct sndstate **handle; - u32 rand1 = random(); - u32 rand2 = random(); + u32 rand1 = rngRandom(); + u32 rand2 = rngRandom(); s16 soundnum; bool overridden; diff --git a/src/game/bondmove.c b/src/game/bondmove.c index cc02f32e1..31b9e9be7 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -2691,7 +2691,7 @@ void bmoveUpdateHead(f32 arg0, f32 arg1, f32 arg2, Mtxf *arg3, f32 arg4) } } else { if (g_Vars.currentplayer->startnewbonddie) { - bheadStartDeathAnimation(g_DeathAnimations[random() % g_NumDeathAnimations], random() % 2, 0, 1); + bheadStartDeathAnimation(g_DeathAnimations[rngRandom() % g_NumDeathAnimations], rngRandom() % 2, 0, 1); g_Vars.currentplayer->startnewbonddie = false; } diff --git a/src/game/bondview.c b/src/game/bondview.c index af101fa37..13bf75af2 100644 --- a/src/game/bondview.c +++ b/src/game/bondview.c @@ -335,7 +335,7 @@ Gfx *bviewDrawStatic(Gfx *gdl, u32 arg1, s32 arg2) s32 viewheight = viGetViewHeight(); s32 viewwidth = viGetViewWidth(); s32 viewleft = viGetViewLeft(); - u16 *fb2 = (u16 *) PHYS_TO_K0(random() & 0xfff00); + u16 *fb2 = (u16 *) PHYS_TO_K0(rngRandom() & 0xfff00); s32 y; gDPPipeSync(gdl++); @@ -344,7 +344,7 @@ Gfx *bviewDrawStatic(Gfx *gdl, u32 arg1, s32 arg2) #ifdef PLATFORM_N64 for (y = viewtop; y < viewtop + viewheight; y++) { - gdl = bviewCopyPixels(gdl, fb2, random() % 240, 5, y, 1.0f, viewleft, viewwidth); + gdl = bviewCopyPixels(gdl, fb2, rngRandom() % 240, 5, y, 1.0f, viewleft, viewwidth); } #else gDPSetCombineLERP(gdl++, @@ -468,8 +468,8 @@ Gfx *bviewDrawFilmInterlace(Gfx *gdl, u32 colour, u32 alpha) } } - if (random() % 20 == 1) { - tmpy = random() % 200; + if (rngRandom() % 20 == 1) { + tmpy = rngRandom() % 200; } gdl = bviewCopyPixels(gdl, fb, tmpy, 5, y, 1, viewleft, viewwidth); @@ -490,8 +490,8 @@ Gfx *bviewDrawFilmInterlace(Gfx *gdl, u32 colour, u32 alpha) } } - if (random() % 20 == 1) { - tmpy += random() % 200; + if (rngRandom() % 20 == 1) { + tmpy += rngRandom() % 200; } gDPFillRectangle(gdl++, viewleft, tmpy, viewleft + viewwidth, tmpy + 1); @@ -762,9 +762,9 @@ Gfx *bviewDrawFisheye(Gfx *gdl, u32 colour, u32 alpha, s32 shuttertime60, s8 sta for (i = viewtop; i < viewtop + viewheight; i++) { if (hit == EYESPYHIT_DAMAGE) { - alpha2 = (random() % 120) + 120; + alpha2 = (rngRandom() % 120) + 120; colour = 0xff333300 | (alpha2 & 0xff); - f22 = ((random() % 32) + (f32) FBALLOC_HEIGHT) * (1.0f / 256.0f); + f22 = ((rngRandom() % 32) + (f32) FBALLOC_HEIGHT) * (1.0f / 256.0f); gDPSetEnvColorViaWord(gdl++, colour); } else { @@ -2163,7 +2163,7 @@ Gfx *bviewDrawNvLens(Gfx *gdl) u8 green; if (((var8007f878 & 1) != (y & 1)) != 0) { - u8 tmp = random() % 12; + u8 tmp = rngRandom() % 12; green = 0xff - tmp; } else { green = 0x94; @@ -2181,7 +2181,7 @@ Gfx *bviewDrawNvLens(Gfx *gdl) u8 green; if (((var8007f878 & 1) != (y & 1)) != 0) { - u8 tmp = random() % 12; + u8 tmp = rngRandom() % 12; green = 0xff - tmp; } else { green = 0x94; @@ -2363,7 +2363,7 @@ Gfx *bviewDrawIrLens(Gfx *gdl) } #endif - red += random() % 8; + red += rngRandom() % 8; if (red > 255) { red = 255; diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index 1d0853c06..78960fdb3 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -1132,7 +1132,7 @@ void bwalkUpdateVertical(void) SFX_JO_LANDING_05B7 }; - psCreate(NULL, g_Vars.currentplayer->prop, sounds[random() % 3], + psCreate(NULL, g_Vars.currentplayer->prop, sounds[rngRandom() % 3], -1, -1, PSFLAG_0400 | PSFLAG_IGNOREROOMS, 0, PSTYPE_NONE, 0, -1, NULL, -1, -1, -1, -1); } } diff --git a/src/game/bot.c b/src/game/bot.c index 2f087092f..3f4334d59 100644 --- a/src/game/bot.c +++ b/src/game/bot.c @@ -185,13 +185,13 @@ void botReset(struct chrdata *chr, u8 respawning) aibot->waypoints[0] = NULL; aibot->numwaystepstotarget = 0; - aibot->random1 = random(); + aibot->random1 = rngRandom(); aibot->random1ttl60 = 0; aibot->targetcloaktimer60 = 0; aibot->canseecloaked = 0; aibot->rcpcloaktimer60 = 0; aibot->random2ttl60 = 0; - aibot->random2 = random(); + aibot->random2 = rngRandom(); aibot->randomfrac = RANDOMFRAC(); aibot->cheap = 0; @@ -1417,8 +1417,8 @@ void bot0f192a74(struct chrdata *chr) aibot->random3ttl60 -= g_Vars.lvupdate60; if (aibot->random3ttl60 <= 0) { - aibot->random3 = random(); - aibot->random3ttl60 = TICKS(20) + random() % TICKS(20); + aibot->random3 = rngRandom(); + aibot->random3ttl60 = TICKS(20) + rngRandom() % TICKS(20); } if (g_Vars.lvupdate240 > 0) { @@ -1559,7 +1559,7 @@ void botChooseGeneralTarget(struct chrdata *botchr) // However, the usage of canseecloaked appears to be botched. // It is implemented in botIsTargetInvisible, but that function is not // called here while canseecloaked is true. - if (random() % TICKS(4 * 60 * 60) < g_MpNumChrs * g_Vars.lvupdate60) { + if (rngRandom() % TICKS(4 * 60 * 60) < g_MpNumChrs * g_Vars.lvupdate60) { aibot->canseecloaked = true; } @@ -1754,7 +1754,7 @@ s32 botFindTeammateToFollow(struct chrdata *chr, f32 range) if ((g_MpSetup.options & MPOPTION_TEAMSENABLED) && chr->myaction != MA_AIBOTFOLLOW - && (random() % 100) < chr->aibot->followchance) { + && (rngRandom() % 100) < chr->aibot->followchance) { f32 closestdistance = 0; s32 closestplayernum = -1; s32 i; @@ -1892,8 +1892,8 @@ struct prop *botFindPickup(struct chrdata *chr, s32 criteria) for (i = 0; i < ARRAYCOUNT(weaponnums); i++) { if (weaponnums[i] > WEAPON_UNARMED && weaponnums[i] == weapon->weaponnum) { - if (random() % 16) { - if (weapproplist[i] == NULL || sqdist1 < weapdistlist[i] || random() % 16 == 0) { + if (rngRandom() % 16) { + if (weapproplist[i] == NULL || sqdist1 < weapdistlist[i] || rngRandom() % 16 == 0) { weapproplist[i] = prop; weapdistlist[i] = sqdist1; } @@ -1904,8 +1904,8 @@ struct prop *botFindPickup(struct chrdata *chr, s32 criteria) ammotype = botactGetAmmoTypeByFunction(weapon->weaponnum, FUNC_PRIMARY); - if (ammotype > 0 && random() % 16) { - if (ammoproplist[ammotype] == NULL || sqdist1 < ammodistlist[ammotype] || random() % 16 == 0) { + if (ammotype > 0 && rngRandom() % 16) { + if (ammoproplist[ammotype] == NULL || sqdist1 < ammodistlist[ammotype] || rngRandom() % 16 == 0) { ammoproplist[ammotype] = prop; ammodistlist[ammotype] = sqdist1; } @@ -1928,8 +1928,8 @@ struct prop *botFindPickup(struct chrdata *chr, s32 criteria) if (weaponnum > 0) { for (j = 0; j < ARRAYCOUNT(weaponnums); j++) { if (weaponnums[j] > WEAPON_UNARMED && weaponnum == weaponnums[j]) { - if (random() % 16) { - if (weapproplist[j] == NULL || sqdist2 < weapdistlist[j] || random() % 16 == 0) { + if (rngRandom() % 16) { + if (weapproplist[j] == NULL || sqdist2 < weapdistlist[j] || rngRandom() % 16 == 0) { weapproplist[j] = prop; weapdistlist[j] = sqdist2; } @@ -1939,8 +1939,8 @@ struct prop *botFindPickup(struct chrdata *chr, s32 criteria) } } - if (random() % 16) { - if (ammoproplist[ammotype] == NULL || sqdist2 < ammodistlist[ammotype] || random() % 16 == 0) { + if (rngRandom() % 16) { + if (ammoproplist[ammotype] == NULL || sqdist2 < ammodistlist[ammotype] || rngRandom() % 16 == 0) { ammoproplist[ammotype] = prop; ammodistlist[ammotype] = sqdist2; } @@ -1952,11 +1952,11 @@ struct prop *botFindPickup(struct chrdata *chr, s32 criteria) if (weaponnums[i] == WEAPON_MPSHIELD) { sqdist2 = chrGetSquaredDistanceToCoord(chr, &prop->pos); - if (random() % 16 == 0) { + if (rngRandom() % 16 == 0) { break; } - if (weapproplist[i] == NULL || sqdist2 < weapdistlist[i] || random() % 16 == 0) { + if (weapproplist[i] == NULL || sqdist2 < weapdistlist[i] || rngRandom() % 16 == 0) { weapproplist[i] = prop; weapdistlist[i] = sqdist2; } @@ -2407,8 +2407,8 @@ void botTickUnpaused(struct chrdata *chr) aibot->random2ttl60 -= g_Vars.lvupdate60; if (aibot->random2ttl60 < 0) { - aibot->random2ttl60 = TICKS(1800) + random() % TICKS(60 * 240); - aibot->random2 = random(); + aibot->random2ttl60 = TICKS(1800) + rngRandom() % TICKS(60 * 240); + aibot->random2 = rngRandom(); aibot->randomfrac = RANDOMFRAC(); } @@ -2539,7 +2539,7 @@ void botTickUnpaused(struct chrdata *chr) if (g_MpSetup.scenario == MPSCENARIO_HOLDTHEBRIEFCASE) { s32 numgetting = botGetCountInTeamDoingCommand(chr, AIBOTCMD_GETCASE2, false); - if (numgetting <= 0 || (numgetting < (teamsize + 1) / 2 || random() % 100 < 66)) { + if (numgetting <= 0 || (numgetting < (teamsize + 1) / 2 || rngRandom() % 100 < 66)) { botApplyScenarioCommand(chr, AIBOTCMD_GETCASE2); } else { botApplyScenarioCommand(chr, AIBOTCMD_NORMAL); @@ -2547,7 +2547,7 @@ void botTickUnpaused(struct chrdata *chr) } else if (g_MpSetup.scenario == MPSCENARIO_HACKERCENTRAL) { s32 numbots = botGetCountInTeamDoingCommand(chr, AIBOTCMD_DOWNLOAD, false); - if (aibot->hasuplink || numbots <= 0 || (numbots < (teamsize + 1) / 2 || random() % 100 < 50)) { + if (aibot->hasuplink || numbots <= 0 || (numbots < (teamsize + 1) / 2 || rngRandom() % 100 < 50)) { botApplyScenarioCommand(chr, AIBOTCMD_DOWNLOAD); } else { botApplyScenarioCommand(chr, AIBOTCMD_NORMAL); @@ -2555,7 +2555,7 @@ void botTickUnpaused(struct chrdata *chr) } else if (g_MpSetup.scenario == MPSCENARIO_POPACAP) { s32 numchasing = botGetCountInTeamDoingCommand(chr, AIBOTCMD_POPCAP, false); - if (numchasing <= 0 || numchasing < (teamsize + 1) / 2 || random() % 100 < 50) { + if (numchasing <= 0 || numchasing < (teamsize + 1) / 2 || rngRandom() % 100 < 50) { botApplyScenarioCommand(chr, AIBOTCMD_POPCAP); } else { botApplyScenarioCommand(chr, AIBOTCMD_NORMAL); @@ -2571,7 +2571,7 @@ void botTickUnpaused(struct chrdata *chr) if (numinhill <= 0 || numinhill < teamsize / 2) { botApplyScenarioCommand(chr, AIBOTCMD_HOLDHILL); } else if (numinhill > botGetNumOpponentsInHill(chr)) { - if (random() % 100 < 50) { + if (rngRandom() % 100 < 50) { botApplyScenarioCommand(chr, AIBOTCMD_DEFHILL); } else { botApplyScenarioCommand(chr, AIBOTCMD_NORMAL); @@ -2587,13 +2587,13 @@ void botTickUnpaused(struct chrdata *chr) if (botShouldReturnCtcToken(chr)) { botApplyScenarioCommand(chr, AIBOTCMD_GETCASE); } else if (botIsChrsCtcTokenHeld(chr)) { - if (random() % 100 < 30) { + if (rngRandom() % 100 < 30) { botApplyScenarioCommand(chr, AIBOTCMD_GETCASE); } else { botApplyScenarioCommand(chr, AIBOTCMD_SAVECASE); } } else { - if (random() % 100 < 70 || numgetting <= 0) { + if (rngRandom() % 100 < 70 || numgetting <= 0) { botApplyScenarioCommand(chr, AIBOTCMD_GETCASE); } else { botApplyScenarioCommand(chr, AIBOTCMD_SAVECASE); @@ -2607,7 +2607,7 @@ void botTickUnpaused(struct chrdata *chr) if (botShouldReturnCtcToken(chr)) { botApplyScenarioCommand(chr, AIBOTCMD_GETCASE); } else if (botIsChrsCtcTokenHeld(chr)) { - if (numsaving <= 0 || random() % 100 < 70) { + if (numsaving <= 0 || rngRandom() % 100 < 70) { botApplyScenarioCommand(chr, AIBOTCMD_SAVECASE); } else { botApplyScenarioCommand(chr, AIBOTCMD_GETCASE); @@ -2616,9 +2616,9 @@ void botTickUnpaused(struct chrdata *chr) botApplyScenarioCommand(chr, AIBOTCMD_GETCASE); } else if (numsaving <= 0 || numsaving < teamsize / 4) { botApplyScenarioCommand(chr, AIBOTCMD_SAVECASE); - } else if (random() % 100 < 30) { + } else if (rngRandom() % 100 < 30) { botApplyScenarioCommand(chr, AIBOTCMD_GETCASE); - } else if (random() % 100 < 30) { + } else if (rngRandom() % 100 < 30) { botApplyScenarioCommand(chr, AIBOTCMD_SAVECASE); } else { botApplyScenarioCommand(chr, AIBOTCMD_NORMAL); @@ -2627,7 +2627,7 @@ void botTickUnpaused(struct chrdata *chr) } // Consider changing command in 20 to 60 seconds - aibot->commandtimer60 = TICKS(1200) + random() % TICKS(2400); + aibot->commandtimer60 = TICKS(1200) + rngRandom() % TICKS(2400); } } @@ -2724,7 +2724,7 @@ void botTickUnpaused(struct chrdata *chr) s32 index; s32 i; - index = random() % numtokens; + index = rngRandom() % numtokens; i = (index + 1) % numtokens; @@ -2752,7 +2752,7 @@ void botTickUnpaused(struct chrdata *chr) aibot->gotoprop = tokens[index]; } else if (botCanFollow(chr, tokens[index]->chr)) { newaction = MA_AIBOTFOLLOW; - aibot->canbreakfollow = random() % 4 == 0; + aibot->canbreakfollow = rngRandom() % 4 == 0; aibot->followingplayernum = mpPlayerGetIndex(tokens[index]->chr); } } @@ -2770,7 +2770,7 @@ void botTickUnpaused(struct chrdata *chr) // Held by a teammate - follow/protect them if (botCanFollow(chr, tokenchr)) { newaction = MA_AIBOTFOLLOW; - aibot->canbreakfollow = random() % 4 == 0; + aibot->canbreakfollow = rngRandom() % 4 == 0; aibot->followingplayernum = mpPlayerGetIndex(tokenchr); } } else { @@ -2860,7 +2860,7 @@ void botTickUnpaused(struct chrdata *chr) // Uplink is held by teammate - protect them if (botCanFollow(chr, uplinkchr)) { newaction = MA_AIBOTFOLLOW; - aibot->canbreakfollow = random() % 4 == 0; + aibot->canbreakfollow = rngRandom() % 4 == 0; aibot->followingplayernum = mpPlayerGetIndex(uplinkchr); } } else { @@ -2891,7 +2891,7 @@ void botTickUnpaused(struct chrdata *chr) // Briefcase is held by teammate - protect them if (botCanFollow(chr, tokenchr)) { newaction = MA_AIBOTFOLLOW; - aibot->canbreakfollow = random() % 4 == 0; + aibot->canbreakfollow = rngRandom() % 4 == 0; aibot->followingplayernum = mpPlayerGetIndex(tokenchr); } } else if (!botIsTargetInvisible(chr, tokenchr) && botPassesCowardCheck(chr, tokenchr)) { @@ -2919,7 +2919,7 @@ void botTickUnpaused(struct chrdata *chr) // Victim is a teammate - protect them if (botCanFollow(chr, victimchr)) { newaction = MA_AIBOTFOLLOW; - aibot->canbreakfollow = random() % 4 == 0; + aibot->canbreakfollow = rngRandom() % 4 == 0; aibot->followingplayernum = mpPlayerGetIndex(victimchr); } } else { @@ -2944,13 +2944,13 @@ void botTickUnpaused(struct chrdata *chr) // Current bot has the briefcase - follow a teammate for protection s32 playernum = -1; - if (random() % 100 < 66) { + if (rngRandom() % 100 < 66) { playernum = botFindTeammateToFollow(chr, 100000); } if (playernum >= 0) { newaction = MA_AIBOTFOLLOW; - aibot->canbreakfollow = random() % 4 == 0; + aibot->canbreakfollow = rngRandom() % 4 == 0; aibot->followingplayernum = playernum; } } @@ -2962,13 +2962,13 @@ void botTickUnpaused(struct chrdata *chr) // Current bot is the victim - follow a teammate for protection s32 playernum = -1; - if (random() % 100 < 66) { + if (rngRandom() % 100 < 66) { playernum = botFindTeammateToFollow(chr, 100000); } if (playernum >= 0) { newaction = MA_AIBOTFOLLOW; - aibot->canbreakfollow = random() % 4 == 0; + aibot->canbreakfollow = rngRandom() % 4 == 0; aibot->followingplayernum = playernum; } } @@ -3095,7 +3095,7 @@ void botTickUnpaused(struct chrdata *chr) if (playernum >= 0) { newaction = MA_AIBOTFOLLOW; - aibot->canbreakfollow = random() % 4 == 0; + aibot->canbreakfollow = rngRandom() % 4 == 0; aibot->followingplayernum = playernum; } } @@ -3435,7 +3435,7 @@ void botTickUnpaused(struct chrdata *chr) aibot->punchtimer60[0] = TICKS(30); } - if (random() % 3 == 0) { + if (rngRandom() % 3 == 0) { aibot->punchtimer60[1] = aibot->punchtimer60[0] - TICKS(20); } break; diff --git a/src/game/botact.c b/src/game/botact.c index c2aa48cd4..fcaeebb6a 100644 --- a/src/game/botact.c +++ b/src/game/botact.c @@ -223,7 +223,7 @@ bool botactShootFarsight(struct chrdata *chr, s32 arg1, struct coord *vector, st aibot = chr->aibot; if (aibot->weaponnum == WEAPON_FARSIGHT) { - rand = random() % 100; + rand = rngRandom() % 100; // 3 in 10 chance of this passing if (rand < 30) { diff --git a/src/game/botcmd.c b/src/game/botcmd.c index eaf9d341d..57f8a4a4e 100644 --- a/src/game/botcmd.c +++ b/src/game/botcmd.c @@ -149,7 +149,7 @@ void botcmdTickDistMode(struct chrdata *chr) if (!insight) { newmode = BOTDISTMODE_ADVANCE; aibot->distoverrideprop = targetprop; - aibot->distoverridetimer60 = TICKS(20) + (random() % TICKS(120)); + aibot->distoverridetimer60 = TICKS(20) + (rngRandom() % TICKS(120)); } else if (aibot->distoverrideprop) { if (g_Vars.lvupdate60 < aibot->distoverridetimer60) { aibot->distoverridetimer60 -= g_Vars.lvupdate60; diff --git a/src/game/botinv.c b/src/game/botinv.c index 7bb773378..82eb82bf5 100644 --- a/src/game/botinv.c +++ b/src/game/botinv.c @@ -904,7 +904,7 @@ void botinvTick(struct chrdata *chr) aibot->dampensuicidesttl60 -= g_Vars.lvupdate60; if (aibot->dampensuicidesttl60 < 0) { - aibot->dampensuicidesttl60 = TICKS(3600) + random() % TICKS(60); + aibot->dampensuicidesttl60 = TICKS(3600) + rngRandom() % TICKS(60); for (i = 0; i < ARRAYCOUNT(aibot->suicidesbygunfunc); i++) { aibot->suicidesbygunfunc[i][0] *= 0.9f; @@ -916,15 +916,15 @@ void botinvTick(struct chrdata *chr) aibot->equipextrascorestimer60 -= g_Vars.lvupdate60; if (aibot->equipextrascorestimer60 < 0) { - aibot->equipextrascorestimer60 = TICKS(600) + random() % TICKS(3000); + aibot->equipextrascorestimer60 = TICKS(600) + rngRandom() % TICKS(3000); for (i = 0; i < ARRAYCOUNT(aibot->equipextrascores); i++) { if (aibot->config->difficulty == BOTDIFF_MEAT) { - aibot->equipextrascores[i] = random() % 200 - 100; // -100 to +100 + aibot->equipextrascores[i] = rngRandom() % 200 - 100; // -100 to +100 } else if (aibot->config->difficulty == BOTDIFF_EASY) { - aibot->equipextrascores[i] = random() % 100 - 50; // -50 to +50 + aibot->equipextrascores[i] = rngRandom() % 100 - 50; // -50 to +50 } else { - aibot->equipextrascores[i] = random() % 30 - 15; // -15 to +15 + aibot->equipextrascores[i] = rngRandom() % 30 - 15; // -15 to +15 } } } @@ -934,8 +934,8 @@ void botinvTick(struct chrdata *chr) aibot->random1ttl60 -= g_Vars.lvupdate60; if (aibot->random1ttl60 < 0) { - aibot->random1ttl60 = TICKS(120) + random() % TICKS(600); - aibot->random1 = random(); + aibot->random1ttl60 = TICKS(120) + rngRandom() % TICKS(600); + aibot->random1 = rngRandom(); } if (aibot->cyclonedischarging[HAND_LEFT] == 0 diff --git a/src/game/botmgr.c b/src/game/botmgr.c index 59778fbff..d8fd489c4 100644 --- a/src/game/botmgr.c +++ b/src/game/botmgr.c @@ -85,7 +85,7 @@ void botmgrAllocateBot(s32 chrnum, s32 aibotnum) if (aibot != NULL) { chr->tude = 0; - chr->voicebox = random() % 3; + chr->voicebox = rngRandom() % 3; if (g_HeadsAndBodies[chr->bodynum].ismale == false) { chr->voicebox = VOICEBOX_FEMALE; @@ -235,7 +235,7 @@ void botmgrAllocateBot(s32 chrnum, s32 aibotnum) aibot->realignangleframe = -1; aibot->waypoints[0] = NULL; aibot->numwaystepstotarget = 0; - aibot->random1 = random(); + aibot->random1 = rngRandom(); aibot->random1ttl60 = 0; for (i = 0; i < ARRAYCOUNT(aibot->killsbygunfunc); i++) { @@ -258,7 +258,7 @@ void botmgrAllocateBot(s32 chrnum, s32 aibotnum) aibot->canseecloaked = false; aibot->random2ttl60 = 0; - aibot->random2 = random(); + aibot->random2 = rngRandom(); aibot->randomfrac = RANDOMFRAC(); aibot->cheap = false; #if VERSION >= VERSION_NTSC_1_0 diff --git a/src/game/botroom.c b/src/game/botroom.c index b27308f13..0db8b4cfb 100644 --- a/src/game/botroom.c +++ b/src/game/botroom.c @@ -135,7 +135,7 @@ bool botroomFindPos(RoomNum room, struct coord *pos, f32 *angleptr, s32 *padnump return false; } - i = random() % totalcount; + i = rngRandom() % totalcount; if (i < covercount) { coverUnpack(covernums[i], &cover); diff --git a/src/game/camdraw.c b/src/game/camdraw.c index ee9b25834..0579df090 100644 --- a/src/game/camdraw.c +++ b/src/game/camdraw.c @@ -317,7 +317,7 @@ void func0f149f18(void) if (var800a45a0->unk470) { for (i = 0; i < 0x4000; i++) { - var800a45a0->unk470[i] = random() % 255; + var800a45a0->unk470[i] = rngRandom() % 255; } } } @@ -1066,13 +1066,13 @@ void func0f14b394(struct var8007f8e0 *arg0) size = align32(func0f14c814(&arg0->unk004)); for (i = 0; i < size; i++) { - arg0->unk004.textureptr[i] = random() % 0xff; + arg0->unk004.textureptr[i] = rngRandom() % 0xff; } size = align32(func0f14c814(&arg0->unk010)); for (i = 0; i < size; i++) { - arg0->unk010.textureptr[i] = random() % 0xff; + arg0->unk010.textureptr[i] = rngRandom() % 0xff; } func0f14b228(arg0); @@ -2358,7 +2358,7 @@ void func0f14e7e0(u8 *arg0) for (i = 0; i < 128; i++) { for (j = 0; j < 128; j++) { - arg0[i * 128 + j] = random() % 255; + arg0[i * 128 + j] = rngRandom() % 255; } } } @@ -3151,7 +3151,7 @@ bool func0f15015c(s8 device, s32 filenum, u8 *arg2) s32 size = 128; for (i = 0; i < size; i++) { - arg2[i] = random(); + arg2[i] = rngRandom(); } return true; diff --git a/src/game/chr.c b/src/game/chr.c index 79dce823f..e42c78012 100644 --- a/src/game/chr.c +++ b/src/game/chr.c @@ -1216,7 +1216,7 @@ void chrInit(struct prop *prop, u8 *ailist) chr->cmnum2 = 0; chr->cmnum3 = 0; chr->cmnum4 = 0; - chr->cmcount = random() % 300; + chr->cmcount = rngRandom() % 300; chr->footstep = 0; chr->magicanim = -1; chr->cover = -1; @@ -1283,7 +1283,7 @@ void chrInit(struct prop *prop, u8 *ailist) chr->p1p2 = g_Vars.bondplayernum; chr->lastattacker = NULL; chr->race = RACE_HUMAN; - chr->aimtesttimer60 = random() % TICKS(30); + chr->aimtesttimer60 = rngRandom() % TICKS(30); chr->lastfootsample = 0; chr->poisoncounter = 0; chr->poisonprop = NULL; @@ -1522,7 +1522,7 @@ void chrFlinchBody(struct chrdata *chr) if (chr->actiontype != ACT_DEAD && chr->flinchcnt < 0) { chr->flinchcnt = 1; chr->hidden2 &= 0x0fff; - chr->hidden2 |= (u16)(random() << 13); + chr->hidden2 |= (u16)(rngRandom() << 13); } } @@ -3683,7 +3683,7 @@ void chrEmitSparks(struct chrdata *chr, struct prop *prop, s32 hitpart, struct c return; } - if ((random() & 4) == 0) { + if ((rngRandom() & 4) == 0) { struct coord coord3; coord3.x = coord2->x * 42.0f + coord->x; coord3.y = coord2->y * 42.0f + coord->y; @@ -3712,7 +3712,7 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc struct coord spd4; struct coord spc8; s32 spbc[3]; - s32 alpha = 20 + (random() % 50); + s32 alpha = 20 + (rngRandom() % 50); struct modelrodata_dl *rodata; struct modelrwdata_dl *rwdata; s32 spac = 0; @@ -3997,7 +3997,7 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct struct coord spd4; struct coord spc8; s32 spbc[3]; - s32 alpha = 20 + (random() % 50); + s32 alpha = 20 + (rngRandom() % 50); struct modelrodata_dl *rodata; struct modelrwdata_dl *rwdata; s32 spac = 0; @@ -4312,7 +4312,7 @@ void chrDisfigure(struct chrdata *chr, struct coord *exppos, f32 damageradius) s32 i; s32 j; - u32 rand = random(); + u32 rand = rngRandom(); if (g_Vars.mplayerisrunning || !chrIsDead(chr)) { return; @@ -4718,7 +4718,7 @@ void chrHit(struct shotdata *shotdata, struct hit *hit) type = g_SurfaceTypes[surfacetype]; if (type->numwallhittexes > 0) { - index = random() % type->numwallhittexes; + index = rngRandom() % type->numwallhittexes; wallhitCreate( &hit->hitthing.pos, @@ -4754,7 +4754,7 @@ void chrHit(struct shotdata *shotdata, struct hit *hit) type = g_SurfaceTypes[g_Textures[hit->hitthing.texturenum].surfacetype]; } - index = random() % type->numwallhittexes; + index = rngRandom() % type->numwallhittexes; wallhitCreate( &hit->hitthing.pos, @@ -5201,7 +5201,7 @@ void shieldhitCreate(struct prop *prop, f32 shield, struct prop *arg2, struct mo shieldhit->unk018[i] = -1; } - shieldhit->unk011 = 2 + (random() % 6); + shieldhit->unk011 = 2 + (rngRandom() % 6); shieldhit->shield = shield; if (arg6) { @@ -6505,7 +6505,7 @@ Gfx *chrRenderShield(Gfx *gdl, struct chrdata *chr, u32 alpha) || (chrGetShield(chr) > 0 && chr->cmcount < 10) || (chr->cloakfadefrac > 0 && !chr->cloakfadefinished)) { if (chrGetShield(chr) > 0 && g_Vars.lvupdate240 > 0) { - s32 numiterations = (random() % 4) + 1; + s32 numiterations = (rngRandom() % 4) + 1; s32 newcmnum = chr->cmnum2; s32 candidate; s8 operation = 0; diff --git a/src/game/chraction.c b/src/game/chraction.c index 1b59dccaa..7f8c3bca3 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -1683,7 +1683,7 @@ void chrChooseStandAnimation(struct chrdata *chr, f32 mergetime) } else if ((leftgun && rightgun) || (!leftgun && !rightgun) || weaponIsOneHanded(leftgun) || weaponIsOneHanded(rightgun)) { - modelSetAnimation(chr->model, ANIM_006A, random() % 2, 0, 0.25, mergetime); + modelSetAnimation(chr->model, ANIM_006A, rngRandom() % 2, 0, 0.25, mergetime); modelSetAnimLooping(chr->model, 0, 16); } else if (rightgun || leftgun) { modelSetAnimation(chr->model, ANIM_TWO_GUN_HOLD, leftgun != NULL, 0, 0.25, mergetime); @@ -1691,7 +1691,7 @@ void chrChooseStandAnimation(struct chrdata *chr, f32 mergetime) modelSetAnimEndFrame(chr->model, 120); } } else if (race == RACE_SKEDAR) { - modelSetAnimation(chr->model, ANIM_00C0, random() % 2, 0, 0.5, mergetime); + modelSetAnimation(chr->model, ANIM_00C0, rngRandom() % 2, 0, 0.5, mergetime); } else if (race == RACE_DRCAROLL) { modelSetAnimation(chr->model, ANIM_013E, 0, 0, 0.5, mergetime); } else if (race == RACE_ROBOT) { @@ -1712,7 +1712,7 @@ void func0f02e9a0(struct chrdata *chr, f32 mergetime) chr->act_stand.reaim = 0; chr->act_stand.turning = TURNSTATE_OFF; chr->act_stand.checkfacingwall = false; - chr->act_stand.wallcount = random() % 120 + 180; // 180 to 299 + chr->act_stand.wallcount = rngRandom() % 120 + 180; // 180 to 299 chr->act_stand.mergetime = mergetime; chr->act_stand.playwalkanim = false; @@ -1754,7 +1754,7 @@ void chrStand(struct chrdata *chr) chr->act_stand.reaim = 0; chr->act_stand.turning = TURNSTATE_OFF; chr->act_stand.checkfacingwall = false; - chr->act_stand.wallcount = random() % 120 + 180; + chr->act_stand.wallcount = rngRandom() % 120 + 180; chr->sleep = 0; chr->act_stand.playwalkanim = false; @@ -1779,7 +1779,7 @@ void chrStand(struct chrdata *chr) chr->act_stand.reaim = 0; chr->act_stand.turning = TURNSTATE_OFF; chr->act_stand.checkfacingwall = false; - chr->act_stand.wallcount = random() % 120 + 180; + chr->act_stand.wallcount = rngRandom() % 120 + 180; chr->sleep = 0; chr->act_stand.playwalkanim = false; @@ -1832,7 +1832,7 @@ void chrKneelChooseAnimation(struct chrdata *chr) || (!leftgun && !rightgun) || weaponIsOneHanded(leftgun) || weaponIsOneHanded(rightgun)) { - bool flip = random() % 2; + bool flip = rngRandom() % 2; modelSetAnimation(chr->model, ANIM_KNEEL_SHOOT_RIGHT_HAND, flip, 0, chrGetRangedSpeed(chr, 0.5, 0.8), 16); modelSetAnimEndFrame(chr->model, 28); } else if (rightgun || leftgun) { @@ -1865,7 +1865,7 @@ void chrStartAlarmChooseAnimation(struct chrdata *chr) if (leftgun && !rightgun) { flip = true; } else if ((leftgun && rightgun) || (!leftgun && !rightgun)) { - flip = random() % 2; + flip = rngRandom() % 2; } modelSetAnimation(chr->model, ANIM_TALKING_003D, flip, 40, 1, 16); @@ -1888,7 +1888,7 @@ void chrStartAlarm(struct chrdata *chr) void chrThrowGrenadeChooseAnimation(struct chrdata *chr) { - u32 rand = random(); + u32 rand = rngRandom(); if (chr->act_throwgrenade.needsequip) { if (rand % 3 == 0) { @@ -1937,17 +1937,17 @@ void chrSurprisedChooseAnimation(struct chrdata *chr) if (leftgun != NULL && rightgun == NULL) { flip = 1; } else if ((leftgun != NULL && rightgun != NULL) || (leftgun == NULL && rightgun == NULL)) { - flip = random() & 1; + flip = rngRandom() & 1; } modelSetAnimation(chr->model, ANIM_003F, flip, 10, chrGetRangedSpeed(chr, 0.6f, 0.96000003f), 16); modelSetAnimEndFrame(chr->model, 52); } else if (chr->act_surprised.type == 2) { - modelSetAnimation(chr->model, ANIM_SURRENDER_002E, random() & 1, 0, chrGetRangedSpeed(chr, 0.35f, 0.56f), 16); + modelSetAnimation(chr->model, ANIM_SURRENDER_002E, rngRandom() & 1, 0, chrGetRangedSpeed(chr, 0.35f, 0.56f), 16); modelSetAnimEndFrame(chr->model, 7); } else { - u32 part = random() % 3; - modelSetAnimation(chr->model, ANIM_0040, random() & 1, 17, 0.6f, 16); + u32 part = rngRandom() % 3; + modelSetAnimation(chr->model, ANIM_0040, rngRandom() & 1, 17, 0.6f, 16); if (part == 0) { modelSetAnimEndFrame(chr->model, chrGetRangedSpeed(chr, 38, 8)); @@ -2018,7 +2018,7 @@ void chrSurrenderChooseAnimation(struct chrdata *chr) struct prop *rightgun = chrGetHeldProp(chr, HAND_RIGHT); if (rightgun || leftgun) { - modelSetAnimation(chr->model, ANIM_SURRENDER_002F, random() & 1, 0, 0.5, 16); + modelSetAnimation(chr->model, ANIM_SURRENDER_002F, rngRandom() & 1, 0, 0.5, 16); modelSetAnimLooping(chr->model, 40, 16); if (leftgun) { @@ -2031,7 +2031,7 @@ void chrSurrenderChooseAnimation(struct chrdata *chr) chr->hidden |= CHRHFLAG_DROPPINGITEM; } else { - modelSetAnimation(chr->model, ANIM_SURRENDER_002E, random() & 1, 0, 0.5, 16); + modelSetAnimation(chr->model, ANIM_SURRENDER_002E, rngRandom() & 1, 0, 0.5, 16); modelSetAnimLooping(chr->model, 30, 16); } @@ -2065,14 +2065,14 @@ void chrSidestepChooseAnimation(struct chrdata *chr) u32 race = CHRRACE(chr); if (leftgun && rightgun) { - flip = random() % 2; - allowflip = random() % 2; + flip = rngRandom() % 2; + allowflip = rngRandom() % 2; } else { if (weaponIsOneHanded(leftgun) == false && weaponIsOneHanded(rightgun) == false && (leftgun || rightgun)) { flip = (leftgun != 0); - allowflip = random() % 2; + allowflip = rngRandom() % 2; } } @@ -2130,7 +2130,7 @@ void chrJumpOutChooseAnimation(struct chrdata *chr) flip = true; } else if ((leftgun && rightgun) || (!leftgun && !rightgun) || weaponIsOneHanded(leftgun) || weaponIsOneHanded(rightgun)) { - flip = random() % 2; + flip = rngRandom() % 2; } if ((chr->act_jumpout.side && !flip) || (chr->act_jumpout.side == 0 && flip)) { @@ -2171,7 +2171,7 @@ void chrRunPosChooseAnimation(struct chrdata *chr) if ((leftgun && rightgun) || (!leftgun && !rightgun)) { heavy = false; - flip = random() % 2; + flip = rngRandom() % 2; } else if (weaponIsOneHanded(leftgun) || weaponIsOneHanded(rightgun)) { heavy = false; flip = (bool)leftgun != false; @@ -2241,9 +2241,9 @@ void chrAttackStand(struct chrdata *chr, u32 attackflags, s32 entityid) struct prop *rightgun2 = chrGetHeldUsableProp(chr, HAND_RIGHT); if (leftgun2 && rightgun2) { - flip = random() % 2; + flip = rngRandom() % 2; - if (random() % 3 == 0) { + if (rngRandom() % 3 == 0) { animgroup = g_StandLightAttackAnims[race]; firing[HAND_LEFT] = flip; firing[HAND_RIGHT] = !flip; @@ -2311,9 +2311,9 @@ void chrAttackKneel(struct chrdata *chr, u32 attackflags, s32 entityid) rightgun2 = chrGetHeldUsableProp(chr, HAND_RIGHT); if (leftgun2 && rightgun2) { - flip = random() % 2; + flip = rngRandom() % 2; - if (random() % 3 == 0) { + if (rngRandom() % 3 == 0) { animgroup = g_KneelLightAttackAnims[race]; firing[HAND_LEFT] = flip; firing[HAND_RIGHT] = !flip; @@ -2372,8 +2372,8 @@ void chrAttackWalk(struct chrdata *chr, bool run) s32 style = 0; if (leftgun2 && rightgun2) { - flip = random() % 2; - style = random() % 3; + flip = rngRandom() % 2; + style = rngRandom() % 3; } else { flip = (bool)rightgun2 == false; } @@ -2473,14 +2473,14 @@ void chrAttackWalk(struct chrdata *chr, bool run) chr->act_attackwalk.frame60count = 0; #if PAL // This is really TICKS(400.0f), but off by one bit :( - chr->act_attackwalk.frame60max = random() % (s32)(333.33331298828f * g_AttackWalkDurationScale) + TICKS(120); + chr->act_attackwalk.frame60max = rngRandom() % (s32)(333.33331298828f * g_AttackWalkDurationScale) + TICKS(120); #else - chr->act_attackwalk.frame60max = random() % (s32)(400 * g_AttackWalkDurationScale) + TICKS(120); + chr->act_attackwalk.frame60max = rngRandom() % (s32)(400 * g_AttackWalkDurationScale) + TICKS(120); #endif chr->act_attackwalk.facedtarget = false; chr->act_attackwalk.animcfg = animcfg; chr->act_attackwalk.nextshot60 = 0; - chr->act_attackwalk.nextgun = random() % 2; + chr->act_attackwalk.nextgun = rngRandom() % 2; chr->act_attackwalk.firegun[HAND_LEFT] = firing[HAND_LEFT]; chr->act_attackwalk.firegun[HAND_RIGHT] = firing[HAND_RIGHT]; chr->act_attackwalk.everytick[HAND_LEFT] = everytick[HAND_LEFT]; @@ -2545,10 +2545,10 @@ void chrAttackRoll(struct chrdata *chr, bool toleft) struct prop *rightgun2 = chrGetHeldUsableProp(chr, HAND_RIGHT); if (leftgun2 && rightgun2) { - flip = random() % 2; + flip = rngRandom() % 2; onehanded = true; - if (random() % 3 == 0) { + if (rngRandom() % 3 == 0) { firing[HAND_LEFT] = flip; firing[HAND_RIGHT] = !flip; } else { @@ -2576,14 +2576,14 @@ void chrAttackRoll(struct chrdata *chr, bool toleft) if ((toleft && !flip) || (!toleft && flip)) { // Roll to left - if (random() % 2) { + if (rngRandom() % 2) { animcfg = &g_RollAttackAnims[0]; } else { animcfg = &g_RollAttackAnims[2]; } } else { // Roll to right - if (random() % 2) { + if (rngRandom() % 2) { animcfg = &g_RollAttackAnims[1]; } else { animcfg = &g_RollAttackAnims[3]; @@ -2637,7 +2637,7 @@ void chrAttackRoll(struct chrdata *chr, bool toleft) chr->act_attack.animcfg = animcfg; chr->act_attack.fired = false; - chr->act_attack.nextgun = random() % 2; + chr->act_attack.nextgun = rngRandom() % 2; chr->act_attack.firegun[HAND_LEFT] = firing[HAND_LEFT]; chr->act_attack.firegun[HAND_RIGHT] = firing[HAND_RIGHT]; chr->act_attack.everytick[HAND_LEFT] = everytick[HAND_LEFT]; @@ -2658,10 +2658,10 @@ void chrAttackRoll(struct chrdata *chr, bool toleft) chr->act_attack.maxshots = 1; } } else { - chr->act_attack.maxshots = (random() % 4) + 2; + chr->act_attack.maxshots = (rngRandom() % 4) + 2; if (firing[HAND_RIGHT] && firing[HAND_LEFT]) { - chr->act_attack.maxshots += (random() % 4) + 2; + chr->act_attack.maxshots += (rngRandom() % 4) + 2; } } @@ -2836,7 +2836,7 @@ void chrAttack(struct chrdata *chr, struct attackanimgroup **animgroups, bool fl groupindex = 0; } - index = random() % animgroups[groupindex]->len; + index = rngRandom() % animgroups[groupindex]->len; animcfg = &animgroups[groupindex]->animcfg[index]; } @@ -2889,7 +2889,7 @@ void chrAttack(struct chrdata *chr, struct attackanimgroup **animgroups, bool fl chr->act_attack.turning = TURNSTATE_TURNING; chr->act_attack.animcfg = animcfg; chr->act_attack.fired = false; - chr->act_attack.nextgun = random() % 2; + chr->act_attack.nextgun = rngRandom() % 2; chr->act_attack.firegun[HAND_LEFT] = firing[HAND_LEFT]; chr->act_attack.firegun[HAND_RIGHT] = firing[HAND_RIGHT]; chr->act_attack.everytick[HAND_LEFT] = everytick[HAND_LEFT]; @@ -2911,13 +2911,13 @@ void chrAttack(struct chrdata *chr, struct attackanimgroup **animgroups, bool fl if (attackflags & ATTACKFLAG_SINGLESHOT) { chr->act_attack.maxshots = 1; } else { - chr->act_attack.maxshots = (random() % 4) + 2; + chr->act_attack.maxshots = (rngRandom() % 4) + 2; } // @bug: ATTACKFLAG_SINGLESHOT is not respected here if both guns // are firing. if (firing[HAND_RIGHT] && firing[HAND_LEFT]) { - chr->act_attack.maxshots += (random() % 4) + 2; + chr->act_attack.maxshots += (rngRandom() % 4) + 2; } } @@ -3127,8 +3127,8 @@ void chrBeginDeath(struct chrdata *chr, struct coord *dir, f32 relangle, s32 hit chr->act_die.thudframe2 = -1; if (chr->race == RACE_DRCAROLL) { - chr->drcarollimage_left = (s32)((random() % 400) * 0.01f) + 1; - chr->drcarollimage_right = (s32)((random() % 400) * 0.01f) + 1; + chr->drcarollimage_left = (s32)((rngRandom() % 400) * 0.01f) + 1; + chr->drcarollimage_right = (s32)((rngRandom() % 400) * 0.01f) + 1; } chr->sleep = 0; @@ -3174,7 +3174,7 @@ void chrBeginDeath(struct chrdata *chr, struct coord *dir, f32 relangle, s32 hit // Consider making the chr do an animation where they slump against // a wall or object which is behind them. if ((relangle < 1.5705462694168f || relangle > 4.7116389274597f) - && random() % 20 == 0 + && rngRandom() % 20 == 0 && chr->specialdie == SPECIALDIE_NONE) { f32 angle1; f32 angle2 = chrGetInverseTheta(chr); @@ -3198,7 +3198,7 @@ void chrBeginDeath(struct chrdata *chr, struct coord *dir, f32 relangle, s32 hit if (fval1 < 150 && fval2 < 150 && fval1 - fval2 < 10 && fval1 - fval2 > -10 && !wasknockedout) { - struct animtablerow *row = &g_AnimTableHumanSlumped[random() % 4]; + struct animtablerow *row = &g_AnimTableHumanSlumped[rngRandom() % 4]; u32 stack3; chr->act_die.thudframe1 = row->thudframe1; @@ -3220,7 +3220,7 @@ void chrBeginDeath(struct chrdata *chr, struct coord *dir, f32 relangle, s32 hit // Consider making the chr do a fall forward animation. // The player must be behind the chr for it to happen. if (relangle > 2.3558194637299f && relangle < 3.9263656139374f - && random() % 5 < 2 + && rngRandom() % 5 < 2 && chr->specialdie == SPECIALDIE_NONE) { struct animtablerow *row; @@ -3243,7 +3243,7 @@ void chrBeginDeath(struct chrdata *chr, struct coord *dir, f32 relangle, s32 hit } } else { row = &rows[1]; - flip = random() % 2; + flip = rngRandom() % 2; } chr->act_die.thudframe1 = row->thudframe1; @@ -3269,10 +3269,10 @@ void chrBeginDeath(struct chrdata *chr, struct coord *dir, f32 relangle, s32 hit struct animtablerow *row; if (chr->specialdie == SPECIALDIE_NONE) { - s32 tmp = random() % g_AnimTablesByRace[race][index].deathanimcount; + s32 tmp = rngRandom() % g_AnimTablesByRace[race][index].deathanimcount; row = &g_AnimTablesByRace[race][index].deathanims[tmp]; } else if (chr->specialdie == SPECIALDIE_ONCHAIR) { - row = &g_SpecialDieAnims[chr->specialdie + random() % 2]; + row = &g_SpecialDieAnims[chr->specialdie + rngRandom() % 2]; // chr->myspecial is the tag number of the chr's chair if (chr->myspecial >= 0) { @@ -3330,7 +3330,7 @@ void chrBeginDeath(struct chrdata *chr, struct coord *dir, f32 relangle, s32 hit if (relangle > 2.3558194637299f && relangle < 3.9263656139374f) { // Player is behind the Skedar - use specific set of anims - row = &g_AnimTablesByRace[race][1 + (random() % 6)].deathanims[random() % 3]; + row = &g_AnimTablesByRace[race][1 + (rngRandom() % 6)].deathanims[rngRandom() % 3]; chr->act_die.thudframe1 = row->thudframe1; chr->act_die.thudframe2 = row->thudframe2; @@ -3345,7 +3345,7 @@ void chrBeginDeath(struct chrdata *chr, struct coord *dir, f32 relangle, s32 hit if (index >= 0 && g_AnimTablesByRace[race][index].deathanims != NULL && g_AnimTablesByRace[race][index].deathanimcount > 0) { - s32 tmp = random() % g_AnimTablesByRace[race][index].deathanimcount; + s32 tmp = rngRandom() % g_AnimTablesByRace[race][index].deathanimcount; row = &g_AnimTablesByRace[race][index].deathanims[tmp]; } else { row = &g_AnimTablesByRace[race][0].deathanims[0]; @@ -3462,7 +3462,7 @@ void chrBeginArgh(struct chrdata *chr, f32 angle, s32 hitpart) && hitpart == HITPART_PELVIS && angle > 2.3558194637299f && angle < 3.9263656139374f - && random() % 5 < 2) { + && rngRandom() % 5 < 2) { struct animtablerow *row; struct animtablerow rows[] = { { 0x013b, 0, -1, 0.5, 0, -1, -1 }, @@ -3482,7 +3482,7 @@ void chrBeginArgh(struct chrdata *chr, f32 angle, s32 hitpart) chr->act_argh.lvframe60 = g_Vars.lvframe60; chr->sleep = 0; - row = &rows[random() % 8]; + row = &rows[rngRandom() % 8]; modelSetAnimationWithMerge(model, row->animnum, row->flip, 0, row->speed, 16, !instant); @@ -3515,7 +3515,7 @@ void chrBeginArgh(struct chrdata *chr, f32 angle, s32 hitpart) } // Select a random animation for this hit location and apply it - rowindex = random() % g_AnimTablesByRace[race][index].injuryanimcount; + rowindex = rngRandom() % g_AnimTablesByRace[race][index].injuryanimcount; row = &g_AnimTablesByRace[race][index].injuryanims[rowindex]; @@ -3658,7 +3658,7 @@ void chrYeetFromPos(struct chrdata *chr, struct coord *exppos, f32 force) angleindex = 0; } - subindex = random() % g_YeetAnimIndexesByRaceAngle[race][angleindex].count; + subindex = rngRandom() % g_YeetAnimIndexesByRaceAngle[race][angleindex].count; if (race == RACE_HUMAN) { row = &g_YeetAnimsHuman[g_YeetAnimIndexesByRaceAngle[race][angleindex].indexes[subindex]]; @@ -3682,8 +3682,8 @@ void chrYeetFromPos(struct chrdata *chr, struct coord *exppos, f32 force) chr->act_die.drcarollimagedelay = TICKS(45); if (chr->race == RACE_DRCAROLL) { - chr->drcarollimage_left = 1 + (s32)((random() % 400) * 0.01f); - chr->drcarollimage_right = 1 + (s32)((random() % 400) * 0.01f); + chr->drcarollimage_left = 1 + (s32)((rngRandom() % 400) * 0.01f); + chr->drcarollimage_right = 1 + (s32)((rngRandom() % 400) * 0.01f); } chr->sleep = 0; @@ -3866,7 +3866,7 @@ void chrChoke(struct chrdata *chr, s32 choketype) SFX_ARGH_MAIAN_05E1 }; - soundnum = sounds[random() % 3]; + soundnum = sounds[rngRandom() % 3]; nextindexmaian++; if (nextindexmaian >= ARRAYCOUNT(sounds)) { @@ -3882,7 +3882,7 @@ void chrChoke(struct chrdata *chr, s32 choketype) SFX_SKEDAR_ROAR_053A, }; - soundnum = sounds[random() % 5]; + soundnum = sounds[rngRandom() % 5]; nextindexskedar++; if (nextindexskedar >= ARRAYCOUNT(sounds)) { @@ -3895,7 +3895,7 @@ void chrChoke(struct chrdata *chr, s32 choketype) SFX_SKEDAR_ROAR_052F, }; - soundnum = sounds[random() % 3]; + soundnum = sounds[rngRandom() % 3]; nextindexskedar++; if (nextindexskedar >= ARRAYCOUNT(sounds)) { @@ -3982,7 +3982,7 @@ void chrChoke(struct chrdata *chr, s32 choketype) SFX_ARGH_JO_02B3, }; - soundnum = sounds[random() % 10]; + soundnum = sounds[rngRandom() % 10]; allowoverride = true; } else { s16 sounds[] = { @@ -4009,21 +4009,21 @@ void chrChoke(struct chrdata *chr, s32 choketype) SFX_GURGLE_05B2, }; - if ((random() % 8) == 0) { - soundnum = sounds[random() % 3]; + if ((rngRandom() % 8) == 0) { + soundnum = sounds[rngRandom() % 3]; } chr->soundgap = 10; chr->soundtimer = 0; } else if (choketype == CHOKETYPE_COUGH) { if (male) { - if ((random() % 2) == 0) { + if ((rngRandom() % 2) == 0) { soundnum = SFX_COUGH_04AF; } else { soundnum = SFX_COUGH_04B0; } } else { - s32 index = random() % 4; + s32 index = rngRandom() % 4; s32 sounds[] = { SFX_COUGH_05AB, SFX_COUGH_05AC, @@ -4571,13 +4571,13 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse f32 sqdist = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff; if (sqdist < 200 * 200) { - damage *= 4.0f + (s32)(random() % 3); // 4, 5 or 6 + damage *= 4.0f + (s32)(rngRandom() % 3); // 4, 5 or 6 } else if (sqdist < 400 * 400) { - damage *= 3.0f + (s32)(random() % 2); // 3 or 4 + damage *= 3.0f + (s32)(rngRandom() % 2); // 3 or 4 } else if (sqdist < 800 * 800) { - damage *= 2.0f + (s32)(random() % 2); // 2 or 3 + damage *= 2.0f + (s32)(rngRandom() % 2); // 2 or 3 } else if (sqdist < 1600 * 1600) { - damage *= 1.0f + (s32)(random() % 2); // 1 or 2 + damage *= 1.0f + (s32)(rngRandom() % 2); // 1 or 2 } } @@ -4650,7 +4650,7 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse u16 sounds[] = { SFX_HIT_METAL_807B, SFX_HIT_METAL_8079, SFX_HATHIT_807C }; damage = 0; - psCreate(NULL, chr->prop, sounds[random() % 3], -1, + psCreate(NULL, chr->prop, sounds[rngRandom() % 3], -1, -1, 0, 0, PSTYPE_NONE, NULL, -1, NULL, -1, -1, -1, -1); } } @@ -5909,7 +5909,7 @@ void chrGoPosChooseAnimation(struct chrdata *chr) if (race == RACE_HUMAN || race == RACE_SKEDAR) { if ((leftgun && rightgun) || (!leftgun && !rightgun)) { heavy = false; - flip = random() % 2; + flip = rngRandom() % 2; } else { if (weaponIsOneHanded(leftgun) || weaponIsOneHanded(rightgun)) { heavy = false; @@ -5996,7 +5996,7 @@ void chrGoPosChooseAnimation(struct chrdata *chr) || chr->hitpart == HITPART_RBICEP) { anim = ANIM_01F8; } else { - if (random() % 2) { + if (rngRandom() % 2) { anim = ANIM_0018; } else { anim = ANIM_0028; @@ -6031,7 +6031,7 @@ void chrGoPosChooseAnimation(struct chrdata *chr) speed = 0.4; flip = false; } else if (male) { - if (random() % 4 == 0) { + if (rngRandom() % 4 == 0) { speed = 0.25; anim = ANIM_001E; } else { @@ -6040,7 +6040,7 @@ void chrGoPosChooseAnimation(struct chrdata *chr) sp60 = 24; } } else { - if (random() % 2) { + if (rngRandom() % 2) { anim = ANIM_005E; } else { anim = ANIM_005A; @@ -6081,14 +6081,14 @@ void chrGoPosChooseAnimation(struct chrdata *chr) } else if (stageGetIndex(g_Vars.stagenum) == STAGEINDEX_CHICAGO) { anim = ANIM_005F; } else if (male) { - if (random() % 2) { + if (rngRandom() % 2) { anim = ANIM_001D; } else { anim = ANIM_RUNNING_ONEHANDGUN; } } else { if (chr->myaction != MA_PANIC) { - if (random() % 2) { + if (rngRandom() % 2) { anim = ANIM_005D; } else { anim = ANIM_0073; @@ -6122,9 +6122,9 @@ void chrGoPosChooseAnimation(struct chrdata *chr) anim = ANIM_01F8; flip = true; } else if (male) { - anim = anims[random() % 3]; + anim = anims[rngRandom() % 3]; } else { - if (random() % 2) { + if (rngRandom() % 2) { anim = ANIM_005C; } else { anim = ANIM_0072; @@ -6212,7 +6212,7 @@ bool chrGoToRoomPos(struct chrdata *chr, struct coord *pos, RoomNum *room, u32 g chr->act_gopos.flags = goposflags | GOPOSFLAG_INIT; chr->act_gopos.turnspeed = 0; chr->unk32c_21 = 0; - chr->act_gopos.waydata.age = random() % 100; + chr->act_gopos.waydata.age = rngRandom() % 100; chr->act_gopos.waydata.gotaimposobj = 0; if (!isgopos) { @@ -6286,7 +6286,7 @@ void chrPatrolChooseAnimation(struct chrdata *chr) if ((leftprop && rightprop) || (!leftprop && !rightprop)) { // No weapon, or double weapons heavy = false; - flip = random() % 2; + flip = rngRandom() % 2; } else { // Single weapon if (weaponIsOneHanded(leftprop) || weaponIsOneHanded(rightprop)) { @@ -6304,12 +6304,12 @@ void chrPatrolChooseAnimation(struct chrdata *chr) speed = 0.5f * func0f02dff0(ANIM_0028) / func0f02dff0(ANIM_006B); if (heavy) { - modelSetAnimation(chr->model, random() % 2 ? ANIM_0018 : ANIM_0028, flip, 0, speed, 16); + modelSetAnimation(chr->model, rngRandom() % 2 ? ANIM_0018 : ANIM_0028, flip, 0, speed, 16); } else if (ismale) { s32 anims[] = { ANIM_006B, ANIM_001B, ANIM_0016 }; - modelSetAnimation(chr->model, anims[random() % 3], flip, 0, speed, 16); + modelSetAnimation(chr->model, anims[rngRandom() % 3], flip, 0, speed, 16); } else { - modelSetAnimation(chr->model, random() % 2 ? ANIM_005C : ANIM_0072, flip, 0, speed, 16); + modelSetAnimation(chr->model, rngRandom() % 2 ? ANIM_005C : ANIM_0072, flip, 0, speed, 16); } } } else if (race == RACE_DRCAROLL) { @@ -6395,7 +6395,7 @@ void chrStartPatrol(struct chrdata *chr, struct path *path) chr->act_patrol.nextstep = nextstep; chr->act_patrol.forward = true; - chr->act_patrol.waydata.age = random() % 100; + chr->act_patrol.waydata.age = rngRandom() % 100; chr->act_patrol.waydata.gotaimposobj = 0; chr->act_patrol.waydata.lastvisible60 = -1; @@ -6761,7 +6761,7 @@ bool chrCheckCanSeeTarget(struct chrdata *chr) } iVar8 = chrGetPercentageOfSlowness(chr, iVar8) + 1; - result = random() % iVar8 == 0; + result = rngRandom() % iVar8 == 0; } } @@ -6853,7 +6853,7 @@ bool chrTrySidestep(struct chrdata *chr) if (angle < 0.7852731347084f || angle > 5.4969120025635f || (angle > 2.3558194637299f && angle < 3.9263656139374f)) { - bool side = (random() % 2) == 0; + bool side = (rngRandom() % 2) == 0; if (chrCanJumpInDirection(chr, side, 100)) { chrSidestep(chr, side); @@ -6891,7 +6891,7 @@ bool chrTryJumpOut(struct chrdata *chr) // || (angle > BADDEG2RAD(135) && angle < BADDEG2RAD(225))) { if (angle < 0.7852731347084f || angle > 5.4969120025635f || (angle > 2.3558194637299f && angle < BADDEG2RAD(225))) { - bool side = (random() % 2) == 0; + bool side = (rngRandom() % 2) == 0; if (chrCanJumpInDirection(chr, side, 200)) { chrJumpOut(chr, side); @@ -6920,7 +6920,7 @@ bool chrTryRunSideways(struct chrdata *chr) struct coord vector; struct coord dstpos; - chrGetSideVectorToTarget(chr, random() % 2 == 0, &vector); + chrGetSideVectorToTarget(chr, rngRandom() % 2 == 0, &vector); dstpos.x = vector.x * distance + prop->pos.x; dstpos.y = prop->pos.y; @@ -7019,7 +7019,7 @@ bool chrTryAttackRoll(struct chrdata *chr) f32 sqdistance = x * x + y * y + z * z; if (sqdistance >= 200 * 200) { - bool toleft = (random() % 2) == 0; + bool toleft = (rngRandom() % 2) == 0; if (chrCanRollInDirection(chr, toleft, 200)) { chrAttackRoll(chr, toleft); @@ -7056,7 +7056,7 @@ bool chrTryAttackAmount(struct chrdata *chr, u32 arg1, u32 arg2, u8 lower, u8 up } if (lower < upper) { - percentage = ((random() % (upper - lower)) + (u32)lower) * 0.01f; + percentage = ((rngRandom() % (upper - lower)) + (u32)lower) * 0.01f; } else { percentage = 0; } @@ -7552,7 +7552,7 @@ bool chrGoToCoverProp(struct chrdata *chr) for (numprops = 0; propnums[numprops] >= 0; numprops++); if (numprops > 0) { - startindex = random() % numprops; + startindex = rngRandom() % numprops; } for (i = 0; i < numprops; i++) { @@ -7653,7 +7653,7 @@ bool chrConsiderGrenadeThrow(struct chrdata *chr, u32 attackflags, u32 entityid) bool done = false; if (CHRRACE(chr) == RACE_HUMAN && - chr->grenadeprob > (random() % 255) && + chr->grenadeprob > (rngRandom() % 255) && chrGetDistanceToTarget(chr) > 200 && chrIsReadyForOrders(chr)) { struct prop *target = chrGetTargetProp(chr); @@ -7847,7 +7847,7 @@ bool chrTryPunch(struct chrdata *chr, u8 reverse) struct punchanim *anims = NULL; s32 race = CHRRACE(chr); s32 animindex; - u32 chranimflags = (random() % 256 > 128) ? CHRANIMFLAG_FLIP : 0; + u32 chranimflags = (rngRandom() % 256 > 128) ? CHRANIMFLAG_FLIP : 0; s32 chrhitradius; s32 playerhitradius; f32 startframe; @@ -7858,7 +7858,7 @@ bool chrTryPunch(struct chrdata *chr, u8 reverse) startframe = 10; chrhitradius = 120; playerhitradius = 120; - animindex = random() % 11; + animindex = rngRandom() % 11; } else if (race == RACE_SKEDAR) { anims = g_SkedarPunchAnims; chrhitradius = 200; @@ -7874,11 +7874,11 @@ bool chrTryPunch(struct chrdata *chr, u8 reverse) animindex = 5; } else if (!chr->weapons_held[HAND_RIGHT] && !chr->weapons_held[HAND_LEFT]) { // Unarmed: Only use indexes 0 or 1 - animindex = random() % 2; + animindex = rngRandom() % 2; } else { // Allow indexes 0-4, but if 3 or 4 then flip the anim based on // which hand is holding the gun - animindex = random() % 5; + animindex = rngRandom() % 5; if (animindex >= 3) { if (!chr->weapons_held[HAND_RIGHT] || !chr->weapons_held[HAND_LEFT]) { @@ -8055,7 +8055,7 @@ void chrTickStand(struct chrdata *chr) || (!leftgun && !rightgun) || weaponIsOneHanded(leftgun) || weaponIsOneHanded(rightgun)) { - modelSetAnimation(chr->model, ANIM_006B, random() % 2, 0, 0.5f, 16); + modelSetAnimation(chr->model, ANIM_006B, rngRandom() % 2, 0, 0.5f, 16); modelSetAnimEndFrame(chr->model, animGetNumFrames(ANIM_006B) - 1); } else { if (rightgun || leftgun) { @@ -8064,7 +8064,7 @@ void chrTickStand(struct chrdata *chr) } } } else if (race == RACE_SKEDAR) { - modelSetAnimation(chr->model, ANIM_0392, random() % 2, 0, 0.5f, 16); + modelSetAnimation(chr->model, ANIM_0392, rngRandom() % 2, 0, 0.5f, 16); modelSetAnimEndFrame(chr->model, animGetNumFrames(ANIM_0392) - 1); } } else if (chr->act_stand.flags & ATTACKFLAG_AIMATDIRECTION) { @@ -8083,7 +8083,7 @@ void chrTickStand(struct chrdata *chr) if (chr->prop->flags & PROPFLAG_ONANYSCREENPREVTICK) { chr->sleep = 0; } else { - chr->sleep = 14 + (random() % 5); + chr->sleep = 14 + (rngRandom() % 5); } if (chr->act_stand.checkfacingwall == false) { @@ -8137,17 +8137,17 @@ void chrTickStand(struct chrdata *chr) if (sp74[sp44[4]] < 200) { index = 7; } else if (sp44[0] == 0 || sp44[1] == 0 || sp44[2] == 0) { - if ((sp44[3] == 4 || sp44[4] == 4) && (random() % 3) == 0) { + if ((sp44[3] == 4 || sp44[4] == 4) && (rngRandom() % 3) == 0) { if (sp44[3] == 4) { index = 3; } else { index = 4; } } else { - index = 5 + random() % 3; + index = 5 + rngRandom() % 3; } } else if ((sp44[0] == 1 || sp44[0] == 7) && sp44[5] && sp44[6] && sp44[7]) { - index = 5 + random() % 3; + index = 5 + rngRandom() % 3; } } @@ -8212,7 +8212,7 @@ void chrTickAnim(struct chrdata *chr) } if (chr->sleep <= 0 && chr->act_anim.slowupdate) { - chr->sleep = 14 + (random() % 5); + chr->sleep = 14 + (rngRandom() % 5); } if (modelGetAnimNum(chr->model) == ANIM_RELOAD_0209) { @@ -8244,7 +8244,7 @@ void chrTickSurrender(struct chrdata *chr) coord.z = -cosf(value); if (!propchrHasClearLineInVector(chr->prop, &coord, 20)) { - modelSetAnimation(chr->model, ANIM_SURRENDER_002E, random() & 1, 30, 0.5, 16); + modelSetAnimation(chr->model, ANIM_SURRENDER_002E, rngRandom() & 1, 30, 0.5, 16); modelSetAnimLooping(chr->model, 30, 16); } } @@ -8453,7 +8453,7 @@ void chrTickDie(struct chrdata *chr) SFX_DRCAROLL_YOU_WERE_SUPPOSED, }; - psCreate(NULL, chr->prop, phrases[random() % 5], -1, + psCreate(NULL, chr->prop, phrases[rngRandom() % 5], -1, -1, 0, 0, PSTYPE_NONE, 0, -1, 0, -1, -1, -1, -1); chr->voicebox = 0; } @@ -8462,9 +8462,9 @@ void chrTickDie(struct chrdata *chr) if (chr->act_die.drcarollimagedelay > 0) { chr->act_die.drcarollimagedelay -= g_Vars.lvupdate60; } else { - chr->act_die.drcarollimagedelay = (random() % TICKS(1000)) * 0.01f + 5.0f; - chr->drcarollimage_left = 1 + (s32)((random() % 400) * 0.01f); - chr->drcarollimage_right = 1 + (s32)((random() % 400) * 0.01f); + chr->act_die.drcarollimagedelay = (rngRandom() % TICKS(1000)) * 0.01f + 5.0f; + chr->drcarollimage_left = 1 + (s32)((rngRandom() % 400) * 0.01f); + chr->drcarollimage_right = 1 + (s32)((rngRandom() % 400) * 0.01f); } if (g_DrCarollDyingTimer > TICKS(310)) { @@ -8571,7 +8571,7 @@ void chrTickDruggedComingUp(struct chrdata *chr) if (i >= 0 && g_AnimTablesByRace[race][i].deathanims != NULL && g_AnimTablesByRace[race][i].deathanimcount > 0) { - s32 index = random() % g_AnimTablesByRace[race][i].deathanimcount; + s32 index = rngRandom() % g_AnimTablesByRace[race][i].deathanimcount; row = &g_AnimTablesByRace[race][i].deathanims[index]; chr->act_die.thudframe1 = row->thudframe1; @@ -9165,7 +9165,7 @@ bool func0f03e9f4(struct chrdata *chr, struct attackanimconfig *animcfg, bool fi sp174 += eyeheight * (0.025f - 0.05f * RANDOMFRAC() * arg4); } } else if (sqdist > 1000.0f * 1000.0f) { - if ((random() % 3) == 0) { + if ((rngRandom() % 3) == 0) { sp174 += eyeheight * (0.05f + 0.1f * RANDOMFRAC() * arg4); } else { sp174 -= eyeheight * (0.05f + 0.55f * RANDOMFRAC() * arg4); @@ -10098,7 +10098,7 @@ void chrTickShoot(struct chrdata *chr, s32 handnum) // This function can never return 2 though... if (botactShootFarsight(chr + zero, 0, &vector, &gunpos) == 2) { - normalshoot = random() % 255 > 200; + normalshoot = rngRandom() % 255 > 200; } } @@ -10135,7 +10135,7 @@ void chrTickShoot(struct chrdata *chr, s32 handnum) // Eyespy is small and hard to hit, so make it a 50/50 chance if (hitprop == NULL && isshootingeyespy) { - fudgeforeyespy = random() % 100 > 50; + fudgeforeyespy = rngRandom() % 100 > 50; if (fudgeforeyespy) { hitprop = targetprop; @@ -10393,10 +10393,10 @@ void chrTickShoot(struct chrdata *chr, s32 handnum) hitpos.y = targetprop->pos.y; hitpos.z = targetprop->pos.z; - if (random() % 2) { - hitpos.y += 2 + random() % 10; + if (rngRandom() % 2) { + hitpos.y += 2 + rngRandom() % 10; } else { - hitpos.y -= 2 + random() % 10; + hitpos.y -= 2 + rngRandom() % 10; } bgunPlayPropHitSound(&gset, targetprop, -1); @@ -10902,13 +10902,13 @@ void robotSetMuzzleFlash(struct chrdata *chr, bool right, bool visible) void robotAttack(struct chrdata *chr) { - u32 numshots = random() % 20; + u32 numshots = rngRandom() % 20; if (chr->unk348[0] && chr->unk348[1]) { chr->actiontype = ACT_ROBOTATTACK; chr->unk348[0]->beam->age = -1; - chr->unk348[0]->unk00 = random() % 3; + chr->unk348[0]->unk00 = rngRandom() % 3; chr->unk348[0]->unk01 = 0; chr->unk348[0]->unk08 = -1; chr->unk348[0]->unk0c = 0.85f; @@ -10931,7 +10931,7 @@ void robotAttack(struct chrdata *chr) chr->act_robotattack.firing[0] = false; chr->unk348[1]->beam->age = -1; - chr->unk348[1]->unk00 = random() % 3; + chr->unk348[1]->unk00 = rngRandom() % 3; chr->unk348[1]->unk01 = 0; chr->unk348[1]->unk08 = -1; chr->unk348[1]->unk0c = 0.85f; @@ -11224,7 +11224,7 @@ void chrTickAttackRoll(struct chrdata *chr) f32 sp34 = 16; if (chr->act_attack.firegun[HAND_LEFT] && chr->act_attack.firegun[HAND_RIGHT]) { - if (random() % 2 == 0) { + if (rngRandom() % 2 == 0) { newanimcfg += 4; } else { newanimcfg += 8; @@ -13269,7 +13269,7 @@ void chrTickSkJump(struct chrdata *chr) SFX_SKEDAR_ROAR_0534, }; - psCreate(NULL, chr->prop, sounds[random() % 3], -1, + psCreate(NULL, chr->prop, sounds[rngRandom() % 3], -1, -1, 0, 0, PSTYPE_NONE, 0, -1, 0, -1, -1, -1, -1); modelSetAnimation(chr->model, ANIM_SKEDAR_JUMPAIR, 0, 0, -1, 16); modelSetAnimSpeed(chr->model, 1, 0); @@ -13657,7 +13657,7 @@ void chraTickBg(void) spawnslen++; if (spawnslen >= 10) { - writeindex = random() % spawnslen; + writeindex = rngRandom() % spawnslen; chrFadeCorpse(spawns[writeindex]); spawns[writeindex] = spawns[spawnslen - 1]; spawnslen--; @@ -13748,7 +13748,7 @@ void chraTickBg(void) onscreenlen++; if (onscreenlen >= (VERSION >= VERSION_NTSC_1_0 ? 2 : 3)) { - writeindex = random() % onscreenlen; + writeindex = rngRandom() % onscreenlen; chrFadeCorpseWhenOffScreen(onscreen[writeindex]); onscreen[writeindex] = onscreen[onscreenlen - 1]; onscreenlen--; @@ -13763,7 +13763,7 @@ void chraTickBg(void) // Allow up to 5 corpses off-screen if (offscreenlen >= (VERSION >= VERSION_NTSC_1_0 ? 5 : 6)) { - writeindex = random() % offscreenlen; + writeindex = rngRandom() % offscreenlen; if (offscreen[writeindex]->actiontype != ACT_DEAD) { chrBeginDead(offscreen[writeindex]); @@ -15257,7 +15257,7 @@ struct prop *chrSpawnAtCoord(s32 bodynum, s32 headnum, struct coord *pos, RoomNu #endif replacechr = NULL; - startindex = random() % g_NumChrSlots; + startindex = rngRandom() % g_NumChrSlots; index = startindex; #if VERSION < VERSION_NTSC_1_0 @@ -15606,7 +15606,7 @@ s32 chrAssignCoverByCriteria(struct chrdata *chr, u16 criteria, s32 refdist) } else if (criteria & COVERCRITERIA_DISTTOFETCHPROP) { sqdist = coordGetSquaredDistanceToCoord(&gotoprop->pos, cover.pos); } else if (userandomdist) { - sqdist = random() % 0xf000; + sqdist = rngRandom() % 0xf000; } else { sqdist = 0; currefdist = 0; @@ -16316,7 +16316,7 @@ void chrAvoid(struct chrdata *chr) } else if (relangle > 135 && relangle < 225) { animindex = 2; - if ((random() % 255) >= 2) { + if ((rngRandom() % 255) >= 2) { cdresult = CDRESULT_COLLISION; chr->chrflags &= ~CHRCFLAG_AVOIDING; } @@ -16324,7 +16324,7 @@ void chrAvoid(struct chrdata *chr) animindex = 3; chrangle += M_PI; } else { - animindex = (random() % 100 < 50) ? 0 : 1; + animindex = (rngRandom() % 100 < 50) ? 0 : 1; if (animindex == 0) { chrangle -= 1.5707963705063f; diff --git a/src/game/chrai.c b/src/game/chrai.c index 1dfaefb71..895f22759 100644 --- a/src/game/chrai.c +++ b/src/game/chrai.c @@ -729,7 +729,7 @@ void chraiExecute(void *entity, s32 proptype) if (g_Vars.chrdata->aishootingatmelist >= 0 && ailistFindById(g_Vars.chrdata->aishootingatmelist) != g_Vars.chrdata->ailist - && g_Vars.chrdata->dodgerating > random() % 100 + && g_Vars.chrdata->dodgerating > rngRandom() % 100 && chrHasFlag(g_Vars.chrdata, CHRFLAG1_INDARKROOM, BANK_1) == 0 && chrHasFlag(g_Vars.chrdata, CHRFLAG0_AIVSAI, BANK_0) == 0 && ailistFindById(g_Vars.chrdata->aishootingatmelist) != g_Vars.chrdata->ailist diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index 85f89f83c..ab2cfa326 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -1100,7 +1100,7 @@ bool aiTryRunToChr(void) */ bool aiRandom(void) { - g_Vars.chrdata->random = random() & 0xff; + g_Vars.chrdata->random = rngRandom() & 0xff; g_Vars.aioffset += 2; return false; @@ -1114,7 +1114,7 @@ bool aiIfRandomLessThan(void) u8 *cmd = g_Vars.ailist + g_Vars.aioffset; if ((g_Vars.chrdata && g_Vars.chrdata->random < cmd[2]) || - (g_Vars.hovercar && ((u8)random()) < cmd[2])) { + (g_Vars.hovercar && ((u8)rngRandom()) < cmd[2])) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); } else { g_Vars.aioffset += 4; @@ -1131,7 +1131,7 @@ bool aiIfRandomGreaterThan(void) u8 *cmd = g_Vars.ailist + g_Vars.aioffset; if ((g_Vars.chrdata && g_Vars.chrdata->random > cmd[2]) || - (g_Vars.hovercar && ((u8)random()) > cmd[2])) { + (g_Vars.hovercar && ((u8)rngRandom()) > cmd[2])) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); } else { g_Vars.aioffset += 4; @@ -6925,7 +6925,7 @@ bool aiSayQuip(void) bank = (s16 *) g_MaianQuipBank; if (row > 2) { - row = random() % 2; + row = rngRandom() % 2; } } else if (cmd[7] == 0) { if (g_Vars.chrdata->voicebox > 3) { @@ -6975,7 +6975,7 @@ bool aiSayQuip(void) // If soundgap permits talking at this time and probability passes if (g_Vars.chrdata->soundgap == 0 || g_Vars.chrdata->soundgap * TICKS(60) < g_Vars.chrdata->soundtimer) { - if (probability > (s32) (random() % 256)) { + if (probability > (s32) (rngRandom() % 256)) { // Try and find a chr in the same squadron who is currently talking while (*chrnums != -2) { loopchr = chrFindByLiteralId(*chrnums); @@ -7000,7 +7000,7 @@ bool aiSayQuip(void) if (!issomeonetalking && ((numnearbychrs == 0 && (!cmd[6] || cmd[6] == 255)) || (numnearbychrs > 0 && cmd[6] > 0))) { rowptr = (s16 *) bank + row * 4; - column = random() % 3; + column = rngRandom() % 3; if ((cmd[7] & 0x80) == 0) { audioid = rowptr[1 + column]; @@ -7627,8 +7627,8 @@ bool aiShuffleInvestigationTerminals(void) * else conditions are unreachable so only 3 of the 4 terminals can be * selected as the destination. */ - rand1 = random() % 3; - rand2 = random() % 3; + rand1 = rngRandom() % 3; + rand2 = rngRandom() % 3; if (cmd[8] == 0) { // Place the good terminal @@ -8768,17 +8768,17 @@ bool aiSayCiStaffQuip(void) s16 quip; if (cmd[2] == CIQUIP_GREETING) { - quip = g_CiGreetingQuips[g_Vars.chrdata->morale][random() % 3]; + quip = g_CiGreetingQuips[g_Vars.chrdata->morale][rngRandom() % 3]; psPlayFromProp((s8)cmd[3], quip, 0, g_Vars.chrdata->prop, PSTYPE_CHRTALK, 0); } if (cmd[2] == CIQUIP_MAIN) { - quip = g_CiMainQuips[g_Vars.chrdata->morale][random() % 3]; + quip = g_CiMainQuips[g_Vars.chrdata->morale][rngRandom() % 3]; psPlayFromProp((s8)cmd[3], quip, 0, g_Vars.chrdata->prop, PSTYPE_CHRTALK, 0); } if (cmd[2] == CIQUIP_ANNOYED) { - quip = g_CiAnnoyedQuips[g_Vars.chrdata->morale][random() % 3]; + quip = g_CiAnnoyedQuips[g_Vars.chrdata->morale][rngRandom() % 3]; psPlayFromProp((s8)cmd[3], quip, 0, g_Vars.chrdata->prop, PSTYPE_CHRTALK, 0); } @@ -8819,7 +8819,7 @@ bool aiDoPresetAnimation(void) }; if (cmd[2] == 255) { - chrTryStartAnim(g_Vars.chrdata, anims[7 + (random() % 8)], 0, -1, 0, 15, 0.5); + chrTryStartAnim(g_Vars.chrdata, anims[7 + (rngRandom() % 8)], 0, -1, 0, 15, 0.5); } else if (cmd[2] == 254) { struct prop *prop0 = chrGetHeldProp(g_Vars.chrdata, 1); struct prop *prop1 = chrGetHeldProp(g_Vars.chrdata, 0); @@ -8830,7 +8830,7 @@ bool aiDoPresetAnimation(void) chrTryStartAnim(g_Vars.chrdata, ANIM_FIX_GUN_JAM_HARD, 0, -1, 0, 5, 0.5); } } else if (cmd[2] == 3) { - chrTryStartAnim(g_Vars.chrdata, anims[3 + (random() & 1)], 0, -1, 0, 15, 0.5); + chrTryStartAnim(g_Vars.chrdata, anims[3 + (rngRandom() & 1)], 0, -1, 0, 15, 0.5); } else { chrTryStartAnim(g_Vars.chrdata, anims[cmd[2]], 0, -1, 0, 15, 0.5); } @@ -8979,9 +8979,9 @@ bool aiShuffleRuinsPillars(void) struct tag *ptr2 = tagFindById(cmd[3]); struct tag *ptr3 = tagFindById(cmd[4]); struct tag *src; - u8 marked1index = random() % 5; - u8 marked2index = random() % 5; - u8 marked3index = random() % 5; + u8 marked1index = rngRandom() % 5; + u8 marked2index = rngRandom() % 5; + u8 marked3index = rngRandom() % 5; u8 pillars[5]; u8 mines[5]; pillars[0] = cmd[5]; @@ -8996,11 +8996,11 @@ bool aiShuffleRuinsPillars(void) mines[4] = cmd[17]; while (marked2index == marked1index) { - marked2index = random() % 5; + marked2index = rngRandom() % 5; } while (marked3index == marked2index || marked3index == marked1index) { - marked3index = random() % 5; + marked3index = rngRandom() % 5; } // Pillar/mine 1 @@ -9160,7 +9160,7 @@ bool aiShufflePelagicSwitches(void) for (i = 8; i < 16; i++) { tag = tagFindById(i); - index = random() & 7; + index = rngRandom() & 7; if (buttonsdone[index] == 0) { // Switch has not yet been mapped @@ -9610,20 +9610,20 @@ bool aiSetDrCarollImages(void) if (drcaroll) { if (cmd[4] == 7) { if ((g_Vars.lvframenum % 4) == 2) { - drcaroll->drcarollimage_left = random() % 6; + drcaroll->drcarollimage_left = rngRandom() % 6; } } else if (cmd[4] == 8) { - drcaroll->drcarollimage_left = random() % 6; + drcaroll->drcarollimage_left = rngRandom() % 6; } else { drcaroll->drcarollimage_left = cmd[4]; } if (cmd[3] == 7) { if ((g_Vars.lvframenum % 4) == 2) { - drcaroll->drcarollimage_right = random() % 6; + drcaroll->drcarollimage_right = rngRandom() % 6; } } else if (cmd[3] == 8) { - drcaroll->drcarollimage_right = random() % 6; + drcaroll->drcarollimage_right = rngRandom() % 6; } else { drcaroll->drcarollimage_right = cmd[3]; } diff --git a/src/game/credits.c b/src/game/credits.c index 54ad8cf8c..e47cca554 100644 --- a/src/game/credits.c +++ b/src/game/credits.c @@ -554,12 +554,12 @@ void creditsCreatePendingBgLayers(u32 mask) s32 shift = i * 8; if (g_CreditsData->unk41b0[i] == 0) { - g_CreditsData->bglayers[i + 2].type = random() % 12; + g_CreditsData->bglayers[i + 2].type = rngRandom() % 12; g_CreditsData->bglayers[i + 2].rotspeed = creditsRandInRange(0.00223f); g_CreditsData->bglayers[i + 2].panspeed = creditsRandInRange(0.00223f); if (((u8)(mask >> shift) & 2)) { - g_CreditsData->bglayers[i + 2].confignum = random() % 6; + g_CreditsData->bglayers[i + 2].confignum = rngRandom() % 6; } } } @@ -642,20 +642,20 @@ void creditsResetParticles(void) tmp = RANDOMFRAC(); g_CreditsData->particles[i].y = (tmp + tmp) * 3000.0f - 3000.0f; - g_CreditsData->particles[i].unk12 = random() % 4; - g_CreditsData->particles[i].colourindex = random() % 4; + g_CreditsData->particles[i].unk12 = rngRandom() % 4; + g_CreditsData->particles[i].colourindex = rngRandom() % 4; g_CreditsData->particles[i].rotation = RANDOMFRAC() * M_BADTAU; if (g_CreditsData->particleminsize < g_CreditsData->particlemaxsize) { g_CreditsData->particles[i].size = g_CreditsData->particleminsize - + (random() % (g_CreditsData->particlemaxsize - g_CreditsData->particleminsize)); + + (rngRandom() % (g_CreditsData->particlemaxsize - g_CreditsData->particleminsize)); } else { g_CreditsData->particles[i].size = g_CreditsData->particleminsize; } g_CreditsData->particles[i].movetype = g_CreditsData->particlemovetype; - if (random() % 2 == 1) { + if (rngRandom() % 2 == 1) { g_CreditsData->particles[i].confignum = g_CreditsData->particleconfignum1; } else { g_CreditsData->particles[i].confignum = g_CreditsData->particleconfignum2; @@ -685,12 +685,12 @@ void creditsTickParticles(void) } else { #if VERSION >= VERSION_NTSC_1_0 if (RANDOMFRAC() < 0.007f && joyGetButtons(0, R_TRIG) == 0) { - g_CreditsData->particlecolourindex1 = random() % 4; + g_CreditsData->particlecolourindex1 = rngRandom() % 4; g_CreditsData->particlecolourweight = 0; } #else if (RANDOMFRAC() < 0.007f) { - g_CreditsData->particlecolourindex1 = random() % 4; + g_CreditsData->particlecolourindex1 = rngRandom() % 4; g_CreditsData->particlecolourweight = 0; } #endif @@ -698,28 +698,28 @@ void creditsTickParticles(void) #if VERSION >= VERSION_NTSC_1_0 if (RANDOMFRAC() < 0.002f && joyGetButtons(0, R_TRIG) == 0) { - g_CreditsData->particlemovetype = random() % 5; + g_CreditsData->particlemovetype = rngRandom() % 5; } #else if (RANDOMFRAC() < 0.002f) { - g_CreditsData->particlemovetype = random() % 5; + g_CreditsData->particlemovetype = rngRandom() % 5; } #endif #if VERSION >= VERSION_NTSC_1_0 if (joyGetButtonsPressedThisFrame(0, R_TRIG)) { - g_CreditsData->particlemovetype = random() % 5; + g_CreditsData->particlemovetype = rngRandom() % 5; if (g_CreditsData->particlecolourindex1 < 0) { - g_CreditsData->particlecolourindex1 = random() % 4; + g_CreditsData->particlecolourindex1 = rngRandom() % 4; g_CreditsData->particlecolourweight = 0; } } #endif if (RANDOMFRAC() < 0.007f) { - g_CreditsData->particleconfignum1 = random() % 2; - g_CreditsData->particleconfignum2 = random() % 2; + g_CreditsData->particleconfignum1 = rngRandom() % 2; + g_CreditsData->particleconfignum2 = rngRandom() % 2; } for (i = 0; i < ARRAYCOUNT(g_CreditsData->particles); i++) { @@ -744,20 +744,20 @@ void creditsTickParticles(void) if (g_CreditsData->particles[i].z > 0.0f) { g_CreditsData->particles[i].x = RANDOMFRAC() * 2.0f * 3000.0f - 3000.0f; g_CreditsData->particles[i].y = RANDOMFRAC() * 2.0f * 3000.0f - 3000.0f; - g_CreditsData->particles[i].unk12 = random() % 4; - g_CreditsData->particles[i].colourindex = random() % 4; + g_CreditsData->particles[i].unk12 = rngRandom() % 4; + g_CreditsData->particles[i].colourindex = rngRandom() % 4; g_CreditsData->particles[i].rotation = RANDOMFRAC() * M_BADTAU; if (g_CreditsData->particleminsize < g_CreditsData->particlemaxsize) { g_CreditsData->particles[i].size = g_CreditsData->particleminsize - + random() % (g_CreditsData->particlemaxsize - g_CreditsData->particleminsize); + + rngRandom() % (g_CreditsData->particlemaxsize - g_CreditsData->particleminsize); } else { g_CreditsData->particles[i].size = g_CreditsData->particleminsize; } g_CreditsData->particles[i].movetype = g_CreditsData->particlemovetype; - if (random() % 2 == 1) { + if (rngRandom() % 2 == 1) { g_CreditsData->particles[i].confignum = g_CreditsData->particleconfignum1; } else { g_CreditsData->particles[i].confignum = g_CreditsData->particleconfignum2; @@ -998,7 +998,7 @@ Gfx *creditsDrawBackgroundText(Gfx *gdl, s32 x, s32 y, char *text, struct fontch f32 f24 = i * 0.2f + g_CreditsParticleRotationFrac * 10.0f * M_BADTAU + sp98; f32 f26 = i * 0.1f * (spread + 0.5f) + 1.0f; - if ((random() % 256) == 1) { + if ((rngRandom() % 256) == 1) { f26 *= 10.0f; } @@ -1075,7 +1075,7 @@ void creditsResetSlides(void) } for (i = 0; i < NUM_CORE_TEAM; i++) { - s32 index = random() % (NUM_CORE_TEAM - i); + s32 index = rngRandom() % (NUM_CORE_TEAM - i); g_CreditsData->coreteammap[i + 1] = pool[index]; @@ -1348,7 +1348,7 @@ void creditsTickSlide(void) } while (credit && credit->more && g_CreditsData->numthisslide < 4); for (i = 0; i < ARRAYCOUNT(g_CreditsData->unk41a8); i++) { - g_CreditsData->unk41a8[i] = random() % 3 | random() % 3 << 2 | random() % 16 << 4; + g_CreditsData->unk41a8[i] = rngRandom() % 3 | rngRandom() % 3 << 2 | rngRandom() % 16 << 4; } creditsCreatePendingBgLayers(0xffffffff); @@ -1656,10 +1656,10 @@ Gfx *creditsDrawSlide(Gfx *gdl) } // Apply random flicker - if (settled && random() % (g_CreditsData->numthisslide * 16) == 1) { + if (settled && rngRandom() % (g_CreditsData->numthisslide * 16) == 1) { transfrac = RANDOMFRAC() * 0.05f; - hdir = random() % 3; - vdir = random() % 3; + hdir = rngRandom() % 3; + vdir = rngRandom() % 3; } extray = 120 - cury / 2; diff --git a/src/game/dlights.c b/src/game/dlights.c index 93d59f826..ee10d3678 100644 --- a/src/game/dlights.c +++ b/src/game/dlights.c @@ -425,7 +425,7 @@ void roomInitLights(s32 roomnum) #if VERSION < VERSION_NTSC_1_0 if (cheatIsActive(CHEAT_PERFECTDARKNESS)) { light->brightness = 0; - light->sparkable = (random() % 2) ? true : false; + light->sparkable = (rngRandom() % 2) ? true : false; light->healthy = false; light->on = false; light->sparking = false; @@ -526,7 +526,7 @@ void roomSetLightsFaulty(s32 roomnum, s32 chance) if (g_Rooms[roomnum].numlights) { for (i = 0; i < g_Rooms[roomnum].numlights; i++) { - if ((random() % 100) < chance) { + if ((rngRandom() % 100) < chance) { light->healthy = false; light->on = false; } @@ -980,9 +980,9 @@ bool lightTickBroken(s32 roomnum, s32 lightnum) } if (light->sparking) { - if ((random() % 8) == 0) { + if ((rngRandom() % 8) == 0) { light->sparking = false; - } else if ((random() % 2) == 0) { + } else if ((rngRandom() % 2) == 0) { struct coord spc8; struct coord spbc; struct coord spb0; @@ -1036,7 +1036,7 @@ bool lightTickBroken(s32 roomnum, s32 lightnum) room = (void *) (roomnum * sizeof(struct bgroom)); - switch (random() % 4) { + switch (rngRandom() % 4) { case 0: if (roomnum && roomnum && roomnum); sparktype = SPARKTYPE_LIGHT1; @@ -1061,7 +1061,7 @@ bool lightTickBroken(s32 roomnum, s32 lightnum) sparksCreate(roomnum, NULL, ¢re, &spa4, &sp8c, sparktype); - if ((random() % 4) == 0) { + if ((rngRandom() % 4) == 0) { smokerooms[0] = roomnum; smokerooms[1] = -1; @@ -1073,7 +1073,7 @@ bool lightTickBroken(s32 roomnum, s32 lightnum) return true; } } else { - if ((random() % 80) == 0) { + if ((rngRandom() % 80) == 0) { light->sparking = true; } } @@ -1125,7 +1125,7 @@ void lightsConfigureForPerfectDarknessCutscene(void) g_Rooms[i].lightop_to_frac = 0.5f; for (j = 0; j < g_Rooms[i].numlights; j++) { - light->sparkable = random() % 2 ? true : false; + light->sparkable = rngRandom() % 2 ? true : false; light->healthy = true; light->on = true; light->sparking = false; @@ -1150,7 +1150,7 @@ void lightsConfigureForPerfectDarknessGameplay(void) g_Rooms[i].lightop_to_frac = 0; for (j = 0; j < g_Rooms[i].numlights; j++) { - light->sparkable = random() % 2 ? true : false; + light->sparkable = rngRandom() % 2 ? true : false; light->healthy = false; light->on = false; light->sparking = false; diff --git a/src/game/explosions.c b/src/game/explosions.c index 72d1877b5..49d7e9bea 100644 --- a/src/game/explosions.c +++ b/src/game/explosions.c @@ -259,7 +259,7 @@ bool explosionCreate(struct prop *sourceprop, struct coord *exppos, RoomNum *exp f32 sum = xdist * xdist + ydist * ydist + zdist * zdist; if (sum * lodscale * lodscale > 400 * 400) { - if (random() % 2 == 0) { + if (rngRandom() % 2 == 0) { if (sourceprop) { smokeCreateSimple(&sourceprop->pos, sourceprop->rooms, g_ExplosionTypes[type].smoketype); } else { @@ -711,7 +711,7 @@ void explosionInflictDamage(struct prop *expprop) // Flicker room lighting for (i = 0; expprop->rooms[i] != -1; i++) { - if (random() % 2048 <= 240) { + if (rngRandom() % 2048 <= 240) { roomFlashLighting(expprop->rooms[i], type->rangeh, 255); } } @@ -1199,7 +1199,7 @@ u32 explosionTick(struct prop *prop) // Create smoke if (((exp->age == TICKS(15) && exp->type == EXPLOSIONTYPE_GASBARREL) || (exp->age == maxage - TICKS(20) && exp->type != EXPLOSIONTYPE_GASBARREL)) - && (exp->type != EXPLOSIONTYPE_BULLETHOLE || (random() % 2) == 0)) { + && (exp->type != EXPLOSIONTYPE_BULLETHOLE || (rngRandom() % 2) == 0)) { if (exp->source) { smokeCreateSimple(&exp->source->pos, exp->source->rooms, type->smoketype); } else { diff --git a/src/game/footstep.c b/src/game/footstep.c index 2480ad470..21191c102 100644 --- a/src/game/footstep.c +++ b/src/game/footstep.c @@ -139,7 +139,7 @@ s32 footstepChooseSound(struct chrdata *chr, s32 footstepindex) running = footstepIsRunning(g_FootstepAnims[footstepindex].animnum); do { - rand = random() % 8; + rand = rngRandom() % 8; index = (running ? 2 : 0) + (rand & 5) + floortype * 8; } while (index == chr->lastfootsample); diff --git a/src/game/gailists.c b/src/game/gailists.c index 7695d2032..567075eea 100644 --- a/src/game/gailists.c +++ b/src/game/gailists.c @@ -1820,7 +1820,7 @@ u8 func0007_alerted[] = { /** * Pseudocode for the below logic: * - * rand = random() + * rand = rngRandom() * if rand < 10 * gun jammed * else if rand <= 64 @@ -1832,7 +1832,7 @@ u8 func0007_alerted[] = { * goto regular_attack * else * regular_attack: - * if random() > 50 + * if rngRandom() > 50 * stand or kneel attack (50% chance each) * else * walk or roll attack (50% chance each) diff --git a/src/game/game_006900.c b/src/game/game_006900.c index cdc523269..863dddb8e 100644 --- a/src/game/game_006900.c +++ b/src/game/game_006900.c @@ -72,7 +72,7 @@ void menuTickTimers(void) if (checksum != CHECKSUM_PLACEHOLDER) { u32 *ptr = (u32 *)&bgReset; - ptr += random() % 0x40; + ptr += rngRandom() % 0x40; end = &ptr[4]; while (ptr < end) { diff --git a/src/game/gunfx.c b/src/game/gunfx.c index f51d004e3..eb16bfae2 100644 --- a/src/game/gunfx.c +++ b/src/game/gunfx.c @@ -361,10 +361,10 @@ Gfx *beamRender(Gfx *gdl, struct beam *beam, bool arg2, u8 arg3) sp130 = 10.0f; texconfig = &g_TexLaserConfigs[0]; - colours[0].a = 150 + (random() % 50); + colours[0].a = 150 + (rngRandom() % 50); - if ((random() % 5) == 0) { - colours[0].r = colours[0].g = 255 - (random() % 100); + if ((rngRandom() % 5) == 0) { + colours[0].r = colours[0].g = 255 - (rngRandom() % 100); } } else { sp130 = 30.0f; @@ -738,8 +738,8 @@ void casingCreateForHand(s32 handnum, f32 ground, Mtxf *mtx) } } - sp5c = ((s32)((random() >> 24) * magic) >> 10) + magic; - f0 = (random() % sp5c) / PALUP((f32) (OS_CPU_COUNTER / 60)); + sp5c = ((s32)((rngRandom() >> 24) * magic) >> 10) + magic; + f0 = (rngRandom() % sp5c) / PALUP((f32) (OS_CPU_COUNTER / 60)); newyspeed = casing->speed.y - f0 * 0.2777778f; @@ -795,8 +795,8 @@ void casingCreateForHand(s32 handnum, f32 ground, Mtxf *mtx) } } - sp4c = ((s32) ((random() >> 24) * magic) >> 10) + magic; - f0 = (random() % sp4c) / PALUP((f32) (OS_CPU_COUNTER / 60)); + sp4c = ((s32) ((rngRandom() >> 24) * magic) >> 10) + magic; + f0 = (rngRandom() % sp4c) / PALUP((f32) (OS_CPU_COUNTER / 60)); newyspeed = casing->speed.y - f0 * 0.2777778f; diff --git a/src/game/lv.c b/src/game/lv.c index 36917c59b..2d0622be5 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -1454,7 +1454,7 @@ Gfx *lvRender(Gfx *gdl) g_CutsceneStaticTimer -= g_Vars.diffframe60; if (g_CutsceneStaticTimer < 0) { - g_CutsceneStaticTimer = random() % TICKS(200) + TICKS(40); + g_CutsceneStaticTimer = rngRandom() % TICKS(200) + TICKS(40); g_CutsceneStaticActive = false; } @@ -1471,7 +1471,7 @@ Gfx *lvRender(Gfx *gdl) // Consider a single frame of static, separate // to the main static above - if (random() % 60 == 1) { + if (rngRandom() % 60 == 1) { cutscenestatic = 255; sndStart(var80095200, SFX_INFIL_STATIC_SHORT, NULL, -1, -1, -1, -1, -1); } diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index e70b1dcd8..035e0bf71 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -1235,13 +1235,13 @@ void mpApplyWeaponSet(void) s32 numoptions = mpGetNumWeaponOptions(); for (i = 0; i < ARRAYCOUNT(g_MpSetup.weapons); i++) { - mpSetWeaponSlot(i, random() % numoptions); + mpSetWeaponSlot(i, rngRandom() % numoptions); } } else if (g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) { s32 numoptions = mpGetNumWeaponOptions() - 2; for (i = 0; i < 5; i++) { - mpSetWeaponSlot(i, random() % numoptions + 1); + mpSetWeaponSlot(i, rngRandom() % numoptions + 1); } mpSetWeaponSlot(i, mpGetNumWeaponOptions() - 1); @@ -1421,7 +1421,7 @@ s32 mpFindMaxInt(s32 numplayers, s32 val0, s32 val1, s32 val2, s32 val3) s32 bestplayer = 0; if (numplayers >= 2) { - if (val1 > bestvalue || (val1 == bestvalue && (random() % 2))) { + if (val1 > bestvalue || (val1 == bestvalue && (rngRandom() % 2))) { bestplayer = 1; bestvalue = val1; } else { @@ -1430,13 +1430,13 @@ s32 mpFindMaxInt(s32 numplayers, s32 val0, s32 val1, s32 val2, s32 val3) } if (numplayers >= 3) { - if (val2 > bestvalue || (val2 == bestvalue && (random() % 2))) { + if (val2 > bestvalue || (val2 == bestvalue && (rngRandom() % 2))) { bestplayer = 2; bestvalue = val2; } if (numplayers >= 4) { - if (val3 > bestvalue || (val3 == bestvalue && (random() % 2))) { + if (val3 > bestvalue || (val3 == bestvalue && (rngRandom() % 2))) { bestplayer = 3; } } @@ -1452,7 +1452,7 @@ s32 mpFindMinInt(s32 numplayers, s32 val0, s32 val1, s32 val2, s32 val3) s32 bestplayer = 0; if (numplayers >= 2) { - if (val1 < bestvalue || (val1 == bestvalue && (random() % 2))) { + if (val1 < bestvalue || (val1 == bestvalue && (rngRandom() % 2))) { bestplayer = 1; bestvalue = val1; } else { @@ -1461,13 +1461,13 @@ s32 mpFindMinInt(s32 numplayers, s32 val0, s32 val1, s32 val2, s32 val3) } if (numplayers >= 3) { - if (val2 < bestvalue || (val2 == bestvalue && (random() % 2))) { + if (val2 < bestvalue || (val2 == bestvalue && (rngRandom() % 2))) { bestplayer = 2; bestvalue = val2; } if (numplayers >= 4) { - if (val3 < bestvalue || (val3 == bestvalue && (random() % 2))) { + if (val3 < bestvalue || (val3 == bestvalue && (rngRandom() % 2))) { bestplayer = 3; } } @@ -1485,7 +1485,7 @@ s32 mpFindMaxFloat(s32 numplayers, f32 val0, f32 val1, f32 val2, f32 val3) s32 bestplayer = 0; if (numplayers >= 2) { - if (val1 > val0 || (val1 == val0 && (random() % 2))) { + if (val1 > val0 || (val1 == val0 && (rngRandom() % 2))) { bestplayer = 1; bestvalue = val1; } else { @@ -1494,13 +1494,13 @@ s32 mpFindMaxFloat(s32 numplayers, f32 val0, f32 val1, f32 val2, f32 val3) } if (numplayers >= 3) { - if (val2 > bestvalue || (val2 == bestvalue && (random() % 2))) { + if (val2 > bestvalue || (val2 == bestvalue && (rngRandom() % 2))) { bestplayer = 2; bestvalue = val2; } if (numplayers >= 4) { - if (val3 > bestvalue || (val3 == bestvalue && (random() % 2))) { + if (val3 > bestvalue || (val3 == bestvalue && (rngRandom() % 2))) { bestplayer = 3; } } @@ -1520,7 +1520,7 @@ s32 mpFindMinFloat(s32 numplayers, f32 val0, f32 val1, f32 val2, f32 val3) if (numplayers >= 2) { if (val0); - if (val1 < val0 || (val1 == val0 && (random() % 2))) { + if (val1 < val0 || (val1 == val0 && (rngRandom() % 2))) { bestplayer = 1; bestvalue = val1; } else { @@ -1529,13 +1529,13 @@ s32 mpFindMinFloat(s32 numplayers, f32 val0, f32 val1, f32 val2, f32 val3) } if (numplayers >= 3) { - if (val2 < bestvalue || (val2 == bestvalue && (random() % 2))) { + if (val2 < bestvalue || (val2 == bestvalue && (rngRandom() % 2))) { bestplayer = 2; bestvalue = val2; } if (numplayers >= 4) { - if (val3 < bestvalue || (val3 == bestvalue && (random() % 2))) { + if (val3 < bestvalue || (val3 == bestvalue && (rngRandom() % 2))) { bestplayer = 3; } } @@ -2351,11 +2351,11 @@ void mpCalculateAwards(void) numdone = 1; } - awardindex = random() % 17; + awardindex = rngRandom() % 17; } while (numdone < 2) { - awardindex = random() % 17; + awardindex = rngRandom() % 17; if (metrics[i].awards & (1 << awardindex)) { metrics[i].awards &= ~(1 << awardindex); @@ -2622,9 +2622,9 @@ s32 mpGetMpheadnumByMpbodynum(s32 mpbodynum) if (headnum == 1000) { if (g_HeadsAndBodies[g_MpBodies[mpbodynum].bodynum].ismale) { - headnum = g_MpMaleHeads[random() % ARRAYCOUNT(g_MpMaleHeads)]; + headnum = g_MpMaleHeads[rngRandom() % ARRAYCOUNT(g_MpMaleHeads)]; } else { - headnum = g_MpFemaleHeads[random() % ARRAYCOUNT(g_MpFemaleHeads)]; + headnum = g_MpFemaleHeads[rngRandom() % ARRAYCOUNT(g_MpFemaleHeads)]; } } @@ -2647,8 +2647,8 @@ void mpFindUnusedHeadAndBody(u8 *mpheadnum, u8 *mpbodynum) do { available = true; - trympheadnum = random() % ARRAYCOUNT(g_MpHeads); - trympbodynum = random() % ARRAYCOUNT(g_MpBodies); + trympheadnum = rngRandom() % ARRAYCOUNT(g_MpHeads); + trympbodynum = rngRandom() % ARRAYCOUNT(g_MpBodies); for (i = 0; i < MAX_MPCHRS; i++) { if (g_MpSetup.chrslots & (1 << i)) { @@ -2673,7 +2673,7 @@ void mpFindUnusedHeadAndBody(u8 *mpheadnum, u8 *mpbodynum) s32 mpChooseRandomLockPlayer(void) { - s32 start = random() % MAX_PLAYERS; + s32 start = rngRandom() % MAX_PLAYERS; s32 i; for (i = (start + 1) % MAX_PLAYERS;; i = (i + 1) % MAX_PLAYERS) { @@ -2929,7 +2929,7 @@ void mpRandomiseMultiTracks(void) s32 i; for (i = 0; i != ARRAYCOUNT(g_BossFile.multipletracknums); i++) { - g_BossFile.multipletracknums[i] = random(); + g_BossFile.multipletracknums[i] = rngRandom(); } } @@ -2964,7 +2964,7 @@ s32 mpChooseTrack(void) if (numselected == 0) { do { - tracknum = mpGetTrackNumAtSlotIndex(random() % numunlocked); + tracknum = mpGetTrackNumAtSlotIndex(rngRandom() % numunlocked); } while (tracknum == g_MpLockInfo.unk04); g_MpLockInfo.unk04 = tracknum; @@ -2974,7 +2974,7 @@ s32 mpChooseTrack(void) } do { - s32 selectionindex = random() % numselected; + s32 selectionindex = rngRandom() % numselected; s32 selectioncount = 0; tracknum = -1; @@ -3008,7 +3008,7 @@ s32 mpChooseTrack(void) s32 numunlocked = mpGetNumUnlockedTracks(); do { - tracknum = mpGetTrackNumAtSlotIndex(random() % numunlocked); + tracknum = mpGetTrackNumAtSlotIndex(rngRandom() % numunlocked); } while (tracknum == g_MpLockInfo.unk04); g_MpLockInfo.unk04 = tracknum; @@ -3129,7 +3129,7 @@ void mpCreateBotFromProfile(s32 botnum, u8 profilenum) g_BotConfigsArray[botnum].base.team = team; while (!available) { - headnum = g_BotHeads[random() % ARRAYCOUNT(g_BotHeads)]; + headnum = g_BotHeads[rngRandom() % ARRAYCOUNT(g_BotHeads)]; available = true; for (i = 0; i < MAX_MPCHRS; i++) { diff --git a/src/game/mplayer/scenarios/capturethecase.inc b/src/game/mplayer/scenarios/capturethecase.inc index 5a843bdd6..79a205f80 100644 --- a/src/game/mplayer/scenarios/capturethecase.inc +++ b/src/game/mplayer/scenarios/capturethecase.inc @@ -254,7 +254,7 @@ void ctcInitProps(void) for (i = 0; i != ARRAYCOUNT(g_ScenarioData.ctc.teamindexes); i++) { do { - g_ScenarioData.ctc.teamindexes[i] = random() % 4; + g_ScenarioData.ctc.teamindexes[i] = rngRandom() % 4; } while (teamsdone[g_ScenarioData.ctc.teamindexes[i]]); teamsdone[g_ScenarioData.ctc.teamindexes[i]] = true; diff --git a/src/game/mplayer/scenarios/hackthatmac.inc b/src/game/mplayer/scenarios/hackthatmac.inc index 1b5bb5310..ce182c1d1 100644 --- a/src/game/mplayer/scenarios/hackthatmac.inc +++ b/src/game/mplayer/scenarios/hackthatmac.inc @@ -272,13 +272,13 @@ void htbCreateUplink(void) } if (count > 0) { - count = random() % count; + count = rngRandom() % count; var800869ec = candidates[count]; var800869ec->hidden |= OBJHFLAG_DELETING; var800869ec->hidden2 |= OBJH2FLAG_CANREGEN; padnum = var800869ec->pad; } else if (g_ScenarioData.htm.numpads > 0) { - padnum = g_ScenarioData.htm.padnums[random() % g_ScenarioData.htm.numpads]; + padnum = g_ScenarioData.htm.padnums[rngRandom() % g_ScenarioData.htm.numpads]; } else { padnum = 0; } @@ -334,7 +334,7 @@ void htmInitProps(void) s32 padnum; do { - rand = random() % data->numpads; + rand = rngRandom() % data->numpads; padnum = data->padnums[rand]; } while (padnum <= 0); diff --git a/src/game/mplayer/scenarios/holdthebriefcase.inc b/src/game/mplayer/scenarios/holdthebriefcase.inc index 65d21e42b..f5ac62e40 100644 --- a/src/game/mplayer/scenarios/holdthebriefcase.inc +++ b/src/game/mplayer/scenarios/holdthebriefcase.inc @@ -274,13 +274,13 @@ void htbCreateToken(void) // Choose the candidate and remove it if (count > 0) { - count = random() % count; + count = rngRandom() % count; var800869ec = candidates[count]; g_ScenarioData.htb.tokenpad = var800869ec->pad; var800869ec->hidden |= OBJHFLAG_DELETING; var800869ec->hidden2 |= OBJH2FLAG_CANREGEN; } else if (g_ScenarioData.htb.nextindex > 0) { - g_ScenarioData.htb.tokenpad = g_ScenarioData.htb.padnums[random() % g_ScenarioData.htb.nextindex]; + g_ScenarioData.htb.tokenpad = g_ScenarioData.htb.padnums[rngRandom() % g_ScenarioData.htb.nextindex]; } else { g_ScenarioData.htb.tokenpad = 0; } diff --git a/src/game/mplayer/scenarios/kingofthehill.inc b/src/game/mplayer/scenarios/kingofthehill.inc index 53e72a358..0160c7632 100644 --- a/src/game/mplayer/scenarios/kingofthehill.inc +++ b/src/game/mplayer/scenarios/kingofthehill.inc @@ -221,7 +221,7 @@ void kohInitProps(void) struct pad pad; if (g_ScenarioData.koh.hillcount > 1) { - g_ScenarioData.koh.hillindex = random() % g_ScenarioData.koh.hillcount; + g_ScenarioData.koh.hillindex = rngRandom() % g_ScenarioData.koh.hillcount; pad_id = g_ScenarioData.koh.hillpads[g_ScenarioData.koh.hillindex]; } else { // @bug: If a stage setup file only has one hill, pad_id is not assigned @@ -311,7 +311,7 @@ void kohTick(void) previndex = g_ScenarioData.koh.hillindex; do { - g_ScenarioData.koh.hillindex = random() % g_ScenarioData.koh.hillcount; + g_ScenarioData.koh.hillindex = rngRandom() % g_ScenarioData.koh.hillcount; } while (g_ScenarioData.koh.hillindex == previndex); padnum = g_ScenarioData.koh.hillpads[g_ScenarioData.koh.hillindex]; diff --git a/src/game/mplayer/scenarios/popacap.inc b/src/game/mplayer/scenarios/popacap.inc index ca9d5060d..1e51adb64 100644 --- a/src/game/mplayer/scenarios/popacap.inc +++ b/src/game/mplayer/scenarios/popacap.inc @@ -170,7 +170,7 @@ void pacReset(void) while (i < g_MpNumChrs) { bool isnew; - s32 victimplayernum = random() % g_MpNumChrs; + s32 victimplayernum = rngRandom() % g_MpNumChrs; for (j = 0, isnew = true; j < i; j++) { if (data->victims[j] == victimplayernum) { diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index 3a333a49f..3a002bd26 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -139,7 +139,7 @@ s16 mpChooseRandomStage(void) } } - index = random() % numchallengescomplete; + index = rngRandom() % numchallengescomplete; for (i = 0; i < 16; i++) { if (challengeIsFeatureUnlocked(g_MpArenas[i].requirefeature)) { @@ -3378,7 +3378,7 @@ MenuItemHandlerResult menuhandlerMpNTeams(s32 operation, struct menuitem *item, s32 somevalue = (numchrs + numteams - 1) / numteams; s32 teamsremaining = numteams; s32 chrsremaining = numchrs; - s32 start = random() % numchrs; + s32 start = rngRandom() % numchrs; s32 i; s32 teamnum; @@ -3401,7 +3401,7 @@ MenuItemHandlerResult menuhandlerMpNTeams(s32 operation, struct menuitem *item, #endif if (teamsremaining >= chrsremaining) { - teamnum = random() % numteams; + teamnum = rngRandom() % numteams; while (true) { if (array[teamnum] == 0) { @@ -3416,7 +3416,7 @@ MenuItemHandlerResult menuhandlerMpNTeams(s32 operation, struct menuitem *item, } } } else { - teamnum = random() % numteams; + teamnum = rngRandom() % numteams; while (true) { if (array[teamnum] < somevalue) { diff --git a/src/game/objectives.c b/src/game/objectives.c index 9d079af7e..a3136ce2c 100644 --- a/src/game/objectives.c +++ b/src/game/objectives.c @@ -117,7 +117,7 @@ void tagsReset(void) // Read 4KB from a random ROM location within 128KB from the start of // the ROM, and write it to a random memory location between 0x80010000 // and 0x80030ff8. This will corrupt instructions in the lib segment. - dmaExec((u8 *)((random() & 0x1fff8) + 0x80010000), random() & 0x1fffe, 0x1000); + dmaExec((u8 *)((rngRandom() & 0x1fff8) + 0x80010000), rngRandom() & 0x1fffe, 0x1000); } } #endif diff --git a/src/game/padhalllv.c b/src/game/padhalllv.c index 2dca0ae16..1eeffbf1a 100644 --- a/src/game/padhalllv.c +++ b/src/game/padhalllv.c @@ -272,7 +272,7 @@ struct waygroup *waygroupChooseNeighbour(s32 *groupnums, s32 step, u32 ignoremas } if (!g_NavSeed[0] && !g_NavSeed[1]) { - if (random() % 2 == 0) { + if (rngRandom() % 2 == 0) { break; } } else { @@ -416,7 +416,7 @@ struct waypoint *waypointChooseNeighbour(s32 *pointnums, s32 step, s32 groupnum, } if (!g_NavSeed[0] && !g_NavSeed[1]) { - if (random() % 2 == 0) { + if (rngRandom() % 2 == 0) { break; } } else { @@ -610,7 +610,7 @@ void waypointFindSegmentIntoGroup(struct waygroup *fromgroup, struct waygroup *t } if (!g_NavSeed[0] && !g_NavSeed[1]) { - if (random() % 2 == 0) { + if (rngRandom() % 2 == 0) { break; } } else { @@ -697,7 +697,7 @@ struct waypoint *waypointFindRandomAtStep(s32 *pointnums, s32 step) len++; } - randomindex = random() % len; + randomindex = rngRandom() % len; for (i = randomindex; i < len; i++) { struct waypoint *point = &g_StageSetup.waypoints[WPSEG_GET_ID(pointnums[i])]; @@ -728,7 +728,7 @@ struct waygroup *waygroupFindRandomAtStep(s32 *groupnums, s32 step) len++; } - randomindex = random() % len; + randomindex = rngRandom() % len; for (i = randomindex; i < len; i++) { struct waygroup *group = &g_StageSetup.waygroups[WPSEG_GET_ID(groupnums[i])]; diff --git a/src/game/pak.c b/src/game/pak.c index 9927b22ad..b3e9c0350 100644 --- a/src/game/pak.c +++ b/src/game/pak.c @@ -370,7 +370,7 @@ u32 pakGenerateSerial(s8 device) } value = g_Paks[device].unk2c8; - rand = (random() % 496) + 16; // range 16-511 + rand = (rngRandom() % 496) + 16; // range 16-511 count = osGetCount(); return value ^ rand ^ count; @@ -2546,7 +2546,7 @@ s32 pakRepairFilesystem(s8 device) } #else if (device != SAVEDEVICE_GAMEPAK && g_Paks[device].serial == 0) { - g_Paks[device].serial = 0x10 + random() % 0x1ff0; + g_Paks[device].serial = 0x10 + rngRandom() % 0x1ff0; return 0; } #endif @@ -2572,7 +2572,7 @@ void pakCorrupt(void) for (i = 0; fileids[i] != 0; i++) { for (j = 0; j < 8; j++) { - payload[j] = random() & 0xff; + payload[j] = rngRandom() & 0xff; } address = pakFindFile(SAVEDEVICE_GAMEPAK, fileids[i], &header); @@ -3427,7 +3427,7 @@ s32 pakCreateFilesystem(s8 device) s32 i; for (i = 0; i < 32; i++) { - data[i] = random() & 0xff; + data[i] = rngRandom() & 0xff; } address = pakGetAlignedFileLenByBodyLen(device, pakGetBodyLenByType(device, PAKFILETYPE_TERMINATOR)); @@ -3436,7 +3436,7 @@ s32 pakCreateFilesystem(s8 device) #if VERSION >= VERSION_NTSC_1_0 g_Paks[device].serial = pakGenerateSerial(device); #else - g_Paks[device].serial = 0x10 + random() % 0x1ff0; + g_Paks[device].serial = 0x10 + rngRandom() % 0x1ff0; #endif g_Paks[device].headercachecount = 0; diff --git a/src/game/player.c b/src/game/player.c index e5d7de700..9b8646793 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -328,7 +328,7 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, RoomNum *dstr // Look for pads that aren't bad (and therefore aren't very bad either) and // are at least 10m away. For each pad added, set their distance to -1 so // they don't get reused later. - i = random() % numpads; + i = rngRandom() % numpads; p = i; \ while (sllen < 4) { if (padsqdists[p] > 1000 * 1000 && !badpads[p]) { @@ -367,7 +367,7 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, RoomNum *dstr // If the shortlist still has vacant slots, iterate the pads again but this // time take the bad pads. Keep the very bad pads out of contention for now. - p = i = random() % numpads; + p = i = rngRandom() % numpads; while (sllen < 4) { if (padsqdists[p] > 1000 * 1000 && !verybadpads[p]) { @@ -460,7 +460,7 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, RoomNum *dstr // Finally, choose a random pad from the shortlist if (sllen > 0) { - p = random() % sllen; + p = rngRandom() % sllen; dstpos->x = slpositions[p].x; dstpos->y = slpositions[p].y; @@ -471,7 +471,7 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, RoomNum *dstr dstangle = slangles[p]; } else { // No shortlisted pads, so pick a random one from the full selection - padUnpack(pads[random() % numpads], PADFIELD_POS | PADFIELD_LOOK | PADFIELD_ROOM, &pad); + padUnpack(pads[rngRandom() % numpads], PADFIELD_POS | PADFIELD_LOOK | PADFIELD_ROOM, &pad); dstrooms[0] = pad.room; dstrooms[1] = -1; @@ -1025,7 +1025,7 @@ void playerSpawn(void) if (g_Vars.lvframenum > 0 && (g_ChrSlots[i].hidden & CHRHFLAG_ONBONDSSCREEN) && func0f06b39c(&sp78, &sp90, &g_ChrSlots[i].prop->pos, modelGetEffectiveScale(g_ChrSlots[i].model)) - && (random() % 8)) { + && (rngRandom() % 8)) { sqdist += 1000 * 1000; } @@ -1061,7 +1061,7 @@ void playerSpawn(void) // Randomly swap some of the earlier elements so the player // doesn't always spawn into the closest - if (numsqdists > 1 && (random() % 2) == 0) { + if (numsqdists > 1 && (rngRandom() % 2) == 0) { tmpchr = sortedchrs[0]; sqdist = sorteddists[0]; sortedchrs[0] = sortedchrs[1]; @@ -1070,7 +1070,7 @@ void playerSpawn(void) sorteddists[1] = sqdist; } - if (numsqdists > 2 && (random() % 4) == 0) { + if (numsqdists > 2 && (rngRandom() % 4) == 0) { tmpchr = sortedchrs[0]; sqdist = sorteddists[0]; sortedchrs[0] = sortedchrs[2]; @@ -2829,7 +2829,7 @@ void playerTickExplode(void) explosionCreateSimple(NULL, &pos, g_Vars.currentplayer->prop->rooms, EXPLOSIONTYPE_BONDEXPLODE, g_Vars.currentplayernum); - g_Vars.currentplayer->bondnextexplode = g_Vars.lvframe60 + TICKS(15) + (random() % TICKS(15)); + g_Vars.currentplayer->bondnextexplode = g_Vars.lvframe60 + TICKS(15) + (rngRandom() % TICKS(15)); } } @@ -4503,7 +4503,7 @@ void playerDisplayShield(void) if (g_Vars.currentplayer->shieldshowtime < 0) { s32 rand = ((g_Vars.currentplayer->shieldshowrnd >> 16) % 200) * 4 + 800; - g_Vars.currentplayer->shieldshowrnd = random(); + g_Vars.currentplayer->shieldshowrnd = rngRandom(); g_Vars.currentplayer->shieldshowrot = g_Vars.thisframestart240 % rand; } @@ -5698,7 +5698,7 @@ void playerChooseThirdPersonAnimation(struct chrdata *chr, s32 crouchpos, f32 sp animnum = prevanimnum; speed = 0.5f; } else { - animnum = g_DeathAnimations[random() % g_NumDeathAnimations]; + animnum = g_DeathAnimations[rngRandom() % g_NumDeathAnimations]; speed = 0.5f; } diff --git a/src/game/playermgr.c b/src/game/playermgr.c index 520b722ab..2b58e98ce 100644 --- a/src/game/playermgr.c +++ b/src/game/playermgr.c @@ -843,7 +843,7 @@ void playermgrShuffle(void) // Randomly swap numbers with later elements for (i = 0; i < MAX_PLAYERS - 1; i++) { - s32 otherindex = random() % (MAX_PLAYERS - i); + s32 otherindex = rngRandom() % (MAX_PLAYERS - i); s32 tmp = g_Vars.playerorder[i]; g_Vars.playerorder[i] = g_Vars.playerorder[i + otherindex]; diff --git a/src/game/prop.c b/src/game/prop.c index 64a34aa4f..78f962334 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -469,7 +469,7 @@ void weaponPlayWhooshSound(s32 weaponnum, struct prop *prop) } else if (weaponnum == WEAPON_REAPER) { // empty } else if (weaponnum == WEAPON_COMBATKNIFE) { - soundnum = random() % 2 == 1 ? SFX_8060 : SFX_8061; + soundnum = rngRandom() % 2 == 1 ? SFX_8060 : SFX_8061; speed = 1.05f - RANDOMFRAC() * 0.2f; } else { soundnum = SFX_0069; @@ -518,7 +518,7 @@ void func0f060bac(s32 weaponnum, struct prop *prop) if (weaponnum == WEAPON_UNARMED) { soundnum = SFX_THUD_808F; - if ((random() % 2) == 1) { + if ((rngRandom() % 2) == 1) { soundnum = SFX_THUD_8094; } @@ -533,7 +533,7 @@ void func0f060bac(s32 weaponnum, struct prop *prop) #else soundnum = SFX_HIT_METAL_8079; - if (weaponnum != WEAPON_COMBATKNIFE && (random() % 2) == 1) { + if (weaponnum != WEAPON_COMBATKNIFE && (rngRandom() % 2) == 1) { soundnum = SFX_HATHIT_807C; } @@ -847,7 +847,7 @@ struct prop *shotCalculateHits(s32 handnum, bool isshooting, struct coord *gunpo && shotdata.gset.weaponnum != WEAPON_LASER && shotdata.gset.weaponnum != WEAPON_TRANQUILIZER && shotdata.gset.weaponnum != WEAPON_FARSIGHT) { - texnum = random() % surfacetype->numwallhittexes; + texnum = rngRandom() % surfacetype->numwallhittexes; texnum = surfacetype->wallhittexes[texnum]; if (texnum >= WALLHITTEX_GLASS1 && texnum <= WALLHITTEX_GLASS3) { @@ -867,7 +867,7 @@ struct prop *shotCalculateHits(s32 handnum, bool isshooting, struct coord *gunpo } else { if (!chrIsUsingPaintball(g_Vars.currentplayer->prop->chr)) { if (PLAYERCOUNT() >= 2) { - if ((random() % 8) == 0) { + if ((rngRandom() % 8) == 0) { smokeCreateSimple(&sp694.pos, rooms2, SMOKETYPE_BULLETIMPACT); } } else { @@ -877,7 +877,7 @@ struct prop *shotCalculateHits(s32 handnum, bool isshooting, struct coord *gunpo } } - if (PLAYERCOUNT() <= 2 || g_Vars.lvupdate240 <= 8 || (random() % 4) == 0) { + if (PLAYERCOUNT() <= 2 || g_Vars.lvupdate240 <= 8 || (rngRandom() % 4) == 0) { if (sp694.pos.x > -32000 && sp694.pos.x < 32000 && sp694.pos.y > -32000 && sp694.pos.y < 32000 && sp694.pos.z > -32000 && sp694.pos.z < 32000) { @@ -2400,18 +2400,18 @@ void propsTickPadEffects(void) up.y = -pad.up.y; up.z = -pad.up.z; - if ((random() % 2048) <= 50) { + if ((rngRandom() % 2048) <= 50) { sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, SPARKTYPE_ENVIRONMENTAL1); psCreate(NULL, NULL, psGetRandomSparkSound(), -1, -1, 0, 0, PSTYPE_NONE, &pad.pos, -1, rooms, -1, -1, -1, -1); } - if ((random() % 2048) <= 15) { + if ((rngRandom() % 2048) <= 15) { sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, SPARKTYPE_ENVIRONMENTAL1); sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, SPARKTYPE_ENVIRONMENTAL2); psCreate(NULL, NULL, psGetRandomSparkSound(), -1, -1, 0, 0, PSTYPE_NONE, &pad.pos, -1, rooms, -1, -1, -1, -1); } - if ((random() % 2048) <= 5) { + if ((rngRandom() % 2048) <= 5) { sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, SPARKTYPE_ENVIRONMENTAL1); sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, SPARKTYPE_ENVIRONMENTAL3); psCreate(NULL, NULL, psGetRandomSparkSound(), -1, -1, 0, 0, PSTYPE_NONE, &pad.pos, -1, rooms, -1, -1, -1, -1); diff --git a/src/game/propobj.c b/src/game/propobj.c index 73d97eeec..358eda12d 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -1105,7 +1105,7 @@ struct projectile *projectileAllocate(void) // If there were none, pick one at random if (bestindex == -1 && g_MaxProjectiles) { - bestindex = random() % g_MaxProjectiles; + bestindex = rngRandom() % g_MaxProjectiles; } if (bestindex >= 0) { @@ -1524,7 +1524,7 @@ s32 func0f068fc8(struct prop *prop, bool arg1) s32 *extraptr; if (prop->rooms[0] == -1) { - actual = random() % 255; + actual = rngRandom() % 255; extra = 0; } else if (obj->type == OBJTYPE_DOOR) { struct doorobj *door = (struct doorobj *)obj; @@ -3738,7 +3738,7 @@ void projectileFall(struct defaultobj *obj, f32 arg1[3][3]) t4 = NEXT(i); t3 = PREV(i); } else { - if ((random() % 2) == 0) { + if ((rngRandom() % 2) == 0) { t4 = PREV(i); t3 = NEXT(i); } else { @@ -3890,7 +3890,7 @@ void knifePlayWooshSound(struct defaultobj *obj) && obj->projectile->bouncecount <= 0 && (obj->hidden & OBJHFLAG_THROWNKNIFE)) { u16 soundnums[] = { SFX_8074, SFX_8074, SFX_8074 }; - s32 index = random() % ARRAYCOUNT(soundnums); + s32 index = rngRandom() % ARRAYCOUNT(soundnums); if (obj->projectile->lastwooshframe < g_Vars.lvframe60 - TICKS(6)) { psStopSound(obj->prop, PSTYPE_GENERAL, 0xffff); @@ -4039,7 +4039,7 @@ void knifeLand(struct defaultobj *obj, struct coord *arg1, struct coord *arg2) // @bug? Should these be assigned to zero? objGetLocalZMin(bbox); - random(); + rngRandom(); sp1c.x = RANDOMFRAC() * 0.8f + arg2->x - 0.4f; sp1c.y = RANDOMFRAC() * 0.8f + arg2->y - 0.4f; @@ -7437,7 +7437,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) } else if (weapon->weaponnum == WEAPON_GRENADE && weapon->gunfunc == FUNC_SECONDARY) { u16 sp100[] = {SFX_0027, SFX_0028, SFX_0029, SFX_002A}; - psCreate(0, prop, sp100[random() % 4], -1, -1, 0, 0, PSTYPE_NONE, 0, -1.0f, 0, -1, -1.0f, -1.0f, -1.0f); + psCreate(0, prop, sp100[rngRandom() % 4], -1, -1, 0, 0, PSTYPE_NONE, 0, -1.0f, 0, -1, -1.0f, -1.0f, -1.0f); psCreate(0, prop, SFX_EYESPYHIT, -1, -1, 0, 0, PSTYPE_NONE, 0, -1.0f, 0, -1, -1.0f, -1.0f, -1.0f); } else { psCreate(0, prop, SFX_EYESPYHIT, -1, -1, 0, 0, PSTYPE_NONE, 0, -1.0f, 0, -1, -1.0f, -1.0f, -1.0f); @@ -9296,10 +9296,10 @@ void autogunTickShoot(struct prop *autogunprop) missed = false; - if (random() % 2) { - hitpos.y += 2 + (random() % 10); + if (rngRandom() % 2) { + hitpos.y += 2 + (rngRandom() % 10); } else { - hitpos.y -= 2 + (random() % 10); + hitpos.y -= 2 + (rngRandom() % 10); } bgunPlayPropHitSound(&gset, targetprop, -1); @@ -9658,7 +9658,7 @@ void chopperFireRocket(struct chopperobj *chopper, bool side) pos.z = sp6c.m[3][2] + chopperprop->pos.f[2]; direction.x = targetprop->pos.x - pos.x; - direction.y = targetprop->pos.y - pos.y + (s32)(random() % 100); + direction.y = targetprop->pos.y - pos.y + (s32)(rngRandom() % 100); direction.z = targetprop->pos.z - pos.z; guNormalize(&direction.x, &direction.y, &direction.z); @@ -9699,8 +9699,8 @@ void chopperIncrementBarrel(struct prop *chopperprop, bool firing) rodata = modelGetPartRodata(model->definition, MODELPART_CHOPPER_0001); gunaimy = targetprop->pos.y - 20.0f; - gunpos.x = random() * random() * 0 * 30.0f + rodata->pos.x; - gunpos.y = random() * 0 * 30.0f + (rodata->pos.y - 50.0f); + gunpos.x = rngRandom() * rngRandom() * 0 * 30.0f + rodata->pos.x; + gunpos.y = rngRandom() * 0 * 30.0f + (rodata->pos.y - 50.0f); gunpos.z = rodata->pos.z + 250.0f; if (obj->modelnum == MODEL_A51INTERCEPTOR) { @@ -9869,7 +9869,7 @@ void chopperIncrementMovement(struct prop *prop, f32 goalroty, f32 goalrotx, str if (chopper->bob > M_BADTAU) { chopper->bob = 0.0f; - chopper->bobstrength = ((random() % 8) + 2) * 0.01f; + chopper->bobstrength = ((rngRandom() % 8) + 2) * 0.01f; if (chopper->base.flags & OBJFLAG_CHOPPER_INACTIVE) { chopper->bobstrength *= 0.15f; @@ -10102,7 +10102,7 @@ void chopperTickFall(struct prop *chopperprop) if (bob > M_BADTAU) { bob = 0; - chopper->bobstrength = (random() % 8 + 2) * 0.01f; + chopper->bobstrength = (rngRandom() % 8 + 2) * 0.01f; if (obj->flags & OBJFLAG_CHOPPER_INACTIVE) { chopper->bobstrength *= 0.15f; @@ -13176,7 +13176,7 @@ Gfx *tvscreenRender(struct model *model, struct modelnode *node, struct tvscreen tvscreenSetCmdlist(screen, (u32 *) cmd->arg1); break; case TVCMD_RANDSETCMDLIST: - if ((random() >> 16) < cmd->arg2) { + if ((rngRandom() >> 16) < cmd->arg2) { tvscreenSetCmdlist(screen, (u32 *) cmd->arg1); } else { screen->offset += 3; @@ -13951,7 +13951,7 @@ void objDeform(struct defaultobj *obj, s32 level) if (debugIsObjDeformDebugEnabled()); if (debugIsObjDeformDebugEnabled()); - salt = random(); + salt = rngRandom(); if (debugIsObjDeformDebugEnabled()) { salt &= 0xffff; @@ -15546,7 +15546,7 @@ void objDamage(struct defaultobj *obj, f32 damage, struct coord *pos, s32 weapon if (objGetDestroyedLevel(obj) == 1) { u32 stack; struct multiammocrateobj *crate = (struct multiammocrateobj *) obj; - s32 startindex = random() % ARRAYCOUNT(crate->slots); + s32 startindex = rngRandom() % ARRAYCOUNT(crate->slots); s32 i = startindex; do { @@ -15888,7 +15888,7 @@ void objHit(struct shotdata *shotdata, struct hit *hit) struct prop *hitprop = hit->prop; s8 iswindoweddoor = obj->model->definition->skel == &g_SkelWindowedDoor ? true : false; - textureindex = WALLHITTEX_GLASS1 + (random() % 3); + textureindex = WALLHITTEX_GLASS1 + (rngRandom() % 3); if ((obj->type == OBJTYPE_DOOR && !iswindoweddoor) || (obj->flags & OBJFLAG_INVINCIBLE) @@ -15916,7 +15916,7 @@ void objHit(struct shotdata *shotdata, struct hit *hit) if (surfacetype->numwallhittexes > 0) { spc4 = false; - spcc = random() % surfacetype->numwallhittexes; + spcc = rngRandom() % surfacetype->numwallhittexes; if ((obj->model->definition->skel == &g_SkelWindowedDoor && hit->dlnode == modelGetPart(obj->model->definition, MODELPART_WINDOWEDDOOR_0003)) || (obj->model->definition->skel == &g_SkelCctv && hit->dlnode == modelGetPart(obj->model->definition, MODELPART_CCTV_LENS))) { @@ -20175,7 +20175,7 @@ void doorCreateSparks(struct doorobj *door) sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp7c, &sp70, &pad.up, SPARKTYPE_ENVIRONMENTAL1); - if (random() % 2) { + if (rngRandom() % 2) { sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp88, &sp70, &pad.up, SPARKTYPE_ENVIRONMENTAL4); } else { sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp88, &sp70, &pad.up, SPARKTYPE_ENVIRONMENTAL5); @@ -20225,7 +20225,7 @@ bool doorCalcIntendedFrac(struct doorobj *door) // Skedar Ruins random door stuckage if (door->base.flags3 & OBJFLAG3_DOOR_STICKY) { - s32 value = (random() % 64) + 30; + s32 value = (rngRandom() % 64) + 30; #ifndef PLATFORM_N64 // emulate low fps cal rate for stuckage test if (((g_Vars.lvframenum % value) == 0) @@ -20239,7 +20239,7 @@ bool doorCalcIntendedFrac(struct doorobj *door) door->fracspeed = 0.0f; doorCreateSparks(door); - if (random() % 2) { + if (rngRandom() % 2) { dothething = true; psStopSound(door->base.prop, PSTYPE_DOOR, 0xffff); door->mode = DOORMODE_IDLE; @@ -20249,7 +20249,7 @@ bool doorCalcIntendedFrac(struct doorobj *door) loopdoor = door; while (loopdoor) { - if (random() % 2 && loopdoor->mode != DOORMODE_IDLE) { + if (rngRandom() % 2 && loopdoor->mode != DOORMODE_IDLE) { loopdoor->fracspeed = 0.0f; doorCreateSparks(loopdoor); @@ -21499,10 +21499,10 @@ void projectileCreate(struct prop *fromprop, struct fireslotthing *arg1, struct endpos.y = targetprop->pos.y; endpos.z = targetprop->pos.z; - if (random() % 2) { - endpos.y += (random() % 10) + 2; + if (rngRandom() % 2) { + endpos.y += (rngRandom() % 10) + 2; } else { - endpos.y -= (random() % 10) + 2; + endpos.y -= (rngRandom() % 10) + 2; } bgunPlayPropHitSound(&gset, targetprop, -1); diff --git a/src/game/propsnd.c b/src/game/propsnd.c index 5125fe70e..7f04bab9c 100644 --- a/src/game/propsnd.c +++ b/src/game/propsnd.c @@ -1486,7 +1486,7 @@ void psApplyVolPan(struct sndstate *handle, struct coord *pos, f32 dist1, f32 di s32 psGetRandomSparkSound(void) { - s32 index = random() % 6; + s32 index = rngRandom() % 6; s16 sounds[] = { SFX_80B0, diff --git a/src/game/setup.c b/src/game/setup.c index 4cfa61cd7..8d281552e 100644 --- a/src/game/setup.c +++ b/src/game/setup.c @@ -2067,7 +2067,7 @@ void setupCreateProps(s32 stagenum) } for (i = 0; i < maxsimulants; i++) { - slotnum = random() % maxsimulants; + slotnum = rngRandom() % maxsimulants; while (slotsdone[slotnum]) { slotnum = (slotnum + 1) % maxsimulants; @@ -2227,7 +2227,7 @@ void setupCreateProps(s32 stagenum) // for storing OBJHFLAG_CONDITIONALSCENERY, which is required // for a match. Any function call would work. if (alwayszero) { - random(); + rngRandom(); } if (expoffset) { diff --git a/src/game/shards.c b/src/game/shards.c index 729579654..4fe3c4ca5 100644 --- a/src/game/shards.c +++ b/src/game/shards.c @@ -88,7 +88,7 @@ void shardsCreate(struct coord *pos, f32 *rotx, f32 *roty, f32 *rotz, f32 relxmi * when you shoot the bottles, half of them don't play any breaking * sound effect. */ - psCreate(NULL, NULL, SFX_BOTTLE_BREAK + (random() % 2) * 2, -1, + psCreate(NULL, NULL, SFX_BOTTLE_BREAK + (rngRandom() % 2) * 2, -1, -1, 0, 0, PSTYPE_NONE, &prop->pos, -1.0f, prop->rooms, -1, -1.0f, -1.0f, -1.0f); } else if (type == SHARDTYPE_WOOD) { psCreate(NULL, NULL, SFX_WOOD_BREAK, -1, @@ -145,7 +145,7 @@ void shardCreate(RoomNum room, struct coord *pos, f32 rotx, f32 size, s32 type) } if (type == SHARDTYPE_WOOD) { - s32 rand = random() % 100; + s32 rand = rngRandom() % 100; if (rand < 20) { g_Shards[g_NextShardNum].colours[0].word = PD_BE32(0xbbbbbbf0); @@ -182,7 +182,7 @@ void shardCreate(RoomNum room, struct coord *pos, f32 rotx, f32 size, s32 type) for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { - g_Shards[g_NextShardNum].colours[i].bytes[j] = random() % 0xff; + g_Shards[g_NextShardNum].colours[i].bytes[j] = rngRandom() % 0xff; } } diff --git a/src/game/smoke.c b/src/game/smoke.c index edc7d5e37..e065c7d9a 100644 --- a/src/game/smoke.c +++ b/src/game/smoke.c @@ -499,7 +499,7 @@ u32 smokeTick(struct prop *prop) part->size = g_SmokeTypes[smoke->type].size * (RANDOMFRAC() * 0.5f + 1.0f); } - part->alpha = (random() % 70) + 110.0f; + part->alpha = (rngRandom() % 70) + 110.0f; part->count = 0; part->rot = RANDOMFRAC() * M_BADTAU; part->deltarot = (0.5f - RANDOMFRAC()) * g_SmokeTypes[smoke->type].bgrotatespeed; diff --git a/src/game/sparks.c b/src/game/sparks.c index 993232b1e..7f6f8f335 100644 --- a/src/game/sparks.c +++ b/src/game/sparks.c @@ -107,9 +107,9 @@ void sparkCreate(struct coord *pos, struct sparktype *type) spark->pos.y = 0.0f; spark->pos.z = 0.0f; - spark->speed.x = (s32)(random() % (type->unk00 * 2 + 1)) - type->unk00; - spark->speed.y = (s32)(random() % (type->unk00 * 2 + 1)) - type->unk00; - spark->speed.z = (s32)(random() % (type->unk00 * 2 + 1)) - type->unk00; + spark->speed.x = (s32)(rngRandom() % (type->unk00 * 2 + 1)) - type->unk00; + spark->speed.y = (s32)(rngRandom() % (type->unk00 * 2 + 1)) - type->unk00; + spark->speed.z = (s32)(rngRandom() % (type->unk00 * 2 + 1)) - type->unk00; if (spark->speed.y == 0.0f) { spark->speed.y = -0.0001f; @@ -148,7 +148,7 @@ void sparkCreate(struct coord *pos, struct sparktype *type) } if (type->unk18 % 2) { - spark->ttl = random() % type->maxage; + spark->ttl = rngRandom() % type->maxage; } else { spark->ttl = type->maxage; } @@ -195,16 +195,16 @@ void sparksCreate(s32 room, struct prop *prop, struct coord *pos, struct coord * type->unk20 = colours[2]; } } else if (typenum == SPARKTYPE_PAINT) { - type->unk1c = (random() % 2 ? 0xff000000 : 0) | (random() % 2 ? 0x00ff0000 : 0) | (random() % 2 ? 0x0000ff00 : 0) | 0xff; + type->unk1c = (rngRandom() % 2 ? 0xff000000 : 0) | (rngRandom() % 2 ? 0x00ff0000 : 0) | (rngRandom() % 2 ? 0x0000ff00 : 0) | 0xff; if (type->unk1c == 0x000000ff) { - type->unk1c |= 0x0000ff00 << ((random() % 3) * 8); + type->unk1c |= 0x0000ff00 << ((rngRandom() % 3) * 8); } - type->unk20 = (random() % 2 ? 0xff000000 : 0) | (random() % 2 ? 0x00ff0000 : 0) | (random() % 2 ? 0x0000ff00 : 0) | 0xff; + type->unk20 = (rngRandom() % 2 ? 0xff000000 : 0) | (rngRandom() % 2 ? 0x00ff0000 : 0) | (rngRandom() % 2 ? 0x0000ff00 : 0) | 0xff; if (type->unk20 == 0xff) { - type->unk20 |= 0x0000ff00 << ((random() % 3) * 8); + type->unk20 |= 0x0000ff00 << ((rngRandom() % 3) * 8); } } diff --git a/src/game/splat.c b/src/game/splat.c index ce9c6bb96..3bcc598c3 100644 --- a/src/game/splat.c +++ b/src/game/splat.c @@ -89,7 +89,7 @@ void splatTickChr(struct prop *prop) if (thudframe != -1.0f && modelGetCurAnimFrame(chr->model) < thudframe) { osSyncPrintf("SPLAT : Not Dead Enough %s%s%f", "", "", modelGetCurAnimFrame(chr->model)); } else if (chr->tickssincesplat > TICKS(30) && chr->deaddropsplatsadded < 6) { - chr->deaddropsplatsadded += splatsCreate(1, 1.1f, prop, NULL, 0, 0, isskedar, SPLATTYPE_PUDDLE, TICKS(150), attacker, random() & 8); + chr->deaddropsplatsadded += splatsCreate(1, 1.1f, prop, NULL, 0, 0, isskedar, SPLATTYPE_PUDDLE, TICKS(150), attacker, rngRandom() & 8); } } else { // Consider creating a wounded drop @@ -134,7 +134,7 @@ void splatsCreateForChrHit(struct prop *prop, struct shotdata *shotdata, struct } if (splattype == 0) { - u32 qty = random() % 3; + u32 qty = rngRandom() % 3; if (qty) { chr->stdsplatsadded += splatsCreate(qty, 0.8f, prop, shotdata, arg2, arg3, isskedar, splattype, TICKS(50), chr2, 0); @@ -424,7 +424,7 @@ void splat0f14986c(struct splatdata *splat) f32 distance; RoomNum smokerooms[2]; - texnum = WALLHITTEX_BLOOD1 + (random() % 3); + texnum = WALLHITTEX_BLOOD1 + (rngRandom() % 3); if (splat->objprop != NULL && splat->objprop->type == PROPTYPE_OBJ) { obj = splat->objprop->obj; @@ -437,14 +437,14 @@ void splat0f14986c(struct splatdata *splat) switch (splat->splattype) { case SPLATTYPE_PUDDLE: - texnum = WALLHITTEX_BLOOD1 + (random() % 3); + texnum = WALLHITTEX_BLOOD1 + (rngRandom() % 3); break; case SPLATTYPE_DROP: - texnum = WALLHITTEX_BLOOD4 + (random() % 1); + texnum = WALLHITTEX_BLOOD4 + (rngRandom() % 1); break; } - switch (random() % 6) { + switch (rngRandom() % 6) { case 0: case 1: case 2: @@ -501,7 +501,7 @@ void splat0f14986c(struct splatdata *splat) NULL, texnum, splat->room, splat->objprop, splat->chrprop, splat->mtxindex, 0, splat->chr, width, height, minalpha, maxalpha, - random() % 360, (u16)splat->timermax, splat->timerspeed, translucent); + rngRandom() % 360, (u16)splat->timermax, splat->timerspeed, translucent); if (sp88 || sp84) { smokerooms[0] = splat->room; diff --git a/src/game/training.c b/src/game/training.c index 5d2bac4d2..18ccbb18c 100644 --- a/src/game/training.c +++ b/src/game/training.c @@ -588,10 +588,10 @@ struct frdata *frGetData(void) u32 frResolveFrPad(u32 arg0) { switch (arg0) { - case 31: return random() % 9 + 4; // 4 - 12 - case 32: return random() % 9 + 13; // 13 - 21 - case 33: return random() % 9 + 22; // 22 - 30 - case 34: return random() % 27 + 4; // 4 - 30 + case 31: return rngRandom() % 9 + 4; // 4 - 12 + case 32: return rngRandom() % 9 + 13; // 13 - 21 + case 33: return rngRandom() % 9 + 22; // 22 - 30 + case 34: return rngRandom() % 27 + 4; // 4 - 30 } return g_FrData.padindexoffset + arg0; diff --git a/src/game/vtxstore.c b/src/game/vtxstore.c index 4999ea6de..d82b94304 100644 --- a/src/game/vtxstore.c +++ b/src/game/vtxstore.c @@ -189,7 +189,7 @@ void *vtxstoreAllocate(s32 count, s32 index, struct modelnode *node, s32 level) chrs[tally] = chr; tally++; } else { - rand = random() % tally; + rand = rngRandom() % tally; chrFadeCorpseWhenOffScreen(chrs[rand]); chrs[rand] = chr; } @@ -202,7 +202,7 @@ void *vtxstoreAllocate(s32 count, s32 index, struct modelnode *node, s32 level) rand = tally >> 1; while (rand) { - i = random() % tally; + i = rngRandom() % tally; if (chrs[i]) { chrFadeCorpseWhenOffScreen(chrs[i]); diff --git a/src/game/wallhit.c b/src/game/wallhit.c index 393dbb1b1..30284ec84 100644 --- a/src/game/wallhit.c +++ b/src/game/wallhit.c @@ -217,7 +217,7 @@ bool chrIsUsingPaintball(struct chrdata *chr) if (chr && chr->prop && chr->prop->type == PROPTYPE_PLAYER) { setCurrentPlayerNum(playermgrGetPlayerNumByProp(chr->prop)); } else { - setCurrentPlayerNum(random() % PLAYERCOUNT()); + setCurrentPlayerNum(rngRandom() % PLAYERCOUNT()); } paintball = optionsGetPaintball(g_Vars.currentplayerstats->mpindex); @@ -720,7 +720,7 @@ void wallhitCreateWith20Args(struct coord *relpos, struct coord *arg1, struct co case WALLHITTEX_SCORCH: case WALLHITTEX_PAINT: case WALLHITTEX_WOOD: - rotdeg = random() % 360; + rotdeg = rngRandom() % 360; break; } @@ -741,7 +741,7 @@ void wallhitCreateWith20Args(struct coord *relpos, struct coord *arg1, struct co default: case WALLHITTEX_SCORCH: case WALLHITTEX_WOOD: - rotdeg = random() % 360; + rotdeg = rngRandom() % 360; break; } @@ -751,7 +751,7 @@ void wallhitCreateWith20Args(struct coord *relpos, struct coord *arg1, struct co height = 15.0f; } - rotdeg = random() % 360; + rotdeg = rngRandom() % 360; type = WALLHITTYPE_PAINT; timermax = TICKS(10); } else { @@ -1083,7 +1083,7 @@ void wallhitCreateWith20Args(struct coord *relpos, struct coord *arg1, struct co range = maxalpha - (u32)minalpha; if (range) { - alpha = minalpha + (random() % range); + alpha = minalpha + (rngRandom() % range); } else { alpha = 0; } @@ -1091,16 +1091,16 @@ void wallhitCreateWith20Args(struct coord *relpos, struct coord *arg1, struct co for (i = 0; i < ARRAYCOUNT(wallhit->basecolours); i++) { switch (type) { case WALLHITTYPE_BULLET: - r = g = b = 255 - (random() % 40); + r = g = b = 255 - (rngRandom() % 40); a = alpha ? alpha : 255; break; case WALLHITTYPE_SOFT: - r = g = b = random() % 70; - a = alpha ? alpha : 255 - (random() % 50); + r = g = b = rngRandom() % 70; + a = alpha ? alpha : 255 - (rngRandom() % 50); break; case WALLHITTYPE_SCORCH: - r = g = b = random() % 50; - a = alpha ? alpha : 255 - (random() % 80); + r = g = b = rngRandom() % 50; + a = alpha ? alpha : 255 - (rngRandom() % 80); break; case WALLHITTYPE_BLOOD: r = g_WallhitBloodColour[0]; @@ -1109,9 +1109,9 @@ void wallhitCreateWith20Args(struct coord *relpos, struct coord *arg1, struct co a = alpha ? alpha : 255; break; case WALLHITTYPE_PAINT: - r = (random() % 2) ? 0xff : 0; - g = (random() % 2) ? 0xff : 0; - b = (random() % 2) ? 0xff : 0; + r = (rngRandom() % 2) ? 0xff : 0; + g = (rngRandom() % 2) ? 0xff : 0; + b = (rngRandom() % 2) ? 0xff : 0; a = alpha ? alpha : 255; break; default: @@ -1486,7 +1486,7 @@ void wallhitFadeSplatsForRemovedChr(struct prop *chrprop) && wallhit->roomnum > 0 && wallhit->chrprop == chrprop && g_WallhitTexes[wallhit->texturenum].type == WALLHITTYPE_BLOOD) { - if (IS_BLOOD_DROP(wallhit->texturenum) || (random() % 100) < 35) { + if (IS_BLOOD_DROP(wallhit->texturenum) || (rngRandom() % 100) < 35) { wallhitFade(wallhit, TICKS(120)); } else { wallhit->createdframe = g_Vars.lvframenum; diff --git a/src/game/weather.c b/src/game/weather.c index 9a95769d6..6d1416696 100644 --- a/src/game/weather.c +++ b/src/game/weather.c @@ -311,10 +311,10 @@ struct weatherparticledata *weatherAllocateParticles(void) void func0f131610(struct weatherdata *weather) { weather->unk94 = 0; - weather->unk98 = (random() & 7) + 1; - weather->unk9c = (random() & 7) + 1; - weather->unka0 = (random() & 7) + 1; - weather->unka4 = (random() & 0xf) + 10; + weather->unk98 = (rngRandom() & 7) + 1; + weather->unk9c = (rngRandom() & 7) + 1; + weather->unka0 = (rngRandom() & 7) + 1; + weather->unka4 = (rngRandom() & 0xf) + 10; } void func0f131678(s32 arg0) diff --git a/src/include/constants.h b/src/include/constants.h index 2fd08e73f..54cfee47d 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -70,7 +70,7 @@ #define LINEHEIGHT (VERSION == VERSION_JPN_FINAL ? 14 : 11) #define MIXCOLOUR(dialog, property) dialog->transitionfrac < 0.0f ? g_MenuColours[dialog->type].property : colourBlend(g_MenuColours[dialog->type2].property, g_MenuColours[dialog->type].property, dialog->colourweight) #define MPCHR(index) ((index) < MAX_PLAYERS ? &g_PlayerConfigsArray[index].base : &g_BotConfigsArray[(index) - MAX_PLAYERS].base) -#define RANDOMFRAC() (random() * (1.0f / U32_MAX)) +#define RANDOMFRAC() (rngRandom() * (1.0f / U32_MAX)) #define SECSTOTIME240(secs) (secs * 240) #define SECSTOTIME60(secs) (secs * 60) #define PFS(device) (device == SAVEDEVICE_GAMEPAK ? NULL : &g_Pfses[device]) diff --git a/src/include/lib/rng.h b/src/include/lib/rng.h index 32741640f..647c496a5 100644 --- a/src/include/lib/rng.h +++ b/src/include/lib/rng.h @@ -4,7 +4,7 @@ #include "data.h" #include "types.h" -u32 random(void); +u32 rngRandom(void); u32 rngRotateSeed(u64 *value); #endif diff --git a/src/lib/model.c b/src/lib/model.c index 929f5c7b4..7ad23e2b1 100644 --- a/src/lib/model.c +++ b/src/lib/model.c @@ -3296,11 +3296,11 @@ void modelRenderNodeStarGunfire(struct modelrenderdata *renderdata, struct model gSPDisplayList(renderdata->gdl++, rodata->gdl); for (i = 0; i < rodata->unk00; i++) { - u16 rand1 = (random() << 10) & 0xffff; + u16 rand1 = (rngRandom() << 10) & 0xffff; s32 s4 = ((coss(rand1) << 5) * 181) >> 18; s32 s3 = ((sins(rand1) << 5) * 181) >> 18; - s32 s1 = random() >> 31; - s32 mult = 0x10000 - (random() & 0x3fff); + s32 s1 = rngRandom() >> 31; + s32 mult = 0x10000 - (rngRandom() & 0x3fff); s32 corner1 = 0x200 + s3; s32 corner2 = 0x200 - s3; s32 corner3 = 0x200 - s4; @@ -3414,7 +3414,7 @@ void modelRenderNodeChrGunfire(struct modelrenderdata *renderdata, struct model rot2 = cosf(spec); spd0 = sinf(spec); - scale = 0.75f + (random() % 128) * (1.0f / 256.0f); // 0.75 to 1.25 + scale = 0.75f + (rngRandom() % 128) * (1.0f / 256.0f); // 0.75 to 1.25 sp9c.f[0] = rodata->dim.f[0] * scale; sp9c.f[1] = rodata->dim.f[1] * scale; @@ -3469,7 +3469,7 @@ void modelRenderNodeChrGunfire(struct modelrenderdata *renderdata, struct model tconfig = rodata->texture; - sp62 = (random() * 1024) & 0xffff; + sp62 = (rngRandom() * 1024) & 0xffff; sp5c = (coss(sp62) * tconfig->width * 0xb5) >> 18; sp58 = (sins(sp62) * tconfig->width * 0xb5) >> 18; diff --git a/src/lib/rng_c.c b/src/lib/rng_c.c index 6bee7e7f3..23ff7b619 100644 --- a/src/lib/rng_c.c +++ b/src/lib/rng_c.c @@ -10,7 +10,7 @@ u64 g_RngSeed = 0xab8d9f7781280783; /** * Generate a random number between 0 and 4294967295. */ -u32 random(void) +u32 rngRandom(void) { g_RngSeed = ((g_RngSeed << 63) >> 31 | (g_RngSeed << 31) >> 32) ^ (g_RngSeed << 44) >> 32; g_RngSeed = ((g_RngSeed >> 20) & 0xfff) ^ g_RngSeed; @@ -27,7 +27,7 @@ void rngSetSeed(u64 seed) } /** - * Rotate the given seed using the same algorithm as random(). + * Rotate the given seed using the same algorithm as rngRandom(). * * Store the new 64-bit seed at the pointed address and return the same seed * cast as a u32. diff --git a/src/lib/snd.c b/src/lib/snd.c index ed76b4afa..61d66b726 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -1888,7 +1888,7 @@ void sndTick(void) if (g_SndCurMp3.responsetimer240 <= 0) { if (g_SndCurMp3.responsetype == MP3RESPONSETYPE_WHISPER) { do { - index = random() % 4; + index = rngRandom() % 4; } while (index == g_SndCurMp3.prevwhisper); g_SndCurMp3.prevwhisper = index; @@ -1901,7 +1901,7 @@ void sndTick(void) } } else if (g_SndCurMp3.responsetype == MP3RESPONSETYPE_ACKNOWLEDGE) { do { - index = random() % 4; + index = rngRandom() % 4; } while (index == g_SndCurMp3.prevacknowledge); g_SndCurMp3.prevacknowledge = index; @@ -1914,7 +1914,7 @@ void sndTick(void) } } else if (g_SndCurMp3.responsetype == MP3RESPONSETYPE_GREETING) { do { - index = random() % 4; + index = rngRandom() % 4; } while (index == g_SndCurMp3.prevgreeting); g_SndCurMp3.prevgreeting = index;