Exemple #1
0
        private void ParseAow1()
        {
            _gameType = AowGameType.Aow1;

            using (BinaryReader input = new BinaryReader(_theAttachment.GetMemoryStream()))
            {
                if (_fetch_compressed_data)
                {
                    if (CheckSignature(input, compressed_part_signature))
                    {
                        DataCompressor compressed_data = new DataCompressor(input, true);
                        compressed_data.Compressed = false;     //	decompression happens here

                        using (BinaryReader main_input = new BinaryReader(new MemoryStream(compressed_data.Data)))
                        {
                            if (CheckSignature(main_input, aow1map_signature))
                            {
                                int possible_class_id = main_input.ReadInt32();
                                main_input.BaseStream.Position += 3;    //	skip field list of root offsetmap, moving straight to the contents

                                OffsetMap map_om = new OffsetMap(main_input.BaseStream);
                                _mapTitle   = map_om.ReadShortPascalString(0x19);
                                _turnNumber = map_om.ReadInt32(0x13);

                                OffsetMap section_15     = map_om.GetSubFieldOffsetMap(0x15);
                                OffsetMap s_15_1         = section_15.GetSubFieldOffsetMap(0x01);
                                OffsetMap s_15_1_1       = s_15_1.GetSubFieldOffsetMap(0x01, true);
                                OffsetMap s_15_1_1_36    = s_15_1_1.GetSubFieldOffsetMap(0x36);
                                OffsetMap s_15_1_1_36_15 = s_15_1_1_36.GetSubFieldOffsetMap(0x15);
                                _gameTitle = s_15_1_1_36_15.ReadShortPascalString(0x14);
                            }
                            else
                            {
                                _isValid = false;
                            }
                        }
                    }
                    else
                    {
                        _isValid = false;
                    }
                }
            }
        }
Exemple #2
0
        private void ParseAow2(byte[] signature)
        {
            using (BinaryReader input = new BinaryReader(_theAttachment.GetMemoryStream()))
            {
                if (CheckSignature(input, signature))
                {
                    int header_length = input.ReadInt32() - 7;  //	хз почему, но это так
                    _modId = input.ReadInt32();

                    if (CheckSignature(input, magic_11_bytes))
                    {
                        long      compressed_part_start = input.BaseStream.Position + header_length;
                        OffsetMap header_om             = new OffsetMap(input.BaseStream, input.BaseStream.Position, header_length);

                        _mapTitle   = header_om.ReadShortPascalString(0x20);
                        _turnNumber = header_om.ReadInt32(0x21);
                        byte playersCount = header_om.ReadByte(0x1e);

                        //	compressed info
                        if (_fetch_compressed_data)
                        {
                            input.BaseStream.Position = compressed_part_start;
                            if (CheckSignature(input, compressed_part_signature))
                            {
                                DataCompressor compressed_data = new DataCompressor(input, true);
                                compressed_data.Compressed = false;     //	decompression happens here

                                using (BinaryReader main_input = new BinaryReader(new MemoryStream(compressed_data.Data)))
                                {
                                    //	digging up the game title
                                    if (CheckSignature(main_input, decompressed_data_signature))
                                    {
                                        OffsetMap map_om = new OffsetMap(main_input.BaseStream);
                                        OffsetMap player_list_wrapper_om         = map_om.GetSubFieldOffsetMap(0x1a);
                                        OffsetMap player_list_om                 = player_list_wrapper_om.GetSubFieldOffsetMap(0x01);
                                        OffsetMap player_1_om                    = player_list_om.GetSubFieldOffsetMap(0x01, true);
                                        OffsetMap player_1_pbem_settings_wrapper = player_1_om.GetSubFieldOffsetMap(0x36);
                                        OffsetMap player_1_pbem_settings         = player_1_pbem_settings_wrapper.GetSubFieldOffsetMap(0x15);
                                        _gameTitle = player_1_pbem_settings.ReadShortPascalString(0x14);

                                        //	WT or SM?
                                        OffsetMap race_list_wrapper_om = map_om.GetSubFieldOffsetMap(0x1b);
                                        OffsetMap race_list_om         = race_list_wrapper_om.GetSubFieldOffsetMap(0x01);
                                        int       race_count           = race_list_om.Fields.Count;

                                        switch (race_count)
                                        {
                                        case 15:
                                            _gameType = _fileType == ASGFileType.AowMpe ? AowGameType.AowMpe : AowGameType.AowSm;
                                            break;

                                        case 12:
                                            _gameType = AowGameType.Aow2;
                                            break;

                                        default:
                                            _gameType = AowGameType.Unknown;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        _isValid = false;
                                    }
                                }
                            }
                            else
                            {
                                _isValid = false;
                            }
                        }
                    }
                }
            }
        }