ID:149087
 
The following is my rather complicated mud saving code. The basic thing I am attempting to accomplish here, is this...

Save_Area()
First loop
1) Check all the rooms currently in the game
2) make sure they have a vnum
3) save them to a file, all named by vnum
4) add them to the master save/load list
Second loop is debugging info, note that NOTHING shows up during runtime from this second loop
5) save the master save/load list to room.list

Load_Area()
1) Load the master save/load list from room.list
First loop
2) Check all the rooms currently in the game
3) Move all 'live' mobiles to null
4) Delete the room
Second loop
5) Scan through the master list
6) Load each item found in the master list to a new room (note that these are saved by vnums, and the master list consists of vnums. Too bad the master list doesn't exist, read the second loop section of Save_Area())
7) Add the new room to the world_rooms list
Third (and final) loop is more debugging info



mob/proc
Save_Area()
var/save_rooms[]
for(var/room/R in world_rooms)
if(R.vnum)
world << "[R] in world_rooms"
var/savefile/S
S = new(file("areas/[R.vnum].room"))
S << R
world << "[R.name] ([R.vnum]) saved to [S]"
save_rooms += "[R.vnum]"
for(var/O in save_rooms)
world << "[O] in save_rooms"
var/savefile/S
S = new("room.list")
S["list"] << save_rooms
world << "save_rooms saved to [S]"
/*
for(var/R in world_rooms)
if(R)
var/savefile/S
S = new(file("areas/[R:vnum].room"))
S << R
world << "[R:name] ([R:vnum]) saved to [S]"
var/save_rooms[]
for(var/room/R in world_rooms)
save_rooms += R
world << "[R] added to save_rooms"
var/savefile/S
S = new(file("areas/room.lst"))
S["list"] << save_rooms
world << "save_rooms saved to /areas/room.lst"
*/

Load_Area()
var/load_rooms[]
var/savefile/S
S = new("room.list")
S["list"] >> load_rooms
world << "load_rooms loaded from [S]"
for(var/room/R in world_rooms)
for(var/mob/M in R.contents)
if(M.client)
M.loc = null
world << "moved [M] to null from [R]"
world << "deleted [R]"
del(R)
for(var/L in load_rooms)
world << "[L] found in load_rooms"
var/room/N
var/savefile/S2
S2 = file("areas/[L].room")
N << S2
new N(null)
world_rooms += N
world << "[N] added to world_rooms"
world << "world_rooms loaded"
for(var/R in world_rooms)
world << "[R] in world_rooms"
/*
var/load_rooms[]
var/dummy_list[]
for(var/room/R in world_rooms)
for(var/M in R.contents)
M:loc = null
usr << "moved [M] to null"
usr << "deleted [R]"
del(R)
for(var/L in load_rooms)
var/room/N
var/savefile/C
C = new(file("areas/[L:vnum].room"))
world << "[N] loaded from [C]"
N = new L(null)
world_rooms += N
world << "world_rooms loaded"
for(var/R in world_rooms)
world << "[R] in world_rooms"
*/
What is the point of that? Quit bumping your post so often.
In response to Kamoku
It's not considered bumping if it's not repeated post in one thread. Polatrite is just deleting his old threads and recreating which isn't wasting space. Polatrite I will read up when I get back from the pool and see what I can do.
In response to Super16
I still say it's bumping...

[edit] And what is the point of the post anyway? Polatrite, are you asking a question about something??? I'm really unclear about that... [/edit]
In response to Kamoku
First off, I only "bumped" it once, otherwise I have just been editing it to change the subject. It was the last post for 5 hours and nobody responded to it, rather annoying. Basically I just need help "fixing" the code listed.
In response to Polatrite
Polatrite wrote:
First off, I only "bumped" it once, otherwise I have just
been editing it to change the subject.

Bumping is not liked no matter how few times you do it. Changing the subject but leaving the content essentially the same is also considered bumping...

It was the last post for 5 hours and nobody responded to
it, rather annoying.

And you have to remember that this is *not* a live medium. Very, very, few people lurk here - this is a forum, not a chat room. The people who actually have the knowledge to help you with this have lives of their own, and usually only show up once or twice a day, sometimes less often. Also, it takes time to form an answer that would actually be of help.

You need to have patience, or use a chat room, or call someone on the telephone. Bumping posts will just get people annoyed at you.

That said, I'm sorry I don't have an answer for you right now. Myself or others will get back to you as soon as possible. Please be patient...
In response to digitalmouse
If actually changing the subject brings the message back to the front, then I'm sorry about that. I was rather bored, and was having a pretty crappy day altogether.
In response to Polatrite
Since this is MUD-realted, try posting on Foomer's MUD forum...you might get more help that way since his forum is specific to that genre of gaming.