diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-12-26 12:02:02 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-12-26 12:02:02 -0500 |
| commit | c6485efcd6745c00f90f8cc507f582f2bbf3f106 (patch) | |
| tree | 2064983d5279ef94b52e3bcd89527b3ff35f1496 /sigmod/MapTile.cpp | |
| parent | 5ad38938406c8a77bd2f83d5fccc84f3cd6e16bb (diff) | |
| download | sigen-c6485efcd6745c00f90f8cc507f582f2bbf3f106.tar.gz sigen-c6485efcd6745c00f90f8cc507f582f2bbf3f106.tar.xz sigen-c6485efcd6745c00f90f8cc507f582f2bbf3f106.zip | |
Added checks to more classes
Diffstat (limited to 'sigmod/MapTile.cpp')
| -rw-r--r-- | sigmod/MapTile.cpp | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/sigmod/MapTile.cpp b/sigmod/MapTile.cpp index c407c5e2..d09f03db 100644 --- a/sigmod/MapTile.cpp +++ b/sigmod/MapTile.cpp @@ -58,8 +58,8 @@ Sigmod::MapTile::~MapTile() void Sigmod::MapTile::validate() { TEST_BEGIN(); - TEST(setTile, tile); - TEST(setPosition, position); + TEST(tile); + TEST(position); TEST_END(); } @@ -80,42 +80,21 @@ QDomElement Sigmod::MapTile::save() const return xml; } -void Sigmod::MapTile::setTile(const int tile) -{ - if (!sigmod()->tileById(tile)) - emit(error(bounds("tile", tile))); - else - CHECK(tile); -} +SETTER(MapTile, int, Tile, tile) +SETTER(MapTile, QPoint&, Position, position) +SETTER(MapTile, int, ZIndex, zIndex) -void Sigmod::MapTile::setPosition(const QPoint& position) -{ - const Map* map = qobject_cast<const Map*>(parent()); - if ((position.x() < 0) || (position.y() < 0) || (map->width() <= position.x()) || (map->height() <= position.y())) - emit(error(bounds("position", QPoint(0, 0), QPoint(map->width(), map->height()), position))); - else - CHECK(position); -} +GETTER(MapTile, int, tile) +GETTER(MapTile, QPoint, position) +GETTER(MapTile, int, zIndex) -void Sigmod::MapTile::setZIndex(const int zIndex) -{ - CHECK(zIndex); -} - -int Sigmod::MapTile::tile() const -{ - return m_tile; -} - -QPoint Sigmod::MapTile::position() const -{ - return m_position; -} - -int Sigmod::MapTile::zIndex() const -{ - return m_zIndex; -} +CHECK_INDEX(MapTile, int, tile, sigmod(), tile) +CHECK_BEGIN(MapTile, QPoint&, position) + const Map* map = qobject_cast<const Map*>(parent()); + TBOUNDS_MOD(position, 0, map->width(), position.x()) + TBOUNDS_MOD(position, 0, map->height(), position.y()) +CHECK_END() +CHECK_DEFAULT(MapTile, int, zIndex) Sigmod::MapTile& Sigmod::MapTile::operator=(const MapTile& rhs) { |
