Unable to add elements to <persistable> IntArray

Summary

My persistable data is a class with ints like this:
class:
IntArray := Int1 := -1, Int2 := -1, Int3 := -1

I have all sorts of numbers stored in these ints and they work fine, these ints have been there for almost a year now. Now when I tried to add a new int, in this example Int4 := -1, this int4 will not be added to the players IntArray in the published island

The weird thing is, in launch sessions games it saves and loads as expected. But in published sessions it does not work and always fails to find Int4

This seems to be a recent bug, maybe from a few months ago. In the past I was able to add more int elements to the int array.

Please select what you are reporting on:

Creative

What Type of Bug are you experiencing?

Assets

Steps to Reproduce

Not sure

Expected Result

The data in published matches returns the int I saved, but it fails to find the new Ints I added

Observed Result

It fails

Platform(s)

PC

Island Code

6570-5231-1418

Video

Video launch session:


Video Published sessions:

Code:



In the second video you see numbers 60,61,62,63 being shown. This is the result of SourceData.EasyAccessData.IntArray[60-1] failing, which only fails in published versions, not in launch session versions.
I recently aded IntValue_51 up to IntValue_100. Everything below that succeeds, for exampple
SourceData.EasyAccessData.IntArray[40-1] succeeds. But as you can see 60-1 should return IntValue_60 which is -1 by default but it fails to find it.

Thank you, @JoeriDukker - getting someone to take a look.

1 Like

I found out a bunch more info, I edited the bug report massively

1 Like

Thank you, the team is on it. Found that it’s a similar issue to FORT-882522 - so you can also watch this thread for updates. Verse persistable data is not saved between games

To verify I have the scenario described accurately, you have a persistable class with a default value for a field IntArray, defined as an array with 50 elements. You have played the map where this definition exists, and as part of playing in this map, an instance of this class is constructed and inserted into a persistent weak_map. The map has been updated such that the default value is now an array with 100 elements. Upon playing the map, your entry in the persistent weak_map still only has 50 values.

If I have the above accurate stated, I believe this is expected behavior. The default value of the class is only used at the moment the class is constructed - effectively, the instance is constructed with fields copied from the default values, but then there is no longer a reference by the instance to the default value. Such an instance is saved (with just 50 elements in the array) when you originally played the map. Changing the default value will have no impact on that instance.

You stated it accurately. This method used to work for atleast a few months, I started with 30 elements in my intarray and added more and more over time. Last time I added a new element to the IntArray was in late january, and it worked fine. So I am confused why it no longer works now.

Anyway, if this is intented behaviour now, then this is not a bug, I will adjust my code to make it work

I think what he means is when you first play it creates a copy of the array with values say xyz then any further changes you make to the default array wont be updated for the player who already has a copy of the array. You could do a CurrentVersion:int then check the player when they join your game and if the player version <> currentversion then set the array to the new array

You probs know this but worth mentioning for others to see

2 Likes

This seems to be a bug though, I added some footage to make it visual