diff options
-rw-r--r-- | src/scripting/lua.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 911c27cc..1fdd90e4 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -250,17 +250,20 @@ static int LuaChr_InvChange(lua_State *s) } else { + ItemClass *ic = ItemManager::getItem(id); + if (!ic) + { + LOG_WARN("LuaChr_InvChange called with an unknown item."); + continue; + } nb = inv.insert(id, nb); if (nb) { - if (ItemClass *ic = ItemManager::getItem(id)) - { - Item *item = new Item(ic, nb); - item->setMap(q->getMap()); - item->setPosition(q->getPosition()); - DelayedEvent e = { EVENT_INSERT }; - GameState::enqueueEvent(item, e); - } + Item *item = new Item(ic, nb); + item->setMap(q->getMap()); + item->setPosition(q->getPosition()); + DelayedEvent e = { EVENT_INSERT }; + GameState::enqueueEvent(item, e); } } } |