mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
cpu variable rename (#166)
This commit is contained in:
+2
-2
@@ -48,7 +48,7 @@
|
||||
|
||||
#ifdef MK64_SUPPORT
|
||||
#include "factories/mk64/CourseVtx.h"
|
||||
#include "factories/mk64/Waypoints.h"
|
||||
#include "factories/mk64/Paths.h"
|
||||
#include "factories/mk64/TrackSections.h"
|
||||
#include "factories/mk64/SpawnData.h"
|
||||
#include "factories/mk64/UnkSpawnData.h"
|
||||
@@ -142,7 +142,7 @@ void Companion::Init(const ExportType type) {
|
||||
|
||||
#ifdef MK64_SUPPORT
|
||||
this->RegisterFactory("MK64:COURSE_VTX", std::make_shared<MK64::CourseVtxFactory>());
|
||||
this->RegisterFactory("MK64:TRACK_WAYPOINTS", std::make_shared<MK64::WaypointsFactory>());
|
||||
this->RegisterFactory("MK64:TRACK_PATH", std::make_shared<MK64::PathsFactory>());
|
||||
this->RegisterFactory("MK64:TRACK_SECTIONS", std::make_shared<MK64::TrackSectionsFactory>());
|
||||
this->RegisterFactory("MK64:SPAWN_DATA", std::make_shared<MK64::SpawnDataFactory>());
|
||||
this->RegisterFactory("MK64:UNK_SPAWN_DATA", std::make_shared<MK64::UnkSpawnDataFactory>());
|
||||
|
||||
@@ -29,7 +29,7 @@ enum class ResourceType {
|
||||
Dictionary = 0x44494354, // DICT
|
||||
GeoLayout = 0x47454F20, // GEO
|
||||
Collision = 0x434F4C20, // COL
|
||||
LevelScript = 0x4C564C53, // LVLS
|
||||
LevelScript = 0x4C564C53, // LVLS
|
||||
MacroObject = 0x4D41434F, // MACO
|
||||
Movtex = 0x4D4F5654, // MOVT
|
||||
MovtexQuad = 0x4D4F5651, // MOVQ
|
||||
@@ -42,8 +42,8 @@ enum class ResourceType {
|
||||
CourseProperties = 0x43505459, // CPTY
|
||||
CourseVertex = 0x43565458, // CVTX
|
||||
TrackSection = 0x5343544E, // SCTN
|
||||
Waypoints = 0x57505453, // WPTS
|
||||
Metadata = 0x4D444154, // MDAT
|
||||
Paths = 0x50415453, // PATH
|
||||
Metadata = 0x4D444154, // MDAT
|
||||
SpawnData = 0x53444154, // SDAT
|
||||
UnkSpawnData = 0x55534454, // USDT
|
||||
DrivingBehaviour = 0x44424856, // DBHV
|
||||
@@ -79,4 +79,4 @@ enum class ResourceType {
|
||||
Envelope = 0x45564C50, // EVLP
|
||||
AudioTable = 0x4154424C // ATBL
|
||||
};
|
||||
} // namespace LUS
|
||||
} // namespace Torch
|
||||
|
||||
@@ -91,17 +91,17 @@ ExportResult MK64::CourseMetadataCodeExporter::Export(std::ostream &write, std::
|
||||
file.close();
|
||||
}
|
||||
|
||||
file.open(outDir+"gKartAIBehaviourLUT.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
file.open(outDir+"cpu_BehaviourLUT.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
if (file.is_open()) {
|
||||
for (const auto& m : metadata) {
|
||||
file << m.kartAIBehaviourLUT << ", ";
|
||||
file << m.CPUBehaviourLUT << ", ";
|
||||
}
|
||||
file << 0; // @WARNING TRAILING ZERO IN ARRAY
|
||||
file << "\n";
|
||||
file.close();
|
||||
}
|
||||
|
||||
file.open(outDir+"gKartAICourseMaximumSeparation.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
file.open(outDir+"cpu_CourseMaximumSeparation.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
if (file.is_open()) {
|
||||
// file << "f32 gWaypointWidth[] = {\n" << fourSpaceTab;
|
||||
for (const auto& m : metadata) {
|
||||
@@ -112,7 +112,7 @@ ExportResult MK64::CourseMetadataCodeExporter::Export(std::ostream &write, std::
|
||||
file.close();
|
||||
}
|
||||
|
||||
file.open(outDir+"gKartAICourseMinimumSeparation.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
file.open(outDir+"cpu_CourseMinimumSeparation.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
if (file.is_open()) {
|
||||
// file << "f32 gWaypointWidth2[] = {\n" << fourSpaceTab;
|
||||
for (const auto& m : metadata) {
|
||||
@@ -134,11 +134,11 @@ ExportResult MK64::CourseMetadataCodeExporter::Export(std::ostream &write, std::
|
||||
file.close();
|
||||
}
|
||||
|
||||
file.open(outDir+"gCPUSteeringSensitivity.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
file.open(outDir+"cpu_SteeringSensitivity.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
|
||||
// @WARNING THIS FILE HAS A TRAILING ZERO
|
||||
if (file.is_open()) {
|
||||
//file << "u16 gCPUSteeringSensitivity[] = {\n" << fourSpaceTab;
|
||||
//file << "u16 cpu_SteeringSensitivity[] = {\n" << fourSpaceTab;
|
||||
for (const auto& m : metadata) {
|
||||
file << m.steeringSensitivity << ", ";
|
||||
}
|
||||
@@ -150,7 +150,7 @@ ExportResult MK64::CourseMetadataCodeExporter::Export(std::ostream &write, std::
|
||||
|
||||
file.open(outDir+"gBombKartSpawns.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
if (file.is_open()) {
|
||||
//file << "u16 gCPUSteeringSensitivity[] = {\n" << fourSpaceTab;
|
||||
//file << "u16 cpu_SteeringSensitivity[] = {\n" << fourSpaceTab;
|
||||
for (const auto& m : metadata) {
|
||||
file << "{ // " << m.name << "\n";
|
||||
for (const auto& bombKart : m.bombKartSpawns) {
|
||||
@@ -190,12 +190,12 @@ ExportResult MK64::CourseMetadataCodeExporter::Export(std::ostream &write, std::
|
||||
file.close();
|
||||
}
|
||||
|
||||
file.open(outDir+"D_0D009418.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
file.open(outDir+"cpu_CurveTargetSpeed.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
if (file.is_open()) {
|
||||
for (const auto& m : metadata) {
|
||||
file << "// " << m.name << "\n";
|
||||
file << "{ ";
|
||||
for (const auto size : m.D_0D009418) {
|
||||
for (const auto size : m.cpu_CurveTargetSpeed) {
|
||||
file << size << ", ";
|
||||
}
|
||||
file << "},\n";
|
||||
@@ -203,12 +203,12 @@ ExportResult MK64::CourseMetadataCodeExporter::Export(std::ostream &write, std::
|
||||
file.close();
|
||||
}
|
||||
|
||||
file.open(outDir+"D_0D009568.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
file.open(outDir+"cpu_NormalTargetSpeed.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
if (file.is_open()) {
|
||||
for (const auto& m : metadata) {
|
||||
file << "// " << m.name << "\n";
|
||||
file << "{ ";
|
||||
for (const auto& size : m.D_0D009568) {
|
||||
for (const auto& size : m.cpu_NormalTargetSpeed) {
|
||||
file << size << ", ";
|
||||
}
|
||||
file << "},\n";
|
||||
@@ -229,12 +229,12 @@ ExportResult MK64::CourseMetadataCodeExporter::Export(std::ostream &write, std::
|
||||
file.close();
|
||||
}
|
||||
|
||||
file.open(outDir+"D_0D009808.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
file.open(outDir+"cpu_OffTrackTargetSpeed.inc.c", std::ios_base::binary | std::ios_base::out);
|
||||
if (file.is_open()) {
|
||||
for (const auto& m : metadata) {
|
||||
file << "// " << m.name << "\n";
|
||||
file << "{ ";
|
||||
for (const auto& size : m.D_0D009808) {
|
||||
for (const auto& size : m.cpu_OffTrackTargetSpeed) {
|
||||
file << size << ", ";
|
||||
}
|
||||
file << "},\n";
|
||||
@@ -310,7 +310,7 @@ ExportResult MK64::CourseMetadataBinaryExporter::Export(std::ostream &write, std
|
||||
writer.Write(m.cup);
|
||||
writer.Write(m.cupIndex);
|
||||
writer.Write(m.courseLength);
|
||||
writer.Write(m.kartAIBehaviourLUT);
|
||||
writer.Write(m.CPUBehaviourLUT);
|
||||
writer.Write(m.kartAIMaximumSeparation);
|
||||
writer.Write(m.kartAIMinimumSeparation);
|
||||
writer.Write(m.D_800DCBB4);
|
||||
@@ -330,11 +330,11 @@ ExportResult MK64::CourseMetadataBinaryExporter::Export(std::ostream &write, std
|
||||
writer.Write(p);
|
||||
}
|
||||
|
||||
for (auto s : m.D_0D009418) {
|
||||
for (auto s : m.cpu_CurveTargetSpeed) {
|
||||
writer.Write(s);
|
||||
}
|
||||
|
||||
for (auto s : m.D_0D009568) {
|
||||
for (auto s : m.cpu_NormalTargetSpeed) {
|
||||
writer.Write(s);
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ ExportResult MK64::CourseMetadataBinaryExporter::Export(std::ostream &write, std
|
||||
writer.Write(s);
|
||||
}
|
||||
|
||||
for (auto s : m.D_0D009808) {
|
||||
for (auto s : m.cpu_OffTrackTargetSpeed) {
|
||||
writer.Write(s);
|
||||
}
|
||||
|
||||
@@ -393,9 +393,9 @@ std::optional<std::shared_ptr<IParsedData>> MK64::CourseMetadataFactory::parse(s
|
||||
data.cupIndex = GetSafeNode<int32_t>(metadata, "cup_index");
|
||||
data.courseLength = GetSafeNode<std::string>(metadata, "course_length");
|
||||
|
||||
data.kartAIBehaviourLUT = GetSafeNode<std::string>(metadata, "kart_ai_behaviour_ptr");
|
||||
data.kartAIMaximumSeparation = GetSafeNode<std::string>(metadata, "kart_ai_maximum_separation");
|
||||
data.kartAIMinimumSeparation = GetSafeNode<std::string>(metadata, "kart_ai_minimum_separation");
|
||||
data.CPUBehaviourLUT = GetSafeNode<std::string>(metadata, "cpu_behaviour_ptr");
|
||||
data.kartAIMaximumSeparation = GetSafeNode<std::string>(metadata, "cpu_maximum_separation");
|
||||
data.kartAIMinimumSeparation = GetSafeNode<std::string>(metadata, "cpu_minimum_separation");
|
||||
|
||||
data.D_800DCBB4 = GetSafeNode<std::string>(metadata, "D_800DCBB4");
|
||||
data.steeringSensitivity = GetSafeNode<uint32_t>(metadata, "cpu_steering_sensitivity");
|
||||
@@ -416,20 +416,20 @@ std::optional<std::shared_ptr<IParsedData>> MK64::CourseMetadataFactory::parse(s
|
||||
data.pathSizes.push_back(size.as<uint16_t>());
|
||||
}
|
||||
|
||||
for (const auto& value : GetSafeNode<YAML::Node>(metadata, "D_0D009418")) {
|
||||
data.D_0D009418.push_back(value.as<std::string>());
|
||||
for (const auto& value : GetSafeNode<YAML::Node>(metadata, "cpu_CurveTargetSpeed")) {
|
||||
data.cpu_CurveTargetSpeed.push_back(value.as<std::string>());
|
||||
}
|
||||
|
||||
for (const auto& value : GetSafeNode<YAML::Node>(metadata, "D_0D009568")) {
|
||||
data.D_0D009568.push_back(value.as<std::string>());
|
||||
for (const auto& value : GetSafeNode<YAML::Node>(metadata, "cpu_NormalTargetSpeed")) {
|
||||
data.cpu_NormalTargetSpeed.push_back(value.as<std::string>());
|
||||
}
|
||||
|
||||
for (const auto& value : GetSafeNode<YAML::Node>(metadata, "D_0D0096B8")) {
|
||||
data.D_0D0096B8.push_back(value.as<std::string>());
|
||||
}
|
||||
SPDLOG_INFO("MIDDLE");
|
||||
for (const auto& value : GetSafeNode<YAML::Node>(metadata, "D_0D009808")) {
|
||||
data.D_0D009808.push_back(value.as<std::string>());
|
||||
for (const auto& value : GetSafeNode<YAML::Node>(metadata, "cpu_OffTrackTargetSpeed")) {
|
||||
data.cpu_OffTrackTargetSpeed.push_back(value.as<std::string>());
|
||||
}
|
||||
|
||||
for (const auto& str : GetSafeNode<YAML::Node>(metadata, "path_table")) {
|
||||
|
||||
@@ -21,17 +21,17 @@ namespace MK64 {
|
||||
std::string cup;
|
||||
int32_t cupIndex;
|
||||
std::string courseLength;
|
||||
std::string kartAIBehaviourLUT;
|
||||
std::string CPUBehaviourLUT;
|
||||
std::string kartAIMaximumSeparation;
|
||||
std::string kartAIMinimumSeparation;
|
||||
std::string D_800DCBB4;
|
||||
uint32_t steeringSensitivity;
|
||||
std::vector<BombKartSpawns> bombKartSpawns;
|
||||
std::vector<uint16_t> pathSizes;
|
||||
std::vector<std::string> D_0D009418;
|
||||
std::vector<std::string> D_0D009568;
|
||||
std::vector<std::string> cpu_CurveTargetSpeed;
|
||||
std::vector<std::string> cpu_NormalTargetSpeed;
|
||||
std::vector<std::string> D_0D0096B8;
|
||||
std::vector<std::string> D_0D009808;
|
||||
std::vector<std::string> cpu_OffTrackTargetSpeed;
|
||||
std::vector<std::string> pathTable;
|
||||
std::vector<std::string> pathTableUnknown;
|
||||
std::vector<uint16_t> skyColors;
|
||||
|
||||
@@ -15,7 +15,7 @@ ExportResult MK64::DrivingBehaviourHeaderExporter::Export(std::ostream &write, s
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
write << "extern KartAIBehaviour " << symbol << "[];\n";
|
||||
write << "extern CPUBehaviour " << symbol << "[];\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ ExportResult MK64::DrivingBehaviourCodeExporter::Export(std::ostream &write, std
|
||||
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
|
||||
}
|
||||
|
||||
write << "KartAIBehaviour " << symbol << "[] = {\n";
|
||||
write << "CPUBehaviour " << symbol << "[] = {\n";
|
||||
|
||||
|
||||
for(auto b : bhv->mBhvs) {
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#include "Paths.h"
|
||||
|
||||
#include "Companion.h"
|
||||
#include "utils/Decompressor.h"
|
||||
|
||||
#define NUM(x) std::dec << std::setfill(' ') << std::setw(6) << x
|
||||
#define COL(c) "0x" << std::hex << std::setw(2) << std::setfill('0') << c
|
||||
|
||||
ExportResult MK64::PathHeaderExporter::Export(std::ostream& write, std::shared_ptr<IParsedData> raw,
|
||||
std::string& entryName, YAML::Node& node, std::string* replacement) {
|
||||
const auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
|
||||
if (Companion::Instance->IsOTRMode()) {
|
||||
write << "static const ALIGN_ASSET(2) char " << symbol << "[] = \"__OTR__" << (*replacement) << "\";\n\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
write << "extern TrackPathPoint " << symbol << "[];\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
ExportResult MK64::PathCodeExporter::Export(std::ostream& write, std::shared_ptr<IParsedData> raw,
|
||||
std::string& entryName, YAML::Node& node, std::string* replacement) {
|
||||
auto paths = std::static_pointer_cast<PathData>(raw)->mPaths;
|
||||
auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
|
||||
write << "TrackPathPoint " << symbol << "[] = {\n";
|
||||
|
||||
for (int i = 0; i < paths.size(); ++i) {
|
||||
auto x = paths[i].posX;
|
||||
auto y = paths[i].posY;
|
||||
auto z = paths[i].posZ;
|
||||
|
||||
// Track segment
|
||||
auto seg = paths[i].trackSegment;
|
||||
|
||||
if (i <= paths.size() - 1) {
|
||||
write << fourSpaceTab;
|
||||
}
|
||||
|
||||
// {{{ x, y, z }, f, { tc1, tc2 }, { c1, c2, c3, c4 }}}
|
||||
write << "{" << NUM(x) << ", " << NUM(y) << ", " << NUM(z) << ", " << NUM(seg) << " },\n";
|
||||
}
|
||||
write << "};\n";
|
||||
|
||||
return offset + paths.size() * sizeof(MK64::TrackPath);
|
||||
}
|
||||
|
||||
ExportResult MK64::PathBinaryExporter::Export(std::ostream& write, std::shared_ptr<IParsedData> raw,
|
||||
std::string& entryName, YAML::Node& node, std::string* replacement) {
|
||||
auto paths = std::static_pointer_cast<PathData>(raw)->mPaths;
|
||||
auto writer = LUS::BinaryWriter();
|
||||
|
||||
WriteHeader(writer, Torch::ResourceType::Paths, 0);
|
||||
writer.Write((uint32_t) paths.size());
|
||||
for (auto w : paths) {
|
||||
writer.Write(w.posX);
|
||||
writer.Write(w.posY);
|
||||
writer.Write(w.posZ);
|
||||
writer.Write(w.trackSegment);
|
||||
}
|
||||
|
||||
writer.Finish(write);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::shared_ptr<IParsedData>> MK64::PathsFactory::parse(std::vector<uint8_t>& buffer, YAML::Node& node) {
|
||||
auto count = GetSafeNode<size_t>(node, "count");
|
||||
|
||||
auto [_, segment] = Decompressor::AutoDecode(node, buffer);
|
||||
LUS::BinaryReader reader(segment.data, count * sizeof(MK64::TrackPath));
|
||||
|
||||
reader.SetEndianness(Torch::Endianness::Big);
|
||||
std::vector<MK64::TrackPath> paths;
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
auto x = reader.ReadInt16();
|
||||
auto y = reader.ReadInt16();
|
||||
auto z = reader.ReadInt16();
|
||||
auto trackSegment = reader.ReadUInt16();
|
||||
|
||||
paths.push_back(MK64::TrackPath({ x, y, z, trackSegment }));
|
||||
}
|
||||
|
||||
return std::make_shared<PathData>(paths);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <factories/BaseFactory.h>
|
||||
|
||||
namespace MK64 {
|
||||
|
||||
struct TrackPath {
|
||||
int16_t posX;
|
||||
int16_t posY;
|
||||
int16_t posZ;
|
||||
uint16_t trackSegment;
|
||||
};
|
||||
|
||||
class PathData : public IParsedData {
|
||||
public:
|
||||
std::vector<TrackPath> mPaths;
|
||||
|
||||
explicit PathData(std::vector<TrackPath> paths) : mPaths(paths) {
|
||||
}
|
||||
};
|
||||
|
||||
class PathHeaderExporter : public BaseExporter {
|
||||
ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName,
|
||||
YAML::Node& node, std::string* replacement) override;
|
||||
};
|
||||
|
||||
class PathBinaryExporter : public BaseExporter {
|
||||
ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName,
|
||||
YAML::Node& node, std::string* replacement) override;
|
||||
};
|
||||
|
||||
class PathCodeExporter : public BaseExporter {
|
||||
ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName,
|
||||
YAML::Node& node, std::string* replacement) override;
|
||||
};
|
||||
|
||||
class PathsFactory : public BaseFactory {
|
||||
public:
|
||||
std::optional<std::shared_ptr<IParsedData>> parse(std::vector<uint8_t>& buffer, YAML::Node& data) override;
|
||||
std::optional<std::shared_ptr<IParsedData>> parse_modding(std::vector<uint8_t>& buffer, YAML::Node& data) override {
|
||||
return std::nullopt;
|
||||
}
|
||||
inline std::unordered_map<ExportType, std::shared_ptr<BaseExporter>> GetExporters() override {
|
||||
return { REGISTER(Code, PathCodeExporter) REGISTER(Header, PathHeaderExporter)
|
||||
REGISTER(Binary, PathBinaryExporter) };
|
||||
}
|
||||
bool SupportModdedAssets() override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
} // namespace MK64
|
||||
@@ -1,86 +0,0 @@
|
||||
#include "Waypoints.h"
|
||||
|
||||
#include "Companion.h"
|
||||
#include "utils/Decompressor.h"
|
||||
|
||||
#define NUM(x) std::dec << std::setfill(' ') << std::setw(6) << x
|
||||
#define COL(c) "0x" << std::hex << std::setw(2) << std::setfill('0') << c
|
||||
|
||||
ExportResult MK64::WaypointHeaderExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement) {
|
||||
const auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
|
||||
if(Companion::Instance->IsOTRMode()){
|
||||
write << "static const ALIGN_ASSET(2) char " << symbol << "[] = \"__OTR__" << (*replacement) << "\";\n\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
write << "extern TrackWaypoint " << symbol << "[];\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
ExportResult MK64::WaypointCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
auto waypoints = std::static_pointer_cast<WaypointData>(raw)->mWaypoints;
|
||||
auto symbol = GetSafeNode(node, "symbol", entryName);
|
||||
auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
|
||||
write << "TrackWaypoint " << symbol << "[] = {\n";
|
||||
|
||||
for (int i = 0; i < waypoints.size(); ++i) {
|
||||
auto x = waypoints[i].posX;
|
||||
auto y = waypoints[i].posY;
|
||||
auto z = waypoints[i].posZ;
|
||||
|
||||
// Track segment
|
||||
auto seg = waypoints[i].trackSegment;
|
||||
|
||||
if(i <= waypoints.size() - 1) {
|
||||
write << fourSpaceTab;
|
||||
}
|
||||
|
||||
// {{{ x, y, z }, f, { tc1, tc2 }, { c1, c2, c3, c4 }}}
|
||||
write << "{" << NUM(x) << ", " << NUM(y) << ", " << NUM(z) << ", " << NUM(seg) << " },\n";
|
||||
}
|
||||
write << "};\n";
|
||||
|
||||
return offset + waypoints.size() * sizeof(MK64::TrackWaypoint);
|
||||
}
|
||||
|
||||
ExportResult MK64::WaypointBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
|
||||
auto waypoints = std::static_pointer_cast<WaypointData>(raw)->mWaypoints;
|
||||
auto writer = LUS::BinaryWriter();
|
||||
|
||||
WriteHeader(writer, Torch::ResourceType::Waypoints, 0);
|
||||
writer.Write((uint32_t) waypoints.size());
|
||||
for(auto w : waypoints) {
|
||||
writer.Write(w.posX);
|
||||
writer.Write(w.posY);
|
||||
writer.Write(w.posZ);
|
||||
writer.Write(w.trackSegment);
|
||||
}
|
||||
|
||||
writer.Finish(write);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::shared_ptr<IParsedData>> MK64::WaypointsFactory::parse(std::vector<uint8_t>& buffer, YAML::Node& node) {
|
||||
auto count = GetSafeNode<size_t>(node, "count");
|
||||
|
||||
auto [_, segment] = Decompressor::AutoDecode(node, buffer);
|
||||
LUS::BinaryReader reader(segment.data, count * sizeof(MK64::TrackWaypoint));
|
||||
|
||||
reader.SetEndianness(Torch::Endianness::Big);
|
||||
std::vector<MK64::TrackWaypoint> waypoints;
|
||||
|
||||
for(size_t i = 0; i < count; i++) {
|
||||
auto x = reader.ReadInt16();
|
||||
auto y = reader.ReadInt16();
|
||||
auto z = reader.ReadInt16();
|
||||
auto trackSegment = reader.ReadUInt16();
|
||||
|
||||
waypoints.push_back(MK64::TrackWaypoint({
|
||||
x, y, z, trackSegment
|
||||
}));
|
||||
}
|
||||
|
||||
return std::make_shared<WaypointData>(waypoints);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <factories/BaseFactory.h>
|
||||
|
||||
namespace MK64 {
|
||||
|
||||
struct TrackWaypoint {
|
||||
int16_t posX;
|
||||
int16_t posY;
|
||||
int16_t posZ;
|
||||
uint16_t trackSegment;
|
||||
};
|
||||
|
||||
class WaypointData : public IParsedData {
|
||||
public:
|
||||
std::vector<TrackWaypoint> mWaypoints;
|
||||
|
||||
explicit WaypointData(std::vector<TrackWaypoint> waypoints) : mWaypoints(waypoints) {}
|
||||
};
|
||||
|
||||
class WaypointHeaderExporter : public BaseExporter {
|
||||
ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
|
||||
};
|
||||
|
||||
class WaypointBinaryExporter : public BaseExporter {
|
||||
ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
|
||||
};
|
||||
|
||||
class WaypointCodeExporter : public BaseExporter {
|
||||
ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
|
||||
};
|
||||
|
||||
class WaypointsFactory : public BaseFactory {
|
||||
public:
|
||||
std::optional<std::shared_ptr<IParsedData>> parse(std::vector<uint8_t>& buffer, YAML::Node& data) override;
|
||||
std::optional<std::shared_ptr<IParsedData>> parse_modding(std::vector<uint8_t>& buffer, YAML::Node& data) override {
|
||||
return std::nullopt;
|
||||
}
|
||||
inline std::unordered_map<ExportType, std::shared_ptr<BaseExporter>> GetExporters() override {
|
||||
return {
|
||||
REGISTER(Code, WaypointCodeExporter)
|
||||
REGISTER(Header, WaypointHeaderExporter)
|
||||
REGISTER(Binary, WaypointBinaryExporter)
|
||||
};
|
||||
}
|
||||
bool SupportModdedAssets() override { return false; }
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user