|
|
@ -319,19 +319,19 @@ OTRGlobals::OTRGlobals() {
|
|
|
|
|
|
|
|
|
|
|
|
SPDLOG_INFO("Starting Ship of Harkinian version {}", (char*)gBuildVersion);
|
|
|
|
SPDLOG_INFO("Starting Ship of Harkinian version {}", (char*)gBuildVersion);
|
|
|
|
|
|
|
|
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Animation, "Animation", std::make_shared<LUS::AnimationFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_Animation), std::make_shared<LUS::AnimationFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_PlayerAnimation, "PlayerAnimation", std::make_shared<LUS::PlayerAnimationFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_PlayerAnimation), std::make_shared<LUS::PlayerAnimationFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Room, "Room", std::make_shared<LUS::SceneFactory>()); // Is room scene? maybe?
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_Room), std::make_shared<LUS::SceneFactory>()); // Is room scene? maybe?
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_CollisionHeader, "CollisionHeader", std::make_shared<LUS::CollisionHeaderFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_CollisionHeader), std::make_shared<LUS::CollisionHeaderFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Skeleton, "Skeleton", std::make_shared<LUS::SkeletonFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_Skeleton), std::make_shared<LUS::SkeletonFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_SkeletonLimb, "SkeletonLimb", std::make_shared<LUS::SkeletonLimbFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_SkeletonLimb), std::make_shared<LUS::SkeletonLimbFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Path, "Path", std::make_shared<LUS::PathFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_Path), std::make_shared<LUS::PathFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Cutscene, "Cutscene", std::make_shared<LUS::CutsceneFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_Cutscene), std::make_shared<LUS::CutsceneFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Text, "Text", std::make_shared<LUS::TextFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_Text), std::make_shared<LUS::TextFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_AudioSample, "AudioSample", std::make_shared<LUS::AudioSampleFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_AudioSample), std::make_shared<LUS::AudioSampleFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_AudioSoundFont, "AudioSoundFont", std::make_shared<LUS::AudioSoundFontFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_AudioSoundFont), std::make_shared<LUS::AudioSoundFontFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_AudioSequence, "AudioSequence", std::make_shared<LUS::AudioSequenceFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_AudioSequence), std::make_shared<LUS::AudioSequenceFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Background, "Background", std::make_shared<LUS::BackgroundFactory>());
|
|
|
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast<uint32_t>(LUS::ResourceType::SOH_Background), std::make_shared<LUS::BackgroundFactory>());
|
|
|
|
|
|
|
|
|
|
|
|
gSaveStateMgr = std::make_shared<SaveStateMgr>();
|
|
|
|
gSaveStateMgr = std::make_shared<SaveStateMgr>();
|
|
|
|
gRandomizer = std::make_shared<Randomizer>();
|
|
|
|
gRandomizer = std::make_shared<Randomizer>();
|
|
|
@ -354,7 +354,7 @@ OTRGlobals::OTRGlobals() {
|
|
|
|
cameraStrings[i] = dup;
|
|
|
|
cameraStrings[i] = dup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto versions = context->GetResourceManager()->GetArchive()->GetGameVersions();
|
|
|
|
auto versions = context->GetResourceManager()->GetArchiveManager()->GetGameVersions();
|
|
|
|
|
|
|
|
|
|
|
|
for (uint32_t version : versions) {
|
|
|
|
for (uint32_t version : versions) {
|
|
|
|
if (!ValidHashes.contains(version)) {
|
|
|
|
if (!ValidHashes.contains(version)) {
|
|
|
@ -836,7 +836,7 @@ extern "C" RandomizerGet RetrieveRandomizerGetFromItemID(ItemID itemID) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" void OTRExtScanner() {
|
|
|
|
extern "C" void OTRExtScanner() {
|
|
|
|
auto lst = *LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->ListFiles("*").get();
|
|
|
|
auto lst = *LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles().get();
|
|
|
|
|
|
|
|
|
|
|
|
for (auto& rPath : lst) {
|
|
|
|
for (auto& rPath : lst) {
|
|
|
|
std::vector<std::string> raw = StringHelper::Split(rPath, ".");
|
|
|
|
std::vector<std::string> raw = StringHelper::Split(rPath, ".");
|
|
|
@ -859,11 +859,11 @@ OTRVersion ReadPortVersionFromOTR(std::string otrPath) {
|
|
|
|
OTRVersion version = {};
|
|
|
|
OTRVersion version = {};
|
|
|
|
|
|
|
|
|
|
|
|
// Use a temporary archive instance to load the otr and read the version file
|
|
|
|
// Use a temporary archive instance to load the otr and read the version file
|
|
|
|
auto archive = std::make_shared<LUS::Archive>(otrPath, "", std::unordered_set<uint32_t>(), false);
|
|
|
|
auto archive = LUS::OtrArchive(otrPath);
|
|
|
|
if (archive->IsMainMPQValid()) {
|
|
|
|
if (archive.LoadRaw()) {
|
|
|
|
auto t = archive->LoadFile("portVersion", false);
|
|
|
|
auto t = archive.LoadFileRaw("portVersion");
|
|
|
|
if (t != nullptr && t->IsLoaded) {
|
|
|
|
if (t != nullptr && t->IsLoaded) {
|
|
|
|
auto stream = std::make_shared<LUS::MemoryStream>(t->Buffer.data(), t->Buffer.size());
|
|
|
|
auto stream = std::make_shared<LUS::MemoryStream>(t->Buffer->data(), t->Buffer->size());
|
|
|
|
auto reader = std::make_shared<LUS::BinaryReader>(stream);
|
|
|
|
auto reader = std::make_shared<LUS::BinaryReader>(stream);
|
|
|
|
LUS::Endianness endianness = (LUS::Endianness)reader->ReadUByte();
|
|
|
|
LUS::Endianness endianness = (LUS::Endianness)reader->ReadUByte();
|
|
|
|
reader->SetEndianness(endianness);
|
|
|
|
reader->SetEndianness(endianness);
|
|
|
@ -871,10 +871,9 @@ OTRVersion ReadPortVersionFromOTR(std::string otrPath) {
|
|
|
|
version.minor = reader->ReadUInt16();
|
|
|
|
version.minor = reader->ReadUInt16();
|
|
|
|
version.patch = reader->ReadUInt16();
|
|
|
|
version.patch = reader->ReadUInt16();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
archive.UnloadRaw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
archive = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return version;
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1412,15 +1411,15 @@ extern "C" uint16_t OTRGetPixelDepth(float x, float y) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" uint32_t ResourceMgr_GetNumGameVersions() {
|
|
|
|
extern "C" uint32_t ResourceMgr_GetNumGameVersions() {
|
|
|
|
return LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions().size();
|
|
|
|
return LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions().size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" uint32_t ResourceMgr_GetGameVersion(int index) {
|
|
|
|
extern "C" uint32_t ResourceMgr_GetGameVersion(int index) {
|
|
|
|
return LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index];
|
|
|
|
return LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
|
|
|
|
extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
|
|
|
|
uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index];
|
|
|
|
uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
|
|
|
|
|
|
|
|
|
|
|
|
switch (version) {
|
|
|
|
switch (version) {
|
|
|
|
case OOT_NTSC_US_10:
|
|
|
|
case OOT_NTSC_US_10:
|
|
|
@ -1443,7 +1442,7 @@ extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" uint32_t ResourceMgr_GetGameRegion(int index) {
|
|
|
|
extern "C" uint32_t ResourceMgr_GetGameRegion(int index) {
|
|
|
|
uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index];
|
|
|
|
uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
|
|
|
|
|
|
|
|
|
|
|
|
switch (version) {
|
|
|
|
switch (version) {
|
|
|
|
case OOT_NTSC_US_10:
|
|
|
|
case OOT_NTSC_US_10:
|
|
|
@ -1529,7 +1528,7 @@ extern "C" void ResourceMgr_UnloadResource(const char* resName) {
|
|
|
|
// OTRTODO: There is probably a more elegant way to go about this...
|
|
|
|
// OTRTODO: There is probably a more elegant way to go about this...
|
|
|
|
// Kenix: This is definitely leaking memory when it's called.
|
|
|
|
// Kenix: This is definitely leaking memory when it's called.
|
|
|
|
extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) {
|
|
|
|
extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) {
|
|
|
|
auto lst = LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->ListFiles(searchMask);
|
|
|
|
auto lst = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(searchMask);
|
|
|
|
char** result = (char**)malloc(lst->size() * sizeof(char*));
|
|
|
|
char** result = (char**)malloc(lst->size() * sizeof(char*));
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < lst->size(); i++) {
|
|
|
|
for (size_t i = 0; i < lst->size(); i++) {
|
|
|
@ -1619,7 +1618,7 @@ extern "C" uint8_t ResourceMgr_TexIsRaw(const char* texPath) {
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" uint8_t ResourceMgr_ResourceIsBackground(char* texPath) {
|
|
|
|
extern "C" uint8_t ResourceMgr_ResourceIsBackground(char* texPath) {
|
|
|
|
auto res = GetResourceByNameHandlingMQ(texPath);
|
|
|
|
auto res = GetResourceByNameHandlingMQ(texPath);
|
|
|
|
return res->GetInitData()->Type == LUS::ResourceType::SOH_Background;
|
|
|
|
return res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::SOH_Background);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" char* ResourceMgr_LoadJPEG(char* data, size_t dataSize)
|
|
|
|
extern "C" char* ResourceMgr_LoadJPEG(char* data, size_t dataSize)
|
|
|
@ -1667,9 +1666,9 @@ extern "C" uint16_t ResourceMgr_LoadTexHeightByName(char* texPath);
|
|
|
|
extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) {
|
|
|
|
extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) {
|
|
|
|
auto res = GetResourceByNameHandlingMQ(filePath);
|
|
|
|
auto res = GetResourceByNameHandlingMQ(filePath);
|
|
|
|
|
|
|
|
|
|
|
|
if (res->GetInitData()->Type == LUS::ResourceType::DisplayList)
|
|
|
|
if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::DisplayList))
|
|
|
|
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
|
|
|
|
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
|
|
|
|
else if (res->GetInitData()->Type == LUS::ResourceType::Array)
|
|
|
|
else if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::Array))
|
|
|
|
return (char*)(std::static_pointer_cast<LUS::Array>(res))->Vertices.data();
|
|
|
|
return (char*)(std::static_pointer_cast<LUS::Array>(res))->Vertices.data();
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
return (char*)GetResourceDataByNameHandlingMQ(filePath);
|
|
|
|
return (char*)GetResourceDataByNameHandlingMQ(filePath);
|
|
|
@ -1679,7 +1678,7 @@ extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) {
|
|
|
|
extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) {
|
|
|
|
extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) {
|
|
|
|
auto res = GetResourceByNameHandlingMQ(filePath);
|
|
|
|
auto res = GetResourceByNameHandlingMQ(filePath);
|
|
|
|
|
|
|
|
|
|
|
|
if (res->GetInitData()->Type == LUS::ResourceType::DisplayList)
|
|
|
|
if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::DisplayList))
|
|
|
|
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
|
|
|
|
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
|
|
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
return nullptr;
|
|
|
|