BYOND Reference
Single operations that write multiple values (such as saving an object) are handled somewhat specially to avoid two references to the same object creating duplicate entries in the savefile. After the object being referenced is written once, successive references to the same object will be saved simply as references rather than as full objects. If this was not done, two references to the same object would be read back in as two separate objects.
However, my tests seem to show exactly that behavior.
Demo: BYOND Home link
Code:
var global
lista[] = list()
listb[] = list()
globalobject/globalobject
globalobjects = 0
globalobject
New()
..()
world.log << "New() for globalobject called (amount = [++globalobjects])"
Read()
..()
world.log << "Read() for globalobject called"
proc/savestuff()
var savefile/s = new("somesavefile.sav")
s["lista"] << lista
s["listb"] << listb
//s << lista
//s << listb
proc/loadstuff()
. = fexists("somesavefile.sav")
if(.)
var savefile/s = new("somesavefile.sav")
s["lista"] >> lista
s["listb"] >> listb
//s >> lista
//s >> listb
world/New()
..()
if(!loadstuff())
world.log << "created new globalobject"
globalobject = new
lista += globalobject
listb += globalobject
else
world.log << "loaded saved globalobject"
world/Del()
savestuff()
..()
Reproducing the Problem:
- Create a global object (in my example and demo, it is globalobject) and save it in a savefile twice (doesn't matter how).
- Load the global objects back in accordingly. Check world.log and there should now be two objects when you only saved one initially.
Expected Results: For the global object not to duplicate when loaded from a savefile twice.
Actual Results: The global object duplicates when loaded.
Does the problem occur:
Every time? Or how often? Every time
In other games? Occurs in a basic test project
In other user accounts? N/A
On other computers? N/A
When does the problem NOT occur? N/A
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.) Occurs as far back as 508.1295.
Workarounds: N/A