diff --git a/SCHIZO/SwarmControl/MessageProcessor.cs b/SCHIZO/SwarmControl/MessageProcessor.cs index ac7f775a..3d11fdc4 100644 --- a/SCHIZO/SwarmControl/MessageProcessor.cs +++ b/SCHIZO/SwarmControl/MessageProcessor.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Net.WebSockets; using SCHIZO.Commands.Base; using SCHIZO.Commands.Context; @@ -13,6 +14,10 @@ namespace SCHIZO.SwarmControl; internal sealed class MessageProcessor { private readonly ControlWebSocket _socket; + + //private readonly Dictionary _redeems = []; + private readonly Dictionary _results = []; + public MessageProcessor(ControlWebSocket socket) { _socket = socket; @@ -74,6 +79,13 @@ private void OnRedeem(RedeemMessage msg) SendResult(guid, false, "Command not found"); return; } + // prevents server replaying redeems in case we receive one but the game doesn't acknowledge it or something (so the server thinks it didn't send and replays it later) + // ...but we do still want to be able to replay manually + if (msg.Source == CommandInvocationSource.Swarm && _results.TryGetValue(guid, out ResultMessage? result)) + { + _socket.SendMessage(result); + return; + } JsonContext ctx = new() { @@ -138,11 +150,13 @@ private void SendHello() private void SendResult(Guid guid, bool success, string? message = null) { - _socket.SendMessage(new ResultMessage() + ResultMessage msg = new() { Guid = guid, Success = success, Message = message - }); + }; + _results[msg.Guid] = msg; + _socket.SendMessage(msg); } } diff --git a/SCHIZO/SwarmControl/SwarmControlManager.cs b/SCHIZO/SwarmControl/SwarmControlManager.cs index 4df898f2..47c0b2e6 100644 --- a/SCHIZO/SwarmControl/SwarmControlManager.cs +++ b/SCHIZO/SwarmControl/SwarmControlManager.cs @@ -46,6 +46,7 @@ public string PrivateApiKey && !Player.main.IsPilotingSeatruck() #endif && !Player.main.IsInBase() + && !Player.main.cinematicModeActive //&& Time.timeScale > 0 ;