mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Use LuaUtil::cast for casting sol::object to prevent crashing on type mismatch in Lua scripts.
This commit is contained in:
parent
61578ca39b
commit
c362b2efa6
12 changed files with 48 additions and 46 deletions
|
@ -85,7 +85,7 @@ namespace LuaUtil
|
|||
if (values)
|
||||
{
|
||||
for (const auto& [k, v] : *values)
|
||||
mValues[k.as<std::string>()] = Value(v);
|
||||
mValues[cast<std::string>(k)] = Value(v);
|
||||
}
|
||||
if (mStorage->mListener)
|
||||
mStorage->mListener->sectionReplaced(mSectionName, values);
|
||||
|
@ -166,9 +166,9 @@ namespace LuaUtil
|
|||
sol::table data = deserialize(mLua, serializedData);
|
||||
for (const auto& [sectionName, sectionTable] : data)
|
||||
{
|
||||
const std::shared_ptr<Section>& section = getSection(sectionName.as<std::string_view>());
|
||||
for (const auto& [key, value] : sol::table(sectionTable))
|
||||
section->set(key.as<std::string_view>(), value);
|
||||
const std::shared_ptr<Section>& section = getSection(cast<std::string_view>(sectionName));
|
||||
for (const auto& [key, value] : cast<sol::table>(sectionTable))
|
||||
section->set(cast<std::string_view>(key), value);
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue