Skip to content

Commit

Permalink
remove map::operator[](int)
Browse files Browse the repository at this point in the history
this operator was confusing because usingn map[i][j] would mean that the
border_size is added to x but not to y, It is better to use
operator[](map_location) or to use tiles_[x][y] directly so that this
issue doesn't appear.
  • Loading branch information
gfgtdf committed Mar 14, 2016
1 parent bf2ec4d commit f1052b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/map.cpp
Expand Up @@ -340,8 +340,8 @@ void gamemap::overlay(const gamemap& m, const config& rules_cfg, int xpos, int y
const int x2 = x1 + xpos;
const int y2 = y1 + ypos + ((xpos & 1) && (x1 & 1) ? 1 : 0);

const t_translation::t_terrain t = m[x1][y1 + m.border_size_];
const t_translation::t_terrain current = (*this)[x2][y2 + border_size_];
const t_translation::t_terrain t = m.tiles_[x1 + m.border_size_][y1 + m.border_size_];
const t_translation::t_terrain current = tiles_[x2 + border_size_][y2 + border_size_];

if(t == t_translation::FOGGED || t == t_translation::VOID_TERRAIN) {
continue;
Expand Down Expand Up @@ -545,7 +545,7 @@ const std::map<t_translation::t_terrain, size_t>& gamemap::get_weighted_terrain_
for(size_t i = 0; i != size_t(w()); ++i) {
for(size_t j = 0; j != size_t(h()); ++j) {
const size_t distance = distance_between(map_location(i,j),center);
terrainFrequencyCache_[(*this)[i][j]] += weight_at_edge +
terrainFrequencyCache_[tiles_[i + border_size_][j]] += weight_at_edge +
(furthest_distance-distance)*additional_weight_at_center;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/map.hpp
Expand Up @@ -226,8 +226,8 @@ class gamemap
{ return sizeof(startingPositions_)/sizeof(*startingPositions_); }

/** Allows lookup of terrain at a particular location. */
const t_translation::t_list operator[](int index) const
{ return tiles_[index + border_size_]; }
//const t_translation::t_list operator[](int index) const
// { return tiles_[index + border_size_]; }


tdata_cache tdata_;
Expand Down

0 comments on commit f1052b0

Please sign in to comment.