[Top][All Lists]
[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);
//@}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-commits] CVS: adonthell/src inventory.cc,1.3,1.4 inventory.h,1.8,1.9,
Kai Sterker <address@hidden> <=
- Prev by Date:
[Adonthell-commits] CVS: adonthell/src item_storage.cc,NONE,1.1 item_storage.h,NONE,1.1 Makefile.am,1.100,1.101 inventory.cc,1.2,1.3 inventory.h,1.7,1.8 item_base.cc,1.5,1.6 item_base.h,1.5,1.6 py_adonthell.i,1.36,1.37 slot.cc,1.1,1.2 slot.h,1.1,1.2
- Next by Date:
[Adonthell-commits] CVS: adonthell/src inventory.cc,1.4,1.5 item_base.cc,1.6,1.7 item_base.h,1.6,1.7 item_storage.cc,1.1,1.2 py_adonthell.i,1.37,1.38 slot.cc,1.2,1.3 slot.h,1.2,1.3
- Previous by thread:
[Adonthell-commits] CVS: adonthell/src item_storage.cc,NONE,1.1 item_storage.h,NONE,1.1 Makefile.am,1.100,1.101 inventory.cc,1.2,1.3 inventory.h,1.7,1.8 item_base.cc,1.5,1.6 item_base.h,1.5,1.6 py_adonthell.i,1.36,1.37 slot.cc,1.1,1.2 slot.h,1.1,1.2
- Next by thread:
[Adonthell-commits] CVS: adonthell/src inventory.cc,1.4,1.5 item_base.cc,1.6,1.7 item_base.h,1.6,1.7 item_storage.cc,1.1,1.2 py_adonthell.i,1.37,1.38 slot.cc,1.2,1.3 slot.h,1.2,1.3
- Index(es):