From: miniduikboot Date: Mon, 5 Jul 2021 17:37:19 +0000 (+0200) Subject: Stop cancelling initial Airship spawn SnapTo RPC X-Git-Tag: v1.5.0~5^2 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=241e8673435ffb099b7cd1a9ab8c03a23a456ccb;p=rhonda%2Fimpostor.git Stop cancelling initial Airship spawn SnapTo RPC This is used to hide players that are still selecting their spawn location. If this is cancelled, players are left standing at the location they were at when the last meeting was called, which is undesirable. --- diff --git a/src/Impostor.Server/Net/Inner/Objects/Components/InnerCustomNetworkTransform.cs b/src/Impostor.Server/Net/Inner/Objects/Components/InnerCustomNetworkTransform.cs index 8d92d50..6b2b131 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Components/InnerCustomNetworkTransform.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Components/InnerCustomNetworkTransform.cs @@ -26,7 +26,7 @@ namespace Impostor.Server.Net.Inner.Objects.Components private readonly ObjectPool _pool; private ushort _lastSequenceId; - private bool _spawnSnapAllowed; + private AirshipSpawnState _spawnState; public InnerCustomNetworkTransform(ICustomMessageManager customMessageManager, Game game, ILogger logger, InnerPlayerControl playerControl, IEventManager eventManager, ObjectPool pool) : base(customMessageManager, game) { @@ -36,6 +36,13 @@ namespace Impostor.Server.Net.Inner.Objects.Components _pool = pool; } + private enum AirshipSpawnState : byte + { + PreSpawn, + SelectingSpawn, + Spawned, + } + public Vector2 Position { get; private set; } public Vector2 Velocity { get; private set; } @@ -98,15 +105,17 @@ namespace Impostor.Server.Net.Inner.Objects.Components if (Game.GameNet.ShipStatus is InnerAirshipStatus airshipStatus) { - // As part of airship spawning, clients are sending snap to -25 40 for no reason(?), cancelling it works just fine - if (Approximately(position, airshipStatus.PreSpawnLocation)) + // As part of airship spawning, clients are sending snap to -25 40 to move themself out of view + if (_spawnState == AirshipSpawnState.PreSpawn && Approximately(position, airshipStatus.PreSpawnLocation)) { - return false; + _spawnState = AirshipSpawnState.SelectingSpawn; + return true; } - if (_spawnSnapAllowed && airshipStatus.SpawnLocations.Any(location => Approximately(position, location))) + // Once the spawn has been selected, the client sends a second snap to the select spawn location + if (_spawnState == AirshipSpawnState.SelectingSpawn && airshipStatus.SpawnLocations.Any(location => Approximately(position, location))) { - _spawnSnapAllowed = false; + _spawnState = AirshipSpawnState.Spawned; return true; } } @@ -152,7 +161,7 @@ namespace Impostor.Server.Net.Inner.Objects.Components internal void OnPlayerSpawn() { - _spawnSnapAllowed = true; + _spawnState = AirshipSpawnState.PreSpawn; } private static bool SidGreaterThan(ushort newSid, ushort prevSid)