Skip to content

Commit

Permalink
PR 1641 Added method to get the current read position of sf::Packet
Browse files Browse the repository at this point in the history
  • Loading branch information
dogunbound authored and eXpl0it3r committed Jun 26, 2023
1 parent e606b52 commit 7d2ebaf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/SFML/Network/Packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ CSFML_NETWORK_API void sfPacket_destroy(sfPacket* packet);
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfPacket_append(sfPacket* packet, const void* data, size_t sizeInBytes);

////////////////////////////////////////////////////////////
/// \brief Get the current reading position in the packet
///
/// The next read operation will read data from this position
///
/// \return The byte offset of the current read position
///
/// \see append
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API size_t sfPacket_getReadPosition(const sfPacket* packet);

////////////////////////////////////////////////////////////
/// \brief Clear a packet
///
Expand Down
7 changes: 7 additions & 0 deletions src/SFML/Network/Packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ void sfPacket_append(sfPacket* packet, const void* data, size_t sizeInBytes)
}


////////////////////////////////////////////////////////////
size_t sfPacket_getReadPosition(const sfPacket* packet)
{
CSFML_CALL_RETURN(packet, getReadPosition(), 0);
}


////////////////////////////////////////////////////////////
void sfPacket_clear(sfPacket* packet)
{
Expand Down

0 comments on commit 7d2ebaf

Please sign in to comment.