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

From: George Greer (greerga@circlemud.org)
Date: 03/21/99


On Sun, 21 Mar 1999, Anthony Benjamin a.k.a. Phreak404 wrote:

>ACMD(do_scan){
>
>struct char_data *i;
>  int is_in, dir, dis, maxdis, found = 0;
>
>
>  if (IS_AFFECTED(ch, AFF_BLIND)) {

For conformity it should be AFF_FLAGGED but otherwise they're the same.

>    act("You can't see anything, you're blind!", TRUE, ch, 0, 0, TO_CHAR);

send_to_char() for simple strings.

>    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);

Urk!

#define W_EXIT(room, num)       (world[(room)].dir_option[(num)])
#define R_EXIT(room, num)       ((room)->dir_option[(num)])

for (dir = 0; dir < NUM_OF_DIRS; dir++) {
   if (W_EXIT(EXIT(ch, dir)->to_room, dir) {
     ... etc ...
   }
}

>    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;

Urk!

if (ch != i && CAN_SEE(ch, i)) {
  sprintf(buf, "Looking %s:\r\n%s is here.\r\n, dirs[dir], GET_NAME(i));
  send_to_char(buf, ch);
  found++;
}

[..extra stuff snipped..]

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

Again, send_to_char(), and don't do the IN_ROOM() stuff if you take my
W_EXIT suggestion.

Don't see a lockup off-hand.

--
George Greer            | Shirak's CircleMUD for Windows help
greerga@circlemud.org   | http://www.connect.ab.ca/~rbmstrk/


     +------------------------------------------------------------+
     | 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