From 5bee3361b758568168a6b5b8c504f516ccded6dc Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 26 May 2016 19:44:41 -1000 Subject: [PATCH] Fix in Rogue Squadron 3 detection --- driver/main.cpp | 115 -------------------------------------- lib/ContainerRegistry.cpp | 14 +---- 2 files changed, 2 insertions(+), 127 deletions(-) diff --git a/driver/main.cpp b/driver/main.cpp index c0356bb..7899986 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -30,121 +30,6 @@ static inline void SNPrintf(boo::SystemChar* str, size_t maxlen, const boo::Syst va_end(va); } -#if 0 -static amuse::IntrusiveAudioGroupData LoadFromArgs(int argc, const boo::SystemChar** argv, - std::string& descOut, bool& good) -{ - if (argc > 1) - { - /* First attempt single-file case */ - std::experimental::optional r; - r.emplace(argv[1], 32 * 1024, false); - if (!r->hasError()) - { - char testBuf[6]; - if (r->readBytesToBuf(testBuf, 6) == 6) - { - if (!memcmp(testBuf, "Audio/", 6)) - { - /* Metroid Prime 1 container */ - r->seek(0, athena::SeekOrigin::Begin); - r->readString(); - descOut = "Metroid Prime (" + r->readString() + ")"; - - std::unique_ptr pool = r->readUBytes(r->readUint32Big()); - std::unique_ptr proj = r->readUBytes(r->readUint32Big()); - std::unique_ptr samp = r->readUBytes(r->readUint32Big()); - std::unique_ptr sdir = r->readUBytes(r->readUint32Big()); - - good = true; - return {proj.release(), pool.release(), sdir.release(), samp.release()}; - } - else if (amuse::SBig(*reinterpret_cast(testBuf)) == 0x1) - { - /* Metroid Prime 2 container */ - r->seek(0, athena::SeekOrigin::Begin); - r->readUint32Big(); - descOut = "Metroid Prime 2 (" + r->readString() + ")"; - - r->readUint16Big(); - uint32_t poolSz = r->readUint32Big(); - uint32_t projSz = r->readUint32Big(); - uint32_t sdirSz = r->readUint32Big(); - uint32_t sampSz = r->readUint32Big(); - - std::unique_ptr pool = r->readUBytes(poolSz); - std::unique_ptr proj = r->readUBytes(projSz); - std::unique_ptr sdir = r->readUBytes(sdirSz); - std::unique_ptr samp = r->readUBytes(sampSz); - - good = true; - return {proj.release(), pool.release(), sdir.release(), samp.release()}; - } - } - } - else - { - /* Now attempt multi-file case */ - boo::SystemChar path[1024]; - - /* Project */ - SNPrintf(path, 1024, _S("%s.pro"), argv[1]); - r.emplace(path, 32 * 1024, false); - if (r->hasError()) - { - SNPrintf(path, 1024, _S("%s.proj"), argv[1]); - r.emplace(path, 32 * 1024, false); - if (r->hasError()) - return {nullptr, nullptr, nullptr, nullptr}; - } - std::unique_ptr proj = r->readUBytes(r->length()); - - /* Pool */ - SNPrintf(path, 1024, _S("%s.poo"), argv[1]); - r.emplace(path, 32 * 1024, false); - if (r->hasError()) - { - SNPrintf(path, 1024, _S("%s.pool"), argv[1]); - r.emplace(path, 32 * 1024, false); - if (r->hasError()) - return {nullptr, nullptr, nullptr, nullptr}; - } - std::unique_ptr pool = r->readUBytes(r->length()); - - /* Sdir */ - SNPrintf(path, 1024, _S("%s.sdi"), argv[1]); - r.emplace(path, 32 * 1024, false); - if (r->hasError()) - { - SNPrintf(path, 1024, _S("%s.sdir"), argv[1]); - r.emplace(path, 32 * 1024, false); - if (r->hasError()) - return {nullptr, nullptr, nullptr, nullptr}; - } - std::unique_ptr sdir = r->readUBytes(r->length()); - - /* Samp */ - SNPrintf(path, 1024, _S("%s.sam"), argv[1]); - r.emplace(path, 32 * 1024, false); - if (r->hasError()) - { - SNPrintf(path, 1024, _S("%s.samp"), argv[1]); - r.emplace(path, 32 * 1024, false); - if (r->hasError()) - return {nullptr, nullptr, nullptr, nullptr}; - } - std::unique_ptr samp = r->readUBytes(r->length()); - - descOut = "4 RAW Chunk Files"; - good = true; - return {proj.release(), pool.release(), sdir.release(), samp.release()}; - } - } - - return {nullptr, nullptr, nullptr, nullptr}; -} -#endif - struct AppCallback; struct EventCallback : boo::IWindowCallback diff --git a/lib/ContainerRegistry.cpp b/lib/ContainerRegistry.cpp index 25d8145..ad66590 100644 --- a/lib/ContainerRegistry.cpp +++ b/lib/ContainerRegistry.cpp @@ -481,36 +481,24 @@ static std::vector> LoadRS1PC(FI proj.reset(new uint8_t[entry.decompSz]); FSeek(fp, entry.offset, SEEK_SET); fread(proj.get(), 1, entry.decompSz, fp); - FILE* wfp = fopen("/Users/jacko/Desktop/RS.proj", "wb"); - fwrite(proj.get(), 1, entry.decompSz, wfp); - fclose(wfp); } else if (!strncmp("pool_SND", entry.name, 16)) { pool.reset(new uint8_t[entry.decompSz]); FSeek(fp, entry.offset, SEEK_SET); fread(pool.get(), 1, entry.decompSz, fp); - FILE* wfp = fopen("/Users/jacko/Desktop/RS.pool", "wb"); - fwrite(pool.get(), 1, entry.decompSz, wfp); - fclose(wfp); } else if (!strncmp("sdir_SND", entry.name, 16)) { sdir.reset(new uint8_t[entry.decompSz]); FSeek(fp, entry.offset, SEEK_SET); fread(sdir.get(), 1, entry.decompSz, fp); - FILE* wfp = fopen("/Users/jacko/Desktop/RS.sdir", "wb"); - fwrite(sdir.get(), 1, entry.decompSz, wfp); - fclose(wfp); } else if (!strncmp("samp_SND", entry.name, 16)) { samp.reset(new uint8_t[entry.decompSz]); FSeek(fp, entry.offset, SEEK_SET); fread(samp.get(), 1, entry.decompSz, fp); - FILE* wfp = fopen("/Users/jacko/Desktop/RS.samp", "wb"); - fwrite(samp.get(), 1, entry.decompSz, wfp); - fclose(wfp); } } @@ -724,6 +712,8 @@ static bool ValidateRS2(FILE* fp) RS2FSTEntry entry; fread(&entry, 1, 64, fp); entry.swapBig(); + if (!entry.offset) + return false; /* This is to reject RS3 data */ if (!strncmp("data", entry.name, 32)) return true; }