Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions Addons/DataToColor/DataToColor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Addons/DataToColor/DataToColor.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Addons/DataToColor/DataToColor_Classic.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Addons/DataToColor/DataToColor_TBC.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions Core/Addon/PlayerReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -64,7 +64,7 @@ public Vector3 TargetMapPos
}
}

public float Direction => reader.GetFixed(3);
public float Direction => reader.GetFixed20(3);

public float _Direction() => Direction;

Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion Core/AddonDataProvider/IAddonDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading