Compare Code

From: Mark Garringer (zizazat@HOTMAIL.COM)
Date: 10/18/02


I have been trying to improve upon the do_compare code which has been
posted to the developer site for some time. Mainly, I want to be able to
compare against objects that are already equiped.

I got the first argument to be either from inventory or equiped, and I
thought the second argument would be easy too. However, I am getting some
very strange results which I cannot seem to figure out.


> eq
You are using:
<wielded>            a dagger
<held>               a sword

> compare dagger sword
Debug2: You do not have that item.

> compare sword dagger
A sword looks better than a dagger.


So, in the first example when I compare the dagger to the sword it cannot
correctly locate the sword object in the held position. But when I reverse
the arguemnts it works just fine and finds both objects?!?!?

  if (!(obj2 = get_obj_in_list_vis(ch, arg2, NULL, ch->carrying))) {
    for (j = 0; j < NUM_WEARS && !found; j++)
      if (GET_EQ(ch, j) && CAN_SEE_OBJ(ch, GET_EQ(ch, j))) {
        if (isname(arg2, GET_EQ(ch, j)->name)) {
          obj2 = GET_EQ(ch, j);
          found = TRUE;
        } else {
          send_to_char(ch, "Debug2: You do not have that item.\n\r");
          return;
        }
      }
  }

Can someone please show me the error of my ways?

--Ziz

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT