コード例 #1
0
            /// <summary>
            /// Reads the data element from the given buffer.
            /// </summary>
            /// <param name="buffer">The buffer where the data element should be deserialized from.</param>
            public PlayerDiplomacyVariousEntry ReadData(RAMBuffer buffer)
            {
                PlayerName     = buffer.ReadString(buffer.ReadUShort());
                InitialCameraX = buffer.ReadFloat();
                InitialCameraY = buffer.ReadFloat();
                UnknownX       = buffer.ReadShort();
                UnknownY       = buffer.ReadShort();
                AlliedVictory  = buffer.ReadByte();

                ushort playerDiplomacyCount = buffer.ReadUShort();

                Diplomacy1 = new List <DiplomacyTypes1>(playerDiplomacyCount);
                for (int i = 0; i < playerDiplomacyCount; i++)
                {
                    Diplomacy1.Add((DiplomacyTypes1)buffer.ReadByte());
                }
                Diplomacy2 = new List <DiplomacyTypes2>(playerDiplomacyCount);
                for (int i = 0; i < playerDiplomacyCount; i++)
                {
                    Diplomacy2.Add((DiplomacyTypes2)buffer.ReadUInteger());
                }

                Color         = buffer.ReadUInteger();
                Unknown1      = buffer.ReadFloat();
                Unknown3Count = buffer.ReadUShort();

                if (Unknown1 == 2)
                {
                    Unknown2 = new List <byte>(8);
                    for (int i = 0; i < 8; i++)
                    {
                        Unknown2.Add(buffer.ReadByte());
                    }
                }

                Unknown3 = new List <byte>(Unknown3Count * 44);
                for (int i = 0; i < Unknown3Count * 44; i++)
                {
                    Unknown3.Add(buffer.ReadByte());
                }

                Unknown4 = new List <byte>(7);
                for (int i = 0; i < 7; i++)
                {
                    Unknown4.Add(buffer.ReadByte());
                }

                Unknown5 = buffer.ReadInteger();

                return(this);
            }
コード例 #2
0
            /// <summary>
            /// Reads the data element from the given buffer.
            /// </summary>
            /// <param name="buffer">The buffer where the data element should be deserialized from.</param>
            public UnitEntry ReadData(RAMBuffer buffer)
            {
                PositionX  = buffer.ReadFloat();
                PositionY  = buffer.ReadFloat();
                PositionZ  = buffer.ReadFloat();
                Id         = buffer.ReadUInteger();
                UnitId     = buffer.ReadUShort();
                State      = buffer.ReadByte();
                Rotation   = buffer.ReadFloat();
                Frame      = buffer.ReadUShort();
                GarrisonId = buffer.ReadInteger();

                return(this);
            }
コード例 #3
0
        public Graphic ReadData(RAMBuffer buffer)
        {
            Name1 = buffer.ReadString(21);
            Name2 = buffer.ReadString(13);

            SLP         = buffer.ReadInteger();
            Unknown1    = buffer.ReadByte();
            Unknown2    = buffer.ReadByte();
            Layer       = buffer.ReadByte();
            PlayerColor = buffer.ReadByte();
            Rainbow     = buffer.ReadByte();
            Replay      = buffer.ReadByte();

            Coordinates = new List <short>(4);
            for (int i = 0; i < 4; ++i)
            {
                Coordinates.Add(buffer.ReadShort());
            }

            int deltaCount = buffer.ReadUShort();

            SoundID         = buffer.ReadShort();
            AttackSoundUsed = buffer.ReadByte();
            FrameCount      = buffer.ReadUShort();
            AngleCount      = buffer.ReadUShort();
            NewSpeed        = buffer.ReadFloat();
            FrameRate       = buffer.ReadFloat();
            ReplayDelay     = buffer.ReadFloat();
            SequenceType    = buffer.ReadByte();
            ID            = buffer.ReadShort();
            MirroringMode = buffer.ReadByte();
            Unknown3      = buffer.ReadByte();

            Deltas = new List <GraphicDelta>(deltaCount);
            for (int i = 0; i < deltaCount; ++i)
            {
                Deltas.Add(new GraphicDelta().ReadData(buffer));
            }

            if (AttackSoundUsed != 0)
            {
                AttackSounds = new List <GraphicAttackSound>(AngleCount);
                for (int i = 0; i < AngleCount; ++i)
                {
                    AttackSounds.Add(new GraphicAttackSound().ReadData(buffer));
                }
            }

            return(this);
        }
コード例 #4
0
        public Research ReadData(RAMBuffer buffer)
        {
            RequiredTechs = new List <short>(6);
            for (int i = 0; i < 6; ++i)
            {
                RequiredTechs.Add(buffer.ReadShort());
            }

            ResourceCosts = new List <ResourceTuple <short, short, byte> >(3);
            for (int i = 0; i < 3; ++i)
            {
                ResourceCosts.Add(new ResourceTuple <short, short, byte>()
                {
                    Type = buffer.ReadShort(), Amount = buffer.ReadShort(), Mode = buffer.ReadByte()
                });
            }

            RequiredTechCount = buffer.ReadShort();
            Civ                    = buffer.ReadShort();
            FullTechMode           = buffer.ReadShort();
            ResearchLocation       = buffer.ReadShort();
            LanguageDLLName1       = buffer.ReadUShort();
            LanguageDLLDescription = buffer.ReadUShort();
            ResearchTime           = buffer.ReadShort();
            TechageID              = buffer.ReadShort();
            Type                   = buffer.ReadShort();
            IconID                 = buffer.ReadShort();
            ButtonID               = buffer.ReadByte();
            LanguageDLLHelp        = buffer.ReadInteger();
            LanguageDLLName2       = buffer.ReadInteger();
            Unknown1               = buffer.ReadInteger();

            int nameLength = buffer.ReadUShort();

            Name = buffer.ReadString(nameLength);

            return(this);
        }
コード例 #5
0
ファイル: Techage.cs プロジェクト: JanWichelmann/GenieLibrary
        public Techage ReadData(RAMBuffer buffer)
        {
            Name = buffer.ReadString(31);

            int effectCount = buffer.ReadUShort();

            Effects = new List <TechageEffect>(effectCount);
            for (int i = 0; i < effectCount; ++i)
            {
                Effects.Add(new TechageEffect().ReadData(buffer));
            }

            return(this);
        }
コード例 #6
0
        public Civ ReadData(RAMBuffer buffer)
        {
            One  = buffer.ReadByte();
            Name = buffer.ReadString(20);
            int resourceCount = buffer.ReadUShort();

            TechTreeID  = buffer.ReadShort();
            TeamBonusID = buffer.ReadShort();

            Resources = new List <float>(resourceCount);
            for (int i = 0; i < resourceCount; ++i)
            {
                Resources.Add(buffer.ReadFloat());
            }

            IconSet = buffer.ReadByte();

            int unitCount = buffer.ReadUShort();

            UnitPointers = new List <int>(unitCount);
            for (int i = 0; i < unitCount; ++i)
            {
                UnitPointers.Add(buffer.ReadInteger());
            }

            Units = new SortedList <int, Unit>(unitCount);
            for (int p = 0; p < UnitPointers.Count; ++p)
            {
                if (UnitPointers[p] != 0)
                {
                    Units.Add(p, new Unit().ReadData(buffer));
                }
            }

            return(this);
        }
コード例 #7
0
        public UnitHeader ReadData(RAMBuffer buffer)
        {
            Exists = buffer.ReadByte();

            if (Exists != 0)
            {
                int commandCount = buffer.ReadUShort();
                Commands = new List <UnitCommand>(commandCount);
                for (int i = 0; i < commandCount; ++i)
                {
                    Commands.Add(new UnitCommand().ReadData(buffer));
                }
            }

            return(this);
        }
コード例 #8
0
ファイル: Type50.cs プロジェクト: JanWichelmann/GenieLibrary
        public Type50 ReadData(RAMBuffer buffer)
        {
            DefaultArmor = buffer.ReadShort();

            ushort attackCount = buffer.ReadUShort();

            Attacks = new Dictionary <ushort, ushort>(attackCount);
            for (int i = 0; i < attackCount; ++i)
            {
                Attacks[buffer.ReadUShort()] = buffer.ReadUShort();
            }

            ushort armourCount = buffer.ReadUShort();

            Armors = new Dictionary <ushort, ushort>(armourCount);
            for (int i = 0; i < armourCount; ++i)
            {
                Armors[buffer.ReadUShort()] = buffer.ReadUShort();
            }

            TerrainRestrictionForDamageMultiplying = buffer.ReadShort();
            MaxRange                  = buffer.ReadFloat();
            BlastRadius               = buffer.ReadFloat();
            ReloadTime                = buffer.ReadFloat();
            ProjectileUnitID          = buffer.ReadShort();
            ProjectileAccuracyPercent = buffer.ReadShort();
            TowerMode                 = buffer.ReadByte();
            ProjectileFrameDelay      = buffer.ReadShort();

            ProjectileGraphicDisplacement = new List <float>(3);
            for (int i = 0; i < 3; ++i)
            {
                ProjectileGraphicDisplacement.Add(buffer.ReadFloat());
            }

            BlastLevel           = buffer.ReadByte();
            MinRange             = buffer.ReadFloat();
            ProjectileDispersion = buffer.ReadFloat();
            AttackGraphic        = buffer.ReadShort();
            DisplayedMeleeArmor  = buffer.ReadShort();
            DisplayedAttack      = buffer.ReadShort();
            DisplayedRange       = buffer.ReadFloat();
            DisplayedReloadTime  = buffer.ReadFloat();

            return(this);
        }
コード例 #9
0
        /// <summary>
        /// Lädt die Bitmap-Datei aus dem angegebenen Puffer.
        /// </summary>
        /// <param name="buffer">Der Puffer, aus dem die Bitmap-Datei gelesen werden soll.</param>
        /// <param name="pal">Optional. Gibt die zu verwendende 256er-Farbtabelle an. Sonst wird die entweder die im Bitmap angegebene oder die 50500er-Farbtabelle verwendet.</param>
        /// <param name="readFileHeader">Optional. Gibt an, ob der Dateiheader gelesen werden oder direkt mit der BITMAPINFOHEADER-Struktur begonnen werden soll.</param>
        public BitmapLoader(RAMBuffer buffer, JASCPalette pal = null, bool readFileHeader = true)
        {
            // Header laden
            _header = new Header();
            if (readFileHeader)
            {
                _header.type       = buffer.ReadUShort();
                _header.fileSize   = buffer.ReadUInteger();
                _header.reserved   = buffer.ReadUInteger();
                _header.offsetData = buffer.ReadUInteger();
            }
            else
            {
                _header.type       = 0x424D;
                _header.fileSize   = 0;
                _header.reserved   = 0;
                _header.offsetData = 54;
            }
            _header.imageHeaderSize     = buffer.ReadUInteger();
            _header.width               = buffer.ReadInteger();
            _header.height              = buffer.ReadInteger();
            _header.layerCount          = buffer.ReadUShort();
            _header.bitsPerPixel        = buffer.ReadUShort();
            _header.compression         = buffer.ReadUInteger();
            _header.size                = buffer.ReadUInteger();
            _header.xDPI                = buffer.ReadInteger();
            _header.yDPI                = buffer.ReadInteger();
            _header.colorCount          = buffer.ReadUInteger();
            _header.colorImportantCount = buffer.ReadUInteger();

            // Farbtabellenanzahl nachjustieren
            if (_header.colorCount == 0 && _header.bitsPerPixel == 8)
            {
                _header.colorCount = 256;
            }

            // Farbtabelle laden
            bool needAdjustColorTable = false;

            if (_header.colorCount > 0)
            {
                // Bildfarbtabelle laden
                _colorTable = new ColorTable(ref buffer, _header.colorCount);

                // Falls eine Palette übergeben wurde, diese mit der Bildtabelle vergleichen
                if (pal == null || pal._farben.GetLength(0) != 256)
                {
                    needAdjustColorTable = true;
                }
                else
                {
                    for (int i = 0; i < 256; ++i)
                    {
                        // Farben vergleichen
                        Color aktF = _colorTable[i];
                        if (pal._farben[i, 0] != aktF.R || pal._farben[i, 1] != aktF.G || pal._farben[i, 2] != aktF.B)
                        {
                            // Farbtabellen unterscheiden sich
                            needAdjustColorTable = true;
                            break;
                        }
                    }
                }
            }
            else
            {
                // Bei 24-Bit-Bitmaps wird die Farbtabelle später geladen
                _colorTable = null;
            }

            // Nach Bitzahl unterscheiden
            if (_header.bitsPerPixel == 8)
            {
                // Bilddatenbreite ggf. auf ein Vielfaches von 4 Bytes erhöhen
                int width  = _header.width;                // Hilfsvariable zur Performanceerhöhung (immer gleichwertig mit _header.width)
                int width2 = width;
                while (width2 % 4 != 0)
                {
                    width2++;
                }

                // Binäre Original-Bilddaten einlesen
                _imageDataBin = buffer.ReadByteArray(width2 * Math.Abs(_header.height));

                // Neues Bilddaten-Array anlegen (ohne Füllbytes)
                _imageData = new byte[width * Math.Abs(_header.height)];

                // Richtung bestimmen
                bool dirTopDown = (_header.height < 0);

                // Der bisher nächste Farbindex
                byte nearestIndex = 0;

                // Der Abstand zum bisher nächsten Farbindex
                double nearestDistance;

                // Der aktuelle Farbabstand
                double tempDistance = 0.0;

                // Bilddaten abrufen
                int height2 = Math.Abs(_header.height);
                for (int x = 0; x < width2; x++)
                {
                    for (int y = 0; y < height2; y++)
                    {
                        // Wenn es sich bei dem aktuellen Pixel um kein Füllbyte handelt, diesen übernehmen
                        if (x < width)
                        {
                            // Pixel abrufen
                            byte aktCol = _imageDataBin[y * width2 + x];

                            // TODO: 0-Indizes in 255 umwandeln??

                            // Falls nötig, Farben vergleichen
                            if (needAdjustColorTable)
                            {
                                // Alle Farbwerte abrufen
                                byte aktB = _colorTable[aktCol].B;
                                byte aktG = _colorTable[aktCol].G;
                                byte aktR = _colorTable[aktCol].R;

                                // Die zur Pixelfarbe nächste Palettenfarbe suchen
                                {
                                    // Werte zurücksetzen
                                    nearestIndex    = 0;
                                    nearestDistance = 441.673;                                     // Anfangswert: maximaler möglicher Abstand

                                    // Alle Einträge durchgehen
                                    for (int i = 0; i < 256; i++)
                                    {
                                        // Aktuelle Paletten-RGB-Werte abrufen
                                        byte pR = pal._farben[i, 0];
                                        byte pG = pal._farben[i, 1];
                                        byte pB = pal._farben[i, 2];

                                        // Gleiche Einträge sofort filtern
                                        if (aktR == pR && aktB == pB && aktG == pG)
                                        {
                                            // Paletten-Index überschreiben
                                            nearestIndex = (byte)i;

                                            // Fertig
                                            break;
                                        }

                                        // Abstand berechnen (Vektorlänge im dreidimensionalen RGB-Farbraum)
                                        tempDistance = Math.Sqrt(Math.Pow(aktR - pR, 2) + Math.Pow(aktG - pG, 2) + Math.Pow(aktB - pB, 2));

                                        // Vergleichen
                                        if (tempDistance < nearestDistance)
                                        {
                                            // Index merken
                                            nearestDistance = tempDistance;
                                            nearestIndex    = (byte)i;
                                        }
                                    }

                                    // Paletten-Index überschreiben
                                    aktCol = nearestIndex;
                                }
                            }                             // Ende Adjust-ColorTable

                            // Pixel zum Hauptbildarray hinzufügen und dabei nach Top-Down / Bottom-Up unterscheiden
                            _imageData[(dirTopDown ? y : height2 - y - 1) * width + x] = aktCol;
                        }
                    }
                }
            }
            else if (_header.bitsPerPixel == 24)
            {
                // Es handelt sich um ein 24-Bit-Bitmap, somit muss eine Farbtabelle eingeführt werden
                {
                    // Farbpalettenreader abrufen
                    JASCPalette tempPal;
                    if (pal == null)
                    {
                        tempPal = new JASCPalette(new RAMBuffer(BitmapLibrary.Properties.Resources.pal50500));
                    }
                    else
                    {
                        tempPal = pal;
                    }

                    // Farbpaletteninhalt in eigene Farbtabelle schreiben
                    _colorTable = new ColorTable();
                    for (int i = 0; i < tempPal._farben.GetLength(0); i++)
                    {
                        // Eintrag in Tabelle einfügen
                        _colorTable[i] = Color.FromArgb(tempPal._farben[i, 0], tempPal._farben[i, 1], tempPal._farben[i, 2]);

                        // Sicherheitshalber bei i = 255 abbrechen (falls Palette zu groß sein sollte)
                        if (i == 255)
                        {
                            break;
                        }
                    }
                }

                // Bilddatenbreite ggf. auf ein Vielfaches von 4 Bytes erhöhen
                int width     = _header.width;             // Hilfsvariable zur Performanceerhöhung (immer gleichwertig mit _header.width)
                int fillBytes = 0;
                while (((width * 3) + fillBytes) % 4 != 0)
                {
                    fillBytes++;
                }

                // Binäre Original-Bilddaten einlesen
                _imageDataBin = buffer.ReadByteArray((3 * width + fillBytes) * Math.Abs(_header.height));

                // Neues Bilddaten-Array anlegen (ohne Füllbytes)
                _imageData = new byte[width * Math.Abs(_header.height)];

                // Richtung bestimmen
                bool dirTopDown = (_header.height < 0);

                // Der bisher nächste Farbindex
                byte nearestIndex = 0;

                // Der Abstand zum bisher nächsten Farbindex
                double nearestDistance;

                // Der aktuelle Farbabstand
                double tempDistance = 0.0;

                // Bilddaten abrufen
                int height2 = Math.Abs(_header.height);
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height2; y++)
                    {
                        // Pixel abrufen
                        byte aktB = _imageDataBin[y * (3 * width + fillBytes) + 3 * x];
                        byte aktG = _imageDataBin[y * (3 * width + fillBytes) + 3 * x + 1];
                        byte aktR = _imageDataBin[y * (3 * width + fillBytes) + 3 * x + 2];

                        // Die zur Pixelfarbe nächste Palettenfarbe suchen
                        {
                            // Werte zurücksetzen
                            nearestIndex    = 0;
                            nearestDistance = 441.673;                             // Anfangswert: maximaler möglicher Abstand

                            // Alle Einträge durchgehen
                            for (int i = 0; i < 256; i++)
                            {
                                // Aktuelle Paletten-RGB-Werte abrufen
                                byte pR = _colorTable[i].R;
                                byte pG = _colorTable[i].G;
                                byte pB = _colorTable[i].B;

                                // Gleiche Einträge sofort filtern
                                if (aktR == pR && aktB == pB && aktG == pG)
                                {
                                    // Pixel zum Hauptbildarray hinzufügen und dabei nach Top-Down / Bottom-Up unterscheiden
                                    _imageData[(dirTopDown ? y : height2 - y - 1) * width + x] = (byte)i;

                                    // Fertig
                                    break;
                                }

                                // Abstand berechnen (Vektorlänge im dreidimensionalen RGB-Farbraum)
                                tempDistance = Math.Sqrt(Math.Pow(aktR - pR, 2) + Math.Pow(aktG - pG, 2) + Math.Pow(aktB - pB, 2));

                                // Vergleichen
                                if (tempDistance < nearestDistance)
                                {
                                    // Index merken
                                    nearestDistance = tempDistance;
                                    nearestIndex    = (byte)i;
                                }
                            }

                            // Pixel zum Hauptbildarray hinzufügen und dabei nach Top-Down / Bottom-Up unterscheiden
                            _imageData[(dirTopDown ? y : height2 - y - 1) * width + x] = nearestIndex;
                        }
                    }

                    // Ggf. Füllbytes überspringen (bei Dateiende nicht)
                    if (buffer.Position < buffer.Length - fillBytes)
                    {
                        buffer.Position = (buffer.Position + fillBytes);
                    }
                }
            }
        }
コード例 #10
0
        public TerrainBlock ReadData(RAMBuffer buffer)
        {
            VirtualFunctionPtr = buffer.ReadInteger();
            MapPointer         = buffer.ReadInteger();
            MapWidth           = buffer.ReadInteger();
            MapHeight          = buffer.ReadInteger();
            WorldWidth         = buffer.ReadInteger();
            WorldHeight        = buffer.ReadInteger();

            TileSizes = new List <TileSize>(19);
            for (int i = 0; i < 19; ++i)
            {
                TileSizes.Add(new TileSize().ReadData(buffer));
            }

            PaddingTS = buffer.ReadShort();

            Terrains = new List <Terrain>(TERRAIN_COUNT);
            for (int i = 0; i < TERRAIN_COUNT; ++i)
            {
                Terrains.Add(new Terrain().ReadData(buffer));
            }

            TerrainBorders = new List <TerrainBorder>(16);
            for (int i = 0; i < 16; ++i)
            {
                TerrainBorders.Add(new TerrainBorder().ReadData(buffer));
            }

            MapRowOffset = buffer.ReadInteger();
            MapMinX      = buffer.ReadFloat();
            MapMinY      = buffer.ReadFloat();
            MapMaxX      = buffer.ReadFloat();
            MapMaxY      = buffer.ReadFloat();
            MapMaxXplus1 = buffer.ReadFloat();
            MapMaxYplus1 = buffer.ReadFloat();

            TerrainsUsed2  = buffer.ReadUShort();
            BordersUsed    = buffer.ReadUShort();
            MaxTerrain     = buffer.ReadShort();
            TileWidth      = buffer.ReadShort();
            TileHeight     = buffer.ReadShort();
            TileHalfHeight = buffer.ReadShort();
            TileHalfWidth  = buffer.ReadShort();
            ElevHeight     = buffer.ReadShort();
            CurRow         = buffer.ReadShort();
            CurCol         = buffer.ReadShort();
            BlockBegRow    = buffer.ReadShort();
            BlockEndRow    = buffer.ReadShort();
            BlockBegCol    = buffer.ReadShort();
            BlockEndCol    = buffer.ReadShort();

            SearchMapPtr     = buffer.ReadInteger();
            SearchMapRowsPtr = buffer.ReadInteger();
            AnyFrameChange   = buffer.ReadByte();

            MapVisibleFlag = buffer.ReadByte();
            FogFlag        = buffer.ReadByte();

            SomeBytes = new List <byte>(21);
            for (int i = 0; i < 21; i++)
            {
                SomeBytes.Add(buffer.ReadByte());
            }

            SomeInt32 = new List <int>(157);
            for (int i = 0; i < 157; i++)
            {
                SomeInt32.Add(buffer.ReadInteger());
            }

            return(this);
        }
コード例 #11
0
            public Unit ReadData(RAMBuffer buffer)
            {
                Type                    = (UnitType)buffer.ReadByte();
                NameLength1             = buffer.ReadUShort();
                ID1                     = buffer.ReadShort();
                LanguageDLLName         = buffer.ReadUShort();
                LanguageDLLCreation     = buffer.ReadUShort();
                Class                   = buffer.ReadShort();
                StandingGraphic1        = buffer.ReadShort();
                StandingGraphic2        = buffer.ReadShort();
                DyingGraphic1           = buffer.ReadShort();
                DyingGraphic2           = buffer.ReadShort();
                DeathMode               = buffer.ReadByte();
                HitPoints               = buffer.ReadShort();
                LineOfSight             = buffer.ReadFloat();
                GarrisonCapacity        = buffer.ReadByte();
                SizeRadius1             = buffer.ReadFloat();
                SizeRadius2             = buffer.ReadFloat();
                HPBarHeight1            = buffer.ReadFloat();
                TrainSound1             = buffer.ReadShort();
                TrainSound2             = buffer.ReadShort();
                DeadUnitID              = buffer.ReadShort();
                PlacementMode           = buffer.ReadByte();
                AirMode                 = buffer.ReadByte();
                IconID                  = buffer.ReadShort();
                HideInEditor            = buffer.ReadByte();
                Unknown1                = buffer.ReadShort();
                Enabled                 = buffer.ReadByte();
                Disabled                = buffer.ReadByte();
                PlacementBypassTerrain1 = buffer.ReadShort();
                PlacementBypassTerrain2 = buffer.ReadShort();
                PlacementTerrain1       = buffer.ReadShort();
                PlacementTerrain2       = buffer.ReadShort();
                EditorRadius1           = buffer.ReadFloat();
                EditorRadius2           = buffer.ReadFloat();
                HillMode                = buffer.ReadByte();
                VisibleInFog            = buffer.ReadByte();
                TerrainRestriction      = buffer.ReadShort();
                FlyMode                 = buffer.ReadByte();
                ResourceCapacity        = buffer.ReadShort();
                ResourceDecay           = buffer.ReadFloat();
                BlastType               = buffer.ReadByte();
                Unknown2                = buffer.ReadByte();
                InteractionMode         = buffer.ReadByte();
                MinimapMode             = buffer.ReadByte();
                CommandAttribute        = buffer.ReadByte();
                Unknown3A               = buffer.ReadFloat();
                MinimapColor            = buffer.ReadByte();
                LanguageDLLHelp         = buffer.ReadInteger();
                LanguageDLLHotKeyText   = buffer.ReadInteger();
                HotKey                  = buffer.ReadInteger();
                Unselectable            = buffer.ReadByte();
                Unknown6                = buffer.ReadByte();
                UnknownSelectionMode    = buffer.ReadByte();
                Unknown8                = buffer.ReadByte();
                SelectionMask           = buffer.ReadByte();
                SelectionShapeType      = buffer.ReadByte();
                SelectionShape          = buffer.ReadByte();
                Attribute               = buffer.ReadByte();
                Civilization            = buffer.ReadByte();
                Nothing                 = buffer.ReadShort();
                SelectionEffect         = buffer.ReadByte();
                EditorSelectionColor    = buffer.ReadByte();
                SelectionRadius1        = buffer.ReadFloat();
                SelectionRadius2        = buffer.ReadFloat();
                HPBarHeight2            = buffer.ReadFloat();

                ResourceStorages = new List <ResourceTuple <short, float, byte> >(3);
                for (int i = 0; i < 3; ++i)
                {
                    ResourceStorages.Add(new ResourceTuple <short, float, byte>()
                    {
                        Type = buffer.ReadShort(), Amount = buffer.ReadFloat(), Mode = buffer.ReadByte()
                    });
                }

                int damageGraphicCount = buffer.ReadByte();

                DamageGraphics = new List <DamageGraphic>();
                for (int i = 0; i < damageGraphicCount; ++i)
                {
                    DamageGraphics.Add(new DamageGraphic().ReadData(buffer));
                }

                SelectionSound = buffer.ReadShort();
                DyingSound     = buffer.ReadShort();
                AttackMode     = buffer.ReadByte();
                EdibleMeat     = buffer.ReadByte();
                Name1          = buffer.ReadString(NameLength1);
                ID2            = buffer.ReadShort();
                ID3            = buffer.ReadShort();

                if (Type >= UnitType.Flag)
                {
                    Speed = buffer.ReadFloat();
                }
                if (Type >= UnitType.DeadFish)
                {
                    DeadFish = new UnitTypes.DeadFish().ReadData(buffer);
                }
                if (Type >= UnitType.Bird)
                {
                    Bird = new UnitTypes.Bird().ReadData(buffer);
                }
                if (Type >= UnitType.Type50)
                {
                    Type50 = new UnitTypes.Type50().ReadData(buffer);
                }
                if (Type == UnitType.Projectile)
                {
                    Projectile = new UnitTypes.Projectile().ReadData(buffer);
                }
                if (Type >= UnitType.Creatable)
                {
                    Creatable = new UnitTypes.Creatable().ReadData(buffer);
                }
                if (Type == UnitType.Building)
                {
                    Building = new UnitTypes.Building().ReadData(buffer);
                }

                return(this);
            }
コード例 #12
0
        /// <summary>
        /// Lädt alle Daten aus dem internen Puffer in die jeweiligen Variablen.
        /// </summary>
        /// <remarks></remarks>
        private void ReadData()
        {
            // Dateiversion lesen
            string version = _buffer.ReadString(8);

            if (version != "VER 5.7\0")
            {
                throw new InvalidDataException("Invalid file format or wrong version.");
            }

            // Anzahlen lesen
            ushort terrainRestrictionCount = _buffer.ReadUShort();
            ushort terrainCount            = _buffer.ReadUShort();

            // Terrain-Pointer lesen
            TerrainRestrictionPointers1 = new List <int>(terrainRestrictionCount);
            for (int i = 0; i < terrainRestrictionCount; ++i)
            {
                TerrainRestrictionPointers1.Add(_buffer.ReadInteger());
            }
            TerrainRestrictionPointers2 = new List <int>(terrainRestrictionCount);
            for (int i = 0; i < terrainRestrictionCount; ++i)
            {
                TerrainRestrictionPointers2.Add(_buffer.ReadInteger());
            }

            // Terrain-Beschränkungen lesen
            TerrainRestrictions = new List <DataElements.TerrainRestriction>(terrainRestrictionCount);
            DataElements.TerrainRestriction.TerrainCount = terrainCount;
            for (int i = 0; i < terrainRestrictionCount; ++i)
            {
                TerrainRestrictions.Add(new DataElements.TerrainRestriction().ReadData(_buffer));
            }

            // Anzahl lesen
            ushort playerColorCount = _buffer.ReadUShort();

            // Spielerfarben lesen
            PlayerColors = new List <DataElements.PlayerColor>(playerColorCount);
            for (int i = 0; i < playerColorCount; ++i)
            {
                PlayerColors.Add(new DataElements.PlayerColor().ReadData(_buffer));
            }

            // Anzahl lesen
            ushort soundCount = _buffer.ReadUShort();

            // Sounds lesen
            Sounds = new List <DataElements.Sound>(soundCount);
            for (int i = 0; i < soundCount; ++i)
            {
                Sounds.Add(new DataElements.Sound().ReadData(_buffer));
            }

            // Anzahl lesen
            int graphicCount = _buffer.ReadUShort();

            // Grafik-Pointer lesen
            GraphicPointers = new List <int>(graphicCount);
            for (int i = 0; i < graphicCount; ++i)
            {
                GraphicPointers.Add(_buffer.ReadInteger());
            }

            // Grafiken lesen
            Graphics = new Dictionary <int, DataElements.Graphic>(graphicCount);
            for (int p = 0; p < GraphicPointers.Count; ++p)
            {
                if (GraphicPointers[p] != 0)
                {
                    Graphics.Add(p, new DataElements.Graphic().ReadData(_buffer));
                }
            }

            // Terrain-Daten lesen
            TerrainBlock = new DataElements.TerrainBlock().ReadData(_buffer);

            // RandomMap-Daten lese
            RandomMaps = new DataElements.RandomMaps().ReadData(_buffer);

            // Anzahl lesen
            int techageCount = _buffer.ReadInteger();

            // Technologie-Effekte lesen
            Techages = new List <DataElements.Techage>(techageCount);
            for (int i = 0; i < techageCount; ++i)
            {
                Techages.Add(new DataElements.Techage().ReadData(_buffer));
            }

            // Anzahl lesen
            int unitCount = _buffer.ReadInteger();

            // Einheiten-Header lesen
            UnitHeaders = new List <DataElements.UnitHeader>(unitCount);
            for (int i = 0; i < unitCount; ++i)
            {
                UnitHeaders.Add(new DataElements.UnitHeader().ReadData(_buffer));
            }

            // Anzahl lesen
            int civCount = _buffer.ReadUShort();

            // Kulturen lesen
            Civs = new List <DataElements.Civ>(civCount);
            for (int i = 0; i < civCount; ++i)
            {
                Civs.Add(new DataElements.Civ().ReadData(_buffer));
            }

            // Anzahl lesen
            int researchCount = _buffer.ReadUShort();

            // Technologien lesen
            Researches = new List <DataElements.Research>(researchCount);
            for (int i = 0; i < researchCount; ++i)
            {
                Researches.Add(new DataElements.Research().ReadData(_buffer));
            }

            // Unbekannte Technologiebaum-Daten lesen
            TechTreeUnknown = new List <int>(7);
            for (int i = 0; i < 7; ++i)
            {
                TechTreeUnknown.Add(_buffer.ReadInteger());
            }

            // TechTree lesen
            TechTree = new DataElements.TechTree().ReadData(_buffer);

            // Auf neuen TechTree prüfen
            if (_buffer.Length - _buffer.Position > 4)
            {
                // Marker einlesen
                string newTechTreeMarker = _buffer.ReadString(3);
                if (newTechTreeMarker == NEW_TECH_TREE_MARKER)
                {
                    _newTechTree = true;
                }
            }
            if (_newTechTree)
            {
                TechTreeNew = new DataElements.TechTreeNew().ReadData(_buffer);
            }

            // Puffer leeren, um Speicher zu sparen
            _buffer.Clear();
        }