Fix a bug in Xpro making the game crash when xp_atual is nil

master
Solebull 2019-01-02 04:08:35 +01:00
parent 22ba21077a
commit fd061ac282
2 changed files with 8 additions and 0 deletions

1
TODO
View File

@ -11,4 +11,5 @@ minetest-solebull - LGPL-2.1 - A PVP/faction game for minetest based on Cobalt.
* v0.0.2-5 (02 Jan. 2019 - ???) CLOC ???,???
- Fix a bug in Xpro making the game crash when xp_atual is nil
- Add more mc mobs with XPs

View File

@ -110,6 +110,13 @@ xpro.add_xp = function(name, xp_add)
local tb_name = "jogador_"..name
local xp_atual = xpro.get_player_xp(name)
-- In rare case, xp_atual can be nil. So, better than nothing
-- do not let the game crash
if xp_atual == nil then
minetest.log("warning", "xp_atual is nil. Will not add XPs")
return
end
-- Evita salvar xp negativo
local new_xp = xp_atual+xp_add