From ca17fdb08d1af298ec79e0b6c8f65ec95df24024 Mon Sep 17 00:00:00 2001 From: Bkacjios Date: Wed, 25 Nov 2020 01:46:03 -0500 Subject: [PATCH] Fixed brawl causing a blue error screen on game load. Fix a regression where multiple addresses assigned to the same name would always use the last assigned addresses value. (Caused low polling rates in Brawl) Bump version to 1.6.1 --- release.iss | 2 +- source/modules/memory/init.lua | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/release.iss b/release.iss index 55a949a..5e7bab7 100644 --- a/release.iss +++ b/release.iss @@ -8,7 +8,7 @@ [Setup] #define AppName "M'Overlay" -#define AppVersion "1.6.0" +#define AppVersion "1.6.1" AppName={#AppName} AppId={#AppName} AppVersion={#AppVersion} diff --git a/source/modules/memory/init.lua b/source/modules/memory/init.lua index 577bd8d..cc83496 100644 --- a/source/modules/memory/init.lua +++ b/source/modules/memory/init.lua @@ -177,6 +177,7 @@ local TYPES_READ = { ["sbyte"] = memory.readByte, ["byte"] = memory.readUByte, ["short"] = memory.readShort, + ["int"] = memory.readInt, ["u8"] = memory.readUByte, ["s8"] = memory.readByte, @@ -225,12 +226,14 @@ function memory.newvalue(addr, offset, struct, name) assert(type(addr) == "number", "argument #1 'address' must be a number") assert(TYPES_READ[struct.type] ~= nil, "unhandled type: " .. struct.type) - name = name or struct.name or "" + name = name or struct.name or addr + + local init = struct.init or NULL -- create/get a new value cache based off of the value name - local tbl, key = memory.cacheValue(memory.values, name, struct.init or NULL) + local tbl, key = memory.cacheValue(memory.values, name, init) - --log.debug("[MEMORY] VALUE CREATED %08X + %X %q", addr, offset, name) + log.debug("[MEMORY] VALUE CREATED %08X + %X %q", addr, offset, name) return setmetatable({ name = name, @@ -244,6 +247,7 @@ function memory.newvalue(addr, offset, struct, name) -- Setup the cache cache = tbl, cache_key = key, + cache_value = init, debug = struct.debug, }, ADDRESS) @@ -257,8 +261,9 @@ function ADDRESS:update() local value, orig = self.read(self.address + self.offset) -- Check if there has been a value change - if self.cache[self.cache_key] ~= value then - self.cache[self.cache_key] = value + if self.cache_value ~= value then + self.cache_value = value + self.cache[self.cache_key] = self.cache_value if self.debug then local numValue = tonumber(orig) or tonumber(value) or (value and 1 or 0)