Skip to content

Commit

Permalink
adding overwrite to sf::Packet
Browse files Browse the repository at this point in the history
et non d'un chien je hais cmake !!!
L'endianness est maintenant gérable proprement.
  • Loading branch information
germinolegrand committed May 12, 2013
1 parent 8315c60 commit 80d0e70
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion include/SFML/Network/Packet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <string>
#include <cstring>
#include <vector>


Expand Down Expand Up @@ -257,6 +258,7 @@ public :
inline void* getRawData();
inline const void* getRawData() const;
inline std::size_t getReadPos();
inline void overwrite(size_t writePos, size_t begin);

private :

Expand Down Expand Up @@ -309,6 +311,12 @@ inline std::size_t Packet::getReadPos()
return m_readPos;
}

inline void Packet::overwrite(size_t writePos, size_t begin)
{
memmove(m_data.data() + writePos, m_data.data() + begin, m_data.size() - begin);
m_data.resize(begin);
}

} // namespace sf


Expand Down Expand Up @@ -432,4 +440,4 @@ inline std::size_t Packet::getReadPos()
///
/// \see sf::TcpSocket, sf::UdpSocket
///
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////

0 comments on commit 80d0e70

Please sign in to comment.