summaryrefslogtreecommitdiffstats
path: root/pokemod/Map.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-02-19 02:04:07 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-02-19 02:04:07 +0000
commita47a7aa7508e18292ace9299692f0e197d7a915a (patch)
tree59ce3711fb4252caf298054e99149813bec147e4 /pokemod/Map.cpp
parent95b265b8838a29e4d923582b07d51f5eed2bb03f (diff)
downloadsigen-a47a7aa7508e18292ace9299692f0e197d7a915a.tar.gz
sigen-a47a7aa7508e18292ace9299692f0e197d7a915a.tar.xz
sigen-a47a7aa7508e18292ace9299692f0e197d7a915a.zip
[FIX] pokemod now passes pointers around instead of references
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@61 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Map.cpp')
-rw-r--r--pokemod/Map.cpp170
1 files changed, 85 insertions, 85 deletions
diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp
index 13b8ffd2..b9385707 100644
--- a/pokemod/Map.cpp
+++ b/pokemod/Map.cpp
@@ -29,7 +29,7 @@
const QStringList Map::TypeStr = QStringList() << "Outdoor" << "Dungeon" << "Building";
-Map::Map(const Pokemod& par, const int _id) :
+Map::Map(const Pokemod* par, const int _id) :
Object("Map", par, _id),
name(""),
flyWarp(-1),
@@ -37,13 +37,13 @@ Map::Map(const Pokemod& par, const int _id) :
{
}
-Map::Map(const Pokemod& par, const Map& m, const int _id) :
+Map::Map(const Pokemod* par, const Map& m, const int _id) :
Object("Map", par, _id)
{
*this = m;
}
-Map::Map(const Pokemod& par, const QString& fname, const int _id) :
+Map::Map(const Pokemod* par, const QString& fname, const int _id) :
Object("Map", par, _id)
{
load(fname, _id);
@@ -52,20 +52,20 @@ Map::Map(const Pokemod& par, const QString& fname, const int _id) :
bool Map::validate() const
{
bool valid = true;
- pokemod.validationMsg(QString("---Map \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg);
+ pokemod->validationMsg(QString("---Map \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg);
if (name == "")
{
- pokemod.validationMsg("name is not defined");
+ pokemod->validationMsg("name is not defined");
valid = false;
}
if ((flyWarp != -1) && (getWarpIndex(flyWarp) == -1))
{
- pokemod.validationMsg("Invalid fly destination warp");
+ pokemod->validationMsg("Invalid fly destination warp");
valid = false;
}
if (type < End)
{
- pokemod.validationMsg("Invalid type");
+ pokemod->validationMsg("Invalid type");
valid = false;
}
QMap<int, int> idChecker;
@@ -78,12 +78,12 @@ bool Map::validate() const
valid = false;
if (getWidth() <= i.peekNext().getCoordinate().getX())
{
- pokemod.validationMsg("Invalid x coordinate");
+ pokemod->validationMsg("Invalid x coordinate");
valid = false;
}
if (getHeight() <= i.peekNext().getCoordinate().getY())
{
- pokemod.validationMsg("Invalid y coordinate");
+ pokemod->validationMsg("Invalid y coordinate");
valid = false;
}
++idChecker[i.peekNext().getId()];
@@ -93,7 +93,7 @@ bool Map::validate() const
{
if (1 < i.value())
{
- pokemod.validationMsg(QString("There are %1 effects with id %2").arg(i.value()).arg(i.key()));
+ pokemod->validationMsg(QString("There are %1 effects with id %2").arg(i.value()).arg(i.key()));
valid = false;
}
}
@@ -101,7 +101,7 @@ bool Map::validate() const
{
if (1 < i.value())
{
- pokemod.validationMsg(QString("There are %1 effects with the name \"%2\"").arg(i.value()).arg(i.key()));
+ pokemod->validationMsg(QString("There are %1 effects with the name \"%2\"").arg(i.value()).arg(i.key()));
valid = false;
}
}
@@ -109,7 +109,7 @@ bool Map::validate() const
nameChecker.clear();
}
else
- pokemod.validationMsg("There are no effects", Pokemod::V_Warn);
+ pokemod->validationMsg("There are no effects", Pokemod::V_Warn);
if (getTrainerCount())
{
for (QListIterator<MapTrainer> i(trainers); i.hasNext(); i.next())
@@ -118,12 +118,12 @@ bool Map::validate() const
valid = false;
if (getWidth() <= i.peekNext().getCoordinate().getX())
{
- pokemod.validationMsg("Invalid x coordinate");
+ pokemod->validationMsg("Invalid x coordinate");
valid = false;
}
if (getHeight() <= i.peekNext().getCoordinate().getY())
{
- pokemod.validationMsg("Invalid y coordinate");
+ pokemod->validationMsg("Invalid y coordinate");
valid = false;
}
++idChecker[i.peekNext().getId()];
@@ -133,7 +133,7 @@ bool Map::validate() const
{
if (1 < i.value())
{
- pokemod.validationMsg(QString("There are %1 trainers with id %2").arg(i.value()).arg(i.key()));
+ pokemod->validationMsg(QString("There are %1 trainers with id %2").arg(i.value()).arg(i.key()));
valid = false;
}
}
@@ -141,7 +141,7 @@ bool Map::validate() const
{
if (1 < i.value())
{
- pokemod.validationMsg(QString("There are %1 trainers with the name \"%2\"").arg(i.value()).arg(i.key()));
+ pokemod->validationMsg(QString("There are %1 trainers with the name \"%2\"").arg(i.value()).arg(i.key()));
valid = false;
}
}
@@ -149,7 +149,7 @@ bool Map::validate() const
nameChecker.clear();
}
else
- pokemod.validationMsg("There are no trainers", Pokemod::V_Warn);
+ pokemod->validationMsg("There are no trainers", Pokemod::V_Warn);
if (getWarpCount())
{
for (QListIterator<MapWarp> i(warps); i.hasNext(); i.next())
@@ -158,12 +158,12 @@ bool Map::validate() const
valid = false;
if (getWidth() <= i.peekNext().getCoordinate().getX())
{
- pokemod.validationMsg("Invalid x coordinate");
+ pokemod->validationMsg("Invalid x coordinate");
valid = false;
}
if (getHeight() <= i.peekNext().getCoordinate().getY())
{
- pokemod.validationMsg("Invalid y coordinate");
+ pokemod->validationMsg("Invalid y coordinate");
valid = false;
}
++idChecker[i.peekNext().getId()];
@@ -173,7 +173,7 @@ bool Map::validate() const
{
if (1 < i.value())
{
- pokemod.validationMsg(QString("There are %1 warps with id %2").arg(i.value()).arg(i.key()));
+ pokemod->validationMsg(QString("There are %1 warps with id %2").arg(i.value()).arg(i.key()));
valid = false;
}
}
@@ -181,7 +181,7 @@ bool Map::validate() const
{
if (1 < i.value())
{
- pokemod.validationMsg(QString("There are %1 warps with the name \"%2\"").arg(i.value()).arg(i.key()));
+ pokemod->validationMsg(QString("There are %1 warps with the name \"%2\"").arg(i.value()).arg(i.key()));
valid = false;
}
}
@@ -190,7 +190,7 @@ bool Map::validate() const
}
else
{
- pokemod.validationMsg("There are no warps");
+ pokemod->validationMsg("There are no warps");
valid = false;
}
if (getWildListCount())
@@ -205,21 +205,21 @@ bool Map::validate() const
{
if (1 < i.value())
{
- pokemod.validationMsg(QString("There are %1 wild lists with id %2").arg(i.value()).arg(i.key()));
+ pokemod->validationMsg(QString("There are %1 wild lists with id %2").arg(i.value()).arg(i.key()));
valid = false;
}
}
idChecker.clear();
}
else
- pokemod.validationMsg("There are no effects", Pokemod::V_Warn);
+ pokemod->validationMsg("There are no effects", Pokemod::V_Warn);
for (int i = 0; i < getWidth(); ++i)
{
for (int j = 0; j < getHeight(); ++j)
{
- if (pokemod.getTileIndex(tiles(i, j)) == -1)
+ if (pokemod->getTileIndex(tiles(i, j)) == -1)
{
- pokemod.validationMsg(QString("Invalid tile at (%1, %2)").arg(i).arg(j));
+ pokemod->validationMsg(QString("Invalid tile at (%1, %2)").arg(i).arg(j));
valid = false;
}
}
@@ -279,7 +279,7 @@ void Map::load(const QString& fname, const int _id) throw(Exception)
for (int j = 0; j < getHeight(); ++j)
ini.getValue(QString("tiles-%1-%2").arg(i).arg(j), tiles(i, j));
}
- QStringList path = pokemod.getPath().split('/');
+ QStringList path = pokemod->getPath().split('/');
path.removeLast();
QDir fdir(path.join("/"));
effects.clear();
@@ -325,7 +325,7 @@ void Map::save() const throw(Exception)
for (int j = 0; j < getWidth(); ++j)
ini.addField(QString("tiles-%1-%2").arg(i).arg(j), tiles(i, j));
}
- ini.save(QString("%1/map/%2/data.pini").arg(pokemod.getPath()).arg(name));
+ ini.save(QString("%1/map/%2/data.pini").arg(pokemod->getPath()).arg(name));
for (QListIterator<MapEffect> i(effects); i.hasNext(); )
i.next().save(name);
for (QListIterator<MapTrainer> i(trainers); i.hasNext(); )
@@ -372,7 +372,7 @@ int Map::getType() const
void Map::setTile(int x, int y, int _id) throw(BoundsException)
{
- if (pokemod.getTileIndex(_id) == -1)
+ if (pokemod->getTileIndex(_id) == -1)
throw(BoundsException(className, "tile"));
tiles(x, y) = _id;
}
@@ -407,14 +407,14 @@ void Map::deleteRow(int y)
tiles.deleteRow(y);
}
-const Matrix<int>& Map::getMap() const
+const Matrix<int>* Map::getMap() const
{
- return tiles;
+ return &tiles;
}
-Matrix<int>& Map::getMap()
+Matrix<int>* Map::getMap()
{
- return tiles;
+ return &tiles;
}
int Map::getTile(int x, int y) const
@@ -432,26 +432,26 @@ int Map::getHeight() const
return tiles.getHeight();
}
-const MapEffect& Map::getEffect(const int i) const throw(IndexException)
+const MapEffect* Map::getEffect(const int i) const throw(IndexException)
{
if (getEffectCount() <= i)
throw(IndexException(className));
- return effects.at(i);
+ return &effects.at(i);
}
-MapEffect& Map::getEffect(const int i) throw(IndexException)
+MapEffect* Map::getEffect(const int i) throw(IndexException)
{
if (getEffectCount() <= i)
throw(IndexException(className));
- return effects[i];
+ return &effects[i];
}
-const MapEffect& Map::getEffectByID(const int i) const throw(IndexException)
+const MapEffect* Map::getEffectByID(const int i) const throw(IndexException)
{
return getEffect(getEffectIndex(i));
}
-MapEffect& Map::getEffectByID(const int i) throw(IndexException)
+MapEffect* Map::getEffectByID(const int i) throw(IndexException)
{
return getEffect(getEffectIndex(i));
}
@@ -471,22 +471,22 @@ int Map::getEffectCount() const
return effects.size();
}
-MapEffect& Map::newEffect()
+MapEffect* Map::newEffect()
{
effects.append(MapEffect(pokemod, getNewEffectId()));
- return effects[getEffectCount() - 1];
+ return &effects[getEffectCount() - 1];
}
-MapEffect& Map::newEffect(const QString& fname)
+MapEffect* Map::newEffect(const QString& fname)
{
effects.append(MapEffect(pokemod, fname, getNewEffectId()));
- return effects[getEffectCount() - 1];
+ return &effects[getEffectCount() - 1];
}
-MapEffect& Map::newEffect(const MapEffect& e)
+MapEffect* Map::newEffect(const MapEffect& e)
{
effects.append(MapEffect(pokemod, e, getNewEffectId()));
- return effects[getEffectCount() - 1];
+ return &effects[getEffectCount() - 1];
}
void Map::deleteEffect(const int i) throw(IndexException)
@@ -496,26 +496,26 @@ void Map::deleteEffect(const int i) throw(IndexException)
effects.removeAt(i);
}
-const MapTrainer& Map::getTrainer(const int i) const throw(IndexException)
+const MapTrainer* Map::getTrainer(const int i) const throw(IndexException)
{
if (getTrainerCount() <= i)
throw(IndexException(className));
- return trainers.at(i);
+ return &trainers.at(i);
}
-MapTrainer& Map::getTrainer(const int i) throw(IndexException)
+MapTrainer* Map::getTrainer(const int i) throw(IndexException)
{
if (getTrainerCount() <= i)
throw(IndexException(className));
- return trainers[i];
+ return &trainers[i];
}
-const MapTrainer& Map::getTrainerByID(const int i) const throw(IndexException)
+const MapTrainer* Map::getTrainerByID(const int i) const throw(IndexException)
{
return getTrainer(getTrainerIndex(i));
}
-MapTrainer& Map::getTrainerByID(const int i) throw(IndexException)
+MapTrainer* Map::getTrainerByID(const int i) throw(IndexException)
{
return getTrainer(getTrainerIndex(i));
}
@@ -535,22 +535,22 @@ int Map::getTrainerCount() const
return trainers.size();
}
-MapTrainer& Map::newTrainer()
+MapTrainer* Map::newTrainer()
{
trainers.append(MapTrainer(pokemod, getNewTrainerId()));
- return trainers[getTrainerCount() - 1];
+ return &trainers[getTrainerCount() - 1];
}
-MapTrainer& Map::newTrainer(const QString& fname)
+MapTrainer* Map::newTrainer(const QString& fname)
{
trainers.append(MapTrainer(pokemod, fname, getNewTrainerId()));
- return trainers[getTrainerCount() - 1];
+ return &trainers[getTrainerCount() - 1];
}
-MapTrainer& Map::newTrainer(const MapTrainer& t)
+MapTrainer* Map::newTrainer(const MapTrainer& t)
{
trainers.append(MapTrainer(pokemod, t, getNewTrainerId()));
- return trainers[getTrainerCount() - 1];
+ return &trainers[getTrainerCount() - 1];
}
void Map::deleteTrainer(const int i) throw(IndexException)
@@ -560,26 +560,26 @@ void Map::deleteTrainer(const int i) throw(IndexException)
trainers.removeAt(i);
}
-const MapWarp& Map::getWarp(const int i) const throw(IndexException)
+const MapWarp* Map::getWarp(const int i) const throw(IndexException)
{
if (getWarpCount() <= i)
throw(IndexException(className));
- return warps.at(i);
+ return &warps.at(i);
}
-MapWarp& Map::getWarp(const int i) throw(IndexException)
+MapWarp* Map::getWarp(const int i) throw(IndexException)
{
if (getWarpCount() <= i)
throw(IndexException(className));
- return warps[i];
+ return &warps[i];
}
-const MapWarp& Map::getWarpByID(const int i) const throw(IndexException)
+const MapWarp* Map::getWarpByID(const int i) const throw(IndexException)
{
return getWarp(getWarpIndex(i));
}
-MapWarp& Map::getWarpByID(const int i) throw(IndexException)
+MapWarp* Map::getWarpByID(const int i) throw(IndexException)
{
return getWarp(getWarpIndex(i));
}
@@ -599,22 +599,22 @@ int Map::getWarpCount() const
return warps.size();
}
-MapWarp& Map::newWarp()
+MapWarp* Map::newWarp()
{
warps.append(MapWarp(pokemod, getNewWarpId()));
- return warps[getWarpCount() - 1];
+ return &warps[getWarpCount() - 1];
}
-MapWarp& Map::newWarp(const QString& fname)
+MapWarp* Map::newWarp(const QString& fname)
{
warps.append(MapWarp(pokemod, fname, getNewWarpId()));
- return warps[getWarpCount() - 1];
+ return &warps[getWarpCount() - 1];
}
-MapWarp& Map::newWarp(const MapWarp& w)
+MapWarp* Map::newWarp(const MapWarp& w)
{
warps.append(MapWarp(pokemod, w, getNewWarpId()));
- return warps[getWarpCount() - 1];
+ return &warps[getWarpCount() - 1];
}
void Map::deleteWarp(const int i) throw(IndexException)
@@ -624,26 +624,26 @@ void Map::deleteWarp(const int i) throw(IndexException)
warps.removeAt(i);
}
-const MapWildList& Map::getWildList(const int i) const throw(IndexException)
+const MapWildList* Map::getWildList(const int i) const throw(IndexException)
{
if (getWildListCount() <= i)
throw(IndexException(className));
- return wildLists.at(i);
+ return &wildLists.at(i);
}
-MapWildList& Map::getWildList(const int i) throw(IndexException)
+MapWildList* Map::getWildList(const int i) throw(IndexException)
{
if (getWildListCount() <= i)
throw(IndexException(className));
- return wildLists[i];
+ return &wildLists[i];
}
-const MapWildList& Map::getWildListByID(const int i) const throw(IndexException)
+const MapWildList* Map::getWildListByID(const int i) const throw(IndexException)
{
return getWildList(getWildListIndex(i));
}
-MapWildList& Map::getWildListByID(const int i) throw(IndexException)
+MapWildList* Map::getWildListByID(const int i) throw(IndexException)
{
return getWildList(getWildListIndex(i));
}
@@ -663,22 +663,22 @@ int Map::getWildListCount() const
return wildLists.size();
}
-MapWildList& Map::newWildList()
+MapWildList* Map::newWildList()
{
wildLists.append(MapWildList(pokemod, getNewWildListId()));
- return wildLists[getWildListCount() - 1];
+ return &wildLists[getWildListCount() - 1];
}
-MapWildList& Map::newWildList(const QString& fname)
+MapWildList* Map::newWildList(const QString& fname)
{
wildLists.append(MapWildList(pokemod, fname, getNewWildListId()));
- return wildLists[getWildListCount() - 1];
+ return &wildLists[getWildListCount() - 1];
}
-MapWildList& Map::newWildList(const MapWildList& w)
+MapWildList* Map::newWildList(const MapWildList& w)
{
wildLists.append(MapWildList(pokemod, w, getNewWildListId()));
- return wildLists[getWildListCount() - 1];
+ return &wildLists[getWildListCount() - 1];
}
void Map::deleteWildList(const int i) throw(IndexException)
@@ -698,15 +698,15 @@ Map& Map::operator=(const Map& rhs)
tiles = rhs.tiles;
effects.clear();
for (int i = 0; i < rhs.getEffectCount(); ++i)
- newEffect(rhs.getEffect(i));
+ newEffect(*rhs.getEffect(i));
trainers.clear();
for (int i = 0; i < rhs.getTrainerCount(); ++i)
- newTrainer(rhs.getTrainer(i));
+ newTrainer(*rhs.getTrainer(i));
warps.clear();
for (int i = 0; i < rhs.getWarpCount(); ++i)
- newWarp(rhs.getWarp(i));
+ newWarp(*rhs.getWarp(i));
wildLists.clear();
for (int i = 0; i < rhs.getWildListCount(); ++i)
- newWildList(rhs.getWildList(i));
+ newWildList(*rhs.getWildList(i));
return *this;
}