ID:2039485
 
Not a bug
BYOND Version:510.1321
Operating System:Windows 7 Pro 64-bit
Web Browser:Chrome 48.0.2564.109
Applies to:DM Language
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary: The reference for the (<<) operator for savefiles reads:

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:
  1. Create a global object (in my example and demo, it is globalobject) and save it in a savefile twice (doesn't matter how).
  2. 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
I think this is due to you saving the lists, rather than your global object itself.
In response to CrimsonVision
CrimsonVision wrote:
I think this is due to you saving the lists, rather than your global object itself.

It does not matter how you save it; the same thing occurs.
What does the log say? You put in detailed debugging statements, so it would help to see what they say.
In response to Lummox JR
I knew I forgot something.

created new globalobject
New() for globalobject called (amount = 1)
Stopped server.
World opened on network port 3333.
New() for globalobject called (amount = 1)
Read() for globalobject called
New() for globalobject called (amount = 2)
Read() for globalobject called
loaded saved globalobject
And if you open the savefile in an editor (or use ExportText), what does that show you?
Also I'm not sure there's any bug here. The text you quoted says that a single operation saving multiple values avoids duplicates. Implied is that you cannot count on that for multiple operations.
Also I'm not sure there's any bug here.

There's not. The reference check only occurs on a single write operation.

FKI is triggering two write operations.

If you were to make lista/listb a datum member and then output the datum to a savefile, it would not cause duplication.
Oh, I see now. Glad that's cleared up. Appreciate it.
Lummox JR resolved issue (Not a bug)