diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-07-19 15:09:51 -0400 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-07-19 15:09:51 -0400 |
| commit | 4979294d0a40dd52f65e1c25ed00891c02112aca (patch) | |
| tree | b43c9ea14959036a5eba5f2235832692592648f7 | |
| parent | 220d83da8361ac3a46d3ee057de428669f0d9c84 (diff) | |
| download | sigen-4979294d0a40dd52f65e1c25ed00891c02112aca.tar.gz sigen-4979294d0a40dd52f65e1c25ed00891c02112aca.tar.xz sigen-4979294d0a40dd52f65e1c25ed00891c02112aca.zip | |
Area can fail, add checks for them
| -rw-r--r-- | sigmod/MapWarp.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sigmod/MapWarp.cpp b/sigmod/MapWarp.cpp index 214a1eb7..f02d300d 100644 --- a/sigmod/MapWarp.cpp +++ b/sigmod/MapWarp.cpp @@ -66,6 +66,7 @@ void MapWarp::validate() if (m_name.isEmpty()) emit(error("Name is empty")); TEST(position); + TEST(area); TEST(toMap); TEST(toWarp); TEST_END(); @@ -114,7 +115,19 @@ CHECK_BEGIN(MapWarp, QPoint&, position) TBOUNDS_MOD(position_x, 0, map->width() - 1, position.x()) TBOUNDS_MOD(position_y, 0, map->height() - 1, position.y()) CHECK_END() -CHECK(MapWarp, QPainterPath&, area) +CHECK_BEGIN(MapWarp, QPainterPath&, area) + if (area.isEmpty()) + { + ERROR("Warp has no area"); + return false; + } + const Map* map = qobject_cast<const Map*>(parent()); + if (!area.intersects(QRect(-m_position.x(), -m_position.y(), map->width(), map->height()))) + { + ERROR("Warp is not inside the map"); + return false; + } +CHECK_END() CHECK_INDEX(MapWarp, int, toMap, game(), map) CHECK_BEGIN(MapWarp, int, toWarp) const Map* map = game()->mapById(m_toMap); |
