diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-11 12:24:36 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-11 12:24:36 +0000 |
commit | dddbb52f6724b8b0dd6f99b996e50ad9bfbca432 (patch) | |
tree | e5f127f890256d42c3fbf3e8cc819fcfd31da0d9 | |
parent | 797f8b0f29d8cfcefe8777bf337d75406210f71c (diff) | |
download | manaserv-dddbb52f6724b8b0dd6f99b996e50ad9bfbca432.tar.gz manaserv-dddbb52f6724b8b0dd6f99b996e50ad9bfbca432.tar.bz2 manaserv-dddbb52f6724b8b0dd6f99b996e50ad9bfbca432.tar.xz manaserv-dddbb52f6724b8b0dd6f99b996e50ad9bfbca432.zip |
Prevented scripts from inserting buggy items in inventories.
-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); } } } |