コード例 #1
0
        public void Read(OsiReader reader)
        {
            Name = reader.ReadString();
            if (Name.Length > 0)
            {
                var hasParams = reader.ReadByte();
                if (hasParams > 0)
                {
                    Parameters = new List <TypedValue>();
                    var numParams = reader.ReadByte();
                    while (numParams-- > 0)
                    {
                        TypedValue param;
                        var        type = reader.ReadByte();
                        if (type == 1)
                        {
                            param = new Variable();
                        }
                        else
                        {
                            param = new TypedValue();
                        }
                        param.Read(reader);
                        Parameters.Add(param);
                    }
                }

                Negate = reader.ReadBoolean();
            }

            GoalIdOrDebugHook = reader.ReadInt32();
        }
コード例 #2
0
ファイル: Value.cs プロジェクト: xenogenesi/lslib
        public virtual void Read(OsiReader reader)
        {
            var wtf = reader.ReadByte();

            if (wtf == 49)
            {
                TypeId   = reader.ReadUInt32();
                IntValue = reader.ReadInt32();
            }
            else if (wtf == 48)
            {
                TypeId = reader.ReadUInt32();
                switch ((Type)TypeId)
                {
                case Type.Unknown:
                    break;

                case Type.Integer:
                    IntValue = reader.ReadInt32();
                    break;

                case Type.Float:
                    FloatValue = reader.ReadSingle();
                    break;

                case Type.String:
                    if (reader.ReadByte() > 0)
                    {
                        StringValue = reader.ReadString();
                    }
                    break;

                default:
                    StringValue = reader.ReadString();
                    break;
                }
            }
            else
            {
                throw new InvalidDataException("Unrecognized value type");
            }
        }
コード例 #3
0
        public override void Read(OsiReader reader)
        {
            base.Read(reader);
            Value1Index = reader.ReadSByte();
            Value2Index = reader.ReadSByte();

            Value1 = new Value();
            Value1.Read(reader);

            Value2 = new Value();
            Value2.Read(reader);

            RelOp = (RelOpType)reader.ReadInt32();
        }
コード例 #4
0
ファイル: RelOp.cs プロジェクト: soderstrom-rikard/dos2-lslib
        public override void Read(OsiReader reader)
        {
            base.Read(reader);
            LeftValueIndex  = reader.ReadSByte();
            RightValueIndex = reader.ReadSByte();

            LeftValue = new Value();
            LeftValue.Read(reader);

            RightValue = new Value();
            RightValue.Read(reader);

            RelOp = (RelOpType)reader.ReadInt32();
        }
コード例 #5
0
        public virtual void Read(OsiReader reader)
        {
            // possibly isReference?
            var wtf = reader.ReadByte();

            if (wtf == '1')
            {
                TypeId   = reader.ReadUInt32();
                IntValue = reader.ReadInt32();
            }
            else if (wtf == '0')
            {
                TypeId = reader.ReadUInt32();
                uint writtenTypeId = TypeId;

                uint alias;
                bool dos1alias = false;
                if (reader.TypeAliases.TryGetValue(writtenTypeId, out alias))
                {
                    writtenTypeId = alias;
                    if (reader.Ver < OsiVersion.VerEnhancedTypes)
                    {
                        dos1alias = true;
                    }
                }

                if (reader.Ver < OsiVersion.VerEnhancedTypes)
                {
                    // Convert D:OS 1 type ID to D:OS 2 type ID
                    writtenTypeId = ConvertOS1ToOS2Type(writtenTypeId);
                }

                switch ((Type)writtenTypeId)
                {
                case Type.Unknown:
                    break;

                case Type.Integer:
                    IntValue = reader.ReadInt32();
                    break;

                case Type.Integer64:
                    Int64Value = reader.ReadInt64();
                    break;

                case Type.Float:
                    FloatValue = reader.ReadSingle();
                    break;

                case Type.GuidString:
                case Type.String:
                    // D:OS 1 aliased strings didn't have a flag byte
                    if (dos1alias)
                    {
                        StringValue = reader.ReadString();
                    }
                    else if (reader.ReadByte() > 0)
                    {
                        StringValue = reader.ReadString();
                    }
                    break;

                default:
                    StringValue = reader.ReadString();
                    break;
                }
            }
            else
            {
                throw new InvalidDataException("Unrecognized value type");
            }
        }