ID:143971
 
Code:
/*
Ok. These two functions change how stuff is saved.
Their purpose if to prevent saving references to mobs.
The reason is that doing so can cause strange errors, like random rollbacks of players.
*/

var/list/unsaved_vars = list("loc") //any non-tmp vars that you do NOT want saved go here.
datum/Write(savefile/F)
//modifed softcode for default writing
//original version from DM guide
//modified to fix the infamous 'rollback' bug
var/V
for(V in vars)
if(issaved(vars[V]) && !(V in unsaved_vars))
if(ismob(vars[V]) && vars[V] != src)
world.log << "[src] attempted to save mob into [V]."
else
if(initial(vars[V]) == vars[V])
F.dir.Remove(V) //just in case
else
var/temp = vars[V]
if(istype(vars[V], /list))
for(var/O in vars[V])
if(ismob(O) && O != src)
world.log << "[src] attempted to save mob into list [V]."
temp -= O
F[V] << temp //write variable

datum/Read(savefile/F)
//modifed softcode for default reading
//original version from DM guide
//modified to fix the infamous 'rollback' bug
var/V
for(V in vars)
if(issaved(vars[V]) && !(V in unsaved_vars))
if(V in F.dir)
var/temp
F[V] >> temp //read variable

if(istype(vars[V], /list))
for(var/O in vars[V])
if(ismob(O) && O != src)
world.log << "[src] attempted to load saved mob from list [V]."
temp -= O

if(!ismob(vars[V]) || vars[V] == src)
vars[V] = temp
else
world.log << "[src] attempted to load saved mob from [V]."


Problem description:
Well, the game where this is used on laggs continuously and freezes like 2 times per minute.
I don't know how to solve this, we're sure it's in this code.
Could any of you help me?

Edit: we get a lot of world.loc << "" messages, too many of them.
Scrap that code. You don't need it if you code the rest of your game properly. That 'rollback bug' isn't a [BYOND] bug, neither does it occur 'randomly'; if you have references to other objects in an object, when that object is saved those objects are also saved with it, by default, unless the referencing vars are marked 'tmp' (or global or const), which is what you should do to such vars.

And of course you get those messages, they're right there in the code... do you even know basic coding? You can't remove the messages?
In response to Kaioken
This was coded to fix rollbacks. But could it be it's the save code of the game that causes the rollbacks and thus in need of this code, that causes those laggs and freezes.

Anyway, thanks for answering so quick.
In response to Sokkiejjj
Could anyone help me with this issue, please?
Thanks if doing so. :)