Merge branch 'fix_getall' into 'master'

Fix argument validation in Lua command `cell:getAll`

See merge request OpenMW/openmw!3195
revert-6246b479
psi29a 1 year ago
commit f4295cf67a

@ -88,19 +88,15 @@ namespace MWLua
return true;
};
bool ok = false;
sol::optional<uint32_t> typeId = sol::nullopt;
if (type.has_value())
typeId = ids[*type];
else
{
ok = true;
bool ok = true;
if (!type.has_value())
cell.mStore->forEach(std::move(visitor));
}
if (typeId.has_value())
else if (ids[*type] == sol::nil)
ok = false;
else
{
ok = true;
switch (*typeId)
uint32_t typeId = ids[*type];
switch (typeId)
{
case ESM::REC_INTERNAL_PLAYER:
{

@ -112,7 +112,7 @@ namespace MWLua
{
auto* lua = context.mLua;
sol::table api(lua->sol(), sol::create);
api["API_REVISION"] = 41;
api["API_REVISION"] = 42;
api["quit"] = [lua]() {
Log(Debug::Warning) << "Quit requested by a Lua script.\n" << lua->debugTraceback();
MWBase::Environment::get().getStateManager()->requestQuit();

@ -1,3 +1,6 @@
#include <sol/sol.hpp>
#include "../../mwworld/class.hpp"
#include "types.hpp"

@ -51,7 +51,7 @@ namespace MWLua
return &mDoorsInScene;
if (typeid(cls) == typeid(MWClass::Container))
return &mContainersInScene;
if (cls.isItem(ptr))
if (cls.isItem(ptr) || ptr.mRef->getType() == ESM::REC_LIGH)
return &mItemsInScene;
return nullptr;
}

@ -23,7 +23,7 @@
-- @field [parent=#nearby] openmw.core#ObjectList doors
---
-- Everything that can be picked up in the nearby.
-- Everything in the nearby that is derived from @{openmw.types#Item}.
-- @field [parent=#nearby] openmw.core#ObjectList items
---

@ -592,10 +592,11 @@
-- @field #SkillStats skills
--- @{#Item} functions (all pickable items that can be placed to an inventory or container)
--------------------------------------------------------------------------------
-- @{#Item} functions (all items that can be placed to an inventory or container)
-- @field [parent=#types] #Item Item
--- Functions for pickable items that can be placed to an inventory or container
--- Functions for items that can be placed to an inventory or container
-- @type Item
---
@ -607,16 +608,26 @@
---
-- Get this item's current enchantment charge.
-- @function [parent=#Item] getEnchantmentCharge
-- @param #Item item
-- @param openmw.core#GameObject item
-- @return #number The charge remaining. -1 if the enchantment has never been used, implying the charge is full. Unenchanted items will always return a value of -1.
---
-- Set this item's enchantment charge.
-- @function [parent=#Item] setEnchantmentCharge
-- @param #Item item
-- @param openmw.core#GameObject item
-- @param #number charge
--- @{#Creature} functions
---
-- Whether the object is supposed to be carriable. It is true for all items except
-- lights without the Carry flag. Non-carriable lights can still be put into
-- an inventory with an explicit `object:moveInto` call.
-- @function [parent=#Item] isCarriable
-- @param openmw.core#GameObject object
-- @return #boolean
--------------------------------------------------------------------------------
-- @{#Creature} functions
-- @field [parent=#types] #Creature Creature
---

Loading…
Cancel
Save