remove OnlySendToSpecific, just use uint.MaxValue to denote no ForId

This commit is contained in:
JohnCorby 2021-12-06 00:11:55 -08:00
parent 4b4c142e20
commit 45537b8636
2 changed files with 8 additions and 19 deletions

View File

@ -65,7 +65,7 @@ namespace QSB.Events
{
_eventHandler.SendToHost(message);
}
else if (message.OnlySendToSpecific)
else if (message.ForId != uint.MaxValue)
{
_eventHandler.SendTo(message.ForId, message);
}

View File

@ -22,14 +22,11 @@ namespace QSB.Messaging
public bool OnlySendToHost { get; set; }
/// <summary>
/// If true, only send this message to ForId
/// The Player ID that this message is for.
/// By default, this is uint.MaxValue,
/// which means this is ignored and the message is sent to all clients
/// </summary>
public bool OnlySendToSpecific { get; set; }
/// <summary>
/// The Player ID that this message is for
/// </summary>
public uint ForId { get; set; }
public uint ForId { get; set; } = uint.MaxValue;
public override void Deserialize(QNetworkReader reader)
{
@ -38,11 +35,7 @@ namespace QSB.Messaging
OnlySendToHost = reader.ReadBoolean();
if (!OnlySendToHost)
{
OnlySendToSpecific = reader.ReadBoolean();
if (OnlySendToSpecific)
{
ForId = reader.ReadUInt32();
}
reader.ReadUInt32();
}
}
@ -52,13 +45,9 @@ namespace QSB.Messaging
writer.Write(AboutId);
writer.Write(OnlySendToHost);
if (!OnlySendToHost)
{
writer.Write(OnlySendToSpecific);
if (OnlySendToSpecific)
{
writer.Write(ForId);
}
}
}
}
}