public void Load(VMQueuedActionMarshal input, VMContext context) { CodeOwner = FSO.Content.Content.Get().WorldObjects.Get(input.CodeOwnerGUID); BHAV bhav = null; if (input.RoutineID >= 8192) { bhav = CodeOwner.Resource.SemiGlobal.Get <BHAV>(input.RoutineID); } else if (input.RoutineID >= 4096) { bhav = CodeOwner.Resource.Get <BHAV>(input.RoutineID); } else { bhav = context.Globals.Resource.Get <BHAV>(input.RoutineID); } ActionRoutine = context.VM.Assemble(bhav); if (input.CheckRoutineID != 0) { if (input.CheckRoutineID >= 8192) { bhav = CodeOwner.Resource.SemiGlobal.Get <BHAV>(input.CheckRoutineID); } else if (input.CheckRoutineID >= 4096) { bhav = CodeOwner.Resource.Get <BHAV>(input.CheckRoutineID); } else { bhav = context.Globals.Resource.Get <BHAV>(input.CheckRoutineID); } CheckRoutine = context.VM.Assemble(bhav); } Callee = context.VM.GetObjectById(input.Callee); StackObject = context.VM.GetObjectById(input.StackObject); IconOwner = context.VM.GetObjectById(input.IconOwner); Name = input.Name; Args = input.Args; InteractionNumber = input.InteractionNumber; Cancelled = input.Cancelled; Priority = input.Priority; Mode = input.Mode; Flags = input.Flags; Flags2 = input.Flags2; UID = input.UID; Callback = (input.Callback == null)?null:new VMActionCallback(input.Callback, context); InteractionResult = input.InteractionResult; ResultCheckCounter = input.ResultCheckCounter; }
public void Deserialize(BinaryReader reader) { RoutineID = reader.ReadUInt16(); CheckRoutineID = reader.ReadUInt16(); Callee = reader.ReadInt16(); StackObject = reader.ReadInt16(); IconOwner = reader.ReadInt16(); CodeOwnerGUID = reader.ReadUInt32(); if (reader.ReadBoolean()) { Name = reader.ReadString(); } var argsLen = reader.ReadInt32(); if (argsLen > -1) { Args = new short[argsLen]; for (int i = 0; i < argsLen; i++) { Args[i] = reader.ReadInt16(); } } InteractionNumber = reader.ReadInt32(); NotifyIdle = reader.ReadBoolean(); Priority = reader.ReadInt16(); Mode = (VMQueueMode)reader.ReadByte(); Flags = (TTABFlags)reader.ReadUInt32(); Flags2 = (TSOFlags)reader.ReadUInt32(); UID = reader.ReadUInt16(); if (reader.ReadBoolean()) { Callback = new VMActionCallbackMarshal(); Callback.Deserialize(reader); } if (Version > 11) { InteractionResult = reader.ReadSByte(); ResultCheckCounter = reader.ReadUInt16(); } }
public List <VMPieMenuInteraction> CheckAction(VMQueuedAction action) { // 1. check action flags for permissions (if we are avatar) // 2. run check tree // rules: // Dogs/Cats means people CANNOT use these interactions. (DogsFlag|CatsFlag & IsDog|IsCat) // When Allow Object Owner is OFF it disallows the object owner, otherwise no effect // Visitors, Roommates, Ghosts have this same negative effect. // Friends apprars to override Owner, Visitors, Roommates // Allow CSRs:positive effect. if (action == null) { return(null); } if (Context.VM.TS1) { return(CheckTS1Action(action)); } var result = new List <VMPieMenuInteraction>(); if (((action.Flags & TTABFlags.MustRun) == 0) && Entity is VMAvatar) //just let everyone use the CSR interactions { var avatar = (VMAvatar)Entity; if (avatar.GetSlot(0) != null && (action.Flags & TTABFlags.TSOAvailableCarrying) == 0) { return(null); } if ((action.Flags & (TTABFlags.AllowCats | TTABFlags.AllowDogs)) > 0) { //interaction can only be performed by cats or dogs if (!avatar.IsPet) { return(null); } //check we're the correct type if (avatar.IsCat && (action.Flags & TTABFlags.AllowCats) == 0) { return(null); } if (avatar.IsDog && (action.Flags & TTABFlags.AllowDogs) == 0) { return(null); } } else if (avatar.IsPet) { return(null); //not allowed } if ((action.Flags & TTABFlags.TSOIsRepair) > 0 != ((action.Callee.MultitileGroup.BaseObject.TSOState as VMTSOObjectState)?.Broken ?? false)) { return(null); } TSOFlags tsoState = ((!(action.Callee is VMGameObject) || avatar.PersistID == ((VMTSOObjectState)action.Callee.TSOState).OwnerID) ? TSOFlags.AllowObjectOwner : 0) | ((((VMTSOAvatarState)avatar.TSOState).Permissions == VMTSOAvatarPermissions.Visitor) ? TSOFlags.AllowVisitors : 0) | ((((VMTSOAvatarState)avatar.TSOState).Permissions >= VMTSOAvatarPermissions.Roommate) ? TSOFlags.AllowRoommates : 0) | ((((VMTSOAvatarState)avatar.TSOState).Permissions == VMTSOAvatarPermissions.Admin) ? TSOFlags.AllowCSRs : 0) | ((avatar.GetPersonData(VMPersonDataVariable.IsGhost) > 0) ? TSOFlags.AllowGhost : 0) | TSOFlags.AllowFriends; TSOFlags tsoCompare = action.Flags2; //if flags are empty apart from "Non-Empty", force everything but visitor. (a kind of default state) if (tsoCompare == TSOFlags.NonEmpty) { tsoCompare |= TSOFlags.AllowFriends | TSOFlags.AllowRoommates | TSOFlags.AllowObjectOwner; } //DEBUG: enable debug interction for all CSRs. if ((action.Flags & TTABFlags.Debug) > 0) { if ((tsoState & TSOFlags.AllowCSRs) > 0) { return(result); //do not bother running check } else { return(null); //disable debug for everyone else. } } if ((action.Flags & TTABFlags.TSOAvailableWhenDead) > 0) { tsoCompare |= TSOFlags.AllowGhost; } if ((action.Flags & TTABFlags.AllowVisitors) > 0) { tsoCompare |= TSOFlags.AllowVisitors; //wrong??????? } var posMask = (TSOFlags.AllowObjectOwner); if (((tsoState & posMask) & (tsoCompare & posMask)) == 0) { //NEGATIVE EFFECTS: var negMask = (TSOFlags.AllowVisitors | TSOFlags.AllowRoommates | TSOFlags.AllowGhost); var negatedFlags = (~tsoCompare) & negMask; if ((negatedFlags & tsoState) > 0) { return(null); //we are disallowed } if ((tsoCompare & TSOFlags.AllowCSRs) > 0 && (tsoState & TSOFlags.AllowCSRs) == 0) { return(null); // only admins can run csr. } } } if (((action.Flags & TTABFlags.MustRun) == 0 || ((action.Flags & TTABFlags.TSORunCheckAlways) > 0)) && action.CheckRoutine != null && EvaluateCheck(Context, Entity, new VMStackFrame() { Caller = Entity, Callee = action.Callee, CodeOwner = action.CodeOwner, StackObject = action.StackObject, Routine = action.CheckRoutine, Args = new short[4] }, null, result) != VMPrimitiveExitCode.RETURN_TRUE) { return(null); } return(result); }
public void Deserialize(BinaryReader reader) { RoutineID = reader.ReadUInt16(); CheckRoutineID = reader.ReadUInt16(); Callee = reader.ReadInt16(); StackObject = reader.ReadInt16(); IconOwner = reader.ReadInt16(); CodeOwnerGUID = reader.ReadUInt32(); if (reader.ReadBoolean()) Name = reader.ReadString(); var argsLen = reader.ReadInt32(); if (argsLen > -1) { Args = new short[argsLen]; for (int i = 0; i < argsLen; i++) Args[i] = reader.ReadInt16(); } InteractionNumber = reader.ReadInt32(); Cancelled = reader.ReadBoolean(); Priority = reader.ReadInt16(); Mode = (VMQueueMode)reader.ReadByte(); Flags = (TTABFlags)reader.ReadUInt32(); Flags2 = (TSOFlags)reader.ReadUInt32(); UID = reader.ReadUInt16(); if (reader.ReadBoolean()) { Callback = new VMActionCallbackMarshal(); Callback.Deserialize(reader); } }
public void Load(VMQueuedActionMarshal input, VMContext context) { CodeOwner = FSO.Content.Content.Get().WorldObjects.Get(input.CodeOwnerGUID); BHAV bhav = null; if (input.RoutineID >= 8192) bhav = CodeOwner.Resource.SemiGlobal.Get<BHAV>(input.RoutineID); else if (input.RoutineID >= 4096) bhav = CodeOwner.Resource.Get<BHAV>(input.RoutineID); else bhav = context.Globals.Resource.Get<BHAV>(input.RoutineID); ActionRoutine = context.VM.Assemble(bhav); if (input.CheckRoutineID != 0) { if (input.CheckRoutineID >= 8192) bhav = CodeOwner.Resource.SemiGlobal.Get<BHAV>(input.CheckRoutineID); else if (input.CheckRoutineID >= 4096) bhav = CodeOwner.Resource.Get<BHAV>(input.CheckRoutineID); else bhav = context.Globals.Resource.Get<BHAV>(input.CheckRoutineID); CheckRoutine = context.VM.Assemble(bhav); } Callee = context.VM.GetObjectById(input.Callee); StackObject = context.VM.GetObjectById(input.StackObject); IconOwner = context.VM.GetObjectById(input.IconOwner); Name = input.Name; Args = input.Args; InteractionNumber = input.InteractionNumber; Cancelled = input.Cancelled; Priority = input.Priority; Mode = input.Mode; Flags = input.Flags; Flags2 = input.Flags2; UID = input.UID; Callback = (input.Callback == null)?null:new VMActionCallback(input.Callback, context); }