This commit is contained in:
gfgtdf 2018-10-21 16:08:45 +02:00
parent eee9214e9a
commit 0830d776ec
4 changed files with 10 additions and 11 deletions

View file

@ -209,7 +209,8 @@ std::string gamemap::write() const
void gamemap::overlay(const gamemap& m, map_location loc, const std::vector<overlay_rule>& rules, bool m_is_odd, bool ignore_special_locations)
{
overlay_impl(tiles_, starting_positions_, m.tiles_, m.starting_positions_, [this](auto&&... arg) { set_terrain(std::forward<decltype(arg)>(arg)...); }, loc, rules, m_is_odd, ignore_special_locations);
//the following line doesn't compile on all compiler without the 'this->'
overlay_impl(tiles_, starting_positions_, m.tiles_, m.starting_positions_, [this](auto&&... arg) { this->set_terrain(std::forward<decltype(arg)>(arg)...); }, loc, rules, m_is_odd, ignore_special_locations);
}
void gamemap::overlay_impl(

View file

@ -112,9 +112,9 @@ public:
static void overlay_impl(
// const but changed via set_terrain
const t_translation::ter_map& m1,
starting_positions& m1_st,
t_translation::starting_positions& m1_st,
const t_translation::ter_map& m2,
const starting_positions& m2_st,
const t_translation::starting_positions& m2_st,
std::function<void (const map_location&, const t_translation::terrain_code&, terrain_type_data::merge_mode, bool)> set_terrain,
map_location loc,
const std::vector<overlay_rule>& rules,

View file

@ -348,7 +348,7 @@ static std::vector<gamemap::overlay_rule> read_rules_vector(lua_State *L, int in
{
lua_rawgeti(L, index, i);
if(!lua_istable(L, -1)) {
return luaL_argerror(L, index, "rules must be a table of tables");
luaL_argerror(L, index, "rules must be a table of tables");
}
rules.push_back(gamemap::overlay_rule());
auto& rule = rules.back();
@ -398,11 +398,11 @@ static std::vector<gamemap::overlay_rule> read_rules_vector(lua_State *L, int in
* - ignore_special_locations: boolean
* - rules: table of tables
*/
static int intf_mg_terrain_mask(lua_State *L)
int mapgen_gamemap::intf_mg_terrain_mask(lua_State *L)
{
mapgen_gamemap& tm1 = luaW_checkterrainmap(L, 1);
map_location loc = luaW_checklocation(L, 2);
mapgen_gamemap& tm1 = luaW_checkterrainmap(L, 3);
mapgen_gamemap& tm2 = luaW_checkterrainmap(L, 3);
bool is_odd = false;
bool ignore_special_locations = false;
@ -416,13 +416,11 @@ static int intf_mg_terrain_mask(lua_State *L)
if(!lua_istable(L, -1)) {
return luaL_argerror(L, 4, "rules must be a table");
}
rules = read_rules_vector(L, -1)
rules = read_rules_vector(L, -1);
lua_pop(L, 1);
}
}
board().map_->overlay(mask_map, loc, rules, is_odd, ignore_special_locations);
gamemap::overlay_impl(
tm1.tiles_,
tm1.starting_positions_,
@ -463,7 +461,7 @@ namespace lua_terrainmap {
lua_setfield(L, -2, "get_locations");
lua_pushcfunction(L, intf_mg_get_tiles_radius);
lua_setfield(L, -2, "get_tiles_radius");
lua_pushcfunction(L, intf_mg_terrain_mask);
lua_pushcfunction(L, &mapgen_gamemap::intf_mg_terrain_mask);
lua_setfield(L, -2, "terrain_mask");
cmd_out << "Adding terrainmamap2 metatable...\n";

View file

@ -88,7 +88,7 @@ public:
}
}
}
friend int intf_terrain_mask(lua_State *L);
static int intf_mg_terrain_mask(lua_State *L);
private:
t_translation::ter_map tiles_;
starting_positions starting_positions_;