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/Ability.cpp | 61 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 15 deletions(-) (limited to 'pokemod/Ability.cpp') diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp index 102348c8..01396882 100644 --- a/pokemod/Ability.cpp +++ b/pokemod/Ability.cpp @@ -25,7 +25,7 @@ #include "Ability.h" PokeGen::PokeMod::Ability::Ability(const unsigned _id) : - name("") + name("") { LogCtor("Ability", id); id = _id; @@ -47,22 +47,38 @@ PokeGen::PokeMod::Ability::~Ability() void PokeGen::PokeMod::Ability::Validate() { LogValidateStart("Ability", id, name); - // Make sure the name is set to something if (name == "") { - LogVarNotSet("Ability", id, "Name", name); + LogVarNotSet("Ability", id, "name"); isValid = false; } - // Check if there are any effects defined if (GetAbilityEffectCount()) { - // Validate each effect + std::map idChecker; + std::map effectChecker; for (std::vector::iterator i = effects.begin(); i != effects.end(); ++i) { LogSubmoduleIterate("Ability", id, "effect", i->GetId(), name); - // If an effect isn't valid, neither is the ability 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("Ability", id, "effect", i->first, name); + isValid = false; + } + } + for (std::map::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateSubmodule("Ability", id, "effect", i->first, name); + isValid = false; + } } } else @@ -77,23 +93,41 @@ void PokeGen::PokeMod::Ability::Validate() void PokeGen::PokeMod::Ability::Validate(const wxListBox &output) { LogValidateStart("Ability", id, name); - // Make sure the name is set to something if (name == "") { - LogVarNotSet("Ability", id, "Name", name); - output.Append(ConsoleLogVarNotSet("Ability", id, "Name", name)); + LogVarNotSet("Ability", id, "name"); + output.Append(ConsoleLogVarNotSet("Ability", id, "name")); isValid = false; } - // Check if there are any effects defined if (GetAbilityEffectCount()) { - // Validate each effect + std::map idChecker; + std::map effectChecker; for (std::vector::iterator i = effects.begin(); i != effects.end(); ++i) { LogSubmoduleIterate("Ability", id, "effect", i->GetId(), name); - // If an effect isn't valid, neither is the ability 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("Ability", id, "effect", i->first, name); + output.Append(ConsoleLogDuplicateId("Ability", id, "effect", i->first, name)); + isValid = false; + } + } + for (std::map::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateSubmodule("Ability", id, "effect", i->first, name); + output.Append(ConsoleLogDuplicateSubmodule("Ability", id, "effect", i->first, name)); + isValid = false; + } } } else @@ -112,7 +146,6 @@ void PokeGen::PokeMod::Ability::ImportIni(Ini &ini, const unsigned _id) if (_id == UINT_MAX) { ini.GetValue("id", id); - // Was there an id associated with the element? if (id == UINT_MAX) LogIdNotFound("Ability"); } @@ -126,7 +159,6 @@ void PokeGen::PokeMod::Ability::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::Ability::ExportIni(std::ofstream &fout) const { LogExportStart("Ability", id, name); - // Make elements Ini exAbility("ability"); exAbility.AddField("id", id); exAbility.AddField("name", name); @@ -169,7 +201,6 @@ unsigned PokeGen::PokeMod::Ability::GetAbilityEffectCount() const void PokeGen::PokeMod::Ability::NewAbilityEffect(Ini *const ini) { unsigned i = 0; - // Find the first unused ID in the vector for (; i < GetAbilityEffectCount(); ++i) { if (!GetAbilityEffect(i)) -- cgit