diff options
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 546f4a66..579ae13a 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -206,10 +206,7 @@ static int npc_create(lua_State *s) } q->setMap(m); q->setPosition(Point(x, y)); - bool b = GameState::insert(q); - /* Do not try to deal with a failure there. There are some serious issues - if an insertion failed on an almost empty map. */ - assert(b); (void)b; + GameState::enqueueInsert(q); lua_pushlightuserdata(s, q); return 1; } @@ -370,7 +367,7 @@ static int chr_inv_change(lua_State *s) return 0; } int nb_items = (lua_gettop(s) - 1) / 2; - Inventory inv(q, true); + Inventory inv(q); for (int i = 0; i < nb_items; ++i) { if (!(lua_isnumber(s, i * 2 + 2) || lua_isstring(s, i * 2 + 2)) || @@ -408,12 +405,13 @@ static int chr_inv_change(lua_State *s) id = ic->getDatabaseID(); if (nb < 0) { + // Removing too much item is a success as for the scripter's + // point of view. We log it anyway. nb = inv.remove(id, -nb); if (nb) { - inv.cancel(); - lua_pushboolean(s, 0); - return 1; + LOG_WARN("mana.chr_inv_change() removed more items than owned: " + << "character: " << q->getName() << " item id: " << id); } } else @@ -1158,14 +1156,14 @@ static int monster_change_anger(lua_State *s) */ static int monster_remove(lua_State *s) { - bool monsterEnqueued = false; + bool monsterRemoved = false; Monster *m = getMonster(s, 1); if (m) { - GameState::enqueueRemove(m); - monsterEnqueued = true; + GameState::remove(m); + monsterRemoved = true; } - lua_pushboolean(s, monsterEnqueued); + lua_pushboolean(s, monsterRemoved); return 1; } |