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/CoinList.cpp | 86 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 75 insertions(+), 11 deletions(-) (limited to 'pokemod/CoinList.cpp') diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp index 08bc019d..5a3c3fc2 100644 --- a/pokemod/CoinList.cpp +++ b/pokemod/CoinList.cpp @@ -27,8 +27,8 @@ extern PokeGen::PokeMod::Pokemod curPokeMod; PokeGen::PokeMod::CoinList::CoinList(const unsigned _id) : - name(""), - value(0) + name(""), + value(0) { LogCtor("CoinList", _id); id = _id; @@ -57,11 +57,43 @@ void PokeGen::PokeMod::CoinList::Validate() } if (GetCoinItemCount()) { - for (unsigned i = 0; i < GetCoinItemCount(); ++i) + std::map idChecker; + std::map itemChecker; + std::map pokemonChecker; + for (std::vector::iterator i = items.begin(); i != items.end(); ++i) { - LogSubmoduleIterate("CoinList", id, "item", i, name); - if (!items[i].IsValid()) + LogSubmoduleIterate("CoinList", id, "item", i->GetId(), name); + if (!i->IsValid()) isValid = false; + ++idChecker[i->GetId()]; + if (i->GetType() == CIT_ITEM) + ++itemChecker[i->GetObjectString()]; + else if (i->GetType() == CIT_POKEMON) + ++pokemonChecker[i->GetObjectString()]; + } + for (std::map::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateId("CoinList", id, "coin item", i->first, name); + isValid = false; + } + } + for (std::map::const_iterator i = itemChecker.begin(); i != itemChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateSubmodule("CoinList", id, "item", i->first, name); + isValid = false; + } + } + for (std::map::const_iterator i = pokemonChecker.begin(); i != pokemonChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateSubmodule("CoinList", id, "Pokémon", i->first, name); + isValid = false; + } } } else @@ -84,11 +116,46 @@ void PokeGen::PokeMod::CoinList::Validate(const wxListBox &output) } if (GetCoinItemCount()) { - for (unsigned i = 0; i < GetCoinItemCount(); ++i) + std::map idChecker; + std::map itemChecker; + std::map pokemonChecker; + for (std::vector::iterator i = items.begin(); i != items.end(); ++i) + { + LogSubmoduleIterate("CoinList", id, "item", i->GetId(), name); + if (!i->IsValid()) + isValid = false; + ++idChecker[i->GetId()]; + if (i->GetType() == CIT_ITEM) + ++itemChecker[i->GetObjectString()]; + else if (i->GetType() == CIT_POKEMON) + ++pokemonChecker[i->GetObjectString()]; + } + for (std::map::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateId("CoinList", id, "coin item", i->first, name); + output.Append(ConsoleLogDuplicateId("CoinList", id, "coin item", i->first, name)); + isValid = false; + } + } + for (std::map::const_iterator i = itemChecker.begin(); i != itemChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateSubmodule("CoinList", id, "item", i->first, name); + output.Append(ConsoleLogDuplicateSubmodule("CoinList", id, "item", i->first, name)); + isValid = false; + } + } + for (std::map::const_iterator i = pokemonChecker.begin(); i != pokemonChecker.end(); ++i) { - LogSubmoduleIterate("CoinList", id, "item", i, name); - if (!items[i].IsValid()) + if (1 < i->second) + { + LogDuplicateSubmodule("CoinList", id, "Pokémon", i->first, name); + output.Append(ConsoleLogDuplicateSubmodule("CoinList", id, "Pokémon", i->first, name)); isValid = false; + } } } else @@ -107,7 +174,6 @@ void PokeGen::PokeMod::CoinList::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("CoinList"); } @@ -122,7 +188,6 @@ void PokeGen::PokeMod::CoinList::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::CoinList::ExportIni(std::ofstream &fout) const { LogExportStart("CoinList", id, name); - // Make elements Ini exCoinList("coinList"); exCoinList.AddField("id", id); exCoinList.AddField("name", name); @@ -190,7 +255,6 @@ unsigned PokeGen::PokeMod::CoinList::GetCoinItemCount() const void PokeGen::PokeMod::CoinList::NewCoinItem(Ini *const ini) { unsigned i = 0; - // Find the first unused ID in the vector for (; i < GetCoinItemCount(); ++i) { if (!GetCoinItem(i)) -- cgit