Skip to content

Commit

Permalink
Fix vfs bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
Assumeru committed Sep 14, 2024
1 parent 1ac0f27 commit 2978b32
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/openmw/mwlua/vfsbindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ namespace MWLua
values.push_back(sol::make_object<std::string>(lua, msg));
}
else
values.push_back(sol::make_object<std::streampos>(lua, self.mFilePtr->tellg()));
{
// tellg returns std::streampos which is not required to be a numeric type. It is required to be
// convertible to std::streamoff which is a number
values.push_back(sol::make_object<std::streamoff>(lua, self.mFilePtr->tellg()));
}
}
catch (std::exception& e)
{
Expand Down Expand Up @@ -205,7 +209,7 @@ namespace MWLua
});
};

handle["close"] = [](lua_State* L, FileHandle& self) {
handle["close"] = [](sol::this_state lua, FileHandle& self) {
sol::variadic_results values;
try
{
Expand All @@ -214,16 +218,16 @@ namespace MWLua
{
auto msg = "Can not close file '" + self.mFileName + "': file handle is still opened.";
values.push_back(sol::nil);
values.push_back(sol::make_object<std::string>(L, msg));
values.push_back(sol::make_object<std::string>(lua, msg));
}
else
values.push_back(sol::make_object<bool>(L, true));
values.push_back(sol::make_object<bool>(lua, true));
}
catch (std::exception& e)
{
auto msg = "Can not close file '" + self.mFileName + "': " + std::string(e.what());
values.push_back(sol::nil);
values.push_back(sol::make_object<std::string>(L, msg));
values.push_back(sol::make_object<std::string>(lua, msg));
}

return values;
Expand Down

0 comments on commit 2978b32

Please sign in to comment.