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:
Joonas Rikkonen
2018-08-09 12:39:14 +03:00
parent 45939a9144
commit 7a7c92a2ce
2 changed files with 2 additions and 6 deletions

View File

@@ -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)

View File

@@ -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++)