diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2021-06-30 20:39:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-30 20:39:38 +0200 |
commit | f2fd4432625ee5cf0380bdd006cd1f15d053b12f (patch) | |
tree | c86099e50c53442900ea034342f9e50f9a87c603 /src/script/common | |
parent | 72927b73ca857acd4dc5a40a96be220d090436f3 (diff) | |
download | minetest-f2fd4432625ee5cf0380bdd006cd1f15d053b12f.tar.gz minetest-f2fd4432625ee5cf0380bdd006cd1f15d053b12f.tar.bz2 minetest-f2fd4432625ee5cf0380bdd006cd1f15d053b12f.zip |
Inventory: Make addList() consistent (#11382)
Fixes list clearing for inv:set_list() using same size, since 2db6b07.
addList() now clears the list in all cases. Use setSize() to resize without clearing.
Diffstat (limited to 'src/script/common')
-rw-r--r-- | src/script/common/c_content.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index f8cc40927..a0b45982a 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -1359,9 +1359,9 @@ void read_inventory_list(lua_State *L, int tableindex, // Get Lua-specified items to insert into the list std::vector<ItemStack> items = read_items(L, tableindex,srv); - size_t listsize = (forcesize > 0) ? forcesize : items.size(); + size_t listsize = (forcesize >= 0) ? forcesize : items.size(); - // Create or clear list + // Create or resize/clear list InventoryList *invlist = inv->addList(name, listsize); if (!invlist) { luaL_error(L, "inventory list: cannot create list named '%s'", name); |