diff options
Diffstat (limited to 'sigmod/MapWarp.cpp')
| -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); |
