summaryrefslogtreecommitdiffstats
path: root/pokemod/Store.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-06-01 02:54:29 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-06-01 02:54:29 +0000
commitf71140fae5218ee9839ffcd4ec83abfded5124f4 (patch)
tree9af8f2174728cedb93580411223bc59fd9a86d0a /pokemod/Store.cpp
parent9e28e6ecd358a9801ad25914d3e8cca7b6d7f4f7 (diff)
downloadsigen-f71140fae5218ee9839ffcd4ec83abfded5124f4.tar.gz
sigen-f71140fae5218ee9839ffcd4ec83abfded5124f4.tar.xz
sigen-f71140fae5218ee9839ffcd4ec83abfded5124f4.zip
Added Map and Tile, added Hat class, and fixed up some other minor things
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@17 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Store.cpp')
-rw-r--r--pokemod/Store.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/pokemod/Store.cpp b/pokemod/Store.cpp
index 514e6459..7f5936c2 100644
--- a/pokemod/Store.cpp
+++ b/pokemod/Store.cpp
@@ -48,7 +48,6 @@ PokeGen::PokeMod::Store::~Store()
void PokeGen::PokeMod::Store::Validate()
{
- isValid = true;
LogValidateStart("Store", id, name);
if (name == "")
{
@@ -69,7 +68,6 @@ void PokeGen::PokeMod::Store::Validate()
#ifdef PG_DEBUG_WINDOW
void PokeGen::PokeMod::Store::Validate(const wxListBox &output)
{
- isValid = true;
LogValidateStart("Store", id, name);
if (name == "")
{
@@ -142,21 +140,19 @@ PokeGen::PokeMod::String PokeGen::PokeMod::Store::GetName()
return name;
}
-int PokeGen::PokeMod::Store::GetItem(const unsigned i) const
+unsigned PokeGen::PokeMod::Store::GetItem(const unsigned i) const
{
LogSubmoduleFetch("Store", id, "item", i, name);
- if (GetItemCount() <= i)
- {
- LogSubmoduleFetchFail("Store", id, "item", i, name);
- return -1;
- }
- return items[i];
+ if (i < GetItemCount() <= i)
+ return items[i];
+ LogSubmoduleFetchFail("Store", id, "item", i, name);
+ return UINT_MAX;
}
bool PokeGen::PokeMod::Store::HasItem(const unsigned _id) const
{
LogSubmoduleFetch("Store", id, "item", _id, name);
- return (GetItem(_id) != -1);
+ return (GetItem(_id) != UINT_MAX);
}
bool PokeGen::PokeMod::Store::HasItem(const String &n) const
@@ -179,17 +175,34 @@ unsigned PokeGen::PokeMod::Store::GetItemCount() const
void PokeGen::PokeMod::Store::NewItem(const unsigned i)
{
- LogSubmoduleNew("Store", id, "item", items.size());
- items.push_back(i);
+ LogSubmoduleNew("Store", id, "item", i);
+ if (curPokeMod.GetItem(i))
+ items.push_back(i);
+}
+
+void PokeGen::PokeMod::Store::NewItem(const String &i)
+{
+ LogSubmoduleNew("Store", id, "item", i);
+ if (Item *temp = curPokeMod.GetItem(i))
+ items.push_back(temp->GetId());
}
void PokeGen::PokeMod::Store::DeleteItem(const unsigned i)
{
LogSubmoduleRemoveStart("Store", id, "item", i, name);
- if (GetItemCount() <= i)
+ if (i < GetItemCount())
+ DeleteItemByID(items[i]);
+ else
LogSubmoduleRemoveFail("Store", id, "item", i, name);
+}
+
+void PokeGen::PokeMod::Store::DeleteItem(const String &n)
+{
+ LogSubmoduleRemoveStart("Store", id, "item", n, name);
+ if (Item *i = curPokeMod.GetItem(n))
+ DeleteItemByID(i->GetId());
else
- DeleteItemByID(items[i]);
+ LogSubmoduleRemoveFail("Store", id, "item", n, name);
}
void PokeGen::PokeMod::Store::DeleteItemByID(const unsigned _id)