コード例 #1
0
ファイル: VMBreakPoint.cs プロジェクト: RHY3756547/FreeSO
 public void Read(byte[] bytes)
 {
     using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN))
     {
         Data = io.ReadInt16();
         Scope = (VMVariableScope)io.ReadUInt16();
     }
 }
コード例 #2
0
ファイル: VMTestObjectType.cs プロジェクト: Daribon/FreeSO
 public void Read(byte[] bytes)
 {
     using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
         GUID = io.ReadUInt32();
         IdData = io.ReadUInt16();
         IdOwner = (VMVariableScope)io.ReadByte();
     }
 }
コード例 #3
0
 public void Read(byte[] bytes)
 {
     using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
         DestinationData  = io.ReadInt16();
         DestinationScope = (VMVariableScope)io.ReadUInt16();
         RangeData        = io.ReadInt16();
         RangeScope       = (VMVariableScope)io.ReadUInt16();
     }
 }
コード例 #4
0
ファイル: VMMemory.cs プロジェクト: simscolony/FreeSims
        public static int GetBigVariable(VMStackFrame context, VMVariableScope scope, short data) //used by functions which can take 32 bit integers, such as VMExpression.
        {
            switch (scope)
            {
            case VMVariableScope.TempXL:
                return(context.Thread.TempXL[data]);

            default:
                return(GetVariable(context, scope, data));    //return a normal var
            }
        }
コード例 #5
0
 public void Read(byte[] bytes)
 {
     using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
         LhsData  = io.ReadInt16();
         RhsData  = io.ReadInt16();
         IsSigned = io.ReadByte();
         Operator = (VMExpressionOperator)io.ReadByte();
         LhsOwner = (VMVariableScope)io.ReadByte();
         RhsOwner = (VMVariableScope)io.ReadByte();
     }
 }
コード例 #6
0
ファイル: VMMemory.cs プロジェクト: simscolony/FreeSims
        public static bool SetBigVariable(VMStackFrame context, VMVariableScope scope, short data, int value)
        {
            switch (scope)
            {
            case VMVariableScope.TempXL:
                context.Thread.TempXL[data] = value;
                return(true);

            default:
                return(SetVariable(context, scope, data, (short)value));    //truncate value and set the relevant 16 bit var to it.
            }
        }
コード例 #7
0
        public void Read(byte[] bytes)
        {
            using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
                DeltaOwner = (VMVariableScope)io.ReadByte();
                MaxOwner   = (VMVariableScope)io.ReadByte();
                Motive     = (VMMotive)io.ReadByte();
                Flags      = (VMSetMotiveChangeFlags)io.ReadByte();

                DeltaData = io.ReadUInt16();
                MaxData   = io.ReadUInt16();
            }
        }
コード例 #8
0
 public void Read(byte[] bytes)
 {
     using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
         OldAmountOwner = (VMTransferFundsOldOwner)io.ReadByte();
         AmountOwner    = (VMVariableScope)io.ReadByte();
         AmountData     = io.ReadUInt16();
         Flags          = (VMTransferFundsFlags)io.ReadByte();
         io.ReadByte();
         ExpenseType  = (VMTransferFundsExpenseType)io.ReadByte();
         TransferType = (VMTransferFundsType)io.ReadByte();
     }
 }
コード例 #9
0
        public void Read(byte[] bytes)
        {
            using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
                OldAmmountOwner = (VMTransferFundsOldOwner)io.ReadByte();
                AmmountOwner    = (VMVariableScope)io.ReadByte();

                //TODO: Not certain of the boundaries for the next 2 fields
                Flags        = (VMTransferFundsFlags)io.ReadUInt32();
                ExpenseType  = (VMTransferFundsExpenseType)io.ReadByte();
                TransferType = (VMTransferFundsType)io.ReadByte();
            }
        }
コード例 #10
0
        public static string GetConstant(CSTranslationContext context, VMVariableScope scope, short data)
        {
            switch (scope)
            {
            case VMVariableScope.Literal:
                return(data.ToString());

            case VMVariableScope.Tuning:
                return(GetTuningVariable(context, (ushort)data).ToString());
            }
            throw new Exception("Scope " + scope.ToString() + " not supported as Constant.");
        }
コード例 #11
0
ファイル: EditorScope.cs プロジェクト: wishiwashi-hack/FreeSO
        public string GetVarScopeDataName(VMVariableScope scope, short data)
        {
            switch (scope)
            {
            case VMVariableScope.Tuning:
                return(GetTuningVariableLabel((ushort)data) + " (" + (ushort)(data >> 7) + ", "
                       + (ushort)(data & 0x7F) + ": " + GetTuningVariable((ushort)data) + ")");

            case VMVariableScope.MyMotives:
            case VMVariableScope.StackObjectMotives:
                return(Behaviour.Get <STR>(134).GetString(data));

            case VMVariableScope.MyPersonData:
            case VMVariableScope.NeighborPersonData:
            case VMVariableScope.StackObjectPersonData:
                return(Behaviour.Get <STR>(200).GetString(data));

            case VMVariableScope.MyObject:
            case VMVariableScope.StackObject:
                return(Behaviour.Get <STR>(141).GetString(data));

            case VMVariableScope.MyObjectAttributes:
                var callerAttr = CallerObject.Resource.Get <STR>(256);
                if (callerAttr == null)
                {
                    break;
                }
                var attr = callerAttr.GetString(data);
                return((attr == null) ? data.ToString() : attr);

            case VMVariableScope.StackObjectAttributes:
            case VMVariableScope.StackObjectLeadTileAttribute:
                if (StackObject == null)
                {
                    break;
                }
                var stackAttr = StackObject.Resource.Get <STR>(256);
                if (stackAttr == null)
                {
                    break;
                }
                attr = stackAttr.GetString(data);
                return((attr == null) ? data.ToString() : attr);

            case VMVariableScope.Global:
                return(Behaviour.Get <STR>(129).GetString(data));

            default:
                break;
            }
            return(data.ToString());
        }
コード例 #12
0
        public void Read(byte[] bytes)
        {
            using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){

                DeltaOwner = (VMVariableScope)io.ReadByte();
                MaxOwner = (VMVariableScope)io.ReadByte();
                Motive = (VMMotive)io.ReadByte();
                Flags = (VMSetMotiveChangeFlags)io.ReadByte();

                DeltaData = io.ReadUInt16();
                MaxData = io.ReadUInt16();
            }
        }
コード例 #13
0
        public void Read(byte[] bytes)
        {
            using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
                this.GUID = io.ReadUInt32();
                //132 was object of type
                this.Flags       = io.ReadByte();
                this.TargetOwner = (VMVariableScope)io.ReadByte();
                this.Local       = io.ReadByte();
                this.TargetData  = io.ReadByte();

                this.SearchType = (VMSetToNextSearchType)(this.Flags & 0x7F);
            }
        }
コード例 #14
0
ファイル: VMMemory.cs プロジェクト: simscolony/FreeSims
        public static LinkedList <short> GetList(VMStackFrame context, VMVariableScope scope)
        {
            switch (scope)
            {
            case VMVariableScope.MyList:
                return(context.Caller.MyList);

            case VMVariableScope.StackObjectList:
                return(context.StackObject.MyList);

            default:
                throw new VMSimanticsException("Cannot get specified variable scope as a list.", context);
            }
        }
コード例 #15
0
 public static bool ScopeMutable(VMVariableScope scope)
 {
     switch (scope)
     {
     case VMVariableScope.Temps:
     case VMVariableScope.Parameters:
     case VMVariableScope.StackObjectID:
     case VMVariableScope.TempByTemp:
     case VMVariableScope.Local:
     case VMVariableScope.LocalByTemp:
     case VMVariableScope.TempXL:
     case VMVariableScope.StackObjectTemp:
         return(true);
     }
     return(false);
 }
コード例 #16
0
ファイル: VMMemory.cs プロジェクト: fourks/FreeSO
        public static bool SetBigVariable(VMStackFrame context, VMVariableScope scope, short data, int value)
        {
            switch (scope)
            {
            case VMVariableScope.TempXL:
                context.Thread.TempXL[data] = value;
                return(true);

            case VMVariableScope.MoneyOverHead32Bit:
                ((VMAvatar)context.Caller).ShowMoneyHeadline(value);
                return(true);

            default:
                return(SetVariable(context, scope, data, (short)value));    //truncate value and set the relevant 16 bit var to it.
            }
        }
コード例 #17
0
ファイル: EditorScope.cs プロジェクト: wishiwashi-hack/FreeSO
        public string GetVarName(VMVariableScope scope, short data)
        {
            switch (scope)
            {
            case VMVariableScope.StackObjectID:
                return(GetVarScopeName(scope));

            case VMVariableScope.Literal:
                return(data.ToString());

            case VMVariableScope.Parameters:
                if (BHAVNames == null)
                {
                    break;
                }
                if (data < 0 || data >= BHAVNames.ParamNames.Length)
                {
                    break;
                }
                return(BHAVNames.ParamNames[data].Trim(new char[] { (char)0xA3, (char)0x05 }));

            case VMVariableScope.Local:
                if (BHAVNames == null)
                {
                    break;
                }
                if (data < 0 || data >= BHAVNames.LocalNames.Length)
                {
                    break;
                }
                return(BHAVNames.LocalNames[data].Trim(new char[] { (char)0xA3, (char)0x05 }));

            default:
                break;
            }
            var dataName = GetVarScopeDataName(scope, data);

            if (dataName == null)
            {
                dataName = data.ToString();
            }

            return(GetVarScopeName(scope) + " " + dataName);
        }
コード例 #18
0
 public override void Deserialize(BinaryReader reader)
 {
     base.Deserialize(reader);
     Success     = reader.ReadBoolean();
     WriteResult = reader.ReadBoolean();
     Temp0Value  = reader.ReadInt16();
     if (Version > 34)
     {
         ObjectPersistID = reader.ReadUInt32();
         WriteScope      = (VMVariableScope)reader.ReadByte();
         WriteData       = reader.ReadInt16();
     }
     else
     {
         if (WriteResult)
         {
             WriteScope = VMVariableScope.Temps;
             WriteData  = 0;
         }
     }
 }
コード例 #19
0
        public static string SetStatement(CSTranslationContext context, VMVariableScope scope, short data, string op, string value, bool big)
        {
            UpdateUsing(context, scope);
            if (big && !IsBig(scope))
            {
                value = $"(short)({value})";
            }

            if (ScopeMutable(scope))
            {
                //the GetVariable version is mutable, meaning we can use +=, %= etc.
                var exp = GetExpression(context, scope, data, big);
                return($"{exp} {op} {value};");
            }
            else
            {
                if (op != "=")
                {
                    op = op.Substring(0, 1);
                    var exp = GetExpression(context, scope, data, big);
                    value = $"(short)({exp} {op} {value})"; //eg. "x[0] += 1" becomes "x[0] = x[0] + 1";
                }
                switch (scope)
                {
                case VMVariableScope.MyObjectAttributes:     //0
                    return($"context.Caller.SetAttribute({(ushort)data}, {value});");

                case VMVariableScope.StackObjectAttributes:     //1
                    return($"context.StackObject.SetAttribute({(ushort)data}, {value});");

                case VMVariableScope.TargetObjectAttributes:     //2
                    throw new Exception("Target Object is Deprecated!");

                case VMVariableScope.MyObject:     //3
                    return($"context.Caller.SetValue({EnumValueName((VMStackObjectVariable)data)}, {value});");

                case VMVariableScope.StackObject:     //4
                    return($"context.StackObject.SetValue({EnumValueName((VMStackObjectVariable)data)}, {value});");

                case VMVariableScope.TargetObject:     //5
                    throw new Exception("Target Object is Deprecated!");

                case VMVariableScope.Global:     //6
                    return($"context.VM.SetGlobalValue({(ushort)data}, {value});");

                case VMVariableScope.Literal:     //7
                    /** Huh? **/
                    return($"");

                case VMVariableScope.TreeAdRange:     //12
                    return($"");                      //can't set this!

                case VMVariableScope.StackObjectTemp: //13
                    break;

                case VMVariableScope.MyMotives:     //14
                    return($"((VMAvatar)context.Caller).SetMotiveData({EnumValueName((VMMotive)data)}, {value});");

                case VMVariableScope.StackObjectMotives:     //15
                    return($"(context.StackObject as VMAvatar)?.SetMotiveData({EnumValueName((VMMotive)data)}, {value});");

                case VMVariableScope.StackObjectSlot:                         //16
                    return($"/* attempting to assign stack object slot? */"); //can't set this!

                //throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectMotiveByTemp:     //17
                    return($"((VMAvatar)context.StackObject).SetMotiveData((VMMotive)temps[{data}], {value});");

                case VMVariableScope.MyPersonData:     //18
                    return($"((VMAvatar)context.Caller).SetPersonData({EnumValueName((VMPersonDataVariable)data)}, {value});");

                case VMVariableScope.StackObjectPersonData:     //19
                    return($"((VMAvatar)context.StackObject).SetPersonData({EnumValueName((VMPersonDataVariable)data)}, {value});");

                case VMVariableScope.MySlot:     //20
                    throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectDefinition:           //21
                    return($"");                                      //you can't set this!

                case VMVariableScope.StackObjectAttributeByParameter: //22
                    return($"context.StackObject.SetAttribute((ushort)args[{data}], {value});");

                //23: room by temp 0
                //24: neighbor in stack object

                case VMVariableScope.Tuning:                            //26
                    return($"");                                        //you can't set this!

                case VMVariableScope.DynSpriteFlagForTempOfStackObject: //27
                    return($"context.StackObject.SetDynamicSpriteFlag((ushort)temps[{data}], {value} > 0);");

                case VMVariableScope.TreeAdPersonalityVar: //28
                    return($"");                           //you can't set this!

                case VMVariableScope.TreeAdMin:            //29
                    return($"");                           //you can't set this!

                case VMVariableScope.MyPersonDataByTemp:   //30
                    return($"((VMAvatar)context.Caller).SetPersonData((VMPersonDataVariable)temps[{data}], {value});");

                case VMVariableScope.StackObjectPersonDataByTemp:     //31
                    return($"((VMAvatar)context.StackObject).SetPersonData((VMPersonDataVariable)temps[{data}], {value});");

                case VMVariableScope.NeighborPersonData:     //32
                    throw new Exception("Not implemented...");

                case VMVariableScope.JobData:     //33
                    throw new Exception("Not implemented...");

                case VMVariableScope.NeighborhoodData:     //34
                    throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectFunction: //35
                    return($"");                          //you can't set this!

                case VMVariableScope.MyTypeAttr:          //36
                    if (context.TS1)
                    {
                        return($"Content.Content.Get().Neighborhood.SetTATT((context.Caller.MasterDefinition ?? context.Caller.Object.OBJ).TypeAttrGUID, {data}, {value});");
                    }
                    return($"");

                case VMVariableScope.StackObjectTypeAttr:     //37
                    if (context.TS1)
                    {
                        return($"Content.Content.Get().Neighborhood.SetTATT((context.StackObject.MasterDefinition ?? context.StackObject.Object.OBJ).TypeAttrGUID, {data}, {value});");
                    }
                    return($"");

                case VMVariableScope.NeighborsObjectDefinition:  //38
                    return($"");                                 //you can't set this!

                case VMVariableScope.StackObjectAttributeByTemp: //41
                    return($"context.StackObject.SetAttribute((ushort)temps[{data}], {value});");

                case VMVariableScope.CityTime:        //43
                case VMVariableScope.TSOStandardTime: //44
                case VMVariableScope.GameTime:        //45
                    return($"");                      //you can't set this!

                case VMVariableScope.MyList:          //46
                    return($"/** Set My List **/");

                //throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectList:      //47
                    return($"/** Set Stack Obj List **/"); //you can't set this!

                //throw new Exception("Not implemented...");

                case VMVariableScope.MoneyOverHead32Bit:     //48
                    return($"((VMAvatar)context.Caller).ShowMoneyHeadline({value});");

                case VMVariableScope.MyLeadTileAttribute:     //49
                    return($"context.Caller.MultitileGroup.BaseObject.SetAttribute({(ushort)data}, {value});");

                case VMVariableScope.StackObjectLeadTileAttribute:     //50
                    return($"context.StackObject.MultitileGroup.BaseObject.SetAttribute({(ushort)data}, {value});");

                case VMVariableScope.MyLeadTile:     //51
                    return($"context.Caller.MultitileGroup.BaseObject.SetValue({EnumValueName((VMStackObjectVariable)data)}, {value});");

                case VMVariableScope.StackObjectLeadTile:     //52
                    return($"context.StackObject.MultitileGroup.BaseObject.SetValue({EnumValueName((VMStackObjectVariable)data)}, {value});");

                case VMVariableScope.StackObjectMasterDef:     //53
                    return($"");

                case VMVariableScope.FeatureEnableLevel:     //54
                    throw new Exception("Not implemented...");

                case VMVariableScope.MyAvatarID: //59
                    return($"");                 //you can't set this!
                }
            }
            return($"VMMemory.SetVariable(context, {EnumValueName(scope)}, {data}, {value});");
        }
コード例 #20
0
        /// <summary>
        /// Get a variable
        /// </summary>
        /// <param name="context"></param>
        /// <param name="scope"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static short GetVariable(VMStackFrame context, VMVariableScope scope, ushort data)
        {
            switch (scope){
                case VMVariableScope.MyObjectAttributes: //0
                    return context.Caller.GetAttribute(data);

                case VMVariableScope.StackObjectAttributes: //1
                    return context.StackObject.GetAttribute(data);

                case VMVariableScope.TargetObjectAttributes: //2
                    throw new Exception("Target Object is Deprecated!");

                case VMVariableScope.MyObject: //3
                    return context.Caller.GetValue((VMStackObjectVariable)data);

                case VMVariableScope.StackObject: //4
                    return context.StackObject.GetValue((VMStackObjectVariable)data);

                case VMVariableScope.TargetObject: //5
                    throw new Exception("Target Object is Deprecated!");

                case VMVariableScope.Global: //6
                    return context.VM.GetGlobalValue((ushort)data);

                case VMVariableScope.Literal: //7
                    return (short)data;

                case VMVariableScope.Temps: //8
                    return context.Thread.TempRegisters[data];

                case VMVariableScope.Parameters: //9
                    return (short)context.Args[data];

                case VMVariableScope.StackObjectID: //10
                    if (context.StackObject != null)
                    {
                        return context.StackObject.ObjectID;
                    }
                    return -1;

                case VMVariableScope.TempByTemp: //11
                    return context.Thread.TempRegisters[context.Thread.TempRegisters[data]];

                case VMVariableScope.TreeAdRange: //12
                    throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectTemp: //13
                    throw new Exception("Not implemented..."); //accesses the stack object's thread and gets its temp...

                case VMVariableScope.MyMotives: //14
                    return ((VMAvatar)context.Caller).GetMotiveData((VMMotive)data);

                case VMVariableScope.StackObjectMotives: //15
                    return ((VMAvatar)context.StackObject).GetMotiveData((VMMotive)data);

                case VMVariableScope.StackObjectSlot: //16
                    return 0;
                    //throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectMotiveByTemp: //17
                    return ((VMAvatar)context.StackObject).GetMotiveData((VMMotive)context.Thread.TempRegisters[data]);

                case VMVariableScope.MyPersonData: //18
                    return ((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)data);

                case VMVariableScope.StackObjectPersonData: //19
                    return ((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)data);

                case VMVariableScope.MySlot: //20
                    throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectDefinition: //21
                    return GetEntityDefinitionVar(context.StackObject.Object, (VMStackObjectDefinitionVariable)data);

                case VMVariableScope.StackObjectAttributeByParameter: //22
                    return context.StackObject.GetAttribute((ushort)context.Args[data]);

                case VMVariableScope.RoomByTemp0: //23
                    throw new Exception("Not implemented...");

                case VMVariableScope.NeighborInStackObject: //24
                    throw new Exception("Not implemented...");

                case VMVariableScope.Local: //25
                    return (short)context.Locals[data];

                case VMVariableScope.Tuning: //26
                    return GetTuningVariable(context.Callee, data, context);

                case VMVariableScope.DynSpriteFlagForTempOfStackObject: //27
                    return context.StackObject.IsDynamicSpriteFlagSet(data) ? (short)1 : (short)0;

                case VMVariableScope.TreeAdPersonalityVar: //28
                    throw new Exception("Not implemented...");

                case VMVariableScope.TreeAdMin: //29
                    throw new Exception("Not implemented...");

                case VMVariableScope.MyPersonDataByTemp: //30
                    return ((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)(context.Thread.TempRegisters[data]));

                case VMVariableScope.StackObjectPersonDataByTemp: //31
                    return ((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)(context.Thread.TempRegisters[data]));

                case VMVariableScope.NeighborPersonData: //32
                    throw new Exception("Not implemented...");

                case VMVariableScope.JobData: //33 jobdata(temp0, temp1), used a few times to test if a person is at work but that isn't relevant for tso...
                    throw new Exception("Should not be used, but if this shows implement an empty shell to return ideal values.");

                case VMVariableScope.NeighborhoodData: //34
                    throw new Exception("Should not be used, but if this shows implement an empty shell to return ideal values.");

                case VMVariableScope.StackObjectFunction: //35
                    throw new Exception("Not implemented...");

                case VMVariableScope.MyTypeAttr: //36
                    throw new Exception("Unused");

                case VMVariableScope.StackObjectTypeAttr: //37
                    throw new Exception("Unused");

                case VMVariableScope.ThirtyEight: //38
                    throw new Exception("Really");

                case VMVariableScope.LocalByTemp: //40
                    return (short)context.Locals[context.Thread.TempRegisters[data]];

                case VMVariableScope.StackObjectAttributeByTemp: //41
                    return context.StackObject.GetAttribute((ushort)context.Thread.TempRegisters[data]);

                case VMVariableScope.TempXL: //42
                    //this needs a really intricate special case for specific operations.
                    throw new Exception("Not implemented...");

                case VMVariableScope.CityTime: //43
                    //return GetCityTime(data)
                    throw new Exception("Not implemented...");

                case VMVariableScope.TSOStandardTime: //44
                    //return GetTSOStandardTime(data)
                    throw new Exception("Not implemented...");

                case VMVariableScope.GameTime: //45
                    //return GameTime(data)
                    throw new Exception("Not implemented...");

                case VMVariableScope.MyList: //46 (man if only i knew what this meant)
                    throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectList: //47
                    throw new Exception("Not implemented...");

                case VMVariableScope.MoneyOverHead32Bit: //48
                    //we're poor... will need special case for this in expression like TempXL
                    return 0;

                case VMVariableScope.MyLeadTileAttribute: //49
                    throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectLeadTileAttribute: //50
                    throw new Exception("Not implemented...");

                case VMVariableScope.MyLeadTile: //51
                    throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectLeadTile: //52
                    throw new Exception("Not implemented...");

                case VMVariableScope.StackObjectMasterDef: //53
                    //gets definition of the master tile of a multi tile object in the stack object.
                    throw new Exception("Not implemented...");

                case VMVariableScope.FeatureEnableLevel: //54
                    return 1;
                    //all of them are enabled, dont really care right now

                case VMVariableScope.MyAvatarID: //59
                    return 0;

            }
            throw new Exception("Unknown get variable");
        }
コード例 #21
0
        public void Read(byte[] bytes)
        {
            using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){

                this.GUID = io.ReadUInt32();
                //132 was object of type
                this.Flags = io.ReadByte();
                this.TargetOwner = (VMVariableScope)io.ReadByte();
                this.Local = io.ReadByte();
                this.TargetData = io.ReadByte();

                this.SearchType = (VMSetToNextSearchType)(this.Flags & 0x7F);

            }
        }
コード例 #22
0
ファイル: VMMemory.cs プロジェクト: kevinmel2000/FreeSO
        /// <summary>
        /// Get a variable
        /// </summary>
        /// <param name="context"></param>
        /// <param name="scope"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static short GetVariable(VMStackFrame context, VMVariableScope scope, short data)
        {
            switch (scope)
            {
            case VMVariableScope.MyObjectAttributes:     //0
                return(context.Caller.GetAttribute((ushort)data));

            case VMVariableScope.StackObjectAttributes:     //1
                return(context.StackObject.GetAttribute((ushort)data));

            case VMVariableScope.TargetObjectAttributes:     //2
                throw new VMSimanticsException("Target Object is Deprecated!", context);

            case VMVariableScope.MyObject:     //3
                return(context.Caller.GetValue((VMStackObjectVariable)data));

            case VMVariableScope.StackObject:     //4
                return(context.StackObject.GetValue((VMStackObjectVariable)data));

            case VMVariableScope.TargetObject:     //5
                throw new VMSimanticsException("Target Object is Deprecated!", context);

            case VMVariableScope.Global:     //6
                return(context.VM.GetGlobalValue((ushort)data));

            case VMVariableScope.Literal:     //7
                return(data);

            case VMVariableScope.Temps:     //8
                return(context.Thread.TempRegisters[data]);

            case VMVariableScope.Parameters:     //9
                return(context.Args[data]);

            case VMVariableScope.StackObjectID:     //10
                return(context.StackObjectID);

            case VMVariableScope.TempByTemp:     //11
                return(context.Thread.TempRegisters[context.Thread.TempRegisters[data]]);

            case VMVariableScope.TreeAdRange:     //12
                return(0);

            //throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectTemp:                              //13
                throw new VMSimanticsException("Not implemented...", context); //accesses the stack object's thread and gets its temp...

            case VMVariableScope.MyMotives:                                    //14
                return(((VMAvatar)context.Caller).GetMotiveData((VMMotive)data));

            case VMVariableScope.StackObjectMotives:     //15
                return((context.StackObject as VMAvatar)?.GetMotiveData((VMMotive)data) ?? 0);

            case VMVariableScope.StackObjectSlot:     //16
                var slotObj = context.StackObject.GetSlot(data);
                return((slotObj == null)?(short)0:slotObj.ObjectID);

            case VMVariableScope.StackObjectMotiveByTemp:     //17
                return(((VMAvatar)context.StackObject).GetMotiveData((VMMotive)context.Thread.TempRegisters[data]));

            case VMVariableScope.MyPersonData:     //18
                return(((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)data));

            case VMVariableScope.StackObjectPersonData:     //19
                return(((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)data));

            case VMVariableScope.MySlot:     //20
                var slotObj2 = context.Caller.GetSlot(data);
                return((slotObj2 == null) ? (short)0 : slotObj2.ObjectID);

            case VMVariableScope.StackObjectDefinition:     //21
                return(GetEntityDefinitionVar(context.StackObject.Object.OBJ, (VMOBJDVariable)data, context));

            case VMVariableScope.StackObjectAttributeByParameter:     //22
                return(context.StackObject.GetAttribute((ushort)context.Args[data]));

            case VMVariableScope.RoomByTemp0:     //23
                //returns information on the selected room. Right now we don't have a room system, so always return the same values. (everywhere is indoors, not a pool)
                var roomID = Math.Max(0, Math.Min(context.VM.Context.RoomInfo.Length - 1, context.Thread.TempRegisters[0]));
                var room   = context.VM.Context.RoomInfo[roomID];

                if (data == 0)
                {
                    return(100);               //ambient light 0-100
                }
                else if (data == 1)
                {
                    return((short)((room.Room.IsOutside)?1:0));                    //outside
                }
                else if (data == 2)
                {
                    return(0);                    //level
                }
                else if (data == 3)
                {
                    return((short)room.Room.Area);                    //area (???)
                }
                else if (data == 4)
                {
                    return((short)(room.Room.IsPool?1:0));                    //is pool
                }
                else
                {
                    throw new VMSimanticsException("Invalid room data!", context);
                }

            //throw new VMSimanticsException("Not implemented...");

            case VMVariableScope.NeighborInStackObject:     //24
                if (!context.VM.TS1)
                {
                    throw new VMSimanticsException("Only valid in TS1.", context);
                }
                var neighbor = Content.Content.Get().Neighborhood.GetNeighborByID(context.StackObjectID);
                if (neighbor == null)
                {
                    return(0);
                }
                switch (data)
                {
                case 0:         //instance id
                    //find neighbour in the lot
                    return(context.VM.Context.ObjectQueries.Avatars.FirstOrDefault(x => x.Object.GUID == neighbor.GUID)?.ObjectID ?? 0);

                case 1:         //belongs in house
                    return(1);  //uh, okay.

                case 2:         //person age
                    return(neighbor.PersonData?.ElementAt((int)VMPersonDataVariable.PersonsAge) ?? 0);

                case 3:         //relationship raw score
                                //to this person or from? what
                    return(0);

                case 4:         //relationship score
                    return(0);

                case 5:         //friend count
                    return(0);

                case 6:         //house number (unknown)
                    return(0);

                case 7:         //has telephone
                    return(1);

                case 8:         //has baby
                    return(0);

                case 9:         //family friend count
                    return(0);
                }
                throw new VMSimanticsException("Neighbor data out of bounds.", context);

            case VMVariableScope.Local:     //25
                return((short)context.Locals[data]);

            case VMVariableScope.Tuning:     //26
                return(GetTuningVariable(context.Callee, (ushort)data, context));

            case VMVariableScope.DynSpriteFlagForTempOfStackObject:     //27
                return(context.StackObject.IsDynamicSpriteFlagSet((ushort)context.Thread.TempRegisters[data]) ? (short)1 : (short)0);

            case VMVariableScope.TreeAdPersonalityVar:     //28
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.TreeAdMin:     //29
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.MyPersonDataByTemp:     //30
                return(((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)(context.Thread.TempRegisters[data])));

            case VMVariableScope.StackObjectPersonDataByTemp:     //31
                return(((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)(context.Thread.TempRegisters[data])));

            case VMVariableScope.NeighborPersonData:     //32
                if (!context.VM.TS1)
                {
                    throw new VMSimanticsException("Only valid in TS1.", context);
                }
                return(Content.Content.Get().Neighborhood.GetNeighborByID(context.StackObjectID)?.PersonData?.ElementAt(data) ?? 0);

            case VMVariableScope.JobData:     //33 jobdata(temp0, temp1), used a few times to test if a person is at work but that isn't relevant for tso...
                if (!context.VM.TS1)
                {
                    throw new VMSimanticsException("Only valid in TS1.", context);
                }
                return(Content.Content.Get().Jobs.GetJobData((ushort)context.Thread.TempRegisters[0], context.Thread.TempRegisters[1], data));

            case VMVariableScope.NeighborhoodData:     //34
                return(0);

                throw new VMSimanticsException("Should not be used, but if this shows implement an empty shell to return ideal values.", context);

            case VMVariableScope.StackObjectFunction:     //35
                return((short)context.StackObject.EntryPoints[data].ActionFunction);

            case VMVariableScope.MyTypeAttr:     //36
                if (context.VM.TS1)
                {
                    return(Content.Content.Get().Neighborhood.GetTATT((context.Caller.MasterDefinition ?? context.Caller.Object.OBJ).TypeAttrGUID, data));
                }
                return(0);

            case VMVariableScope.StackObjectTypeAttr:     //37
                if (context.VM.TS1)
                {
                    return(Content.Content.Get().Neighborhood.GetTATT((context.StackObject.MasterDefinition ?? context.StackObject.Object.OBJ).TypeAttrGUID, data));
                }
                return(0);

            case VMVariableScope.NeighborsObjectDefinition:     //38
                if (!context.VM.TS1)
                {
                    throw new VMSimanticsException("Only valid in TS1.", context);
                }
                var neighbor2 = Content.Content.Get().Neighborhood.GetNeighborByID(context.StackObjectID);
                if (neighbor2 == null)
                {
                    return(0);
                }
                var objd = Content.Content.Get().WorldObjects.Get(neighbor2.GUID)?.OBJ;
                if (objd == null)
                {
                    return(0);
                }
                return(GetEntityDefinitionVar(objd, (VMOBJDVariable)data, context));

            case VMVariableScope.LocalByTemp:     //40
                return((short)context.Locals[context.Thread.TempRegisters[data]]);

            case VMVariableScope.StackObjectAttributeByTemp:     //41
                return(context.StackObject.GetAttribute((ushort)context.Thread.TempRegisters[data]));

            case VMVariableScope.TempXL:     //42
                //this needs a really intricate special case for specific operations.
                throw new VMSimanticsException("Caller function does not support TempXL!", context);

            case VMVariableScope.CityTime:     //43
                //return GetCityTime(data)
                switch (data)
                {
                case 0:
                    return((short)context.VM.Context.Clock.Seconds);

                case 1:
                    return((short)context.VM.Context.Clock.Minutes);

                case 2:
                    return((short)context.VM.Context.Clock.Hours);

                case 3:
                    return((short)context.VM.Context.Clock.TimeOfDay);
                }
                ;
                break;

            case VMVariableScope.TSOStandardTime:     //44
                //return GetTSOStandardTime(data)
                var time = context.VM.Context.Clock.UTCNow;

                switch (data)
                {
                case 0:
                    return((short)time.Second);

                case 1:
                    return((short)time.Minute);

                case 2:
                    return((short)time.Hour);

                case 3:
                    return((short)time.Day);

                case 4:
                    return((short)time.Month);

                case 5:
                    return((short)time.Year);
                }
                ;
                return(0);

            case VMVariableScope.GameTime:     //45
                switch (data)
                {
                case 0:
                    return((short)context.VM.Context.Clock.Seconds);

                case 1:
                    return((short)context.VM.Context.Clock.Minutes);

                case 2:
                    return((short)context.VM.Context.Clock.Hours);

                case 3:
                    return((short)context.VM.Context.Clock.TimeOfDay);
                }
                ;
                break;

            case VMVariableScope.MyList:     //46 (man if only i knew what this meant)
                switch (data)
                {
                case 0: return(context.Caller.MyList.First.Value);        //is this allowed?

                case 1: return(context.Caller.MyList.Last.Value);

                case 2: return((short)context.Caller.MyList.Count);

                default: throw new VMSimanticsException("Unknown List Accessor", context);
                }

            case VMVariableScope.StackObjectList:     //47
                if (context.StackObject == null)
                {
                    return(0);
                }
                switch (data)
                {
                case 0: return(context.StackObject.MyList.First.Value);

                case 1: return(context.StackObject.MyList.Last.Value);

                case 2: return((short)context.StackObject.MyList.Count);

                default: throw new VMSimanticsException("Unknown List Accessor", context);
                }

            case VMVariableScope.MoneyOverHead32Bit:     //48
                //we're poor... will need special case for this in expression like TempXL
                return(0);

            case VMVariableScope.MyLeadTileAttribute:     //49
                return(context.Caller.MultitileGroup.BaseObject.GetAttribute((ushort)data));

            case VMVariableScope.StackObjectLeadTileAttribute:     //50
                return(context.StackObject.MultitileGroup.BaseObject.GetAttribute((ushort)data));

            case VMVariableScope.MyLeadTile:     //51
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectLeadTile:     //52
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectMasterDef:     //53
                //gets definition of the master tile of a multi tile object in the stack object.
                var masterDef = context.StackObject.MasterDefinition;
                return(GetEntityDefinitionVar((masterDef == null)?context.StackObject.Object.OBJ:masterDef, (VMOBJDVariable)data, context));

            case VMVariableScope.FeatureEnableLevel:     //54
                return(1);

            //all of them are enabled, dont really care right now

            case VMVariableScope.MyAvatarID:     //59
                return(0);
            }
            throw new VMSimanticsException("Unknown get variable", context);
        }
コード例 #23
0
ファイル: VMMemory.cs プロジェクト: Daribon/FreeSO
 //used by functions which can take 32 bit integers, such as VMExpression.
 public static int GetBigVariable(VMStackFrame context, VMVariableScope scope, ushort data)
 {
     switch (scope)
     {
         case VMVariableScope.TempXL:
             return context.Thread.TempXL[data];
         default:
             return GetVariable(context, scope, data); //return a normal var
     }
 }
コード例 #24
0
ファイル: VMMemory.cs プロジェクト: simscolony/FreeSims
        /// <summary>
        /// Get a variable
        /// </summary>
        /// <param name="context"></param>
        /// <param name="scope"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static short GetVariable(VMStackFrame context, VMVariableScope scope, short data)
        {
            switch (scope)
            {
            case VMVariableScope.MyObjectAttributes:     //0
                return(context.Caller.GetAttribute((ushort)data));

            case VMVariableScope.StackObjectAttributes:     //1

                if (context.StackObject != null)
                {
                    return(context.StackObject.GetAttribute((ushort)data));
                }
                else
                {
                    return(0);
                }

            case VMVariableScope.TargetObjectAttributes:     //2
                throw new VMSimanticsException("Target Object is Deprecated!", context);

            case VMVariableScope.MyObject:     //3
                return(context.Caller.GetValue((VMStackObjectVariable)data));

            case VMVariableScope.StackObject:     //4
                if (context.StackObject != null)
                {
                    return(context.StackObject.GetValue((VMStackObjectVariable)data));
                }
                return(0);

            case VMVariableScope.TargetObject:     //5
                throw new VMSimanticsException("Target Object is Deprecated!", context);

            case VMVariableScope.Global:     //6
                return(context.VM.GetGlobalValue((ushort)data));

            case VMVariableScope.Literal:     //7
                return(data);

            case VMVariableScope.Temps:     //8
                return(context.Thread.TempRegisters[data]);

            case VMVariableScope.Parameters:     //9
                return(context.Args[data]);

            case VMVariableScope.StackObjectID:     //10
                if (context.StackObject != null)
                {
                    return(context.StackObject.ObjectID);
                }
                return(0);                   //no object = 0, ids have a base of 1

            case VMVariableScope.TempByTemp: //11
                return(context.Thread.TempRegisters[context.Thread.TempRegisters[data]]);

            case VMVariableScope.TreeAdRange:     //12
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectTemp:                              //13
                throw new VMSimanticsException("Not implemented...", context); //accesses the stack object's thread and gets its temp...

            case VMVariableScope.MyMotives:                                    //14
                if (context.StackObject != null && context.StackObject is VMAvatar)
                {
                    return(((VMAvatar)context.Caller).GetMotiveData((VMMotive)data));
                }
                return(0);

            case VMVariableScope.StackObjectMotives:     //15
                if (context.StackObject != null && context.StackObject is VMAvatar)
                {
                    return(((VMAvatar)context.StackObject).GetMotiveData((VMMotive)data));
                }
                return(0);

            case VMVariableScope.StackObjectSlot:     //16
                var slotObj = context.StackObject.GetSlot(data);
                return((slotObj == null)?(short)0:slotObj.ObjectID);

            case VMVariableScope.StackObjectMotiveByTemp:     //17
                if (context.StackObject != null)
                {
                    return(((VMAvatar)context.StackObject).GetMotiveData((VMMotive)context.Thread.TempRegisters[data]));
                }
                return(0);

            case VMVariableScope.MyPersonData:     //18
                return(((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)data));

            case VMVariableScope.StackObjectPersonData:     //19
                if (context.StackObject != null && context.StackObject is VMAvatar)
                {
                    return(((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)data));
                }
                return(0);

            case VMVariableScope.MySlot:     //20
                var slotObj2 = context.Caller.GetSlot(data);
                return((slotObj2 == null) ? (short)0 : slotObj2.ObjectID);

            case VMVariableScope.StackObjectDefinition:     //21
                return(GetEntityDefinitionVar(context.StackObject.Object.OBJ, (VMOBJDVariable)data, context));

            case VMVariableScope.StackObjectAttributeByParameter:     //22
                return(context.StackObject.GetAttribute((ushort)context.Args[data]));

            case VMVariableScope.RoomByTemp0:     //23
                //returns information on the selected room. Right now we don't have a room system, so always return the same values. (everywhere is indoors, not a pool)
                var roomID = Math.Max(0, Math.Min(context.VM.Context.RoomInfo.Length - 1, context.Thread.TempRegisters[0]));
                var room   = context.VM.Context.RoomInfo[roomID];

                if (data == 0)
                {
                    return(100);               //ambient light 0-100
                }
                else if (data == 1)
                {
                    return((short)((room.Room.IsOutside)?1:0));                    //outside
                }
                else if (data == 2)
                {
                    return(0);                    //level
                }
                else if (data == 3)
                {
                    return((short)room.Room.Area);                    //area (???)
                }
                else if (data == 4)
                {
                    return((short)(room.Room.IsPool?1:0));                    //is pool
                }
                else
                {
                    throw new VMSimanticsException("Invalid room data!", context);
                }

            //throw new VMSimanticsException("Not implemented...");

            case VMVariableScope.NeighborInStackObject:     //24

                return(1);

            case VMVariableScope.Local:     //25
                return((short)context.Locals[data]);

            case VMVariableScope.Tuning:     //26
                return(GetTuningVariable(context.Callee, (ushort)data, context));

            case VMVariableScope.DynSpriteFlagForTempOfStackObject:     //27
                return(context.StackObject.IsDynamicSpriteFlagSet((ushort)context.Thread.TempRegisters[data]) ? (short)1 : (short)0);

            case VMVariableScope.TreeAdPersonalityVar:     //28
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.TreeAdMin:     //29
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.MyPersonDataByTemp:     //30
                return(((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)(context.Thread.TempRegisters[data])));

            case VMVariableScope.StackObjectPersonDataByTemp:     //31
                return(((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)(context.Thread.TempRegisters[data])));

            case VMVariableScope.NeighborPersonData:     //32
                //Neighbour neighbour = Content.Content.Get().TS1Neighborhood.GetNeighborByID(context.Caller.ObjectID);

                //return (neighbour != null) ? neighbour.PersonData.ElementAt(data) : (short)0;
                return(1);

            case VMVariableScope.JobData:     //33 jobdata(temp0, temp1), used a few times to test if a person is at work but that isn't relevant for tso...
                throw new VMSimanticsException("Should not be used, but if this shows implement an empty shell to return ideal values.", context);

            case VMVariableScope.NeighborhoodData:     //34
                throw new VMSimanticsException("Should not be used, but if this shows implement an empty shell to return ideal values.", context);

            case VMVariableScope.StackObjectFunction:     //35
                return((short)context.StackObject.EntryPoints[data].ActionFunction);

            case VMVariableScope.MyTypeAttr:     //36
                throw new VMSimanticsException("Unused", context);

            case VMVariableScope.StackObjectTypeAttr:     //37
                throw new VMSimanticsException("Unused", context);

            case VMVariableScope.ThirtyEight:     //38
                throw new VMSimanticsException("Really", context);

            case VMVariableScope.LocalByTemp:     //40
                return((short)context.Locals[context.Thread.TempRegisters[data]]);

            case VMVariableScope.StackObjectAttributeByTemp:     //41
                return(context.StackObject.GetAttribute((ushort)context.Thread.TempRegisters[data]));

            case VMVariableScope.TempXL:     //42
                //this needs a really intricate special case for specific operations.
                throw new VMSimanticsException("Caller function does not support TempXL!", context);

            case VMVariableScope.CityTime:     //43
                //return GetCityTime(data)
                switch (data)
                {
                case 0:
                    return((short)context.VM.Context.Clock.Seconds);

                case 1:
                    return((short)context.VM.Context.Clock.Minutes);

                case 2:
                    return((short)context.VM.Context.Clock.Hours);

                case 3:
                    return((short)context.VM.Context.Clock.TimeOfDay);
                }
                ;
                break;

            case VMVariableScope.TSOStandardTime:     //44
                //return GetTSOStandardTime(data)
                return(0);

                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.GameTime:     //45
                switch (data)
                {
                case 0:
                    return((short)context.VM.Context.Clock.Seconds);

                case 1:
                    return((short)context.VM.Context.Clock.Minutes);

                case 2:
                    return((short)context.VM.Context.Clock.Hours);

                case 3:
                    return((short)context.VM.Context.Clock.TimeOfDay);
                }
                ;
                break;

            case VMVariableScope.MyList:     //46 (man if only i knew what this meant)
                switch (data)
                {
                case 0: return(context.Caller.MyList.First.Value);        //is this allowed?

                case 1: return(context.Caller.MyList.Last.Value);

                case 2: return((short)context.Caller.MyList.Count);

                default: throw new VMSimanticsException("Unknown List Accessor", context);
                }

            case VMVariableScope.StackObjectList:     //47
                if (context.StackObject == null)
                {
                    return(0);
                }
                switch (data)
                {
                case 0: return(context.StackObject.MyList.First.Value);

                case 1: return(context.StackObject.MyList.Last.Value);

                case 2: return((short)context.StackObject.MyList.Count);

                default: throw new VMSimanticsException("Unknown List Accessor", context);
                }

            case VMVariableScope.MoneyOverHead32Bit:     //48
                //we're poor... will need special case for this in expression like TempXL
                return(0);

            case VMVariableScope.MyLeadTileAttribute:     //49
                return(context.Caller.MultitileGroup.BaseObject.GetAttribute((ushort)data));

            case VMVariableScope.StackObjectLeadTileAttribute:     //50
                return(context.StackObject.MultitileGroup.BaseObject.GetAttribute((ushort)data));

            case VMVariableScope.MyLeadTile:     //51
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectLeadTile:     //52
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectMasterDef:     //53
                //gets definition of the master tile of a multi tile object in the stack object.
                var masterDef = context.StackObject.MasterDefinition;
                return(GetEntityDefinitionVar((masterDef == null)?context.StackObject.Object.OBJ:masterDef, (VMOBJDVariable)data, context));

            case VMVariableScope.FeatureEnableLevel:     //54
                return(1);

            //all of them are enabled, dont really care right now

            case VMVariableScope.MyAvatarID:     //59
                return(0);
            }
            throw new VMSimanticsException("Unknown get variable", context);
        }
コード例 #25
0
        /**
         * Provides a string description of a variable, this is a utility for trace messages
         * that show what he VM is doing
         */
        public static string DescribeVariable(VMStackFrame context,VMVariableScope scope,ushort data)
        {
            bool didPrint = false;

            var result = "";

            switch (scope)
            {
            case VMVariableScope.Literal:
                result += "literal " + data;
                break;

            case VMVariableScope.Local:
                result += "local #" + data;
                if (context != null)
                {
                    result += " (current value = " + VMMemory.GetVariable(context,scope,data) + ")";
                }
                break;

            case VMVariableScope.StackObject:
                result += "callee." + ((VMStackObjectVariable)data).ToString();
                if (context != null)
                {
                    result += " (current value = " + VMMemory.GetVariable(context,scope,data) + ")";
                }
                break;

            case VMVariableScope.MyObjectAttributes:
                if (context != null)
                {
                    if (context.Caller.RTTI != null && context.Caller.RTTI.AttributeLabels != null)
                    {
                        string[] attributeLabels = context.Caller.RTTI.AttributeLabels;
                        if (data < attributeLabels.Length)
                        {
                            result  += "caller.attributes." + attributeLabels[data] + "(" + data + ")";
                            didPrint = true;
                        }
                    }
                }
                if (!didPrint)
                {
                    result += "caller.attributes.(" + data + ")";
                }
                if (context != null)
                {
                    result += " (current value = " + VMMemory.GetVariable(context,scope,data) + ")";
                }
                break;

            case VMVariableScope.StackObjectAttributes:
                if (context != null)
                {
                    if (context.StackObject.RTTI != null && context.StackObject.RTTI.AttributeLabels != null)
                    {
                        string[] attributeLabels = context.StackObject.RTTI.AttributeLabels;
                        if (data < attributeLabels.Length)
                        {
                            result  += "StackObject.attributes." + attributeLabels[data] + "(" + data + ")";
                            didPrint = true;
                        }
                    }
                }
                if (!didPrint)
                {
                    result += "StackObject.attributes.(" + data + ")";
                }
                if (context != null)
                {
                    result += " (current value = " + VMMemory.GetVariable(context,scope,data) + ")";
                }
                break;

            case VMVariableScope.Tuning:
                result = "to be actually done";

                /*if (context != null)
                 * {
                 *  var label = GetTuningVariableLabel(context.StackObject.Object, data);
                 *  if (label != null)
                 *  {
                 *      result += "StackObject.tuning." + label + "(" + data + ") (value = " + GetTuningVariable(context.StackObject, data, context) + ")";
                 *      didPrint = true;
                 *  }
                 * }
                 * if (!didPrint){
                 *  result = "StackObject.tuning." + data;
                 * }*/
                break;

            case VMVariableScope.Temps:
                result = "temp." + data;
                if (context != null)
                {
                    result += " (value = " + context.Thread.TempRegisters[data] + ")";
                }
                break;

            case VMVariableScope.Parameters:
                result = "arg." + data;
                if (context != null)
                {
                    result += " (value = " + context.Args[data] + ")";
                }
                break;

            case VMVariableScope.StackObjectDefinition:
                result = "stack.objd." + ((VMStackObjectDefinitionVariable)data);
                if (context != null)
                {
                    result += " (value = " + GetEntityDefinitionVar(context.StackObject.Object,((VMStackObjectDefinitionVariable)data)) + ")";
                }
                break;

            case VMVariableScope.MyPersonData:
                result = "myPersonData." + ((VMPersonDataVariable)data).ToString();
                break;

            case VMVariableScope.DynSpriteFlagForTempOfStackObject:
                result = "stack.dynFlags." + data;
                break;

            default:
                result = "Unknown type: " + scope;
                break;
            }
            return(result);
        }
コード例 #26
0
ファイル: EditorScope.cs プロジェクト: wishiwashi-hack/FreeSO
 public string GetVarScopeName(VMVariableScope scope)
 {
     return(Behaviour.Get <STR>(132).GetString((int)scope));
 }
コード例 #27
0
ファイル: EditorScope.cs プロジェクト: wishiwashi-hack/FreeSO
        public List <ScopeDataDefinition> GetVarScopeDataNames(VMVariableScope scope)
        {
            switch (scope)
            {
            case VMVariableScope.MyMotives:
            case VMVariableScope.StackObjectMotives:
                return(DataListFromSTR(Behaviour.Get <STR>(134), 0, null));

            case VMVariableScope.MyPersonData:
            case VMVariableScope.NeighborPersonData:
            case VMVariableScope.StackObjectPersonData:
                return(DataListFromSTR(Behaviour.Get <STR>(200), 0, null));

            case VMVariableScope.MyObject:
            case VMVariableScope.StackObject:
                return(DataListFromSTR(Behaviour.Get <STR>(141), 0, null));

            case VMVariableScope.MyObjectAttributes:
                var callerAttr = CallerObject.Resource.Get <STR>(256);
                if (callerAttr == null)
                {
                    return(DataListFromStrings(MakeEnumeratedStrings("Attribute ", Object.OBJ.NumAttributes), 0, null));
                }
                return(DataListFromSTR(callerAttr, 0, null));

            case VMVariableScope.StackObjectAttributes:
            case VMVariableScope.StackObjectLeadTileAttribute:
                var stackAttr = StackObject?.Resource.Get <STR>(256);
                if (stackAttr == null)
                {
                    return(DataListFromStrings(MakeEnumeratedStrings("Attribute ", Object.OBJ.NumAttributes), 0, null));
                }
                return(DataListFromSTR(stackAttr, 0, null));

            case VMVariableScope.Global:
                return(DataListFromSTR(Behaviour.Get <STR>(129), 0, null));

            case VMVariableScope.Parameters:
            case VMVariableScope.StackObjectAttributeByParameter:
                if (BHAVNames == null)
                {
                    return(DataListFromStrings(MakeEnumeratedStrings("Parameter ", Math.Max(4, (int)Active.Args)), 0, null));
                }
                return(DataListFromStrings(BHAVNames.ParamNames, 0, null));

            case VMVariableScope.Local:
                if (BHAVNames == null)
                {
                    return(DataListFromStrings(MakeEnumeratedStrings("Local ", Active.Locals), 0, null));
                }
                return(DataListFromStrings(BHAVNames.LocalNames, 0, null));

            case VMVariableScope.Temps:
                return(DataListFromStrings(MakeEnumeratedStrings("Temp ", 20), 0, null));

            case VMVariableScope.TempXL:
                return(DataListFromStrings(MakeEnumeratedStrings("TempXL ", 2), 0, null));

            default:
                break;
            }
            return(null);
        }
コード例 #28
0
        public static string GetExpression(CSTranslationContext context, VMVariableScope scope, short data, bool big)
        {
            UpdateUsing(context, scope);

            switch (scope)
            {
            case VMVariableScope.MyObjectAttributes:     //0
                return(Exp($"context.Caller.GetAttribute({(ushort)data})"));

            case VMVariableScope.StackObjectAttributes:     //1
                return(Exp($"context.StackObject.GetAttribute({(ushort)data})"));

            case VMVariableScope.TargetObjectAttributes:     //2
                throw new Exception("Target Object is Deprecated!");

            case VMVariableScope.MyObject:     //3
                return(Exp($"context.Caller.GetValue({EnumValueName((VMStackObjectVariable)data)})"));

            case VMVariableScope.StackObject:     //4
                return(Exp($"context.StackObject.GetValue({EnumValueName((VMStackObjectVariable)data)})"));

            case VMVariableScope.TargetObject:     //5
                throw new Exception("Target Object is Deprecated!");

            case VMVariableScope.Global:     //6
                return(Exp($"context.VM.GetGlobalValue({(ushort)data})"));

            case VMVariableScope.Literal:     //7
                return(Exp(data.ToString()));

            case VMVariableScope.Temps:     //8
                return(Exp($"temps[{data}]"));

            case VMVariableScope.Parameters:     //9
                return(Exp($"args[{data}]"));

            case VMVariableScope.StackObjectID:     //10
                return(Exp($"context.StackObjectID"));

            case VMVariableScope.TempByTemp:     //11
                return(Exp($"temps[temps[{data}]]"));

            case VMVariableScope.TreeAdRange:     //12
                return(Exp($"0"));

            //throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectTemp:     //13
                return(Exp($"context.StackObject.Thread.TempRegisters[{data}]"));

            case VMVariableScope.MyMotives:     //14
                return(Exp($"((VMAvatar)context.Caller).GetMotiveData({EnumValueName((VMMotive)data)})"));

            case VMVariableScope.StackObjectMotives:     //15
                return(Exp($"((context.StackObject as VMAvatar)?.GetMotiveData({EnumValueName((VMMotive)data)}) ?? 0)"));

            case VMVariableScope.StackObjectSlot:     //16
                return(Exp($"(context.StackObject.GetSlot({data})?.ObjectID ?? 0)"));

            case VMVariableScope.StackObjectMotiveByTemp:     //17
                return(Exp($"((VMAvatar)context.StackObject).GetMotiveData((VMMotive)temps[{data}])"));

            case VMVariableScope.MyPersonData:     //18
                return(Exp($"((VMAvatar)context.Caller).GetPersonData({EnumValueName((VMPersonDataVariable)data)})"));

            case VMVariableScope.StackObjectPersonData:     //19
                return(Exp($"((VMAvatar)context.StackObject).GetPersonData({EnumValueName((VMPersonDataVariable)data)})"));

            case VMVariableScope.MySlot:     //20
                return(Exp($"(context.Caller.GetSlot({data})?.ObjectID ?? 0)"));

            case VMVariableScope.StackObjectDefinition:     //21
                return(Exp($"VMMemory.GetEntityDefinitionVar(context.StackObject.Object.OBJ, {EnumValueName((VMOBJDVariable)data)}, context)"));

            case VMVariableScope.StackObjectAttributeByParameter:     //22
                return(Exp($"context.StackObject.GetAttribute((ushort)args[{data}])"));

            //23 : room, fallback
            //24 : nhood, fallback

            case VMVariableScope.Local:     //25
                return(Exp($"locals[{data}]"));

            case VMVariableScope.Tuning:     //26
                return(Exp($"VMMemory.GetTuningVariable(context.Callee, {(ushort)data}, context)"));

            case VMVariableScope.DynSpriteFlagForTempOfStackObject:     //27
                return(Exp($"(context.StackObject.IsDynamicSpriteFlagSet((ushort)temps[{data}]) ? (short)1 : (short)0)"));

            case VMVariableScope.TreeAdPersonalityVar:     //28
                throw new Exception("Not implemented...");

            case VMVariableScope.TreeAdMin:     //29
                throw new Exception("Not implemented...");

            case VMVariableScope.MyPersonDataByTemp:     //30
                return(Exp($"((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)(temps[{data}]))"));

            case VMVariableScope.StackObjectPersonDataByTemp:     //31
                return(Exp($"((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)(temps[{data}]))"));

            case VMVariableScope.NeighborPersonData:     //32
                if (!context.TS1)
                {
                    throw new Exception("Only valid in TS1.");
                }
                return(Exp($"(Content.Content.Get().Neighborhood.GetNeighborByID(context.StackObjectID)?.PersonData?.ElementAt({data}) ?? 0)"));

            case VMVariableScope.JobData:     //33 jobdata(temp0, temp1), used a few times to test if a person is at work but that isn't relevant for tso...
                if (!context.TS1)
                {
                    throw new Exception("Only valid in TS1.");
                }
                return(Exp($"Content.Content.Get().Jobs.GetJobData((ushort)temps[0], temps[1], {data})"));

            case VMVariableScope.NeighborhoodData:    //34
                return(Exp($"0"));                    //tutorial values only

            case VMVariableScope.StackObjectFunction: //35
                return(Exp($"(short)context.StackObject.EntryPoints[{data}].ActionFunction"));

            case VMVariableScope.MyTypeAttr:     //36
                if (context.TS1)
                {
                    return(Exp($"Content.Content.Get().Neighborhood.GetTATT((context.Caller.MasterDefinition ?? context.Caller.Object.OBJ).TypeAttrGUID, {data})"));
                }
                return(Exp($"0"));

            case VMVariableScope.StackObjectTypeAttr:     //37
                if (context.TS1)
                {
                    return(Exp($"Content.Content.Get().Neighborhood.GetTATT((context.StackObject.MasterDefinition ?? context.StackObject.Object.OBJ).TypeAttrGUID, {data})"));
                }
                return(Exp($"0"));

            //38 neighbor object definition: fallback

            case VMVariableScope.Unused:
                return(Exp($"context.VM.TuningCache.GetLimit({EnumValueName((VMMotive)data)})"));

            case VMVariableScope.LocalByTemp:     //40
                return(Exp($"locals[temps[{data}]]"));

            case VMVariableScope.StackObjectAttributeByTemp:     //41
                return(Exp($"context.StackObject.GetAttribute((ushort)temps[{data}])"));

            case VMVariableScope.TempXL:     //42
                if (big)
                {
                    return(Exp($"context.Thread.TempXL[{data}]"));
                }
                else
                {
                    return(Exp($"(short)context.Thread.TempXL[{data}]"));
                }

            case VMVariableScope.TSOStandardTime:     //44
                //return GetTSOStandardTime(data)
                var time = "context.VM.Context.Clock.UTCNow";

                switch (data)
                {
                case 0:
                    return(Exp($"(short){time}.Second"));

                case 1:
                    return(Exp($"(short){time}.Minute"));

                case 2:
                    return(Exp($"(short){time}.Hour"));

                case 3:
                    return(Exp($"(short){time}.Day"));

                case 4:
                    return(Exp($"(short){time}.Month"));

                case 5:
                    return(Exp($"(short){time}.Year"));
                }
                ;
                return(Exp($"0"));

            case VMVariableScope.CityTime:     //43
            case VMVariableScope.GameTime:     //45
                var timeN = "context.VM.Context.Clock";
                switch (data)
                {
                case 0:
                    return(Exp($"(short){timeN}.Seconds"));

                case 1:
                    return(Exp($"(short){timeN}.Minutes"));

                case 2:
                    return(Exp($"(short){timeN}.Hours"));

                case 3:
                    return(Exp($"(short){timeN}.TimeOfDay"));

                case 4:
                    return(Exp($"(short){timeN}.DayOfMonth"));

                case 5:
                    return(Exp($"(short){timeN}.Month"));

                case 6:
                    return(Exp($"(short){timeN}.Year"));
                }
                ;
                break;

            case VMVariableScope.MyList:     //46 (man if only i knew what this meant)
                switch (data)
                {
                case 0: return(Exp($"context.Caller.MyList.First.Value"));        //is this allowed?

                case 1: return(Exp($"context.Caller.MyList.Last.Value"));

                case 2: return(Exp($"(short)context.Caller.MyList.Count"));

                default: return(Exp($"context.Caller.MyList.ElementAt(temps[0])"));
                }

            case VMVariableScope.StackObjectList:     //47
                //if (context.StackObject == null) return 0; (this hack is probably needed by something)
                switch (data)
                {
                case 0: return(Exp($"context.StackObject.MyList.First.Value"));

                case 1: return(Exp($"context.StackObject.MyList.Last.Value"));

                case 2: return(Exp($"(short)context.StackObject.MyList.Count"));

                default: return(Exp($"context.StackObject.MyList.ElementAt(temps[0])"));
                }

            case VMVariableScope.MoneyOverHead32Bit:     //48
                //we're poor... will need special case for this in expression like TempXL
                if (big)
                {
                    Exp($"0");
                }
                return(Exp($"0"));

            case VMVariableScope.MyLeadTileAttribute:     //49
                return(Exp($"context.Caller.MultitileGroup.BaseObject.GetAttribute({(ushort)data})"));

            case VMVariableScope.StackObjectLeadTileAttribute:     //50
                return(Exp($"context.StackObject.MultitileGroup.BaseObject.GetAttribute({(ushort)data})"));

            case VMVariableScope.MyLeadTile:     //51
                return($"context.Caller.MultitileGroup.BaseObject.GetValue({EnumValueName((VMStackObjectVariable)data)})");

            case VMVariableScope.StackObjectLeadTile:     //52
                return($"context.StackObject.MultitileGroup.BaseObject.GetValue({EnumValueName((VMStackObjectVariable)data)})");

            //throw new Exception("Not implemented...");

            case VMVariableScope.StackObjectMasterDef:     //53
                //gets definition of the master tile of a multi tile object in the stack object.
                return(Exp($"GetEntityDefinitionVar(context.StackObject.MasterDefinition ?? context.StackObject.Object.OBJ, {EnumValueName((VMOBJDVariable)data)}, context)"));

            case VMVariableScope.FeatureEnableLevel:     //54
                return(Exp($"1"));
                //all of them are enabled, dont really care right now

                //59: MyAvatarID, fallback
            }

            return(Exp($"VMMemory.GetVariable(context, {EnumValueName(scope)}, {data})"));
        }
コード例 #29
0
ファイル: VMSetToNext.cs プロジェクト: Daribon/FreeSO
        public void Read(byte[] bytes)
        {
            using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){

                this.GUID = io.ReadUInt32();
                //132 was object of type
                this.Flags = io.ReadByte();
                this.TargetOwner = (VMVariableScope)io.ReadByte();
                this.Local = io.ReadByte();
                this.TargetData = io.ReadByte();

                if ((Flags & 0x80) == 0)
                {
                    //clobber this, we should always set flag for saving.
                    Flags |= 0x80;
                    TargetOwner = VMVariableScope.StackObjectID;
                    TargetData = 0;
                }
            }
        }
コード例 #30
0
 /// <summary>
 /// Set a variable
 /// </summary>
 /// <param name="context"></param>
 /// <param name="scope"></param>
 /// <param name="data"></param>
 /// <param name="value"></param>
 public static bool SetVariable(VMStackFrame context, VMVariableScope scope, ushort data, short value)
 {
     switch (scope){
         case VMVariableScope.Local:
             context.Locals[data] = (ushort)value;
             return true;
         case VMVariableScope.Literal:
             /** Huh? **/
             return false;
         case VMVariableScope.StackObject:
             return context.Callee.SetValue((VMStackObjectVariable)data, value);
         case VMVariableScope.StackObjectAttributes:
             context.Callee.SetAttribute(data, value);
             return true;
         case VMVariableScope.MyObjectAttributes:
             context.Caller.SetAttribute(data, value);
             return true;
         case VMVariableScope.MyObject:
             return context.Caller.SetValue((VMStackObjectVariable)data, value);
         case VMVariableScope.StackObjectID:
             /** Change the stack object **/
             context.Callee = context.VM.GetObjectById(value);
             return true;
         case VMVariableScope.Temps:
             context.Thread.TempRegisters[data] = value;
             return true;
         case VMVariableScope.Parameters:
             /** Not too sure if this is illegal **/
             context.Args[data] = value;
             return true;
         case VMVariableScope.DynSpriteFlagForTempOfStackObject:
             context.Callee.SetDynamicSpriteFlag(data, value > 0);
             return true;
         case VMVariableScope.MyPersonData:
             var avatar = ((VMAvatar)context.Caller);
             return avatar.SetPersonData((VMPersonDataVariable)data, value);
         default:
             throw new Exception("Unknown scope for set variable!");
     }
 }
コード例 #31
0
ファイル: VMRelationship.cs プロジェクト: RHY3756547/FreeSO
 public virtual void Read(byte[] bytes)
 {
     using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN))
     {
         RelVar = io.ReadByte();
         Mode = io.ReadByte();
         Flags = io.ReadByte();
         Local = io.ReadByte();
         VarScope = (VMVariableScope)io.ReadUInt16();
         VarData = io.ReadInt16();
     }
 }
コード例 #32
0
ファイル: VMMemory.cs プロジェクト: Daribon/FreeSO
        /**
         * Provides a string description of a variable, this is a utility for trace messages
         * that show what he VM is doing
         */
        public static string DescribeVariable(VMStackFrame context, VMVariableScope scope, ushort data)
        {
            bool didPrint = false;

            var result = "";
            switch (scope){
                case VMVariableScope.Literal:
                    result += "literal " + data;
                    break;
                case VMVariableScope.Local:
                    result += "local #" + data;
                    if (context != null){
                        result += " (current value = " + VMMemory.GetVariable(context, scope, data) + ")";
                    }
                    break;
                case VMVariableScope.StackObject:
                    result += "callee." + ((VMStackObjectVariable)data).ToString();
                    if (context != null){
                        result += " (current value = " + VMMemory.GetVariable(context, scope, data) + ")";
                    }
                    break;
                case VMVariableScope.MyObjectAttributes:
                    if (context != null)
                    {
                        if (context.Caller.RTTI != null && context.Caller.RTTI.AttributeLabels != null)
                        {
                            string[] attributeLabels = context.Caller.RTTI.AttributeLabels;
                            if (data < attributeLabels.Length)
                            {
                                result += "caller.attributes." + attributeLabels[data] + "(" + data + ")";
                                didPrint = true;
                            }
                        }
                    }
                    if (!didPrint)
                    {
                        result += "caller.attributes.(" + data + ")";
                    }
                    if (context != null)
                    {
                        result += " (current value = " + VMMemory.GetVariable(context, scope, data) + ")";
                    }
                    break;
                case VMVariableScope.StackObjectAttributes:
                    if (context != null){
                        if (context.StackObject.RTTI != null && context.StackObject.RTTI.AttributeLabels != null){
                            string[] attributeLabels = context.StackObject.RTTI.AttributeLabels;
                            if (data < attributeLabels.Length){
                                result += "StackObject.attributes." + attributeLabels[data] + "(" + data + ")";
                                didPrint = true;
                            }
                        }
                    }
                    if (!didPrint){
                        result += "StackObject.attributes.(" + data + ")";
                    }
                    if (context != null){
                        result += " (current value = " + VMMemory.GetVariable(context, scope, data) + ")";
                    }
                    break;
                case VMVariableScope.Tuning:
                    result = "to be actually done";
                    /*if (context != null)
                    {
                        var label = GetTuningVariableLabel(context.StackObject.Object, data);
                        if (label != null)
                        {
                            result += "StackObject.tuning." + label + "(" + data + ") (value = " + GetTuningVariable(context.StackObject, data, context) + ")";
                            didPrint = true;
                        }
                    }
                    if (!didPrint){
                        result = "StackObject.tuning." + data;
                    }*/
                    break;
                case VMVariableScope.Temps:
                    result = "temp." + data;
                    if (context != null)
                    {
                        result += " (value = " + context.Thread.TempRegisters[data] + ")";
                    }
                    break;
                case VMVariableScope.Parameters:
                    result = "arg." + data;
                    if (context != null)
                    {
                        result += " (value = " + context.Args[data] + ")";
                    }
                    break;
                case VMVariableScope.StackObjectDefinition:
                    result = "stack.objd." + ((VMOBJDVariable)data);
                    if (context != null){
                        result += " (value = " + GetEntityDefinitionVar(context.StackObject.Object.OBJ, ((VMOBJDVariable)data), null) + ")";
                    }
                    break;
                case VMVariableScope.MyPersonData:
                    result = "myPersonData." + ((VMPersonDataVariable)data).ToString();
                    break;
                case VMVariableScope.DynSpriteFlagForTempOfStackObject:
                    result = "stack.dynFlags." + data;
                    break;
                default:
                    result = "Unknown type: " + scope;
                    break;
            }
            return result;
        }
コード例 #33
0
 /// <summary>
 /// Get a variable
 /// </summary>
 /// <param name="context"></param>
 /// <param name="scope"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public static short GetVariable(VMStackFrame context, VMVariableScope scope, ushort data)
 {
     switch (scope){
         case VMVariableScope.Literal:
             return (short)data;
         case VMVariableScope.Local:
             return (short)context.Locals[data];
         case VMVariableScope.StackObject:
             return context.Callee.GetValue((VMStackObjectVariable)data);
         case VMVariableScope.StackObjectAttributes:
             return context.Callee.GetAttribute(data);
         case VMVariableScope.MyObjectAttributes:
             return context.Caller.GetAttribute(data);
         case VMVariableScope.MyObject:
             return context.Caller.GetValue((VMStackObjectVariable)data);
         case VMVariableScope.Temps:
             return context.Thread.TempRegisters[data];
         case VMVariableScope.Parameters:
             return (short)context.Args[data];
         case VMVariableScope.StackObjectsDefinition:
             return GetEntityDefinitionVar(context.Callee.Object, (VMStackObjectDefinitionVariable)data);
         case VMVariableScope.StackObjectID:
             if (context.Callee != null){
                 return context.Callee.ObjectID;
             }
             return -1;
         case VMVariableScope.StackObjectTuning:
             return GetTuningVariable(context.Callee.Object, data);
         case VMVariableScope.DynSpriteFlagForTempOfStackObject:
             return context.Callee.IsDynamicSpriteFlagSet(data) ? (short)1 : (short)0;
         case VMVariableScope.MyPersonData:
             var avatar = (VMAvatar)context.Caller;
             return avatar.GetPersonData((VMPersonDataVariable)data);
     }
     throw new Exception("Unknown get variable");
 }
コード例 #34
0
ファイル: VMGetDirectionTo.cs プロジェクト: RHY3756547/FreeSO
        public void Read(byte[] bytes)
        {
            using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN))
            {
                ResultData = io.ReadInt16();
                ResultOwner = (VMVariableScope)io.ReadUInt16();
                Flags = io.ReadByte();
                ObjectScope = (VMVariableScope)io.ReadByte();
                OScopeData = io.ReadInt16();

                if ((Flags & 1) == 0)
                {
                    ObjectScope = VMVariableScope.MyObject;
                    OScopeData = 11;
                }
                Flags |= 1;
            }
        }
コード例 #35
0
 public static bool IsBig(VMVariableScope scope)
 {
     return(scope == VMVariableScope.TempXL || scope == VMVariableScope.MoneyOverHead32Bit);
 }
コード例 #36
0
        /// <summary>
        /// Get a variable
        /// </summary>
        /// <param name="context"></param>
        /// <param name="scope"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static short GetVariable(VMStackFrame context, VMVariableScope scope, ushort data)
        {
            switch (scope)
            {
            case VMVariableScope.MyObjectAttributes:     //0
                return(context.Caller.GetAttribute(data));

            case VMVariableScope.StackObjectAttributes:     //1
                return(context.StackObject.GetAttribute(data));

            case VMVariableScope.TargetObjectAttributes:     //2
                throw new Exception("Target Object is Deprecated!");

            case VMVariableScope.MyObject:     //3
                return(context.Caller.GetValue((VMStackObjectVariable)data));

            case VMVariableScope.StackObject:     //4
                return(context.StackObject.GetValue((VMStackObjectVariable)data));

            case VMVariableScope.TargetObject:     //5
                throw new Exception("Target Object is Deprecated!");

            case VMVariableScope.Global:     //6
                return(context.VM.GetGlobalValue((ushort)data));

            case VMVariableScope.Literal:     //7
                return((short)data);

            case VMVariableScope.Temps:     //8
                return(context.Thread.TempRegisters[data]);

            case VMVariableScope.Parameters:     //9
                return((short)context.Args[data]);

            case VMVariableScope.StackObjectID:     //10
                if (context.StackObject != null)
                {
                    return(context.StackObject.ObjectID);
                }
                return(-1);

            case VMVariableScope.TempByTemp:     //11
                return(context.Thread.TempRegisters[context.Thread.TempRegisters[data]]);

            case VMVariableScope.TreeAdRange:     //12
                throw new Exception("Not implemented...");

            case VMVariableScope.StackObjectTemp:          //13
                throw new Exception("Not implemented..."); //accesses the stack object's thread and gets its temp...

            case VMVariableScope.MyMotives:                //14
                return(((VMAvatar)context.Caller).GetMotiveData((VMMotive)data));

            case VMVariableScope.StackObjectMotives:     //15
                return(((VMAvatar)context.StackObject).GetMotiveData((VMMotive)data));

            case VMVariableScope.StackObjectSlot:     //16
                return(0);

            //throw new Exception("Not implemented...");

            case VMVariableScope.StackObjectMotiveByTemp:     //17
                return(((VMAvatar)context.StackObject).GetMotiveData((VMMotive)context.Thread.TempRegisters[data]));

            case VMVariableScope.MyPersonData:     //18
                return(((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)data));

            case VMVariableScope.StackObjectPersonData:     //19
                return(((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)data));

            case VMVariableScope.MySlot:     //20
                throw new Exception("Not implemented...");

            case VMVariableScope.StackObjectDefinition:     //21
                return(GetEntityDefinitionVar(context.StackObject.Object, (VMStackObjectDefinitionVariable)data));

            case VMVariableScope.StackObjectAttributeByParameter:     //22
                return(context.StackObject.GetAttribute((ushort)context.Args[data]));

            case VMVariableScope.RoomByTemp0:     //23
                throw new Exception("Not implemented...");

            case VMVariableScope.NeighborInStackObject:     //24
                throw new Exception("Not implemented...");

            case VMVariableScope.Local:     //25
                return((short)context.Locals[data]);

            case VMVariableScope.Tuning:     //26
                return(GetTuningVariable(context.Callee, data, context));

            case VMVariableScope.DynSpriteFlagForTempOfStackObject:     //27
                return(context.StackObject.IsDynamicSpriteFlagSet(data) ? (short)1 : (short)0);

            case VMVariableScope.TreeAdPersonalityVar:     //28
                throw new Exception("Not implemented...");

            case VMVariableScope.TreeAdMin:     //29
                throw new Exception("Not implemented...");

            case VMVariableScope.MyPersonDataByTemp:     //30
                return(((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)(context.Thread.TempRegisters[data])));

            case VMVariableScope.StackObjectPersonDataByTemp:     //31
                return(((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)(context.Thread.TempRegisters[data])));

            case VMVariableScope.NeighborPersonData:     //32
                throw new Exception("Not implemented...");

            case VMVariableScope.JobData:     //33 jobdata(temp0, temp1), used a few times to test if a person is at work but that isn't relevant for tso...
                throw new Exception("Should not be used, but if this shows implement an empty shell to return ideal values.");

            case VMVariableScope.NeighborhoodData:     //34
                throw new Exception("Should not be used, but if this shows implement an empty shell to return ideal values.");

            case VMVariableScope.StackObjectFunction:     //35
                throw new Exception("Not implemented...");

            case VMVariableScope.MyTypeAttr:     //36
                throw new Exception("Unused");

            case VMVariableScope.StackObjectTypeAttr:     //37
                throw new Exception("Unused");

            case VMVariableScope.ThirtyEight:     //38
                throw new Exception("Really");

            case VMVariableScope.LocalByTemp:     //40
                return((short)context.Locals[context.Thread.TempRegisters[data]]);

            case VMVariableScope.StackObjectAttributeByTemp:     //41
                return(context.StackObject.GetAttribute((ushort)context.Thread.TempRegisters[data]));

            case VMVariableScope.TempXL:     //42
                //this needs a really intricate special case for specific operations.
                throw new Exception("Not implemented...");

            case VMVariableScope.CityTime:     //43
                //return GetCityTime(data)
                throw new Exception("Not implemented...");

            case VMVariableScope.TSOStandardTime:     //44
                //return GetTSOStandardTime(data)
                throw new Exception("Not implemented...");

            case VMVariableScope.GameTime:     //45
                //return GameTime(data)
                throw new Exception("Not implemented...");

            case VMVariableScope.MyList:     //46 (man if only i knew what this meant)
                throw new Exception("Not implemented...");

            case VMVariableScope.StackObjectList:     //47
                throw new Exception("Not implemented...");

            case VMVariableScope.MoneyOverHead32Bit:     //48
                //we're poor... will need special case for this in expression like TempXL
                return(0);

            case VMVariableScope.MyLeadTileAttribute:     //49
                throw new Exception("Not implemented...");

            case VMVariableScope.StackObjectLeadTileAttribute:     //50
                throw new Exception("Not implemented...");

            case VMVariableScope.MyLeadTile:     //51
                throw new Exception("Not implemented...");

            case VMVariableScope.StackObjectLeadTile:     //52
                throw new Exception("Not implemented...");

            case VMVariableScope.StackObjectMasterDef:     //53
                //gets definition of the master tile of a multi tile object in the stack object.
                throw new Exception("Not implemented...");

            case VMVariableScope.FeatureEnableLevel:     //54
                return(1);

            //all of them are enabled, dont really care right now

            case VMVariableScope.MyAvatarID:     //59
                return(0);
            }
            throw new Exception("Unknown get variable");
        }
コード例 #37
0
ファイル: VMMemory.cs プロジェクト: Daribon/FreeSO
 public static LinkedList<short> GetList(VMStackFrame context, VMVariableScope scope)
 {
     switch (scope)
     {
         case VMVariableScope.MyList:
             return context.Caller.MyList;
         case VMVariableScope.StackObjectList:
             return context.StackObject.MyList;
         default:
             throw new VMSimanticsException("Cannot get specified variable scope as a list.", context);
     }
 }
コード例 #38
0
ファイル: VMTransferFunds.cs プロジェクト: RHY3756547/FreeSO
 public void Read(byte[] bytes)
 {
     using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
         OldAmountOwner = (VMTransferFundsOldOwner)io.ReadByte();
         AmountOwner = (VMVariableScope)io.ReadByte();
         AmountData = io.ReadUInt16();
         Flags = (VMTransferFundsFlags)io.ReadByte();
         io.ReadByte();
         ExpenseType = (VMTransferFundsExpenseType)io.ReadByte();
         TransferType = (VMTransferFundsType)io.ReadByte();
     }
 }
コード例 #39
0
ファイル: VMMemory.cs プロジェクト: simscolony/FreeSims
        /// <summary>
        /// Set a variable
        /// </summary>
        /// <param name="context"></param>
        /// <param name="scope"></param>
        /// <param name="data"></param>
        /// <param name="value"></param>
        public static bool SetVariable(VMStackFrame context, VMVariableScope scope, short data, short value)
        {
            switch (scope)
            {
            case VMVariableScope.MyObjectAttributes:     //0
                context.Caller.SetAttribute((ushort)data, value);
                return(true);

            case VMVariableScope.StackObjectAttributes:     //1

                if (context.StackObject != null)
                {
                    context.StackObject.SetAttribute((ushort)data, value);
                }

                return(true);

            case VMVariableScope.TargetObjectAttributes:     //2
                throw new VMSimanticsException("Target Object is Deprecated!", context);

            case VMVariableScope.MyObject:     //3
                return(context.Caller.SetValue((VMStackObjectVariable)data, value));

            case VMVariableScope.StackObject:     //4

                if (context.StackObject != null)
                {
                    return(context.StackObject.SetValue((VMStackObjectVariable)data, value));
                }
                else
                {
                    return(true);
                }

            case VMVariableScope.TargetObject:     //5
                throw new VMSimanticsException("Target Object is Deprecated!", context);

            case VMVariableScope.Global:     //6
                return(context.VM.SetGlobalValue((ushort)data, value));

            case VMVariableScope.Literal:     //7
                /** Huh? **/
                return(false);

            case VMVariableScope.Temps:     //8
                context.Thread.TempRegisters[data] = value;
                return(true);

            case VMVariableScope.Parameters:     //9
                /** Not too sure if this is illegal **/
                context.Args[data] = value;
                return(true);

            case VMVariableScope.StackObjectID:     //10
                /** Change the stack object **/
                context.StackObject = context.VM.GetObjectById(value);
                return(true);

            case VMVariableScope.TempByTemp:     //11
                context.Thread.TempRegisters[context.Thread.TempRegisters[data]] = value;
                return(true);

            case VMVariableScope.TreeAdRange:     //12
                return(false);                    //can't set this!

            case VMVariableScope.StackObjectTemp: //13
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.MyMotives:     //14
                if (context.Caller is VMAvatar)
                {
                    return(((VMAvatar)context.Caller).SetMotiveData((VMMotive)data, value));
                }

                return(false);

            case VMVariableScope.StackObjectMotives:     //15
                return(((VMAvatar)context.StackObject).SetMotiveData((VMMotive)data, value));

            case VMVariableScope.StackObjectSlot:     //16
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectMotiveByTemp:     //17
                return(((VMAvatar)context.StackObject).SetMotiveData((VMMotive)context.Thread.TempRegisters[data], value));

            case VMVariableScope.MyPersonData:     //18
                return(((VMAvatar)context.Caller).SetPersonData((VMPersonDataVariable)data, value));

            case VMVariableScope.StackObjectPersonData:     //19
                return(((VMAvatar)context.StackObject).SetPersonData((VMPersonDataVariable)data, value));

            case VMVariableScope.MySlot:     //20
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectDefinition:           //21
                return(false);                                    //you can't set this!

            case VMVariableScope.StackObjectAttributeByParameter: //22
                context.StackObject.SetAttribute((ushort)context.Args[data], value);
                return(true);

            case VMVariableScope.RoomByTemp0:     //23
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.NeighborInStackObject:     //24
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.Local:     //25
                context.Locals[data] = value;
                return(true);

            case VMVariableScope.Tuning:                            //26
                return(false);                                      //you can't set this!

            case VMVariableScope.DynSpriteFlagForTempOfStackObject: //27
                context.StackObject.SetDynamicSpriteFlag((ushort)context.Thread.TempRegisters[data], value > 0);
                return(true);

            case VMVariableScope.TreeAdPersonalityVar: //28
                return(false);                         //you can't set this!

            case VMVariableScope.TreeAdMin:            //29
                return(false);                         //you can't set this!

            case VMVariableScope.MyPersonDataByTemp:   //30
                return(((VMAvatar)context.Caller).SetPersonData((VMPersonDataVariable)context.Thread.TempRegisters[data], value));

            case VMVariableScope.StackObjectPersonDataByTemp:     //31
                return(((VMAvatar)context.StackObject).SetPersonData((VMPersonDataVariable)context.Thread.TempRegisters[data], value));

            case VMVariableScope.NeighborPersonData:     //32
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.JobData:     //33
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.NeighborhoodData:     //34
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectFunction: //35
                return(false);                        //you can't set this!

            case VMVariableScope.MyTypeAttr:          //36
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectTypeAttr:     //37
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.ThirtyEight: //38
                return(false);                //you can't set this!

            case VMVariableScope.LocalByTemp: //40
                context.Locals[context.Thread.TempRegisters[data]] = value;
                return(true);

            case VMVariableScope.StackObjectAttributeByTemp:     //41
                context.StackObject.SetAttribute((ushort)context.Thread.TempRegisters[data], value);
                return(true);

            case VMVariableScope.TempXL:     //42
                throw new VMSimanticsException("Not implemented...", context);
            //this will need a special case for the expression primitive

            case VMVariableScope.CityTime:        //43
            case VMVariableScope.TSOStandardTime: //44
            case VMVariableScope.GameTime:        //45
                return(false);                    //you can't set this!

            case VMVariableScope.MyList:          //46
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.StackObjectList:     //47
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.MoneyOverHead32Bit:     //48
                //throw new VMSimanticsException("Not implemented...", context);
                return(true);

            //needs special case like TempXL.

            case VMVariableScope.MyLeadTileAttribute:     //49
                context.Caller.MultitileGroup.BaseObject.SetAttribute((ushort)data, value);
                return(true);

            case VMVariableScope.StackObjectLeadTileAttribute:     //50
                context.StackObject.MultitileGroup.BaseObject.SetAttribute((ushort)data, value);
                return(true);

            case VMVariableScope.MyLeadTile:           //51
            case VMVariableScope.StackObjectLeadTile:  //52
            case VMVariableScope.StackObjectMasterDef: //53
                return(false);

            case VMVariableScope.FeatureEnableLevel:     //54
                throw new VMSimanticsException("Not implemented...", context);

            case VMVariableScope.MyAvatarID: //59
                return(false);               //you can't set this!

            default:
                throw new VMSimanticsException("Unknown scope for set variable!", context);
            }
        }
コード例 #40
0
ファイル: VMMemory.cs プロジェクト: Daribon/FreeSO
        /// <summary>
        /// Get a variable
        /// </summary>
        /// <param name="context"></param>
        /// <param name="scope"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static short GetVariable(VMStackFrame context, VMVariableScope scope, ushort data)
        {
            switch (scope){
                case VMVariableScope.MyObjectAttributes: //0
                    return context.Caller.GetAttribute(data);

                case VMVariableScope.StackObjectAttributes: //1
                    return context.StackObject.GetAttribute(data);

                case VMVariableScope.TargetObjectAttributes: //2
                    throw new VMSimanticsException("Target Object is Deprecated!", context);

                case VMVariableScope.MyObject: //3
                    return context.Caller.GetValue((VMStackObjectVariable)data);

                case VMVariableScope.StackObject: //4
                    return context.StackObject.GetValue((VMStackObjectVariable)data);

                case VMVariableScope.TargetObject: //5
                    throw new VMSimanticsException("Target Object is Deprecated!", context);

                case VMVariableScope.Global: //6
                    return context.VM.GetGlobalValue((ushort)data);

                case VMVariableScope.Literal: //7
                    return (short)data;

                case VMVariableScope.Temps: //8
                    return context.Thread.TempRegisters[data];

                case VMVariableScope.Parameters: //9
                    return (short)context.Args[data];

                case VMVariableScope.StackObjectID: //10
                    if (context.StackObject != null)
                    {
                        return context.StackObject.ObjectID;
                    }
                    return 0; //no object = 0, ids have a base of 1

                case VMVariableScope.TempByTemp: //11
                    return context.Thread.TempRegisters[context.Thread.TempRegisters[data]];

                case VMVariableScope.TreeAdRange: //12
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.StackObjectTemp: //13
                    throw new VMSimanticsException("Not implemented...", context); //accesses the stack object's thread and gets its temp...

                case VMVariableScope.MyMotives: //14
                    return ((VMAvatar)context.Caller).GetMotiveData((VMMotive)data);

                case VMVariableScope.StackObjectMotives: //15
                    return ((VMAvatar)context.StackObject).GetMotiveData((VMMotive)data);

                case VMVariableScope.StackObjectSlot: //16
                    var slotObj = context.StackObject.GetSlot(data);
                    return (slotObj == null)?(short)0:slotObj.ObjectID;

                case VMVariableScope.StackObjectMotiveByTemp: //17
                    return ((VMAvatar)context.StackObject).GetMotiveData((VMMotive)context.Thread.TempRegisters[data]);

                case VMVariableScope.MyPersonData: //18
                    return ((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)data);

                case VMVariableScope.StackObjectPersonData: //19
                    return ((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)data);

                case VMVariableScope.MySlot: //20
                    var slotObj2 = context.Caller.GetSlot(data);
                    return (slotObj2 == null) ? (short)0 : slotObj2.ObjectID;

                case VMVariableScope.StackObjectDefinition: //21
                    return GetEntityDefinitionVar(context.StackObject.Object.OBJ, (VMOBJDVariable)data, context);

                case VMVariableScope.StackObjectAttributeByParameter: //22
                    return context.StackObject.GetAttribute((ushort)context.Args[data]);

                case VMVariableScope.RoomByTemp0: //23
                    //returns information on the selected room. Right now we don't have a room system, so always return the same values. (everywhere is indoors, not a pool)

                    if (data == 0) return 100; //ambient light 0-100
                    else if (data == 1) return 0; //outside
                    else if (data == 2) return 0; //level
                    else if (data == 3) return 0; //area (???)
                    else if (data == 4) return 0; //is pool
                    else throw new VMSimanticsException("Invalid room data!", context);

                    //throw new VMSimanticsException("Not implemented...");

                case VMVariableScope.NeighborInStackObject: //24
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.Local: //25
                    return (short)context.Locals[data];

                case VMVariableScope.Tuning: //26
                    return GetTuningVariable(context.Callee, data, context);

                case VMVariableScope.DynSpriteFlagForTempOfStackObject: //27
                    return context.StackObject.IsDynamicSpriteFlagSet((ushort)context.Thread.TempRegisters[data]) ? (short)1 : (short)0;

                case VMVariableScope.TreeAdPersonalityVar: //28
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.TreeAdMin: //29
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.MyPersonDataByTemp: //30
                    return ((VMAvatar)context.Caller).GetPersonData((VMPersonDataVariable)(context.Thread.TempRegisters[data]));

                case VMVariableScope.StackObjectPersonDataByTemp: //31
                    return ((VMAvatar)context.StackObject).GetPersonData((VMPersonDataVariable)(context.Thread.TempRegisters[data]));

                case VMVariableScope.NeighborPersonData: //32
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.JobData: //33 jobdata(temp0, temp1), used a few times to test if a person is at work but that isn't relevant for tso...
                    throw new VMSimanticsException("Should not be used, but if this shows implement an empty shell to return ideal values.", context);

                case VMVariableScope.NeighborhoodData: //34
                    throw new VMSimanticsException("Should not be used, but if this shows implement an empty shell to return ideal values.", context);

                case VMVariableScope.StackObjectFunction: //35
                    return (short)context.StackObject.EntryPoints[data].ActionFunction;

                case VMVariableScope.MyTypeAttr: //36
                    throw new VMSimanticsException("Unused", context);

                case VMVariableScope.StackObjectTypeAttr: //37
                    throw new VMSimanticsException("Unused", context);

                case VMVariableScope.ThirtyEight: //38
                    throw new VMSimanticsException("Really", context);

                case VMVariableScope.LocalByTemp: //40
                    return (short)context.Locals[context.Thread.TempRegisters[data]];

                case VMVariableScope.StackObjectAttributeByTemp: //41
                    return context.StackObject.GetAttribute((ushort)context.Thread.TempRegisters[data]);

                case VMVariableScope.TempXL: //42
                    //this needs a really intricate special case for specific operations.
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.CityTime: //43
                    //return GetCityTime(data)
                    switch (data)
                    {
                        case 0:
                            return (short)context.VM.Context.Clock.Seconds;
                        case 1:
                            return (short)context.VM.Context.Clock.Minutes;
                        case 2:
                            return (short)context.VM.Context.Clock.Hours;
                        case 3:
                            return (short)context.VM.Context.Clock.TimeOfDay;

                    };
                    break;
                case VMVariableScope.TSOStandardTime: //44
                    //return GetTSOStandardTime(data)
                    return 0;
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.GameTime: //45
                    switch (data)
                    {
                        case 0:
                            return (short)context.VM.Context.Clock.Seconds;
                        case 1:
                            return (short)context.VM.Context.Clock.Minutes;
                        case 2:
                            return (short)context.VM.Context.Clock.Hours;
                        case 3:
                            return (short)context.VM.Context.Clock.TimeOfDay;

                    };
                    break;

                case VMVariableScope.MyList: //46 (man if only i knew what this meant)
                    switch (data)
                    {
                        case 0: return context.Caller.MyList.First.Value; //is this allowed?
                        case 1: return context.Caller.MyList.Last.Value;
                        case 2: return (short)context.Caller.MyList.Count;
                        default: throw new VMSimanticsException("Unknown List Accessor", context);
                    }
                case VMVariableScope.StackObjectList: //47
                    if (context.StackObject == null) return 0;
                    switch (data)
                    {
                        case 0: return context.StackObject.MyList.First.Value;
                        case 1: return context.StackObject.MyList.Last.Value;
                        case 2: return (short)context.StackObject.MyList.Count;
                        default: throw new VMSimanticsException("Unknown List Accessor", context);
                    }

                case VMVariableScope.MoneyOverHead32Bit: //48
                    //we're poor... will need special case for this in expression like TempXL
                    return 0;

                case VMVariableScope.MyLeadTileAttribute: //49
                    return context.Caller.MultitileGroup.BaseObject.GetAttribute(data);

                case VMVariableScope.StackObjectLeadTileAttribute: //50
                    return context.StackObject.MultitileGroup.BaseObject.GetAttribute(data);

                case VMVariableScope.MyLeadTile: //51
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.StackObjectLeadTile: //52
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.StackObjectMasterDef: //53
                    //gets definition of the master tile of a multi tile object in the stack object.
                    var masterDef = context.StackObject.MasterDefinition;
                    return GetEntityDefinitionVar((masterDef == null)?context.StackObject.Object.OBJ:masterDef, (VMOBJDVariable)data, context);

                case VMVariableScope.FeatureEnableLevel: //54
                    return 1;
                    //all of them are enabled, dont really care right now

                case VMVariableScope.MyAvatarID: //59
                    return 0;

            }
            throw new VMSimanticsException("Unknown get variable", context);
        }
コード例 #41
0
        public void Read(byte[] bytes)
        {
            using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
                OldAmmountOwner = (VMTransferFundsOldOwner)io.ReadByte();
                AmmountOwner = (VMVariableScope)io.ReadByte();

                //TODO: Not certain of the boundaries for the next 2 fields
                Flags = (VMTransferFundsFlags)io.ReadUInt32();
                ExpenseType = (VMTransferFundsExpenseType)io.ReadByte();
                TransferType = (VMTransferFundsType)io.ReadByte();
            }
        }
コード例 #42
0
ファイル: VMMemory.cs プロジェクト: Daribon/FreeSO
 public static bool SetBigVariable(VMStackFrame context, VMVariableScope scope, ushort data, int value)
 {
     switch (scope)
     {
         case VMVariableScope.TempXL:
             context.Thread.TempXL[data] = value;
             return true;
         default:
             return SetVariable(context, scope, data, (short)value); //truncate value and set the relevant 16 bit var to it.
     }
 }
コード例 #43
0
ファイル: VMExpression.cs プロジェクト: Daribon/FreeSO
 public void Read(byte[] bytes)
 {
     using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
         LhsData = io.ReadUInt16();
         RhsData = io.ReadUInt16();
         IsSigned = io.ReadByte();
         Operator = (VMExpressionOperator)io.ReadByte();
         LhsOwner = (VMVariableScope)io.ReadByte();
         RhsOwner = (VMVariableScope)io.ReadByte();
     }
 }
コード例 #44
0
ファイル: VMMemory.cs プロジェクト: Daribon/FreeSO
        /// <summary>
        /// Set a variable
        /// </summary>
        /// <param name="context"></param>
        /// <param name="scope"></param>
        /// <param name="data"></param>
        /// <param name="value"></param>
        public static bool SetVariable(VMStackFrame context, VMVariableScope scope, ushort data, short value)
        {
            switch (scope){
                case VMVariableScope.MyObjectAttributes: //0
                    context.Caller.SetAttribute(data, value);
                    return true;

                case VMVariableScope.StackObjectAttributes: //1
                    context.StackObject.SetAttribute(data, value);
                    return true;

                case VMVariableScope.TargetObjectAttributes: //2
                    throw new VMSimanticsException("Target Object is Deprecated!", context);

                case VMVariableScope.MyObject: //3
                    return context.Caller.SetValue((VMStackObjectVariable)data, value);

                case VMVariableScope.StackObject: //4
                    return context.StackObject.SetValue((VMStackObjectVariable)data, value);

                case VMVariableScope.TargetObject: //5
                    throw new VMSimanticsException("Target Object is Deprecated!", context);

                case VMVariableScope.Global: //6
                    return context.VM.SetGlobalValue((ushort)data, value);

                case VMVariableScope.Literal: //7
                    /** Huh? **/
                    return false;

                case VMVariableScope.Temps: //8
                    context.Thread.TempRegisters[data] = value;
                    return true;

                case VMVariableScope.Parameters: //9
                    /** Not too sure if this is illegal **/
                    context.Args[data] = value;
                    return true;

                case VMVariableScope.StackObjectID: //10
                    /** Change the stack object **/
                    context.StackObject = context.VM.GetObjectById(value);
                    return true;

                case VMVariableScope.TempByTemp: //11
                    context.Thread.TempRegisters[context.Thread.TempRegisters[data]] = value;
                    return true;

                case VMVariableScope.TreeAdRange: //12
                    return false; //can't set this!

                case VMVariableScope.StackObjectTemp: //13
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.MyMotives: //14
                    return ((VMAvatar)context.Caller).SetMotiveData((VMMotive)data, value);

                case VMVariableScope.StackObjectMotives: //15
                    return ((VMAvatar)context.StackObject).SetMotiveData((VMMotive)data, value);

                case VMVariableScope.StackObjectSlot: //16
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.StackObjectMotiveByTemp: //17
                    return ((VMAvatar)context.StackObject).SetMotiveData((VMMotive)context.Thread.TempRegisters[data], value);

                case VMVariableScope.MyPersonData: //18
                    return ((VMAvatar)context.Caller).SetPersonData((VMPersonDataVariable)data, value);

                case VMVariableScope.StackObjectPersonData: //19
                    return ((VMAvatar)context.StackObject).SetPersonData((VMPersonDataVariable)data, value);

                case VMVariableScope.MySlot: //20
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.StackObjectDefinition: //21
                    return false; //you can't set this!

                case VMVariableScope.StackObjectAttributeByParameter: //22
                    context.StackObject.SetAttribute((ushort)context.Args[data], value);
                    return true;

                case VMVariableScope.RoomByTemp0: //23
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.NeighborInStackObject: //24
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.Local: //25
                    context.Locals[data] = (ushort)value;
                    return true;

                case VMVariableScope.Tuning: //26
                    return false; //you can't set this!

                case VMVariableScope.DynSpriteFlagForTempOfStackObject: //27
                    context.StackObject.SetDynamicSpriteFlag((ushort)context.Thread.TempRegisters[data], value > 0);
                    return true;

                case VMVariableScope.TreeAdPersonalityVar: //28
                    return false; //you can't set this!

                case VMVariableScope.TreeAdMin: //29
                    return false; //you can't set this!

                case VMVariableScope.MyPersonDataByTemp: //30
                    return ((VMAvatar)context.Caller).SetPersonData((VMPersonDataVariable)context.Thread.TempRegisters[data], value);

                case VMVariableScope.StackObjectPersonDataByTemp: //31
                    return ((VMAvatar)context.StackObject).SetPersonData((VMPersonDataVariable)context.Thread.TempRegisters[data], value);

                case VMVariableScope.NeighborPersonData: //32
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.JobData: //33
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.NeighborhoodData: //34
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.StackObjectFunction: //35
                    return false; //you can't set this!

                case VMVariableScope.MyTypeAttr: //36
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.StackObjectTypeAttr: //37
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.ThirtyEight: //38
                    return false; //you can't set this!

                case VMVariableScope.LocalByTemp: //40
                    context.Locals[context.Thread.TempRegisters[data]] = (ushort)value;
                    return true;

                case VMVariableScope.StackObjectAttributeByTemp: //41
                    context.StackObject.SetAttribute((ushort)context.Thread.TempRegisters[data], value);
                    return true;

                case VMVariableScope.TempXL: //42
                    throw new VMSimanticsException("Not implemented...", context);
                    //this will need a special case for the expression primitive

                case VMVariableScope.CityTime: //43
                case VMVariableScope.TSOStandardTime: //44
                case VMVariableScope.GameTime: //45
                    return false; //you can't set this!

                case VMVariableScope.MyList: //46
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.StackObjectList: //47
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.MoneyOverHead32Bit: //48
                    //throw new VMSimanticsException("Not implemented...", context);
                    return true;
                    //needs special case like TempXL.

                case VMVariableScope.MyLeadTileAttribute: //49
                    context.Caller.MultitileGroup.BaseObject.SetAttribute(data, value);
                    return true;

                case VMVariableScope.StackObjectLeadTileAttribute: //50
                    context.StackObject.MultitileGroup.BaseObject.SetAttribute(data, value);
                    return true;

                case VMVariableScope.MyLeadTile: //51
                case VMVariableScope.StackObjectLeadTile: //52
                case VMVariableScope.StackObjectMasterDef: //53
                    return false;

                case VMVariableScope.FeatureEnableLevel: //54
                    throw new VMSimanticsException("Not implemented...", context);

                case VMVariableScope.MyAvatarID: //59
                    return false; //you can't set this!

                default:
                    throw new VMSimanticsException("Unknown scope for set variable!", context);
            }
        }