Merge branch 'fix_getall' into 'master'

Fix argument validation in Lua command `cell:getAll`

See merge request OpenMW/openmw!3195
This commit is contained in:
psi29a 2023-07-16 08:45:54 +00:00
commit f4295cf67a
6 changed files with 29 additions and 19 deletions

View file

@ -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];
bool ok = true;
if (!type.has_value())
cell.mStore->forEach(std::move(visitor));
else if (ids[*type] == sol::nil)
ok = false;
else
{
ok = true;
cell.mStore->forEach(std::move(visitor));
}
if (typeId.has_value())
{
ok = true;
switch (*typeId)
uint32_t typeId = ids[*type];
switch (typeId)
{
case ESM::REC_INTERNAL_PLAYER:
{

View file

@ -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();

View file

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

View file

@ -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;
}