aboutsummaryrefslogtreecommitdiff
path: root/analyzer/parser/fight_results.h
blob: 76083ab7aa794bcf43a0ea9c8d410056529795d5 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// parser/fight_results.h
// utilities for parsing the fight results data

#include "parser/parser_defs.h"
#include "utils/tcp.h"

#ifndef FIGHT_RESULTS_H
#define FIGHT_RESULTS_H

// Payload structure:
// FIGHT_RESULTS_START EntityResults (SEPARATOR_ENTITY EntityResults)* FIGHT_RESULTS_END
#define FIGHT_RESULTS_START "3;19;"
#define FIGHT_RESULTS_END "[--];"
#define SEPARATOR_ENTITY "[--]"
#define SEPARATOR_RESULT "&"

// EntityResults structure:
// field (SEPARATOR_RESULT field)*
// fields are defined in order in the EntityResults struct
#define ENTITY_FIELD_COUNT 35
// clang-format off
#define ENTITY_FIELD_TYPES { \
    /* team */       INT,    \
    /* name */       STRING, \
    /* exp */        INT,    \
    /* field4 */     FLOAT,  \
    /* gold */       INT,    \
    /* field6 */     FLOAT,  \
    /* field7 */     STRING, \
    /* gear */       STRING, \
    /* field9 */     INT,    \
    /* items */      STRING, \
    /* field11 */    INT,    \
    /* field12 */    INT,    \
    /* field13 */    FLOAT,  \
    /* field14 */    FLOAT,  \
    /* field15 */    FLOAT,  \
    /* level */      INT,    \
    /* field17 */    DOUBLE, \
    /* field18 */    FLOAT,  \
    /* field19 */    INT,    \
    /* field20 */    INT,    \
    /* field21 */    FLOAT,  \
    /* field22 */    FLOAT,  \
    /* field23 */    INT,    \
    /* field24 */    INT,    \
    /* psycho */     INT,    \
    /* drifs */      STRING, \
    /* splinters */  INT,    \
    /* field28 */    INT,    \
    /* field29 */    STRING, \
    /* field30 */    INT,    \
    /* field31 */    INT,    \
    /* field32 */    INT,    \
    /* field33 */    INT,    \
    /* field34 */    STRING, \
    /* saturation */ STRING  \
}
#define ENTITY_FIELD_ADDRESSES(entity_results) {\
    &entity_results.team,      \
    &entity_results.name,      \
    &entity_results.exp,       \
    &entity_results.field4,    \
    &entity_results.gold,      \
    &entity_results.field6,    \
    &entity_results.field7,    \
    &entity_results.gear,      \
    &entity_results.field9,    \
    &entity_results.items,     \
    &entity_results.field11,   \
    &entity_results.field12,   \
    &entity_results.field13,   \
    &entity_results.field14,   \
    &entity_results.field15,   \
    &entity_results.level,     \
    &entity_results.field17,   \
    &entity_results.field18,   \
    &entity_results.field19,   \
    &entity_results.field20,   \
    &entity_results.field21,   \
    &entity_results.field22,   \
    &entity_results.field23,   \
    &entity_results.field24,   \
    &entity_results.psycho,    \
    &entity_results.drifs,     \
    &entity_results.splinters, \
    &entity_results.field28,   \
    &entity_results.field29,   \
    &entity_results.field30,   \
    &entity_results.field31,   \
    &entity_results.field32,   \
    &entity_results.field33,   \
    &entity_results.field34,   \
    &entity_results.saturation \
}
// clang-format on
typedef struct {
    int team; // friend or enemy
    char *name;
    int exp;
    float field4;
    int gold;
    float field6;
    char *field7;
    char *gear; // rares, sets, syngs, orbs
    int field9;
    char *items; // regular items
    int field11;
    int field12;
    float field13;
    float field14; // some multiplier most likely exp/gold/psycho/something else idk
    float field15;
    int level;
    double field17;
    float field18;
    int field19;
    int field20;
    float field21;
    float field22;
    int field23;
    int field24;
    int psycho;
    char *drifs;
    int splinters;
    int field28;
    char *field29;
    int field30;
    int field31;
    int field32;
    int field33;
    char *field34;
    char *saturation;
} EntityResults;

// items/gear/drifs fields parsing info
#define INIT_ITEMS_CAPACITY 8
#define SINGLE_ITEM_BUFFER_LEN 128
#define SEPARATOR_ITEMS "[-]"
#define SEPARATOR_DRIFS "???" // TODO: change it to correct one which idk at this moment
#define SEPARATOR_DRIF_INFO ","
// Item struct - for keeping item string and type
typedef enum { NORMAL, DRIF, SYNG, SET, RARE, EPIC } ItemType;
typedef struct {
    char *data;
    ItemType type;
} Item;

// Drif structure:
// field (SEPARATOR_DRIF field)*
// fields are defined in order in the Drif struct
#define DRIF_FIELD_COUNT 19
// clang-format off
#define DRIF_FIELD_TYPES { \
    /* field1 */  STRING, \
    /* field2 */  INT,    \
    /* field3 */  INT,    \
    /* field4 */  STRING, \
    /* field5 */  INT,    \
    /* field6 */  INT,    \
    /* field7 */  FLOAT,  \
    /* field8 */  FLOAT,  \
    /* field9 */  INT,    \
    /* field10 */ INT,    \
    /* field11 */ STRING, \
    /* field12 */ STRING, \
    /* field13 */ INT,    \
    /* field14 */ INT,    \
    /* field15 */ INT,    \
    /* field16 */ INT,    \
    /* name */    STRING, \
    /* field18 */ STRING, \
    /* field19 */ STRING, \
}
#define DRIF_FIELD_ADDRESSES(drif) {\
    &drif.field1,  \
    &drif.field2,  \
    &drif.field3,  \
    &drif.field4,  \
    &drif.field5,  \
    &drif.field6,  \
    &drif.field7,  \
    &drif.field8,  \
    &drif.field9,  \
    &drif.field10, \
    &drif.field11, \
    &drif.field12, \
    &drif.field13, \
    &drif.field14, \
    &drif.field15, \
    &drif.field16, \
    &drif.name,    \
    &drif.field18, \
    &drif.field19, \
}
// clang-format on
typedef struct {
    char *field1;
    int field2;
    int field3;
    char *field4;
    int field5;
    int field6;
    float field7;
    float field8;
    int field9;
    int field10;
    char *field11;
    char *field12;
    int field13;
    int field14;
    int field15;
    int field16;
    char *name; // <size>drif <name>
    char *field18;
    char *field19;
} Drif;

// values of field "team"
#define TEAM_FRIEND 1
#define TEAM_ENEMY 2

// fight results data for friendly
typedef struct {
    char *name;
    int exp;
    int gold;
    Item *items;
    size_t num_items;
    int level;
    int psycho;
    int splinters;
    char *saturation_type;
    int saturation;
} FriendlyResults;

// fight results data for enemy
typedef struct {
    char *name;
    int level;
} EnemyResults;

#define MAX_ENTITIES_PER_SIDE 8

// entire fight resutls
typedef struct {
    size_t num_friendly;
    FriendlyResults friendly_results[MAX_ENTITIES_PER_SIDE];
    size_t num_enemy;
    EnemyResults enemy_results[MAX_ENTITIES_PER_SIDE];
} FightResults;

extern find_function_t find_fight_results;
extern parse_function_t parse_fight_results;

#endif