Saving List<Enum> Saves the Enum Indexes?

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
eruperu
Posts: 4
Joined: Thu Nov 23, 2017 11:07 am

Saving List<Enum> Saves the Enum Indexes?

Post by eruperu »

Hello,

I'm saving and loading an enum List with ES2 and everything is working so far. However, if I insert or remove entries in the enum data, ES2 would load the wrong values?

For example my old enum data is:

Code: Select all

enum Data { Munchkin, Caramel, Emily, Pippi, Bento }; 
And I have a saved List that contains "Pippi" and "Bento", which loads the values correctly when I use ES2.LoadList.

But, if I then insert a new enum value "Brownie" into the enum data to this:

Code: Select all

enum Data { Munchkin, Caramel, Brownie, Emily, Pippi, Bento };
It would load "Emily" and "Pippi" when I call ES2.LoadList. Is it because SaveList and LoadList uses the indexes instead of the actual values or?

As a test I shortened the enum data to:

Code: Select all

enum Data { Munchkin, Caramel };
And I would see the LoadList output "3" and "4" as values.

How can I make sure that it always outputs "Pippi" and "Bento" regardless whether I insert or remove new enum values? I'm using EasySave 2.8.5.
Hope this makes sense.

Thanks! :)
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving List<Enum> Saves the Enum Indexes?

Post by Joel »

Hi there,

Unfortunately it's necessary to save enums by index. However, the easiest way to address this would be to manually assign indexes to your enums. For example:
enum Data { Munchkin=0, Caramel=1, Emily=2, Pippi=3, Bento=4 };
And then when you add a value:
enum Data { Munchkin=0, Caramel=1, Brownie=5, Emily=2, Pippi=3, Bento=4 };
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
eruperu
Posts: 4
Joined: Thu Nov 23, 2017 11:07 am

Re: Saving List<Enum> Saves the Enum Indexes?

Post by eruperu »

Great! That helped :) And thanks for clearing that up.
Locked