Skip to content

Commit

Permalink
pre-empty a division by zero
Browse files Browse the repository at this point in the history
(whether or not it's actually possible based on other
considerations, this is a good idea)
  • Loading branch information
cbeck88 committed May 20, 2014
1 parent 987e34a commit aa83190
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/editor/map/map_fragment.cpp
Expand Up @@ -83,8 +83,10 @@ map_location map_fragment::center_of_mass() const
BOOST_FOREACH(const tile_info& ti, items_) {
sum.vector_sum_assign(ti.offset);
}
sum.x /= static_cast<int>(items_.size());
sum.y /= static_cast<int>(items_.size());
if (items_.size() > 0) {
sum.x /= static_cast<int>(items_.size());
sum.y /= static_cast<int>(items_.size());
}
return sum;
}

Expand Down

0 comments on commit aa83190

Please sign in to comment.