mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 13:23:45 -07:00
Re-enables OTR patches from mods folder (#1785)
* Re-enables OTR patches from mods folder. * Don't error if an OTR doesn't include a version file Just info log and continue. If the patch fails to apply then we can error, and SoH can do it's own validation later. * Fixes small error on my side
This commit is contained in:
parent
e96df1649f
commit
f300c02b63
4 changed files with 32 additions and 5 deletions
|
@ -448,12 +448,12 @@ namespace Ship {
|
||||||
}
|
}
|
||||||
for (int j = i; j < OTRFiles.size(); j++) {
|
for (int j = i; j < OTRFiles.size(); j++) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::wstring wfullPath = std::filesystem::absolute(OTRFiles[i]).wstring();
|
std::wstring wfullPath = std::filesystem::absolute(OTRFiles[j]).wstring();
|
||||||
#endif
|
#endif
|
||||||
#if defined(__SWITCH__)
|
#if defined(__SWITCH__)
|
||||||
std::string fullPath = OTRFiles[i];
|
std::string fullPath = OTRFiles[i];
|
||||||
#else
|
#else
|
||||||
std::string fullPath = std::filesystem::absolute(OTRFiles[i]).string();
|
std::string fullPath = std::filesystem::absolute(OTRFiles[j]).string();
|
||||||
#endif
|
#endif
|
||||||
if (LoadPatchMPQ(fullPath, true))
|
if (LoadPatchMPQ(fullPath, true))
|
||||||
{
|
{
|
||||||
|
@ -493,8 +493,7 @@ namespace Ship {
|
||||||
// i.e. Ocarina of Time along with Master Quest.
|
// i.e. Ocarina of Time along with Master Quest.
|
||||||
if (validateVersion) {
|
if (validateVersion) {
|
||||||
if (!PushGameVersion(patchHandle)) {
|
if (!PushGameVersion(patchHandle)) {
|
||||||
SPDLOG_WARN("({}) Invalid MQP file.", path.c_str());
|
SPDLOG_INFO("({}) Missing version file. Attempting to apply patch anyway.", path.c_str());
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,10 @@ void ThrowMissingOTR(const char* otrPath) {
|
||||||
OSFatal("Main OTR file not found!");
|
OSFatal("Main OTR file not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThrowInvalidOTR() {
|
||||||
|
OSFatal("Invalid OTR files! Try regenerating them!");
|
||||||
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
bool rescan = false;
|
bool rescan = false;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ void Exit();
|
||||||
|
|
||||||
void ThrowMissingOTR(const char* otrPath);
|
void ThrowMissingOTR(const char* otrPath);
|
||||||
|
|
||||||
|
void ThrowInvalidOTR();
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
VPADStatus *GetVPADStatus(VPADReadError *error);
|
VPADStatus *GetVPADStatus(VPADReadError *error);
|
||||||
|
|
|
@ -86,6 +86,16 @@ OTRGlobals::OTRGlobals() {
|
||||||
if (std::filesystem::exists(ootPath)) {
|
if (std::filesystem::exists(ootPath)) {
|
||||||
OTRFiles.push_back(ootPath);
|
OTRFiles.push_back(ootPath);
|
||||||
}
|
}
|
||||||
|
std::string patchesPath = Ship::Window::GetPathRelativeToAppDirectory("mods");
|
||||||
|
if (patchesPath.length() > 0 && std::filesystem::exists(patchesPath)) {
|
||||||
|
if (std::filesystem::is_directory(patchesPath)) {
|
||||||
|
for (const auto& p : std::filesystem::recursive_directory_iterator(patchesPath)) {
|
||||||
|
if (StringHelper::IEquals(p.path().extension().string(), ".otr")) {
|
||||||
|
OTRFiles.push_back(p.path().generic_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
std::unordered_set<uint32_t> ValidHashes = {
|
std::unordered_set<uint32_t> ValidHashes = {
|
||||||
OOT_PAL_MQ,
|
OOT_PAL_MQ,
|
||||||
OOT_NTSC_JP_MQ,
|
OOT_NTSC_JP_MQ,
|
||||||
|
@ -103,7 +113,7 @@ OTRGlobals::OTRGlobals() {
|
||||||
OOT_PAL_GC_DBG1,
|
OOT_PAL_GC_DBG1,
|
||||||
OOT_PAL_GC_DBG2
|
OOT_PAL_GC_DBG2
|
||||||
};
|
};
|
||||||
context = Ship::Window::CreateInstance("Ship of Harkinian", OTRFiles, ValidHashes);
|
context = Ship::Window::CreateInstance("Ship of Harkinian", OTRFiles);
|
||||||
gSaveStateMgr = std::make_shared<SaveStateMgr>();
|
gSaveStateMgr = std::make_shared<SaveStateMgr>();
|
||||||
gRandomizer = std::make_shared<Randomizer>();
|
gRandomizer = std::make_shared<Randomizer>();
|
||||||
|
|
||||||
|
@ -112,6 +122,18 @@ OTRGlobals::OTRGlobals() {
|
||||||
auto versions = context->GetResourceManager()->GetGameVersions();
|
auto versions = context->GetResourceManager()->GetGameVersions();
|
||||||
|
|
||||||
for (uint32_t version : versions) {
|
for (uint32_t version : versions) {
|
||||||
|
if (!ValidHashes.contains(version)) {
|
||||||
|
#if defined(__SWITCH__)
|
||||||
|
printf("Invalid OTR File!\n");
|
||||||
|
#elif defined(__WIIU__)
|
||||||
|
Ship::WiiU::ThrowInvalidOTR();
|
||||||
|
#else
|
||||||
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Invalid OTR File",
|
||||||
|
"Attempted to load an invalid OTR file. Try regenerating.", nullptr);
|
||||||
|
SPDLOG_ERROR("Invalid OTR File!");
|
||||||
|
#endif
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case OOT_PAL_MQ:
|
case OOT_PAL_MQ:
|
||||||
case OOT_NTSC_JP_MQ:
|
case OOT_NTSC_JP_MQ:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue