From 2a0c0939c780babc45c8c22dfd6f94563485bae5 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Fri, 23 May 2025 16:53:14 -0600 Subject: [PATCH] Refactor World::Courses to unique_ptr (#211) * wip course unique ptr * Track unique_ptr : This probably compiles * Finish impl Courses as unique_ptr * Fix error * Fixes * More fixes * Cleanup * Remove old vars --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com> --- src/actors/piranha_plant/render.inc.c | 2 +- src/actors/trees/render.inc.c | 2 +- src/audio/external.c | 22 +- src/camera.c | 6 +- src/code_800029B0.c | 8 +- src/code_80005FD0.c | 93 ++++---- src/code_80057C60.c | 108 ++++----- src/code_8006E9C0.c | 8 +- src/code_8006E9C0.h | 2 +- src/code_80086E70.c | 4 +- src/effects.c | 16 +- src/ending/code_80281780.c | 2 +- src/engine/World.cpp | 12 +- src/engine/World.h | 14 +- src/engine/objects/BombKart.cpp | 8 +- src/engine/objects/GrandPrixBalloons.cpp | 6 +- src/engine/objects/HotAirBalloon.cpp | 2 +- src/engine/objects/Lakitu.cpp | 4 +- src/engine/objects/TrashBin.cpp | 2 +- src/menu_items.c | 33 +-- src/player_controller.c | 20 +- src/port/Game.cpp | 279 ++++++++--------------- src/port/Game.h | 82 +++---- src/port/ui/ContentBrowser.cpp | 25 +- src/racing/actors.c | 24 +- src/racing/math_util.c | 6 +- src/racing/race_logic.c | 10 +- src/racing/render_courses.c | 6 +- src/racing/skybox_and_splitscreen.c | 4 +- src/render_objects.c | 24 +- src/render_player.c | 6 +- src/spawn_players.c | 22 +- src/staff_ghosts.c | 6 +- src/update_objects.c | 8 +- 34 files changed, 403 insertions(+), 473 deletions(-) diff --git a/src/actors/piranha_plant/render.inc.c b/src/actors/piranha_plant/render.inc.c index 23d018d1b..ed2281095 100644 --- a/src/actors/piranha_plant/render.inc.c +++ b/src/actors/piranha_plant/render.inc.c @@ -120,7 +120,7 @@ void render_actor_piranha_plant(Camera* arg0, Mat4 arg1, struct PiranhaPlant* ar G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - if (GetCourse() == GetMarioRaceway()) { + if (IsMarioRaceway()) { gSPDisplayList(gDisplayListHead++, &d_course_mario_raceway_dl_piranha_plant); } else { gSPDisplayList(gDisplayListHead++, &d_course_royal_raceway_dl_piranha_plant); diff --git a/src/actors/trees/render.inc.c b/src/actors/trees/render.inc.c index cb54275c6..9939d14ef 100644 --- a/src/actors/trees/render.inc.c +++ b/src/actors/trees/render.inc.c @@ -202,7 +202,7 @@ void func_80299864(Camera* camera, Mat4 arg1, struct Actor* arg2) { // Unless both courses use this actor and use the same addr for the texture. // Just in-case changed the code into a switch to prevent future crashes. // This comment can be removed when this is confirmed to work. - if (GetCourse() == GetLuigiRaceway()) { + if (IsLuigiRaceway()) { gSPDisplayList(gDisplayListHead++, d_course_luigi_raceway_dl_FC70); } } diff --git a/src/audio/external.c b/src/audio/external.c index 97a2ce7f3..3ed17f5db 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -2647,11 +2647,11 @@ void func_800C847C(u8 playerId) { func_800C97C4(playerId); D_800E9F74[playerId] = 1; func_800C94A4(playerId); - if (((GetCourse() == GetChocoMountain()) || (GetCourse() == GetBowsersCastle()) || - (GetCourse() == GetBansheeBoardwalk()) || (GetCourse() == GetYoshiValley()) || - (GetCourse() == GetFrappeSnowland()) || (GetCourse() == GetKoopaTroopaBeach()) || - (GetCourse() == GetRoyalRaceway()) || (GetCourse() == GetSherbetLand()) || - (GetCourse() == GetDkJungle()) || (GetCourse() == GetBigDonut())) && + if (((IsChocoMountain()) || (IsBowsersCastle()) || + (IsBansheeBoardwalk()) || (IsYoshiValley()) || + (IsFrappeSnowland()) || (IsKoopaTroopaBeach()) || + (IsRoyalRaceway()) || (IsSherbetLand()) || + (IsDkJungle()) || (IsBigDonut())) && (D_800EA0EC[playerId] == 0)) { play_sound((gPlayers[playerId].characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x05), &D_800E9F7C[playerId].pos, playerId, &D_800EA1D4, &D_800EA1D4, @@ -2664,7 +2664,7 @@ void func_800C847C(u8 playerId) { D_800E9F74[playerId] = 2; func_800C94A4(playerId); D_800E9F74[playerId] = 0; - if ((GetCourse() == GetKoopaTroopaBeach()) && (D_800EA0EC[playerId] == 0)) { + if ((IsKoopaTroopaBeach()) && (D_800EA0EC[playerId] == 0)) { play_sound((gPlayers[playerId].characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x08), &D_800E9F7C[playerId].pos, playerId, &D_800EA1D4, &D_800EA1D4, (u8*) &D_800E9F7C[playerId].unk_14); @@ -2746,7 +2746,7 @@ void func_800C89E4(void) { } void func_800C8AE4(void) { - if (GetCourse() == GetLuigiRaceway()) { + if (IsLuigiRaceway()) { if (D_800EA184 != 0) { if ((u8) D_800EA16C == 0) { // Has to be this way, can't be D_800EA184++ @@ -2824,11 +2824,11 @@ void func_800C8CCC() { } void play_sound2(s32 soundBits) { - if ((soundBits == SOUND_ACTION_REV_ENGINE) && (GetCourse() == GetDkJungle())) { + if ((soundBits == SOUND_ACTION_REV_ENGINE) && (IsDkJungle())) { soundBits = SOUND_ARG_LOAD(0x49, 0x00, 0x80, 0x27); } - if ((soundBits == SOUND_ACTION_REV_ENGINE_2) && (GetCourse() == GetDkJungle())) { + if ((soundBits == SOUND_ACTION_REV_ENGINE_2) && (IsDkJungle())) { soundBits = SOUND_ARG_LOAD(0x49, 0x00, 0x80, 0x28); } play_sound(soundBits, &D_800EA1C8, 4, &D_800EA1D4, &D_800EA1D4, &D_800EA1DC); @@ -3467,7 +3467,9 @@ void func_800CAEC4(u8 playerId, f32 arg1) { arg1 = 0.0f; } D_800EA120[playerId] = arg1; - play_sound(gCurrentCourseId + 0x19007020, &D_800E9F7C[playerId].pos, playerId, &D_800EA1D4, + //! @warning this used to be gCurrentCourseId + 0x19007020 + // This may not be equivallent. + play_sound(GetCourseIndex() + 0x19007020, &D_800E9F7C[playerId].pos, playerId, &D_800EA1D4, &D_800EA120[playerId], (u8*) &D_800E9F7C[playerId].unk_14); break; default: diff --git a/src/camera.c b/src/camera.c index 01ece4a2b..6620c3ac0 100644 --- a/src/camera.c +++ b/src/camera.c @@ -383,7 +383,7 @@ void func_8001CA78(UNUSED Player* player, Camera* camera, Vec3f arg2, f32* arg3, arg2[2] = camera->lookAt[2]; calculate_orientation_matrix(sp74, 0, 1, 0, -0x00008000); mtxf_translate_vec3f_mat3(sp5C, sp74); - if (GetCourse() == GetToadsTurnpike()) { + if (IsToadsTurnpike()) { var_f14 = sp5C[0]; } else { var_f14 = sp5C[0] + temp_s2->posX; @@ -394,7 +394,7 @@ void func_8001CA78(UNUSED Player* player, Camera* camera, Vec3f arg2, f32* arg3, arg2[1] += (temp_f18 - camera->lookAt[1]) * 1; arg2[2] += (temp_f16 - camera->lookAt[2]) * 1; mtxf_translate_vec3f_mat3(sp68, sp74); - if (GetCourse() == GetToadsTurnpike()) { + if (IsToadsTurnpike()) { var_f14 = sp68[0]; } else { var_f14 = sp68[0] + temp_s2->posX; @@ -487,7 +487,7 @@ void func_8001CCEC(Player* player, Camera* camera, Vec3f arg2, f32* arg3, f32* a move_f32_towards(&D_80164AA0[index], 10, 0.02f); break; default: - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { move_f32_towards(&D_80164A90[index], 50, 0.04f); move_f32_towards(&D_80164AA0[index], 35, 0.04f); } else { diff --git a/src/code_800029B0.c b/src/code_800029B0.c index 73f104ed8..beba2e490 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -233,16 +233,18 @@ void setup_race(void) { // D_8015F8D0[1] = (f32) (D_80164490->posY - 15); // D_8015F8D0[2] = D_80164490->posZ; - // if (GetCourse() == GetToadsTurnpike()) { + // if (IsToadsTurnpike()) { // D_8015F8D0[0] = (gIsMirrorMode != 0) ? D_80164490->posX + 138.0f : D_80164490->posX - 138.0f; - // } else if (GetCourse() == GetWarioStadium()) { + // } else if (IsWarioStadium()) { // D_8015F8D0[0] = (gIsMirrorMode != 0) ? D_80164490->posX + 12.0f : D_80164490->posX - 12.0f; // } else { // D_8015F8D0[0] = D_80164490->posX; // } // } if (!gDemoMode) { - func_800CA008(gPlayerCountSelection1 - 1, gCurrentCourseId + 4); + //! @warning this used to be gCurrentCourseId + 4 + // Hopefully this is equivallent. + func_800CA008(gPlayerCountSelection1 - 1, GetCourseIndex() + 4); func_800CB2C4(); } diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 6263883f2..3f8a0b1fc 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -1076,7 +1076,7 @@ void func_80008424(s32 playerId, f32 arg1, Player* player) { if (!(player->effects & 0x80) && !(player->effects & 0x40) && !(player->effects & 0x20000) && !(player->soundEffects & 0x400000) && !(player->soundEffects & 0x01000000) && !(player->soundEffects & 2) && !(player->soundEffects & 4)) { - if (GetCourse() == GetPodiumCeremony()) { + if (IsPodiumCeremony()) { func_80007FA4(playerId, player, var_f2); } else if ((bStopAICrossing[playerId] == 1) && !(player->effects & (STAR_EFFECT | BOO_EFFECT))) { decelerate_ai_player(player, 10.0f); @@ -1140,7 +1140,7 @@ void func_80008424(s32 playerId, f32 arg1, Player* player) { } if (var_a1 != 1) { if (var_f2 < arg1) { - if ((gDemoMode == 1) && (GetCourse() != GetPodiumCeremony())) { + if ((gDemoMode == 1) && (!IsPodiumCeremony())) { player_speed(player); } else if (D_80163330[playerId] == 1) { func_80007D04(playerId, player); @@ -1448,15 +1448,15 @@ void func_8000929C(s32 playerId, Player* player) { D_801630E2 = 1; func_80008F38(playerId); } - if (GetCourse() == GetPodiumCeremony()) { + if (IsPodiumCeremony()) { func_8000B95C(playerId, sSomeNearestWaypoint, D_80163448); return; } if ((sSomeNearestWaypoint < 0x14) || ((gWaypointCountByPathIndex[D_80163448] - 0x14) < sSomeNearestWaypoint) || - (GetCourse() == GetKalimariDesert())) { + (IsKalimariDesert())) { var_v1 = 0; var_t0 = 0; - if (GetCourse() == GetKalimariDesert()) { + if (IsKalimariDesert()) { D_801634EC = 0; if (player->effects & 0x200) { D_801634EC = 1; @@ -1510,7 +1510,7 @@ void func_8000929C(s32 playerId, Player* player) { } } D_80163450[playerId] = tempPos2; - if ((GetCourse() == GetYoshiValley()) && (D_801630E2 == 1)) { + if ((IsYoshiValley()) && (D_801630E2 == 1)) { func_80009000(playerId); if (((player->type & 0x4000) == 0) || (player->type & 0x1000)) { func_800090F0(playerId, player); @@ -1664,7 +1664,7 @@ void func_80009B60(s32 playerId) { if (!(player->unk_0CA & 2) && !(player->unk_0CA & 8)) { D_80163448 = gPathIndexByPlayerId[playerId]; func_80008DC0(D_80163448); - //if (GetCourse() == GetKalimariDesert()) { + //if (IsKalimariDesert()) { CM_VehicleCollision(playerId, player); //func_80012DC0(playerId, player); if (playerId == 0) { @@ -1672,9 +1672,9 @@ void func_80009B60(s32 playerId) { //func_80013054(); } //} - if (GetCourse() == GetDkJungle()) { + if (IsDkJungle()) { //func_80013854(player); - } else if (GetCourse() == GetToadsTurnpike()) { + } else if (IsToadsTurnpike()) { func_800148C4(playerId, player); func_80014A18(playerId, player); func_80014B6C(playerId, player); @@ -1685,11 +1685,11 @@ void func_80009B60(s32 playerId) { player->unk_044 &= ~0x0001; } func_8000929C(playerId, player); - if ((GetCourse() != GetPodiumCeremony()) && ((D_80163240[playerId] == 1) || (playerId == 0))) { + if ((!IsPodiumCeremony()) && ((D_80163240[playerId] == 1) || (playerId == 0))) { set_places(); } if (player->type & 0x1000) { - if ((D_801630E2 == 1) && (GetCourse() != GetPodiumCeremony())) { + if ((D_801630E2 == 1) && (!IsPodiumCeremony())) { kart_ai_behaviour(playerId); } if ((playerId & 1) != (D_80163378 & 1)) { @@ -1706,11 +1706,11 @@ void func_80009B60(s32 playerId) { break; } D_801631E0[playerId] = 0; - if ((player->effects & 0x1000) && (GetCourse() != GetPodiumCeremony())) { + if ((player->effects & 0x1000) && (!IsPodiumCeremony())) { D_801631E0[playerId] = 1; } - if ((D_801646CC == 1) || (player->type & 0x800) || (GetCourse() == GetPodiumCeremony())) { - if (GetCourse() != GetToadsTurnpike()) { + if ((D_801646CC == 1) || (player->type & 0x800) || (IsPodiumCeremony())) { + if (!IsToadsTurnpike()) { D_801634F8[playerId].unk4 = 0.0f; } D_801634F8[playerId].unkC = 0.0f; @@ -1731,9 +1731,9 @@ void func_80009B60(s32 playerId) { // Old vehicle draw method was here - if ((GetCourse() == GetYoshiValley()) || (GetCourse() == GetPodiumCeremony())) { + if ((IsYoshiValley()) || (IsPodiumCeremony())) { D_801634F8[playerId].unk4 = 0.0f; - } else if (GetCourse() == GetToadsTurnpike()) { + } else if (IsToadsTurnpike()) { // func_8001490C(playerId); // func_80014A60(playerId); // func_80014BB4(playerId); @@ -1840,10 +1840,10 @@ void func_80009B60(s32 playerId) { } D_801630B8[playerId] = func_8000B7E4(playerId, sSomeNearestWaypoint); func_8000D438(playerId, sSomeNearestWaypoint); - if (GetCourse() != GetPodiumCeremony()) { + if (!IsPodiumCeremony()) { if (D_80164450[playerId] < 0xB) { stackPadding1A = D_801630E0; - if ((D_80164450[playerId] > 0) && (GetCourse() == GetToadsTurnpike())) { + if ((D_80164450[playerId] > 0) && (IsToadsTurnpike())) { stackPadding1A += 0x14; stackPadding1A %= D_80164430; func_8000BBD8(stackPadding1A, 0.0f, 0); @@ -1877,7 +1877,7 @@ void func_80009B60(s32 playerId) { } } } - if (GetCourse() == GetPodiumCeremony()) { + if (IsPodiumCeremony()) { switch (D_80163410[playerId]) { /* switch 3; irregular */ case 3: /* switch 3 */ D_80162FA0[0] = D_80163418[playerId]; @@ -2297,7 +2297,7 @@ s16 find_closest_waypoint_track_section(f32 posX, f32 posY, f32 posZ, u16 trackS considerWaypoint = &pathWaypoints[0]; for (considerWaypointIndex = 0; considerWaypointIndex < pathWaypointCount; considerWaypointIndex++, considerWaypoint++) { - if ((considerWaypoint->trackSectionId == trackSectionId) || (GetCourse() == GetPodiumCeremony())) { + if ((considerWaypoint->trackSectionId == trackSectionId) || (IsPodiumCeremony())) { var_t1 = 1; x_dist = (f32) considerWaypoint->posX - posX; y_dist = (f32) considerWaypoint->posY - posY; @@ -2463,7 +2463,7 @@ void func_8000CBA4(UNUSED f32 posX, f32 posY, UNUSED f32 posZ, s16* waypointInde s16 var_v0; var_v0 = *waypointIndex; - if ((GetCourse() == GetWarioStadium()) && (var_v0 >= 0x475) && (var_v0 < 0x480) && (posY < 0.0f)) { + if ((IsWarioStadium()) && (var_v0 >= 0x475) && (var_v0 < 0x480) && (posY < 0.0f)) { var_v0 = 0x0398; } *waypointIndex = var_v0; @@ -2666,11 +2666,11 @@ void func_8000D438(s32 arg0, u16 arg1) { sp2C = func_8000D3B8(arg0); thing = arg1; - if (GetCourse() == GetPodiumCeremony()) { + if (IsPodiumCeremony()) { var_a2 = 1; - } else if (GetCourse() == GetToadsTurnpike()) { + } else if (IsToadsTurnpike()) { var_a2 = 7; - } else if (GetCourse() == GetYoshiValley()) { + } else if (IsYoshiValley()) { } else { if (temp_v1 < 6) { var_a2 = 8; @@ -2908,11 +2908,11 @@ void set_bomb_kart_spawn_positions(void) { for (var_s3 = 0; var_s3 < NUM_BOMB_KARTS_VERSUS; var_s3++) { //bombKartSpawn = &gBombKartSpawns[gCurrentCourseId][var_s3]; - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { startingXPos = bombKartSpawn->startingXPos; startingZPos = bombKartSpawn->startingZPos; startingYPos = spawn_actor_on_surface(startingXPos, 2000.0f, startingZPos); - } else if (GetCourse() == GetPodiumCeremony()) { + } else if (IsPodiumCeremony()) { temp_v0 = &D_80164550[3][bombKartSpawn->waypointIndex]; startingXPos = temp_v0->posX; startingYPos = temp_v0->posY; @@ -3014,7 +3014,7 @@ void func_8000DF8C(s32 bombKartId) { return; } - if (((bombKart->unk_4A != 1) || (GetCourse() == GetPodiumCeremony()))) { + if (((bombKart->unk_4A != 1) || (IsPodiumCeremony()))) { var_f22 = bombKart->bombPos[0]; var_f20 = bombKart->bombPos[1]; var_f24 = bombKart->bombPos[2]; @@ -3025,7 +3025,7 @@ void func_8000DF8C(s32 bombKartId) { var_s1 = bombKart->circleTimer; if ((sp7E != 0) && (sp7E != 4)) { if (1) {} - if (GetCourse() == GetPodiumCeremony()) { + if (IsPodiumCeremony()) { if (D_8016347E == 1) { var_v0 = gPlayerFour; temp_f0 = var_f22 - var_v0->pos[0]; @@ -3049,7 +3049,7 @@ void func_8000DF8C(s32 bombKartId) { if ((((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) + (temp_f12 * temp_f12)) < 25.0f) { sp7E = 4; var_s1 = 0; - if (GetCourse() == GetFrappeSnowland()) { + if (IsFrappeSnowland()) { var_v0->soundEffects |= 0x01000000; } else { var_v0->soundEffects |= 0x400000; @@ -3466,7 +3466,7 @@ void func_8000F628(void) { D_80163050[i] = 0; D_80162FF8[i] = 0; D_80163010[i] = 0; - if (GetCourse() != GetPodiumCeremony()) { + if (!IsPodiumCeremony()) { func_8000B95C(i, 0, 0); } //! todo: @BUG this doesn't seem right. This variable is metadata. @@ -3551,7 +3551,7 @@ void func_8000F628(void) { } } } - if ((gDemoUseController == 1) && (GetCourse() != GetPodiumCeremony())) { + if ((gDemoUseController == 1) && (!IsPodiumCeremony())) { for (i = 0; i < NUM_PLAYERS; i++) { D_80163330[i] = 0; } @@ -3635,7 +3635,7 @@ void func_800100F0(s32 pathIndex) { if (CM_GetProps()->AIMaximumSeparation >= 1.0f) { pathDest = D_80164550[pathIndex]; bInvalidPath = 1; - if (GetCourse() != GetPodiumCeremony()) { + if (!IsPodiumCeremony()) { TrackWaypoint* pathSrc = CM_GetProps()->PathTable2[pathIndex]; if (pathSrc == NULL) { @@ -3879,7 +3879,7 @@ void func_80010E6C(s32 pathIndex) { } else { break; } - if (GetCourse() == GetPodiumCeremony()) { + if (IsPodiumCeremony()) { break; } } @@ -3934,7 +3934,7 @@ s32 func_80011014(TrackWaypoint* pathDest, TrackWaypoint* path, s32 numPathPoint var_s0 = 0; temp_f20 = (f32) path[0].posX; temp_f22 = (f32) path[0].posZ; - var_f28 = func_80010F40(temp_f20, 2000.0f, temp_f22, gCurrentCourseId, 0); + var_f28 = func_80010F40(temp_f20, 2000.0f, temp_f22, 0, 0); for (i = 0; i < numPathPoints; i++) { point1 = &path[i % numPathPoints]; @@ -3969,10 +3969,10 @@ s32 func_80011014(TrackWaypoint* pathDest, TrackWaypoint* path, s32 numPathPoint if (gIsMirrorMode) { // temp_f12 = -temp_f24_2; pathDest->posX = (s16) -temp_f24_2; - var_f20_2 = func_80010FA0(-temp_f24_2, var_f28, x1_2, gCurrentCourseId, var_s0); + var_f20_2 = func_80010FA0(-temp_f24_2, var_f28, x1_2, 0, var_s0); } else { pathDest->posX = (s16) temp_f24_2; - var_f20_2 = func_80010FA0(temp_f24_2, var_f28, x1_2, gCurrentCourseId, var_s0); + var_f20_2 = func_80010FA0(temp_f24_2, var_f28, x1_2, 0, var_s0); } pathDest->posZ = (s16) temp_f22; @@ -3982,11 +3982,11 @@ s32 func_80011014(TrackWaypoint* pathDest, TrackWaypoint* path, s32 numPathPoint var_f20_2 = var_f28; } else { - if (GetCourse() == GetRainbowRoad()) { + if (IsRainbowRoad()) { if (var_f20_2 < (var_f28 - 15.0)) { var_f20_2 = (f32) var_f28 - 15.0; } - } else if (GetCourse() == GetWarioStadium()) { + } else if (IsWarioStadium()) { if ((var_s0 >= 1140) && (var_s0 <= 1152)) { var_f20_2 = var_f28; } else { @@ -3994,7 +3994,7 @@ s32 func_80011014(TrackWaypoint* pathDest, TrackWaypoint* path, s32 numPathPoint var_f20_2 = (f32) (var_f28 - 4.0); } } - } else if (GetCourse() == GetDkJungle()) { + } else if (IsDkJungle()) { if ((var_s0 > 204) && (var_s0 < 220)) { var_f20_2 = var_f28; } else { @@ -4628,7 +4628,7 @@ void func_80013054(void) { void check_ai_crossing_distance(s32 playerId) { bStopAICrossing[playerId] = 0; - if (GetCourse() == GetKalimariDesert()) { + if (IsKalimariDesert()) { if ((!(D_801631E0[playerId] != 0)) || (set_vehicle_render_distance_flags(gPlayers[playerId].pos, TRAIN_CROSSING_AI_DISTANCE, 0))) { @@ -5819,7 +5819,7 @@ void func_80016C3C(UNUSED s32 playerId, UNUSED f32 arg1, s32 cameraId) { D_80164688[cameraId] = -0.1f; } D_80163DD8[cameraId] = 0; - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { D_80163DD8[cameraId] = random_int(4U); D_80164688[cameraId] = 0.0f; } @@ -5892,8 +5892,7 @@ void func_80017054(Camera* camera, UNUSED Player* player, UNUSED s32 index, s32 D_80163238 = playerId; sp56 = gNearestWaypointByCameraId[cameraId]; gNearestWaypointByCameraId[cameraId] = func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestWaypointByCameraId[cameraId], pathIndex); - // if (GetCourse() == GetYoshiValley()) { - if (gCurrentCourseId == 4) { + if (IsYoshiValley()) { if ((sp56 != gNearestWaypointByCameraId[cameraId]) && (gNearestWaypointByCameraId[cameraId] == 1)) { pathIndex = (D_80163DD8[cameraId] = random_int(4U)); gNearestWaypointByCameraId[cameraId] = func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestWaypointByCameraId[cameraId], pathIndex); @@ -6574,7 +6573,7 @@ void func_80019D2C(Camera* camera, Player* player, s32 arg2) { s32 nearestWaypoint; playerId = camera->playerId; - if ((D_80163378 != 0) && (GetCourse() == GetLuigiRaceway())) { + if ((D_80163378 != 0) && (IsLuigiRaceway())) { calculate_camera_up_vector(camera, arg2); nearestWaypoint = gNearestWaypointByPlayerId[playerId]; if (((nearestWaypoint >= 0x65) && (nearestWaypoint < 0xFA)) || @@ -6719,7 +6718,7 @@ void func_8001A220(UNUSED s32 arg0, s32 cameraId) { } s32 func_8001A310(s32 waypoint, s32 arg1) { - if ((GetCourse() == GetBowsersCastle()) && (arg1 != 0) && (waypoint >= 0xE7) && (waypoint < 0x1C2)) { + if ((IsBowsersCastle()) && (arg1 != 0) && (waypoint >= 0xE7) && (waypoint < 0x1C2)) { arg1 = 0; } return arg1; @@ -7500,7 +7499,7 @@ void func_8001BE78(void) { void func_8001C05C(void) { init_segment_racing(); gCurrentCourseId = COURSE_AWARD_CEREMONY; - SetCourseByClass(GetPodiumCeremony()); + SelectPodiumCeremony(); D_8016347C = 0; D_8016347E = 0; D_80163480 = 0; @@ -7573,7 +7572,7 @@ void func_8001C14C(void) { } void render_bomb_karts_wrap(s32 cameraId) { - if (GetCourse() == GetPodiumCeremony()) { + if (IsPodiumCeremony()) { if (gBombKarts[0].waypointIndex >= 16) { render_bomb_karts(PLAYER_FOUR); } diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 50622a10a..2ce053cac 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -778,7 +778,7 @@ void render_object_for_player(s32 cameraId) { } void render_snowing_effect(s32 playerId) { - if (GetCourse() == GetFrappeSnowland()) { + if (IsFrappeSnowland()) { if (gGamestate != 9) { if ((D_8015F894 == 0) && (gPlayerCountSelection1 == 1)) { render_object_snowflakes_particles(); @@ -1563,7 +1563,7 @@ void func_8005A3C0(void) { } void func_8005A71C(void) { - // if (GetCourse() == GetBowsersCastle()) { + // if (IsBowsersCastle()) { // func_80081210(); //} } @@ -1644,7 +1644,7 @@ void update_object(void) { // func_80074EE8(); // Grand prix balloons //} func_80076F2C(); - if ((s16) GetCourse() != GetFrappeSnowland()) { + if (!IsFrappeSnowland()) { update_leaf(); } } @@ -2596,7 +2596,7 @@ void func_8005CB60(s32 playerId, s32 lapCount) { case 1: /* switch 1 */ CM_ActivateSecondLapLakitu(playerId); // func_80079084(playerId); func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0xF0, 0x15)); - if ((GetCourse() == GetLuigiRaceway()) && (D_80165898 == 0) && + if ((IsLuigiRaceway()) && (D_80165898 == 0) && (gModeSelection != (s32) TIME_TRIALS)) { D_80165898 = 1; } @@ -2618,7 +2618,7 @@ void func_8005CB60(s32 playerId, s32 lapCount) { if (D_8018D114 == 2) { D_80165800[playerId] = 0; } - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { playerHUD[playerId].unk_81 = 1; } playerHUD[playerId].lap1CompletionTimeX = 0x0140; @@ -2935,22 +2935,22 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); - if ((GetCourse() == GetChocoMountain()) || (GetCourse() == GetRoyalRaceway())) { + if ((IsChocoMountain()) || (IsRoyalRaceway())) { func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080); } - if (GetCourse() == GetKalimariDesert()) { + if (IsKalimariDesert()) { func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080); } - if (GetCourse() == GetMooMooFarm()) { + if (IsMooMooFarm()) { func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080); } - if (GetCourse() == GetWarioStadium()) { + if (IsWarioStadium()) { func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080); } - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { func_8005DAD8(&player->unk_258[10 + arg1], 10, 0, 0x0080); } - if (GetCourse() == GetDkJungle()) { + if (IsDkJungle()) { func_8005DAD8(&player->unk_258[10 + arg1], 11, 0, 0x0080); } player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); @@ -2959,22 +2959,22 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); - if ((GetCourse() == GetChocoMountain()) || (GetCourse() == GetRoyalRaceway())) { + if ((IsChocoMountain()) || (IsRoyalRaceway())) { func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080); } - if (GetCourse() == GetKalimariDesert()) { + if (IsKalimariDesert()) { func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080); } - if (GetCourse() == GetMooMooFarm()) { + if (IsMooMooFarm()) { func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080); } - if (GetCourse() == GetWarioStadium()) { + if (IsWarioStadium()) { func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080); } - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { func_8005DAD8(&player->unk_258[10 + arg1], 10, 0, 0x0080); } - if (GetCourse() == GetDkJungle()) { + if (IsDkJungle()) { func_8005DAD8(&player->unk_258[10 + arg1], 11, 0, 0x0080); } player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); @@ -3201,44 +3201,44 @@ void func_8005ED48(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f); - if ((GetCourse() == GetChocoMountain()) || (GetCourse() == GetRoyalRaceway())) { + if ((IsChocoMountain()) || (IsRoyalRaceway())) { func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080); } - if (GetCourse() == GetKalimariDesert()) { + if (IsKalimariDesert()) { func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080); } - if (GetCourse() == GetMooMooFarm()) { + if (IsMooMooFarm()) { func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080); } - if (GetCourse() == GetWarioStadium()) { + if (IsWarioStadium()) { func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080); } - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { func_8005DAD8(&player->unk_258[10 + arg1], 10, 0, 0x0080); } - if (GetCourse() == GetDkJungle()) { + if (IsDkJungle()) { func_8005DAD8(&player->unk_258[10 + arg1], 11, 0, 0x0080); } player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); } else if (player->unk_258[10 + arg2].unk_01E > 0) { func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f); - if ((GetCourse() == GetChocoMountain()) || (GetCourse() == GetRoyalRaceway())) { + if ((IsChocoMountain()) || (IsRoyalRaceway())) { func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080); } - if (GetCourse() == GetKalimariDesert()) { + if (IsKalimariDesert()) { func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080); } - if (GetCourse() == GetMooMooFarm()) { + if (IsMooMooFarm()) { func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080); } - if (GetCourse() == GetWarioStadium()) { + if (IsWarioStadium()) { func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080); } - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { func_8005DAD8(&player->unk_258[10 + arg1], 0x000A, 0, 0x0080); } - if (GetCourse() == GetDkJungle()) { + if (IsDkJungle()) { func_8005DAD8(&player->unk_258[10 + arg1], 0x000B, 0, 0x0080); } player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); @@ -3402,44 +3402,44 @@ void func_8005F90C(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1); func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f); - if ((GetCourse() == GetChocoMountain()) || (GetCourse() == GetRoyalRaceway())) { + if ((IsChocoMountain()) || (IsRoyalRaceway())) { func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080); } - if (GetCourse() == GetKalimariDesert()) { + if (IsKalimariDesert()) { func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080); } - if (GetCourse() == GetMooMooFarm()) { + if (IsMooMooFarm()) { func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080); } - if (GetCourse() == GetWarioStadium()) { + if (IsWarioStadium()) { func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080); } - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { func_8005DAD8(&player->unk_258[10 + arg1], 0x000A, 0, 0x0080); } - if (GetCourse() == GetDkJungle()) { + if (IsDkJungle()) { func_8005DAD8(&player->unk_258[10 + arg1], 0x000B, 0, 0x0080); } player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); } else if (player->unk_258[10 + arg2].unk_01E > 0) { func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1); func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f); - if ((GetCourse() == GetChocoMountain()) || (GetCourse() == GetRoyalRaceway())) { + if ((IsChocoMountain()) || (IsRoyalRaceway())) { func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080); } - if (GetCourse() == GetKalimariDesert()) { + if (IsKalimariDesert()) { func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080); } - if (GetCourse() == GetMooMooFarm()) { + if (IsMooMooFarm()) { func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080); } - if (GetCourse() == GetWarioStadium()) { + if (IsWarioStadium()) { func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080); } - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { func_8005DAD8(&player->unk_258[10 + arg1], 0x000A, 0, 0x0080); } - if (GetCourse() == GetDkJungle()) { + if (IsDkJungle()) { func_8005DAD8(&player->unk_258[10 + arg1], 0x000B, 0, 0x0080); } player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); @@ -3638,13 +3638,13 @@ void func_800608E0(Player* player, s16 arg1, UNUSED s32 arg2, s8 arg3, UNUSED s8 var_f0 = 0.0f; } sp4C = (D_801652A0[arg3] - player->pos[1]) - 3.0f; - if ((player->unk_0DE & 1) && (GetCourse() != GetKoopaTroopaBeach())) { + if ((player->unk_0DE & 1) && (!IsKoopaTroopaBeach())) { var_f0 = 2.5f; sp4C = (f32) ((f64) (D_801652A0[arg3] - player->pos[1]) + 0.1); } func_8005D794(player, &player->unk_258[arg1], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0); func_8005D7D8(&player->unk_258[arg1], 3, var_f0); - if ((GetCourse() == GetBowsersCastle()) || (GetCourse() == GetBigDonut())) { + if ((IsBowsersCastle()) || (IsBigDonut())) { func_8005D800(&player->unk_258[arg1], 0, 0x00AF); } else { func_8005D800(&player->unk_258[arg1], 0x00FFFFFF, 0x00CF); @@ -3658,7 +3658,7 @@ void func_800608E0(Player* player, s16 arg1, UNUSED s32 arg2, s8 arg3, UNUSED s8 } void func_80060B14(Player* player, s16 arg1, s32 arg2, s8 arg3, s8 arg4) { - if ((GetCourse() != GetSkyscraper()) && (GetCourse() != GetRainbowRoad())) { + if ((!IsSkyscraper()) && (!IsRainbowRoad())) { if ((arg1 == 0) && ((player->unk_258[arg2].unk_01E > 0) || (player->unk_258[arg2].unk_01C == 0))) { func_800608E0(player, arg1, arg2, arg3, arg4); } else if (player->unk_258[arg2].unk_01E > 0) { @@ -3674,10 +3674,10 @@ void func_80060BCC(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 f32 sp48; f32 sp44; - if (GetCourse() == GetSkyscraper()) { + if (IsSkyscraper()) { return; } - if (GetCourse() == GetRainbowRoad()) { + if (IsRainbowRoad()) { return; } sp54 = random_int(0x0168U) - 0xB4; @@ -3712,7 +3712,7 @@ void func_80060F50(Player* player, s16 arg1, UNUSED s32 arg2, s8 arg3, UNUSED s8 func_8005D794(player, &player->unk_258[arg1], 0.0f, 0.0f, 0.0f, 0, 0); func_8005D7D8(&player->unk_258[arg1], 5, 4.0f); - if ((GetCourse() == GetBowsersCastle()) || (GetCourse() == GetBigDonut())) { + if ((IsBowsersCastle()) || (IsBigDonut())) { func_8005D800(&player->unk_258[arg1], 0xFF0000, 0xFF); } else { func_8005D800(&player->unk_258[arg1], 0xFFFFFF, 0xFF); @@ -4058,22 +4058,22 @@ void func_800624D8(Player* player, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s8 a switch (player->surfaceType) { case DIRT: for (var_s1 = 0; var_s1 < 10; var_s1++) { - if ((GetCourse() == GetChocoMountain()) || (GetCourse() == GetRoyalRaceway())) { + if ((IsChocoMountain()) || (IsRoyalRaceway())) { func_8005DAD8(&player->unk_258[0x1E + var_s1], 1, 0, 0x00A8); } - if (GetCourse() == GetKalimariDesert()) { + if (IsKalimariDesert()) { func_8005DAD8(&player->unk_258[0x1E + var_s1], 7, 0, 0x00A8); } - if (GetCourse() == GetMooMooFarm()) { + if (IsMooMooFarm()) { func_8005DAD8(&player->unk_258[0x1E + var_s1], 8, 0, 0x00A8); } - if (GetCourse() == GetWarioStadium()) { + if (IsWarioStadium()) { func_8005DAD8(&player->unk_258[0x1E + var_s1], 9, 0, 0x00A8); } - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { func_8005DAD8(&player->unk_258[0x1E + var_s1], 0x000A, 0, 0x00A8); } - if (GetCourse() == GetDkJungle()) { + if (IsDkJungle()) { func_8005DAD8(&player->unk_258[0x1E + var_s1], 0x000B, 0, 0x00A8); } func_80062484(player, &player->unk_258[0x1E + var_s1], var_s1); @@ -4628,7 +4628,7 @@ void func_80064184(Player* player, s16 arg1, s8 arg2, UNUSED s8 arg3) { f32 sp3C; sp40 = D_801652A0[arg2] - player->pos[1] - 3.0f; - if (((player->unk_0DE & 1) != 0) && (GetCourse() != GetKoopaTroopaBeach())) { + if (((player->unk_0DE & 1) != 0) && (!IsKoopaTroopaBeach())) { sp40 = D_801652A0[arg2] - player->pos[1] + 0.1; } diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index d74346d00..55d08c423 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -162,7 +162,7 @@ void init_item_window(s32 objectIndex) { temp_v0->sizeScaling = 1.0f; } -void func_8006EEE8(s32 courseId) { +void get_minimap_properties() { D_8018D240 = (uintptr_t) CM_GetProps()->Minimap.Texture; // This is incredibly dumb. MinimapDimensions ought to be something more like // `u16 MinimapDimensions[][2]` but that doesn't match for some insane reason @@ -191,8 +191,8 @@ void func_8006F008(void) { xOrientation = -1.0f; } - if (GetCourse() != GetPodiumCeremony()) { - func_8006EEE8((s32) gCurrentCourseId); + if (!IsPodiumCeremony()) { + get_minimap_properties(); } // Flip the minimap player markers @@ -203,7 +203,7 @@ void func_8006F008(void) { switch(gPlayerCount) { case 2: // Set X coord - if (GetCourse() != GetToadsTurnpike()) { + if (!IsToadsTurnpike()) { CM_GetProps()->Minimap.Pos[PLAYER_ONE].X = 265; CM_GetProps()->Minimap.Pos[PLAYER_TWO].X = 265; } else { diff --git a/src/code_8006E9C0.h b/src/code_8006E9C0.h index e5e9bc8d3..e41f7da1e 100644 --- a/src/code_8006E9C0.h +++ b/src/code_8006E9C0.h @@ -11,7 +11,7 @@ void clear_object_list(void); u8* dma_misc_textures(u8*, u8*, u32, u32); void load_mario_kart_64_logo(void); void init_item_window(s32); -void func_8006EEE8(s32); +void get_minimap_properties(void); void func_8006EF60(void); void func_8006F008(void); void func_8006F824(s32); diff --git a/src/code_80086E70.c b/src/code_80086E70.c index 89f51308a..3b0b0d5a0 100644 --- a/src/code_80086E70.c +++ b/src/code_80086E70.c @@ -977,7 +977,7 @@ void func_80089020(s32 playerId, f32* arg1) { var_f2 = -*arg1; } if (player->effects & 0xC0) { - if (GetCourse() == GetSherbetLand()) { + if (IsSherbetLand()) { if (var_f2 <= 0.5) { var_f0 = 0.025f; } else if (var_f2 <= 2.0) { @@ -998,7 +998,7 @@ void func_80089020(s32 playerId, f32* arg1) { var_f0 = 0.25f; } } - } else if (GetCourse() == GetSherbetLand()) { + } else if (IsSherbetLand()) { if (var_f2 <= 0.5) { var_f0 = 0.025f; } else if (var_f2 <= 2.0) { diff --git a/src/effects.c b/src/effects.c index 06e476117..da583c0c4 100644 --- a/src/effects.c +++ b/src/effects.c @@ -1698,7 +1698,7 @@ void func_80090178(Player* player, s8 playerId, Vec3f arg2, Vec3f arg3) { f32 sp18[4] = { 10.0f, -10.0f, -575.0f, 575.0f }; f32 sp08[4] = { 575.0f, -575.0f, 10.0f, -10.0f }; - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { test = player->nearestWaypointId; temp_v1 = &D_80164550[gCopyPathIndexByPlayerId[playerId]][test]; arg2[0] = temp_v1->posX; @@ -1710,28 +1710,28 @@ void func_80090178(Player* player, s8 playerId, Vec3f arg2, Vec3f arg3) { arg3[0] = temp_v1->posX; arg3[1] = temp_v1->posY; arg3[2] = temp_v1->posZ; - } else if (GetCourse() == GetBlockFort()) { + } else if (IsBlockFort()) { arg2[0] = spF8[playerId]; arg2[1] = 0.0f; arg2[2] = spE8[playerId]; arg3[0] = spD8[playerId]; arg3[1] = 0.0f; arg3[2] = spC8[playerId]; - } else if (GetCourse() == GetSkyscraper()) { + } else if (IsSkyscraper()) { arg2[0] = spB8[playerId]; arg2[1] = 480.0f; arg2[2] = spA8[playerId]; arg3[0] = sp98[playerId]; arg3[1] = 480.0f; arg3[2] = sp88[playerId]; - } else if (GetCourse() == GetDoubleDeck()) { + } else if (IsDoubleDeck()) { arg2[0] = sp78[playerId]; arg2[1] = 0.0f; arg2[2] = sp68[playerId]; arg3[0] = sp58[playerId]; arg3[1] = 0.0f; arg3[2] = sp48[playerId]; - } else if (GetCourse() == GetBigDonut()) { + } else if (IsBigDonut()) { arg2[0] = sp38[playerId]; arg2[1] = 200.0f; arg2[2] = sp28[playerId]; @@ -1799,14 +1799,14 @@ void func_80090868(Player* player) { player->unk_0CA |= 2; player->unk_0C8 = 0; if ((player->unk_0DE & 1) == 1) { - if ((GetCourse() == GetBowsersCastle()) || (GetCourse() == GetBigDonut())) { + if ((IsBowsersCastle()) || (IsBigDonut())) { player->unk_0CA |= 0x1000; } else { player->unk_0CA |= 0x2000; } - if ((GetCourse() == GetSherbetLand()) || (GetCourse() == GetSkyscraper()) || - (GetCourse() == GetRainbowRoad())) { + if ((IsSherbetLand()) || (IsSkyscraper()) || + (IsRainbowRoad())) { player->unk_0CA &= ~0x3000; } } diff --git a/src/ending/code_80281780.c b/src/ending/code_80281780.c index 1085fb30c..83d75a63d 100644 --- a/src/ending/code_80281780.c +++ b/src/ending/code_80281780.c @@ -93,7 +93,7 @@ void setup_podium_ceremony(void) { Camera* camera = &cameras[0]; gCurrentCourseId = COURSE_ROYAL_RACEWAY; - SetCourseByClass(GetPodiumCeremony()); + SelectPodiumCeremony(); D_800DC5B4 = (u16) 1; gIsMirrorMode = 0; gGotoMenu = 0xFFFF; diff --git a/src/engine/World.cpp b/src/engine/World.cpp index 6620a2815..88c6717c6 100644 --- a/src/engine/World.cpp +++ b/src/engine/World.cpp @@ -29,8 +29,10 @@ World::~World() { Course* CurrentCourse; Cup* CurrentCup; -void World::AddCourse(Course* course) { - gWorldInstance.Courses.push_back(course); +Course* World::AddCourse(std::unique_ptr course) { + Course* ptr = course.get(); + gWorldInstance.Courses.push_back(std::move(course)); + return ptr; } void World::AddCup(Cup* cup) { @@ -97,7 +99,7 @@ void World::SetCourse(const char* name) { //! @todo Use content dictionary instead for (size_t i = 0; i < Courses.size(); i++) { if (strcmp(Courses[i]->Props.Name, name) == 0) { - CurrentCourse = Courses[i]; + CurrentCourse = Courses[i].get(); break; } } @@ -110,7 +112,7 @@ void World::NextCourse() { } else { CourseIndex = 0; } - gWorldInstance.CurrentCourse = Courses[CourseIndex]; + gWorldInstance.CurrentCourse = Courses[CourseIndex].get(); } void World::PreviousCourse() { @@ -119,7 +121,7 @@ void World::PreviousCourse() { } else { CourseIndex = Courses.size() - 1; } - gWorldInstance.CurrentCourse = Courses[CourseIndex]; + gWorldInstance.CurrentCourse = Courses[CourseIndex].get(); } AActor* World::AddActor(AActor* actor) { diff --git a/src/engine/World.h b/src/engine/World.h index 91287b162..f32cf00ff 100644 --- a/src/engine/World.h +++ b/src/engine/World.h @@ -54,7 +54,7 @@ public: explicit World(); ~World(); - void AddCourse(Course* course); + Course* AddCourse(std::unique_ptr course); AActor* AddActor(AActor* actor); struct Actor* AddBaseActor(); @@ -96,6 +96,16 @@ public: // These are only for browsing through the course list void SetCourse(const char*); + template + void SetCourseByType() { + for (const auto& course : Courses) { + if (dynamic_cast(course.get())) { + CurrentCourse = course.get(); + return; + } + } + printf("World::SetCourseByType() No course by the type found"); + } void NextCourse(void); void PreviousCourse(void); @@ -122,7 +132,7 @@ public: std::vector> Crossings; // Holds all available courses - std::vector Courses; + std::vector> Courses; size_t CourseIndex = 0; // For browsing courses. private: diff --git a/src/engine/objects/BombKart.cpp b/src/engine/objects/BombKart.cpp index 53b4a4262..8aaaae6cf 100644 --- a/src/engine/objects/BombKart.cpp +++ b/src/engine/objects/BombKart.cpp @@ -118,7 +118,7 @@ void OBombKart::Tick() { return; } - if (((Unk_4A != 1) || (GetCourse() == GetPodiumCeremony()))) { + if (((Unk_4A != 1) || (IsPodiumCeremony()))) { newPos[0] = Pos[0]; newPos[1] = Pos[1]; newPos[2] = Pos[2]; @@ -128,7 +128,7 @@ void OBombKart::Tick() { bounceTimer = BounceTimer; circleTimer = CircleTimer; if ((state != States::DISABLED) && (state != States::EXPLODE)) { - if (GetCourse() == GetPodiumCeremony()) { + if (IsPodiumCeremony()) { if (D_8016347E == 1) { player = gPlayerFour; temp_f0 = newPos[0] - player->pos[0]; @@ -152,7 +152,7 @@ void OBombKart::Tick() { if ((((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) + (temp_f12 * temp_f12)) < 25.0f) { state = States::EXPLODE; circleTimer = 0; - if (GetCourse() == GetFrappeSnowland()) { + if (IsFrappeSnowland()) { player->soundEffects |= 0x01000000; } else { player->soundEffects |= 0x400000; @@ -346,7 +346,7 @@ void OBombKart::Draw(s32 cameraId) { return; } - if (GetCourse() == GetPodiumCeremony()) { + if (IsPodiumCeremony()) { if ((_idx == 0) && (WaypointIndex < 16)) { return; } else { diff --git a/src/engine/objects/GrandPrixBalloons.cpp b/src/engine/objects/GrandPrixBalloons.cpp index 544a3e4d1..2bd58ef13 100644 --- a/src/engine/objects/GrandPrixBalloons.cpp +++ b/src/engine/objects/GrandPrixBalloons.cpp @@ -139,7 +139,7 @@ void OGrandPrixBalloons::func_80074924(s32 objectIndex) { object = &gObjectList[objectIndex]; object->sizeScaling = 0.15f; - if (GetCourse() == GetMarioRaceway()) { + if (IsMarioRaceway()) { sp2C = random_int(0x00C8U); sp28 = random_int(_numBalloons3); sp24 = random_int(0x0096U); @@ -147,7 +147,7 @@ void OGrandPrixBalloons::func_80074924(s32 objectIndex) { object->origin_pos[0] = (f32) ((((f64) Pos.x + 100.0) - (f64) sp2C) * (f64) xOrientation); object->origin_pos[1] = (f32) (Pos.y + sp28); object->origin_pos[2] = (f32) (((f64) Pos.z + 200.0) - (f64) sp24); - } else if (GetCourse() == GetRoyalRaceway()) { + } else if (IsRoyalRaceway()) { sp2C = random_int(0x0168U); sp28 = random_int(_numBalloons3); sp24 = random_int(0x00B4U); @@ -155,7 +155,7 @@ void OGrandPrixBalloons::func_80074924(s32 objectIndex) { object->origin_pos[0] = (f32) ((((f64) Pos.x + 180.0) - (f64) sp2C) * (f64) xOrientation); object->origin_pos[1] = (f32) (Pos.y + sp28); object->origin_pos[2] = (f32) (((f64) Pos.z + 200.0) - (f64) sp24); - } else if (GetCourse() == GetLuigiRaceway()) { + } else if (IsLuigiRaceway()) { sp2C = random_int(0x012CU); sp28 = random_int(_numBalloons3); sp24 = random_int(0x0096U); diff --git a/src/engine/objects/HotAirBalloon.cpp b/src/engine/objects/HotAirBalloon.cpp index 4e337d98e..f1e367d8d 100644 --- a/src/engine/objects/HotAirBalloon.cpp +++ b/src/engine/objects/HotAirBalloon.cpp @@ -21,7 +21,7 @@ OHotAirBalloon::OHotAirBalloon(const FVector& pos) { D_80165898 = 0; // Spawn balloon on second lap. - if (GetCourse() == GetLuigiRaceway()) { + if (IsLuigiRaceway()) { _visible = (bool*)&D_80165898; } else { // Spawn balloon on race start bool mod = true; diff --git a/src/engine/objects/Lakitu.cpp b/src/engine/objects/Lakitu.cpp index 92f164e95..988d3bc22 100644 --- a/src/engine/objects/Lakitu.cpp +++ b/src/engine/objects/Lakitu.cpp @@ -297,7 +297,7 @@ void OLakitu::func_800729EC(s32 objectIndex) { D_8018D2BC = 1; D_8018D2A4 = 1; - if (GetCourse() != GetYoshiValley()) { + if (!IsYoshiValley()) { for (i = 0; i < gPlayerCount; i++) { playerHUD[i].unk_81 = temp_v1; } @@ -366,7 +366,7 @@ void OLakitu::func_800797AC(s32 playerId) { objectIndex = gIndexLakituList[playerId]; player = &gPlayerOne[playerId]; - //if ((GetCourse() == GetSherbetLand()) && (player->unk_0CA & 1)) { + //if ((IsSherbetLand()) && (player->unk_0CA & 1)) { if ((CM_GetProps()->LakituTowType == LakituTowType::ICE) && (player->unk_0CA & 1)) { init_object(objectIndex, 7); player->unk_0CA |= 0x10; diff --git a/src/engine/objects/TrashBin.cpp b/src/engine/objects/TrashBin.cpp index 89ac5dae5..57c702275 100644 --- a/src/engine/objects/TrashBin.cpp +++ b/src/engine/objects/TrashBin.cpp @@ -32,7 +32,7 @@ OTrashBin::OTrashBin(const FVector& pos, const IRotator& rotation, f32 scale, OT init_object(_objectIndex, 0); - if (GetCourse() != GetBansheeBoardwalk()) { + if (!IsBansheeBoardwalk()) { _drawBin = true; } } diff --git a/src/menu_items.c b/src/menu_items.c index 713250882..d65e4b2a4 100644 --- a/src/menu_items.c +++ b/src/menu_items.c @@ -2528,12 +2528,15 @@ void func_80095574(void) { } else { debug_print_str2(0x000000AA, 0x00000064, "off"); } - if ((gCurrentCourseId >= (NUM_COURSES - 1)) || (gCurrentCourseId < 0)) { - gCurrentCourseId = 0; - } + + // This reset is not necessary. It wraps around automatically. + // if ((GetCourseIndex() >= (NUM_COURSES - 1)) || (GetCourseIndex() < 0)) { + // gCurrentCourseId = 0; + // } print_str_num(0x00000050, 0x0000006E, "map_number", GetCourseIndex()); - // This isn't functionally equivallent, but who cares. - if (gCurrentCourseId < COURSE_TOADS_TURNPIKE) { + + // Bump the text over by 1 character width when the track id becomes two digits (10, 11, 12 etc.) + if (GetCourseIndex() < 10) { var_v0 = 0; } else { var_v0 = 8; @@ -4889,7 +4892,7 @@ void func_8009CE64(s32 arg0) { gCCSelection = (s32) 1; switch (gNextDemoId) { /* switch 4 */ case 0: /* switch 4 */ - SetCourseByClass(GetMarioRaceway()); + SelectMarioRaceway(); CM_SetCup(GetFlowerCup()); SetCupCursorPosition(COURSE_FOUR); gCurrentCourseId = 0; @@ -4900,7 +4903,7 @@ void func_8009CE64(s32 arg0) { gModeSelection = 0; break; case 1: /* switch 4 */ - SetCourseByClass(GetLuigiRaceway()); + SelectLuigiRaceway(); CM_SetCup(GetMushroomCup()); SetCupCursorPosition(COURSE_ONE); gCurrentCourseId = (s16) 1; @@ -4912,7 +4915,7 @@ void func_8009CE64(s32 arg0) { gModeSelection = 2; break; case 2: /* switch 4 */ - SetCourseByClass(GetKalimariDesert()); + SelectKalimariDesert(); CM_SetCup(GetMushroomCup()); SetCupCursorPosition(COURSE_FOUR); gCurrentCourseId = COURSE_KALIMARI_DESERT; @@ -4923,7 +4926,7 @@ void func_8009CE64(s32 arg0) { gModeSelection = 0; break; case 3: /* switch 4 */ - SetCourseByClass(GetWarioStadium()); + SelectWarioStadium(); CM_SetCup(GetStarCup()); SetCupCursorPosition(COURSE_ONE); gCurrentCourseId = 0x000E; @@ -4936,7 +4939,7 @@ void func_8009CE64(s32 arg0) { gModeSelection = (s32) 2; break; case 4: /* switch 4 */ - SetCourseByClass(GetBowsersCastle()); + SelectBowsersCastle(); CM_SetCup(GetStarCup()); SetCupCursorPosition(COURSE_FOUR); gCurrentCourseId = 2; @@ -4947,7 +4950,7 @@ void func_8009CE64(s32 arg0) { gModeSelection = 0; break; case 5: /* switch 4 */ - SetCourseByClass(GetSherbetLand()); + SelectSherbetLand(); CM_SetCup(GetFlowerCup()); SetCupCursorPosition(COURSE_TWO); gCurrentCourseId = 0x000C; @@ -5034,8 +5037,8 @@ void func_8009CE64(s32 arg0) { } } - if (GetCourse() == GetBlockFort() || GetCourse() == GetSkyscraper() || GetCourse() == GetDoubleDeck() || - GetCourse() == GetBigDonut()) { + if (IsBlockFort() || IsSkyscraper() || IsDoubleDeck() || + IsBigDonut()) { gModeSelection = BATTLE; if (gPlayerCountSelection1 == 1) { @@ -8230,7 +8233,9 @@ void func_800A6034(MenuItem* arg0) { set_text_color(TEXT_BLUE_GREEN_RED_CYCLE_2); print_text1_center_mode_2(arg0->column + 0x41, arg0->row + 0xA0, text, 0, 0.85f, 1.0f); text = CM_GetProps()->Name; - set_text_color((s32) gCurrentCourseId % 4); + //! @warning this used to be gCurrentCourseId % 4 + // Hopefully this is equivallent. + set_text_color((s32) GetCourseIndex() % 4); print_text1_center_mode_2(arg0->column + 0x41, arg0->row + 0xC3, text, 0, 0.65f, 0.85f); } } diff --git a/src/player_controller.c b/src/player_controller.c index df4b794bb..46038dbda 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -1711,7 +1711,7 @@ void func_8002C11C(Player* player) { } void func_8002C17C(Player* player, s8 playerId) { - if (GetCourse() == GetYoshiValley()) { + if (IsYoshiValley()) { if ((player->collision.surfaceDistance[2] >= 600.0f) && (D_80165330[playerId] == 0)) { D_80165330[playerId] = 1; gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; @@ -1724,7 +1724,7 @@ void func_8002C17C(Player* player, s8 playerId) { D_80165330[playerId] = 0; } } - } else if (GetCourse() == GetFrappeSnowland()) { + } else if (IsFrappeSnowland()) { if ((player->surfaceType == SNOW_OFFROAD) && (D_80165330[playerId] == 0)) { D_80165330[playerId] = 1; gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; @@ -1734,7 +1734,7 @@ void func_8002C17C(Player* player, s8 playerId) { gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } - } else if (GetCourse() == GetRoyalRaceway()) { + } else if (IsRoyalRaceway()) { if (((player->effects & BOOST_RAMP_ASPHALT_EFFECT) != 0) && (D_80165330[playerId] == 0)) { D_80165330[playerId] = 1; gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; @@ -1744,7 +1744,7 @@ void func_8002C17C(Player* player, s8 playerId) { gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } - } else if (GetCourse() == GetRainbowRoad()) { + } else if (IsRainbowRoad()) { if ((player->collision.surfaceDistance[2] >= 600.0f) && (D_80165330[playerId] == 0)) { D_80165330[playerId] = 1; gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; @@ -1778,9 +1778,9 @@ void func_8002C4F8(Player* player, s8 arg1) { if ((player->unk_0DE & 4) != 4) { player->unk_0DE |= 8; player->unk_0DE |= 4; - if ((GetCourse() != GetKoopaTroopaBeach()) && (GetCourse() != GetSkyscraper()) && - (GetCourse() != GetRainbowRoad()) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { - if ((GetCourse() == GetBowsersCastle()) || (GetCourse() == GetBigDonut())) { + if ((!IsKoopaTroopaBeach()) && (!IsSkyscraper()) && + (!IsRainbowRoad()) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((IsBowsersCastle()) || (IsBigDonut())) { func_800C9060((u8) arg1, 0x1900801CU); } else { func_800C9060((u8) arg1, 0x19008008U); @@ -1788,8 +1788,8 @@ void func_8002C4F8(Player* player, s8 arg1) { } } } - if ((GetCourse() == GetKoopaTroopaBeach()) || (GetCourse() == GetSkyscraper()) || - (GetCourse() == GetRainbowRoad())) { + if ((IsKoopaTroopaBeach()) || (IsSkyscraper()) || + (IsRainbowRoad())) { player->unk_0DE &= ~0x000C; } if ((player->boundingBoxSize < (D_801652A0[arg1] - player->pos[1])) && @@ -2254,7 +2254,7 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->unk_DB4.unkC = 1.5f; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - if (((player->unk_0C2 < 0xB) && (player->unk_0C2 >= 4)) && (GetCourse() == GetBowsersCastle())) { + if (((player->unk_0C2 < 0xB) && (player->unk_0C2 >= 4)) && (IsBowsersCastle())) { func_800CADD0((u8) playerId, player->unk_0C2 / 14.0f); } else { func_800CADD0((u8) playerId, player->unk_0C2 / 25.0f); diff --git a/src/port/Game.cpp b/src/port/Game.cpp index caccd9f90..4cea9c5e2 100644 --- a/src/port/Game.cpp +++ b/src/port/Game.cpp @@ -69,29 +69,7 @@ extern "C" void Timer_Update(); // Create the world instance World gWorldInstance; -MarioRaceway* gMarioRaceway; -ChocoMountain* gChocoMountain; -BowsersCastle* gBowsersCastle; -BansheeBoardwalk* gBansheeBoardwalk; -YoshiValley* gYoshiValley; -FrappeSnowland* gFrappeSnowland; -KoopaTroopaBeach* gKoopaTroopaBeach; -RoyalRaceway* gRoyalRaceway; -LuigiRaceway* gLuigiRaceway; -MooMooFarm* gMooMooFarm; -ToadsTurnpike* gToadsTurnpike; -KalimariDesert* gKalimariDesert; -SherbetLand* gSherbetLand; -RainbowRoad* gRainbowRoad; -WarioStadium* gWarioStadium; -BlockFort* gBlockFort; -Skyscraper* gSkyscraper; -DoubleDeck* gDoubleDeck; -DKJungle* gDkJungle; -BigDonut* gBigDonut; -PodiumCeremony* gPodiumCeremony; -Harbour* gHarbour; -TestCourse* gTestCourse; +std::unique_ptr gPodiumCeremony; Cup* gMushroomCup; Cup* gFlowerCup; @@ -108,65 +86,52 @@ Editor::Editor gEditor; s32 gTrophyIndex = NULL; void CustomEngineInit() { - - gMarioRaceway = new MarioRaceway(); - gChocoMountain = new ChocoMountain(); - gBowsersCastle = new BowsersCastle(); - gBansheeBoardwalk = new BansheeBoardwalk(); - gYoshiValley = new YoshiValley(); - gFrappeSnowland = new FrappeSnowland(); - gKoopaTroopaBeach = new KoopaTroopaBeach(); - gRoyalRaceway = new RoyalRaceway(); - gLuigiRaceway = new LuigiRaceway(); - gMooMooFarm = new MooMooFarm(); - gToadsTurnpike = new ToadsTurnpike(); - gKalimariDesert = new KalimariDesert(); - gSherbetLand = new SherbetLand(); - gRainbowRoad = new RainbowRoad(); - gWarioStadium = new WarioStadium(); - gBlockFort = new BlockFort(); - gSkyscraper = new Skyscraper(); - gDoubleDeck = new DoubleDeck(); - gDkJungle = new DKJungle(); - gBigDonut = new BigDonut(); - gPodiumCeremony = new PodiumCeremony(); - gHarbour = new Harbour(); - gTestCourse = new TestCourse(); - /* Add all courses to the global course list */ - gWorldInstance.AddCourse(gMarioRaceway); - gWorldInstance.AddCourse(gChocoMountain); - gWorldInstance.AddCourse(gBowsersCastle); - gWorldInstance.AddCourse(gBansheeBoardwalk); - gWorldInstance.AddCourse(gYoshiValley); - gWorldInstance.AddCourse(gFrappeSnowland); - gWorldInstance.AddCourse(gKoopaTroopaBeach); - gWorldInstance.AddCourse(gRoyalRaceway); - gWorldInstance.AddCourse(gLuigiRaceway); - gWorldInstance.AddCourse(gMooMooFarm); - gWorldInstance.AddCourse(gToadsTurnpike); - gWorldInstance.AddCourse(gKalimariDesert); - gWorldInstance.AddCourse(gSherbetLand); - gWorldInstance.AddCourse(gRainbowRoad); - gWorldInstance.AddCourse(gWarioStadium); - gWorldInstance.AddCourse(gBlockFort); - gWorldInstance.AddCourse(gSkyscraper); - gWorldInstance.AddCourse(gDoubleDeck); - gWorldInstance.AddCourse(gDkJungle); - gWorldInstance.AddCourse(gBigDonut); - gWorldInstance.AddCourse(gHarbour); - gWorldInstance.AddCourse(gTestCourse); + Course* mario = gWorldInstance.AddCourse(std::make_unique()); + Course* choco = gWorldInstance.AddCourse(std::make_unique()); + Course* bowser = gWorldInstance.AddCourse(std::make_unique()); + Course* banshee = gWorldInstance.AddCourse(std::make_unique()); + Course* yoshi = gWorldInstance.AddCourse(std::make_unique()); + Course* frappe = gWorldInstance.AddCourse(std::make_unique()); + Course* koopa = gWorldInstance.AddCourse(std::make_unique()); + Course* royal = gWorldInstance.AddCourse(std::make_unique()); + Course* luigi = gWorldInstance.AddCourse(std::make_unique()); + Course* mooMoo = gWorldInstance.AddCourse(std::make_unique()); + Course* toads = gWorldInstance.AddCourse(std::make_unique()); + Course* kalimari = gWorldInstance.AddCourse(std::make_unique()); + Course* sherbet = gWorldInstance.AddCourse(std::make_unique()); + Course* rainbow = gWorldInstance.AddCourse(std::make_unique()); + Course* wario = gWorldInstance.AddCourse(std::make_unique()); + Course* block = gWorldInstance.AddCourse(std::make_unique()); + Course* skyscraper = gWorldInstance.AddCourse(std::make_unique()); + Course* doubleDeck = gWorldInstance.AddCourse(std::make_unique()); + Course* dkJungle = gWorldInstance.AddCourse(std::make_unique()); + Course* bigDonut = gWorldInstance.AddCourse(std::make_unique()); + Course* harbour = gWorldInstance.AddCourse(std::make_unique()); + Course* testCourse = gWorldInstance.AddCourse(std::make_unique()); - gMushroomCup = new Cup("mk:mushroom_cup", "mushroom cup", - std::vector{ gLuigiRaceway, gMooMooFarm, gKoopaTroopaBeach, gKalimariDesert }); - gFlowerCup = new Cup("mk:flower_cup", "flower cup", - std::vector{ gToadsTurnpike, gFrappeSnowland, gChocoMountain, gMarioRaceway }); - gStarCup = new Cup("mk:star_cup", "star cup", - std::vector{ gWarioStadium, gSherbetLand, gRoyalRaceway, gBowsersCastle }); - gSpecialCup = new Cup("mk:special_cup", "special cup", - std::vector{ gDkJungle, gYoshiValley, gBansheeBoardwalk, gRainbowRoad }); - gBattleCup = - new Cup("mk:battle_cup", "battle", std::vector{ gBigDonut, gBlockFort, gDoubleDeck, gSkyscraper }); + gPodiumCeremony = std::make_unique(); + + // Construct cups with vectors of Course* (non-owning references) + gMushroomCup = new Cup("mk:mushroom_cup", "Mushroom Cup", { + luigi, mooMoo, koopa, kalimari + }); + + gFlowerCup = new Cup("mk:flower_cup", "Flower Cup", { + toads, frappe, choco, mario + }); + + gStarCup = new Cup("mk:star_cup", "Star Cup", { + wario, sherbet, royal, bowser + }); + + gSpecialCup = new Cup("mk:special_cup", "Special Cup", { + dkJungle, yoshi, banshee, rainbow + }); + + gBattleCup = new Cup("mk:battle_cup", "Battle Cup", { + bigDonut, block, doubleDeck, skyscraper + }); /* Instantiate Cups */ gWorldInstance.AddCup(gMushroomCup); @@ -176,7 +141,7 @@ void CustomEngineInit() { gWorldInstance.AddCup(gBattleCup); /* Set default course; mario raceway */ - gWorldInstance.CurrentCourse = gMarioRaceway; + SelectMarioRaceway(); gWorldInstance.CurrentCup = gMushroomCup; gWorldInstance.CurrentCup->CursorPosition = 3; gWorldInstance.CupIndex = 0; @@ -199,30 +164,6 @@ void CustomEngineInit() { } void CustomEngineDestroy() { - delete gMarioRaceway; - delete gChocoMountain; - delete gBowsersCastle; - delete gBansheeBoardwalk; - delete gYoshiValley; - delete gFrappeSnowland; - delete gKoopaTroopaBeach; - delete gRoyalRaceway; - delete gLuigiRaceway; - delete gMooMooFarm; - delete gToadsTurnpike; - delete gKalimariDesert; - delete gSherbetLand; - delete gRainbowRoad; - delete gWarioStadium; - delete gBlockFort; - delete gSkyscraper; - delete gDoubleDeck; - delete gDkJungle; - delete gBigDonut; - delete gPodiumCeremony; - delete gHarbour; - delete gTestCourse; - delete gMushroomCup; delete gFlowerCup; delete gStarCup; @@ -311,7 +252,7 @@ void SetCourseById(s32 course) { return; } gWorldInstance.CourseIndex = course; - gWorldInstance.CurrentCourse = gWorldInstance.Courses[gWorldInstance.CourseIndex]; + gWorldInstance.CurrentCourse = gWorldInstance.Courses[gWorldInstance.CourseIndex].get(); } void CM_VehicleCollision(s32 playerId, Player* player) { @@ -760,89 +701,51 @@ f32 CM_GetWaterLevel(Vec3f pos, Collision* collision) { return gWorldInstance.CurrentCourse->GetWaterLevel(fPos, collision); } -void* GetMarioRaceway(void) { - return gMarioRaceway; -} +// clang-format off +bool IsMarioRaceway() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsLuigiRaceway() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsChocoMountain() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsBowsersCastle() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsBansheeBoardwalk() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsYoshiValley() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsFrappeSnowland() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsKoopaTroopaBeach() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsRoyalRaceway() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsMooMooFarm() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsToadsTurnpike() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsKalimariDesert() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsSherbetLand() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsRainbowRoad() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsWarioStadium() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsBlockFort() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsSkyscraper() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsDoubleDeck() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsDkJungle() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsBigDonut() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } +bool IsPodiumCeremony() { return dynamic_cast(gWorldInstance.CurrentCourse) != nullptr; } -void* GetLuigiRaceway(void) { - return gLuigiRaceway; -} - -void* GetChocoMountain(void) { - return gChocoMountain; -} - -void* GetBowsersCastle(void) { - return gBowsersCastle; -} - -void* GetBansheeBoardwalk(void) { - return gBansheeBoardwalk; -} - -void* GetYoshiValley(void) { - return gYoshiValley; -} - -void* GetFrappeSnowland(void) { - return gFrappeSnowland; -} - -void* GetKoopaTroopaBeach(void) { - return gKoopaTroopaBeach; -} - -void* GetRoyalRaceway(void) { - return gRoyalRaceway; -} - -void* GetMooMooFarm(void) { - return gMooMooFarm; -} - -void* GetToadsTurnpike(void) { - return gToadsTurnpike; -} - -void* GetKalimariDesert(void) { - return gKalimariDesert; -} - -void* GetSherbetLand(void) { - return gSherbetLand; -} - -void* GetRainbowRoad(void) { - return gRainbowRoad; -} - -void* GetWarioStadium(void) { - return gWarioStadium; -} - -void* GetBlockFort(void) { - return gBlockFort; -} - -void* GetSkyscraper(void) { - return gSkyscraper; -} - -void* GetDoubleDeck(void) { - return gDoubleDeck; -} - -void* GetDkJungle(void) { - return gDkJungle; -} - -void* GetBigDonut(void) { - return gBigDonut; -} - -void* GetPodiumCeremony(void) { - return gPodiumCeremony; -} +void SelectMarioRaceway() { gWorldInstance.SetCourseByType(); } +void SelectLuigiRaceway() { gWorldInstance.SetCourseByType(); } +void SelectChocoMountain() { gWorldInstance.SetCourseByType(); } +void SelectBowsersCastle() { gWorldInstance.SetCourseByType(); } +void SelectBansheeBoardwalk() { gWorldInstance.SetCourseByType(); } +void SelectYoshiValley() { gWorldInstance.SetCourseByType(); } +void SelectFrappeSnowland() { gWorldInstance.SetCourseByType(); } +void SelectKoopaTroopaBeach() { gWorldInstance.SetCourseByType(); } +void SelectRoyalRaceway() { gWorldInstance.SetCourseByType(); } +void SelectMooMooFarm() { gWorldInstance.SetCourseByType(); } +void SelectToadsTurnpike() { gWorldInstance.SetCourseByType(); } +void SelectKalimariDesert() { gWorldInstance.SetCourseByType(); } +void SelectSherbetLand() { gWorldInstance.SetCourseByType(); } +void SelectRainbowRoad() { gWorldInstance.SetCourseByType(); } +void SelectWarioStadium() { gWorldInstance.SetCourseByType(); } +void SelectBlockFort() { gWorldInstance.SetCourseByType(); } +void SelectSkyscraper() { gWorldInstance.SetCourseByType(); } +void SelectDoubleDeck() { gWorldInstance.SetCourseByType(); } +void SelectDkJungle() { gWorldInstance.SetCourseByType(); } +void SelectBigDonut() { gWorldInstance.SetCourseByType(); } +void SelectPodiumCeremony() { gWorldInstance.CurrentCourse = gPodiumCeremony.get(); } +// clang-format on void* GetMushroomCup(void) { return gMushroomCup; diff --git a/src/port/Game.h b/src/port/Game.h index 2731372ca..14cc0edf6 100644 --- a/src/port/Game.h +++ b/src/port/Game.h @@ -157,47 +157,49 @@ void CM_CleanWorld(void); f32 CM_GetWaterLevel(Vec3f pos, Collision* collision); -void* GetMarioRaceway(void); +bool IsMarioRaceway(); +bool IsLuigiRaceway(); +bool IsChocoMountain(); +bool IsBowsersCastle(); +bool IsBansheeBoardwalk(); +bool IsYoshiValley(); +bool IsFrappeSnowland(); +bool IsKoopaTroopaBeach(); +bool IsRoyalRaceway(); +bool IsMooMooFarm(); +bool IsToadsTurnpike(); +bool IsKalimariDesert(); +bool IsSherbetLand(); +bool IsRainbowRoad(); +bool IsWarioStadium(); +bool IsBlockFort(); +bool IsSkyscraper(); +bool IsDoubleDeck(); +bool IsDkJungle(); +bool IsBigDonut(); +bool IsPodiumCeremony(); -void* GetLuigiRaceway(void); - -void* GetChocoMountain(void); - -void* GetBowsersCastle(void); - -void* GetBansheeBoardwalk(void); - -void* GetYoshiValley(void); - -void* GetFrappeSnowland(void); - -void* GetKoopaTroopaBeach(void); - -void* GetRoyalRaceway(void); - -void* GetMooMooFarm(void); - -void* GetToadsTurnpike(void); - -void* GetKalimariDesert(void); - -void* GetSherbetLand(void); - -void* GetRainbowRoad(void); - -void* GetWarioStadium(void); - -void* GetBlockFort(void); - -void* GetSkyscraper(void); - -void* GetDoubleDeck(void); - -void* GetDkJungle(void); - -void* GetBigDonut(void); - -void* GetPodiumCeremony(void); +void SelectMarioRaceway(); +void SelectLuigiRaceway(); +void SelectChocoMountain(); +void SelectBowsersCastle(); +void SelectBansheeBoardwalk(); +void SelectYoshiValley(); +void SelectFrappeSnowland(); +void SelectKoopaTroopaBeach(); +void SelectRoyalRaceway(); +void SelectMooMooFarm(); +void SelectToadsTurnpike(); +void SelectKalimariDesert(); +void SelectSherbetLand(); +void SelectRainbowRoad(); +void SelectWarioStadium(); +void SelectBlockFort(); +void SelectSkyscraper(); +void SelectDoubleDeck(); +void SelectDkJungle(); +void SelectBigDonut(); +void SelectPodiumCeremony(); void* GetMushroomCup(void); diff --git a/src/port/ui/ContentBrowser.cpp b/src/port/ui/ContentBrowser.cpp index 826477ea5..5390d8a9d 100644 --- a/src/port/ui/ContentBrowser.cpp +++ b/src/port/ui/ContentBrowser.cpp @@ -147,12 +147,13 @@ namespace Editor { } } + // When resetting the known content, we need to also pop the custom courses + // out of World::Courses vector. Otherwise, duplicate courses would show up for users. void ContentBrowserWindow::RemoveCustomTracksFromTrackList() { for (auto& track : Tracks) { auto it = gWorldInstance.Courses.begin(); while (it != gWorldInstance.Courses.end()) { - if (track.course == *it) { - delete *it; + if (track.course == it->get()) { it = gWorldInstance.Courses.erase(it); } else { ++it; @@ -233,27 +234,31 @@ namespace Editor { std::string name = dir.substr(dir.find_last_of('/') + 1); std::string sceneFile = dir + "/scene.json"; std::string minimapFile = dir + "/minimap.png"; + // The track has a valid scene file if (manager->HasFile(sceneFile)) { auto archive = manager->GetArchiveFromFile(sceneFile); - Course* course = new Course(); + auto course = std::make_unique(); course->LoadO2R(dir); - gWorldInstance.Courses.push_back(course); - LoadLevel(archive, course, sceneFile); - LoadMinimap(archive, course, minimapFile); - Tracks.push_back({course, sceneFile, name, dir, archive}); - } else { + gWorldInstance.Courses.push_back(std::move(course)); + LoadLevel(archive, course.get(), sceneFile); + LoadMinimap(archive, course.get(), minimapFile); + Tracks.push_back({course.get(), sceneFile, name, dir, archive}); + } else { // The track does not have a valid scene file const std::string file = dir + "/data_track_sections"; + // If the track has a data_track_sections file, + // then it must at least be a valid track. + // So lets add it as an uninitialized track. if (manager->HasFile(file)) { - Course* course = new Course(); + auto course = std::make_unique(); course->Id = (std::string("mods:") + name).c_str(); course->Props.SetText(course->Props.Name, name.c_str(), sizeof(course->Props.Name)); course->Props.SetText(course->Props.DebugName, name.c_str(), sizeof(course->Props.Name)); auto archive = manager->GetArchiveFromFile(file); - Tracks.push_back({course, "", name, dir, archive}); + Tracks.push_back({course.get(), "", name, dir, archive}); } else { printf("ContentBrowser.cpp: Track '%s' missing required track files. Cannot add to game\n Missing %s/data_track_sections file\n", name.c_str(), dir.c_str()); } diff --git a/src/racing/actors.c b/src/racing/actors.c index d6fd2ade1..137e3556e 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -944,15 +944,15 @@ void spawn_foliage(struct ActorSpawnData* actor) { position[2] = var_s3->pos[2]; position[1] = var_s3->pos[1]; - if (GetCourse() == GetMarioRaceway()) { + if (IsMarioRaceway()) { actorType = 2; - } else if (GetCourse() == GetBowsersCastle()) { + } else if (IsBowsersCastle()) { actorType = 0x0021; - } else if (GetCourse() == GetYoshiValley()) { + } else if (IsYoshiValley()) { actorType = 3; - } else if (GetCourse() == GetFrappeSnowland()) { + } else if (IsFrappeSnowland()) { actorType = 0x001D; - } else if (GetCourse() == GetRoyalRaceway()) { + } else if (IsRoyalRaceway()) { switch (var_s3->signedSomeId) { case 6: actorType = 0x001C; @@ -961,11 +961,11 @@ void spawn_foliage(struct ActorSpawnData* actor) { actorType = 4; break; } - } else if (GetCourse() == GetLuigiRaceway()) { + } else if (IsLuigiRaceway()) { actorType = 0x001A; - } else if (GetCourse() == GetMooMooFarm()) { + } else if (IsMooMooFarm()) { actorType = 0x0013; - } else if (GetCourse() == GetKalimariDesert()) { + } else if (IsKalimariDesert()) { switch (var_s3->signedSomeId) { case 5: actorType = 0x001E; @@ -1706,8 +1706,8 @@ bool collision_tree(Player* player, struct Actor* actor) { actorPos[0] = actor->pos[0]; actorPos[1] = actor->pos[1]; actorPos[2] = actor->pos[2]; - if (((GetCourse() == GetMarioRaceway()) || (GetCourse() == GetYoshiValley()) || - (GetCourse() == GetRoyalRaceway()) || (GetCourse() == GetLuigiRaceway())) && + if (((IsMarioRaceway()) || (IsYoshiValley()) || + (IsRoyalRaceway()) || (IsLuigiRaceway())) && (player->unk_094 > 1.0f)) { spawn_leaf(actorPos, 0); } @@ -2571,9 +2571,9 @@ void render_course_actors(struct UnkStruct_800DC5EC* arg0) { } FrameInterpolation_RecordCloseChild(); } - if (GetCourse() == GetMooMooFarm()) { + if (IsMooMooFarm()) { render_cows(camera, sBillBoardMtx); - } else if (GetCourse() == GetDkJungle()) { + } else if (IsDkJungle()) { render_palm_trees(camera, sBillBoardMtx); } } diff --git a/src/racing/math_util.c b/src/racing/math_util.c index 3682e07d5..127961703 100644 --- a/src/racing/math_util.c +++ b/src/racing/math_util.c @@ -14,8 +14,6 @@ #include #pragma intrinsic(sqrtf, fabs) -extern s16 gCurrentCourseId; - s32 D_802B91C0[2] = { 13, 13 }; Vec3f D_802B91C8 = { 0.0f, 0.0f, 0.0f }; @@ -1146,7 +1144,7 @@ f32 is_within_render_distance(Vec3f cameraPos, Vec3f objectPos, u16 orientationY if (minDistance == 0.0f) { if (is_visible_between_angle((orientationY + extended_fov), (orientationY - extended_fov), angleObject) == 1) { - if (gCurrentCourseId == 0xB /* COURSE_KALAMARI_DESERT */) { + if (IsKalimariDesert()) { return distance / 6.5f; // set for better DD settings in Desert } else { return distance / 10.0f; // Items @@ -1156,7 +1154,7 @@ f32 is_within_render_distance(Vec3f cameraPos, Vec3f objectPos, u16 orientationY } if (is_visible_between_angle((u16) plus_fov_angle, (u16) minus_fov_angle, angleObject) == 1) { - if (gCurrentCourseId == 0xB /* COURSE_KALAMARI_DESERT */) { + if (IsKalimariDesert()) { return distance / 2.0f; } else { return distance / 10.0f; // DD Vhicles diff --git a/src/racing/race_logic.c b/src/racing/race_logic.c index 4b9cf1af9..4247cd88c 100644 --- a/src/racing/race_logic.c +++ b/src/racing/race_logic.c @@ -418,7 +418,7 @@ void func_8028EC38(s32 arg0) { void func_8028EC98(s32 arg0) { - // We want music in mutilplayer + // We want music in multiplayer, so this was removed //if (gScreenModeSelection == SCREEN_MODE_3P_4P_SPLITSCREEN) { // return; //} @@ -897,9 +897,9 @@ void func_8028FCBC(void) { func_8028F914(); if (D_802BA034 == 1.0f) { if (gActiveScreenMode != SCREEN_MODE_1P) { - if (GetCourse() == GetLuigiRaceway()) { + if (IsLuigiRaceway()) { func_802A7940(); - } else if (GetCourse() == GetWarioStadium()) { + } else if (IsWarioStadium()) { func_802A7728(); } } @@ -909,7 +909,9 @@ void func_8028FCBC(void) { CM_SpawnStarterLakitu(); // func_80078F64(); if ((gModeSelection == TIME_TRIALS) && (D_80162DD6 == 0)) { phi_v0_4 = 0x1; - for (i = 0; i < gCurrentCourseId; i++) { + //! @warning this used to be < gCurrentCourseId + // Hopefully this is equivallent. + for (i = 0; i < GetCourseIndex(); i++) { phi_v0_4 <<= 1; } if ((D_8015F890 == 0) && (!(D_800DC5AC & phi_v0_4))) { diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c index 1b1e7ec26..bf16380d3 100644 --- a/src/racing/render_courses.c +++ b/src/racing/render_courses.c @@ -133,7 +133,7 @@ void render_course_segments(const char* addr[], struct UnkStruct_800DC5EC* arg1) index = sp1E; } } else { - if (GetCourse() == GetBowsersCastle()) { + if (IsBowsersCastle()) { if ((temp_v0_3 >= 0x11) && (temp_v0_3 < 0x18)) { index = temp_v0_3; } else if ((temp_v0_3 == 255) && (sp1E != 255)) { @@ -143,7 +143,7 @@ void render_course_segments(const char* addr[], struct UnkStruct_800DC5EC* arg1) } else { index = arg1->pathCounter; } - } else if (GetCourse() == GetChocoMountain()) { + } else if (IsChocoMountain()) { if ((temp_v0_3 >= 0xE) && (temp_v0_3 < 0x16)) { index = temp_v0_3; } else if ((temp_v0_3 == 255) && (sp1E != 255)) { @@ -176,7 +176,7 @@ void render_course_segments(const char* addr[], struct UnkStruct_800DC5EC* arg1) index = ((index - 1) * 4) + direction; gSPDisplayList(gDisplayListHead++, addr[index]); - if (CVarGetInteger("gDisableLod", 1) == 1 && (GetCourse() == GetBowsersCastle()) && + if (CVarGetInteger("gDisableLod", 1) == 1 && (IsBowsersCastle()) && (index < 20 || index > 99)) { // always render higher version of bowser statue gDisplayListHead--; gSPDisplayList(gDisplayListHead++, d_course_bowsers_castle_dl_9148); // use credit version of the course diff --git a/src/racing/skybox_and_splitscreen.c b/src/racing/skybox_and_splitscreen.c index 9a31c378a..62399dfea 100644 --- a/src/racing/skybox_and_splitscreen.c +++ b/src/racing/skybox_and_splitscreen.c @@ -407,7 +407,7 @@ void func_802A487C(Vtx* arg0, UNUSED struct UnkStruct_800DC5EC* arg1, UNUSED s32 UNUSED f32* arg4) { init_rdp(); - if (GetCourse() != GetRainbowRoad()) { + if (!IsRainbowRoad()) { gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gSPClearGeometryMode(gDisplayListHead++, G_ZBUFFER | G_LIGHTING); @@ -485,7 +485,7 @@ void func_802A4A0C(Vtx* vtx, struct UnkStruct_800DC5EC* arg1, UNUSED s32 arg2, U gSPMatrix(gDisplayListHead++, &gIdentityMatrix2, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPVertex(gDisplayListHead++, &vtx[0], 4, 0); gSP2Triangles(gDisplayListHead++, 0, 3, 1, 0, 1, 3, 2, 0); - if (GetCourse() == GetRainbowRoad()) { + if (IsRainbowRoad()) { gSPVertex(gDisplayListHead++, &vtx[4], 4, 0); gSP2Triangles(gDisplayListHead++, 0, 3, 1, 0, 1, 3, 2, 0); } diff --git a/src/render_objects.c b/src/render_objects.c index 3b6aa44c6..7aa06dcaf 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -3013,7 +3013,7 @@ void draw_lap_count(s16 lapX, s16 lapY, s8 lap) { } void func_8004FDB4(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 characterId, s32 arg5, s32 arg6, s32 arg7, s32 arg8) { - if ((GetCourse() == GetYoshiValley()) && (arg3 < 3) && (arg8 == 0)) { + if ((IsYoshiValley()) && (arg3 < 3) && (arg8 == 0)) { func_80042330((s32) arg0, (s32) arg1, 0U, 1.0f); gSPDisplayList(gDisplayListHead++, D_0D007DB8); func_8004B35C(0x000000FF, 0x000000FF, 0x000000FF, D_8018D3E0); @@ -3320,7 +3320,7 @@ void func_80050E34(s32 playerId, s32 arg1) { spB8 = 0; } - if ((GetCourse() == GetYoshiValley()) && (lapCount < 3)) { + if ((IsYoshiValley()) && (lapCount < 3)) { gSPDisplayList(gDisplayListHead++, D_0D007DB8); gDPLoadTLUT_pal256(gDisplayListHead++, common_tlut_portrait_bomb_kart_and_question_mark); rsp_load_texture(common_texture_portrait_question_mark, 0x00000020, 0x00000020); @@ -3553,16 +3553,16 @@ void func_80051C60(s16 arg0, s32 arg1) { Object* object; if (D_801658FE == 0) { - if (GetCourse() == GetKoopaTroopaBeach()) { + if (IsKoopaTroopaBeach()) { var_s5 = arg0; - } else if (GetCourse() == GetMooMooFarm()) { + } else if (IsMooMooFarm()) { var_s5 = arg0 - 16; - } else if (GetCourse() == GetYoshiValley()) { + } else if (IsYoshiValley()) { var_s5 = arg0 - 16; } else { var_s5 = arg0 + 16; } - } else if (GetCourse() == GetKoopaTroopaBeach()) { + } else if (IsKoopaTroopaBeach()) { var_s5 = arg0 * 2; } else { var_s5 = arg0 + 32; @@ -3596,11 +3596,11 @@ void func_80051EF8(void) { s16 temp_a0; temp_a0 = 0xF0 - D_800DC5EC->cameraHeight; - if (GetCourse() == GetKoopaTroopaBeach()) { + if (IsKoopaTroopaBeach()) { temp_a0 = temp_a0 - 0x30; - } else if (GetCourse() == GetMooMooFarm()) { + } else if (IsMooMooFarm()) { temp_a0 = temp_a0 - 0x40; - } else if (GetCourse() == GetYoshiValley()) { + } else if (IsYoshiValley()) { temp_a0 = temp_a0 - 0x40; } else { temp_a0 = temp_a0 - 0x30; @@ -3612,11 +3612,11 @@ void func_80051F9C(void) { s16 temp_a0; temp_a0 = 0xF0 - D_800DC5F0->cameraHeight; - if (GetCourse() == GetKoopaTroopaBeach()) { + if (IsKoopaTroopaBeach()) { temp_a0 = temp_a0 - 0x30; - } else if (GetCourse() == GetMooMooFarm()) { + } else if (IsMooMooFarm()) { temp_a0 = temp_a0 - 0x40; - } else if (GetCourse() == GetYoshiValley()) { + } else if (IsYoshiValley()) { temp_a0 = temp_a0 - 0x40; } else { temp_a0 = temp_a0 - 0x30; diff --git a/src/render_player.c b/src/render_player.c index ca4247ef9..5061826f6 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -1277,7 +1277,7 @@ void change_player_color_effect_cmy(UNUSED Player* player, s8 arg1, s32 arg2, f3 * Sort of an atmospheric effect. */ bool is_player_under_light_luigi_raceway(Player* player, s8 arg1) { - if (GetCourse() == GetLuigiRaceway()) { + if (IsLuigiRaceway()) { if (((gNearestWaypointByPlayerId[arg1] >= 0x14F) && (gNearestWaypointByPlayerId[arg1] < 0x158)) || ((gNearestWaypointByPlayerId[arg1] >= 0x15E) && (gNearestWaypointByPlayerId[arg1] < 0x164)) || ((gNearestWaypointByPlayerId[arg1] >= 0x169) && (gNearestWaypointByPlayerId[arg1] < 0x170)) || @@ -1295,7 +1295,7 @@ bool is_player_under_light_luigi_raceway(Player* player, s8 arg1) { } void render_light_environment_on_player(Player* player, s8 arg1) { - if (GetCourse() == GetBowsersCastle()) { + if (IsBowsersCastle()) { if (((gNearestWaypointByPlayerId[arg1] >= 0x15) && (gNearestWaypointByPlayerId[arg1] < 0x2A)) || ((gNearestWaypointByPlayerId[arg1] >= 0x14D) && (gNearestWaypointByPlayerId[arg1] < 0x15C)) || ((gNearestWaypointByPlayerId[arg1] >= 0x1D1) && (gNearestWaypointByPlayerId[arg1] < 0x1E4)) || @@ -1318,7 +1318,7 @@ void render_light_environment_on_player(Player* player, s8 arg1) { change_player_color_effect_cmy(player, arg1, 0, 0.3f); D_80164B80[arg1] = 0; } - } else if (GetCourse() == GetBansheeBoardwalk()) { + } else if (IsBansheeBoardwalk()) { if (((gNearestWaypointByPlayerId[arg1] >= 0xD) && (gNearestWaypointByPlayerId[arg1] < 0x15)) || ((gNearestWaypointByPlayerId[arg1] >= 0x29) && (gNearestWaypointByPlayerId[arg1] < 0x39)) || ((gNearestWaypointByPlayerId[arg1] >= 0x46) && (gNearestWaypointByPlayerId[arg1] < 0x4E)) || diff --git a/src/spawn_players.c b/src/spawn_players.c index 92185f3d9..96b6dcd2e 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -729,7 +729,7 @@ void spawn_players_versus_two_player(f32* arg0, f32* arg1, f32 arg2) { } void spawn_players_2p_battle(f32* arg0, f32* arg1, f32 arg2) { - if (GetCourse() == GetBigDonut()) { + if (IsBigDonut()) { spawn_player(gPlayerOne, 0, arg0[0], arg1[0], arg2, -16384.0f, gCharacterSelections[0], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); spawn_player(gPlayerTwo, 1, arg0[1], arg1[1], arg2, 16384.0f, gCharacterSelections[1], @@ -778,7 +778,7 @@ void func_8003B318(f32* arg0, f32* arg1, f32 arg2) { } void spawn_players_3p_battle(f32* arg0, f32* arg1, f32 arg2) { - if (GetCourse() == GetBigDonut()) { + if (IsBigDonut()) { spawn_player(gPlayerOne, 0, arg0[0], arg1[0], arg2, -16384.0f, gCharacterSelections[0], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); spawn_player(gPlayerTwo, 1, arg0[1], arg1[1], arg2, 16384.0f, gCharacterSelections[1], @@ -830,7 +830,7 @@ void func_8003B870(f32* arg0, f32* arg1, f32 arg2) { } void spawn_players_4p_battle(f32* arg0, f32* arg1, f32 arg2) { - if (GetCourse() == GetBigDonut()) { + if (IsBigDonut()) { spawn_player(gPlayerOne, 0, arg0[0], arg1[0], arg2, -16384.0f, gCharacterSelections[0], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); spawn_player(gPlayerTwo, 1, arg0[1], arg1[1], arg2, 16384.0f, gCharacterSelections[1], @@ -888,17 +888,17 @@ void func_8003C0F0(void) { if (gModeSelection == BATTLE) { func_8000EEDC(); - } else if (GetCourse() != GetPodiumCeremony()) { + } else if (!IsPodiumCeremony()) { func_8000F2DC(); sp5E = (f32) D_80164550[0][0].posX; sp5C = (f32) D_80164550[0][0].posZ; sp5A = (f32) D_80164550[0][0].posY; - if (GetCourse() == GetToadsTurnpike()) { + if (IsToadsTurnpike()) { sp5E = 0; } } - if ((gModeSelection != BATTLE) && (GetCourse() != GetPodiumCeremony())) { + if ((gModeSelection != BATTLE) && (!IsPodiumCeremony())) { switch (gActiveScreenMode) { case SCREEN_MODE_1P: switch (gModeSelection) { @@ -993,7 +993,7 @@ void func_8003C0F0(void) { } break; } - } else if (GetCourse() == GetBlockFort()) { + } else if (IsBlockFort()) { switch (gActiveScreenMode) { case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: @@ -1023,7 +1023,7 @@ void func_8003C0F0(void) { } break; } - } else if (GetCourse() == GetSkyscraper()) { + } else if (IsSkyscraper()) { switch (gActiveScreenMode) { case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: @@ -1053,7 +1053,7 @@ void func_8003C0F0(void) { } break; } - } else if (GetCourse() == GetDoubleDeck()) { + } else if (IsDoubleDeck()) { switch (gActiveScreenMode) { case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: @@ -1083,7 +1083,7 @@ void func_8003C0F0(void) { } break; } - } else if (GetCourse() == GetBigDonut()) { + } else if (IsBigDonut()) { switch (gActiveScreenMode) { case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: @@ -1200,7 +1200,7 @@ void func_8003D080(void) { case SCREEN_MODE_1P: switch (gModeSelection) { case GRAND_PRIX: - if (GetCourse() == GetToadsTurnpike()) { + if (IsToadsTurnpike()) { camera_init(0.0f, player->pos[1], D_80165230[7], player->rotation[1], 8, 0); } else { camera_init((D_80165210[7] + D_80165210[6]) / 2, player->pos[1], D_80165230[7], diff --git a/src/staff_ghosts.c b/src/staff_ghosts.c index 914809d38..c92892cdc 100644 --- a/src/staff_ghosts.c +++ b/src/staff_ghosts.c @@ -39,7 +39,7 @@ u32* D_80162DB4; s16 D_80162DB8; u32* D_80162DBC; -u16 D_80162DC0; +uintptr_t staff_ghost_track_ptr; StaffGhost* D_80162DC4; s32 D_80162DC8; s32 D_80162DCC; @@ -164,11 +164,11 @@ void func_80005310(void) { set_staff_ghost(); - if (D_80162DC0 != gCurrentCourseId) { + if (staff_ghost_track_ptr != (uintptr_t)GetCourse()) { D_80162DD4 = 1; } - D_80162DC0 = (u16) gCurrentCourseId; + staff_ghost_track_ptr = (uintptr_t)GetCourse(); D_80162DF0 = 0; D_80162DEC = 0; D_80162DF8 = 0; diff --git a/src/update_objects.c b/src/update_objects.c index 6d2b8a77a..0435a69d7 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -2106,19 +2106,19 @@ void init_object_leaf_particle(s32 objectIndex, Vec3f arg1, s32 num) { gObjectList[objectIndex].sizeScaling = 0.1f; gObjectList[objectIndex].surfaceHeight = arg1[1]; - if (GetCourse() == GetMarioRaceway()) { + if (IsMarioRaceway()) { object_origin_pos_randomize_around_xyz(objectIndex, arg1[0], arg1[1] + 25.0, arg1[2], 0x14, 0x1E, 0x14); gObjectList[objectIndex].unk_034 = 1.5f; gObjectList[objectIndex].velocity[1] = 1.5f; - } else if (GetCourse() == GetYoshiValley()) { + } else if (IsYoshiValley()) { object_origin_pos_randomize_around_xyz(objectIndex, arg1[0], arg1[1] + 25.0, arg1[2], 0x14, 0x1E, 0x14); gObjectList[objectIndex].unk_034 = 2.0f; gObjectList[objectIndex].velocity[1] = 2.0f; - } else if (GetCourse() == GetRoyalRaceway()) { + } else if (IsRoyalRaceway()) { object_origin_pos_randomize_around_xyz(objectIndex, arg1[0], arg1[1] + 30.0, arg1[2], 0x10, 0x28, 0x10); gObjectList[objectIndex].unk_034 = 2.0f; gObjectList[objectIndex].velocity[1] = 2.0f; - } else if (GetCourse() == GetLuigiRaceway()) { + } else if (IsLuigiRaceway()) { object_origin_pos_randomize_around_xyz(objectIndex, arg1[0], arg1[1] + 25.0, arg1[2], 0x14, 0x1E, 0x14); gObjectList[objectIndex].unk_034 = 1.5f; gObjectList[objectIndex].velocity[1] = 1.0f;