with request resync, server should only send requesting client the info, rather than sending it to everyone

This commit is contained in:
JohnCorby 2021-12-06 00:15:47 -08:00
parent 45537b8636
commit ed14c30f9e
2 changed files with 11 additions and 3 deletions

View File

@ -28,6 +28,10 @@ namespace QSB.Messaging
/// </summary>
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);
}
}
}

View File

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