[CODE] [FTP] ROOM_SAVE flag

From: Russell Ryan (rjwr10@hotmail.com)
Date: 07/27/01


About the file in /contrib/code/rooms/roomsave.txt

It basically adds a ROOM_SAVE flag and at about the interval circle saves
houses, it goes through all rooms and if ROOM_SAVE is flagged, it saves
objects in the room in /lib/save/ as x.save where x is the rooms rnum.

A little problem is (well not really a problem) but an annoyance is that it
saves it using the rnum.

Suppose I have a save room with vnum 2001 rnum 1205
So now it saves as /lib/save/1205.save
Then suppose I create a room with vnum 1001.

Circle then renumbers all the rnums pushing every rooms rnum up one.
Vnum 2001's rnum is now 1206.

I reboot, when the code searches through the database for rooms marked
ROOM_SAVE it finds rnum 1206 is marker ROOM_SAVE, but hmm, theres no
1206.save so it must have no objects to load.

The objects in 1205.save wont load into rnum 1205 unless that room is marked
ROOM_SAVE though, so its not really that bad.

Anyhow, the solution is to save the file using the vnum not rnum. Its a
quite simple modification:
btw i know this works on bpl18,
ive no idea about anything else, but it should

in save_get_filename:
int save_get_filename(int i, char *filename)
{
  if (i < 0)
    return 0;

-  sprintf(filename, "save/%d.save", i);
+  sprintf(filename, "save/%d.save", world[i].number);
  return 1;
}

in save_saved
void save_saved(int i)
{
  char buf[MAX_STRING_LENGTH];
  FILE *fll;

  if (i == -1)
    return;

-   sprintf(buf, "save/%d.save", i);
+   sprintf(buf, "save/%d.save", world[i].number);
//rest of function skipped

Thats it! Simple eh?

Credits go to The Dark One (Reza Nejad) <naxos@tiac.net> for designing the
original roomsave.txt. I really like it.

Sorry if this was a bit long, but I thought it would be useful to those who
use the room saving code.

regards,
rj

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/06/01 PST