summaryrefslogtreecommitdiff
path: root/src/factories/Vec3fFactory.cpp
diff options
context:
space:
mode:
authorLywx <kiritodev01@gmail.com>2024-03-20 21:17:11 -0600
committerGitHub <noreply@github.com>2024-03-20 21:17:11 -0600
commitf0c70f855a892ca7dc21cee4b4037dad983adb8f (patch)
treef15cc271b00166476a2e7b780e50d911770a7316 /src/factories/Vec3fFactory.cpp
parent8465919ab7aba6cfde7d25ad1731673e5da01642 (diff)
Auto pad and overlap detection (#47)
* Fully implemented pad and overlap detection * Cleaned code, fixed pad generation and added alignment * Added debug size on pads
Diffstat (limited to 'src/factories/Vec3fFactory.cpp')
-rw-r--r--src/factories/Vec3fFactory.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/factories/Vec3fFactory.cpp b/src/factories/Vec3fFactory.cpp
index e6dbf2b..41b7bfb 100644
--- a/src/factories/Vec3fFactory.cpp
+++ b/src/factories/Vec3fFactory.cpp
@@ -16,15 +16,16 @@ Vec3fData::Vec3fData(std::vector<Vec3f> vecs): mVecs(vecs) {
}
}
-void Vec3fHeaderExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement) {
+ExportResult Vec3fHeaderExporter::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 char " << symbol << "[] = \"__OTR__" << (*replacement) << "\";\n\n";
- return;
+ return std::nullopt;
}
write << "extern Vec3f " << symbol << "[];\n";
+ return std::nullopt;
}
@@ -32,7 +33,7 @@ int GetPrecision(Vec3f v) {
return std::max(std::max(GetPrecision(v.x), GetPrecision(v.y)), GetPrecision(v.z));
}
-void Vec3fCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
+ExportResult Vec3fCodeExporter::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);
const auto offset = GetSafeNode<uint32_t>(node, "offset");
auto vecData = std::static_pointer_cast<Vec3fData>(raw);
@@ -41,7 +42,7 @@ void Vec3fCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData>
if(IS_SEGMENTED(off)) {
off = SEGMENT_OFFSET(off);
- }
+ }
if (Companion::Instance->IsDebug()) {
write << "// 0x" << std::uppercase << std::hex << off << "\n";
}
@@ -58,16 +59,16 @@ void Vec3fCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData>
}
write << "\n};\n";
+
if (Companion::Instance->IsDebug()) {
write << "// Count: " << vecData->mVecs.size() << " Vec3fs\n";
- write << "// 0x" << std::uppercase << std::hex << off + vecData->mVecs.size() * sizeof(Vec3f) << "\n";
}
- write << "\n";
-
-}
-void Vec3fBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
+ return (IS_SEGMENTED(off) ? SEGMENT_OFFSET(off) : off) + vecData->mVecs.size() * sizeof(Vec3f);
+}
+ExportResult Vec3fBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
+ return std::nullopt;
}
std::optional<std::shared_ptr<IParsedData>> Vec3fFactory::parse(std::vector<uint8_t>& buffer, YAML::Node& node) {