[ScryMUD] SVN Commit Info r735 - branches/version-2-1/mud/grrmud/server

scrymud at wanfear.com scrymud at wanfear.com
Sun Dec 5 17:35:49 PST 2004


Author: eroper
Date: 2004-12-05 17:35:48 -0800 (Sun, 05 Dec 2004)
New Revision: 735

Modified:
   branches/version-2-1/mud/grrmud/server/misc.cc
   branches/version-2-1/mud/grrmud/server/misc.h
Log:
When listing categorized inventory we now update the *real* inventory so that
things are in the same order (#.sw) as players would expect from the
inventory listing.
--Khaav


Modified: branches/version-2-1/mud/grrmud/server/misc.cc
===================================================================
--- branches/version-2-1/mud/grrmud/server/misc.cc	2004-12-05 18:25:15 UTC (rev 734)
+++ branches/version-2-1/mud/grrmud/server/misc.cc	2004-12-06 01:35:48 UTC (rev 735)
@@ -2059,15 +2059,15 @@
 
 
 
-void out_inv(const List<object*>& lst, critter& pc, 
+void out_inv(List<object*>& lst, critter& pc, 
              const short type_of_list, int is_board) {
                                //outs the names object*
 
    List<object*>* lst_ptr = NULL;
    int lst_idx;
 
-   List<object*> full_lst(lst);
-   Cell<object*> cell(full_lst);
+   List<object*> reordered_lst(NULL);
+   Cell<object*> cell(lst);
 
    List<object*> inv_weapons(NULL);
    List<object*> inv_armor(NULL);
@@ -2098,7 +2098,7 @@
 
    //when doing obj/crit inventory, MOBs walk these lists.
    List<object*>* mob_inv_lists[] = {
-      &full_lst,
+      &lst,
       NULL
    };
 
@@ -2131,7 +2131,7 @@
       pc.show("<ITEM_LIST>");
    }
 
-   if (IsEmpty(full_lst) && type_of_list == OBJ_INV) {
+   if (IsEmpty(lst) && type_of_list == OBJ_INV) {
       pc.show("        [empty]        \n");
       if (pc.isUsingClient()) {
          pc.show("</ITEM_LIST>");
@@ -2156,7 +2156,7 @@
                } else if (obj_ptr->isArmor()) {
                   inv_armor.append(obj_ptr);
                } else if (obj_ptr->isPotion()) {
-                  inv_consumables.append(obj_ptr);
+                  inv_potions.append(obj_ptr);
                } else if (obj_ptr->isFood()) {
                   inv_consumables.append(obj_ptr);
                } else if (obj_ptr->isContainer()) {
@@ -2175,9 +2175,27 @@
          }//switch
 
       }//while
-      full_lst.head(cell);
-   }
 
+      //if we're showing categories, we actually need to reorganize the real
+      //inventory so that get #.name works as players expect.
+      switch (type_of_list) {
+         case OBJ_INV:
+         case CRIT_INV:
+            lst_ptr = inv_lists[0];
+            lst_idx = 0;
+            while (lst_ptr) {
+               lst_ptr->head(cell);
+               while ( (obj_ptr = cell.next()) ) {
+                  reordered_lst.append(obj_ptr);
+               }
+               lst_ptr = inv_lists[++lst_idx];
+            }
+            lst = reordered_lst;
+      }//switch
+
+      lst.head(cell);
+   }//if (stack)
+
    switch (type_of_list)
       {
       case ROOM_INV:
@@ -2256,8 +2274,11 @@
             lst_ptr->head(cell);
 
             if ( stack  ) {
-               Sprintf(buf, "%s\n", inv_names[lst_idx]);
-               pc.show(buf, HL_OBJ_LIST);
+               if ( (obj_ptr = cell.next()) ) {
+                  Sprintf(buf, "%s\n", inv_names[lst_idx]);
+                  pc.show(buf, HL_OBJ_LIST);
+                  obj_ptr = cell.prev();
+               }
             }
 
             while ((obj_ptr = cell.next())) {

Modified: branches/version-2-1/mud/grrmud/server/misc.h
===================================================================
--- branches/version-2-1/mud/grrmud/server/misc.h	2004-12-05 18:25:15 UTC (rev 734)
+++ branches/version-2-1/mud/grrmud/server/misc.h	2004-12-06 01:35:48 UTC (rev 735)
@@ -110,7 +110,7 @@
 
 void out_str(const List<String*>& lst, critter& pc); 
 void out_crit(const List<critter*>& lst, critter& pc, int see_all = FALSE);
-void out_inv(const List<object*>& lst, critter& pc, const short l_type, const
+void out_inv(List<object*>& lst, critter& pc, const short l_type, const
       int is_board = false); 
          //outs the names object*, formats according to l_type
 




More information about the ScryMUD mailing list