Keep living remote contender alive when quantized CoreHpRatio rounds to 0
This commit is contained in:
parent
02ad6d68cf
commit
c4e67c951f
3 changed files with 16 additions and 3 deletions
|
|
@ -829,6 +829,17 @@ namespace RustToDust.Tests
|
|||
var clientRival = client.ViewState.Contenders[rivalSlot];
|
||||
float actualRatio = clientRival.Grid.MaxCoreHp > 0f ? clientRival.Grid.CoreHp / clientRival.Grid.MaxCoreHp : 1f;
|
||||
Assert.True(synced, $"Expected remote contender {rivalSlot} CoreHpRatio ~ {expectedRatio:F3}, got {actualRatio:F3}");
|
||||
|
||||
// Edge case: living rival at 0.30 HP rounds 8-bit CoreHpRatio to 0, yet must remain Alive on remote client
|
||||
serverRival.Grid.ApplyReplicatedDamage(0, 0, 0f, 20f, 0.30f, serverRival.Grid.HitSequence + 1);
|
||||
Assert.True(serverRival.Alive);
|
||||
bool lowHpSynced = PumpUntil(host, new[] { client }, () =>
|
||||
{
|
||||
var c = client.ViewState.Contenders[rivalSlot];
|
||||
return c.Alive && c.Grid.CoreHp > 0f && c.Grid.CoreHp <= 0.5f;
|
||||
}, ref nowMs, 2500);
|
||||
Assert.True(lowHpSynced && clientRival.Alive && !clientRival.Grid.IsDestroyed && clientRival.Grid.CoreHp > 0f,
|
||||
$"Expected living 0.30 HP rival to stay Alive on remote client, got Alive={clientRival.Alive}, CoreHp={clientRival.Grid.CoreHp:F3}");
|
||||
}
|
||||
|
||||
private static byte[] EncodeRudpLatestDatagram(byte[] frameBytes, uint sequence) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue