Add FPS display, make world latency opt-in, bump to 1.3

World latency never populates on OctoWoW (always 0), so it's now hidden
behind /octolat worldlatency instead of showing a misleading "0 ms".
This commit is contained in:
kompolompo
2026-09-05 18:30:47 +02:00
parent 5e1f373b75
commit a8ec255a90
4 changed files with 43 additions and 10 deletions
+31 -7
View File
@@ -51,12 +51,21 @@ function OctoLatency_OnLoad(self)
OctoLatency_SafeCall("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_TOP")
GameTooltip:AddLine("OctoLatency", 0, 1, 1)
local db = OctoLatency_EnsureDB()
local bandwidth, latency, homeLatency, worldLatency = GetNetStats()
bandwidth = bandwidth or 0
homeLatency = homeLatency or 0
worldLatency = worldLatency or 0
GameTooltip:AddLine("Home Latency: " .. homeLatency .. " ms", 1, 1, 1)
GameTooltip:AddLine("World Latency: " .. worldLatency .. " ms", 1, 1, 1)
if (db.showWorldLatency) then
GameTooltip:AddLine("World Latency: " .. worldLatency .. " ms", 1, 1, 1)
else
-- Many private-server cores never populate this (always 0), so
-- it's hidden behind an opt-in setting (/octolat worldlatency)
-- instead of showing a permanently-wrong "0 ms".
GameTooltip:AddLine("World Latency: N/A", 1, 1, 1)
end
GameTooltip:AddLine("FPS: " .. string.format("%.0f", GetFramerate() or 0), 1, 1, 1)
GameTooltip:AddLine("Bandwidth: " .. string.format("%.2f", bandwidth) .. " KB/s", 1, 1, 1)
GameTooltip:AddLine("Left-click and drag to move.", 0.7, 0.7, 0.7)
GameTooltip:Show()
@@ -69,14 +78,16 @@ function OctoLatency_OnLoad(self)
end
local function OctoLatency_UpdateText()
local db = OctoLatency_EnsureDB()
-- GetNetStats returns: bandwidth, latency, homeLatency, worldLatency
local _, _, homeLatency, worldLatency = GetNetStats()
-- We'll display world latency (or max of home/world)
-- Some servers never populate world latency (always 0), and 0 is
-- truthy in Lua, so treat a zero world latency as "unavailable" too.
-- World latency defaults to off since many private-server cores never
-- populate it (always 0); enable it with /octolat worldlatency if your
-- server does report it.
local latency = homeLatency or 0
if (worldLatency and worldLatency > 0) then
if (db.showWorldLatency and worldLatency and worldLatency > 0) then
latency = worldLatency
end
@@ -90,7 +101,17 @@ local function OctoLatency_UpdateText()
colorHex = "|cffff0000" -- Red
end
OctoLatencyText:SetText(colorHex .. latency .. " ms|r")
local fps = GetFramerate() or 0
local fpsColorHex
if (fps >= 30) then
fpsColorHex = "|cff00ff00" -- Green
elseif (fps >= 15) then
fpsColorHex = "|cffffff00" -- Yellow
else
fpsColorHex = "|cffff0000" -- Red
end
OctoLatencyText:SetText(colorHex .. latency .. " ms|r " .. fpsColorHex .. string.format("%.0f", fps) .. " fps|r")
end
function OctoLatency_OnUpdate(elapsed)
@@ -236,7 +257,10 @@ SlashCmdList["OCTOLATENCY"] = function(msg)
elseif (msg == "clearerrors") then
db.errorLog = {}
DEFAULT_CHAT_FRAME:AddMessage("OctoLatency: error log cleared.")
elseif (msg == "worldlatency") then
db.showWorldLatency = not db.showWorldLatency
DEFAULT_CHAT_FRAME:AddMessage("OctoLatency: world latency display " .. (db.showWorldLatency and "enabled" or "disabled") .. ".")
else
DEFAULT_CHAT_FRAME:AddMessage("OctoLatency commands: /octolat errors, /octolat copyerrors, /octolat clearerrors")
DEFAULT_CHAT_FRAME:AddMessage("OctoLatency commands: /octolat errors, /octolat copyerrors, /octolat clearerrors, /octolat worldlatency")
end
end