summaryrefslogtreecommitdiffstats
path: root/pokemod/Map.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-05-03 10:45:40 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-05-03 10:45:40 +0000
commit8714e1d409f46b05980b3e1e9f3a10910294b429 (patch)
tree5d4931ed73a4947df329c6825474ddb902c465b8 /pokemod/Map.cpp
parent822b5fcaa34b78b9668a58680f9e0d89aa3fd7bd (diff)
downloadsigen-8714e1d409f46b05980b3e1e9f3a10910294b429.tar.gz
sigen-8714e1d409f46b05980b3e1e9f3a10910294b429.tar.xz
sigen-8714e1d409f46b05980b3e1e9f3a10910294b429.zip
[FIX] pokemod now uses signals/slots for errors and warnings
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@120 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Map.cpp')
-rw-r--r--pokemod/Map.cpp51
1 files changed, 23 insertions, 28 deletions
diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp
index 429b3d0f..db12de34 100644
--- a/pokemod/Map.cpp
+++ b/pokemod/Map.cpp
@@ -36,7 +36,7 @@ Map::Map(const Map& map) :
*this = map;
}
-Map::Map(const Object* parent, const int id) :
+Map::Map(const Pokemod* parent, const int id) :
Object("Map", parent, id),
m_name(""),
m_flyWarp(INT_MAX),
@@ -44,13 +44,13 @@ Map::Map(const Object* parent, const int id) :
{
}
-Map::Map(const Map& map, const Object* parent, const int id) :
+Map::Map(const Map& map, const Pokemod* parent, const int id) :
Object("Map", parent, id)
{
*this = map;
}
-Map::Map(const QDomElement& xml, const Object* parent, const int id) :
+Map::Map(const QDomElement& xml, const Pokemod* parent, const int id) :
Object("Map", parent, id)
{
load(xml, id);
@@ -61,69 +61,64 @@ Map::~Map()
clear();
}
-void Map::validate(QTextStream& stream)
+void Map::validate()
{
// TODO: validate that every tile that can have a wild encounter has a list to go along with it
- TEST_SETUP();
if (m_name.isEmpty())
- error(stream, "Name is empty");
+ emit(error("Name is empty"));
TEST(setFlyWarp, flyWarp);
TEST(setType, type);
TEST_MATRIX(setTile, tile);
QSet<int> idChecker;
QSet<QString> nameChecker;
if (!effectCount())
- warning(stream, "There are no effects");
+ emit(warning("There are no effects"));
foreach (MapEffect* effect, m_effects)
{
- if (!effect->isValid(stream))
- setValid(false);
+ effect->validate();
if (idChecker.contains(effect->id()))
- subclassError(stream, "effect", effect->id());
+ emit(error(subclass("effect", effect->id())));
idChecker.insert(effect->id());
if (nameChecker.contains(effect->name()))
- subclassError(stream, "effect", effect->name());
+ emit(error(subclass("effect", effect->name())));
nameChecker.insert(effect->name());
}
idChecker.clear();
nameChecker.clear();
if (!trainerCount())
- warning(stream, "There are no trainers");
+ emit(warning("There are no trainers"));
foreach (MapTrainer* trainer, m_trainers)
{
- if (!trainer->isValid(stream))
- setValid(false);
+ trainer->validate();
if (idChecker.contains(trainer->id()))
- subclassError(stream, "trainer", trainer->id());
+ emit(error(subclass("trainer", trainer->id())));
idChecker.insert(trainer->id());
if (nameChecker.contains(trainer->name()))
- subclassError(stream, "trainer", trainer->name());
+ emit(error(subclass("trainer", trainer->name())));
nameChecker.insert(trainer->name());
}
idChecker.clear();
nameChecker.clear();
if (!warpCount())
- error(stream, "There are no warps");
+ emit(error("There are no warps"));
foreach (MapWarp* warp, m_warps)
{
- if (!warp->isValid(stream))
- setValid(false);
+ warp->validate();
if (idChecker.contains(warp->id()))
- subclassError(stream, "warp", warp->id());
+ emit(error(subclass("warp", warp->id())));
idChecker.insert(warp->id());
if (nameChecker.contains(warp->name()))
- subclassError(stream, "warp", warp->name());
+ emit(error(subclass("warp", warp->name())));
nameChecker.insert(warp->name());
}
idChecker.clear();
if (!wildListCount())
- error(stream, "There are no wild lists");
+ emit(error("There are no wild lists"));
foreach (MapWildList* wildList, m_wildLists)
{
- if (!wildList->isValid(stream))
- setValid(false);
+ wildList->validate();
if (idChecker.contains(wildList->id()))
- subclassError(stream, "effect", wildList->id());
+ emit(error(subclass("effect", wildList->id())));
idChecker.insert(wildList->id());
}
}
@@ -164,7 +159,7 @@ void Map::setFlyWarp(const int warp)
{
if ((warp != INT_MAX) && (warpIndex(warp) == INT_MAX))
{
- boundsError("warp");
+ emit(error(bounds("warp")));
return;
}
m_flyWarp = warp;
@@ -174,7 +169,7 @@ void Map::setType(const int type)
{
if (End <= type)
{
- boundsError("type");
+ emit(error(bounds("type")));
return;
}
m_type = type;
@@ -199,7 +194,7 @@ void Map::setTile(const int row, const int column, const int tile)
{
if (static_cast<const Pokemod*>(pokemod())->tileIndex(tile) == INT_MAX)
{
- boundsError("tile");
+ emit(error(bounds("tile")));
return;
}
m_tile.set(row, column, tile);