Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

scan.c

Go to the documentation of this file.
00001 /***************************************************************************
00002  *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
00003  *  Michael Seifert, Hans Henrik Strfeldt, Tom Madsen, and Katja Nyboe.    *
00004  *                                                                         *
00005  *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael          *
00006  *  Chastain, Michael Quan, and Mitchell Tse.                              *
00007  *                                                                         *
00008  *  In order to use any part of this Merc Diku Mud, you must comply with   *
00009  *  both the original Diku license in 'license.doc' as well the Merc       *
00010  *  license in 'license.txt'.  In particular, you may not remove either of *
00011  *  these copyright notices.                                               *
00012  *                                                                         *
00013  *  Much time and thought has gone into this software and you are          *
00014  *  benefitting.  We hope that you share your changes too.  What goes      *
00015  *  around, comes around.                                                  *
00016  ***************************************************************************/
00017 
00018 /***************************************************************************
00019  *  ROM 2.4 is copyright 1993-1998 Russ Taylor                             *
00020  *  ROM has been brought to you by the ROM consortium                      *
00021  *      Russ Taylor (rtaylor@hypercube.org)                                *
00022  *      Gabrielle Taylor (gtaylor@hypercube.org)                           *
00023  *      Brian Moore (zump@rom.org)                                         *
00024  *  By using this code, you have agreed to follow the terms of the         *
00025  *  ROM license, in the file Rom24/doc/rom.license                         *
00026  ***************************************************************************/
00027 
00028 #if defined(macintosh)
00029 #include <types.h>
00030 #else
00031 #include <sys/types.h>
00032 #endif
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #include <string.h>
00036 #include <time.h>
00037 #include "merc.h"
00038 
00039 char *const distance[4] = {
00040     "right here.", "nearby to the %s.", "not far %s.",
00041     "off in the distance %s."
00042 };
00043 
00044 void scan_list args ((ROOM_INDEX_DATA * scan_room, CHAR_DATA * ch,
00045                       sh_int depth, sh_int door));
00046 void scan_char args ((CHAR_DATA * victim, CHAR_DATA * ch,
00047                       sh_int depth, sh_int door));
00048 void do_scan (CHAR_DATA * ch, char *argument)
00049 {
00050     extern char *const dir_name[];
00051     char arg1[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH];
00052     ROOM_INDEX_DATA *scan_room;
00053     EXIT_DATA *pExit;
00054     sh_int door, depth;
00055 
00056     argument = one_argument (argument, arg1);
00057 
00058     if (arg1[0] == '\0')
00059     {
00060         act ("$n looks all around.", ch, NULL, NULL, TO_ROOM);
00061         send_to_char ("Looking around you see:\n\r", ch);
00062         scan_list (ch->in_room, ch, 0, -1);
00063 
00064         for (door = 0; door < 10; door++)
00065         {
00066             if ((pExit = ch->in_room->exit[door]) != NULL)
00067                 scan_list (pExit->u1.to_room, ch, 1, door);
00068         }
00069         return;
00070     }
00071     else if (!str_cmp (arg1, "n") || !str_cmp (arg1, "north"))
00072         door = 0;
00073     else if (!str_cmp (arg1, "e") || !str_cmp (arg1, "east"))
00074         door = 1;
00075     else if (!str_cmp (arg1, "s") || !str_cmp (arg1, "south"))
00076         door = 2;
00077     else if (!str_cmp (arg1, "w") || !str_cmp (arg1, "west"))
00078         door = 3;
00079     else if (!str_cmp (arg1, "u") || !str_cmp (arg1, "up"))
00080         door = 4;
00081     else if (!str_cmp (arg1, "d") || !str_cmp (arg1, "down"))
00082         door = 5;
00083  else if ( !str_cmp( arg1, "ne" ) || !str_cmp( arg1, "northeast"  ) )
00084 door = 6;
00085     else if ( !str_cmp( arg1, "nw" ) || !str_cmp( arg1, "northwest"  ) )
00086 door = 7;
00087     else if ( !str_cmp( arg1, "se" ) || !str_cmp( arg1, "southeast"  ) )
00088 door = 8;
00089     else if ( !str_cmp( arg1, "sw" ) || !str_cmp( arg1, "southwest"  ) )
00090 door = 9;
00091     
00092 else
00093     {
00094         send_to_char ("Which way do you want to scan?\n\r", ch);
00095         return;
00096     }
00097 
00098     act ("You peer intently $T.", ch, NULL, dir_name[door], TO_CHAR);
00099     act ("$n peers intently $T.", ch, NULL, dir_name[door], TO_ROOM);
00100     sprintf (buf, "Looking %s you see:\n\r", dir_name[door]);
00101 
00102     scan_room = ch->in_room;
00103 
00104     for (depth = 1; depth < 4; depth++)
00105     {
00106         if ((pExit = scan_room->exit[door]) != NULL)
00107         {
00108             scan_room = pExit->u1.to_room;
00109             scan_list (pExit->u1.to_room, ch, depth, door);
00110         }
00111     }
00112     return;
00113 }
00114 
00115 void scan_list (ROOM_INDEX_DATA * scan_room, CHAR_DATA * ch, sh_int depth,
00116                 sh_int door)
00117 {
00118     CHAR_DATA *rch;
00119 
00120     if (scan_room == NULL)
00121         return;
00122     for (rch = scan_room->people; rch != NULL; rch = rch->next_in_room)
00123     {
00124         if (rch == ch)
00125             continue;
00126         if (!IS_NPC (rch) && rch->invis_level > get_trust (ch))
00127             continue;
00128         if (can_see (ch, rch))
00129             scan_char (rch, ch, depth, door);
00130     }
00131     return;
00132 }
00133 
00134 void scan_char (CHAR_DATA * victim, CHAR_DATA * ch, sh_int depth, sh_int door)
00135 {
00136     extern char *const dir_name[];
00137     extern char *const distance[];
00138     char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
00139 
00140     buf[0] = '\0';
00141 
00142     strcat (buf, PERS (victim, ch));
00143     strcat (buf, ", ");
00144     sprintf (buf2, distance[depth], dir_name[door]);
00145     strcat (buf, buf2);
00146     strcat (buf, "\n\r");
00147 
00148     send_to_char (buf, ch);
00149     return;
00150 }

Generated on Thu Jan 13 21:48:14 2005 for Beyond the Shadows by  doxygen 1.4.0