void save_rooms( FILE *fp, AREA_DATA *pArea )
{
ROOM_INDEX_DATA *pRoomIndex;
EXTRA_DESCR_DATA *pEd;
EXIT_DATA *pExit;
int iHash;
int door;
char buf[MAX_STRING_LENGTH];
fprintf( fp, "#ROOMS\n" );
for( iHash = 0; iHash < MAX_KEY_HASH; iHash++ )
{
for( pRoomIndex = room_index_hash[iHash]; pRoomIndex; pRoomIndex = pRoomIndex->next )
{
if ( pRoomIndex->area == pArea )
{
fprintf( fp, "#%d\n", pRoomIndex->vnum );
fprintf( fp, "%s~\n", pRoomIndex->name );
fprintf( fp, "%s~\n", fix_string( pRoomIndex->description ) );
fprintf( fp, "0 " );
fprintf( fp, "%d ", pRoomIndex->room_flags );
fprintf( fp, "%d\n", pRoomIndex->sector_type );
if(pRoomIndex->car > 0 && get_room_index(pRoomIndex->car))
{
fprintf( fp, "V\n%d %d\n", pRoomIndex->car,
get_stop(get_room_index(pRoomIndex->car), pRoomIndex) );
}
fprintf( fp, "E\nXNUMB1~\n%s~\n", pRoomIndex->uname ? pRoomIndex->uname : "");
fprintf( fp, "E\nXDUMB1~\n%s~\n", fix_string(pRoomIndex->udescription) );
fprintf( fp, "E\nXNDREAM~\n%s~\n", pRoomIndex->dname ? pRoomIndex->dname : "" );
fprintf( fp, "E\nXDDREAM~\n%s~\n", fix_string(pRoomIndex->ddescription) );
for ( pEd = pRoomIndex->extra_descr; pEd;
pEd = pEd->next )
{
fprintf( fp, "E\n%s~\n%s~\n", pEd->keyword,
fix_string( pEd->description ) );
}
for( door = 0; door < MAX_DIR; door++ ) /* I hate this! */
{
pExit = pRoomIndex->exit[door];
if(pExit)
{
fprintf( fp, "D%d\n", pExit->orig_door );
fprintf( fp, "%s~\n", fix_string( pExit->description ) );
fprintf( fp, "%s~\n", pExit->keyword );
fprintf( fp, "%s %d %d\n", fwrite_flag( pExit->exit_info, buf ),
pExit->key,
pExit->u1.to_room == NULL ? 0 : pExit->u1.to_room->vnum );
if(pExit->jumpto.to_room)
{
fprintf( fp, "J%d %d\n", pExit->orig_door,
pExit->jumpto.to_room == NULL ? 0 : pExit->jumpto.to_room->vnum);
}
}
}
if (pRoomIndex->mana_rate != 100 || pRoomIndex->heal_rate != 100)
fprintf ( fp, "M %d H %d\n",pRoomIndex->mana_rate,
pRoomIndex->heal_rate);
if (pRoomIndex->clan > 0)
fprintf ( fp, "C %s~\n" , clan_table[pRoomIndex->clan].name );
if (pRoomIndex->owner[0] != '\0')
fprintf ( fp, "O %s~\n" , pRoomIndex->owner );
fprintf( fp, "S\n" );
}
}
}
fprintf( fp, "#0\n\n\n\n" );
return;
}
void load_rooms( FILE *fp )
{
ROOM_INDEX_DATA *pRoomIndex;
if ( area_last == NULL )
{
bug( "Load_resets: no #AREA seen yet.", 0 );
exit( 1 );
}
if ( !area_last ) /* OLC */
{
bug( "Load_rooms: no #AREA seen yet.", 0 );
exit( 1 );
}
for ( ; ; )
{
sh_int vnum;
char letter;
int door;
int iHash;
letter = fread_letter( fp );
if ( letter != '#' )
{
bug( "Load_rooms: # not found.", 0 );
exit( 1 );
}
vnum = fread_number( fp );
if ( vnum == 0 )
break;
fBootDb = FALSE;
if ( get_room_index( vnum ) != NULL )
{
bug( "Load_rooms: vnum %d duplicated.", vnum );
exit( 1 );
}
fBootDb = TRUE;
pRoomIndex = new_room_index();
free_string( pRoomIndex->owner );
pRoomIndex->owner = str_dup("");
pRoomIndex->people = NULL;
pRoomIndex->contents = NULL;
pRoomIndex->extra_descr = NULL;
pRoomIndex->area = area_last;
pRoomIndex->vnum = vnum;
pRoomIndex->name = fread_string( fp );
pRoomIndex->description = fread_string( fp );
/* Area number */ fread_number( fp );
pRoomIndex->room_flags = fread_flag( fp );
pRoomIndex->sector_type = fread_number( fp );
pRoomIndex->light = 0;
for ( door = 0; door <= 5; door++ )
pRoomIndex->exit[door] = NULL;
/* defaults */
pRoomIndex->heal_rate = 100;
for ( ; ; )
{
letter = fread_letter( fp );
if ( letter == 'S' )
break;
if ( letter == 'H') /* healing room */
pRoomIndex->heal_rate = fread_number(fp);
else if ( letter == 'M') /* mana room */
pRoomIndex->mana_rate = fread_number(fp);
else if ( letter == 'C') /* clan */
{
if (pRoomIndex->clan)
{
bug("Load_rooms: duplicate clan fields.",0);
exit(1);
}
pRoomIndex->clan = clan_lookup(fread_string(fp));
}
else if ( letter == 'D' )
{
EXIT_DATA *pexit;
door = fread_number( fp );
if ( door < 0 || door > 5 )
{
bug( "Fread_rooms: vnum %d has bad door number.", vnum );
exit( 1 );
}
pexit = alloc_perm( sizeof(*pexit) );
pexit->description = fread_string( fp );
pexit->keyword = fread_string( fp );
pexit->exit_info = fread_flag( fp );
pexit->rs_flags = pexit->exit_info; /* OLC */
pexit->key = fread_number( fp );
pexit->u1.vnum = fread_number( fp );
pexit->orig_door = door; /* OLC */
pRoomIndex->exit[door] = pexit;
pRoomIndex->old_exit[door] = pexit;
top_exit++;
}
else if ( letter == 'E' )
{
EXTRA_DESCR_DATA *ed;
ed = new_extra_descr();
ed->keyword = fread_string( fp );
ed->description = fread_string( fp );
ed->timer = -1;
if(!str_cmp(ed->keyword, "XDUMB1"))
{
pRoomIndex->udescription = ed->description;
free_extra_descr(ed);
}
else if(!str_cmp(ed->keyword, "XNUMB1"))
{
pRoomIndex->uname = ed->description;
free_extra_descr(ed);
}
else if(!str_cmp(ed->keyword, "XNDREAM"))
{
pRoomIndex->dname = ed->description;
free_extra_descr(ed);
}
else if(!str_cmp(ed->keyword, "XDDREAM"))
{
pRoomIndex->ddescription = ed->description;
free_extra_descr(ed);
}
else
{
ed->next = pRoomIndex->extra_descr;
pRoomIndex->extra_descr = ed;
top_ed++;
}
}
else if ( letter == 'J' )
{
EXIT_DATA *pexit;
door = fread_number( fp );
if ( door < 0 || door > 5 )
{
bug( "Fread_rooms: vnum %d has bad jumpto.", vnum );
}
else
{
pexit = pRoomIndex->exit[door];
pexit->jumpto.vnum = fread_number( fp );
}
}
else if (letter == 'O')
{
if (pRoomIndex->owner[0] != '\0')
{
bug("Load_rooms: duplicate owner.",0);
exit(1);
}
free_string(pRoomIndex->owner);
pRoomIndex->owner = fread_string(fp);
}
else if (letter == 'V') /* Vehicle/Train/Elevator */
{
if(!IS_SET(pRoomIndex->room_flags, ROOM_STOP)
&& !IS_SET(pRoomIndex->room_flags, ROOM_VEHICLE)
&& !IS_SET(pRoomIndex->room_flags, ROOM_ELEVATOR))
{
bug("Load_rooms: Unnecessary vehicle data.", 0);
fread_number(fp);
fread_number(fp);
continue;
}
else
{
pRoomIndex->car = fread_number(fp);
pRoomIndex->stops[0] = fread_number(fp);
}
}
else
{
bug( "Load_rooms: vnum %d has flag not 'DES'.", vnum );
exit( 1 );
}
}
iHash = vnum % MAX_KEY_HASH;
pRoomIndex->next = room_index_hash[iHash];
room_index_hash[iHash] = pRoomIndex;
top_room++;
top_vnum_room = top_vnum_room < vnum ? vnum : top_vnum_room; /* OLC */
assign_area_vnum( vnum ); /* OLC */
}
return;
}
get_stop(get_room_index(pRoomIndex->car), pRoomIndex)
for(door = 1; door < MAX_CAR_STOPS; door++)
{
if(pRoom->stops[door] > 0) {
sprintf( buf, "[%d] %d ", door, pRoom->stops[door]);
strcat( buf1, buf );
}
}
pRoomIndex->stops[0] = fread_number(fp);
#12705
Elevator~
This is an elevator.
~
0 396 0
V
12704 -1
E
XNUMB1~
~
E
XDUMB1~
~
E
XNDREAM~
~
E
XDDREAM~
~
S
I've got another question. And I originally typed an e-mail before I realized that what I thought was the problem, really wasn't the problem. So, here is the problem. We have code for using elevators. And the code is comprised of two parts, the elevator code and the stop code. It is saving the stop part, but not the elevator part. Basically, you can set a room as an elevator and then from there, tell it what rooms it will stop in. It sets the STOP flag in the rooms and saves it, but doesn't save the actual elevator information, resulting in broken elevators when rebooting. Anyway…
I looked in save_rooms and I can see it saves the stops. I can see in redit that it creates the elevator, but it is not saving the elevator code. Now, I have a few questions.
1) Does it matter where in save_rooms I put the code for the elevator?
2) Does it matter where in load_rooms I put the code for the elevator?
What it is not saving is
Thoughts? Am I on the right track, missing something, or totally off base?