CSkinRules: Fix ReadCount not incrementing offset properly

This commit is contained in:
Phillip Stephens 2022-03-03 00:24:46 -08:00
parent 7010c36056
commit 487dcc4bde
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
4 changed files with 17 additions and 2 deletions

View File

@ -12,8 +12,9 @@ static u32 ReadCount(CInputStream& in) {
return in.ReadLong();
}
u8 junk[784];
for (u32 i = 0; i < (result * 3); ++i) {
u32 iVar2 = ((result * 3) - i);
u32 iVar2 = 0;
for (u32 i = 0; i < (result * 3); i += iVar2) {
iVar2 = ((result * 3) - i);
iVar2 = 192 < iVar2 ? 192 : iVar2;
in.Get(junk, iVar2 * 4);
}

View File

@ -325,6 +325,10 @@ bool CTexture::sMangleMips = false;
u32 CTexture::sCurrentFrameCount = 0;
u32 CTexture::sTotalAllocatedMemory = 0;
void CTexture::InvalidateTexMap(GX::TexMapID id) {
sLoadedTextures[id] = nullptr;
}
CFactoryFnReturn FTextureFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
CObjectReference* selfRef) {
return TToken<CTexture>::GetIObjObjectFor(std::make_unique<CTexture>(in));

View File

@ -95,6 +95,7 @@ public:
return x0_fmt == ETexelFormat::C4 || x0_fmt == ETexelFormat::C8 || x0_fmt == ETexelFormat::C14X2;
}
static void InvalidateTexMap(GX::TexMapID id);
static void SetMangleMips(bool b) { sMangleMips = b; }
static void SetCurrentFrameCount(u32 frameCount) { sCurrentFrameCount = frameCount; }
};

View File

@ -4,8 +4,11 @@
#endif
#include <cstring>
#include <logvisor/logvisor.hpp>
namespace metaforce {
static logvisor::Module Log("metaforce::CInputStream");
static u32 min_containing_bytes(u32 v) {
v = 32 - v;
v = (v >> 3) - (static_cast<s32>(-(v & 7)) >> 31);
@ -46,6 +49,12 @@ void CInputStream::Get(u8* dest, u32 len) {
x4_blockOffset += blockLen;
} else if (len > 256) {
u32 readLen = Read(dest + readCount, len);
#ifndef NDEBUG
if (readLen == 0) {
Log.report(logvisor::Fatal, FMT_STRING("Invalid read size!"));
break;
}
#endif
len -= readLen;
readCount += readLen;
} else {