r5sdk/r5dev/tier1/bitbuf.h
Kawe Mazidjatari 6feb41c285 Partial CNetChan class rebuild and implementation (see description)
* Adapt codebase to new class to reduce rune-like code.
* Fixed several bugs where the global CClient pointer was used instead of the instance in question to issue bans and display information about a certain client in CBanSystem and Pylon.
* Upgraded CBanSystem and Pylon to use IPv6 instead (including IPv4 mapped IPv6 addresses). This breaks all existing banlist files! All bans have to be re-issued or the existing file has to be updated to use IPv4 mapped IPv6 addresses and renamed to 'banlist.json', and moved to the root of the 'platform' folder.
2022-04-02 02:48:54 +02:00

41 lines
1.0 KiB
C++

#ifndef BITBUF_H
#define BITBUF_H
typedef enum
{
BITBUFERROR_VALUE_OUT_OF_RANGE = 0, // Tried to write a value with too few bits.
BITBUFERROR_BUFFER_OVERRUN, // Was about to overrun a buffer.
BITBUFERROR_NUM_ERRORS
} BitBufErrorType;
//-----------------------------------------------------------------------------
// Used for serialization
//-----------------------------------------------------------------------------
struct bf_write
{
public:
// How many bytes are filled in?
int GetNumBytesWritten() const;
int GetNumBitsWritten() const;
int GetMaxNumBits() const;
int GetNumBitsLeft() const;
int GetNumBytesLeft() const;
unsigned char* GetData();
const unsigned char* GetData() const;
// Has the buffer overflowed?
bool CheckForOverflow(int nBits);
bool IsOverflowed() const;
void SetOverflowFlag();
private:
unsigned __int8* m_pData;
int m_nDataBytes;
int m_nDataBits;
int m_iCurBit;
bool m_bOverflow;
bool m_bAssertOnOverflow;
const char* m_pDebugName;
};
#endif // BITBUF_H