summaryrefslogtreecommitdiffstats
path: root/pokemod/Store.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-06-04 01:35:20 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-06-04 01:35:20 +0000
commit3595239f08f2bc1df32ef22ed6de9bde10ca3384 (patch)
treed9962c84e3a1f19e2da422f9bb49f65c21ada9f6 /pokemod/Store.cpp
parentc9afda3ab74614fb36986f96b7972c082f275eca (diff)
downloadsigen-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/Store.cpp')
-rw-r--r--pokemod/Store.cpp85
1 files changed, 71 insertions, 14 deletions
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<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> itemChecker;
+ for (std::vector<unsigned>::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<unsigned, unsigned>::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<String, unsigned>::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<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> itemChecker;
+ for (std::vector<unsigned>::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<unsigned, unsigned>::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<String, unsigned>::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;