Page 1 of 1

Savegame date contains unneeded data

Posted: Fri Jul 07, 2023 8:59 am
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

Re: Savegame date contains unneeded data

Posted: Fri Jul 07, 2023 10:18 am
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.

Re: Savegame date contains unneeded data

Posted: Tue Jul 11, 2023 2:12 am
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

Re: Savegame date contains unneeded data

Posted: Tue Jul 11, 2023 8:27 am
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.