mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-07-09 23:02:11 -04:00
nearly working
This commit is contained in:
@@ -31,7 +31,6 @@ Course::Course() {
|
||||
// Props.CourseLength = "567m";
|
||||
// Props.Cup = FLOWER_CUP;
|
||||
// Props.CupIndex = 3;
|
||||
Props.TrackSectionsPtr = NULL;
|
||||
Props.LakituTowType = (s32) OLakitu::LakituTowType::NORMAL;
|
||||
Props.AIBehaviour = D_0D008F28;
|
||||
Props.AIMaximumSeparation = 50.0f;
|
||||
@@ -91,7 +90,7 @@ void Course::Load(Vtx* vtx, Gfx* gfx) {
|
||||
|
||||
void Course::LoadO2R(std::string trackPath) {
|
||||
if (!trackPath.empty()) {
|
||||
Props.TrackSectionsPtr = (trackPath + "/data_track_sections").c_str();
|
||||
TrackSectionsPtr = (trackPath + "/data_track_sections");
|
||||
|
||||
std::string path_file = (trackPath + "/data_paths").c_str();
|
||||
|
||||
@@ -126,14 +125,16 @@ void Course::LoadO2R(std::string trackPath) {
|
||||
void Course::Load() {
|
||||
|
||||
// Load from O2R
|
||||
if (Props.TrackSectionsPtr != NULL || Props.TrackSectionsPtr[0] != '\0') {
|
||||
if (!TrackSectionsPtr.empty()) {
|
||||
|
||||
auto res = std::dynamic_pointer_cast<MK64::TrackSectionsO2RClass>(ResourceLoad(Props.TrackSectionsPtr));
|
||||
//auto res = std::dynamic_pointer_cast<MK64::TrackSectionsO2RClass>(ResourceLoad(TrackSectionsPtr.c_str()));
|
||||
|
||||
if (res != nullptr) {
|
||||
std::vector<TrackSectionsO2R> sections = res->TrackSectionsList;
|
||||
TrackSectionsO2R* sections = (TrackSectionsO2R*) LOAD_ASSET_RAW(TrackSectionsPtr.c_str());
|
||||
size_t size = ResourceGetSizeByName(TrackSectionsPtr.c_str());
|
||||
|
||||
ParseCourseSections(sections);
|
||||
if (sections != nullptr) {
|
||||
Course::Init();
|
||||
ParseCourseSections(sections, size);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -184,24 +185,25 @@ void Course::Load() {
|
||||
}
|
||||
|
||||
// C++ version of parse_course_displaylists()
|
||||
void Course::ParseCourseSections(std::vector<TrackSectionsO2R> sections) {
|
||||
for (auto& section : sections) {
|
||||
if (section.flags & 0x8000) {
|
||||
void Course::ParseCourseSections(TrackSectionsO2R* sections, size_t size) {
|
||||
for (size_t i = 0; i < (size / sizeof(TrackSectionsO2R)); i++) {
|
||||
if (sections[i].flags & 0x8000) {
|
||||
D_8015F59C = 1;
|
||||
} else {
|
||||
D_8015F59C = 0;
|
||||
}
|
||||
if (section.flags & 0x2000) {
|
||||
if (sections[i].flags & 0x2000) {
|
||||
D_8015F5A0 = 1;
|
||||
} else {
|
||||
D_8015F5A0 = 0;
|
||||
}
|
||||
if (section.flags & 0x4000) {
|
||||
if (sections[i].flags & 0x4000) {
|
||||
D_8015F5A4 = 1;
|
||||
} else {
|
||||
D_8015F5A4 = 0;
|
||||
}
|
||||
generate_collision_mesh((Gfx*)LOAD_ASSET_RAW(section.addr), section.surfaceType, section.sectionId);
|
||||
printf("LOADING DL %s\n", sections[i].addr.c_str());
|
||||
generate_collision_mesh((Gfx*)LOAD_ASSET_RAW(sections[i].addr.c_str()), sections[i].surfaceType, sections[i].sectionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +304,7 @@ void Course::Waypoints(Player* player, int8_t playerId) {
|
||||
}
|
||||
|
||||
void Course::Render(struct UnkStruct_800DC5EC* arg0) {
|
||||
//if (Props.TrackSectionsPtr) {
|
||||
//if (!TrackSectionsPtr.empty()) {
|
||||
// gSPDisplayList(gDisplayListHead++, (Gfx*)LOAD_ASSET_RAW(Props.TrackModel));
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ 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* TrackSectionsPtr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
nlohmann::json to_json() const {
|
||||
@@ -234,16 +233,17 @@ public:
|
||||
const course_texture* textures = nullptr;
|
||||
bool bSpawnFinishline = true;
|
||||
std::optional<FVector> FinishlineSpawnPoint;
|
||||
std::string TrackSectionsPtr;
|
||||
|
||||
virtual ~Course() = default;
|
||||
|
||||
explicit Course();
|
||||
|
||||
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(); // Decompress and load stock courses or from o2r but 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<TrackSectionsO2R> sections);
|
||||
virtual void ParseCourseSections(TrackSectionsO2R* sections, size_t size);
|
||||
|
||||
/**
|
||||
* @brief BeginPlay This function is called once at the start of gameplay.
|
||||
|
||||
@@ -49,14 +49,19 @@ ResourceFactoryXMLTrackSectionsV0::ReadResource(std::shared_ptr<Ship::File> file
|
||||
std::get<std::shared_ptr<tinyxml2::XMLDocument>>(file->Reader)->FirstChildElement()->FirstChildElement();
|
||||
|
||||
while (child != nullptr) {
|
||||
TrackSectionsO2R data;
|
||||
// Convert n64 addr to native addr
|
||||
data.addr = child->Attribute("gfx_path");
|
||||
data.surfaceType = child->IntAttribute("surface");
|
||||
data.sectionId = child->IntAttribute("section");
|
||||
data.flags = child->IntAttribute("flags");
|
||||
std::string childName = child->Name();
|
||||
|
||||
section->TrackSectionsList.push_back(data);
|
||||
if (childName == "Section") {
|
||||
TrackSectionsO2R data;
|
||||
// Convert n64 addr to native addr
|
||||
data.addr = std::string(child->Attribute("gfx_path"));
|
||||
data.surfaceType = child->IntAttribute("surface");
|
||||
data.sectionId = child->IntAttribute("section");
|
||||
data.flags = child->IntAttribute("flags");
|
||||
|
||||
section->TrackSectionsList.push_back(data);
|
||||
}
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
|
||||
return section;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
#include "resource/ResourceFactoryXML.h"
|
||||
|
||||
namespace MK64 {
|
||||
class ResourceFactoryBinaryTrackSectionsV0 : public Ship::ResourceFactoryBinary {
|
||||
@@ -10,7 +11,7 @@ class ResourceFactoryBinaryTrackSectionsV0 : public Ship::ResourceFactoryBinary
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) override;
|
||||
};
|
||||
|
||||
class ResourceFactoryXMLTrackSectionsV0 : public Ship::ResourceFactoryBinary {
|
||||
class ResourceFactoryXMLTrackSectionsV0 : public Ship::ResourceFactoryXML {
|
||||
public:
|
||||
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) override;
|
||||
|
||||
@@ -21,6 +21,6 @@ TrackSectionsO2R* TrackSectionsO2RClass::GetPointer() {
|
||||
}
|
||||
|
||||
size_t TrackSectionsO2RClass::GetPointerSize() {
|
||||
return TrackSectionsList.size() *sizeof(TrackSectionsO2R);
|
||||
return TrackSectionsList.size() * sizeof(TrackSectionsO2R);
|
||||
}
|
||||
} // namespace MK64
|
||||
|
||||
@@ -12,7 +12,7 @@ typedef struct {
|
||||
} TrackSectionsI;
|
||||
|
||||
typedef struct {
|
||||
const char* addr;
|
||||
std::string addr;
|
||||
uint8_t surfaceType;
|
||||
uint8_t sectionId;
|
||||
uint16_t flags;
|
||||
|
||||
Reference in New Issue
Block a user