fix: Updates encoded packet handler to use function pointers (#1066)
This commit is contained in:
parent
f24b98f8e2
commit
057cf87e60
6 changed files with 79 additions and 54 deletions
|
|
@ -1,26 +1,37 @@
|
|||
namespace Server.Network
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: EncodedReader.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
namespace Server.Network;
|
||||
|
||||
public ref struct EncodedReader
|
||||
{
|
||||
public ref struct EncodedReader
|
||||
{
|
||||
private CircularBufferReader m_Reader;
|
||||
private CircularBufferReader _reader;
|
||||
|
||||
public EncodedReader(CircularBufferReader reader) => m_Reader = reader;
|
||||
public EncodedReader(CircularBufferReader reader) => _reader = reader;
|
||||
|
||||
public void Trace(NetState state)
|
||||
{
|
||||
m_Reader.Trace(state);
|
||||
}
|
||||
public void Trace(NetState state) => _reader.Trace(state);
|
||||
|
||||
public int ReadInt32() => m_Reader.ReadByte() != 0 ? 0 : m_Reader.ReadInt32();
|
||||
public int ReadInt32() => _reader.ReadByte() != 0 ? 0 : _reader.ReadInt32();
|
||||
|
||||
public Point3D ReadPoint3D() => m_Reader.ReadByte() != 3
|
||||
? Point3D.Zero
|
||||
: new Point3D(m_Reader.ReadInt16(), m_Reader.ReadInt16(), m_Reader.ReadByte());
|
||||
public Point3D ReadPoint3D() => _reader.ReadByte() != 3
|
||||
? Point3D.Zero
|
||||
: new Point3D(_reader.ReadInt16(), _reader.ReadInt16(), _reader.ReadByte());
|
||||
|
||||
public string ReadUnicodeStringSafe() =>
|
||||
m_Reader.ReadByte() != 2 ? string.Empty : m_Reader.ReadBigUniSafe(m_Reader.ReadUInt16());
|
||||
public string ReadUnicodeStringSafe() =>
|
||||
_reader.ReadByte() != 2 ? string.Empty : _reader.ReadBigUniSafe(_reader.ReadUInt16());
|
||||
|
||||
public string ReadUnicodeString() =>
|
||||
m_Reader.ReadByte() != 2 ? string.Empty : m_Reader.ReadBigUni(m_Reader.ReadUInt16());
|
||||
}
|
||||
public string ReadUnicodeString() =>
|
||||
_reader.ReadByte() != 2 ? string.Empty : _reader.ReadBigUni(_reader.ReadUInt16());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue