tibia-client/src/framework/net/inputmessage.h

44 lines
955 B
C
Raw Normal View History

2011-05-21 21:02:37 +02:00
#ifndef INPUTMESSAGE_H
#define INPUTMESSAGE_H
2011-08-15 16:06:15 +02:00
#include "declarations.h"
2011-05-21 21:02:37 +02:00
class InputMessage
{
public:
enum {
2011-05-31 07:24:30 +02:00
BUFFER_MAXSIZE = 4096,
2011-05-30 05:11:12 +02:00
HEADER_POS = 0,
2011-05-21 21:02:37 +02:00
HEADER_LENGTH = 2,
2011-05-30 05:11:12 +02:00
CHECKSUM_POS = 2,
CHECKSUM_LENGTH = 4,
DATA_POS = 6,
UNENCRYPTED_DATA_POS = 8
2011-05-21 21:02:37 +02:00
};
InputMessage();
void reset();
2011-08-16 06:24:20 +02:00
uint8 getU8(bool peek = false);
uint16 getU16(bool peek = false);
uint32 getU32(bool peek = false);
uint64 getU64(bool peek = false);
2011-05-21 21:02:37 +02:00
std::string getString();
2011-08-01 06:28:41 +02:00
void skipBytes(uint16 bytes) { m_readPos += bytes; }
2011-07-28 01:01:33 +02:00
uint8* getBuffer() { return m_buffer; }
2011-05-30 05:11:12 +02:00
uint16 getMessageSize() { return m_messageSize; }
void setMessageSize(uint16 messageSize) { m_messageSize = messageSize; }
2011-08-16 06:24:20 +02:00
bool eof() { return m_readPos == m_messageSize; }
2011-05-21 21:02:37 +02:00
private:
bool canRead(int bytes);
2011-05-30 05:11:12 +02:00
uint16 m_readPos;
uint16 m_messageSize;
uint8 m_buffer[BUFFER_MAXSIZE];
2011-05-21 21:02:37 +02:00
};
#endif