diff --git a/TSOClient/tso.simantics/Primitives/VMInventoryOperations.cs b/TSOClient/tso.simantics/Primitives/VMInventoryOperations.cs index 92fed9d48..c1daf71b8 100644 --- a/TSOClient/tso.simantics/Primitives/VMInventoryOperations.cs +++ b/TSOClient/tso.simantics/Primitives/VMInventoryOperations.cs @@ -44,7 +44,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe if (state.Responded) { context.Thread.BlockingState = null; - if (state.ObjectPersistID > 0) + if (state.ObjectPersistID > 0 && (operand.Mode == VMInventoryOpMode.FSOCopyObjectOfTypeOOW || operand.Mode == VMInventoryOpMode.FSOCreateObjectOfTypeOOW)) { var persistObj = context.VM.GetObjectByPersist(state.ObjectPersistID); state.Temp0Value = persistObj?.ObjectID ?? 0; @@ -80,12 +80,14 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe context.Thread.TempRegisters[0] = 255; //TODO: hard object limit imposed by db. return VMPrimitiveExitCode.GOTO_TRUE; } + var check = context.Thread.IsCheck; context.Thread.BlockingState = new VMInventoryOpState(); if (context.VM.GlobalLink != null) { - var id = context.Caller.ObjectID; //this thread's object id. + var id = (check) ? (short)0 : context.Caller.ObjectID; //this thread's object id. var vm = context.VM; + var targetPID = target.PersistID; switch (operand.Mode) { case VMInventoryOpMode.FSOSaveStackObj: @@ -93,7 +95,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe // vm initiated inventory transfer. // TODO: should this force owner? Crafting Bench uses separate command to change owner before doing this. { - var mypid = target.PersistID; + var mypid = targetPID; var opid = context.StackObject.PersistID; var oid = context.StackObject.ObjectID; vm.GlobalLink.MoveToInventory(vm, context.StackObject.MultitileGroup, (bool success, uint pid) => @@ -135,7 +137,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe //if deleted# != selected#, reverse transaction and declare it failed. //same for selected# being < x. { - vm.GlobalLink.ConsumeInventory(vm, target.PersistID, operand.GUID, 1, context.Thread.TempRegisters[0], + vm.GlobalLink.ConsumeInventory(vm, targetPID, operand.GUID, 1, context.Thread.TempRegisters[0], (bool success, int count) => { vm.SendCommand(new VMNetAsyncResponseCmd(id, new VMInventoryOpState @@ -152,7 +154,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe { //get id and vm now to avoid race conditions var all = operand.Mode == VMInventoryOpMode.FSOCountAllObjectsOfType; - vm.GlobalLink.ConsumeInventory(vm, target.PersistID, operand.GUID, all ? 2 : 0, 0, + vm.GlobalLink.ConsumeInventory(vm, targetPID, operand.GUID, all ? 2 : 0, 0, (bool success, int count) => { vm.SendCommand(new VMNetAsyncResponseCmd(id, new VMInventoryOpState @@ -171,7 +173,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe { var reserve = operand.Mode == VMInventoryOpMode.FSOCreateObjectOfTypeOOW; var index = VMMemory.GetBigVariable(context, operand.FSOScope, operand.FSOData); - vm.GlobalLink.RetrieveFromInventoryByType(vm, target.PersistID, operand.GUID, index, reserve, (data) => + vm.GlobalLink.RetrieveFromInventoryByType(vm, targetPID, operand.GUID, index, reserve, (data) => { vm.SendCommand(new VMNetAsyncResponseCmd(id, new VMInventoryOpState { @@ -215,7 +217,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe //returns false if it didn't exist before. temp 0 contains -1 if it STILL doesn't exist (creation failed) //this will also force the object to have db_attribute type >0 { - var mypid = target.PersistID; + var mypid = targetPID; var data = new List(); var temps = context.Thread.TempRegisters; var attrCount = Math.Min(temps[0], temps.Length - 1); @@ -225,7 +227,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe } vm.GlobalLink.TokenRequest(vm, mypid, operand.GUID, InventoryToRequestMode[operand.Mode], data, (success, result) => { - TokenResponse(vm, operand, id, success, result); + TokenResponse(vm, operand, id, targetPID, success, result); }); } break; @@ -236,7 +238,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe //access token attribute[temp 0] for the zeroth object of this type. Value to read or set is in scope/data. { { - var mypid = target.PersistID; + var mypid = targetPID; var data = new List(); data.Add(context.Thread.TempRegisters[0]); //index @@ -247,7 +249,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe vm.GlobalLink.TokenRequest(vm, mypid, operand.GUID, InventoryToRequestMode[operand.Mode], data, (success, result) => { - TokenResponse(vm, operand, id, success, result); + TokenResponse(vm, operand, id, targetPID, success, result); }); } } @@ -256,13 +258,13 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe case VMInventoryOpMode.FSOTokenTotalAttributeTemp0: //total all instances of an attribute (guid, attribute) and return value (can be int size) { - var mypid = target.PersistID; + var mypid = targetPID; var data = new List(); data.Add(context.Thread.TempRegisters[0]); //index data.Add(0); vm.GlobalLink.TokenRequest(vm, mypid, operand.GUID, VMTokenRequestMode.TotalAttribute, data, (success, result) => { - TokenResponse(vm, operand, id, success, result); + TokenResponse(vm, operand, id, targetPID, success, result); }); } break; @@ -270,7 +272,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe case VMInventoryOpMode.FSOGetUserID: { { - var mypid = target.PersistID; + var mypid = targetPID; vm.GlobalLink.GetAccountIDFromAvatar(mypid, (userID) => { vm.SendCommand(new VMNetAsyncResponseCmd(id, new VMInventoryOpState @@ -292,7 +294,7 @@ public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOpe return (context.Thread.IsCheck) ? VMPrimitiveExitCode.GOTO_TRUE : VMPrimitiveExitCode.CONTINUE_NEXT_TICK; } - private void TokenResponse(VM vm, VMInventoryOperationsOperand op, short threadID, bool success, List result) + private void TokenResponse(VM vm, VMInventoryOperationsOperand op, short threadID, uint targetPID, bool success, List result) { if (op.Mode == VMInventoryOpMode.FSOTokenEnsureGUIDExists || op.Mode == VMInventoryOpMode.FSOTokenReplaceGUIDAttributes) { diff --git a/TSOClient/tso.world/Components/AbstractSkyDome.cs b/TSOClient/tso.world/Components/AbstractSkyDome.cs index c06a4e4ce..24b1a30ee 100644 --- a/TSOClient/tso.world/Components/AbstractSkyDome.cs +++ b/TSOClient/tso.world/Components/AbstractSkyDome.cs @@ -156,7 +156,7 @@ public void Draw(GraphicsDevice gd, Color outsideColor, Matrix view, Matrix proj var color = ocolor - new Vector4(0.35f) * 1.5f + new Vector4(0.35f); color.W = 1; - var wint = weather.WeatherIntensity; + var wint = Math.Min(1f, weather.WeatherIntensity); effect.LightingEnabled = false; effect.Texture = GradTex; diff --git a/TSOClient/tso.world/Model/WeatherController.cs b/TSOClient/tso.world/Model/WeatherController.cs index a56e17453..a39f38207 100644 --- a/TSOClient/tso.world/Model/WeatherController.cs +++ b/TSOClient/tso.world/Model/WeatherController.cs @@ -84,7 +84,7 @@ public void Update() var ocolor = TintColor ?? Bp.OutsideColor.ToVector4(); var color = SRGBToLinear(LinearToSRGB(ocolor) - new Vector4(0.35f) * 1.5f + new Vector4(0.35f)); color.W = 1; - var wint = WeatherIntensity; + var wint = Math.Min(1f, WeatherIntensity); FogColor = (color * new Color(0x80, 0xC0, 0xFF, 0xFF).ToVector4()) * (1 - wint * 0.75f) + LinearToSRGB(ocolor) * (wint * 0.75f); FogColor.W = (wint) * (15 * 75f) + (1 - wint) * (300f * 75f); var enabled = WorldConfig.Current.Weather;