From e8f48ef66a92c46fc030fd45cb27410554b9c060 Mon Sep 17 00:00:00 2001 From: parax0 Date: Fri, 26 Feb 2016 04:58:58 -0700 Subject: [PATCH] Bugfixes + removing warning for invalid property count in MP2/3 areas --- src/Core/Resource/Factory/CAreaLoader.cpp | 2 +- src/Core/Resource/Factory/CScriptLoader.cpp | 23 ++++--------------- src/Core/Resource/Factory/CTemplateLoader.cpp | 2 +- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/Core/Resource/Factory/CAreaLoader.cpp b/src/Core/Resource/Factory/CAreaLoader.cpp index 1119bb99..f2516d01 100644 --- a/src/Core/Resource/Factory/CAreaLoader.cpp +++ b/src/Core/Resource/Factory/CAreaLoader.cpp @@ -128,7 +128,7 @@ void CAreaLoader::ReadSCLYPrime() Log::FileError(mpMREA->GetSourceString(), mpMREA->Tell() - 4, "Invalid SCLY magic: " + SCLY.ToString()); return; } - mpMREA->Seek(0x4, SEEK_CUR); // Skipping unknown value which is always 4 + mpMREA->Seek(mVersion <= ePrime ? 4 : 1, SEEK_CUR); // Skipping unknown value which is always 1 // Read layer sizes mNumLayers = mpMREA->ReadLong(); diff --git a/src/Core/Resource/Factory/CScriptLoader.cpp b/src/Core/Resource/Factory/CScriptLoader.cpp index d23e16aa..35f3e9d1 100644 --- a/src/Core/Resource/Factory/CScriptLoader.cpp +++ b/src/Core/Resource/Factory/CScriptLoader.cpp @@ -182,7 +182,8 @@ void CScriptLoader::LoadStructMP1(IInputStream& SCLY, CPropertyStruct *pStruct, TIDString IDString = pTemp->IDString(true); if (!IDString.IsEmpty()) IDString = " (" + IDString + ")"; - Log::FileWarning(SCLY.GetSourceString(), StructStart, "Struct \"" + pTemp->Name() + "\"" + IDString + " template prop count doesn't match file"); + Log::FileWarning(SCLY.GetSourceString(), StructStart, "Struct \"" + pTemp->Name() + "\"" + IDString + " template prop count doesn't match file; template is " + TString::HexString(PropCount, true, true, 2) + ", file is " + TString::HexString(FilePropCount, true, true, 2)); + Version = 0; } } @@ -208,7 +209,7 @@ CScriptObject* CScriptLoader::LoadObjectMP1(IInputStream& SCLY) if (!pTemp) { // No valid template for this object; can't load - Log::FileError(SCLY.GetSourceString(), ObjStart, "Invalid object ID encountered: " + TString::HexString(Type)); + Log::FileError(SCLY.GetSourceString(), ObjStart, "Unknown object ID encountered: " + TString::HexString(Type)); SCLY.Seek(End, SEEK_SET); return nullptr; } @@ -269,23 +270,9 @@ void CScriptLoader::LoadStructMP2(IInputStream& SCLY, CPropertyStruct *pStruct, u32 StructStart = SCLY.Tell(); StructStart += 0; u32 PropCount = pTemp->Count(); - u32 Version = 0; if (!pTemp->IsSingleProperty()) - { - u16 NumProperties = SCLY.ReadShort(); - Version = pTemp->VersionForPropertyCount(NumProperties); - - if ((NumProperties != PropCount) && (mVersion < eReturns)) - { - TIDString IDString = pTemp->IDString(true); - if (!IDString.IsEmpty()) IDString = " (" + IDString + ")"; - - Log::FileWarning(SCLY.GetSourceString(), StructStart, "Struct \"" + pTemp->Name() + "\"" + IDString + " template prop count doesn't match file"); - } - - PropCount = NumProperties; - } + PropCount = SCLY.ReadShort(); // Parse properties for (u32 iProp = 0; iProp < PropCount; iProp++) @@ -334,7 +321,7 @@ CScriptObject* CScriptLoader::LoadObjectMP2(IInputStream& SCLY) if (!pTemplate) { - Log::FileError(SCLY.GetSourceString(), ObjStart, "Invalid object ID encountered: " + CFourCC(ObjectID).ToString()); + Log::FileError(SCLY.GetSourceString(), ObjStart, "Unknown object ID encountered: " + CFourCC(ObjectID).ToString()); SCLY.Seek(ObjEnd, SEEK_SET); return nullptr; } diff --git a/src/Core/Resource/Factory/CTemplateLoader.cpp b/src/Core/Resource/Factory/CTemplateLoader.cpp index 0d628a70..7f2698fe 100644 --- a/src/Core/Resource/Factory/CTemplateLoader.cpp +++ b/src/Core/Resource/Factory/CTemplateLoader.cpp @@ -413,7 +413,7 @@ CScriptTemplate* CTemplateLoader::LoadScriptTemplate(XMLDocument *pDoc, const TS { CScriptTemplate *pScript = new CScriptTemplate(mpMaster); pScript->mObjectID = ObjectID; - pScript->mpBaseStruct = new CStructTemplate(-1, nullptr, mpMaster); + pScript->mpBaseStruct = new CStructTemplate(-1, pScript, mpMaster); pScript->mSourceFile = rkTemplateName; XMLElement *pRoot = pDoc->FirstChildElement("ScriptTemplate");