From 891299dc9f76dbad7f182af68f548d8b61d509ab Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 22 Feb 2021 22:31:37 -0500 Subject: [PATCH] Enable find() and matches() to be called as map methods --- src/scripting/game_lua_kernel.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/scripting/game_lua_kernel.cpp b/src/scripting/game_lua_kernel.cpp index 5405e3ea263b6..640dfa1d14547 100644 --- a/src/scripting/game_lua_kernel.cpp +++ b/src/scripting/game_lua_kernel.cpp @@ -2743,6 +2743,14 @@ static int intf_do_unsynced(lua_State *L) */ int game_lua_kernel::intf_get_locations(lua_State *L) { + if(luaW_isterrainmap(L, 1)) { + auto& map = luaW_checkterrainmap(L, 1); + if(auto gm = dynamic_cast(&map); gm != &game_state_.get_disp_context().map()) { + return luaL_error(L, "Filters are currently only supported on the active game map"); + } + lua_remove(L, 1); + } + vconfig filter = luaW_checkvconfig(L, 1); std::set res; @@ -2807,6 +2815,14 @@ int game_lua_kernel::intf_get_villages(lua_State *L) */ int game_lua_kernel::intf_match_location(lua_State *L) { + if(luaW_isterrainmap(L, 1)) { + auto& map = luaW_checkterrainmap(L, 1); + if(auto gm = dynamic_cast(&map); gm != &game_state_.get_disp_context().map()) { + return luaL_error(L, "Filters are currently only supported on the active game map"); + } + lua_remove(L, 1); + } + map_location loc = luaW_checklocation(L, 1); vconfig filter = luaW_checkvconfig(L, 2, true);