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

scrymud at wanfear.com scrymud at wanfear.com
Sat Dec 4 02:04:31 PST 2004


Author: eroper
Date: 2004-12-04 02:04:29 -0800 (Sat, 04 Dec 2004)
New Revision: 730

Modified:
   branches/version-2-1/mud/grrmud/server/misc.cc
Log:
Inventory listing are now less spammy.
--Khaav


Modified: branches/version-2-1/mud/grrmud/server/misc.cc
===================================================================
--- branches/version-2-1/mud/grrmud/server/misc.cc	2004-12-02 23:26:19 UTC (rev 729)
+++ branches/version-2-1/mud/grrmud/server/misc.cc	2004-12-04 10:04:29 UTC (rev 730)
@@ -2044,19 +2044,24 @@
              const short type_of_list) {
                                //outs the names object*
    Cell<object*> cell(lst);
+
+   //Can't use lst.head(cell) because of the const definition above.
+   //if there's a workaround, this is horrible. Thought about
+   //un-const'ing it but thought better of it.
+   Cell<object*> cnt_cell(lst);
+
    object*  obj_ptr;
    String buf(100);
+   String qty_str;
+   static int item_counts[NUMBER_OF_ITEMS + 1];
+   int id_num;
+   
 
    mudlog.log(TRC, "In out_inv.\n");
 
    if (pc.isUsingClient()) {
       pc.show("<ITEM_LIST>");
    }
-   /* KHAAVREN DELETE ME MARKER 
-   else if (pc.isUsingColor()) {
-      pc.show(*(pc.getObjListColor()));
-   }
-   */
 
    if (IsEmpty(lst) && type_of_list == OBJ_INV) {
       pc.show("        [empty]        \n");
@@ -2064,30 +2069,42 @@
          pc.show("</ITEM_LIST>");
       }
 
-   /* KHAAVREN DELETE ME MARKER 
-      else if (pc.isUsingColor()) {
-         pc.show(*(pc.getDefaultColor()));
-      }
-      */
-
       mudlog.log(DBG, "Done with out_inv (empty).\n");
       return;
    }//if
 
+   //set the counts to zero, then update them all.
+   memset(item_counts, 0, sizeof(int) * (NUMBER_OF_ITEMS + 1));
+   while ( (obj_ptr = cnt_cell.next()) ) {
+      item_counts[obj_ptr->getIdNum()]++;
+   }//while
+
    switch (type_of_list)
       {
       case ROOM_INV:
          while ((obj_ptr = cell.next())) {
 
             if (detect(pc.SEE_BIT, obj_ptr->OBJ_VIS_BIT)) {
+
+               id_num = obj_ptr->getIdNum();
+               if ( item_counts[id_num] == -1 ) {
+                  //already done it.
+                  continue;
+               } else if ( item_counts[id_num] > 1 ) {
+                  Sprintf(qty_str, "(%ix) ", item_counts[id_num]);
+               } else {
+                  qty_str = "";
+               }
+               item_counts[id_num] = -1;
+
                if (pc.shouldShowVnums()) {
                   char tmp[50];
                   sprintf(tmp, "%p: ", obj_ptr);
-                  Sprintf(buf, "   %s [%i] %P11 %S", tmp, obj_ptr->OBJ_NUM,
-                          &(obj_ptr->in_room_desc));
+                  Sprintf(buf, "   %s [%i] %P11 %S%S", tmp, obj_ptr->OBJ_NUM,
+                          &qty_str, &(obj_ptr->in_room_desc));
                }
                else {
-                  Sprintf(buf, "\t%S", &(obj_ptr->in_room_desc));
+                  Sprintf(buf, "\t%S%S", &qty_str, &(obj_ptr->in_room_desc));
                }
                buf.Cap();
 
@@ -2118,14 +2135,27 @@
       case OBJ_INV: case CRIT_INV:
          while ((obj_ptr = cell.next())) {
             if (detect(pc.SEE_BIT, obj_ptr->OBJ_VIS_BIT)) {
+
+               id_num = obj_ptr->getIdNum();
+               if ( item_counts[id_num] == -1 ) {
+                  //already done it.
+                  continue;
+               } else if ( item_counts[id_num] > 1 ) {
+                  Sprintf(qty_str, "(%ix) ", item_counts[id_num]);
+               } else {
+                  qty_str = "";
+               }
+               item_counts[id_num] = -1;
+
                if (pc.shouldShowVnums()) {
                   char tmp[50];
                   sprintf(tmp, "%p: ", obj_ptr);
-                  Sprintf(buf, "   %s [%i] %P11 %S", tmp, obj_ptr->OBJ_NUM,
-                          long_name_of_obj(*obj_ptr, ~0));
+                  Sprintf(buf, "   %s [%i] %P11 %S%S", tmp, obj_ptr->OBJ_NUM,
+                          &qty_str, long_name_of_obj(*obj_ptr, ~0));
                }
                else {
-                  Sprintf(buf, "\t%S", long_name_of_obj(*obj_ptr, ~0));
+                  Sprintf(buf, "\t%S%S", &qty_str,
+                        long_name_of_obj(*obj_ptr, ~0));
                }
 
                buf.Cap();
@@ -2162,11 +2192,6 @@
    if (pc.isUsingClient()) {
       pc.show("</ITEM_LIST>");
    }
-   /* KHAAVREN DELETE ME MARKER 
-   else if (pc.isUsingColor()) {
-      pc.show(*(pc.getDefaultColor()));
-   }
-   */
 
    mudlog.log(DBG, "Done with out_inv.\n");
 




More information about the ScryMUD mailing list