You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-19 00:26:30 +09:00
PeekString fixed not to advance read position
This commit is contained in:
@@ -306,22 +306,10 @@ namespace Lidgren.Network
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string PeekString()
|
public string PeekString()
|
||||||
{
|
{
|
||||||
int byteLen = (int)ReadVariableUInt32();
|
int wasReadPosition = m_readPosition;
|
||||||
|
string retval = ReadString();
|
||||||
if (byteLen == 0)
|
m_readPosition = wasReadPosition;
|
||||||
return String.Empty;
|
return retval;
|
||||||
|
|
||||||
NetException.Assert(m_bitLength - m_readPosition >= (byteLen * 8), c_readOverflowError);
|
|
||||||
|
|
||||||
if ((m_readPosition & 7) == 0)
|
|
||||||
{
|
|
||||||
// read directly
|
|
||||||
string retval = System.Text.Encoding.UTF8.GetString(m_data, m_readPosition >> 3, byteLen);
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] bytes = PeekBytes(byteLen);
|
|
||||||
return System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user