Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
 public void Load(SaveFileReader reader)
 {
     reader.ReadVersion(1);
     Type        = reader.ReadEnum <ObjectGeometry>();
     IsSmall     = reader.ReadBoolean();
     Height      = reader.ReadSingle();
     MajorRadius = reader.ReadSingle();
     MinorRadius = reader.ReadSingle();
     var unknown1 = reader.ReadSingle();
     var unknown2 = reader.ReadSingle();
 }
Ejemplo n.º 3
0
        internal void Load(SaveFileReader reader)
        {
            FadeType = reader.ReadEnum <CameraFadeType>();

            From = reader.ReadSingle();
            To   = reader.ReadSingle();

            CurrentValue = reader.ReadSingle();
            CurrentFrame = reader.ReadUInt32();

            FramesIncrease = reader.ReadUInt32();
            FramesHold     = reader.ReadUInt32();
            FramesDecrease = reader.ReadUInt32();
        }
Ejemplo n.º 4
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            // This is the object definition which defined the WeaponSet
            // (either a normal object or DefaultThingTemplate)
            var objectDefinitionName = reader.ReadAsciiString();

            var conditions = reader.ReadBitArray <WeaponSetConditions>();

            _currentWeaponTemplateSet = _gameObject.Definition.WeaponSets[conditions];

            // In Generals there are 3 possible weapons.
            // Later games have up to 5.
            for (var i = 0; i < 3; i++)
            {
                var slotFilled = reader.ReadBoolean();
                if (slotFilled)
                {
                    _weapons[i] = new Weapon(_gameObject, _currentWeaponTemplateSet.Slots[i].Weapon.Value, (WeaponSlot)i, _gameObject.GameContext);
                    _weapons[i].Load(reader);
                }
                else
                {
                    _weapons[i] = null;
                }
            }

            _currentWeaponSlot = reader.ReadEnum <WeaponSlot>();

            var unknown2 = reader.ReadUInt32();

            _filledWeaponSlots = reader.ReadUInt32();
            _combinedAntiMask  = reader.ReadEnumFlags <WeaponAntiFlags>();

            var unknown5 = reader.ReadUInt32();

            var unknownBool1 = reader.ReadBoolean();
            var unknownBool2 = reader.ReadBoolean();
        }
Ejemplo n.º 5
0
        internal void Load(SaveFileReader reader, GameLogic gameLogic, Game game)
        {
            reader.ReadVersion(1);
            reader.ReadVersion(1);

            var objectId = reader.ReadObjectID();

            _gameObject = gameLogic.GetObjectById(objectId);

            _geometryType = reader.ReadEnum <ObjectGeometry>();

            // Sometimes there's a 0xC0, when it should be 0x0.
            _geometryIsSmall = reader.ReadByte() == 1;

            _geometryMajorRadius = reader.ReadSingle();
            _geometryMinorRadius = reader.ReadSingle();

            _angle    = reader.ReadSingle();
            _position = reader.ReadVector3();

            var unknown6 = reader.ReadUInt32();

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

            var unknown7 = reader.ReadUInt32();

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

            var unknown8 = reader.ReadUInt32();

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

            for (var i = 0; i < 16; i++)
            {
                var numModels = reader.ReadByte();

                if (numModels > 0 && i != 2)
                {
                    throw new InvalidDataException();
                }

                var modelInstances = new ModelInstance[numModels];

                for (var j = 0; j < numModels; j++)
                {
                    var modelName = reader.ReadAsciiString();

                    var model         = game.AssetStore.Models.GetByName(modelName);
                    var modelInstance = model.CreateInstance(game.AssetStore.LoadContext);
                    modelInstances[j] = modelInstance;

                    var scale = reader.ReadSingle();
                    if (scale != 1.0f)
                    {
                        throw new InvalidDataException();
                    }

                    var houseColor = reader.ReadColorRgba();
                    // TODO: Use house color.

                    reader.ReadVersion(1);

                    var modelTransform = reader.ReadMatrix4x3Transposed();

                    modelInstance.SetWorldMatrix(modelTransform.ToMatrix4x4());

                    var numMeshes = reader.ReadUInt32();
                    if (numMeshes > 0 && numMeshes != model.SubObjects.Length)
                    {
                        throw new InvalidDataException();
                    }

                    for (var k = 0; k < numMeshes; k++)
                    {
                        var meshName      = reader.ReadAsciiString();
                        var meshBool      = reader.ReadBoolean();
                        var meshTransform = reader.ReadMatrix4x3Transposed();

                        if (meshName != model.SubObjects[k].Name)
                        {
                            throw new InvalidDataException();
                        }

                        // TODO: meshTransform is actually absolute, not relative.
                        modelInstance.RelativeBoneTransforms[k] = meshTransform.ToMatrix4x4();
                    }
                }
            }

            var unknown = reader.ReadBoolean();

            if (unknown)
            {
                reader.ReadByte();
                reader.ReadUInt32();
            }
        }
Ejemplo n.º 6
0
        internal void Load(SaveFileReader reader)
        {
            reader.ReadVersion(1);

            Status = reader.ReadEnum <UpgradeStatus>();
        }
Ejemplo n.º 7
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();
            }
        }