Exemplo n.º 1
0
        /// <summary>
        /// Gets the path to the current autosave folder.
        /// </summary>
        /// <returns>The location where autosaves are saved.</returns>
        private static string GetActiveAutoSavePath()
        {
            string filename = SaveLoader.GetActiveSaveFilePath();
            bool   flag     = filename == null;
            string result;

            if (flag)
            {
                result = SaveLoader.GetAutoSavePrefix();
            }
            else
            {
                string root = Path.GetDirectoryName(filename);
                result = Path.Combine(root, "auto_save");
            }
            return(result);
        }
    private void DoAutoSave(int day)
    {
        if (!GenericGameSettings.instance.disableAutosave)
        {
            day++;
            newDayMetric[NewCycleKey] = day;
            ThreadedHttps <KleiMetrics> .Instance.SendEvent(newDayMetric);

            string text = SaveLoader.GetActiveSaveFilePath();
            if (text == null)
            {
                text = SaveLoader.GetAutosaveFilePath();
            }
            int num = text.LastIndexOf("\\");
            if (num > 0)
            {
                int num2 = text.IndexOf(" Cycle ", num);
                if (num2 > 0)
                {
                    text = text.Substring(0, num2);
                }
            }
            text = text.Replace(".sav", string.Empty);
            text = text + " Cycle " + day.ToString();
            text = SaveScreen.GetValidSaveFilename(text);
            string autoSavePrefix = SaveLoader.GetAutoSavePrefix();
            text = Path.Combine(autoSavePrefix, Path.GetFileName(text));
            string text2 = text;
            int    num3  = 1;
            while (File.Exists(text))
            {
                text = text2.Replace(".sav", string.Empty);
                text = SaveScreen.GetValidSaveFilename(text2 + " (" + num3 + ")");
                num3++;
            }
            Game.Instance.StartDelayedSave(text, true, false);
        }
    }