From 7ca70d496dfdcab4a4132eb1e02887d7a1715637 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Sun, 19 Jun 2022 04:14:55 +0100 Subject: [PATCH] Change `Rand_Next` to `u32`, document `rand.c` a bit more (#819) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change Rand_Next to u32, document rand.c a bit more * Clean up the quotes a bit, add another note * Format * — -> - * Review * Remove unnecessary casts * Remove quote, reformat the comments * Fix new files * Make docs a bit more consistent and specific * Format --- include/functions.h | 2 +- src/boot_O2/rand.c | 60 +++++++++++-------- src/code/sys_math_atan.c | 48 +++++++-------- src/code/z_actor.c | 2 +- .../ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c | 6 +- .../ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 4 +- .../z_bg_dblue_waterfall.c | 2 +- .../z_bg_hakugin_bombwall.c | 16 ++--- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 14 ++--- src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c | 4 +- src/overlays/actors/ovl_En_Bb/z_en_bb.c | 2 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 4 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 20 +++---- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 4 +- src/overlays/actors/ovl_En_Famos/z_en_famos.c | 25 ++++---- src/overlays/actors/ovl_En_Fish/z_en_fish.c | 8 +-- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.c | 2 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 10 ++-- .../actors/ovl_En_Hakurock/z_en_hakurock.c | 20 +++---- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 6 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 2 +- src/overlays/actors/ovl_En_Kame/z_en_kame.c | 2 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 4 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 12 ++-- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 54 ++++++++--------- .../actors/ovl_En_Minislime/z_en_minislime.c | 12 ++-- .../actors/ovl_En_Mushi2/z_en_mushi2.c | 8 +-- .../actors/ovl_En_Peehat/z_en_peehat.c | 2 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 2 +- .../actors/ovl_En_Snowman/z_en_snowman.c | 8 +-- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 2 +- .../actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c | 4 +- .../actors/ovl_Obj_Dhouse/z_obj_dhouse.c | 36 +++++------ .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 12 ++-- .../actors/ovl_Obj_Grass/z_obj_grass.c | 10 ++-- .../actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c | 2 +- .../actors/ovl_Obj_Hamishi/z_obj_hamishi.c | 2 +- .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 4 +- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.c | 6 +- .../actors/ovl_Obj_Kibako2/z_obj_kibako2.c | 2 +- .../actors/ovl_Obj_Snowball/z_obj_snowball.c | 10 ++-- .../ovl_Obj_Snowball2/z_obj_snowball2.c | 10 ++-- 43 files changed, 239 insertions(+), 228 deletions(-) diff --git a/include/functions.h b/include/functions.h index 92db30a010..7e01d5afe5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -171,7 +171,7 @@ f64 func_80086D6C(f64 param_1); s32 func_80086D8C(f32 param_1); s32 func_80086DAC(f64 param_1); -s32 Rand_Next(void); +u32 Rand_Next(void); void Rand_Seed(u32 seed); f32 Rand_ZeroOne(void); f32 Rand_Centered(void); diff --git a/src/boot_O2/rand.c b/src/boot_O2/rand.c index de603590eb..2db64e9d57 100644 --- a/src/boot_O2/rand.c +++ b/src/boot_O2/rand.c @@ -1,33 +1,39 @@ #include "global.h" -// The latest generated random number, used to generate the next number in the sequence. +//! The latest generated random number, used to generate the next number in the sequence. static u32 sRandInt = 1; -// Space to store a value to be re-interpreted as a float. -// This can't be static because it is used in z_kankyo +//! Space to store a value to be re-interpreted as a float. +//! This can't be static because it is used in z_kankyo. u32 sRandFloat; +//! These values are recommended by the algorithms book *Numerical Recipes in C. The Art of Scientific Computing*, 2nd +//! Edition, 1992, ISBN 0-521-43108-5. (p. 284): +//! > This is about as good as any 32-bit linear congruential generator, entirely adequate for many uses. #define RAND_MULTIPLIER 1664525 #define RAND_INCREMENT 1013904223 /** - * Gets the next integer in the sequence of pseudo-random numbers. + * Generates the next pseudo-random integer. */ -s32 Rand_Next(void) { - return sRandInt = (sRandInt * 1664525) + 1013904223; +u32 Rand_Next(void) { + return sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; } /** - * Seeds the pseudo-random number generator by providing a starting value. + * Seeds the internal pseudo-random number generator with a provided starting value. */ void Rand_Seed(u32 seed) { sRandInt = seed; } /** - * Returns a pseudo-random floating-point number between 0.0f and 1.0f, by generating - * the next integer and masking it to an IEEE-754 compliant floating-point number - * between 1.0f and 2.0f, returning the result subtract 1.0f. + * Returns a pseudo-random float between 0.0f and 1.0f from the internal PRNG. + * + * @note Works by generating the next integer, masking it to an IEEE-754 compliant float between 1.0f and 2.0f, and + * subtracting 1.0f. + * + * @remark This is also recommended by Numerical Recipes, pp. 284-5. */ f32 Rand_ZeroOne(void) { sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; @@ -36,8 +42,7 @@ f32 Rand_ZeroOne(void) { } /** - * Returns a pseudo-random floating-point number between -0.5f and 0.5f by the same - * manner in which Rand_ZeroOne generates its result. + * Returns a pseudo-random float between -0.5f and 0.5f in the same way as Rand_ZeroOne(). */ f32 Rand_Centered(void) { sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; @@ -45,40 +50,47 @@ f32 Rand_Centered(void) { return *((f32*)&sRandFloat) - 1.5f; } +//! All functions below are unused variants of the above four, that use a provided random number variable instead of the +//! internal `sRandInt` + /** - * Seeds a pseudo-random number at rndNum with a provided seed. + * Seeds a provided pseudo-random number with a provided starting value. + * + * @see Rand_Seed */ void Rand_Seed_Variable(u32* rndNum, u32 seed) { *rndNum = seed; } /** - * Generates the next pseudo-random integer from the provided rndNum. + * Generates the next pseudo-random number from the provided rndNum. + * + * @see Rand_Next */ u32 Rand_Next_Variable(u32* rndNum) { return *rndNum = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; } /** - * Generates the next pseudo-random floating-point number between 0.0f and - * 1.0f from the provided rndNum. + * Generates the next pseudo-random float between 0.0f and 1.0f from the provided rndNum. + * + * @see Rand_ZeroOne */ f32 Rand_ZeroOne_Variable(u32* rndNum) { u32 next = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; - // clang-format off - *rndNum = next; sRandFloat = (next >> 9) | 0x3F800000; - // clang-format on + + sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000; return *((f32*)&sRandFloat) - 1.0f; } /** - * Generates the next pseudo-random floating-point number between -0.5f and - * 0.5f from the provided rndNum. + * Generates the next pseudo-random float between -0.5f and 0.5f from the provided rndNum. + * + * @see Rand_ZeroOne, Rand_Centered */ f32 Rand_Centered_Variable(u32* rndNum) { u32 next = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; - // clang-format off - *rndNum = next; sRandFloat = (next >> 9) | 0x3F800000; - // clang-format on + + sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000; return *((f32*)&sRandFloat) - 1.5f; } diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.c index 09f355d64d..d68e1e293a 100644 --- a/src/code/sys_math_atan.c +++ b/src/code/sys_math_atan.c @@ -77,57 +77,57 @@ u16 sATan2Tbl[] = { 0x1FF6, 0x1FFB, 0x2000, }; -u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent) { - return sATan2Tbl[(s32)((opposite / adjacent) * 0x400)]; +u16 Math_GetAtan2Tbl(f32 y, f32 x) { + return sATan2Tbl[(s32)((y / x) * 0x400)]; } -s16 Math_Atan2S(f32 opposite, f32 adjacent) { +s16 Math_Atan2S(f32 y, f32 x) { s32 angle; - if (opposite == 0.0f) { - if (adjacent >= 0.0f) { + if (y == 0.0f) { + if (x >= 0.0f) { angle = 0; } else { angle = 0x8000; } - } else if (adjacent == 0.0f) { - if (opposite >= 0.0f) { + } else if (x == 0.0f) { + if (y >= 0.0f) { angle = 0x4000; } else { angle = 0xC000; } - } else if (opposite >= 0.0f) { - if (adjacent >= 0.0f) { - if (opposite <= adjacent) { - angle = Math_GetAtan2Tbl(opposite, adjacent); + } else if (y >= 0.0f) { + if (x >= 0.0f) { + if (y <= x) { + angle = Math_GetAtan2Tbl(y, x); } else { - angle = 0x4000 - Math_GetAtan2Tbl(adjacent, opposite); + angle = 0x4000 - Math_GetAtan2Tbl(x, y); } } else { - if (-adjacent < opposite) { - angle = Math_GetAtan2Tbl(-adjacent, opposite) + 0x4000; + if (-x < y) { + angle = Math_GetAtan2Tbl(-x, y) + 0x4000; } else { - angle = 0x8000 - Math_GetAtan2Tbl(opposite, -adjacent); + angle = 0x8000 - Math_GetAtan2Tbl(y, -x); } } - } else if (adjacent < 0.0f) { - if (-opposite <= -adjacent) { - angle = Math_GetAtan2Tbl(-opposite, -adjacent) + 0x8000; + } else if (x < 0.0f) { + if (-y <= -x) { + angle = Math_GetAtan2Tbl(-y, -x) + 0x8000; } else { - angle = 0xC000 - Math_GetAtan2Tbl(-adjacent, -opposite); + angle = 0xC000 - Math_GetAtan2Tbl(-x, -y); } } else { - if (adjacent < -opposite) { - angle = Math_GetAtan2Tbl(adjacent, -opposite) + 0xC000; + if (x < -y) { + angle = Math_GetAtan2Tbl(x, -y) + 0xC000; } else { - angle = -Math_GetAtan2Tbl(-opposite, adjacent); + angle = -Math_GetAtan2Tbl(-y, x); } } return angle; } -f32 Math_Atan2F(f32 opposite, f32 adjacent) { - return Math_Atan2S(opposite, adjacent) * (M_PI / 0x8000); +f32 Math_Atan2F(f32 y, f32 x) { + return Math_Atan2S(y, x) * (M_PI / 0x8000); } s16 Math_FAtan2F(f32 adjacent, f32 opposite) { diff --git a/src/code/z_actor.c b/src/code/z_actor.c index bbabeafd5a..4e1e641dea 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4782,7 +4782,7 @@ void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos yaw = Actor_YawToPoint(actor, limbPos); for (j = 0; j < effectsPerLimb; j++) { - randomYaw = (Rand_Next() >> 0x13) + yaw; + randomYaw = ((s32)Rand_Next() >> 0x13) + yaw; velocity.z = Rand_ZeroFloat(5.0f); diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index 6ac390ce57..2bcc31b5bf 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -78,7 +78,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { Matrix_RotateXS(this->dyna.actor.home.rot.x, MTXMODE_APPLY); Matrix_RotateZS(this->dyna.actor.home.rot.z, MTXMODE_APPLY); for (i = 0; i < 4; i++) { - if ((u32)Rand_Next() >= 0x40000000) { + if (Rand_Next() >= 0x40000000) { splashOffset.x = sExitSplashOffsets[i].x - (Rand_ZeroOne() * 30.0f); splashOffset.y = sExitSplashOffsets[i].y; splashOffset.z = sExitSplashOffsets[i].z; @@ -86,7 +86,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); - EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, ((u32)Rand_Next() >> 25) + 340); + EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 340); } } } @@ -104,7 +104,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); - EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, ((u32)Rand_Next() >> 25) + 280); + EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 280); } } } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 0c5b92496a..da39431410 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -276,7 +276,7 @@ void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { for (i = 0; i < ARRAY_COUNT(D_80B83A94); i++) { temp_f0 = Rand_ZeroOne(); temp_f20 = 1.0f - SQ(temp_f0); - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { temp_f20 = -temp_f20; } @@ -285,7 +285,7 @@ void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { temp_f0 = Rand_ZeroOne(); temp_f20 = 1.0f - SQ(temp_f0); - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { temp_f20 = -temp_f20; } sp60.z = (temp_f20 * arg2) + arg1->z; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index fcec4ebb39..a9777972d5 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -295,7 +295,7 @@ void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { if (this->unk_1A7 <= 0) { this->unk_1A7 = 16; } else { - this->unk_1A7 -= (s8)((u32)Rand_Next() >> 0x1F); + this->unk_1A7 -= (s8)(Rand_Next() >> 0x1F); } if (this->unk_1A7 >= 6) { diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index 20d68e7a47..1103c6d815 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -138,7 +138,7 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { for (i = 0; i < 6; i++) { temp = (i + 1) * (80.0f / 3.0f); for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { - spD8.x = D_80ABD020[j] + (s32)((u32)Rand_Next() >> 0x1C); + spD8.x = D_80ABD020[j] + (s32)(Rand_Next() >> 0x1C); spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + temp; spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; @@ -159,11 +159,11 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { phi_s0 = 64; } - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 |= 1; phi_s1 = 1; func_800B0E48(globalCtx, &spF0, &gZeroVec3f, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, - ((u32)Rand_Next() >> 0x1B) + 70, ((u32)Rand_Next() >> 0x1A) + 60); + (Rand_Next() >> 0x1B) + 70, (Rand_Next() >> 0x1A) + 60); } else { phi_s1 = 0; } @@ -224,7 +224,7 @@ void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { if ((i & 1) == 0) { func_800B0E48(globalCtx, &spC8, &D_80ABD034, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, - ((u32)Rand_Next() >> 0x1B) + 60, ((u32)Rand_Next() >> 0x1A) + 50); + (Rand_Next() >> 0x1B) + 60, (Rand_Next() >> 0x1A) + 50); } } } @@ -269,8 +269,8 @@ void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { spC0.y += this->dyna.actor.world.pos.y; spC0.z += this->dyna.actor.world.pos.z; - func_800B0E48(globalCtx, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, - ((u32)Rand_Next() >> 0x1B) + 60); + func_800B0E48(globalCtx, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1A) + 60, + (Rand_Next() >> 0x1B) + 60); } } @@ -303,8 +303,8 @@ void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx) { spB8.x = spAC.x * -0.095f; spB8.z = spAC.z * -0.095f; - func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, - ((u32)Rand_Next() >> 0x1B) + 60); + func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1A) + 60, + (Rand_Next() >> 0x1B) + 60); } } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index a7f20b7b48..f0831055f8 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -343,9 +343,9 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU temp_f0 = spAC.z; unkStruct2->unk_10.z = ((Rand_ZeroOne() * 60.0f - 30.0f) + temp_f28 * 50.0f) * temp_f22 + temp_f0 * temp_f20; unkStruct2->unk_1C = 0.90999997f - (0.04f - unkStruct2->unk_00) * (500.0f / 19.0f) * 0.02f; - unkStruct2->unk_20.x = Rand_Next() >> 0x10; - unkStruct2->unk_20.y = Rand_Next() >> 0x10; - unkStruct2->unk_20.z = Rand_Next() >> 0x10; + unkStruct2->unk_20.x = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.y = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.z = (s32)Rand_Next() >> 0x10; unkStruct2->unk_26 = (Rand_Next() & 0x3FFF) - 0x1FFF; unkStruct2->unk_28 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_2A = (Rand_Next() & 0x1FFF) - 0xFFF; @@ -359,7 +359,7 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU spA0.y = (Rand_ZeroOne() * 1.2f - 0.1f) * spE4 + spB8.y; spA0.z = Math_CosS(val) * temp_f20 + spB8.z; func_800B0E48(globalCtx, &spA0, &gZeroVec3f, &D_80A9D8EC, &D_80A9D8E4, &D_80A9D8E8, - (Rand_Next() >> 0x1A) + 0x82, (Rand_Next() >> 0x1A) + 0x6E); + ((s32)Rand_Next() >> 0x1A) + 0x82, ((s32)Rand_Next() >> 0x1A) + 0x6E); } unkStruct1Temp = func_80A9B32C(unkStruct, unkStruct1); @@ -386,9 +386,9 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU unkStruct2->unk_10.y = 0.0f; unkStruct2->unk_10.z = Rand_ZeroOne() + temp_f28 * 7.0f; unkStruct2->unk_1C = 0.90999997f - (0.04f - unkStruct2->unk_00) * (500.0f / 19.0f) * 0.075f; - unkStruct2->unk_20.x = Rand_Next() >> 0x10; - unkStruct2->unk_20.y = Rand_Next() >> 0x10; - unkStruct2->unk_20.z = Rand_Next() >> 0x10; + unkStruct2->unk_20.x = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.y = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.z = (s32)Rand_Next() >> 0x10; unkStruct2->unk_26 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_28 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_2A = (Rand_Next() & 0x1FFF) - 0xFFF; diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 71f1d2b6a4..ccf8e2d430 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -47,7 +47,7 @@ void BgLotus_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &thisx->floorPoly, &bgId, &this->dyna.actor, &this->dyna.actor.world.pos); this->timer2 = 96; - this->dyna.actor.world.rot.y = Rand_Next() >> 0x10; + this->dyna.actor.world.rot.y = (s32)Rand_Next() >> 0x10; this->actionFunc = BgLotus_Wait; } @@ -82,7 +82,7 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { if (this->timer2 == 0) { this->timer2 = 96; - this->dyna.actor.world.rot.y += (s16)(Rand_Next() >> 0x12); + this->dyna.actor.world.rot.y += (s16)((s32)Rand_Next() >> 0x12); } } diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index f48976cd6b..65d582eb36 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -241,7 +241,7 @@ void EnBb_SetupFlyIdle(EnBb* this) { if ((this->actor.xzDistToPlayer < (this->attackRange + 120.0f)) || (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 300.0f)) { - this->targetYRotation += (s16)(Rand_Next() >> 0x11); + this->targetYRotation += (s16)((s32)Rand_Next() >> 0x11); } this->collider.base.atFlags |= AT_ON; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index acf465f83f..4c4261a4c4 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -505,7 +505,7 @@ void EnBigpo_WarpingOut(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 distance = CLAMP_MIN(this->actor.xzDistToPlayer, 200.0f); - s16 randomYaw = (Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; + s16 randomYaw = ((s32)Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); Animation_PlayLoop(&this->skelAnime, &gBigpoAwakenStretchAnim); @@ -565,7 +565,7 @@ void EnBigpo_IdleFlying(EnBigpo* this, GlobalContext* globalCtx) { } if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk208, 0x200) && (Rand_ZeroOne() < 0.075f)) { - this->unk208 += (s16)((((u32)Rand_Next() >> 0x14) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + this->unk208 += (s16)(((Rand_Next() >> 0x14) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); } this->actor.world.rot.y = this->actor.shape.rot.y; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 1a507b5b6b..0e3c9b20ae 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -2089,9 +2089,9 @@ void EnBigslime_SetupIdleLookAround(EnBigslime* this) { this->idleTimer = 60; this->actor.speedXZ = 0.0f; if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { - this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { - this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; } this->actionFunc = EnBigslime_IdleLookAround; } @@ -2111,9 +2111,9 @@ void EnBigslime_IdleLookAround(EnBigslime* this, GlobalContext* globalCtx) { if ((this->skelAnime.animation == &gGekkoNervousIdleAnim) && Math_ScaledStepToS(&this->gekkoRot.y, this->gekkoYaw, 0x400)) { if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { - this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { - this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; } } @@ -2700,9 +2700,9 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { iceShardEffect->pos.x = (targetVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; iceShardEffect->pos.y = (targetVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; iceShardEffect->pos.z = (targetVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; - iceShardEffect->rotation.x = Rand_Next() >> 0x10; - iceShardEffect->rotation.y = Rand_Next() >> 0x10; - iceShardEffect->rotation.z = Rand_Next() >> 0x10; + iceShardEffect->rotation.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.z = (s32)Rand_Next() >> 0x10; iceShardEffect->isActive = true; randPitch = Rand_S16Offset(0x1000, 0x3000); vtxZ = targetVtx->n.ob[2]; @@ -2742,9 +2742,9 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { if (iceShardEffect->pos.y < (GBT_ROOM_5_MIN_Y - 20.0f)) { iceShardEffect->isActive = false; } - iceShardEffect->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); - iceShardEffect->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); - iceShardEffect->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + iceShardEffect->rotation.x += (s16)((Rand_Next() >> 0x17) + 0x700); + iceShardEffect->rotation.y += (s16)((Rand_Next() >> 0x17) + 0x900); + iceShardEffect->rotation.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 914ee2bcaa..c31b534a19 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -449,7 +449,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f20; Math_Vec3f_Copy(&sp68, &this->limbPos[0]); - sp66 = (Rand_Next() >> 0x12) + this->actor.shape.rot.y; + sp66 = ((s32)Rand_Next() >> 0x12) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); @@ -482,7 +482,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp62 = this->unk_334 * 25.0f; func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); - sp66 = ((u32)Rand_Next() >> 0x13) + this->actor.shape.rot.y; + sp66 = (Rand_Next() >> 0x13) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index 42ff95aba7..32ce1988f1 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -226,15 +226,15 @@ void EnFamos_SetupAttackDebris(EnFamos* this) { this->debrisTimer = 40; rock = &this->rocks[0]; for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { - randVelDirection = Rand_Next() >> 0x10; + randVelDirection = (s32)Rand_Next() >> 0x10; randOffset = Rand_S16Offset(0x1800, 0x2800); randFloat = Rand_ZeroFloat(5.0f) + 5.0f; rock->velocity.x = randFloat * Math_CosS(randOffset) * Math_SinS(randVelDirection); rock->velocity.y = Math_SinS(randOffset) * randFloat + 3.0f; rock->velocity.z = randFloat * Math_CosS(randOffset) * Math_CosS(randVelDirection); - rock->rotation.x = Rand_Next() >> 0x10; - rock->rotation.y = Rand_Next() >> 0x10; - rock->rotation.z = Rand_Next() >> 0x10; + rock->rotation.x = (s32)Rand_Next() >> 0x10; + rock->rotation.y = (s32)Rand_Next() >> 0x10; + rock->rotation.z = (s32)Rand_Next() >> 0x10; rock->pos.x = (Math_SinS(randVelDirection) * 20.0f) + this->actor.world.pos.x; rock->pos.y = this->actor.floorHeight; rock->pos.z = (Math_CosS(randVelDirection) * 20.0f) + this->actor.world.pos.z; @@ -255,15 +255,15 @@ void EnFamos_SetupDeathDebris(EnFamos* this) { this->debrisTimer = 40; rock = &this->rocks[0]; for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { - randVelDirection = Rand_Next() >> 0x10; - randSmaller = (u32)Rand_Next() >> 0x12; + randVelDirection = (s32)Rand_Next() >> 0x10; + randSmaller = Rand_Next() >> 0x12; randFloat = Rand_ZeroFloat(6.0f) + 7.0f; rock->velocity.x = randFloat * Math_CosS(randSmaller) * Math_SinS(randVelDirection); rock->velocity.y = Math_SinS(randSmaller) * randFloat + 4.5f; rock->velocity.z = randFloat * Math_CosS(randSmaller) * Math_CosS(randVelDirection); - rock->rotation.x = Rand_Next() >> 0x10; - rock->rotation.y = Rand_Next() >> 0x10; - rock->rotation.z = Rand_Next() >> 0x10; + rock->rotation.x = (s32)Rand_Next() >> 0x10; + rock->rotation.y = (s32)Rand_Next() >> 0x10; + rock->rotation.z = (s32)Rand_Next() >> 0x10; rock->pos.x = Math_SinS(randVelDirection) * 20.0f + this->actor.world.pos.x; rock->pos.y = randPlusMinusPoint5Scaled(60.0f) + (this->actor.world.pos.y + 40.0f); rock->pos.z = Math_CosS(randVelDirection) * 20.0f + this->actor.world.pos.z; @@ -735,10 +735,9 @@ void EnFamos_UpdateDebrisPosRot(EnFamos* this) { for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { rock->velocity.y -= 1.0f; Math_Vec3f_Sum(&rock->pos, &rock->velocity, &rock->pos); - // all casts seem required - rock->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); - rock->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); - rock->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + rock->rotation.x += (s16)((Rand_Next() >> 0x17) + 0x700); + rock->rotation.y += (s16)((Rand_Next() >> 0x17) + 0x900); + rock->rotation.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index 6c9f813fd5..d456f48edb 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -210,8 +210,8 @@ void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); this->actor.colChkInfo.mass = this->unk_25C * 30.0f; - this->unk_244 = (u32)Rand_Next() >> 0x10; - this->unk_246 = (u32)Rand_Next() >> 0x10; + this->unk_244 = Rand_Next() >> 0x10; + this->unk_246 = Rand_Next() >> 0x10; if (sp36 == ENFISH_0) { this->actor.flags |= ACTOR_FLAG_10; @@ -707,12 +707,12 @@ void func_8091EFE8(Actor* thisx, GlobalContext* globalCtx) { this->actor.speedXZ *= 0.5f; } - if (!((u32)Rand_Next() >> 0x1B) || ((this->actor.bgCheckFlags & 8) && !((u32)Rand_Next() >> 0x1E)) || + if (((Rand_Next() >> 0x1B) == 0) || ((this->actor.bgCheckFlags & 8) && ((Rand_Next() >> 0x1E) == 0)) || !(this->actor.bgCheckFlags & 0x20)) { temp_f0 = Rand_ZeroOne(); sp34 = (1.0f - SQ(temp_f0)) * sp3C->home.rot.x; sp30 = Rand_ZeroOne() * sp3C->home.rot.z; - sp2E = (u32)Rand_Next() >> 0x10; + sp2E = Rand_Next() >> 0x10; this->actor.home.pos.x = (Math_SinS(sp2E) * sp34) + sp3C->world.pos.x; this->actor.home.pos.y = sp3C->world.pos.y + sp30; this->actor.home.pos.z = (Math_CosS(sp2E) * sp34) + sp3C->world.pos.z; diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index 4591eab65e..7fe1d6e58c 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -201,7 +201,7 @@ void func_80ACE850(EnFuMato* this, GlobalContext* globalCtx) { s32 phi_s2; s32 i; - this->unk_308 = (u32)Rand_Next() % ARRAY_COUNT(this->unk_1B8); + this->unk_308 = Rand_Next() % ARRAY_COUNT(this->unk_1B8); this->unk_302 = 1; this->dyna.actor.gravity = -1.0f; this->dyna.actor.velocity.y = Rand_ZeroOne(); diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index f17a75f6a1..e4b8225468 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -599,7 +599,7 @@ void func_8093FC6C(EnGoroiwa* this, GlobalContext* globalCtx) { temp = 0x10000 / sp80; for (i = 0, phi_s0 = 0; i < sp80; i++, phi_s0 += temp) { - temp_s3 = (u32)Rand_Next() >> 0x10; + temp_s3 = Rand_Next() >> 0x10; temp_f20 = Math_SinS(temp_s3); temp_f22 = Math_CosS(temp_s3); @@ -701,7 +701,7 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { phi_s1 = D_80942E0C[sp120][0]; phi_s3 = 1; phi_f22 = 0.8f; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -779,7 +779,7 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB phi_s7 = arg2[0]; phi_fp = -0x190; spC8 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -856,7 +856,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA if ((i & 3) == 1) { phi_s1 = arg2[1]; phi_s2 = -0x154; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -864,7 +864,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA } else { phi_s1 = arg2[0]; phi_s2 = -0x190; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index d8551103d4..63da6c3296 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -102,7 +102,7 @@ void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2) { Math_Vec3f_Copy(&gohtParticle->unk_0, arg1); sp2C = Rand_S16Offset(0x1000, 0x3000); - sp2E = (u32)Rand_Next() >> 0x10; + sp2E = Rand_Next() >> 0x10; sp28 = Rand_ZeroFloat(5.0f) + 10.0f; gohtParticle->unk_C.x = (sp28 * Math_CosS(sp2C)) * Math_SinS(sp2E); gohtParticle->unk_C.y = (Math_SinS(sp2C) * sp28); @@ -120,9 +120,9 @@ void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2) { gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.z) + arg1->z; gohtParticle->unk_1A = 0; } - gohtParticle->unk_1C.x = Rand_Next() >> 0x10; - gohtParticle->unk_1C.y = Rand_Next() >> 0x10; - gohtParticle->unk_1C.z = Rand_Next() >> 0x10; + gohtParticle->unk_1C.x = (s32)Rand_Next() >> 0x10; + gohtParticle->unk_1C.y = (s32)Rand_Next() >> 0x10; + gohtParticle->unk_1C.z = (s32)Rand_Next() >> 0x10; gohtParticle->unk_18 = 0x28; return; } @@ -189,10 +189,10 @@ void func_80B220A8(EnHakurock* this) { this->actor.speedXZ = Rand_ZeroFloat(3.5f) + 2.5f; this->actor.velocity.y = Rand_ZeroFloat(4.5f) + 18.0f; Actor_SetScale(&this->actor, (Rand_ZeroFloat(5.0f) + 15.0f) * 0.001f); - this->actor.world.rot.y = (Rand_Next() >> 0x12) + this->actor.parent->shape.rot.y + 0x8000; - this->actor.shape.rot.x = Rand_Next() >> 0x10; - this->actor.shape.rot.y = Rand_Next() >> 0x10; - this->actor.shape.rot.z = Rand_Next() >> 0x10; + this->actor.world.rot.y = ((s32)Rand_Next() >> 0x12) + this->actor.parent->shape.rot.y + 0x8000; + this->actor.shape.rot.x = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.z = (s32)Rand_Next() >> 0x10; this->collider.dim.radius = (this->actor.scale.x * 2500.0f); this->collider.dim.yShift = -this->collider.dim.radius; this->collider.dim.height = this->collider.dim.radius * 2; @@ -222,8 +222,8 @@ void func_80B222AC(EnHakurock* this, GlobalContext* globalCtx) { s16 angle; this->actor.draw = EnHakurock_Draw; - angle = (Rand_Next() >> 0x13) + player->actor.shape.rot.y; - this->actor.shape.rot.y = Rand_Next() >> 0x10; + angle = ((s32)Rand_Next() >> 0x13) + player->actor.shape.rot.y; + this->actor.shape.rot.y = (s32)Rand_Next() >> 0x10; this->actor.world.pos.x = (Math_SinS(angle) * 600.0f) + player->actor.world.pos.x; this->actor.world.pos.y = player->actor.world.pos.y + 700.0f; this->actor.world.pos.z = (Math_CosS(angle) * 600.0f) + player->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 2eace7815a..4c9dcc0e8e 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -2656,7 +2656,7 @@ void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer > 0) { temp_v1_3 = this->actionTimer & 0x1F; if ((temp_v1_3 == 0) && (Rand_ZeroOne() < 0.3f)) { - temp_v1_3 = Rand_Next() % 4; + temp_v1_3 = (s32)Rand_Next() % 4; if (temp_v1_3 != this->rand) { this->rand = temp_v1_3; if (this->rand == 0) { diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 9b60a41dd3..6f29acf4a4 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -203,8 +203,8 @@ void func_8095D804(Actor* thisx, GlobalContext* globalCtx) { spC4.y += (Rand_ZeroOne() * 7.0f) + 6.0f; spC4.z += (Rand_ZeroOne() - 0.5f) * 11.0f; - EffectSsKakera_Spawn(globalCtx, &spB8, &spC4, &spB8, -420, (Rand_Next() > 0) ? 65 : 33, 30, 5, 0, D_8095F74C[i], - 3, 10, 40, -1, temp, phi_s4); + EffectSsKakera_Spawn(globalCtx, &spB8, &spC4, &spB8, -420, ((s32)Rand_Next() > 0) ? 65 : 33, 30, 5, 0, + D_8095F74C[i], 3, 10, 40, -1, temp, phi_s4); } } @@ -389,7 +389,7 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { } if ((this->actor.shape.rot.y == 0) && !(this->unk_197 & 2)) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } Actor_SetScale(&this->actor, D_8095F6B8[sp34]); diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index c16fa41473..9e00b09e4f 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -313,7 +313,7 @@ void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx) { s32 rand; if ((this->unk_2FC > 100) || func_80C14BCC(this, globalCtx)) { - rand = (u32)Rand_Next() % 3; + rand = Rand_Next() % 3; this->unk_2FC = 0; if (rand < this->unk_218) { diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index d2a1f99027..ab3e8531f4 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -230,7 +230,7 @@ void func_80AD7254(EnKame* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk_2A4, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 40.0f) { - this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); } this->unk_29E--; diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index 92053374a1..5b32a556bb 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -600,8 +600,8 @@ void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { } play_sound(NA_SE_SY_FOUND); - func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 1); - func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 4); + func_80B279F0(this, globalCtx, (((s32)Rand_Next() & 0xFF) % 3) + 1); + func_80B279F0(this, globalCtx, (((s32)Rand_Next() & 0xFF) % 3) + 4); this->unk_290 = 0; this->unk_284++; } else if (this->unk_290 == 120) { diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 1767f3c86c..fb20fcd67e 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -381,7 +381,7 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = ((u32)Rand_Next() >> 0x10); + this->actor.shape.rot.y = (Rand_Next() >> 0x10); this->actor.home.rot.y = this->actor.shape.rot.y; this->actor.world.rot.y = this->actor.shape.rot.y; } @@ -401,11 +401,11 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { EnKusa_SetupWaitObject(this); if (D_809366B4) { - D_80936CD8 = ((u32)Rand_Next() >> 0x10); - D_80936CDA = ((u32)Rand_Next() >> 0x10); - D_80936CDC = ((u32)Rand_Next() >> 0x10); - D_80936CDE = ((u32)Rand_Next() >> 0x10); - D_80936CE0 = ((u32)Rand_Next() >> 0x10); + D_80936CD8 = Rand_Next() >> 0x10; + D_80936CDA = Rand_Next() >> 0x10; + D_80936CDC = Rand_Next() >> 0x10; + D_80936CDE = Rand_Next() >> 0x10; + D_80936CE0 = Rand_Next() >> 0x10; D_809366B4 = false; EnKusa_Sway(); kusaGameplayFrames = globalCtx->gameplayFrames; diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 6ba532ceff..8852319dfd 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -102,7 +102,7 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { ptr = this->unk_194; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); *ptr = actor; if (*ptr != NULL) { @@ -117,8 +117,8 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { ptr = &this->unk_194[i]; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, (Math_SinS(temp_s1) * 80.0f) + this->actor.world.pos.x, - this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, - (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, + 0, 1, this->actor.cutscene, this->actor.unk20, NULL); *ptr = actor; if (*ptr != NULL) { (*ptr)->actor.room = this->actor.room; @@ -741,7 +741,7 @@ void func_80A5CD0C(EnKusa2* this) { s32 pad; for (i = 0; i < 2; i++) { - temp_s0 = (u32)Rand_Next() & 0xFFFF; + temp_s0 = Rand_Next() & 0xFFFF; temp_f20 = Rand_ZeroOne() * 30.0f; spA8.x = Math_SinS(temp_s0) * temp_f20; @@ -756,13 +756,13 @@ void func_80A5CD0C(EnKusa2* this) { spA8.y += this->actor.world.pos.y; spA8.z += this->actor.world.pos.z; - sp94.x = (u32)Rand_Next() & 0xFFFF; - sp94.y = (u32)Rand_Next() & 0xFFFF; - sp94.z = (u32)Rand_Next() & 0xFFFF; + sp94.x = Rand_Next() & 0xFFFF; + sp94.y = Rand_Next() & 0xFFFF; + sp94.z = Rand_Next() & 0xFFFF; - sp8C.x = ((u32)Rand_Next() % 0x4000) - 0x1FFF; - sp8C.y = ((u32)Rand_Next() % 0x2000) - 0xFFF; - sp8C.z = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp8C.x = (Rand_Next() % 0x4000) - 0x1FFF; + sp8C.y = (Rand_Next() % 0x2000) - 0xFFF; + sp8C.z = (Rand_Next() % 0x4000) - 0x1FFF; func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.4f) + 0.02f, &spA8, &sp9C, &sp94, &sp8C); } @@ -779,7 +779,7 @@ void func_80A5CF44(EnKusa2* this) { s32 phi_s2; for (i = 0, phi_s2 = 0; i < 8; i++, phi_s2 += 0x2000) { - temp_s0 = ((u32)Rand_Next() % 0x2000) + phi_s2; + temp_s0 = (Rand_Next() % 0x2000) + phi_s2; temp_f20 = Rand_ZeroOne() * 30.0f; spA8.x = Math_SinS(temp_s0) * temp_f20; @@ -798,9 +798,9 @@ void func_80A5CF44(EnKusa2* this) { sp94.y = Rand_Next() & 0xFFFF; sp94.z = Rand_Next() & 0xFFFF; - sp8C.x = ((u32)Rand_Next() % 0x4000) - 0x1FFF; - sp8C.y = ((u32)Rand_Next() % 0x2000) - 0xFFF; - sp8C.z = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp8C.x = (Rand_Next() % 0x4000) - 0x1FFF; + sp8C.y = (Rand_Next() % 0x2000) - 0xFFF; + sp8C.z = (Rand_Next() % 0x4000) - 0x1FFF; func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.45f) + 0.04f, &spA8, &sp9C, &sp94, &sp8C); } @@ -819,7 +819,7 @@ void func_80A5D178(EnKusa2* this) { s32 pad; for (i = 0; i < 8; i++) { - temp_s0 = (u32)Rand_Next(); + temp_s0 = Rand_Next(); temp_f22 = Math_SinS(temp_s0); temp_f20 = Math_CosS(temp_s0); temp_f24 = (Rand_ZeroOne() * 40.0f) + 10.0f; @@ -836,12 +836,12 @@ void func_80A5D178(EnKusa2* this) { spB0.y += this->actor.world.pos.y; spB0.z += this->actor.world.pos.z; - sp9C.x = (u32)Rand_Next() & 0xFFFF; - sp9C.y = (u32)Rand_Next() & 0xFFFF; - sp9C.z = (u32)Rand_Next() & 0xFFFF; + sp9C.x = Rand_Next() & 0xFFFF; + sp9C.y = Rand_Next() & 0xFFFF; + sp9C.z = Rand_Next() & 0xFFFF; sp94.x = Rand_S16Offset(-12000, 24000); - sp94.y = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp94.y = (Rand_Next() % 0x4000) - 0x1FFF; sp94.z = Rand_S16Offset(-12000, 24000); func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.38f) + 0.02f, &spB0, &spA4, &sp9C, &sp94); } @@ -868,11 +868,11 @@ void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx) { D_80A5EAEC = 0; D_80A60900 = globalCtx->gameplayFrames; func_80A5CAD4(&D_80A5F1C0); - D_80A60B08 = (u32)Rand_Next() >> 0x10; - D_80A60B0A = (u32)Rand_Next() >> 0x10; - D_80A60B0C = (u32)Rand_Next() >> 0x10; - D_80A60B0E = (u32)Rand_Next() >> 0x10; - D_80A60B10 = (u32)Rand_Next() >> 0x10; + D_80A60B08 = Rand_Next() >> 0x10; + D_80A60B0A = Rand_Next() >> 0x10; + D_80A60B0C = Rand_Next() >> 0x10; + D_80A60B0E = Rand_Next() >> 0x10; + D_80A60B10 = Rand_Next() >> 0x10; func_80A5B508(); } func_80A5D5E0(this); @@ -1048,14 +1048,14 @@ void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx) { sp30.y = this->actor.world.pos.y + 20.0f; sp30.z = this->actor.world.pos.z; - if ((u32)Rand_Next() < 0xFFFFFFF) { + if (Rand_Next() < 0xFFFFFFF) { func_80A5CD0C(this); } this->unk_1D0--; if (this->unk_1D0 <= 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); - this->unk_1D0 = ((u32)Rand_Next() >> 0x1D) + 14; + this->unk_1D0 = (Rand_Next() >> 0x1D) + 14; } this->actor.floorHeight = @@ -1152,7 +1152,7 @@ void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx) { func_80A5BF38(this, 4); func_80A5BF84(this, globalCtx); - if ((u32)Rand_Next() < 0xFFFFFFF) { + if (Rand_Next() < 0xFFFFFFF) { func_80A5CD0C(this); } diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index 4efc187144..68f587ba3f 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -192,9 +192,9 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) { iceShardEffect->pos.y = this->actor.world.pos.y + (((iceShardEffect->vel.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y); iceShardEffect->pos.z = this->actor.world.pos.z + (400.0f * this->actor.scale.z) * iceShardEffect->vel.z; - iceShardEffect->rotation.x = Rand_Next() >> 0x10; - iceShardEffect->rotation.y = Rand_Next() >> 0x10; - iceShardEffect->rotation.z = Rand_Next() >> 0x10; + iceShardEffect->rotation.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.z = (s32)Rand_Next() >> 0x10; iceShardEffect->isActive = true; Math_Vec3f_ScaleAndStore(&iceShardEffect->vel, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->vel); iceShardEffect->scale = (Rand_ZeroFloat(6.0f) + 2.0f) * 0.001f; @@ -276,8 +276,8 @@ void EnMinislime_SetupBreakFromBigslime(EnMinislime* this) { this->actor.gravity = -1.0f; this->frozenScale = 0.1f; this->actor.world.rot.x = Rand_S16Offset(0x800, 0x800); - this->actor.shape.rot.x = (s16)(Rand_Next() >> 0x10); - this->actor.shape.rot.z = (s16)(Rand_Next() >> 0x10); + this->actor.shape.rot.x = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.z = (s32)Rand_Next() >> 0x10; this->actor.scale.x = 0.15f; this->actor.scale.y = 0.075f; this->actor.scale.z = 0.15f; @@ -437,7 +437,7 @@ void EnMinislime_Idle(EnMinislime* this, GlobalContext* globalCtx) { if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 200.0f) { this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); } else { - this->actor.world.rot.y += (s16)(Rand_Next() >> 19); + this->actor.world.rot.y += (s16)((s32)Rand_Next() >> 0x13); } } this->idleTimer = 20; diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 4afae57933..e08969c6be 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -618,7 +618,7 @@ void func_80A69ADC(Actor* thisx) { if (Rand_ZeroOne() < this->unk_358) { this->unk_366 = (sp44 >= 0.0f) ? 2000 : -2000; } else { - this->unk_366 = (Rand_Next() > 0) ? 2000 : -2000; + this->unk_366 = ((s32)Rand_Next() > 0) ? 2000 : -2000; } this->unk_366 += (s16)(((Rand_ZeroOne() * (1.0f - this->unk_358)) - 0.5f) * 0x400); } else { @@ -634,7 +634,7 @@ void func_80A69CE0(Actor* thisx) { this->unk_360 = Rand_ZeroOne() * 1500.0f; this->unk_364 = 0; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { this->unk_366 = 2000; } else { this->unk_366 = -2000; @@ -770,7 +770,7 @@ void EnMushi2_Init(Actor* thisx, GlobalContext* globalCtx) { if (sp3C != 0) { func_80A69F5C(&this->actor, globalCtx); - this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.world.rot.y = Rand_Next() >> 0x10; func_80A6AE14(this); } else { func_80A6A300(this); @@ -1034,7 +1034,7 @@ void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.depthInWater > 5.0f) && - (this->actor.depthInWater < 30.0f) && ((Rand_Next() & 0x1FF) < this->unk_368)) { + (this->actor.depthInWater < 30.0f) && ((s32)(Rand_Next() & 0x1FF) < this->unk_368)) { EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, ((Rand_ZeroOne() * 4.0f) + 2.0f) * this->actor.scale.x); } diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index 708bae3efb..4f65a541c6 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -249,7 +249,7 @@ void func_80897258(GlobalContext* globalCtx, EnPeehat* this, Vec3f* arg2, f32 ar static Vec3f D_80899558 = { 0.0f, 8.0f, 0.0f }; static Vec3f D_80899564 = { 0.0f, -1.5f, 0.0f }; Vec3f sp44; - s16 sp42 = Rand_Next() >> 0x10; + s16 sp42 = (s32)Rand_Next() >> 0x10; s32 temp_v1; sp44.y = this->actor.floorHeight; diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 6d3a118f4f..c98c279cec 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -478,7 +478,7 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 22.5f)) { - this->unk_3D4 = (u32)Rand_Next() % 0x7D0; + this->unk_3D4 = Rand_Next() % 0x7D0; } this->actor.shape.rot.x = Math_SinS(this->unk_3D4 * sp26) * 20000.0f; diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index ef0ad1b571..2b579bf8da 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -319,7 +319,7 @@ void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, GlobalContext* g for (i = 0; i < 15; i++) { altitude = Rand_S16Offset(0x1800, 0x2800); - azimuth = ((u32)Rand_Next() >> 0x10); + azimuth = Rand_Next() >> 0x10; speed = Rand_ZeroFloat(3.0f) + 8.0f; velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); velocity.y = speed * Math_SinS(altitude); @@ -406,9 +406,9 @@ void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx) { } else if (this->actor.bgCheckFlags & 8) { this->snowPileTargetRotY = this->actor.wallYaw; } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 200.0f) { - this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); } else if (Rand_ZeroOne() < 0.02f) { - this->snowPileTargetRotY += (s16)((((u32)Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + this->snowPileTargetRotY += (s16)(((Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); } } @@ -746,7 +746,7 @@ void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx) { for (i = 0; i < 15; i++) { altitude = Rand_S16Offset(0x1000, 0x3000); - azimuth = ((u32)Rand_Next() >> 0x10); + azimuth = (Rand_Next() >> 0x10); speed = Rand_ZeroFloat(2.0f) + 4.0f; velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); velocity.y = speed * Math_SinS(altitude); diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index faeb3163e0..f642502401 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -196,7 +196,7 @@ void func_80C10984(EnThiefbird* this, s32 arg1) { ptr->unk_0C.z = randPlusMinusPoint5Scaled(5.0f); ptr->unk_1C = Rand_ZeroFloat(1000.0f); ptr->unk_18 = (Rand_ZeroFloat(20.0f) + 40.0f) * 0.0001f; - ptr->unk_1E = Rand_Next() >> 0x10; + ptr->unk_1E = (s32)Rand_Next() >> 0x10; arg1--; if (arg1 == 0) { break; diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index 55304d1950..8cf2039b4f 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -193,7 +193,7 @@ void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { if (sp34 == OBJBOMBIWA_100_0) { if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } func_80939594(this, globalCtx); } @@ -387,7 +387,7 @@ void func_8093A080(ObjBombiwa* this) { ptr->unk_10 = i + 3.0f; ptr->unk_14.x = phi_s2; - ptr->unk_14.y = (u32)Rand_Next() >> 0x10; + ptr->unk_14.y = Rand_Next() >> 0x10; ptr->unk_14.z = 0; ptr->unk_1A = 0; } diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index c6eef8626c..22df1af736 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -263,13 +263,13 @@ void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr2->unk_18 = (Rand_ZeroOne() * 0.057f) + 0.003f; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x11) - 0x3FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_22 = (Rand_Next() >> 0x11) - 0x3FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; ptr2->unk_29 = 0; ptr2->unk_28 = 40; @@ -307,13 +307,13 @@ void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr2->unk_00.y = (ptr2->unk_00.y * 23.0f) + sp98.y + 15.0f; ptr2->unk_00.z = (ptr2->unk_00.z * 80.0f) + sp98.z; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_22 = (Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; ptr2->unk_28 = 40; @@ -356,13 +356,13 @@ void func_80B13474(ObjDhouse* this, GlobalContext* globalCtx, Vec3f* arg2) { ptr2->unk_00.y = ((ptr2->unk_00.y - 0.4f) * 20.0f) + arg2->y; ptr2->unk_00.z = (ptr2->unk_00.z * 40.0f) + arg2->z; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_22 = (Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; ptr2->unk_28 = 40; ptr2->unk_18 = (Rand_ZeroOne() * 0.07f) + 0.003f; diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 57964559dc..d03912b14b 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -399,7 +399,7 @@ void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } Collider_InitJntSph(globalCtx, &this->collider); @@ -415,11 +415,11 @@ void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A1C818(this); if (D_80A1D404) { - D_80A1DA38 = (u32)Rand_Next() >> 0x10; - D_80A1DA3A = (u32)Rand_Next() >> 0x10; - D_80A1DA3C = (u32)Rand_Next() >> 0x10; - D_80A1DA3E = (u32)Rand_Next() >> 0x10; - D_80A1DA40 = (u32)Rand_Next() >> 0x10; + D_80A1DA38 = Rand_Next() >> 0x10; + D_80A1DA3A = Rand_Next() >> 0x10; + D_80A1DA3C = Rand_Next() >> 0x10; + D_80A1DA3E = Rand_Next() >> 0x10; + D_80A1DA40 = Rand_Next() >> 0x10; D_80A1D404 = false; func_80A1B3D0(); D_80A1D830 = globalCtx->gameplayFrames; diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 51f2febc74..705325429e 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -146,11 +146,11 @@ void ObjGrass_Init(Actor* thisx, GlobalContext* globalCtx) { } this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->unk_3288 = (u32)Rand_Next() >> 0x10; - this->unk_328A = (u32)Rand_Next() >> 0x10; - this->unk_328C = (u32)Rand_Next() >> 0x10; - this->unk_328E = (u32)Rand_Next() >> 0x10; - this->unk_3290 = (u32)Rand_Next() >> 0x10; + this->unk_3288 = Rand_Next() >> 0x10; + this->unk_328A = Rand_Next() >> 0x10; + this->unk_328C = Rand_Next() >> 0x10; + this->unk_328E = Rand_Next() >> 0x10; + this->unk_3290 = Rand_Next() >> 0x10; } void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c index d3199e8d88..c6dac659e3 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -389,7 +389,7 @@ void func_80B15264(ObjHakaisi* this) { Matrix_RotateZYX(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); Matrix_MultVec3f(&D_80B15600, &this->unk_184); this->dyna.actor.gravity = -1.0f; - this->unk_19C = Rand_Next() >> 0x12; + this->unk_19C = (s32)Rand_Next() >> 0x12; this->dyna.actor.velocity.x = Math_SinS(sp32) * 4.0f; this->dyna.actor.velocity.z = Math_CosS(sp32) * 4.0f; this->dyna.actor.velocity.y = 7.0f; diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index 10d8891ef7..7b8377cee8 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -170,7 +170,7 @@ void ObjHamishi_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.home.rot.y = this->actor.shape.rot.y; } diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 3fc7f84b13..c31eeb151e 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -463,7 +463,7 @@ void func_80A54E10(ObjHugebombiwa* this) { ptr->unk_18 = (i * 1.04f) + 2.4f; ptr->unk_1C.x = phi_s2; - ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.y = Rand_Next() >> 0x10; ptr->unk_1C.z = 0; ptr->unk_22 = Rand_ZeroFloat(5000.0f); ptr->unk_24 = 0; @@ -558,7 +558,7 @@ void func_80A55310(ObjHugebombiwa* this) { ptr->unk_18 = (i * 1.04f) + 2.4f; ptr->unk_1C.x = phi_s2; - ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.y = Rand_Next() >> 0x10; ptr->unk_1C.z = 0; ptr->unk_22 = Rand_ZeroFloat(5000.0f); diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index a4db0d04e6..1a6d96c730 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -106,8 +106,8 @@ void func_80A2311C(Vec3f* arg0, Vec3f* arg1, s16 arg2) { void func_80A2319C(ObjIceblock* this, f32 arg1) { s32 i; - s16 temp_s1 = (u32)Rand_Next() >> 0x10; - s16 temp_s2 = (u32)Rand_Next() >> 0x10; + s16 temp_s1 = Rand_Next() >> 0x10; + s16 temp_s2 = Rand_Next() >> 0x10; ObjIceBlockUnkStruct* ptr; for (i = 0; i < ARRAY_COUNT(this->unk_1B4); i++) { @@ -1364,7 +1364,7 @@ void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { ptr->unk_0C = Rand_S16Offset(300, 300); ptr->unk_0E = Rand_S16Offset(900, 600); ptr->unk_04 = (2.0f * Rand_ZeroOne()) + 1.0f; - ptr->unk_14 = (u32)Rand_Next() >> 0x10; + ptr->unk_14 = Rand_Next() >> 0x10; func_80A24B74(this, globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c index c0e5d8b4b8..194989ad55 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -121,7 +121,7 @@ void ObjKibako2_SpawnSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { if (ObjKibako2_ContainsSkulltula(this, globalCtx)) { actorSpawnParam = KIBAKO2_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); - yRotation = ((u32)Rand_Next() >> 0x11) + this->dyna.actor.yawTowardsPlayer + 0xC000; + yRotation = (Rand_Next() >> 0x11) + this->dyna.actor.yawTowardsPlayer + 0xC000; skulltula = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, yRotation, 0, actorSpawnParam); diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 3979479f63..b3464d7443 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -205,7 +205,7 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { gravity = -400; phi_s4 = 1; phi_f22 = 0.8f; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -245,7 +245,7 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { temp_f26 = this->unk_20C * 60.0f; for (i = 0, phi_s6 = 0; i < 16; i++, phi_s6 += 0x1000) { - temp_s0 = (u32)Rand_Next() >> 0x10; + temp_s0 = Rand_Next() >> 0x10; temp_f20 = Math_SinS(temp_s0); temp_f22 = Math_CosS(temp_s0); @@ -368,7 +368,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { temp_s1 = D_80B04FC8[0]; phi_s2 = -400; phi_s3 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -377,7 +377,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { temp_s1 = D_80B04FC8[1]; phi_s2 = -340; phi_s3 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -474,7 +474,7 @@ void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.y += 20.0f * phi_f20; this->actor.uncullZoneScale = 150.0f * phi_f20; this->actor.uncullZoneDownward = 300.0f * phi_f20; - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; this->unk_20C = phi_f20; if (sp34) { diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index 5356e2e88d..3737a5426b 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -145,7 +145,7 @@ void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { for (i = 0, phi_s5 = 0; i < 11; i++, phi_s5 += (0x10000 / 11)) { temp_s3 = (s32)(Rand_ZeroOne() * 5957.0f) + phi_s5; - if (((u32)Rand_Next() >> 0x1E) == 0) { + if ((Rand_Next() >> 0x1E) == 0) { phi_s1 = 0x20; } else { phi_s1 = 0x40; @@ -234,7 +234,7 @@ void func_80B39638(GlobalContext* globalCtx, Vec3f* arg1) { f32 temp_f2; s32 i; - D_80B3A938 += (s16)((u32)Rand_Next() >> 0x11); + D_80B3A938 += (s16)(Rand_Next() >> 0x11); for (i = 0; i < 2; i++) { D_80B3A938 += 0x8000; @@ -319,7 +319,7 @@ void ObjSnowball2_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitJntSph(globalCtx, &this->collider); this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; ActorShape_Init(&this->actor.shape, 200.0f, NULL, 12.5f); this->actor.shape.shadowAlpha = 130; Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); @@ -480,7 +480,7 @@ void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 0x40) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); } - } else if ((((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) && + } else if ((((globalCtx->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) && (this->actor.depthInWater < (1200.0f * this->actor.scale.y))) { func_80B395EC(&this->actor, globalCtx); } @@ -567,7 +567,7 @@ void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx) { this->actor.velocity.y += this->actor.gravity; this->actor.world.pos.y += this->actor.velocity.y; - if (((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) { + if (((globalCtx->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) { func_80B395C4(globalCtx, &this->actor.home.pos); }