[newbie][code][dummy]Can anyone help me?

From: Anthony Benjamin a.k.a. Phreak404 (benjamin@powerweb.net)
Date: 03/21/99


I am not a very good C coder and I was wondering if anyone could help me
with the following...
Can anyone see anything wrong with this code?? it worked pretty ok,
until I added the little  if(EXIT(ch, dir)) which I thought would check
to make sure it was a valid direction...another problem is if I try to
scan twice in a row...nothing happens..it freezes the mud...doesn't
crash but altogether freezes. Any help!???!?

anthony


ACMD(do_scan){

struct char_data *i;
  int is_in, dir, dis, maxdis, found = 0;


  if (IS_AFFECTED(ch, AFF_BLIND)) {
    act("You can't see anything, you're blind!", TRUE, ch, 0, 0,
TO_CHAR);
    return;
  }
  is_in = ch->in_room;

  for (dir = 0; dir < NUM_OF_DIRS; dir++) {
    char_from_room(ch);
    char_to_room(ch, world[is_in].dir_option[dir]->to_room);
    if(EXIT(ch, dir)){
  for (i = world[ch->in_room].people; i; i = i->next_in_room) {
     if (!(ch == i) && CAN_SEE(ch, i)) {
      switch(dir){
     case 0:
     sprintf(buf, "Looking north:\r\n%s is here.\r\n", GET_NAME(i));
     send_to_char(buf,ch);
     found++;
     break;
      case 1:
     sprintf(buf, "Looking east:\r\n%s is here.\r\n", GET_NAME(i));
     send_to_char(buf,ch);
     found++;
     break;
      case 2:
     sprintf(buf, "Looking south:\r\n%s is here.\r\n", GET_NAME(i));
     send_to_char(buf,ch);
     found++;
     break;
      case 3:
     sprintf(buf, "Looking west:\r\n%s is here.\r\n", GET_NAME(i));
     send_to_char(buf,ch);
     found++;
     break;
      case 4:
     sprintf(buf, "Looking up:\r\n%s is here.\r\n", GET_NAME(i));
     send_to_char(buf,ch);
     found++;
     break;
      case 5:
     sprintf(buf, "Looking down:\r\n%s is here.\r\n", GET_NAME(i));
     send_to_char(buf,ch);
     found++;
     break;
      default:
       send_to_char("This is an error!",ch);
       break;
    }
     }
     }
 }
  }

   if (found == 0)
    act("Nobody anywhere near you.", TRUE, ch, 0, 0, TO_CHAR);
IN_ROOM(ch) = is_in;
}


     +------------------------------------------------------------+
     | 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 : 12/15/00 PST