summaryrefslogtreecommitdiffstats
path: root/pokemod/MapWarp.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
commit807071d35159de0660f9df31c48d5bf895ca3622 (patch)
treea1e9dbdc1e58b91cd2e4a5e472597b0204ccb41d /pokemod/MapWarp.cpp
parentf444f5a45e9325644a360f656176d47d7f540f52 (diff)
[FIX] Pokemod objects now know about parents
[FIX] Project includes are now relative [FIX] Headers included for better detection of invalid headers [FIX] Validation code commented out so it can be done better git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@111 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/MapWarp.cpp')
-rw-r--r--pokemod/MapWarp.cpp117
1 files changed, 60 insertions, 57 deletions
diff --git a/pokemod/MapWarp.cpp b/pokemod/MapWarp.cpp
index 0dc045e9..15e6ee38 100644
--- a/pokemod/MapWarp.cpp
+++ b/pokemod/MapWarp.cpp
@@ -15,24 +15,24 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Header include
+#include "MapWarp.h"
+
// Pokemod includes
-#include "Pokemod.h"
#include "Dialog.h"
#include "Map.h"
-
-// Header include
-#include "MapWarp.h"
+#include "Pokemod.h"
const QStringList MapWarp::TypeStr = QStringList() << "Door/Stair" << "Warp Pad" << "Hole" << "Boundary";
MapWarp::MapWarp(const MapWarp& warp) :
- Object("MapWarp", warp.pokemod(), warp.id())
+ Object("MapWarp", warp.parent(), warp.id())
{
*this = warp;
}
-MapWarp::MapWarp(const Pokemod* pokemod, const int id) :
- Object("MapWarp", pokemod, id),
+MapWarp::MapWarp(const Object* parent, const int id) :
+ Object("MapWarp", parent, id),
m_name(""),
m_coordinate(0, 0),
m_directionOut(INT_MAX),
@@ -49,61 +49,62 @@ MapWarp::MapWarp(const Pokemod* pokemod, const int id) :
m_from[i] = false;
}
-MapWarp::MapWarp(const MapWarp& warp, const Pokemod* pokemod, const int id) :
- Object("MapWarp", pokemod, id)
+MapWarp::MapWarp(const MapWarp& warp, const Object* parent, const int id) :
+ Object("MapWarp", parent, id)
{
*this = warp;
}
-MapWarp::MapWarp(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MapWarp", pokemod, id)
+MapWarp::MapWarp(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MapWarp", parent, id)
{
load(xml, id);
}
bool MapWarp::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Warp \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- if (!m_from[Pokemod::D_Up] && !m_from[Pokemod::D_Down] && !m_from[Pokemod::D_Left] && !m_from[Pokemod::D_Right])
- {
- pokemod()->validationMsg("No access from any direction");
- valid = false;
- }
- if (Pokemod::D_End_None <= m_directionOut)
- {
- pokemod()->validationMsg("Invalid direction out");
- valid = false;
- }
- if (End <= m_warpType)
- {
- pokemod()->validationMsg("Invalid type");
- valid = false;
- }
- if (pokemod()->mapIndex(m_toMap) != INT_MAX)
- {
- if (pokemod()->mapById(m_toMap)->warpIndex(m_toWarp) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid destination warp");
- valid = false;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid destination map");
- valid = false;
- }
- if (pokemod()->dialogIndex(m_dialog) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid dialog");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Warp \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// if (!m_from[Pokemod::D_Up] && !m_from[Pokemod::D_Down] && !m_from[Pokemod::D_Left] && !m_from[Pokemod::D_Right])
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("No access from any direction");
+// valid = false;
+// }
+// if (Pokemod::D_End_None <= m_directionOut)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid direction out");
+// valid = false;
+// }
+// if (End <= m_warpType)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid type");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->mapIndex(m_toMap) != INT_MAX)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->mapById(m_toMap)->warpIndex(m_toWarp) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid destination warp");
+// valid = false;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid destination map");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->dialogIndex(m_dialog) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid dialog");
+// valid = false;
+// }
+// return valid;
}
void MapWarp::load(const QDomElement& xml, int id)
@@ -146,8 +147,10 @@ void MapWarp::setName(const QString& name)
m_name = name;
}
-void MapWarp::setCoordinate(const Point& coordinate)
+void MapWarp::setCoordinate(const Point& coordinate) throw(BoundsException)
{
+ if ((static_cast<const Map*>(parent())->width() <= coordinate.x()) || (static_cast<const Map*>(parent())->height() <= coordinate.y()))
+ error<BoundsException>("coordinate");
m_coordinate = coordinate;
}
@@ -195,7 +198,7 @@ void MapWarp::setIsFoggy(const int isFoggy) throw(BoundsException)
void MapWarp::setToMap(const int toMap) throw(BoundsException)
{
- if (pokemod()->mapIndex(toMap) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->mapIndex(toMap) == INT_MAX)
error<BoundsException>("toMap");
m_toMap = toMap;
m_toWarp = INT_MAX;
@@ -203,9 +206,9 @@ void MapWarp::setToMap(const int toMap) throw(BoundsException)
void MapWarp::setToWarp(const int toWarp) throw(BoundsException)
{
- if (pokemod()->mapIndex(m_toMap) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->mapIndex(m_toMap) == INT_MAX)
error<BoundsException>("toMap");
- if (pokemod()->mapById(m_toMap)->warpIndex(toWarp) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->mapById(m_toMap)->warpIndex(toWarp) == INT_MAX)
error<BoundsException>("toWarp");
m_toWarp = toWarp;
}
@@ -217,7 +220,7 @@ void MapWarp::setWorkingFlag(const Flag& workingFlag)
void MapWarp::setDialog(const int dialog) throw(BoundsException)
{
- if (pokemod()->dialogIndex(dialog) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->dialogIndex(dialog) == INT_MAX)
error<BoundsException>("dialog");
m_dialog = dialog;
}