From dfa56f5b37bb4469657f4fd291e1586670d8de94 Mon Sep 17 00:00:00 2001 From: Xian55 <367101+Xian55@users.noreply.github.com> Date: Sat, 28 Mar 2026 23:21:27 +0100 Subject: [PATCH] Addon: [1.9.15] Use full 24-bit range for position encoding Replace the generic float encoding (6% of 24-bit range) with a dedicated fixed24 encoder that uses the full 0-16777215 range for normalized 0-1 position coordinates, improving world precision from ~0.005 to ~0.0003 yards. Also rename float/GetFixed to fixed20/GetFixed20 for consistency with the new fixed24/GetFixed24 naming convention. Co-Authored-By: Claude Opus 4.6 (1M context) --- Addons/DataToColor/DataToColor.lua | 22 ++++++++++++-------- Addons/DataToColor/DataToColor.toc | 2 +- Addons/DataToColor/DataToColor_Classic.toc | 2 +- Addons/DataToColor/DataToColor_TBC.toc | 2 +- Core/Addon/PlayerReader.cs | 12 +++++------ Core/AddonDataProvider/IAddonDataProvider.cs | 7 ++++++- 6 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Addons/DataToColor/DataToColor.lua b/Addons/DataToColor/DataToColor.lua index be5d10b67..2e0a05447 100644 --- a/Addons/DataToColor/DataToColor.lua +++ b/Addons/DataToColor/DataToColor.lua @@ -776,12 +776,16 @@ function DataToColor:CreateFrames() return band(rshift(i, 16), 255) / 255, band(rshift(i, 8), 255) / 255, band(i, 255) / 255, 1 end - -- This function is able to pass numbers in range 0 to 9.99999 (6 digits) - -- converting them to a 6-digit integer. - local function float(self, f) + -- 20-bit fixed-point encoding for values in range 0 to 9.99999 (6 digits) + local function fixed20(self, f) return int(self, floor(f * 100000)) end + -- 24-bit fixed-point encoding for normalized 0-1 values + local function fixed24(self, p) + return int(self, floor(p * 16777215)) + end + local function Pixel(func, value, slot) if valueCache[slot] ~= value then valueCache[slot] = value @@ -841,17 +845,17 @@ function DataToColor:CreateFrames() Pixel(int, 2000001, NUMBER_OF_FRAMES - 1) local x, y = DataToColor:GetPosition() - Pixel(float, x * 10, 1) - Pixel(float, y * 10, 2) + Pixel(fixed24, x, 1) + Pixel(fixed24, y, 2) - Pixel(float, GetPlayerFacing() or 0, 3) + Pixel(fixed20, GetPlayerFacing() or 0, 3) Pixel(int, DataToColor.map or 0, 4) -- MapUIId local playerLevel = UnitLevel(DataToColor.C.unitPlayer) Pixel(int, playerLevel, 5) local cx, cy = DataToColor:GetCorpsePosition() - Pixel(float, cx * 10, 6) - Pixel(float, cy * 10, 7) + Pixel(fixed24, cx, 6) + Pixel(fixed24, cy, 7) -- Boolean variables -- Use event-driven cached versions (reduces API calls from ~46 to ~5 per frame) @@ -1302,7 +1306,7 @@ function DataToColor:CreateFrames() Pixel(int, DataToColor.EnemySummonQueue:shift(globalTick) or 0, 110) local _, playerRunSpeed = GetUnitSpeed(DataToColor.C.unitPlayer) - Pixel(float, playerRunSpeed or 0, 111) + Pixel(fixed20, playerRunSpeed or 0, 111) UpdateGlobalTime() -- NUMBER_OF_FRAMES - 1 reserved for validation diff --git a/Addons/DataToColor/DataToColor.toc b/Addons/DataToColor/DataToColor.toc index 35e72a149..a2e5f0c12 100644 --- a/Addons/DataToColor/DataToColor.toc +++ b/Addons/DataToColor/DataToColor.toc @@ -2,7 +2,7 @@ ## Title: DataToColor ## Author: FreeHongKongMMO ## Notes: Displays data as colors (Legacy Cataclysm 4.3.0) -## Version: 1.9.14 +## Version: 1.9.15 ## RequiredDeps: ## OptionalDeps: Ace3, LibRangeCheck, cTimerBackport ## SavedVariables: diff --git a/Addons/DataToColor/DataToColor_Classic.toc b/Addons/DataToColor/DataToColor_Classic.toc index c28c4ea1f..930e14f49 100644 --- a/Addons/DataToColor/DataToColor_Classic.toc +++ b/Addons/DataToColor/DataToColor_Classic.toc @@ -2,7 +2,7 @@ ## Title: DataToColor ## Author: FreeHongKongMMO ## Notes: Displays data as colors (Classic) -## Version: 1.9.14 +## Version: 1.9.15 ## RequiredDeps: ## OptionalDeps: Ace3, LibRangeCheck, LibClassicCasterino ## SavedVariables: diff --git a/Addons/DataToColor/DataToColor_TBC.toc b/Addons/DataToColor/DataToColor_TBC.toc index ca7218195..118c4bec3 100644 --- a/Addons/DataToColor/DataToColor_TBC.toc +++ b/Addons/DataToColor/DataToColor_TBC.toc @@ -2,7 +2,7 @@ ## Title: DataToColor ## Author: FreeHongKongMMO ## Notes: Displays data as colors (Classic TBC) -## Version: 1.9.14 +## Version: 1.9.15 ## RequiredDeps: ## OptionalDeps: Ace3, LibRangeCheck, LibClassicCasterino ## SavedVariables: diff --git a/Core/Addon/PlayerReader.cs b/Core/Addon/PlayerReader.cs index 2bc690c08..05579ca7f 100644 --- a/Core/Addon/PlayerReader.cs +++ b/Core/Addon/PlayerReader.cs @@ -46,8 +46,8 @@ public PlayerReader( public float WorldPosZ { get; set; } // MapZ not exists. Alias for WorldLoc.Z - public float MapX => reader.GetFixed(1) * 10; - public float MapY => reader.GetFixed(2) * 10; + public float MapX => reader.GetFixed24(1); + public float MapY => reader.GetFixed24(2); public Vector3 TargetMapPos { @@ -64,7 +64,7 @@ public Vector3 TargetMapPos } } - public float Direction => reader.GetFixed(3); + public float Direction => reader.GetFixed20(3); public float _Direction() => Direction; @@ -75,8 +75,8 @@ public Vector3 TargetMapPos public RecordInt Level { get; } = new(5); public Vector3 CorpseMapPos => new(CorpseMapX, CorpseMapY, 0); - public float CorpseMapX => reader.GetFixed(6) * 10; - public float CorpseMapY => reader.GetFixed(7) * 10; + public float CorpseMapX => reader.GetFixed24(6); + public float CorpseMapY => reader.GetFixed24(7); public int HealthMax() => reader.GetInt(10); public int HealthCurrent() => reader.GetInt(11); @@ -255,7 +255,7 @@ public void ReadLastCastGCD() public int SoftInteract_Guid => reader.GetInt(101); - public float RunSpeed => reader.GetFixed(111); + public float RunSpeed => reader.GetFixed20(111); private int previousHealthPercent; private long lastDamageTakenTimestamp; diff --git a/Core/AddonDataProvider/IAddonDataProvider.cs b/Core/AddonDataProvider/IAddonDataProvider.cs index 095c6c2b3..bba62f1d0 100644 --- a/Core/AddonDataProvider/IAddonDataProvider.cs +++ b/Core/AddonDataProvider/IAddonDataProvider.cs @@ -49,11 +49,16 @@ int GetInt(int index) return Data[index]; } - float GetFixed(int index) + float GetFixed20(int index) { return Data[index] / 100000f; } + float GetFixed24(int index) + { + return Data[index] * 100f / 16777215f; + } + string GetString(int index) { int color = GetInt(index);