summaryrefslogtreecommitdiffstats
path: root/pokemod/Tile.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/Tile.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/Tile.cpp')
-rw-r--r--pokemod/Tile.cpp107
1 files changed, 54 insertions, 53 deletions
diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp
index 833e7f78..c6e346cb 100644
--- a/pokemod/Tile.cpp
+++ b/pokemod/Tile.cpp
@@ -15,25 +15,25 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QBuffer>
+// Header include
+#include "Tile.h"
// Pokemod includes
#include "Pokemod.h"
-// Header include
-#include "Tile.h"
+// Qt includes
+#include <QBuffer>
const QStringList Tile::ForceStr = QStringList() << "Slip" << "Stop" << "Force" << "Push";
Tile::Tile(const Tile& tile) :
- Object("Tile", tile.pokemod(), tile.id())
+ Object("Tile", tile.parent(), tile.id())
{
*this = tile;
}
-Tile::Tile(const Pokemod* pokemod, const int id) :
- Object("Tile", pokemod, id),
+Tile::Tile(const Object* parent, const int id) :
+ Object("Tile", parent, id),
m_name(""),
m_sprite(64, 64),
m_wildChance(1, 1),
@@ -46,61 +46,62 @@ Tile::Tile(const Pokemod* pokemod, const int id) :
m_from[i] = false;
}
-Tile::Tile(const Tile& tile, const Pokemod* pokemod, const int id) :
- Object("Tile", pokemod, id)
+Tile::Tile(const Tile& tile, const Object* parent, const int id) :
+ Object("Tile", parent, id)
{
*this = tile;
}
-Tile::Tile(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Tile", pokemod, id)
+Tile::Tile(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Tile", parent, id)
{
load(xml, id);
}
bool Tile::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Tile \"%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_hmType == Pokemod::HM_Waterfall) && (!m_from[Pokemod::D_Up] || !m_from[Pokemod::D_Down]))
- {
- pokemod()->validationMsg("A waterfall tile must be accessible from above and below");
- valid = false;
- }
- else if ((m_hmType == Pokemod::HM_Whirlpool) && ((m_under == id()) || (pokemod()->tileIndex(m_under) == INT_MAX) || (pokemod()->tileById(m_under)->hmType() != Pokemod::HM_Surf) || (pokemod()->tileById(m_under)->hmType() != Pokemod::HM_Dive)))
- {
- pokemod()->validationMsg("Invalid under tile");
- valid = false;
- }
- else if ((m_hmType == Pokemod::HM_Whirlpool) && ((m_under == id()) || (pokemod()->tileIndex(m_under) == INT_MAX) || (pokemod()->tileById(m_under)->hmType() != Pokemod::HM_End)))
- {
- pokemod()->validationMsg("Invalid under tile");
- valid = false;
- }
- else if ((m_hmType == Pokemod::HM_RockClimb) && (!m_from[Pokemod::D_Up] || !m_from[Pokemod::D_Down]))
- {
- pokemod()->validationMsg("A rock climb tile must be accessible from above and below");
- valid = false;
- }
- if (m_forceType < End)
- {
- if (((m_forceType == Slip) || (m_forceType == Force) || (m_forceType == Push)) && (Pokemod::D_End <= m_forceDirection))
- {
- pokemod()->validationMsg("Invalid force direction");
- valid = false;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid force type");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Tile \"%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_hmType == Pokemod::HM_Waterfall) && (!m_from[Pokemod::D_Up] || !m_from[Pokemod::D_Down]))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("A waterfall tile must be accessible from above and below");
+// valid = false;
+// }
+// else if ((m_hmType == Pokemod::HM_Whirlpool) && ((m_under == id()) || (static_cast<const Pokemod*>(pokemod())->tileIndex(m_under) == INT_MAX) || (static_cast<const Pokemod*>(pokemod())->tileById(m_under)->hmType() != Pokemod::HM_Surf) || (static_cast<const Pokemod*>(pokemod())->tileById(m_under)->hmType() != Pokemod::HM_Dive)))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid under tile");
+// valid = false;
+// }
+// else if ((m_hmType == Pokemod::HM_Whirlpool) && ((m_under == id()) || (static_cast<const Pokemod*>(pokemod())->tileIndex(m_under) == INT_MAX) || (static_cast<const Pokemod*>(pokemod())->tileById(m_under)->hmType() != Pokemod::HM_End)))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid under tile");
+// valid = false;
+// }
+// else if ((m_hmType == Pokemod::HM_RockClimb) && (!m_from[Pokemod::D_Up] || !m_from[Pokemod::D_Down]))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("A rock climb tile must be accessible from above and below");
+// valid = false;
+// }
+// if (m_forceType < End)
+// {
+// if (((m_forceType == Slip) || (m_forceType == Force) || (m_forceType == Push)) && (Pokemod::D_End <= m_forceDirection))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid force direction");
+// valid = false;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid force type");
+// valid = false;
+// }
+// return valid;
}
void Tile::load(const QDomElement& xml, int id)
@@ -170,7 +171,7 @@ void Tile::setUnder(const int under) throw(Exception)
{
if ((m_hmType != Pokemod::HM_Whirlpool) || (m_hmType != Pokemod::HM_Cut) || (m_hmType != Pokemod::HM_RockSmash))
error<UnusedException>("under");
- if ((under == id()) || (pokemod()->tileIndex(under) == INT_MAX))
+ if ((under == id()) || (static_cast<const Pokemod*>(pokemod())->tileIndex(under) == INT_MAX))
error<BoundsException>("under");
}
m_under = under;