From f87ad2350098dee00b235d771d068d53559dff8c Mon Sep 17 00:00:00 2001 From: MegaMech <7255464+MegaMech@users.noreply.github.com> Date: Fri, 6 Dec 2024 13:38:50 -0700 Subject: [PATCH] Add warning if no finishline. Remove printfs --- src/engine/courses/Course.cpp | 1 - src/port/Game.cpp | 11 +++++++++++ src/port/Game.h | 2 ++ src/racing/actors.c | 9 +++++++++ src/racing/memory.c | 1 - 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/engine/courses/Course.cpp b/src/engine/courses/Course.cpp index 26c549367..e5c9a0498 100644 --- a/src/engine/courses/Course.cpp +++ b/src/engine/courses/Course.cpp @@ -104,7 +104,6 @@ void Course::Load() { freeMemory = (u8*) allocate_memory(size); texture = (u8*)(asset->addr); - printf("TEXTURE: 0x%llX\n",texture); if (texture) { if (asset == &this->Props.textures[0]) { gSegmentTable[5] = reinterpret_cast(&freeMemory[0]); diff --git a/src/port/Game.cpp b/src/port/Game.cpp index f6918a2a4..337321662 100644 --- a/src/port/Game.cpp +++ b/src/port/Game.cpp @@ -27,6 +27,7 @@ #include "engine/courses/DKJungle.h" #include "engine/courses/BigDonut.h" #include "engine/courses/TestCourse.h" +#include "engine/actors/AFinishline.h" #include "engine/courses/PodiumCeremony.h" @@ -377,6 +378,16 @@ extern "C" { } } + // Helps prevents users from forgetting to add a finishline to their course + bool cm_DoesFinishlineExist() { + for (AActor* actor : gWorldInstance.Actors) { + if (dynamic_cast(actor)) { + return true; + } + } + return false; + } + void CourseManager_InitClouds() { if (gWorldInstance.CurrentCourse) { gWorldInstance.CurrentCourse->InitClouds(); diff --git a/src/port/Game.h b/src/port/Game.h index c35e933e2..6e19b1b63 100644 --- a/src/port/Game.h +++ b/src/port/Game.h @@ -43,6 +43,8 @@ void CourseManager_RenderCredits(); void CourseManager_SpawnActors(); +bool cm_DoesFinishlineExist(); + void CourseManager_InitClouds(); void CourseManager_DrawActor(Camera* camera, struct Actor* actor); diff --git a/src/racing/actors.c b/src/racing/actors.c index d7b1168a0..bc031a568 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -1045,6 +1045,15 @@ void spawn_course_actors(void) { gNumPermanentActors = 0; CourseManager_SpawnActors(); + if (gModeSelection != BATTLE) { + if (!cm_DoesFinishlineExist()) { + printf("\n[actors.c] COURSE MISSING THE FINISHLINE\n"); + printf(" In the course class SpawnActors() function make sure to include:\n"); + printf(" gWorldInstance.AddActor(new AFinishline());\n\n"); + printf("\n Otherwise, course textures may glitch out or other strange issues may occur.\n"); + } + } + // switch (gCurrentCourseId) { // case COURSE_MARIO_RACEWAY: // // spawn_foliage(d_course_mario_raceway_tree_spawns); diff --git a/src/racing/memory.c b/src/racing/memory.c index e2aed1a58..4538fd1ec 100644 --- a/src/racing/memory.c +++ b/src/racing/memory.c @@ -828,7 +828,6 @@ uintptr_t get_texture(size_t offset) { while (textures->addr) { if (totalOffset == offset) { - printf("FOUND TEXTURE: 0x%s\n", (textures->addr)); return (textures->addr); } totalOffset += textures->data_size;