Skip to content

Commit

Permalink
Enable find() and matches() to be called as map methods
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Feb 23, 2021
1 parent fa56006 commit 891299d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/scripting/game_lua_kernel.cpp
Expand Up @@ -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<gamemap*>(&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<map_location> res;
Expand Down Expand Up @@ -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<gamemap*>(&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);

Expand Down

0 comments on commit 891299d

Please sign in to comment.