Savegame date contains unneeded data

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Savegame date contains unneeded data

Post by OneManOnMars »

Hey Pixelcrushers,

I have a question about the savegame system of the Dialogue System.

We are writing away the raw data and combining it with other savegame stuff. Here is what we are using:

Code: Select all

 private byte[] GetRawData()
        {         
            PersistentDataManager.Record();
            using (var ms = new MemoryStream())
            {
                //Some methods of PersistentDataManager need to be public to test this
                var writer = new BinaryWriter(ms);
                var luaResult = new Result(LuaExtensions.RunRawExt(false, "return Conversation", false, Lua.Environment));
                var conversationTable = luaResult.AsTable.luaTable;
                prepSimStatusForRawDataMethod.Invoke(null, new object[] { conversationTable });
                var luaValue = new Result(LuaExtensions.RunRawExt(false, "return Actor", false, Lua.Environment)).AsTable.luaTable;
                if (luaValue != null)
                {
                    writeValueMethod.Invoke(null, new object[] { writer, luaValue});
                }

                luaValue = new Result(LuaExtensions.RunRawExt(false, "return Item", false, Lua.Environment)).AsTable.luaTable;
                if (luaValue != null)
                {
                    writeValueMethod.Invoke(null, new object[] { writer, luaValue });
                }

                luaValue = new Result(LuaExtensions.RunRawExt(false, "return Location", false, Lua.Environment)).AsTable.luaTable;
                if (luaValue != null)
                {
                    writeValueMethod.Invoke(null, new object[] { writer, luaValue });
                }

                luaValue = new Result(LuaExtensions.RunRawExt(false, "return Variable", false, Lua.Environment)).AsTable.luaTable;
                if (luaValue != null)
                {
                    writeValueMethod.Invoke(null, new object[] { writer, luaValue });
                }
                
                if (conversationTable != null)
                {
                    writeValueMethod.Invoke(null, new object[] { writer, conversationTable });
                }
                writeExtraDataMethod.Invoke(null, new object[] { writer });
                writer.Flush();
                return ms.GetBuffer();
            }
        }       
And it does all work as it should but I feel, that the savegame file is just much too big. It contains for example conversation descriptions and similar stuff that is totally unnecessary.

The only thing that my game needs are Quests (Name/Id and State) this is needed to drive the conversation selection. And Variables (Name, maybe Type, and Value). There is no need to have my actors in the save game nor any information about my conversations since this is never altered in any way but just selected via values or states in the Quests or the variables.

If I am right, I never change my database except for the quest states or the variable values.

Is there a good way to streamline the save game raw data? Can I simply get rid of the actors for example when writing the raw data, or will it be overwritten with no data if I remove it?

Image
Attachments
savegame00.txt
(257.06 KiB) Downloaded 91 times
User avatar
Tony Li
Posts: 21050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Savegame date contains unneeded data

Post by Tony Li »

Hi,

With the Persistent Data Settings shown in your screenshot above, the save data returned by PersistentDataManager.GetSaveData() should only contain variables and quest states.
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Re: Savegame date contains unneeded data

Post by OneManOnMars »

Thank you Toni for your reply.

Do you know why we still get more data when using the code provided? Can we remove the following lines?

var luaResult = new Result(LuaExtensions.RunRawExt(false, "return Conversation", false, Lua.Environment));
var luaValue = new Result(LuaExtensions.RunRawExt(false, "return Actor", false, Lua.Environment)).AsTable.luaTable;
luaValue = new Result(LuaExtensions.RunRawExt(false, "return Location", false, Lua.Environment)).AsTable.luaTable;

Thank you for your help
User avatar
Tony Li
Posts: 21050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Savegame date contains unneeded data

Post by Tony Li »

Hi,

I think that's some custom code that someone on your team added. There's no such code in the Dialogue System itself.
Post Reply