Switch to using atoidx whenever we are handling an IDXTYPE. cleanup and linting of asciimap.c

This commit is contained in:
welcor 2024-12-31 00:18:53 +01:00
parent 9c5787129b
commit b489a72c58
28 changed files with 478 additions and 422 deletions

View file

@ -180,7 +180,7 @@ room_rnum find_target_room(struct char_data *ch, char *rawroomstr)
} }
if (isdigit(*roomstr) && !strchr(roomstr, '.')) { 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"); send_to_char(ch, "No room exists with that number.\r\n");
return (NOWHERE); return (NOWHERE);
} }
@ -1008,7 +1008,7 @@ ACMD(do_stat)
if (!*buf2) if (!*buf2)
room = &world[IN_ROOM(ch)]; room = &world[IN_ROOM(ch)];
else { else {
room_rnum rnum = real_room(atoi(buf2)); room_rnum rnum = real_room(atoidx(buf2));
if (rnum == NOWHERE) { if (rnum == NOWHERE) {
send_to_char(ch, "That is not a valid room.\r\n"); send_to_char(ch, "That is not a valid room.\r\n");
return; return;
@ -1070,7 +1070,7 @@ ACMD(do_stat)
print_zone(ch, zone_table[world[IN_ROOM(ch)].zone].number); print_zone(ch, zone_table[world[IN_ROOM(ch)].zone].number);
return; return;
} else { } else {
print_zone(ch, atoi(buf2)); print_zone(ch, atoidx(buf2));
return; return;
} }
} else { } else {
@ -1329,7 +1329,7 @@ ACMD(do_load)
return; 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"); send_to_char(ch, "There is no monster with that number.\r\n");
return; return;
} }
@ -1351,7 +1351,7 @@ ACMD(do_load)
return; 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"); send_to_char(ch, "There is no object with that number.\r\n");
return; return;
} }
@ -1392,7 +1392,7 @@ ACMD(do_vstat)
switch (LOWER(*buf)) { switch (LOWER(*buf)) {
case 'm': 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"); send_to_char(ch, "There is no monster with that number.\r\n");
return; return;
} }
@ -1402,7 +1402,7 @@ ACMD(do_vstat)
extract_char(mob); extract_char(mob);
break; break;
case 'o': 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"); send_to_char(ch, "There is no object with that number.\r\n");
return; return;
} }
@ -1411,19 +1411,19 @@ ACMD(do_vstat)
extract_obj(obj); extract_obj(obj);
break; break;
case 'r': case 'r':
sprintf(buf2, "room %d", atoi(buf2)); sprintf(buf2, "room %d", atoidx(buf2));
do_stat(ch, buf2, 0, 0); do_stat(ch, buf2, 0, 0);
break; break;
case 'z': case 'z':
sprintf(buf2, "zone %d", atoi(buf2)); sprintf(buf2, "zone %d", atoidx(buf2));
do_stat(ch, buf2, 0, 0); do_stat(ch, buf2, 0, 0);
break; break;
case 't': case 't':
sprintf(buf2, "%d", atoi(buf2)); sprintf(buf2, "%d", atoidx(buf2));
do_tstat(ch, buf2, 0, 0); do_tstat(ch, buf2, 0, 0);
break; break;
case 's': case 's':
sprintf(buf2, "shops %d", atoi(buf2)); sprintf(buf2, "shops %d", atoidx(buf2));
do_show(ch, buf2, 0, 0); do_show(ch, buf2, 0, 0);
break; break;
default: default:
@ -3618,7 +3618,7 @@ ACMD(do_zcheck)
if (!is_number(buf) || !strcmp(buf, ".")) if (!is_number(buf) || !strcmp(buf, "."))
zrnum = world[IN_ROOM(ch)].zone; zrnum = world[IN_ROOM(ch)].zone;
else else
zrnum = real_zone(atoi(buf)); zrnum = real_zone(atoidx(buf));
if (zrnum == NOWHERE) { if (zrnum == NOWHERE) {
send_to_char(ch, "Check what zone ?\r\n"); send_to_char(ch, "Check what zone ?\r\n");
@ -4179,17 +4179,17 @@ ACMD(do_checkloadstatus)
} }
if (LOWER(*buf1) == 'm') { if (LOWER(*buf1) == 'm') {
mob_checkload(ch, atoi(buf2)); mob_checkload(ch, atoidx(buf2));
return; return;
} }
if (LOWER(*buf1) == 'o') { if (LOWER(*buf1) == 'o') {
obj_checkload(ch, atoi(buf2)); obj_checkload(ch, atoidx(buf2));
return; return;
} }
if (LOWER(*buf1) == 't') { if (LOWER(*buf1) == 't') {
trg_checkload(ch, atoi(buf2)); trg_checkload(ch, atoidx(buf2));
return; return;
} }
} }
@ -4288,7 +4288,7 @@ ACMD(do_zpurge)
if (*arg == '.' || !*arg) { if (*arg == '.' || !*arg) {
zone = world[IN_ROOM(ch)].zone; zone = world[IN_ROOM(ch)].zone;
} else if (is_number(arg)) { } else if (is_number(arg)) {
zone = real_zone(atoi(arg)); zone = real_zone(atoidx(arg));
if (zone == NOWHERE || zone > top_of_zone_table) { if (zone == NOWHERE || zone > top_of_zone_table) {
send_to_char(ch, "That zone doesn't exist!\r\n"); send_to_char(ch, "That zone doesn't exist!\r\n");
return; return;
@ -4802,7 +4802,7 @@ ACMD(do_zlock)
send_to_char(ch, "There are currently no locked zones!\r\n"); send_to_char(ch, "There are currently no locked zones!\r\n");
} }
return; 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); send_to_char(ch, "Usage: %szlock <zone number>%s\r\n", QYEL, QNRM);
return; return;
} }
@ -4895,7 +4895,7 @@ ACMD(do_zunlock)
send_to_char(ch, "There are currently no unlocked zones!\r\n"); send_to_char(ch, "There are currently no unlocked zones!\r\n");
} }
return; 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); send_to_char(ch, "Usage: %szunlock <zone number>%s\r\n", QYEL, QNRM);
return; return;
} }

View file

@ -15,12 +15,8 @@
#include "utils.h" #include "utils.h"
#include "comm.h" #include "comm.h"
#include "interpreter.h" #include "interpreter.h"
#include "handler.h"
#include "db.h" #include "db.h"
#include "spells.h"
#include "house.h"
#include "constants.h" #include "constants.h"
#include "dg_scripts.h"
#include "asciimap.h" #include "asciimap.h"
/****************************************************************************** /******************************************************************************
@ -33,29 +29,28 @@
#define DEFAULT_MAP_SIZE CONFIG_MAP_SIZE #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 CANVAS_WIDTH
#define MAX_MAP_DIR 10 #define MAX_MAP_DIR 10
#define MAX_MAP_FOLLOW 10
#define SECT_EMPTY 30 /* anything greater than num sect types */ #define SECT_EMPTY 30 /* anything greater than num sect types */
#define SECT_STRANGE (SECT_EMPTY + 1) #define SECT_STRANGE (SECT_EMPTY + 1)
#define SECT_HERE (SECT_STRANGE + 1) #define SECT_HERE (SECT_STRANGE + 1)
#define DOOR_NS -1 #define DOOR_NS (-1)
#define DOOR_EW -2 #define DOOR_EW (-2)
#define DOOR_UP -3 #define DOOR_UP (-3)
#define DOOR_DOWN -4 #define DOOR_DOWN (-4)
#define DOOR_DIAGNE -5 #define DOOR_DIAGNE (-5)
#define DOOR_DIAGNW -6 #define DOOR_DIAGNW (-6)
#define VDOOR_NS -7 #define VDOOR_NS (-7)
#define VDOOR_EW -8 #define VDOOR_EW (-8)
#define VDOOR_DIAGNE -9 #define VDOOR_DIAGNE (-9)
#define VDOOR_DIAGNW -10 #define VDOOR_DIAGNW (-10)
#define DOOR_UP_AND_NE -11 #define DOOR_UP_AND_NE (-11)
#define DOOR_DOWN_AND_SE -12 #define DOOR_DOWN_AND_SE (-12)
#define DOOR_NONE -13 #define DOOR_NONE (-13)
#define NUM_DOOR_TYPES 13 #define NUM_DOOR_TYPES 13
#define MAP_CIRCLE 0 #define MAP_CIRCLE 0
@ -64,8 +59,6 @@
#define MAP_NORMAL 0 #define MAP_NORMAL 0
#define MAP_COMPACT 1 #define MAP_COMPACT 1
static bool show_worldmap(struct char_data *ch);
struct map_info_type struct map_info_type
{ {
int sector_type; int sector_type;
@ -192,9 +185,12 @@ static int door_offsets[6][2] ={ {-1, 0},{ 0, 1},{ 1, 0},{ 0, -1},{ -1, 1},{ 1,
static int door_marks[6] = { DOOR_NS, DOOR_EW, DOOR_NS, DOOR_EW, DOOR_UP, DOOR_DOWN }; 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[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 offsets_worldmap[10][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {0, 0}, {0, 0}, {-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} }; {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 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 vdoor_marks[4] = {VDOOR_NS, VDOOR_EW, VDOOR_NS, VDOOR_EW};
/****************************************************************************** /******************************************************************************
* End Local (File Scope) Defines and Global Variables * End Local (File Scope) Defines and Global Variables
@ -203,33 +199,36 @@ static int vdoor_marks[4] = { VDOOR_NS, VDOOR_EW, VDOOR_NS, VDOOR_EW };
/****************************************************************************** /******************************************************************************
* Begin Local (File Scope) Function Prototypes * 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 *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 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 * 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? */ /* Is the map funcionality disabled? */
if (CONFIG_MAP == MAP_OFF) if (CONFIG_MAP == MAP_OFF || (CONFIG_MAP == MAP_IMM_ONLY && GET_LEVEL(ch) < LVL_IMMORT))
return FALSE;
else if ((CONFIG_MAP == MAP_IMM_ONLY) && (GET_LEVEL(ch) < LVL_IMMORT))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
/* MapArea function - create the actual map */ /* 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; room_rnum prospect_room;
struct room_direction_data *pexit; struct room_direction_data *pexit;
int door, ew_size=0, ns_size=0, x_exit_pos=0, y_exit_pos=0; int door;
sh_int prospect_xpos, prospect_ypos; 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) if (map[x][y] < 0)
return; /* this is a door */ return; /* this is a door */
@ -240,56 +239,74 @@ static void MapArea(room_rnum room, struct char_data *ch, int x, int y, int min,
else else
map[x][y] = SECT(room); 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 */ /* Check for exits */
for (door = 0; door < MAX_MAP_DIR; door++) { for (door = 0; door < MAX_MAP_DIR; door++) {
if( door < MAX_MAP_FOLLOW && if (xpos + door_offsets[door][0] >= 0 &&
xpos+door_offsets[door][0] >= 0 &&
xpos + door_offsets[door][0] <= ns_size && xpos + door_offsets[door][0] <= ns_size &&
ypos + door_offsets[door][1] >= 0 && ypos + door_offsets[door][1] >= 0 &&
ypos+door_offsets[door][1] <= ew_size) ypos + door_offsets[door][1] <= ew_size) { /* Virtual exit */
{ /* 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) 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); 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; continue;
} }
if ((pexit = world[room].dir_option[door]) != NULL && if ((pexit = world[room].dir_option[door]) != NULL &&
(pexit->to_room > 0 ) && (pexit->to_room != NOWHERE) && pexit->to_room > 0 && pexit->to_room != NOWHERE &&
(!IS_SET(pexit->exit_info, EX_CLOSED)) && !IS_SET(pexit->exit_info, EX_CLOSED) &&
(!IS_SET(pexit->exit_info, EX_HIDDEN) || PRF_FLAGGED(ch, PRF_HOLYLIGHT)) ) (!IS_SET(pexit->exit_info, EX_HIDDEN) || PRF_FLAGGED(ch, PRF_HOLYLIGHT))) { /* A real exit */
{ /* A real exit */
/* But is the door here... */ /* But is the door here... */
switch (door) { switch (door) {
case NORTH: case NORTH:
if(xpos > 0 || ypos!=y_exit_pos) continue; if (xpos > 0 || ypos != y_exit_pos)
continue;
break; break;
case SOUTH: case SOUTH:
if(xpos < ns_size || ypos!=y_exit_pos) continue; if (xpos < ns_size || ypos != y_exit_pos)
continue;
break; break;
case EAST: case EAST:
if(ypos < ew_size || xpos!=x_exit_pos) continue; if (ypos < ew_size || xpos != x_exit_pos)
continue;
break; break;
case WEST: case WEST:
if(ypos > 0 || xpos!=x_exit_pos) continue; if (ypos > 0 || xpos != x_exit_pos)
continue;
break; break;
case NORTHWEST: 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; break;
case NORTHEAST: 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; break;
case SOUTHEAST: 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; break;
case SOUTHWEST: 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; 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);
} }
@ -304,16 +321,16 @@ static void MapArea(room_rnum room, struct char_data *ch, int x, int y, int min,
} }
if (!worldmap) { if (!worldmap) {
if ((map[x+door_offsets[door][0]][y+door_offsets[door][1]] == DOOR_NONE) || 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]] == SECT_EMPTY) {
map[x + door_offsets[door][0]][y + door_offsets[door][1]] = door_marks[door]; map[x + door_offsets[door][0]][y + door_offsets[door][1]] = door_marks[door];
} else { } else {
if ( ((door == NORTHEAST) && (map[x+door_offsets[door][0]][y+door_offsets[door][1]] == DOOR_UP)) || 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)) ) { (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; 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)
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)) ) { (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; map[x + door_offsets[door][0]][y + door_offsets[door][1]] = DOOR_DOWN_AND_SE;
} }
} }
@ -338,21 +355,29 @@ static void MapArea(room_rnum room, struct char_data *ch, int x, int y, int min,
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;
prospect_ypos = world[prospect_room].dir_option[rev_dir[door]] ? y_exit_pos : ew_size / 2; prospect_ypos = world[prospect_room].dir_option[rev_dir[door]] ? y_exit_pos : ew_size / 2;
break; 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 (worldmap) {
if ( door < MAX_MAP_FOLLOW && map[x+offsets_worldmap[door][0]][y+offsets_worldmap[door][1]] == SECT_EMPTY ) 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); MapArea(pexit->to_room, ch, x + offsets_worldmap[door][0], y + offsets_worldmap[door][1], min, max,
prospect_xpos, prospect_ypos, worldmap);
} else { } else {
if ( door < MAX_MAP_FOLLOW && map[x+offsets[door][0]][y+offsets[door][1]] == SECT_EMPTY ) 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); MapArea(pexit->to_room, ch, x + offsets[door][0], y + offsets[door][1], min, max, prospect_xpos,
prospect_ypos, worldmap);
} }
} /* end if exit there */ } /* end if exit there */
} }
return;
} }
/* Returns a string representation of the map */ /* Returns a string representation of the map */
// ReSharper disable once CppDFAConstantParameter
static char *StringMap(int centre, int size) 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];
@ -365,9 +390,7 @@ static char *StringMap(int centre, int size)
/* every column */ /* every column */
for (y = centre - CANVAS_WIDTH / 6; y <= centre + CANVAS_WIDTH / 6; y++) { for (y = centre - CANVAS_WIDTH / 6; y <= centre + CANVAS_WIDTH / 6; y++) {
if (abs(centre - x) <= size && abs(centre - y) <= size) if (abs(centre - x) <= size && abs(centre - y) <= size)
tmp = (map[x][y]<0) ? \ tmp = map[x][y] < 0 ? door_info[NUM_DOOR_TYPES + map[x][y]].disp : map_info[map[x][y]].disp;
door_info[NUM_DOOR_TYPES + map[x][y]].disp : \
map_info[map[x][y]].disp ;
else else
tmp = map_info[SECT_EMPTY].disp; tmp = map_info[SECT_EMPTY].disp;
strcpy(mp, tmp); strcpy(mp, tmp);
@ -380,6 +403,7 @@ static char *StringMap(int centre, int size)
return strmap; return strmap;
} }
// ReSharper disable once CppDFAConstantParameter
static char *WorldMap(int centre, int size, int mapshape, int maptype) 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];
@ -387,14 +411,12 @@ static char *WorldMap(int centre, int size, int mapshape, int maptype )
int x, y; int x, y;
int xmin, xmax, ymin, ymax; int xmin, xmax, ymin, ymax;
switch(maptype) { if (maptype == MAP_COMPACT) {
case MAP_COMPACT:
xmin = centre - size; xmin = centre - size;
xmax = centre + size; xmax = centre + size;
ymin = centre - 2 * size; ymin = centre - 2 * size;
ymax = centre + 2 * size; ymax = centre + 2 * size;
break; } else {
default:
xmin = centre - CANVAS_HEIGHT / 2; xmin = centre - CANVAS_HEIGHT / 2;
xmax = centre + CANVAS_HEIGHT / 2; xmax = centre + CANVAS_HEIGHT / 2;
ymin = centre - CANVAS_WIDTH / 2; ymin = centre - CANVAS_WIDTH / 2;
@ -410,7 +432,8 @@ static char *WorldMap(int centre, int size, int mapshape, int maptype )
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) || 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))) { (mapshape == MAP_CIRCLE && (centre - x) * (centre - x) + (centre - y) * (centre - y) / 4 <= size * size +
1)) {
strcpy(mp, world_map_info[map[x][y]].disp); strcpy(mp, world_map_info[map[x][y]].disp);
mp += strlen(world_map_info[map[x][y]].disp); mp += strlen(world_map_info[map[x][y]].disp);
} else { } else {
@ -424,6 +447,7 @@ static char *WorldMap(int centre, int size, int mapshape, int maptype )
return strmap; return strmap;
} }
// ReSharper disable once CppDFAConstantParameter
static char *CompactStringMap(int centre, int size) 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];
@ -434,12 +458,8 @@ static char *CompactStringMap(int centre, int size)
for (x = centre - size; x <= centre + size; x++) { for (x = centre - size; x <= centre + size; x++) {
/* every column */ /* every column */
for (y = centre - size; y <= centre + size; y++) { for (y = centre - size; y <= centre + size; y++) {
strcpy(mp, (map[x][y]<0) ? \ strcpy(mp, map[x][y] < 0 ? compact_door_info[NUM_DOOR_TYPES + map[x][y]].disp : map_info[map[x][y]].disp);
compact_door_info[NUM_DOOR_TYPES + 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);
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"); strcpy(mp, "\r\n");
mp += 2; mp += 2;
@ -449,24 +469,25 @@ static char *CompactStringMap(int centre, int size)
} }
/* Display a nicely formatted map with a legend */ /* 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 size = DEFAULT_MAP_SIZE;
int centre, x, y, min, max; 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 count = 0;
int ew_size=0, ns_size=0; const int ew_size = 0, ns_size = 0;
int mapshape = MAP_CIRCLE; int mapshape = MAP_CIRCLE;
two_arguments(argument, arg1, arg2); two_arguments(argument, arg1, arg2);
if(*arg1) if (*arg1) {
{ size = parse_int(arg1);
size = atoi(arg1);
} }
if (*arg2) if (*arg2) {
{ if (is_abbrev(arg2, "normal"))
if (is_abbrev(arg2, "normal")) worldmap=FALSE; worldmap = FALSE;
else if (is_abbrev(arg2, "world")) worldmap=TRUE; else if (is_abbrev(arg2, "world"))
worldmap = TRUE;
else { else {
send_to_char(ch, "Usage: \tymap <distance> [ normal | world ]\tn"); send_to_char(ch, "Usage: \tymap <distance> [ normal | world ]\tn");
return; return;
@ -492,7 +513,7 @@ static void perform_map( struct char_data *ch, char *argument, bool worldmap )
/* Blank the map */ /* Blank the map */
for (x = 0; x < MAX_MAP; ++x) for (x = 0; x < MAX_MAP; ++x)
for (y = 0; y < MAX_MAP; ++y) 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 centre room */ /* 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);
@ -503,7 +524,7 @@ static void perform_map( struct char_data *ch, char *argument, bool worldmap )
/* Feel free to put your own MUD name or header in 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" 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 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\tn\tn%s Down\\\\", door_info[NUM_DOOR_TYPES + DOOR_DOWN].disp);
count += sprintf(buf + count, "\tn%s You\\\\", map_info[SECT_HERE].disp); count += sprintf(buf + count, "\tn%s You\\\\", map_info[SECT_HERE].disp);
@ -528,7 +549,7 @@ static void perform_map( struct char_data *ch, char *argument, bool worldmap )
/* Set up the map */ /* Set up the map */
memset(buf, ' ', CANVAS_WIDTH); memset(buf, ' ', CANVAS_WIDTH);
count = (CANVAS_WIDTH); count = CANVAS_WIDTH;
if (worldmap) if (worldmap)
count += sprintf(buf + count, "\r\n%s", WorldMap(centre, size, mapshape, MAP_NORMAL)); count += sprintf(buf + count, "\r\n%s", WorldMap(centre, size, mapshape, MAP_NORMAL));
else else
@ -543,11 +564,11 @@ static void perform_map( struct char_data *ch, char *argument, bool worldmap )
send_to_char(ch, "%s", buf2); send_to_char(ch, "%s", buf2);
send_to_char(ch, "\tD `.-.__--.,-.__.-.-'\tn\r\n"); send_to_char(ch, "\tD `.-.__--.,-.__.-.-'\tn\r\n");
return;
} }
/* Display a string with the map beside it */ /* 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 size, centre, x, y, min, max, char_size;
int ew_size = 0, ns_size = 0; int ew_size = 0, ns_size = 0;
bool worldmap; bool worldmap;
@ -572,7 +593,7 @@ void str_and_map(char *str, struct char_data *ch, room_vnum target_room ) {
for (x = 0; x < MAX_MAP; ++x) for (x = 0; x < MAX_MAP; ++x)
for (y = 0; y < MAX_MAP; ++y) 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 */ /* 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);
@ -582,26 +603,32 @@ MapArea(target_room, ch, centre, centre, min, max, ns_size/2, ew_size/2, worldma
if (worldmap) if (worldmap)
char_size = size * 4 + 5; char_size = size * 4 + 5;
else else
char_size = 3*(size+1) + (size) + 4; char_size = 3 * (size + 1) + size + 4;
if (worldmap) 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")); 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 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); room_rnum rm = IN_ROOM(ch);
zone_rnum zn = GET_ROOM_ZONE(rm); zone_rnum zn = GET_ROOM_ZONE(rm);
if (ROOM_FLAGGED(rm, ROOM_WORLDMAP)) return TRUE; if (ROOM_FLAGGED(rm, ROOM_WORLDMAP))
if (ZONE_FLAGGED(zn, ZONE_WORLDMAP)) return TRUE; return TRUE;
if (ZONE_FLAGGED(zn, ZONE_WORLDMAP))
return TRUE;
return FALSE; return FALSE;
} }
ACMD(do_map) { ACMD(do_map)
{
if (!can_see_map(ch)) { if (!can_see_map(ch)) {
send_to_char(ch, "Sorry, the map is disabled!\r\n"); send_to_char(ch, "Sorry, the map is disabled!\r\n");
return; return;

View file

@ -16,8 +16,8 @@
#define MAP_IMM_ONLY 2 #define MAP_IMM_ONLY 2
/* Exported function prototypes */ /* Exported function prototypes */
bool can_see_map(struct char_data *ch); bool can_see_map(const char_data *ch);
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);
ACMD(do_map); ACMD(do_map);
#endif /* ASCIIMAP_H_*/ #endif /* ASCIIMAP_H_*/

View file

@ -1520,12 +1520,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
write_to_output(d, write_to_output(d,
"That is an invalid choice!\r\n" "That is an invalid choice!\r\n"
"Enter the room's vnum where mortals should load into : "); "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, write_to_output(d,
"That room doesn't exist!\r\n" "That room doesn't exist!\r\n"
"Enter the room's vnum where mortals should load into : "); "Enter the room's vnum where mortals should load into : ");
} else { } 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); cedit_disp_room_numbers(d);
} }
break; break;
@ -1535,12 +1535,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
write_to_output(d, write_to_output(d,
"That is an invalid choice!\r\n" "That is an invalid choice!\r\n"
"Enter the room's vnum where immortals should load into : "); "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, write_to_output(d,
"That room doesn't exist!\r\n" "That room doesn't exist!\r\n"
"Enter the room's vnum where immortals should load into : "); "Enter the room's vnum where immortals should load into : ");
} else { } 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); cedit_disp_room_numbers(d);
} }
break; break;
@ -1550,12 +1550,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
write_to_output(d, write_to_output(d,
"That is an invalid choice!\r\n" "That is an invalid choice!\r\n"
"Enter the room's vnum where frozen people should load into : "); "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, write_to_output(d,
"That room doesn't exist!\r\n" "That room doesn't exist!\r\n"
"Enter the room's vnum where frozen people should load into : "); "Enter the room's vnum where frozen people should load into : ");
} else { } 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); cedit_disp_room_numbers(d);
} }
break; break;
@ -1565,12 +1565,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
write_to_output(d, write_to_output(d,
"That is an invalid choice!\r\n" "That is an invalid choice!\r\n"
"Enter the vnum for donation room #1 : "); "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, write_to_output(d,
"That room doesn't exist!\r\n" "That room doesn't exist!\r\n"
"Enter the vnum for donation room #1 : "); "Enter the vnum for donation room #1 : ");
} else { } 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); cedit_disp_room_numbers(d);
} }
break; break;
@ -1580,12 +1580,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
write_to_output(d, write_to_output(d,
"That is an invalid choice!\r\n" "That is an invalid choice!\r\n"
"Enter the vnum for donation room #2 : "); "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, write_to_output(d,
"That room doesn't exist!\r\n" "That room doesn't exist!\r\n"
"Enter the vnum for donation room #2 : "); "Enter the vnum for donation room #2 : ");
} else { } 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); cedit_disp_room_numbers(d);
} }
break; break;
@ -1595,12 +1595,12 @@ void cedit_parse(struct descriptor_data *d, char *arg)
write_to_output(d, write_to_output(d,
"That is an invalid choice!\r\n" "That is an invalid choice!\r\n"
"Enter the vnum for donation room #3 : "); "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, write_to_output(d,
"That room doesn't exist!\r\n" "That room doesn't exist!\r\n"
"Enter the vnum for donation room #3 : "); "Enter the vnum for donation room #3 : ");
} else { } 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); cedit_disp_room_numbers(d);
} }
break; break;

View file

@ -2464,6 +2464,11 @@ void send_to_range(room_vnum start, room_vnum finish, const char *messg, ...)
va_list args; va_list args;
int j; int j;
if (start == NOWHERE || finish == NOWHERE) {
log("send_to_range passed start room or end room NOWHERE.");
return;
}
if (start > finish) { if (start > finish) {
log("send_to_range passed start room value greater then finish."); log("send_to_range passed start room value greater then finish.");
return; return;

View file

@ -3597,7 +3597,7 @@ room_rnum real_room(room_vnum vnum)
bot = 0; bot = 0;
top = top_of_world; 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); return (NOWHERE);
/* perform binary search on world-table */ /* perform binary search on world-table */
@ -3623,7 +3623,7 @@ mob_rnum real_mobile(mob_vnum vnum)
top = top_of_mobt; top = top_of_mobt;
/* quickly reject out-of-range vnums */ /* 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); return (NOBODY);
/* perform binary search on mob-table */ /* perform binary search on mob-table */
@ -3649,7 +3649,7 @@ obj_rnum real_object(obj_vnum vnum)
top = top_of_objt; top = top_of_objt;
/* quickly reject out-of-range vnums */ /* 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); return (NOTHING);
/* perform binary search on obj-table */ /* perform binary search on obj-table */
@ -3674,7 +3674,7 @@ zone_rnum real_zone(zone_vnum vnum)
bot = 0; bot = 0;
top = top_of_zone_table; 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); return (NOWHERE);
/* perform binary search on zone-table */ /* perform binary search on zone-table */

View file

@ -320,7 +320,7 @@ ACMD(do_mzoneecho)
if (!*room_number || !*msg) if (!*room_number || !*msg)
mob_log(ch, "mzoneecho called with too few args"); 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"); mob_log(ch, "mzoneecho called for nonexistant zone");
else { else {
@ -355,7 +355,7 @@ ACMD(do_mload)
target = two_arguments(argument, arg1, arg2); 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"); mob_log(ch, "mload: bad syntax");
return; return;
} }
@ -366,7 +366,7 @@ ACMD(do_mload)
if (!target || !*target) { if (!target || !*target) {
rnum = IN_ROOM(ch); rnum = IN_ROOM(ch);
} else { } 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 " mob_log(ch, "mload: room target vnum doesn't exist "
"(loading mob vnum %d to room %s)", number, target); "(loading mob vnum %d to room %s)", number, target);
return; return;
@ -914,10 +914,10 @@ ACMD(do_mtransform)
mob_log(ch, "mtransform: bad argument"); mob_log(ch, "mtransform: bad argument");
else { else {
if (isdigit(*arg)) if (isdigit(*arg))
m = read_mobile(atoi(arg), VIRTUAL); m = read_mobile(atoidx(arg), VIRTUAL);
else { else {
keep_hp = 0; keep_hp = 0;
m = read_mobile(atoi(arg+1), VIRTUAL); m = read_mobile(atoidx(arg+1), VIRTUAL);
} }
if (m==NULL) { if (m==NULL) {
mob_log(ch, "mtransform: bad mobile vnum"); mob_log(ch, "mtransform: bad mobile vnum");
@ -1070,7 +1070,7 @@ ACMD(do_mdoor)
newexit->exit_info = (sh_int)asciiflag_conv(value); newexit->exit_info = (sh_int)asciiflag_conv(value);
break; break;
case 3: /* key */ case 3: /* key */
newexit->key = atoi(value); newexit->key = atoidx(value);
break; break;
case 4: /* name */ case 4: /* name */
if (newexit->keyword) if (newexit->keyword)
@ -1079,7 +1079,7 @@ ACMD(do_mdoor)
strcpy(newexit->keyword, value); strcpy(newexit->keyword, value);
break; break;
case 5: /* room */ case 5: /* room */
if ((to_room = real_room(atoi(value))) != NOWHERE) if ((to_room = real_room(atoidx(value))) != NOWHERE)
newexit->to_room = to_room; newexit->to_room = to_room;
else else
mob_log(ch, "mdoor: invalid door target"); mob_log(ch, "mdoor: invalid door target");
@ -1176,5 +1176,5 @@ ACMD(do_mrecho)
if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish)) if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish))
mob_log(ch, "mrecho called with too few args"); mob_log(ch, "mrecho called with too few args");
else else
send_to_range(atoi(start), atoi(finish), "%s\r\n", msg); send_to_range(atoidx(start), atoidx(finish), "%s\r\n", msg);
} }

View file

@ -88,7 +88,7 @@ room_rnum obj_room(obj_data *obj)
/* returns the real room number, or NOWHERE if not found or invalid */ /* returns the real room number, or NOWHERE if not found or invalid */
static room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr) static room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr)
{ {
int tmp; room_vnum tmp;
room_rnum location; room_rnum location;
char_data *target_mob; char_data *target_mob;
obj_data *target_obj; 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, '.')) if (isdigit(*roomstr) && !strchr(roomstr, '.'))
{ {
tmp = atoi(roomstr); tmp = atoidx(roomstr);
if ((location = real_room(tmp)) == NOWHERE) if ((location = real_room(tmp)) == NOWHERE)
return NOWHERE; return NOWHERE;
} }
@ -220,7 +220,7 @@ static OCMD(do_ozoneecho)
if (!*room_number || !*msg) if (!*room_number || !*msg)
obj_log(obj, "ozoneecho called with too few args"); 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"); obj_log(obj, "ozoneecho called for nonexistant zone");
else { else {
@ -275,7 +275,7 @@ static OCMD(do_orecho)
if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish)) if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish))
obj_log(obj, "orecho: too few args"); obj_log(obj, "orecho: too few args");
else 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)) else if (!isdigit(*arg))
obj_log(obj, "otransform: bad argument"); obj_log(obj, "otransform: bad argument");
else { else {
o = read_object(atoi(arg), VIRTUAL); o = read_object(atoidx(arg), VIRTUAL);
if (o==NULL) { if (o==NULL) {
obj_log(obj, "otransform: bad object vnum"); obj_log(obj, "otransform: bad object vnum");
return; return;
@ -459,7 +459,7 @@ static OCMD(do_dgoload)
target = two_arguments(argument, arg1, arg2); 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"); obj_log(obj, "oload: bad syntax");
return; return;
@ -477,7 +477,7 @@ static OCMD(do_dgoload)
if (!target || !*target) { if (!target || !*target) {
rnum = room; rnum = room;
} else { } 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 " obj_log(obj, "oload: room target vnum doesn't exist "
"(loading mob vnum %d to room %s)", number, target); "(loading mob vnum %d to room %s)", number, target);
return; return;
@ -671,7 +671,7 @@ static OCMD(do_odoor)
newexit->exit_info = (sh_int)asciiflag_conv(value); newexit->exit_info = (sh_int)asciiflag_conv(value);
break; break;
case 3: /* key */ case 3: /* key */
newexit->key = atoi(value); newexit->key = atoidx(value);
break; break;
case 4: /* name */ case 4: /* name */
if (newexit->keyword) if (newexit->keyword)
@ -680,7 +680,7 @@ static OCMD(do_odoor)
strcpy(newexit->keyword, value); strcpy(newexit->keyword, value);
break; break;
case 5: /* room */ case 5: /* room */
if ((to_room = real_room(atoi(value))) != NOWHERE) if ((to_room = real_room(atoidx(value))) != NOWHERE)
newexit->to_room = to_room; newexit->to_room = to_room;
else else
obj_log(obj, "odoor: invalid door target"); obj_log(obj, "odoor: invalid door target");
@ -743,7 +743,7 @@ static OCMD(do_oat)
return; 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); else if ((ch = get_char_by_obj(obj, arg))) loc = IN_ROOM(ch);
if (loc == NOWHERE) { if (loc == NOWHERE) {

View file

@ -602,7 +602,7 @@ void trigedit_parse(struct descriptor_data *d, char *arg)
return; return;
case TRIGEDIT_COPY: case TRIGEDIT_COPY:
if ((i = real_trigger(atoi(arg))) != NOWHERE) { if ((i = real_trigger(atoidx(arg))) != NOWHERE) {
trigedit_setup_existing(d, i); trigedit_setup_existing(d, i);
} else } else
write_to_output(d, "That trigger does not exist.\r\n"); write_to_output(d, "That trigger does not exist.\r\n");

View file

@ -186,7 +186,7 @@ obj_data *get_object_in_equip(char_data * ch, char *name)
if (id == obj->script_id) if (id == obj->script_id)
return (obj); return (obj);
} else if (is_number(name)) { } else if (is_number(name)) {
obj_vnum ovnum = atoi(name); obj_vnum ovnum = atoidx(name);
for (j = 0; j < NUM_WEARS; j++) for (j = 0; j < NUM_WEARS; j++)
if ((obj = GET_EQ(ch, j))) if ((obj = GET_EQ(ch, j)))
if (GET_OBJ_VNUM(obj) == ovnum) if (GET_OBJ_VNUM(obj) == ovnum)
@ -486,7 +486,7 @@ room_data *get_room(char *name)
if (*name == UID_CHAR) if (*name == UID_CHAR)
return find_room(atoi(name + 1)); return find_room(atoi(name + 1));
else if ((nr = real_room(atoi(name))) == NOWHERE) else if ((nr = real_room(atoidx(name))) == NOWHERE)
return NULL; return NULL;
else else
return &world[nr]; return &world[nr];
@ -944,8 +944,11 @@ ACMD(do_attach)
trig_data *trig; trig_data *trig;
char targ_name[MAX_INPUT_LENGTH], trig_name[MAX_INPUT_LENGTH]; char targ_name[MAX_INPUT_LENGTH], trig_name[MAX_INPUT_LENGTH];
char loc_name[MAX_INPUT_LENGTH], arg[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; room_rnum rnum;
IDXTYPE num_arg;
trig_vnum tn;
argument = two_arguments(argument, arg, trig_name); argument = two_arguments(argument, arg, trig_name);
two_arguments(argument, targ_name, loc_name); two_arguments(argument, targ_name, loc_name);
@ -955,8 +958,8 @@ ACMD(do_attach)
return; return;
} }
num_arg = atoi(targ_name); num_arg = atoidx(targ_name);
tn = atoi(trig_name); tn = atoidx(trig_name);
loc = (*loc_name) ? atoi(loc_name) : -1; loc = (*loc_name) ? atoi(loc_name) : -1;
if (is_abbrev(arg, "mobile") || is_abbrev(arg, "mtr")) { if (is_abbrev(arg, "mobile") || is_abbrev(arg, "mtr")) {
@ -1147,13 +1150,15 @@ ACMD(do_detach)
struct room_data *room; struct room_data *room;
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH], arg3[MAX_INPUT_LENGTH], *snum; char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH], arg3[MAX_INPUT_LENGTH], *snum;
char *trigger = 0; char *trigger = 0;
int num_arg, tn, rn; IDXTYPE num_arg;
trig_vnum tn;
trig_rnum rn;
room_rnum rnum; room_rnum rnum;
trig_data *trig; trig_data *trig;
argument = two_arguments(argument, arg1, arg2); argument = two_arguments(argument, arg1, arg2);
one_argument(argument, arg3); one_argument(argument, arg3);
tn = atoi(arg3); tn = atoidx(arg3);
rn = real_trigger(tn); rn = real_trigger(tn);
trig = read_trigger(rn); trig = read_trigger(rn);
@ -1164,7 +1169,7 @@ ACMD(do_detach)
} }
/* vnum of mob/obj, if given */ /* vnum of mob/obj, if given */
num_arg = atoi(arg2); num_arg = atoidx(arg2);
if (!str_cmp(arg1, "room") || !str_cmp(arg1, "wtr")) { if (!str_cmp(arg1, "room") || !str_cmp(arg1, "wtr")) {
if (!*arg3 || (strchr(arg2, '.'))) 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; char_data *c=NULL;
obj_data *o=NULL; obj_data *o=NULL;
room_data *r=NULL; room_data *r=NULL;
long trignum, id; long id;
trig_rnum trignum;
id_p = two_arguments(cmd, arg, trignum_s); id_p = two_arguments(cmd, arg, trignum_s);
skip_spaces(&id_p); 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 */ /* 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))) { if (trignum == NOTHING || !(newtrig=read_trigger(trignum))) {
script_log("Trigger: %s, VNum %d. attach invalid trigger: '%s'", script_log("Trigger: %s, VNum %d. attach invalid trigger: '%s'",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), trignum_s); GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), trignum_s);
@ -2725,7 +2731,7 @@ trig_rnum real_trigger(trig_vnum vnum)
bot = 0; bot = 0;
top = top_of_trigt - 1; 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); return (NOTHING);
/* perform binary search on trigger-table */ /* perform binary search on trigger-table */
@ -2749,7 +2755,7 @@ ACMD(do_tstat)
half_chop(argument, str, argument); half_chop(argument, str, argument);
if (*str) { if (*str) {
rnum = real_trigger(atoi(str)); rnum = real_trigger(atoidx(str));
if (rnum == NOTHING) { if (rnum == NOTHING) {
send_to_char(ch, "That vnum does not exist.\r\n"); send_to_char(ch, "That vnum does not exist.\r\n");
return; return;
@ -3096,7 +3102,7 @@ bool check_flags_by_name_ar(int *array, int numflags, char *search, const char *
return FALSE; 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; trig_data *t;

View file

@ -16,6 +16,7 @@
#define _DG_SCRIPTS_H_ #define _DG_SCRIPTS_H_
#include "utils.h" /* To make sure ACMD is defined */ #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 MOB_TRIGGER 0
#define OBJ_TRIGGER 1 #define OBJ_TRIGGER 1
@ -191,14 +192,6 @@ struct script_memory {
struct script_memory *next; 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 */ /* function prototypes from dg_triggers.c */
char *one_phrase(char *arg, char *first_arg); char *one_phrase(char *arg, char *first_arg);
int is_substring(char *sub, char *string); 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 read_saved_vars_ascii(FILE *file, struct char_data *ch, int count);
void save_char_vars_ascii(FILE *file, struct char_data *ch); 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 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 */ /* 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. */ /* Thanks to Chris Gilbert for reminding me that there are other options. */

View file

@ -98,7 +98,7 @@ int item_in_list(char *item, obj_data *list)
count += item_in_list(item, i->contains); count += item_in_list(item, i->contains);
} }
} else if (is_number(item)) { /* check for vnum */ } 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) { for (i = list; i; i = i->next_content) {
if (GET_OBJ_VNUM(i) == ovnum) 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; struct room_data *room, *r = NULL;
char *name; char *name;
int num, count, i, j, doors; int num, count, i, j, doors;
IDXTYPE idx;
char *log_cmd[] = {"mlog ", "olog ", "wlog " }; char *log_cmd[] = {"mlog ", "olog ", "wlog " };
char *send_cmd[] = {"msend ", "osend ", "wsend " }; char *send_cmd[] = {"msend ", "osend ", "wsend " };
@ -429,7 +430,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
return; return;
} }
else if (!str_cmp(var, "people")) { 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; return;
} }
else if (!str_cmp(var, "happyhour")) { 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"); script_log("findmob.vnum(mvnum) - illegal syntax");
strcpy(str, "0"); strcpy(str, "0");
} else { } else {
room_rnum rrnum = real_room(atoi(field)); room_rnum rrnum = real_room(atoidx(field));
mob_vnum mvnum = atoi(subfield); mob_vnum mvnum = atoidx(subfield);
if (rrnum == NOWHERE) { if (rrnum == NOWHERE) {
script_log("findmob.vnum(ovnum): No room with vnum %d", atoi(field)); 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"); script_log("findobj.vnum(ovnum) - illegal syntax");
strcpy(str, "0"); strcpy(str, "0");
} else { } else {
room_rnum rrnum = real_room(atoi(field)); room_rnum rrnum = real_room(atoidx(field));
if (rrnum == NOWHERE) { if (rrnum == NOWHERE) {
script_log("findobj.vnum(ovnum): No room with vnum %d", atoi(field)); 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")) else if (!str_cmp(field, "questdone"))
{ {
if (!IS_NPC(c) && subfield && *subfield) { if (!IS_NPC(c) && subfield && *subfield) {
int q_num = atoi(subfield); qst_vnum q_num = atoidx(subfield);
if (is_complete(c, q_num)) if (is_complete(c, q_num))
strcpy(str, "1"); strcpy(str, "1");
else 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 * something like if %actor.vnum(500)%. It should return false for PC's instead
* -- Fizban 02/18 * -- 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 { } else {
if (IS_NPC(c)) if (IS_NPC(c))
snprintf(str, slen, "%d", GET_MOB_VNUM(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)) if (!(subfield && *subfield))
*str = '\0'; *str = '\0';
else { else {
i = atoi(subfield); idx = atoidx(subfield);
snprintf(str, slen, "%d", trig_is_attached(SCRIPT(o), i)); snprintf(str, slen, "%d", trig_is_attached(SCRIPT(o), idx));
} }
} }
break; break;
@ -1311,7 +1312,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
case 'v': case 'v':
if (!str_cmp(field, "vnum")) if (!str_cmp(field, "vnum"))
if (subfield && *subfield) { 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 { } else {
snprintf(str, slen, "%d", GET_OBJ_VNUM(o)); 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")) { else if (!str_cmp(field, "vnum")) {
if (subfield && *subfield) { if (subfield && *subfield) {
snprintf(str, slen, "%d", (int)(r->number == atoi(subfield))); snprintf(str, slen, "%d", r->number == atoidx(subfield));
} else { } else {
snprintf(str, slen,"%d",r->number); snprintf(str, slen,"%d",r->number);
} }
} else if (!str_cmp(field, "contents")) { } else if (!str_cmp(field, "contents")) {
if (subfield && *subfield) { if (subfield && *subfield) {
for (obj = r->contents; obj; obj = obj->next_content) { 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 */ /* arg given, found */
snprintf(str, slen, "%c%ld", UID_CHAR, obj_script_id(obj)); snprintf(str, slen, "%c%ld", UID_CHAR, obj_script_id(obj));
return; return;
@ -1457,8 +1458,8 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
if (!(subfield && *subfield)) if (!(subfield && *subfield))
*str = '\0'; *str = '\0';
else { else {
i = atoi(subfield); idx = atoidx(subfield);
snprintf(str, slen, "%d", trig_is_attached(SCRIPT(r), i)); snprintf(str, slen, "%d", trig_is_attached(SCRIPT(r), idx));
} }
} }
else if (!str_cmp(field, "zonenumber")) else if (!str_cmp(field, "zonenumber"))

View file

@ -169,7 +169,7 @@ WCMD(do_wzoneecho)
if (!*room_num || !*msg) if (!*room_num || !*msg)
wld_log(room, "wzoneecho called with too few args"); 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"); wld_log(room, "wzoneecho called for nonexistant zone");
else { else {
@ -191,7 +191,7 @@ WCMD(do_wrecho)
if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish)) if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish))
wld_log(room, "wrecho: too few args"); wld_log(room, "wrecho: too few args");
else 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); newexit->exit_info = (sh_int)asciiflag_conv(value);
break; break;
case 3: /* key */ case 3: /* key */
newexit->key = atoi(value); newexit->key = atoidx(value);
break; break;
case 4: /* name */ case 4: /* name */
if (newexit->keyword) if (newexit->keyword)
@ -279,7 +279,7 @@ WCMD(do_wdoor)
strcpy(newexit->keyword, value); strcpy(newexit->keyword, value);
break; break;
case 5: /* room */ case 5: /* room */
if ((to_room = real_room(atoi(value))) != NOWHERE) if ((to_room = real_room(atoidx(value))) != NOWHERE)
newexit->to_room = to_room; newexit->to_room = to_room;
else else
wld_log(room, "wdoor: invalid door target"); wld_log(room, "wdoor: invalid door target");
@ -291,7 +291,8 @@ WCMD(do_wdoor)
WCMD(do_wteleport) WCMD(do_wteleport)
{ {
char_data *ch, *next_ch; char_data *ch, *next_ch;
room_rnum target, nr; room_rnum target;
room_vnum nr;
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
two_arguments(argument, arg1, arg2); two_arguments(argument, arg1, arg2);
@ -301,7 +302,7 @@ WCMD(do_wteleport)
return; return;
} }
nr = atoi(arg2); nr = atoidx(arg2);
target = real_room(nr); target = real_room(nr);
if (target == NOWHERE) if (target == NOWHERE)
@ -435,7 +436,7 @@ WCMD(do_wpurge)
WCMD(do_wload) WCMD(do_wload)
{ {
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int number = 0; IDXTYPE number = NOTHING;
char_data *mob; char_data *mob;
obj_data *object; obj_data *object;
char *target; char *target;
@ -445,7 +446,7 @@ WCMD(do_wload)
target = two_arguments(argument, arg1, arg2); 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"); wld_log(room, "wload: bad syntax");
return; return;
} }
@ -456,7 +457,7 @@ WCMD(do_wload)
if (!target || !*target) { if (!target || !*target) {
rnum = real_room(room->number); rnum = real_room(room->number);
} else { } 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); wld_log(room, "wload: room target vnum doesn't exist (loading mob vnum %d to room %s)", number, target);
return; return;
} }
@ -564,7 +565,7 @@ WCMD(do_wat)
return; 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); else if ((ch = get_char_by_room(room, arg))) loc = IN_ROOM(ch);
if (loc == NOWHERE) { if (loc == NOWHERE) {
@ -577,7 +578,8 @@ WCMD(do_wat)
WCMD(do_wmove) WCMD(do_wmove)
{ {
obj_data *obj, *next_obj; obj_data *obj, *next_obj;
room_rnum target, nr; room_rnum target;
room_vnum nr;
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
two_arguments(argument, arg1, arg2); two_arguments(argument, arg1, arg2);
@ -587,7 +589,7 @@ WCMD(do_wmove)
return; return;
} }
nr = atoi(arg2); nr = atoidx(arg2);
target = real_room(nr); target = real_room(nr);
if (target == NOWHERE) { if (target == NOWHERE) {

View file

@ -330,7 +330,7 @@ ACMD(do_export_zone)
return; return;
} }
zvnum = atoi(argument); zvnum = atoidx(argument);
zrnum = real_zone(zvnum); zrnum = real_zone(zvnum);
if (zrnum == NOWHERE) { if (zrnum == NOWHERE) {

View file

@ -300,7 +300,7 @@ void hcontrol_list_houses(struct char_data *ch, char *arg)
if (*arg == '.') if (*arg == '.')
toshow = GET_ROOM_VNUM(IN_ROOM(ch)); toshow = GET_ROOM_VNUM(IN_ROOM(ch));
else else
toshow = atoi(arg); toshow = atoidx(arg);
if ((i = find_house(toshow)) == NOWHERE) { if ((i = find_house(toshow)) == NOWHERE) {
send_to_char(ch, "Unknown house, \"%s\".\r\n", arg); 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); send_to_char(ch, "%s", HCONTROL_FORMAT);
return; return;
} }
virt_house = atoi(arg1); virt_house = atoidx(arg1);
if ((real_house = real_room(virt_house)) == NOWHERE) { if ((real_house = real_room(virt_house)) == NOWHERE) {
send_to_char(ch, "No such room exists.\r\n"); send_to_char(ch, "No such room exists.\r\n");
return; return;
@ -436,17 +436,17 @@ static void hcontrol_destroy_house(struct char_data *ch, char *arg)
send_to_char(ch, "%s", HCONTROL_FORMAT); send_to_char(ch, "%s", HCONTROL_FORMAT);
return; return;
} }
if ((i = find_house(atoi(arg))) == NOWHERE) { if ((i = find_house(atoidx(arg))) == NOWHERE) {
send_to_char(ch, "Unknown house.\r\n"); send_to_char(ch, "Unknown house.\r\n");
return; return;
} }
if ((real_atrium = real_room(house_control[i].atrium)) == NOWHERE) 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 else
REMOVE_BIT_AR(ROOM_FLAGS(real_atrium), ROOM_ATRIUM); REMOVE_BIT_AR(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
if ((real_house = real_room(house_control[i].vnum)) == NOWHERE) 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 { else {
REMOVE_BIT_AR(ROOM_FLAGS(real_house), ROOM_HOUSE); REMOVE_BIT_AR(ROOM_FLAGS(real_house), ROOM_HOUSE);
REMOVE_BIT_AR(ROOM_FLAGS(real_house), ROOM_PRIVATE); 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) if (!*arg)
send_to_char(ch, "%s", HCONTROL_FORMAT); 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"); send_to_char(ch, "Unknown house.\r\n");
else { else {
mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "Payment for house %s collected by %s.", arg, GET_NAME(ch)); mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "Payment for house %s collected by %s.", arg, GET_NAME(ch));

View file

@ -37,7 +37,9 @@ static room_vnum redit_find_new_vnum(zone_rnum zone);
***********************************************************/ ***********************************************************/
ACMD(do_oasis_copy) 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 buf1[MAX_INPUT_LENGTH];
char buf2[MAX_INPUT_LENGTH]; char buf2[MAX_INPUT_LENGTH];
struct descriptor_data *d; struct descriptor_data *d;
@ -82,7 +84,7 @@ ACMD(do_oasis_copy)
/* We can't copy non-existing data. */ /* We can't copy non-existing data. */
/* Note: the source data can be in any zone. It's not restricted */ /* Note: the source data can be in any zone. It's not restricted */
/* to the builder's designated OLC zone. */ /* 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); src_rnum = (*oasis_copy_info[i].binary_search)(src_vnum);
if (src_rnum == NOWHERE) { if (src_rnum == NOWHERE) {
send_to_char(ch, "The source %s (#%d) does not exist.\r\n", oasis_copy_info[i].text, src_vnum); 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. */ /* 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); dst_rnum = (*oasis_copy_info[i].binary_search)(dst_vnum);
if (dst_rnum != NOWHERE) { if (dst_rnum != NOWHERE) {
send_to_char(ch, "The target %s (#%d) already exists.\r\n", oasis_copy_info[i].text, dst_vnum); send_to_char(ch, "The target %s (#%d) already exists.\r\n", oasis_copy_info[i].text, dst_vnum);

View file

@ -375,7 +375,7 @@ ACMD(do_oasis_list)
if (!*smin || *smin == '.') { if (!*smin || *smin == '.') {
rzone = world[IN_ROOM(ch)].zone; rzone = world[IN_ROOM(ch)].zone;
} else if (!*smax) { } else if (!*smax) {
rzone = real_zone(atoi(smin)); rzone = real_zone(atoidx(smin));
if ((rzone == NOWHERE || rzone == 0) && subcmd == SCMD_OASIS_ZLIST && !isdigit(*smin)) { if ((rzone == NOWHERE || rzone == 0) && subcmd == SCMD_OASIS_ZLIST && !isdigit(*smin)) {
/* Must be zlist, with builder name as arg */ /* Must be zlist, with builder name as arg */
@ -521,7 +521,7 @@ ACMD(do_oasis_links)
zrnum = world[IN_ROOM(ch)].zone; zrnum = world[IN_ROOM(ch)].zone;
zvnum = zone_table[zrnum].number; zvnum = zone_table[zrnum].number;
} else { } else {
zvnum = atoi(arg); zvnum = atoidx(arg);
zrnum = real_zone(zvnum); zrnum = real_zone(zvnum);
} }

View file

@ -51,7 +51,9 @@ static void oedit_save_to_disk(int zone_num);
/* Utility and exported functions */ /* Utility and exported functions */
ACMD(do_oasis_oedit) 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; struct descriptor_data *d;
char buf1[MAX_STRING_LENGTH]; char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH]; char buf2[MAX_STRING_LENGTH];
@ -76,7 +78,7 @@ ACMD(do_oasis_oedit)
save = TRUE; save = TRUE;
if (is_number(buf2)) if (is_number(buf2))
number = atoi(buf2); number = atoidx(buf2);
else if (GET_OLC_ZONE(ch) > 0) { else if (GET_OLC_ZONE(ch) > 0) {
zone_rnum zlok; zone_rnum zlok;
@ -94,7 +96,7 @@ ACMD(do_oasis_oedit)
/* If a numeric argument was given, get it. */ /* If a numeric argument was given, get it. */
if (number == NOWHERE) if (number == NOWHERE)
number = atoi(buf1); number = atoidx(buf1);
if (number < IDXTYPE_MIN || number > IDXTYPE_MAX) { if (number < IDXTYPE_MIN || number > IDXTYPE_MAX) {
send_to_char(ch, "That object VNUM can't exist.\r\n"); 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; break;
case OEDIT_COPY: case OEDIT_COPY:
if ((number = real_object(atoi(arg))) != NOTHING) { if ((number = real_object(atoidx(arg))) != NOTHING) {
oedit_setup_existing(d, number); oedit_setup_existing(d, number);
} else } else
write_to_output(d, "That object does not exist.\r\n"); write_to_output(d, "That object does not exist.\r\n");

View file

@ -400,7 +400,7 @@ int load_char(const char *name, struct char_data *ch)
break; break;
case 'O': case 'O':
if (!strcmp(tag, "Olc ")) GET_OLC_ZONE(ch) = atoi(line); if (!strcmp(tag, "Olc ")) GET_OLC_ZONE(ch) = atoidx(line);
break; break;
case 'P': case 'P':
@ -429,7 +429,7 @@ int load_char(const char *name, struct char_data *ch)
break; break;
case 'R': case 'R':
if (!strcmp(tag, "Room")) GET_LOADROOM(ch) = atoi(line); if (!strcmp(tag, "Room")) GET_LOADROOM(ch) = atoidx(line);
break; break;
case 'S': 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, "Thr5")) GET_SAVE(ch, 4) = atoi(line);
else if (!strcmp(tag, "Titl")) GET_TITLE(ch) = strdup(line); else if (!strcmp(tag, "Titl")) GET_TITLE(ch) = strdup(line);
else if (!strcmp(tag, "Trig") && CONFIG_SCRIPT_PLAYERS) { 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); t = read_trigger(t_rnum);
if (!SCRIPT(ch)) if (!SCRIPT(ch))
CREATE(SCRIPT(ch), struct script_data, 1); CREATE(SCRIPT(ch), struct script_data, 1);

View file

@ -692,7 +692,7 @@ void qedit_parse(struct descriptor_data *d, char *arg)
return; return;
} }
} }
OLC_QUEST(d)->next_quest = (number == -1 ? NOTHING : atoi(arg)); OLC_QUEST(d)->next_quest = (number == -1 ? NOTHING : atoidx(arg));
break; break;
case QEDIT_PREVQUEST: case QEDIT_PREVQUEST:
if ((number = atoi(arg)) != -1) { if ((number = atoi(arg)) != -1) {
@ -701,7 +701,7 @@ void qedit_parse(struct descriptor_data *d, char *arg)
return; return;
} }
} }
OLC_QUEST(d)->prev_quest = (number == -1 ? NOTHING : atoi(arg)); OLC_QUEST(d)->prev_quest = (number == -1 ? NOTHING : atoidx(arg));
break; break;
case QEDIT_GOLD: case QEDIT_GOLD:
OLC_QUEST(d)->gold_reward = LIMIT(number, 0, 99999); OLC_QUEST(d)->gold_reward = LIMIT(number, 0, 99999);

View file

@ -653,7 +653,7 @@ static void quest_stat(struct char_data *ch, char argument[MAX_INPUT_LENGTH])
if (!*argument) if (!*argument)
send_to_char(ch, "%s\r\n", quest_imm_usage); 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"); send_to_char(ch, "That quest does not exist.\r\n");
else { else {
sprintbit(QST_FLAGS(rnum), aq_flags, buf, sizeof(buf)); sprintbit(QST_FLAGS(rnum), aq_flags, buf, sizeof(buf));

View file

@ -57,7 +57,7 @@ ACMD(do_oasis_redit)
save = TRUE; save = TRUE;
if (is_number(buf2)) if (is_number(buf2))
number = atoi(buf2); number = atoidx(buf2);
else if (GET_OLC_ZONE(ch) != NOWHERE) { else if (GET_OLC_ZONE(ch) != NOWHERE) {
zone_rnum zlok; zone_rnum zlok;
@ -75,7 +75,7 @@ ACMD(do_oasis_redit)
/* If a numeric argument was given (like a room number), get it. */ /* If a numeric argument was given (like a room number), get it. */
if (number == NOWHERE) if (number == NOWHERE)
number = atoi(buf1); number = atoidx(buf1);
if (number < IDXTYPE_MIN || number > IDXTYPE_MAX) { if (number < IDXTYPE_MIN || number > IDXTYPE_MAX) {
send_to_char(ch, "That room VNUM can't exist.\r\n"); send_to_char(ch, "That room VNUM can't exist.\r\n");
@ -799,10 +799,7 @@ void redit_parse(struct descriptor_data *d, char *arg)
return; return;
case REDIT_EXIT_KEY: case REDIT_EXIT_KEY:
number = atoi(arg); number = atoidx(arg);
if (number < 0)
OLC_EXIT(d)->key = NOTHING;
else
OLC_EXIT(d)->key = number; OLC_EXIT(d)->key = number;
redit_disp_exit_menu(d); redit_disp_exit_menu(d);
return; return;
@ -886,7 +883,7 @@ void redit_parse(struct descriptor_data *d, char *arg)
break; break;
case REDIT_COPY: case REDIT_COPY:
if ((number = real_room(atoi(arg))) != NOWHERE) { if ((number = real_room(atoidx(arg))) != NOWHERE) {
redit_setup_existing(d, number); redit_setup_existing(d, number);
} else } else
write_to_output(d, "That room does not exist.\r\n"); write_to_output(d, "That room does not exist.\r\n");

View file

@ -72,7 +72,7 @@ ACMD(do_oasis_sedit)
save = TRUE; save = TRUE;
if (is_number(buf2)) if (is_number(buf2))
number = atoi(buf2); number = atoidx(buf2);
else if (GET_OLC_ZONE(ch) > 0) { else if (GET_OLC_ZONE(ch) > 0) {
zone_rnum zlok; zone_rnum zlok;
@ -90,7 +90,7 @@ ACMD(do_oasis_sedit)
/* If a numeric argument was given, get it. */ /* If a numeric argument was given, get it. */
if (number == NOWHERE) if (number == NOWHERE)
number = atoi(buf1); number = atoidx(buf1);
if (number < IDXTYPE_MIN || number > IDXTYPE_MAX) { if (number < IDXTYPE_MIN || number > IDXTYPE_MAX) {
send_to_char(ch, "That shop VNUM can't exist.\r\n"); send_to_char(ch, "That shop VNUM can't exist.\r\n");

View file

@ -1506,7 +1506,7 @@ void show_shops(struct char_data *ch, char *arg)
return; return;
} }
} else if (is_number(arg)) } else if (is_number(arg))
shop_nr = real_shop(atoi(arg)); shop_nr = real_shop(atoidx(arg));
else else
shop_nr = -1; shop_nr = -1;

View file

@ -1081,6 +1081,13 @@ struct descriptor_data {
struct list_data * events; 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 */ /* other miscellaneous structures */
/** Fight message display. This structure is used to hold the information to /** Fight message display. This structure is used to hold the information to
* be displayed for every different violent hit type. */ * be displayed for every different violent hit type. */

View file

@ -1239,7 +1239,7 @@ size_t file_sizeof( FILE *file )
int file_numlines( FILE *file ) int file_numlines( FILE *file )
{ {
int numlines = 0; int numlines = 0;
char c; int c;
rewind(file); rewind(file);
@ -1257,6 +1257,23 @@ int file_numlines( FILE *file )
return numlines; 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. /** A string converter designed to deal with the compile sensitive IDXTYPE.
* Relies on the friendlier strtol function. * Relies on the friendlier strtol function.
@ -1266,16 +1283,11 @@ int file_numlines( FILE *file )
*/ */
IDXTYPE atoidx( const char *str_to_conv ) IDXTYPE atoidx( const char *str_to_conv )
{ {
long int result; const long int result = parse_long(str_to_conv);
/* Check for errors */ if (errno || result > IDXTYPE_MAX || result < 0)
errno = 0;
result = strtol(str_to_conv, NULL, 10);
if ( errno || (result > IDXTYPE_MAX) || (result < 0) )
return NOWHERE; /* All of the NO* settings should be the same */ return NOWHERE; /* All of the NO* settings should be the same */
else
return (IDXTYPE)result; return (IDXTYPE)result;
} }

View file

@ -64,6 +64,8 @@ int file_tail(FILE *file, char *buf, size_t bufsize, int lines_to_read);
size_t file_sizeof(FILE *file); size_t file_sizeof(FILE *file);
int file_numlines(FILE *file); int file_numlines(FILE *file);
IDXTYPE atoidx(const char *str_to_conv); 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 *strfrmt(char *str, int w, int h, int justify, int hpad, int vpad);
char *strpaste(char *str1, char *str2, char *joiner); char *strpaste(char *str1, char *str2, char *joiner);
void new_affect(struct affected_type *af); void new_affect(struct affected_type *af);

View file

@ -978,7 +978,7 @@ void zedit_parse(struct descriptor_data *d, char *arg)
} }
switch (OLC_CMD(d).command) { switch (OLC_CMD(d).command) {
case 'M': case 'M':
if ((pos = real_mobile(atoi(arg))) != NOBODY) { if ((pos = real_mobile(atoidx(arg))) != NOBODY) {
OLC_CMD(d).arg1 = pos; OLC_CMD(d).arg1 = pos;
zedit_disp_arg2(d); zedit_disp_arg2(d);
} else } else
@ -988,7 +988,7 @@ void zedit_parse(struct descriptor_data *d, char *arg)
case 'P': case 'P':
case 'E': case 'E':
case 'G': case 'G':
if ((pos = real_object(atoi(arg))) != NOTHING) { if ((pos = real_object(atoidx(arg))) != NOTHING) {
OLC_CMD(d).arg1 = pos; OLC_CMD(d).arg1 = pos;
zedit_disp_arg2(d); zedit_disp_arg2(d);
} else } else
@ -1044,8 +1044,8 @@ void zedit_parse(struct descriptor_data *d, char *arg)
OLC_MODE(d) = ZEDIT_SARG1; OLC_MODE(d) = ZEDIT_SARG1;
break; break;
case 'T': case 'T':
if (real_trigger(atoi(arg)) != NOTHING) { if (real_trigger(atoidx(arg)) != NOTHING) {
OLC_CMD(d).arg2 = real_trigger(atoi(arg)); /* trigger */ OLC_CMD(d).arg2 = real_trigger(atoidx(arg)); /* trigger */
OLC_CMD(d).arg3 = real_room(OLC_NUM(d)); OLC_CMD(d).arg3 = real_room(OLC_NUM(d));
zedit_disp_menu(d); zedit_disp_menu(d);
} else } else
@ -1062,7 +1062,7 @@ void zedit_parse(struct descriptor_data *d, char *arg)
} }
break; break;
case 'R': case 'R':
if ((pos = real_object(atoi(arg))) != NOTHING) { if ((pos = real_object(atoidx(arg))) != NOTHING) {
OLC_CMD(d).arg2 = pos; OLC_CMD(d).arg2 = pos;
zedit_disp_menu(d); zedit_disp_menu(d);
} else } else
@ -1096,7 +1096,7 @@ void zedit_parse(struct descriptor_data *d, char *arg)
} }
break; break;
case 'P': case 'P':
if ((pos = real_object(atoi(arg))) != NOTHING) { if ((pos = real_object(atoidx(arg))) != NOTHING) {
OLC_CMD(d).arg3 = pos; OLC_CMD(d).arg3 = pos;
zedit_disp_menu(d); zedit_disp_menu(d);
} else } else