mirror of
https://github.com/mehah/otclient
synced 2026-08-15 16:29:06 -04:00
fix: XP bar renders full and the tooltip reads "-5500 percent to go" (#1797)
Bug Fixes: - Improved experience and level progress accuracy when handling level-change updates. - Prevented analyser updates when no local player is available. - Normalized level percentages for newer protocols, ensuring progress bars and tooltips display correct values.
This commit is contained in:
parent
e6bcb1f2f6
commit
478522f36c
2 changed files with 12 additions and 2 deletions
|
|
@ -544,7 +544,13 @@ function checkNumber(self, text)
|
|||
end
|
||||
|
||||
function onLevelChange(localPlayer, value, percent)
|
||||
XPAnalyser:setupLevel(value, percent)
|
||||
-- See game_skills/skills.lua onLevelChange: the callback passes the level percent raw
|
||||
-- (centipercent with GameLevelPercentU16, protocol >= 1520). Normalize it with
|
||||
-- getLevelPercent() or the analyser bar renders full.
|
||||
if not localPlayer then
|
||||
return
|
||||
end
|
||||
XPAnalyser:setupLevel(value, localPlayer:getLevelPercent())
|
||||
end
|
||||
|
||||
function managerDropTracker(itemId, checked)
|
||||
|
|
|
|||
|
|
@ -1105,7 +1105,11 @@ function onLevelChange(localPlayer, value, percent)
|
|||
if not localPlayer then
|
||||
return
|
||||
end
|
||||
percent = percent or localPlayer:getLevelPercent()
|
||||
-- The C++ onLevelChange callback passes m_levelPercent raw, which is centipercent
|
||||
-- (0-10000) once GameLevelPercentU16 is enabled (protocol >= 1520), not the 0-100 the
|
||||
-- UI expects. getLevelPercent() normalizes it, so always use the getter: otherwise the
|
||||
-- bar renders full and the tooltip reads "-5500 percent to go" at high levels.
|
||||
percent = localPlayer:getLevelPercent()
|
||||
setSkillValue('level', comma_value(value))
|
||||
local text = tr('You have %s percent to go', 100 - percent)
|
||||
setSkillPercent('level', percent, text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue