summaryrefslogtreecommitdiffstats
path: root/pokemod/MapWildList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/MapWildList.cpp')
-rw-r--r--pokemod/MapWildList.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp
index 68ff881b..737f506d 100644
--- a/pokemod/MapWildList.cpp
+++ b/pokemod/MapWildList.cpp
@@ -30,6 +30,7 @@
#include "Pokemod.h"
#include "Item.h"
#include "ItemEffect.h"
+#include "MapWildListEncounter.h"
#include "MapWildList.h"
const QStringList MapWildList::ControlStr = QStringList() << "Grass" << "Surfing" << "Fishing" << "Dive" << "Headbutt" << "Rock Smash";
@@ -54,6 +55,12 @@ MapWildList::MapWildList(const Pokemod* par, const QString& fname, const int _id
load(fname, _id);
}
+MapWildList::~MapWildList()
+{
+ for (QListIterator<MapWildListEncounter*> i(encounters); i.hasNext(); )
+ delete i.next();
+}
+
bool MapWildList::validate() const
{
bool valid = true;
@@ -117,6 +124,7 @@ bool MapWildList::validate() const
valid = false;
}
}
+ // TODO: MapWildList Encounter validation
return valid;
}
@@ -170,8 +178,8 @@ void MapWildList::save(const QString& map) const throw(Exception)
ini.addField(QString("time-%1").arg(i), times[i]);
ini.addField("scope", scope);
ini.save(QString("%1/map/%2/wildlist/%3/data.pini").arg(pokemod->getPath()).arg(map).arg(id));
- for (QListIterator<MapWildListEncounter> i(encounters); i.hasNext(); )
- i.next().save(map, id);
+ for (QListIterator<MapWildListEncounter*> i(encounters); i.hasNext(); )
+ i.next()->save(map, id);
}
void MapWildList::setControl(const int c) throw(BoundsException)
@@ -267,14 +275,14 @@ const MapWildListEncounter* MapWildList::getEncounter(const int i) const throw(I
{
if (getEncounterCount() <= i)
throw(IndexException(className));
- return &encounters.at(i);
+ return encounters.at(i);
}
MapWildListEncounter* MapWildList::getEncounter(const int i) throw(IndexException)
{
if (getEncounterCount() <= i)
throw(IndexException(className));
- return &encounters[i];
+ return encounters[i];
}
const MapWildListEncounter* MapWildList::getEncounterByID(const int i) const throw(IndexException)
@@ -291,7 +299,7 @@ int MapWildList::getEncounterIndex(const int _id) const
{
for (int i = 0; i < getEncounterCount(); ++i)
{
- if (encounters[i].getId() == _id)
+ if (encounters[i]->getId() == _id)
return i;
}
return -1;
@@ -304,26 +312,27 @@ int MapWildList::getEncounterCount() const
MapWildListEncounter* MapWildList::newEncounter()
{
- encounters.append(MapWildListEncounter(pokemod, getNewId()));
- return &encounters[getEncounterCount() - 1];
+ encounters.append(new MapWildListEncounter(pokemod, getNewId()));
+ return encounters[getEncounterCount() - 1];
}
MapWildListEncounter* MapWildList::newEncounter(const QString& fname)
{
- encounters.append(MapWildListEncounter(pokemod, fname, getNewId()));
- return &encounters[getEncounterCount() - 1];
+ encounters.append(new MapWildListEncounter(pokemod, fname, getNewId()));
+ return encounters[getEncounterCount() - 1];
}
MapWildListEncounter* MapWildList::newEncounter(const MapWildListEncounter& p)
{
- encounters.append(MapWildListEncounter(pokemod, p, getNewId()));
- return &encounters[getEncounterCount() - 1];
+ encounters.append(new MapWildListEncounter(pokemod, p, getNewId()));
+ return encounters[getEncounterCount() - 1];
}
void MapWildList::deleteEncounter(const int i) throw(IndexException)
{
if (getEncounterCount() <= i)
throw(IndexException(className));
+ delete encounters[i];
encounters.removeAt(i);
}
@@ -337,6 +346,6 @@ MapWildList& MapWildList::operator=(const MapWildList& rhs)
scope = rhs.scope;
encounters.clear();
for (int i = 0; i < rhs.getEncounterCount(); ++i)
- newEncounter(*rhs.getEncounter(i));
+ encounters.append(new MapWildListEncounter(pokemod, *rhs.getEncounter(i), rhs.getEncounter(i)->getId()));
return *this;
}