Skip to content

Commit

Permalink
added the ability to undefined properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zarklord committed Feb 20, 2020
1 parent e2d53c6 commit b1ed86b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
11 changes: 11 additions & 0 deletions UniversalPropertyEnhancer/UniversalPropertyPostInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
14 changes: 11 additions & 3 deletions UniversalPropertyEnhancer/UniversalPropertyReplacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char*>(static_cast<void*>(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);
Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 2 additions & 0 deletions UniversalPropertyEnhancer/UniversalPropertyReplacement.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace UniversalPropertyReplacement {
bool Inititalize();
long AttachDetours();

static eastl::map<uint32_t, bool> deletePropertyIDs {};

static eastl::map<uint32_t, bool> boolValueMapOverride {};
static eastl::map<uint32_t, eastl::pair<bool*, uint32_t>> boolValueMapArrayOverride {};

Expand Down
15 changes: 13 additions & 2 deletions UniversalPropertyEnhancer/VerificationCheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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!");
}
}

0 comments on commit b1ed86b

Please sign in to comment.