123456789101112131415161718192021222324252627282930313233343536 |
- #ifndef PACKET_H
- #define PACKET_H
- #include "common/network/ENet.h"
- class Packet {
- ENetPacket* packet;
- int readIndex;
- bool error;
-
- public:
- typedef char int8;
- typedef short int16;
- typedef int int32;
- static_assert(sizeof (int8) == 1, "size of int8 must be 1 byte");
- static_assert(sizeof (int16) == 2, "size of int16 must be 2 byte");
- static_assert(sizeof (int32) == 4, "size of int32 must be 4 byte");
- Packet(ENetPacket* packet);
- ~Packet();
- Packet(const Packet&) = delete;
- Packet& operator=(const Packet&) = delete;
- Packet(Packet&&) = delete;
- Packet& operator=(Packet&&) = delete;
- bool hasData() const;
- bool hasError() const;
- void read(void* buffer, int length);
- int8 read8();
- int16 read16();
- int32 read32();
- };
- #endif
|