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 | |
| parent | c9afda3ab74614fb36986f96b7972c082f275eca (diff) | |
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')
62 files changed, 4395 insertions, 783 deletions
diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp index 102348c8..01396882 100644 --- a/pokemod/Ability.cpp +++ b/pokemod/Ability.cpp @@ -25,7 +25,7 @@ #include "Ability.h"
PokeGen::PokeMod::Ability::Ability(const unsigned _id) :
- name("")
+ name("")
{
LogCtor("Ability", id);
id = _id;
@@ -47,22 +47,38 @@ PokeGen::PokeMod::Ability::~Ability() void PokeGen::PokeMod::Ability::Validate()
{
LogValidateStart("Ability", id, name);
- // Make sure the name is set to something
if (name == "")
{
- LogVarNotSet("Ability", id, "Name", name);
+ LogVarNotSet("Ability", id, "name");
isValid = false;
}
- // Check if there are any effects defined
if (GetAbilityEffectCount())
{
- // Validate each effect
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
for (std::vector<AbilityEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
LogSubmoduleIterate("Ability", id, "effect", i->GetId(), name);
- // If an effect isn't valid, neither is the ability
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("Ability", 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("Ability", id, "effect", i->first, name);
+ isValid = false;
+ }
}
}
else
@@ -77,23 +93,41 @@ void PokeGen::PokeMod::Ability::Validate() void PokeGen::PokeMod::Ability::Validate(const wxListBox &output)
{
LogValidateStart("Ability", id, name);
- // Make sure the name is set to something
if (name == "")
{
- LogVarNotSet("Ability", id, "Name", name);
- output.Append(ConsoleLogVarNotSet("Ability", id, "Name", name));
+ LogVarNotSet("Ability", id, "name");
+ output.Append(ConsoleLogVarNotSet("Ability", id, "name"));
isValid = false;
}
- // Check if there are any effects defined
if (GetAbilityEffectCount())
{
- // Validate each effect
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
for (std::vector<AbilityEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
LogSubmoduleIterate("Ability", id, "effect", i->GetId(), name);
- // If an effect isn't valid, neither is the ability
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("Ability", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Ability", 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("Ability", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Ability", id, "effect", i->first, name));
+ isValid = false;
+ }
}
}
else
@@ -112,7 +146,6 @@ void PokeGen::PokeMod::Ability::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("Ability");
}
@@ -126,7 +159,6 @@ void PokeGen::PokeMod::Ability::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::Ability::ExportIni(std::ofstream &fout) const
{
LogExportStart("Ability", id, name);
- // Make elements
Ini exAbility("ability");
exAbility.AddField("id", id);
exAbility.AddField("name", name);
@@ -169,7 +201,6 @@ unsigned PokeGen::PokeMod::Ability::GetAbilityEffectCount() const void PokeGen::PokeMod::Ability::NewAbilityEffect(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetAbilityEffectCount(); ++i)
{
if (!GetAbilityEffect(i))
diff --git a/pokemod/AbilityEffect.cpp b/pokemod/AbilityEffect.cpp index 7c50fdc8..2247c37e 100644 --- a/pokemod/AbilityEffect.cpp +++ b/pokemod/AbilityEffect.cpp @@ -26,14 +26,14 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::AbilityEffect::AbilityEffect(const unsigned _id) :
- chance(1, 1),
- effect(UINT_MAX),
- val1(UINT_MAX),
- val2(UINT_MAX),
- val3(UINT_MAX),
- trigger(UINT_MAX),
- tval1(UINT_MAX),
- tval2(UINT_MAX)
+ chance(1, 1),
+ effect(UINT_MAX),
+ val1(UINT_MAX),
+ val2(UINT_MAX),
+ val3(UINT_MAX),
+ trigger(UINT_MAX),
+ tval1(UINT_MAX),
+ tval2(UINT_MAX)
{
LogCtor("AbilityEffect", _id);
id = _id;
@@ -226,7 +226,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (AE_END <= effect)
{
LogVarNotValid("AbilityEffect", id, "effect");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "effect"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "effect"));
isValid = false;
}
else
@@ -237,7 +237,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if ((BST_END <= val1) || ((val1 == BST_SPECIAL_DEFENSE) && !curPokeMod.IsSpecialSplit()))
{
LogVarNotValid("AbilityEffect", id, "val1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
isValid = false;
}
break;
@@ -245,7 +245,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (!curPokeMod.GetStatus(val1))
{
LogVarNotValid("AbilityEffect", id, "val1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
isValid = false;
}
break;
@@ -253,7 +253,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (!curPokeMod.GetAbility(val1))
{
LogVarNotValid("AbilityEffect", id, "val1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
isValid = false;
}
break;
@@ -261,7 +261,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (PA_END <= val1)
{
LogVarNotValid("AbilityEffect", id, "val1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
isValid = false;
}
break;
@@ -269,7 +269,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (ABIT_END <= val1)
{
LogVarNotValid("AbilityEffect", id, "val1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
isValid = false;
}
break;
@@ -277,7 +277,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (!curPokeMod.GetType(val1))
{
LogVarNotValid("AbilityEffect", id, "val1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
isValid = false;
}
break;
@@ -285,7 +285,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (W_END_ALL <= val1)
{
LogVarNotValid("AbilityEffect", id, "val1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val1"));
isValid = false;
}
}
@@ -295,7 +295,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (BM_END <= val2)
{
LogVarNotValid("AbilityEffect", id, "val2");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val2"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val2"));
isValid = false;
}
break;
@@ -304,7 +304,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (CA_END <= val2)
{
LogVarNotValid("AbilityEffect", id, "val2");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val2"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val2"));
isValid = false;
}
break;
@@ -312,7 +312,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (ABI_END <= val2)
{
LogVarNotValid("AbilityEffect", id, "val2");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val2"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val2"));
isValid = false;
}
break;
@@ -320,7 +320,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (BO_END <= val2)
{
LogVarNotValid("AbilityEffect", id, "val2");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val2"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val2"));
isValid = false;
}
}
@@ -337,7 +337,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if ((val3 < 0) || (100 < val3))
{
LogVarNotValid("AbilityEffect", id, "val3");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val3"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val3"));
isValid = false;
}
break;
@@ -345,7 +345,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if ((val3 < -6) || (6 < val3))
{
LogVarNotValid("AbilityEffect", id, "val3");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "val3"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "val3"));
isValid = false;
}
}
@@ -353,7 +353,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (AT_END <= trigger)
{
LogVarNotValid("AbilityEffect", id, "trigger");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "trigger"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "trigger"));
isValid = false;
}
else
@@ -364,7 +364,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (W_END_ALL <= tval1)
{
LogVarNotValid("AbilityEffect", id, "tVal1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "tVal1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "tVal1"));
isValid = false;
}
break;
@@ -372,7 +372,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (!curPokeMod.GetType(tval1))
{
LogVarNotValid("AbilityEffect", id, "tVal1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "tVal1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "tVal1"));
isValid = false;
}
break;
@@ -380,7 +380,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (SI_END <= tval1)
{
LogVarNotValid("AbilityEffect", id, "tVal1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "tVal1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "tVal1"));
isValid = false;
}
break;
@@ -388,7 +388,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if ((BST_END <= tval1) || ((tval1 == BST_SPECIAL_DEFENSE) && !curPokeMod.IsSpecialSplit()))
{
LogVarNotValid("AbilityEffect", id, "tVal1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "tVal1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "tVal1"));
isValid = false;
}
break;
@@ -396,7 +396,7 @@ void PokeGen::PokeMod::AbilityEffect::Validate(const wxListBox &output) if (!curPokeMod.GetStatus(tval1))
{
LogVarNotValid("AbilityEffect", id, "tVal1");
- output.append(OutputLogVarNotValid("AbilityEffect", id, "tVal1"));
+ output.Append(OutputLogVarNotValid("AbilityEffect", id, "tVal1"));
isValid = false;
}
}
@@ -412,7 +412,6 @@ void PokeGen::PokeMod::AbilityEffect::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("AbilityEffect");
}
@@ -438,8 +437,7 @@ void PokeGen::PokeMod::AbilityEffect::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::AbilityEffect::ExportIni(std::ofstream &fout, const String &ability) const
{
LogExportStart("AbilityEffect", id);
- // Make elements
- Ini exAbilityEffect(ability + " abilityEffect");
+ Ini exAbilityEffect("abilityEffect " + ability);
exAbilityEffect.AddField("id", id);
exAbilityEffect.AddField("chance-n", chance.GetNum());
exAbilityEffect.AddField("chance-d", chance.GetDenom());
diff --git a/pokemod/Author.cpp b/pokemod/Author.cpp index fadd0893..20d34db3 100644 --- a/pokemod/Author.cpp +++ b/pokemod/Author.cpp @@ -24,9 +24,9 @@ #include "Author.h"
PokeGen::PokeMod::Author::Author(const unsigned _id) :
- name(""),
- email(""),
- role("")
+ name(""),
+ email(""),
+ role("")
{
LogCtor("Author", id);
id = _id;
@@ -96,158 +96,158 @@ void PokeGen::PokeMod::Author::Validate(const wxListBox &output) LogValNotSet("Author", "role", id, name);
output.Append(ConsoleLogValNotSet("Author", "role", id, name)));
isValid = false;
- }
- LogValidateOver("Author", isValid, id, name);
-}
+ }
+ LogValidateOver("Author", isValid, id, name);
+ }
#endif
-
-void PokeGen::PokeMod::Author::ImportIni(Ini &ini, const unsigned _id)
-{
- LogImportStart("Author");
- String curName;
- if (_id == UINT_MAX)
- {
- ini.GetValue("id", id);
- if (id == UINT_MAX)
- LogIdNotFound("Author");
- }
- else
- id = _id;
- ini.GetValue("name", name);
- ini.GetValue("email", email);
- ini.GetValue("role", role);
- LogImportOver("Author", id, name);
-}
-
-void PokeGen::PokeMod::Author::ExportIni(std::ofstream &fout) const
-{
- LogExportStart("Author", id, name);
- // Declare the elements
- Ini exAuthor("author");
- exAuthor.AddField("id", id);
- exAuthor.AddField("name", name);
- exAuthor.AddField("email", email);
- exAuthor.AddField("role", role);
- exAuthor.Export(fout);
- LogExportOver("Author", id, name);
-}
-
-void PokeGen::PokeMod::Author::SetName(const String &n)
-{
- LogSetVar("Author", id, "name", n, name);
- name = n;
-}
-
-void PokeGen::PokeMod::Author::SetEmail(const String &e)
-{
- LogSetVar("Author", id, "email", e, name);
- email = e;
-}
-
-void PokeGen::PokeMod::Author::SetRole(const String &r)
-{
- LogSetVar("Author", id, "role", r, name);
- role = r;
-}
-
-PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetName() const
-{
- LogFetchVar("Author", id, "name", name);
- return name;
-}
-
-PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetEmail() const
-{
- LogFetchVar("Author", id, "email", email, name);
- return email;
-}
-
-PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetRole() const
-{
- LogFetchVar("Author", id, "role", role, name);
- return role;
-}
-
-bool PokeGen::PokeMod::Author::IsValidEmail() const
-{
- bool valid = true;
- Log(String("Author: Validating email of %d (%s)", id, name.c_str()), PM_DEBUG_DEBUG);
- EmailCheck stage = EM_NAME;
- int count = 0;
- for (unsigned i = 0; (i < email.length()) && valid; ++i)
- {
- switch (stage)
- {
- case EM_NAME:
- switch (email[i])
- {
- // Only allow alphanumerics and '%-_.' in the name
- case 'a' ... 'z':
- case 'A' ... 'Z':
- case '0' ... '9':
- case '%':
- case '-':
- case '_':
- case '.':
- ++count;
- break;
- // Move to the next part if '@' is encountered
- case '@':
- if (!count)
- valid = false;
- count = 0;
- stage = EM_HOST;
- break;
- // Not valid if anything else is encountered
- default:
- valid = false;
- }
- break;
- case EM_HOST:
- switch (email[i])
- {
- // Only allow alphanumerics and '%-_.' in the host
- case 'a' ... 'z':
- case 'A' ... 'Z':
- case '0' ... '9':
- case '-':
- ++count;
- break;
- // Move to the next part if '.' is encountered
- case '.':
- if (!count)
- valid = false;
- count = 0;
- stage = EM_DOMAIN;
- break;
- // Not valid if anything else is encountered
- default:
- valid = false;
- }
- break;
- case EM_DOMAIN:
- switch (email[i])
- {
- // Only allow alphanumerics and '%-_.' in the host
- case 'a' ... 'z':
- case 'A' ... 'Z':
- ++count;
- break;
- // Move to the next domain extension if '.' is encountered
- case '.':
- if (!count)
- valid = false;
- count = 0;
- break;
- // Not valid if anything else is encountered
- default:
- valid = false;
- }
- }
- }
- // Make sure the domain was entered and the extension is in the valid range
- if ((stage != EM_DOMAIN) || (count < 2) || (4 < count))
- valid = false;
- Log(String("Author: Validated email of %d (%s) as %s", id, name.c_str(), valid ? "valid" : "invalid"), PM_DEBUG_DEBUG);
- return valid;
-}
+
+ void PokeGen::PokeMod::Author::ImportIni(Ini &ini, const unsigned _id)
+ {
+ LogImportStart("Author");
+ String curName;
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id);
+ if (id == UINT_MAX)
+ LogIdNotFound("Author");
+ }
+ else
+ id = _id;
+ ini.GetValue("name", name);
+ ini.GetValue("email", email);
+ ini.GetValue("role", role);
+ LogImportOver("Author", id, name);
+ }
+
+ void PokeGen::PokeMod::Author::ExportIni(std::ofstream &fout) const
+ {
+ LogExportStart("Author", id, name);
+ Ini exAuthor("author");
+ exAuthor.AddField("id", id);
+ exAuthor.AddField("name", name);
+ exAuthor.AddField("email", email);
+ exAuthor.AddField("role", role);
+ exAuthor.Export(fout);
+ LogExportOver("Author", id, name);
+ }
+
+ void PokeGen::PokeMod::Author::SetName(const String &n)
+ {
+ LogSetVar("Author", id, "name", n, name);
+ name = n;
+ }
+
+ void PokeGen::PokeMod::Author::SetEmail(const String &e)
+ {
+ LogSetVar("Author", id, "email", e, name);
+ email = e;
+ }
+
+ void PokeGen::PokeMod::Author::SetRole(const String &r)
+ {
+ LogSetVar("Author", id, "role", r, name);
+ role = r;
+ }
+
+ PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetName() const
+ {
+ LogFetchVar("Author", id, "name", name);
+ return name;
+ }
+
+ PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetEmail() const
+ {
+ LogFetchVar("Author", id, "email", email, name);
+ return email;
+ }
+
+ PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetRole() const
+ {
+ LogFetchVar("Author", id, "role", role, name);
+ return role;
+ }
+
+ bool PokeGen::PokeMod::Author::IsValidEmail() const
+ {
+ bool valid = true;
+ Log(String("Author: Validating email of %d (%s)", id, name.c_str()), PM_DEBUG_DEBUG);
+ EmailCheck stage = EM_NAME;
+ int count = 0;
+ for (unsigned i = 0; (i < email.length()) && valid; ++i)
+ {
+ switch (stage)
+ {
+ case EM_NAME:
+ switch (email[i])
+ {
+ // Only allow alphanumerics and '%-_.' in the name
+ case 'a' ... 'z':
+ case 'A' ... 'Z':
+ case '0' ... '9':
+ case '%':
+ case '-':
+ case '_':
+ case '.':
+ ++count;
+ break;
+ // Move to the next part if '@' is encountered
+ case '@':
+ if (!count)
+ valid = false;
+ count = 0;
+ stage = EM_HOST;
+ break;
+ // Not valid if anything else is encountered
+ default:
+ valid = false;
+ }
+ break;
+ case EM_HOST:
+ switch (email[i])
+ {
+ // Only allow alphanumerics and '%-_.' in the host
+ case 'a' ... 'z':
+ case 'A' ... 'Z':
+ case '0' ... '9':
+ case '-':
+ ++count;
+ break;
+ // Move to the next part if '.' is encountered
+ case '.':
+ if (!count)
+ valid = false;
+ count = 0;
+ stage = EM_DOMAIN;
+ break;
+ // Not valid if anything else is encountered
+ default:
+ valid = false;
+ }
+ break;
+ case EM_DOMAIN:
+ switch (email[i])
+ {
+ // Only allow alphanumerics and '%-_.' in the host
+ case 'a' ... 'z':
+ case 'A' ... 'Z':
+ ++count;
+ break;
+ // Move to the next domain extension if '.' is encountered
+ case '.':
+ if (!count)
+ valid = false;
+ count = 0;
+ break;
+ // Not valid if anything else is encountered
+ default:
+ valid = false;
+ }
+ }
+ }
+ // Make sure the domain was entered and the extension is in the valid range
+ if ((stage != EM_DOMAIN) || (count < 2) || (4 < count))
+ valid = false;
+ Log(String("Author: Validated email of %d (%s) as %s", id, name.c_str(), valid ? "valid" : "invalid"), PM_DEBUG_DEBUG);
+ return valid;
+ }
+
diff --git a/pokemod/Author.h b/pokemod/Author.h index 33ebb39e..dacdb900 100644 --- a/pokemod/Author.h +++ b/pokemod/Author.h @@ -59,7 +59,7 @@ namespace PokeGen EM_NAME = 0,
EM_HOST = 1,
EM_DOMAIN = 2
- };
+ };
bool IsValidEmail() const;
diff --git a/pokemod/Badge.cpp b/pokemod/Badge.cpp index 3b99508d..70911bc9 100644 --- a/pokemod/Badge.cpp +++ b/pokemod/Badge.cpp @@ -27,10 +27,10 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::Badge::Badge(const unsigned _id) :
- name(""),
- face(""),
- badge(""),
- obey(0)
+ name(""),
+ face(""),
+ badge(""),
+ obey(0)
{
LogCtor("Badge", _id);
for (unsigned i = 0; i < STH_END_GSC; ++i)
@@ -130,15 +130,14 @@ void PokeGen::PokeMod::Badge::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("Badge");
}
else
id = _id;
- ini.GetValue("name", name, "");
- ini.GetValue("face", face, "");
- ini.GetValue("badge", badge, "");
+ ini.GetValue("name", name);
+ ini.GetValue("face", face);
+ ini.GetValue("badge", badge);
ini.GetValue("obey", obey, 0);
for (int i = 0; i < STH_END_GSC; ++i)
{
diff --git a/pokemod/CoinItem.cpp b/pokemod/CoinItem.cpp index db7e560d..726234bd 100644 --- a/pokemod/CoinItem.cpp +++ b/pokemod/CoinItem.cpp @@ -26,10 +26,10 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::CoinItem::CoinItem(const unsigned _id) :
- type(CIT_ITEM),
- object(UINT_MAX),
- amount(1),
- cost(0)
+ type(CIT_ITEM),
+ object(UINT_MAX),
+ amount(1),
+ cost(0)
{
LogCtor("CoinItem", _id);
id = _id;
@@ -124,7 +124,6 @@ void PokeGen::PokeMod::CoinItem::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("CoinItem");
}
@@ -140,10 +139,9 @@ void PokeGen::PokeMod::CoinItem::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::CoinItem::ExportIni(std::ofstream &fout, const String &coinList) const
{
LogExportStart("CoinItem", id);
- // Make elements
- Ini exCoinItem(coinList + " CoinItem");
+ Ini exCoinItem("coinItem " + coinList);
exCoinItem.AddField("id", id);
- exCoinItem.AddField("type",type);
+ exCoinItem.AddField("type", type);
exCoinItem.AddField("object", object);
exCoinItem.AddField("amount", amount);
exCoinItem.AddField("cost", cost);
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))
diff --git a/pokemod/CoinList.h b/pokemod/CoinList.h index b9016cb0..d31489ce 100644 --- a/pokemod/CoinList.h +++ b/pokemod/CoinList.h @@ -26,6 +26,7 @@ #define __POKEMOD_COINLIST__
#include <vector>
+#include <map>
#include "Object.h"
#include "String.h"
#include "Pokemod.h"
@@ -50,7 +51,7 @@ namespace PokeGen String GetName() const;
unsigned GetValue() const;
-
+
const CoinItem *GetCoinItem(const unsigned _id) const;
const CoinItem *GetCoinItem(const String &n) const;
unsigned GetCoinItemCount() const;
diff --git a/pokemod/Debug.cpp b/pokemod/Debug.cpp index 87a9b7e0..389c3138 100644 --- a/pokemod/Debug.cpp +++ b/pokemod/Debug.cpp @@ -31,7 +31,7 @@ extern debugWindow PokeModDebugWindow; int PokeModDebugLevel;
-void PokeGen::PokeMod::Log(const char *msg, int level)
+void PokeGen::PokeMod::Log(const char *msg, const int level)
{
// Actual strings of the debugging levels
const char *PokeModDebugStr[8] = {"Emergency", "Alert", "Critical Error", "Error", "Warning", "Notice", "Info", "Debug"};
@@ -81,7 +81,7 @@ void PokeGen::PokeMod::Log(const char *msg, int level) #else
// Empty function if debugging isn't wanted
-void PokeGen::PokeMod::Log(const String &msg, int level)
+void PokeGen::PokeMod::Log(const String &msg, const int level)
{
return;
}
diff --git a/pokemod/Debug.h b/pokemod/Debug.h index 1cbbc685..b212426a 100644 --- a/pokemod/Debug.h +++ b/pokemod/Debug.h @@ -24,8 +24,6 @@ #ifndef __POKEMOD_DEBUG__
#define __POKEMOD_DEBUG__
-// TODO (Ben#1#): Comment logging functions
-
#define PM_DEBUG
#ifdef PM_DEBUG
@@ -385,6 +383,21 @@ namespace PokeGen Log(String("%s: Failed to remove %s %s from %u%s", module, subName, subStr, id, name ? String(" (%s)", name).c_str() : ""), PM_DEBUG_ERROR);
}
+ inline void LogDuplicateId(const char *module, const unsigned id, const char *subName, const unsigned subId, const char *name = NULL)
+ {
+ Log(String("%s: Duplicate ID for %s of %u found in %u%s", module, subName, subId, id, name ? String(" (%s)", name).c_str() : ""), PM_DEBUG_ERROR);
+ }
+
+ inline void LogDuplicateSubmodule(const char *module, const unsigned id, const char *subName, const unsigned subVal, const char *name = NULL)
+ {
+ Log(String("%s: Duplicate %s of %u found in %u%s", module, subName, subVal, id, name ? String(" (%s)", name).c_str() : ""), PM_DEBUG_ERROR);
+ }
+
+ inline void LogDuplicateSubmodule(const char *module, const unsigned id, const char *subName, const char *subVal, const char *name = NULL)
+ {
+ Log(String("%s: Duplicate %s of %s found in %u%s", module, subName, subVal, id, name ? String(" (%s)", name).c_str() : ""), PM_DEBUG_ERROR);
+ }
+
/* inline void Log(const char *module, const unsigned id, const char *name = NULL)
{
Log(String("%s: ", module, id, name ? String(" (%s)", name).c_str() : ""), PM_DEBUG_);
diff --git a/pokemod/Dialog.cpp b/pokemod/Dialog.cpp index c7677cf1..23f09e1b 100644 --- a/pokemod/Dialog.cpp +++ b/pokemod/Dialog.cpp @@ -26,7 +26,7 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::Dialog::Dialog(const unsigned _id) :
- dialog("")
+ dialog("")
{
LogCtor("Dialog", _id);
id = _id;
@@ -53,6 +53,7 @@ void PokeGen::PokeMod::Dialog::Validate() {
LogValidateStart("Dialog", id);
// TODO (Validation#1#): Dialog Validation
+# warning "Dialog Validation"
LogValidateOver("Dialog", id, isValid);
}
@@ -62,7 +63,6 @@ void PokeGen::PokeMod::Dialog::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("Dialog");
}
@@ -75,7 +75,6 @@ void PokeGen::PokeMod::Dialog::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::Dialog::ExportIni(std::ofstream &fout) const
{
LogExportStart("Dialog", id);
- // Make elements
Ini exDialog("dialog");
exDialog.AddField("id", id);
exDialog.AddField("dialog", dialog);
@@ -148,5 +147,5 @@ void PokeGen::PokeMod::Dialog::InsertDialogCommand(const unsigned cmd, const uns void PokeGen::PokeMod::Dialog::InsertDialogCommand(const String &cmd, const unsigned pos)
{
- // TODO (Ben#1#): Dialog commands
+ InsertDialogCommand(FindIn(DC_END, cmd, DialogCommandStr), pos);
}
diff --git a/pokemod/EggGroup.cpp b/pokemod/EggGroup.cpp index 5c77efab..8556fd77 100644 --- a/pokemod/EggGroup.cpp +++ b/pokemod/EggGroup.cpp @@ -24,7 +24,7 @@ #include "EggGroup.h"
PokeGen::PokeMod::EggGroup::EggGroup(const unsigned _id) :
- name("")
+ name("")
{
LogCtor("EggGroup", _id);
id = _id;
@@ -48,7 +48,7 @@ void PokeGen::PokeMod::EggGroup::Validate() LogValidateStart("EggGroup", id, name);
if (name == "")
{
- LogVarNotSet("EggGroup", id, "name", name);
+ LogVarNotSet("EggGroup", id, "name");
isValid = false;
}
LogValidateOver("EggGroup", id, isValid, name);
@@ -87,7 +87,6 @@ void PokeGen::PokeMod::EggGroup::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::EggGroup::ExportIni(std::ofstream &fout) const
{
LogExportStart("EggGroup", id, name);
- // Declare the elements
Ini exType("eggGroup");
exType.AddField("id", id);
exType.AddField("name", name);
@@ -97,12 +96,12 @@ void PokeGen::PokeMod::EggGroup::ExportIni(std::ofstream &fout) const void PokeGen::PokeMod::EggGroup::SetName(const String &n)
{
- LogSetVar("EggGroup", id, "name", n, name);
+ LogSetVar("EggGroup", id, "name", n);
name = n;
}
PokeGen::PokeMod::String PokeGen::PokeMod::EggGroup::GetName() const
{
- LogFetchVar("EggGroup", id, "name", name, name);
+ LogFetchVar("EggGroup", id, "name", name);
return name;
}
diff --git a/pokemod/Flag.cpp b/pokemod/Flag.cpp index 2cff5267..e83e0bd5 100644 --- a/pokemod/Flag.cpp +++ b/pokemod/Flag.cpp @@ -24,8 +24,8 @@ #include "Flag.h"
PokeGen::PokeMod::Flag::Flag(const unsigned f, const unsigned s) :
- flag(f),
- status(0)
+ flag(f),
+ status(0)
{
LogCtor("Flag", 0);
}
@@ -48,7 +48,6 @@ void PokeGen::PokeMod::Flag::ImportIni(Ini &ini) void PokeGen::PokeMod::Flag::ExportIni(std::ofstream &fout, const String &val) const
{
LogExportStart("Flag", 0);
- // Declare the elements
Ini exFlag(val);
exFlag.AddField("flag", flag);
exFlag.AddField("status", status);
@@ -77,7 +76,6 @@ void PokeGen::PokeMod::Flag::SetFlag(const unsigned f) void PokeGen::PokeMod::Flag::SetStatus(const unsigned s)
{
LogSetVar("Flag", 0, "status", s);
- // Avoid errors
status = (s ? ((s > FV_UNSET) ? FV_SET : FV_IGNORE) : FV_UNSET);
}
diff --git a/pokemod/Frac.cpp b/pokemod/Frac.cpp index 7d919f1b..9341e6a5 100644 --- a/pokemod/Frac.cpp +++ b/pokemod/Frac.cpp @@ -24,9 +24,9 @@ #include "Frac.h"
PokeGen::PokeMod::Frac::Frac(const bool i) :
- num(1),
- denom(1),
- improper(i)
+ num(1),
+ denom(1),
+ improper(i)
{
Log("Frac: Initializing", PM_DEBUG_DEBUG);
}
@@ -49,9 +49,7 @@ void PokeGen::PokeMod::Frac::ImportIni(Ini &ini) void PokeGen::PokeMod::Frac::ExportIni(std::ofstream &fout, const String &val)
{
Log(String("Frac Export: Starting %u/%u as %s", num, denom, val.c_str()), PM_DEBUG_INFO);
- // Reduce fraction before storing
Reduce();
- // Declare the elements
Ini exFrac(val);
exFrac.AddField("num", num);
exFrac.AddField("denom", denom);
@@ -76,7 +74,6 @@ void PokeGen::PokeMod::Frac::Set(const unsigned n, const unsigned d, const bool void PokeGen::PokeMod::Frac::SetNum(const unsigned n)
{
- // Make sure the numerator is less than the denominator if proper
if ((n <= denom) || improper)
{
Log(String("Frac: Setting numerator to %u (%u/%u)", n, n, denom), PM_DEBUG_DEBUG);
@@ -88,7 +85,6 @@ void PokeGen::PokeMod::Frac::SetNum(const unsigned n) void PokeGen::PokeMod::Frac::SetDenom(const unsigned d)
{
- // Make sure the denominator isn't 0
if (d)
{
Log(String("Frac: Setting denominator to %u", d), PM_DEBUG_DEBUG);
@@ -96,7 +92,6 @@ void PokeGen::PokeMod::Frac::SetDenom(const unsigned d) }
else
Log("Frac: Attempting to set denominator to 0", PM_DEBUG_DEBUG);
- // Set the numerator to less than the denominator if proper
if ((num <= denom) && !improper)
{
Log(String("Frac: Setting numerator to 1 after denominator reset to (%u)", d), PM_DEBUG_DEBUG);
@@ -138,10 +133,8 @@ float PokeGen::PokeMod::Frac::GetValue() const void PokeGen::PokeMod::Frac::Reduce()
{
Log(String("Frac: Reducing %u/%u", num, denom), PM_DEBUG_DEBUG);
- // Iterate until i is greater than the square root on num
- for (unsigned i = 2; i * i <= num; ++i)
+ for (unsigned i = 2; i <= (num < denom ? num : denom); ++i)
{
- // Keep iterating while i is a factor of both
while (!((num % i) || (denom % i)))
{
num /= i;
diff --git a/pokemod/Ini.cpp b/pokemod/Ini.cpp index af99da47..6fd7347f 100644 --- a/pokemod/Ini.cpp +++ b/pokemod/Ini.cpp @@ -24,7 +24,7 @@ #include "Ini.h"
PokeGen::PokeMod::Ini::Ini(const String &n) :
- name(n)
+ name(n)
{
}
diff --git a/pokemod/Ini.h b/pokemod/Ini.h index 4539fee9..79b1c07f 100644 --- a/pokemod/Ini.h +++ b/pokemod/Ini.h @@ -64,7 +64,7 @@ namespace PokeGen POS_FIELD = 0,
POS_VALUE = 1
};
-
+
bool Load(std::ifstream &file);
String name;
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))
diff --git a/pokemod/Item.h b/pokemod/Item.h index c509fc53..82ad57bd 100644 --- a/pokemod/Item.h +++ b/pokemod/Item.h @@ -25,6 +25,7 @@ #define __POKEMOD_ITEM__
#include <vector>
+#include <map>
#include "Object.h"
#include "String.h"
#include "Pokemod.h"
@@ -57,7 +58,7 @@ namespace PokeGen String GetTypeString() const;
unsigned GetPrice() const;
String GetDescription() const;
-
+
const ItemEffect *GetItemEffect(const unsigned _id) const;
unsigned GetItemEffectCount() const;
void NewItemEffect(Ini *const ini = NULL);
diff --git a/pokemod/ItemEffect.cpp b/pokemod/ItemEffect.cpp index ecc3566a..61b5c674 100644 --- a/pokemod/ItemEffect.cpp +++ b/pokemod/ItemEffect.cpp @@ -25,18 +25,18 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
-PokeGen::PokeMod::ItemEffect::ItemEffect(const unsigned _id)
+PokeGen::PokeMod::ItemEffect::ItemEffect(const unsigned _id) :
+ overworld(false),
+ battle(false),
+ held(false),
+ effect(UINT_MAX),
+ val1(UINT_MAX),
+ val2(UINT_MAX),
+ val3(1, 1),
+ val4(UINT_MAX),
+ val5(UINT_MAX)
{
LogCtor("ItemEffect", _id);
- overworld = false;
- battle = false;
- held = false;
- effect = UINT_MAX;
- val1 = INT_MAX;
- val2 = INT_MAX;
- val3.Set(1, 1);
- val4 = UINT_MAX;
- val5 = UINT_MAX;
id = _id;
}
@@ -61,6 +61,7 @@ void PokeGen::PokeMod::ItemEffect::Validate() {
LogValidateStart("ItemEffect", id);
// TODO (Validation#1#): ItemEffect Validation
+# warning "ItemEffect Validation"
LogValidateOver("ItemEffect", id, isValid);
}
@@ -70,7 +71,6 @@ void PokeGen::PokeMod::ItemEffect::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("ItemEffect");
}
@@ -95,7 +95,6 @@ void PokeGen::PokeMod::ItemEffect::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::ItemEffect::ExportIni(std::ofstream &fout, const String &item) const
{
LogExportStart("ItemEffect", id);
- // Make elements
Ini exItemEffect(item + " itemEffect");
exItemEffect.AddField("id", id);
exItemEffect.AddField("overworld", overworld);
@@ -178,6 +177,7 @@ void PokeGen::PokeMod::ItemEffect::SetVal1(const int v1) case IE_MAP:
case IE_ITEMFINDER:
case IE_BIKE:
+ case IE_SCOPE:
LogNoUse("ItemEffect", id, "val1", v1, "effect", ItemEffectStr[effect]);
break;
case IE_LEVEL_BOOST:
@@ -203,7 +203,6 @@ void PokeGen::PokeMod::ItemEffect::SetVal1(const int v1) LogOutOfRange("ItemEffect", id, "val1", v1, "effect", "Modify Stat (Battle)");
break;
case IE_FISH:
- case IE_SCOPE:
case IE_COIN:
case IE_COIN_CASE:
val1 = v1;
diff --git a/pokemod/ItemStorage.cpp b/pokemod/ItemStorage.cpp index 57f09ef5..591f4d8d 100644 --- a/pokemod/ItemStorage.cpp +++ b/pokemod/ItemStorage.cpp @@ -73,8 +73,8 @@ void PokeGen::PokeMod::ItemStorage::Validate(const wxListBox &output) }
if (!player)
{
- LogVarNotValid("ItemStorage", id, "player");
- output.Append(ConsoleLogVarNotValid("ItemStorage", id, "player"));
+ LogVarNotValid("ItemStorage", id, "player", name);
+ output.Append(ConsoleLogVarNotValid("ItemStorage", id, "player", name));
isValid = false;
}
LogValidateOver("ItemStorage", id, isValid, name);
@@ -87,13 +87,12 @@ void PokeGen::PokeMod::ItemStorage::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("ItemStorage");
}
else
id = _id;
- ini.GetValue("name", name, "");
+ ini.GetValue("name", name);
ini.GetValue("computer", computer, 0);
ini.GetValue("player", player, 1);
LogImportOver("ItemStorage", id, name);
diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp index 32728d90..20db2d5d 100644 --- a/pokemod/Map.cpp +++ b/pokemod/Map.cpp @@ -26,9 +26,9 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::Map::Map(const unsigned _id) :
- name(""),
- flyWarp(UINT_MAX),
- type(UINT_MAX)
+ name(""),
+ flyWarp(UINT_MAX),
+ type(UINT_MAX)
{
LogCtor("Map", id);
id = _id;
@@ -50,7 +50,6 @@ PokeGen::PokeMod::Map::~Map() void PokeGen::PokeMod::Map::Validate()
{
LogValidateStart("Map", id, name);
- // Make sure the name is set to something
if (name == "")
{
LogVarNotSet("Map", id, "name");
@@ -66,65 +65,166 @@ void PokeGen::PokeMod::Map::Validate() LogVarNotValid("Map", id, "type", name);
isValid = false;
}
- // Check if there are any effects defined
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> nameChecker;
if (GetMapEffectCount())
{
- // Validate each effect
for (std::vector<MapEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
LogSubmoduleIterate("Map", id, "effect", i->GetId(), name);
- // If an effect isn't valid, neither is the map
if (!i->IsValid())
isValid = false;
+ if (GetWidth() <= i->GetCoordinateX())
+ {
+ LogVarNotValid("MapEffect", i->GetId(), "x", i->GetName());
+ isValid = false;
+ }
+ if (GetHeight() <= i->GetCoordinateY())
+ {
+ LogVarNotValid("MapEffect", i->GetId(), "y", i->GetName());
+ isValid = false;
+ }
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetName()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Map", id, "effect", i->first, name);
+ isValid = false;
+ }
}
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Map", id, "effect", i->first, name);
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
}
else
LogSubmoduleEmpty("Map", id, "effect", name);
- // Check if there are any trainers defined
if (GetMapTrainerCount())
{
- // Validate each trainer
for (std::vector<MapTrainer>::iterator i = trainers.begin(); i != trainers.end(); ++i)
{
LogSubmoduleIterate("Map", id, "trainer", i->GetId(), name);
- // If a trainer isn't valid, neither is the map
if (!i->IsValid())
isValid = false;
+ if (GetWidth() <= i->GetCoordinateX())
+ {
+ LogVarNotValid("MapTrainer", i->GetId(), "x", i->GetName());
+ isValid = false;
+ }
+ if (GetHeight() <= i->GetCoordinateY())
+ {
+ LogVarNotValid("MapTrainer", i->GetId(), "y", i->GetName());
+ isValid = false;
+ }
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetName()];
}
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Map", id, "trainer", i->first, name);
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Map", id, "trainer", i->first, name);
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
}
else
LogSubmoduleEmpty("Map", id, "trainer", name);
- // Check if there are any warps defined
if (GetMapWarpCount())
{
- // Validate each warp
for (std::vector<MapWarp>::iterator i = warps.begin(); i != warps.end(); ++i)
{
LogSubmoduleIterate("Map", id, "warp", i->GetId(), name);
- // If a warp isn't valid, neither is the map
if (!i->IsValid())
isValid = false;
+ if (GetWidth() <= i->GetCoordinateX())
+ {
+ LogVarNotValid("MapWarp", i->GetId(), "x", i->GetName());
+ isValid = false;
+ }
+ if (GetHeight() <= i->GetCoordinateY())
+ {
+ LogVarNotValid("MapWarp", i->GetId(), "y", i->GetName());
+ isValid = false;
+ }
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetName()];
}
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Map", id, "warp", i->first, name);
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Map", id, "warp", i->first, name);
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
}
else
{
LogSubmoduleEmpty("Map", id, "warp", name);
isValid = false;
}
- // Check if there are any wild lists defined
if (GetMapWildListCount())
{
- // Validate each wild list
for (std::vector<MapWildList>::iterator i = wildLists.begin(); i != wildLists.end(); ++i)
{
LogSubmoduleIterate("Map", id, "wild list", i->GetId(), name);
- // If a wildList isn't valid, neither is the map
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Map", id, "effect", i->first, name);
+ isValid = false;
+ }
}
+ idChecker.clear();
}
else
LogSubmoduleEmpty("Map", id, "effect", name);
+ for (unsigned i = 0; i < GetWidth(); ++i)
+ {
+ for (unsigned j = 0; j < GetHeight(); ++j)
+ {
+ if (!curPokeMod.GetTile(tiles[i][j]))
+ {
+ LogVarNotValid("Map", id, String("tiles[%u][%u]", i, j), name);
+ isValid = false;
+ }
+ }
+ }
LogValidateOver("Map", id, isValid, name);
}
@@ -132,7 +232,6 @@ void PokeGen::PokeMod::Map::Validate() void PokeGen::PokeMod::Map::Validate(const wxListBox &output)
{
LogValidateStart("Map", id, name);
- // Make sure the name is set to something
if (name == "")
{
LogVarNotSet("Map", id, "Name", name);
@@ -142,60 +241,148 @@ void PokeGen::PokeMod::Map::Validate(const wxListBox &output) if (!GetWarp(flyWarp))
{
LogVarNotValid("Map", id, "flyWarp", name);
- output.append(ConsoleLogVarNotValid("Map", id, "flyWarp", name));
+ output.Append(ConsoleLogVarNotValid("Map", id, "flyWarp", name));
isValid = false;
}
if ((MTY_NONE < type) && (type < MTY_END))
{
LogVarNotValid("Map", id, "type", name);
- output.append(ConsoleLogVarNotValid("Map", id, "type", name));
+ output.Append(ConsoleLogVarNotValid("Map", id, "type", name));
isValid = false;
}
- // Check if there are any effects defined
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> nameChecker;
if (GetMapEffectCount())
{
- // Validate each effect
for (std::vector<MapEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
LogSubmoduleIterate("Map", id, "effect", i->GetId(), name);
- // If an effect isn't valid, neither is the map
if (!i->IsValid())
isValid = false;
+ if (GetWidth() <= i->GetCoordinateX())
+ {
+ LogVarNotValid("MapEffect", i->GetId(), "x", i->GetName());
+ isValid = false;
+ }
+ if (GetHeight() <= i->GetCoordinateY())
+ {
+ LogVarNotValid("MapEffect", i->GetId(), "y", i->GetName());
+ isValid = false;
+ }
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetName()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Map", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Map", id, "effect", i->first, name));
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Map", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Map", id, "effect", i->first, name));
+ isValid = false;
+ }
}
+ idChecker.clear();
+ nameChecker.clear();
}
else
{
LogSubmoduleEmpty("Map", id, "effect", id, name);
output.Append(ConsoleLogSubmoduleEmptyW("Map", id, "effect", name));
}
- // Check if there are any trainers defined
if (GetMapTrainerCount())
{
- // Validate each trainer
for (std::vector<MapTrainer>::iterator i = trainers.begin(); i != trainers.end(); ++i)
{
LogSubmoduleIterate("Map", id, "trainer", i->GetId(), name);
- // If a trainer isn't valid, neither is the map
if (!i->IsValid())
isValid = false;
+ if (GetWidth() <= i->GetCoordinateX())
+ {
+ LogVarNotValid("MapTrainer", i->GetId(), "x", i->GetName());
+ isValid = false;
+ }
+ if (GetHeight() <= i->GetCoordinateY())
+ {
+ LogVarNotValid("MapTrainer", i->GetId(), "y", i->GetName());
+ isValid = false;
+ }
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetName()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Map", id, "trainer", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Map", id, "trainer", i->first, name));
+ isValid = false;
+ }
}
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Map", id, "trainer", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Map", id, "trainer", i->first, name));
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
}
else
{
LogSubmoduleEmpty("Map", id, "trainer", id, name);
output.Append(ConsoleLogSubmoduleEmptyW("Map", id, "trainer", name));
}
- // Check if there are any warps defined
if (GetMapWarpCount())
{
- // Validate each warp
for (std::vector<MapWarp>::iterator i = warps.begin(); i != warps.end(); ++i)
{
LogSubmoduleIterate("Map", id, "warp", i->GetId(), name);
- // If a warp isn't valid, neither is the map
if (!i->IsValid())
isValid = false;
+ if (GetWidth() <= i->GetCoordinateX())
+ {
+ LogVarNotValid("MapWarp", i->GetId(), "x", i->GetName());
+ isValid = false;
+ }
+ if (GetHeight() <= i->GetCoordinateY())
+ {
+ LogVarNotValid("MapWarp", i->GetId(), "y", i->GetName());
+ isValid = false;
+ }
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetName()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Map", id, "warp", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Map", id, "warp", i->first, name));
+ isValid = false;
+ }
}
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Map", id, "warp", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Map", id, "warp", i->first, name));
+ isValid = false;
+ }
+ }
+ idChecker.clear();
}
else
{
@@ -203,23 +390,42 @@ void PokeGen::PokeMod::Map::Validate(const wxListBox &output) output.Append(ConsoleLogSubmoduleEmpty("Map", id, "warp", name));
isValid = false;
}
- // Check if there are any wild lists defined
if (GetMapWildListCount())
{
- // Validate each wild list
for (std::vector<MapWildList>::iterator i = wildLists.begin(); i != wildLists.end(); ++i)
{
LogSubmoduleIterate("Map", id, "wild list", i->GetId(), name);
- // If a wild list isn't valid, neither is the Map
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
}
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Map", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Map", id, "effect", i->first, name));
+ isValid = false;
+ }
+ }
+ idChecker.clear();
}
else
{
- LogSubmoduleEmpty("Map", id, "effect", id, name);
- output.Append(ConsoleLogSubmoduleEmpty("Map", id, "effect", name));
- isValid = false;
+ LogSubmoduleEmpty("Map", id, "wild list", id, name);
+ output.Append(ConsoleLogSubmoduleEmptyW("Map", id, "wild list", name));
+ }
+ for (unsigned i = 0; i < GetWidth(); ++i)
+ {
+ for (unsigned j = 0; j < GetHeight(); ++j)
+ {
+ if (!curPokeMod.GetTile(tiles[i][j]))
+ {
+ LogVarNotValid("Map", id, String("tiles[%u][%u]", i, j), name);
+ output.Append(ConsoleLogVarNotValid("Map", id, String("tiles[%u][%u]", i, j), name));
+ isValid = false;
+ }
+ }
}
LogValidateOver("Map", id, isValid, name);
}
@@ -231,15 +437,24 @@ void PokeGen::PokeMod::Map::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("Map");
}
else
id = _id;
+ unsigned i;
+ unsigned j;
ini.GetValue("name", name);
ini.GetValue("flyWarp", flyWarp);
ini.GetValue("type", type);
+ ini.GetValue("width", i, 0);
+ ini.GetValue("height", j, 0);
+ tiles.resize(i, j, Frac(1, 1));
+ for (unsigned i = 0; i < GetWidth(); ++i)
+ {
+ for (unsigned j = 0; j < GetHeight(); ++j)
+ ini.GetValue(String("tiles-%u-%u", i, j), tiles[i][j]);
+ }
effects.clear();
trainers.clear();
warps.clear();
@@ -250,12 +465,18 @@ void PokeGen::PokeMod::Map::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::Map::ExportIni(std::ofstream &fout) const
{
LogExportStart("Map", id, name);
- // Make elements
Ini exMap("Map");
exMap.AddField("id", id);
exMap.AddField("name", name);
exMap.AddField("flyWarp", flyWarp);
exMap.AddField("type", type);
+ exMap.AddField("width", GetWidth());
+ exMap.AddField("height", GetHeight());
+ for (unsigned i = 0; i < GetWidth(); ++i)
+ {
+ for (unsigned j = 0; j < GetWidth(); ++j)
+ exMap.AddField(String("tiles-%u-%u", i, j), tiles[i][j]);
+ }
exMap.Export(fout);
for (std::vector<MapEffect>::const_iterator i = effects.begin(); i != effects.end(); ++i)
i->ExportIni(fout, name);
@@ -419,7 +640,6 @@ unsigned PokeGen::PokeMod::Map::GetMapEffectCount() const void PokeGen::PokeMod::Map::NewMapEffect(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetMapEffectCount(); ++i)
{
if (!GetMapEffect(i))
@@ -493,7 +713,6 @@ unsigned PokeGen::PokeMod::Map::GetMapTrainerCount() const void PokeGen::PokeMod::Map::NewMapTrainer(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetMapTrainerCount(); ++i)
{
if (!GetMapTrainer(i))
@@ -567,7 +786,6 @@ unsigned PokeGen::PokeMod::Map::GetMapWarpCount() const void PokeGen::PokeMod::Map::NewMapWarp(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetMapWarpCount(); ++i)
{
if (!GetMapWarp(i))
@@ -629,7 +847,6 @@ unsigned PokeGen::PokeMod::Map::GetMapWildListCount() const void PokeGen::PokeMod::Map::NewMapWildList(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetMapWildListCount(); ++i)
{
if (!GetMapWildList(i))
diff --git a/pokemod/Map.h b/pokemod/Map.h index 70ecbb28..3afaca5f 100644 --- a/pokemod/Map.h +++ b/pokemod/Map.h @@ -25,6 +25,7 @@ #define __POKEMOD_MAP__
#include <vector>
+#include <map>
#include "Object.h"
#include "String.h"
#include "Matrix.h"
diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp index 35022b16..2735fd78 100644 --- a/pokemod/MapEffect.cpp +++ b/pokemod/MapEffect.cpp @@ -26,16 +26,16 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::MapEffect::MapEffect(const unsigned _id) :
- name(""),
- coordinate(0, 0),
- existFlag(0, 0),
- skin(""),
- effect(UINT_MAX),
- val1(UINT_MAX),
- val2(UINT_MAX),
- direction(UINT_MAX),
- isTransparent(false),
- dialog(UINT_MAX)
+ name(""),
+ coordinate(0, 0),
+ existFlag(0, 0),
+ skin(""),
+ effect(UINT_MAX),
+ val1(UINT_MAX),
+ val2(UINT_MAX),
+ direction(UINT_MAX),
+ isTransparent(false),
+ dialog(UINT_MAX)
{
LogCtor("MapEffect", _id);
id = _id;
@@ -57,14 +57,15 @@ PokeGen::PokeMod::MapEffect::~MapEffect() void PokeGen::PokeMod::MapEffect::Validate()
{
LogValidateStart("MapEffect", id, name);
- // TODO (Ben#1#): MapEffect validation
+ // TODO (Validation#1#): MapEffect validation
+# warning "MapEffect Validation"
LogValidateOver("MapEffect", id, isValid, name);
}
#ifdef PG_DEBUG_WINDOW
void PokeGen::PokeMod::MapEffect::Validate(const wxListBox &output)
{
-
+
}
#endif
@@ -205,7 +206,7 @@ void PokeGen::PokeMod::MapEffect::SetEffect(const String &e) void PokeGen::PokeMod::MapEffect::SetVal1(const unsigned v1)
{
LogSetVar("MapEffect", id, "val1", v1, name);
- switch(effect)
+ switch (effect)
{
default:
LogNotSet("MapEffect", id, "val1", v1, "effect");
@@ -215,7 +216,7 @@ void PokeGen::PokeMod::MapEffect::SetVal1(const unsigned v1) void PokeGen::PokeMod::MapEffect::SetVal2(const unsigned v2)
{
LogSetVar("MapEffect", id, "val2", v2, name);
- switch(effect)
+ switch (effect)
{
default:
LogNotSet("MapEffect", id, "val2", v2, "effect");
@@ -224,7 +225,7 @@ void PokeGen::PokeMod::MapEffect::SetVal2(const unsigned v2) void PokeGen::PokeMod::MapEffect::SetVal2(const String &v2)
{
- switch(effect)
+ switch (effect)
{
default:
LogNotSet("MapEffect", id, "val2", v2, "effect");
@@ -253,7 +254,7 @@ void PokeGen::PokeMod::MapEffect::SetDialog(const unsigned d) {
LogSetVar("MapEffect", id, "dialog", d, name);
if (curPokeMod.GetDialog(d))
- dialog = d;
+ dialog = d;
}
PokeGen::PokeMod::String PokeGen::PokeMod::MapEffect::GetName() const
@@ -340,9 +341,9 @@ PokeGen::PokeMod::String PokeGen::PokeMod::MapEffect::GetVal2String() const {
LogFetchVar("MapEffect", id, "val2 string", val2, name);
String ret = "";
- switch(effect)
+ switch (effect)
{
- // TODO (Ben#1#): Effect code
+ // TODO (Ben#1#): Effect code
}
return ret;
}
diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp index a42299a3..5516e7e3 100644 --- a/pokemod/MapTrainer.cpp +++ b/pokemod/MapTrainer.cpp @@ -26,17 +26,17 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::MapTrainer::MapTrainer(const unsigned _id) :
- name(""),
- coordinate(0, 0),
- skin(""),
- sight(0),
- direction(UINT_MAX),
- ai(""),
- appearFlag(0, 0),
- overworldDialog(UINT_MAX),
- winDialog(UINT_MAX),
- loseDialog(UINT_MAX),
- leadPokemon(UINT_MAX)
+ name(""),
+ coordinate(0, 0),
+ skin(""),
+ sight(0),
+ direction(UINT_MAX),
+ ai(""),
+ appearFlag(0, 0),
+ overworldDialog(UINT_MAX),
+ winDialog(UINT_MAX),
+ loseDialog(UINT_MAX),
+ leadPokemon(UINT_MAX)
{
LogCtor("MapTrainer", _id);
id = _id;
@@ -104,16 +104,23 @@ void PokeGen::PokeMod::MapTrainer::Validate() LogVarNotValid("MapTrainer", id, "leadPokemon", name);
isValid = false;
}
- // Check if there are any Pokémon defined
if (GetMapTrainerTeamCount())
{
- // Validate each Pokémon
+ std::map<unsigned, unsigned> idChecker;
for (std::vector<MapTrainerTeam>::iterator i = team.begin(); i != team.end(); ++i)
{
LogSubmoduleIterate("MapTrainer", id, "team Pokémon", i->GetId(), name);
- // If a Pokémon isn't valid, neither is the ability
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("MapTrainer", id, "team Pokémon", i->first, name);
+ isValid = false;
+ }
}
}
else
@@ -131,7 +138,7 @@ void PokeGen::PokeMod::MapTrainer::Validate(const wxListBox &output) if (name == "")
{
LogVarNotSet("MapTrainer", id, "name");
- output.append(ConsoleLogVarNotSet("MapTrainer", id, "name"));
+ output.Append(ConsoleLogVarNotSet("MapTrainer", id, "name"));
isValid = false;
}
if (!skin.DoesExist())
@@ -139,19 +146,19 @@ void PokeGen::PokeMod::MapTrainer::Validate(const wxListBox &output) if (skin == "")
{
LogVarNotSet("MapTrainer", id, "skin", name);
- output.append(ConsoleLogVarNotSet("MapTrainer", id, "skin", name));
+ output.Append(ConsoleLogVarNotSet("MapTrainer", id, "skin", name));
}
else
{
LogVarNotValid("MapTrainer", id, "skin", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "skin", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "skin", name));
}
isValid = false;
}
if (DIR_END_NONE <= direction)
{
LogVarNotValid("MapTrainer", id, "direction", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "direction", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "direction", name));
isValid = false;
}
if (!ai.DoesExist())
@@ -159,55 +166,63 @@ void PokeGen::PokeMod::MapTrainer::Validate(const wxListBox &output) if (ai == "")
{
LogVarNotSet("MapTrainer", id, "ai", name);
- output.append(ConsoleLogVarNotSet("MapTrainer", id, "ai", name));
+ output.Append(ConsoleLogVarNotSet("MapTrainer", id, "ai", name));
}
else
{
LogVarNotValid("MapTrainer", id, "ai", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "ai", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "ai", name));
}
isValid = false;
}
if (!curPokeMod.GetDialog(overworldDialog))
{
LogVarNotValid("MapTrainer", id, "overworldDialog", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "overworldDialog", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "overworldDialog", name));
isValid = false;
}
if (!curPokeMod.GetDialog(winDialog))
{
LogVarNotValid("MapTrainer", id, "winDialog", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "winDialog", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "winDialog", name));
isValid = false;
}
if (!curPokeMod.GetDialog(loseDialog))
{
LogVarNotValid("MapTrainer", id, "loseDialog", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "loseDialog", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "loseDialog", name));
isValid = false;
}
if (!GetMapTrainerTeam(leadPokemon))
{
LogVarNotValid("MapTrainer", id, "leadPokemon", name);
- output.append(ConsoleLogVarNotValid("MapTrainer", id, "leadPokemon", name));
+ output.Append(ConsoleLogVarNotValid("MapTrainer", id, "leadPokemon", name));
isValid = false;
}
- // Check if there are any Pokémon defined
if (GetMapTrainerTeamCount())
{
- // Validate each Pokémon
+ std::map<unsigned, unsigned> idChecker;
for (std::vector<MapTrainerTeam>::iterator i = team.begin(); i != team.end(); ++i)
{
LogSubmoduleIterate("MapTrainer", id, "team Pokémon", i->GetId(), name);
- // If a Pokémon isn't valid, neither is the ability
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecekr.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("MapTrainer", id, "team Pokémon", i->first, name);
+ output.Append(ConsoleLogDuplicateId("MapTrainer", id, "team Pokémon", i->first, name));
+ isValid = false;
+ }
}
}
else
{
LogSubmoduleEmpty("MapTrainer", id, "team Pokémon", name);
- output.append(ConsoleLogSubmoduleEmpty("MapTrainer", id, "team Pokémon", name));
+ output.Append(ConsoleLogSubmoduleEmpty("MapTrainer", id, "team Pokémon", name));
isValid = false;
}
LogValidateOver("MapTrainer", id, isValid, name);
@@ -248,7 +263,7 @@ void PokeGen::PokeMod::MapTrainer::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::MapTrainer::ExportIni(std::ofstream &fout, const String &map) const
{
LogExportStart("MapTrainer", id, name);
- Ini exMapTrainer(map + "MapTrainer");
+ Ini exMapTrainer("mapTrainer " + map);
exMapTrainer.AddField("id", id);
exMapTrainer.AddField("name", name);
exMapTrainer.AddField("name", name);
@@ -364,14 +379,14 @@ void PokeGen::PokeMod::MapTrainer::SetOverworldDialog(const unsigned o) {
LogSetVar("MapTrainer", id, "overworldDialog", o, name);
if (curPokeMod.GetDialog(o))
- overworldDialog = o;
+ overworldDialog = o;
}
void PokeGen::PokeMod::MapTrainer::SetWinDialog(const unsigned w)
{
LogSetVar("MapTrainer", id, "winDialog", w, name);
if (curPokeMod.GetDialog(w))
- winDialog = w;
+ winDialog = w;
}
PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetName() const
@@ -534,7 +549,6 @@ unsigned PokeGen::PokeMod::MapTrainer::GetMapTrainerTeamCount() const void PokeGen::PokeMod::MapTrainer::NewMapTrainerTeam(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetMapTrainerTeamCount(); ++i)
{
if (!GetMapTrainerTeam(i))
diff --git a/pokemod/MapTrainer.h b/pokemod/MapTrainer.h index ba6692e3..ed319d4e 100644 --- a/pokemod/MapTrainer.h +++ b/pokemod/MapTrainer.h @@ -25,6 +25,7 @@ #define __POKEMOD_MAPTRAINER__
#include <vector>
+#include <map>
#include "Object.h"
#include "String.h"
#include "Flag.h"
diff --git a/pokemod/MapTrainerTeam.cpp b/pokemod/MapTrainerTeam.cpp index bd7c59d6..6e61bee9 100644 --- a/pokemod/MapTrainerTeam.cpp +++ b/pokemod/MapTrainerTeam.cpp @@ -26,9 +26,9 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::MapTrainerTeam::MapTrainerTeam(const unsigned _id) :
- species(UINT_MAX),
- level(1),
- item(UINT_MAX)
+ species(UINT_MAX),
+ level(1),
+ item(UINT_MAX)
{
LogCtor("MapTrainerTeam", _id);
id = _id;
@@ -100,7 +100,6 @@ void PokeGen::PokeMod::MapTrainerTeam::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("MapTrainerTeam");
}
@@ -115,8 +114,7 @@ void PokeGen::PokeMod::MapTrainerTeam::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::MapTrainerTeam::ExportIni(std::ofstream &fout, const String &map, const unsigned trainerId) const
{
LogExportStart("MapTrainerTeam", id);
- // Make elements
- Ini exMapTrainerTeam(map + String(" %u MapTrainerTeam", trainerId));
+ Ini exMapTrainerTeam(String("MapTrainerTeam %u ", trainerId) + map);
exMapTrainerTeam.AddField("id", id);
exMapTrainerTeam.AddField("species", species);
exMapTrainerTeam.AddField("level", level);
diff --git a/pokemod/MapWarp.cpp b/pokemod/MapWarp.cpp index 3fbf3cf4..ee7e4e5f 100644 --- a/pokemod/MapWarp.cpp +++ b/pokemod/MapWarp.cpp @@ -26,20 +26,20 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::MapWarp::MapWarp(const unsigned _id) :
- name(""),
- coordinate(0, 0),
- fromUp(false),
- fromDown(false),
- fromLeft(false),
- fromRight(false),
- directionOut(UINT_MAX),
- warpType(UINT_MAX),
- isBiking(false),
- isFlash(false),
- toMap(UINT_MAX),
- toWarp(UINT_MAX),
- workingFlag(0, 0),
- dialog(UINT_MAX)
+ name(""),
+ coordinate(0, 0),
+ fromUp(false),
+ fromDown(false),
+ fromLeft(false),
+ fromRight(false),
+ directionOut(UINT_MAX),
+ warpType(UINT_MAX),
+ isBiking(false),
+ isFlash(false),
+ toMap(UINT_MAX),
+ toWarp(UINT_MAX),
+ workingFlag(0, 0),
+ dialog(UINT_MAX)
{
LogCtor("MapWarp", _id);
id = _id;
@@ -109,25 +109,25 @@ void PokeGen::PokeMod::MapWarp::Validate(const wxListBox &output) if (name == "")
{
LogVarNotSet("MapWarp", id, "name");
- output.append(ConsoleLogVarNotSet("MapWarp", id, "name"));
+ output.Append(ConsoleLogVarNotSet("MapWarp", id, "name"));
isValid = false;
}
if (!fromUp && !fromDown && !fromLeft && !fromRight)
{
LogVarNotSet("MapWarp", id, "directions", name);
- output.append(ConsoleLogVarNotSet("MapWarp", id, "directions", name));
+ output.Append(ConsoleLogVarNotSet("MapWarp", id, "directions", name));
isValid = false;
}
if (DIR_END_NONE <= directionOut)
{
LogVarNotValid("MapWarp", id, "directionOut", name);
- output.append(ConsoleLogVarNotValid("MapWarp", id, "directionOut", name));
+ output.Append(ConsoleLogVarNotValid("MapWarp", id, "directionOut", name));
isValid = false;
}
if (WT_END <= warpType)
{
LogVarNotValid("MapWarp", id, "warpType", name);
- output.append(ConsoleLogVarNotValid("MapWarp", id, "warpType", name));
+ output.Append(ConsoleLogVarNotValid("MapWarp", id, "warpType", name));
isValid = false;
}
if (const Map *m = curPokeMod.GetMap(toMap))
@@ -135,20 +135,20 @@ void PokeGen::PokeMod::MapWarp::Validate(const wxListBox &output) if (!m->GetMapWarp(toWarp))
{
LogVarNotValid("MapWarp", id, "toWarp");
- output.append(ConsoleLogVarNotValid("MapWarp", id, "toWarp"));
+ output.Append(ConsoleLogVarNotValid("MapWarp", id, "toWarp"));
isValid = false;
}
}
else
{
LogVarNotValid("MapWarp", id, "toMap");
- output.append(ConsoleLogVarNotValid("MapWarp", id, "toMap"));
+ output.Append(ConsoleLogVarNotValid("MapWarp", id, "toMap"));
isValid = false;
}
if (!curPokeMod.GetDialog(dialog))
{
LogVarNotValid("MapWarp", id, "dialog");
- output.append(ConsoleLogVarNotValid("MapWarp", id, "dialog"));
+ output.Append(ConsoleLogVarNotValid("MapWarp", id, "dialog"));
isValid = false;
}
LogValidateOver("MapWarp", id, isValid, name);
@@ -192,7 +192,7 @@ void PokeGen::PokeMod::MapWarp::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::MapWarp::ExportIni(std::ofstream &fout, const String &map) const
{
LogExportStart("MapWarp", id, name);
- Ini exMapWarp(map + " mapWarp");
+ Ini exMapWarp("mapWarp " + map);
exMapWarp.AddField("id", id);
exMapWarp.AddField("coordinate-x", coordinate.GetX());
exMapWarp.AddField("coordinate-y", coordinate.GetY());
@@ -318,8 +318,8 @@ void PokeGen::PokeMod::MapWarp::SetToMap(const String &t) LogSetVar("MapWarp", id, "toMap string", t, name);
if (const Map *m = curPokeMod.GetMap(t))
{
- toMap = m->GetId();
- toWarp = UINT_MAX;
+ toMap = m->GetId();
+ toWarp = UINT_MAX;
}
}
diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp index d7dab5f5..6ffdcf28 100644 --- a/pokemod/MapWildList.cpp +++ b/pokemod/MapWildList.cpp @@ -26,9 +26,9 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::MapWildList::MapWildList(const unsigned _id) :
- control(UINT_MAX),
- value(INT_MAX),
- scope(INT_MAX)
+ control(UINT_MAX),
+ value(INT_MAX),
+ scope(INT_MAX)
{
LogCtor("MapWildList", _id);
id = _id;
@@ -54,15 +54,35 @@ void PokeGen::PokeMod::MapWildList::Validate() #endif
{
LogValidateStart("MapWildList", id);
+ unsigned i = 0;
+ unsigned j = 0;
+ bool temp = false;
if (CTRL_END <= control)
{
LogVarNotValid("MapWildList", id, "control");
- isValid = true;
+ isValid = false;
}
else if (control == CTRL_FISHING)
{
- // TODO (Ben#1#): Value validation
+ if (const Item *item = curPokeMod.GetItem(value))
+ {
+ while ((i < item->GetItemEffectCount()) || !temp)
+ {
+ if (const ItemEffect *e = item->GetItemEffect(j++))
+ {
+ ++i;
+ if (e->GetEffect() == IE_FISH)
+ temp = true;
+ }
+ }
+ }
+ if (!temp)
+ {
+ LogVarNotValid("ItemEffect", id, "value");
+ isValid = false;
+ }
}
+ std::map<unsigned, unsigned> idChecker;
for (std::vector<unsigned>::const_iterator i = times.begin(); i != times.end(); ++i)
{
if (!curPokeMod.GetTime(*i))
@@ -70,8 +90,42 @@ void PokeGen::PokeMod::MapWildList::Validate() LogVarNotValid("MapWildList", id, "times");
isValid = false;
}
+ ++idChecker[*i];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("MapWildList", id, "times", i->first);
+ isValid = false;
+ }
+ }
+ if (scope != UINT_MAX)
+ {
+ temp = false;
+ if (const Item *item = curPokeMod.GetItem(scope))
+ {
+ i = 0;
+ j = 0;
+ while (i < item->GetItemEffectCount())
+ {
+ if (const ItemEffect *e = item->GetItemEffect(j++))
+ {
+ ++i;
+ if (e->GetEffect() == IE_SCOPE)
+ {
+ temp = true;
+ break;
+ }
+ }
+ }
+ }
+ if (!temp)
+ {
+ LogVarNotValid("ItemEffect", id, "value");
+ isValid = false;
+ }
}
- // TODO (Ben#1#): Scope validation
LogValidateOver("MapWildList", id, isValid);
}
@@ -81,7 +135,6 @@ void PokeGen::PokeMod::MapWildList::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("MapWildList");
}
@@ -106,7 +159,6 @@ void PokeGen::PokeMod::MapWildList::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::MapWildList::ExportIni(std::ofstream &fout, const String &map) const
{
LogExportStart("MapWildList", id);
- // Make elements
Ini exMapWildList(map + " mapWildList");
exMapWildList.AddField("id", id);
exMapWildList.AddField("control", control);
@@ -130,11 +182,11 @@ void PokeGen::PokeMod::MapWildList::SetControl(const unsigned c) void PokeGen::PokeMod::MapWildList::SetValue(const unsigned v)
{
- unsigned i = 0;
- unsigned j = 0;
LogSetVar("MapWildList", id, "value", v);
if (const Item *item = curPokeMod.GetItem(v))
{
+ unsigned i = 0;
+ unsigned j = 0;
while (i < item->GetItemEffectCount())
{
if (const ItemEffect *effect = item->GetItemEffect(j++))
@@ -142,7 +194,7 @@ void PokeGen::PokeMod::MapWildList::SetValue(const unsigned v) ++i;
if (effect->GetEffect() == IE_FISH)
{
- value = effect->GetVal1();
+ value = v;
break;
}
}
@@ -187,17 +239,22 @@ void PokeGen::PokeMod::MapWildList::SetTime(const String &ts, const bool t) void PokeGen::PokeMod::MapWildList::SetScope(const unsigned s)
{
LogSetVar("MapWildList", id, "scope", s);
- unsigned i = 0;
- unsigned j = 0;
+ if (s == UINT_MAX)
+ {
+ scope = UINT_MAX;
+ return;
+ }
if (const Item *item = curPokeMod.GetItem(s))
{
+ unsigned i = 0;
+ unsigned j = 0;
while (i < item->GetItemEffectCount())
{
if (const ItemEffect *effect = item->GetItemEffect(j++))
{
++i;
if (effect->GetEffect() == IE_SCOPE)
- scope = effect->GetVal1();
+ scope = s;
}
}
}
@@ -206,6 +263,11 @@ void PokeGen::PokeMod::MapWildList::SetScope(const unsigned s) void PokeGen::PokeMod::MapWildList::SetScope(const String &s)
{
LogSetVar("MapWildList", id, "scope string", s);
+ if (s == "None")
+ {
+ scope = UINT_MAX;
+ return;
+ }
if (const Item *i = curPokeMod.GetItem(s))
SetScope(i->GetId());
}
@@ -280,7 +342,6 @@ unsigned PokeGen::PokeMod::MapWildList::GetMapWildPokemonCount() const void PokeGen::PokeMod::MapWildList::NewMapWildPokemon(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetMapWildPokemonCount(); ++i)
{
if (!GetMapWildPokemon(i))
diff --git a/pokemod/MapWildList.h b/pokemod/MapWildList.h index 56499367..f1817879 100644 --- a/pokemod/MapWildList.h +++ b/pokemod/MapWildList.h @@ -57,7 +57,7 @@ namespace PokeGen bool GetTime(const unsigned ts) const;
bool GetTime(const String &ts) const;
int GetScope() const;
-
+
const MapWildPokemon *GetMapWildPokemon(const unsigned _id) const;
const MapWildPokemon *GetMapWildPokemon(const String &n) const;
unsigned GetMapWildPokemonCount() const;
@@ -70,9 +70,9 @@ namespace PokeGen # endif
unsigned control;
- int value;
+ unsigned value;
std::vector<unsigned> times;
- int scope;
+ unsigned scope;
std::vector<MapWildPokemon> pokemon;
};
diff --git a/pokemod/MapWildPokemon.cpp b/pokemod/MapWildPokemon.cpp index 07a4dee3..cc42f3b4 100644 --- a/pokemod/MapWildPokemon.cpp +++ b/pokemod/MapWildPokemon.cpp @@ -26,9 +26,9 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::MapWildPokemon::MapWildPokemon(const unsigned _id) :
- pokemon(UINT_MAX),
- level(1),
- weight(1)
+ pokemon(UINT_MAX),
+ level(1),
+ weight(1)
{
LogCtor("MapWildPokemon", _id);
id = _id;
@@ -100,7 +100,6 @@ void PokeGen::PokeMod::MapWildPokemon::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("MapWildPokemon");
}
@@ -115,8 +114,7 @@ void PokeGen::PokeMod::MapWildPokemon::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::MapWildPokemon::ExportIni(std::ofstream &fout, const String &map, const unsigned listId) const
{
LogExportStart("MapWildPokemon", id);
- // Make elements
- Ini exMapWildPokemon(map + String(" %u mapWildPokemon", listId));
+ Ini exMapWildPokemon(String("mapWildPokemon %u ", listId) + map);
exMapWildPokemon.AddField("id", id);
exMapWildPokemon.AddField("pokemon", pokemon);
exMapWildPokemon.AddField("level", level);
diff --git a/pokemod/Matrix.h b/pokemod/Matrix.h index c4ea42c0..7b78bcec 100644 --- a/pokemod/Matrix.h +++ b/pokemod/Matrix.h @@ -37,13 +37,13 @@ namespace PokeGen {
public:
MatrixBase() :
- width(0),
- height(0)
+ width(0),
+ height(0)
{
}
MatrixBase(const unsigned w, const unsigned h, const T &d = T()) :
- width(w),
- height(h)
+ width(w),
+ height(h)
{
matrix.resize(w, std::vector<T>(h, d));
}
@@ -64,7 +64,7 @@ namespace PokeGen if (height < pos)
return false;
for (typename std::vector< std::vector<T> >::iterator i = matrix.begin(); i != matrix.end(); ++i)
- i->insert(pos, d);
+ i->insert(i->begin() + pos, d);
++height;
return true;
}
@@ -72,7 +72,7 @@ namespace PokeGen {
if (width < pos)
return false;
- matrix.insert(pos, std::vector<T>(height, d));
+ matrix.insert(matrix.begin() + pos, std::vector<T>(height, d));
++width;
return true;
}
@@ -93,6 +93,10 @@ namespace PokeGen --width;
return true;
}
+ void Clear()
+ {
+ matrix.clear();
+ }
bool Set(const unsigned row, const unsigned col, const T &s)
{
@@ -101,6 +105,13 @@ namespace PokeGen (matrix.begin() + col)->assign(row, s);
return true;
}
+ void Resize(const unsigned w, const unsigned h, const T &d = T())
+ {
+ Clear();
+ width = w;
+ height = h;
+ matrix.resize(w, std::vector<T>(h, d));
+ }
T Get(const unsigned row, const unsigned col) const
{
diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp index 6dee45f6..5aa55267 100644 --- a/pokemod/Move.cpp +++ b/pokemod/Move.cpp @@ -25,28 +25,25 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
-PokeGen::PokeMod::Move::Move(const unsigned _id)
+PokeGen::PokeMod::Move::Move(const unsigned _id) :
+ name(""),
+ accuracy(1, 1),
+ power(0),
+ type(UINT_MAX),
+ special(false),
+ powerPoints(0),
+ target(UINT_MAX),
+ ignoreAccuracy(false),
+ ignoreFlinch(false),
+ sound(false),
+ description(""),
+ contestType(UINT_MAX),
+ contestPoints(0),
+ jamPoints(0),
+ contestEffect(UINT_MAX),
+ contestTarget(UINT_MAX)
{
LogCtor("Move", _id);
- name = "";
- accuracy.Set(1, 1);
- power = 0;
- type = UINT_MAX;
- special = false;
- powerPoints = 1;
- target = UINT_MAX;
- numTargets = 0;
- targetChoice = UINT_MAX;
- ignoreAccuracy = false;
- ignoreFlinch = false;
- sound = false;
- description = "";
- contestType = UINT_MAX;
- contestPoints = 0;
- jamPoints = 0;
- contestEffect = UINT_MAX;
- contestTarget = UINT_MAX;
- effects.clear();
id = _id;
}
@@ -120,6 +117,40 @@ void PokeGen::PokeMod::Move::Validate() isValid = false;
}
}
+ if (GetMoveEffectCount())
+ {
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
+ for (std::vector<MoveEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
+ {
+ LogSubmoduleIterate("Move", 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("Move", 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("Move", id, "effect", i->first, name);
+ isValid = false;
+ }
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Move", id, "effect", name);
+ isValid = false;
+ }
LogValidateOver("Move", id, name);
}
@@ -127,40 +158,40 @@ void PokeGen::PokeMod::Move::Validate() void PokeGen::PokeMod::Move::Validate(const wxListBox &output)
{
LogValidateStart("Move", id, name);
- if (name == ""
+ if (name == "")
{
LogVarNotSet("Move", id, "name");
- output.append(ConsoleLogVarNotSet("Move", id, "name"););
+ output.Append(ConsoleLogVarNotSet("Move", id, "name"););
isValid = "";
}
if (!curPokeMod.GetType(type))
{
LogVarNotValid("Move", id, "type", name);
- output.append(ConsoleLogVarNotValid("Move", id, "type", name));
+ output.Append(ConsoleLogVarNotValid("Move", id, "type", name));
isValid = false;
}
if (!powerPoints)
{
LogVarNotValid("Move", id, "powerPoints", name);
- output.append(ConsoleLogVarNotValid("Move", id, "powerPoints", name));
+ output.Append(ConsoleLogVarNotValid("Move", id, "powerPoints", name));
isValid = false;
}
if (TAR_END <= target)
{
LogVarNotValid("Move", id, "target", name);
- output.append(ConsoleLogVarNotValid("Move", id, "target", name));
+ output.Append(ConsoleLogVarNotValid("Move", id, "target", name));
isValid = false;
}
if (!targets || (curPokeMod.GetMaxFight() << 1) < numTargets)
{
LogVarNotValid("Move", id, "numTargets", name);
- output.append(ConsoleLogVarNotValid("Move", id, "numTargets", name));
+ output.Append(ConsoleLogVarNotValid("Move", id, "numTargets", name));
isValid = false;
}
if (CHC_END <= targetChoice)
{
LogVarNotValid("Move", id, "targetChoice", name);
- output.append(ConsoleLogVarNotValid("Move", id, "targetChoice", name));
+ output.Append(ConsoleLogVarNotValid("Move", id, "targetChoice", name));
isValid = false;
}
if (curPokeMod.IsContestAllowed())
@@ -168,28 +199,65 @@ void PokeGen::PokeMod::Move::Validate(const wxListBox &output) if (COTY_END <= contestType)
{
LogVarNotValid("Move", id, "contestType", name);
- output.append(ConsoleLogVarNotValid("Move", id, "contestType", name));
+ output.Append(ConsoleLogVarNotValid("Move", id, "contestType", name));
isValid = false;
}
if (!contestPoints)
{
LogVarNotValid("Move", id, "contestPoints", name);
- output.append(ConsoleLogVarNotValid("Move", id, "contestPoints", name));
+ output.Append(ConsoleLogVarNotValid("Move", id, "contestPoints", name));
isValid = false;
}
if (CONE_END <= contestEffect)
{
LogVarNotValid("Move", id, "contestEffect", name);
- output.append(ConsoleLogVarNotValid("Move", id, "contestEffect", name));
+ output.Append(ConsoleLogVarNotValid("Move", id, "contestEffect", name));
isValid = false;
}
if (CONT_END <= contestTarget)
{
LogVarNotValid("Move", id, "contestTarget", name);
- output.append(ConsoleLogVarNotValid("Move", id, "contestTarget", name));
+ output.Append(ConsoleLogVarNotValid("Move", id, "contestTarget", name));
isValid = false;
}
}
+ if (GetMoveEffectCount())
+ {
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
+ for (std::vector<MoveEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
+ {
+ LogSubmoduleIterate("Move", 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("Move", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Move", 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("Move", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Move", id, "effect", i->first, name));
+ isValid = false;
+ }
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Move", id, "effect", name);
+ output.Append(ConsoleLogSubmoduleEmpty("Move", id, "effect", name));
+ isValid = false;
+ }
LogValidateOver("Move", id, move);
}
#endif
@@ -207,7 +275,7 @@ void PokeGen::PokeMod::Move::ImportIni(Ini &ini, const unsigned _id) id = _id;
unsigned i;
unsigned j;
- ini.GetValue("name", name, "");
+ ini.GetValue("name", name);
ini.GetValue("accuracy-n", i, 1);
ini.GetValue("accuracy-d", j, 1);
accuracy.Set(i, j);
@@ -392,7 +460,7 @@ void PokeGen::PokeMod::Move::SetContestPoints(const int c) void PokeGen::PokeMod::Move::SetJamPoints(const int j)
{
- LogSetVar("Move", id, "jamPoints",j, name);
+ LogSetVar("Move", id, "jamPoints", j, name);
jamPoints = j;
}
@@ -603,7 +671,6 @@ unsigned PokeGen::PokeMod::Move::GetMoveEffectCount() const void PokeGen::PokeMod::Move::NewMoveEffect(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetMoveEffectCount(); ++i)
{
if (!GetMoveEffect(i))
@@ -629,3 +696,4 @@ void PokeGen::PokeMod::Move::DeleteMoveEffect(unsigned _id) }
LogSubmoduleRemoveFail("Move", id, "effect", _id, name);
}
+
diff --git a/pokemod/Move.h b/pokemod/Move.h index ccc03850..e585eee2 100644 --- a/pokemod/Move.h +++ b/pokemod/Move.h @@ -25,6 +25,7 @@ #define __POKEMOD_MOVE__
#include <vector>
+#include <map>
#include "Object.h"
#include "String.h"
#include "MoveEffect.h"
diff --git a/pokemod/MoveEffect.cpp b/pokemod/MoveEffect.cpp index fc05511d..88926348 100644 --- a/pokemod/MoveEffect.cpp +++ b/pokemod/MoveEffect.cpp @@ -25,13 +25,13 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
-PokeGen::PokeMod::MoveEffect::MoveEffect(const unsigned _id)
+PokeGen::PokeMod::MoveEffect::MoveEffect(const unsigned _id) :
+ chance(1, 1),
+ effect(UINT_MAX),
+ val1(INT_MAX),
+ val2(UINT_MAX)
{
LogCtor("MoveEffect", _id);
- chance.Set(1, 1);
- effect = UINT_MAX;
- val1 = INT_MAX;
- val2 = UINT_MAX;
id = _id;
}
@@ -56,6 +56,7 @@ void PokeGen::PokeMod::MoveEffect::Validate() {
LogValidateStart("MoveEffect", id);
// TODO (Validation#1#): MoveEffect Validation
+# warning "MoveEffect Validation"
LogValidateOver("MoveEffect", id, isValid);
}
@@ -65,7 +66,6 @@ void PokeGen::PokeMod::MoveEffect::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("MoveEffect");
}
@@ -84,7 +84,6 @@ void PokeGen::PokeMod::MoveEffect::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::MoveEffect::ExportIni(std::ofstream &fout, const String &move) const
{
LogExportStart("MoveEffect", id);
- // Make elements
Ini exMoveEffect(move + " moveEffect");
exMoveEffect.AddField("id", id);
exMoveEffect.AddField("chance-n", chance.GetNum());
diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp index e7ff5c93..c6059ccb 100644 --- a/pokemod/Nature.cpp +++ b/pokemod/Nature.cpp @@ -24,7 +24,7 @@ #include "Nature.h"
PokeGen::PokeMod::Nature::Nature(const unsigned _id) :
- name("")
+ name("")
{
LogCtor("Nature", _id);
id = _id;
@@ -51,13 +51,33 @@ void PokeGen::PokeMod::Nature::Validate() LogVarNotSet("Nature", id, "name");
isValid = false;
}
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
if (GetNatureEffectCount())
{
- for (unsigned i = 0; i < GetNatureEffectCount(); ++i)
+ for (std::vector<NatureEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
- LogSubmoduleIterate("Nature", id, "effect", i, name);
- if (!effects[i].IsValid())
+ LogSubmoduleIterate("Nature", id, "effect", i->GetId(), name);
+ if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ ++effectChecker[i->GetStatString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Nature", 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("Nature", id, "effect", i->first, name);
+ isValid = false;
+ }
}
}
else
@@ -75,16 +95,38 @@ void PokeGen::PokeMod::Nature::Validate(const wxListBox &output) if (name == "")
{
LogVarNotSet("Nature", id, "name");
- output.Append(ConsoleLogVarNotSet("Nature", id, "name");
+ output.Append(ConsoleLogVarNotSet("Nature", id, "name"));
isValid = false;
}
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
if (GetNatureEffectCount())
{
- for (unsigned i = 0; i < GetNatureEffectCount(); ++i)
+ for (std::vector<NatureEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
+ {
+ LogSubmoduleIterate("Nature", 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("Nature", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Nature", id, "effect", i->first, name));
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i)
{
- LogSubmoduleIterate("Nature", "effect", id, i, name);
- if (!effects[i].IsValid())
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Nature", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Nature", id, "effect", i->first, name));
isValid = false;
+ }
}
}
else
@@ -104,13 +146,12 @@ void PokeGen::PokeMod::Nature::ImportIni(Ini &ini, const unsigned _id) if (_id == UINT_MAX)
{
ini.GetValue("id", id);
- // Was there an id associated with the section?
if (id == UINT_MAX)
LogIdNotFound("Nature");
}
else
id = _id;
- ini.GetValue("name", name, "");
+ ini.GetValue("name", name);
effects.clear();
LogImportOver("Nature");
}
@@ -159,7 +200,6 @@ unsigned PokeGen::PokeMod::Nature::GetNatureEffectCount() const void PokeGen::PokeMod::Nature::NewNatureEffect(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetNatureEffectCount(); ++i)
{
if (!GetNatureEffect(i))
diff --git a/pokemod/Nature.h b/pokemod/Nature.h index eb544884..57bd4ba0 100644 --- a/pokemod/Nature.h +++ b/pokemod/Nature.h @@ -46,7 +46,7 @@ namespace PokeGen void SetName(const String &n);
String GetName() const;
-
+
const NatureEffect *GetNatureEffect(const unsigned _id) const;
unsigned GetNatureEffectCount() const;
void NewNatureEffect(Ini *const ini = NULL);
diff --git a/pokemod/NatureEffect.cpp b/pokemod/NatureEffect.cpp index 6f040b5f..04ab35f5 100644 --- a/pokemod/NatureEffect.cpp +++ b/pokemod/NatureEffect.cpp @@ -26,8 +26,8 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::NatureEffect::NatureEffect(const unsigned _id) :
- stat(UINT_MAX),
- multiplier(1, 1)
+ stat(UINT_MAX),
+ multiplier(1, 1)
{
LogCtor("NatureEffect", _id);
id = _id;
@@ -65,7 +65,7 @@ void PokeGen::PokeMod::NatureEffect::Validate(const wxListBox &output) if ((curPokeMod.IsSpecialSplit() ? STH_END_GSC : STH_END_RBY) <= stat)
{
LogVarNotValid("NatureEffect", id, "stat");
- output.append(ConsoleLogVarNotValid("NatureEffect", id, "stat"));
+ output.Append(ConsoleLogVarNotValid("NatureEffect", id, "stat"));
isValid = false;
}
multipler.Reduce();
@@ -80,7 +80,6 @@ void PokeGen::PokeMod::NatureEffect::ImportIni(Ini &ini, const unsigned _id) if (_id == UINT_MAX)
{
ini.GetValue("id", id);
- // Was there an id associated with the section?
if (id == UINT_MAX)
LogIdNotFound("NatureEffect");
}
@@ -98,8 +97,7 @@ void PokeGen::PokeMod::NatureEffect::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::NatureEffect::ExportIni(std::ofstream &fout, const String &nature) const
{
LogExportStart("NatureEffect", id);
- // Make elements
- Ini exNatureEffect(nature + " natureEffect");
+ Ini exNatureEffect("natureEffect " + nature);
exNatureEffect.AddField("id", id);
exNatureEffect.AddField("stat", stat);
exNatureEffect.AddField("multiplier-n", multiplier.GetNum());
diff --git a/pokemod/Object.cpp b/pokemod/Object.cpp index cb9f1f8b..d2d9c315 100644 --- a/pokemod/Object.cpp +++ b/pokemod/Object.cpp @@ -40,7 +40,6 @@ bool PokeGen::PokeMod::Object::IsValid() #ifdef PG_DEBUG_WINDOW
bool PokeGen::PokeMod::Object::IsValid(const wxListBox &output)
{
- // Validate with debugging console output
isValid = (id != UINT_MAX);
if (isValid)
Validate(output);
diff --git a/pokemod/Path.cpp b/pokemod/Path.cpp index c8945e28..a8fa5ebb 100644 --- a/pokemod/Path.cpp +++ b/pokemod/Path.cpp @@ -50,7 +50,6 @@ bool PokeGen::PokeMod::Path::DoesExist() {
if (*this == "")
return false;
- // Try to open the file
std::ifstream test(c_str(), std::ios::in);
test.close();
if (test.fail())
@@ -65,7 +64,6 @@ bool PokeGen::PokeMod::Path::HasExtension(const String &ext) String fileExt(substr(pos + 1));
if ((pos == npos) || (pos + 1 == length()) || (fileExt.length() != ext.length()))
return false;
- // Loop while the two are equal
for (unsigned i = 0; ret && (i < ext.length()); ++i)
ret = (tolower(ext[i]) == tolower(fileExt[i]));
return ret;
diff --git a/pokemod/Point.cpp b/pokemod/Point.cpp index c4e32859..40c97050 100644 --- a/pokemod/Point.cpp +++ b/pokemod/Point.cpp @@ -35,7 +35,6 @@ void PokeGen::PokeMod::Point::ImportIni(Ini &ini) void PokeGen::PokeMod::Point::ExportIni(std::ofstream &fout, const String &val) const
{
Log(String("Point Export: Starting (%u, %u) as %s", x, y, val.c_str()), PM_DEBUG_INFO);
- // Declare the elements
Ini exPoint(val);
exPoint.AddField("x", x);
exPoint.AddField("y", y);
diff --git a/pokemod/Point.h b/pokemod/Point.h index 6071d205..b05a7428 100644 --- a/pokemod/Point.h +++ b/pokemod/Point.h @@ -35,8 +35,8 @@ namespace PokeGen {
public:
inline Point(const unsigned _x = 0, const unsigned _y = 0) :
- x(_x),
- y(_y)
+ x(_x),
+ y(_y)
{
}
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index 4799fd89..615fb565 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////
// Name: pokemod/Pokemod.cpp
-// Purpose:
+// Purpose: Define a custom PokéMod for PokéGen
// Author: Ben Boeckel
// Modified by: Ben Boeckel
// Created: Sat Feb 24 21:41:19 2007
@@ -23,7 +23,54 @@ #include "Pokemod.h"
-PokeGen::PokeMod::Pokemod::Pokemod()
+PokeGen::PokeMod::Pokemod::Pokemod() :
+ title(""),
+ version(""),
+ description(""),
+ genderAllowed(false),
+ breedingAllowed(false),
+ eggSpecies(UINT_MAX),
+ holdItems(false),
+ criticalDomains(false),
+ contestAllowed(false),
+ abilityAllowed(false),
+ natureAllowed(false),
+ numDaycares(0),
+ numPokemonBoxes(0),
+ numPokemonPerBox(1),
+ maxParty(1),
+ maxFight(1),
+ maxMoves(1),
+ maxLevel(1),
+ maxMoney(0),
+ hardCash(false),
+ specialSplit(false),
+ specialDVSplit(false),
+ maxDVValue(16),
+ happiness(false),
+ happyFaintLoss(0),
+ happyLevelGain(0),
+ happySteps(0),
+ effortValuesAllowed(false),
+ maxTotalEV(0),
+ maxEVPerStat(0),
+ pokerusChance(1, 1),
+ startMap(UINT_MAX),
+ startMoney(0),
+ startCoordinate(0, 0),
+ startDirection(UINT_MAX),
+ startDialog(UINT_MAX),
+ walkSkin(""),
+ bikeSkin(""),
+ surfSkin(""),
+ flySkin(""),
+ fishSkin(""),
+ surfFishSkin(""),
+ superPCUname(""),
+ superPCPasswd(""),
+ struggleMove(UINT_MAX),
+ confuseMove(UINT_MAX),
+ typeChart(1, 1, Frac(1, 1, true))
{
LogCtor("Pokemod", 0);
}
@@ -43,6 +90,7 @@ void PokeGen::PokeMod::Pokemod::Validate() {
LogValidateStart("Pokemod", 0);
// TODO (Validation#1#): Pokemod Validation
+# warning "Pokemod Validation"
LogValidateOver("Pokemod", 0, isValid);
}
@@ -55,10 +103,2565 @@ void PokeGen::PokeMod::Pokemod::Validate(const wxListBox &output) void PokeGen::PokeMod::Pokemod::ImportIni(std::ifstream &fin)
{
- // TODO (Ini#1#): Import Pokemod
+ LogImportStart("Pokemod");
+ std::vector<Ini> sections;
+ Ini meta("unset");
+ while (fin.peek() != '\n')
+ {
+ Ini curSection(fin);
+ if (curSection.GetName() == "pokemod")
+ {
+ if (meta.GetName() == "unset")
+ {
+ Log(String("Pokemod: Multiple meta data sections in PokéMod file"), PM_DEBUG_ERROR);
+ return;
+ }
+ meta = curSection;
+ unsigned i;
+ unsigned j;
+ curSection.GetValue("title", title);
+ curSection.GetValue("version", version);
+ curSection.GetValue("description", description);
+ curSection.GetValue("genderAllowed", genderAllowed, false);
+ curSection.GetValue("breedingAllowed", breedingAllowed, false);
+ curSection.GetValue("eggSpecies", eggSpecies);
+ curSection.GetValue("holdItems", holdItems, false);
+ curSection.GetValue("criticalDomains", criticalDomains, false);
+ curSection.GetValue("contestAllowed", contestAllowed, false);
+ curSection.GetValue("abilityAllowed", abilityAllowed, false);
+ curSection.GetValue("natureAllowed", natureAllowed, false);
+ curSection.GetValue("numDaycares", numDaycares, 0);
+ curSection.GetValue("numPokemonBoxes", numPokemonBoxes, 0);
+ curSection.GetValue("numPokemonPerBox", numPokemonPerBox, 1);
+ curSection.GetValue("maxParty", maxParty, 1);
+ curSection.GetValue("maxFight", maxFight, 1);
+ curSection.GetValue("maxMoves", maxMoves, 1);
+ curSection.GetValue("maxLevel", maxLevel, 0);
+ curSection.GetValue("maxMoney", maxMoney, 0);
+ curSection.GetValue("hardCash", hardCash, false);
+ curSection.GetValue("specialSplit", specialSplit, false);
+ curSection.GetValue("specialDVSplit", specialDVSplit, false);
+ curSection.GetValue("maxDVValue", maxDVValue, 16);
+ curSection.GetValue("happiness", happiness, false);
+ curSection.GetValue("happyFaintLoss", happyFaintLoss, 0);
+ curSection.GetValue("happyLevelGain", happyLevelGain, 0);
+ curSection.GetValue("happySteps", happySteps, 0);
+ curSection.GetValue("effortValuesAllowed", effortValuesAllowed, false);
+ curSection.GetValue("maxTotalEV", maxTotalEV, 0);
+ curSection.GetValue("maxEVPerStat", maxEVPerStat, 0);
+ curSection.GetValue("pokerusChance-n", i, 1);
+ curSection.GetValue("pokerusChance-d", j, 1);
+ pokerusChance.Set(i, j);
+ curSection.GetValue("startMap", startMap);
+ curSection.GetValue("startMoney", startMoney, 0);
+ curSection.GetValue("startCoordinate-x", i, 0);
+ curSection.GetValue("startCoordinate-y", j, 0);
+ startCoordinate.Set(i, j);
+ curSection.GetValue("startDirection", startDirection);
+ curSection.GetValue("startDialog", startDialog);
+ curSection.GetValue("walkSkin", walkSkin);
+ curSection.GetValue("bikeSkin", bikeSkin);
+ curSection.GetValue("surfSkin", surfSkin);
+ curSection.GetValue("flySkin", flySkin);
+ curSection.GetValue("fishSkin", fishSkin);
+ curSection.GetValue("surfFishSkin", surfFishSkin);
+ curSection.GetValue("superPCUname", superPCUname);
+ curSection.GetValue("superPCPasswd", superPCPasswd);
+ curSection.GetValue("struggleMove", struggleMove);
+ curSection.GetValue("confuseMove", confuseMove);
+ }
+ else if (curSection.GetName() == "ability")
+ NewAbility(&curSection);
+ else if (curSection.GetName() == "author")
+ NewAuthor(&curSection);
+ else if (curSection.GetName() == "badge")
+ NewBadge(&curSection);
+ else if (curSection.GetName() == "coinList")
+ NewCoinList(&curSection);
+ else if (curSection.GetName() == "dialog")
+ NewDialog(&curSection);
+ else if (curSection.GetName() == "eggGroup")
+ NewEggGroup(&curSection);
+ else if (curSection.GetName() == "item")
+ NewItem(&curSection);
+ else if (curSection.GetName() == "itemStorage")
+ NewItemStorage(&curSection);
+ else if (curSection.GetName() == "map")
+ NewMap(&curSection);
+ else if (curSection.GetName() == "move")
+ NewMove(&curSection);
+ else if (curSection.GetName() == "nature")
+ NewNature(&curSection);
+ else if (curSection.GetName() == "pokemon")
+ NewPokemon(&curSection);
+ else if (curSection.GetName() == "status")
+ NewStatus(&curSection);
+ else if (curSection.GetName() == "store")
+ NewStore(&curSection);
+ else if (curSection.GetName() == "tile")
+ NewTile(&curSection);
+ else if (curSection.GetName() == "time")
+ NewTime(&curSection);
+ else if (curSection.GetName() == "type")
+ NewType(&curSection);
+ else
+ sections.push_back(curSection);
+ }
+ if (meta.GetName() == "unset")
+ {
+ Log(String("Pokemod: No meta data found in PokéMod file"), PM_DEBUG_ERROR);
+ return;
+ }
+ for (std::vector<Type>::iterator i = types.begin(); i != types.end(); ++i)
+ {
+ for (std::vector<Type>::iterator j = types.begin(); j != types.end(); ++j)
+ {
+ unsigned k;
+ unsigned l;
+ meta.GetValue(String("typeChart-%u-%u-n", i->GetId(), j->GetId()), k, 1);
+ meta.GetValue(String("typeChart-%u-%u-d", i->GetId(), j->GetId()), l, 1);
+ SetTypeChart(i->GetId(), j->GetId(), k, l);
+ }
+ }
+ std::stringstream ss;
+ std::string s;
+ std::string s1;
+ unsigned u;
+ for (std::vector<Ini>::iterator i = sections.begin(); i != sections.end(); ++i)
+ {
+ ss.write(i->GetName().c_str(), i->GetName().length());
+ ss >> s;
+ ss >> s1;
+ if (s == "abilityEffect")
+ {
+ if (Ability *a = (Ability *)GetAbility(s1))
+ a->NewAbilityEffect(&*i);
+ sections.erase(i);
+ }
+ else if (s == "coinItem")
+ {
+ if (CoinList *c = (CoinList *)GetCoinList(s1))
+ c->NewCoinItem(&*i);
+ sections.erase(i);
+ }
+ else if (s == "itemEffect")
+ {
+ if (Item *it = (Item *)GetItem(s1))
+ it->NewItemEffect(&*i);
+ sections.erase(i);
+ }
+ else if (s == "mapEffect")
+ {
+ if (Map *m = (Map *)GetMap(s1))
+ m->NewMapEffect(&*i);
+ sections.erase(i);
+ }
+ else if (s == "mapTrainer")
+ {
+ if (Map *m = (Map *)GetMap(s1))
+ m->NewMapTrainer(&*i);
+ sections.erase(i);
+ }
+ else if (s == "mapWarp")
+ {
+ if (Map *m = (Map *)GetMap(s1))
+ m->NewMapWarp(&*i);
+ sections.erase(i);
+ }
+ else if (s == "mapWildList")
+ {
+ if (Map *m = (Map *)GetMap(s1))
+ m->NewMapWildList(&*i);
+ sections.erase(i);
+ }
+ else if (s == "moveEffect")
+ {
+ if (Move *m = (Move *)GetMove(s1))
+ m->NewMoveEffect(&*i);
+ sections.erase(i);
+ }
+ else if (s == "natureEffect")
+ {
+ if (Nature *n = (Nature *)GetNature(s1))
+ n->NewNatureEffect(&*i);
+ sections.erase(i);
+ }
+ else if (s == "pokemonAbility")
+ {
+ if (Pokemon *p = (Pokemon *)GetPokemon(s1))
+ p->NewPokemonAbility(&*i);
+ sections.erase(i);
+ }
+ else if (s == "pokemonEvolution")
+ {
+ if (Pokemon *p = (Pokemon *)GetPokemon(s1))
+ p->NewPokemonEvolution(&*i);
+ sections.erase(i);
+ }
+ else if (s == "pokemonItem")
+ {
+ if (Pokemon *p = (Pokemon *)GetPokemon(s1))
+ p->NewPokemonItem(&*i);
+ sections.erase(i);
+ }
+ else if (s == "pokemonMove")
+ {
+ if (Pokemon *p = (Pokemon *)GetPokemon(s1))
+ p->NewPokemonMove(&*i);
+ sections.erase(i);
+ }
+ else if (s == "pokemonNature")
+ {
+ if (Pokemon *p = (Pokemon *)GetPokemon(s1))
+ p->NewPokemonNature(&*i);
+ sections.erase(i);
+ }
+ else if (s == "statusEffect")
+ {
+ if (Status *st = (Status *)GetStatus(s1))
+ st->NewStatusEffect(&*i);
+ sections.erase(i);
+ }
+ ss.clear();
+ }
+ for (std::vector<Ini>::iterator i = sections.begin(); i != sections.end(); ++i)
+ {
+ if (s == "mapTrainerTeam")
+ {
+ ss >> u;
+ if (const Map *m = GetMap(s1))
+ {
+ if (MapTrainer *t = (MapTrainer *)m->GetMapTrainer(u))
+ t->NewMapTrainerTeam(&*i);
+ }
+ sections.erase(i);
+ }
+ else if (s == "mapWildPokemon")
+ {
+ ss >> u;
+ if (const Map *m = GetMap(s1))
+ {
+ if (MapWildList *t = (MapWildList *)m->GetMapWildList(u))
+ t->NewMapWildPokemon(&*i);
+ }
+ sections.erase(i);
+ }
+ }
+ for (std::vector<Ini>::iterator i = sections.begin(); i != sections.end(); ++i)
+ Log(String("Pokemod: Unused INI section named \"%s\"", i->GetName().c_str()), PM_DEBUG_INFO);
+ LogImportOver("Pokemod", 0, title);
}
void PokeGen::PokeMod::Pokemod::ExportIni(std::ofstream &fout) const
{
- // TODO (Ini#1#): Export Pokemod
+ LogExportStart("Pokemod", 0, title);
+ Ini exPokemod("pokemod");
+ exPokemod.AddField("title", title);
+ exPokemod.AddField("version", version);
+ exPokemod.AddField("description", description);
+ exPokemod.AddField("genderAllowed", genderAllowed);
+ exPokemod.AddField("breedingAllowed", breedingAllowed);
+ exPokemod.AddField("eggSpecies", eggSpecies);
+ exPokemod.AddField("holdItems", holdItems);
+ exPokemod.AddField("criticalDomains", criticalDomains);
+ exPokemod.AddField("contestAllowed", contestAllowed);
+ exPokemod.AddField("abilityAllowed", abilityAllowed);
+ exPokemod.AddField("natureAllowed", natureAllowed);
+ exPokemod.AddField("numDaycares", numDaycares);
+ exPokemod.AddField("numPokemonBoxes", numPokemonBoxes);
+ exPokemod.AddField("numPokemonPerBox", numPokemonPerBox);
+ exPokemod.AddField("maxParty", maxParty);
+ exPokemod.AddField("maxFight", maxFight);
+ exPokemod.AddField("maxMoves", maxMoves);
+ exPokemod.AddField("maxLevel", maxLevel);
+ exPokemod.AddField("maxMoney", maxMoney);
+ exPokemod.AddField("hardCash", hardCash);
+ exPokemod.AddField("specialSplit", specialSplit);
+ exPokemod.AddField("specialDVSplit", specialDVSplit);
+ exPokemod.AddField("maxDVValue", maxDVValue);
+ exPokemod.AddField("happiness", happiness);
+ exPokemod.AddField("happyFaintLoss", happyFaintLoss);
+ exPokemod.AddField("happyLevelGain", happyLevelGain);
+ exPokemod.AddField("happySteps", happySteps);
+ exPokemod.AddField("effortValuesAllowed", effortValuesAllowed);
+ exPokemod.AddField("maxTotalEV", maxTotalEV);
+ exPokemod.AddField("maxEVPerStat", maxEVPerStat);
+ exPokemod.AddField("pokerusChance-n", pokerusChance.GetNum());
+ exPokemod.AddField("pokerusChance-d", pokerusChance.GetDenom());
+ exPokemod.AddField("startMap", startMap);
+ exPokemod.AddField("startMoney", startMoney);
+ exPokemod.AddField("startCoordinate-x", startCoordinate.GetX());
+ exPokemod.AddField("startCoordinate-y", startCoordinate.GetY());
+ exPokemod.AddField("startDirection", startDirection);
+ exPokemod.AddField("startDialog", startDialog);
+ exPokemod.AddField("walkSkin", walkSkin);
+ exPokemod.AddField("bikeSkin", bikeSkin);
+ exPokemod.AddField("surfSkin", surfSkin);
+ exPokemod.AddField("flySkin", flySkin);
+ exPokemod.AddField("fishSkin", fishSkin);
+ exPokemod.AddField("surfFishSkin", surfFishSkin);
+ exPokemod.AddField("superPCUname", superPCUname);
+ exPokemod.AddField("superPCPasswd", superPCPasswd);
+ exPokemod.AddField("struggleMove", struggleMove);
+ exPokemod.AddField("confuseMove", confuseMove);
+ for (unsigned i = 1; i < typeChart.GetWidth(); ++i)
+ {
+ for (unsigned j = 1; j < typeChart.GetHeight(); ++j)
+ {
+ exPokemod.AddField(String("typeChart-%u-%u-n", typeChart[i][0].GetNum(), typeChart[0][j].GetNum()), typeChart[i][j].GetNum());
+ exPokemod.AddField(String("typeChart-%u-%u-d", typeChart[i][0].GetNum(), typeChart[0][j].GetNum()), typeChart[i][j].GetDenom());
+ }
+ }
+ exPokemod.Export(fout);
+ for (std::vector<Ability>::const_iterator i = abilities.begin(); i != abilities.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Author>::const_iterator i = authors.begin(); i != authors.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Badge>::const_iterator i = badges.begin(); i != badges.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<CoinList>::const_iterator i = coinLists.begin(); i != coinLists.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Dialog>::const_iterator i = dialogs.begin(); i != dialogs.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<EggGroup>::const_iterator i = eggGroups.begin(); i != eggGroups.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Item>::const_iterator i = items.begin(); i != items.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<ItemStorage>::const_iterator i = itemStorages.begin(); i != itemStorages.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Map>::const_iterator i = maps.begin(); i != maps.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Move>::const_iterator i = moves.begin(); i != moves.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Nature>::const_iterator i = natures.begin(); i != natures.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Pokemon>::const_iterator i = pokemon.begin(); i != pokemon.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Status>::const_iterator i = statuses.begin(); i != statuses.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Store>::const_iterator i = stores.begin(); i != stores.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Tile>::const_iterator i = tiles.begin(); i != tiles.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Time>::const_iterator i = times.begin(); i != times.end(); ++i)
+ i->ExportIni(fout);
+ for (std::vector<Type>::const_iterator i = types.begin(); i != types.end(); ++i)
+ i->ExportIni(fout);
+ LogExportOver("Pokemod", 0, title);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTitle(const String &t)
+{
+ LogSetVar("Pokemod", 0, "title", t);
+ title = t;
+}
+
+void PokeGen::PokeMod::Pokemod::SetVersion(const String &v)
+{
+ LogSetVar("Pokemod", 0, "version", v);
+ version = v;
+}
+
+void PokeGen::PokeMod::Pokemod::SetDescription(const String &d)
+{
+ LogSetVar("Pokemod", 0, "description", d);
+ description = d;
+}
+
+void PokeGen::PokeMod::Pokemod::SetIsGenderAllowed(const bool g)
+{
+ LogSetVar("Pokemod", 0, "genderAllowed", g);
+ genderAllowed = g;
+}
+
+void PokeGen::PokeMod::Pokemod::SetIsBreedingAllowed(const bool b)
+{
+ LogSetVar("Pokemod", 0, "breedingAllowed", b);
+ breedingAllowed = b;
+}
+
+void PokeGen::PokeMod::Pokemod::SetEggSpecies(const unsigned e)
+{
+ LogSetVar("Pokemod", 0, "eggSpecies", e);
+ if (GetPokemon(e))
+ eggSpecies = e;
+}
+
+void PokeGen::PokeMod::Pokemod::SetEggSpecies(const String &e)
+{
+ LogSetVar("Pokemod", 0, "eggSpecies string", e);
+ if (const Pokemon *p = GetPokemon(e))
+ eggSpecies = p->GetId();
+}
+
+void PokeGen::PokeMod::Pokemod::SetCanHoldItems(const bool h)
+{
+ LogSetVar("Pokemod", 0, "holdItems", h);
+ holdItems = h;
+}
+
+void PokeGen::PokeMod::Pokemod::SetHasCriticalDomains(const bool c)
+{
+ LogSetVar("Pokemod", 0, "criticalDomains", c);
+ criticalDomains = c;
+}
+
+void PokeGen::PokeMod::Pokemod::SetIsContestAllowed(const bool c)
+{
+ LogSetVar("Pokemod", 0, "contestAllowed", c);
+ contestAllowed = c;
+}
+
+void PokeGen::PokeMod::Pokemod::SetIsAbilityAllowed(const bool a)
+{
+ LogSetVar("Pokemod", 0, "abilityAllowed", a);
+ abilityAllowed = a;
+}
+
+void PokeGen::PokeMod::Pokemod::SetIsNatureAllowed(const bool n)
+{
+ LogSetVar("Pokemod", 0, "natureAllowed", n);
+ natureAllowed = n;
+}
+
+void PokeGen::PokeMod::Pokemod::SetNumDaycares(const unsigned n)
+{
+ LogSetVar("Pokemod", 0, "numDaycares", n);
+ numDaycares = n;
+}
+
+void PokeGen::PokeMod::Pokemod::SetNumPokemonBoxes(const unsigned n)
+{
+ LogSetVar("Pokemod", 0, "numPokemonBoxes", n);
+ numPokemonBoxes = n;
+}
+
+void PokeGen::PokeMod::Pokemod::SetNumPokemonPerBox(const unsigned n)
+{
+ LogSetVar("Pokemod", 0, "numPokemonPerBox", n);
+ numPokemonPerBox = n;
+}
+
+void PokeGen::PokeMod::Pokemod::SetMaxParty(const unsigned m)
+{
+ LogSetVar("Pokemod", 0, "maxParty", m);
+ maxParty = m;
+}
+
+void PokeGen::PokeMod::Pokemod::SetMaxFight(const unsigned m)
+{
+ LogSetVar("Pokemod", 0, "maxFight", m);
+ if (m <= maxParty)
+ maxFight = m;
+}
+
+void PokeGen::PokeMod::Pokemod::SetMaxMoves(const unsigned m)
+{
+ LogSetVar("Pokemod", 0, "maxMoves", m);
+ maxMoves = m;
+}
+
+void PokeGen::PokeMod::Pokemod::SetMaxLevel(const unsigned m)
+{
+ LogSetVar("Pokemod", 0, "maxLevel", m);
+ maxLevel = m;
+}
+
+void PokeGen::PokeMod::Pokemod::SetMaxMoney(const unsigned m)
+{
+ LogSetVar("Pokemod", 0, "maxMoney", m);
+ maxMoney = m;
+}
+
+void PokeGen::PokeMod::Pokemod::SetIsHardCash(const bool h)
+{
+ LogSetVar("Pokemod", 0, "hardCash", h);
+ hardCash = h;
+}
+
+void PokeGen::PokeMod::Pokemod::SetIsSpecialSplit(const bool s)
+{
+ LogSetVar("Pokemod", 0, "specialSplit", s);
+ specialSplit = s;
+}
+
+void PokeGen::PokeMod::Pokemod::SetIsSpecialDVSplit(const bool s)
+{
+ LogSetVar("Pokemod", 0, "specialDVSplit", s);
+ specialDVSplit = s;
+}
+
+void PokeGen::PokeMod::Pokemod::SetMaxDVValue(const unsigned char m)
+{
+ LogSetVar("Pokemod", 0, "maxDVValue", m);
+ if ((m == 16) || (m == 32))
+ maxDVValue = m;
+}
+
+void PokeGen::PokeMod::Pokemod::SetIsHappiness(const bool h)
+{
+ LogSetVar("Pokemod", 0, "happiness", h);
+ happiness = h;
+}
+
+void PokeGen::PokeMod::Pokemod::SetHappyFaintLoss(const unsigned h)
+{
+ LogSetVar("Pokemod", 0, "happyFaintLoss", h);
+ happyFaintLoss = h;
+}
+
+void PokeGen::PokeMod::Pokemod::SetHappyLevelGain(const unsigned h)
+{
+ LogSetVar("Pokemod", 0, "happyLevelGain", h);
+ happyLevelGain = h;
+}
+
+void PokeGen::PokeMod::Pokemod::SetHappySteps(const unsigned h)
+{
+ LogSetVar("Pokemod", 0, "happySteps", h);
+ happySteps = h;
+}
+
+void PokeGen::PokeMod::Pokemod::SetIsEffortValuesAllowed(const bool e)
+{
+ LogSetVar("Pokemod", 0, "effortValuesAllowed", e);
+ effortValuesAllowed = e;
+}
+
+void PokeGen::PokeMod::Pokemod::SetMaxTotalEV(const unsigned m)
+{
+ LogSetVar("Pokemod", 0, "maxTotalEV", m);
+ maxTotalEV = m;
+}
+
+void PokeGen::PokeMod::Pokemod::SetMaxEVPerStat(const unsigned m)
+{
+ LogSetVar("Pokemod", 0, "maxEVPerStat", m);
+ maxEVPerStat = m;
+}
+
+void PokeGen::PokeMod::Pokemod::SetPokerusChance(const Frac &p)
+{
+ LogSetVar("Pokemod", 0, "pokerusChance", p.GetNum(), p.GetDenom());
+ pokerusChance = p;
+}
+
+void PokeGen::PokeMod::Pokemod::SetPokerusChance(const unsigned n, const unsigned d)
+{
+ LogSetVar("Pokemod", 0, "pokerusChance", n, d);
+ pokerusChance.Set(n, d);
+}
+
+void PokeGen::PokeMod::Pokemod::SetPokerusChanceNum(const unsigned n)
+{
+ LogSetVar("Pokemod", 0, "pokerusChance numerator", n);
+ pokerusChance.SetNum(n);
+}
+
+void PokeGen::PokeMod::Pokemod::SetPokerusChanceDenom(const unsigned d)
+{
+ LogSetVar("Pokemod", 0, "pokerusChance denominator", d);
+ pokerusChance.SetDenom(d);
+}
+
+void PokeGen::PokeMod::Pokemod::SetStartMap(const unsigned s)
+{
+ LogSetVar("Pokemod", 0, "startMap", s);
+ if (GetMap(s))
+ startMap = s;
+}
+
+void PokeGen::PokeMod::Pokemod::SetStartMap(const String &s)
+{
+ LogSetVar("Pokemod", 0, "startMap string", s);
+ if (const Map *m = GetMap(s))
+ startMap = m->GetId();
+}
+
+void PokeGen::PokeMod::Pokemod::SetStartMoney(const unsigned s)
+{
+ LogSetVar("Pokemod", 0, "startMoney", s);
+ startMoney = s;
+}
+
+void PokeGen::PokeMod::Pokemod::SetStartCoordinate(const Point &s)
+{
+ LogSetVar("Pokemod", 0, "startCoordinate", s.GetX(), s.GetY());
+ if (const Map *m = GetMap(startMap))
+ {
+ if ((s.GetX() < m->GetWidth()) && (s.GetY() < m->GetHeight()))
+ startCoordinate = s;
+ }
+}
+
+void PokeGen::PokeMod::Pokemod::SetStartCoordinate(const unsigned x, const unsigned y)
+{
+ LogSetVar("Pokemod", 0, "startCoordinate", x, y);
+ if (const Map *m = GetMap(startMap))
+ {
+ if ((x < m->GetWidth()) && (y < m->GetHeight()))
+ startCoordinate.Set(x, y);
+ }
+}
+
+void PokeGen::PokeMod::Pokemod::SetStartCoordinateX(const unsigned x)
+{
+ LogSetVar("Pokemod", 0, "startCoordinate x", x);
+ if (const Map *m = GetMap(startMap))
+ {
+ if (x < m->GetWidth())
+ startCoordinate.SetX(x);
+ }
+}
+
+void PokeGen::PokeMod::Pokemod::SetStartCoordinateY(const unsigned y)
+{
+ LogSetVar("Pokemod", 0, "startCoordinate y", y);
+ if (const Map *m = GetMap(startMap))
+ {
+ if (y < m->GetHeight())
+ startCoordinate.SetY(y);
+ }
+}
+
+void PokeGen::PokeMod::Pokemod::SetStartDirection(const unsigned s)
+{
+ LogSetVar("Pokemod", 0, "startDirection", s);
+ if (s < DIR_END)
+ startDirection = s;
+}
+
+void PokeGen::PokeMod::Pokemod::SetStartDirection(const String &s)
+{
+ SetStartDirection(FindIn(DIR_END, s, DirectionStr));
+}
+
+void PokeGen::PokeMod::Pokemod::SetStartDialog(const unsigned s)
+{
+ LogSetVar("Pokemod", 0, "startDialog", s);
+ if (GetDialog(s))
+ startDialog = s;
+}
+
+void PokeGen::PokeMod::Pokemod::SetWalkSkin(const Path &w)
+{
+ LogSetVar("Pokemod", 0, "walkSkin", w);
+ walkSkin = w;
+}
+
+void PokeGen::PokeMod::Pokemod::SetBikeSkin(const Path &b)
+{
+ LogSetVar("Pokemod", 0, "bikeSkin", b);
+ bikeSkin = b;
+}
+
+void PokeGen::PokeMod::Pokemod::SetSurfSkin(const Path &s)
+{
+ LogSetVar("Pokemod", 0, "surfSkin", s);
+ surfSkin = s;
+}
+
+void PokeGen::PokeMod::Pokemod::SetFlySkin(const Path &f)
+{
+ LogSetVar("Pokemod", 0, "flySkin", f);
+ flySkin = f;
+}
+
+void PokeGen::PokeMod::Pokemod::SetFishSkin(const Path &f)
+{
+ LogSetVar("Pokemod", 0, "fishSkin", f);
+ fishSkin = f;
+}
+
+void PokeGen::PokeMod::Pokemod::SetSurfFishSkin(const Path &s)
+{
+ LogSetVar("Pokemod", 0, "surfFishSkin", s);
+ surfFishSkin = s;
+}
+
+void PokeGen::PokeMod::Pokemod::SetSuperPCUname(const String &u)
+{
+ LogSetVar("Pokemod", 0, "superPCUname", u);
+ superPCUname = u;
+}
+
+void PokeGen::PokeMod::Pokemod::SetSuperPCPasswd(const String &p)
+{
+ LogSetVar("Pokemod", 0, "superPCPasswd", p);
+ superPCPasswd = p;
+}
+
+void PokeGen::PokeMod::Pokemod::SetStruggleMove(const unsigned s)
+{
+ LogSetVar("Pokemod", 0, "struggleMove", s);
+ if (GetMove(s))
+ struggleMove = s;
+}
+
+void PokeGen::PokeMod::Pokemod::SetStruggleMove(const String &s)
+{
+ LogSetVar("Pokemod", 0, "struggleMove string", s);
+ if (const Move *m = GetMove(s))
+ struggleMove = m->GetId();
+}
+
+void PokeGen::PokeMod::Pokemod::SetConfuseMove(const unsigned c)
+{
+ LogSetVar("Pokemod", 0, "confuseMove", c);
+ if (GetMove(c))
+ confuseMove = c;
+}
+
+void PokeGen::PokeMod::Pokemod::SetConfuseMove(const String &c)
+{
+ LogSetVar("Pokemod", 0, "confuseMove string", c);
+ if (const Move *m = GetMove(c))
+ confuseMove = m->GetId();
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetTitle() const
+{
+ LogFetchVar("Pokemod", 0, "title", title);
+ return title;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetVersion() const
+{
+ LogFetchVar("Pokemod", 0, "version", version);
+ return version;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetDescription() const
+{
+ LogFetchVar("Pokemod", 0, "description", description);
+ return description;
+}
+
+bool PokeGen::PokeMod::Pokemod::IsGenderAllowed() const
+{
+ LogFetchVar("Pokemod", 0, "genderAllowed", genderAllowed);
+ return genderAllowed;
+}
+
+bool PokeGen::PokeMod::Pokemod::IsBreedingAllowed() const
+{
+ LogFetchVar("Pokemod", 0, "breedingAllowed", breedingAllowed);
+ return breedingAllowed;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetEggSpecies() const
+{
+ LogFetchVar("Pokemod", 0, "eggSpecies", eggSpecies);
+ return eggSpecies;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetEggSpeciesString() const
+{
+ LogFetchVar("Pokemod", 0, "eggSpecies", eggSpecies);
+ if (const Pokemon *p = GetPokemon(eggSpecies))
+ return p->GetName();
+ return "";
+}
+
+bool PokeGen::PokeMod::Pokemod::CanHoldItems() const
+{
+ LogFetchVar("Pokemod", 0, "holdItems", holdItems);
+ return holdItems;
+}
+
+bool PokeGen::PokeMod::Pokemod::HasCriticalDomains() const
+{
+ LogFetchVar("Pokemod", 0, "criticalDomains", criticalDomains);
+ return criticalDomains;
+}
+
+bool PokeGen::PokeMod::Pokemod::IsContestAllowed() const
+{
+ LogFetchVar("Pokemod", 0, "contestAllowed", contestAllowed);
+ return contestAllowed;
+}
+
+bool PokeGen::PokeMod::Pokemod::IsAbilityAllowed() const
+{
+ LogFetchVar("Pokemod", 0, "abilityAllowed", abilityAllowed);
+ return abilityAllowed;
+}
+
+bool PokeGen::PokeMod::Pokemod::IsNatureAllowed() const
+{
+ LogFetchVar("Pokemod", 0, "natureAllowed", natureAllowed);
+ return natureAllowed;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetNumDaycares() const
+{
+ LogFetchVar("Pokemod", 0, "numDaycares", numDaycares);
+ return numDaycares;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetNumPokemonBoxes() const
+{
+ LogFetchVar("Pokemod", 0, "numPokemonBoxes", numPokemonBoxes);
+ return numPokemonBoxes;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetNumPokemonPerBox() const
+{
+ LogFetchVar("Pokemod", 0, "numPokemonPerBox", numPokemonPerBox);
+ return numPokemonPerBox;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetMaxParty() const
+{
+ LogFetchVar("Pokemod", 0, "maxParty", maxParty);
+ return maxParty;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetMaxFight() const
+{
+ LogFetchVar("Pokemod", 0, "maxFight", maxFight);
+ return maxFight;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetMaxMoves() const
+{
+ LogFetchVar("Pokemod", 0, "maxMoves", maxMoves);
+ return maxMoves;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetMaxLevel() const
+{
+ LogFetchVar("Pokemod", 0, "maxLevel", maxLevel);
+ return maxLevel;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetMaxMoney() const
+{
+ LogFetchVar("Pokemod", 0, "maxMoney", maxMoney);
+ return maxMoney;
+}
+
+bool PokeGen::PokeMod::Pokemod::IsHardCash() const
+{
+ LogFetchVar("Pokemod", 0, "hardCash", hardCash);
+ return hardCash;
+}
+
+bool PokeGen::PokeMod::Pokemod::IsSpecialSplit() const
+{
+ LogFetchVar("Pokemod", 0, "specialSplit", specialSplit);
+ return specialSplit;
+}
+
+bool PokeGen::PokeMod::Pokemod::IsSpecialDVSplit() const
+{
+ LogFetchVar("Pokemod", 0, "specialDVSplit", specialDVSplit);
+ return specialDVSplit;
+}
+
+unsigned char PokeGen::PokeMod::Pokemod::GetMaxDVValue() const
+{
+ LogFetchVar("Pokemod", 0, "maxDVValue", maxDVValue);
+ return maxDVValue;
+}
+
+bool PokeGen::PokeMod::Pokemod::IsHappiness() const
+{
+ LogFetchVar("Pokemod", 0, "happiness", happiness);
+ return happiness;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetHappyFaintLoss() const
+{
+ LogFetchVar("Pokemod", 0, "happyFaintLoss", happyFaintLoss);
+ return happyFaintLoss;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetHappyLevelGain() const
+{
+ LogFetchVar("Pokemod", 0, "happyLevelGain", happyLevelGain);
+ return happyLevelGain;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetHappySteps() const
+{
+ LogFetchVar("Pokemod", 0, "happySteps", happySteps);
+ return happySteps;
+}
+
+bool PokeGen::PokeMod::Pokemod::IsEffortValuesAllowed() const
+{
+ LogFetchVar("Pokemod", 0, "effortValuesAllowed", effortValuesAllowed);
+ return effortValuesAllowed;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetMaxTotalEV() const
+{
+ LogFetchVar("Pokemod", 0, "maxTotalEV", maxTotalEV);
+ return maxTotalEV;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetMaxEVPerStat() const
+{
+ LogFetchVar("Pokemod", 0, "maxEVPerStat", maxEVPerStat);
+ return maxEVPerStat;
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Pokemod::GetPokerusChance() const
+{
+ LogFetchVar("Pokemod", 0, "pokerusChance", pokerusChance.GetNum(), pokerusChance.GetDenom());
+ return pokerusChance;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetPokerusChanceNum() const
+{
+ LogFetchVar("Pokemod", 0, "pokerusChance numerator", pokerusChance.GetNum());
+ return pokerusChance.GetNum();
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetPokerusChanceDenom() const
+{
+ LogFetchVar("Pokemod", 0, "pokerusChance denominator", pokerusChance.GetDenom());
+ return pokerusChance.GetDenom();
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetStartMap() const
+{
+ LogFetchVar("Pokemod", 0, "startMap", startMap);
+ return startMap;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetStartMapString() const
+{
+ LogFetchVar("Pokemod", 0, "startMap string", startMap);
+ if (const Map *m = GetMap(startMap))
+ return m->GetName();
+ return "";
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetStartMoney() const
+{
+ LogFetchVar("Pokemod", 0, "startMoney", startMoney);
+ return startMoney;
+}
+
+PokeGen::PokeMod::Point PokeGen::PokeMod::Pokemod::GetStartCoordinate() const
+{
+ LogFetchVar("Pokemod", 0, "startCoordinate", startCoordinate.GetX(), startCoordinate.GetY());
+ return startCoordinate;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetStartCoordinateX() const
+{
+ LogFetchVar("Pokemod", 0, "startCoordinate x", startCoordinate.GetX());
+ return startCoordinate.GetX();
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetStartCoordinateY() const
+{
+ LogFetchVar("Pokemod", 0, "startCoordinate y", startCoordinate.GetY());
+ return startCoordinate.GetY();
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetStartDirection() const
+{
+ LogFetchVar("Pokemod", 0, "startDirection", startDirection);
+ return startDirection;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetStartDirectionString() const
+{
+ LogFetchVar("Pokemod", 0, "startDirection string", startDirection);
+ if (startDirection < DIR_END)
+ return DirectionStr[startDirection];
+ return "";
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetStartDialog() const
+{
+ LogFetchVar("Pokemod", 0, "startDialog", startDialog);
+ return startDialog;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetStartDialogString() const
+{
+ LogFetchVar("Pokemod", 0, "startDialog string", startDialog);
+ if (const Dialog *d = GetDialog(startDialog))
+ return d->GetDialog();
+ return "";
+}
+
+PokeGen::PokeMod::Path PokeGen::PokeMod::Pokemod::GetWalkSkin() const
+{
+ LogFetchVar("Pokemod", 0, "walkSkin", walkSkin);
+ return walkSkin;
+}
+
+PokeGen::PokeMod::Path PokeGen::PokeMod::Pokemod::GetBikeSkin() const
+{
+ LogFetchVar("Pokemod", 0, "bikeSkin", bikeSkin);
+ return bikeSkin;
+}
+
+PokeGen::PokeMod::Path PokeGen::PokeMod::Pokemod::GetSurfSkin() const
+{
+ LogFetchVar("Pokemod", 0, "surfSkin", surfSkin);
+ return surfSkin;
+}
+
+PokeGen::PokeMod::Path PokeGen::PokeMod::Pokemod::GetFlySkin() const
+{
+ LogFetchVar("Pokemod", 0, "flySkin", flySkin);
+ return flySkin;
+}
+
+PokeGen::PokeMod::Path PokeGen::PokeMod::Pokemod::GetFishSkin() const
+{
+ LogFetchVar("Pokemod", 0, "fishSkin", fishSkin);
+ return fishSkin;
+}
+
+PokeGen::PokeMod::Path PokeGen::PokeMod::Pokemod::GetSurfFishSkin() const
+{
+ LogFetchVar("Pokemod", 0, "surfFishSkin", surfFishSkin);
+ return surfFishSkin;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetSuperPCUname() const
+{
+ LogFetchVar("Pokemod", 0, "superPCUname", superPCUname);
+ return superPCUname;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetSuperPCPasswd() const
+{
+ LogFetchVar("Pokemod", 0, "superPCPasswd", superPCPasswd);
+ return superPCPasswd;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetStruggleMove() const
+{
+ LogFetchVar("Pokemod", 0, "struggleMove", struggleMove);
+ return struggleMove;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetStruggleMoveString() const
+{
+ LogFetchVar("Pokemod", 0, "struggleMove string", struggleMove);
+ if (const Move *m = GetMove(struggleMove))
+ return m->GetName();
+ return "";
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetConfuseMove() const
+{
+ LogFetchVar("Pokemod", 0, "confuseMove", confuseMove);
+ return confuseMove;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemod::GetConfuseMoveString() const
+{
+ LogFetchVar("Pokemod", 0, "confuseMove string", confuseMove);
+ if (const Move *m = GetMove(confuseMove))
+ return m->GetName();
+ return "";
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChart(const unsigned att, const unsigned def, const Frac &m) const
+{
+ unsigned col = UINT_MAX;
+ unsigned row = UINT_MAX;
+ for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row != UINT_MAX)); ++i)
+ {
+ if (typeChart[i][0].GetNum() == att)
+ row = i;
+ if (typeChart[i][0].GetNum() == def)
+ col = i;
+ }
+ if ((col != UINT_MAX) && (row != UINT_MAX))
+ typeChart[col][row] = m;
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChart(const unsigned att, const unsigned def, const unsigned n, const unsigned d) const
+{
+ unsigned col = UINT_MAX;
+ unsigned row = UINT_MAX;
+ for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row != UINT_MAX)); ++i)
+ {
+ if (typeChart[i][0].GetNum() == att)
+ row = i;
+ if (typeChart[i][0].GetNum() == def)
+ col = i;
+ }
+ if ((col != UINT_MAX) && (row != UINT_MAX))
+ typeChart[col][row].Set(n, d);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChartNum(const unsigned att, const unsigned def, const unsigned n) const
+{
+ unsigned col = UINT_MAX;
+ unsigned row = UINT_MAX;
+ for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row != UINT_MAX)); ++i)
+ {
+ if (typeChart[i][0].GetNum() == att)
+ row = i;
+ if (typeChart[i][0].GetNum() == def)
+ col = i;
+ }
+ if ((col != UINT_MAX) && (row != UINT_MAX))
+ typeChart[col][row].SetNum(n);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChartDenom(const unsigned att, const unsigned def, const unsigned d) const
+{
+ unsigned col = UINT_MAX;
+ unsigned row = UINT_MAX;
+ for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row != UINT_MAX)); ++i)
+ {
+ if (typeChart[i][0].GetNum() == att)
+ row = i;
+ if (typeChart[i][0].GetNum() == def)
+ col = i;
+ }
+ if ((col != UINT_MAX) && (row != UINT_MAX))
+ typeChart[col][row].SetDenom(d);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChart(const String &att, const unsigned def, const Frac &m) const
+{
+ if (const Type *t = GetType(att))
+ SetTypeChart(t->GetId(), def, m);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChart(const String &att, const unsigned def, const unsigned n, const unsigned d) const
+{
+ if (const Type *t = GetType(att))
+ SetTypeChart(t->GetId(), def, n, d);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChartNum(const String &att, const unsigned def, const unsigned n) const
+{
+ if (const Type *t = GetType(att))
+ SetTypeChartNum(t->GetId(), def, n);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChartDenom(const String &att, const unsigned def, const unsigned d) const
+{
+ if (const Type *t = GetType(att))
+ SetTypeChartDenom(t->GetId(), def, d);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChart(const unsigned att, const String &def, const Frac &m) const
+{
+ if (const Type *t = GetType(def))
+ SetTypeChart(att, t->GetId(), m);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChart(const unsigned att, const String &def, const unsigned n, const unsigned d) const
+{
+ if (const Type *t = GetType(def))
+ SetTypeChart(att, t->GetId(), n, d);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChartNum(const unsigned att, const String &def, const unsigned n) const
+{
+ if (const Type *t = GetType(def))
+ SetTypeChartNum(att, t->GetId(), n);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChartDenom(const unsigned att, const String &def, const unsigned d) const
+{
+ if (const Type *t = GetType(def))
+ SetTypeChartDenom(att, t->GetId(), d);
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChart(const String &att, const String &def, const Frac &m) const
+{
+ if (const Type *t = GetType(att))
+ {
+ if (const Type *t2 = GetType(def))
+ SetTypeChart(t->GetId(), t2->GetId(), m);
+ }
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChart(const String &att, const String &def, const unsigned n, const unsigned d) const
+{
+ if (const Type *t = GetType(att))
+ {
+ if (const Type *t2 = GetType(def))
+ SetTypeChart(t->GetId(), t2->GetId(), n, d);
+ }
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChartNum(const String &att, const String &def, const unsigned n) const
+{
+ if (const Type *t = GetType(att))
+ {
+ if (const Type *t2 = GetType(def))
+ SetTypeChartNum(t->GetId(), t2->GetId(), n);
+ }
+}
+
+void PokeGen::PokeMod::Pokemod::SetTypeChartDenom(const String &att, const String &def, const unsigned d) const
+{
+ if (const Type *t = GetType(att))
+ {
+ if (const Type *t2 = GetType(def))
+ SetTypeChartDenom(t->GetId(), t2->GetId(), d);
+ }
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Pokemod::GetTypeChart(const unsigned att, const unsigned def) const
+{
+ unsigned col = UINT_MAX;
+ unsigned row = UINT_MAX;
+ for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row != UINT_MAX)); ++i)
+ {
+ if (typeChart[i][0].GetNum() == att)
+ row = i;
+ if (typeChart[i][0].GetNum() == def)
+ col = i;
+ }
+ if ((col != UINT_MAX) && (row != UINT_MAX))
+ return typeChart[col][row];
+ return Frac(1, 1);
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTypeChartNum(const unsigned att, const unsigned def) const
+{
+ unsigned col = UINT_MAX;
+ unsigned row = UINT_MAX;
+ for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row != UINT_MAX)); ++i)
+ {
+ if (typeChart[i][0].GetNum() == att)
+ row = i;
+ if (typeChart[i][0].GetNum() == def)
+ col = i;
+ }
+ if ((col != UINT_MAX) && (row != UINT_MAX))
+ return typeChart[col][row].GetNum();
+ return UINT_MAX;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTypeChartDenom(const unsigned att, const unsigned def) const
+{
+ unsigned col = UINT_MAX;
+ unsigned row = UINT_MAX;
+ for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row != UINT_MAX)); ++i)
+ {
+ if (typeChart[i][0].GetNum() == att)
+ row = i;
+ if (typeChart[i][0].GetNum() == def)
+ col = i;
+ }
+ if ((col != UINT_MAX) && (row != UINT_MAX))
+ return typeChart[col][row].GetDenom();
+ return UINT_MAX;
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Pokemod::GetTypeChart(const String &att, const unsigned def) const
+{
+ if (const Type *t = GetType(att))
+ return GetTypeChart(t->GetId(), def);
+ return Frac(1, 1);
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTypeChartNum(const String &att, const unsigned def) const
+{
+ if (const Type *t = GetType(att))
+ return GetTypeChartNum(t->GetId(), def);
+ return UINT_MAX;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTypeChartDenom(const String &att, const unsigned def) const
+{
+ if (const Type *t = GetType(att))
+ return GetTypeChartDenom(t->GetId(), def);
+ return UINT_MAX;
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Pokemod::GetTypeChart(const unsigned att, const String &def) const
+{
+ if (const Type *t = GetType(def))
+ return GetTypeChart(att, t->GetId());
+ return Frac(1, 1);
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTypeChartNum(const unsigned att, const String &def) const
+{
+ if (const Type *t = GetType(def))
+ return GetTypeChartNum(att, t->GetId());
+ return UINT_MAX;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTypeChartDenom(const unsigned att, const String &def) const
+{
+ if (const Type *t = GetType(def))
+ return GetTypeChartDenom(def, t->GetId());
+ return UINT_MAX;
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Pokemod::GetTypeChart(const String &att, const String &def) const
+{
+ if (const Type *t = GetType(att))
+ {
+ if (const Type *t2 = GetType(def))
+ return GetTypeChart(t->GetId(), t2->GetId());
+ }
+ return Frac(1, 1);
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTypeChartNum(const String &att, const String &def) const
+{
+ if (const Type *t = GetType(att))
+ {
+ if (const Type *t2 = GetType(def))
+ return GetTypeChartNum(t->GetId(), t2->GetId());
+ }
+ return UINT_MAX;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTypeChartDenom(const String &att, const String &def) const
+{
+ if (const Type *t = GetType(att))
+ {
+ if (const Type *t2 = GetType(def))
+ return GetTypeChartDenom(t->GetId(), t2->GetId());
+ }
+ return UINT_MAX;
+}
+
+const PokeGen::PokeMod::Ability *PokeGen::PokeMod::Pokemod::GetAbility(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "ability", _id);
+ for (unsigned i = 0; i < GetAbilityCount(); ++i)
+ {
+ if (abilities[i].GetId() == _id)
+ return &abilities[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "ability", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Ability *PokeGen::PokeMod::Pokemod::GetAbility(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "ability", n);
+ for (unsigned i = 0; i < GetAbilityCount(); ++i)
+ {
+ if (abilities[i].GetName() == n)
+ return &abilities[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "ability", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetAbilityCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "ability");
+ return abilities.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewAbility(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetAbilityCount(); ++i)
+ {
+ if (!GetAbility(i))
+ break;
+ }
+ Ability newAbility(i);
+ if (ini)
+ newAbility.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "ability", i);
+ abilities.push_back(newAbility);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteAbility(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "ability", _id);
+ for (std::vector<Ability>::iterator i = abilities.begin(); i != abilities.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "ability", _id);
+ abilities.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "ability", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteAbility(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "ability", n);
+ for (std::vector<Ability>::iterator i = abilities.begin(); i != abilities.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "ability", n);
+ abilities.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "ability", n);
+}
+
+const PokeGen::PokeMod::Author *PokeGen::PokeMod::Pokemod::GetAuthor(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "author", _id);
+ for (unsigned i = 0; i < GetAuthorCount(); ++i)
+ {
+ if (authors[i].GetId() == _id)
+ return &authors[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "author", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Author *PokeGen::PokeMod::Pokemod::GetAuthor(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "author", n);
+ for (unsigned i = 0; i < GetAuthorCount(); ++i)
+ {
+ if (authors[i].GetName() == n)
+ return &authors[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "author", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetAuthorCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "author");
+ return authors.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewAuthor(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetAuthorCount(); ++i)
+ {
+ if (!GetAuthor(i))
+ break;
+ }
+ Author newAuthor(i);
+ if (ini)
+ newAuthor.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "author", i);
+ authors.push_back(newAuthor);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteAuthor(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "author", _id);
+ for (std::vector<Author>::iterator i = authors.begin(); i != authors.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "author", _id);
+ authors.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "author", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteAuthor(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "author", n);
+ for (std::vector<Author>::iterator i = authors.begin(); i != authors.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "author", n);
+ authors.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "author", n);
+}
+
+const PokeGen::PokeMod::Badge *PokeGen::PokeMod::Pokemod::GetBadge(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "badge", _id);
+ for (unsigned i = 0; i < GetBadgeCount(); ++i)
+ {
+ if (badges[i].GetId() == _id)
+ return &badges[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "badge", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Badge *PokeGen::PokeMod::Pokemod::GetBadge(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "badge", n);
+ for (unsigned i = 0; i < GetBadgeCount(); ++i)
+ {
+ if (badges[i].GetName() == n)
+ return &badges[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "badge", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetBadgeCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "badge");
+ return badges.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewBadge(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetBadgeCount(); ++i)
+ {
+ if (!GetBadge(i))
+ break;
+ }
+ Badge newBadge(i);
+ if (ini)
+ newBadge.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "badge", i);
+ badges.push_back(newBadge);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteBadge(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "badge", _id);
+ for (std::vector<Badge>::iterator i = badges.begin(); i != badges.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "badge", _id);
+ badges.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "badge", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteBadge(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "badge", n);
+ for (std::vector<Badge>::iterator i = badges.begin(); i != badges.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "badge", n);
+ badges.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "badge", n);
+}
+
+const PokeGen::PokeMod::CoinList *PokeGen::PokeMod::Pokemod::GetCoinList(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "coin list", _id);
+ for (unsigned i = 0; i < GetCoinListCount(); ++i)
+ {
+ if (coinLists[i].GetId() == _id)
+ return &coinLists[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "coin list", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::CoinList *PokeGen::PokeMod::Pokemod::GetCoinList(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "coin list", n);
+ for (unsigned i = 0; i < GetCoinListCount(); ++i)
+ {
+ if (coinLists[i].GetName() == n)
+ return &coinLists[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "coin list", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetCoinListCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "coin list");
+ return coinLists.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewCoinList(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetCoinListCount(); ++i)
+ {
+ if (!GetCoinList(i))
+ break;
+ }
+ CoinList newCoinList(i);
+ if (ini)
+ newCoinList.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "coin list", i);
+ coinLists.push_back(newCoinList);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteCoinList(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "coin list", _id);
+ for (std::vector<CoinList>::iterator i = coinLists.begin(); i != coinLists.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "coin list", _id);
+ coinLists.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "coin list", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteCoinList(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "coin list", n);
+ for (std::vector<CoinList>::iterator i = coinLists.begin(); i != coinLists.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "coin list", n);
+ coinLists.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "coin list", n);
+}
+
+const PokeGen::PokeMod::Dialog *PokeGen::PokeMod::Pokemod::GetDialog(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "dialog", _id);
+ for (unsigned i = 0; i < GetDialogCount(); ++i)
+ {
+ if (dialogs[i].GetId() == _id)
+ return &dialogs[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "dialog", _id);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetDialogCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "dialog");
+ return dialogs.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewDialog(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetDialogCount(); ++i)
+ {
+ if (!GetDialog(i))
+ break;
+ }
+ Dialog newDialog(i);
+ if (ini)
+ newDialog.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "dialog", i);
+ dialogs.push_back(newDialog);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteDialog(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "dialog", _id);
+ for (std::vector<Dialog>::iterator i = dialogs.begin(); i != dialogs.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "dialog", _id);
+ dialogs.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "dialog", _id);
+}
+
+const PokeGen::PokeMod::EggGroup *PokeGen::PokeMod::Pokemod::GetEggGroup(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "egg group", _id);
+ for (unsigned i = 0; i < GetEggGroupCount(); ++i)
+ {
+ if (eggGroups[i].GetId() == _id)
+ return &eggGroups[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "egg group", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::EggGroup *PokeGen::PokeMod::Pokemod::GetEggGroup(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "egg group", n);
+ for (unsigned i = 0; i < GetEggGroupCount(); ++i)
+ {
+ if (eggGroups[i].GetName() == n)
+ return &eggGroups[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "egg group", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetEggGroupCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "egg group");
+ return eggGroups.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewEggGroup(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetEggGroupCount(); ++i)
+ {
+ if (!GetEggGroup(i))
+ break;
+ }
+ EggGroup newEggGroup(i);
+ if (ini)
+ newEggGroup.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "egg group", i);
+ eggGroups.push_back(newEggGroup);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteEggGroup(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "egg group", _id);
+ for (std::vector<EggGroup>::iterator i = eggGroups.begin(); i != eggGroups.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "egg group", _id);
+ eggGroups.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "egg group", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteEggGroup(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "egg group", n);
+ for (std::vector<EggGroup>::iterator i = eggGroups.begin(); i != eggGroups.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "egg group", n);
+ eggGroups.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "egg group", n);
+}
+
+const PokeGen::PokeMod::Item *PokeGen::PokeMod::Pokemod::GetItem(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "item", _id);
+ for (unsigned i = 0; i < GetItemCount(); ++i)
+ {
+ if (items[i].GetId() == _id)
+ return &items[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "item", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Item *PokeGen::PokeMod::Pokemod::GetItem(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "item", n);
+ for (unsigned i = 0; i < GetItemCount(); ++i)
+ {
+ if (items[i].GetName() == n)
+ return &items[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "item", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetItemCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "item");
+ return items.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewItem(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetItemCount(); ++i)
+ {
+ if (!GetItem(i))
+ break;
+ }
+ Item newItem(i);
+ if (ini)
+ newItem.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "item", i);
+ items.push_back(newItem);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteItem(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "item", _id);
+ for (std::vector<Item>::iterator i = items.begin(); i != items.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "item", _id);
+ items.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "item", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteItem(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "item", n);
+ for (std::vector<Item>::iterator i = items.begin(); i != items.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "item", n);
+ items.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "item", n);
+}
+
+const PokeGen::PokeMod::ItemStorage *PokeGen::PokeMod::Pokemod::GetItemStorage(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "item storage", _id);
+ for (unsigned i = 0; i < GetItemStorageCount(); ++i)
+ {
+ if (itemStorages[i].GetId() == _id)
+ return &itemStorages[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "item storage", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::ItemStorage *PokeGen::PokeMod::Pokemod::GetItemStorage(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "item storage", n);
+ for (unsigned i = 0; i < GetItemStorageCount(); ++i)
+ {
+ if (itemStorages[i].GetName() == n)
+ return &itemStorages[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "item storage", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetItemStorageCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "item storage");
+ return itemStorages.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewItemStorage(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetItemStorageCount(); ++i)
+ {
+ if (!GetItemStorage(i))
+ break;
+ }
+ ItemStorage newItemStorage(i);
+ if (ini)
+ newItemStorage.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "item storage", i);
+ itemStorages.push_back(newItemStorage);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteItemStorage(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "item storage", _id);
+ for (std::vector<ItemStorage>::iterator i = itemStorages.begin(); i != itemStorages.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "item storage", _id);
+ itemStorages.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "item storage", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteItemStorage(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "item storage", n);
+ for (std::vector<ItemStorage>::iterator i = itemStorages.begin(); i != itemStorages.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "item storage", n);
+ itemStorages.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "item storage", n);
+}
+
+const PokeGen::PokeMod::Map *PokeGen::PokeMod::Pokemod::GetMap(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "map", _id);
+ for (unsigned i = 0; i < GetMapCount(); ++i)
+ {
+ if (maps[i].GetId() == _id)
+ return &maps[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "map", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Map *PokeGen::PokeMod::Pokemod::GetMap(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "map", n);
+ for (unsigned i = 0; i < GetMapCount(); ++i)
+ {
+ if (maps[i].GetName() == n)
+ return &maps[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "map", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetMapCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "map");
+ return maps.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewMap(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetMapCount(); ++i)
+ {
+ if (!GetMap(i))
+ break;
+ }
+ Map newMap(i);
+ if (ini)
+ newMap.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "map", i);
+ maps.push_back(newMap);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteMap(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "map", _id);
+ for (std::vector<Map>::iterator i = maps.begin(); i != maps.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "map", _id);
+ maps.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "map", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteMap(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "map", n);
+ for (std::vector<Map>::iterator i = maps.begin(); i != maps.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "map", n);
+ maps.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "map", n);
+}
+
+const PokeGen::PokeMod::Move *PokeGen::PokeMod::Pokemod::GetMove(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "move", _id);
+ for (unsigned i = 0; i < GetMoveCount(); ++i)
+ {
+ if (moves[i].GetId() == _id)
+ return &moves[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "move", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Move *PokeGen::PokeMod::Pokemod::GetMove(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "move", n);
+ for (unsigned i = 0; i < GetMoveCount(); ++i)
+ {
+ if (moves[i].GetName() == n)
+ return &moves[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "move", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetMoveCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "move");
+ return moves.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewMove(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetMoveCount(); ++i)
+ {
+ if (!GetMove(i))
+ break;
+ }
+ Move newMove(i);
+ if (ini)
+ newMove.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "move", i);
+ moves.push_back(newMove);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteMove(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "move", _id);
+ for (std::vector<Move>::iterator i = moves.begin(); i != moves.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "move", _id);
+ moves.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "move", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteMove(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "move", n);
+ for (std::vector<Move>::iterator i = moves.begin(); i != moves.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "move", n);
+ moves.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "move", n);
+}
+
+const PokeGen::PokeMod::Nature *PokeGen::PokeMod::Pokemod::GetNature(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "nature", _id);
+ for (unsigned i = 0; i < GetNatureCount(); ++i)
+ {
+ if (natures[i].GetId() == _id)
+ return &natures[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "nature", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Nature *PokeGen::PokeMod::Pokemod::GetNature(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "nature", n);
+ for (unsigned i = 0; i < GetNatureCount(); ++i)
+ {
+ if (natures[i].GetName() == n)
+ return &natures[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "nature", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetNatureCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "nature");
+ return natures.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewNature(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetNatureCount(); ++i)
+ {
+ if (!GetNature(i))
+ break;
+ }
+ Nature newNature(i);
+ if (ini)
+ newNature.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "nature", i);
+ natures.push_back(newNature);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteNature(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "nature", _id);
+ for (std::vector<Nature>::iterator i = natures.begin(); i != natures.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "nature", _id);
+ natures.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "nature", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteNature(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "nature", n);
+ for (std::vector<Nature>::iterator i = natures.begin(); i != natures.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "nature", n);
+ natures.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "nature", n);
+}
+
+const PokeGen::PokeMod::Pokemon *PokeGen::PokeMod::Pokemod::GetPokemon(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "Pokémon", _id);
+ for (unsigned i = 0; i < GetPokemonCount(); ++i)
+ {
+ if (pokemon[i].GetId() == _id)
+ return &pokemon[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "Pokémon", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Pokemon *PokeGen::PokeMod::Pokemod::GetPokemon(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "Pokémon", n);
+ for (unsigned i = 0; i < GetPokemonCount(); ++i)
+ {
+ if (pokemon[i].GetName() == n)
+ return &pokemon[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "Pokémon", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetPokemonCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "Pokémon");
+ return pokemon.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewPokemon(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetPokemonCount(); ++i)
+ {
+ if (!GetPokemon(i))
+ break;
+ }
+ Pokemon newPokemon(i);
+ if (ini)
+ newPokemon.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "Pokémon", i);
+ pokemon.push_back(newPokemon);
+}
+
+void PokeGen::PokeMod::Pokemod::DeletePokemon(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "Pokémon", _id);
+ for (std::vector<Pokemon>::iterator i = pokemon.begin(); i != pokemon.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "Pokémon", _id);
+ pokemon.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "Pokémon", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeletePokemon(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "Pokémon", n);
+ for (std::vector<Pokemon>::iterator i = pokemon.begin(); i != pokemon.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "Pokémon", n);
+ pokemon.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "Pokémon", n);
+}
+
+const PokeGen::PokeMod::Status *PokeGen::PokeMod::Pokemod::GetStatus(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "status", _id);
+ for (unsigned i = 0; i < GetStatusCount(); ++i)
+ {
+ if (statuses[i].GetId() == _id)
+ return &statuses[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "status", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Status *PokeGen::PokeMod::Pokemod::GetStatus(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "status", n);
+ for (unsigned i = 0; i < GetStatusCount(); ++i)
+ {
+ if (statuses[i].GetName() == n)
+ return &statuses[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "status", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetStatusCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "status");
+ return statuses.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewStatus(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetStatusCount(); ++i)
+ {
+ if (!GetStatus(i))
+ break;
+ }
+ Status newStatus(i);
+ if (ini)
+ newStatus.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "status", i);
+ statuses.push_back(newStatus);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteStatus(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "status", _id);
+ for (std::vector<Status>::iterator i = statuses.begin(); i != statuses.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "status", _id);
+ statuses.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "status", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteStatus(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "status", n);
+ for (std::vector<Status>::iterator i = statuses.begin(); i != statuses.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "status", n);
+ statuses.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "status", n);
+}
+
+const PokeGen::PokeMod::Store *PokeGen::PokeMod::Pokemod::GetStore(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "store", _id);
+ for (unsigned i = 0; i < GetStoreCount(); ++i)
+ {
+ if (stores[i].GetId() == _id)
+ return &stores[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "store", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Store *PokeGen::PokeMod::Pokemod::GetStore(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "store", n);
+ for (unsigned i = 0; i < GetStoreCount(); ++i)
+ {
+ if (stores[i].GetName() == n)
+ return &stores[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "store", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetStoreCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "store");
+ return stores.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewStore(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetStoreCount(); ++i)
+ {
+ if (!GetStore(i))
+ break;
+ }
+ Store newStore(i);
+ if (ini)
+ newStore.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "store", i);
+ stores.push_back(newStore);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteStore(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "store", _id);
+ for (std::vector<Store>::iterator i = stores.begin(); i != stores.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "store", _id);
+ stores.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "store", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteStore(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "store", n);
+ for (std::vector<Store>::iterator i = stores.begin(); i != stores.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "store", n);
+ stores.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "store", n);
+}
+
+const PokeGen::PokeMod::Tile *PokeGen::PokeMod::Pokemod::GetTile(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "tile", _id);
+ for (unsigned i = 0; i < GetTileCount(); ++i)
+ {
+ if (tiles[i].GetId() == _id)
+ return &tiles[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "tile", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Tile *PokeGen::PokeMod::Pokemod::GetTile(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "tile", n);
+ for (unsigned i = 0; i < GetTileCount(); ++i)
+ {
+ if (tiles[i].GetName() == n)
+ return &tiles[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "tile", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTileCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "tile");
+ return tiles.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewTile(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetTileCount(); ++i)
+ {
+ if (!GetTile(i))
+ break;
+ }
+ Tile newTile(i);
+ if (ini)
+ newTile.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "tile", i);
+ tiles.push_back(newTile);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteTile(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "tile", _id);
+ for (std::vector<Tile>::iterator i = tiles.begin(); i != tiles.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "tile", _id);
+ tiles.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "tile", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteTile(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "tile", n);
+ for (std::vector<Tile>::iterator i = tiles.begin(); i != tiles.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "tile", n);
+ tiles.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "tile", n);
+}
+
+const PokeGen::PokeMod::Time *PokeGen::PokeMod::Pokemod::GetTime(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "time", _id);
+ for (unsigned i = 0; i < GetTimeCount(); ++i)
+ {
+ if (times[i].GetId() == _id)
+ return ×[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "time", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Time *PokeGen::PokeMod::Pokemod::GetTime(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "time", n);
+ for (unsigned i = 0; i < GetTimeCount(); ++i)
+ {
+ if (times[i].GetName() == n)
+ return ×[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "time", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTimeCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "time");
+ return times.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewTime(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetTimeCount(); ++i)
+ {
+ if (!GetTime(i))
+ break;
+ }
+ Time newTime(i);
+ if (ini)
+ newTime.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "time", i);
+ times.push_back(newTime);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteTime(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "time", _id);
+ for (std::vector<Time>::iterator i = times.begin(); i != times.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "time", _id);
+ times.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "time", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteTime(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "time", n);
+ for (std::vector<Time>::iterator i = times.begin(); i != times.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "time", n);
+ times.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "time", n);
+}
+
+const PokeGen::PokeMod::Type *PokeGen::PokeMod::Pokemod::GetType(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemod", id, "type", _id);
+ for (unsigned i = 0; i < GetTypeCount(); ++i)
+ {
+ if (types[i].GetId() == _id)
+ return &types[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "type", _id);
+ return NULL;
+}
+
+const PokeGen::PokeMod::Type *PokeGen::PokeMod::Pokemod::GetType(const String &n) const
+{
+ LogSubmoduleFetch("Pokemod", id, "type", n);
+ for (unsigned i = 0; i < GetTypeCount(); ++i)
+ {
+ if (types[i].GetName() == n)
+ return &types[i];
+ }
+ LogSubmoduleFetchFail("Pokemod", id, "type", n);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemod::GetTypeCount() const
+{
+ LogSubmoduleCount("Pokemod", id, "type");
+ return types.size();
+}
+
+void PokeGen::PokeMod::Pokemod::NewType(Ini *const ini)
+{
+ unsigned i = 0;
+ for (; i < GetTypeCount(); ++i)
+ {
+ if (!GetType(i))
+ break;
+ }
+ Type newType(i);
+ if (ini)
+ newType.ImportIni(*ini);
+ LogSubmoduleNew("Pokemod", id, "type", i);
+ types.push_back(newType);
+ typeChart.AddCol(Frac(1, 1));
+ typeChart.AddRow(Frac(1, 1));
+ typeChart[0][typeChart.GetHeight() - 1] = Frac(i, 1, true);
+ typeChart[typeChart.GetHeight() - 1][0] = Frac(i, 1, true);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteType(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "type", _id);
+ for (std::vector<Type>::iterator i = types.begin(); i != types.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "type", _id);
+ for (unsigned j = 0; j < typeChart.GetWidth(); ++j)
+ {
+ if (typeChart[j][0].GetNum() == _id)
+ {
+ typeChart.DeleteCol(j);
+ typeChart.DeleteRow(j);
+ }
+ }
+ types.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "type", _id);
+}
+
+void PokeGen::PokeMod::Pokemod::DeleteType(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemod", id, "type", n);
+ for (std::vector<Type>::iterator i = types.begin(); i != types.end(); ++i)
+ {
+ if (i->GetName() == n)
+ {
+ LogSubmoduleRemoved("Pokemod", id, "type", n);
+ for (unsigned j = 0; j < typeChart.GetWidth(); ++j)
+ {
+ if (typeChart[j][0].GetNum() == i->GetId())
+ {
+ typeChart.DeleteCol(j);
+ typeChart.DeleteRow(j);
+ }
+ }
+ types.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemod", id, "type", n);
}
diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h index d9776957..a1bbc096 100644 --- a/pokemod/Pokemod.h +++ b/pokemod/Pokemod.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////
// Name: pokemod/Pokemod.h
-// Purpose:
+// Purpose: Define a custom PokéMod for PokéGen
// Author: Ben Boeckel
// Modified by: Ben Boeckel
// Created: Sat Feb 24 21:41:19 2007
@@ -24,7 +24,13 @@ #ifndef __POKEMOD_POKEMOD__
#define __POKEMOD_POKEMOD__
+#define CUR_MAJOR_VERSION 0
+#define CUR_MINOR_VERSION 1
+
#include <vector>
+#include <map>
+#include <sstream>
+#include <string>
#include "pokemod_inc.h"
#include "Object.h"
#include "Ref.h"
@@ -34,14 +40,17 @@ #include "CoinList.h"
#include "Dialog.h"
#include "EggGroup.h"
+#include "Ini.h"
#include "Item.h"
#include "ItemStorage.h"
#include "Map.h"
#include "Move.h"
#include "Nature.h"
+#include "Point.h"
#include "Pokemon.h"
#include "Status.h"
#include "Store.h"
+#include "String.h"
#include "Tile.h"
#include "Time.h"
#include "Type.h"
@@ -60,11 +69,151 @@ namespace PokeGen void ImportIni(std::ifstream &fin);
void ExportIni(std::ofstream &fout) const;
- bool IsSpecialSplit() const;
- bool IsSpecialDVSplit() const;
+ unsigned MaxCompatability(const Pokemod &p) const;
+
+ void SetTitle(const String &t);
+ void SetVersion(const String &v);
+ void SetDescription(const String &d);
+ void SetIsGenderAllowed(const bool g);
+ void SetIsBreedingAllowed(const bool b);
+ void SetEggSpecies(const unsigned e);
+ void SetEggSpecies(const String &e);
+ void SetCanHoldItems(const bool h);
+ void SetHasCriticalDomains(const bool c);
+ void SetIsContestAllowed(const bool c);
+ void SetIsAbilityAllowed(const bool a);
+ void SetIsNatureAllowed(const bool n);
+ void SetNumDaycares(const unsigned n);
+ void SetNumPokemonBoxes(const unsigned n);
+ void SetNumPokemonPerBox(const unsigned n);
+ void SetMaxParty(const unsigned m);
+ void SetMaxFight(const unsigned m);
+ void SetMaxMoves(const unsigned m);
+ void SetMaxLevel(const unsigned m);
+ void SetMaxMoney(const unsigned m);
+ void SetIsHardCash(const bool h);
+ void SetIsSpecialSplit(const bool s);
+ void SetIsSpecialDVSplit(const bool s);
+ void SetMaxDVValue(const unsigned char m);
+ void SetIsHappiness(const bool h);
+ void SetHappyFaintLoss(const unsigned h);
+ void SetHappyLevelGain(const unsigned h);
+ void SetHappySteps(const unsigned h);
+ void SetIsEffortValuesAllowed(const bool e);
+ void SetMaxTotalEV(const unsigned m);
+ void SetMaxEVPerStat(const unsigned m);
+ void SetPokerusChance(const Frac &p);
+ void SetPokerusChance(const unsigned n, const unsigned d);
+ void SetPokerusChanceNum(const unsigned n);
+ void SetPokerusChanceDenom(const unsigned d);
+ void SetStartMap(const unsigned s);
+ void SetStartMap(const String &s);
+ void SetStartMoney(const unsigned s);
+ void SetStartCoordinate(const Point &s);
+ void SetStartCoordinate(const unsigned x, const unsigned y);
+ void SetStartCoordinateX(const unsigned x);
+ void SetStartCoordinateY(const unsigned y);
+ void SetStartDirection(const unsigned s);
+ void SetStartDirection(const String &s);
+ void SetStartDialog(const unsigned s);
+ void SetWalkSkin(const Path &w);
+ void SetBikeSkin(const Path &b);
+ void SetSurfSkin(const Path &s);
+ void SetFlySkin(const Path &f);
+ void SetFishSkin(const Path &f);
+ void SetSurfFishSkin(const Path &s);
+ void SetSuperPCUname(const String &u);
+ void SetSuperPCPasswd(const String &p);
+ void SetStruggleMove(const unsigned s);
+ void SetStruggleMove(const String &s);
+ void SetConfuseMove(const unsigned c);
+ void SetConfuseMove(const String &c);
+
+ String GetTitle() const;
+ String GetVersion() const;
+ String GetDescription() const;
+ bool IsGenderAllowed() const;
+ bool IsBreedingAllowed() const;
+ unsigned GetEggSpecies() const;
+ String GetEggSpeciesString() const;
+ bool CanHoldItems() const;
+ bool HasCriticalDomains() const;
bool IsContestAllowed() const;
- unsigned GetMaxLevel() const;
+ bool IsAbilityAllowed() const;
+ bool IsNatureAllowed() const;
+ unsigned GetNumDaycares() const;
+ unsigned GetNumPokemonBoxes() const;
+ unsigned GetNumPokemonPerBox() const;
+ unsigned GetMaxParty() const;
unsigned GetMaxFight() const;
+ unsigned GetMaxMoves() const;
+ unsigned GetMaxLevel() const;
+ unsigned GetMaxMoney() const;
+ bool IsHardCash() const;
+ bool IsSpecialSplit() const;
+ bool IsSpecialDVSplit() const;
+ unsigned char GetMaxDVValue() const;
+ bool IsHappiness() const;
+ unsigned GetHappyFaintLoss() const;
+ unsigned GetHappyLevelGain() const;
+ unsigned GetHappySteps() const;
+ bool IsEffortValuesAllowed() const;
+ unsigned GetMaxTotalEV() const;
+ unsigned GetMaxEVPerStat() const;
+ Frac GetPokerusChance() const;
+ unsigned GetPokerusChanceNum() const;
+ unsigned GetPokerusChanceDenom() const;
+ unsigned GetStartMap() const;
+ String GetStartMapString() const;
+ unsigned GetStartMoney() const;
+ Point GetStartCoordinate() const;
+ unsigned GetStartCoordinateX() const;
+ unsigned GetStartCoordinateY() const;
+ unsigned GetStartDirection() const;
+ String GetStartDirectionString() const;
+ unsigned GetStartDialog() const;
+ String GetStartDialogString() const;
+ Path GetWalkSkin() const;
+ Path GetBikeSkin() const;
+ Path GetSurfSkin() const;
+ Path GetFlySkin() const;
+ Path GetFishSkin() const;
+ Path GetSurfFishSkin() const;
+ String GetSuperPCUname() const;
+ String GetSuperPCPasswd() const;
+ unsigned GetStruggleMove() const;
+ String GetStruggleMoveString() const;
+ unsigned GetConfuseMove() const;
+ String GetConfuseMoveString() const;
+
+ void SetTypeChart(const unsigned att, const unsigned def, const Frac &m) const;
+ void SetTypeChart(const unsigned att, const unsigned def, const unsigned n, const unsigned d) const;
+ void SetTypeChartNum(const unsigned att, const unsigned def, const unsigned n) const;
+ void SetTypeChartDenom(const unsigned att, const unsigned def, const unsigned d) const;
+ void SetTypeChart(const String &att, const unsigned def, const Frac &m) const;
+ void SetTypeChart(const String &att, const unsigned def, const unsigned n, const unsigned d) const;
+ void SetTypeChartNum(const String &att, const unsigned def, const unsigned n) const;
+ void SetTypeChartDenom(const String &att, const unsigned def, const unsigned d) const;
+ void SetTypeChart(const unsigned att, const String &def, const Frac &m) const;
+ void SetTypeChart(const unsigned att, const String &def, const unsigned n, const unsigned d) const;
+ void SetTypeChartNum(const unsigned att, const String &def, const unsigned n) const;
+ void SetTypeChartDenom(const unsigned att, const String &def, const unsigned d) const;
+ void SetTypeChart(const String &att, const String &def, const Frac &m) const;
+ void SetTypeChart(const String &att, const String &def, const unsigned n, const unsigned d) const;
+ void SetTypeChartNum(const String &att, const String &def, const unsigned n) const;
+ void SetTypeChartDenom(const String &att, const String &def, const unsigned d) const;
+ Frac GetTypeChart(const unsigned att, const unsigned def) const;
+ unsigned GetTypeChartNum(const unsigned att, const unsigned def) const;
+ unsigned GetTypeChartDenom(const unsigned att, const unsigned def) const;
+ Frac GetTypeChart(const String &att, const unsigned def) const;
+ unsigned GetTypeChartNum(const String &att, const unsigned def) const;
+ unsigned GetTypeChartDenom(const String &att, const unsigned def) const;
+ Frac GetTypeChart(const unsigned att, const String &def) const;
+ unsigned GetTypeChartNum(const unsigned att, const String &def) const;
+ unsigned GetTypeChartDenom(const unsigned att, const String &def) const;
+ Frac GetTypeChart(const String &att, const String &def) const;
+ unsigned GetTypeChartNum(const String &att, const String &def) const;
+ unsigned GetTypeChartDenom(const String &att, const String &def) const;
const Ability *GetAbility(const unsigned _id) const;
const Ability *GetAbility(const String &n) const;
@@ -188,9 +337,54 @@ namespace PokeGen void Validate(const wxListBox &output);
# endif
- bool splitSpecial;
- bool splitSpecialDV;
+ String title;
+ String version;
+ String description;
+ bool genderAllowed;
+ bool breedingAllowed;
+ unsigned eggSpecies;
+ bool holdItems;
+ bool criticalDomains;
+ bool contestAllowed;
+ bool abilityAllowed;
+ bool natureAllowed;
+ unsigned numDaycares;
+ unsigned numPokemonBoxes;
+ unsigned numPokemonPerBox;
+ unsigned maxParty;
+ unsigned maxFight;
+ unsigned maxMoves;
unsigned maxLevel;
+ unsigned maxMoney;
+ bool hardCash;
+ bool specialSplit;
+ bool specialDVSplit;
+ unsigned char maxDVValue;
+ bool happiness;
+ unsigned happyFaintLoss;
+ unsigned happyLevelGain;
+ unsigned happySteps;
+ bool effortValuesAllowed;
+ unsigned maxTotalEV;
+ unsigned maxEVPerStat;
+ Frac pokerusChance;
+ unsigned startMap;
+ unsigned startMoney;
+ Point startCoordinate;
+ unsigned startDirection;
+ unsigned startDialog;
+ Path walkSkin;
+ Path bikeSkin;
+ Path surfSkin;
+ Path flySkin;
+ Path fishSkin;
+ Path surfFishSkin;
+ String superPCUname;
+ String superPCPasswd;
+ unsigned struggleMove;
+ unsigned confuseMove;
+
+ MatrixFrac typeChart;
std::vector<Ability> abilities;
std::vector<Author> authors;
@@ -199,7 +393,7 @@ namespace PokeGen std::vector<Dialog> dialogs;
std::vector<EggGroup> eggGroups;
std::vector<Item> items;
- std::vector<ItemStorage> itemStorage;
+ std::vector<ItemStorage> itemStorages;
std::vector<Map> maps;
std::vector<Move> moves;
std::vector<Nature> natures;
diff --git a/pokemod/Pokemon.cpp b/pokemod/Pokemon.cpp index cacd72a5..fdbf3072 100644 --- a/pokemod/Pokemon.cpp +++ b/pokemod/Pokemon.cpp @@ -25,33 +25,32 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
-PokeGen::PokeMod::Pokemon::Pokemon(const unsigned _id)
+PokeGen::PokeMod::Pokemon::Pokemon(const unsigned _id) :
+ name(""),
+ growth(UINT_MAX),
+ catchValue(0),
+ runChance(1, 1),
+ itemChance(1, 1),
+ pokedexNumber(UINT_MAX),
+ weight(0),
+ heightFeet(0),
+ heightInches(0),
+ pokedexEntry(""),
+ frontSprite(""),
+ backSprite(""),
+ listSprite(""),
+ genderFactor(1, 1, true),
+ eggSpecies(UINT_MAX),
+ eggSteps(0),
+ isDitto(false),
+ nidoranGroup(UINT_MAX)
{
LogCtor("Pokemon", id);
- name = "";
for (unsigned i = 0; i < STH_END_GSC; ++i)
{
baseStats[i] = 0;
effortValues[i] = 0;
}
- growth = UINT_MAX;
- experienceValue = 0;
- catchValue = 0;
- runChance.Set(1, 1);
- itemChance.Set(1, 1);
- pokedexNumber = UINT_MAX;
- weight = 0;
- heightFeet = 0;
- heightInches = 0;
- pokedexEntry = "";
- frontSprite = "";
- backSprite = "";
- listSprite = "";
- genderFactor.Set(1, 1, true);
- eggSpecies = UINT_MAX;
- eggSteps = 0;
- isDitto = false;
- nidoranGroup = UINT_MAX;
id = _id;
}
@@ -132,90 +131,183 @@ void PokeGen::PokeMod::Pokemon::Validate() LogVarNotValid("Pokemon", id, "eggSteps", name);
isValid = false;
}
- // Check if there are any abilities defined
- if (GetPokemonAbilityCount())
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> nameChecker;
+ if (curPokeMod.IsAbilityAllowed())
{
- // Validate each ability
- for (std::vector<PokemonAbility>::iterator i = abilities.begin(); i != abilities.end(); ++i)
+ if (GetPokemonAbilityCount())
{
- LogSubmoduleIterate("Pokemon", id, "ability", i->GetId(), name);
- // If an ability isn't valid, neither is the Pokémon
- if (!i->IsValid())
- isValid = false;
+ for (std::vector<PokemonAbility>::iterator i = abilities.begin(); i != abilities.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "ability", i->GetId(), name);
+ if (!i->IsValid())
+ isValid = false;
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetAbilityString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Pokemon", id, "ability", i->first, name);
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Pokemon", id, "ability", i->first, name);
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "ability", name);
+ isValid = false;
}
}
- else
- {
- LogSubmoduleEmpty("Pokemon", id, "ability", name);
- isValid = false;
- }
- // Check if there are any evolutions defined
- if (GetPokemonAbilityCount())
+ if (GetPokemonEvolutionCount())
{
- // Validate each evolution
for (std::vector<PokemonEvolution>::iterator i = evolutions.begin(); i != evolutions.end(); ++i)
{
LogSubmoduleIterate("Pokemon", id, "evolution", i->GetId(), name);
- // If an evolution isn't valid, neither is the Pokémon
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetSpeciesString()];
}
- }
- else
- {
- LogSubmoduleEmpty("Pokemon", id, "evolution", name);
- isValid = false;
- }
- // Check if there are any item defined
- if (GetPokemonItemCount())
- {
- // Validate each item
- for (std::vector<PokemonItem>::iterator i = items.begin(); i != items.end(); ++i)
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
{
- LogSubmoduleIterate("Pokemon", id, "item", i->GetId(), name);
- // If an item isn't valid, neither is the Pokémon
- if (!i->IsValid())
+ if (1 < i->second)
+ {
+ LogDuplicateId("Pokemon", id, "evolution", i->first, name);
isValid = false;
+ }
}
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Pokemon", id, "evolution", i->first, name);
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
}
else
+ LogSubmoduleEmpty("Pokemon", id, "evolution", name);
+ if (curPokeMod.CanHoldItems())
{
- LogSubmoduleEmpty("Pokemon", id, "item", name);
- isValid = false;
+ if (GetPokemonItemCount())
+ {
+ for (std::vector<PokemonItem>::iterator i = items.begin(); i != items.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "item", i->GetId(), name);
+ if (!i->IsValid())
+ isValid = false;
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetItemString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Pokemon", id, "item", i->first, name);
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Pokemon", id, "item", i->first, name);
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "item", name);
+ isValid = false;
+ }
}
- // Check if there are any move defined
if (GetPokemonMoveCount())
{
- // Validate each move
for (std::vector<PokemonMove>::iterator i = moves.begin(); i != moves.end(); ++i)
{
LogSubmoduleIterate("Pokemon", id, "move", i->GetId(), name);
- // If an move isn't valid, neither is the Pokémon
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetMoveString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Pokemon", id, "move", i->first, name);
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Pokemon", id, "move", i->first, name);
+ isValid = false;
+ }
}
+ idChecker.clear();
+ nameChecker.clear();
}
else
{
LogSubmoduleEmpty("Pokemon", id, "move", name);
isValid = false;
}
- // Check if there are any natures defined
- if (GetPokemonAbilityCount())
+ if (curPokeMod.IsNatureAllowed())
{
- // Validate each nature
- for (std::vector<PokemonNature>::iterator i = natures.begin(); i != natures.end(); ++i)
+ if (GetPokemonNatureCount())
{
- LogSubmoduleIterate("Pokemon", id, "nature", i->GetId(), name);
- // If an nature isn't valid, neither is the Pokémon
- if (!i->IsValid())
- isValid = false;
+ for (std::vector<PokemonNature>::iterator i = natures.begin(); i != natures.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "nature", i->GetId(), name);
+ if (!i->IsValid())
+ isValid = false;
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetNatureString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Pokemon", id, "nature", i->first, name);
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Pokemon", id, "nature", i->first, name);
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "nature", name);
+ isValid = false;
}
- }
- else
- {
- LogSubmoduleEmpty("Pokemon", id, "nature", name);
- isValid = false;
}
LogValidateOver("Pokemon", id, isValid, name);
}
@@ -233,7 +325,7 @@ void PokeGen::PokeMod::Pokemon::Validate(const wxListBox &output) if (name == "")
{
LogVarNotSet("Pokemon", id, "name", name);
- output.append(ConsoleLogVarNotSet("Pokemon", id, "name", name));
+ output.Append(ConsoleLogVarNotSet("Pokemon", id, "name", name));
isValid = false;
}
for (unsigned i = 0; i < (curPokeMod.IsSpecialSplit() ? STH_END_GSC : STH_END_RBY); ++i)
@@ -241,31 +333,31 @@ void PokeGen::PokeMod::Pokemon::Validate(const wxListBox &output) if (!baseStats[i])
{
LogVarNotValid("Pokemon", id, String("baseStats[%u]", i), name);
- output.append(ConsoleLogVarNotValid("Pokemon", id, String("baseStats[%u]", i), name));
+ output.Append(ConsoleLogVarNotValid("Pokemon", id, String("baseStats[%u]", i), name));
isValid = false;
}
}
if (STY_END <= growth)
{
LogVarNotValid("Pokemon", id, "growth", name);
- output.append(ConsoleLogVarNotValid("Pokemon", id, "growth", name));
+ output.Append(ConsoleLogVarNotValid("Pokemon", id, "growth", name));
isValid = false;
}
if (curPokeMod.GetPokemonCount() <= pokedexNumber)
{
LogVarNotValid("Pokemon", id, "pokedexNumber", name);
- output.append(ConsoleLogVarNotValid("Pokemon", id, "pokedexNumber", name));
+ output.Append(ConsoleLogVarNotValid("Pokemon", id, "pokedexNumber", name));
isValid = false;
}
if (!weight)
{
LogVarNotSet("Pokemon", id, "weight", name);
- output.append(ConsoleLogVarNotSetW("Pokemon", id, "weight", name));
+ output.Append(ConsoleLogVarNotSetW("Pokemon", id, "weight", name));
}
if (12 <= heightInches)
{
LogVarNotValid("Pokemon", id, "heightInches", name);
- output.append(ConsoleLogVarNotValid("Pokemon", id, "heightInches", name));
+ output.Append(ConsoleLogVarNotValid("Pokemon", id, "heightInches", name));
isValid = false;
}
if (!frontSprite.DoesExist())
@@ -273,12 +365,12 @@ void PokeGen::PokeMod::Pokemon::Validate(const wxListBox &output) if (frontSprite == "")
{
LogVarNotSet("Pokemon", id, "frontSprite", name);
- output.append(ConsoleLogVarNotSet("Pokemon", id, "frontSprite", name));
+ output.Append(ConsoleLogVarNotSet("Pokemon", id, "frontSprite", name));
}
else
{
LogVarNotValid("Pokemon", id, "frontSprite", name);
- output.append(ConsoleLogVarNotValid("Pokemon", id, "frontSprite", name));
+ output.Append(ConsoleLogVarNotValid("Pokemon", id, "frontSprite", name));
}
isValid = false;
}
@@ -287,12 +379,12 @@ void PokeGen::PokeMod::Pokemon::Validate(const wxListBox &output) if (backSprite == "")
{
LogVarNotSet("Pokemon", id, "backSprite", name);
- output.append(ConsoleLogVarNotSet("Pokemon", id, "backSprite", name));
+ output.Append(ConsoleLogVarNotSet("Pokemon", id, "backSprite", name));
}
else
{
LogVarNotValid("Pokemon", id, "backSprite", name);
- output.append(ConsoleLogVarNotValid("Pokemon", id, "backSprite", name));
+ output.Append(ConsoleLogVarNotValid("Pokemon", id, "backSprite", name));
}
isValid = false;
}
@@ -301,115 +393,220 @@ void PokeGen::PokeMod::Pokemon::Validate(const wxListBox &output) if (listSprite == "")
{
LogVarNotSet("Pokemon", id, "listSprite", name);
- output.append(ConsoleLogVarNotSet("Pokemon", id, "listSprite", name));
+ output.Append(ConsoleLogVarNotSet("Pokemon", id, "listSprite", name));
}
else
{
LogVarNotValid("Pokemon", id, "listSprite", name);
- output.append(ConsoleLogVarNotValid("Pokemon", id, "listSprite", name));
+ output.Append(ConsoleLogVarNotValid("Pokemon", id, "listSprite", name));
}
isValid = false;
}
if (!curPokeMod.GetPokemon(eggSpecies))
{
LogVarNotValid("Pokemon", id, "eggSpecies", name);
- output.append(ConsoleLogVarNotValidW("Pokemon", id, "eggSpecies", name));
+ output.Append(ConsoleLogVarNotValidW("Pokemon", id, "eggSpecies", name));
}
else if (!eggSteps)
{
LogVarNotValid("Pokemon", id, "eggSteps", name);
- output.append(ConsoleLogVarNotValid("Pokemon", id, "eggSteps", name));
+ output.Append(ConsoleLogVarNotValid("Pokemon", id, "eggSteps", name));
isValid = false;
}
- // Check if there are any abilities defined
- if (GetPokemonAbilityCount())
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> nameChecker;
+ if (curPokeMod.IsAbilityAllowed())
{
- // Validate each ability
- for (std::vector<PokemonAbility>::iterator i = abilities.begin(); i != abilities.end(); ++i)
+ if (GetPokemonAbilityCount())
{
- LogSubmoduleIterate("Pokemon", id, "ability", i->GetId(), name);
- // If an ability isn't valid, neither is the Pokémon
- if (!i->IsValid())
- isValid = false;
+ for (std::vector<PokemonAbility>::iterator i = abilities.begin(); i != abilities.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "ability", i->GetId(), name);
+ if (!i->IsValid())
+ isValid = false;
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetAbilityString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Pokemon", id, "ability", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Pokemon", id, "ability", i->first, name));
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Pokemon", id, "ability", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Pokemon", id, "ability", i->first, name));
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "ability", name);
+ output.Append(ConsoleLogSubmoduleEmpty("Pokemon", id, "ability", name));
+ isValid = false;
}
}
- else
- {
- LogSubmoduleEmpty("Pokemon", id, "ability", name);
- output.append(ConsoleLogSubmoduleEmpty("Pokemon", id, "ability", name));
- isValid = false;
- }
- // Check if there are any evolutions defined
- if (GetPokemonAbilityCount())
+ if (GetPokemonEvolutionCount())
{
- // Validate each evolution
for (std::vector<PokemonEvolution>::iterator i = evolutions.begin(); i != evolutions.end(); ++i)
{
LogSubmoduleIterate("Pokemon", id, "evolution", i->GetId(), name);
- // If an evolution isn't valid, neither is the Pokémon
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetSpeciesString()];
}
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Pokemon", id, "evolution", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Pokemon", id, "evolution", i->first, name));
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Pokemon", id, "evolution", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Pokemon", id, "evolution", i->first, name));
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
}
else
{
LogSubmoduleEmpty("Pokemon", id, "evolution", name);
- output.append(ConsoleLogSubmoduleEmpty("Pokemon", id, "evolution", name));
- isValid = false;
+ output.Append(ConsoleLogSubmoduleEmptyW("Pokemon", id, "evolution", name));
}
- // Check if there are any item defined
- if (GetPokemonItemCount())
+ if (curPokeMod.CanHoldItems())
{
- // Validate each item
- for (std::vector<PokemonItem>::iterator i = items.begin(); i != items.end(); ++i)
+ if (GetPokemonItemCount())
{
- LogSubmoduleIterate("Pokemon", id, "item", i->GetId(), name);
- // If an item isn't valid, neither is the Pokémon
- if (!i->IsValid())
- isValid = false;
+ for (std::vector<PokemonItem>::iterator i = items.begin(); i != items.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "item", i->GetId(), name);
+ if (!i->IsValid())
+ isValid = false;
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetItemString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Pokemon", id, "item", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Pokemon", id, "item", i->first, name));
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Pokemon", id, "item", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Pokemon", id, "item", i->first, name));
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "item", name);
+ output.Append(ConsoleLogSubmoduleEmpty("Pokemon", id, "item", name));
+ isValid = false;
}
}
- else
- {
- LogSubmoduleEmpty("Pokemon", id, "item", name);
- output.append(ConsoleLogSubmoduleEmpty("Pokemon", id, "item", name));
- isValid = false;
- }
- // Check if there are any move defined
if (GetPokemonMoveCount())
{
- // Validate each move
for (std::vector<PokemonMove>::iterator i = moves.begin(); i != moves.end(); ++i)
{
LogSubmoduleIterate("Pokemon", id, "move", i->GetId(), name);
- // If an move isn't valid, neither is the Pokémon
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetMoveString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Pokemon", id, "move", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Pokemon", id, "move", i->first, name));
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Pokemon", id, "move", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Pokemon", id, "move", i->first, name));
+ isValid = false;
+ }
}
+ idChecker.clear();
+ nameChecker.clear();
}
else
{
LogSubmoduleEmpty("Pokemon", id, "move", name);
- output.append(ConsoleLogSubmoduleEmpty("Pokemon", id, "move", name));
+ output.Append(ConsoleLogSubmoduleEmpty("Pokemon", id, "move", name));
isValid = false;
}
- // Check if there are any natures defined
- if (GetPokemonAbilityCount())
+ if (curPokeMod.IsNatureAllowed())
{
- // Validate each nature
- for (std::vector<PokemonNature>::iterator i = natures.begin(); i != natures.end(); ++i)
+ if (GetPokemonNatureCount())
{
- LogSubmoduleIterate("Pokemon", id, "nature", i->GetId(), name);
- // If an nature isn't valid, neither is the Pokémon
- if (!i->IsValid())
- isValid = false;
+ for (std::vector<PokemonNature>::iterator i = natures.begin(); i != natures.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "nature", i->GetId(), name);
+ if (!i->IsValid())
+ isValid = false;
+ ++idChecker[i->GetId()];
+ ++nameChecker[i->GetNatureString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Pokemon", id, "nature", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Pokemon", id, "nature", i->first, name));
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Pokemon", id, "nature", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Pokemon", id, "nature", i->first, name));
+ isValid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "nature", name);
+ output.Append(ConsoleLogSubmoduleEmpty("Pokemon", id, "nature", name));
+ isValid = false;
}
- }
- else
- {
- LogSubmoduleEmpty("Pokemon", id, "nature", name);
- output.append(ConsoleLogSubmoduleEmpty("Pokemon", id, "nature", name));
- isValid = false;
}
LogValidateOver("Pokemon", id, isValid, name);
}
diff --git a/pokemod/Pokemon.h b/pokemod/Pokemon.h index 0b61841d..a3946c9a 100644 --- a/pokemod/Pokemon.h +++ b/pokemod/Pokemon.h @@ -25,6 +25,7 @@ #define __POKEMOD_POKEMON__
#include <vector>
+#include <map>
#include "Object.h"
#include "String.h"
#include "Frac.h"
diff --git a/pokemod/PokemonAbility.cpp b/pokemod/PokemonAbility.cpp index 8fc9a068..f710be27 100644 --- a/pokemod/PokemonAbility.cpp +++ b/pokemod/PokemonAbility.cpp @@ -26,8 +26,8 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::PokemonAbility::PokemonAbility(const unsigned _id) :
- ability(UINT_MAX),
- weight(1)
+ ability(UINT_MAX),
+ weight(1)
{
LogCtor("PokemonAbility", _id);
id = _id;
@@ -76,9 +76,9 @@ void PokeGen::PokeMod::PokemonAbility::Validate(const wxListBox &output) {
LogVarNotSet("PokemonAbility", id, "weight", GetAbilityString());
output.Append(ConsoleLogVarNotSet("PokemonAbility", id, weight, GetAbilityString());
- isValid = false;
- }
- LogValidateOver("PokemonAbility", id, isValid, GetAbilityString());
+ isValid = false;
+ }
+ LogValidateOver("PokemonAbility", id, isValid, GetAbilityString());
}
#endif
@@ -88,7 +88,6 @@ void PokeGen::PokeMod::PokemonAbility::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("PokemonAbility");
}
@@ -102,8 +101,7 @@ void PokeGen::PokeMod::PokemonAbility::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::PokemonAbility::ExportIni(std::ofstream &fout, const String &pokemon) const
{
LogExportStart("PokemonAbility", id);
- // Make elements
- Ini exPokemonAbility(pokemon + " pokemonAbility");
+ Ini exPokemonAbility("pokemonAbility " + pokemon);
exPokemonAbility.AddField("id", id);
exPokemonAbility.AddField("ability", ability);
exPokemonAbility.AddField("weight", weight);
diff --git a/pokemod/PokemonEvolution.cpp b/pokemod/PokemonEvolution.cpp index 92ef1a8c..cfc424db 100644 --- a/pokemod/PokemonEvolution.cpp +++ b/pokemod/PokemonEvolution.cpp @@ -26,11 +26,11 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::PokemonEvolution::PokemonEvolution(const unsigned _id) :
- species(UINT_MAX),
- style(UINT_MAX),
- level(0),
- item(UINT_MAX),
- happiness(0)
+ species(UINT_MAX),
+ style(UINT_MAX),
+ level(0),
+ item(UINT_MAX),
+ happiness(0)
{
LogCtor("PokemonEvolution", _id);
id = _id;
@@ -113,7 +113,6 @@ void PokeGen::PokeMod::PokemonEvolution::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("PokemonEvolution");
}
@@ -130,8 +129,7 @@ void PokeGen::PokeMod::PokemonEvolution::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::PokemonEvolution::ExportIni(std::ofstream &fout, const String &pokemon) const
{
LogExportStart("PokemonEvolution", id);
- // Make elements
- Ini exPokemonEvolution(pokemon + " pokemonEvolution");
+ Ini exPokemonEvolution("pokemonEvolution " + pokemon);
exPokemonEvolution.AddField("id", id);
exPokemonEvolution.AddField("species", species);
exPokemonEvolution.AddField("style", style);
diff --git a/pokemod/PokemonItem.cpp b/pokemod/PokemonItem.cpp index af4a9626..f1c1ceca 100644 --- a/pokemod/PokemonItem.cpp +++ b/pokemod/PokemonItem.cpp @@ -26,8 +26,8 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::PokemonItem::PokemonItem(const unsigned _id) :
- item(UINT_MAX),
- weight(1)
+ item(UINT_MAX),
+ weight(1)
{
LogCtor("PokemonItem", _id);
id = _id;
@@ -75,7 +75,7 @@ void PokeGen::PokeMod::PokemonItem::Validate(const wxListBox &output) if (!weight)
{
LogVarNotSet("PokemonItem", id, weight, GetItemString());
- output.Append(ConsoleLogVarNotSet("PokemonItem", id, weight, GetItemString());
+ output.Append(ConsoleLogVarNotSet("PokemonItem", id, weight, GetItemString()));
isValid = false;
}
LogValidateOver("PokemonItem", id, isValid, GetItemString());
@@ -88,7 +88,6 @@ void PokeGen::PokeMod::PokemonItem::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("PokemonItem");
}
@@ -102,8 +101,7 @@ void PokeGen::PokeMod::PokemonItem::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::PokemonItem::ExportIni(std::ofstream &fout, const String &pokemon) const
{
LogExportStart("PokemonItem", id);
- // Make elements
- Ini exPokemonItem(pokemon + " pokemonItem");
+ Ini exPokemonItem("pokemonItem " + pokemon);
exPokemonItem.AddField("id", id);
exPokemonItem.AddField("item", item);
exPokemonItem.AddField("weight", weight);
diff --git a/pokemod/PokemonMove.cpp b/pokemod/PokemonMove.cpp index 7aa75024..e3d0df75 100644 --- a/pokemod/PokemonMove.cpp +++ b/pokemod/PokemonMove.cpp @@ -100,7 +100,6 @@ void PokeGen::PokeMod::PokemonMove::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("PokemonMove");
}
@@ -115,8 +114,7 @@ void PokeGen::PokeMod::PokemonMove::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::PokemonMove::ExportIni(std::ofstream &fout, const String &pokemon) const
{
LogExportStart("PokemonMove", id);
- // Make elements
- Ini exPokemonMove(pokemon + " pokemonMove");
+ Ini exPokemonMove("pokemonMove " + pokemon);
exPokemonMove.AddField("id", id);
exPokemonMove.AddField("move", move);
exPokemonMove.AddField("level", level);
diff --git a/pokemod/PokemonNature.cpp b/pokemod/PokemonNature.cpp index 27c402a0..c4c1ad39 100644 --- a/pokemod/PokemonNature.cpp +++ b/pokemod/PokemonNature.cpp @@ -26,8 +26,8 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::PokemonNature::PokemonNature(const unsigned _id) :
- nature(UINT_MAX),
- weight(1)
+ nature(UINT_MAX),
+ weight(1)
{
LogCtor("PokemonNature", _id);
id = _id;
@@ -76,9 +76,9 @@ void PokeGen::PokeMod::PokemonNature::Validate(const wxListBox &output) {
LogVarNotSet("PokemonNature", id, "weight", GetNatureString());
output.Append(ConsoleLogVarNotSet("PokemonNature", id, weight, GetNatureString());
- isValid = false;
- }
- LogValidateOver("PokemonNature", id, isValid, GetNatureString());
+ isValid = false;
+ }
+ LogValidateOver("PokemonNature", id, isValid, GetNatureString());
}
#endif
@@ -88,7 +88,6 @@ void PokeGen::PokeMod::PokemonNature::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("PokemonNature");
}
@@ -102,8 +101,7 @@ void PokeGen::PokeMod::PokemonNature::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::PokemonNature::ExportIni(std::ofstream &fout, const String &pokemon) const
{
LogExportStart("PokemonNature", id);
- // Make elements
- Ini exPokemonNature(pokemon + " pokemonNature");
+ Ini exPokemonNature("pokemonNature " + pokemon);
exPokemonNature.AddField("id", id);
exPokemonNature.AddField("nature", nature);
exPokemonNature.AddField("weight", weight);
diff --git a/pokemod/Ref.cpp b/pokemod/Ref.cpp index 51d6b49a..78862a15 100644 --- a/pokemod/Ref.cpp +++ b/pokemod/Ref.cpp @@ -26,7 +26,6 @@ int PokeGen::PokeMod::FindIn(const int end, const String &str, const char *array[])
{
int i = 0;
- // Loop through looking for where the string is in the array
for (; i < end; ++i)
{
if (str == array[i])
diff --git a/pokemod/Ref.h b/pokemod/Ref.h index 7e79a648..c920eadb 100644 --- a/pokemod/Ref.h +++ b/pokemod/Ref.h @@ -27,8 +27,6 @@ #include <vector>
#include "String.h"
-// TODO (Comment#1#): Comment Ref
-
namespace PokeGen
{
namespace PokeMod
diff --git a/pokemod/Status.cpp b/pokemod/Status.cpp index d867a436..b09de29a 100644 --- a/pokemod/Status.cpp +++ b/pokemod/Status.cpp @@ -27,13 +27,13 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::Status::Status(const unsigned _id) :
- name(""),
- abbreviation(""),
- verb(""),
- afterSwitch(UINT_MAX),
- afterBattle(UINT_MAX),
- maxTurns(0),
- catchBonus(0)
+ name(""),
+ abbreviation(""),
+ verb(""),
+ afterSwitch(UINT_MAX),
+ afterBattle(UINT_MAX),
+ maxTurns(0),
+ catchBonus(0)
{
LogCtor("Status", id);
id = _id;
@@ -57,13 +57,21 @@ void PokeGen::PokeMod::Status::Validate() LogValidateStart("Status", id, name);
if (name == "")
{
- LogVarNotSet("Status", id, "name", name);
+ LogVarNotSet("Status", id, "name");
+ isValid = false;
+ }
+ else if ((name == "Clear") || (name == "Any"))
+ {
+ LogVarNotValid("Status", id, "name", name);
isValid = false;
}
if (abbreviation == "")
LogVarNotSet("Status", id, "abbreviation", name);
else if (4 <= abbreviation.length())
+ {
LogVarNotValid("Status", id, "abbreviation", name);
+ isValid = false;
+ }
if (verb == "")
LogVarNotSet("Status", id, "verb", name);
if (afterSwitch == UINT_MAX)
@@ -80,16 +88,33 @@ void PokeGen::PokeMod::Status::Validate() LogVarNotValid("Status", id, "afterBattle", name);
isValid = false;
}
- // Check if there are any effects defined
if (GetStatusEffectCount())
{
- // Validate each effect
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
for (std::vector<StatusEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
LogSubmoduleIterate("Status", id, "effect", i->GetId(), name);
- // If an effect isn't valid, neither is the Status
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("Status", 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("Status", id, "effect", i->first, name);
+ isValid = false;
+ }
}
}
else
@@ -110,6 +135,11 @@ void PokeGen::PokeMod::Status::Validate(const wxListBox &output) output.Append(ConsoleLogVarNotSet("Status", id, "Name", name));
isValid = false;
}
+ else if (name == "Clear")
+ {
+ LogVarNotValid("Status", id, "name", name);
+ isValid = false;
+ }
if (abbreviation == "")
{
LogVarNotSet("Status", id, "abbreviation", name);
@@ -118,7 +148,8 @@ void PokeGen::PokeMod::Status::Validate(const wxListBox &output) else if (4 <= abbreviation.length())
{
LogVarNotValid("Status", id, "abbreviation", name);
- output.Append(ConsoleLogVarNotValidW("Status", id, "abbreviation", name));
+ output.Append(ConsoleLogVarNotValid("Status", id, "abbreviation", name));
+ isValid = false;
}
if (verb == "")
{
@@ -147,16 +178,35 @@ void PokeGen::PokeMod::Status::Validate(const wxListBox &output) output.Append(ConsoleLogVarNotValid("Status", id, "afterBattle", name));
isValid = false;
}
- // Check if there are any effects defined
if (GetStatusEffectCount())
{
- // Validate each effect
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
for (std::vector<StatusEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
LogSubmoduleIterate("Status", id, "effect", i->GetId(), name);
- // If an effect isn't valid, neither is the Status
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("Status", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Status", 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("Status", id, "effect", i->first, name);
+ output.Append(LogDuplicateSubmodule("Status", id, "effect", i->first, name));
+ isValid = false;
+ }
}
}
else
@@ -175,7 +225,6 @@ void PokeGen::PokeMod::Status::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("Status");
}
@@ -195,7 +244,6 @@ void PokeGen::PokeMod::Status::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::Status::ExportIni(std::ofstream &fout) const
{
LogExportStart("Status", id, name);
- // Make elements
Ini exStatus("Status");
exStatus.AddField("id", id);
exStatus.AddField("name", name);
@@ -353,7 +401,6 @@ unsigned PokeGen::PokeMod::Status::GetStatusEffectCount() const void PokeGen::PokeMod::Status::NewStatusEffect(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetStatusEffectCount(); ++i)
{
if (!GetStatusEffect(i))
diff --git a/pokemod/Status.h b/pokemod/Status.h index 4dbb2607..515e1760 100644 --- a/pokemod/Status.h +++ b/pokemod/Status.h @@ -26,6 +26,7 @@ #define __POKEMOD_STATUS__
#include <vector>
+#include <map>
#include "Object.h"
#include "String.h"
#include "Pokemod.h"
diff --git a/pokemod/StatusEffect.cpp b/pokemod/StatusEffect.cpp index 2ecd5f66..c9b1f401 100644 --- a/pokemod/StatusEffect.cpp +++ b/pokemod/StatusEffect.cpp @@ -26,9 +26,9 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::StatusEffect::StatusEffect(const unsigned _id) :
- effect(UINT_MAX),
- val1(UINT_MAX),
- val2(UINT_MAX)
+ effect(UINT_MAX),
+ val1(UINT_MAX),
+ val2(UINT_MAX)
{
LogCtor("StatusEffect", _id);
id = _id;
@@ -50,7 +50,8 @@ PokeGen::PokeMod::StatusEffect::~StatusEffect() void PokeGen::PokeMod::StatusEffect::Validate()
{
LogValidateStart("StatusEffect", id);
- // TODO (Ben#1#): Validation
+ // TODO (Validation#1#): Validation
+# warning "StatusEffect Validation"
LogValidateOver("StatusEffect", id, isValid);
}
@@ -68,7 +69,6 @@ void PokeGen::PokeMod::StatusEffect::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("StatusEffect");
}
@@ -83,8 +83,7 @@ void PokeGen::PokeMod::StatusEffect::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::StatusEffect::ExportIni(std::ofstream &fout, const String &Status) const
{
LogExportStart("StatusEffect", id);
- // Make elements
- Ini exStatusEffect(Status + " StatusEffect");
+ Ini exStatusEffect("statusEffect " + status);
exStatusEffect.AddField("id", id);
exStatusEffect.AddField("effect", effect);
exStatusEffect.AddField("val1", val1);
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;
diff --git a/pokemod/Store.h b/pokemod/Store.h index f9b3cd35..166efd25 100644 --- a/pokemod/Store.h +++ b/pokemod/Store.h @@ -25,6 +25,7 @@ #define __POKEMOD_STORE__
#include <vector>
+#include <map>
#include "Object.h"
#include "String.h"
#include "Pokemod.h"
@@ -45,7 +46,7 @@ namespace PokeGen void SetName(const String &n);
- String GetName();
+ String GetName() const;
unsigned GetItem(const unsigned i) const;
bool HasItem(const unsigned _id) const;
diff --git a/pokemod/String.cpp b/pokemod/String.cpp index 846c0667..0d8b8367 100644 --- a/pokemod/String.cpp +++ b/pokemod/String.cpp @@ -98,7 +98,7 @@ void PokeGen::PokeMod::String::printf(const char *fmt, va_list &args) unit.c = (char)va_arg(args, int);
append(1, unit.c);
break;
- // Characters
+ // Unsigned characters
case 'x':
unit.uc = (unsigned char)va_arg(args, int);
append(1, unit.uc);
diff --git a/pokemod/TODO b/pokemod/TODO index 6f843e1a..d05b7c15 100644 --- a/pokemod/TODO +++ b/pokemod/TODO @@ -2,6 +2,11 @@ Urgent
=================
+-----
+Paths
+-----
+Make bool and check for default places (???)
+
----------
References
----------
@@ -10,6 +15,7 @@ ContestEffects CONE Move MoveEffects ME MoveEffect
MapEffect MAPE MapEffect
StatusEffect SE StatusEffect
+DialogCommand DC Dialog
---------------
Effect Switches
@@ -18,6 +24,11 @@ ItemEffect MoveEffect
MapEffect
+---------------
+Enum <-> String
+---------------
+Class Template-ize (???)
+
=================
Showstopper
=================
@@ -28,7 +39,6 @@ Validation StatusEffect
Dialog
ItemEffect
-MapWildList (Value/Scope)
MoveEffect
Pokemod
MapEffect
@@ -36,22 +46,6 @@ MapEffect ---------------
Duplicate Check
---------------
-Ability -> AbilityEffect
-CoinList -> CoinItem
-Item -> ItemEffect
-Map -> MapEffect
- -> MapTrainer
- -> MapWarp
- -> MapWildList
-MapWildList -> MapWildPokemon
- -> Times
-Move -> MoveEffect
-Pokemon -> PokemonAbility
- -> PokemonItem
- -> PokemonMove
- -> PokemonNature
-Status -> StatusEffect
-Store -> Item
Pokemod -> Ability
-> Author
-> Badge
diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp index 6465811f..7e3e7153 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -26,23 +26,23 @@ extern PokeGen::PokeMod::Pokemod curPokeMod;
PokeGen::PokeMod::Tile::Tile(const unsigned _id) :
- name(""),
- pic(""),
- fromUp(false),
- fromDown(false),
- fromLeft(false),
- fromRight(false),
- isWild(false),
- wildChance(1, 1),
- isWater(false),
- waterType(UINT_MAX),
- underWater(UINT_MAX),
- canDive(false),
- isCuttable(false),
- underCut(UINT_MAX),
- canHeadbutt(false),
- forceType(UINT_MAX),
- forceDirection(UINT_MAX)
+ name(""),
+ pic(""),
+ fromUp(false),
+ fromDown(false),
+ fromLeft(false),
+ fromRight(false),
+ isWild(false),
+ wildChance(1, 1),
+ isWater(false),
+ waterType(UINT_MAX),
+ underWater(UINT_MAX),
+ canDive(false),
+ isCuttable(false),
+ underCut(UINT_MAX),
+ canHeadbutt(false),
+ forceType(UINT_MAX),
+ forceDirection(UINT_MAX)
{
LogCtor("Tile", id);
id = _id;
@@ -127,7 +127,7 @@ void PokeGen::PokeMod::Tile::Validate(const wxListBox &output) if (name == "")
{
LogVarNotSet("Tile", id, "Name", name);
- output.append(ConsoleLogVarNotSet("Tile", id, "Name", name));
+ output.Append(ConsoleLogVarNotSet("Tile", id, "Name", name));
isValid = false;
}
if (!pic.DoesExist())
@@ -135,12 +135,12 @@ void PokeGen::PokeMod::Tile::Validate(const wxListBox &output) if (pic == "")
{
LogVarNotSet("Tile", id, "pic", name);
- output.append(ConsoleLogVarNotSet("Tile", id, "pic", name));
+ output.Append(ConsoleLogVarNotSet("Tile", id, "pic", name));
}
else
{
LogVarNotValid("Tile", id, "pic", name);
- output.append(ConsoleLogVarNotValid("Tile", id, "pic", name));
+ output.Append(ConsoleLogVarNotValid("Tile", id, "pic", name));
}
isValid = false;
}
@@ -149,7 +149,7 @@ void PokeGen::PokeMod::Tile::Validate(const wxListBox &output) if (WT_END <= waterType)
{
LogVarNotValid("Tile", id, "waterType", name);
- output.append(Console);
+ output.Append(Console);
isValid = false;
}
else if (waterType == WT_WHIRLPOOL)
@@ -157,7 +157,7 @@ void PokeGen::PokeMod::Tile::Validate(const wxListBox &output) if (!curPokeMod.GetTile(underWater))
{
LogVarNotValid("Tile", id, "underWater", name);
- output.append(Console);
+ output.Append(Console);
isValid = false;
}
}
@@ -167,7 +167,7 @@ void PokeGen::PokeMod::Tile::Validate(const wxListBox &output) if (!curPokeMod.GetTile(underCut))
{
LogVarNotValid("Tile", id, "underCut", name);
- output.append(Console);
+ output.Append(Console);
isValid = false;
}
}
@@ -178,7 +178,7 @@ void PokeGen::PokeMod::Tile::Validate(const wxListBox &output) if (DIR_END <= forceDirection)
{
LogVarNotValid("Tile", id, "forceDirection", name);
- output.append(Console);
+ output.Append(Console);
isValid = false;
}
}
@@ -186,7 +186,7 @@ void PokeGen::PokeMod::Tile::Validate(const wxListBox &output) else
{
LogVarNotValid("Tile", id, "forceType", name);
- output.append(Console);
+ output.Append(Console);
isValid = false;
}
LogValidateOver("Tile", id, isValid, name);
@@ -199,7 +199,6 @@ void PokeGen::PokeMod::Tile::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("Tile");
}
@@ -232,7 +231,6 @@ void PokeGen::PokeMod::Tile::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::Tile::ExportIni(std::ofstream &fout) const
{
LogExportStart("Tile", id, name);
- // Make elements
Ini exTile("Tile");
exTile.AddField("id", id);
exTile.AddField("name", name);
diff --git a/pokemod/Time.cpp b/pokemod/Time.cpp index ea49bac0..2e6fc6ab 100644 --- a/pokemod/Time.cpp +++ b/pokemod/Time.cpp @@ -24,9 +24,9 @@ #include "Time.h"
PokeGen::PokeMod::Time::Time(const unsigned _id) :
- name(""),
- startHour(0),
- startMinute(0)
+ name(""),
+ startHour(0),
+ startMinute(0)
{
LogCtor("Time", id);
id = _id;
@@ -98,7 +98,6 @@ void PokeGen::PokeMod::Time::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("Time");
}
@@ -113,7 +112,6 @@ void PokeGen::PokeMod::Time::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::Time::ExportIni(std::ofstream &fout) const
{
LogExportStart("Time", id, name);
- // Make elements
Ini exTime("time");
exTime.AddField("id", id);
exTime.AddField("name", name);
diff --git a/pokemod/Type.cpp b/pokemod/Type.cpp index 5af815bf..c0b568c2 100644 --- a/pokemod/Type.cpp +++ b/pokemod/Type.cpp @@ -24,8 +24,8 @@ #include "Type.h"
PokeGen::PokeMod::Type::Type(const unsigned _id) :
- name(""),
- stab(false)
+ name(""),
+ stab(false)
{
LogCtor("Type", _id);
id = _id;
@@ -89,7 +89,6 @@ void PokeGen::PokeMod::Type::ImportIni(Ini &ini, const unsigned _id) void PokeGen::PokeMod::Type::ExportIni(std::ofstream &fout) const
{
LogExportStart("Type", id, name);
- // Declare the elements
Ini exType("type");
exType.AddField("id", id);
exType.AddField("name", name);
|
