mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-27 12:35:28 +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>
|
/// </summary>
|
||||||
public uint ForId { get; set; } = uint.MaxValue;
|
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)
|
public override void Deserialize(QNetworkReader reader)
|
||||||
{
|
{
|
||||||
FromId = reader.ReadUInt32();
|
FromId = reader.ReadUInt32();
|
||||||
@ -46,7 +50,7 @@ namespace QSB.Messaging
|
|||||||
writer.Write(OnlySendToHost);
|
writer.Write(OnlySendToHost);
|
||||||
if (!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)
|
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)
|
if (isHost)
|
||||||
{
|
{
|
||||||
|
PlayerMessage.ForIdOverride = message.FromId;
|
||||||
|
|
||||||
QSBEventManager.FireEvent(EventNames.QSBServerState, ServerStateManager.Instance.GetServerState());
|
QSBEventManager.FireEvent(EventNames.QSBServerState, ServerStateManager.Instance.GetServerState());
|
||||||
QSBEventManager.FireEvent(EventNames.QSBPlayerInformation);
|
QSBEventManager.FireEvent(EventNames.QSBPlayerInformation);
|
||||||
|
|
||||||
SendWorldObjectInfo();
|
SendWorldObjectInfo();
|
||||||
|
|
||||||
|
PlayerMessage.ForIdOverride = uint.MaxValue;
|
||||||
}
|
}
|
||||||
// if client, send player and client states
|
// if client, send player and client states TO EVERYONE
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QSBEventManager.FireEvent(EventNames.QSBPlayerInformation);
|
QSBEventManager.FireEvent(EventNames.QSBPlayerInformation);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user