mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 15:35:22 +00:00
with request resync, server should only send requesting client the info, rather than sending it to everyone
This commit is contained in:
parent
45537b8636
commit
ed14c30f9e
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user