Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: stewbasic on April 19, 2014, 03:15:36 PM

Title: Possible bug in restoring lists on game load
Post by: stewbasic on April 19, 2014, 03:15:36 PM
It seems that if a core has an empty list assigned to a variable, then when the game is loaded GetListCount returns 1 instead of 0. The list appears to still be empty as expected. Here's a minimal example.


once
CreateList ->list
endonce

SetText(GetListCount(<-list))

:Awake
ShowTraceLog
Trace2(<-list GetListCount(<-list))


The core's text is initially 0 as expected. However after loading the game the trace shows "[] 1" and the core's text changes to 1 (after 1 frame). If the list is not empty, everything works as expected.
Title: Re: Possible bug in restoring lists on game load
Post by: kwinse on April 19, 2014, 04:36:26 PM
Odd indeed.

Curious though, why the (TRUE)? ShowTraceLog doesn't take any arguments so all you're doing is leaving a 1 on the stack (which isn't the source of this).
Title: Re: Possible bug in restoring lists on game load
Post by: stewbasic on April 19, 2014, 08:37:23 PM
Quote from: kwinse on April 19, 2014, 04:36:26 PM
Curious though, why the (TRUE)? ShowTraceLog doesn't take any arguments so all you're doing is leaving a 1 on the stack (which isn't the source of this).
Ah you're right, thanks. I'll correct the original post.
Title: Re: Possible bug in restoring lists on game load
Post by: knucracker on April 20, 2014, 11:16:05 AM
Looks like an empty list when loaded gets created with an empty string as an element.  This is a bug in the way the game loads a serialized list.  I will fix this... and hopefully it won't break anything.  I'm guessing that no existing maps have persisted empty lists for any intentional purpose.