Skip to content

Commit

Permalink
Bump LUS version (HarbourMasters#2849)
Browse files Browse the repository at this point in the history
* Bump LUS version

* Removes the "now" boolean from the LUS resource bridge functions.

* Bump LUS

* More LUS bump

* Update soh/soh/resource/importer/AudioSampleFactory.cpp

---------

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
  • Loading branch information
Kenix3 and briaguya-ai authored May 8, 2023
1 parent f31a841 commit 91bd693
Show file tree
Hide file tree
Showing 59 changed files with 233 additions and 218 deletions.
10 changes: 5 additions & 5 deletions OTRExporter/OTRExporter/AudioExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "Main.h"
#include <Utils/MemoryStream.h>
#include <Globals.h>
#include <Utils/File.h>
#include <Utils/DiskFile.h>
#include "DisplayListExporter.h"

void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* entry, std::map<uint32_t, SampleEntry*> samples, BinaryWriter* writer)
Expand All @@ -29,7 +29,7 @@ void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* en

void OTRExporter_Audio::WriteSampleEntry(SampleEntry* entry, BinaryWriter* writer)
{
WriteHeader(nullptr, "", writer, Ship::ResourceType::SOH_AudioSample, Ship::Version::Rachael);
WriteHeader(nullptr, "", writer, Ship::ResourceType::SOH_AudioSample, 2);

writer->Write(entry->codec);
writer->Write(entry->medium);
Expand Down Expand Up @@ -81,7 +81,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
{
ZAudio* audio = (ZAudio*)res;

WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Audio, Ship::Version::Rachael);
WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Audio, 2);

// Write Samples as individual files
for (auto pair : audio->samples)
Expand Down Expand Up @@ -114,7 +114,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
MemoryStream* fntStream = new MemoryStream();
BinaryWriter fntWriter = BinaryWriter(fntStream);

WriteHeader(nullptr, "", &fntWriter, Ship::ResourceType::SOH_AudioSoundFont, Ship::Version::Rachael);
WriteHeader(nullptr, "", &fntWriter, Ship::ResourceType::SOH_AudioSoundFont, 2);

fntWriter.Write((uint32_t)i);
fntWriter.Write(audio->soundFontTable[i].medium);
Expand Down Expand Up @@ -173,7 +173,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
MemoryStream* seqStream = new MemoryStream();
BinaryWriter seqWriter = BinaryWriter(seqStream);

WriteHeader(nullptr, "", &seqWriter, Ship::ResourceType::SOH_AudioSequence, Ship::Version::Rachael);
WriteHeader(nullptr, "", &seqWriter, Ship::ResourceType::SOH_AudioSequence, 2);

seqWriter.Write((uint32_t)seq.size());
seqWriter.Write(seq.data(), seq.size());
Expand Down
8 changes: 4 additions & 4 deletions OTRExporter/OTRExporter/DisplayListExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <iostream>
#include <string>
#include "MtxExporter.h"
#include <Utils/File.h>
#include <Utils/DiskFile.h>
#include "VersionInfo.h"

#define GFX_SIZE 8
Expand Down Expand Up @@ -356,7 +356,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
//std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str());
std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str());

if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName))
if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName))
{
MemoryStream* dlStream = new MemoryStream();
BinaryWriter dlWriter = BinaryWriter(dlStream);
Expand Down Expand Up @@ -442,7 +442,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
//std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str());
std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str());

if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName))
if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName))
{
MemoryStream* dlStream = new MemoryStream();
BinaryWriter dlWriter = BinaryWriter(dlStream);
Expand Down Expand Up @@ -767,7 +767,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
word0 = hash >> 32;
word1 = hash & 0xFFFFFFFF;

if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName))
if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName))
{
// Write vertices to file
MemoryStream* vtxStream = new MemoryStream();
Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/OTRExporter/Exporter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Exporter.h"
#include "VersionInfo.h"

void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, Ship::Version resVersion)
void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, int32_t resVersion)
{
writer->Write((uint8_t)Endianness::Little); // 0x00
writer->Write((uint8_t)0); // 0x01
Expand Down
3 changes: 2 additions & 1 deletion OTRExporter/OTRExporter/Exporter.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include "ZResource.h"
#include "ZArray.h"
#include "stdint.h"
//#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
#include <libultraship/bridge.h>
Expand All @@ -9,5 +10,5 @@
class OTRExporter : public ZResourceExporter
{
protected:
static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, Ship::Version resVersion = MAJOR_VERSION);
static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, int32_t resVersion = 0);
};
18 changes: 9 additions & 9 deletions OTRExporter/OTRExporter/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "MtxExporter.h"
#include "AudioExporter.h"
#include <Globals.h>
#include <Utils/File.h>
#include <Utils/DiskFile.h>
#include <Utils/Directory.h>
#include <Utils/MemoryStream.h>
#include <Utils/BinaryWriter.h>
Expand Down Expand Up @@ -47,7 +47,7 @@ static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileM

printf("BOTR: Generating OTR Archive...\n");

if (File::Exists(otrFileName))
if (DiskFile::Exists(otrFileName))
otrArchive = std::shared_ptr<Ship::Archive>(new Ship::Archive(otrFileName, true));
else
otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000);
Expand All @@ -56,7 +56,7 @@ static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileM

for (auto item : lst)
{
auto fileData = File::ReadAllBytes(item);
auto fileData = DiskFile::ReadAllBytes(item);
otrArchive->AddFile(StringHelper::Split(item, "Extract/")[1], (uintptr_t)fileData.data(), fileData.size());
}
}
Expand All @@ -70,7 +70,7 @@ static void ExporterProgramEnd()
if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory)
{
std::string romPath = Globals::Instance->baseRomPath.string();
const std::vector<uint8_t>& romData = File::ReadAllBytes(romPath);
const std::vector<uint8_t>& romData = DiskFile::ReadAllBytes(romPath);
crc = BitConverter::ToUInt32BE(romData, 0x10);
printf("Creating version file...\n");

Expand Down Expand Up @@ -111,7 +111,7 @@ static void ExporterProgramEnd()
files.clear();

// Add any additional files that need to be manually copied...
if (File::Exists("soh.otr")) {
if (DiskFile::Exists("soh.otr")) {
return;
}
const auto& lst = Directory::ListFiles("Extract");
Expand Down Expand Up @@ -158,14 +158,14 @@ static void ExporterProgramEnd()
splitPath.pop_back();
if (extension == "json")
{
const auto &fileData = File::ReadAllBytes(item);
const auto &fileData = DiskFile::ReadAllBytes(item);
printf("Adding accessibility texts %s\n", StringHelper::Split(item, "texts/")[1].c_str());
sohOtr->AddFile(StringHelper::Split(item, "Extract/assets/")[1], (uintptr_t)fileData.data(), fileData.size());
}
continue;
}

const auto& fileData = File::ReadAllBytes(item);
const auto& fileData = DiskFile::ReadAllBytes(item);
printf("sohOtr->AddFile(%s)\n", StringHelper::Split(item, "Extract/")[1].c_str());
sohOtr->AddFile(StringHelper::Split(item, item.find("Extract/assets/") != std::string::npos ? "Extract/assets/" : "Extract/")[1], (uintptr_t)fileData.data(), fileData.size());
}
Expand Down Expand Up @@ -249,7 +249,7 @@ static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer)
files[fName] = strem->ToVector();
}
else
File::WriteAllBytes("Extract/" + fName, strem->ToVector());
DiskFile::WriteAllBytes("Extract/" + fName, strem->ToVector());
}

auto end = std::chrono::steady_clock::now();
Expand All @@ -275,7 +275,7 @@ static void ExporterXMLEnd()
void AddFile(std::string fName, std::vector<char> data)
{
if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory)
File::WriteAllBytes("Extract/" + fName, data);
DiskFile::WriteAllBytes("Extract/" + fName, data);
else
{
std::unique_lock Lock(fileMutex);
Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/OTRExporter/RoomExporter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "RoomExporter.h"
#include "Utils/BinaryWriter.h"
#include "Utils/MemoryStream.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include <ZRoom/Commands/SetMesh.h>
#include <ZRoom/Commands/SetWind.h>
#include <ZRoom/Commands/SetTimeSettings.h>
Expand Down
2 changes: 0 additions & 2 deletions OTRExporter/OTRExporter/VersionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@
#include <vector>
#include "src/resource/Resource.h"

#define MAJOR_VERSION Ship::Version::Deckard

extern std::map<Ship::ResourceType, uint32_t> resourceVersions;
4 changes: 2 additions & 2 deletions ZAPDTR/ExporterTest/RoomExporter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "RoomExporter.h"
#include "CollisionExporter.h"
#include "Utils/BinaryWriter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/MemoryStream.h"
#include "ZRoom/Commands/SetCameraSettings.h"
#include "ZRoom/Commands/SetCollisionHeader.h"
Expand Down Expand Up @@ -367,6 +367,6 @@ void ExporterExample_Room::Save(ZResource* res, const fs::path& outPath, BinaryW
}

// writer->Close();
// File::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()),
// DiskFile::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()),
// memStream->ToVector());
}
8 changes: 4 additions & 4 deletions ZAPDTR/ZAPD/GameConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <unordered_map>

#include "Utils/Directory.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "ZFile.h"
#include "tinyxml2.h"
Expand Down Expand Up @@ -57,7 +57,7 @@ void GameConfig::ReadTexturePool(const fs::path& texturePoolXmlPath)

void GameConfig::GenSymbolMap(const fs::path& symbolMapPath)
{
auto symbolLines = File::ReadAllLines(symbolMapPath);
auto symbolLines = DiskFile::ReadAllLines(symbolMapPath);

for (std::string& symbolLine : symbolLines)
{
Expand All @@ -79,7 +79,7 @@ void GameConfig::ConfigFunc_ActorList(const tinyxml2::XMLElement& element)
{
std::string fileName = element.Attribute("File");
std::vector<std::string> lines =
File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);
DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);

for (auto& line : lines)
actorList.emplace_back(std::move(line));
Expand All @@ -89,7 +89,7 @@ void GameConfig::ConfigFunc_ObjectList(const tinyxml2::XMLElement& element)
{
std::string fileName = element.Attribute("File");
std::vector<std::string> lines =
File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);
DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);

for (auto& line : lines)
objectList.emplace_back(std::move(line));
Expand Down
10 changes: 5 additions & 5 deletions ZAPDTR/ZAPD/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <algorithm>
#include <string_view>

#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "WarningHandler.h"
#include "tinyxml2.h"
Expand Down Expand Up @@ -134,12 +134,12 @@ void Globals::BuildAssetTexture(const fs::path& pngFilePath, TextureType texType
tex.FromPNG(pngFilePath.string(), texType);
std::string cfgPath = StringHelper::Split(pngFilePath.string(), ".")[0] + ".cfg";

if (File::Exists(cfgPath))
name = File::ReadAllText(cfgPath);
if (DiskFile::Exists(cfgPath))
name = DiskFile::ReadAllText(cfgPath);

std::string src = tex.GetBodySourceCode();

File::WriteAllBytes(outPath.string(), src.c_str(), src.size());
DiskFile::WriteAllBytes(outPath.string(), src.c_str(), src.size());
}

std::map<std::string, ExporterSet*>& Globals::GetExporterMap()
Expand Down Expand Up @@ -186,7 +186,7 @@ std::vector<uint8_t> Globals::GetBaseromFile(std::string fileName)

}
else
return File::ReadAllBytes(fileName);
return DiskFile::ReadAllBytes(fileName);
}

bool Globals::GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile,
Expand Down
6 changes: 3 additions & 3 deletions ZAPDTR/ZAPD/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Globals.h"
#include "Utils/Directory.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "WarningHandler.h"

Expand Down Expand Up @@ -578,7 +578,7 @@ void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath
ZBackground background(nullptr);
background.ParseBinaryFile(imageFilePath.string(), false);

File::WriteAllText(outPath.string(), background.GetBodySourceCode());
DiskFile::WriteAllText(outPath.string(), background.GetBodySourceCode());
}

void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath)
Expand All @@ -588,7 +588,7 @@ void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath)

std::string src = blob->GetBodySourceCode();

File::WriteAllText(outPath.string(), src);
DiskFile::WriteAllText(outPath.string(), src);

delete blob;
}
4 changes: 2 additions & 2 deletions ZAPDTR/ZAPD/Overlays/ZOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <unordered_set>
#include "Globals.h"
#include "Utils/Directory.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "WarningHandler.h"
Expand Down Expand Up @@ -76,7 +76,7 @@ static const std::unordered_set<std::string> sSections = {

ZOverlay* ZOverlay::FromBuild(fs::path buildPath, fs::path cfgFolderPath)
{
std::string cfgText = File::ReadAllText(cfgFolderPath / "overlay.cfg");
std::string cfgText = DiskFile::ReadAllText(cfgFolderPath / "overlay.cfg");
std::vector<std::string> cfgLines = StringHelper::Split(cfgText, "\n");

ZOverlay* ovl = new ZOverlay(StringHelper::Strip(cfgLines[0], "\r"));
Expand Down
2 changes: 1 addition & 1 deletion ZAPDTR/ZAPD/ZAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/StringHelper.h"
#include "WarningHandler.h"
#include "ZFile.h"
Expand Down
2 changes: 1 addition & 1 deletion ZAPDTR/ZAPD/ZAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
Expand Down
6 changes: 3 additions & 3 deletions ZAPDTR/ZAPD/ZBackground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
#include <Utils/DiskFile.h>
#include "Utils/Path.h"
#include "Utils/StringHelper.h"
#include "WarningHandler.h"
Expand Down Expand Up @@ -46,7 +46,7 @@ void ZBackground::ParseBinaryFile(const std::string& inFolder, bool appendOutNam
if (appendOutName)
filepath = filepath / (outName + "." + GetExternalExtension());

data = File::ReadAllBytes(filepath.string());
data = DiskFile::ReadAllBytes(filepath.string());

// Add padding.
data.insert(data.end(), GetRawDataSize() - data.size(), 0x00);
Expand Down Expand Up @@ -153,7 +153,7 @@ void ZBackground::Save(const fs::path& outFolder)
if (!Globals::Instance->otrMode)
{
fs::path filepath = outFolder / (outName + "." + GetExternalExtension());
File::WriteAllBytes(filepath.string(), data);
DiskFile::WriteAllBytes(filepath.string(), data);
}
}

Expand Down
Loading

0 comments on commit 91bd693

Please sign in to comment.