diff options
Diffstat (limited to 'pokemod/Map.cpp')
| -rw-r--r-- | pokemod/Map.cpp | 129 |
1 files changed, 64 insertions, 65 deletions
diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp index 42793c8d..1765f4a5 100644 --- a/pokemod/Map.cpp +++ b/pokemod/Map.cpp @@ -6,19 +6,18 @@ // Created: Mon May 28 21:45:48 2007
// Copyright: ©2007 Nerdy Productions
// Licence:
-// This program is free software; you can redistribute it and/or modify
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
+// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTMap or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+// with this program. If not, see <http://www.gnu.org/licenses/>.
/////////////////////////////////////////////////////////////////////////////
#include "Map.h"
@@ -65,11 +64,11 @@ void PokeGen::PokeMod::Map::Validate() LogVarNotValid("Map", id, "type", name);
isValid = false;
}
- std::map<unsigned, unsigned> idChecker;
- std::map<String, unsigned> nameChecker;
+ QMap<unsigned, unsigned> idChecker;
+ QMap<QString, unsigned> nameChecker;
if (GetMapEffectCount())
{
- for (std::vector<MapEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
+ for (QList<MapEffect>::Iterator i = effects.begin(); i != effects.end(); ++i)
{
LogSubmoduleIterate("Map", id, "effect", i->GetId(), name);
if (!i->IsValid())
@@ -87,19 +86,19 @@ void PokeGen::PokeMod::Map::Validate() ++idChecker[i->GetId()];
++nameChecker[i->GetName()];
}
- for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
{
- if (1 < i->second)
+ if (1 < i.value())
{
- LogDuplicateId("Map", id, "effect", i->first, name);
+ LogDuplicateId("Map", id, "effect", i.key(), name);
isValid = false;
}
}
- for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
{
- if (1 < i->second)
+ if (1 < i.value())
{
- LogDuplicateSubmodule("Map", id, "effect", i->first, name);
+ LogDuplicateSubmodule("Map", id, "effect", i.key(), name);
isValid = false;
}
}
@@ -110,7 +109,7 @@ void PokeGen::PokeMod::Map::Validate() LogSubmoduleEmpty("Map", id, "effect", name);
if (GetMapTrainerCount())
{
- for (std::vector<MapTrainer>::iterator i = trainers.begin(); i != trainers.end(); ++i)
+ for (QList<MapTrainer>::Iterator i = trainers.begin(); i != trainers.end(); ++i)
{
LogSubmoduleIterate("Map", id, "trainer", i->GetId(), name);
if (!i->IsValid())
@@ -128,19 +127,19 @@ void PokeGen::PokeMod::Map::Validate() ++idChecker[i->GetId()];
++nameChecker[i->GetName()];
}
- for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
{
- if (1 < i->second)
+ if (1 < i.value())
{
- LogDuplicateId("Map", id, "trainer", i->first, name);
+ LogDuplicateId("Map", id, "trainer", i.key(), name);
isValid = false;
}
}
- for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
{
- if (1 < i->second)
+ if (1 < i.value())
{
- LogDuplicateSubmodule("Map", id, "trainer", i->first, name);
+ LogDuplicateSubmodule("Map", id, "trainer", i.key(), name);
isValid = false;
}
}
@@ -151,7 +150,7 @@ void PokeGen::PokeMod::Map::Validate() LogSubmoduleEmpty("Map", id, "trainer", name);
if (GetMapWarpCount())
{
- for (std::vector<MapWarp>::iterator i = warps.begin(); i != warps.end(); ++i)
+ for (QList<MapWarp>::Iterator i = warps.begin(); i != warps.end(); ++i)
{
LogSubmoduleIterate("Map", id, "warp", i->GetId(), name);
if (!i->IsValid())
@@ -169,19 +168,19 @@ void PokeGen::PokeMod::Map::Validate() ++idChecker[i->GetId()];
++nameChecker[i->GetName()];
}
- for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
{
- if (1 < i->second)
+ if (1 < i.value())
{
- LogDuplicateId("Map", id, "warp", i->first, name);
+ LogDuplicateId("Map", id, "warp", i.key(), name);
isValid = false;
}
}
- for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
{
- if (1 < i->second)
+ if (1 < i.value())
{
- LogDuplicateSubmodule("Map", id, "warp", i->first, name);
+ LogDuplicateSubmodule("Map", id, "warp", i.key(), name);
isValid = false;
}
}
@@ -195,18 +194,18 @@ void PokeGen::PokeMod::Map::Validate() }
if (GetMapWildListCount())
{
- for (std::vector<MapWildList>::iterator i = wildLists.begin(); i != wildLists.end(); ++i)
+ for (QList<MapWildList>::Iterator i = wildLists.begin(); i != wildLists.end(); ++i)
{
LogSubmoduleIterate("Map", id, "wild list", i->GetId(), name);
if (!i->IsValid())
isValid = false;
++idChecker[i->GetId()];
}
- for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
{
- if (1 < i->second)
+ if (1 < i.value())
{
- LogDuplicateId("Map", id, "effect", i->first, name);
+ LogDuplicateId("Map", id, "effect", i.key(), name);
isValid = false;
}
}
@@ -220,7 +219,7 @@ void PokeGen::PokeMod::Map::Validate() {
if (!pokemod->GetTile(tiles[i][j]))
{
- LogVarNotValid("Map", id, String("tiles[%u][%u]", i, j), name);
+ LogVarNotValid("Map", id, QString("tiles[%u][%u]", i, j), name);
isValid = false;
}
}
@@ -250,7 +249,7 @@ void PokeGen::PokeMod::Map::ImportIni(Ini &ini, const unsigned _id) for (unsigned i = 0; i < GetWidth(); ++i)
{
for (unsigned j = 0; j < GetHeight(); ++j)
- ini.GetValue(String("tiles-%u-%u", i, j), tiles[i][j]);
+ ini.GetValue(QString("tiles-%u-%u", i, j), tiles[i][j]);
}
effects.clear();
trainers.clear();
@@ -259,7 +258,7 @@ void PokeGen::PokeMod::Map::ImportIni(Ini &ini, const unsigned _id) LogImportOver("Map", id, name);
}
-void PokeGen::PokeMod::Map::ExportIni(std::ofstream &fout) const
+void PokeGen::PokeMod::Map::ExportIni(QFile &fout) const
{
LogExportStart("Map", id, name);
Ini exMap("Map");
@@ -272,21 +271,21 @@ void PokeGen::PokeMod::Map::ExportIni(std::ofstream &fout) const for (unsigned i = 0; i < GetWidth(); ++i)
{
for (unsigned j = 0; j < GetWidth(); ++j)
- exMap.AddField(String("tiles-%u-%u", i, j), tiles[i][j]);
+ exMap.AddField(QString("tiles-%u-%u", i, j), tiles[i][j]);
}
exMap.Export(fout);
- for (std::vector<MapEffect>::const_iterator i = effects.begin(); i != effects.end(); ++i)
+ for (QList<MapEffect>::ConstIterator i = effects.begin(); i != effects.end(); ++i)
i->ExportIni(fout, name);
- for (std::vector<MapTrainer>::const_iterator j = trainers.begin(); j != trainers.end(); ++j)
+ for (QList<MapTrainer>::ConstIterator j = trainers.begin(); j != trainers.end(); ++j)
j->ExportIni(fout, name);
- for (std::vector<MapWarp>::const_iterator k = warps.begin(); k != warps.end(); ++k)
+ for (QList<MapWarp>::ConstIterator k = warps.begin(); k != warps.end(); ++k)
k->ExportIni(fout, name);
- for (std::vector<MapWildList>::const_iterator l = wildLists.begin(); l != wildLists.end(); ++l)
+ for (QList<MapWildList>::ConstIterator l = wildLists.begin(); l != wildLists.end(); ++l)
l->ExportIni(fout, name);
LogExportOver("Map", id, name);
}
-void PokeGen::PokeMod::Map::SetName(const String &n)
+void PokeGen::PokeMod::Map::SetName(const QString &n)
{
LogSetVar("Map", id, "name", n);
name = n;
@@ -299,7 +298,7 @@ void PokeGen::PokeMod::Map::SetFlyWarp(const unsigned f) flyWarp = f;
}
-void PokeGen::PokeMod::Map::SetFlyWarp(const String &f)
+void PokeGen::PokeMod::Map::SetFlyWarp(const QString &f)
{
LogSetVar("Map", id, "flyWarp string", f, name);
if (const MapWarp *m = GetMapWarp(f))
@@ -313,13 +312,13 @@ void PokeGen::PokeMod::Map::SetType(const unsigned t) type = t;
}
-void PokeGen::PokeMod::Map::SetType(const String &t)
+void PokeGen::PokeMod::Map::SetType(const QString &t)
{
LogSetVar("Map", id, "type string", t, name);
type = FindIn(MTY_END, t, MapTypeStr);
}
-PokeGen::PokeMod::String PokeGen::PokeMod::Map::GetName() const
+QString PokeGen::PokeMod::Map::GetName() const
{
LogFetchVar("Map", id, "name", name);
return name;
@@ -331,7 +330,7 @@ unsigned PokeGen::PokeMod::Map::GetFlyWarp() const return flyWarp;
}
-PokeGen::PokeMod::String PokeGen::PokeMod::Map::GetFlyWarpString() const
+QString PokeGen::PokeMod::Map::GetFlyWarpString() const
{
LogFetchVar("Map", id, "flyWarp string", flyWarp, name);
if (const MapWarp *m = GetMapWarp(flyWarp))
@@ -345,7 +344,7 @@ unsigned PokeGen::PokeMod::Map::GetType() const return type;
}
-PokeGen::PokeMod::String PokeGen::PokeMod::Map::GetTypeString() const
+QString PokeGen::PokeMod::Map::GetTypeString() const
{
LogFetchVar("Map", id, "type string", type, name);
if (type < MTY_END)
@@ -359,7 +358,7 @@ void PokeGen::PokeMod::Map::SetTile(unsigned x, unsigned y, unsigned _id) tiles[x][y] = _id;
}
-void PokeGen::PokeMod::Map::SetTile(unsigned x, unsigned y, const String &n)
+void PokeGen::PokeMod::Map::SetTile(unsigned x, unsigned y, const QString &n)
{
if (const Tile *t = pokemod->GetTile(n))
tiles[x][y] = t->GetId();
@@ -422,7 +421,7 @@ const PokeGen::PokeMod::MapEffect *PokeGen::PokeMod::Map::GetMapEffect(const uns return NULL;
}
-const PokeGen::PokeMod::MapEffect *PokeGen::PokeMod::Map::GetMapEffect(const String &n) const
+const PokeGen::PokeMod::MapEffect *PokeGen::PokeMod::Map::GetMapEffect(const QString &n) const
{
LogSubmoduleFetch("Map", id, "effect", n, name);
for (unsigned i = 0; i < GetMapEffectCount(); ++i)
@@ -452,13 +451,13 @@ void PokeGen::PokeMod::Map::NewMapEffect(Ini *const ini) if (ini)
newMapEffect.ImportIni(*ini);
LogSubmoduleNew("Map", id, "effect", i, name);
- effects.push_back(newMapEffect);
+ effects.append(newMapEffect);
}
void PokeGen::PokeMod::Map::DeleteMapEffect(const unsigned _id)
{
LogSubmoduleRemoveStart("Map", id, "effect", _id, name);
- for (std::vector<MapEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
+ for (QList<MapEffect>::Iterator i = effects.begin(); i != effects.end(); ++i)
{
if (i->GetId() == _id)
{
@@ -469,10 +468,10 @@ void PokeGen::PokeMod::Map::DeleteMapEffect(const unsigned _id) LogSubmoduleRemoveFail("Map", id, "effect", _id, name);
}
-void PokeGen::PokeMod::Map::DeleteMapEffect(const String &n)
+void PokeGen::PokeMod::Map::DeleteMapEffect(const QString &n)
{
LogSubmoduleRemoveStart("Map", id, "effect", n, name);
- for (std::vector<MapEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
+ for (QList<MapEffect>::Iterator i = effects.begin(); i != effects.end(); ++i)
{
if (i->GetName() == n)
{
@@ -495,7 +494,7 @@ const PokeGen::PokeMod::MapTrainer *PokeGen::PokeMod::Map::GetMapTrainer(const u return NULL;
}
-const PokeGen::PokeMod::MapTrainer *PokeGen::PokeMod::Map::GetMapTrainer(const String &n) const
+const PokeGen::PokeMod::MapTrainer *PokeGen::PokeMod::Map::GetMapTrainer(const QString &n) const
{
LogSubmoduleFetch("Map", id, "trainer", n, name);
for (unsigned i = 0; i < GetMapTrainerCount(); ++i)
@@ -525,13 +524,13 @@ void PokeGen::PokeMod::Map::NewMapTrainer(Ini *const ini) if (ini)
newMapTrainer.ImportIni(*ini);
LogSubmoduleNew("Map", id, "trainer", i, name);
- trainers.push_back(newMapTrainer);
+ trainers.append(newMapTrainer);
}
void PokeGen::PokeMod::Map::DeleteMapTrainer(const unsigned _id)
{
LogSubmoduleRemoveStart("Map", id, "trainer", _id, name);
- for (std::vector<MapTrainer>::iterator i = trainers.begin(); i != trainers.end(); ++i)
+ for (QList<MapTrainer>::Iterator i = trainers.begin(); i != trainers.end(); ++i)
{
if (i->GetId() == _id)
{
@@ -542,10 +541,10 @@ void PokeGen::PokeMod::Map::DeleteMapTrainer(const unsigned _id) LogSubmoduleRemoveFail("Map", id, "trainer", _id, name);
}
-void PokeGen::PokeMod::Map::DeleteMapTrainer(const String &n)
+void PokeGen::PokeMod::Map::DeleteMapTrainer(const QString &n)
{
LogSubmoduleRemoveStart("Map", id, "trainer", n, name);
- for (std::vector<MapTrainer>::iterator i = trainers.begin(); i != trainers.end(); ++i)
+ for (QList<MapTrainer>::Iterator i = trainers.begin(); i != trainers.end(); ++i)
{
if (i->GetName() == n)
{
@@ -568,7 +567,7 @@ const PokeGen::PokeMod::MapWarp *PokeGen::PokeMod::Map::GetMapWarp(const unsigne return NULL;
}
-const PokeGen::PokeMod::MapWarp *PokeGen::PokeMod::Map::GetMapWarp(const String &n) const
+const PokeGen::PokeMod::MapWarp *PokeGen::PokeMod::Map::GetMapWarp(const QString &n) const
{
LogSubmoduleFetch("Map", id, "warp", n, name);
for (unsigned i = 0; i < GetMapWarpCount(); ++i)
@@ -598,13 +597,13 @@ void PokeGen::PokeMod::Map::NewMapWarp(Ini *const ini) if (ini)
newMapWarp.ImportIni(*ini);
LogSubmoduleNew("Map", id, "warp", i, name);
- warps.push_back(newMapWarp);
+ warps.append(newMapWarp);
}
void PokeGen::PokeMod::Map::DeleteMapWarp(const unsigned _id)
{
LogSubmoduleRemoveStart("Map", id, "warp", _id, name);
- for (std::vector<MapWarp>::iterator i = warps.begin(); i != warps.end(); ++i)
+ for (QList<MapWarp>::Iterator i = warps.begin(); i != warps.end(); ++i)
{
if (i->GetId() == _id)
{
@@ -615,10 +614,10 @@ void PokeGen::PokeMod::Map::DeleteMapWarp(const unsigned _id) LogSubmoduleRemoveFail("Map", id, "warp", _id, name);
}
-void PokeGen::PokeMod::Map::DeleteMapWarp(const String &n)
+void PokeGen::PokeMod::Map::DeleteMapWarp(const QString &n)
{
LogSubmoduleRemoveStart("Map", id, "warp", n, name);
- for (std::vector<MapWarp>::iterator i = warps.begin(); i != warps.end(); ++i)
+ for (QList<MapWarp>::Iterator i = warps.begin(); i != warps.end(); ++i)
{
if (i->GetName() == n)
{
@@ -659,13 +658,13 @@ void PokeGen::PokeMod::Map::NewMapWildList(Ini *const ini) if (ini)
newMapWildList.ImportIni(*ini);
LogSubmoduleNew("Map", id, "wild list", i, name);
- wildLists.push_back(newMapWildList);
+ wildLists.append(newMapWildList);
}
void PokeGen::PokeMod::Map::DeleteMapWildList(const unsigned _id)
{
LogSubmoduleRemoveStart("Map", id, "wild list", _id, name);
- for (std::vector<MapWildList>::iterator i = wildLists.begin(); i != wildLists.end(); ++i)
+ for (QList<MapWildList>::Iterator i = wildLists.begin(); i != wildLists.end(); ++i)
{
if (i->GetId() == _id)
{
|
