Ejemplo n.º 1
0
        public override void ReadData(RAMBuffer buffer)
        {
            ResourceCosts = new List<ResourceTuple<short, short, short>>(3);
            for(int i = 0; i < 3; ++i)
                ResourceCosts.Add(new ResourceTuple<short, short, short>() { Type = buffer.ReadShort(), Amount = buffer.ReadShort(), Enabled = buffer.ReadShort() });

            TrainTime = buffer.ReadShort();
            TrainLocationID = buffer.ReadShort();
            ButtonID = buffer.ReadByte();
            Unknown26 = buffer.ReadInteger();
            Unknown27 = buffer.ReadInteger();
            Unknown28 = buffer.ReadByte();
            HeroMode = buffer.ReadByte();
            GarrisonGraphic = buffer.ReadInteger();
            DuplicatedMissilesMin = buffer.ReadFloat();
            DuplicatedMissilesMax = buffer.ReadByte();

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

            AlternativeProjectileUnit = buffer.ReadInteger();
            ChargingGraphic = buffer.ReadInteger();
            ChargingMode = buffer.ReadByte();
            DisplayedPierceArmour = buffer.ReadShort();
        }
Ejemplo n.º 2
0
        public override void WriteData(RAMBuffer buffer)
        {
            AssertListLength(ResourceCosts, 3);
            ResourceCosts.ForEach(e =>
            {
                buffer.WriteShort(e.Type);
                buffer.WriteShort(e.Amount);
                buffer.WriteShort(e.Enabled);
            });

            buffer.WriteShort(TrainTime);
            buffer.WriteShort(TrainLocationID);
            buffer.WriteByte(ButtonID);
            buffer.WriteInteger(Unknown26);
            buffer.WriteInteger(Unknown27);
            buffer.WriteByte(Unknown28);
            buffer.WriteByte(HeroMode);
            buffer.WriteInteger(GarrisonGraphic);
            buffer.WriteFloat(DuplicatedMissilesMin);
            buffer.WriteByte(DuplicatedMissilesMax);

            AssertListLength(MissileSpawningArea, 3);
            MissileSpawningArea.ForEach(e => buffer.WriteFloat(e));

            buffer.WriteInteger(AlternativeProjectileUnit);
            buffer.WriteInteger(ChargingGraphic);
            buffer.WriteByte(ChargingMode);
            buffer.WriteShort(DisplayedPierceArmour);
        }
Ejemplo n.º 3
0
 public override void ReadData(RAMBuffer buffer)
 {
     Buildable = buffer.ReadInteger();
     GraphicID1 = buffer.ReadInteger();
     GraphicID2 = buffer.ReadInteger();
     ReplicationAmount = buffer.ReadInteger();
 }
Ejemplo n.º 4
0
        public override void ReadData(RAMBuffer buffer)
        {
            ConstructionGraphicID = buffer.ReadShort();
            SnowGraphicID = buffer.ReadShort();
            AdjacentMode = buffer.ReadByte();
            GraphicsAngle = buffer.ReadShort();
            DisappearsWhenBuilt = buffer.ReadByte();
            StackUnitID = buffer.ReadShort();
            FoundationTerrainID = buffer.ReadShort();
            OldTerrainLikeID = buffer.ReadShort();
            ResearchID = buffer.ReadShort();
            Unknown33 = buffer.ReadByte();

            Annexes = new List<BuildingAnnex>(4);
            for(int i = 0; i < 4; ++i)
                Annexes.Add(new BuildingAnnex().ReadDataInline(buffer));

            HeadUnit = buffer.ReadShort();
            TransformUnit = buffer.ReadShort();
            UnknownSound = buffer.ReadShort();
            ConstructionSound = buffer.ReadShort();
            GarrisonType = buffer.ReadByte();
            GarrisonHealRate = buffer.ReadFloat();
            Unknown35 = buffer.ReadFloat();
            PileUnit = buffer.ReadShort();

            LootingTable = new List<byte>(6);
            for(int i = 0; i < 6; ++i)
                LootingTable.Add(buffer.ReadByte());
        }
Ejemplo n.º 5
0
        public override void 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(), Enabled = 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);
        }
Ejemplo n.º 6
0
        public override void WriteData(RAMBuffer buffer)
        {
            AssertListLength(TerrainAccessibleFlags, TerrainCount);
            TerrainAccessibleFlags.ForEach(e => buffer.WriteFloat(e));

            AssertListLength(TerrainPassGraphics, TerrainCount);
            TerrainPassGraphics.ForEach(e => e.WriteData(buffer));
        }
Ejemplo n.º 7
0
 public override void WriteData(RAMBuffer buffer)
 {
     buffer.WriteString(FileName, 13);
     buffer.WriteInteger(ResourceID);
     buffer.WriteShort(Probability);
     buffer.WriteShort(Civ);
     buffer.WriteShort(Unknown1);
 }
Ejemplo n.º 8
0
 public override void WriteData(RAMBuffer buffer)
 {
     buffer.WriteByte(Type);
     buffer.WriteShort(A);
     buffer.WriteShort(B);
     buffer.WriteShort(C);
     buffer.WriteFloat(D);
 }
Ejemplo n.º 9
0
 public override void ReadData(RAMBuffer buffer)
 {
     FileName = buffer.ReadString(13);
     ResourceID = buffer.ReadInteger();
     Probability = buffer.ReadShort();
     Civ = buffer.ReadShort();
     Unknown1 = buffer.ReadShort();
 }
Ejemplo n.º 10
0
 public override void ReadData(RAMBuffer buffer)
 {
     Type = buffer.ReadByte();
     A = buffer.ReadShort();
     B = buffer.ReadShort();
     C = buffer.ReadShort();
     D = buffer.ReadFloat();
 }
Ejemplo n.º 11
0
        public override void WriteData(RAMBuffer buffer)
        {
            buffer.WriteShort(ID);
            buffer.WriteShort(Unknown1);
            buffer.WriteShort((short)Items.Count);
            buffer.WriteInteger(Unknown2);

            Items.ForEach(e => e.WriteData(buffer));
        }
Ejemplo n.º 12
0
        public override void 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().ReadDataInline(buffer));
        }
Ejemplo n.º 13
0
 public override void ReadData(RAMBuffer buffer)
 {
     StretchMode = buffer.ReadByte();
     CompensationMode = buffer.ReadByte();
     DropAnimationMode = buffer.ReadByte();
     PenetrationMode = buffer.ReadByte();
     Unknown24 = buffer.ReadByte();
     ProjectileArc = buffer.ReadFloat();
 }
Ejemplo n.º 14
0
 public override void WriteData(RAMBuffer buffer)
 {
     buffer.WriteByte(StretchMode);
     buffer.WriteByte(CompensationMode);
     buffer.WriteByte(DropAnimationMode);
     buffer.WriteByte(PenetrationMode);
     buffer.WriteByte(Unknown24);
     buffer.WriteFloat(ProjectileArc);
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Schreibt die TechTree-Daten.
        /// </summary>
        /// <param name="buffer">Der Datenpuffer.</param>
        /// <param name="writeTreeOnly">Gibt an, ob nur die Baumdaten (und nicht auch das Design) geschrieben werden sollen.</param>
        public void WriteData(RAMBuffer buffer, bool writeTreeOnly)
        {
            // Stammelemente schreiben
            buffer.WriteShort((short)ParentElements.Count);
            ParentElements.ForEach(p => p.WriteData(buffer));

            // Designdaten schreiben
            if(!writeTreeOnly)
                DesignData.WriteData(buffer);
        }
Ejemplo n.º 16
0
        public override void ReadData(RAMBuffer buffer)
        {
            TerrainAccessibleFlags = new List<float>(TerrainCount);
            for(int i = 0; i < TerrainCount; ++i)
                TerrainAccessibleFlags.Add(buffer.ReadFloat());

            TerrainPassGraphics = new List<TerrainPassGraphic>(TerrainCount);
            for(int i = 0; i < TerrainCount; ++i)
                TerrainPassGraphics.Add(new TerrainPassGraphic().ReadDataInline(buffer));
        }
Ejemplo n.º 17
0
        public override void WriteData(RAMBuffer buffer)
        {
            buffer.WriteByte(Exists);

            if(Exists != 0)
            {
                buffer.WriteUShort((ushort)Commands.Count);
                Commands.ForEach(e => e.WriteData(buffer));
            }
        }
Ejemplo n.º 18
0
        public override void ReadData(RAMBuffer buffer)
        {
            ID = buffer.ReadShort();
            Unknown1 = buffer.ReadShort();
            short count = buffer.ReadShort();
            Unknown2 = buffer.ReadInteger();

            Items = new List<SoundItem>(count);
            for(int i = 0; i < count; ++i)
                Items.Add(new SoundItem().ReadDataInline(buffer));
        }
Ejemplo n.º 19
0
 public override void ReadData(RAMBuffer buffer)
 {
     SheepConversion = buffer.ReadShort();
     SearchRadius = buffer.ReadFloat();
     WorkRate = buffer.ReadFloat();
     DropSite1 = buffer.ReadShort();
     DropSite2 = buffer.ReadShort();
     VillagerMode = buffer.ReadByte();
     AttackSound = buffer.ReadShort();
     MoveSound = buffer.ReadShort();
     AnimalMode = buffer.ReadByte();
 }
Ejemplo n.º 20
0
 public override void WriteData(RAMBuffer buffer)
 {
     buffer.WriteShort(SheepConversion);
     buffer.WriteFloat(SearchRadius);
     buffer.WriteFloat(WorkRate);
     buffer.WriteShort(DropSite1);
     buffer.WriteShort(DropSite2);
     buffer.WriteByte(VillagerMode);
     buffer.WriteShort(AttackSound);
     buffer.WriteShort(MoveSound);
     buffer.WriteByte(AnimalMode);
 }
Ejemplo n.º 21
0
 public override void WriteData(RAMBuffer buffer)
 {
     buffer.WriteInteger(ID);
     buffer.WriteInteger(Palette);
     buffer.WriteInteger(Color);
     buffer.WriteInteger(Unknown1);
     buffer.WriteInteger(Unknown2);
     buffer.WriteInteger(MinimapColor);
     buffer.WriteInteger(Unknown3);
     buffer.WriteInteger(Unknown4);
     buffer.WriteInteger(StatisticsText);
 }
Ejemplo n.º 22
0
 public override void ReadData(RAMBuffer buffer)
 {
     ID = buffer.ReadInteger();
     Palette = buffer.ReadInteger();
     Color = buffer.ReadInteger();
     Unknown1 = buffer.ReadInteger();
     Unknown2 = buffer.ReadInteger();
     MinimapColor = buffer.ReadInteger();
     Unknown3 = buffer.ReadInteger();
     Unknown4 = buffer.ReadInteger();
     StatisticsText = buffer.ReadInteger();
 }
Ejemplo n.º 23
0
        public override void 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().ReadDataInline(buffer));
            }
        }
Ejemplo n.º 24
0
        public override void WriteData(RAMBuffer buffer)
        {
            buffer.WriteByte((byte)TechTreeAges.Count);
            buffer.WriteByte((byte)BuildingConnections.Count);
            buffer.WriteByte((byte)UnitConnections.Count);
            buffer.WriteByte((byte)ResearchConnections.Count);
            buffer.WriteInteger(Unknown2);

            TechTreeAges.ForEach(e => e.WriteData(buffer));
            BuildingConnections.ForEach(e => e.WriteData(buffer));
            UnitConnections.ForEach(e => e.WriteData(buffer));
            ResearchConnections.ForEach(e => e.WriteData(buffer));
        }
Ejemplo n.º 25
0
        public override void WriteData(RAMBuffer buffer)
        {
            buffer.WriteShort(WalkingGraphic1);
            buffer.WriteShort(WalkingGraphic2);
            buffer.WriteFloat(RotationSpeed);
            buffer.WriteByte(Unknown11);
            buffer.WriteShort(TrackingUnit);
            buffer.WriteByte(TrackingUnitUsed);
            buffer.WriteFloat(TrackingUnitDensity);
            buffer.WriteByte(Unknown16);

            AssertListLength(Unknown16B, 5);
            Unknown16B.ForEach(e => buffer.WriteInteger(e));
        }
Ejemplo n.º 26
0
        public override void ReadData(RAMBuffer buffer)
        {
            WalkingGraphic1 = buffer.ReadShort();
            WalkingGraphic2 = buffer.ReadShort();
            RotationSpeed = buffer.ReadFloat();
            Unknown11 = buffer.ReadByte();
            TrackingUnit = buffer.ReadShort();
            TrackingUnitUsed = buffer.ReadByte();
            TrackingUnitDensity = buffer.ReadFloat();
            Unknown16 = buffer.ReadByte();

            Unknown16B = new List<int>(5);
            for(int i = 0; i < 5; ++i)
                Unknown16B.Add(buffer.ReadInteger());
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Schreibt die Daten aus dem gegebenen Puffer in diese Instanz.
        /// </summary>
        /// <param name="buffer">Der Puffer mit den zu schreibenden Daten.</param>
        /// <param name="overWrite">Legt fest, ob die Daten im Puffer mit den neuen Daten überschrieben werden sollen.</param>
        public void Write(RAMBuffer buffer, bool overWrite = true)
        {
            // Datenlänge merken
            int len = buffer.Length;

            // Bei großen List-Allokationen kann eine OutOfMemory-Exception auftreten, wenn kein hinreichend großer virtueller Speicherblock gefunden wird
            try
            {
                // Soll überschrieben werden? => Wenn _pos an das Ende des Arrays zeigt, wird in jedem Fall nur eingefügt
                if (overWrite && _pos < _data.Count)
                {
                    // Es muss ein bestimmter Bereich gelöscht werden; der Löschbereich darf die Puffergrenze nicht überschreiten
                    if (_pos + len < _data.Count - 1)
                    {
                        // Alles OK, Bereich löschen
                        _data.RemoveRange(_pos, len);

                        // Daten einfügen
                        _data.InsertRange(_pos, buffer._data);
                    }
                    else
                    {
                        // Nur bis zum Listenende löschen
                        _data.RemoveRange(_pos, _data.Count - _pos);

                        // Daten anhängen
                        _data.AddRange(buffer._data);
                    }
                }
                else
                {
                    // Daten anhängen
                    _data.AddRange(buffer._data);
                }
            }
            catch (OutOfMemoryException)
            {
                // Fehlermeldung ausgeben
                MessageBox.Show("Schwerwiegender Fehler: Es kann kein hinreichend großer virtueller Speicherblock allokiert werden.\nVersuchen Sie ungespeicherte Änderungen zu sichern und starten Sie das Programm neu, da möglicherweise ein instabiler Zustand besteht.\n\nVielleicht hilft es, das Programm im 64-Bit-Modus auszuführen?", "Fehler bei Allokation", MessageBoxButtons.OK, MessageBoxIcon.Error);

                // Puffer leeren, damit die Meldung nicht noch x-mal auftaucht - der Schaden ist eh schon angerichtet
                _data.Clear();
            }

            // Die Position um die Datenlänge erhöhen
            _pos += len;
        }
Ejemplo n.º 28
0
        public override void WriteData(RAMBuffer buffer)
        {
            buffer.WriteByte(One);
            buffer.WriteString(Name, 20);
            buffer.WriteUShort((ushort)Resources.Count);
            buffer.WriteShort(TechTreeID);
            buffer.WriteShort(TeamBonusID);
            Resources.ForEach(e => buffer.WriteFloat(e));
            buffer.WriteByte(IconSet);
            buffer.WriteUShort((ushort)UnitPointers.Count);
            UnitPointers.ForEach(e => buffer.WriteInteger(e));

            // Sicherstellen, dass genau jede definierte Einheit einen entsprechenden Pointer hat; hier nur über die Listenlänge, sollte aber die meisten auftretenden Fehler abdecken
            AssertListLength(Units, UnitPointers.Count(p => p != 0));
            foreach(var u in Units)
                u.Value.WriteData(buffer);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Lädt die TechTree-Daten.
        /// </summary>
        /// <param name="buffer">Der Datenpuffer.</param>
        /// <param name="readTreeOnly">Gibt an, ob nur die Baumdaten (und nicht auch das Design) geladen werden sollen.</param>
        public void ReadData(RAMBuffer buffer, bool readTreeOnly)
        {
            // Stammelemente lesen
            short parentCount = buffer.ReadShort();
            ParentElements = new List<TechTreeElement>();
            for(int i = 0; i < parentCount; ++i)
                ParentElements.Add(new TechTreeElement().ReadDataInline(buffer));

            // Design lesen
            if(!readTreeOnly)
            {
                // Nur wenn vorhanden, um Kompatibilität zu älteren Dateien zu erhalten
                DesignData = new TechTreeDesign();
                if(buffer.Position < buffer.Length)
                    DesignData.ReadData(buffer);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Erstellt eine neue Instanz von DRSFile und lädt alle Daten.
        /// </summary>
        /// <param name="filename">Der Pfad und Dateiname der zu ladenden DRS-Datei.</param>
        /// <remarks></remarks>
        public DRSFile(string filename)
        {
            // Speichern des Dateinamens
            _filename = filename;

            // Sicherstellen, dass die Datei existiert
            if(!File.Exists(filename))
            {
                MessageBox.Show("Fehler: Die DRS-Datei wurde nicht gefunden!", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Erstellen des Puffer-Objekts und Laden der Daten
            _buffer = new RAMBuffer(_filename);

            // Laden der Daten
            LoadData();
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Erstellt eine neue Farbtabelle aus derm Bitmap-Puffer (d.h. aus einer binären Bitmap-Tabelle).
        /// </summary>
        /// <param name="buffer">Der Bitmap-Puffer mit einem Zeiger am Beginn der Farbtabelle.</param>
        /// <param name="count">Die Anzahl der in der Tabelle definierten Farben.</param>
        public ColorTable(ref RAMBuffer buffer, uint count)
        {
            // Einträge einzeln einlesen
            for(int i = 0; i < count; ++i)
            {
                // 4 Bytes lesen
                byte[] b = buffer.ReadByteArray(4);

                // Farbeintrag erstellen
                _colors[i] = Color.FromArgb(b[2], b[1], b[0]);
            }

            // Fehlende Einträge mit 255er-Weiß initialisieren
            for(int i = (int)count; i < 256; ++i)
            {
                // Weiß einfügen
                _colors[i] = Color.FromArgb(255, 255, 255);
            }
        }