diff --git a/src/engine/courses/BansheeBoardwalk.cpp b/src/engine/courses/BansheeBoardwalk.cpp index 3f2fd6cf9..0d53c29a3 100644 --- a/src/engine/courses/BansheeBoardwalk.cpp +++ b/src/engine/courses/BansheeBoardwalk.cpp @@ -35,6 +35,7 @@ extern "C" { #include "collision.h" #include "memory.h" #include "course_offsets.h" + #include "course.h" extern const char *banshee_boardwalk_dls[]; } @@ -143,7 +144,7 @@ void BansheeBoardwalk::Load() { D_801625EC = 0; D_801625F4 = 0; D_801625F0 = 0; - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_banshee_boardwalk_track_sections)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_banshee_boardwalk_track_sections)); func_80295C6C(); find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07000878), 128, 0, 0, 0); } diff --git a/src/engine/courses/BowsersCastle.cpp b/src/engine/courses/BowsersCastle.cpp index 44a757b1f..7d5dedc8c 100644 --- a/src/engine/courses/BowsersCastle.cpp +++ b/src/engine/courses/BowsersCastle.cpp @@ -31,6 +31,7 @@ extern "C" { #include "collision.h" #include "code_8003DC40.h" #include "memory.h" + #include "course.h" extern const char *bowsers_castle_dls[]; } @@ -142,7 +143,7 @@ BowsersCastle::BowsersCastle() { void BowsersCastle::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_bowsers_castle_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_bowsers_castle_addr)); func_80295C6C(); find_vtx_and_set_colours(segmented_gfx_to_virtual(reinterpret_cast(0x07001350)), 0x32, 0, 0, 0); } diff --git a/src/engine/courses/ChocoMountain.cpp b/src/engine/courses/ChocoMountain.cpp index 2a8ed9502..471a07809 100644 --- a/src/engine/courses/ChocoMountain.cpp +++ b/src/engine/courses/ChocoMountain.cpp @@ -31,6 +31,7 @@ extern "C" { #include "code_8003DC40.h" #include "memory.h" #include "course_offsets.h" + #include "course.h" extern const char *choco_mountain_dls[]; } @@ -156,7 +157,7 @@ void ChocoMountain::Load() { nullify_displaylist((uintptr_t) segmented_gfx_to_virtual(reinterpret_cast(0x070003C8))); } - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_choco_mountain_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_choco_mountain_addr)); func_802B5CAC(0x238E, 0x31C7, D_8015F590); func_80295C6C(); } diff --git a/src/engine/courses/Course.cpp b/src/engine/courses/Course.cpp index b38d7dda6..ae3caed9b 100644 --- a/src/engine/courses/Course.cpp +++ b/src/engine/courses/Course.cpp @@ -4,6 +4,8 @@ #include "MarioRaceway.h" #include "ChocoMountain.h" #include "port/Game.h" +#include "port/resource/type/TrackWaypoint.h" +#include "port/resource/type/TrackSections.h" extern "C" { #include "main.h" @@ -29,7 +31,7 @@ Course::Course() { // Props.CourseLength = "567m"; // Props.Cup = FLOWER_CUP; // Props.CupIndex = 3; - Props.TrackModel = NULL; + Props.TrackSectionsPtr = NULL; Props.LakituTowType = (s32) OLakitu::LakituTowType::NORMAL; Props.AIBehaviour = D_0D008F28; Props.AIMaximumSeparation = 50.0f; @@ -87,18 +89,53 @@ void Course::Load(Vtx* vtx, Gfx* gfx) { Course::Init(); } -// Load custom track from o2r -void Course::Load(std::string dls) { - std::vector sections = LOAD_ASSET_RAW(dls); +void Course::LoadO2R(std::string trackPath) { + if (!trackPath.empty()) { + Props.TrackSectionsPtr = (trackPath + "/data_track_sections").c_str(); - for (auto& section : sections) { - generate_collision_mesh((Gfx*)LOAD_ASSET_RAW(section.addr), section.surfaceType, section.sectionId); + std::string path_file = (trackPath + "/data_paths").c_str(); + + auto res = std::dynamic_pointer_cast(ResourceLoad(path_file.c_str())); + + if (res != nullptr) { + std::vector> 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; + } + + i += 1; + } + } + + } else { + printf("Course.cpp: LoadO2R: trackPath str is empty\n"); } - Course::Init(); } // Load stock track void Course::Load() { + + // Load from O2R + if (Props.TrackSectionsPtr != NULL || Props.TrackSectionsPtr[0] != '\0') { + + auto res = std::dynamic_pointer_cast(ResourceLoad(Props.TrackSectionsPtr)); + + if (res != nullptr) { + std::vector sections = res->TrackSectionsList; + + ParseCourseSections(sections); + } + return; + } + + // Stock size_t vtxSize = (ResourceGetSizeByName(this->vtx) / sizeof(CourseVtx)) * sizeof(Vtx); size_t texSegSize; @@ -143,6 +180,28 @@ void Course::Load() { Course::Init(); } +// C++ version of parse_course_displaylists() +void Course::ParseCourseSections(std::vector sections) { + for (auto& section : sections) { + if (section.flags & 0x8000) { + D_8015F59C = 1; + } else { + D_8015F59C = 0; + } + if (section.flags & 0x2000) { + D_8015F5A0 = 1; + } else { + D_8015F5A0 = 0; + } + if (section.flags & 0x4000) { + D_8015F5A4 = 1; + } else { + D_8015F5A4 = 0; + } + generate_collision_mesh((Gfx*)LOAD_ASSET_RAW(section.addr), section.surfaceType, section.sectionId); + } +} + void Course::Init() { gNumActors = 0; gCourseMinX = 0; @@ -240,9 +299,9 @@ void Course::Waypoints(Player* player, int8_t playerId) { } void Course::Render(struct UnkStruct_800DC5EC* arg0) { - if (Props.TrackModel) { - gSPDisplayList(gDisplayListHead++, (Gfx*)LOAD_ASSET_RAW(Props.TrackModel)); - } + //if (Props.TrackSectionsPtr) { + // gSPDisplayList(gDisplayListHead++, (Gfx*)LOAD_ASSET_RAW(Props.TrackModel)); + //} } void Course::RenderCredits() { diff --git a/src/engine/courses/Course.h b/src/engine/courses/Course.h index 4889e081a..cefe0d4dd 100644 --- a/src/engine/courses/Course.h +++ b/src/engine/courses/Course.h @@ -6,6 +6,7 @@ #ifdef __cplusplus #include "engine/objects/Lakitu.h" +#include "port/resource/type/TrackSections.h" extern "C" { #endif @@ -77,7 +78,7 @@ typedef struct Properties { const course_texture *textures; enum MusicSeq Sequence; float WaterLevel; // Used for effects, and Lakitu pick up height. Not necessarily the visual water model height. - const char* TrackModel; + const char* TrackSectionsPtr; #ifdef __cplusplus nlohmann::json to_json() const { @@ -238,10 +239,11 @@ public: explicit Course(); - virtual void Load(); // Decompress and load stock courses - virtual void Load(Vtx* vtx, Gfx *gfx); // Load custom track from code - virtual void Load(std::string dls); // Load custom track from o2r + virtual void LoadO2R(std::string trackPath); // Load custom track from o2r + virtual void Load(); // Decompress and load stock courses or from o2r but Props.TrackSectionsPtr must be set. + virtual void Load(Vtx* vtx, Gfx *gfx); // Load custom track from code. Load must be overridden and then call to this base class method impl. virtual void LoadTextures(); + virtual void ParseCourseSections(std::vector sections); /** * @brief BeginPlay This function is called once at the start of gameplay. diff --git a/src/engine/courses/DKJungle.cpp b/src/engine/courses/DKJungle.cpp index e47d86989..db2e9e7c5 100644 --- a/src/engine/courses/DKJungle.cpp +++ b/src/engine/courses/DKJungle.cpp @@ -35,6 +35,7 @@ extern "C" { #include "code_8003DC40.h" #include "memory.h" #include "sounds.h" + #include "course.h" extern const char *d_course_dks_jungle_parkway_unknown_dl_list[]; extern s16 currentScreenSection; } @@ -140,7 +141,7 @@ DKJungle::DKJungle() { void DKJungle::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_dks_jungle_parkway_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_dks_jungle_parkway_addr)); func_80295C6C(); // d_course_dks_jungle_parkway_packed_dl_3FA8 find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07003FA8), 120, 255, 255, 255); diff --git a/src/engine/courses/FrappeSnowland.cpp b/src/engine/courses/FrappeSnowland.cpp index ab85c7270..5bbf1b001 100644 --- a/src/engine/courses/FrappeSnowland.cpp +++ b/src/engine/courses/FrappeSnowland.cpp @@ -34,6 +34,7 @@ extern "C" { #include "memory.h" #include "update_objects.h" #include "course_offsets.h" + #include "course.h" extern const char *d_course_frappe_snowland_dl_list[]; extern s8 gPlayerCount; } @@ -119,7 +120,7 @@ FrappeSnowland::FrappeSnowland() { void FrappeSnowland::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_frappe_snowland_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_frappe_snowland_addr)); func_80295C6C(); } diff --git a/src/engine/courses/Harbour.cpp b/src/engine/courses/Harbour.cpp index 4d5a831a7..2da03f938 100644 --- a/src/engine/courses/Harbour.cpp +++ b/src/engine/courses/Harbour.cpp @@ -50,12 +50,7 @@ extern "C" { #include "collision.h" #include "memory.h" #include "courses/harbour/track.h" - typedef struct { - Gfx* addr; - u8 surfaceType; - u8 sectionId; - u16 flags; - } TrackSections; + #include "course.h" } TrackWaypoint harbour_path[] = { @@ -609,7 +604,7 @@ void Harbour::Load() { generate_collision_mesh_with_defaults(bush_map_004_mesh); generate_collision_mesh_with_defaults(statue_map_005_mesh); - parse_course_displaylists((TrackSectionsI*)harbour_surfaces); + parse_course_displaylists((TrackSections*)harbour_surfaces); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } diff --git a/src/engine/courses/KalimariDesert.cpp b/src/engine/courses/KalimariDesert.cpp index c0d48561e..27599cce1 100644 --- a/src/engine/courses/KalimariDesert.cpp +++ b/src/engine/courses/KalimariDesert.cpp @@ -32,6 +32,7 @@ extern "C" { #include "actors.h" #include "collision.h" #include "memory.h" + #include "course.h" extern const char *kalimari_desert_dls[]; } @@ -122,7 +123,7 @@ KalimariDesert::KalimariDesert() { void KalimariDesert::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_kalimari_desert_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_kalimari_desert_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } diff --git a/src/engine/courses/KoopaTroopaBeach.cpp b/src/engine/courses/KoopaTroopaBeach.cpp index 8435e220f..828fcf5ac 100644 --- a/src/engine/courses/KoopaTroopaBeach.cpp +++ b/src/engine/courses/KoopaTroopaBeach.cpp @@ -32,6 +32,7 @@ extern "C" { #include "collision.h" #include "code_8003DC40.h" #include "memory.h" + #include "course.h" extern const char *koopa_troopa_beach_dls[]; extern s8 gPlayerCount; } @@ -132,7 +133,7 @@ KoopaTroopaBeach::KoopaTroopaBeach() { void KoopaTroopaBeach::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_koopa_troopa_beach_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_koopa_troopa_beach_addr)); func_80295C6C(); find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x0700ADE0), -0x6A, 255, 255, 255); find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x0700A540), -0x6A, 255, 255, 255); diff --git a/src/engine/courses/LuigiRaceway.cpp b/src/engine/courses/LuigiRaceway.cpp index f2e32634b..787cef62c 100644 --- a/src/engine/courses/LuigiRaceway.cpp +++ b/src/engine/courses/LuigiRaceway.cpp @@ -34,6 +34,7 @@ extern "C" { #include "courses/staff_ghost_data.h" #include "framebuffer_effects.h" #include "skybox_and_splitscreen.h" +#include "course.h" extern const char* luigi_raceway_dls[]; extern s16 currentScreenSection; } @@ -154,7 +155,7 @@ LuigiRaceway::LuigiRaceway() { void LuigiRaceway::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*) LOAD_ASSET_RAW(d_course_luigi_raceway_addr)); + parse_course_displaylists((TrackSections*) LOAD_ASSET_RAW(d_course_luigi_raceway_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } diff --git a/src/engine/courses/MarioRaceway.cpp b/src/engine/courses/MarioRaceway.cpp index 238ce9154..910f5a342 100644 --- a/src/engine/courses/MarioRaceway.cpp +++ b/src/engine/courses/MarioRaceway.cpp @@ -31,6 +31,7 @@ extern "C" { #include "collision.h" #include "memory.h" #include "courses/staff_ghost_data.h" + #include "course.h" extern const char *mario_raceway_dls[]; } @@ -156,7 +157,7 @@ void MarioRaceway::Load() { } } - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_mario_raceway_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_mario_raceway_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } diff --git a/src/engine/courses/MooMooFarm.cpp b/src/engine/courses/MooMooFarm.cpp index 71ac6b467..485604c9f 100644 --- a/src/engine/courses/MooMooFarm.cpp +++ b/src/engine/courses/MooMooFarm.cpp @@ -32,6 +32,7 @@ extern "C" { #include "collision.h" #include "memory.h" #include "code_80086E70.h" + #include "course.h" extern const char *moo_moo_farm_dls[]; extern s16 currentScreenSection; extern s8 gPlayerCount; @@ -140,7 +141,7 @@ MooMooFarm::MooMooFarm() { void MooMooFarm::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_moo_moo_farm_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_moo_moo_farm_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } diff --git a/src/engine/courses/PodiumCeremony.cpp b/src/engine/courses/PodiumCeremony.cpp index 830182aa4..61f1525d7 100644 --- a/src/engine/courses/PodiumCeremony.cpp +++ b/src/engine/courses/PodiumCeremony.cpp @@ -35,6 +35,7 @@ extern "C" { #include "memory.h" #include "courses/staff_ghost_data.h" #include "podium_ceremony_actors.h" + #include "course.h" extern const char *royal_raceway_dls[]; } @@ -154,7 +155,7 @@ PodiumCeremony::PodiumCeremony() { void PodiumCeremony::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_royal_raceway_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_royal_raceway_addr)); func_80295C6C(); } diff --git a/src/engine/courses/RainbowRoad.cpp b/src/engine/courses/RainbowRoad.cpp index 54f063824..573853e16 100644 --- a/src/engine/courses/RainbowRoad.cpp +++ b/src/engine/courses/RainbowRoad.cpp @@ -30,6 +30,7 @@ extern "C" { #include "actors.h" #include "collision.h" #include "memory.h" + #include "course.h" extern const char *rainbow_road_dls[]; } @@ -117,7 +118,7 @@ void RainbowRoad::Load() { Course::Load(); D_800DC5C8 = 1; - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_rainbow_road_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_rainbow_road_addr)); func_80295C6C(); // d_course_rainbow_road_packed_dl_2068 find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07002068), -0x6A, 255, 255, 255); diff --git a/src/engine/courses/RoyalRaceway.cpp b/src/engine/courses/RoyalRaceway.cpp index 80428f7d1..e6fba3a73 100644 --- a/src/engine/courses/RoyalRaceway.cpp +++ b/src/engine/courses/RoyalRaceway.cpp @@ -30,6 +30,7 @@ extern "C" { #include "collision.h" #include "memory.h" #include "courses/staff_ghost_data.h" + #include "course.h" extern const char *royal_raceway_dls[]; } @@ -153,7 +154,7 @@ RoyalRaceway::RoyalRaceway() { void RoyalRaceway::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_royal_raceway_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_royal_raceway_addr)); func_80295C6C(); } diff --git a/src/engine/courses/SherbetLand.cpp b/src/engine/courses/SherbetLand.cpp index a47bed6e7..e15d1dcca 100644 --- a/src/engine/courses/SherbetLand.cpp +++ b/src/engine/courses/SherbetLand.cpp @@ -30,6 +30,7 @@ extern "C" { #include "actors.h" #include "collision.h" #include "memory.h" + #include "course.h" extern const char *sherbet_land_dls[]; extern const char *sherbet_land_dls_2[]; } @@ -118,7 +119,7 @@ SherbetLand::SherbetLand() { void SherbetLand::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_sherbet_land_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_sherbet_land_addr)); func_80295C6C(); // d_course_sherbet_land_packed_dl_1EB8 find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07001EB8), -0x4C, 255, 255, 255); diff --git a/src/engine/courses/TestCourse.cpp b/src/engine/courses/TestCourse.cpp index 54ac990bc..1ad4cefbb 100644 --- a/src/engine/courses/TestCourse.cpp +++ b/src/engine/courses/TestCourse.cpp @@ -49,12 +49,7 @@ extern "C" { #include "actors.h" #include "collision.h" #include "memory.h" - typedef struct { - Gfx* addr; - u8 surfaceType; - u8 sectionId; - u16 flags; - } TrackSections; + #include "course.h" extern Gfx test_course_dls[]; extern Vtx mario_Plane_001_mesh_vtx_1[]; extern Gfx mario_Plane_001_mesh[]; @@ -135,7 +130,7 @@ void TestCourse::Load() { generate_collision_mesh_with_defaults(mario_Plane_001_mesh); - parse_course_displaylists((TrackSectionsI*)test_course_addr); + parse_course_displaylists((TrackSections*)test_course_addr); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } diff --git a/src/engine/courses/ToadsTurnpike.cpp b/src/engine/courses/ToadsTurnpike.cpp index 5060c3f0c..d6b4f14c3 100644 --- a/src/engine/courses/ToadsTurnpike.cpp +++ b/src/engine/courses/ToadsTurnpike.cpp @@ -36,6 +36,7 @@ extern "C" { #include "collision.h" #include "memory.h" #include "code_80086E70.h" + #include "course.h" extern const char *d_course_toads_turnpike_dl_list[]; extern s16 currentScreenSection; extern s8 gPlayerCount; @@ -148,7 +149,7 @@ void ToadsTurnpike::Load() { D_801625F0 = 4; D_802B87B0 = 993; D_802B87B4 = 1000; - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_toads_turnpike_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_toads_turnpike_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } diff --git a/src/engine/courses/WarioStadium.cpp b/src/engine/courses/WarioStadium.cpp index 99cb0678a..5bb37c924 100644 --- a/src/engine/courses/WarioStadium.cpp +++ b/src/engine/courses/WarioStadium.cpp @@ -32,6 +32,7 @@ extern "C" { #include "code_8003DC40.h" #include "memory.h" #include "skybox_and_splitscreen.h" +#include "course.h" extern const char* wario_stadium_dls[]; extern s16 currentScreenSection; } @@ -139,7 +140,7 @@ WarioStadium::WarioStadium() { void WarioStadium::Load() { Course::Load(); - parse_course_displaylists((TrackSectionsI*) LOAD_ASSET_RAW(d_course_wario_stadium_addr)); + parse_course_displaylists((TrackSections*) LOAD_ASSET_RAW(d_course_wario_stadium_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; // d_course_wario_stadium_packed_dl_C50 diff --git a/src/engine/courses/YoshiValley.cpp b/src/engine/courses/YoshiValley.cpp index 41cca62b6..75ea1a6a6 100644 --- a/src/engine/courses/YoshiValley.cpp +++ b/src/engine/courses/YoshiValley.cpp @@ -33,6 +33,7 @@ extern "C" { #include "actors.h" #include "collision.h" #include "memory.h" + #include "course.h" extern const char *d_course_yoshi_valley_dl_list[]; } @@ -128,7 +129,7 @@ void YoshiValley::Load() { Lights1 lights4 = gdSPDefLights1(100, 100, 100, 255, 254, 254, 0, 0, 120); set_track_light_direction(&lights4, -0x38F0, 0x1C70, 1); - parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_yoshi_valley_addr)); + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_yoshi_valley_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } diff --git a/src/port/resource/importers/TrackWaypointFactory.cpp b/src/port/resource/importers/TrackWaypointFactory.cpp index 4975e018b..75707c5ce 100644 --- a/src/port/resource/importers/TrackWaypointFactory.cpp +++ b/src/port/resource/importers/TrackWaypointFactory.cpp @@ -18,7 +18,7 @@ ResourceFactoryBinaryTrackWaypointsV0::ReadResource(std::shared_ptr section->TrackWaypointList.reserve(count); for (uint32_t i = 0; i < count; i++) { - TrackWaypoint data; + TrackWaypointData data; data.posX = reader->ReadInt16(); data.posY = reader->ReadInt16(); data.posZ = reader->ReadInt16(); @@ -45,12 +45,12 @@ ResourceFactoryXMLTrackWaypointsV0::ReadResource(std::shared_ptr fil while (path != nullptr) { - std::vector waypointPath; // Temporary container for this path + std::vector waypointPath; // Temporary container for this path auto pointElem = path->FirstChildElement("Point"); while (pointElem != nullptr) { - TrackWaypoint point; + TrackWaypointData point; point.posX = pointElem->IntAttribute("X"); point.posY = pointElem->IntAttribute("Y"); point.posZ = pointElem->IntAttribute("Z"); diff --git a/src/port/resource/type/TrackWaypoint.cpp b/src/port/resource/type/TrackWaypoint.cpp index 56ec1c760..0492c7285 100644 --- a/src/port/resource/type/TrackWaypoint.cpp +++ b/src/port/resource/type/TrackWaypoint.cpp @@ -5,12 +5,12 @@ namespace MK64 { TrackWaypoints::TrackWaypoints() : Resource(std::shared_ptr()) { } -TrackWaypoint* TrackWaypoints::GetPointer() { +TrackWaypointData* TrackWaypoints::GetPointer() { return TrackWaypointList.data(); } size_t TrackWaypoints::GetPointerSize() { - return TrackWaypointList.size() * sizeof(TrackWaypoint); + return TrackWaypointList.size() * sizeof(TrackWaypointData); } @@ -18,7 +18,8 @@ Paths::Paths() : Resource(std::shared_ptr()) { } // I don't know how to return this properly -TrackWaypoint* Paths::GetPointer() { +TrackWaypointData* Paths::GetPointer() { + printf("Do not LOAD_ASSET an XML track waypoint/path, you need to use dynamic_cast(ResourceLoad())"); return nullptr; } @@ -27,7 +28,7 @@ size_t Paths::GetPointerSize() { for (const auto& path : PathList) { totalWaypoints += path.size(); } - return totalWaypoints * sizeof(TrackWaypoint); + return totalWaypoints * sizeof(TrackWaypointData); } } // namespace MK64 diff --git a/src/port/resource/type/TrackWaypoint.h b/src/port/resource/type/TrackWaypoint.h index 54176bae0..71c976d1b 100644 --- a/src/port/resource/type/TrackWaypoint.h +++ b/src/port/resource/type/TrackWaypoint.h @@ -4,7 +4,7 @@ #include #include -struct TrackWaypoint { +struct TrackWaypointData { int16_t posX; int16_t posY; int16_t posZ; @@ -13,29 +13,29 @@ struct TrackWaypoint { namespace MK64 { // Used for binary import from torch -class TrackWaypoints : public Ship::Resource { +class TrackWaypoints : public Ship::Resource { public: using Resource::Resource; TrackWaypoints(); - TrackWaypoint* GetPointer() override; + TrackWaypointData* GetPointer() override; size_t GetPointerSize() override; - std::vector TrackWaypointList; + std::vector TrackWaypointList; }; // Used for xml -class Paths : public Ship::Resource { +class Paths : public Ship::Resource { public: using Resource::Resource; Paths(); - TrackWaypoint* GetPointer() override; + TrackWaypointData* GetPointer() override; size_t GetPointerSize() override; - std::vector> PathList; + std::vector> PathList; }; } // namespace MK64 diff --git a/src/port/ui/ContentBrowser.cpp b/src/port/ui/ContentBrowser.cpp index ba59dbb77..6e8dd1284 100644 --- a/src/port/ui/ContentBrowser.cpp +++ b/src/port/ui/ContentBrowser.cpp @@ -131,10 +131,10 @@ namespace Editor { if (asset.ends_with("scene.json")) { foundTrackFile = true; if (ImGui::Button(label.c_str())) { - - SetCourseByClass(new Course()); + gWorldInstance.Courses.push_back(new Course()); + SetCourseByClass(gWorldInstance.Courses.back()); LoadLevel(asset); - + gWorldInstance.CurrentCourse->LoadO2R(TrackPath[track]); gGamestateNext = RACING; break; } diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c index 5f5940904..71b182544 100644 --- a/src/racing/render_courses.c +++ b/src/racing/render_courses.c @@ -1,4 +1,4 @@ -#include + #include #include #include #include @@ -50,7 +50,7 @@ s32 func_80290C20(Camera* camera) { return 0; } -void parse_course_displaylists(TrackSectionsI* asset) { +void parse_course_displaylists(TrackSections* asset) { TrackSections* section = (TrackSections*) asset; while (section->addr != 0) { diff --git a/src/racing/render_courses.h b/src/racing/render_courses.h index 5140c2780..cb11ad4c7 100644 --- a/src/racing/render_courses.h +++ b/src/racing/render_courses.h @@ -3,17 +3,11 @@ #include "code_800029B0.h" #include "../camera.h" - -typedef struct { - u32 addr; - u8 surfaceType; - u8 sectionId; - u16 flags; -} TrackSectionsI; +#include void func_8029122C(struct UnkStruct_800DC5EC*, s32); s32 func_80290C20(Camera*); -void parse_course_displaylists(TrackSectionsI* asset); +void parse_course_displaylists(TrackSections* asset); void render_course_segments(const char*[], struct UnkStruct_800DC5EC*); void func_80291198(void); void render_mario_raceway_pipe(void);