From c8d9178937239f25bfc1f2d5b063d5204022f449 Mon Sep 17 00:00:00 2001 From: AleaJactaEst Date: Thu, 12 Dec 2019 17:32:49 +0100 Subject: [PATCH] read msg.xml --- assets/Definition/msg.xml | 1165 +++++++++++++++++++++++ assets/Scripts/Definition/msg.gd | 59 ++ assets/Scripts/Network/net_low_level.gd | 8 + assets/Scripts/Tools/hexa.gd | 62 ++ export_presets.cfg | 49 + project.godot | 1 + 6 files changed, 1344 insertions(+) create mode 100644 assets/Definition/msg.xml create mode 100644 assets/Scripts/Definition/msg.gd create mode 100644 assets/Scripts/Tools/hexa.gd create mode 100644 export_presets.cfg diff --git a/assets/Definition/msg.xml b/assets/Definition/msg.xml new file mode 100644 index 0000000..5fb971a --- /dev/null +++ b/assets/Definition/msg.xml @@ -0,0 +1,1165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/Scripts/Definition/msg.gd b/assets/Scripts/Definition/msg.gd new file mode 100644 index 0000000..f8a008d --- /dev/null +++ b/assets/Scripts/Definition/msg.gd @@ -0,0 +1,59 @@ +extends Node + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +var _msg_xml = XMLParser.new() +var _msg_md5sum + +func open_message_xml(): + var file = File.new() + file.open("res://assets/Definition/msg.xml", File.READ) + var content = file.get_as_text() + _msg_md5sum = content.md5_text() + file.close() + _msg_xml.open("res://assets/Definition/msg.xml") + print("[msg:open_message_xml] " + _msg_md5sum) + +func is_correct_md5(value): + return (_msg_md5sum == value) + +func read_all_node(): + var i + _msg_xml.seek(0) + var ret = _msg_xml.read() + var branch = "" + var leaf = "" + while ret == OK: + #print("Node: Name:" + _msg_xml.get_node_name() + ", Type:" + str(_msg_xml.get_node_type()) + ", Data:" + str(_msg_xml.get_node_data()) + ", attribut count:" + str(_msg_xml.get_attribute_count()) ) + #i = 0 + #while i < _msg_xml.get_attribute_count(): + # print(" -- Attribut Name:" + _msg_xml.get_attribute_name(i) + " Value:" + _msg_xml.get_attribute_value(i)) + # i += 1 + match _msg_xml.get_node_name(): + "branch": + i = 0 + while i < _msg_xml.get_attribute_count() and _msg_xml.get_attribute_name(i) != "name": + i += 1 + if i < _msg_xml.get_attribute_count(): + print(_msg_xml.get_attribute_value(i)) + branch = _msg_xml.get_attribute_value(i) + "leaf": + i = 0 + while i < _msg_xml.get_attribute_count() and _msg_xml.get_attribute_name(i) != "name": + i += 1 + if i < _msg_xml.get_attribute_count(): + print(branch + ":" + _msg_xml.get_attribute_value(i)) + + + ret = _msg_xml.read() + +# Called when the node enters the scene tree for the first time. +func _ready(): + open_message_xml() + read_all_node() + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/assets/Scripts/Network/net_low_level.gd b/assets/Scripts/Network/net_low_level.gd index 96e0d2e..88aec39 100644 --- a/assets/Scripts/Network/net_low_level.gd +++ b/assets/Scripts/Network/net_low_level.gd @@ -136,6 +136,7 @@ func send_system_ack_probe(): return func send_system_quit(): + # TODO - check why we send quit_id var msgout = preload("res://bitstream.gdns").new() _quit_id += 1 msgout.put_sint32(_current_received_number) @@ -183,6 +184,7 @@ func decode_system_message(msgin): CLFECOMMON.SYSTEM_LOGIN_CODE: pass CLFECOMMON.SYSTEM_SYNC_CODE: + var hexa = load("res://assets/Scripts/Tools/hexa.gd").new() var synchronize = msgin.get_uint32() var stime = msgin.get_sint64() _latest_sync = msgin.get_uint32() @@ -193,10 +195,16 @@ func decode_system_message(msgin): for item in msg_xml: num += str(item) + "." print(num) + print(hexa.ArrayIntToStringHexa(msg_xml)) num = "" for item in database_xml: num += str(item) + "." print(num) + print(hexa.ArrayIntToStringHexa(database_xml)) + if not msg.is_correct_md5(hexa.ArrayIntToStringHexa(msg_xml)): + print("[net_low_level:analyze_message_received] Wrong MD5 for msg.xml") + # TODO - we need quit with message error and go to login + return send_system_sync() CLFECOMMON.SYSTEM_STALLED_CODE: pass diff --git a/assets/Scripts/Tools/hexa.gd b/assets/Scripts/Tools/hexa.gd new file mode 100644 index 0000000..5584f49 --- /dev/null +++ b/assets/Scripts/Tools/hexa.gd @@ -0,0 +1,62 @@ +extends Node + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + +func HexaArray(value): + match value: + 0: + return "0" + 1: + return "1" + 2: + return "2" + 3: + return "3" + 4: + return "4" + 5: + return "5" + 6: + return "6" + 7: + return "7" + 8: + return "8" + 9: + return "9" + 10: + return "a" + 11: + return "b" + 12: + return "c" + 13: + return "d" + 14: + return "e" + 15: + return "f" + _: + return "?" + +func IntToStringHexa(value): + var ret = "" + ret += HexaArray(value >> 4) + ret += HexaArray(value & 15) + return ret + +func ArrayIntToStringHexa(array_int): + var ret = "" + for data in array_int: + ret += IntToStringHexa(data) + return ret \ No newline at end of file diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..8645d72 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,49 @@ +[preset.0] + +name="khaganat.linux.64" +platform="Linux/X11" +runnable=true +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="" +patch_list=PoolStringArray( ) +script_export_mode=1 +script_encryption_key="" + +[preset.0.options] + +texture_format/bptc=false +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +texture_format/no_bptc_fallbacks=true +binary_format/64_bits=true +custom_template/release="" +custom_template/debug="" + +[preset.1] + +name="khaganat.linux.32" +platform="Linux/X11" +runnable=true +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="" +patch_list=PoolStringArray( ) +script_export_mode=1 +script_encryption_key="" + +[preset.1.options] + +texture_format/bptc=false +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +texture_format/no_bptc_fallbacks=true +binary_format/64_bits=false +custom_template/release="" +custom_template/debug="" diff --git a/project.godot b/project.godot index 29fafa8..5bf0fde 100644 --- a/project.godot +++ b/project.godot @@ -25,6 +25,7 @@ config/icon="res://icon.png" global="*res://global.tscn" character="*res://game_scene/Game/Character/Character.tscn" net_low_level="*res://assets/Scripts/Network/net_low_level.gd" +msg="*res://assets/Scripts/Definition/msg.gd" [display]