summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2022-01-05 22:59:22 -0500
committerNicholas Estelami <NEstelami@users.noreply.github.com>2022-01-05 22:59:22 -0500
commit6ac2cf0d0960a79f63b898101bd2c1cf72189559 (patch)
treec1968a2403ef2dee574d2f340e26abf9fd1c9859
parente6469d7028bbb48a4ac78e042269561c02f42d4a (diff)
parent53d4d5645b70a5d9d5634f193ecf17bfda9a5991 (diff)
Merge conflict fix
-rw-r--r--.gitignore5
-rw-r--r--OTRExporter/BackgroundExporter.cpp6
-rw-r--r--OTRExporter/DisplayListExporter.cpp12
-rw-r--r--OTRExporter/ExporterTest.abin4711232 -> 0 bytes
-rw-r--r--OTRExporter/Main.cpp12
-rw-r--r--OTRExporter/Makefile56
-rw-r--r--OTRExporter/OTRSkeletonExporter.cpp2
-rw-r--r--OTRExporter/OTRSkeletonLimbExporter.cpp8
-rw-r--r--OTRExporter/PlayerAnimationExporter.cpp6
-rw-r--r--OTRExporter/RoomExporter.cpp15
-rw-r--r--OTRExporter/TextureExporter.cpp6
-rw-r--r--OTRExporter/VtxExporter.cpp3
-rwxr-xr-x[-rw-r--r--]extract_assets.py10
13 files changed, 96 insertions, 45 deletions
diff --git a/.gitignore b/.gitignore
index 66bf034..a1b8c9c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
# User-specific files
*.suo
*.user
@@ -343,5 +344,7 @@ assets/
baserom/
*.vtx.inc
*.otr
+*.swp
+*.a
-tmp.txt \ No newline at end of file
+tmp.txt
diff --git a/OTRExporter/BackgroundExporter.cpp b/OTRExporter/BackgroundExporter.cpp
index b7f9cd0..08a4896 100644
--- a/OTRExporter/BackgroundExporter.cpp
+++ b/OTRExporter/BackgroundExporter.cpp
@@ -11,11 +11,11 @@ void OTRExporter_Background::Save(ZResource* res, fs::path outPath, BinaryWriter
auto data = bg->parent->GetRawData();
- for (int i = bg->GetRawDataIndex(); i < bg->GetRawDataIndex() + bg->GetRawDataSize(); i++)
+ for (size_t i = bg->GetRawDataIndex(); i < bg->GetRawDataIndex() + bg->GetRawDataSize(); i++)
writer->Write(data[i]);
auto end = std::chrono::steady_clock::now();
- auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
+ size_t diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
- printf("Exported BG %s in %lims\n", bg->GetName().c_str(), diff);
+ printf("Exported BG %s in %zums\n", bg->GetName().c_str(), diff);
} \ No newline at end of file
diff --git a/OTRExporter/DisplayListExporter.cpp b/OTRExporter/DisplayListExporter.cpp
index 5deadfd..be0dded 100644
--- a/OTRExporter/DisplayListExporter.cpp
+++ b/OTRExporter/DisplayListExporter.cpp
@@ -251,7 +251,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
spdlog::error(StringHelper::Sprintf("dListDecl == nullptr! Addr = %08X", GETSEGOFFSET(data)));
}
- for (int i = 0; i < dList->otherDLists.size(); i++)
+ for (size_t i = 0; i < dList->otherDLists.size(); i++)
{
Declaration* dListDecl2 = dList->parent->GetDeclaration(GETSEGOFFSET(dList->otherDLists[i]->GetRawDataIndex()));
@@ -526,7 +526,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
auto lastItem = vertsKeys[0];
- for (int i = 1; i < vertsKeys.size(); i++)
+ for (size_t i = 1; i < vertsKeys.size(); i++)
{
auto curItem = vertsKeys[i];
@@ -650,9 +650,9 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
otrArchive->AddFile(fName, (uintptr_t)vtxStream->ToVector().data(), vtxWriter.GetBaseAddress());
auto end = std::chrono::steady_clock::now();
- auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
+ size_t diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
- printf("Exported VTX Array %s in %lims\n", fName.c_str(), diff);
+ printf("Exported VTX Array %s in %zums\n", fName.c_str(), diff);
}
}
}
@@ -679,9 +679,9 @@ void OTRExporter_DisplayList::Save(ZResource* res, fs::path outPath, BinaryWrite
}
auto dlEnd = std::chrono::steady_clock::now();
- auto dlDiff = std::chrono::duration_cast<std::chrono::milliseconds>(dlEnd - dlStart).count();
+ size_t dlDiff = std::chrono::duration_cast<std::chrono::milliseconds>(dlEnd - dlStart).count();
- printf("Display List Gen in %lims\n", dlDiff);
+ printf("Display List Gen in %zums\n", dlDiff);
}
std::string OTRExporter_DisplayList::GetPathToRes(ZResource* res, std::string varName)
diff --git a/OTRExporter/ExporterTest.a b/OTRExporter/ExporterTest.a
deleted file mode 100644
index b9ee13a..0000000
--- a/OTRExporter/ExporterTest.a
+++ /dev/null
Binary files differ
diff --git a/OTRExporter/Main.cpp b/OTRExporter/Main.cpp
index 23a2016..7f3e644 100644
--- a/OTRExporter/Main.cpp
+++ b/OTRExporter/Main.cpp
@@ -82,9 +82,9 @@ static void ExporterFileEnd(ZFile* file)
printf("ExporterFileEnd() called on ZFile %s.\n", file->GetName().c_str());
auto fileEnd = std::chrono::steady_clock::now();
- auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(fileEnd - fileStart).count();
+ size_t diff = std::chrono::duration_cast<std::chrono::milliseconds>(fileEnd - fileStart).count();
- printf("File Export Ended %s in %lims\n", file->GetName().c_str(), diff);
+ printf("File Export Ended %s in %zums\n", file->GetName().c_str(), diff);
//MemoryStream* strem = (MemoryStream*)fileWriter->GetStream().get();
//otrArchive->AddFile(file->GetName(), (uintptr_t)strem->ToVector().data(), strem->GetLength());
@@ -132,10 +132,10 @@ static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer)
}
auto end = std::chrono::steady_clock::now();
- auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
+ size_t diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
//if (diff > 10)
- printf("Exported Resource End %s in %lims\n", res->GetName().c_str(), diff);
+ printf("Exported Resource End %s in %zums\n", res->GetName().c_str(), diff);
}
static void ExporterXMLBegin()
@@ -180,8 +180,8 @@ static void ImportExporters()
exporterSet->exporters[ZResourceType::Limb] = new OTRExporter_SkeletonLimb();
exporterSet->exporters[ZResourceType::Animation] = new OTRExporter_Animation();
exporterSet->exporters[ZResourceType::Cutscene] = new OTRExporter_Cutscene();
- //exporterSet->exporters[ZResourceType::Vertex] = new OTRExporter_Vtx();
- //exporterSet->exporters[ZResourceType::Array] = new OTRExporter_Array();
+ exporterSet->exporters[ZResourceType::Vertex] = new OTRExporter_Vtx();
+ exporterSet->exporters[ZResourceType::Array] = new OTRExporter_Array();
Globals::AddExporter("OTR", exporterSet);
}
diff --git a/OTRExporter/Makefile b/OTRExporter/Makefile
index a17a4b0..1c4e61b 100644
--- a/OTRExporter/Makefile
+++ b/OTRExporter/Makefile
@@ -1,15 +1,55 @@
# Only used for standalone compilation, usually inherits these from the main makefile
-CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17
+
+CXX := g++
+AR := ar
+FORMAT := clang-format-11
+
+ASAN ?= 0
+DEBUG ?= 1
+OPTFLAGS ?= -O0
+LTO ?= 0
+
+WARN := -Wall -Wextra -Werror \
+ -Wno-unused-parameter \
+ -Wno-unused-function \
+ -Wno-unused-variable
+
+
+CXXFLAGS := $(WARN) -std=c++17
+CPPFLAGS := -MMD
+
+ifneq ($(DEBUG),0)
+ CXXFLAGS += -g
+endif
+
+ifneq ($(ASAN),0)
+ CXXFLAGS += -fsanitize=address
+endif
+
+ifneq ($(LTO),0)
+ CXXFLAGS += -flto
+endif
SRC_DIRS := $(shell find -type d -not -path "*build*")
-CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
+CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h))
-O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f)
-LIB := ExporterTest.a
+O_FILES := $(CXX_FILES:%.cpp=build/%.o)
+D_FILES := $(O_FILES:%.o=%.d)
+LIB := OTRExporter.a
+
+INC_DIRS := $(addprefix -I, \
+ ../../ZAPD/ZAPD \
+ ../../ZAPD/lib/tinyxml2 \
+ ../../ZAPD/lib/libgfxd \
+ ../../ZAPD/ZAPDUtils \
+ ../../OtrLib/otrlib \
+ ../../OtrLib/otrlib/Lib/spdlog/include \
+ ../../OtrLib/otrlib/Lib/Fast3D/U64 \
+)
# create build directories
-$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))
+$(shell mkdir -p $(SRC_DIRS:%=build/%))
all: $(LIB)
@@ -17,12 +57,14 @@ clean:
rm -rf build $(LIB)
format:
- clang-format-11 -i $(CPP_FILES) $(H_FILES)
+ $(FORMAT) -i $(CXX_FILES) $(H_FILES)
.PHONY: all clean format
build/%.o: %.cpp
- $(CXX) $(CXXFLAGS) $(OPTFLAGS) -I ./ -I ../../ZAPD/ZAPD -I ../../ZAPD/ZAPDUtils -I ../../ZAPD/lib/tinyxml2 -I ../../otrlib/otrlib -c $(OUTPUT_OPTION) $<
+ $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) -c $< -o $@
$(LIB): $(O_FILES)
$(AR) rcs $@ $^
+
+-include $(D_FILES) \ No newline at end of file
diff --git a/OTRExporter/OTRSkeletonExporter.cpp b/OTRExporter/OTRSkeletonExporter.cpp
index d2ad3d9..eaba5ab 100644
--- a/OTRExporter/OTRSkeletonExporter.cpp
+++ b/OTRExporter/OTRSkeletonExporter.cpp
@@ -16,7 +16,7 @@ void OTRExporter_Skeleton::Save(ZResource* res, fs::path outPath, BinaryWriter*
writer->Write((uint8_t)skel->limbsTable.limbType);
writer->Write((uint32_t)skel->limbsTable.count);
- for (int i = 0; i < skel->limbsTable.count; i++)
+ for (size_t i = 0; i < skel->limbsTable.count; i++)
{
Declaration* skelDecl = skel->parent->GetDeclarationRanged(GETSEGOFFSET(skel->limbsTable.limbsAddresses[i]));
diff --git a/OTRExporter/OTRSkeletonLimbExporter.cpp b/OTRExporter/OTRSkeletonLimbExporter.cpp
index f5b861c..1ff1839 100644
--- a/OTRExporter/OTRSkeletonLimbExporter.cpp
+++ b/OTRExporter/OTRSkeletonLimbExporter.cpp
@@ -19,7 +19,7 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, fs::path outPath, BinaryWrit
writer->Write(limb->rotZ);
// OTRTODO:
- if (limb->childPtr != NULL)
+ if (limb->childPtr != 0)
{
auto childDecl = limb->parent->GetDeclaration(GETSEGOFFSET(limb->childPtr));
@@ -33,7 +33,7 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, fs::path outPath, BinaryWrit
writer->Write("");
}
- if (limb->siblingPtr != NULL)
+ if (limb->siblingPtr != 0)
{
auto siblingDecl = limb->parent->GetDeclaration(GETSEGOFFSET(limb->siblingPtr));
@@ -47,7 +47,7 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, fs::path outPath, BinaryWrit
writer->Write("");
}
- if (limb->dListPtr != NULL)
+ if (limb->dListPtr != 0)
{
auto dlDecl = limb->parent->GetDeclaration(GETSEGOFFSET(limb->dListPtr));
@@ -61,7 +61,7 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, fs::path outPath, BinaryWrit
writer->Write("");
}
- if (limb->dList2Ptr != NULL)
+ if (limb->dList2Ptr != 0)
{
auto dlDecl = limb->parent->GetDeclaration(GETSEGOFFSET(limb->dList2Ptr));
diff --git a/OTRExporter/PlayerAnimationExporter.cpp b/OTRExporter/PlayerAnimationExporter.cpp
index dbfc580..934ebec 100644
--- a/OTRExporter/PlayerAnimationExporter.cpp
+++ b/OTRExporter/PlayerAnimationExporter.cpp
@@ -11,11 +11,11 @@ void OTRExporter_PlayerAnimationExporter::Save(ZResource* res, fs::path outPath,
writer->Write((uint32_t)anim->limbRotData.size());
- for (int i = 0; i < anim->limbRotData.size(); i++)
+ for (size_t i = 0; i < anim->limbRotData.size(); i++)
writer->Write(anim->limbRotData[i]);
auto end = std::chrono::steady_clock::now();
- auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
+ size_t diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
- printf("Exported Player Anim %s in %lims\n", anim->GetName().c_str(), diff);
+ printf("Exported Player Anim %s in %zums\n", anim->GetName().c_str(), diff);
}
diff --git a/OTRExporter/RoomExporter.cpp b/OTRExporter/RoomExporter.cpp
index 21cf429..07e448a 100644
--- a/OTRExporter/RoomExporter.cpp
+++ b/OTRExporter/RoomExporter.cpp
@@ -40,7 +40,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
writer->Write((uint32_t)room->commands.size());
- for (int i = 0; i < room->commands.size(); i++)
+ for (size_t i = 0; i < room->commands.size(); i++)
{
ZRoomCommand* cmd = room->commands[i];
@@ -135,7 +135,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
writer->Write((uint32_t)cmdCsCam->cameras.size());
- for (int i = 0; i < cmdCsCam->cameras.size(); i++)
+ for (size_t i = 0; i < cmdCsCam->cameras.size(); i++)
{
// OTRTODO: FINISH THIS...
writer->Write(cmdCsCam->cameras[i].baseOffset);
@@ -254,7 +254,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
writer->Write((uint32_t)cmdLight->lights.size());
- for (int i = 0; i < cmdLight->lights.size(); i++)
+ for (size_t i = 0; i < cmdLight->lights.size(); i++)
{
writer->Write(cmdLight->lights[i].type);
writer->Write(cmdLight->lights[i].x);
@@ -311,7 +311,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
writer->Write((uint32_t)cmdRoom->romfile->numRooms); // 0x01
- for (int i = 0;i < cmdRoom->romfile->numRooms; i++)
+ for (size_t i = 0;i < cmdRoom->romfile->numRooms; i++)
{
//std::string roomName = StringHelper::Sprintf("%s\\%s_room_%i", (StringHelper::Split(room->GetName(), "_")[0] + "_scene").c_str(), StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i);
std::string roomName = OTRExporter_DisplayList::GetPathToRes(room, StringHelper::Sprintf("%s_room_%i", StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i));
@@ -376,7 +376,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
writer->Write((uint32_t)cmdHeaders->headers.size());
- for (int i = 0; i < cmdHeaders->headers.size(); i++)
+ for (size_t i = 0; i < cmdHeaders->headers.size(); i++)
{
uint32_t seg = cmdHeaders->headers[i] & 0xFFFFFFFF;
std::string headerName = "";
@@ -404,7 +404,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
writer->Write((uint32_t)cmdExit->exits.size());
- for (int i = 0; i < cmdExit->exits.size(); i++)
+ for (size_t i = 0; i < cmdExit->exits.size(); i++)
writer->Write(cmdExit->exits[i]);
}
break;
@@ -414,7 +414,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path outPath, BinaryWriter
writer->Write((uint32_t)cmdSetObjectList->objects.size());
- for (int i = 0; i < cmdSetObjectList->objects.size(); i++)
+ for (size_t i = 0; i < cmdSetObjectList->objects.size(); i++)
writer->Write(cmdSetObjectList->objects[i]);
}
break;
@@ -448,6 +448,7 @@ void OTRExporter_Room::WritePolyDList(BinaryWriter* writer, ZRoom* room, Polygon
writer->Write(dlist->y);
writer->Write(dlist->z);
writer->Write(dlist->unk_06);
+ [[fallthrough]];
default:
//writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclOpa->varName.c_str()));
diff --git a/OTRExporter/TextureExporter.cpp b/OTRExporter/TextureExporter.cpp
index c693356..f946611 100644
--- a/OTRExporter/TextureExporter.cpp
+++ b/OTRExporter/TextureExporter.cpp
@@ -11,13 +11,13 @@ void OTRExporter_Texture::Save(ZResource* res, fs::path outPath, BinaryWriter* w
auto data = tex->parent->GetRawData();
- for (int i = tex->GetRawDataIndex(); i < tex->GetRawDataIndex() + tex->GetRawDataSize(); i++)
+ for (size_t i = tex->GetRawDataIndex(); i < tex->GetRawDataIndex() + tex->GetRawDataSize(); i++)
writer->Write(data[i]);
auto end = std::chrono::steady_clock::now();
- auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
+ size_t diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
- printf("Exported Texture %s in %lims\n", tex->GetName().c_str(), diff);
+ printf("Exported Texture %s in %zums\n", tex->GetName().c_str(), diff);
//if (diff > 2)
//printf("Export took %lms\n", diff);
diff --git a/OTRExporter/VtxExporter.cpp b/OTRExporter/VtxExporter.cpp
index 8e36a76..2907fe2 100644
--- a/OTRExporter/VtxExporter.cpp
+++ b/OTRExporter/VtxExporter.cpp
@@ -8,6 +8,7 @@ void OTRExporter_Vtx::SaveArr(const std::vector<ZResource*>& vec, BinaryWriter*
writer->Write((uint32_t)OtrLib::ResourceType::OTRVtx);
writer->Write((uint32_t)OtrLib::OTRVersion::Deckard);
writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id
+ writer->Write((uint32_t)vec.size());
for (auto& res: vec) {
ZVtx* vtx = (ZVtx*)res;
@@ -31,6 +32,8 @@ void OTRExporter_Vtx::Save(ZResource* res, fs::path outPath, BinaryWriter* write
WriteHeader(res, outPath, writer, OtrLib::ResourceType::OTRVtx);
+ writer->Write((uint32_t)1); //Yes I'm hard coding it to one, it *should* be fine.
+
writer->Write(vtx->x);
writer->Write(vtx->y);
writer->Write(vtx->z);
diff --git a/extract_assets.py b/extract_assets.py
index d47d867..6f33a52 100644..100755
--- a/extract_assets.py
+++ b/extract_assets.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-import argparse, json, os, signal, time
+import argparse, json, os, signal, time, sys
from multiprocessing import Pool, cpu_count, Event, Manager, ProcessError
EXTRACTED_ASSETS_NAMEFILE = ".extracted-assets.json"
@@ -16,11 +16,13 @@ def ExtractFile(xmlPath, outputPath, outputSourcePath):
# Don't extract if another file wasn't extracted properly.
# return
- execStr = "x64\\Release\\ZAPD.exe e -eh -i %s -b baserom/ -o %s -osf %s -gsf 1 -rconf CFG\\Config.xml -se OTR" % (xmlPath, outputPath, outputSourcePath)
-
+ execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out"
+
+ execStr += " e -eh -i %s -b baserom/ -o %s -osf %s -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath, outputPath, outputSourcePath)
+
if "overlays" in xmlPath:
execStr += " --static"
-
+
#if globalUnaccounted:
# execStr += " -wu"