Server writes item condition at full accuracy instead of just using 8 bits. The more inaccurate condition caused issues when the value was just above some specific threshold (e.g. minimum condition for a fabricator ingredient) server-side and below it client-side. Closes #616
This commit is contained in:
@@ -381,8 +381,7 @@ namespace Barotrauma
|
||||
(components[containerIndex] as ItemContainer).Inventory.ClientRead(type, msg, sendingTime);
|
||||
break;
|
||||
case NetEntityEvent.Type.Status:
|
||||
condition = msg.ReadRangedSingle(0.0f, prefab.Health, 8);
|
||||
|
||||
condition = msg.ReadSingle();
|
||||
if (FixRequirements.Count > 0)
|
||||
{
|
||||
if (Condition <= 0.0f)
|
||||
|
||||
@@ -1375,10 +1375,7 @@ namespace Barotrauma
|
||||
(components[containerIndex] as ItemContainer).Inventory.ServerWrite(msg, c);
|
||||
break;
|
||||
case NetEntityEvent.Type.Status:
|
||||
//clamp to (MaxHealth / 255.0f) if condition > 0.0f
|
||||
//to prevent condition from being rounded down to 0.0 even if the item is not broken
|
||||
msg.WriteRangedSingle(condition > 0.0f ? Math.Max(condition, prefab.Health / 255.0f) : 0.0f, 0.0f, prefab.Health, 8);
|
||||
|
||||
msg.Write(condition);
|
||||
if (condition <= 0.0f && FixRequirements.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < FixRequirements.Count; i++)
|
||||
|
||||
Reference in New Issue
Block a user