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/Status.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 18 deletions(-) (limited to 'pokemod/Status.cpp') diff --git a/pokemod/Status.cpp b/pokemod/Status.cpp index d867a436..b09de29a 100644 --- a/pokemod/Status.cpp +++ b/pokemod/Status.cpp @@ -27,13 +27,13 @@ extern PokeGen::PokeMod::Pokemod curPokeMod; PokeGen::PokeMod::Status::Status(const unsigned _id) : - name(""), - abbreviation(""), - verb(""), - afterSwitch(UINT_MAX), - afterBattle(UINT_MAX), - maxTurns(0), - catchBonus(0) + name(""), + abbreviation(""), + verb(""), + afterSwitch(UINT_MAX), + afterBattle(UINT_MAX), + maxTurns(0), + catchBonus(0) { LogCtor("Status", id); id = _id; @@ -57,13 +57,21 @@ void PokeGen::PokeMod::Status::Validate() LogValidateStart("Status", id, name); if (name == "") { - LogVarNotSet("Status", id, "name", name); + LogVarNotSet("Status", id, "name"); + isValid = false; + } + else if ((name == "Clear") || (name == "Any")) + { + LogVarNotValid("Status", id, "name", name); isValid = false; } if (abbreviation == "") LogVarNotSet("Status", id, "abbreviation", name); else if (4 <= abbreviation.length()) + { LogVarNotValid("Status", id, "abbreviation", name); + isValid = false; + } if (verb == "") LogVarNotSet("Status", id, "verb", name); if (afterSwitch == UINT_MAX) @@ -80,16 +88,33 @@ void PokeGen::PokeMod::Status::Validate() LogVarNotValid("Status", id, "afterBattle", name); isValid = false; } - // Check if there are any effects defined if (GetStatusEffectCount()) { - // Validate each effect + std::map idChecker; + std::map effectChecker; for (std::vector::iterator i = effects.begin(); i != effects.end(); ++i) { LogSubmoduleIterate("Status", id, "effect", i->GetId(), name); - // If an effect isn't valid, neither is the Status 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("Status", id, "effect", i->first, name); + isValid = false; + } + } + for (std::map::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateSubmodule("Status", id, "effect", i->first, name); + isValid = false; + } } } else @@ -110,6 +135,11 @@ void PokeGen::PokeMod::Status::Validate(const wxListBox &output) output.Append(ConsoleLogVarNotSet("Status", id, "Name", name)); isValid = false; } + else if (name == "Clear") + { + LogVarNotValid("Status", id, "name", name); + isValid = false; + } if (abbreviation == "") { LogVarNotSet("Status", id, "abbreviation", name); @@ -118,7 +148,8 @@ void PokeGen::PokeMod::Status::Validate(const wxListBox &output) else if (4 <= abbreviation.length()) { LogVarNotValid("Status", id, "abbreviation", name); - output.Append(ConsoleLogVarNotValidW("Status", id, "abbreviation", name)); + output.Append(ConsoleLogVarNotValid("Status", id, "abbreviation", name)); + isValid = false; } if (verb == "") { @@ -147,16 +178,35 @@ void PokeGen::PokeMod::Status::Validate(const wxListBox &output) output.Append(ConsoleLogVarNotValid("Status", id, "afterBattle", name)); isValid = false; } - // Check if there are any effects defined if (GetStatusEffectCount()) { - // Validate each effect + std::map idChecker; + std::map effectChecker; for (std::vector::iterator i = effects.begin(); i != effects.end(); ++i) { LogSubmoduleIterate("Status", id, "effect", i->GetId(), name); - // If an effect isn't valid, neither is the Status 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("Status", id, "effect", i->first, name); + output.Append(ConsoleLogDuplicateId("Status", id, "effect", i->first, name)); + isValid = false; + } + } + for (std::map::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateSubmodule("Status", id, "effect", i->first, name); + output.Append(LogDuplicateSubmodule("Status", id, "effect", i->first, name)); + isValid = false; + } } } else @@ -175,7 +225,6 @@ void PokeGen::PokeMod::Status::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("Status"); } @@ -195,7 +244,6 @@ void PokeGen::PokeMod::Status::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::Status::ExportIni(std::ofstream &fout) const { LogExportStart("Status", id, name); - // Make elements Ini exStatus("Status"); exStatus.AddField("id", id); exStatus.AddField("name", name); @@ -353,7 +401,6 @@ unsigned PokeGen::PokeMod::Status::GetStatusEffectCount() const void PokeGen::PokeMod::Status::NewStatusEffect(Ini *const ini) { unsigned i = 0; - // Find the first unused ID in the vector for (; i < GetStatusEffectCount(); ++i) { if (!GetStatusEffect(i)) -- cgit