mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 12:39:59 +00:00
Handle zero length Lua storage files more gracefully (#7823)
This commit is contained in:
parent
d7257e056c
commit
6515fdd73f
@ -154,6 +154,7 @@
|
|||||||
Bug #7785: OpenMW-CS initialising Skill and Attribute fields to 0 instead of -1 on non-FortifyStat spells
|
Bug #7785: OpenMW-CS initialising Skill and Attribute fields to 0 instead of -1 on non-FortifyStat spells
|
||||||
Bug #7794: Fleeing NPCs name tooltip doesn't appear
|
Bug #7794: Fleeing NPCs name tooltip doesn't appear
|
||||||
Bug #7796: Absorbed enchantments don't restore magicka
|
Bug #7796: Absorbed enchantments don't restore magicka
|
||||||
|
Bug #7823: Game crashes when launching it.
|
||||||
Bug #7832: Ingredient tooltips show magnitude for Fortify Maximum Magicka effect
|
Bug #7832: Ingredient tooltips show magnitude for Fortify Maximum Magicka effect
|
||||||
Bug #7840: First run of the launcher doesn't save viewing distance as the default value
|
Bug #7840: First run of the launcher doesn't save viewing distance as the default value
|
||||||
Bug #7841: Editor: "Dirty" water heights are saved in modified CELLs
|
Bug #7841: Editor: "Dirty" water heights are saved in modified CELLs
|
||||||
|
@ -239,8 +239,11 @@ namespace LuaUtil
|
|||||||
assert(mData.empty()); // Shouldn't be used before loading
|
assert(mData.empty()); // Shouldn't be used before loading
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log(Debug::Info) << "Loading Lua storage \"" << path << "\" (" << std::filesystem::file_size(path)
|
std::uintmax_t fileSize = std::filesystem::file_size(path);
|
||||||
<< " bytes)";
|
Log(Debug::Info) << "Loading Lua storage \"" << path << "\" (" << fileSize << " bytes)";
|
||||||
|
if (fileSize == 0)
|
||||||
|
throw std::runtime_error("Storage file has zero length");
|
||||||
|
|
||||||
std::ifstream fin(path, std::fstream::binary);
|
std::ifstream fin(path, std::fstream::binary);
|
||||||
std::string serializedData((std::istreambuf_iterator<char>(fin)), std::istreambuf_iterator<char>());
|
std::string serializedData((std::istreambuf_iterator<char>(fin)), std::istreambuf_iterator<char>());
|
||||||
sol::table data = deserialize(mLua, serializedData);
|
sol::table data = deserialize(mLua, serializedData);
|
||||||
@ -253,7 +256,7 @@ namespace LuaUtil
|
|||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
Log(Debug::Error) << "Can not read \"" << path << "\": " << e.what();
|
Log(Debug::Error) << "Cannot read \"" << path << "\": " << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user