Re: [Code] Object sorting in inv & vis

From: Scott B. Clifford (scott@youssef.cyberportal.net)
Date: 12/01/96


in act.informative.c chane list_obj_to_char to this

void list_obj_to_char(struct obj_data * list, struct char_data * ch, int mode,
		           bool show)
{
  struct obj_data *i, *j;
  char buf[10];
  bool found;
  int num;

  found = FALSE;
  for (i = list; i; i = i->next_content) {
      num = 0;
      for (j = list; j != i; j = j->next_content)
	if (j->item_number==NOTHING) {
	    if(strcmp(j->short_description,i->short_description)==0) break;
	}
	else if (j->item_number==i->item_number) break;
      if (j!=i) continue;
      for (j = i; j; j = j->next_content)
	if (j->item_number==NOTHING) {
	    if(strcmp(j->short_description,i->short_description)==0) num++;
	  }
	else if (j->item_number==i->item_number) num++;

      if (CAN_SEE_OBJ(ch, i)) {
	  if (num!=1) {
		sprintf(buf,"(%2i) ",num);
		send_to_char(buf,ch);
	    }
	  show_obj_to_char(i, ch, mode);
	  found = TRUE;
      }
  }
  if (!found && show)
    send_to_char(" Nothing.\r\n", ch);
}

Malcor :)

At 03:00 PM 12/1/96 -0500, you wrote:
>First off I'd like to thank everyone for being so free with their advince
>and suggestions (even though I've been a silent subscriber most of the
>time, other peoples tips have solved many problems).  Off with that, here
>is my problem =), I was wondering if anyone had a solution to the problem
>of object sorting so that:
>
>a bread
>a bread
>a bread
>
>would be:
>
>(3x) a bread
>
>I would greatly appreciate any help in the matter.
>
>claywar! (morgaelin - coming this winter after almost a year of hard work)
>
>+-----------------------------------------------------------+
>| Ensure that you have read the CircleMUD Mailing List FAQ: |
>|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
>+-----------------------------------------------------------+
>

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST