Skip to content

Commit

Permalink
[LotView] Fix graphics during overdriven weather.
Browse files Browse the repository at this point in the history
  • Loading branch information
riperiperi committed Dec 19, 2019
1 parent 986d7cc commit 1919230
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
30 changes: 16 additions & 14 deletions TSOClient/tso.simantics/Primitives/VMInventoryOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,20 +80,22 @@ 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:
case VMInventoryOpMode.AddStackObjToInventory:
// 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) =>
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
{
Expand Down Expand Up @@ -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<int>();
var temps = context.Thread.TempRegisters;
var attrCount = Math.Min(temps[0], temps.Length - 1);
Expand All @@ -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;
Expand All @@ -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<int>();
data.Add(context.Thread.TempRegisters[0]); //index

Expand All @@ -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);
});
}
}
Expand All @@ -256,21 +258,21 @@ 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<int>();
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;

case VMInventoryOpMode.FSOGetUserID:
{
{
var mypid = target.PersistID;
var mypid = targetPID;
vm.GlobalLink.GetAccountIDFromAvatar(mypid, (userID) =>
{
vm.SendCommand(new VMNetAsyncResponseCmd(id, new VMInventoryOpState
Expand All @@ -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<int> result)
private void TokenResponse(VM vm, VMInventoryOperationsOperand op, short threadID, uint targetPID, bool success, List<int> result)
{
if (op.Mode == VMInventoryOpMode.FSOTokenEnsureGUIDExists || op.Mode == VMInventoryOpMode.FSOTokenReplaceGUIDAttributes)
{
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.world/Components/AbstractSkyDome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.world/Model/WeatherController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1919230

Please sign in to comment.