From e5114e3ad73dd12a4246a6b208dd54ca35f84a95 Mon Sep 17 00:00:00 2001 From: MegaMech <7255464+MegaMech@users.noreply.github.com> Date: Fri, 18 Apr 2025 08:38:20 -0600 Subject: [PATCH] Custom Track Load path O2r --- src/code_80005FD0.c | 8 +++++++- src/engine/courses/Course.cpp | 19 +++++++++++-------- src/port/ui/ContentBrowser.cpp | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 0e3c362dd..dd7858e55 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -3635,7 +3635,13 @@ void func_800100F0(s32 pathIndex) { pathDest = D_80164550[pathIndex]; bInvalidPath = 1; if (GetCourse() != GetPodiumCeremony()) { - var_v0 = process_path_data(pathDest, CM_GetProps()->PathTable2[pathIndex]); + + TrackWaypoint* pathSrc = CM_GetProps()->PathTable2[pathIndex]; + if (pathSrc == NULL) { + printf("code_80005FD0.c: Path %d in Course::PathTable2, was NULL.\n Your track is missing a path\n", pathIndex); + } + + var_v0 = process_path_data(pathDest, pathSrc); gWaypointCountByPathIndex[pathIndex] = (u16) var_v0; } else { // Course path included in course_data which has already been loaded into memory. diff --git a/src/engine/courses/Course.cpp b/src/engine/courses/Course.cpp index ae3caed9b..340fdf1bc 100644 --- a/src/engine/courses/Course.cpp +++ b/src/engine/courses/Course.cpp @@ -98,16 +98,19 @@ void Course::LoadO2R(std::string trackPath) { auto res = std::dynamic_pointer_cast(ResourceLoad(path_file.c_str())); if (res != nullptr) { - std::vector> paths = res->PathList; - + auto& paths = res->PathList; + size_t i = 0; for (auto& path : paths) { - if (i < 4) { // Paths 1-4 - Props.PathTable[i] = (TrackWaypoint*)&path[0]; - } else if (i < 8) { // Paths 5-8 - Props.PathTable2[i - 4] = (TrackWaypoint*)&path[0]; - } else { // Only 8 course paths are supported. - break; + if (i == 0) { + Props.PathTable[0] = (TrackWaypoint*)path.data(); + Props.PathTable[1] = (TrackWaypoint*)path.data(); + Props.PathTable[2] = (TrackWaypoint*)path.data(); + Props.PathTable[3] = (TrackWaypoint*)path.data(); + Props.PathTable2[0] = (TrackWaypoint*)path.data(); + Props.PathTable2[1] = (TrackWaypoint*)path.data(); + Props.PathTable2[2] = (TrackWaypoint*)path.data(); + Props.PathTable2[3] = (TrackWaypoint*)path.data(); } i += 1; diff --git a/src/port/ui/ContentBrowser.cpp b/src/port/ui/ContentBrowser.cpp index 6e8dd1284..98c4de352 100644 --- a/src/port/ui/ContentBrowser.cpp +++ b/src/port/ui/ContentBrowser.cpp @@ -248,7 +248,7 @@ namespace Editor { printf("dir %s\n", directoryPath.c_str()); // Store in TrackPath - TrackPath[trackName] = file; + TrackPath[trackName] = directoryPath; } // Move unique tracks into the vector