diff --git a/QSB/Messaging/PlayerMessage.cs b/QSB/Messaging/PlayerMessage.cs index b14eb553..1be3da98 100644 --- a/QSB/Messaging/PlayerMessage.cs +++ b/QSB/Messaging/PlayerMessage.cs @@ -28,6 +28,10 @@ namespace QSB.Messaging /// public uint ForId { get; set; } = uint.MaxValue; + /// used to force set ForId. + /// primarily used for state resyncing, when the server needs to send a specific client a bunch of events + public static uint ForIdOverride = uint.MaxValue; + public override void Deserialize(QNetworkReader reader) { FromId = reader.ReadUInt32(); @@ -46,7 +50,7 @@ namespace QSB.Messaging writer.Write(OnlySendToHost); if (!OnlySendToHost) { - writer.Write(ForId); + writer.Write(ForIdOverride != uint.MaxValue ? ForIdOverride : ForId); } } } diff --git a/QSB/Player/Events/RequestStateResyncEvent.cs b/QSB/Player/Events/RequestStateResyncEvent.cs index 3d8cd289..57d0a231 100644 --- a/QSB/Player/Events/RequestStateResyncEvent.cs +++ b/QSB/Player/Events/RequestStateResyncEvent.cs @@ -30,15 +30,19 @@ namespace QSB.Player.Events public override void OnReceiveRemote(bool isHost, PlayerMessage message) { - // if host, send worldobject and server states + // if host, send worldobject and server states TO THE REQUESTING CLIENT if (isHost) { + PlayerMessage.ForIdOverride = message.FromId; + QSBEventManager.FireEvent(EventNames.QSBServerState, ServerStateManager.Instance.GetServerState()); QSBEventManager.FireEvent(EventNames.QSBPlayerInformation); SendWorldObjectInfo(); + + PlayerMessage.ForIdOverride = uint.MaxValue; } - // if client, send player and client states + // if client, send player and client states TO EVERYONE else { QSBEventManager.FireEvent(EventNames.QSBPlayerInformation);