diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2007-06-04 01:35:20 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2007-06-04 01:35:20 +0000 |
| commit | 3595239f08f2bc1df32ef22ed6de9bde10ca3384 (patch) | |
| tree | d9962c84e3a1f19e2da422f9bb49f65c21ada9f6 /pokemod/CoinList.cpp | |
| parent | c9afda3ab74614fb36986f96b7972c082f275eca (diff) | |
| download | sigen-3595239f08f2bc1df32ef22ed6de9bde10ca3384.tar.gz sigen-3595239f08f2bc1df32ef22ed6de9bde10ca3384.tar.xz sigen-3595239f08f2bc1df32ef22ed6de9bde10ca3384.zip | |
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
Diffstat (limited to 'pokemod/CoinList.cpp')
| -rw-r--r-- | pokemod/CoinList.cpp | 86 |
1 files changed, 75 insertions, 11 deletions
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<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> itemChecker;
+ std::map<String, unsigned> pokemonChecker;
+ for (std::vector<CoinItem>::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<unsigned, unsigned>::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<String, unsigned>::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<String, unsigned>::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<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> itemChecker;
+ std::map<String, unsigned> pokemonChecker;
+ for (std::vector<CoinItem>::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<unsigned, unsigned>::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<String, unsigned>::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<String, unsigned>::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))
|
