Example #1
0
        public void Save()
        {
            Backup();

            LastSaved = DateTime.Now.Ticks;
            var bootSerialized = dynamicBoot.Serialize();

            SlotData.m_Dict["boot"] = EncryptString.Compress(bootSerialized);

            if (Boot.m_SceneName.Value != OriginalRegion)
            {
                Global.GameManagerData.SceneTransition.m_ForceNextSceneLoadTriggerScene = null;
            }
            Global.GameManagerData.SceneTransition.m_SceneSaveFilenameCurrent  = Boot.m_SceneName.Value;
            Global.GameManagerData.SceneTransition.m_SceneSaveFilenameNextLoad = Boot.m_SceneName.Value;
            Global.PlayerManager.m_CheatsUsed = true;
            Afflictions.SerializeTo(Global);

            var globalSerialized = dynamicGlobal.Serialize();

            SlotData.m_Dict["global"] = EncryptString.Compress(globalSerialized);

            SlotData.m_Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
            var slotDataSerialized = dynamicSlotData.Serialize();

            File.WriteAllBytes(this.path, EncryptString.Compress(slotDataSerialized));
        }
Example #2
0
        public void Save()
        {
            LastSaved = DateTime.Now.Ticks;
            var bootSerialized = dynamicBoot.Serialize();

            SlotData.m_Dict["boot"] = EncryptString.Compress(bootSerialized);

            // If position is changed, set z coordinate to float.infinity to avoid going under terrain
            var pos = Global.PlayerManager.m_SaveGamePosition;

            if (OriginalRegion != Boot.m_SceneName.Value || pos[0] != originalPosition[0] || pos[1] != originalPosition[1] || pos[2] != originalPosition[2])
            {
                pos[1] = 9999999;
            }

            Global.SceneTransition.m_SceneSaveFilenameCurrent  = Boot.m_SceneName.Value;
            Global.SceneTransition.m_SceneSaveFilenameNextLoad = Boot.m_SceneName.Value;
            Global.PlayerManager.m_CheatsUsed = true;
            Afflictions.SerializeTo(Global);

            var globalSerialized = dynamicGlobal.Serialize();

            SlotData.m_Dict["global"] = EncryptString.Compress(globalSerialized);

            SlotData.m_Timestamp = DateTime.Now;
            var slotDataSerialized = dynamicSlotData.Serialize();

            File.WriteAllBytes(path, EncryptString.Compress(slotDataSerialized));
        }
Example #3
0
        public void Save()
        {
            string json = dynamicState.Serialize();

            #region Break m_StatsDictionary

            // And of course the game can't read that valid json so we have to f**k it up again

            int currentIndex = 0;
            while (true)
            {
                int statsDictStartIndex = json.IndexOf("m_StatsDictionary", currentIndex);
                if (statsDictStartIndex == -1)
                {
                    break;
                }
                statsDictStartIndex = json.IndexOf('{', statsDictStartIndex);
                currentIndex        = statsDictStartIndex;

                int statsDictEndIndex = json.IndexOf('}', statsDictStartIndex);

                var newStats = json.Substring(statsDictStartIndex, statsDictEndIndex - statsDictStartIndex);
                if (newStats.Length <= 2)
                {
                    continue;
                }

                int currentIndex2 = 0;
                while (true)
                {
                    int colonIndex = newStats.IndexOf(':', currentIndex2);
                    if (colonIndex == -1)
                    {
                        break;
                    }
                    currentIndex2 = colonIndex + 1;

                    int i = colonIndex;
                    while (newStats[i] != '{' && newStats[i] != ',')
                    {
                        if (newStats[i] == '\\' || newStats[i] == '\"')
                        {
                            newStats = newStats.Remove(i, 1);
                        }
                        i--;
                    }
                }

                json = json.Substring(0, statsDictStartIndex) + newStats + json.Substring(statsDictEndIndex);
            }

            #endregion

            File.WriteAllBytes(path, EncryptString.Compress(json));
        }
Example #4
0
        public void Save()
        {
            string json = dynamicState.Serialize();

            // Game cannot read valid json for m_StatsDictionary so remove quotes from keys
            json = Regex.Replace(json, @"(\\*\""m_StatsDictionary\\*\"":\{)((?:\\*\""[-0-9\.]+\\*\"":\\*\""[-+0-9eE\.]+\\*\""\,?)+)(\})", delegate(Match match)
            {
                string jsonSubStr = Regex.Replace(match.Groups[2].ToString(), @"\\*\""([-0-9]+)\\*\"":", delegate(Match matchSub)
                {
                    return(matchSub.Groups[1].ToString() + @":");
                });
                return(match.Groups[1].ToString() + jsonSubStr + match.Groups[3].ToString());
            });

            File.WriteAllBytes(path, EncryptString.Compress(json));
        }