Пример #1
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            var numScripts = reader.ReadUInt16();

            if (numScripts != Scripts.Length)
            {
                throw new InvalidDataException();
            }

            for (var i = 0; i < numScripts; i++)
            {
                Scripts[i].Load(reader);
            }

            var numScriptGroups = reader.ReadUInt16();

            if (numScriptGroups != ScriptGroups.Length)
            {
                throw new InvalidDataException();
            }

            for (var i = 0; i < numScriptGroups; i++)
            {
                ScriptGroups[i].Load(reader);
            }
        }
Пример #2
0
        internal override void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            var unknownShort1 = reader.ReadUInt16();
            var unknownShort2 = reader.ReadUInt16();
        }
Пример #3
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(3);

            _currentFrame = reader.ReadUInt32();

            _objectDefinitionLookupTable.Load(reader);

            var drawablesCount = reader.ReadUInt16();

            for (var i = 0; i < drawablesCount; i++)
            {
                var objectDefinitionId = reader.ReadUInt16();
                var objectDefinition   = _objectDefinitionLookupTable.GetById(objectDefinitionId);

                reader.BeginSegment();

                var objectID   = reader.ReadUInt32();
                var gameObject = _gameLogic.GetObjectById(objectID);

                gameObject.Drawable.Load(reader);

                reader.EndSegment();
            }

            reader.ReadUInt32();
        }
Пример #4
0
        internal void Load(SaveFileReader reader, PlayerManager players)
        {
            reader.ReadVersion(2);

            // This will be the same as the existing Owner, unless control of this team has been transferred.
            var ownerPlayerId = reader.ReadUInt32();

            Owner = players.GetPlayerByIndex(ownerPlayerId);

            _attackPriorityName = reader.ReadAsciiString();

            var unknown2 = reader.ReadBoolean();

            _templateData.Load(reader);

            var teamCount = reader.ReadUInt16();

            for (var i = 0; i < teamCount; i++)
            {
                var id = reader.ReadUInt32();

                var team = FindTeamById(id);
                if (team == null)
                {
                    team    = TeamFactory.AddTeam(this);
                    team.Id = id;
                }

                team.Load(reader);
            }
        }
Пример #5
0
        internal void Load(SaveFileReader reader)
        {
            State      = reader.ReadEnum <SkirmishSlotState>();
            PlayerName = reader.ReadUnicodeString();

            var unknown1 = reader.ReadUInt16();

            if (unknown1 != 1u)
            {
                throw new InvalidDataException();
            }

            ColorIndex    = (sbyte)reader.ReadInt32();
            StartPosition = (byte)reader.ReadInt32();

            // Bit ugly... this is really an index into player templates,
            // but FactionIndex only counts playable sides... and also is 1-based.
            FactionIndex = (byte)(reader.ReadInt32() - 1);

            Team = (sbyte)reader.ReadInt32();

            var colorChosen               = reader.ReadInt32();
            var startPositionChosen       = reader.ReadInt32();
            var playerTemplateIndexChosen = reader.ReadInt32();
        }
Пример #6
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            var numLocomotorTemplates = reader.ReadUInt16();

            for (var i = 0; i < numLocomotorTemplates; i++)
            {
                var locomotorTemplateName = reader.ReadAsciiString();

                var locomotorTemplate = _gameObject.GameContext.AssetLoadContext.AssetStore.LocomotorTemplates.GetByName(locomotorTemplateName);

                var locomotor = new Locomotor(_gameObject, locomotorTemplate, 100);

                locomotor.Load(reader);

                _locomotors.Add(locomotor);
            }

            _surfaces = reader.ReadEnumFlags <Surfaces>();

            var unknownBool1 = reader.ReadBoolean();

            if (unknownBool1 != false)
            {
                throw new InvalidDataException();
            }
        }
Пример #7
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(2);

            var playerId = reader.ReadUInt32();

            if (playerId != Owner.Id)
            {
                throw new InvalidDataException();
            }

            _attackPriorityName = reader.ReadAsciiString();

            var unknown2 = reader.ReadBoolean();

            _templateData.Load(reader);

            var teamCount = reader.ReadUInt16();

            for (var i = 0; i < teamCount; i++)
            {
                var id = reader.ReadUInt32();

                var team = FindTeamById(id);
                if (team == null)
                {
                    team    = TeamFactory.AddTeam(this);
                    team.Id = id;
                }

                team.Load(reader);
            }
        }
Пример #8
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            Name = reader.ReadAsciiString();

            var numObjects = reader.ReadUInt16();

            for (var j = 0; j < numObjects; j++)
            {
                _objectTypes.Add(reader.ReadAsciiString());
            }
        }
Пример #9
0
        public void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            _nameLookup.Clear();

            var count = reader.ReadUInt32();

            for (var i = 0; i < count; i++)
            {
                var name = reader.ReadAsciiString();
                var id   = reader.ReadUInt16();

                _nameLookup.Add(id, name);
            }
        }
Пример #10
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            Name = reader.ReadAsciiString();

            var unknown = reader.ReadUInt32(); // Probably default value?

            var numTargets = reader.ReadUInt16();

            for (var i = 0; i < numTargets; i++)
            {
                var target = new AttackPriorityTarget();
                target.Load(reader);
                Targets.Add(target);
            }
        }
Пример #11
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            var unknown1 = reader.ReadUInt32();

            var count = reader.ReadUInt16();

            for (var i = 0; i < count; i++)
            {
                var id = reader.ReadUInt32();

                var teamTemplate = _teamTemplatesById[id];

                teamTemplate.Load(reader);
            }
        }
Пример #12
0
        internal void Load(SaveFileReader reader, GameLogic gameLogic, Game game)
        {
            reader.ReadVersion(1);
            reader.ReadVersion(1);

            var unknown1 = reader.ReadUInt32();

            var ghostObjectCount = reader.ReadUInt16();

            for (var i = 0; i < ghostObjectCount; i++)
            {
                var objectId   = reader.ReadObjectID();
                var gameObject = gameLogic.GetObjectById(objectId);

                var ghostObject = new GhostObject(); // TODO
                ghostObject.Load(reader, gameLogic, game);
            }
        }
Пример #13
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            _lastTeamId = reader.ReadUInt32();

            var count = reader.ReadUInt16();

            if (count != _teamTemplatesById.Count)
            {
                throw new InvalidDataException();
            }

            for (var i = 0; i < count; i++)
            {
                var id           = reader.ReadUInt32();
                var teamTemplate = _teamTemplatesById[id];
                teamTemplate.Load(reader);
            }
        }
Пример #14
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(2);

            _playerId = reader.ReadUInt32();

            _attackPriorityName = reader.ReadAsciiString();

            var unknown2 = reader.ReadBoolean();

            _templateData.Load(reader);

            var teamCount = reader.ReadUInt16();

            for (var i = 0; i < teamCount; i++)
            {
                var id = reader.ReadUInt32();

                var team = new Team {
                    ID = id
                };
                team.Load(reader);
            }
        }
Пример #15
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            var id = reader.ReadUInt32();

            if (id != Id)
            {
                throw new InvalidDataException();
            }

            var numObjects = reader.ReadUInt16();

            for (var i = 0; i < numObjects; i++)
            {
                ObjectIds.Add(reader.ReadObjectID());
            }

            for (var i = 0; i < 1; i++)
            {
                var unknownByte = reader.ReadByte();
                if (unknownByte != 0)
                {
                    throw new InvalidDataException();
                }
            }

            _enteredOrExitedPolygonTrigger = reader.ReadBoolean();

            _isAlive = reader.ReadBoolean();

            for (var i = 0; i < 5; i++)
            {
                var unknown1 = reader.ReadBoolean();
                if (unknown1 != false)
                {
                    throw new InvalidDataException();
                }
            }

            _numDestroyedSomething = reader.ReadUInt32();

            var unknown11 = reader.ReadUInt32();

            if (unknown11 != 0 && unknown11 != ObjectIds.Count)
            {
                throw new InvalidDataException();
            }

            var waypointID = reader.ReadUInt32();

            var unknown13 = reader.ReadUInt16();

            if (unknown13 != 16)
            {
                throw new InvalidDataException();
            }

            for (var i = 0; i < unknown13; i++)
            {
                var unknown19 = reader.ReadBoolean();
                if (unknown19 != false)
                {
                    //throw new InvalidDataException();
                }
            }

            var unknown14 = reader.ReadBoolean();

            if (unknown14 != false)
            {
                throw new InvalidDataException();
            }

            var unknown15 = reader.ReadBoolean();

            if (unknown15 != false)
            {
                throw new InvalidDataException();
            }

            TargetObjectID = reader.ReadObjectID();

            TeamToTeamRelationships.Load(reader);
            TeamToPlayerRelationships.Load(reader);
        }
Пример #16
0
        public void Load(SaveFileReader reader)
        {
            reader.ReadVersion(9);

            _currentFrame = reader.ReadUInt32();

            _objectDefinitionLookupTable.Load(reader);

            var gameObjectsCount = reader.ReadUInt32();

            _objects.Clear();
            _objects.Capacity = (int)gameObjectsCount;

            for (var i = 0; i < gameObjectsCount; i++)
            {
                var objectDefinitionId = reader.ReadUInt16();
                var objectDefinition   = _objectDefinitionLookupTable.GetById(objectDefinitionId);

                var gameObject = _scene3D.GameObjects.Add(objectDefinition, _scene3D.LocalPlayer);

                reader.BeginSegment();

                gameObject.Load(reader);

                while (_objects.Count <= gameObject.ID)
                {
                    _objects.Add(null);
                }
                _objects[(int)gameObject.ID] = gameObject;

                reader.EndSegment();
            }

            reader.ReadByte(); // 3

            var sideName    = reader.ReadAsciiString();
            var missionName = reader.ReadAsciiString();

            reader.__Skip(12);

            var someCount4 = reader.ReadUInt32();

            for (var i = 0; i < someCount4; i++)
            {
                var maybeIndex = reader.ReadUInt32();
                reader.ReadBoolean(); // 1
                var someCount5 = reader.ReadUInt32();
                for (var j = 0; j < someCount5; j++)
                {
                    reader.ReadUInt32();
                    reader.ReadUInt32();
                    reader.ReadUInt32();
                }
                reader.ReadUInt32();
                reader.ReadUInt32();
                reader.ReadUInt32();
                reader.ReadUInt32();
                reader.ReadSingle();
                reader.ReadBoolean();
            }

            reader.ReadUInt32();  // 1000
            reader.ReadUInt32();  // 0
            reader.ReadBoolean(); // 0
            reader.ReadBoolean(); // 1
            reader.ReadBoolean(); // 1
            reader.ReadBoolean(); // 1
            reader.ReadUInt32();  // 0xFFFFFFFF



            reader.ReadUInt32();  // 0
            reader.ReadBoolean(); // 0
        }
Пример #17
0
        public void Load(SaveFileReader reader)
        {
            reader.ReadVersion(9);

            _currentFrame = reader.ReadUInt32();

            _objectDefinitionLookupTable.Load(reader);

            var gameObjectsCount = reader.ReadUInt32();

            _objects.Clear();
            _objects.Capacity = (int)gameObjectsCount;

            for (var i = 0; i < gameObjectsCount; i++)
            {
                var objectDefinitionId = reader.ReadUInt16();
                var objectDefinition   = _objectDefinitionLookupTable.GetById(objectDefinitionId);

                var gameObject = _scene3D.GameObjects.Add(objectDefinition, _scene3D.LocalPlayer);

                reader.BeginSegment();

                gameObject.Load(reader);

                while (_objects.Count <= gameObject.ID)
                {
                    _objects.Add(null);
                }
                _objects[(int)gameObject.ID] = gameObject;

                reader.EndSegment();
            }

            reader.ReadByte(); // 3

            var sideName    = reader.ReadAsciiString();
            var missionName = reader.ReadAsciiString();

            reader.__Skip(12);

            var numPolygonTriggers = reader.ReadUInt32();

            if (numPolygonTriggers != _scene3D.MapFile.PolygonTriggers.Triggers.Length)
            {
                throw new InvalidDataException();
            }
            for (var i = 0; i < numPolygonTriggers; i++)
            {
                var id             = reader.ReadUInt32();
                var polygonTrigger = _scene3D.MapFile.PolygonTriggers.GetPolygonTriggerById(id);
                polygonTrigger.Load(reader);
            }

            _rankLevelLimit = reader.ReadUInt32();

            var unknown2 = reader.ReadUInt32();

            if (unknown2 != 0)
            {
                throw new InvalidDataException();
            }

            while (true)
            {
                var objectDefinitionName = reader.ReadAsciiString();
                if (objectDefinitionName == "")
                {
                    break;
                }

                var buildableStatus = reader.ReadEnum <ObjectBuildableType>();

                _techTreeOverrides.Add(
                    objectDefinitionName,
                    buildableStatus);
            }

            if (!reader.ReadBoolean())
            {
                throw new InvalidDataException();
            }

            if (!reader.ReadBoolean())
            {
                throw new InvalidDataException();
            }

            if (!reader.ReadBoolean())
            {
                throw new InvalidDataException();
            }

            var unknown3 = reader.ReadUInt32();

            if (unknown3 != uint.MaxValue)
            {
                throw new InvalidDataException();
            }

            // Command button overrides
            while (true)
            {
                var commandSetNamePrefixedWithCommandButtonIndex = reader.ReadAsciiString();
                if (commandSetNamePrefixedWithCommandButtonIndex == "")
                {
                    break;
                }

                var unknownBool1 = reader.ReadBoolean();
                if (unknownBool1)
                {
                    throw new InvalidDataException();
                }
            }

            var unknown4 = reader.ReadUInt32();

            if (unknown4 != 0)
            {
                throw new InvalidDataException();
            }
        }
Пример #18
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(2);

            var partitionCellSize = reader.ReadSingle();

            if (partitionCellSize != _partitionCellSize)
            {
                throw new InvalidDataException();
            }

            var partitionCellCount = reader.ReadUInt32();

            if (partitionCellCount != _cells.Length)
            {
                throw new InvalidDataException();
            }

            for (var i = 0; i < partitionCellCount; i++)
            {
                _cells[i].Load(reader);
            }

#if DEBUG
            var builder = new System.Text.StringBuilder();
            for (var y = 0; y < _numCellsY; y++)
            {
                for (var x = 0; x < _numCellsX; x++)
                {
                    var cell  = _cells[((_numCellsY - 1 - y) * _numCellsX) + x];
                    var value = cell.Values[2];

                    char c;
                    if (value.State < 0)
                    {
                        c = (char)((-value.State) + '0');
                    }
                    else if (value.State == 0)
                    {
                        c = '-';
                    }
                    else if (value.State == 1)
                    {
                        c = '*';
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }

                    builder.Append(c);
                }
                builder.AppendLine();
            }
            File.WriteAllText($"Partition{Path.GetFileNameWithoutExtension(((FileStream) reader.Inner.BaseStream).Name)}.txt", builder.ToString());
#endif

            var someOtherCount = reader.ReadUInt32();
            for (var i = 0; i < someOtherCount; i++)
            {
                reader.ReadVersion(1);
                var position    = reader.ReadVector3();
                var visionRange = reader.ReadSingle();
                reader.ReadUInt16();
                var frameSomething = reader.ReadUInt32();
            }
        }
Пример #19
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            var id = reader.ReadUInt32();

            if (id != ID)
            {
                throw new InvalidDataException();
            }

            var numObjects = reader.ReadUInt16();

            for (var i = 0; i < numObjects; i++)
            {
                ObjectIds.Add(reader.ReadObjectID());
            }

            for (var i = 0; i < 2; i++)
            {
                var unknown1 = reader.ReadBoolean();
                if (unknown1 != false)
                {
                    throw new InvalidDataException();
                }
            }

            var unknown2 = reader.ReadBoolean();

            if (unknown2 != true)
            {
                //throw new InvalidDataException();
            }

            for (var i = 0; i < 5; i++)
            {
                var unknown1 = reader.ReadBoolean();
                if (unknown1 != false)
                {
                    throw new InvalidDataException();
                }
            }

            var unknown10 = reader.ReadUInt32();

            if (unknown10 != 0)
            {
                throw new InvalidDataException();
            }

            var unknown11 = reader.ReadUInt32();

            if (unknown11 != 0 && unknown11 != ObjectIds.Count)
            {
                throw new InvalidDataException();
            }

            var waypointID = reader.ReadUInt32();

            var unknown13 = reader.ReadUInt16();

            if (unknown13 != 16)
            {
                throw new InvalidDataException();
            }

            for (var i = 0; i < unknown13; i++)
            {
                var unknown19 = reader.ReadBoolean();
                if (unknown19 != false)
                {
                    //throw new InvalidDataException();
                }
            }

            var unknown14 = reader.ReadBoolean();

            if (unknown14 != false)
            {
                throw new InvalidDataException();
            }

            var unknown15 = reader.ReadBoolean();

            if (unknown15 != false)
            {
                throw new InvalidDataException();
            }

            TargetObjectID = reader.ReadObjectID();

            TeamToTeamRelationships.Load(reader.Inner);
            TeamToPlayerRelationships.Load(reader.Inner);
        }
Пример #20
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(5);

            var numSequentialScripts = reader.ReadUInt16();

            for (var i = 0; i < numSequentialScripts; i++)
            {
                var sequentialScript = new SequentialScript();
                sequentialScript.Load(reader);
            }

            var numTimersAndCounters = reader.ReadUInt32();

            var unknown2 = reader.ReadUInt32();

            if (unknown2 != 0)
            {
                throw new InvalidDataException();
            }

            for (var i = 1; i < numTimersAndCounters; i++)
            {
                var value  = reader.ReadInt32();
                var name   = reader.ReadAsciiString();
                var active = reader.ReadBoolean();
            }

            var numTimersAndCounters2 = reader.ReadUInt32();

            if (numTimersAndCounters2 != numTimersAndCounters)
            {
                throw new InvalidDataException();
            }

            var numFlags = reader.ReadUInt32();

            for (var i = 1; i < numFlags; i++)
            {
                var value = reader.ReadBoolean();
                var name  = reader.ReadAsciiString();
            }

            var numFlags2 = reader.ReadUInt32();

            if (numFlags2 != numFlags)
            {
                throw new InvalidDataException();
            }

            var numAttackPrioritySets = reader.ReadUInt16();

            reader.__Skip(8); // TODO

            for (var i = 1; i < numAttackPrioritySets; i++)
            {
                var attackPriority = new AttackPriority();
                attackPriority.Load(reader);
            }

            var numAttackPrioritySets2 = reader.ReadUInt32();

            if (numAttackPrioritySets2 != numAttackPrioritySets)
            {
                throw new InvalidDataException();
            }

            var unknown7 = reader.ReadInt32();

            if (unknown7 != -1)
            {
                throw new InvalidDataException();
            }

            var unknown8 = reader.ReadInt32();

            if (unknown8 != -1)
            {
                throw new InvalidDataException();
            }

            var unknownCount = reader.ReadUInt16();

            for (var i = 0; i < unknownCount; i++)
            {
                var objectName = reader.ReadAsciiString();
                var someId     = reader.ReadUInt32();
            }

            var unknown9 = reader.ReadByte();

            if (unknown9 != 0)
            {
                throw new InvalidDataException();
            }

            CameraFadeOverlay.Load(reader);

            reader.__Skip(12);

            var numSpecialPowerSets = reader.ReadUInt16(); // Maybe not sides, maybe player count?

            for (var i = 0; i < numSpecialPowerSets; i++)
            {
                var version = reader.ReadByte();

                var numSpecialPowers = reader.ReadUInt16();
                for (var j = 0; j < numSpecialPowers; j++)
                {
                    var name      = reader.ReadAsciiString();
                    var timestamp = reader.ReadUInt32();
                }
            }

            var numUnknown1Sets = reader.ReadUInt16();

            for (var i = 0; i < numUnknown1Sets; i++)
            {
                var version = reader.ReadByte();

                var count = reader.ReadUInt16();
                if (count != 0)
                {
                    throw new InvalidDataException();
                }
            }

            var numUnknown2Sets = reader.ReadUInt16();

            for (var i = 0; i < numUnknown2Sets; i++)
            {
                var version = reader.ReadByte();

                var count = reader.ReadUInt16();
                if (count != 0)
                {
                    throw new InvalidDataException();
                }
            }

            var numUpgradeSets = reader.ReadUInt16();

            for (var i = 0; i < numUpgradeSets; i++)
            {
                var version = reader.ReadByte();

                var numUpgrades = reader.ReadUInt16();
                for (var j = 0; j < numUpgrades; j++)
                {
                    var name      = reader.ReadAsciiString();
                    var timestamp = reader.ReadUInt32();
                }
            }

            var numScienceSets = reader.ReadUInt16();

            for (var i = 0; i < numScienceSets; i++)
            {
                var version = reader.ReadByte();

                var numSciences = reader.ReadUInt16();
                for (var j = 0; j < numSciences; j++)
                {
                    var name = reader.ReadAsciiString();
                }
            }

            var unknown14_1 = reader.ReadByte();

            if (unknown14_1 != 1)
            {
                throw new InvalidDataException();
            }

            var unknown14_2 = reader.ReadUInt16();

            if (unknown14_2 != 0)
            {
                throw new InvalidDataException();
            }

            for (var i = 0; i < 6; i++)
            {
                var unknown15 = reader.ReadSingle();
            }

            var unknown16 = reader.ReadUInt32();

            if (unknown16 != 150)
            {
                throw new InvalidDataException();
            }

            var unknown17 = reader.ReadUInt32();

            if (unknown17 != 0 && unknown17 != 1 && unknown17 != 2)
            {
                throw new InvalidDataException();
            }

            var unknown18 = reader.ReadByte();

            if (unknown18 != 0)
            {
                throw new InvalidDataException();
            }

            var numMapReveals = reader.ReadUInt16();

            for (var i = 0; i < numMapReveals; i++)
            {
                var revealName = reader.ReadAsciiString();
                var waypoint   = reader.ReadAsciiString();
                var radius     = reader.ReadSingle();
                var player     = reader.ReadAsciiString();
            }

            var numObjectTypeLists = reader.ReadUInt16();

            for (var i = 0; i < numObjectTypeLists; i++)
            {
                var objectTypeList = new ObjectTypeList();
                objectTypeList.Load(reader);
            }

            var unknown20 = reader.ReadByte();

            if (unknown20 != 1)
            {
                throw new InvalidDataException();
            }

            var musicTrack = reader.ReadAsciiString();

            var unknown21 = reader.ReadByte();

            if (unknown21 != 0)
            {
                throw new InvalidDataException();
            }
        }