From 37c0ccafa3bec08592a78b6fc1b77d25e45311f8 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 2 May 2017 22:23:46 -0400 Subject: [PATCH] Allow wesnoth.dofile to forward arbitrary arguments to the file's "..." --- src/scripting/lua_kernel_base.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scripting/lua_kernel_base.cpp b/src/scripting/lua_kernel_base.cpp index 241a1e6c9f67..fb13e8147657 100644 --- a/src/scripting/lua_kernel_base.cpp +++ b/src/scripting/lua_kernel_base.cpp @@ -615,11 +615,13 @@ void lua_kernel_base::interactive_run(char const * prog) { */ int lua_kernel_base::intf_dofile(lua_State* L) { + lua_rotate(L, 1, -1); if (lua_fileops::load_file(L) != 1) return 0; //^ should end with the file contents loaded on the stack. actually it will call lua_error otherwise, the return 0 is redundant. error_handler eh = std::bind(&lua_kernel_base::log_error, this, _1, _2 ); - this->protected_call(0, LUA_MULTRET, eh); + lua_rotate(L, 1, 1); + this->protected_call(lua_gettop(L) - 1, LUA_MULTRET, eh); return lua_gettop(L); }