Example #1
0
        public static Save_Data read(BinaryReader reader)
        {
            Save_Data result = new Save_Data();

            if (!Global.LOADED_VERSION.older_than(0, 4, 3, 0))
            {
                result.Time = DateTime.FromBinary(reader.ReadInt64());
            }
            result.Chapter_Id     = reader.ReadString();
            result.Progression_Id = reader.ReadString();
            result.System         = new Game_System();
            result.System.read(reader);
            if (Global.LOADED_VERSION.older_than(0, 4, 0, 4))
            {
                List <string> previous_chapters = Global.data_chapters[result.Chapter_Id].Prior_Chapters;
                result.System.previous_chapters.AddRange(previous_chapters);
            }
            result.Battalions = new Game_Battalions();
            result.Battalions.read(reader);
            if (Global.LOADED_VERSION.older_than(0, 5, 3, 1))
            {
                if (Global.data_chapters.ContainsKey(result.Chapter_Id))
                {
                    // Correct battalion id
                    result.Battalions.correct_battalion_id(
                        Global.data_chapters[result.Chapter_Id]);
                }
            }


            result.Actors = new Game_Actors();
            result.Actors.read(reader);
            result.Switches = Event_Variable_Data <bool> .read(reader);

            //result.Switches = new bool[Config.EVENT_DATA_LENGTH]; //Debug
            //result.Switches = result.Switches.read(reader);
            result.Variables = Event_Variable_Data <int> .read(reader);

            //result.Variables = new int[Config.EVENT_DATA_LENGTH];
            //result.Variables = result.Variables.read(reader);
            result.Ranking = Game_Ranking.read(reader);
            if (!Global.LOADED_VERSION.older_than(0, 4, 4, 0))
            {
                result.Past_Rankings = PastRankings.read(reader, result.System.Difficulty_Mode);
            }
            else
            {
                result.Past_Rankings = new PastRankings();
            }
            // If this save predates storing difficulty in the ranking object
            if (Global.LOADED_VERSION.older_than(0, 6, 1, 1))
            {
                Difficulty_Modes difficulty = result.System.Difficulty_Mode;
                result.Ranking = new Game_Ranking(result.Ranking, difficulty);
            }

            return(result);
        }
Example #2
0
        internal void save_data(string chapter_id, string progression_id, PastRankings rankings)
        {
            if (!Data.ContainsKey(chapter_id))
            {
                Data[chapter_id] = new Dictionary <string, Save_Data>();
            }

            Data[chapter_id][progression_id] = new Save_Data();
            Data[chapter_id][progression_id].save_data(chapter_id, progression_id, rankings);
        }
Example #3
0
 public void save_data(string chapter_id, string progression_id, PastRankings past_rankings)
 {
     Time           = DateTime.Now;
     Chapter_Id     = chapter_id;
     Progression_Id = progression_id;
     System         = Global.game_system.copy();
     Battalions     = Global.game_battalions;
     Actors         = Global.game_actors;
     Switches       = new Event_Variable_Data <bool>(Config.EVENT_DATA_LENGTH);
     Variables      = new Event_Variable_Data <int>(Config.EVENT_DATA_LENGTH);
     System.get_event_data(Switches, Variables);
     //Event_Processor.get_data(Switches, Variables); //Debug
     Ranking       = new Game_Ranking();
     Past_Rankings = (PastRankings)past_rankings.Clone();
 }
Example #4
0
        public static PastRankings process_past_ranking(List <Save_Data> previous_data)
        {
            PastRankings pastRankings = new PastRankings();

            // Go through data in reverse order, the data at the start of the list is the most important to maintain
            for (int i = previous_data.Count - 1; i >= 0; i--)
            {
                previous_data[i].Past_Rankings.CopyTo(pastRankings);
                if (!Global.data_chapters[previous_data[i].Chapter_Id].Unranked)
                {
                    pastRankings.SetRanking(
                        previous_data[i].Chapter_Id,
                        previous_data[i].Ranking);
                }
            }

            return(pastRankings);
        }