summaryrefslogtreecommitdiffstats
path: root/pokemod/Map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/Map.cpp')
-rw-r--r--pokemod/Map.cpp107
1 files changed, 93 insertions, 14 deletions
diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp
index ea8ed60e..e6c0d162 100644
--- a/pokemod/Map.cpp
+++ b/pokemod/Map.cpp
@@ -53,7 +53,7 @@ bool PokeMod::Map::validate() const
pokemod.validationMsg("name is not defined");
valid = false;
}
- if ((flyWarp != UINT_MAX) && (getWarpByID(flyWarp) == UINT_MAX))
+ if ((flyWarp != UINT_MAX) && (getWarpIndex(flyWarp) == UINT_MAX))
{
pokemod.validationMsg("Invalid fly destination warp");
valid = false;
@@ -71,12 +71,12 @@ bool PokeMod::Map::validate() const
{
if (!i.peekNext().isValid())
valid = false;
- if (getWidth() <= i.peekNext().getCoordinateX())
+ if (getWidth() <= i.peekNext().getCoordinate().getX())
{
pokemod.validationMsg("Invalid x coordinate");
valid = false;
}
- if (getHeight() <= i.peekNext().getCoordinateY())
+ if (getHeight() <= i.peekNext().getCoordinate().getY())
{
pokemod.validationMsg("Invalid y coordinate");
valid = false;
@@ -111,12 +111,12 @@ bool PokeMod::Map::validate() const
{
if (!i.peekNext().isValid())
valid = false;
- if (getWidth() <= i.peekNext().getCoordinateX())
+ if (getWidth() <= i.peekNext().getCoordinate().getX())
{
pokemod.validationMsg("Invalid x coordinate");
valid = false;
}
- if (getHeight() <= i.peekNext().getCoordinateY())
+ if (getHeight() <= i.peekNext().getCoordinate().getY())
{
pokemod.validationMsg("Invalid y coordinate");
valid = false;
@@ -151,12 +151,12 @@ bool PokeMod::Map::validate() const
{
if (!i.peekNext().isValid())
valid = false;
- if (getWidth() <= i.peekNext().getCoordinateX())
+ if (getWidth() <= i.peekNext().getCoordinate().getX())
{
pokemod.validationMsg("Invalid x coordinate");
valid = false;
}
- if (getHeight() <= i.peekNext().getCoordinateY())
+ if (getHeight() <= i.peekNext().getCoordinate().getY())
{
pokemod.validationMsg("Invalid y coordinate");
valid = false;
@@ -212,7 +212,7 @@ bool PokeMod::Map::validate() const
{
for (unsigned j = 0; j < getHeight(); ++j)
{
- if (pokemod.getTileByID(tiles(i, j)) == UINT_MAX)
+ if (pokemod.getTileIndex(tiles(i, j)) == UINT_MAX)
{
pokemod.validationMsg(QString("Invalid tile at (%1, %2)").arg(i).arg(j));
valid = false;
@@ -222,6 +222,38 @@ bool PokeMod::Map::validate() const
return valid;
}
+unsigned PokeMod::Map::getNewEffectId() const
+{
+ unsigned i = 0;
+ for (; (i < getEffectCount()) && (getEffectIndex(i) != UINT_MAX); ++i)
+ ;
+ return i;
+}
+
+unsigned PokeMod::Map::getNewTrainerId() const
+{
+ unsigned i = 0;
+ for (; (i < getTrainerCount()) && (getTrainerIndex(i) != UINT_MAX); ++i)
+ ;
+ return i;
+}
+
+unsigned PokeMod::Map::getNewWarpId() const
+{
+ unsigned i = 0;
+ for (; (i < getWarpCount()) && (getWarpIndex(i) != UINT_MAX); ++i)
+ ;
+ return i;
+}
+
+unsigned PokeMod::Map::getNewWildListId() const
+{
+ unsigned i = 0;
+ for (; (i < getWarpCount()) && (getWarpIndex(i) != UINT_MAX); ++i)
+ ;
+ return i;
+}
+
void PokeMod::Map::load(const QString& fname, const unsigned _id) throw(Exception)
{
Ini ini(fname);
@@ -306,7 +338,7 @@ void PokeMod::Map::setName(const QString& n)
void PokeMod::Map::setFlyWarp(const unsigned f) throw(BoundsException)
{
- if (getWarpByID(f) == UINT_MAX)
+ if (getWarpIndex(f) == UINT_MAX)
throw(BoundsException("Map", "warp"));
flyWarp = f;
}
@@ -335,7 +367,7 @@ unsigned PokeMod::Map::getType() const
void PokeMod::Map::setTile(unsigned x, unsigned y, unsigned _id) throw(BoundsException)
{
- if (pokemod.getTileByID(_id) == UINT_MAX)
+ if (pokemod.getTileIndex(_id) == UINT_MAX)
throw(BoundsException("Map", "tile"));
tiles(x, y) = _id;
}
@@ -399,7 +431,17 @@ PokeMod::MapEffect& PokeMod::Map::getEffect(const unsigned i) throw(IndexExcepti
return effects[i];
}
-unsigned PokeMod::Map::getEffectByID(const unsigned _id) const
+const PokeMod::MapEffect& PokeMod::Map::getEffectByID(const unsigned i) const throw(IndexException)
+{
+ return getEffect(getEffectIndex(i));
+}
+
+PokeMod::MapEffect& PokeMod::Map::getEffectByID(const unsigned i) throw(IndexException)
+{
+ return getEffect(getEffectIndex(i));
+}
+
+unsigned PokeMod::Map::getEffectIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getEffectCount(); ++i)
{
@@ -453,7 +495,17 @@ PokeMod::MapTrainer& PokeMod::Map::getTrainer(const unsigned i) throw(IndexExcep
return trainers[i];
}
-unsigned PokeMod::Map::getTrainerByID(const unsigned _id) const
+const PokeMod::MapTrainer& PokeMod::Map::getTrainerByID(const unsigned i) const throw(IndexException)
+{
+ return getTrainer(getTrainerIndex(i));
+}
+
+PokeMod::MapTrainer& PokeMod::Map::getTrainerByID(const unsigned i) throw(IndexException)
+{
+ return getTrainer(getTrainerIndex(i));
+}
+
+unsigned PokeMod::Map::getTrainerIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getTrainerCount(); ++i)
{
@@ -507,7 +559,17 @@ PokeMod::MapWarp& PokeMod::Map::getWarp(const unsigned i) throw(IndexException)
return warps[i];
}
-unsigned PokeMod::Map::getWarpByID(const unsigned _id) const
+const PokeMod::MapWarp& PokeMod::Map::getWarpByID(const unsigned i) const throw(IndexException)
+{
+ return getWarp(getWarpIndex(i));
+}
+
+PokeMod::MapWarp& PokeMod::Map::getWarpByID(const unsigned i) throw(IndexException)
+{
+ return getWarp(getWarpIndex(i));
+}
+
+unsigned PokeMod::Map::getWarpIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getWarpCount(); ++i)
{
@@ -551,10 +613,27 @@ const PokeMod::MapWildList& PokeMod::Map::getWildList(const unsigned i) const th
{
if (getWildListCount() <= i)
throw(IndexException("Map"));
+ return wildLists.at(i);
+}
+
+PokeMod::MapWildList& PokeMod::Map::getWildList(const unsigned i) throw(IndexException)
+{
+ if (getWildListCount() <= i)
+ throw(IndexException("Map"));
return wildLists[i];
}
-unsigned PokeMod::Map::getWildListByID(const unsigned _id) const
+const PokeMod::MapWildList& PokeMod::Map::getWildListByID(const unsigned i) const throw(IndexException)
+{
+ return getWildList(getWildListIndex(i));
+}
+
+PokeMod::MapWildList& PokeMod::Map::getWildListByID(const unsigned i) throw(IndexException)
+{
+ return getWildList(getWildListIndex(i));
+}
+
+unsigned PokeMod::Map::getWildListIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getWildListCount(); ++i)
{