You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 07:36:32 +09:00
Update NetPeer.MessagePools.cs
Added a null check. Had been experiencing exception throws by the internal network thread due to null-reference in this method.
This commit is contained in:
@@ -106,12 +106,23 @@ namespace Lidgren.Network
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new message for sending and writes the provided string to it
|
/// Creates a new message for sending and writes the provided string to it
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public NetOutgoingMessage CreateMessage(string content)
|
public NetOutgoingMessage CreateMessage(string content)
|
||||||
{
|
{
|
||||||
var om = CreateMessage(2 + content.Length); // fair guess
|
NetOutgoingMessage om;
|
||||||
om.Write(content);
|
|
||||||
return om;
|
// Since this could be null.
|
||||||
}
|
if (string.IsNullOrEmpty(content))
|
||||||
|
{
|
||||||
|
om = CreateMessage(1); // One byte for the internal variable-length zero byte.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
om = CreateMessage(2 + content.Length); // Fair guess.
|
||||||
|
}
|
||||||
|
|
||||||
|
om.Write(content);
|
||||||
|
return om;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new message for sending
|
/// Creates a new message for sending
|
||||||
|
|||||||
Reference in New Issue
Block a user