diff --git a/editor/region.cpp b/editor/region.cpp index ec320f5..ab59971 100644 --- a/editor/region.cpp +++ b/editor/region.cpp @@ -59,9 +59,6 @@ bool Region::NewTileR(Tile const& tile) { } Tile Region::GetTileR(int tx, int ty, int tw, int th, int minDepth) { - //find the first tile at this location, with the specified minimum depth - //since neither the Region or Tile classes store the tile sizes, - //this function takes the sizes as arguments std::set::iterator ptr = tiles.begin(); while(ptr != tiles.end()) { //skip the tiles that are too deep @@ -80,13 +77,17 @@ Tile Region::GetTileR(int tx, int ty, int tw, int th, int minDepth) { if (ptr != tiles.end()) { return *ptr; } - return {0,0,0,-1}; //value = -1 is a crappy error code + return {0,0,0,-1}; //TODO: value = -1 is a crappy error code } bool Region::DeleteTileR(Tile const& tile) { if (!InBoundsR(tile.x, tile.y)) { throw(std::runtime_error("Deleted tile location out of bounds")); } + //sentinel + if (tile.value == -1) { + return 0; + } return tiles.erase(tile); } diff --git a/editor/region.hpp b/editor/region.hpp index 5897577..5c17001 100644 --- a/editor/region.hpp +++ b/editor/region.hpp @@ -89,7 +89,7 @@ public: friend bool operator>(Region const& lhs, Region const& rhs); friend bool operator==(Region const& lhs, Region const& rhs); -private: +public: //TMP int const x; int const y; int const width; diff --git a/editor/tile.hpp b/editor/tile.hpp index a07d393..1e362e8 100644 --- a/editor/tile.hpp +++ b/editor/tile.hpp @@ -29,10 +29,10 @@ struct Tile { Tile() = default; Tile(int i, int j, int k, int l) : x(i), y(j), depth(k), value(l) {} - - friend bool operator<(Tile const& lhs, Tile const& rhs); - friend bool operator>(Tile const& lhs, Tile const& rhs); - friend bool operator==(Tile const& lhs, Tile const& rhs); }; +bool operator<(Tile const& lhs, Tile const& rhs); +bool operator>(Tile const& lhs, Tile const& rhs); +bool operator==(Tile const& lhs, Tile const& rhs); + #endif