aboutsummaryrefslogtreecommitdiff
path: root/analyzer/parser/fight_results
diff options
context:
space:
mode:
Diffstat (limited to 'analyzer/parser/fight_results')
-rw-r--r--analyzer/parser/fight_results/drif.h6
-rw-r--r--analyzer/parser/fight_results/entity.h30
-rw-r--r--analyzer/parser/fight_results/fight_results.c48
-rw-r--r--analyzer/parser/fight_results/gear.h15
-rw-r--r--analyzer/parser/fight_results/gear_info.h18
5 files changed, 84 insertions, 33 deletions
diff --git a/analyzer/parser/fight_results/drif.h b/analyzer/parser/fight_results/drif.h
index 1f8b3e2..d73e948 100644
--- a/analyzer/parser/fight_results/drif.h
+++ b/analyzer/parser/fight_results/drif.h
@@ -16,8 +16,10 @@ typedef struct {
char *field4;
int field5;
int id; // id of orb type
- float value1; // value1, value2 (in %) - one is start value, the other is value per lvl (both are the same)
- float value2; // value1, value2 (in %) - one is start value, the other is value per lvl (both are the same)
+ float value1; // value1, value2 (in %) - one is start value, the other is value per lvl (both
+ // are the same)
+ float value2; // value1, value2 (in %) - one is start value, the other is value per lvl (both
+ // are the same)
int field9;
int field10;
char *field11;
diff --git a/analyzer/parser/fight_results/entity.h b/analyzer/parser/fight_results/entity.h
index 8e082ec..4436f07 100644
--- a/analyzer/parser/fight_results/entity.h
+++ b/analyzer/parser/fight_results/entity.h
@@ -52,16 +52,22 @@ typedef struct {
} EntityResults;
static const StructField entity_fields[] = {
- {INT, offsetof(EntityResults, team)}, {STRING, offsetof(EntityResults, name)}, {INT, offsetof(EntityResults, exp)},
- {FLOAT, offsetof(EntityResults, field4)}, {INT, offsetof(EntityResults, gold)}, {FLOAT, offsetof(EntityResults, field6)},
- {STRING, offsetof(EntityResults, field7)}, {STRING, offsetof(EntityResults, gear)}, {INT, offsetof(EntityResults, field9)},
- {STRING, offsetof(EntityResults, items)}, {INT, offsetof(EntityResults, field11)}, {INT, offsetof(EntityResults, field12)},
- {FLOAT, offsetof(EntityResults, field13)}, {FLOAT, offsetof(EntityResults, field14)}, {FLOAT, offsetof(EntityResults, field15)},
- {INT, offsetof(EntityResults, level)}, {DOUBLE, offsetof(EntityResults, field17)}, {FLOAT, offsetof(EntityResults, field18)},
- {INT, offsetof(EntityResults, field19)}, {INT, offsetof(EntityResults, field20)}, {FLOAT, offsetof(EntityResults, field21)},
- {FLOAT, offsetof(EntityResults, field22)}, {INT, offsetof(EntityResults, field23)}, {INT, offsetof(EntityResults, field24)},
- {INT, offsetof(EntityResults, psycho)}, {STRING, offsetof(EntityResults, drifs)}, {INT, offsetof(EntityResults, splinters)},
- {INT, offsetof(EntityResults, field28)}, {STRING, offsetof(EntityResults, field29)}, {INT, offsetof(EntityResults, field30)},
- {INT, offsetof(EntityResults, field31)}, {INT, offsetof(EntityResults, field32)}, {INT, offsetof(EntityResults, field33)},
- {STRING, offsetof(EntityResults, field34)}, {STRING, offsetof(EntityResults, saturation)},
+ {INT, offsetof(EntityResults, team)}, {STRING, offsetof(EntityResults, name)},
+ {INT, offsetof(EntityResults, exp)}, {FLOAT, offsetof(EntityResults, field4)},
+ {INT, offsetof(EntityResults, gold)}, {FLOAT, offsetof(EntityResults, field6)},
+ {STRING, offsetof(EntityResults, field7)}, {STRING, offsetof(EntityResults, gear)},
+ {INT, offsetof(EntityResults, field9)}, {STRING, offsetof(EntityResults, items)},
+ {INT, offsetof(EntityResults, field11)}, {INT, offsetof(EntityResults, field12)},
+ {FLOAT, offsetof(EntityResults, field13)}, {FLOAT, offsetof(EntityResults, field14)},
+ {FLOAT, offsetof(EntityResults, field15)}, {INT, offsetof(EntityResults, level)},
+ {DOUBLE, offsetof(EntityResults, field17)}, {FLOAT, offsetof(EntityResults, field18)},
+ {INT, offsetof(EntityResults, field19)}, {INT, offsetof(EntityResults, field20)},
+ {FLOAT, offsetof(EntityResults, field21)}, {FLOAT, offsetof(EntityResults, field22)},
+ {INT, offsetof(EntityResults, field23)}, {INT, offsetof(EntityResults, field24)},
+ {INT, offsetof(EntityResults, psycho)}, {STRING, offsetof(EntityResults, drifs)},
+ {INT, offsetof(EntityResults, splinters)}, {INT, offsetof(EntityResults, field28)},
+ {STRING, offsetof(EntityResults, field29)}, {INT, offsetof(EntityResults, field30)},
+ {INT, offsetof(EntityResults, field31)}, {INT, offsetof(EntityResults, field32)},
+ {INT, offsetof(EntityResults, field33)}, {STRING, offsetof(EntityResults, field34)},
+ {STRING, offsetof(EntityResults, saturation)},
};
diff --git a/analyzer/parser/fight_results/fight_results.c b/analyzer/parser/fight_results/fight_results.c
index f79d113..9087f70 100644
--- a/analyzer/parser/fight_results/fight_results.c
+++ b/analyzer/parser/fight_results/fight_results.c
@@ -46,7 +46,9 @@ byte_t *find_fight_results(byte_t *bytes, size_t bytes_count, int *length) {
byte_t *start = memmem(bytes, bytes_count, FIGHT_RESULTS_START, strlen(FIGHT_RESULTS_START));
byte_t *end = NULL;
if (start)
- end = memmem(start, bytes_count - (start - bytes), FIGHT_RESULTS_END, strlen(FIGHT_RESULTS_END));
+ end = memmem(
+ start, bytes_count - (start - bytes), FIGHT_RESULTS_END, strlen(FIGHT_RESULTS_END)
+ );
*length = end ? (int)(end - start + strlen(FIGHT_RESULTS_END)) : -1;
return start;
}
@@ -73,7 +75,14 @@ void add_gear(DynArray *items, char *gears_str) {
// get gear info for rank, name and stars / syng level
GearInfo gear_info = {0};
- fill_struct(&gear_info, gear_info_fields, ARR_LEN(gear_info_fields), gear.info, strlen(gear.info), SEPARATOR_GEAR_INFO_FIELD);
+ fill_struct(
+ &gear_info,
+ gear_info_fields,
+ ARR_LEN(gear_info_fields),
+ gear.info,
+ strlen(gear.info),
+ SEPARATOR_GEAR_INFO_FIELD
+ );
// create the buffer of information about gear
char buffer[SINGLE_ITEM_BUFFER_LEN];
@@ -121,10 +130,22 @@ void add_gear(DynArray *items, char *gears_str) {
// add orb to items if it exists
if (strlen(gear.orb)) {
Orb orb = {0};
- fill_struct(&orb, orb_fields, ARR_LEN(orb_fields), gear.orb, strlen(gear.orb), SEPARATOR_ORB_FIELD);
+ fill_struct(
+ &orb,
+ orb_fields,
+ ARR_LEN(orb_fields),
+ gear.orb,
+ strlen(gear.orb),
+ SEPARATOR_ORB_FIELD
+ );
char buffer[SINGLE_ITEM_BUFFER_LEN];
- sprintf(buffer, "%sorb %s", get_artifact_size_from_id(orb.size), get_orb_name_from_id(orb.id));
+ sprintf(
+ buffer,
+ "%sorb %s",
+ get_artifact_size_from_id(orb.size),
+ get_orb_name_from_id(orb.id)
+ );
Item item = {.data = strdup(buffer), .type = ORB};
array_append(items, &item);
@@ -215,7 +236,9 @@ EnemyResults parse_to_enemy(EntityResults entity_results) {
}
ParsedData parse_fight_results(byte_t *data, size_t length) {
- ParsedData parsed_data = {.data_type = TYPE_FIGHT_RESULTS, .data_cleanup = cleanup_fight_results};
+ ParsedData parsed_data = {
+ .data_type = TYPE_FIGHT_RESULTS, .data_cleanup = cleanup_fight_results
+ };
// ignore start and end indicators
data += strlen(FIGHT_RESULTS_START);
@@ -223,8 +246,10 @@ ParsedData parse_fight_results(byte_t *data, size_t length) {
FightResults *results = safe_malloc(sizeof(FightResults));
- results->friendly_results = array_new(sizeof(FriendlyResults), INIT_ENTITIES_PER_SIDE, cleanup_friendly_results);
- results->enemy_results = array_new(sizeof(EnemyResults), INIT_ENTITIES_PER_SIDE, cleanup_enemy_results);
+ results->friendly_results =
+ array_new(sizeof(FriendlyResults), INIT_ENTITIES_PER_SIDE, cleanup_friendly_results);
+ results->enemy_results =
+ array_new(sizeof(EnemyResults), INIT_ENTITIES_PER_SIDE, cleanup_enemy_results);
byte_t *entity_separator;
do {
@@ -232,7 +257,14 @@ ParsedData parse_fight_results(byte_t *data, size_t length) {
entity_separator = memmem(data, length, SEPARATOR_ENTITY, strlen(SEPARATOR_ENTITY));
size_t len = entity_separator ? (size_t)(entity_separator - data) : length;
EntityResults entity_results = {0};
- fill_struct(&entity_results, entity_fields, ARR_LEN(entity_fields), (char *)data, len, SEPARATOR_ENTITY_FIELD);
+ fill_struct(
+ &entity_results,
+ entity_fields,
+ ARR_LEN(entity_fields),
+ (char *)data,
+ len,
+ SEPARATOR_ENTITY_FIELD
+ );
// depending on team - parse it into friendly or enemy results
switch (entity_results.team) {
diff --git a/analyzer/parser/fight_results/gear.h b/analyzer/parser/fight_results/gear.h
index 66f52f3..a311262 100644
--- a/analyzer/parser/fight_results/gear.h
+++ b/analyzer/parser/fight_results/gear.h
@@ -37,9 +37,14 @@ typedef struct {
} Gear;
static const StructField gear_fields[] = {
- {STRING, offsetof(Gear, stats)}, {STRING, offsetof(Gear, resistances)}, {STRING, offsetof(Gear, info)}, {STRING, offsetof(Gear, reqs)},
- {STRING, offsetof(Gear, field5)}, {STRING, offsetof(Gear, psycho)}, {STRING, offsetof(Gear, field7)}, {STRING, offsetof(Gear, field8)},
- {STRING, offsetof(Gear, field9)}, {STRING, offsetof(Gear, syng_tier)}, {INT, offsetof(Gear, field11)}, {INT, offsetof(Gear, field12)},
- {INT, offsetof(Gear, field13)}, {STRING, offsetof(Gear, field14)}, {INT, offsetof(Gear, type)}, {INT, offsetof(Gear, field16)},
- {STRING, offsetof(Gear, orb)}, {STRING, offsetof(Gear, field18)}, {STRING, offsetof(Gear, field19)},
+ {STRING, offsetof(Gear, stats)}, {STRING, offsetof(Gear, resistances)},
+ {STRING, offsetof(Gear, info)}, {STRING, offsetof(Gear, reqs)},
+ {STRING, offsetof(Gear, field5)}, {STRING, offsetof(Gear, psycho)},
+ {STRING, offsetof(Gear, field7)}, {STRING, offsetof(Gear, field8)},
+ {STRING, offsetof(Gear, field9)}, {STRING, offsetof(Gear, syng_tier)},
+ {INT, offsetof(Gear, field11)}, {INT, offsetof(Gear, field12)},
+ {INT, offsetof(Gear, field13)}, {STRING, offsetof(Gear, field14)},
+ {INT, offsetof(Gear, type)}, {INT, offsetof(Gear, field16)},
+ {STRING, offsetof(Gear, orb)}, {STRING, offsetof(Gear, field18)},
+ {STRING, offsetof(Gear, field19)},
};
diff --git a/analyzer/parser/fight_results/gear_info.h b/analyzer/parser/fight_results/gear_info.h
index f0cf83a..f9bd103 100644
--- a/analyzer/parser/fight_results/gear_info.h
+++ b/analyzer/parser/fight_results/gear_info.h
@@ -35,10 +35,16 @@ typedef struct {
} GearInfo;
static const StructField gear_info_fields[] = {
- {STRING, offsetof(GearInfo, name)}, {INT, offsetof(GearInfo, field2)}, {INT, offsetof(GearInfo, lvl)}, {INT, offsetof(GearInfo, price)},
- {INT, offsetof(GearInfo, field5)}, {INT, offsetof(GearInfo, field6)}, {INT, offsetof(GearInfo, field7)}, {INT, offsetof(GearInfo, rank)},
- {INT, offsetof(GearInfo, field9)}, {INT, offsetof(GearInfo, field10)}, {INT, offsetof(GearInfo, field11)}, {INT, offsetof(GearInfo, durability)},
- {STRING, offsetof(GearInfo, field13)}, {INT, offsetof(GearInfo, field14)}, {INT, offsetof(GearInfo, field15)}, {FLOAT, offsetof(GearInfo, charges)},
- {STRING, offsetof(GearInfo, field17)}, {INT, offsetof(GearInfo, field18)}, {INT, offsetof(GearInfo, stars)}, {INT, offsetof(GearInfo, field20)},
- {INT, offsetof(GearInfo, field21)}, {INT, offsetof(GearInfo, field22)}, {INT, offsetof(GearInfo, field23)},
+ {STRING, offsetof(GearInfo, name)}, {INT, offsetof(GearInfo, field2)},
+ {INT, offsetof(GearInfo, lvl)}, {INT, offsetof(GearInfo, price)},
+ {INT, offsetof(GearInfo, field5)}, {INT, offsetof(GearInfo, field6)},
+ {INT, offsetof(GearInfo, field7)}, {INT, offsetof(GearInfo, rank)},
+ {INT, offsetof(GearInfo, field9)}, {INT, offsetof(GearInfo, field10)},
+ {INT, offsetof(GearInfo, field11)}, {INT, offsetof(GearInfo, durability)},
+ {STRING, offsetof(GearInfo, field13)}, {INT, offsetof(GearInfo, field14)},
+ {INT, offsetof(GearInfo, field15)}, {FLOAT, offsetof(GearInfo, charges)},
+ {STRING, offsetof(GearInfo, field17)}, {INT, offsetof(GearInfo, field18)},
+ {INT, offsetof(GearInfo, stars)}, {INT, offsetof(GearInfo, field20)},
+ {INT, offsetof(GearInfo, field21)}, {INT, offsetof(GearInfo, field22)},
+ {INT, offsetof(GearInfo, field23)},
};