From b1ed86b5ffda331456ec5dc2b22cff1444e5ad3d Mon Sep 17 00:00:00 2001 From: Zarklord Date: Thu, 20 Feb 2020 16:15:57 -0500 Subject: [PATCH] added the ability to undefined properties. --- .../UniversalPropertyPostInit.cpp | 11 +++++++++++ .../UniversalPropertyReplacement.cpp | 14 +++++++++++--- .../UniversalPropertyReplacement.h | 2 ++ UniversalPropertyEnhancer/VerificationCheat.cpp | 15 +++++++++++++-- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/UniversalPropertyEnhancer/UniversalPropertyPostInit.cpp b/UniversalPropertyEnhancer/UniversalPropertyPostInit.cpp index d451289..3dfb060 100644 --- a/UniversalPropertyEnhancer/UniversalPropertyPostInit.cpp +++ b/UniversalPropertyEnhancer/UniversalPropertyPostInit.cpp @@ -65,6 +65,17 @@ void ApplyPostInits(FN* original_function, T* ClassPtr, uint32_t instanceID, uin if (i.first.groupID == groupID && i.first.instanceID == instanceID) { PropertyListPtr postProp; if (!original_function(ClassPtr, i.second.instanceID, i.second.groupID, postProp)) continue; + uint32_t removePropertiesID = id("removeProperties"); + if (postProp->HasProperty(removePropertiesID)) { + uint32_t* properties; + size_t count; + if (App::Property::GetArrayUInt32(postProp.get(), removePropertiesID, count, properties)) { + for (size_t j = 0; j < count; j++) { + pDst->RemoveProperty(properties[j]); + } + } + postProp->RemoveProperty(removePropertiesID); + } pDst->AddAllPropertiesFrom(postProp.get()); } } diff --git a/UniversalPropertyEnhancer/UniversalPropertyReplacement.cpp b/UniversalPropertyEnhancer/UniversalPropertyReplacement.cpp index e156219..5b554c9 100644 --- a/UniversalPropertyEnhancer/UniversalPropertyReplacement.cpp +++ b/UniversalPropertyEnhancer/UniversalPropertyReplacement.cpp @@ -51,13 +51,17 @@ namespace UniversalPropertyReplacement { //as much as GetArrayString8 says it gives a string8 array it doesn't, this took alot of debugging to get this right, the strings are seperated every 0x8 bytes as pointers to the strings. ArgScript::Line PropLine = ArgScript::Line(*(char**)(static_cast(static_cast(stringList)) + (0x8 * j))); - if (PropLine.GetArgumentsCount() < 3 && PropLine.GetArgumentsCount() > 4) continue; + if (PropLine.GetArgumentsCount() > 2 && PropLine.GetArgumentsCount() > 4) continue; typeString = PropLine.GetArgumentAt(0); + typeString.make_lower(); + replaceHash = std::strtoul(PropLine.GetArgumentAt(1), nullptr, 16); + if (typeString == "delete") { + deletePropertyIDs[replaceHash] = true; + continue; + } valueString = PropLine.GetArgumentAt(2); - typeString.make_lower(); - if (typeString == "bool") { bool value; result = App::Property::GetBool(propList.get(), id(valueString.c_str()), value); @@ -266,6 +270,10 @@ void ApplyTemplateValueMapArrayProperty(App::Property*& prop, uint32_t propertyI } void ApplyValueMapProperty(App::Property*& prop, uint32_t propertyID) { + if (deletePropertyIDs.find(propertyID) != deletePropertyIDs.end()) { + prop->Set(App::PropertyType::Void, 0, NULL, 0, 0); + return; + } if (prop->mnFlags & App::Property::PropertyFlags::kPropertyFlagArray) { switch (prop->mnType) { case App::PropertyType::Bool: { diff --git a/UniversalPropertyEnhancer/UniversalPropertyReplacement.h b/UniversalPropertyEnhancer/UniversalPropertyReplacement.h index 55caad5..1c8be71 100644 --- a/UniversalPropertyEnhancer/UniversalPropertyReplacement.h +++ b/UniversalPropertyEnhancer/UniversalPropertyReplacement.h @@ -24,6 +24,8 @@ namespace UniversalPropertyReplacement { bool Inititalize(); long AttachDetours(); + static eastl::map deletePropertyIDs {}; + static eastl::map boolValueMapOverride {}; static eastl::map> boolValueMapArrayOverride {}; diff --git a/UniversalPropertyEnhancer/VerificationCheat.cpp b/UniversalPropertyEnhancer/VerificationCheat.cpp index 812a966..9063d8d 100644 --- a/UniversalPropertyEnhancer/VerificationCheat.cpp +++ b/UniversalPropertyEnhancer/VerificationCheat.cpp @@ -96,6 +96,11 @@ void VerificationCheat::ParseLine(const ArgScript::Line& line) { App::Property* out; bool testFailed = false; + bool deleteTest; + if (App::Property::GetBool(propList.get(), GetPropertyId("delete"), deleteTest)) { + ReportReplacementFailed("delete"); + testFailed = true; + } bool boolTest = false; App::Property::GetBool(propList.get(), GetPropertyId("bool"), boolTest); if (VerifyValue(boolTest)) { @@ -342,16 +347,22 @@ void VerificationCheat::ParseLine(const ArgScript::Line& line) { } if (!testFailed) { - App::ConsolePrintF("no replacement tests failed!"); + App::ConsolePrintF("All replacement tests passed!"); } testFailed = false; + bool addTest = false; App::Property::GetBool(propList.get(), id("postinitAdd"), addTest); if (VerifyValue(addTest)) { App::ConsolePrintF("Add Postinit failed!"); testFailed = true; } + bool removeTest = false; + if (App::Property::GetBool(propList.get(), id("postinitRemove"), removeTest)) { + App::ConsolePrintF("Remove Postinit failed!"); + testFailed = true; + } int32_t replaceTest; App::Property::GetInt32(propList.get(), id("postinitReplace"), replaceTest); if (VerifyValue(replaceTest)) { @@ -366,6 +377,6 @@ void VerificationCheat::ParseLine(const ArgScript::Line& line) { } if (!testFailed) { - App::ConsolePrintF("no postinit tests failed!"); + App::ConsolePrintF("All postinit tests passed!"); } } \ No newline at end of file