Skip to content
Snippets Groups Projects
Commit f0056f9d authored by DarkGod's avatar DarkGod
Browse files

Merge branch 'callback-fix' into 'master'

Callback fix

I honestly wasn't expecting THAT.
Due to an old typo in learnTalent, callbacks for passives were added once per talent level. So I fixed that, twice, just in case.
(Grumble grumble wouldn't have happened if __sorted updated at once)
parents adefac31 383e233d
No related branches found
No related tags found
No related merge requests found
......@@ -4044,7 +4044,7 @@ end
-- @param t_id the id of the talent to learn
-- @return true if the talent was learnt, nil and an error message otherwise
function _M:learnTalent(t_id, force, nb, extra)
local just_learnt = not self:knowTalent(tid)
local just_learnt = not self:knowTalent(t_id)
if not engine.interface.ActorTalents.learnTalent(self, t_id, force, nb) then return false end
-- If we learned a spell, get mana, if you learned a technique get stamina, if we learned a wild gift, get power
......@@ -4798,20 +4798,22 @@ function _M:registerCallbacks(objdef, objid, objtype)
if objdef[event] then
local cb = self[store] or {}
upgradeStore(cb, store)
cb[objid] = objtype
-- extract a priority, 0 by default
cb.__priorities[objid] = (objdef.callbackPriorities and objdef.callbackPriorities[event]) or 0
self[store] = cb
-- insert into priorities
local sortedkey = {cb.__priorities[objid], objtype, convertToString(objid), objid}
local idx = #cb.__sorted + 1
for i, key in ipairs(cb.__sorted) do
if callbackKeyLess(sortedkey, key) then
idx = i
break
if not cb[objid] then
cb[objid] = objtype
-- extract a priority, 0 by default
cb.__priorities[objid] = (objdef.callbackPriorities and objdef.callbackPriorities[event]) or 0
self[store] = cb
-- insert into priorities
local sortedkey = {cb.__priorities[objid], objtype, convertToString(objid), objid}
local idx = #cb.__sorted + 1
for i, key in ipairs(cb.__sorted) do
if callbackKeyLess(sortedkey, key) then
idx = i
break
end
end
table.insert(cb.__sorted, idx, sortedkey)
end
table.insert(cb.__sorted, idx, sortedkey) -- may be nil, which means to the
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment