/// <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 IncludedFile ReadData(RAMBuffer buffer) { Title = buffer.ReadString(buffer.ReadInteger()); Content = buffer.ReadString(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 MessagesCinematics ReadData(RAMBuffer buffer) { InstructionsStringDllId = buffer.ReadUInteger(); HintsStringDllId = buffer.ReadUInteger(); VictoryStringDllId = buffer.ReadUInteger(); LossStringDllId = buffer.ReadUInteger(); HistoryStringDllId = buffer.ReadUInteger(); ScoutsStringDllId = buffer.ReadUInteger(); InstructionsString = buffer.ReadString(buffer.ReadShort()); HintsString = buffer.ReadString(buffer.ReadShort()); VictoryString = buffer.ReadString(buffer.ReadShort()); LossString = buffer.ReadString(buffer.ReadShort()); HistoryString = buffer.ReadString(buffer.ReadShort()); ScoutsString = buffer.ReadString(buffer.ReadShort()); PregameCinematicFileName = buffer.ReadString(buffer.ReadShort()); VictoryCinematicFileName = buffer.ReadString(buffer.ReadShort()); LossCinematicFileName = buffer.ReadString(buffer.ReadShort()); BackgroundFileName = buffer.ReadString(buffer.ReadShort()); BitmapIncluded = buffer.ReadUInteger(); buffer.ReadInteger(); // Width buffer.ReadInteger(); // Height buffer.ReadShort(); // Unknown, -1 for Bitmaps, 1 for no bitmaps Bitmap = BitmapIncluded != 0 ? new BitmapLibrary.BitmapLoader(buffer, readFileHeader: false) : null; return(this); }
/// <summary> /// Deserializes the data elements from the internal buffer. /// </summary> /// <remarks></remarks> private void ReadData() { // Read version string version = _buffer.ReadString(4); if (version != "1.21") { throw new InvalidDataException($"Invalid primary file version: '{version}'"); } // Read remaining file header _buffer.ReadUInteger(); // Header length _buffer.ReadInteger(); // Unknown constant = 2 LastSaveTimestamp = _buffer.ReadUInteger(); int instructionsLength = _buffer.ReadInteger(); ScenarioInstructions = _buffer.ReadString(instructionsLength); _buffer.ReadUInteger(); // Unknown constant = 0 PlayerCount = _buffer.ReadUInteger(); // Create memory stream for decompression using (MemoryStream output = new MemoryStream()) using (MemoryStream input = _buffer.ToMemoryStream()) { // Go to begin of uncompressed data input.Seek(_buffer.Position, SeekOrigin.Begin); // Create decompressor stream using (DeflateStream decompressor = new DeflateStream(input, CompressionMode.Decompress)) { // Decompress decompressor.CopyTo(output); decompressor.Close(); } // Save decompressed data into buffer _buffer = new RAMBuffer(output.ToArray()); } // Read parts Header = new DataElements.Header().ReadData(_buffer); MessagesCinematics = new DataElements.MessagesCinematics().ReadData(_buffer); PlayerAiResources = new DataElements.PlayerAiResources().ReadData(_buffer); GlobalVictory = new DataElements.GlobalVictory().ReadData(_buffer); Diplomacy = new DataElements.Diplomacy().ReadData(_buffer); Disables = new DataElements.Disables().ReadData(_buffer); Map = new DataElements.Map().ReadData(_buffer); Units = new DataElements.Units().ReadData(_buffer); PlayerDiplomacyVarious = new DataElements.PlayerDiplomacyVarious().ReadData(_buffer); Triggers = new DataElements.Triggers().ReadData(_buffer); IncludedFiles = new DataElements.IncludedFiles().ReadData(_buffer); // Clear buffer to save memory _buffer.Clear(); }
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); }
/// <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); }
public TerrainBorder ReadData(RAMBuffer buffer) { Enabled = buffer.ReadByte(); Random = buffer.ReadByte(); Name = buffer.ReadString(13); Name2 = buffer.ReadString(13); SLP = buffer.ReadInteger(); ShapePtr = buffer.ReadInteger(); SoundID = buffer.ReadInteger(); Colors = new List <byte>(3); for (int i = 0; i < 3; ++i) { Colors.Add(buffer.ReadByte()); } IsAnimated = buffer.ReadByte(); AnimationFrames = buffer.ReadShort(); PauseFames = buffer.ReadShort(); Interval = buffer.ReadFloat(); PauseBetweenLoops = buffer.ReadFloat(); Frame = buffer.ReadShort(); DrawFrame = buffer.ReadShort(); AnimateLast = buffer.ReadFloat(); FrameChanged = buffer.ReadByte(); Drawn = buffer.ReadByte(); Borders = new List <List <FrameData> >(19); for (int i = 0; i < 19; ++i) { List <FrameData> frameData = new List <FrameData>(12); for (int j = 0; j < 12; ++j) { frameData.Add(new FrameData().ReadData(buffer)); } Borders.Add(frameData); } DrawTerrain = buffer.ReadShort(); UnderlayTerrain = buffer.ReadShort(); BorderStyle = buffer.ReadShort(); 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 AiFile ReadData(RAMBuffer buffer) { Unknown1 = buffer.ReadUInteger(); Unknown2 = buffer.ReadUInteger(); AiPerFileContent = buffer.ReadString(buffer.ReadInteger()); return(this); }
public SoundItem ReadData(RAMBuffer buffer) { FileName = buffer.ReadString(13); ResourceID = buffer.ReadInteger(); Probability = buffer.ReadShort(); Civ = buffer.ReadShort(); Unknown1 = buffer.ReadShort(); return(this); }
/// <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 NodeType ReadData(RAMBuffer buffer, byte version) { Name = buffer.ReadString(buffer.ReadInteger()); FrameIndex = buffer.ReadInteger(); if (version >= 1) { LegendLabelDllId = 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 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); }
/// <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); }
/// <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); }
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); }
// 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); }
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 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); }
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); }
public TechTreeDesign ReadData(RAMBuffer buffer) { // Puffer-Position merken, um alte Dateien ohne Versionsmarker lesen zu können int bufferPos = buffer.Position; // Versionsbyte lesen byte version = buffer.ReadByte(); if (version > NEW_TECH_TREE_DESIGN_VERSION) { throw new Exception("This file was created with a newer version of this program. Please consider updating."); } // SLP-Daten NodeSlpFileName = buffer.ReadString(buffer.ReadInteger()); NodeSlpId = buffer.ReadInteger(); ScrollSlpFileName = buffer.ReadString(buffer.ReadInteger()); ScrollSlpId = buffer.ReadInteger(); TileSlpFileName = buffer.ReadString(buffer.ReadInteger()); TileSlpId = buffer.ReadInteger(); LegendAgesSlpFileName = buffer.ReadString(buffer.ReadInteger()); LegendAgesSlpId = buffer.ReadInteger(); LegendDisableSlpFileName = buffer.ReadString(buffer.ReadInteger()); LegendDisableSlpId = buffer.ReadInteger(); // Scroll-Daten MouseScrollArea = buffer.ReadInteger(); MouseScrollDelay = buffer.ReadInteger(); MouseScrollOffset = buffer.ReadInteger(); KeyScrollOffset = buffer.ReadInteger(); // Button-Rechtecke CloseButtonRelativeRectangle = new Rectangle(buffer.ReadInteger(), buffer.ReadInteger(), buffer.ReadInteger(), buffer.ReadInteger()); ScrollLeftButtonRelativeRectangle = new Rectangle(buffer.ReadInteger(), buffer.ReadInteger(), buffer.ReadInteger(), buffer.ReadInteger()); ScrollRightButtonRelativeRectangle = new Rectangle(buffer.ReadInteger(), buffer.ReadInteger(), buffer.ReadInteger(), buffer.ReadInteger()); // Auflösungsdaten int count = buffer.ReadInteger(); ResolutionData = new Dictionary <int, ResolutionConfiguration>(); for (int i = 0; i < count; ++i) { ResolutionData.Add(buffer.ReadInteger(), new ResolutionConfiguration().ReadData(buffer, version)); } // Popup-Label-Daten PopupLabelDelay = buffer.ReadInteger(); PopupLabelWidth = buffer.ReadInteger(); PopupInnerPadding = buffer.ReadInteger(); PopupBoxBevelColorIndices = new List <byte>(6); for (int i = 0; i < 6; ++i) { PopupBoxBevelColorIndices.Add(buffer.ReadByte()); } // Node-Daten NodeFontIndex = buffer.ReadByte(); NodeTypes = new List <NodeType>(); int nodeTypesCount = buffer.ReadInteger(); for (int i = 0; i < nodeTypesCount; i++) { NodeTypes.Add(new NodeType().ReadData(buffer, version)); } // Age-Labels if (version >= 2) { FirstLineBaseDllId = buffer.ReadInteger(); SecondLineDllId = buffer.ReadInteger(); IncrementSecondLineDllId = buffer.ReadByte() > 0; } else { FirstLineBaseDllId = 20110; SecondLineDllId = 20114; IncrementSecondLineDllId = false; } // Erfolg, beenden return(this); }
/// <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(); }
public Terrain ReadData(RAMBuffer buffer) { Enabled = buffer.ReadByte(); Random = buffer.ReadByte(); Name = buffer.ReadString(13); Name2 = buffer.ReadString(13); SLP = buffer.ReadInteger(); ShapePtr = buffer.ReadInteger(); SoundID = buffer.ReadInteger(); BlendPriority = buffer.ReadInteger(); BlendType = buffer.ReadInteger(); Colors = new List <byte>(3); for (int i = 0; i < 3; ++i) { Colors.Add(buffer.ReadByte()); } CliffColors = new Tuple <byte, byte>(buffer.ReadByte(), buffer.ReadByte()); PassableTerrain = buffer.ReadByte(); ImpassableTerrain = buffer.ReadByte(); IsAnimated = buffer.ReadByte(); AnimationFrames = buffer.ReadShort(); PauseFames = buffer.ReadShort(); Interval = buffer.ReadFloat(); PauseBetweenLoops = buffer.ReadFloat(); Frame = buffer.ReadShort(); DrawFrame = buffer.ReadShort(); AnimateLast = buffer.ReadFloat(); FrameChanged = buffer.ReadByte(); Drawn = buffer.ReadByte(); ElevationGraphics = new List <FrameData>(19); for (int i = 0; i < 19; ++i) { ElevationGraphics.Add(new FrameData().ReadData(buffer)); } TerrainToDraw = buffer.ReadShort(); TerrainDimensions = new Tuple <short, short>(buffer.ReadShort(), buffer.ReadShort()); Borders = new List <short>(TERRAIN_COUNT); for (int i = 0; i < TERRAIN_COUNT; ++i) { Borders.Add(buffer.ReadShort()); } TerrainUnitID = new List <short>(30); for (int i = 0; i < 30; ++i) { TerrainUnitID.Add(buffer.ReadShort()); } TerrainUnitDensity = new List <short>(30); for (int i = 0; i < 30; ++i) { TerrainUnitDensity.Add(buffer.ReadShort()); } TerrainUnitCentering = new List <byte>(30); for (int i = 0; i < 30; ++i) { TerrainUnitCentering.Add(buffer.ReadByte()); } NumberOfTerrainUnitsUsed = buffer.ReadShort(); Phantom = buffer.ReadShort(); return(this); }