diff --git a/src/openrct2/network/NetworkConnection.cpp b/src/openrct2/network/NetworkConnection.cpp index bcaf80a386..853d8e4999 100644 --- a/src/openrct2/network/NetworkConnection.cpp +++ b/src/openrct2/network/NetworkConnection.cpp @@ -17,6 +17,8 @@ #include "Socket.h" #include "network.h" + #include + using namespace OpenRCT2; static constexpr size_t kNetworkDisconnectReasonBufSize = 256; @@ -101,7 +103,7 @@ NetworkReadPacket NetworkConnection::ReadPacket() return NetworkReadPacket::MoreData; } -static std::vector serializePacket(const NetworkPacket& packet) +static sfl::small_vector serializePacket(const NetworkPacket& packet) { // NOTE: For compatibility reasons for the master server we need to add sizeof(Header.Id) to the size. // Previously the Id field was not part of the header rather part of the body. @@ -114,7 +116,7 @@ static std::vector serializePacket(const NetworkPacket& packet) header.Size = Convert::HostToNetwork(header.Size); header.Id = ByteSwapBE(header.Id); - std::vector buffer; + sfl::small_vector buffer; buffer.reserve(sizeof(header) + packet.Data.size()); buffer.insert(buffer.end(), reinterpret_cast(&header), reinterpret_cast(&header) + sizeof(header)); diff --git a/src/openrct2/network/NetworkPacket.h b/src/openrct2/network/NetworkPacket.h index 20f4a7cd87..a262fc1761 100644 --- a/src/openrct2/network/NetworkPacket.h +++ b/src/openrct2/network/NetworkPacket.h @@ -13,6 +13,7 @@ #include "NetworkTypes.h" #include +#include #include #pragma pack(push, 1) @@ -76,7 +77,7 @@ struct NetworkPacket final public: PacketHeader Header{}; - std::vector Data; + sfl::small_vector Data; size_t BytesTransferred = 0; size_t BytesRead = 0; };