summaryrefslogtreecommitdiffstats
path: root/pokemod/CoinList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/CoinList.cpp')
-rw-r--r--pokemod/CoinList.cpp86
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))