Merge branch 'fix_group_count' into 'master'

Fix use of uninitialized data.

See merge request rubenwardy/awards!84
This commit is contained in:
Beha 2020-04-05 04:38:01 +00:00
commit 6f1f546b88
1 changed files with 11 additions and 11 deletions

View File

@ -141,17 +141,6 @@ function awards.register_trigger(tname, tdef)
function tdef.notify(player, key, n)
n = n or 1
if tdef.key_is_item and key:sub(1, 6) ~= "group:" then
local itemdef = minetest.registered_items[key]
if itemdef then
for groupname,rating in pairs(itemdef.groups or {}) do
if rating ~= 0 and tdef.watched_groups[groupname] then
tdef.notify(player, "group:" .. groupname, n)
end
end
end
end
assert(player and player.is_player and player:is_player() and key)
local name = player:get_player_name()
local data = awards.player(name)
@ -164,6 +153,17 @@ function awards.register_trigger(tname, tdef)
data[tname].__total = (data[tname].__total or 0) + n
end
if tdef.key_is_item and key:sub(1, 6) ~= "group:" then
local itemdef = minetest.registered_items[key]
if itemdef then
for groupname,rating in pairs(itemdef.groups or {}) do
if rating ~= 0 and tdef.watched_groups[groupname] then
tdef.notify(player, "group:" .. groupname, n)
end
end
end
end
tdef:run_callbacks(player, data, function(entry)
local current
if entry.key == key then