adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-commits] CVS: adonthell/src inventory.cc,1.3,1.4 inventory.h


From: Kai Sterker <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src inventory.cc,1.3,1.4 inventory.h,1.8,1.9
Date: Tue, 11 Feb 2003 16:00:38 -0500

Update of /cvsroot/adonthell/adonthell/src
In directory subversions:/tmp/cvs-serv336

Modified Files:
        inventory.cc inventory.h 
Log Message:
ADDED handling of unlimited invetories

Index: inventory.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/inventory.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** inventory.cc        11 Feb 2003 19:59:26 -0000      1.3
--- inventory.cc        11 Feb 2003 21:00:35 -0000      1.4
***************
*** 86,89 ****
--- 86,92 ----
  u_int32 inventory::add (item_base *item, const u_int32 & count)
  {
+     // nothing to do
+     if (count == 0) return 0;
+     
      std::vector<slot*>::iterator i;
      s_int32 remaining = count;
***************
*** 108,113 ****
          } 
  
      // return how many items didn't fit
!     return remaining;  
  }
  
--- 111,129 ----
          } 
  
+     // if there are still items left, grow inventory if allowed
+     if (remaining && !Limited)
+     {
+         slot *s;
+         
+         while (remaining)
+         {
+             s = new slot (this);
+             remaining = s->add (item, remaining);
+             Slots.push_back (s);
+         }
+     }
+     
      // return how many items didn't fit
!     return remaining;
  }
  
***************
*** 123,126 ****
--- 139,145 ----
      for (i = Slots.begin (); i != Slots.end (); i++)
      {
+         // in case of unlimited inventory, don't bother with saving empty 
slots
+         if (!Limited && (*i)->count () == 0) continue;
+         
          true >> file;
          (*i)->put_state (file);

Index: inventory.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/inventory.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** inventory.h 11 Feb 2003 19:59:26 -0000      1.8
--- inventory.h 11 Feb 2003 21:00:35 -0000      1.9
***************
*** 117,121 ****
       * @return the number of items that did not fit.
       */
!     u_int32 add (item_base *item, const u_int32 & count);
      //@}
      
--- 117,121 ----
       * @return the number of items that did not fit.
       */
!     u_int32 add (item_base *item, const u_int32 & count = 1);
      //@}
      





reply via email to

[Prev in Thread] Current Thread [Next in Thread]