summaryrefslogtreecommitdiffstats
path: root/pokemod/MapWildList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/MapWildList.cpp')
-rw-r--r--pokemod/MapWildList.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp
index 3aa51d85..5c866aef 100644
--- a/pokemod/MapWildList.cpp
+++ b/pokemod/MapWildList.cpp
@@ -277,20 +277,23 @@ int MapWildList::encounterCount() const
MapWildListEncounter* MapWildList::newEncounter()
{
- m_encounters.append(new MapWildListEncounter(this, newEncounterId()));
- return m_encounters[encounterCount() - 1];
+ return newEncounter(new MapWildListEncounter(this, newEncounterId()));
}
MapWildListEncounter* MapWildList::newEncounter(const QDomElement& xml)
{
- m_encounters.append(new MapWildListEncounter(xml, this, newEncounterId()));
- return m_encounters[encounterCount() - 1];
+ return newEncounter(new MapWildListEncounter(xml, this, newEncounterId()));
}
MapWildListEncounter* MapWildList::newEncounter(const MapWildListEncounter& encounter)
{
- m_encounters.append(new MapWildListEncounter(encounter, this, newEncounterId()));
- return m_encounters[encounterCount() - 1];
+ return newEncounter(new MapWildListEncounter(encounter, this, newEncounterId()));
+}
+
+MapWildListEncounter* MapWildList::newEncounter(MapWildListEncounter* encounter)
+{
+ m_encounters.append(encounter);
+ return encounter;
}
void MapWildList::deleteEncounter(const int index) throw(IndexException)
@@ -326,3 +329,9 @@ MapWildList& MapWildList::operator=(const MapWildList& rhs)
COPY_SUB(MapWildListEncounter, encounters);
return *this;
}
+
+void MapWildList::clear()
+{
+ while (encounterCount())
+ deleteEncounter(0);
+}