3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2015 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef NETWORKPACKET_HEADER
22 #define NETWORKPACKET_HEADER
24 #include "util/numeric.h"
25 #include "networkprotocol.h"
31 NetworkPacket(u8 *data, u32 datasize, u16 peer_id);
35 u32 getSize() { return m_datasize; }
36 u16 getPeerId() { return m_peer_id; }
39 char* getString(u32 from_offset);
40 NetworkPacket& operator>>(std::string& dst);
41 NetworkPacket& operator>>(std::wstring& dst);
42 std::string readLongString();
44 char getChar(u32 offset);
45 NetworkPacket& operator>>(char& dst);
47 NetworkPacket& operator>>(bool& dst);
50 NetworkPacket& operator>>(u8& dst);
52 u8* getU8Ptr(u32 offset);
53 u16 getU16(u32 from_offset);
54 NetworkPacket& operator>>(u16& dst);
55 u32 getU32(u32 from_offset);
56 NetworkPacket& operator>>(u32& dst);
57 u64 getU64(u32 from_offset);
58 NetworkPacket& operator>>(u64& dst);
60 float getF1000(u32 offset);
61 NetworkPacket& operator>>(float& dst);
62 NetworkPacket& operator>>(v2f& dst);
63 NetworkPacket& operator>>(v3f& dst);
65 s16 getS16(u32 from_offset);
66 NetworkPacket& operator>>(s16& dst);
67 s32 getS32(u32 from_offset);
68 NetworkPacket& operator>>(s32& dst);
70 NetworkPacket& operator>>(v2s32& dst);
72 v3s16 getV3S16(u32 from_offset);
73 NetworkPacket& operator>>(v3s16& dst);
75 v3s32 getV3S32(u32 from_offset);
76 NetworkPacket& operator>>(v3s32& dst);