ctf_classes: Fix crash when player meta contains invalid class name (#607)

This commit is contained in:
ANAND 2020-05-07 14:52:14 +05:30 committed by GitHub
parent 3a0397ee28
commit b1aa1366f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,7 +59,11 @@ function ctf_classes.get(player)
player = minetest.get_player_by_name(player)
end
local cname = player:get_meta():get("ctf_classes:class") or ctf_classes.default_class
-- Return class from player meta if valid, or default class
local cname = player:get_meta():get("ctf_classes:class")
if not ctf_classes.__classes[cname] then
cname = ctf_classes.default_class
end
return ctf_classes.__classes[cname]
end