mirror of
https://github.com/tbamud/tbamud.git
synced 2025-09-22 05:50:48 +02:00
Switch to using atoidx whenever we are handling an IDXTYPE. cleanup and linting of asciimap.c
This commit is contained in:
parent
9c5787129b
commit
b489a72c58
28 changed files with 478 additions and 422 deletions
|
@ -180,7 +180,7 @@ room_rnum find_target_room(struct char_data *ch, char *rawroomstr)
|
|||
}
|
||||
|
||||
if (isdigit(*roomstr) && !strchr(roomstr, '.')) {
|
||||
if ((location = real_room((room_vnum)atoi(roomstr))) == NOWHERE) {
|
||||
if ((location = real_room(atoidx(roomstr))) == NOWHERE) {
|
||||
send_to_char(ch, "No room exists with that number.\r\n");
|
||||
return (NOWHERE);
|
||||
}
|
||||
|
@ -1008,7 +1008,7 @@ ACMD(do_stat)
|
|||
if (!*buf2)
|
||||
room = &world[IN_ROOM(ch)];
|
||||
else {
|
||||
room_rnum rnum = real_room(atoi(buf2));
|
||||
room_rnum rnum = real_room(atoidx(buf2));
|
||||
if (rnum == NOWHERE) {
|
||||
send_to_char(ch, "That is not a valid room.\r\n");
|
||||
return;
|
||||
|
@ -1070,7 +1070,7 @@ ACMD(do_stat)
|
|||
print_zone(ch, zone_table[world[IN_ROOM(ch)].zone].number);
|
||||
return;
|
||||
} else {
|
||||
print_zone(ch, atoi(buf2));
|
||||
print_zone(ch, atoidx(buf2));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -1329,7 +1329,7 @@ ACMD(do_load)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((r_num = real_mobile(atoi(buf2))) == NOBODY) {
|
||||
if ((r_num = real_mobile(atoidx(buf2))) == NOBODY) {
|
||||
send_to_char(ch, "There is no monster with that number.\r\n");
|
||||
return;
|
||||
}
|
||||
|
@ -1351,7 +1351,7 @@ ACMD(do_load)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((r_num = real_object(atoi(buf2))) == NOTHING) {
|
||||
if ((r_num = real_object(atoidx(buf2))) == NOTHING) {
|
||||
send_to_char(ch, "There is no object with that number.\r\n");
|
||||
return;
|
||||
}
|
||||
|
@ -1392,7 +1392,7 @@ ACMD(do_vstat)
|
|||
|
||||
switch (LOWER(*buf)) {
|
||||
case 'm':
|
||||
if ((r_num = real_mobile(atoi(buf2))) == NOBODY) {
|
||||
if ((r_num = real_mobile(atoidx(buf2))) == NOBODY) {
|
||||
send_to_char(ch, "There is no monster with that number.\r\n");
|
||||
return;
|
||||
}
|
||||
|
@ -1402,7 +1402,7 @@ ACMD(do_vstat)
|
|||
extract_char(mob);
|
||||
break;
|
||||
case 'o':
|
||||
if ((r_num = real_object(atoi(buf2))) == NOTHING) {
|
||||
if ((r_num = real_object(atoidx(buf2))) == NOTHING) {
|
||||
send_to_char(ch, "There is no object with that number.\r\n");
|
||||
return;
|
||||
}
|
||||
|
@ -1411,19 +1411,19 @@ ACMD(do_vstat)
|
|||
extract_obj(obj);
|
||||
break;
|
||||
case 'r':
|
||||
sprintf(buf2, "room %d", atoi(buf2));
|
||||
sprintf(buf2, "room %d", atoidx(buf2));
|
||||
do_stat(ch, buf2, 0, 0);
|
||||
break;
|
||||
case 'z':
|
||||
sprintf(buf2, "zone %d", atoi(buf2));
|
||||
sprintf(buf2, "zone %d", atoidx(buf2));
|
||||
do_stat(ch, buf2, 0, 0);
|
||||
break;
|
||||
case 't':
|
||||
sprintf(buf2, "%d", atoi(buf2));
|
||||
sprintf(buf2, "%d", atoidx(buf2));
|
||||
do_tstat(ch, buf2, 0, 0);
|
||||
break;
|
||||
case 's':
|
||||
sprintf(buf2, "shops %d", atoi(buf2));
|
||||
sprintf(buf2, "shops %d", atoidx(buf2));
|
||||
do_show(ch, buf2, 0, 0);
|
||||
break;
|
||||
default:
|
||||
|
@ -3618,7 +3618,7 @@ ACMD(do_zcheck)
|
|||
if (!is_number(buf) || !strcmp(buf, "."))
|
||||
zrnum = world[IN_ROOM(ch)].zone;
|
||||
else
|
||||
zrnum = real_zone(atoi(buf));
|
||||
zrnum = real_zone(atoidx(buf));
|
||||
|
||||
if (zrnum == NOWHERE) {
|
||||
send_to_char(ch, "Check what zone ?\r\n");
|
||||
|
@ -4179,17 +4179,17 @@ ACMD(do_checkloadstatus)
|
|||
}
|
||||
|
||||
if (LOWER(*buf1) == 'm') {
|
||||
mob_checkload(ch, atoi(buf2));
|
||||
mob_checkload(ch, atoidx(buf2));
|
||||
return;
|
||||
}
|
||||
|
||||
if (LOWER(*buf1) == 'o') {
|
||||
obj_checkload(ch, atoi(buf2));
|
||||
obj_checkload(ch, atoidx(buf2));
|
||||
return;
|
||||
}
|
||||
|
||||
if (LOWER(*buf1) == 't') {
|
||||
trg_checkload(ch, atoi(buf2));
|
||||
trg_checkload(ch, atoidx(buf2));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -4288,7 +4288,7 @@ ACMD(do_zpurge)
|
|||
if (*arg == '.' || !*arg) {
|
||||
zone = world[IN_ROOM(ch)].zone;
|
||||
} else if (is_number(arg)) {
|
||||
zone = real_zone(atoi(arg));
|
||||
zone = real_zone(atoidx(arg));
|
||||
if (zone == NOWHERE || zone > top_of_zone_table) {
|
||||
send_to_char(ch, "That zone doesn't exist!\r\n");
|
||||
return;
|
||||
|
@ -4802,7 +4802,7 @@ ACMD(do_zlock)
|
|||
send_to_char(ch, "There are currently no locked zones!\r\n");
|
||||
}
|
||||
return;
|
||||
} else if ((znvnum = atoi(arg)) == 0) {
|
||||
} else if ((znvnum = atoidx(arg)) == NOWHERE) {
|
||||
send_to_char(ch, "Usage: %szlock <zone number>%s\r\n", QYEL, QNRM);
|
||||
return;
|
||||
}
|
||||
|
@ -4895,7 +4895,7 @@ ACMD(do_zunlock)
|
|||
send_to_char(ch, "There are currently no unlocked zones!\r\n");
|
||||
}
|
||||
return;
|
||||
} else if ((znvnum = atoi(arg)) == 0) {
|
||||
} else if ((znvnum = atoidx(arg)) == NOWHERE) {
|
||||
send_to_char(ch, "Usage: %szunlock <zone number>%s\r\n", QYEL, QNRM);
|
||||
return;
|
||||
}
|
||||
|
|
567
src/asciimap.c
567
src/asciimap.c
|
@ -15,12 +15,8 @@
|
|||
#include "utils.h"
|
||||
#include "comm.h"
|
||||
#include "interpreter.h"
|
||||
#include "handler.h"
|
||||
#include "db.h"
|
||||
#include "spells.h"
|
||||
#include "house.h"
|
||||
#include "constants.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "asciimap.h"
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -33,29 +29,28 @@
|
|||
|
||||
#define DEFAULT_MAP_SIZE CONFIG_MAP_SIZE
|
||||
|
||||
#define MAX_MAP_SIZE (CANVAS_WIDTH - 1)/4
|
||||
#define MAX_MAP_SIZE ((CANVAS_WIDTH - 1)/4)
|
||||
#define MAX_MAP CANVAS_WIDTH
|
||||
|
||||
#define MAX_MAP_DIR 10
|
||||
#define MAX_MAP_FOLLOW 10
|
||||
#define MAX_MAP_DIR 10
|
||||
|
||||
#define SECT_EMPTY 30 /* anything greater than num sect types */
|
||||
#define SECT_STRANGE (SECT_EMPTY + 1)
|
||||
#define SECT_HERE (SECT_STRANGE + 1)
|
||||
#define SECT_EMPTY 30 /* anything greater than num sect types */
|
||||
#define SECT_STRANGE (SECT_EMPTY + 1)
|
||||
#define SECT_HERE (SECT_STRANGE + 1)
|
||||
|
||||
#define DOOR_NS -1
|
||||
#define DOOR_EW -2
|
||||
#define DOOR_UP -3
|
||||
#define DOOR_DOWN -4
|
||||
#define DOOR_DIAGNE -5
|
||||
#define DOOR_DIAGNW -6
|
||||
#define VDOOR_NS -7
|
||||
#define VDOOR_EW -8
|
||||
#define VDOOR_DIAGNE -9
|
||||
#define VDOOR_DIAGNW -10
|
||||
#define DOOR_UP_AND_NE -11
|
||||
#define DOOR_DOWN_AND_SE -12
|
||||
#define DOOR_NONE -13
|
||||
#define DOOR_NS (-1)
|
||||
#define DOOR_EW (-2)
|
||||
#define DOOR_UP (-3)
|
||||
#define DOOR_DOWN (-4)
|
||||
#define DOOR_DIAGNE (-5)
|
||||
#define DOOR_DIAGNW (-6)
|
||||
#define VDOOR_NS (-7)
|
||||
#define VDOOR_EW (-8)
|
||||
#define VDOOR_DIAGNE (-9)
|
||||
#define VDOOR_DIAGNW (-10)
|
||||
#define DOOR_UP_AND_NE (-11)
|
||||
#define DOOR_DOWN_AND_SE (-12)
|
||||
#define DOOR_NONE (-13)
|
||||
#define NUM_DOOR_TYPES 13
|
||||
|
||||
#define MAP_CIRCLE 0
|
||||
|
@ -64,46 +59,44 @@
|
|||
#define MAP_NORMAL 0
|
||||
#define MAP_COMPACT 1
|
||||
|
||||
static bool show_worldmap(struct char_data *ch);
|
||||
|
||||
struct map_info_type
|
||||
{
|
||||
int sector_type;
|
||||
int sector_type;
|
||||
char disp[20];
|
||||
};
|
||||
|
||||
static struct map_info_type door_info[] =
|
||||
{
|
||||
{ DOOR_NONE, " " },
|
||||
{ DOOR_DOWN_AND_SE, "\tr-\tn\\ " },
|
||||
{ DOOR_UP_AND_NE, "\tr+\tn/ " },
|
||||
{ VDOOR_DIAGNW, " \tm+\tn " },
|
||||
{ VDOOR_DIAGNE, " \tm+\tn "},
|
||||
{ VDOOR_EW, " \tm+\tn " },
|
||||
{ VDOOR_NS, " \tm+\tn "},
|
||||
{ DOOR_DIAGNW, " \\ " },
|
||||
{ DOOR_DIAGNE, " / " },
|
||||
{ DOOR_DOWN, "\tr-\tn " },
|
||||
{ DOOR_UP, "\tr+\tn " },
|
||||
{ DOOR_EW, " - " },
|
||||
{ DOOR_NS, " | " }
|
||||
{DOOR_NONE, " "},
|
||||
{DOOR_DOWN_AND_SE, "\tr-\tn\\ "},
|
||||
{DOOR_UP_AND_NE, "\tr+\tn/ "},
|
||||
{VDOOR_DIAGNW, " \tm+\tn "},
|
||||
{VDOOR_DIAGNE, " \tm+\tn "},
|
||||
{VDOOR_EW, " \tm+\tn "},
|
||||
{VDOOR_NS, " \tm+\tn "},
|
||||
{DOOR_DIAGNW, " \\ "},
|
||||
{DOOR_DIAGNE, " / "},
|
||||
{DOOR_DOWN, "\tr-\tn "},
|
||||
{DOOR_UP, "\tr+\tn "},
|
||||
{DOOR_EW, " - "},
|
||||
{DOOR_NS, " | "}
|
||||
};
|
||||
|
||||
static struct map_info_type compact_door_info[] =
|
||||
{
|
||||
{ DOOR_NONE, " " },
|
||||
{ DOOR_DOWN_AND_SE, "\tR\\\tn" },
|
||||
{ DOOR_UP_AND_NE, "\tR/\tn" },
|
||||
{ VDOOR_DIAGNW, "\tm+\tn" },
|
||||
{ VDOOR_DIAGNE, "\tm+\tn"},
|
||||
{ VDOOR_EW, " \tm+\tn " },
|
||||
{ VDOOR_NS, " \tm+\tn "},
|
||||
{ DOOR_DIAGNW,"\\" },
|
||||
{ DOOR_DIAGNE,"/" },
|
||||
{ DOOR_DOWN, "\tr-\tn" },
|
||||
{ DOOR_UP, "\tr+\tn" },
|
||||
{ DOOR_EW, "-" },
|
||||
{ DOOR_NS, " | " }
|
||||
{DOOR_NONE, " "},
|
||||
{DOOR_DOWN_AND_SE, "\tR\\\tn"},
|
||||
{DOOR_UP_AND_NE, "\tR/\tn"},
|
||||
{VDOOR_DIAGNW, "\tm+\tn"},
|
||||
{VDOOR_DIAGNE, "\tm+\tn"},
|
||||
{VDOOR_EW, " \tm+\tn "},
|
||||
{VDOOR_NS, " \tm+\tn "},
|
||||
{DOOR_DIAGNW, "\\"},
|
||||
{DOOR_DIAGNE, "/"},
|
||||
{DOOR_DOWN, "\tr-\tn"},
|
||||
{DOOR_UP, "\tr+\tn"},
|
||||
{DOOR_EW, "-"},
|
||||
{DOOR_NS, " | "}
|
||||
};
|
||||
|
||||
/* Add new sector types below for both map_info and world_map_info */
|
||||
|
@ -111,76 +104,76 @@ static struct map_info_type compact_door_info[] =
|
|||
/* New sectors also need to be added to the perform_map function below */
|
||||
static struct map_info_type map_info[] =
|
||||
{
|
||||
{ SECT_INSIDE, "\tc[\tn.\tc]\tn" }, /* 0 */
|
||||
{ SECT_CITY, "\tc[\twC\tc]\tn" },
|
||||
{ SECT_FIELD, "\tc[\tg,\tc]\tn" },
|
||||
{ SECT_FOREST, "\tc[\tgY\tc]\tn" },
|
||||
{ SECT_HILLS, "\tc[\tMm\tc]\tn" },
|
||||
{ SECT_MOUNTAIN, "\tc[\trM\tc]\tn" }, /* 5 */
|
||||
{ SECT_WATER_SWIM, "\tc[\tc~\tc]\tn" },
|
||||
{ SECT_WATER_NOSWIM, "\tc[\tb=\tc]\tn" },
|
||||
{ SECT_FLYING, "\tc[\tC^\tc]\tn" },
|
||||
{ SECT_UNDERWATER, "\tc[\tbU\tc]\tn" },
|
||||
{ -1, "" }, /* 10 */
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" }, /* 15 */
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" }, /* 20 */
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" }, /* 25 */
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ SECT_EMPTY, " " }, /* 30 */
|
||||
{ SECT_STRANGE, "\tc[\tR?\tc]\tn" },
|
||||
{ SECT_HERE, "\tc[\tB!\tc]\tn" },
|
||||
{SECT_INSIDE, "\tc[\tn.\tc]\tn"}, /* 0 */
|
||||
{SECT_CITY, "\tc[\twC\tc]\tn"},
|
||||
{SECT_FIELD, "\tc[\tg,\tc]\tn"},
|
||||
{SECT_FOREST, "\tc[\tgY\tc]\tn"},
|
||||
{SECT_HILLS, "\tc[\tMm\tc]\tn"},
|
||||
{SECT_MOUNTAIN, "\tc[\trM\tc]\tn"}, /* 5 */
|
||||
{SECT_WATER_SWIM, "\tc[\tc~\tc]\tn"},
|
||||
{SECT_WATER_NOSWIM, "\tc[\tb=\tc]\tn"},
|
||||
{SECT_FLYING, "\tc[\tC^\tc]\tn"},
|
||||
{SECT_UNDERWATER, "\tc[\tbU\tc]\tn"},
|
||||
{-1, ""}, /* 10 */
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""}, /* 15 */
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""}, /* 20 */
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""}, /* 25 */
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{SECT_EMPTY, " "}, /* 30 */
|
||||
{SECT_STRANGE, "\tc[\tR?\tc]\tn"},
|
||||
{SECT_HERE, "\tc[\tB!\tc]\tn"},
|
||||
};
|
||||
|
||||
static struct map_info_type world_map_info[] =
|
||||
{
|
||||
{ SECT_INSIDE, "\tn." }, /* 0 */
|
||||
{ SECT_CITY, "\twC" },
|
||||
{ SECT_FIELD, "\tg," },
|
||||
{ SECT_FOREST, "\tgY" },
|
||||
{ SECT_HILLS, "\tMm" },
|
||||
{ SECT_MOUNTAIN, "\trM" }, /* 5 */
|
||||
{ SECT_WATER_SWIM, "\tc~" },
|
||||
{ SECT_WATER_NOSWIM, "\tb=" },
|
||||
{ SECT_FLYING, "\tC^" },
|
||||
{ SECT_UNDERWATER, "\tbU" },
|
||||
{ -1, "" }, /* 10 */
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" }, /* 15 */
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" }, /* 20 */
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" }, /* 25 */
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ -1, "" },
|
||||
{ SECT_EMPTY, " " }, /* 30 */
|
||||
{ SECT_STRANGE, "\tR?" },
|
||||
{ SECT_HERE, "\tB!" },
|
||||
{SECT_INSIDE, "\tn."}, /* 0 */
|
||||
{SECT_CITY, "\twC"},
|
||||
{SECT_FIELD, "\tg,"},
|
||||
{SECT_FOREST, "\tgY"},
|
||||
{SECT_HILLS, "\tMm"},
|
||||
{SECT_MOUNTAIN, "\trM"}, /* 5 */
|
||||
{SECT_WATER_SWIM, "\tc~"},
|
||||
{SECT_WATER_NOSWIM, "\tb="},
|
||||
{SECT_FLYING, "\tC^"},
|
||||
{SECT_UNDERWATER, "\tbU"},
|
||||
{-1, ""}, /* 10 */
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""}, /* 15 */
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""}, /* 20 */
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""}, /* 25 */
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{-1, ""},
|
||||
{SECT_EMPTY, " "}, /* 30 */
|
||||
{SECT_STRANGE, "\tR?"},
|
||||
{SECT_HERE, "\tB!"},
|
||||
};
|
||||
|
||||
|
||||
|
@ -191,11 +184,14 @@ static int offsets_worldmap[4][2] ={ {-1, 0},{ 0, 1},{ 1, 0},{ 0, -1} };
|
|||
static int door_offsets[6][2] ={ {-1, 0},{ 0, 1},{ 1, 0},{ 0, -1},{ -1, 1},{ 1, 1} };
|
||||
static int door_marks[6] = { DOOR_NS, DOOR_EW, DOOR_NS, DOOR_EW, DOOR_UP, DOOR_DOWN };
|
||||
*/
|
||||
static int offsets[10][2] ={ {-2, 0},{ 0, 2},{ 2, 0},{ 0, -2},{0, 0},{ 0, 0},{ -2, -2},{ -2, 2},{2, 2},{ 2, -2} };
|
||||
static int offsets_worldmap[10][2] ={ {-1, 0},{ 0, 1},{ 1, 0},{ 0, -1},{0, 0},{ 0, 0},{ -1, -1},{ -1, 1},{1, 1},{ 1, -1} };
|
||||
static int door_offsets[10][2] ={ {-1, 0},{ 0, 1},{ 1, 0},{ 0, -1},{ -1, 1},{ 1, 1},{ -1, -1},{ -1, 1},{ 1, 1},{ 1, -1} };
|
||||
static int door_marks[10] = { DOOR_NS, DOOR_EW, DOOR_NS, DOOR_EW, DOOR_UP, DOOR_DOWN, DOOR_DIAGNW, DOOR_DIAGNE, DOOR_DIAGNW, DOOR_DIAGNE};
|
||||
static int vdoor_marks[4] = { VDOOR_NS, VDOOR_EW, VDOOR_NS, VDOOR_EW };
|
||||
static int offsets[10][2] = {{-2, 0}, {0, 2}, {2, 0}, {0, -2}, {0, 0}, {0, 0}, {-2, -2}, {-2, 2}, {2, 2}, {2, -2}};
|
||||
static int offsets_worldmap[10][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {0, 0}, {0, 0}, {-1, -1}, {-1, 1}, {1, 1},
|
||||
{1, -1}};
|
||||
static int door_offsets[10][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {-1, 1}, {1, 1}, {-1, -1}, {-1, 1}, {1, 1},
|
||||
{1, -1}};
|
||||
static int door_marks[10] = {DOOR_NS, DOOR_EW, DOOR_NS, DOOR_EW, DOOR_UP, DOOR_DOWN, DOOR_DIAGNW, DOOR_DIAGNE,
|
||||
DOOR_DIAGNW, DOOR_DIAGNE};
|
||||
static int vdoor_marks[4] = {VDOOR_NS, VDOOR_EW, VDOOR_NS, VDOOR_EW};
|
||||
/******************************************************************************
|
||||
* End Local (File Scope) Defines and Global Variables
|
||||
*****************************************************************************/
|
||||
|
@ -203,118 +199,139 @@ static int vdoor_marks[4] = { VDOOR_NS, VDOOR_EW, VDOOR_NS, VDOOR_EW };
|
|||
/******************************************************************************
|
||||
* Begin Local (File Scope) Function Prototypes
|
||||
*****************************************************************************/
|
||||
static void MapArea(room_rnum room, struct char_data *ch, int x, int y, int min, int max, sh_int xpos, sh_int ypos, bool worldmap);
|
||||
static void MapArea(room_rnum room, const char_data *ch, int x, int y, int min, int max, int xpos, int ypos,
|
||||
bool worldmap);
|
||||
static char *StringMap(int centre, int size);
|
||||
static char *WorldMap(int centre, int size, int mapshape, int maptype );
|
||||
static char *WorldMap(int centre, int size, int mapshape, int maptype);
|
||||
static char *CompactStringMap(int centre, int size);
|
||||
static void perform_map( struct char_data *ch, char *argument, bool worldmap );
|
||||
static void perform_map(char_data *ch, char *argument, bool worldmap);
|
||||
static bool show_worldmap(const char_data *ch);
|
||||
/******************************************************************************
|
||||
* End Local (File Scope) Function Prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
bool can_see_map(struct char_data *ch) {
|
||||
bool can_see_map(const char_data *ch)
|
||||
{
|
||||
/* Is the map funcionality disabled? */
|
||||
if (CONFIG_MAP == MAP_OFF)
|
||||
return FALSE;
|
||||
else if ((CONFIG_MAP == MAP_IMM_ONLY) && (GET_LEVEL(ch) < LVL_IMMORT))
|
||||
if (CONFIG_MAP == MAP_OFF || (CONFIG_MAP == MAP_IMM_ONLY && GET_LEVEL(ch) < LVL_IMMORT))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* MapArea function - create the actual map */
|
||||
static void MapArea(room_rnum room, struct char_data *ch, int x, int y, int min, int max, sh_int xpos, sh_int ypos, bool worldmap)
|
||||
static void MapArea(const room_rnum room, const char_data *ch, const int x, const int y, // NOLINT(*-no-recursion)
|
||||
const int min, const int max, const int xpos, const int ypos, const bool worldmap)
|
||||
{
|
||||
room_rnum prospect_room;
|
||||
struct room_direction_data *pexit;
|
||||
int door, ew_size=0, ns_size=0, x_exit_pos=0, y_exit_pos=0;
|
||||
sh_int prospect_xpos, prospect_ypos;
|
||||
int door;
|
||||
const int ew_size = 0, ns_size = 0, x_exit_pos = 0, y_exit_pos = 0;
|
||||
int prospect_xpos, prospect_ypos;
|
||||
|
||||
if (map[x][y] < 0)
|
||||
return; /* this is a door */
|
||||
|
||||
/* marks the room as visited */
|
||||
if(room == IN_ROOM(ch))
|
||||
if (room == IN_ROOM(ch))
|
||||
map[x][y] = SECT_HERE;
|
||||
else
|
||||
map[x][y] = SECT(room);
|
||||
|
||||
if ( (x < min) || ( y < min) || ( x > max ) || ( y > max) ) return;
|
||||
if (x < min || y < min || x > max || y > max)
|
||||
return;
|
||||
|
||||
/* Check for exits */
|
||||
for ( door = 0; door < MAX_MAP_DIR; door++ ) {
|
||||
for (door = 0; door < MAX_MAP_DIR; door++) {
|
||||
|
||||
if( door < MAX_MAP_FOLLOW &&
|
||||
xpos+door_offsets[door][0] >= 0 &&
|
||||
xpos+door_offsets[door][0] <= ns_size &&
|
||||
ypos+door_offsets[door][1] >= 0 &&
|
||||
ypos+door_offsets[door][1] <= ew_size)
|
||||
{ /* Virtual exit */
|
||||
if (xpos + door_offsets[door][0] >= 0 &&
|
||||
xpos + door_offsets[door][0] <= ns_size &&
|
||||
ypos + door_offsets[door][1] >= 0 &&
|
||||
ypos + door_offsets[door][1] <= ew_size) { /* Virtual exit */
|
||||
// linting tells me vdoor_marks will have an index out of bounds here, since doors can have more values than
|
||||
// vdoor_marks contains. Either we're not actually getting here for those values, or we're not getting here at all.
|
||||
// Adding a guard for now. --welcor 20241230
|
||||
if (door < sizeof(vdoor_marks))
|
||||
map[x + door_offsets[door][0]][y + door_offsets[door][1]] = vdoor_marks[door];
|
||||
|
||||
map[x+door_offsets[door][0]][y+door_offsets[door][1]] = vdoor_marks[door] ;
|
||||
if (map[x+offsets[door][0]][y+offsets[door][1]] == SECT_EMPTY )
|
||||
MapArea(room,ch,x + offsets[door][0], y + offsets[door][1], min, max, xpos+door_offsets[door][0], ypos+door_offsets[door][1], worldmap);
|
||||
if (map[x + offsets[door][0]][y + offsets[door][1]] == SECT_EMPTY)
|
||||
MapArea(room, ch, x + offsets[door][0], y + offsets[door][1], min, max, xpos + door_offsets[door][0],
|
||||
ypos + door_offsets[door][1], worldmap);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( (pexit = world[room].dir_option[door]) != NULL &&
|
||||
(pexit->to_room > 0 ) && (pexit->to_room != NOWHERE) &&
|
||||
(!IS_SET(pexit->exit_info, EX_CLOSED)) &&
|
||||
(!IS_SET(pexit->exit_info, EX_HIDDEN) || PRF_FLAGGED(ch, PRF_HOLYLIGHT)) )
|
||||
{ /* A real exit */
|
||||
if ((pexit = world[room].dir_option[door]) != NULL &&
|
||||
pexit->to_room > 0 && pexit->to_room != NOWHERE &&
|
||||
!IS_SET(pexit->exit_info, EX_CLOSED) &&
|
||||
(!IS_SET(pexit->exit_info, EX_HIDDEN) || PRF_FLAGGED(ch, PRF_HOLYLIGHT))) { /* A real exit */
|
||||
|
||||
/* But is the door here... */
|
||||
switch (door) {
|
||||
case NORTH:
|
||||
if(xpos > 0 || ypos!=y_exit_pos) continue;
|
||||
if (xpos > 0 || ypos != y_exit_pos)
|
||||
continue;
|
||||
break;
|
||||
case SOUTH:
|
||||
if(xpos < ns_size || ypos!=y_exit_pos) continue;
|
||||
if (xpos < ns_size || ypos != y_exit_pos)
|
||||
continue;
|
||||
break;
|
||||
case EAST:
|
||||
if(ypos < ew_size || xpos!=x_exit_pos) continue;
|
||||
if (ypos < ew_size || xpos != x_exit_pos)
|
||||
continue;
|
||||
break;
|
||||
case WEST:
|
||||
if(ypos > 0 || xpos!=x_exit_pos) continue;
|
||||
if (ypos > 0 || xpos != x_exit_pos)
|
||||
continue;
|
||||
break;
|
||||
case NORTHWEST:
|
||||
if(xpos > 0 || ypos!=y_exit_pos || ypos > 0 || xpos!=x_exit_pos) continue;
|
||||
if (xpos > 0 || ypos != y_exit_pos || ypos > 0 || xpos != x_exit_pos)
|
||||
continue;
|
||||
break;
|
||||
case NORTHEAST:
|
||||
if(xpos > 0 || ypos!=y_exit_pos || ypos < ew_size || xpos!=x_exit_pos) continue;
|
||||
if (xpos > 0 || ypos != y_exit_pos || ypos < ew_size || xpos != x_exit_pos)
|
||||
continue;
|
||||
break;
|
||||
case SOUTHEAST:
|
||||
if(xpos < ns_size || ypos!=y_exit_pos || ypos < ew_size || xpos!=x_exit_pos) continue;
|
||||
if (xpos < ns_size || ypos != y_exit_pos || ypos < ew_size || xpos != x_exit_pos)
|
||||
continue;
|
||||
break;
|
||||
case SOUTHWEST:
|
||||
if(xpos < ns_size || ypos!=y_exit_pos || ypos > 0 || xpos!=x_exit_pos) continue;
|
||||
if (xpos < ns_size || ypos != y_exit_pos || ypos > 0 || xpos != x_exit_pos)
|
||||
continue;
|
||||
break;
|
||||
case UP:
|
||||
case DOWN:
|
||||
/* no check for up/down here */
|
||||
break;
|
||||
default:
|
||||
log("Default case reached in switch in door check in asciimap. "
|
||||
"Are any directions unaccounted for? door = %d", door);
|
||||
}
|
||||
|
||||
|
||||
/* if ( (x < min) || ( y < min) || ( x > max ) || ( y > max) ) return;*/
|
||||
/* if ( (x < min) || ( y < min) || ( x > max ) || ( y > max) ) return;*/
|
||||
prospect_room = pexit->to_room;
|
||||
|
||||
/* one way into area OR maze */
|
||||
if ( world[prospect_room].dir_option[rev_dir[door]] &&
|
||||
world[prospect_room].dir_option[rev_dir[door]]->to_room != room) {
|
||||
map[x][y] = SECT_STRANGE;
|
||||
/* one way into area OR maze */
|
||||
if (world[prospect_room].dir_option[rev_dir[door]] &&
|
||||
world[prospect_room].dir_option[rev_dir[door]]->to_room != room) {
|
||||
map[x][y] = SECT_STRANGE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldmap) {
|
||||
if ((map[x+door_offsets[door][0]][y+door_offsets[door][1]] == DOOR_NONE) ||
|
||||
(map[x+door_offsets[door][0]][y+door_offsets[door][1]] == SECT_EMPTY) ) {
|
||||
map[x+door_offsets[door][0]][y+door_offsets[door][1]] = door_marks[door];
|
||||
if (!worldmap) {
|
||||
if (map[x + door_offsets[door][0]][y + door_offsets[door][1]] == DOOR_NONE ||
|
||||
map[x + door_offsets[door][0]][y + door_offsets[door][1]] == SECT_EMPTY) {
|
||||
map[x + door_offsets[door][0]][y + door_offsets[door][1]] = door_marks[door];
|
||||
} else {
|
||||
if ( ((door == NORTHEAST) && (map[x+door_offsets[door][0]][y+door_offsets[door][1]] == DOOR_UP)) ||
|
||||
((door == UP) && (map[x+door_offsets[door][0]][y+door_offsets[door][1]] == DOOR_DIAGNE)) ) {
|
||||
map[x+door_offsets[door][0]][y+door_offsets[door][1]] = DOOR_UP_AND_NE;
|
||||
}
|
||||
else if ( ((door == SOUTHEAST) && (map[x+door_offsets[door][0]][y+door_offsets[door][1]] == DOOR_DOWN)) ||
|
||||
((door == DOWN) && (map[x+door_offsets[door][0]][y+door_offsets[door][1]] == DOOR_DIAGNW)) ) {
|
||||
map[x+door_offsets[door][0]][y+door_offsets[door][1]] = DOOR_DOWN_AND_SE;
|
||||
if ((door == NORTHEAST && map[x + door_offsets[door][0]][y + door_offsets[door][1]] == DOOR_UP) ||
|
||||
(door == UP && map[x + door_offsets[door][0]][y + door_offsets[door][1]] == DOOR_DIAGNE)) {
|
||||
map[x + door_offsets[door][0]][y + door_offsets[door][1]] = DOOR_UP_AND_NE;
|
||||
} else if ((door == SOUTHEAST && map[x + door_offsets[door][0]][y + door_offsets[door][1]] == DOOR_DOWN)
|
||||
||
|
||||
(door == DOWN && map[x + door_offsets[door][0]][y + door_offsets[door][1]] == DOOR_DIAGNW)) {
|
||||
map[x + door_offsets[door][0]][y + door_offsets[door][1]] = DOOR_DOWN_AND_SE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,81 +341,86 @@ static void MapArea(room_rnum room, struct char_data *ch, int x, int y, int min,
|
|||
case NORTH:
|
||||
prospect_xpos = ns_size;
|
||||
case SOUTH:
|
||||
prospect_ypos = world[prospect_room].dir_option[rev_dir[door]] ? y_exit_pos : ew_size/2;
|
||||
break;
|
||||
prospect_ypos = world[prospect_room].dir_option[rev_dir[door]] ? y_exit_pos : ew_size / 2;
|
||||
break;
|
||||
case WEST:
|
||||
prospect_ypos = ew_size;
|
||||
case EAST:
|
||||
prospect_xpos = world[prospect_room].dir_option[rev_dir[door]] ? x_exit_pos : ns_size/2;
|
||||
prospect_xpos = world[prospect_room].dir_option[rev_dir[door]] ? x_exit_pos : ns_size / 2;
|
||||
break;
|
||||
case NORTHEAST:
|
||||
case NORTHWEST:
|
||||
case SOUTHEAST:
|
||||
case SOUTHWEST:
|
||||
prospect_xpos = world[prospect_room].dir_option[rev_dir[door]] ? x_exit_pos : ns_size/2;
|
||||
prospect_ypos = world[prospect_room].dir_option[rev_dir[door]] ? y_exit_pos : ew_size/2;
|
||||
prospect_xpos = world[prospect_room].dir_option[rev_dir[door]] ? x_exit_pos : ns_size / 2;
|
||||
prospect_ypos = world[prospect_room].dir_option[rev_dir[door]] ? y_exit_pos : ew_size / 2;
|
||||
break;
|
||||
case UP:
|
||||
case DOWN:
|
||||
/* no check for up/down here */
|
||||
break;
|
||||
default:
|
||||
log("Default case reached in prospect switch in asciimap. Are any directions unaccounted for? door = %d", door);
|
||||
}
|
||||
|
||||
if(worldmap) {
|
||||
if ( door < MAX_MAP_FOLLOW && map[x+offsets_worldmap[door][0]][y+offsets_worldmap[door][1]] == SECT_EMPTY )
|
||||
MapArea(pexit->to_room,ch,x + offsets_worldmap[door][0], y + offsets_worldmap[door][1], min, max, prospect_xpos, prospect_ypos, worldmap);
|
||||
if (worldmap) {
|
||||
if (map[x + offsets_worldmap[door][0]][y + offsets_worldmap[door][1]] == SECT_EMPTY)
|
||||
MapArea(pexit->to_room, ch, x + offsets_worldmap[door][0], y + offsets_worldmap[door][1], min, max,
|
||||
prospect_xpos, prospect_ypos, worldmap);
|
||||
} else {
|
||||
if ( door < MAX_MAP_FOLLOW && map[x+offsets[door][0]][y+offsets[door][1]] == SECT_EMPTY )
|
||||
MapArea(pexit->to_room,ch,x + offsets[door][0], y + offsets[door][1], min, max, prospect_xpos, prospect_ypos, worldmap);
|
||||
if (map[x + offsets[door][0]][y + offsets[door][1]] == SECT_EMPTY)
|
||||
MapArea(pexit->to_room, ch, x + offsets[door][0], y + offsets[door][1], min, max, prospect_xpos,
|
||||
prospect_ypos, worldmap);
|
||||
}
|
||||
} /* end if exit there */
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Returns a string representation of the map */
|
||||
// ReSharper disable once CppDFAConstantParameter
|
||||
static char *StringMap(int centre, int size)
|
||||
{
|
||||
static char strmap[MAX_MAP*MAX_MAP*11 + MAX_MAP*2 + 1];
|
||||
static char strmap[MAX_MAP * MAX_MAP * 11 + MAX_MAP * 2 + 1];
|
||||
char *mp = strmap;
|
||||
char *tmp;
|
||||
int x, y;
|
||||
|
||||
/* every row */
|
||||
for (x = centre - CANVAS_HEIGHT/2; x <= centre + CANVAS_HEIGHT/2; x++) {
|
||||
for (x = centre - CANVAS_HEIGHT / 2; x <= centre + CANVAS_HEIGHT / 2; x++) {
|
||||
/* every column */
|
||||
for (y = centre - CANVAS_WIDTH/6; y <= centre + CANVAS_WIDTH/6; y++) {
|
||||
if (abs(centre - x)<=size && abs(centre-y)<=size)
|
||||
tmp = (map[x][y]<0) ? \
|
||||
door_info[NUM_DOOR_TYPES + map[x][y]].disp : \
|
||||
map_info[map[x][y]].disp ;
|
||||
for (y = centre - CANVAS_WIDTH / 6; y <= centre + CANVAS_WIDTH / 6; y++) {
|
||||
if (abs(centre - x) <= size && abs(centre - y) <= size)
|
||||
tmp = map[x][y] < 0 ? door_info[NUM_DOOR_TYPES + map[x][y]].disp : map_info[map[x][y]].disp;
|
||||
else
|
||||
tmp = map_info[SECT_EMPTY].disp;
|
||||
tmp = map_info[SECT_EMPTY].disp;
|
||||
strcpy(mp, tmp);
|
||||
mp += strlen(tmp);
|
||||
}
|
||||
strcpy(mp, "\r\n");
|
||||
mp+=2;
|
||||
mp += 2;
|
||||
}
|
||||
*mp='\0';
|
||||
*mp = '\0';
|
||||
return strmap;
|
||||
}
|
||||
|
||||
static char *WorldMap(int centre, int size, int mapshape, int maptype )
|
||||
// ReSharper disable once CppDFAConstantParameter
|
||||
static char *WorldMap(int centre, int size, int mapshape, int maptype)
|
||||
{
|
||||
static char strmap[MAX_MAP*MAX_MAP*4 + MAX_MAP*2 + 1];
|
||||
static char strmap[MAX_MAP * MAX_MAP * 4 + MAX_MAP * 2 + 1];
|
||||
char *mp = strmap;
|
||||
int x, y;
|
||||
int xmin, xmax, ymin, ymax;
|
||||
|
||||
switch(maptype) {
|
||||
case MAP_COMPACT:
|
||||
xmin = centre - size;
|
||||
xmax = centre + size;
|
||||
ymin = centre - 2*size;
|
||||
ymax = centre + 2*size;
|
||||
break;
|
||||
default:
|
||||
xmin = centre - CANVAS_HEIGHT/2;
|
||||
xmax = centre + CANVAS_HEIGHT/2;
|
||||
ymin = centre - CANVAS_WIDTH/2;
|
||||
ymax = centre + CANVAS_WIDTH/2;
|
||||
if (maptype == MAP_COMPACT) {
|
||||
xmin = centre - size;
|
||||
xmax = centre + size;
|
||||
ymin = centre - 2 * size;
|
||||
ymax = centre + 2 * size;
|
||||
} else {
|
||||
xmin = centre - CANVAS_HEIGHT / 2;
|
||||
xmax = centre + CANVAS_HEIGHT / 2;
|
||||
ymin = centre - CANVAS_WIDTH / 2;
|
||||
ymax = centre + CANVAS_WIDTH / 2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -407,26 +429,28 @@ static char *WorldMap(int centre, int size, int mapshape, int maptype )
|
|||
for (x = xmin; x <= xmax; x++) {
|
||||
/* every column */
|
||||
/* for (y = centre - (2*size) ; y <= centre + (2*size) ; y++) { */
|
||||
for (y = ymin ; y <= ymax ; y++) {
|
||||
for (y = ymin; y <= ymax; y++) {
|
||||
|
||||
if((mapshape == MAP_RECTANGLE && abs(centre - y) <= size*2 && abs(centre - x) <= size ) ||
|
||||
((mapshape == MAP_CIRCLE) && (centre-x)*(centre-x) + (centre-y)*(centre-y)/4 <= (size * size + 1))) {
|
||||
if ((mapshape == MAP_RECTANGLE && abs(centre - y) <= size * 2 && abs(centre - x) <= size) ||
|
||||
(mapshape == MAP_CIRCLE && (centre - x) * (centre - x) + (centre - y) * (centre - y) / 4 <= size * size +
|
||||
1)) {
|
||||
strcpy(mp, world_map_info[map[x][y]].disp);
|
||||
mp += strlen(world_map_info[map[x][y]].disp);
|
||||
} else {
|
||||
strcpy(mp++, " ");
|
||||
strcpy(mp++, " ");
|
||||
}
|
||||
}
|
||||
strcpy(mp, "\tn\r\n");
|
||||
mp+=4;
|
||||
mp += 4;
|
||||
}
|
||||
*mp='\0';
|
||||
*mp = '\0';
|
||||
return strmap;
|
||||
}
|
||||
|
||||
// ReSharper disable once CppDFAConstantParameter
|
||||
static char *CompactStringMap(int centre, int size)
|
||||
{
|
||||
static char strmap[MAX_MAP*MAX_MAP*12 + MAX_MAP*2 + 1];
|
||||
static char strmap[MAX_MAP * MAX_MAP * 12 + MAX_MAP * 2 + 1];
|
||||
char *mp = strmap;
|
||||
int x, y;
|
||||
|
||||
|
@ -434,56 +458,53 @@ static char *CompactStringMap(int centre, int size)
|
|||
for (x = centre - size; x <= centre + size; x++) {
|
||||
/* every column */
|
||||
for (y = centre - size; y <= centre + size; y++) {
|
||||
strcpy(mp, (map[x][y]<0) ? \
|
||||
compact_door_info[NUM_DOOR_TYPES + map[x][y]].disp : \
|
||||
map_info[map[x][y]].disp);
|
||||
mp += strlen((map[x][y]<0) ? \
|
||||
compact_door_info[NUM_DOOR_TYPES + map[x][y]].disp : \
|
||||
map_info[map[x][y]].disp);
|
||||
strcpy(mp, map[x][y] < 0 ? compact_door_info[NUM_DOOR_TYPES + map[x][y]].disp : map_info[map[x][y]].disp);
|
||||
mp += strlen(map[x][y] < 0 ? compact_door_info[NUM_DOOR_TYPES + map[x][y]].disp : map_info[map[x][y]].disp);
|
||||
}
|
||||
strcpy(mp, "\r\n");
|
||||
mp+=2;
|
||||
mp += 2;
|
||||
}
|
||||
*mp='\0';
|
||||
*mp = '\0';
|
||||
return strmap;
|
||||
}
|
||||
|
||||
/* Display a nicely formatted map with a legend */
|
||||
static void perform_map( struct char_data *ch, char *argument, bool worldmap )
|
||||
static void perform_map(char_data *ch, char *argument, bool worldmap)
|
||||
{
|
||||
int size = DEFAULT_MAP_SIZE;
|
||||
int centre, x, y, min, max;
|
||||
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH], buf1[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH];
|
||||
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH], buf1[MAX_STRING_LENGTH], buf2[
|
||||
MAX_STRING_LENGTH];
|
||||
int count = 0;
|
||||
int ew_size=0, ns_size=0;
|
||||
const int ew_size = 0, ns_size = 0;
|
||||
int mapshape = MAP_CIRCLE;
|
||||
|
||||
two_arguments( argument, arg1 , arg2 );
|
||||
if(*arg1)
|
||||
{
|
||||
size = atoi(arg1);
|
||||
two_arguments(argument, arg1, arg2);
|
||||
if (*arg1) {
|
||||
size = parse_int(arg1);
|
||||
}
|
||||
if (*arg2)
|
||||
{
|
||||
if (is_abbrev(arg2, "normal")) worldmap=FALSE;
|
||||
else if (is_abbrev(arg2, "world")) worldmap=TRUE;
|
||||
if (*arg2) {
|
||||
if (is_abbrev(arg2, "normal"))
|
||||
worldmap = FALSE;
|
||||
else if (is_abbrev(arg2, "world"))
|
||||
worldmap = TRUE;
|
||||
else {
|
||||
send_to_char(ch, "Usage: \tymap <distance> [ normal | world ]\tn");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(size<0) {
|
||||
if (size < 0) {
|
||||
size = -size;
|
||||
mapshape = MAP_RECTANGLE;
|
||||
}
|
||||
size = URANGE(1,size,MAX_MAP_SIZE);
|
||||
size = URANGE(1, size, MAX_MAP_SIZE);
|
||||
|
||||
centre = MAX_MAP/2;
|
||||
centre = MAX_MAP / 2;
|
||||
|
||||
if(worldmap) {
|
||||
min = centre - 2*size;
|
||||
max = centre + 2*size;
|
||||
if (worldmap) {
|
||||
min = centre - 2 * size;
|
||||
max = centre + 2 * size;
|
||||
} else {
|
||||
min = centre - size;
|
||||
max = centre + size;
|
||||
|
@ -491,19 +512,19 @@ static void perform_map( struct char_data *ch, char *argument, bool worldmap )
|
|||
|
||||
/* Blank the map */
|
||||
for (x = 0; x < MAX_MAP; ++x)
|
||||
for (y = 0; y < MAX_MAP; ++y)
|
||||
map[x][y]= (!(y%2) && !worldmap) ? DOOR_NONE : SECT_EMPTY;
|
||||
for (y = 0; y < MAX_MAP; ++y)
|
||||
map[x][y] = !(y % 2) && !worldmap ? DOOR_NONE : SECT_EMPTY;
|
||||
|
||||
/* starts the mapping with the centre room */
|
||||
MapArea(IN_ROOM(ch), ch, centre, centre, min, max, ns_size/2, ew_size/2, worldmap);
|
||||
MapArea(IN_ROOM(ch), ch, centre, centre, min, max, ns_size / 2, ew_size / 2, worldmap);
|
||||
|
||||
/* marks the center, where ch is */
|
||||
map[centre][centre] = SECT_HERE;
|
||||
|
||||
/* Feel free to put your own MUD name or header in here */
|
||||
send_to_char(ch, " \tY-\tytbaMUD Map System\tY-\tn\r\n"
|
||||
"\tD .-.__--.,--.__.-.\tn\r\n" );
|
||||
|
||||
"\tD .-.__--.,--.__.-.\tn\r\n");
|
||||
// TODO switch to snprintf
|
||||
count += sprintf(buf + count, "\tn\tn\tn%s Up\\\\", door_info[NUM_DOOR_TYPES + DOOR_UP].disp);
|
||||
count += sprintf(buf + count, "\tn\tn\tn%s Down\\\\", door_info[NUM_DOOR_TYPES + DOOR_DOWN].disp);
|
||||
count += sprintf(buf + count, "\tn%s You\\\\", map_info[SECT_HERE].disp);
|
||||
|
@ -521,18 +542,18 @@ static void perform_map( struct char_data *ch, char *argument, bool worldmap )
|
|||
strcpy(buf, strfrmt(buf, LEGEND_WIDTH, CANVAS_HEIGHT + 2, FALSE, TRUE, TRUE));
|
||||
|
||||
/* Start with an empty column */
|
||||
strcpy(buf1, strfrmt("",0, CANVAS_HEIGHT + 2, FALSE, FALSE, TRUE));
|
||||
strcpy(buf1, strfrmt("", 0, CANVAS_HEIGHT + 2, FALSE, FALSE, TRUE));
|
||||
|
||||
/* Paste the legend */
|
||||
strcpy(buf2, strpaste(buf1, buf, "\tD | \tn"));
|
||||
|
||||
/* Set up the map */
|
||||
memset(buf, ' ', CANVAS_WIDTH);
|
||||
count = (CANVAS_WIDTH);
|
||||
if(worldmap)
|
||||
count += sprintf(buf + count , "\r\n%s", WorldMap(centre, size, mapshape, MAP_NORMAL));
|
||||
count = CANVAS_WIDTH;
|
||||
if (worldmap)
|
||||
count += sprintf(buf + count, "\r\n%s", WorldMap(centre, size, mapshape, MAP_NORMAL));
|
||||
else
|
||||
count += sprintf(buf + count , "\r\n%s", StringMap(centre, size));
|
||||
count += sprintf(buf + count, "\r\n%s", StringMap(centre, size));
|
||||
memset(buf + count, ' ', CANVAS_WIDTH);
|
||||
strcpy(buf + count + CANVAS_WIDTH, "\r\n");
|
||||
/* Paste it on */
|
||||
|
@ -543,13 +564,13 @@ static void perform_map( struct char_data *ch, char *argument, bool worldmap )
|
|||
send_to_char(ch, "%s", buf2);
|
||||
|
||||
send_to_char(ch, "\tD `.-.__--.,-.__.-.-'\tn\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Display a string with the map beside it */
|
||||
void str_and_map(char *str, struct char_data *ch, room_vnum target_room ) {
|
||||
void str_and_map(char *str, char_data *ch, room_vnum target_room)
|
||||
{
|
||||
int size, centre, x, y, min, max, char_size;
|
||||
int ew_size=0, ns_size=0;
|
||||
int ew_size = 0, ns_size = 0;
|
||||
bool worldmap;
|
||||
|
||||
/* Check MUDs map config options - if disabled, just show room decsription */
|
||||
|
@ -560,48 +581,54 @@ void str_and_map(char *str, struct char_data *ch, room_vnum target_room ) {
|
|||
|
||||
worldmap = show_worldmap(ch);
|
||||
|
||||
if(!PRF_FLAGGED(ch, PRF_AUTOMAP)) {
|
||||
if (!PRF_FLAGGED(ch, PRF_AUTOMAP)) {
|
||||
send_to_char(ch, "%s", strfrmt(str, GET_SCREEN_WIDTH(ch), 1, FALSE, FALSE, FALSE));
|
||||
return;
|
||||
}
|
||||
|
||||
size = CONFIG_MINIMAP_SIZE;
|
||||
centre = MAX_MAP/2;
|
||||
min = centre - 2*size;
|
||||
max = centre + 2*size;
|
||||
centre = MAX_MAP / 2;
|
||||
min = centre - 2 * size;
|
||||
max = centre + 2 * size;
|
||||
|
||||
for (x = 0; x < MAX_MAP; ++x)
|
||||
for (y = 0; y < MAX_MAP; ++y)
|
||||
map[x][y]= (!(y%2) && !worldmap) ? DOOR_NONE : SECT_EMPTY;
|
||||
map[x][y] = !(y % 2) && !worldmap ? DOOR_NONE : SECT_EMPTY;
|
||||
|
||||
/* starts the mapping with the center room */
|
||||
MapArea(target_room, ch, centre, centre, min, max, ns_size/2, ew_size/2, worldmap );
|
||||
MapArea(target_room, ch, centre, centre, min, max, ns_size / 2, ew_size / 2, worldmap);
|
||||
map[centre][centre] = SECT_HERE;
|
||||
|
||||
/* char_size = rooms + doors + padding */
|
||||
if(worldmap)
|
||||
if (worldmap)
|
||||
char_size = size * 4 + 5;
|
||||
else
|
||||
char_size = 3*(size+1) + (size) + 4;
|
||||
char_size = 3 * (size + 1) + size + 4;
|
||||
|
||||
if(worldmap)
|
||||
send_to_char(ch, "%s", strpaste(strfrmt(str, GET_SCREEN_WIDTH(ch) - char_size, size*2 + 1, FALSE, TRUE, TRUE), WorldMap(centre, size, MAP_CIRCLE, MAP_COMPACT), " \tn"));
|
||||
if (worldmap)
|
||||
send_to_char(ch, "%s", strpaste(strfrmt(str, GET_SCREEN_WIDTH(ch) - char_size, size * 2 + 1, FALSE, TRUE, TRUE),
|
||||
WorldMap(centre, size, MAP_CIRCLE, MAP_COMPACT), " \tn"));
|
||||
else
|
||||
send_to_char(ch, "%s", strpaste(strfrmt(str, GET_SCREEN_WIDTH(ch) - char_size, size*2 + 1, FALSE, TRUE, TRUE), CompactStringMap(centre, size), " \tn"));
|
||||
send_to_char(ch, "%s", strpaste(strfrmt(str, GET_SCREEN_WIDTH(ch) - char_size, size * 2 + 1, FALSE, TRUE, TRUE),
|
||||
CompactStringMap(centre, size), " \tn"));
|
||||
|
||||
}
|
||||
|
||||
static bool show_worldmap(struct char_data *ch) {
|
||||
static bool show_worldmap(const char_data *ch)
|
||||
{
|
||||
room_rnum rm = IN_ROOM(ch);
|
||||
zone_rnum zn = GET_ROOM_ZONE(rm);
|
||||
|
||||
if (ROOM_FLAGGED(rm, ROOM_WORLDMAP)) return TRUE;
|
||||
if (ZONE_FLAGGED(zn, ZONE_WORLDMAP)) return TRUE;
|
||||
if (ROOM_FLAGGED(rm, ROOM_WORLDMAP))
|
||||
return TRUE;
|
||||
if (ZONE_FLAGGED(zn, ZONE_WORLDMAP))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ACMD(do_map) {
|
||||
ACMD(do_map)
|
||||
{
|
||||
if (!can_see_map(ch)) {
|
||||
send_to_char(ch, "Sorry, the map is disabled!\r\n");
|
||||
return;
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#define MAP_IMM_ONLY 2
|
||||
|
||||
/* Exported function prototypes */
|
||||
bool can_see_map(struct char_data *ch);
|
||||
void str_and_map(char *str, struct char_data *ch, room_vnum target_room );
|
||||
bool can_see_map(const char_data *ch);
|
||||
void str_and_map(char *str, char_data *ch, room_vnum target_room);
|
||||
ACMD(do_map);
|
||||
|
||||
#endif /* ASCIIMAP_H_*/
|
||||
|
|
24
src/cedit.c
24
src/cedit.c
|
@ -1520,12 +1520,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
|
|||
write_to_output(d,
|
||||
"That is an invalid choice!\r\n"
|
||||
"Enter the room's vnum where mortals should load into : ");
|
||||
} else if (real_room(atoi(arg)) == NOWHERE) {
|
||||
} else if (real_room(atoidx(arg)) == NOWHERE) {
|
||||
write_to_output(d,
|
||||
"That room doesn't exist!\r\n"
|
||||
"Enter the room's vnum where mortals should load into : ");
|
||||
} else {
|
||||
OLC_CONFIG(d)->room_nums.mortal_start_room = atoi(arg);
|
||||
OLC_CONFIG(d)->room_nums.mortal_start_room = atoidx(arg);
|
||||
cedit_disp_room_numbers(d);
|
||||
}
|
||||
break;
|
||||
|
@ -1535,12 +1535,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
|
|||
write_to_output(d,
|
||||
"That is an invalid choice!\r\n"
|
||||
"Enter the room's vnum where immortals should load into : ");
|
||||
} else if (real_room(atoi(arg)) == NOWHERE) {
|
||||
} else if (real_room(atoidx(arg)) == NOWHERE) {
|
||||
write_to_output(d,
|
||||
"That room doesn't exist!\r\n"
|
||||
"Enter the room's vnum where immortals should load into : ");
|
||||
} else {
|
||||
OLC_CONFIG(d)->room_nums.immort_start_room = atoi(arg);
|
||||
OLC_CONFIG(d)->room_nums.immort_start_room = atoidx(arg);
|
||||
cedit_disp_room_numbers(d);
|
||||
}
|
||||
break;
|
||||
|
@ -1550,12 +1550,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
|
|||
write_to_output(d,
|
||||
"That is an invalid choice!\r\n"
|
||||
"Enter the room's vnum where frozen people should load into : ");
|
||||
} else if (real_room(atoi(arg)) == NOWHERE) {
|
||||
} else if (real_room(atoidx(arg)) == NOWHERE) {
|
||||
write_to_output(d,
|
||||
"That room doesn't exist!\r\n"
|
||||
"Enter the room's vnum where frozen people should load into : ");
|
||||
} else {
|
||||
OLC_CONFIG(d)->room_nums.frozen_start_room = atoi(arg);
|
||||
OLC_CONFIG(d)->room_nums.frozen_start_room = atoidx(arg);
|
||||
cedit_disp_room_numbers(d);
|
||||
}
|
||||
break;
|
||||
|
@ -1565,12 +1565,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
|
|||
write_to_output(d,
|
||||
"That is an invalid choice!\r\n"
|
||||
"Enter the vnum for donation room #1 : ");
|
||||
} else if (real_room(atoi(arg)) == NOWHERE) {
|
||||
} else if (real_room(atoidx(arg)) == NOWHERE) {
|
||||
write_to_output(d,
|
||||
"That room doesn't exist!\r\n"
|
||||
"Enter the vnum for donation room #1 : ");
|
||||
} else {
|
||||
OLC_CONFIG(d)->room_nums.donation_room_1 = atoi(arg);
|
||||
OLC_CONFIG(d)->room_nums.donation_room_1 = atoidx(arg);
|
||||
cedit_disp_room_numbers(d);
|
||||
}
|
||||
break;
|
||||
|
@ -1580,12 +1580,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
|
|||
write_to_output(d,
|
||||
"That is an invalid choice!\r\n"
|
||||
"Enter the vnum for donation room #2 : ");
|
||||
} else if (real_room(atoi(arg)) == NOWHERE) {
|
||||
} else if (real_room(atoidx(arg)) == NOWHERE) {
|
||||
write_to_output(d,
|
||||
"That room doesn't exist!\r\n"
|
||||
"Enter the vnum for donation room #2 : ");
|
||||
} else {
|
||||
OLC_CONFIG(d)->room_nums.donation_room_2 = atoi(arg);
|
||||
OLC_CONFIG(d)->room_nums.donation_room_2 = atoidx(arg);
|
||||
cedit_disp_room_numbers(d);
|
||||
}
|
||||
break;
|
||||
|
@ -1595,12 +1595,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
|
|||
write_to_output(d,
|
||||
"That is an invalid choice!\r\n"
|
||||
"Enter the vnum for donation room #3 : ");
|
||||
} else if (real_room(atoi(arg)) == NOWHERE) {
|
||||
} else if (real_room(atoidx(arg)) == NOWHERE) {
|
||||
write_to_output(d,
|
||||
"That room doesn't exist!\r\n"
|
||||
"Enter the vnum for donation room #3 : ");
|
||||
} else {
|
||||
OLC_CONFIG(d)->room_nums.donation_room_3 = atoi(arg);
|
||||
OLC_CONFIG(d)->room_nums.donation_room_3 = atoidx(arg);
|
||||
cedit_disp_room_numbers(d);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -2464,6 +2464,11 @@ void send_to_range(room_vnum start, room_vnum finish, const char *messg, ...)
|
|||
va_list args;
|
||||
int j;
|
||||
|
||||
if (start == NOWHERE || finish == NOWHERE) {
|
||||
log("send_to_range passed start room or end room NOWHERE.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (start > finish) {
|
||||
log("send_to_range passed start room value greater then finish.");
|
||||
return;
|
||||
|
|
8
src/db.c
8
src/db.c
|
@ -3597,7 +3597,7 @@ room_rnum real_room(room_vnum vnum)
|
|||
bot = 0;
|
||||
top = top_of_world;
|
||||
|
||||
if (world[bot].number > vnum || world[top].number < vnum)
|
||||
if (vnum == NOWHERE || world[bot].number > vnum || world[top].number < vnum)
|
||||
return (NOWHERE);
|
||||
|
||||
/* perform binary search on world-table */
|
||||
|
@ -3623,7 +3623,7 @@ mob_rnum real_mobile(mob_vnum vnum)
|
|||
top = top_of_mobt;
|
||||
|
||||
/* quickly reject out-of-range vnums */
|
||||
if (mob_index[bot].vnum > vnum || mob_index[top].vnum < vnum)
|
||||
if (vnum == NOBODY || mob_index[bot].vnum > vnum || mob_index[top].vnum < vnum)
|
||||
return (NOBODY);
|
||||
|
||||
/* perform binary search on mob-table */
|
||||
|
@ -3649,7 +3649,7 @@ obj_rnum real_object(obj_vnum vnum)
|
|||
top = top_of_objt;
|
||||
|
||||
/* quickly reject out-of-range vnums */
|
||||
if (obj_index[bot].vnum > vnum || obj_index[top].vnum < vnum)
|
||||
if (vnum == NOTHING || obj_index[bot].vnum > vnum || obj_index[top].vnum < vnum)
|
||||
return (NOTHING);
|
||||
|
||||
/* perform binary search on obj-table */
|
||||
|
@ -3674,7 +3674,7 @@ zone_rnum real_zone(zone_vnum vnum)
|
|||
bot = 0;
|
||||
top = top_of_zone_table;
|
||||
|
||||
if (zone_table[bot].number > vnum || zone_table[top].number < vnum)
|
||||
if (vnum == NOWHERE || zone_table[bot].number > vnum || zone_table[top].number < vnum)
|
||||
return (NOWHERE);
|
||||
|
||||
/* perform binary search on zone-table */
|
||||
|
|
|
@ -320,7 +320,7 @@ ACMD(do_mzoneecho)
|
|||
if (!*room_number || !*msg)
|
||||
mob_log(ch, "mzoneecho called with too few args");
|
||||
|
||||
else if ((zone = real_zone_by_thing(atoi(room_number))) == NOWHERE)
|
||||
else if ((zone = real_zone_by_thing(atoidx(room_number))) == NOWHERE)
|
||||
mob_log(ch, "mzoneecho called for nonexistant zone");
|
||||
|
||||
else {
|
||||
|
@ -355,7 +355,7 @@ ACMD(do_mload)
|
|||
|
||||
target = two_arguments(argument, arg1, arg2);
|
||||
|
||||
if (!*arg1 || !*arg2 || !is_number(arg2) || ((number = atoi(arg2)) < 0)) {
|
||||
if (!*arg1 || !*arg2 || !is_number(arg2) || ((number = atoidx(arg2)) == NOBODY)) {
|
||||
mob_log(ch, "mload: bad syntax");
|
||||
return;
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ ACMD(do_mload)
|
|||
if (!target || !*target) {
|
||||
rnum = IN_ROOM(ch);
|
||||
} else {
|
||||
if (!isdigit(*target) || (rnum = real_room(atoi(target))) == NOWHERE) {
|
||||
if (!isdigit(*target) || (rnum = real_room(atoidx(target))) == NOWHERE) {
|
||||
mob_log(ch, "mload: room target vnum doesn't exist "
|
||||
"(loading mob vnum %d to room %s)", number, target);
|
||||
return;
|
||||
|
@ -914,10 +914,10 @@ ACMD(do_mtransform)
|
|||
mob_log(ch, "mtransform: bad argument");
|
||||
else {
|
||||
if (isdigit(*arg))
|
||||
m = read_mobile(atoi(arg), VIRTUAL);
|
||||
m = read_mobile(atoidx(arg), VIRTUAL);
|
||||
else {
|
||||
keep_hp = 0;
|
||||
m = read_mobile(atoi(arg+1), VIRTUAL);
|
||||
m = read_mobile(atoidx(arg+1), VIRTUAL);
|
||||
}
|
||||
if (m==NULL) {
|
||||
mob_log(ch, "mtransform: bad mobile vnum");
|
||||
|
@ -1070,7 +1070,7 @@ ACMD(do_mdoor)
|
|||
newexit->exit_info = (sh_int)asciiflag_conv(value);
|
||||
break;
|
||||
case 3: /* key */
|
||||
newexit->key = atoi(value);
|
||||
newexit->key = atoidx(value);
|
||||
break;
|
||||
case 4: /* name */
|
||||
if (newexit->keyword)
|
||||
|
@ -1079,7 +1079,7 @@ ACMD(do_mdoor)
|
|||
strcpy(newexit->keyword, value);
|
||||
break;
|
||||
case 5: /* room */
|
||||
if ((to_room = real_room(atoi(value))) != NOWHERE)
|
||||
if ((to_room = real_room(atoidx(value))) != NOWHERE)
|
||||
newexit->to_room = to_room;
|
||||
else
|
||||
mob_log(ch, "mdoor: invalid door target");
|
||||
|
@ -1176,5 +1176,5 @@ ACMD(do_mrecho)
|
|||
if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish))
|
||||
mob_log(ch, "mrecho called with too few args");
|
||||
else
|
||||
send_to_range(atoi(start), atoi(finish), "%s\r\n", msg);
|
||||
send_to_range(atoidx(start), atoidx(finish), "%s\r\n", msg);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ room_rnum obj_room(obj_data *obj)
|
|||
/* returns the real room number, or NOWHERE if not found or invalid */
|
||||
static room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr)
|
||||
{
|
||||
int tmp;
|
||||
room_vnum tmp;
|
||||
room_rnum location;
|
||||
char_data *target_mob;
|
||||
obj_data *target_obj;
|
||||
|
@ -101,7 +101,7 @@ static room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr)
|
|||
|
||||
if (isdigit(*roomstr) && !strchr(roomstr, '.'))
|
||||
{
|
||||
tmp = atoi(roomstr);
|
||||
tmp = atoidx(roomstr);
|
||||
if ((location = real_room(tmp)) == NOWHERE)
|
||||
return NOWHERE;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ static OCMD(do_ozoneecho)
|
|||
if (!*room_number || !*msg)
|
||||
obj_log(obj, "ozoneecho called with too few args");
|
||||
|
||||
else if ((zone = real_zone_by_thing(atoi(room_number))) == NOWHERE)
|
||||
else if ((zone = real_zone_by_thing(atoidx(room_number))) == NOWHERE)
|
||||
obj_log(obj, "ozoneecho called for nonexistant zone");
|
||||
|
||||
else {
|
||||
|
@ -275,7 +275,7 @@ static OCMD(do_orecho)
|
|||
if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish))
|
||||
obj_log(obj, "orecho: too few args");
|
||||
else
|
||||
send_to_range(atoi(start), atoi(finish), "%s\r\n", msg);
|
||||
send_to_range(atoidx(start), atoidx(finish), "%s\r\n", msg);
|
||||
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ static OCMD(do_otransform)
|
|||
else if (!isdigit(*arg))
|
||||
obj_log(obj, "otransform: bad argument");
|
||||
else {
|
||||
o = read_object(atoi(arg), VIRTUAL);
|
||||
o = read_object(atoidx(arg), VIRTUAL);
|
||||
if (o==NULL) {
|
||||
obj_log(obj, "otransform: bad object vnum");
|
||||
return;
|
||||
|
@ -459,7 +459,7 @@ static OCMD(do_dgoload)
|
|||
|
||||
target = two_arguments(argument, arg1, arg2);
|
||||
|
||||
if (!*arg1 || !*arg2 || !is_number(arg2) || ((number = atoi(arg2)) < 0))
|
||||
if (!*arg1 || !*arg2 || !is_number(arg2) || ((number = atoidx(arg2)) == NOTHING))
|
||||
{
|
||||
obj_log(obj, "oload: bad syntax");
|
||||
return;
|
||||
|
@ -477,7 +477,7 @@ static OCMD(do_dgoload)
|
|||
if (!target || !*target) {
|
||||
rnum = room;
|
||||
} else {
|
||||
if (!isdigit(*target) || (rnum = real_room(atoi(target))) == NOWHERE) {
|
||||
if (!isdigit(*target) || (rnum = real_room(atoidx(target))) == NOWHERE) {
|
||||
obj_log(obj, "oload: room target vnum doesn't exist "
|
||||
"(loading mob vnum %d to room %s)", number, target);
|
||||
return;
|
||||
|
@ -671,7 +671,7 @@ static OCMD(do_odoor)
|
|||
newexit->exit_info = (sh_int)asciiflag_conv(value);
|
||||
break;
|
||||
case 3: /* key */
|
||||
newexit->key = atoi(value);
|
||||
newexit->key = atoidx(value);
|
||||
break;
|
||||
case 4: /* name */
|
||||
if (newexit->keyword)
|
||||
|
@ -680,7 +680,7 @@ static OCMD(do_odoor)
|
|||
strcpy(newexit->keyword, value);
|
||||
break;
|
||||
case 5: /* room */
|
||||
if ((to_room = real_room(atoi(value))) != NOWHERE)
|
||||
if ((to_room = real_room(atoidx(value))) != NOWHERE)
|
||||
newexit->to_room = to_room;
|
||||
else
|
||||
obj_log(obj, "odoor: invalid door target");
|
||||
|
@ -743,7 +743,7 @@ static OCMD(do_oat)
|
|||
return;
|
||||
}
|
||||
|
||||
if (isdigit(*arg)) loc = real_room(atoi(arg));
|
||||
if (isdigit(*arg)) loc = real_room(atoidx(arg));
|
||||
else if ((ch = get_char_by_obj(obj, arg))) loc = IN_ROOM(ch);
|
||||
|
||||
if (loc == NOWHERE) {
|
||||
|
|
|
@ -602,7 +602,7 @@ void trigedit_parse(struct descriptor_data *d, char *arg)
|
|||
return;
|
||||
|
||||
case TRIGEDIT_COPY:
|
||||
if ((i = real_trigger(atoi(arg))) != NOWHERE) {
|
||||
if ((i = real_trigger(atoidx(arg))) != NOWHERE) {
|
||||
trigedit_setup_existing(d, i);
|
||||
} else
|
||||
write_to_output(d, "That trigger does not exist.\r\n");
|
||||
|
|
|
@ -186,7 +186,7 @@ obj_data *get_object_in_equip(char_data * ch, char *name)
|
|||
if (id == obj->script_id)
|
||||
return (obj);
|
||||
} else if (is_number(name)) {
|
||||
obj_vnum ovnum = atoi(name);
|
||||
obj_vnum ovnum = atoidx(name);
|
||||
for (j = 0; j < NUM_WEARS; j++)
|
||||
if ((obj = GET_EQ(ch, j)))
|
||||
if (GET_OBJ_VNUM(obj) == ovnum)
|
||||
|
@ -486,7 +486,7 @@ room_data *get_room(char *name)
|
|||
|
||||
if (*name == UID_CHAR)
|
||||
return find_room(atoi(name + 1));
|
||||
else if ((nr = real_room(atoi(name))) == NOWHERE)
|
||||
else if ((nr = real_room(atoidx(name))) == NOWHERE)
|
||||
return NULL;
|
||||
else
|
||||
return &world[nr];
|
||||
|
@ -944,8 +944,11 @@ ACMD(do_attach)
|
|||
trig_data *trig;
|
||||
char targ_name[MAX_INPUT_LENGTH], trig_name[MAX_INPUT_LENGTH];
|
||||
char loc_name[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];
|
||||
int loc, tn, rn, num_arg;
|
||||
int loc;
|
||||
trig_rnum rn;
|
||||
room_rnum rnum;
|
||||
IDXTYPE num_arg;
|
||||
trig_vnum tn;
|
||||
|
||||
argument = two_arguments(argument, arg, trig_name);
|
||||
two_arguments(argument, targ_name, loc_name);
|
||||
|
@ -955,8 +958,8 @@ ACMD(do_attach)
|
|||
return;
|
||||
}
|
||||
|
||||
num_arg = atoi(targ_name);
|
||||
tn = atoi(trig_name);
|
||||
num_arg = atoidx(targ_name);
|
||||
tn = atoidx(trig_name);
|
||||
loc = (*loc_name) ? atoi(loc_name) : -1;
|
||||
|
||||
if (is_abbrev(arg, "mobile") || is_abbrev(arg, "mtr")) {
|
||||
|
@ -1147,13 +1150,15 @@ ACMD(do_detach)
|
|||
struct room_data *room;
|
||||
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH], arg3[MAX_INPUT_LENGTH], *snum;
|
||||
char *trigger = 0;
|
||||
int num_arg, tn, rn;
|
||||
IDXTYPE num_arg;
|
||||
trig_vnum tn;
|
||||
trig_rnum rn;
|
||||
room_rnum rnum;
|
||||
trig_data *trig;
|
||||
|
||||
argument = two_arguments(argument, arg1, arg2);
|
||||
one_argument(argument, arg3);
|
||||
tn = atoi(arg3);
|
||||
tn = atoidx(arg3);
|
||||
rn = real_trigger(tn);
|
||||
trig = read_trigger(rn);
|
||||
|
||||
|
@ -1164,7 +1169,7 @@ ACMD(do_detach)
|
|||
}
|
||||
|
||||
/* vnum of mob/obj, if given */
|
||||
num_arg = atoi(arg2);
|
||||
num_arg = atoidx(arg2);
|
||||
|
||||
if (!str_cmp(arg1, "room") || !str_cmp(arg1, "wtr")) {
|
||||
if (!*arg3 || (strchr(arg2, '.')))
|
||||
|
@ -1793,7 +1798,8 @@ static void process_attach(void *go, struct script_data *sc, trig_data *trig,
|
|||
char_data *c=NULL;
|
||||
obj_data *o=NULL;
|
||||
room_data *r=NULL;
|
||||
long trignum, id;
|
||||
long id;
|
||||
trig_rnum trignum;
|
||||
|
||||
id_p = two_arguments(cmd, arg, trignum_s);
|
||||
skip_spaces(&id_p);
|
||||
|
@ -1831,7 +1837,7 @@ static void process_attach(void *go, struct script_data *sc, trig_data *trig,
|
|||
}
|
||||
|
||||
/* locate and load the trigger specified */
|
||||
trignum = real_trigger(atoi(trignum_s));
|
||||
trignum = real_trigger(atoidx(trignum_s));
|
||||
if (trignum == NOTHING || !(newtrig=read_trigger(trignum))) {
|
||||
script_log("Trigger: %s, VNum %d. attach invalid trigger: '%s'",
|
||||
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), trignum_s);
|
||||
|
@ -2725,7 +2731,7 @@ trig_rnum real_trigger(trig_vnum vnum)
|
|||
bot = 0;
|
||||
top = top_of_trigt - 1;
|
||||
|
||||
if (!top_of_trigt || trig_index[bot]->vnum > vnum || trig_index[top]->vnum < vnum)
|
||||
if (vnum == NOTHING || !top_of_trigt || trig_index[bot]->vnum > vnum || trig_index[top]->vnum < vnum)
|
||||
return (NOTHING);
|
||||
|
||||
/* perform binary search on trigger-table */
|
||||
|
@ -2749,7 +2755,7 @@ ACMD(do_tstat)
|
|||
|
||||
half_chop(argument, str, argument);
|
||||
if (*str) {
|
||||
rnum = real_trigger(atoi(str));
|
||||
rnum = real_trigger(atoidx(str));
|
||||
if (rnum == NOTHING) {
|
||||
send_to_char(ch, "That vnum does not exist.\r\n");
|
||||
return;
|
||||
|
@ -3096,7 +3102,7 @@ bool check_flags_by_name_ar(int *array, int numflags, char *search, const char *
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
int trig_is_attached(struct script_data *sc, int trig_num)
|
||||
int trig_is_attached(struct script_data *sc, trig_vnum trig_num)
|
||||
{
|
||||
trig_data *t;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define _DG_SCRIPTS_H_
|
||||
|
||||
#include "utils.h" /* To make sure ACMD is defined */
|
||||
#include "structs.h" /* To make sure we have access to typedefs */
|
||||
|
||||
#define MOB_TRIGGER 0
|
||||
#define OBJ_TRIGGER 1
|
||||
|
@ -191,14 +192,6 @@ struct script_memory {
|
|||
struct script_memory *next;
|
||||
};
|
||||
|
||||
/* typedefs that the dg functions rely on */
|
||||
typedef struct index_data index_data;
|
||||
typedef struct room_data room_data;
|
||||
typedef struct obj_data obj_data;
|
||||
typedef struct trig_data trig_data;
|
||||
typedef struct char_data char_data;
|
||||
|
||||
|
||||
/* function prototypes from dg_triggers.c */
|
||||
char *one_phrase(char *arg, char *first_arg);
|
||||
int is_substring(char *sub, char *string);
|
||||
|
@ -297,7 +290,7 @@ bool check_flags_by_name_ar(int *array, int numflags, char *search, const char *
|
|||
void read_saved_vars_ascii(FILE *file, struct char_data *ch, int count);
|
||||
void save_char_vars_ascii(FILE *file, struct char_data *ch);
|
||||
int perform_set_dg_var(struct char_data *ch, struct char_data *vict, char *val_arg);
|
||||
int trig_is_attached(struct script_data *sc, int trig_num);
|
||||
int trig_is_attached(struct script_data *sc, trig_vnum trig_num);
|
||||
|
||||
/* To maintain strict-aliasing we'll have to do this trick with a union */
|
||||
/* Thanks to Chris Gilbert for reminding me that there are other options. */
|
||||
|
|
|
@ -98,7 +98,7 @@ int item_in_list(char *item, obj_data *list)
|
|||
count += item_in_list(item, i->contains);
|
||||
}
|
||||
} else if (is_number(item)) { /* check for vnum */
|
||||
obj_vnum ovnum = atoi(item);
|
||||
obj_vnum ovnum = atoidx(item);
|
||||
|
||||
for (i = list; i; i = i->next_content) {
|
||||
if (GET_OBJ_VNUM(i) == ovnum)
|
||||
|
@ -256,6 +256,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
struct room_data *room, *r = NULL;
|
||||
char *name;
|
||||
int num, count, i, j, doors;
|
||||
IDXTYPE idx;
|
||||
|
||||
char *log_cmd[] = {"mlog ", "olog ", "wlog " };
|
||||
char *send_cmd[] = {"msend ", "osend ", "wsend " };
|
||||
|
@ -429,7 +430,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
return;
|
||||
}
|
||||
else if (!str_cmp(var, "people")) {
|
||||
snprintf(str, slen, "%d",((num = atoi(field)) > 0) ? trgvar_in_room(num) : 0);
|
||||
snprintf(str, slen, "%d",((num = atoidx(field)) > 0) ? trgvar_in_room(num) : 0);
|
||||
return;
|
||||
}
|
||||
else if (!str_cmp(var, "happyhour")) {
|
||||
|
@ -469,8 +470,8 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
script_log("findmob.vnum(mvnum) - illegal syntax");
|
||||
strcpy(str, "0");
|
||||
} else {
|
||||
room_rnum rrnum = real_room(atoi(field));
|
||||
mob_vnum mvnum = atoi(subfield);
|
||||
room_rnum rrnum = real_room(atoidx(field));
|
||||
mob_vnum mvnum = atoidx(subfield);
|
||||
|
||||
if (rrnum == NOWHERE) {
|
||||
script_log("findmob.vnum(ovnum): No room with vnum %d", atoi(field));
|
||||
|
@ -490,7 +491,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
script_log("findobj.vnum(ovnum) - illegal syntax");
|
||||
strcpy(str, "0");
|
||||
} else {
|
||||
room_rnum rrnum = real_room(atoi(field));
|
||||
room_rnum rrnum = real_room(atoidx(field));
|
||||
|
||||
if (rrnum == NOWHERE) {
|
||||
script_log("findobj.vnum(ovnum): No room with vnum %d", atoi(field));
|
||||
|
@ -978,7 +979,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
else if (!str_cmp(field, "questdone"))
|
||||
{
|
||||
if (!IS_NPC(c) && subfield && *subfield) {
|
||||
int q_num = atoi(subfield);
|
||||
qst_vnum q_num = atoidx(subfield);
|
||||
if (is_complete(c, q_num))
|
||||
strcpy(str, "1");
|
||||
else
|
||||
|
@ -1111,7 +1112,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
* something like if %actor.vnum(500)%. It should return false for PC's instead
|
||||
* -- Fizban 02/18
|
||||
*/
|
||||
snprintf(str, slen, "%d", IS_NPC(c) ? (int)(GET_MOB_VNUM(c) == atoi(subfield)) : 0 );
|
||||
snprintf(str, slen, "%d", IS_NPC(c) ? GET_MOB_VNUM(c) == atoidx(subfield) : 0 );
|
||||
} else {
|
||||
if (IS_NPC(c))
|
||||
snprintf(str, slen, "%d", GET_MOB_VNUM(c));
|
||||
|
@ -1249,8 +1250,8 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
if (!(subfield && *subfield))
|
||||
*str = '\0';
|
||||
else {
|
||||
i = atoi(subfield);
|
||||
snprintf(str, slen, "%d", trig_is_attached(SCRIPT(o), i));
|
||||
idx = atoidx(subfield);
|
||||
snprintf(str, slen, "%d", trig_is_attached(SCRIPT(o), idx));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1311,7 +1312,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
case 'v':
|
||||
if (!str_cmp(field, "vnum"))
|
||||
if (subfield && *subfield) {
|
||||
snprintf(str, slen, "%d", (int)(GET_OBJ_VNUM(o) == atoi(subfield)));
|
||||
snprintf(str, slen, "%d", GET_OBJ_VNUM(o) == atoidx(subfield));
|
||||
} else {
|
||||
snprintf(str, slen, "%d", GET_OBJ_VNUM(o));
|
||||
}
|
||||
|
@ -1403,14 +1404,14 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
|
||||
else if (!str_cmp(field, "vnum")) {
|
||||
if (subfield && *subfield) {
|
||||
snprintf(str, slen, "%d", (int)(r->number == atoi(subfield)));
|
||||
snprintf(str, slen, "%d", r->number == atoidx(subfield));
|
||||
} else {
|
||||
snprintf(str, slen,"%d",r->number);
|
||||
}
|
||||
} else if (!str_cmp(field, "contents")) {
|
||||
if (subfield && *subfield) {
|
||||
for (obj = r->contents; obj; obj = obj->next_content) {
|
||||
if (GET_OBJ_VNUM(obj) == atoi(subfield)) {
|
||||
if (GET_OBJ_VNUM(obj) == atoidx(subfield)) {
|
||||
/* arg given, found */
|
||||
snprintf(str, slen, "%c%ld", UID_CHAR, obj_script_id(obj));
|
||||
return;
|
||||
|
@ -1457,8 +1458,8 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
|||
if (!(subfield && *subfield))
|
||||
*str = '\0';
|
||||
else {
|
||||
i = atoi(subfield);
|
||||
snprintf(str, slen, "%d", trig_is_attached(SCRIPT(r), i));
|
||||
idx = atoidx(subfield);
|
||||
snprintf(str, slen, "%d", trig_is_attached(SCRIPT(r), idx));
|
||||
}
|
||||
}
|
||||
else if (!str_cmp(field, "zonenumber"))
|
||||
|
|
|
@ -169,7 +169,7 @@ WCMD(do_wzoneecho)
|
|||
if (!*room_num || !*msg)
|
||||
wld_log(room, "wzoneecho called with too few args");
|
||||
|
||||
else if ((zone = real_zone_by_thing(atoi(room_num))) == NOWHERE)
|
||||
else if ((zone = real_zone_by_thing(atoidx(room_num))) == NOWHERE)
|
||||
wld_log(room, "wzoneecho called for nonexistant zone");
|
||||
|
||||
else {
|
||||
|
@ -191,7 +191,7 @@ WCMD(do_wrecho)
|
|||
if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish))
|
||||
wld_log(room, "wrecho: too few args");
|
||||
else
|
||||
send_to_range(atoi(start), atoi(finish), "%s\r\n", msg);
|
||||
send_to_range(atoidx(start), atoidx(finish), "%s\r\n", msg);
|
||||
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ WCMD(do_wdoor)
|
|||
newexit->exit_info = (sh_int)asciiflag_conv(value);
|
||||
break;
|
||||
case 3: /* key */
|
||||
newexit->key = atoi(value);
|
||||
newexit->key = atoidx(value);
|
||||
break;
|
||||
case 4: /* name */
|
||||
if (newexit->keyword)
|
||||
|
@ -279,7 +279,7 @@ WCMD(do_wdoor)
|
|||
strcpy(newexit->keyword, value);
|
||||
break;
|
||||
case 5: /* room */
|
||||
if ((to_room = real_room(atoi(value))) != NOWHERE)
|
||||
if ((to_room = real_room(atoidx(value))) != NOWHERE)
|
||||
newexit->to_room = to_room;
|
||||
else
|
||||
wld_log(room, "wdoor: invalid door target");
|
||||
|
@ -291,7 +291,8 @@ WCMD(do_wdoor)
|
|||
WCMD(do_wteleport)
|
||||
{
|
||||
char_data *ch, *next_ch;
|
||||
room_rnum target, nr;
|
||||
room_rnum target;
|
||||
room_vnum nr;
|
||||
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
|
||||
|
||||
two_arguments(argument, arg1, arg2);
|
||||
|
@ -301,7 +302,7 @@ WCMD(do_wteleport)
|
|||
return;
|
||||
}
|
||||
|
||||
nr = atoi(arg2);
|
||||
nr = atoidx(arg2);
|
||||
target = real_room(nr);
|
||||
|
||||
if (target == NOWHERE)
|
||||
|
@ -435,7 +436,7 @@ WCMD(do_wpurge)
|
|||
WCMD(do_wload)
|
||||
{
|
||||
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
|
||||
int number = 0;
|
||||
IDXTYPE number = NOTHING;
|
||||
char_data *mob;
|
||||
obj_data *object;
|
||||
char *target;
|
||||
|
@ -445,7 +446,7 @@ WCMD(do_wload)
|
|||
|
||||
target = two_arguments(argument, arg1, arg2);
|
||||
|
||||
if (!*arg1 || !*arg2 || !is_number(arg2) || ((number = atoi(arg2)) < 0)) {
|
||||
if (!*arg1 || !*arg2 || !is_number(arg2) || (number = atoidx(arg2)) == NOTHING) {
|
||||
wld_log(room, "wload: bad syntax");
|
||||
return;
|
||||
}
|
||||
|
@ -456,7 +457,7 @@ WCMD(do_wload)
|
|||
if (!target || !*target) {
|
||||
rnum = real_room(room->number);
|
||||
} else {
|
||||
if (!isdigit(*target) || (rnum = real_room(atoi(target))) == NOWHERE) {
|
||||
if (!isdigit(*target) || (rnum = real_room(atoidx(target))) == NOWHERE) {
|
||||
wld_log(room, "wload: room target vnum doesn't exist (loading mob vnum %d to room %s)", number, target);
|
||||
return;
|
||||
}
|
||||
|
@ -564,7 +565,7 @@ WCMD(do_wat)
|
|||
return;
|
||||
}
|
||||
|
||||
if (isdigit(*arg)) loc = real_room(atoi(arg));
|
||||
if (isdigit(*arg)) loc = real_room(atoidx(arg));
|
||||
else if ((ch = get_char_by_room(room, arg))) loc = IN_ROOM(ch);
|
||||
|
||||
if (loc == NOWHERE) {
|
||||
|
@ -577,7 +578,8 @@ WCMD(do_wat)
|
|||
WCMD(do_wmove)
|
||||
{
|
||||
obj_data *obj, *next_obj;
|
||||
room_rnum target, nr;
|
||||
room_rnum target;
|
||||
room_vnum nr;
|
||||
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
|
||||
|
||||
two_arguments(argument, arg1, arg2);
|
||||
|
@ -587,7 +589,7 @@ WCMD(do_wmove)
|
|||
return;
|
||||
}
|
||||
|
||||
nr = atoi(arg2);
|
||||
nr = atoidx(arg2);
|
||||
target = real_room(nr);
|
||||
|
||||
if (target == NOWHERE) {
|
||||
|
|
|
@ -330,7 +330,7 @@ ACMD(do_export_zone)
|
|||
return;
|
||||
}
|
||||
|
||||
zvnum = atoi(argument);
|
||||
zvnum = atoidx(argument);
|
||||
zrnum = real_zone(zvnum);
|
||||
|
||||
if (zrnum == NOWHERE) {
|
||||
|
|
12
src/house.c
12
src/house.c
|
@ -300,7 +300,7 @@ void hcontrol_list_houses(struct char_data *ch, char *arg)
|
|||
if (*arg == '.')
|
||||
toshow = GET_ROOM_VNUM(IN_ROOM(ch));
|
||||
else
|
||||
toshow = atoi(arg);
|
||||
toshow = atoidx(arg);
|
||||
|
||||
if ((i = find_house(toshow)) == NOWHERE) {
|
||||
send_to_char(ch, "Unknown house, \"%s\".\r\n", arg);
|
||||
|
@ -363,7 +363,7 @@ static void hcontrol_build_house(struct char_data *ch, char *arg)
|
|||
send_to_char(ch, "%s", HCONTROL_FORMAT);
|
||||
return;
|
||||
}
|
||||
virt_house = atoi(arg1);
|
||||
virt_house = atoidx(arg1);
|
||||
if ((real_house = real_room(virt_house)) == NOWHERE) {
|
||||
send_to_char(ch, "No such room exists.\r\n");
|
||||
return;
|
||||
|
@ -436,17 +436,17 @@ static void hcontrol_destroy_house(struct char_data *ch, char *arg)
|
|||
send_to_char(ch, "%s", HCONTROL_FORMAT);
|
||||
return;
|
||||
}
|
||||
if ((i = find_house(atoi(arg))) == NOWHERE) {
|
||||
if ((i = find_house(atoidx(arg))) == NOWHERE) {
|
||||
send_to_char(ch, "Unknown house.\r\n");
|
||||
return;
|
||||
}
|
||||
if ((real_atrium = real_room(house_control[i].atrium)) == NOWHERE)
|
||||
log("SYSERR: House %d had invalid atrium %d!", atoi(arg), house_control[i].atrium);
|
||||
log("SYSERR: House %s had invalid atrium %d!", arg, house_control[i].atrium);
|
||||
else
|
||||
REMOVE_BIT_AR(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
|
||||
|
||||
if ((real_house = real_room(house_control[i].vnum)) == NOWHERE)
|
||||
log("SYSERR: House %d had invalid vnum %d!", atoi(arg), house_control[i].vnum);
|
||||
log("SYSERR: House %s had invalid vnum %d!", arg, house_control[i].vnum);
|
||||
else {
|
||||
REMOVE_BIT_AR(ROOM_FLAGS(real_house), ROOM_HOUSE);
|
||||
REMOVE_BIT_AR(ROOM_FLAGS(real_house), ROOM_PRIVATE);
|
||||
|
@ -475,7 +475,7 @@ static void hcontrol_pay_house(struct char_data *ch, char *arg)
|
|||
|
||||
if (!*arg)
|
||||
send_to_char(ch, "%s", HCONTROL_FORMAT);
|
||||
else if ((i = find_house(atoi(arg))) == NOWHERE)
|
||||
else if ((i = find_house(atoidx(arg))) == NOWHERE)
|
||||
send_to_char(ch, "Unknown house.\r\n");
|
||||
else {
|
||||
mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "Payment for house %s collected by %s.", arg, GET_NAME(ch));
|
||||
|
|
|
@ -37,7 +37,9 @@ static room_vnum redit_find_new_vnum(zone_rnum zone);
|
|||
***********************************************************/
|
||||
ACMD(do_oasis_copy)
|
||||
{
|
||||
int i, src_vnum, src_rnum, dst_vnum, dst_rnum;
|
||||
int i;
|
||||
room_vnum src_vnum, dst_vnum;
|
||||
room_rnum src_rnum, dst_rnum;
|
||||
char buf1[MAX_INPUT_LENGTH];
|
||||
char buf2[MAX_INPUT_LENGTH];
|
||||
struct descriptor_data *d;
|
||||
|
@ -82,7 +84,7 @@ ACMD(do_oasis_copy)
|
|||
/* We can't copy non-existing data. */
|
||||
/* Note: the source data can be in any zone. It's not restricted */
|
||||
/* to the builder's designated OLC zone. */
|
||||
src_vnum = atoi(buf1);
|
||||
src_vnum = atoidx(buf1);
|
||||
src_rnum = (*oasis_copy_info[i].binary_search)(src_vnum);
|
||||
if (src_rnum == NOWHERE) {
|
||||
send_to_char(ch, "The source %s (#%d) does not exist.\r\n", oasis_copy_info[i].text, src_vnum);
|
||||
|
@ -90,7 +92,7 @@ ACMD(do_oasis_copy)
|
|||
}
|
||||
|
||||
/* Don't copy if the target already exists. */
|
||||
dst_vnum = atoi(buf2);
|
||||
dst_vnum = atoidx(buf2);
|
||||
dst_rnum = (*oasis_copy_info[i].binary_search)(dst_vnum);
|
||||
if (dst_rnum != NOWHERE) {
|
||||
send_to_char(ch, "The target %s (#%d) already exists.\r\n", oasis_copy_info[i].text, dst_vnum);
|
||||
|
|
|
@ -375,7 +375,7 @@ ACMD(do_oasis_list)
|
|||
if (!*smin || *smin == '.') {
|
||||
rzone = world[IN_ROOM(ch)].zone;
|
||||
} else if (!*smax) {
|
||||
rzone = real_zone(atoi(smin));
|
||||
rzone = real_zone(atoidx(smin));
|
||||
|
||||
if ((rzone == NOWHERE || rzone == 0) && subcmd == SCMD_OASIS_ZLIST && !isdigit(*smin)) {
|
||||
/* Must be zlist, with builder name as arg */
|
||||
|
@ -521,7 +521,7 @@ ACMD(do_oasis_links)
|
|||
zrnum = world[IN_ROOM(ch)].zone;
|
||||
zvnum = zone_table[zrnum].number;
|
||||
} else {
|
||||
zvnum = atoi(arg);
|
||||
zvnum = atoidx(arg);
|
||||
zrnum = real_zone(zvnum);
|
||||
}
|
||||
|
||||
|
|
10
src/oedit.c
10
src/oedit.c
|
@ -51,7 +51,9 @@ static void oedit_save_to_disk(int zone_num);
|
|||
/* Utility and exported functions */
|
||||
ACMD(do_oasis_oedit)
|
||||
{
|
||||
int number = NOWHERE, save = 0, real_num;
|
||||
int save = 0;
|
||||
zone_vnum number = NOWHERE;
|
||||
zone_rnum real_num;
|
||||
struct descriptor_data *d;
|
||||
char buf1[MAX_STRING_LENGTH];
|
||||
char buf2[MAX_STRING_LENGTH];
|
||||
|
@ -76,7 +78,7 @@ ACMD(do_oasis_oedit)
|
|||
save = TRUE;
|
||||
|
||||
if (is_number(buf2))
|
||||
number = atoi(buf2);
|
||||
number = atoidx(buf2);
|
||||
else if (GET_OLC_ZONE(ch) > 0) {
|
||||
zone_rnum zlok;
|
||||
|
||||
|
@ -94,7 +96,7 @@ ACMD(do_oasis_oedit)
|
|||
|
||||
/* If a numeric argument was given, get it. */
|
||||
if (number == NOWHERE)
|
||||
number = atoi(buf1);
|
||||
number = atoidx(buf1);
|
||||
|
||||
if (number < IDXTYPE_MIN || number > IDXTYPE_MAX) {
|
||||
send_to_char(ch, "That object VNUM can't exist.\r\n");
|
||||
|
@ -1182,7 +1184,7 @@ void oedit_parse(struct descriptor_data *d, char *arg)
|
|||
break;
|
||||
|
||||
case OEDIT_COPY:
|
||||
if ((number = real_object(atoi(arg))) != NOTHING) {
|
||||
if ((number = real_object(atoidx(arg))) != NOTHING) {
|
||||
oedit_setup_existing(d, number);
|
||||
} else
|
||||
write_to_output(d, "That object does not exist.\r\n");
|
||||
|
|
|
@ -400,7 +400,7 @@ int load_char(const char *name, struct char_data *ch)
|
|||
break;
|
||||
|
||||
case 'O':
|
||||
if (!strcmp(tag, "Olc ")) GET_OLC_ZONE(ch) = atoi(line);
|
||||
if (!strcmp(tag, "Olc ")) GET_OLC_ZONE(ch) = atoidx(line);
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
|
@ -429,7 +429,7 @@ int load_char(const char *name, struct char_data *ch)
|
|||
break;
|
||||
|
||||
case 'R':
|
||||
if (!strcmp(tag, "Room")) GET_LOADROOM(ch) = atoi(line);
|
||||
if (!strcmp(tag, "Room")) GET_LOADROOM(ch) = atoidx(line);
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
|
@ -448,7 +448,7 @@ int load_char(const char *name, struct char_data *ch)
|
|||
else if (!strcmp(tag, "Thr5")) GET_SAVE(ch, 4) = atoi(line);
|
||||
else if (!strcmp(tag, "Titl")) GET_TITLE(ch) = strdup(line);
|
||||
else if (!strcmp(tag, "Trig") && CONFIG_SCRIPT_PLAYERS) {
|
||||
if ((t_rnum = real_trigger(atoi(line))) != NOTHING) {
|
||||
if ((t_rnum = real_trigger(atoidx(line))) != NOTHING) {
|
||||
t = read_trigger(t_rnum);
|
||||
if (!SCRIPT(ch))
|
||||
CREATE(SCRIPT(ch), struct script_data, 1);
|
||||
|
|
|
@ -692,7 +692,7 @@ void qedit_parse(struct descriptor_data *d, char *arg)
|
|||
return;
|
||||
}
|
||||
}
|
||||
OLC_QUEST(d)->next_quest = (number == -1 ? NOTHING : atoi(arg));
|
||||
OLC_QUEST(d)->next_quest = (number == -1 ? NOTHING : atoidx(arg));
|
||||
break;
|
||||
case QEDIT_PREVQUEST:
|
||||
if ((number = atoi(arg)) != -1) {
|
||||
|
@ -701,7 +701,7 @@ void qedit_parse(struct descriptor_data *d, char *arg)
|
|||
return;
|
||||
}
|
||||
}
|
||||
OLC_QUEST(d)->prev_quest = (number == -1 ? NOTHING : atoi(arg));
|
||||
OLC_QUEST(d)->prev_quest = (number == -1 ? NOTHING : atoidx(arg));
|
||||
break;
|
||||
case QEDIT_GOLD:
|
||||
OLC_QUEST(d)->gold_reward = LIMIT(number, 0, 99999);
|
||||
|
|
|
@ -653,7 +653,7 @@ static void quest_stat(struct char_data *ch, char argument[MAX_INPUT_LENGTH])
|
|||
|
||||
if (!*argument)
|
||||
send_to_char(ch, "%s\r\n", quest_imm_usage);
|
||||
else if ((rnum = real_quest(atoi(argument))) == NOTHING)
|
||||
else if ((rnum = real_quest(atoidx(argument))) == NOTHING)
|
||||
send_to_char(ch, "That quest does not exist.\r\n");
|
||||
else {
|
||||
sprintbit(QST_FLAGS(rnum), aq_flags, buf, sizeof(buf));
|
||||
|
|
13
src/redit.c
13
src/redit.c
|
@ -57,7 +57,7 @@ ACMD(do_oasis_redit)
|
|||
save = TRUE;
|
||||
|
||||
if (is_number(buf2))
|
||||
number = atoi(buf2);
|
||||
number = atoidx(buf2);
|
||||
else if (GET_OLC_ZONE(ch) != NOWHERE) {
|
||||
zone_rnum zlok;
|
||||
|
||||
|
@ -75,7 +75,7 @@ ACMD(do_oasis_redit)
|
|||
|
||||
/* If a numeric argument was given (like a room number), get it. */
|
||||
if (number == NOWHERE)
|
||||
number = atoi(buf1);
|
||||
number = atoidx(buf1);
|
||||
|
||||
if (number < IDXTYPE_MIN || number > IDXTYPE_MAX) {
|
||||
send_to_char(ch, "That room VNUM can't exist.\r\n");
|
||||
|
@ -799,11 +799,8 @@ void redit_parse(struct descriptor_data *d, char *arg)
|
|||
return;
|
||||
|
||||
case REDIT_EXIT_KEY:
|
||||
number = atoi(arg);
|
||||
if (number < 0)
|
||||
OLC_EXIT(d)->key = NOTHING;
|
||||
else
|
||||
OLC_EXIT(d)->key = number;
|
||||
number = atoidx(arg);
|
||||
OLC_EXIT(d)->key = number;
|
||||
redit_disp_exit_menu(d);
|
||||
return;
|
||||
|
||||
|
@ -886,7 +883,7 @@ void redit_parse(struct descriptor_data *d, char *arg)
|
|||
break;
|
||||
|
||||
case REDIT_COPY:
|
||||
if ((number = real_room(atoi(arg))) != NOWHERE) {
|
||||
if ((number = real_room(atoidx(arg))) != NOWHERE) {
|
||||
redit_setup_existing(d, number);
|
||||
} else
|
||||
write_to_output(d, "That room does not exist.\r\n");
|
||||
|
|
|
@ -72,7 +72,7 @@ ACMD(do_oasis_sedit)
|
|||
save = TRUE;
|
||||
|
||||
if (is_number(buf2))
|
||||
number = atoi(buf2);
|
||||
number = atoidx(buf2);
|
||||
else if (GET_OLC_ZONE(ch) > 0) {
|
||||
zone_rnum zlok;
|
||||
|
||||
|
@ -90,7 +90,7 @@ ACMD(do_oasis_sedit)
|
|||
|
||||
/* If a numeric argument was given, get it. */
|
||||
if (number == NOWHERE)
|
||||
number = atoi(buf1);
|
||||
number = atoidx(buf1);
|
||||
|
||||
if (number < IDXTYPE_MIN || number > IDXTYPE_MAX) {
|
||||
send_to_char(ch, "That shop VNUM can't exist.\r\n");
|
||||
|
|
|
@ -1506,7 +1506,7 @@ void show_shops(struct char_data *ch, char *arg)
|
|||
return;
|
||||
}
|
||||
} else if (is_number(arg))
|
||||
shop_nr = real_shop(atoi(arg));
|
||||
shop_nr = real_shop(atoidx(arg));
|
||||
else
|
||||
shop_nr = -1;
|
||||
|
||||
|
|
|
@ -1081,6 +1081,13 @@ struct descriptor_data {
|
|||
struct list_data * events;
|
||||
};
|
||||
|
||||
typedef struct index_data index_data;
|
||||
typedef struct room_data room_data;
|
||||
typedef struct obj_data obj_data;
|
||||
typedef struct trig_data trig_data;
|
||||
typedef struct char_data char_data;
|
||||
typedef struct descriptor_data descriptor_data;
|
||||
|
||||
/* other miscellaneous structures */
|
||||
/** Fight message display. This structure is used to hold the information to
|
||||
* be displayed for every different violent hit type. */
|
||||
|
|
32
src/utils.c
32
src/utils.c
|
@ -1239,7 +1239,7 @@ size_t file_sizeof( FILE *file )
|
|||
int file_numlines( FILE *file )
|
||||
{
|
||||
int numlines = 0;
|
||||
char c;
|
||||
int c;
|
||||
|
||||
rewind(file);
|
||||
|
||||
|
@ -1257,6 +1257,23 @@ int file_numlines( FILE *file )
|
|||
return numlines;
|
||||
}
|
||||
|
||||
long parse_long(const char *str_to_conv)
|
||||
{
|
||||
/* Check for errors */
|
||||
errno = 0;
|
||||
|
||||
return strtol(str_to_conv, NULL, 10);
|
||||
}
|
||||
|
||||
int parse_int(const char *str_to_conv)
|
||||
{
|
||||
const long int result = parse_long(str_to_conv);
|
||||
|
||||
if (errno || result > INT_MAX || result < INT_MIN)
|
||||
return 0;
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
/** A string converter designed to deal with the compile sensitive IDXTYPE.
|
||||
* Relies on the friendlier strtol function.
|
||||
|
@ -1266,17 +1283,12 @@ int file_numlines( FILE *file )
|
|||
*/
|
||||
IDXTYPE atoidx( const char *str_to_conv )
|
||||
{
|
||||
long int result;
|
||||
const long int result = parse_long(str_to_conv);
|
||||
|
||||
/* Check for errors */
|
||||
errno = 0;
|
||||
|
||||
result = strtol(str_to_conv, NULL, 10);
|
||||
|
||||
if ( errno || (result > IDXTYPE_MAX) || (result < 0) )
|
||||
if (errno || result > IDXTYPE_MAX || result < 0)
|
||||
return NOWHERE; /* All of the NO* settings should be the same */
|
||||
else
|
||||
return (IDXTYPE) result;
|
||||
|
||||
return (IDXTYPE)result;
|
||||
}
|
||||
|
||||
#define isspace_ignoretabs(c) ((c)!='\t' && isspace(c))
|
||||
|
|
|
@ -64,6 +64,8 @@ int file_tail(FILE *file, char *buf, size_t bufsize, int lines_to_read);
|
|||
size_t file_sizeof(FILE *file);
|
||||
int file_numlines(FILE *file);
|
||||
IDXTYPE atoidx(const char *str_to_conv);
|
||||
long parse_long(const char *str_to_conv);
|
||||
int parse_int(const char *str_to_conv);
|
||||
char *strfrmt(char *str, int w, int h, int justify, int hpad, int vpad);
|
||||
char *strpaste(char *str1, char *str2, char *joiner);
|
||||
void new_affect(struct affected_type *af);
|
||||
|
|
12
src/zedit.c
12
src/zedit.c
|
@ -978,7 +978,7 @@ void zedit_parse(struct descriptor_data *d, char *arg)
|
|||
}
|
||||
switch (OLC_CMD(d).command) {
|
||||
case 'M':
|
||||
if ((pos = real_mobile(atoi(arg))) != NOBODY) {
|
||||
if ((pos = real_mobile(atoidx(arg))) != NOBODY) {
|
||||
OLC_CMD(d).arg1 = pos;
|
||||
zedit_disp_arg2(d);
|
||||
} else
|
||||
|
@ -988,7 +988,7 @@ void zedit_parse(struct descriptor_data *d, char *arg)
|
|||
case 'P':
|
||||
case 'E':
|
||||
case 'G':
|
||||
if ((pos = real_object(atoi(arg))) != NOTHING) {
|
||||
if ((pos = real_object(atoidx(arg))) != NOTHING) {
|
||||
OLC_CMD(d).arg1 = pos;
|
||||
zedit_disp_arg2(d);
|
||||
} else
|
||||
|
@ -1044,8 +1044,8 @@ void zedit_parse(struct descriptor_data *d, char *arg)
|
|||
OLC_MODE(d) = ZEDIT_SARG1;
|
||||
break;
|
||||
case 'T':
|
||||
if (real_trigger(atoi(arg)) != NOTHING) {
|
||||
OLC_CMD(d).arg2 = real_trigger(atoi(arg)); /* trigger */
|
||||
if (real_trigger(atoidx(arg)) != NOTHING) {
|
||||
OLC_CMD(d).arg2 = real_trigger(atoidx(arg)); /* trigger */
|
||||
OLC_CMD(d).arg3 = real_room(OLC_NUM(d));
|
||||
zedit_disp_menu(d);
|
||||
} else
|
||||
|
@ -1062,7 +1062,7 @@ void zedit_parse(struct descriptor_data *d, char *arg)
|
|||
}
|
||||
break;
|
||||
case 'R':
|
||||
if ((pos = real_object(atoi(arg))) != NOTHING) {
|
||||
if ((pos = real_object(atoidx(arg))) != NOTHING) {
|
||||
OLC_CMD(d).arg2 = pos;
|
||||
zedit_disp_menu(d);
|
||||
} else
|
||||
|
@ -1096,7 +1096,7 @@ void zedit_parse(struct descriptor_data *d, char *arg)
|
|||
}
|
||||
break;
|
||||
case 'P':
|
||||
if ((pos = real_object(atoi(arg))) != NOTHING) {
|
||||
if ((pos = real_object(atoidx(arg))) != NOTHING) {
|
||||
OLC_CMD(d).arg3 = pos;
|
||||
zedit_disp_menu(d);
|
||||
} else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue