Skip to content

Commit

Permalink
improve: check and return in addChildLoot Method (opentibiabr#1774)
Browse files Browse the repository at this point in the history
Check child loot and return boolean in addChildLoot Method
  • Loading branch information
luanluciano93 authored and marcusvcj committed Nov 4, 2023
1 parent 8fc4ff0 commit ffb4934
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lua/functions/creatures/monster/loot_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,13 @@ int LootFunctions::luaLootAddChildLoot(lua_State* L) {
// loot:addChildLoot(loot)
const auto loot = getUserdataShared<Loot>(L, 1);
if (loot) {
loot->lootBlock.childLoot.push_back(getUserdata<Loot>(L, 2)->lootBlock);
const auto childLoot = getUserdata<Loot>(L, 2);
if (childLoot) {
loot->lootBlock.childLoot.push_back(childLoot->lootBlock);
pushBoolean(L, true);
} else {
pushBoolean(L, false);
}
} else {
lua_pushnil(L);
}
Expand Down

0 comments on commit ffb4934

Please sign in to comment.