01 Jul, 2011, arholly wrote in the 1st comment:
Votes: 0
Hello:
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.
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
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]]->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 */

}


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.
01 Jul, 2011, Rarva.Riendf wrote in the 2nd comment:
Votes: 0
My EXIT_DATA
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;
};

Obviously you do without ROOM_INDEX_DATA * to_room; right now.
01 Jul, 2011, arholly wrote in the 3rd comment:
Votes: 0
Ok, so I did that and got this:
wizutil.c:143: error: to_room undeclared (first use in this function)
wizutil.c:143: error: (Each undeclared identifier is reported only once
wizutil.c:143: error: for each function it appears in.)
wizutil.c:143: error: EXIT_DATA has no member named to_room
wizutil.c:160: error: EXIT_DATA has no member named to_room

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 */

}
01 Jul, 2011, Kaz wrote in the 4th comment:
Votes: 0
arholly said:
Hello:
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.


I think the clue is in the code, as well as the EXIT_DATA structure. If it matches with Rarva's, then the problem is quite simple:

Quote
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!


I believe you need to change ->to_room into ->u1.to_room on the lines specified in the error message.


(Caveat that you may not need to read: u1 is a union. I presume that the vnum variable is loaded when parsing .are files, and then *all* of them switch over to the to_room variable after all files have been loaded, so that you never need worry about whether vnum or to_room is the active variable in the union)
01 Jul, 2011, arholly wrote in the 5th comment:
Votes: 0
OK, I did that. But it was then crashing when I ran the command (exlist). So, I started up the in gdb and this is what it gave me.
Quote
Program received signal SIGSEGV, Segmentation fault.
checkexits (room=0xb7dcc72c, pArea=0xb7d4a5d4, buffer=0xbfee4d0c "")
at wizutil.c:145
145 to_room = pexit->u1.to_room;


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 */

}


Thoughts, help?
02 Jul, 2011, Rarva.Riendf wrote in the 6th comment:
Votes: 0
You have to fill the values while loading the areas otherwise of course it will be null. Look where exit are created

in db.c some of the code shoud looks like this

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);
03 Jul, 2011, arholly wrote in the 7th comment:
Votes: 0
Tried that, still getting the same problem.
Program received signal SIGSEGV, Segmentation fault.
checkexits (room=0xb7df9340, pArea=0xb7d665fc, buffer=0xbfdeb41c "") at wizutil.c:145
145 to_room = pexit->u1.to_room;
03 Jul, 2011, Rarva.Riendf wrote in the 8th comment:
Votes: 0
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….)
03 Jul, 2011, arholly wrote in the 9th comment:
Votes: 0
OK, I got it figured out. Thanks.
0.0/9