Example #1
0
        List <T> ReadList <T>(FileReader reader, Int32 position, Int32 count, Func <FileReader, T> func = null) where T : struct
        {
            Assert.IsNotNull(reader, nameof(reader));

            func = func ?? DefaultReadFunction <T>;

            var list = new List <T>();

            using (var saver = new StreamPositionSaver(reader.Stream))
            {
                reader.Stream.Position = position;

                for (var i = 0; i != count; ++i)
                {
                    list.Add(func(reader));
                }
            }

            if (list.Count > 0)
            {
                FileMap[(UInt32)position] = list;
            }

            return(list);
        }
Example #2
0
        void ReadBattleInformation(FileReader reader)
        {
            Assert.IsNotNull(reader, nameof(reader));

            UInt32 offset = (UInt32)reader.Stream.Position;

            var battle = DefaultReadFunction <FileHeaders.SCENARIO_BATTLE>(reader);

            FileMap[offset] = battle;

            foreach (var val in battle.Probability)
            {
                if (val == 0)
                {
                    continue;
                }

                var bmi_offset        = (UInt32)reader.Stream.Position;
                var battlemonsterinfo = DefaultReadFunction <FileHeaders.SCENARIO_BATTLEMONSTERINFO>(reader);

                var positionnormaldata = ReadList <FileHeaders.SCENARIO_BATTLEMONSTERPOSITION>(reader, battlemonsterinfo.PositionNormalOffset, 8);
                var positionambushdata = ReadList <FileHeaders.SCENARIO_BATTLEMONSTERPOSITION>(reader, battlemonsterinfo.PositionEnemyAdvantageOffset, 8);

                FileHeaders.SCENARIO_ATBONUS atbonus;
                using (var saver = new StreamPositionSaver(reader.Stream))
                {
                    reader.Stream.Position = battlemonsterinfo.ATBonusOffset;
                    atbonus = DefaultReadFunction <FileHeaders.SCENARIO_ATBONUS>(reader);
                }

                FileMap[bmi_offset] = battlemonsterinfo;
                FileMap[battlemonsterinfo.PositionNormalOffset]         = positionnormaldata;
                FileMap[battlemonsterinfo.PositionEnemyAdvantageOffset] = positionambushdata;
                FileMap[battlemonsterinfo.ATBonusOffset] = atbonus;
            }

            // Pointer into string table?
            //var battlemap = reader.ReadString(battle.BattleMapOffset);
            //filemap[battle.BattleMapOffset] = battlemap;

            if (battle.SepithOffset != 0)
            {
                reader.Stream.Position = battle.SepithOffset;
                var sepith = DefaultReadFunction <FileHeaders.SCENARIO_BATTLESEPITH>(reader);

                FileMap[battle.SepithOffset] = sepith;
            }
        }