Re: [CODE][BUG?] Bug in the stock (pl17) do_examine function?

From: Adam Scriven (scriven@lore.com)
Date: 09/27/00


On Wed, Sep 27, 2000 at 11:55:57PM -0400, Adam Scriven wrote:
> While I was hacking around with the multi-exit stuff, playing with the code
> (pl17 + random typo and multi-exits), I tried to fix a bug that I found.
>
> Here's the bug:
> You can examine a container, like a bag, and it gives you the result of the
> examine ("...nothing special", perhaps), and then says what's inside.
> This part works like a charm.
>
> The problem is, if you "examine 2.bag", it gives you the contents of
> the first bag, no matter what happens.
>
> This happens with not only containers that you're holding, but that are in
> a room as well (multiple corpses, for instance).

(snipped)

> I'll try and hack around a bit more myself (my c's very rusty, so this may
> take a while. 8-) ), but if there's a ready fix available, I'd also love a
> pointer to it.

I hate to reply to my own posts, but I think I found the bug.

The function look_at_target strips any leading "number." stuff from the
passed argument pointer, so that it can't be used later.

I've done some experiments, and the "argument" variable (compare with the
"arg" variable in the function) keeps the "number." stuff.

So what I did was change this:

  look_at_target(ch, arg);

  generic_find(arg, FIND_OBJ_INV | FIND_OBJ_ROOM | FIND_CHAR_ROOM |
                      FIND_OBJ_EQUIP, ch, &tmp_char, &tmp_object);

  if (tmp_object) {
    if ((GET_OBJ_TYPE(tmp_object) == ITEM_DRINKCON) ||
        (GET_OBJ_TYPE(tmp_object) == ITEM_FOUNTAIN) ||
        (GET_OBJ_TYPE(tmp_object) == ITEM_CONTAINER)) {
      send_to_char("When you look inside, you see:\r\n", ch);
      look_in_obj(ch, arg);
    }

to this:

  look_at_target(ch, arg);

  generic_find(argument, FIND_OBJ_INV | FIND_OBJ_ROOM | FIND_CHAR_ROOM |
                      FIND_OBJ_EQUIP, ch, &tmp_char, &tmp_object);

  if (tmp_object) {
    if ((GET_OBJ_TYPE(tmp_object) == ITEM_DRINKCON) ||
        (GET_OBJ_TYPE(tmp_object) == ITEM_FOUNTAIN) ||
        (GET_OBJ_TYPE(tmp_object) == ITEM_CONTAINER)) {
      send_to_char("When you look inside, you see:\r\n", ch);
      look_in_obj(ch, argument);
    }


It seems to work OK.  If anyone more familiar with the code than me can
think of a reason why I shouldn't do this, please LMK!

I hope this helps!
Thanks!
Adam


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/11/01 PDT