diff options
Diffstat (limited to 'pokemod/MapTrainer.cpp')
| -rw-r--r-- | pokemod/MapTrainer.cpp | 147 |
1 files changed, 73 insertions, 74 deletions
diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp index e1bbeab6..e1c9e4fb 100644 --- a/pokemod/MapTrainer.cpp +++ b/pokemod/MapTrainer.cpp @@ -6,19 +6,18 @@ // Created: Fri June 1 2007 23:11:28
// 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
// MERCHANTABILITY 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 "MapTrainer.h"
@@ -28,7 +27,7 @@ PokeGen::PokeMod::MapTrainer::MapTrainer(const Pokemod *par, const unsigned _id) coordinate(0, 0),
skin(""),
sight(0),
- direction(UINT_MAX), + direction(UINT_MAX),
numFight(1),
ai(""),
appearFlag(0, 0),
@@ -64,20 +63,20 @@ void PokeGen::PokeMod::MapTrainer::Validate() LogVarNotSet("MapTrainer", id, "name");
isValid = false;
}
- if (!Path(pokemod->GetPath() + "skins/" + skin).DoesExist()) - { - LogVarNotValid("MapTrainer", id, "skin", name); - isValid = false; - } + if (!Path(pokemod->GetPath() + "skins/" + skin).DoesExist())
+ {
+ LogVarNotValid("MapTrainer", id, "skin", name);
+ isValid = false;
+ }
if (DIR_END_NONE <= direction)
{
LogVarNotValid("MapTrainer", id, "direction", name);
isValid = false;
- } - if (!numFight || (pokemod->GetMaxFight() < numFight)) - { - LogVarNotValid("MapTrainer", id, "maxFight", name); - isValid = false; + }
+ if (!numFight || (pokemod->GetMaxFight() < numFight))
+ {
+ LogVarNotValid("MapTrainer", id, "maxFight", name);
+ isValid = false;
}
if (!Path(pokemod->GetPath() + "ai/" + ai).DoesExist())
{
@@ -106,19 +105,19 @@ void PokeGen::PokeMod::MapTrainer::Validate() }
if (GetMapTrainerTeamCount())
{
- std::map<unsigned, unsigned> idChecker;
- for (std::vector<MapTrainerTeam>::iterator i = team.begin(); i != team.end(); ++i)
+ QMap<unsigned, unsigned> idChecker;
+ for (QList<MapTrainerTeam>::Iterator i = team.begin(); i != team.end(); ++i)
{
LogSubmoduleIterate("MapTrainer", id, "team Pokémon", 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("MapTrainer", id, "team Pokémon", i->first, name);
+ LogDuplicateId("MapTrainer", id, "team Pokémon", i.key(), name);
isValid = false;
}
}
@@ -150,8 +149,8 @@ void PokeGen::PokeMod::MapTrainer::ImportIni(Ini &ini, const unsigned _id) coordinate.Set(i, j);
ini.GetValue("skin", skin);
ini.GetValue("sight", sight, 0);
- ini.GetValue("direction", direction); - ini.GetValue("numFight", numFight, 1); + ini.GetValue("direction", direction);
+ ini.GetValue("numFight", numFight, 1);
ini.GetValue("ai", ai);
ini.GetValue("appearFlag-f", i, 0);
ini.GetValue("appearFlag-s", j, 0);
@@ -163,7 +162,7 @@ void PokeGen::PokeMod::MapTrainer::ImportIni(Ini &ini, const unsigned _id) LogImportOver("MapTrainer", id, name);
}
-void PokeGen::PokeMod::MapTrainer::ExportIni(std::ofstream &fout, const String &map) const
+void PokeGen::PokeMod::MapTrainer::ExportIni(QFile &fout, const QString &map) const
{
LogExportStart("MapTrainer", id, name);
Ini exMapTrainer("mapTrainer " + map);
@@ -174,7 +173,7 @@ void PokeGen::PokeMod::MapTrainer::ExportIni(std::ofstream &fout, const String & exMapTrainer.AddField("coordinate-y", coordinate.GetY());
exMapTrainer.AddField("skin", skin);
exMapTrainer.AddField("sight", sight);
- exMapTrainer.AddField("direction", direction); + exMapTrainer.AddField("direction", direction);
exMapTrainer.AddField("numFight", numFight);
exMapTrainer.AddField("ai", ai);
exMapTrainer.AddField("appearFlag-f", appearFlag.GetFlag());
@@ -184,12 +183,12 @@ void PokeGen::PokeMod::MapTrainer::ExportIni(std::ofstream &fout, const String & exMapTrainer.AddField("loseDialog", loseDialog);
exMapTrainer.AddField("leadPokemon", leadPokemon);
exMapTrainer.Export(fout);
- for (std::vector<MapTrainerTeam>::const_iterator i = team.begin(); i != team.end(); ++i)
+ for (QList<MapTrainerTeam>::ConstIterator i = team.begin(); i != team.end(); ++i)
i->ExportIni(fout, map, id);
LogExportOver("MapTrainer", id, name);
}
-void PokeGen::PokeMod::MapTrainer::SetName(const String &n)
+void PokeGen::PokeMod::MapTrainer::SetName(const QString &n)
{
LogSetVar("MapTrainer", id, "name", n);
name = n;
@@ -222,8 +221,8 @@ void PokeGen::PokeMod::MapTrainer::SetCoordinateY(const unsigned y) void PokeGen::PokeMod::MapTrainer::SetSkin(const Path &s)
{
LogSetVar("MapTrainer", id, "skin", s, name);
- skin = s.GetFilename(); - s.CopyTo(pokemod->GetPath() + "skins/" + skin); + skin = s.GetFilename();
+ s.CopyTo(pokemod->GetPath() + "skins/" + skin);
}
void PokeGen::PokeMod::MapTrainer::SetSight(const unsigned s)
@@ -237,16 +236,16 @@ void PokeGen::PokeMod::MapTrainer::SetDirection(const unsigned d) LogSetVar("MapTrainer", id, "direction", d, name);
if (d < DIR_END_NONE)
direction = d;
-} - -void PokeGen::PokeMod::MapTrainer::SetNumFight(const unsigned m) -{ - LogSetVar("MapTrainer", id, "maxFight", m, name); - if (m && (m <= pokemod->GetMaxFight())) - numFight = m; }
-void PokeGen::PokeMod::MapTrainer::SetDirection(const String &d)
+void PokeGen::PokeMod::MapTrainer::SetNumFight(const unsigned m)
+{
+ LogSetVar("MapTrainer", id, "maxFight", m, name);
+ if (m && (m <= pokemod->GetMaxFight()))
+ numFight = m;
+}
+
+void PokeGen::PokeMod::MapTrainer::SetDirection(const QString &d)
{
SetDirection(FindIn(DIR_END_NONE, d, DirectionStr));
}
@@ -254,8 +253,8 @@ void PokeGen::PokeMod::MapTrainer::SetDirection(const String &d) void PokeGen::PokeMod::MapTrainer::SetAI(const Path &a)
{
LogSetVar("MapTrainer", id, "ai", a, name);
- ai = a.GetFilename(); - a.CopyTo(pokemod->GetPath() + "ai/" + ai); + ai = a.GetFilename();
+ a.CopyTo(pokemod->GetPath() + "ai/" + ai);
}
void PokeGen::PokeMod::MapTrainer::SetAppearFlag(const Flag &a)
@@ -283,7 +282,7 @@ void PokeGen::PokeMod::MapTrainer::SetAppearFlagStatus(const unsigned s) appearFlag.SetStatus(s);
}
-void PokeGen::PokeMod::MapTrainer::SetAppearFlagStatus(const String &s)
+void PokeGen::PokeMod::MapTrainer::SetAppearFlagStatus(const QString &s)
{
SetAppearFlagStatus(FindIn(FV_END, s, FlagValueStr));
}
@@ -302,7 +301,7 @@ void PokeGen::PokeMod::MapTrainer::SetWinDialog(const unsigned w) winDialog = w;
}
-PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetName() const
+QString PokeGen::PokeMod::MapTrainer::GetName() const
{
LogFetchVar("MapTrainer", id, "name", name);
return name;
@@ -326,17 +325,17 @@ unsigned PokeGen::PokeMod::MapTrainer::GetCoordinateY() const return coordinate.GetY();
}
-bool PokeGen::PokeMod::MapTrainer::GetSkinExists() const -{ - LogFetchVar("MapTrainer", id, "skin exists", skin, name); - return GetSkin().DoesExist(); -} - -PokeGen::PokeMod::Path PokeGen::PokeMod::MapTrainer::GetSkin() const -{ - LogFetchVar("MapTrainer", id, "skins", skin, name); - return Path(pokemod->GetPath() + "skins/" + skin); -} +bool PokeGen::PokeMod::MapTrainer::GetSkinExists() const
+{
+ LogFetchVar("MapTrainer", id, "skin exists", skin, name);
+ return GetSkin().DoesExist();
+}
+
+PokeGen::PokeMod::Path PokeGen::PokeMod::MapTrainer::GetSkin() const
+{
+ LogFetchVar("MapTrainer", id, "skins", skin, name);
+ return Path(pokemod->GetPath() + "skins/" + skin);
+}
unsigned PokeGen::PokeMod::MapTrainer::GetSight() const
{
@@ -349,14 +348,14 @@ unsigned PokeGen::PokeMod::MapTrainer::GetDirection() const LogFetchVar("MapTrainer", id, "direction", direction, name);
return direction;
}
- -unsigned PokeGen::PokeMod::MapTrainer::GetNumFight() const -{ - LogFetchVar("MapTrainer", id, "numFight", numFight, name); - return numFight; -} -PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetDirectionString() const
+unsigned PokeGen::PokeMod::MapTrainer::GetNumFight() const
+{
+ LogFetchVar("MapTrainer", id, "numFight", numFight, name);
+ return numFight;
+}
+
+QString PokeGen::PokeMod::MapTrainer::GetDirectionString() const
{
LogFetchVar("MapTrainer", id, "direction string", direction, name);
if (direction < DIR_END_NONE)
@@ -364,16 +363,16 @@ PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetDirectionString() cons return "";
}
-bool PokeGen::PokeMod::MapTrainer::GetAIExists() const -{ - LogFetchVar("MapTrainer", id, "ai exists", ai, name); - return GetAI().DoesExist(); -} - +bool PokeGen::PokeMod::MapTrainer::GetAIExists() const
+{
+ LogFetchVar("MapTrainer", id, "ai exists", ai, name);
+ return GetAI().DoesExist();
+}
+
PokeGen::PokeMod::Path PokeGen::PokeMod::MapTrainer::GetAI() const
{
LogFetchVar("MapTrainer", id, "ai", ai, name);
- return Path(pokemod->GetPath() + "ai/" + ai); + return Path(pokemod->GetPath() + "ai/" + ai);
}
PokeGen::PokeMod::Flag PokeGen::PokeMod::MapTrainer::GetAppearFlag() const
@@ -394,7 +393,7 @@ unsigned PokeGen::PokeMod::MapTrainer::GetAppearFlagStatus() const return appearFlag.GetStatus();
}
-PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetAppearFlagStatusString() const
+QString PokeGen::PokeMod::MapTrainer::GetAppearFlagStatusString() const
{
LogFetchVar("MapTrainer", id, "appearFlag status string", appearFlag.GetStatus(), name);
return appearFlag.GetStatusString();
@@ -406,7 +405,7 @@ unsigned PokeGen::PokeMod::MapTrainer::GetOverworldDialog() const return overworldDialog;
}
-PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetOverworldDialogString() const
+QString PokeGen::PokeMod::MapTrainer::GetOverworldDialogString() const
{
LogFetchVar("MapTrainer", id, "overworldDialog string", overworldDialog, name);
if (const Dialog *d = pokemod->GetDialog(overworldDialog))
@@ -420,7 +419,7 @@ unsigned PokeGen::PokeMod::MapTrainer::GetWinDialog() const return winDialog;
}
-PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetWinDialogString() const
+QString PokeGen::PokeMod::MapTrainer::GetWinDialogString() const
{
LogFetchVar("MapTrainer", id, "winDialog string", winDialog, name);
if (const Dialog *d = pokemod->GetDialog(winDialog))
@@ -434,7 +433,7 @@ unsigned PokeGen::PokeMod::MapTrainer::GetLoseDialog() const return loseDialog;
}
-PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetLoseDialogString() const
+QString PokeGen::PokeMod::MapTrainer::GetLoseDialogString() const
{
LogFetchVar("MapTrainer", id, "loseDialog string", loseDialog, name);
if (const Dialog *d = pokemod->GetDialog(loseDialog))
@@ -448,7 +447,7 @@ unsigned PokeGen::PokeMod::MapTrainer::GetLeadPokemon() const return leadPokemon;
}
-PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetLeadPokemonString() const
+QString PokeGen::PokeMod::MapTrainer::GetLeadPokemonString() const
{
LogFetchVar("MapTrainer", id, "leadPokemon string", leadPokemon, name);
if (const MapTrainerTeam *s = GetMapTrainerTeam(leadPokemon))
@@ -489,13 +488,13 @@ void PokeGen::PokeMod::MapTrainer::NewMapTrainerTeam(Ini *const ini) if (ini)
newMapTrainerTeam.ImportIni(*ini);
LogSubmoduleNew("MapTrainer", id, "team member", i, name);
- team.push_back(newMapTrainerTeam);
+ team.append(newMapTrainerTeam);
}
void PokeGen::PokeMod::MapTrainer::DeleteMapTrainerTeam(const unsigned _id)
{
LogSubmoduleRemoveStart("MapTrainer", id, "team member", _id, name);
- for (std::vector<MapTrainerTeam>::iterator i = team.begin(); i != team.end(); ++i)
+ for (QList<MapTrainerTeam>::Iterator i = team.begin(); i != team.end(); ++i)
{
if (i->GetId() == _id)
{
|
