From 006a213747eb8063ad543211b9776caba027ea4a Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Wed, 27 Jul 2011 13:04:24 +0200 Subject: Removed the inventory delay mode for now. I said I wouldn't do it, but I change my mind. Here is why: The delay mode is used in the trading code, and in the inventory code for lua only. In the lua part, the delay mode is useless as it is used only when the script is requesting removal of more items than owned. This is something that can't be handled well anyway, as for the script part, even when the character was still keeping its items. Plus, it's not actually an error, IMHO. In the trading code, it made sense. But the next commit will bring design changes making the inventory items and the equipment items not linked anymore. Hence, making it impossible to trade equipped items, for instance, which is a good thing IMHO. It will also remove the need of a delayed inventory mode in that case. The two cases where it is used will disappear, making it useless. Last but no least, the part watching for equipment changes in the commit() function is not something easy to debug without first having a proper and working base. (checking of two multimaps changes, for instance). We can add it back once the code has been fully debugged for the most skilled among us. And yes, I am sure of what I'm currently doing. For now the whole inventory and trading code is in need of review but it already was, anyway. --- src/scripting/lua.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index d461bf44..b422fc3e 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -359,7 +359,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_isnumber(s, i * 2 + 3)) @@ -377,12 +377,13 @@ static int chr_inv_change(lua_State *s) } else 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 -- cgit v1.2.3-70-g09d2