ID:147173
 
Hi everyone, don't think I've had a coding problem in some time, but I do now. See I figured out that the reason DD is crashing on me, is not fully due to version 340. See it crashes less often when I go to 339, but it doesnt neutralize the problem, making it also in my code. I have a feeling it has something to do with this code, but I'm not sure. If theres any problems anyone can spot with it, please reply.

proc
SaveHouses()
var/savefile/S=new("houses")
var/area/housing/A
for(var/area in typesof(/area/housing)-list(/area/housing))
A=locate(area)
S["/[A.name]"]<<A.owner
S["/[A.name]/welcomemsg"]<<A.welcomemsg
S["/[A.name]/goodbyemsg"]<<A.goodbyemsg
S["/[A.name]/invited"]<<A.invited

LoadHouses()
var/savefile/S=new("houses")
var/area/housing/A
for(var/area in typesof(/area/housing)-list(/area/housing))
A=locate(area)
S["/[A.name]"]>>A.owner
S["/[A.name]/welcomemsg"]>>A.welcomemsg
S["/[A.name]/goodbyemsg"]>>A.goodbyemsg
S["/[A.name]/invited"]>>A.invited

SaveObjs()
var/list/objects=list()
var/savefile/S=new("objects")
for(var/obj/O in world)
if(isturf(O.loc))
objects+=O
objects[O]=list(O.x,O.y,O.z)
S<<objects

LoadObjs()
var/list/objects
var/savefile/S=new("objects")
S>>objects
var/list/L
for(var/obj/O in objects)
L=objects[O]
O.loc=locate(L[1],L[2],L[3])

I've currently deactivated this code, so it shouldnt crash in my game anymore, so the problem is neutralized, but this is the only code that could possibly cause problems, ONLY when the world is rebooting, or shutting down. Please help, The save versions are the only things called in world/Del()
Metroid wrote:
Hi everyone, don't think I've had a coding problem in some time, but I do now. See I figured out that the reason DD is crashing on me, is not fully due to version 340. See it crashes less often when I go to 339, but it doesnt neutralize the problem, making it also in my code.

It won't crash any less often in 339 than 340. The two versions are practically identical.

I have a feeling it has something to do with this code, but I'm not sure. If theres any problems anyone can spot with it, please reply.

proc
SaveHouses()
var/savefile/S=new("houses")
var/area/housing/A
for(var/area in typesof(/area/housing)-list(/area/housing))
A=locate(area)
S["/[A.name]"]<<A.owner
S["/[A.name]/welcomemsg"]<<A.welcomemsg
S["/[A.name]/goodbyemsg"]<<A.goodbyemsg
S["/[A.name]/invited"]<<A.invited

LoadHouses()
var/savefile/S=new("houses")
var/area/housing/A
for(var/area in typesof(/area/housing)-list(/area/housing))
A=locate(area)
S["/[A.name]"]>>A.owner
S["/[A.name]/welcomemsg"]>>A.welcomemsg
S["/[A.name]/goodbyemsg"]>>A.goodbyemsg
S["/[A.name]/invited"]>>A.invited

SaveObjs()
var/list/objects=list()
var/savefile/S=new("objects")
for(var/obj/O in world)
if(isturf(O.loc))
objects+=O
objects[O]=list(O.x,O.y,O.z)
S<<objects

LoadObjs()
var/list/objects
var/savefile/S=new("objects")
S>>objects
var/list/L
for(var/obj/O in objects)
L=objects[O]
O.loc=locate(L[1],L[2],L[3])

I've currently deactivated this code, so it shouldnt crash in my game anymore, so the problem is neutralized, but this is the only code that could possibly cause problems, ONLY when the world is rebooting, or shutting down. Please help, The save versions are the only things called in world/Del()

I see two problems involving list husbandry.

First: When subtracting from typesof() you do not need list() around the thing you subtract. typesof(/area/housing)-/area/housing is just as effective as typesof(/area/housing)-list(/area/housing), but quicker because it doesn't create a list temporarily. (Of course, this loop is doomed to failure anyway, since it's going by type and not by actual areas. Clearly you can't hardcode a type path for everyone in your game, so this loop should only find and save a single house of each type. You should simply loop through var/area/housing/A (all the ones in the world) instead.

Second: Your object saving is tossing about a zillion lists into the savefile that it doesn't need. Consider what DM is going to do when it tries to load that. Better to simply modify obj/Read() and obj/Write() to save the position info you want, and restore its position on load.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
I see two problems involving list husbandry.

First: When subtracting from typesof() you do not need list() around the thing you subtract. typesof(/area/housing)-/area/housing is just as effective as typesof(/area/housing)-list(/area/housing), but quicker because it doesn't create a list temporarily. (Of course, this loop is doomed to failure anyway, since it's going by type and not by actual areas. Clearly you can't hardcode a type path for everyone in your game, so this loop should only find and save a single house of each type. You should simply loop through var/area/housing/A (all the ones in the world) instead.

Second: Your object saving is tossing about a zillion lists into the savefile that it doesn't need. Consider what DM is going to do when it tries to load that. Better to simply modify obj/Read() and obj/Write() to save the position info you want, and restore its position on load.

Lummox JR

I only need 1 save for each type of house, since each house has its own stats, like House 1, House 2, etc. for each house. So there's only 1 type of house 1 for house 1. I will fix the list thing in both. Thanks for the help, I'll edit this when I know if it helps or not.