Exemplo n.º 1
0
        public static OBL_File Parse(byte[] bytes)
        {
            OBL_File oblFile = new OBL_File();

            int lobbyCount  = BitConverter.ToInt32(bytes, 8);
            int battleCount = BitConverter.ToInt32(bytes, 12);
            int questCount  = BitConverter.ToInt32(bytes, 16);
            int hcCount     = BitConverter.ToInt32(bytes, 20);

            //Validate the file size
            if (32 + (20 * lobbyCount) + (20 * battleCount) + (20 * questCount) + (20 * hcCount) != bytes.Length)
            {
                throw new InvalidDataException("OBL parse failed. File size validation failed!");
            }

            //Calculate offsets
            int lobbyOffset  = 32;
            int battleOffset = lobbyOffset + (20 * lobbyCount);
            int questOffset  = battleOffset + (20 * battleCount);
            int hcOffset     = questOffset + (20 * questCount);

            //Read data
            oblFile.LobbyCues         = OBL_Cue.ReadAll(bytes, lobbyOffset, lobbyCount);
            oblFile.BattleCues        = OBL_Cue.ReadAll(bytes, battleOffset, battleCount);
            oblFile.QuestCues         = OBL_Cue.ReadAll(bytes, questOffset, questCount);
            oblFile.HeroColosseumCues = OBL_Cue.ReadAll(bytes, hcOffset, hcCount);

            return(oblFile);
        }
Exemplo n.º 2
0
        public static OBL_File Parse(string path, bool writeXml)
        {
            OBL_File oblFile = Parse(File.ReadAllBytes(path));

            if (writeXml)
            {
                YAXSerializer serializer = new YAXSerializer(typeof(OBL_File));
                serializer.SerializeToFile(oblFile, path + ".xml");
            }

            return(oblFile);
        }