@@ -330,29 +330,31 @@ static std::string dfhack_version_desc()
330330 return s.str ();
331331}
332332
333- static bool init_run_script (color_ostream &out, lua_State *state, const std::string& pcmd, std::vector< std::string>& pargs)
333+ static bool init_run_script (color_ostream &out, lua_State *state, const std::string& pcmd, std::span< const std::string> pargs)
334334{
335335 if (!lua_checkstack (state, pargs.size ()+10 ))
336336 return false ;
337337 Lua::PushDFHack (state);
338338 lua_getfield (state, -1 , " run_script" );
339339 lua_remove (state, -2 );
340340 lua_pushstring (state, pcmd.c_str ());
341- for (auto & arg : pargs)
341+ for (const auto & arg : pargs)
342342 lua_pushstring (state, arg.c_str ());
343343 return true ;
344344}
345345
346- static command_result runLuaScript (color_ostream &out, std::string name, std::vector< std::string> & args)
346+ static command_result runLuaScript (color_ostream &out, std::string name, std::span< const std::string> args)
347347{
348- using namespace std ::placeholders;
349- auto init_fn = std::bind (init_run_script, _1, _2, name, args);
348+ auto init_fn = [n = std::move (name), args](color_ostream& out, lua_State* state) -> bool {
349+ return init_run_script (out, state, n, args);
350+ };
351+
350352 bool ok = Lua::RunCoreQueryLoop (out, DFHack::Core::getInstance ().getLuaState (true ), init_fn);
351353
352354 return ok ? CR_OK : CR_FAILURE;
353355}
354356
355- static bool init_enable_script (color_ostream &out, lua_State *state, std::string& name, bool enable)
357+ static bool init_enable_script (color_ostream &out, lua_State *state, const std::string& name, bool enable)
356358{
357359 if (!lua_checkstack (state, 4 ))
358360 return false ;
@@ -364,10 +366,12 @@ static bool init_enable_script(color_ostream &out, lua_State *state, std::string
364366 return true ;
365367}
366368
367- static command_result enableLuaScript (color_ostream &out, std::string name, bool state )
369+ static command_result enableLuaScript (color_ostream &out, std::string name, bool enabled )
368370{
369- using namespace std ::placeholders;
370- auto init_fn = std::bind (init_enable_script, _1, _2, name, state);
371+ auto init_fn = [n = std::move (name), enabled](color_ostream& out, lua_State* state) -> bool {
372+ return init_enable_script (out, state, n, enabled);
373+ };
374+
371375 bool ok = Lua::RunCoreQueryLoop (out, DFHack::Core::getInstance ().getLuaState (), init_fn);
372376
373377 return ok ? CR_OK : CR_FAILURE;
0 commit comments