private void UpdateInventoryToken(VMStackFrame context, VMInventoryOperationsOperand operand, VMInventoryOpState state) { var vm = context.VM; var match = vm.MyInventory.Where(x => x.GUID == operand.GUID); foreach (var obj in match) { if (operand.Mode == VMInventoryOpMode.FSOTokenReplaceGUIDAttributes || operand.Mode == VMInventoryOpMode.FSOTokenEnsureGUIDExists) { //replace all. var copy = state.TempWrite.Select(x => (int)x).ToList(); copy.RemoveAt(0); obj.Attributes = copy; } else if (operand.Mode != VMInventoryOpMode.FSOTokenGetAttributeTemp0) { //replace single var index = context.Thread.TempRegisters[0]; while (obj.Attributes.Count <= index) { obj.Attributes.Add(0); } obj.Attributes[index] = state.Temp0Value; } } }
private void TokenResponse(VM vm, VMInventoryOperationsOperand op, short threadID, bool success, List <int> result) { if (op.Mode == VMInventoryOpMode.FSOTokenEnsureGUIDExists || op.Mode == VMInventoryOpMode.FSOTokenReplaceGUIDAttributes) { var temps = result.Select(x => (short)x).ToList(); temps.Insert(0, (short)temps.Count); vm.SendCommand(new VMNetAsyncResponseCmd(threadID, new VMInventoryOpState { Responded = true, Success = success, WriteResult = false, TempWrite = temps })); } else { var value = ((result.Count > 1) ? result[1] : 0); vm.SendCommand(new VMNetAsyncResponseCmd(threadID, new VMInventoryOpState { Responded = true, Success = success, WriteResult = true, WriteScope = op.FSOScope, WriteData = op.FSOData, Temp0Value = value, })); } }