struct exit_data {
EXIT_DATA *next;
union {
ROOM_INDEX_DATA * to_room;
short int vnum;
} u1;
int exit_info;
short int key;
char * keyword;
char * description;
int rs_flags;
long spell_flags;
short int size;
AFFECT_DATA * affected;
};
void checkexits (ROOM_INDEX_DATA *room, AREA_DATA *pArea, char* buffer)
{
char buf[MAX_STRING_LENGTH];
int i;
EXIT_DATA *exit;
strcpy (buffer, "");
for (i = 0; i < 6; i++)
{
exit = room->exit[i];
if (!exit)
continue;
else
to_room = exit->to_room;
if (to_room) /* there is something on the other side */
if ( (room->area == pArea) && (to_room->area != pArea) )
{ /* an exit from our area to another area */
/* check first if it is a two-way exit */
if ( to_room->exit[opposite_dir[i]] &&
to_room->exit[opposite_dir[i]]->to_room == room )
room_pair (room,to_room,exit_both,buf); /* <> */
else
room_pair (room,to_room,exit_to,buf); /* > */
strcat (buffer, buf);
}
else
if ( (room->area != pArea) && (exit->to_room->area == pArea) )
{ /* an exit from another area to our area */
if (!
(to_room->exit[opposite_dir[i]] &&
to_room->exit[opposite_dir[i]]->to_room == room )
)
/* two-way exits are handled in the other if */
{
room_pair (to_room,room,exit_from,buf);
strcat (buffer, buf);
}
} /* if room->area */
} /* for */
}
void checkexits (ROOM_INDEX_DATA *room, AREA_DATA *pArea, char* buffer)
{
// …
EXIT_DATA *pexit;
ROOM_INDEX_DATA *to_room;
// …
to_room = pexit->u1.to_room; // NOTE: pexit-> ->u1<-
// …
to_room->exit[opposite_dir[i]]->to_room == room ) // NOTE: exit[…]->to_room NO u1!
void checkexits (ROOM_INDEX_DATA *room, AREA_DATA *pArea, char* buffer)
{
char buf[MAX_STRING_LENGTH];
int i;
EXIT_DATA *exit;
EXIT_DATA *pexit;
ROOM_INDEX_DATA *to_room;
strcpy (buffer, "");
for (i = 0; i < 6; i++)
{
exit = room->exit[i];
if (!exit)
continue;
else
/* This is line 145 */ to_room = pexit->u1.to_room;
if (to_room) /* there is something on the other side */
if ( (room->area == pArea) && (to_room->area != pArea) )
{ /* an exit from our area to another area */
/* check first if it is a two-way exit */
if ( to_room->exit[opposite_dir[i]] &&
to_room->exit[opposite_dir[i]]->u1.to_room == room )
room_pair (room,to_room,exit_both,buf); /* <> */
else
room_pair (room,to_room,exit_to,buf); /* > */
strcat (buffer, buf);
}
else
if ( (room->area != pArea) && (exit->u1.to_room->area == pArea) )
{ /* an exit from another area to our area */
if (!
(to_room->exit[opposite_dir[i]] &&
to_room->exit[opposite_dir[i]]->u1.to_room == room )
)
/* two-way exits are handled in the other if */
{
room_pair (to_room,room,exit_from,buf);
strcat (buffer, buf);
}
} /* if room->area */
} /* for */
}
else if (letter == 'D') {
short int door = fread_number(fp);
if (door < 0 || door > (MAX_DIR -1)) {
bug("Fread_rooms: vnum %d has bad door number.", vnum);
exit(0);
}
EXIT_DATA *pexit = new_exit();
tempChar = fread_string(fp);
replace_string(&pexit->description,tempChar);
free_string(&tempChar);
tempChar = fread_string(fp);
replace_string(&pexit->keyword,tempChar);
free_string(&tempChar);
pexit->rs_flags = fread_flag(fp);
pexit->key = fread_number(fp);
pexit->u1.vnum = fread_number(fp); <- this is where I fill the value but that means it is in the file in the first place
if (pexit->u1.vnum == 0)
pexit->u1.vnum = 1;
pexit->size = fread_number(fp);
Program received signal SIGSEGV, Segmentation fault.
checkexits (room=0xb7df9340, pArea=0xb7d665fc, buffer=0xbfdeb41c "") at wizutil.c:145
145 to_room = pexit->u1.to_room;
EXIT_DATA *pexit;
ROOM_INDEX_DATA *to_room;
strcpy (buffer, "");
for (i = 0; i < 6; i++)
{
exit = room->exit[i];
if (!exit)
continue;
else
/* This is line 145 */ to_room = pexit->u1.to_room;
[code]
Look at the code pexit at this point has not even been defined, and I cannot see any other reference to pexit in the code you posted.
This code is crap. (should have started by that….)
I am trying to put in the Erwin snippet for wizutil.v3 and am coming across some errors with the checkexits function. Here it is.
When I compile, I'm getting these messages:
gcc -c -Wall -O -ggdb wizutil.c
wizutil.c: In function checkexits:
wizutil.c:154: error: EXIT_DATA has no member named to_room
wizutil.c:162: error: EXIT_DATA has no member named to_room
wizutil.c:167: error: EXIT_DATA has no member named to_room
Any thoughts on how to fix it? Thanks.