1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2026-01-05 02:43:05 +00:00

Merge branch 'cecinestpasunetable' into 'master'

Don't attempt to parse table-like objects as ignore lists

Closes #8775

See merge request OpenMW/openmw!4974
This commit is contained in:
Alexei Kotov 2025-11-03 07:11:06 +03:00
commit 7c0702a71c
2 changed files with 19 additions and 10 deletions

View file

@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...")
set(OPENMW_VERSION_MAJOR 0)
set(OPENMW_VERSION_MINOR 51)
set(OPENMW_VERSION_RELEASE 0)
set(OPENMW_LUA_API_REVISION 99)
set(OPENMW_LUA_API_REVISION 100)
set(OPENMW_POSTPROCESSING_API_REVISION 3)
set(OPENMW_VERSION_COMMITHASH "")

View file

@ -26,18 +26,27 @@ namespace
{
std::vector<T> ignore;
if (const auto& ignoreObj = options.get<sol::optional<MWLua::LObject>>("ignore"))
if (const auto& ignoreObj = options.get<sol::optional<sol::object>>("ignore"))
{
ignore.push_back(ignoreObj->ptr());
}
else if (const auto& ignoreTable = options.get<sol::optional<sol::table>>("ignore"))
{
ignoreTable->for_each([&](const auto& _, const sol::object& value) {
if (value.is<MWLua::LObject>())
if (ignoreObj->is<MWLua::LObject>())
ignore.push_back(ignoreObj->as<MWLua::LObject>().ptr());
else if (ignoreObj->is<MWLua::LObjectList>())
{
for (const MWLua::ObjectId& id : *ignoreObj->as<MWLua::LObjectList>().mIds)
{
ignore.push_back(value.as<MWLua::LObject>().ptr());
ignore.push_back(MWLua::LObject(id).ptr());
}
});
}
else
{
// ignoreObj->as throws if the type doesn't match, but an unchecked value.as crashes...
ignoreObj->as<sol::lua_table>().for_each([&](sol::object _, sol::object value) {
if (value.is<MWLua::LObject>())
ignore.push_back(value.as<MWLua::LObject>().ptr());
else
throw std::runtime_error("Table value is not a GameObject");
});
}
}
return ignore;