Skip to content

Commit

Permalink
Editor/Action Village: cleaned up some messy code @GregoryLundberg po…
Browse files Browse the repository at this point in the history
…inted out

Also fixes the issue brought up in #2111.
  • Loading branch information
Vultraz authored and GregoryLundberg committed Nov 30, 2017
1 parent 17f8598 commit d204f8f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/editor/action/action_village.cpp
Expand Up @@ -29,20 +29,21 @@ IMPLEMENT_ACTION(village)

editor_action* editor_action_village::perform(map_context& mc) const
{
editor_action_ptr undo;

if(!mc.get_map().is_village(loc_)) {
return nullptr;
}

std::vector<team>& teams = mc.get_teams();

team* t = unsigned(side_number_) < teams.size() ? &teams[side_number_] : nullptr;
if(t && t->owns_village(loc_)) {
return nullptr;
try {
if(teams.at(side_number_).owns_village(loc_)) {
return nullptr;
}
} catch(const std::out_of_range&) {
// side_number_ was an invalid team index.
}

undo.reset(new editor_action_village_delete(loc_));
editor_action_ptr undo(new editor_action_village_delete(loc_));

for(const team& t : teams) {
if(t.owns_village(loc_)) {
Expand Down

0 comments on commit d204f8f

Please sign in to comment.