Re: targeting worn object bug

From: George Greer (greerga@circlemud.org)
Date: 04/18/01


On Wed, 18 Apr 2001, Kras Kresh wrote:

>This is a pl18 bug, so ignore this if you are not using it.
>I seemed to have fixed the bug in which you can't do remove #.item.
>Also, this also seems to fix the do_stat bug in which if you want to
>stat something with the same alias as the object you wear, you only
>get the first one. The fix provided to me by George Greer for the stat bug
>didn't fix it but I'll include it because it looks right. If anyone can
>improve on my code please send me a copy.

Oh yeah, that was the 2nd half of the fix. ('stat obj') Here's a semi-patch
format for the do_remove part. Basically, get_obj_pos_in_equip_vis() wasn't
number-ized because of it's historical baggage.

--- act.item.c  2001/01/26 00:50:43     1.36
+++ act.item.c  2001/04/11 00:07:16
@@ -1475,8 +1472,7 @@ ACMD(do_remove)
       }
     }
   } else {
-    /* Returns object pointer but we don't need it, just true/false. */
-    if (!get_object_in_equip_vis(ch, arg, ch->equipment, &i)) {
+    if ((i = get_obj_pos_in_equip_vis(ch, arg, NULL, ch->equipment)) <
0) {
       sprintf(buf, "You don't seem to be using %s %s.\r\n", AN(arg), arg);
       send_to_char(buf, ch);
     } else

Then to handler.c:

-struct obj_data *get_object_in_equip_vis(struct char_data * ch, char *arg,
struct obj_data *equipment[], int *j)
+struct obj_data *get_obj_in_equip_vis(struct char_data * ch, char *arg,
int *numbr, struct obj_data *equipment[])
 {
-  for ((*j) = 0; (*j) < NUM_WEARS; (*j)++)
-    if (equipment[(*j)])
-      if (CAN_SEE_OBJ(ch, equipment[(*j)]))
-       if (isname(arg, equipment[(*j)]->name))
-         return (equipment[(*j)]);
+  int j, num;
+
+  if (!numbr) {
+    numbr = &num;
+    num = get_number(&arg);
+  }
+
+  if (*numbr == 0)
+    return (NULL);
+
+  for (j = 0; j < NUM_WEARS; j++)
+    if (equipment[j] && CAN_SEE_OBJ(ch, equipment[j]) && isname(arg,
equipment[j]->name))
+      if (--(*numbr) == 0)
+        return (equipment[j]);

   return (NULL);
 }


+int get_obj_pos_in_equip_vis(struct char_data * ch, char *arg, int *numbr,
struct obj_data *equipment[])
+{
+  int j, num;
+
+  if (!numbr) {
+    numbr = &num;
+    num = get_number(&arg);
+  }
+
+  if (*numbr == 0)
+    return (-1);
+
+  for (j = 0; j < NUM_WEARS; j++)
+    if (equipment[j] && CAN_SEE_OBJ(ch, equipment[j]) && isname(arg,
equipment[j]->name))
+      if (--(*numbr) == 0)
+        return (j);
+
+  return (-1);
+}

--
George Greer
greerga@circlemud.org

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST