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/Store.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 14 deletions(-) (limited to 'pokemod/Store.cpp') diff --git a/pokemod/Store.cpp b/pokemod/Store.cpp index 5d75ac37..a7b6a3d7 100644 --- a/pokemod/Store.cpp +++ b/pokemod/Store.cpp @@ -26,7 +26,7 @@ extern PokeGen::PokeMod::Pokemod curPokeMod; PokeGen::PokeMod::Store::Store(const unsigned _id) : - name("") + name("") { LogCtor("Store", _id); id = _id; @@ -53,14 +53,42 @@ void PokeGen::PokeMod::Store::Validate() LogVarNotSet("Store", id, "name", name); isValid = false; } - for (unsigned i = 0; i < GetItemCount(); ++i) + if (GetItemCount()) { - if (!curPokeMod.GetItem(items[i])) + std::map idChecker; + std::map itemChecker; + for (std::vector::const_iterator i = items.begin(); i != items.end(); ++i) + { + if (!curPokeMod.GetItem(*i)) + { + LogVarNotValid("Store", id, "item", name); + isValid = false; + } + ++idChecker[*i]; + ++itemChecker[curPokeMod.GetItem(*i)->GetName()]; + } + for (std::map::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateId("Store", id, "item", i->first, name); + isValid = false; + } + } + for (std::map::const_iterator i = itemChecker.begin(); i != itemChecker.end(); ++i) { - LogSubmoduleEmpty("Store", id, "item", name); - isValid = false; + if (1 < i->second) + { + LogDuplicateSubmodule("Store", id, "item", i->first, name); + isValid = false; + } } } + else + { + LogSubmoduleEmpty("Store", id, "item", name); + isValid = false; + } LogValidateOver("Store", id, isValid, name); } @@ -74,15 +102,46 @@ void PokeGen::PokeMod::Store::Validate(const wxListBox &output) output.Append(ConsoleLogVarNotSet("Store", id, "name", name)); isValid = false; } - for (unsigned i = 0; i < GetItemCount(); ++i) + if (GetItemCount()) { - if (!curPokeGen::PokeMod.GetItem(items[i])) + std::map idChecker; + std::map itemChecker; + for (std::vector::const_iterator i = items.begin(); i != items.end(); ++i) + { + if (!curPokeMod.GetItem(*i)) + { + LogVarNotValid("Store", id, "item", name); + output.Append(ConsoleLogVarNotValid("Store", id, "item", name)); + isValid = false; + } + ++idChecker[*i]; + ++itemChecker[curPokeMod.GetItem(*i)->GetName()]; + } + for (std::map::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateId("Store", id, "item", i->first, name); + output.Append(ConsoleLogDuplicateId("Store", id, "item", i->first, name)); + isValid = false; + } + } + for (std::map::const_iterator i = itemChecker.begin(); i != itemChecker.end(); ++i) { - LogSubmoduleEmpty("Store", id, "item", name); - output.Append(ConsoleLogVarNotSet("Store", id, "item", name)); - isValid = false; + if (1 < i->second) + { + LogDuplicateSubmodule("Store", id, "item", i->first, name); + output.Append(ConsoleLogDuplicateSubmodule("Store", id, "item", i->first, name)); + isValid = false; + } } } + else + { + LogSubmoduleEmpty("Store", id, "item", name); + output.Append(ConsoleLogSubmoduleEmpty("Store", id, "item", name)); + isValid = false; + } LogValidateOver("Store", id, isValid, name); } #endif @@ -93,7 +152,6 @@ void PokeGen::PokeMod::Store::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("Store"); } @@ -102,7 +160,7 @@ void PokeGen::PokeMod::Store::ImportIni(Ini &ini, const unsigned _id) items.clear(); unsigned i; unsigned j; - ini.GetValue("name", name, ""); + ini.GetValue("name", name); ini.GetValue("numItems", i, 0); for (unsigned k = 0; k < i; ++k) { @@ -116,7 +174,6 @@ void PokeGen::PokeMod::Store::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::Store::ExportIni(std::ofstream &fout) const { LogExportStart("Store", id, name); - // Make elements Ini exStore("store"); exStore.AddField("id", id); exStore.AddField("name", name); @@ -133,7 +190,7 @@ void PokeGen::PokeMod::Store::SetName(const String &n) name = n; } -PokeGen::PokeMod::String PokeGen::PokeMod::Store::GetName() +PokeGen::PokeMod::String PokeGen::PokeMod::Store::GetName() const { LogFetchVar("Store", id, "name", name, name); return name; -- cgit