diff options
Diffstat (limited to 'pokemod/Nature.cpp')
| -rw-r--r-- | pokemod/Nature.cpp | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp index e7ff5c93..c6059ccb 100644 --- a/pokemod/Nature.cpp +++ b/pokemod/Nature.cpp @@ -24,7 +24,7 @@ #include "Nature.h"
PokeGen::PokeMod::Nature::Nature(const unsigned _id) :
- name("")
+ name("")
{
LogCtor("Nature", _id);
id = _id;
@@ -51,13 +51,33 @@ void PokeGen::PokeMod::Nature::Validate() LogVarNotSet("Nature", id, "name");
isValid = false;
}
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
if (GetNatureEffectCount())
{
- for (unsigned i = 0; i < GetNatureEffectCount(); ++i)
+ for (std::vector<NatureEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
- LogSubmoduleIterate("Nature", id, "effect", i, name);
- if (!effects[i].IsValid())
+ LogSubmoduleIterate("Nature", id, "effect", i->GetId(), name);
+ if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ ++effectChecker[i->GetStatString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Nature", id, "effect", i->first, name);
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Nature", id, "effect", i->first, name);
+ isValid = false;
+ }
}
}
else
@@ -75,16 +95,38 @@ void PokeGen::PokeMod::Nature::Validate(const wxListBox &output) if (name == "")
{
LogVarNotSet("Nature", id, "name");
- output.Append(ConsoleLogVarNotSet("Nature", id, "name");
+ output.Append(ConsoleLogVarNotSet("Nature", id, "name"));
isValid = false;
}
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
if (GetNatureEffectCount())
{
- for (unsigned i = 0; i < GetNatureEffectCount(); ++i)
+ for (std::vector<NatureEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
+ {
+ LogSubmoduleIterate("Nature", id, "effect", i->GetId(), name);
+ if (!i->IsValid())
+ isValid = false;
+ ++idChecker[i->GetId()];
+ ++effectChecker[i->GetEffectString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Nature", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Nature", id, "effect", i->first, name));
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i)
{
- LogSubmoduleIterate("Nature", "effect", id, i, name);
- if (!effects[i].IsValid())
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Nature", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Nature", id, "effect", i->first, name));
isValid = false;
+ }
}
}
else
@@ -104,13 +146,12 @@ void PokeGen::PokeMod::Nature::ImportIni(Ini &ini, const unsigned _id) if (_id == UINT_MAX)
{
ini.GetValue("id", id);
- // Was there an id associated with the section?
if (id == UINT_MAX)
LogIdNotFound("Nature");
}
else
id = _id;
- ini.GetValue("name", name, "");
+ ini.GetValue("name", name);
effects.clear();
LogImportOver("Nature");
}
@@ -159,7 +200,6 @@ unsigned PokeGen::PokeMod::Nature::GetNatureEffectCount() const void PokeGen::PokeMod::Nature::NewNatureEffect(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetNatureEffectCount(); ++i)
{
if (!GetNatureEffect(i))
|
