Skip to content

Commit

Permalink
Core/PacketIO: Read directly into output variable for numeric ByteBuf…
Browse files Browse the repository at this point in the history
…fer::operator>> overloads
  • Loading branch information
Shauren committed Dec 19, 2024
1 parent 736836a commit 5a1fe84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/server/shared/Packets/ByteBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ ByteBufferInvalidValueException::ByteBufferInvalidValueException(char const* typ

ByteBuffer& ByteBuffer::operator>>(float& value)
{
value = read<float>();
read(&value, 1);
if (!std::isfinite(value))
throw ByteBufferInvalidValueException("float", "infinity");
return *this;
}

ByteBuffer& ByteBuffer::operator>>(double& value)
{
value = read<double>();
read(&value, 1);
if (!std::isfinite(value))
throw ByteBufferInvalidValueException("double", "infinity");
return *this;
Expand Down
16 changes: 8 additions & 8 deletions src/server/shared/Packets/ByteBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,50 +320,50 @@ class TC_SHARED_API ByteBuffer

ByteBuffer& operator>>(uint8& value)
{
value = read<uint8>();
read(&value, 1);
return *this;
}

ByteBuffer& operator>>(uint16& value)
{
value = read<uint16>();
read(&value, 1);
return *this;
}

ByteBuffer& operator>>(uint32& value)
{
value = read<uint32>();
read(&value, 1);
return *this;
}

ByteBuffer& operator>>(uint64& value)
{
value = read<uint64>();
read(&value, 1);
return *this;
}

//signed as in 2e complement
ByteBuffer& operator>>(int8& value)
{
value = read<int8>();
read(&value, 1);
return *this;
}

ByteBuffer& operator>>(int16& value)
{
value = read<int16>();
read(&value, 1);
return *this;
}

ByteBuffer& operator>>(int32& value)
{
value = read<int32>();
read(&value, 1);
return *this;
}

ByteBuffer& operator>>(int64& value)
{
value = read<int64>();
read(&value, 1);
return *this;
}

Expand Down

0 comments on commit 5a1fe84

Please sign in to comment.