mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-16 18:31:32 +00:00
make lua require use our filesystem functions
previously only lua dofile did this.
This commit is contained in:
parent
f126846be2
commit
77fb3852f9
@ -1183,6 +1183,22 @@ static int intf_require(lua_State *L)
|
||||
return luaL_argerror(L, 1, "file not found");
|
||||
|
||||
// Compile the file.
|
||||
|
||||
#if 1
|
||||
try
|
||||
{
|
||||
if(lua_filestream::lua_loadfile(L, p))
|
||||
throw game::error(lua_tostring(L, -1));
|
||||
}
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
chat_message("Lua error", ex.what());
|
||||
ERR_LUA << ex.what() << '\n';
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
//oldcode to be deleted if newcode works
|
||||
|
||||
int res = luaL_loadfile(L, p.c_str());
|
||||
if (res)
|
||||
{
|
||||
@ -1191,6 +1207,7 @@ static int intf_require(lua_State *L)
|
||||
ERR_LUA << m << '\n';
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Execute it.
|
||||
if (!luaW_pcall(L, 0, 1)) return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user