コード例 #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 Condition ReadData(RAMBuffer buffer)
            {
                Type = (ConditionTypes)buffer.ReadUInteger();

                ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0x00000010);

                Amount          = buffer.ReadInteger();
                ResourceId      = buffer.ReadInteger();
                UnitInstanceId  = buffer.ReadInteger();
                UnitLocation    = buffer.ReadInteger();
                UnitType        = buffer.ReadInteger();
                Player          = buffer.ReadInteger();
                ResearchId      = buffer.ReadInteger();
                Timer           = buffer.ReadInteger();
                Unknown         = buffer.ReadInteger();
                AreaBottomLeftX = buffer.ReadInteger();
                AreaBottomLeftY = buffer.ReadInteger();
                AreaTopRightX   = buffer.ReadInteger();
                AreaTopRightY   = buffer.ReadInteger();
                UnitClass       = buffer.ReadInteger();
                UnitType2       = buffer.ReadInteger();
                AiSignal        = buffer.ReadInteger();

                return(this);
            }
コード例 #2
0
            /// <summary>
            /// Writes the data element into the given buffer (at its current position).
            /// </summary>
            /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
            public void WriteData(RAMBuffer buffer)
            {
                buffer.WriteUInteger(Enabled);
                buffer.WriteUInteger(Looping);

                buffer.WriteByte(State);
                buffer.WriteByte(ShowAsObjective);
                buffer.WriteInteger(ObjectiveDescriptionIndex);
                buffer.WriteUInteger(Unknown);

                if (Description.Length == 0 || Description.Last() != '\0')
                {
                    Description += '\0';
                }
                buffer.WriteInteger(Description.Length);
                buffer.WriteString(Description);

                if (Name.Length == 0 || Name.Last() != '\0')
                {
                    Name += '\0';
                }
                buffer.WriteInteger(Name.Length);
                buffer.WriteString(Name);

                ScenarioDataElementTools.AssertTrue(Effects.Count == EffectDisplayIndices.Count);
                buffer.WriteInteger(Effects.Count);
                Effects.ForEach(t => t.WriteData(buffer));
                EffectDisplayIndices.ForEach(t => buffer.WriteInteger(t));

                ScenarioDataElementTools.AssertTrue(Conditions.Count == ConditionDisplayIndices.Count);
                buffer.WriteInteger(Conditions.Count);
                Conditions.ForEach(t => t.WriteData(buffer));
                ConditionDisplayIndices.ForEach(t => buffer.WriteInteger(t));
            }
コード例 #3
0
        /// <summary>
        /// Writes the data element into the given buffer (at its current position).
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
        public void WriteData(RAMBuffer buffer)
        {
            ScenarioDataElementTools.AssertListLength(DisabledTechsPerPlayer, 16);
            DisabledTechsPerPlayer.ForEach(p => buffer.WriteInteger(p.Count));
            DisabledTechsPerPlayer.ForEach(p =>
            {
                p.ForEach(e => buffer.WriteUInteger(e));
                buffer.Write(new byte[4 * (30 - p.Count)]);
            });

            ScenarioDataElementTools.AssertListLength(DisabledUnitsPerPlayer, 16);
            DisabledUnitsPerPlayer.ForEach(p => buffer.WriteInteger(p.Count));
            DisabledUnitsPerPlayer.ForEach(p =>
            {
                p.ForEach(e => buffer.WriteUInteger(e));
                buffer.Write(new byte[4 * (30 - p.Count)]);
            });

            ScenarioDataElementTools.AssertListLength(DisabledBuildingsPerPlayer, 16);
            DisabledBuildingsPerPlayer.ForEach(p => buffer.WriteInteger(p.Count));
            DisabledBuildingsPerPlayer.ForEach(p =>
            {
                p.ForEach(e => buffer.WriteUInteger(e));
                buffer.Write(new byte[4 * (20 - p.Count)]);
            });

            buffer.WriteUInteger(Unused1);
            buffer.WriteUInteger(Unused2);
            buffer.WriteUInteger(FullTechMode);

            ScenarioDataElementTools.AssertListLength(StartingAges, 16);
            StartingAges.ForEach(a => buffer.WriteInteger(a));
        }
コード例 #4
0
            /// <summary>
            /// Writes the data element into the given buffer (at its current position).
            /// </summary>
            /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
            public void WriteData(RAMBuffer buffer)
            {
                buffer.WriteUShort((ushort)PlayerName.Length);
                buffer.WriteString(PlayerName);
                buffer.WriteFloat(InitialCameraX);
                buffer.WriteFloat(InitialCameraY);
                buffer.WriteShort(UnknownX);
                buffer.WriteShort(UnknownY);
                buffer.WriteByte(AlliedVictory);

                ScenarioDataElementTools.AssertTrue(Diplomacy1.Count == Diplomacy2.Count);
                buffer.WriteUShort((ushort)Diplomacy1.Count);
                Diplomacy1.ForEach(d => buffer.WriteByte((byte)d));
                Diplomacy2.ForEach(d => buffer.WriteUInteger((uint)d));

                buffer.WriteUInteger(Color);
                buffer.WriteFloat(Unknown1);
                buffer.WriteUShort(Unknown3Count);

                if (Unknown1 == 2)
                {
                    ScenarioDataElementTools.AssertListLength(Unknown2, 8);
                    Unknown2.ForEach(b => buffer.WriteByte(b));
                }

                ScenarioDataElementTools.AssertListLength(Unknown3, Unknown3Count * 44);
                Unknown3.ForEach(b => buffer.WriteByte(b));

                ScenarioDataElementTools.AssertListLength(Unknown4, 7);
                Unknown4.ForEach(b => buffer.WriteByte(b));

                buffer.WriteInteger(Unknown5);
            }
コード例 #5
0
        /// <summary>
        /// Writes the data element into the given buffer (at its current position).
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
        public void WriteData(RAMBuffer buffer)
        {
            buffer.WriteUInteger(UnknownPlayerCount);

            ScenarioDataElementTools.AssertListLength(PlayerDiplomacyVariousEntries, 8);
            PlayerDiplomacyVariousEntries.ForEach(e => e.WriteData(buffer));

            buffer.WriteULong(Unknown);
        }
コード例 #6
0
        /// <summary>
        /// Writes the data element into the given buffer (at its current position).
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
        public void WriteData(RAMBuffer buffer)
        {
            buffer.WriteInteger(UnitSections.Count);

            ScenarioDataElementTools.AssertListLength(PlayerResourcesPopulationLimits, 8);
            PlayerResourcesPopulationLimits.ForEach(e => e.WriteData(buffer));

            UnitSections.ForEach(s => s.WriteData(buffer));
        }
コード例 #7
0
        /// <summary>
        /// Writes the data element into the given buffer (at its current position).
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
        public void WriteData(RAMBuffer buffer)
        {
            buffer.WriteByte(Unknown);

            ScenarioDataElementTools.AssertTrue(TriggerData.Count == TriggerDisplayIndices.Count);
            buffer.WriteInteger(TriggerData.Count);
            TriggerData.ForEach(t => t.WriteData(buffer));
            TriggerDisplayIndices.ForEach(t => buffer.WriteInteger(t));
        }
コード例 #8
0
        /// <summary>
        /// Writes the data element into the given buffer (at its current position).
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
        public void WriteData(RAMBuffer buffer)
        {
            ScenarioDataElementTools.AssertListLength(StancesPerPlayer, 16);
            StancesPerPlayer.ForEach(s => s.WriteData(buffer));

            buffer.Write(new byte[11520]);
            buffer.WriteUInteger(0xFFFFFF9D);

            ScenarioDataElementTools.AssertListLength(AlliedVictoryObsolete, 16);
            AlliedVictoryObsolete.ForEach(av => buffer.WriteUInteger(av));
        }
コード例 #9
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 Effect ReadData(RAMBuffer buffer)
            {
                Type = (EffectTypes)buffer.ReadUInteger();

                ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0x00000017);

                AiGoal     = buffer.ReadInteger();
                Amount     = buffer.ReadInteger();
                ResourceId = buffer.ReadInteger();
                Diplomacy  = buffer.ReadInteger();

                int selectedUnitsCount = buffer.ReadInteger();

                if (selectedUnitsCount < 0)
                {
                    selectedUnitsCount = 0;
                }

                LocationUnitInstanceId = buffer.ReadInteger();
                UnitType         = buffer.ReadInteger();
                PlayerSource     = buffer.ReadInteger();
                PlayerTarget     = buffer.ReadInteger();
                ResearchId       = buffer.ReadInteger();
                StringId         = buffer.ReadInteger();
                SoundId          = buffer.ReadInteger();
                DisplayTime      = buffer.ReadInteger();
                TriggerIndex     = buffer.ReadInteger();
                LocationX        = buffer.ReadInteger();
                LocationY        = buffer.ReadInteger();
                AreaBottomLeftX  = buffer.ReadInteger();
                AreaBottomLeftY  = buffer.ReadInteger();
                AreaTopRightX    = buffer.ReadInteger();
                AreaTopRightY    = buffer.ReadInteger();
                UnitClass        = buffer.ReadInteger();
                UnitType2        = buffer.ReadInteger();
                InstructionPanel = buffer.ReadInteger();

                Text          = buffer.ReadString(buffer.ReadInteger());
                SoundFileName = buffer.ReadString(buffer.ReadInteger());

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

                return(this);
            }
コード例 #10
0
        /// <summary>
        /// Writes the data element into the given buffer (at its current position).
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
        public void WriteData(RAMBuffer buffer)
        {
            buffer.WriteInteger(Files.Count > 0 ? 1 : 0);

            buffer.WriteUInteger(EsOnlyDataIncluded);
            if (EsOnlyDataIncluded > 0)
            {
                ScenarioDataElementTools.AssertListLength(EsOnlyData, 396);
                EsOnlyData.ForEach(b => buffer.WriteByte(b));
            }

            if (Files.Count > 0)
            {
                buffer.WriteInteger(Files.Count);
                Files.ForEach(f => f.WriteData(buffer));
            }
        }
コード例 #11
0
ファイル: Map.cs プロジェクト: JanWichelmann/ScenarioLibrary
        /// <summary>
        /// Writes the data element into the given buffer (at its current position).
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
        public void WriteData(RAMBuffer buffer)
        {
            buffer.WriteUInteger(0xFFFFFF9D);

            buffer.WriteInteger(Player1CameraY);
            buffer.WriteInteger(Player1CameraX);
            buffer.WriteInteger(AiMapCode);
            buffer.WriteUInteger(MapWidth);
            buffer.WriteUInteger(MapHeight);

            ScenarioDataElementTools.AssertListLength(Tiles, (int)MapWidth);
            Tiles.ForEach(i =>
            {
                ScenarioDataElementTools.AssertListLength(i, (int)MapHeight);
                i.ForEach(j => j.WriteData(buffer));
            });
        }
コード例 #12
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 GlobalVictory ReadData(RAMBuffer buffer)
        {
            // Separator
            ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0xFFFFFF9D);

            ConquestRequired            = buffer.ReadUInteger();
            Unused1                     = buffer.ReadUInteger();
            NumberOfRelicsRequired      = buffer.ReadUInteger();
            Unused2                     = buffer.ReadUInteger();
            ExploredPercentRequired     = buffer.ReadUInteger();
            Unused3                     = buffer.ReadUInteger();
            AllCustomConditionsRequired = buffer.ReadUInteger();
            Mode          = (VictoryMode)buffer.ReadUInteger();
            ScoreRequired = buffer.ReadUInteger();
            TimeRequired  = buffer.ReadUInteger();

            return(this);
        }
コード例 #13
0
        /// <summary>
        /// Writes the data element into the given buffer (at its current position).
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
        public void WriteData(RAMBuffer buffer)
        {
            ScenarioDataElementTools.AssertListLength(UnknownStrings, 32);
            UnknownStrings.ForEach(s => { buffer.WriteShort((short)s.Length); buffer.WriteString(s); });

            ScenarioDataElementTools.AssertListLength(AiNames, 16);
            AiNames.ForEach(s => { buffer.WriteShort((short)s.Length); buffer.WriteString(s); });

            ScenarioDataElementTools.AssertListLength(AiFiles, 16);
            AiFiles.ForEach(f => f.WriteData(buffer));

            ScenarioDataElementTools.AssertListLength(AiTypes, 16);
            AiTypes.ForEach(t => buffer.WriteByte(t));

            buffer.WriteUInteger(0xFFFFFF9D);

            ScenarioDataElementTools.AssertListLength(ResourceEntries, 16);
            ResourceEntries.ForEach(e => e.WriteData(buffer));
        }
コード例 #14
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 Diplomacy ReadData(RAMBuffer buffer)
        {
            StancesPerPlayer = new List <StancesToPlayers>(16);
            for (int i = 0; i < 16; ++i)
            {
                StancesPerPlayer.Add(new StancesToPlayers().ReadData(buffer));
            }

            // Separator
            buffer.ReadByteArray(11520);
            ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0xFFFFFF9D);

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

            return(this);
        }
コード例 #15
0
ファイル: Map.cs プロジェクト: JanWichelmann/ScenarioLibrary
        /// <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 Map ReadData(RAMBuffer buffer)
        {
            // Separator
            ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0xFFFFFF9D);

            Player1CameraY = buffer.ReadInteger();
            Player1CameraX = buffer.ReadInteger();
            AiMapCode      = buffer.ReadInteger();
            MapWidth       = buffer.ReadUInteger();
            MapHeight      = buffer.ReadUInteger();

            Tiles = new List <List <MapTileTerrainData> >((int)MapWidth);
            for (int i = 0; i < MapWidth; ++i)
            {
                Tiles.Add(new List <MapTileTerrainData>((int)MapHeight));
                for (int j = 0; j < MapHeight; ++j)
                {
                    Tiles[i].Add(new MapTileTerrainData().ReadData(buffer));
                }
            }
            return(this);
        }
コード例 #16
0
        /// <summary>
        /// Writes the data element into the given buffer (at its current position).
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
        public void WriteData(RAMBuffer buffer)
        {
            buffer.WriteUInteger(NextUnitIdToPlace);

            buffer.WriteFloat(1.22f);

            ScenarioDataElementTools.AssertListLength(PlayerNames, 16);
            PlayerNames.ForEach(p => buffer.WriteString(p, 256));

            ScenarioDataElementTools.AssertListLength(PlayerNameDllIds, 16);
            PlayerNameDllIds.ForEach(p => buffer.WriteUInteger(p));

            ScenarioDataElementTools.AssertListLength(PlayerData, 16);
            PlayerData.ForEach(p => p.WriteData(buffer));

            buffer.WriteUInteger(Unknown1);
            buffer.WriteByte(0);
            buffer.WriteFloat(Unknown2);

            buffer.WriteShort((short)OriginalFileName.Length);
            buffer.WriteString(OriginalFileName);
        }
コード例 #17
0
        // Resources

        #endregion

        #region Functions

        /// <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 PlayerAiResources ReadData(RAMBuffer buffer)
        {
            UnknownStrings = new List <string>(32);
            for (int i = 0; i < 32; ++i)
            {
                UnknownStrings.Add(buffer.ReadString(buffer.ReadShort()));
            }

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

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

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

            // Separator
            ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0xFFFFFF9D);

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

            return(this);
        }
コード例 #18
0
 /// <summary>
 /// Writes the data element into the given buffer (at its current position).
 /// </summary>
 /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
 public void WriteData(RAMBuffer buffer)
 {
     ScenarioDataElementTools.AssertListLength(Stances, 16);
     Stances.ForEach(s => buffer.WriteUInteger(s));
 }