From 3595239f08f2bc1df32ef22ed6de9bde10ca3384 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 4 Jun 2007 01:35:20 +0000 Subject: 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 --- pokemod/Nature.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 11 deletions(-) (limited to 'pokemod/Nature.cpp') 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 idChecker; + std::map effectChecker; if (GetNatureEffectCount()) { - for (unsigned i = 0; i < GetNatureEffectCount(); ++i) + for (std::vector::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::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::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 idChecker; + std::map effectChecker; if (GetNatureEffectCount()) { - for (unsigned i = 0; i < GetNatureEffectCount(); ++i) + for (std::vector::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::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::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)) -- cgit