Skip to content

Commit

Permalink
fix villages after terrain_mask
Browse files Browse the repository at this point in the history
(cherry-picked from commit 6cd9de1)
  • Loading branch information
gfgtdf committed Oct 7, 2018
1 parent 6a10e12 commit e4c170f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/scripting/game_lua_kernel.cpp
Expand Up @@ -1110,10 +1110,14 @@ int game_lua_kernel::intf_terrain_mask(lua_State *L)
}


gamemap mask_map(resources::gameboard->map().tdata(), "");
gamemap mask_map(board().map().tdata(), "");
mask_map.read(t_str, false);
board().map_->overlay(mask_map, loc, rules, is_odd, ignore_special_locations);

for(team& t : board().teams()) {
t.fix_villages(board().map());
}

if (game_display_) {
game_display_->needs_rebuild(true);
}
Expand Down
12 changes: 12 additions & 0 deletions src/team.cpp
Expand Up @@ -422,6 +422,18 @@ void team::write(config& cfg) const
cfg["action_bonus_count"] = action_bonus_count_;
}

void team::fix_villages(const gamemap &map)
{
for (auto it = villages_.begin(); it != villages_.end(); ) {
if (map.is_village(*it)) {
++it;
}
else {
it = villages_.erase(it);
}
}
}

game_events::pump_result_t team::get_village(const map_location& loc, const int owner_side, game_data* gamedata)
{
villages_.insert(loc);
Expand Down
1 change: 1 addition & 0 deletions src/team.hpp
Expand Up @@ -177,6 +177,7 @@ class team

void write(config& cfg) const;

void fix_villages(const gamemap &map);
game_events::pump_result_t get_village(const map_location&, const int owner_side, game_data * fire_event); //!< Acquires a village from owner_side. Pointer fire_event should be the game_data for the game if it is desired to fire an event -- a "capture" event with owner_side variable scoped in will be fired. For no event, pass it nullptr. Default is the resources::gamedata pointer
void lose_village(const map_location&);
void clear_villages() { villages_.clear(); }
Expand Down

0 comments on commit e4c170f

Please sign in to comment.