mirror of
https://github.com/OpenMW/openmw.git
synced 2025-11-09 22:26:41 +00:00
Type check the ignore list
This commit is contained in:
parent
3558f9c48b
commit
492716ee6b
1 changed files with 17 additions and 15 deletions
|
|
@ -26,25 +26,27 @@ namespace
|
||||||
{
|
{
|
||||||
std::vector<T> ignore;
|
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());
|
if (ignoreObj->is<MWLua::LObject>())
|
||||||
}
|
ignore.push_back(ignoreObj->as<MWLua::LObject>().ptr());
|
||||||
else if (const auto& ignoreList = options.get<sol::optional<MWLua::LObjectList>>("ignore"))
|
else if (ignoreObj->is<MWLua::LObjectList>())
|
||||||
{
|
|
||||||
for (const MWLua::ObjectId& id : *ignoreList->mIds)
|
|
||||||
{
|
{
|
||||||
ignore.push_back(MWLua::LObject(id).ptr());
|
for (const MWLua::ObjectId& id : *ignoreObj->as<MWLua::LObjectList>().mIds)
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (const auto& ignoreTable = options.get<sol::optional<sol::lua_table>>("ignore"))
|
|
||||||
{
|
|
||||||
ignoreTable->for_each([&](const auto& _, const sol::object& value) {
|
|
||||||
if (value.is<MWLua::LObject>())
|
|
||||||
{
|
{
|
||||||
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;
|
return ignore;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue