Fix crash on moving empty NetPacket
This commit is contained in:
@@ -27,6 +27,8 @@ namespace Nz
|
||||
ByteStream(ByteStream&& stream) noexcept = default;
|
||||
virtual ~ByteStream();
|
||||
|
||||
inline void ClearStream();
|
||||
|
||||
inline Endianness GetDataEndianness() const;
|
||||
inline Nz::UInt64 GetSize() const;
|
||||
inline Stream* GetStream() const;
|
||||
|
||||
@@ -30,6 +30,18 @@ namespace Nz
|
||||
NazaraWarning("Failed to flush bits at serializer destruction");
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Reset stream
|
||||
*/
|
||||
inline void ByteStream::ClearStream()
|
||||
{
|
||||
// We don't want to lose some bits..
|
||||
FlushBits();
|
||||
|
||||
m_context.stream = nullptr;
|
||||
m_ownedStream.reset();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the stream endianness
|
||||
* \return Type of the endianness
|
||||
@@ -113,22 +125,15 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets this with a stream
|
||||
* \brief Changes stream
|
||||
*
|
||||
* \param stream Stream existing
|
||||
*
|
||||
* \remark Produces a NazaraAssert if stream is invalid
|
||||
*/
|
||||
|
||||
inline void ByteStream::SetStream(Stream* stream)
|
||||
{
|
||||
NazaraAssert(stream, "Invalid stream");
|
||||
|
||||
// We don't want to lose some bits..
|
||||
FlushBits();
|
||||
ClearStream();
|
||||
|
||||
m_context.stream = stream;
|
||||
m_ownedStream.reset();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user