-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c398388
commit 3d3ca79
Showing
17 changed files
with
623 additions
and
1,603 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// | ||
// Created by nickid2018 on 24-9-20. | ||
// | ||
|
||
#include <epan/conversation.h> | ||
#include "functions.h" | ||
#include "protocol/storage/storage.h" | ||
#include "protocol/protocol_data.h" | ||
|
||
extern int hf_generated; | ||
extern int hf_invalid_data; | ||
|
||
DISSECT_PROTOCOL(record_entity_id) { | ||
if (!get_settings_flag("registries") && !get_settings_flag("entities")) | ||
return 0; | ||
wmem_map_t *entity_id_record = wmem_map_lookup(get_global_data(pinfo), "#entity_id_record"); | ||
if (entity_id_record == NULL) { | ||
entity_id_record = wmem_map_new(wmem_file_scope(), g_str_hash, g_str_equal); | ||
wmem_map_insert(get_global_data(pinfo), "#entity_id_record", entity_id_record); | ||
} | ||
gchar *entity_id = wmem_map_lookup(packet_saves, "entity_id"); | ||
gchar *str_type = wmem_map_lookup(packet_saves, "entity_type"); | ||
wmem_map_insert(entity_id_record, entity_id, str_type); | ||
return 0; | ||
} | ||
|
||
DISSECT_PROTOCOL(record_entity_id_player) { | ||
if (!get_settings_flag("registries") && !get_settings_flag("entities")) | ||
return 0; | ||
wmem_map_t *entity_id_record = wmem_map_lookup(get_global_data(pinfo), "#entity_id_record"); | ||
if (entity_id_record == NULL) { | ||
entity_id_record = wmem_map_new(wmem_file_scope(), g_str_hash, g_str_equal); | ||
wmem_map_insert(get_global_data(pinfo), "#entity_id_record", entity_id_record); | ||
} | ||
gchar *entity_id = wmem_map_lookup(packet_saves, "entity_id"); | ||
wmem_map_insert(entity_id_record, entity_id, "player"); | ||
return 0; | ||
} | ||
|
||
DISSECT_PROTOCOL(record_entity_id_experience_orb) { | ||
if (!get_settings_flag("registries") && !get_settings_flag("entities")) | ||
return 0; | ||
wmem_map_t *entity_id_record = wmem_map_lookup(get_global_data(pinfo), "#entity_id_record"); | ||
if (entity_id_record == NULL) { | ||
entity_id_record = wmem_map_new(wmem_file_scope(), g_str_hash, g_str_equal); | ||
wmem_map_insert(get_global_data(pinfo), "#entity_id_record", entity_id_record); | ||
} | ||
gchar *entity_id = wmem_map_lookup(packet_saves, "entity_id"); | ||
wmem_map_insert(entity_id_record, entity_id, "experience_orb"); | ||
return 0; | ||
} | ||
|
||
DISSECT_PROTOCOL(record_entity_id_painting) { | ||
if (!get_settings_flag("registries") && !get_settings_flag("entities")) | ||
return 0; | ||
wmem_map_t *entity_id_record = wmem_map_lookup(get_global_data(pinfo), "#entity_id_record"); | ||
if (entity_id_record == NULL) { | ||
entity_id_record = wmem_map_new(wmem_file_scope(), g_str_hash, g_str_equal); | ||
wmem_map_insert(get_global_data(pinfo), "#entity_id_record", entity_id_record); | ||
} | ||
gchar *entity_id = wmem_map_lookup(packet_saves, "entity_id"); | ||
wmem_map_insert(entity_id_record, entity_id, "painting"); | ||
return 0; | ||
} | ||
|
||
DISSECT_PROTOCOL(sync_entity_data) { | ||
if (!tree || !get_settings_flag("entity_sync_datas")) | ||
return 0; | ||
wmem_map_t *entity_id_record = wmem_map_lookup(get_global_data(pinfo), "#entity_id_record"); | ||
if (entity_id_record == NULL) { | ||
entity_id_record = wmem_map_new(wmem_file_scope(), g_str_hash, g_str_equal); | ||
wmem_map_insert(get_global_data(pinfo), "#entity_id_record", entity_id_record); | ||
} | ||
gchar *entity_id = wmem_map_lookup(packet_saves, "entity_id"); | ||
char *type = wmem_map_lookup(entity_id_record, entity_id); | ||
if (type != NULL) { | ||
proto_item *item = proto_tree_add_string(tree, hf_generated, tvb, 0, 0, type); | ||
proto_item_set_generated(item); | ||
proto_item_prepend_text(item, "Entity Type"); | ||
} else { | ||
proto_item *item = proto_tree_add_string(tree, hf_generated, tvb, 0, 0, "Unknown"); | ||
proto_item_set_generated(item); | ||
proto_item_prepend_text(item, "Entity Type"); | ||
return 0; | ||
} | ||
gchar *sync_id = wmem_map_lookup(packet_saves, "sync_id"); | ||
gchar *end; | ||
int64_t sync = strtol(sync_id, &end, 10); | ||
uint32_t protocol_version = (uint64_t) wmem_map_lookup(get_global_data(pinfo), "protocol_version"); | ||
gchar *found_name = get_entity_sync_data_name(protocol_version, type, sync); | ||
if (found_name == NULL) | ||
found_name = "Unknown Sync Data!"; | ||
proto_item *item = proto_tree_add_string(tree, hf_generated, tvb, 0, 0, found_name); | ||
proto_item_set_generated(item); | ||
proto_item_prepend_text(item, "Sync Data Type"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// Created by nickid2018 on 24-9-20. | ||
// | ||
|
||
#ifndef MC_DISSECTOR_FUNCTIONS_H | ||
#define MC_DISSECTOR_FUNCTIONS_H | ||
|
||
#include "schema.h" | ||
|
||
#define DISSECT_PROTOCOL(fn) \ | ||
int32_t dissect_##fn( \ | ||
proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset, \ | ||
protocol_dissector *dissector, gchar *name, wmem_map_t *packet_saves, gchar **value \ | ||
) | ||
|
||
DISSECT_PROTOCOL(record_entity_id); | ||
|
||
DISSECT_PROTOCOL(record_entity_id_player); | ||
|
||
DISSECT_PROTOCOL(record_entity_id_experience_orb); | ||
|
||
DISSECT_PROTOCOL(record_entity_id_painting); | ||
|
||
DISSECT_PROTOCOL(sync_entity_data); | ||
|
||
#endif //MC_DISSECTOR_FUNCTIONS_H |
Oops, something went wrong.