[CODE][LONG] look_at_target from the dynamic boards patch (against stock+oasis)

From: Tony Robbins (tonyr@NWPACLINK.COM)
Date: 03/08/98


Ok, I was pretty well flamed yesterday when I was looking for help, but
I
am going to try again.  The look_at_target that is made after the
dynamic boards
2.2 is put in has one medium sized bug:  You can only read stuff in a
room
that has a board in it.

I have worked for 24 hours (nearly 16 straight on this one thing) and
have
thoroughly worn out my brain.

Anyway, here is strange part of look_at_target
void look_at_target(struct char_data * ch, char *arg, int read)
{
  int bits, found = 0, j, msg=1;
  struct char_data *found_char = NULL;
  struct obj_data *obj = NULL, *found_obj = NULL;
  char *desc;
  char number[MAX_STRING_LENGTH];

  if (!ch->desc)
    return;

  if (!*arg) {
    send_to_char("Look at what?\r\n", ch);
    return;
  }

/* start problem */
  if (read) {
    for (obj = ch->carrying; obj;obj=obj->next_content) {
      if (GET_OBJ_TYPE(obj) == ITEM_BOARD) {
        found=1;
        break;
      }
    }
    if(!obj) {

      for (obj = world[ch->in_room].contents; obj;obj=obj->next_content)
{
        if (GET_OBJ_TYPE(obj) == ITEM_BOARD) {
          found=1;
          break;
        }
      }
    }
    if (obj) {
      arg = one_argument(arg, number);
      if (!*number)
        send_to_char("Read what?\r\n",ch);
      if (isname(number, obj->name)) {
        Board_show_board(GET_OBJ_VNUM(obj), ch);
      }
       /* Okay, here i'm faced with the fact that the person could be
        entering in something like 'read 5' or 'read 4.mail' .. so,
whats the
        difference between the two?  Well, there's a period in the
second,
        so, we'll just stick with that basic difference */
      else if ((!isdigit(*number) || (!(msg = atoi(number)))) ||
                (strchr(number,'.'))) {
        sprintf(arg,"%s %s", number,arg);
        look_at_target(ch, arg, 0);
      }      arg = one_argument(arg, number);
      if (!*number)
        send_to_char("Read what?\r\n",ch);
      if (isname(number, obj->name)) {
        Board_show_board(GET_OBJ_VNUM(obj), ch);
      }
       /* Okay, here i'm faced with the fact that the person could be
        entering in something like 'read 5' or 'read 4.mail' .. so,
whats the
        difference between the two?  Well, there's a period in the
second,
        so, we'll just stick with that basic difference */
      else if ((!isdigit(*number) || (!(msg = atoi(number)))) ||
                (strchr(number,'.'))) {
        sprintf(arg,"%s %s", number,arg);
        look_at_target(ch, arg, 0);
      }
      else {
        Board_display_msg(GET_OBJ_VNUM(obj), ch, msg);
      }
    }
  }
/* the problem only exists with read, so it's here up */
  else {

  bits = generic_find(arg, FIND_OBJ_INV | FIND_OBJ_ROOM | FIND_OBJ_EQUIP
|
                      FIND_CHAR_ROOM, ch, &found_char, &found_obj);

  /* Is the target a character? */
  if (found_char != NULL) {
    look_at_char(found_char, ch);
    if (ch != found_char) {
      if (CAN_SEE(found_char, ch))
        act("$n looks at you.", TRUE, ch, 0, found_char, TO_VICT);
      act("$n looks at $N.", TRUE, ch, 0, found_char, TO_NOTVICT);
    return;
  }
  /* Does the argument match an extra desc in the room? */
  if ((desc = find_exdesc(arg, world[ch->in_room].ex_description)) !=
NULL) {
    page_string(ch->desc, desc, 0);
    return;
  }
  /* Does the argument match an extra desc in the char's equipment? */
  for (j = 0; j < NUM_WEARS && !found; j++)
    if (GET_EQ(ch, j) && CAN_SEE_OBJ(ch, GET_EQ(ch, j)))
      if ((desc = find_exdesc(arg, GET_EQ(ch, j)->ex_description)) !=
NULL) {
          send_to_char(desc,ch);
        found = 1;
      }
  /* Does the argument match an extra desc in the char's inventory? */
  for (obj = ch->carrying; obj && !found; obj = obj->next_content) {
    if (CAN_SEE_OBJ(ch, obj))
        if ((desc = find_exdesc(arg, obj->ex_description)) != NULL) {
        if(GET_OBJ_TYPE(obj) == ITEM_BOARD) {
          Board_show_board(GET_OBJ_VNUM(obj), ch);
        } else
          send_to_char(desc, ch);
        found = 1;
      }
  }

  /* Does the argument match an extra desc of an object in the room? */
  for (obj = world[ch->in_room].contents; obj && !found; obj =
obj->next_content)
    if (CAN_SEE_OBJ(ch, obj))
      if ((desc = find_exdesc(arg, obj->ex_description)) != NULL) {
        if(GET_OBJ_TYPE(obj) == ITEM_BOARD) {
          Board_show_board(GET_OBJ_VNUM(obj), ch);

      else {        } else
          send_to_char(desc, ch);
        found = 1;
      }
  if (bits) {                   /* If an object was found back in
                                 * generic_find */
    if (!found)
      show_obj_to_char(found_obj, ch, 5);       /* Show no-description
*/
    else
      show_obj_to_char(found_obj, ch, 6);       /* Find hum, glow etc */
  } else if (!found)
    send_to_char("You do not see that here.\r\n", ch);
 }
}

I'm sorry for the trouble, maybe you can help....  Thanks
-B.


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



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