]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/pouch.cpp
fixed some bugs
[irc/gameservirc.git] / gameserv / pouch.cpp
index 50e76a249fac3bcd39637ed3a92e35d6c79ef259..078ff42bce0be65fa41fa780b2d6863b89e9d2d5 100644 (file)
@@ -29,6 +29,22 @@ void pouch::sort()
   items.sort();
 }
 
+itemContainer *pouch::Find(int id)
+{
+  list<itemContainer>::iterator item_iter;
+  item_iter = items.begin();
+
+  while (item_iter != items.end())
+    {
+      if ((*item_iter).getItem()->getID() == id)
+       {
+         return &(*item_iter);
+       }
+      ++item_iter;
+    }
+  return NULL;
+}
+
 itemContainer *pouch::Find(char *n)
 {
   list<itemContainer>::iterator item_iter;
@@ -40,7 +56,7 @@ itemContainer *pouch::Find(char *n)
        {
          return &(*item_iter);
        }
-      item_iter++;
+      ++item_iter;
     }
   return NULL;
 }
@@ -56,7 +72,7 @@ itemContainer *pouch::Find(string &n)
         {
           return &(*item_iter);
         }
-      item_iter++;
+      ++item_iter;
     }
 
   return NULL;
@@ -68,12 +84,32 @@ itemContainer *pouch::addItem(item *i)
     {
       return NULL;
     }
-  itemContainer it(i);
+  itemContainer it(i), *temp;
   items.push_front(it);
   ++count;
+  temp = &items.front();
   sort();
-  return &items.front();
+  return temp;
 }
+
+itemContainer *pouch::addItem(item *i, int amt)
+{
+  if (count >= 3000 || count + amt >= maxitems)
+       {
+         return NULL;
+       }
+
+  itemContainer it(i), *temp;
+  for (int x=0; x < amt; x++)
+       {
+         items.push_front(it);
+         ++count;
+       }
+  temp = &items.front();
+  sort();
+  return temp;
+}
+
 itemContainer *pouch::addItemNoChecks(item *i)
 {
   itemContainer it(i);
@@ -86,7 +122,7 @@ void pouch::deleteItem(item *i)
 {
   list<itemContainer>::iterator item_iter;
   count--;
-
+  
   item_iter = find(items.begin(), items.end(), i);
   
   if (item_iter != items.end())