public TechTree ReadData(RAMBuffer buffer)
        {
            byte ageCount      = buffer.ReadByte();
            byte buildingCount = buffer.ReadByte();
            byte unitCount     = buffer.ReadByte();
            byte researchCount = buffer.ReadByte();

            Unknown2 = buffer.ReadInteger();

            TechTreeAges = new List <TechTreeAge>(ageCount);
            for (int i = 0; i < ageCount; ++i)
            {
                TechTreeAges.Add(new TechTreeAge().ReadData(buffer));
            }

            BuildingConnections = new List <BuildingConnection>(buildingCount);
            for (int i = 0; i < buildingCount; ++i)
            {
                BuildingConnections.Add(new BuildingConnection().ReadData(buffer));
            }

            UnitConnections = new List <UnitConnection>(unitCount);
            for (int i = 0; i < unitCount; ++i)
            {
                UnitConnections.Add(new UnitConnection().ReadData(buffer));
            }

            ResearchConnections = new List <ResearchConnection>(researchCount);
            for (int i = 0; i < researchCount; ++i)
            {
                ResearchConnections.Add(new ResearchConnection().ReadData(buffer));
            }

            return(this);
        }
            public UnitConnection ReadData(RAMBuffer buffer)
            {
                ID            = buffer.ReadInteger();
                Unknown1      = buffer.ReadByte();
                UpperBuilding = buffer.ReadInteger();

                Common = new Common().ReadData(buffer);

                VerticalLine = buffer.ReadInteger();

                byte unitCount = buffer.ReadByte();

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

                LocationInAge    = buffer.ReadInteger();
                RequiredResearch = buffer.ReadInteger();
                LineMode         = buffer.ReadInteger();
                EnablingResearch = buffer.ReadInteger();

                return(this);
            }
Exemple #3
0
        public Creatable 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(), Mode = buffer.ReadShort()
                });
            }

            TrainTime       = buffer.ReadShort();
            TrainLocationID = buffer.ReadShort();
            ButtonID        = buffer.ReadByte();
            Unknown26       = buffer.ReadFloat();
            Unknown27       = buffer.ReadFloat();
            Unknown28       = buffer.ReadByte();
            HeroMode        = buffer.ReadByte();
            GarrisonGraphic = buffer.ReadInteger();
            ProjectileCount = buffer.ReadFloat();
            ProjectileCountOnFullGarrison    = buffer.ReadByte();
            ProjectileSpawningAreaWidth      = buffer.ReadFloat();
            ProjectileSpawningAreaHeight     = buffer.ReadFloat();
            ProjectileSpawningAreaRandomness = buffer.ReadFloat();
            AlternativeProjectileUnit        = buffer.ReadInteger();
            ChargingGraphic      = buffer.ReadInteger();
            ChargingMode         = buffer.ReadByte();
            DisplayedPierceArmor = buffer.ReadShort();

            return(this);
        }
Exemple #4
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 MapTileTerrainData ReadData(RAMBuffer buffer)
            {
                TerrainId = buffer.ReadByte();
                Elevation = buffer.ReadByte();
                Unused    = buffer.ReadByte();

                return(this);
            }
Exemple #5
0
                public DamageGraphic ReadData(RAMBuffer buffer)
                {
                    GraphicID     = buffer.ReadShort();
                    DamagePercent = buffer.ReadByte();
                    ApplyMode     = buffer.ReadByte();
                    Unknown2      = buffer.ReadByte();

                    return(this);
                }
Exemple #6
0
        public Projectile ReadData(RAMBuffer buffer)
        {
            StretchMode       = buffer.ReadByte();
            CompensationMode  = buffer.ReadByte();
            DropAnimationMode = buffer.ReadByte();
            PenetrationMode   = buffer.ReadByte();
            Unknown24         = buffer.ReadByte();
            ProjectileArc     = buffer.ReadFloat();

            return(this);
        }
Exemple #7
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);
            }
Exemple #8
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);
        }
Exemple #9
0
        public Bird 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();

            return(this);
        }
        /// <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 TechTreeNew ReadData(RAMBuffer buffer, bool readTreeOnly)
        {
            // Versionsbyte lesen
            byte version = buffer.ReadByte();

            if (version > NEW_TECH_TREE_VERSION)
            {
                throw new Exception("This file was created with a newer version of this program. Please consider updating.");
            }

            // Stammelemente lesen
            short parentCount = buffer.ReadShort();

            ParentElements = new List <TechTreeElement>();
            for (int i = 0; i < parentCount; ++i)
            {
                ParentElements.Add(new TechTreeElement().ReadData(buffer, version));
            }

            // Design lesen
            if (!readTreeOnly)
            {
                DesignData = new TechTreeDesign().ReadData(buffer);
            }

            return(this);
        }
Exemple #11
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 IncludedFiles ReadData(RAMBuffer buffer)
        {
            int filesIncluded = buffer.ReadInteger();

            EsOnlyDataIncluded = buffer.ReadUInteger();
            if (EsOnlyDataIncluded > 0)
            {
                EsOnlyData = new List <byte>(396);
                for (int i = 0; i < 396; ++i)
                {
                    EsOnlyData.Add(buffer.ReadByte());
                }
            }

            if (filesIncluded > 0)
            {
                int fileCount = buffer.ReadInteger();
                Files = new List <IncludedFile>(fileCount);
                for (int i = 0; i < fileCount; i++)
                {
                    Files.Add(new IncludedFile().ReadData(buffer));
                }
            }

            return(this);
        }
Exemple #12
0
        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);
        }
        /// <summary>
        /// Konstruktor. Liest die Daten aus dem gegebenen Puffer.
        /// </summary>
        /// <param name="buffer">Der Puffer, aus dem die Segeldaten gelesen werden sollen.</param>
        public Sail(RAMBuffer buffer)
            : this()
        {
            // Benutzung lesen
            Used = (buffer.ReadByte() == 1);

            // SLPs lesen
            int count = buffer.ReadByte();

            for (int i = 0; i < count; ++i)
            {
                // Lesen
                ShipFile.Civ currCiv = (ShipFile.Civ)buffer.ReadByte();
                SLPFile      currSlp = new SLPFile(buffer);
                SailSlps.Add(currCiv, currSlp);
            }
        }
Exemple #14
0
            public UnitCommand ReadData(RAMBuffer buffer)
            {
                One        = buffer.ReadShort();
                ID         = buffer.ReadShort();
                Unknown1   = buffer.ReadByte();
                Type       = buffer.ReadShort();
                ClassID    = buffer.ReadShort();
                UnitID     = buffer.ReadShort();
                TerrainID  = buffer.ReadShort();
                ResourceIn = buffer.ReadShort();
                ResourceProductivityMultiplier = buffer.ReadShort();
                ResourceOut        = buffer.ReadShort();
                Resource           = buffer.ReadShort();
                WorkRateMultiplier = buffer.ReadFloat();
                ExecutionRadius    = buffer.ReadFloat();
                ExtraRange         = buffer.ReadFloat();
                Unknown4           = buffer.ReadByte();
                Unknown5           = buffer.ReadFloat();
                SelectionEnabler   = buffer.ReadByte();
                Unknown7           = buffer.ReadByte();
                PlunderSource      = buffer.ReadShort();
                Unknown9           = buffer.ReadShort();
                SelectionMode      = buffer.ReadByte();
                RightClickMode     = buffer.ReadByte();
                Unknown12          = buffer.ReadByte();

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

                return(this);
            }
            public MapUnit ReadData(RAMBuffer buffer)
            {
                Unit                  = buffer.ReadInteger();
                HostTerrain           = buffer.ReadInteger();
                GroupPlacing          = buffer.ReadByte();
                ScaleFlag             = buffer.ReadByte();
                Padding1              = buffer.ReadShort();
                ObjectsPerGroup       = buffer.ReadInteger();
                Fluctuation           = buffer.ReadInteger();
                GroupsPerPlayer       = buffer.ReadInteger();
                GroupArea             = buffer.ReadInteger();
                PlayerID              = buffer.ReadInteger();
                SetPlaceForAllPlayers = buffer.ReadInteger();
                MinDistanceToPlayers  = buffer.ReadInteger();
                MaxDistanceToPlayers  = buffer.ReadInteger();

                return(this);
            }
        public DeadFish 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());
            }

            return(this);
        }
Exemple #17
0
            public TechageEffect ReadData(RAMBuffer buffer)
            {
                Type = buffer.ReadByte();
                A    = buffer.ReadShort();
                B    = buffer.ReadShort();
                C    = buffer.ReadShort();
                D    = buffer.ReadFloat();

                return(this);
            }
            public MapLand ReadData(RAMBuffer buffer)
            {
                LandID          = buffer.ReadInteger();
                Terrain         = buffer.ReadInteger();
                LandSpacing     = buffer.ReadInteger();
                BaseSize        = buffer.ReadInteger();
                Zone            = buffer.ReadByte();
                PlacementType   = buffer.ReadByte();
                Padding1        = buffer.ReadShort();
                BaseX           = buffer.ReadInteger();
                BaseY           = buffer.ReadInteger();
                LandProportion  = buffer.ReadByte();
                ByPlayerFlag    = buffer.ReadByte();
                Padding2        = buffer.ReadShort();
                StartAreaRadius = buffer.ReadInteger();
                TerrainEdgeFade = buffer.ReadInteger();
                Clumpiness      = buffer.ReadInteger();

                return(this);
            }
Exemple #19
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 Trigger ReadData(RAMBuffer buffer)
            {
                Enabled                   = buffer.ReadUInteger();
                Looping                   = buffer.ReadUInteger();
                State                     = buffer.ReadByte();
                ShowAsObjective           = buffer.ReadByte();
                ObjectiveDescriptionIndex = buffer.ReadInteger();
                Unknown                   = buffer.ReadUInteger();

                Description = buffer.ReadString(buffer.ReadInteger());
                Name        = buffer.ReadString(buffer.ReadInteger());

                int effectCount = buffer.ReadInteger();

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

                int conditionCount = buffer.ReadInteger();

                Conditions = new List <Condition>(conditionCount);
                for (int i = 0; i < conditionCount; i++)
                {
                    Conditions.Add(new Condition().ReadData(buffer));
                }
                ConditionDisplayIndices = new List <int>(conditionCount);
                for (int i = 0; i < conditionCount; i++)
                {
                    ConditionDisplayIndices.Add(buffer.ReadInteger());
                }

                return(this);
            }
            public TechTreeAge ReadData(RAMBuffer buffer)
            {
                ID       = buffer.ReadInteger();
                Unknown2 = buffer.ReadByte();

                byte buildingCount = buffer.ReadByte();

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

                byte unitCount = buffer.ReadByte();

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

                byte researchCount = buffer.ReadByte();

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

                Common    = new Common().ReadData(buffer);
                SlotsUsed = buffer.ReadByte();

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

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

                Unknown6 = buffer.ReadByte();
                LineMode = buffer.ReadInteger();

                return(this);
            }
Exemple #21
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);
        }
            public ResearchConnection ReadData(RAMBuffer buffer)
            {
                ID            = buffer.ReadInteger();
                Unknown1      = buffer.ReadByte();
                UpperBuilding = buffer.ReadInteger();

                byte buildingCount = buffer.ReadByte();

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

                byte unitCount = buffer.ReadByte();

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

                byte researchCount = buffer.ReadByte();

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

                Common = new Common().ReadData(buffer);

                VerticalLine  = buffer.ReadInteger();
                LocationInAge = buffer.ReadInteger();
                LineMode      = buffer.ReadInteger();

                return(this);
            }
Exemple #23
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);
            }
Exemple #24
0
        public Building 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().ReadData(buffer));
            }

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

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

            return(this);
        }
Exemple #25
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);
        }
Exemple #26
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);
        }
Exemple #27
0
        /// <summary>
        /// Konstruktor. Lädt die angegebene Datei.
        /// </summary>
        /// <param name="filename">Die zu ladende Datei.</param>
        public ShipFile(string filename)
            : this()
        {
            // Datei laden
            RAMBuffer buffer = new RAMBuffer(filename);

            // Namen lesen
            Name = buffer.ReadString(buffer.ReadInteger());

            // Rumpf-SLP lesen
            if (buffer.ReadByte() == 1)
            {
                BaseSlp = new SLPFile(buffer);
            }

            // Schatten-SLP lesen
            if (buffer.ReadByte() == 1)
            {
                ShadowSlp = new SLPFile(buffer);
            }

            // Segel lesen
            int sailCount = buffer.ReadByte();

            for (int i = 0; i < sailCount; ++i)
            {
                // Lesen
                Sail.SailType currType = (Sail.SailType)buffer.ReadByte();
                Sail          currSail = new Sail(buffer);
                Sails.Add(currType, currSail);
            }

            // Invertierte Segeltypen lesen
            int invSailCount = buffer.ReadByte();

            for (int i = 0; i < invSailCount; ++i)
            {
                InvertedSails.Add((Sail.SailType)buffer.ReadByte());
            }

            // 0 -> 0, 10 -> 0, 20 -> 10, 30 -> 10, 40 -> 20, 50 -> 20, 60 -> 30, 70 -> 30, 80 -> 40

            /*func(Sail.SailType.MainGo, Civ.AS, Properties.Resources.MainGo_AS);
             * func(Sail.SailType.MainGo, Civ.IN, Properties.Resources.MainGo_IN);
             * func(Sail.SailType.MainGo, Civ.ME, Properties.Resources.MainGo_ME);
             * func(Sail.SailType.MainGo, Civ.OR, Properties.Resources.MainGo_OR);
             * func(Sail.SailType.MainGo, Civ.WE, Properties.Resources.MainGo_WE);
             * func(Sail.SailType.MainStop, Civ.AS, Properties.Resources.MainStop_AS);
             * func(Sail.SailType.MainStop, Civ.IN, Properties.Resources.MainStop_IN);
             * func(Sail.SailType.MainStop, Civ.ME, Properties.Resources.MainStop_ME);
             * func(Sail.SailType.MainStop, Civ.OR, Properties.Resources.MainStop_OR);
             * func(Sail.SailType.MainStop, Civ.WE, Properties.Resources.MainStop_WE);
             *
             * Save(Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename) + "_converted.ship"));*/
        }
            public BuildingConnection ReadData(RAMBuffer buffer)
            {
                ID       = buffer.ReadInteger();
                Unknown1 = buffer.ReadByte();

                byte buildingCount = buffer.ReadByte();

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

                byte unitCount = buffer.ReadByte();

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

                byte researchCount = buffer.ReadByte();

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

                Common        = new Common().ReadData(buffer);
                LocationInAge = buffer.ReadByte();

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

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

                LineMode         = buffer.ReadInteger();
                EnablingResearch = buffer.ReadInteger();

                return(this);
            }
Exemple #29
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 Triggers ReadData(RAMBuffer buffer)
        {
            Unknown = buffer.ReadByte();

            int triggerCount = buffer.ReadInteger();

            TriggerData = new List <Trigger>(triggerCount);
            for (int i = 0; i < triggerCount; i++)
            {
                TriggerData.Add(new Trigger().ReadData(buffer));
            }
            TriggerDisplayIndices = new List <int>(triggerCount);
            for (int i = 0; i < triggerCount; i++)
            {
                TriggerDisplayIndices.Add(buffer.ReadInteger());
            }

            return(this);
        }
        /// <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 Header ReadData(RAMBuffer buffer)
        {
            NextUnitIdToPlace = buffer.ReadUInteger();

            float version = buffer.ReadFloat();

            if (version != 1.22f)
            {
                throw new InvalidDataException($"Invalid secondary file version: '{version}'");
            }

            PlayerNames = new List <string>(16);
            for (int i = 0; i < 16; ++i)
            {
                PlayerNames.Add(buffer.ReadString(256));
            }

            PlayerNameDllIds = new List <uint>(16);
            for (int i = 0; i < 16; ++i)
            {
                PlayerNameDllIds.Add(buffer.ReadUInteger());
            }

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

            Unknown1 = buffer.ReadUInteger();
            byte unknown = buffer.ReadByte();             // = 0

            Unknown2 = buffer.ReadFloat();

            short length = buffer.ReadShort();

            OriginalFileName = buffer.ReadString(length);

            return(this);
        }