summaryrefslogtreecommitdiffstats
path: root/pokemod/Item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/Item.cpp')
-rw-r--r--pokemod/Item.cpp66
1 files changed, 53 insertions, 13 deletions
diff --git a/pokemod/Item.cpp b/pokemod/Item.cpp
index 7a2457d1..1e9d1c2c 100644
--- a/pokemod/Item.cpp
+++ b/pokemod/Item.cpp
@@ -26,11 +26,11 @@
extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::Item::Item(const unsigned _id) :
- name(""),
- sellable(false),
- type(UINT_MAX),
- price(0),
- description("")
+ name(""),
+ sellable(false),
+ type(UINT_MAX),
+ price(0),
+ description("")
{
LogCtor("Item", _id);
id = _id;
@@ -64,11 +64,31 @@ void PokeGen::PokeMod::Item::Validate()
}
if (GetItemEffectCount())
{
- for (unsigned i = 0; i < GetItemEffectCount(); ++i)
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
+ for (std::vector<ItemEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
- LogSubmoduleIterate("Item", id, "effect", i, name);
- if (!effects[i].IsValid())
+ LogSubmoduleIterate("Item", id, "effect", i->GetId(), name);
+ if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ ++effectChecker[i->GetEffectString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Item", id, "effect", i->first, name);
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Item", id, "effect", i->first, name);
+ isValid = false;
+ }
}
}
else
@@ -97,11 +117,33 @@ void PokeGen::PokeMod::Item::Validate(const wxListBox &output)
}
if (GetItemEffectCount())
{
- for (unsigned i = 0; i < GetItemEffectCount(); ++i)
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
+ for (std::vector<ItemEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
+ {
+ LogSubmoduleIterate("Item", id, "effect", i->GetId(), name);
+ if (!i->IsValid())
+ isValid = false;
+ ++idChecker[i->GetId()];
+ ++effectChecker[i->GetEffectString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Item", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Item", id, "effect", i->first, name));
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i)
{
- LogSubmoduleIterate("Item", id, "effect", i, name);
- if (!effects[i].IsValid())
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Item", id, "effect", i->first, name);
+ output.Append(LogDuplicateSubmodule("Item", id, "effect", i->first, name));
isValid = false;
+ }
}
}
else
@@ -120,7 +162,6 @@ void PokeGen::PokeMod::Item::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("Item");
}
@@ -249,7 +290,6 @@ unsigned PokeGen::PokeMod::Item::GetItemEffectCount() const
void PokeGen::PokeMod::Item::NewItemEffect(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetItemEffectCount(); ++i)
{
if (!GetItemEffect(i))