-
Notifications
You must be signed in to change notification settings - Fork 2
/
protocol_tree_internal.h
66 lines (59 loc) · 2.51 KB
/
protocol_tree_internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#include "mcpc.h"
extern int
hf_string_length,
hf_player_name,
hf_uuid,
hf_compression_trxld,
hf_protocol_version,
hf_hs_next_state,
hf_server_address,
hf_entity_id,
hf_difficulty,
hf_resourcepack_state,
hf_channel_name,
hf_chunk_x,
hf_chunk_z,
hf_pos_x,
hf_pos_y,
hf_pos_z,
hf_metadata,
hf_metadata_index,
hf_metadata_type,
hf_size,
hf_primary_bit_mask,
hf_bits_per_block,
hf_section_number,
hf_palette,
hf_palette_length;
#define CUSTOM_STR_TO_TREE(tree, format) varlen=VarIntToUint(data+readed, &varint, length-readed);\
{gchar *name=wmem_alloc(wmem_packet_scope(), varint+1);\
memcpy(name, data+readed+varlen, varint);\
name[varint]=0x00;\
proto_item *string_item=proto_tree_add_item(tree, proto_mcpc, tvb, readed, varint+varlen, FALSE);\
proto_item_set_text(string_item, format, name);\
proto_tree_add_uint(\
proto_item_add_subtree(string_item, ett_strlen),\
hf_string_length, tvb, (gint)readed, varlen, varint);\
\
wmem_free(wmem_packet_scope(), name);}\
readed+=varlen+varint
#define STR_TO_TREE(tree, to_hf) varlen=VarIntToUint(data+readed, &varint, length-readed);\
{gchar *name=wmem_alloc(wmem_packet_scope(), varint+1);\
memcpy(name, data+readed+varlen, varint);\
name[varint]=0x00;\
proto_tree_add_uint(\
proto_item_add_subtree(\
proto_tree_add_string(tree, to_hf, tvb, readed, varint+varlen, name),\
ett_strlen),\
hf_string_length, tvb, (gint)readed, varlen, varint);\
wmem_free(wmem_packet_scope(), name);}\
readed+=varlen+varint
#define POS_TO_TREE(tree) proto_tree_add_double(tree, hf_pos_x, tvb, readed, 8, (double)be64toh(*(const uint64_t*)(data+readed)));\
readed+=8;\
proto_tree_add_double(tree, hf_pos_y, tvb, readed, 8, (double)be64toh(*(const uint64_t*)(data+readed)));\
readed+=8;\
proto_tree_add_double(tree, hf_pos_z, tvb, readed, 8, (double)be64toh(*(const uint64_t*)(data+readed)));\
readed+=8
//Skip UUID
#define UUID_TO_TREE(tree) readed+=16