summaryrefslogtreecommitdiffstats
path: root/pokemod/MapTrainer.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-06-04 01:35:20 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-06-04 01:35:20 +0000
commit3595239f08f2bc1df32ef22ed6de9bde10ca3384 (patch)
treed9962c84e3a1f19e2da422f9bb49f65c21ada9f6 /pokemod/MapTrainer.cpp
parentc9afda3ab74614fb36986f96b7972c082f275eca (diff)
downloadsigen-3595239f08f2bc1df32ef22ed6de9bde10ca3384.tar.gz
sigen-3595239f08f2bc1df32ef22ed6de9bde10ca3384.tar.xz
sigen-3595239f08f2bc1df32ef22ed6de9bde10ca3384.zip
Style cleanup, minor Matrix fixes, duplication validations, Pokemod methods
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@19 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/MapTrainer.cpp')
-rw-r--r--pokemod/MapTrainer.cpp78
1 files changed, 46 insertions, 32 deletions
diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp
index a42299a3..5516e7e3 100644
--- a/pokemod/MapTrainer.cpp
+++ b/pokemod/MapTrainer.cpp
@@ -26,17 +26,17 @@
extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::MapTrainer::MapTrainer(const unsigned _id) :
- name(""),
- coordinate(0, 0),
- skin(""),
- sight(0),
- direction(UINT_MAX),
- ai(""),
- appearFlag(0, 0),
- overworldDialog(UINT_MAX),
- winDialog(UINT_MAX),
- loseDialog(UINT_MAX),
- leadPokemon(UINT_MAX)
+ name(""),
+ coordinate(0, 0),
+ skin(""),
+ sight(0),
+ direction(UINT_MAX),
+ ai(""),
+ appearFlag(0, 0),
+ overworldDialog(UINT_MAX),
+ winDialog(UINT_MAX),
+ loseDialog(UINT_MAX),
+ leadPokemon(UINT_MAX)
{
LogCtor("MapTrainer", _id);
id = _id;
@@ -104,16 +104,23 @@ void PokeGen::PokeMod::MapTrainer::Validate()
LogVarNotValid("MapTrainer", id, "leadPokemon", name);
isValid = false;
}
- // Check if there are any Pokémon defined
if (GetMapTrainerTeamCount())
{
- // Validate each Pokémon
+ std::map<unsigned, unsigned> idChecker;
for (std::vector<MapTrainerTeam>::iterator i = team.begin(); i != team.end(); ++i)
{
LogSubmoduleIterate("MapTrainer", id, "team Pokémon", i->GetId(), name);
- // If a Pokémon isn't valid, neither is the ability
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("MapTrainer", id, "team Pokémon", i->first, name);
+ isValid = false;
+ }
}
}
else
@@ -131,7 +138,7 @@ void PokeGen::PokeMod::MapTrainer::Validate(const wxListBox &output)
if (name == "")
{
LogVarNotSet("MapTrainer", id, "name");
- output.append(ConsoleLogVarNotSet("MapTrainer", id, "name"));
+ output.Append(ConsoleLogVarNotSet("MapTrainer", id, "name"));
isValid = false;
}
if (!skin.DoesExist())
@@ -139,19 +146,19 @@ void PokeGen::PokeMod::MapTrainer::Validate(const wxListBox &output)
if (skin == "")
{
LogVarNotSet("MapTrainer", id, "skin", name);
- output.append(ConsoleLogVarNotSet("MapTrainer", id, "skin", name));
+ output.Append(ConsoleLogVarNotSet("MapTrainer", id, "skin", name));
}
else
{
LogVarNotValid("MapTrainer", id, "skin", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "skin", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "skin", name));
}
isValid = false;
}
if (DIR_END_NONE <= direction)
{
LogVarNotValid("MapTrainer", id, "direction", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "direction", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "direction", name));
isValid = false;
}
if (!ai.DoesExist())
@@ -159,55 +166,63 @@ void PokeGen::PokeMod::MapTrainer::Validate(const wxListBox &output)
if (ai == "")
{
LogVarNotSet("MapTrainer", id, "ai", name);
- output.append(ConsoleLogVarNotSet("MapTrainer", id, "ai", name));
+ output.Append(ConsoleLogVarNotSet("MapTrainer", id, "ai", name));
}
else
{
LogVarNotValid("MapTrainer", id, "ai", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "ai", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "ai", name));
}
isValid = false;
}
if (!curPokeMod.GetDialog(overworldDialog))
{
LogVarNotValid("MapTrainer", id, "overworldDialog", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "overworldDialog", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "overworldDialog", name));
isValid = false;
}
if (!curPokeMod.GetDialog(winDialog))
{
LogVarNotValid("MapTrainer", id, "winDialog", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "winDialog", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "winDialog", name));
isValid = false;
}
if (!curPokeMod.GetDialog(loseDialog))
{
LogVarNotValid("MapTrainer", id, "loseDialog", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "loseDialog", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "loseDialog", name));
isValid = false;
}
if (!GetMapTrainerTeam(leadPokemon))
{
LogVarNotValid("MapTrainer", id, "leadPokemon", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "leadPokemon", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "leadPokemon", name));
isValid = false;
}
- // Check if there are any Pokémon defined
if (GetMapTrainerTeamCount())
{
- // Validate each Pokémon
+ std::map<unsigned, unsigned> idChecker;
for (std::vector<MapTrainerTeam>::iterator i = team.begin(); i != team.end(); ++i)
{
LogSubmoduleIterate("MapTrainer", id, "team Pokémon", i->GetId(), name);
- // If a Pokémon isn't valid, neither is the ability
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecekr.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("MapTrainer", id, "team Pokémon", i->first, name);
+ output.Append(ConsoleLogDuplicateId("MapTrainer", id, "team Pokémon", i->first, name));
+ isValid = false;
+ }
}
}
else
{
LogSubmoduleEmpty("MapTrainer", id, "team Pokémon", name);
- output.append(ConsoleLogSubmoduleEmpty("MapTrainer", id, "team Pokémon", name));
+ output.Append(ConsoleLogSubmoduleEmpty("MapTrainer", id, "team Pokémon", name));
isValid = false;
}
LogValidateOver("MapTrainer", id, isValid, name);
@@ -248,7 +263,7 @@ void PokeGen::PokeMod::MapTrainer::ImportIni(Ini &ini, const unsigned _id)
void PokeGen::PokeMod::MapTrainer::ExportIni(std::ofstream &fout, const String &map) const
{
LogExportStart("MapTrainer", id, name);
- Ini exMapTrainer(map + "MapTrainer");
+ Ini exMapTrainer("mapTrainer " + map);
exMapTrainer.AddField("id", id);
exMapTrainer.AddField("name", name);
exMapTrainer.AddField("name", name);
@@ -364,14 +379,14 @@ void PokeGen::PokeMod::MapTrainer::SetOverworldDialog(const unsigned o)
{
LogSetVar("MapTrainer", id, "overworldDialog", o, name);
if (curPokeMod.GetDialog(o))
- overworldDialog = o;
+ overworldDialog = o;
}
void PokeGen::PokeMod::MapTrainer::SetWinDialog(const unsigned w)
{
LogSetVar("MapTrainer", id, "winDialog", w, name);
if (curPokeMod.GetDialog(w))
- winDialog = w;
+ winDialog = w;
}
PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetName() const
@@ -534,7 +549,6 @@ unsigned PokeGen::PokeMod::MapTrainer::GetMapTrainerTeamCount() const
void PokeGen::PokeMod::MapTrainer::NewMapTrainerTeam(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetMapTrainerTeamCount(); ++i)
{
if (!GetMapTrainerTeam(i))