diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bcee8f3..cf4707a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,6 +31,39 @@ variables: XDG_CONFIG_HOME: '/tmp/config' DOCKER_GODOT_SOURCE: '/root/workspace/godot/' +Build Client Linux 64 (Quater): + # ERROR: _load: No loader found for resource: res://assets/GUI/images/Login-Khanat-background.png + stage: build + tags: + - Docker + image: amd64/debian:10 + script: + - export -p WORKDIR=$PWD + - apt-get update + - apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y scons git g++ wget unzip ca-certificates python python-openssl + - DEBIAN_FRONTEND=noninteractive apt-get install -y xvfb libxcursor1 libxinerama1 libxrandr2 libxi6 libasound2 libpulse0 libgl1 mesa-utils libgl1-mesa-dri libasound2 libasound2-plugins alsa-utils alsa-oss pulseaudio pulseaudio-utils + - DEBIAN_FRONTEND=noninteractive apt-get install -y xterm libxcursor1 xcursor-themes icon-slicer libpulse0 + - DEBIAN_FRONTEND=noninteractive apt-get install -y lxde strace + - DEBIAN_FRONTEND=noninteractive apt-get install -y task-gnome-desktop + - DEBIAN_FRONTEND=noninteractive apt-get install -y xvfb libxcursor-dev libxinerama1 libxrandr2 libxi6 libasound2 libpulse0 libgl1-mesa-glx + - DEBIAN_FRONTEND=noninteractive apt-get install -y x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps + - mkdir -p build + - (cd build; git clone https://github.com/godotengine/godot.git && cd godot && git checkout 3.2) + - (cd build/godot; for file in ../../../modules/*; do if [ -d $file ];then ln -s $file .; fi; done) + - (cd build/godot; cp modules/*/doc_classes/* doc/classes/.) + - (cd build/godot; scons -j$(nproc) platform=x11) + - build/godot/bin/godot --editor --quit + - build/godot/bin/godot --quit -v --path $WORKDIR --export khaganat.linux.64 khaganat.linux64.bin + - ls -la assets/GUI/images/ + - ls -la .import/ || echo "" + - ls -la || echo "" + artifacts: + name: "khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-client-linux-64" + paths: + - khaganat.linux64.* + when: manual + Build Client Linux 64 (Ter): # ERROR: _load: No loader found for resource: res://assets/GUI/images/Login-Khanat-background.png stage: build diff --git a/README.md b/README.md index a0fb74e..b2437d0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Build -Before build and launch client, we need build godot-cpp (lib to connect c++ code to godot engine) and build crypt (c++ module use to authentification with khaganat) +Before build and launch client, build module (before, we need include modules on godot source) ## Build module @@ -31,7 +31,8 @@ cp modules/*/doc_classes/* doc/classes/. # Clean project (if you build before) scons -j$(nproc) -c # Build -scons -j$(nproc) platform=x11 +scons -j$(nproc) platform=x11 target=debug +scons -j$(nproc) platform=x11 target=release_debug cd ../.. ``` @@ -51,46 +52,6 @@ bin/godot.x11.tools.64 cd ../.. ``` -## Build godot-cpp - -### Initialize - -Load git submodule (godot-cpp & godot_header) - -``` -git submodule update --init --recursive -``` - -### Build on 64bits - -``` -godot --gdnative-generate-json-api godot-cpp/godot_headers/api.json -scons -C godot-cpp platform=linux generate_bindings=yes custom_api_file=godot_headers/api.json bits=64 -``` - -### Build on 32bits - -``` -godot --gdnative-generate-json-api godot-cpp/godot_headers/api.json -scons -C godot-cpp platform=linux generate_bindings=yes custom_api_file=godot_headers/api.json bits=32 -``` - -## Build gdnative (crypt / bitstream / bitset) - -### Build on 64bits - -``` -scons -C gdnative platform=linux bits=64 target=debug -scons -C gdnative platform=linux bits=64 target=release -``` - -### Build on 32bits - -``` -scons -C gdnative platform=linux bits=32 target=debug -scons -C gdnative platform=linux bits=64 target=release -``` - ## Package client khaganat ### Configure export @@ -137,3 +98,93 @@ godot --path . --export khaganat.linux.64 khaganat.linux64.bin ``` godot login_scene/login_scene.tsc ``` + + + +## Library + +### NetworkConnection + +NetworkConnection -> class to manage/use NetworkConnectionCore + All times, connect on NetworkConnectionCore (to get singleton) and launch function + The goal is to don't managed Singleton, this class manage + At end of program, you need execute function "terminate_network_connection" to remove singleton. + + +NetworkConnectionCore -> class Singleton (uniq object) [contains network connexion, state connexion] + _state_connexion[StateConnectionBase] : Object change class with state connexion [StateConnectionNotInitialized, StateConnectionLogin, StateConnectionSynchronize, StateConnectionConnected, StateConnectionQuit] + _network_data [NetworkData] : Object state connexion (Tick receive, send, bit acknowledge) + _queue [BitStreamQueue] : queue to store message UDP (just simple method to try re-order message receive by UDP) + _socketUDP [Ref] : network connexion + + + NetworkConnection(object A) NetworkConnection(object B) ... + | | ++-------+----+---------------------------------------+-----------------------------------------+ + | + NetworkConnectionCore + * _network_data + * _queue + * _socketUDP + * _state_connexion + if StateConnectionConnected + +### ReferentialMessage + +ReferentialMessage -> class to manage/use ReferentialMessageCore + +ReferentialMessageCore -> class singleton (uniq object) [Manage data provide by msg.xml], we can encode/decode khaganat's message + + +### ViewMessage + +PacketServer + +---------+ +---------+ +---------+ + | Level A | | Level B | | Level C | + | (0) | | (0) | | (0) | + +---------+ +---------+ +---------+ + +---------+ +---------+ + | Level B | | Level C | + | (1) | | (1) | + +---------+ +---------+ + +---------+ + | Level C | + | (2) | + +---------+ + +---------+ + | Level C | + | (3) | + +---------+ + + +Message UDP : + +-------------+ + | Server Part | + +-------------+ + | Type Message (system / application) | + + + + +---------+ + | | +----------------+ + | | -> | System Message | + | Message | +----------------+ + | | + | UDP | +----------------+ +---------+ +---------+ +---------+ + | | -> | Normal Message | -> | Level A +-+ Level B +-+ Level C + + | | +----------------+ +---------+ +---------+ +---------+ + +---------+ + + Message UDP : + +-------------------+------------+--- + | CurrentSendNumber | SystemMode | . . . + | 32 bits | 1 bit | + +-+-+-+-+-+-+-+-+-+-+------------+--- + 1 -> system mode + 0 -> normal mode + + System Message : + +---------+-- + | Message | . . . + | 8 bits | + +---------+-- diff --git a/TODO b/TODO index ddf2413..9c9daf5 100644 --- a/TODO +++ b/TODO @@ -4,3 +4,50 @@ * Execute next step - UDP module to communicate with khaganat * Configuration panel to define all connexion parameter * Path : check version and patch all file (we need generate path file for godot and method to reload data) + + + +##################### +# Debug CI +##################### + +https://github.com/aBARICHELLO/godot-ci/blob/master/Dockerfile +https://github.com/aBARICHELLO/godot-ci/blob/master/.gitlab-ci.yml + +https://github.com/h4de5/docker-godot-3-build-and-run/blob/master/Dockerfile + + +docker run -it -v ~/Projets/khanat/temp/build:/build amd64/debian:10 /bin/bash + +docker run -it -v ~/Projets/khanat/temp/build2:/build amd64/debian:10 /bin/bash + +gitlab-runner exec docker --timeout=3600 --docker-volumes $HOME/Projets/khanat/temp/build2:/builds 'Build Client Linux 64' + + + apt-get install build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev \ + libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libfreetype6-dev libudev-dev libxi-dev \ + libxrandr-dev yasm + +git clone https://github.com/godotengine/godot.git +scons -j8 platform=x11 tools=no target=release bits=64 +scons -j8 platform=x11 tools=yes target=release bits=64 +scons -j8 platform=server tools=no target=release bits=64 +scons -j8 platform=server tools=yes target=release bits=64 + +(cd /build/0/godot/; scons -j8 platform=server tools=yes target=debug bits=64) +/build/0/godot/bin/godot_server.x11.tools.64 -v --path /build/0/project-0 --export khaganat.linux.64 khaganat.linux64.bin + + +apt-get install lxde x11vnc +apt-get install x11vnc mesa-utils libgl1-mesa-dri +apt-get install -y xvfb libxcursor1 libxinerama1 libxrandr2 libxi6 libasound2 libpulse0 libgl1 mesa-utils libgl1-mesa-dri libasound2 libasound2-plugins alsa-utils alsa-oss pulseaudio pulseaudio-utils + +xvfb-run -a -n 99 --server-args="-screen 0 1024x768x24" + +xvfb +pulseaudio -D + +xvfb-run -a -n 99 --server-args="-ac -screen 0 1024x768x24" /build/0/godot/bin/godot.x11.opt.64 -v --path . --export khaganat.linux.64 khaganat.linux64.bin + +xvfb-run -a -n 99 --server-args="-ac -screen 0 1024x768x24" /usr/local/bin/godot --quit -v --path . --export khaganat.linux.64 khaganat.linux64.bin + diff --git a/assets/Scripts/Definition/msg.gd b/assets/Scripts/Definition/msg.gd index 9f9ac7d..d94f849 100644 --- a/assets/Scripts/Definition/msg.gd +++ b/assets/Scripts/Definition/msg.gd @@ -25,60 +25,67 @@ func open_message_xml(): func is_correct_md5(value): return (_msg_md5sum == value) +func load_node(_msg_xml, level): + var ret = _msg_xml.read() + var i + var name + var index = 0 + var dico = {} + while ret == OK: + match _msg_xml.get_node_type(): + XMLParser.NODE_NONE: # 0 + # print("NODE_NONE") + pass + XMLParser.NODE_ELEMENT: # 1 + 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(): + name = _msg_xml.get_attribute_value(i) + #print("NODE_ELEMENT level:" + str(level) + " index:" + str(index) + " name:" + name) + if not _msg_xml.is_empty(): + dico[str(index)+":"+name] = load_node(_msg_xml, level+1) + else: + dico[str(index)+":"+name] = {} + index += 1 + XMLParser.NODE_ELEMENT_END: # 2 + # print("NODE_ELEMENT_END") + # level -= 1 + return dico + XMLParser.NODE_TEXT: # 3 + #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(): + # name = _msg_xml.get_attribute_value(i) + # print("NODE_TEXT level:" + str(level) + " name:" + name) + pass + XMLParser.NODE_COMMENT: # 4 + # print("NODE_COMMENT") + pass + XMLParser.NODE_CDATA: # 5 + # print("NODE_CDATA") + pass + XMLParser.NODE_UNKNOWN: # 6 + # print("NODE_UNKNOWN") + pass + _: + # print("NODE_XXXXXXX") + pass + ret = _msg_xml.read() + return dico + + func read_all_node(): var _msg_xml = XMLParser.new() _msg_xml.open("res://assets/Definition/msg.xml") - - var i _msg_xml.seek(0) - var ret = _msg_xml.read() - var branch = "" - var leaf = "" - var ibranch = 0 - var ileaf = 0 - 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 - if _msg_xml.get_node_type() != XMLParser.NODE_ELEMENT: - ret = _msg_xml.read() - continue - - 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(): - branch = _msg_xml.get_attribute_value(i) - #print(branch + " " + str(_msg_xml.get_node_type())) - _msg_data[branch] = {"leaf": {}, "pos": ibranch} - ibranch += 1 - ileaf = 0 - "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(): - leaf = _msg_xml.get_attribute_value(i) - #print(branch + ":" + leaf + str(_msg_xml.get_node_type())) - _msg_data[branch]["leaf"][leaf] = ileaf - ileaf += 1 - ret = _msg_xml.read() - #var networkConnexion = NetworkConnexion.new() - if ProjectSettings.get_setting("khaganat/debug_mode"): - #print("Branch:" + str(_msg_data.size())) - var sizebranch = _msg_data.size() - #NetworkConnexion.get_master_message_description_node().->set_name("Master") - for key in _msg_data: - var sizeleaf = _msg_data[key]["leaf"].size() - print(" " + key + " -> " + str(_msg_data[key]["pos"]) + "/" + str(sizebranch)) - for leaf in _msg_data[key]["leaf"]: - var opt = str(_msg_data[key]["pos"]) + "/" + str(sizebranch) + " : " + str(_msg_data[key]["leaf"][leaf]) + "/" + str(sizeleaf) - print(" " + key + ":" + leaf + " -> " + opt) - + var dico = load_node(_msg_xml, 0) + var ref = ReferentialMessage.new() + #print(dico) + ref.read_referential(dico) + ref.show() + #print("---") # Called when the node enters the scene tree for the first time. func _ready(): diff --git a/assets/Scripts/Network/net_low_level.gd b/assets/Scripts/Network/net_low_level.gd index 3b74b12..576bb98 100644 --- a/assets/Scripts/Network/net_low_level.gd +++ b/assets/Scripts/Network/net_low_level.gd @@ -18,6 +18,7 @@ extends Control var _networkconnection = NetworkConnection.new() +var _referentialmessage = ReferentialMessage.new() func _ready(): pass @@ -51,3 +52,4 @@ func _exit_tree(): print("[net_low_level] End") disconnect_server() _networkconnection.terminate_network_connection() + _referentialmessage.clear_session() diff --git a/modules/bitstream/bitstream.cpp b/modules/bitstream/bitstream.cpp index 18f0431..fb00764 100644 --- a/modules/bitstream/bitstream.cpp +++ b/modules/bitstream/bitstream.cpp @@ -20,7 +20,7 @@ Build : */ -#include "bitstream.h" +#include "modules/bitstream/bitstream.h" // TODO - check if on godot we have a function or variable to get if processor is little_endian or not bool little_endian = false; @@ -337,13 +337,20 @@ void BitStream::put_data(PoolByteArray value) } -void BitStream::put_bitstream(Ref value) +void BitStream::copy_ref_bitstream(Ref value) { this->_data = value->_data; //*value.ptr(); this->_pos = value->_pos; // ->size() * 8; this->_read = value->_read; } +void BitStream::copy_bitstream(BitStream & value) +{ + this->_data = value._data; //*value.ptr(); + this->_pos = value._pos; // ->size() * 8; + this->_read = value._read; +} + uint32_t BitStream::get_serial(uint32_t nbits) { uint32_t value; @@ -461,4 +468,4 @@ PoolByteArray BitStream::get_array_uint8(uint32_t length) --length; } return ret; -} +} \ No newline at end of file diff --git a/modules/bitstream/bitstream.h b/modules/bitstream/bitstream.h index 84c237c..062e52e 100644 --- a/modules/bitstream/bitstream.h +++ b/modules/bitstream/bitstream.h @@ -65,7 +65,8 @@ public: PoolByteArray get_data(); void put_data(PoolByteArray value); - void put_bitstream(Ref value); + void copy_ref_bitstream(Ref value); + void copy_bitstream(BitStream & value); uint32_t get_serial(uint32_t nbits); bool get_bool(); diff --git a/modules/networkconnection/network_connection.cpp b/modules/networkconnection/network_connection.cpp index 27734eb..e4fefdb 100644 --- a/modules/networkconnection/network_connection.cpp +++ b/modules/networkconnection/network_connection.cpp @@ -90,6 +90,5 @@ MessageDescriptionNode & NetworkConnection::get_master_message_description_node( */ void NetworkConnection::terminate_network_connection() { - if ( NetworkConnectionCore::is_active() ) - NetworkConnectionCore::get_singleton()->terminate_connexion(); + NetworkConnectionCore::terminate_connexion(); } diff --git a/modules/networkconnection/network_connection_core.cpp b/modules/networkconnection/network_connection_core.cpp index f49b6ea..84f7431 100644 --- a/modules/networkconnection/network_connection_core.cpp +++ b/modules/networkconnection/network_connection_core.cpp @@ -92,6 +92,7 @@ void NetworkConnectionCore::open_network() OS::get_singleton()->print("Connect to %s:%ld\n", this->_host.ascii().get_data(), this->_port); this->_socketUDP->set_dest_address(this->_host, this->_port); } + void NetworkConnectionCore::close_network() { this->_socketUDP->close(); @@ -140,48 +141,15 @@ void NetworkConnectionCore::connect_to_server() void NetworkConnectionCore::send_system_quit() { this->_state_connexion->send_system_quit(); -/* - // TODO - check why we send quit_id - if ( this->_state != STATE::Connected && this->_state != STATE::ForceSynchronize ) - return; - OS::get_singleton()->print("[%s:%d] send quit to server\n", __FILE__, __LINE__); - BitStream msgout; - msgout.put_uint32(this->_current_received_number); - msgout.put_bool(true); - msgout.put_uint8(CLFECOMMON::SYSTEM_QUIT_CODE); - msgout.put_sint32(this->_quit_id); - - if ( this->_socketUDP->put_packet_buffer(msgout.get_data()) != Error::OK ) - { - ERR_PRINT("Error to send disconnect"); - } - //this->_state = STATE::Quit; -*/ } /* - * Quit + * Disconnect */ void NetworkConnectionCore::send_system_disconnect() { this->_state_connexion->send_system_disconnect(); -/* - if ( this->_state != STATE::Connected && this->_state != STATE::ForceSynchronize ) - return; - OS::get_singleton()->print("[%s:%d] send disconnect to server\n", __FILE__, __LINE__); - BitStream msgout; - msgout.put_uint32(this->_current_received_number); - msgout.put_bool(true); - msgout.put_uint8(CLFECOMMON::SYSTEM_DISCONNECTION_CODE); - - if ( this->_socketUDP->put_packet_buffer(msgout.get_data()) != Error::OK ) - { - ERR_PRINT("Error to send disconnect"); - } - this->_socketUDP->close(); - this->_state = STATE::Disconnect; -*/ } /* @@ -194,363 +162,6 @@ void NetworkConnectionCore::disconnect_server() send_system_disconnect(); } -/* - * Synchronize - */ -/* -void NetworkConnectionCore::send_system_ack_sync() -{ - - this->_state_connexion->send_system_ack_sync(); - // khanat-opennel-code/code/ryzom/server/src/frontend_service/fe_receive_sub.cpp:1121 void CFeReceiveSub::handleReceivedMsg( CClientHost *clienthost ) - OS::get_singleton()->print("[%s:%d] Send system ACK sync\n", __FILE__, __LINE__); - - if (this->_state != STATE::Connected && this->_state != STATE::Synchronize) - return; - OS::get_singleton()->print("[%s:%d] Send system ACK probe\n", __FILE__, __LINE__); - - OS::get_singleton()->print("[%s:%d] send system ACK Sync to server\n", __FILE__, __LINE__); - Ref msgout; - msgout.instance(); - msgout->put_uint32(this->_current_received_number); - msgout->put_bool(true); - msgout->put_uint8(CLFECOMMON::SYSTEM_ACK_SYNC_CODE); - msgout->put_sint32(this->_last_received_number); - msgout->put_sint32(this->_last_ack_in_long_ack); - this->_long_ack_bit_field.write_serial(msgout); - msgout->put_sint32(this->_latest_sync); - if (this->_socketUDP->put_packet_buffer(msgout->get_data()) != Error::OK) - { - ERR_PRINT("Error to send disconnect"); - return; - } - msgout.unref(); - this->_state = STATE::Connected; -} -*/ - -void NetworkConnectionCore::receive_system_sync(Ref msgin) -{ - /* - int i; - bool valide = true; - - //DEBUG_PRINT("SYSTEM_SYNC_CODE"); - uint32_t synchronize = msgin->get_uint32(); - int64_t stime = msgin->get_sint64(); - uint32_t latestsync = msgin->get_uint32(); - PoolByteArray msg_xml = msgin->get_array_uint8(16); - PoolByteArray database_xml = msgin->get_array_uint8(16); - - OS::get_singleton()->print("[%s:%d] SYSTEM_SYNC_CODE synchronize:%u, stime:%ld, latestsync:%u\n", __FILE__, __LINE__, synchronize, stime, latestsync); - - if ( msg_xml.size() != this->_checksum_msg_xml.size() ) - { - valide = false; - ERR_PRINTS("MSG XML is incorrect (server:" + itos(msg_xml.size()) +", client:" + itos(this->_checksum_msg_xml.size()) + ")"); - } - else - { - for(i=0; i_checksum_msg_xml[i] ) - { - valide = false; - ERR_PRINTS("MSG XML is incorrect (pos:" + itos(i) +")"); - } - } - } - - if ( valide == true ) - { - OS::get_singleton()->print("MSG XML is correct\n"); - this->_latest_sync = latestsync; - this->_synchronize = synchronize; - this->_current_server_tick = this->_synchronize + this->_current_received_number + 2; - this->_current_client_tick = this->_current_server_tick + (LCT + this->_ms_per_tick) / this->_ms_per_tick; - this->_current_client_time = this->_update_time - (LCT + this->_ms_per_tick); - this->_state = STATE::Synchronize; - } - else - ERR_PRINTS("MSG.XML is wrong"); - */ -} - -/* - * Probe - */ - -void NetworkConnectionCore::receive_system_probe(Ref msgin) -{ - /* - OS::get_singleton()->print("[%s:%d] SYSTEM_PROBE_CODE size:%d\n", __FILE__, __LINE__, this->_latest_probes.size()); - this->_latest_probes.append(msgin->get_sint32()); - */ -} - -void NetworkConnectionCore::send_system_ack_probe() -{ - /* - OS::get_singleton()->print("[%s:%d] Send system ACK probe\n", __FILE__, __LINE__); - // khanat-opennel-code/code/ryzom/server/src/frontend_service/fe_receive_sub.cpp:1121 void CFeReceiveSub::handleReceivedMsg( CClientHost *clienthost ) - if (this->_state != STATE::Connected && this->_state != STATE::ForceSynchronize) - return; - - OS::get_singleton()->print("[%s:%d] Send system ACK probe\n", __FILE__, __LINE__); - - int max = this->_latest_probes.size(); - if (max == 0 ) - return; - if (this->_state == STATE::ForceSynchronize && max < 5) - return; - OS::get_singleton()->print("[%s:%d] send system ACK PROBE to server\n", __FILE__, __LINE__); - BitStream msgout; - msgout.put_uint32(this->_current_received_number); - msgout.put_bool(true); - msgout.put_uint8(CLFECOMMON::SYSTEM_ACK_PROBE_CODE); - msgout.put_sint32(max); - for(int i=0; i < max ; ++i ) - { - int data = this->_latest_probes[i]; - msgout.put_sint32(data); - } - if (this->_socketUDP->put_packet_buffer(msgout.get_data()) != Error::OK) - { - ERR_PRINT("Error to send disconnect"); - return; - } - this->_latest_probes.clear(); - if (this->_state == STATE::ForceSynchronize && max >= 5) - { - // We have send ACK, so now we clean all queue and received all message to synchronize - this->_queue.clear(); - this->_state = STATE::Connected; - } - */ -} - -/* - * - */ - -void NetworkConnectionCore::wait_resynchronize(uint32_t current_received_number, Ref msgin) -{ - /* - bool system_mode; - this->_current_received_number = current_received_number; - system_mode = msgin->get_bool(); - if ( system_mode == true ) - { - int message = msgin->get_uint8(); - switch (message) - { - case CLFECOMMON::SYSTEM_LOGIN_CODE: - OS::get_singleton()->print("SYSTEM_LOGIN_CODE\n"); - break; - case CLFECOMMON::SYSTEM_SYNC_CODE: - OS::get_singleton()->print("SYSTEM_SYNC_CODE\n"); - break; - case CLFECOMMON::SYSTEM_STALLED_CODE: - OS::get_singleton()->print("SYSTEM_STALLED_CODE\n"); - break; - case CLFECOMMON::SYSTEM_SERVER_DOWN_CODE: - OS::get_singleton()->print("SYSTEM_SERVER_DOWN_CODE\n"); - break; - case CLFECOMMON::SYSTEM_PROBE_CODE: - this->receive_system_probe(msgin); - break; - default: - ERR_PRINTS("Received unknown message [" + itos(message) + "]"); - break; - } - } - this->_last_received_number = current_received_number; - */ -} - -/* - * - */ - -void NetworkConnectionCore::decode_system_message(Ref msgin) -{ - /* - int message = msgin->get_uint8(); - switch (message) - { - case CLFECOMMON::SYSTEM_LOGIN_CODE: - //DEBUG_PRINT("SYSTEM_LOGIN_CODE"); - OS::get_singleton()->print("[%s:%d] SYSTEM_LOGIN_CODE\n", __FILE__, __LINE__); - break; - case CLFECOMMON::SYSTEM_SYNC_CODE: - this->receive_system_sync(msgin); - break; - case CLFECOMMON::SYSTEM_STALLED_CODE: - //DEBUG_PRINT("SYSTEM_STALLED_CODE"); - OS::get_singleton()->print("[%s:%d] SYSTEM_STALLED_CODE\n", __FILE__, __LINE__); - break; - case CLFECOMMON::SYSTEM_SERVER_DOWN_CODE: - OS::get_singleton()->print("[%s:%d] SYSTEM_SERVER_DOWN_CODE\n", __FILE__, __LINE__); - break; - case CLFECOMMON::SYSTEM_PROBE_CODE: - this->receive_system_probe(msgin); - break; - default: - ERR_PRINTS("Received unknown message [" + itos(message) + "]"); - break; - } - */ -} - -void NetworkConnectionCore::decode_normal_message(Ref msgin) -{ - OS::get_singleton()->print("[%s:%d] Decode normal message\n", __FILE__, __LINE__); -} - -/* - * - */ - -void NetworkConnectionCore::analyze_message_received(uint32_t current_received_number, Ref msgin) -{ - /* - bool system_mode; - bool ackBool = false; - int ackBit = 0; - uint32_t i; - - OS::get_singleton()->print("[%s:%d] analyze_message_received state:%d\n", __FILE__, __LINE__, this->_state); - - this->_current_received_number = current_received_number; - system_mode = msgin->get_bool(); - if ( system_mode == true ) - { - OS::get_singleton()->print("Received system message\n"); - if (this->_current_received_number == this->_last_received_number + 1) - { - OS::get_singleton()->print("Received message\n"); - } - else if (this->_current_received_number < this->_last_received_number + 1) - { - OS::get_singleton()->print("Received old message\n"); - return; - } - else if (this->_current_received_number > this->_last_received_number + 1) - { - OS::get_singleton()->print("Received message in future (lost some message)\n"); - } - } - else - { - OS::get_singleton()->print("Received normal message\n"); - } - if ( system_mode != true ) - { - ackBool = true; - ackBit = 1; - } - if ( current_received_number - this->_last_received_number < 32 ) - { - this->_ack_bit_mask <<= current_received_number - this->_last_received_number; - this->_ack_bit_mask |= this->_last_ack_bit << (current_received_number - this->_last_received_number - 1); - } - else if (((current_received_number - this->_last_received_number) == 32) && (this->_last_ack_bit != 0)) - this->_ack_bit_mask = 0x80000000; - else - this->_ack_bit_mask = 0x00000000; - this->_last_ack_bit = ackBit; - for(i=this->_last_received_number + 1 ;i < _current_received_number; ++i) - this->_long_ack_bit_field.clear_bit(i & (NUM_BITS_IN_LONG_ACK -1) ); - - OS::get_singleton()->print("long_ack_bit_field.put : %u\n", current_received_number & (NUM_BITS_IN_LONG_ACK-1)); - this->_long_ack_bit_field.write(current_received_number & (NUM_BITS_IN_LONG_ACK-1), ackBool); - - // TODO - what's action when we have rotate onthis number (max -> 0) - if( this->_last_received_number > 0x08000000 ) - { - if(this->_last_ack_in_long_ack <= (this->_last_received_number - NUM_BITS_IN_LONG_ACK)) - this->_last_ack_in_long_ack = this->_last_received_number - NUM_BITS_IN_LONG_ACK + 1; - this->_last_received_number = current_received_number; - } - else - { - if(this->_last_ack_in_long_ack - 0x80000000 <= (this->_last_received_number - NUM_BITS_IN_LONG_ACK - 0x80000000)) - this->_last_ack_in_long_ack = this->_last_received_number - NUM_BITS_IN_LONG_ACK + 1; - this->_last_received_number = current_received_number; - } - - if ( system_mode == true ) - this->decode_system_message(msgin); - else - this->decode_normal_message(msgin); - */ -} - -void NetworkConnectionCore::store_message_received(PoolByteArray msgbytes) -{ - /* - Ref msgin; - msgin.instance(); - msgin->put_data(msgbytes); - uint32_t current_received_number = msgin->get_uint32(); - - //msgin.put_data(msgbytes); - //uint32_t current_received_number = msgin.get_uint32(); - - OS::get_singleton()->print("[%s:%d] store message (%d)\n", __FILE__, __LINE__, (int)current_received_number); - SHOW_USAGE_MEMORY - - show_memory_usage(); - - Ref msg; - msg.instance(); - msg->put_id(current_received_number); - msg->put_msgin(msgin); - int index = this->_queue.put_bitstreamfield(msg); - msg.unref(); - /// TODO - check if max int execeded current_received_number < 1000 this->_last_received_number > 0x80000000 - if ( this->_state == STATE::ForceSynchronize ) - { - // We have detected a problem of synchro, we wait message ack probe and after server launch a re-sync - //wait_resynchronize(current_received_number, msgin); - this->_queue.erase_index(index); - } - else if ( current_received_number - this->_last_received_number <= 0 ) // Received old message - { - OS::get_singleton()->print("[%s:%d] current_received_number:%d / queue size:%d\n", __FILE__, __LINE__, current_received_number, this->_queue.length()); - this->_queue.erase_index(index); - return; - } - else if ( this->_last_received_number + 1 == current_received_number ) // Received next message - { - OS::get_singleton()->print("[%s:%d] current_received_number:%u / queue size:%d\n", __FILE__, __LINE__, current_received_number, this->_queue.length()); - //analyze_message_received(current_received_number, msgin); - this->_queue.erase_index(index); - } - else // Received new message (but missing some message between) -> go to queue and cross finger to received the next message (for _last_received_number) - { - OS::get_singleton()->print("[%s:%d] current_received_number:%d / queue size:%d\n", __FILE__, __LINE__, current_received_number, this->_queue.length()); - if (this->_queue.length() >= SIZE_QUEUE_MESSAGE) - { - ERR_PRINT("Network queue is full / wait re-synchronize"); - this->_state = STATE::ForceSynchronize ; - return; - } - } - */ -} - -void NetworkConnectionCore::send_message() -{ - /* - if (this->_latest_probes.size() > 0) - send_system_ack_probe(); - else if (this->_state == STATE::Synchronize) - send_system_ack_sync(); - */ - -} - void NetworkConnectionCore::process(int delta) { // this->_state_connexion->process(delta); @@ -598,21 +209,9 @@ bool NetworkConnectionCore::is_active() void NetworkConnectionCore::terminate_connexion() { - OS::get_singleton()->print("[%s:%d] Terminate network connexion .\n", __FILE__, __LINE__); if ( NetworkConnectionCore::singleton == nullptr ) return; OS::get_singleton()->print("[%s:%d] Terminate network connexion ..\n", __FILE__, __LINE__); - - OS::get_singleton()->print("[%s:%d] Terminate network connexion ...\n", __FILE__, __LINE__); delete NetworkConnectionCore::singleton; - if ( NetworkConnectionCore::singleton != nullptr ) - OS::get_singleton()->print("[%s:%d] Terminate network connexion ?\n", __FILE__, __LINE__); - OS::get_singleton()->print("[%s:%d] Terminate network connexion ....\n", __FILE__, __LINE__); + NetworkConnectionCore::singleton = nullptr; } - -/* -MessageDescriptionNode & NetworkConnectionCore::get_master_message_description_node() -{ - return this->_message_description_node; -} -*/ diff --git a/modules/networkconnection/network_connection_core.h b/modules/networkconnection/network_connection_core.h index 6fd0ead..6289af6 100644 --- a/modules/networkconnection/network_connection_core.h +++ b/modules/networkconnection/network_connection_core.h @@ -27,8 +27,9 @@ #include "modules/bitstreamqueue/bitstreamqueue.h" #include "state_connexion.h" #include "network_data.h" +#include "modules/referentialmessage/referentialmessage.h" -#define MAX_LOOP_READ_BY_STEP 10 +#define MAX_LOOP_READ_BY_STEP 5 #define LCT 100 @@ -60,8 +61,6 @@ protected: NetworkData _network_data; - //MessageDescriptionNode _message_description_node; - void open_network(); void close_network(); public: @@ -88,22 +87,10 @@ public: void send_system_quit(); void disconnect_server(); - void send_system_ack_probe(); - void receive_system_probe(Ref msgin); - - void send_system_ack_sync(); - void receive_system_sync(Ref msgin); - - void decode_system_message(Ref msgin); - void decode_normal_message(Ref msgin); - void wait_resynchronize(uint32_t current_received_number, Ref msgin); - void analyze_message_received(uint32_t current_received_number, Ref msgin); - void store_message_received(PoolByteArray msgbytes); - void send_message(); void process(int delta); bool connected(); static bool is_active(); - void terminate_connexion(); + static void terminate_connexion(); //MessageDescriptionNode & get_master_message_description_node(); }; diff --git a/modules/networkconnection/network_data.h b/modules/networkconnection/network_data.h index 1204a80..eb3205f 100644 --- a/modules/networkconnection/network_data.h +++ b/modules/networkconnection/network_data.h @@ -26,7 +26,7 @@ #include "modules/bitset/bitset.h" #include "core/ustring.h" -#define MAX_LOOP_READ_BY_STEP 10 +//define MAX_LOOP_READ_BY_STEP 10 #define NUM_BITS_IN_LONG_ACK 512 class NetworkData diff --git a/modules/networkconnection/state_connexion.cpp b/modules/networkconnection/state_connexion.cpp index 704596c..4337d1c 100644 --- a/modules/networkconnection/state_connexion.cpp +++ b/modules/networkconnection/state_connexion.cpp @@ -22,6 +22,13 @@ #include "state_connexion.h" #include "network_connection_core.h" +// We need managed when number 'uint32_t' exceed the capacity (32bits => 4294967296) +// So, we split in two group. +// < 0...1073741824 > < 1073741825 ... 3221225472 > < 3221225472 ... 4294967295 > +// Group 1 : < 0...1073741824 > + < 3221225472 ... 4294967295 > => number value : 2147483648 +// Group 2 : < 1073741825 ... 3221225472 > => number value : 2147483648 + + /* * StateConnectionBase */ @@ -365,6 +372,14 @@ void StateConnectionConnected::receive_message(int index) Ref field = this->_network->_queue.get_msg(index); uint32_t current_received_number = field->get_id(); + + if (current_received_number - this->_data->_current_received_number != 1) + { + if(this->_network->_queue.length() >= MAX_SIZE_BIT_STREAM_QUEUE) + this->_network->_state_connexion = & this->_network->_state_synchronize; + return; + } + this->_data->_current_received_number = current_received_number; Ref msgin = field->get_msgin(); @@ -403,6 +418,9 @@ void StateConnectionConnected::receive_message(int index) OS::get_singleton()->print("[%s:%d] application message (%d) [%d]\n", __FILE__, __LINE__, (int)current_received_number, this->_network->_queue.length()); } this->_network->_queue.erase_index(index); + // Check in buffer if we have next + if ( this->_network->_queue.is_index(index + 1) ) + this->receive_message(index + 1); } void StateConnectionConnected::send_message() diff --git a/modules/networkconnection/state_connexion.h b/modules/networkconnection/state_connexion.h index 7b5856f..5b72cb6 100644 --- a/modules/networkconnection/state_connexion.h +++ b/modules/networkconnection/state_connexion.h @@ -27,7 +27,8 @@ #include "modules/bitstreamqueue/bitstreamqueue.h" #include "network_data.h" -#define NUM_BITS_IN_LONG_ACK 512 +#define MAX_SIZE_BIT_STREAM_QUEUE 10 +#define NUM_BITS_IN_LONG_ACK 512 enum STATE { NotInitialised = 0, diff --git a/modules/referentialmessage/SCsub b/modules/referentialmessage/SCsub new file mode 100644 index 0000000..e208d38 --- /dev/null +++ b/modules/referentialmessage/SCsub @@ -0,0 +1,5 @@ +# SCsub + +Import('env') + +env.add_source_files(env.modules_sources, "*.cpp") # Add all cpp files to the build diff --git a/modules/referentialmessage/config.py b/modules/referentialmessage/config.py new file mode 100644 index 0000000..4a3b04b --- /dev/null +++ b/modules/referentialmessage/config.py @@ -0,0 +1,15 @@ +# config.py + +def can_build(env, platform): + return True + +def configure(env): + pass + +def get_doc_classes(): + return [ + "ReferentialMessage", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/modules/referentialmessage/referentialmessage.cpp b/modules/referentialmessage/referentialmessage.cpp new file mode 100644 index 0000000..6c75d87 --- /dev/null +++ b/modules/referentialmessage/referentialmessage.cpp @@ -0,0 +1,46 @@ +/* + + ReferentialMessage : Class to store referential to decode message + + Copyright (C) 2019 AleaJactaEst + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + */ + +#include "referentialmessage.h" +#include "core/os/os.h" + +void ReferentialMessage::_bind_methods() +{ + ClassDB::bind_method(D_METHOD("read_referential", "dictionary_message"), &ReferentialMessage::read_referential); + ClassDB::bind_method(D_METHOD("show"), &ReferentialMessage::show); + ClassDB::bind_method(D_METHOD("clear_session"), &ReferentialMessage::clear_session); +} + +void ReferentialMessage::read_referential(Dictionary dictionary_message) +{ + ReferentialMessageCore::clear_session(); + ReferentialMessageCore::get_singleton()->read_referential(dictionary_message); +} + +void ReferentialMessage::show() +{ + ReferentialMessageCore::get_singleton()->show(); +} + +void ReferentialMessage::clear_session() +{ + ReferentialMessageCore::clear_session(); +} \ No newline at end of file diff --git a/modules/referentialmessage/referentialmessage.h b/modules/referentialmessage/referentialmessage.h new file mode 100644 index 0000000..35f9445 --- /dev/null +++ b/modules/referentialmessage/referentialmessage.h @@ -0,0 +1,45 @@ +/* + Header ReferentialMessage : Class to store referential to decode message + + Copyright (C) 2019 AleaJactaEst + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#ifndef REFERENTIAL_MESSAGE_H +#define REFERENTIAL_MESSAGE_H + +#include "core/reference.h" +//#include "core/dictionary.h" +//#include "modules/bitstream/bitstream.h" +#include "modules/referentialmessage/referentialmessagecore.h" + +class ReferentialMessage : public Reference { + GDCLASS(ReferentialMessage, Reference) +protected: + static void _bind_methods(); +public: + ReferentialMessage() {} + ~ReferentialMessage() {} + + /* _init must exist as it is called by Godot */ + void _init() {}; + void read_referential(Dictionary dictionary_message); + void show(); + + void clear_session(); +}; + +#endif \ No newline at end of file diff --git a/modules/referentialmessage/referentialmessagecore.cpp b/modules/referentialmessage/referentialmessagecore.cpp new file mode 100644 index 0000000..8fd1299 --- /dev/null +++ b/modules/referentialmessage/referentialmessagecore.cpp @@ -0,0 +1,1169 @@ +/* + + ReferentialMessageCore : Class to store referential to decode message + + Copyright (C) 2019 AleaJactaEst + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + */ + +#define DEBUGLEVEL 0 + +#include "referentialmessagecore.h" +#include "core/os/os.h" +#include "thirdparty/zstd/common/debug.h" + +ReferentialMessageCore *ReferentialMessageCore::singleton = nullptr; + +/* + * ElementReferential + */ + +void ElementReferential::show(int level, int pos) +{ + String a; + for(int i=0;iprint("[%s:%d] level:%d %s pos:%3d ------ power:%d\n", __FILE__, __LINE__, level, a.ascii().get_data(), pos, _power2); + DEBUGLOG(5, "level:%d %s pos:%3d ------ power:%d", level, a.ascii().get_data(), pos, _power2); + } + else + { + DEBUGLOG(5, "level:%d %s pos:%3d id:%3d", level, a.ascii().get_data(), pos, _id); + } + level ++; + for(int i=0;i<_children.size() - 1;++i) + { + Ref child = _children[i]; + child->show(level, i); + } +} + +/* + * ReferentialMessageCore + */ +void ReferentialMessageCore::_bind_methods() +{ + BIND_ENUM_CONSTANT(TARGET_PARTY); + BIND_ENUM_CONSTANT(TARGET_INVENTORY); + BIND_ENUM_CONSTANT(TARGET_FOLLOW); + BIND_ENUM_CONSTANT(TARGET_NO_FOLLOW); + BIND_ENUM_CONSTANT(CONNECTION_USER_CHAR); + BIND_ENUM_CONSTANT(CONNECTION_NO_USER_CHAR); + BIND_ENUM_CONSTANT(CONNECTION_USER_CHARS); + BIND_ENUM_CONSTANT(CONNECTION_CREATE_CHAR); + BIND_ENUM_CONSTANT(CONNECTION_SELECT_CHAR); + BIND_ENUM_CONSTANT(CONNECTION_DELETE_CHAR); + BIND_ENUM_CONSTANT(CONNECTION_RENAME_CHAR); + BIND_ENUM_CONSTANT(CONNECTION_ENTER); + BIND_ENUM_CONSTANT(CONNECTION_READY); + BIND_ENUM_CONSTANT(CONNECTION_TIME_DATE_SYNCHRO); + BIND_ENUM_CONSTANT(CONNECTION_ASK_NAME); + BIND_ENUM_CONSTANT(CONNECTION_VALID_NAME); + BIND_ENUM_CONSTANT(CONNECTION_CREATE_CHAR_ERROR); + BIND_ENUM_CONSTANT(CONNECTION_RECONNECT); + BIND_ENUM_CONSTANT(CONNECTION_SERVER_RECONNECT_OK); + BIND_ENUM_CONSTANT(CONNECTION_SHARD_ID); + BIND_ENUM_CONSTANT(CONNECTION_SERVER_QUIT_OK); + BIND_ENUM_CONSTANT(CONNECTION_SERVER_QUIT_ABORT); + BIND_ENUM_CONSTANT(CONNECTION_CLIENT_QUIT_REQUEST); + BIND_ENUM_CONSTANT(CONNECTION_MAIL_AVAILABLE); + BIND_ENUM_CONSTANT(CONNECTION_GUILD_MESSAGE_AVAILABLE); + BIND_ENUM_CONSTANT(CONNECTION_PERMANENT_BAN); + BIND_ENUM_CONSTANT(CONNECTION_UNBAN); + BIND_ENUM_CONSTANT(CONNECTION_FAR_TP); + BIND_ENUM_CONSTANT(CONNECTION_RET_MAINLAND); + BIND_ENUM_CONSTANT(DB_UPD_PLR); + BIND_ENUM_CONSTANT(DB_UPD_INV); + BIND_ENUM_CONSTANT(DB_INIT_PLR); + BIND_ENUM_CONSTANT(DB_INIT_INV); + BIND_ENUM_CONSTANT(DB_GROUP_UPDATE_BANK); + BIND_ENUM_CONSTANT(DB_GROUP_INIT_BANK); + BIND_ENUM_CONSTANT(DB_GROUP_RESET_BANK); + BIND_ENUM_CONSTANT(POSITION); + BIND_ENUM_CONSTANT(HARVEST_DEPOSIT); + BIND_ENUM_CONSTANT(HARVEST_CORPSE); + BIND_ENUM_CONSTANT(HARVEST_INTERRUPT); + BIND_ENUM_CONSTANT(HARVEST_CLOSE_TEMP_INVENTORY); + BIND_ENUM_CONSTANT(TRAINING); + BIND_ENUM_CONSTANT(JOB_SET_JOB_STATUS); + BIND_ENUM_CONSTANT(JOB_SWAP_JOB_STATUS); + BIND_ENUM_CONSTANT(CASTING_BEGIN); + BIND_ENUM_CONSTANT(CASTING_INTERRUPT); + BIND_ENUM_CONSTANT(FABER_OPEN); + BIND_ENUM_CONSTANT(FABER_CLOSE); + BIND_ENUM_CONSTANT(FABER_EXECUTE); + BIND_ENUM_CONSTANT(FABER_SET_NUM_ITEM); + BIND_ENUM_CONSTANT(FABER_START_CREATE); + BIND_ENUM_CONSTANT(FABER_START_REPAIR); + BIND_ENUM_CONSTANT(FABER_START_REFINE); + BIND_ENUM_CONSTANT(FABER_SET_MP_QUALITY); + BIND_ENUM_CONSTANT(FABER_SET_MP_REFINE); + BIND_ENUM_CONSTANT(FABER_SET_TOOL); + BIND_ENUM_CONSTANT(FABER_RESET_TOOL); + BIND_ENUM_CONSTANT(FABER_INTERRUPT); + BIND_ENUM_CONSTANT(COMBAT_ENGAGE); + BIND_ENUM_CONSTANT(COMBAT_DISENGAGE); + BIND_ENUM_CONSTANT(COMBAT_DEFAULT_ATTACK); + BIND_ENUM_CONSTANT(COMBAT_ENGAGE_FAILED); + BIND_ENUM_CONSTANT(COMBAT_VALIDATE_MELEE); + BIND_ENUM_CONSTANT(COMBAT_PARRY); + BIND_ENUM_CONSTANT(COMBAT_DODGE); + BIND_ENUM_CONSTANT(COMBAT_PROTECTED_SLOT); + BIND_ENUM_CONSTANT(COMBAT_FLYING_ChaScore1_DELTA); + BIND_ENUM_CONSTANT(COMBAT_FLYING_TEXT_ISE); + BIND_ENUM_CONSTANT(COMBAT_FLYING_TEXT); + BIND_ENUM_CONSTANT(STRING_TELL); + BIND_ENUM_CONSTANT(STRING_FAR_TELL); + BIND_ENUM_CONSTANT(STRING_CHAT); + BIND_ENUM_CONSTANT(STRING_CHAT_TEAM); + BIND_ENUM_CONSTANT(STRING_ADD_DYN_STR); + BIND_ENUM_CONSTANT(STRING_FILTER); + BIND_ENUM_CONSTANT(STRING_CHAT_MODE); + BIND_ENUM_CONSTANT(STRING_CHAT2); + BIND_ENUM_CONSTANT(STRING_TELL2); + BIND_ENUM_CONSTANT(STRING_DYN_STRING); + BIND_ENUM_CONSTANT(STRING_DYN_STRING_GROUP); + BIND_ENUM_CONSTANT(STRING_AFK_TXT); + BIND_ENUM_CONSTANT(STUN_STUN); + BIND_ENUM_CONSTANT(STUN_WAKE_UP); + BIND_ENUM_CONSTANT(SENTENCE_EXECUTE); + BIND_ENUM_CONSTANT(SENTENCE_CANCEL); + BIND_ENUM_CONSTANT(SENTENCE_CANCEL_CURRENT); + BIND_ENUM_CONSTANT(SENTENCE_CANCEL_ALL); + BIND_ENUM_CONSTANT(SENTENCE_CLEAR); + BIND_ENUM_CONSTANT(SENTENCE_MEMORIZE); + BIND_ENUM_CONSTANT(SENTENCE_FORGET); + BIND_ENUM_CONSTANT(SENTENCE_EVALUATE); + BIND_ENUM_CONSTANT(SENTENCE_ADD_BRICK); + BIND_ENUM_CONSTANT(SENTENCE_REMOVE_BRICK); + BIND_ENUM_CONSTANT(SENTENCE_START); + BIND_ENUM_CONSTANT(SENTENCE_STOP); + BIND_ENUM_CONSTANT(TEAM_JOIN); + BIND_ENUM_CONSTANT(TEAM_LEAVE); + BIND_ENUM_CONSTANT(TEAM_INVITATION); + BIND_ENUM_CONSTANT(TEAM_JOIN_PROPOSAL); + BIND_ENUM_CONSTANT(TEAM_JOIN_PROPOSAL_DECLINE); + BIND_ENUM_CONSTANT(TEAM_KICK); + BIND_ENUM_CONSTANT(TEAM_SET_SUCCESSOR); + BIND_ENUM_CONSTANT(TEAM_SHARE_OPEN); + BIND_ENUM_CONSTANT(TEAM_SHARE_VALID_ITEM); + BIND_ENUM_CONSTANT(TEAM_SHARE_INVALID_ITEM); + BIND_ENUM_CONSTANT(TEAM_SHARE_VALID); + BIND_ENUM_CONSTANT(TEAM_SHARE_INVALID); + BIND_ENUM_CONSTANT(TEAM_SHARE_CLOSE); + BIND_ENUM_CONSTANT(TEAM_CONTACT_INIT); + BIND_ENUM_CONSTANT(TEAM_CONTACT_ADD); + BIND_ENUM_CONSTANT(TEAM_CONTACT_DEL); + BIND_ENUM_CONSTANT(TEAM_CONTACT_MOVE); + BIND_ENUM_CONSTANT(TEAM_CONTACT_CREATE); + BIND_ENUM_CONSTANT(TEAM_CONTACT_STATUS); + BIND_ENUM_CONSTANT(TEAM_CONTACT_REMOVE); + BIND_ENUM_CONSTANT(ITEM_DROP); + BIND_ENUM_CONSTANT(ITEM_PICK_UP); + BIND_ENUM_CONSTANT(ITEM_PICK_UP_CLOSE); + BIND_ENUM_CONSTANT(ITEM_SWAP); + BIND_ENUM_CONSTANT(ITEM_ACTIVATE_SHEATH); + BIND_ENUM_CONSTANT(ITEM_HARVEST); + BIND_ENUM_CONSTANT(ITEM_HARVEST_CLOSE); + BIND_ENUM_CONSTANT(ITEM_GIVE); + BIND_ENUM_CONSTANT(ITEM_DESTROY); + BIND_ENUM_CONSTANT(ITEM_EQUIP); + BIND_ENUM_CONSTANT(ITEM_UNEQUIP); + BIND_ENUM_CONSTANT(ITEM_TEMP_TO_BAG); + BIND_ENUM_CONSTANT(ITEM_ALL_TEMP); + BIND_ENUM_CONSTANT(ITEM_NO_TEMP); + BIND_ENUM_CONSTANT(ITEM_ENCHANT); + BIND_ENUM_CONSTANT(ITEM_OPEN_ROOM_INVENTORY); + BIND_ENUM_CONSTANT(ITEM_CLOSE_ROOM_INVENTORY); + BIND_ENUM_CONSTANT(ITEM_USE_ITEM); + BIND_ENUM_CONSTANT(ITEM_STOP_USE_XP_CAT); + BIND_ENUM_CONSTANT(TP_RESPAWN); + BIND_ENUM_CONSTANT(TP_BOT); + BIND_ENUM_CONSTANT(TP_WANTED); + BIND_ENUM_CONSTANT(TP_DEST); + BIND_ENUM_CONSTANT(TP_DEST_WITH_SEASON); + BIND_ENUM_CONSTANT(TP_ACK); + BIND_ENUM_CONSTANT(TP_CORRECT); + BIND_ENUM_CONSTANT(DEATH_RESPAWN_POINT); + BIND_ENUM_CONSTANT(DEATH_ASK_RESPAWN); + BIND_ENUM_CONSTANT(DEATH_RESPAWN); + BIND_ENUM_CONSTANT(ANIMALS_BEAST); + BIND_ENUM_CONSTANT(ANIMALS_MOUNT_ABORT); + BIND_ENUM_CONSTANT(EXCHANGE_INVITATION); + BIND_ENUM_CONSTANT(EXCHANGE_CLOSE_INVITATION); + BIND_ENUM_CONSTANT(EXCHANGE_PROPOSAL); + BIND_ENUM_CONSTANT(EXCHANGE_ACCEPT_INVITATION); + BIND_ENUM_CONSTANT(EXCHANGE_DECLINE_INVITATION); + BIND_ENUM_CONSTANT(EXCHANGE_VALIDATE); + BIND_ENUM_CONSTANT(EXCHANGE_INVALIDATE); + BIND_ENUM_CONSTANT(EXCHANGE_END); + BIND_ENUM_CONSTANT(EXCHANGE_SEEDS); + BIND_ENUM_CONSTANT(EXCHANGE_ADD); + BIND_ENUM_CONSTANT(EXCHANGE_REMOVE); + BIND_ENUM_CONSTANT(DEBUG_WHERE); + BIND_ENUM_CONSTANT(DEBUG_WHO); + BIND_ENUM_CONSTANT(DEBUG_REPLY_WHERE); + BIND_ENUM_CONSTANT(DEBUG_SERVICES); + BIND_ENUM_CONSTANT(DEBUG_CMD); + BIND_ENUM_CONSTANT(DEBUG_PING); + BIND_ENUM_CONSTANT(DEBUG_COUNTER); + BIND_ENUM_CONSTANT(COMMAND_EMOTE); + BIND_ENUM_CONSTANT(COMMAND_CUSTOM_EMOTE); + BIND_ENUM_CONSTANT(COMMAND_WHERE); + BIND_ENUM_CONSTANT(COMMAND_ADMIN); + BIND_ENUM_CONSTANT(COMMAND_ADMIN_OFFLINE); + BIND_ENUM_CONSTANT(COMMAND_REMOTE_ADMIN); + BIND_ENUM_CONSTANT(COMMAND_REMOTE_ADMIN_ANSWER); + BIND_ENUM_CONSTANT(COMMAND_SIT); + BIND_ENUM_CONSTANT(COMMAND_AFK); + BIND_ENUM_CONSTANT(COMMAND_RANDOM); + BIND_ENUM_CONSTANT(COMMAND_GUILDMOTD); + BIND_ENUM_CONSTANT(MP_EVAL_SET_MP); + BIND_ENUM_CONSTANT(MP_EVAL_SET_MP_LEVEL); + BIND_ENUM_CONSTANT(MP_EVAL_SET_MARKET); + BIND_ENUM_CONSTANT(MP_EVAL_EXECUTE); + BIND_ENUM_CONSTANT(BOTCHAT_NEXT_PAGE_ITEM); + BIND_ENUM_CONSTANT(BOTCHAT_NEXT_PAGE_MISSION); + BIND_ENUM_CONSTANT(BOTCHAT_START_TRADE_ITEM); + BIND_ENUM_CONSTANT(BOTCHAT_START_TRADE_TELEPORT); + BIND_ENUM_CONSTANT(BOTCHAT_START_TRADE_FACTION); + BIND_ENUM_CONSTANT(BOTCHAT_START_TRADE_SKILL); + BIND_ENUM_CONSTANT(BOTCHAT_START_TRADE_PACT); + BIND_ENUM_CONSTANT(BOTCHAT_START_TRADE_ACTION); + BIND_ENUM_CONSTANT(BOTCHAT_BUY); + BIND_ENUM_CONSTANT(BOTCHAT_SELL); + BIND_ENUM_CONSTANT(BOTCHAT_DESTROY_ITEM); + BIND_ENUM_CONSTANT(BOTCHAT_REFRESH_TRADE_LIST); + BIND_ENUM_CONSTANT(BOTCHAT_SET_FILTERS); + BIND_ENUM_CONSTANT(BOTCHAT_START_CHOOSE_MISSION); + BIND_ENUM_CONSTANT(BOTCHAT_START_DYNAMIC_MISSION); + BIND_ENUM_CONSTANT(BOTCHAT_CONTINUE_MISSION); + BIND_ENUM_CONSTANT(BOTCHAT_VALIDATE_PLAYER_GIFT); + BIND_ENUM_CONSTANT(BOTCHAT_PICK_MISSION); + BIND_ENUM_CONSTANT(BOTCHAT_DM_CHOICE); + BIND_ENUM_CONSTANT(BOTCHAT_DM_ACCEPT); + BIND_ENUM_CONSTANT(BOTCHAT_START_NEWS); + BIND_ENUM_CONSTANT(BOTCHAT_START_CREATE_GUILD); + BIND_ENUM_CONSTANT(BOTCHAT_END); + BIND_ENUM_CONSTANT(BOTCHAT_FORCE_END); + BIND_ENUM_CONSTANT(BOTCHAT_START_CHOOSE_DUTY); + BIND_ENUM_CONSTANT(BOTCHAT_NEXT_PAGE_DUTY); + BIND_ENUM_CONSTANT(BOTCHAT_DUTY_APPLY); + BIND_ENUM_CONSTANT(BOTCHAT_DUTY_CANCEL_APPLY); + BIND_ENUM_CONSTANT(BOTCHAT_START_TRADE_GUILD_OPTIONS); + BIND_ENUM_CONSTANT(BOTCHAT_BUY_GUILD_OPTION); + BIND_ENUM_CONSTANT(BOTCHAT_START_GUILD_RESEARCH); + BIND_ENUM_CONSTANT(BOTCHAT_DESTROY_BUILDING); + BIND_ENUM_CONSTANT(BOTCHAT_DYNCHAT_OPEN); + BIND_ENUM_CONSTANT(BOTCHAT_DYNCHAT_CLOSE); + BIND_ENUM_CONSTANT(BOTCHAT_DYNCHAT_SEND); + BIND_ENUM_CONSTANT(JOURNAL_INIT_COMPLETED_MISSIONS); + BIND_ENUM_CONSTANT(JOURNAL_UPDATE_COMPLETED_MISSIONS); + BIND_ENUM_CONSTANT(JOURNAL_MISSION_ABANDON); + BIND_ENUM_CONSTANT(JOURNAL_GROUP_MISSION_ABANDON); + BIND_ENUM_CONSTANT(JOURNAL_ADD_COMPASS); + BIND_ENUM_CONSTANT(JOURNAL_ADD_COMPASS_BOT); + BIND_ENUM_CONSTANT(JOURNAL_REMOVE_COMPASS); + BIND_ENUM_CONSTANT(JOURNAL_REMOVE_COMPASS_BOT); + BIND_ENUM_CONSTANT(STRING_MANAGER_SET_LANGUAGE); + BIND_ENUM_CONSTANT(STRING_MANAGER_PHRASE_SEND); + BIND_ENUM_CONSTANT(STRING_MANAGER_STRING_RQ); + BIND_ENUM_CONSTANT(STRING_MANAGER_STRING_RESP); + BIND_ENUM_CONSTANT(STRING_MANAGER_RELOAD_CACHE); + BIND_ENUM_CONSTANT(GUILD_CREATE); + BIND_ENUM_CONSTANT(GUILD_ABORT_CREATION); + BIND_ENUM_CONSTANT(GUILD_OPEN_GUILD_WINDOW); + BIND_ENUM_CONSTANT(GUILD_INVITATION); + BIND_ENUM_CONSTANT(GUILD_ACCEPT_INVITATION); + BIND_ENUM_CONSTANT(GUILD_REFUSE_INVITATION); + BIND_ENUM_CONSTANT(GUILD_JOIN_PROPOSAL); + BIND_ENUM_CONSTANT(GUILD_SET_GRADE); + BIND_ENUM_CONSTANT(GUILD_SET_LEADER); + BIND_ENUM_CONSTANT(GUILD_KICK_MEMBER); + BIND_ENUM_CONSTANT(GUILD_TELEPORT); + BIND_ENUM_CONSTANT(GUILD_ASCENSOR); + BIND_ENUM_CONSTANT(GUILD_FIRST_ASCENSOR_PAGE); + BIND_ENUM_CONSTANT(GUILD_NEXT_ASCENSOR_PAGE); + BIND_ENUM_CONSTANT(GUILD_LEAVE_ASCENSOR); + BIND_ENUM_CONSTANT(GUILD_QUIT); + BIND_ENUM_CONSTANT(GUILD_SET_PLAYER_TITLE); + BIND_ENUM_CONSTANT(GUILD_UPDATE_PLAYER_TITLE); + BIND_ENUM_CONSTANT(GUILD_USE_FEMALE_TITLES); + BIND_ENUM_CONSTANT(GUILD_PUT_MONEY); + BIND_ENUM_CONSTANT(GUILD_TAKE_MONEY); + BIND_ENUM_CONSTANT(GUILD_OPEN_INVENTORY); + BIND_ENUM_CONSTANT(GUILD_CLOSE_INVENTORY); + BIND_ENUM_CONSTANT(OUTPOST_GIVEUP_OUTPOST); + BIND_ENUM_CONSTANT(OUTPOST_SELECT); + BIND_ENUM_CONSTANT(OUTPOST_UNSELECT); + BIND_ENUM_CONSTANT(OUTPOST_DECLARE_WAR_START); + BIND_ENUM_CONSTANT(OUTPOST_DECLARE_WAR_ACK); + BIND_ENUM_CONSTANT(OUTPOST_DECLARE_WAR_VALIDATE); + BIND_ENUM_CONSTANT(OUTPOST_SET_DEF_PERIOD); + BIND_ENUM_CONSTANT(OUTPOST_SET_SQUAD); + BIND_ENUM_CONSTANT(OUTPOST_SET_SQUAD_SPAWN); + BIND_ENUM_CONSTANT(OUTPOST_INSERT_SQUAD); + BIND_ENUM_CONSTANT(OUTPOST_REMOVE_SQUAD); + BIND_ENUM_CONSTANT(OUTPOST_SET_SQUAD_CAPITAL); + BIND_ENUM_CONSTANT(OUTPOST_CHOOSE_SIDE); + BIND_ENUM_CONSTANT(OUTPOST_SIDE_CHOSEN); + BIND_ENUM_CONSTANT(OUTPOST_BANISH_PLAYER); + BIND_ENUM_CONSTANT(OUTPOST_BANISH_GUILD); + BIND_ENUM_CONSTANT(OUTPOST_BUY_BUILDING); + BIND_ENUM_CONSTANT(OUTPOST_DESTROY_BUILDING); + BIND_ENUM_CONSTANT(PHRASE_DELETE); + BIND_ENUM_CONSTANT(PHRASE_LEARN); + BIND_ENUM_CONSTANT(PHRASE_MEMORIZE); + BIND_ENUM_CONSTANT(PHRASE_FORGET); + BIND_ENUM_CONSTANT(PHRASE_EXECUTE); + BIND_ENUM_CONSTANT(PHRASE_EXECUTE_CYCLIC); + BIND_ENUM_CONSTANT(PHRASE_EXECUTE_FABER); + BIND_ENUM_CONSTANT(PHRASE_DOWNLOAD); + BIND_ENUM_CONSTANT(PHRASE_BUY); + BIND_ENUM_CONSTANT(PHRASE_CONFIRM_BUY); + BIND_ENUM_CONSTANT(PHRASE_BUY_SHEET); + BIND_ENUM_CONSTANT(PHRASE_CANCEL_LINK); + BIND_ENUM_CONSTANT(PHRASE_CANCEL_TOP); + BIND_ENUM_CONSTANT(PHRASE_CANCEL_ALL); + BIND_ENUM_CONSTANT(PHRASE_CRISTALIZE); + BIND_ENUM_CONSTANT(PHRASE_EXEC_CYCLIC_ACK); + BIND_ENUM_CONSTANT(PHRASE_EXEC_NEXT_ACK); + BIND_ENUM_CONSTANT(ITEM_INFO_GET); + BIND_ENUM_CONSTANT(ITEM_INFO_SET); + BIND_ENUM_CONSTANT(ITEM_INFO_REFRESH_VERSION); + BIND_ENUM_CONSTANT(MISSION_PREREQ_GET); + BIND_ENUM_CONSTANT(MISSION_PREREQ_SET); + BIND_ENUM_CONSTANT(MISSION_ENTER_CRITICAL); + BIND_ENUM_CONSTANT(MISSION_ASK_ENTER_CRITICAL); + BIND_ENUM_CONSTANT(MISSION_CLOSE_ENTER_CRITICAL); + BIND_ENUM_CONSTANT(MISSION_WAKE); + BIND_ENUM_CONSTANT(MISSION_GROUP_WAKE); + BIND_ENUM_CONSTANT(DUEL_ASK); + BIND_ENUM_CONSTANT(DUEL_ACCEPT); + BIND_ENUM_CONSTANT(DUEL_REFUSE); + BIND_ENUM_CONSTANT(DUEL_ABANDON); + BIND_ENUM_CONSTANT(DUEL_INVITATION); + BIND_ENUM_CONSTANT(DUEL_CANCEL_INVITATION); + BIND_ENUM_CONSTANT(PVP_CHALLENGE_ASK); + BIND_ENUM_CONSTANT(PVP_CHALLENGE_ACCEPT); + BIND_ENUM_CONSTANT(PVP_CHALLENGE_REFUSE); + BIND_ENUM_CONSTANT(PVP_CHALLENGE_ABANDON); + BIND_ENUM_CONSTANT(PVP_CHALLENGE_INVITATION); + BIND_ENUM_CONSTANT(PVP_CHALLENGE_CANCEL_INVITATION); + BIND_ENUM_CONSTANT(PVP_PVP_TAG); + BIND_ENUM_CONSTANT(PVP_SET_NEUTRAL_ALLEGIANCE); + BIND_ENUM_CONSTANT(PVP_SET_NEUTRAL_ALLEGIANCE_GUILD); + BIND_ENUM_CONSTANT(PVP_FACTION_PUSH_FACTION_WAR); + BIND_ENUM_CONSTANT(PVP_FACTION_POP_FACTION_WAR); + BIND_ENUM_CONSTANT(PVP_FACTION_FACTION_WARS); + BIND_ENUM_CONSTANT(ENCYCLOPEDIA_UPDATE); + BIND_ENUM_CONSTANT(ENCYCLOPEDIA_INIT); + BIND_ENUM_CONSTANT(USER_BARS); + BIND_ENUM_CONSTANT(USER_POPUP); + BIND_ENUM_CONSTANT(EVENT_SET_ITEM_CUSTOM_TEXT); + BIND_ENUM_CONSTANT(EVENT_DUMMY); + BIND_ENUM_CONSTANT(TOTEM_BUILD); + BIND_ENUM_CONSTANT(TOTEM_DUMMY); + BIND_ENUM_CONSTANT(MODULE_GATEWAY_FEOPEN); + BIND_ENUM_CONSTANT(MODULE_GATEWAY_GATEWAY_MSG); + BIND_ENUM_CONSTANT(MODULE_GATEWAY_FECLOSE); + BIND_ENUM_CONSTANT(SEASON_SET); + BIND_ENUM_CONSTANT(SEASON_DUMMY); + BIND_ENUM_CONSTANT(DM_GIFT_BEGIN); + BIND_ENUM_CONSTANT(DM_GIFT_VALIDATE); + BIND_ENUM_CONSTANT(RING_MISSION_MISSION_RING_SELECT); + BIND_ENUM_CONSTANT(RING_MISSION_DSS_DOWN); + BIND_ENUM_CONSTANT(NPC_ICON_GET_DESC); + BIND_ENUM_CONSTANT(NPC_ICON_SET_DESC); + BIND_ENUM_CONSTANT(NPC_ICON_SVR_EVENT_MIS_AVL); + BIND_ENUM_CONSTANT(NPC_ICON_SET_TIMER); + BIND_ENUM_CONSTANT(__LAST_ELEMENT); +} + +ReferentialMessageCore *ReferentialMessageCore::get_singleton() +{ + if ( ReferentialMessageCore::singleton == nullptr ) + ReferentialMessageCore::singleton = new ReferentialMessageCore(); + return ReferentialMessageCore::singleton; +} + +int ReferentialMessageCore::get_command(String name) +{ + if( name == "TARGET_PARTY" ) { + return Command::TARGET_PARTY; + } else if( name == "TARGET_INVENTORY" ) { + return Command::TARGET_INVENTORY; + } else if( name == "TARGET_FOLLOW" ) { + return Command::TARGET_FOLLOW; + } else if( name == "TARGET_NO_FOLLOW" ) { + return Command::TARGET_NO_FOLLOW; + } else if( name == "CONNECTION_USER_CHAR" ) { + return Command::CONNECTION_USER_CHAR; + } else if( name == "CONNECTION_NO_USER_CHAR" ) { + return Command::CONNECTION_NO_USER_CHAR; + } else if( name == "CONNECTION_USER_CHARS" ) { + return Command::CONNECTION_USER_CHARS; + } else if( name == "CONNECTION_CREATE_CHAR" ) { + return Command::CONNECTION_CREATE_CHAR; + } else if( name == "CONNECTION_SELECT_CHAR" ) { + return Command::CONNECTION_SELECT_CHAR; + } else if( name == "CONNECTION_DELETE_CHAR" ) { + return Command::CONNECTION_DELETE_CHAR; + } else if( name == "CONNECTION_RENAME_CHAR" ) { + return Command::CONNECTION_RENAME_CHAR; + } else if( name == "CONNECTION_ENTER" ) { + return Command::CONNECTION_ENTER; + } else if( name == "CONNECTION_READY" ) { + return Command::CONNECTION_READY; + } else if( name == "CONNECTION_TIME_DATE_SYNCHRO" ) { + return Command::CONNECTION_TIME_DATE_SYNCHRO; + } else if( name == "CONNECTION_ASK_NAME" ) { + return Command::CONNECTION_ASK_NAME; + } else if( name == "CONNECTION_VALID_NAME" ) { + return Command::CONNECTION_VALID_NAME; + } else if( name == "CONNECTION_CREATE_CHAR_ERROR" ) { + return Command::CONNECTION_CREATE_CHAR_ERROR; + } else if( name == "CONNECTION_RECONNECT" ) { + return Command::CONNECTION_RECONNECT; + } else if( name == "CONNECTION_SERVER_RECONNECT_OK" ) { + return Command::CONNECTION_SERVER_RECONNECT_OK; + } else if( name == "CONNECTION_SHARD_ID" ) { + return Command::CONNECTION_SHARD_ID; + } else if( name == "CONNECTION_SERVER_QUIT_OK" ) { + return Command::CONNECTION_SERVER_QUIT_OK; + } else if( name == "CONNECTION_SERVER_QUIT_ABORT" ) { + return Command::CONNECTION_SERVER_QUIT_ABORT; + } else if( name == "CONNECTION_CLIENT_QUIT_REQUEST" ) { + return Command::CONNECTION_CLIENT_QUIT_REQUEST; + } else if( name == "CONNECTION_MAIL_AVAILABLE" ) { + return Command::CONNECTION_MAIL_AVAILABLE; + } else if( name == "CONNECTION_GUILD_MESSAGE_AVAILABLE" ) { + return Command::CONNECTION_GUILD_MESSAGE_AVAILABLE; + } else if( name == "CONNECTION_PERMANENT_BAN" ) { + return Command::CONNECTION_PERMANENT_BAN; + } else if( name == "CONNECTION_UNBAN" ) { + return Command::CONNECTION_UNBAN; + } else if( name == "CONNECTION_FAR_TP" ) { + return Command::CONNECTION_FAR_TP; + } else if( name == "CONNECTION_RET_MAINLAND" ) { + return Command::CONNECTION_RET_MAINLAND; + } else if( name == "DB_UPD_PLR" ) { + return Command::DB_UPD_PLR; + } else if( name == "DB_UPD_INV" ) { + return Command::DB_UPD_INV; + } else if( name == "DB_INIT_PLR" ) { + return Command::DB_INIT_PLR; + } else if( name == "DB_INIT_INV" ) { + return Command::DB_INIT_INV; + } else if( name == "DB_GROUP_UPDATE_BANK" ) { + return Command::DB_GROUP_UPDATE_BANK; + } else if( name == "DB_GROUP_INIT_BANK" ) { + return Command::DB_GROUP_INIT_BANK; + } else if( name == "DB_GROUP_RESET_BANK" ) { + return Command::DB_GROUP_RESET_BANK; + } else if( name == "POSITION" ) { + return Command::POSITION; + } else if( name == "HARVEST_DEPOSIT" ) { + return Command::HARVEST_DEPOSIT; + } else if( name == "HARVEST_CORPSE" ) { + return Command::HARVEST_CORPSE; + } else if( name == "HARVEST_INTERRUPT" ) { + return Command::HARVEST_INTERRUPT; + } else if( name == "HARVEST_CLOSE_TEMP_INVENTORY" ) { + return Command::HARVEST_CLOSE_TEMP_INVENTORY; + } else if( name == "TRAINING" ) { + return Command::TRAINING; + } else if( name == "JOB_SET_JOB_STATUS" ) { + return Command::JOB_SET_JOB_STATUS; + } else if( name == "JOB_SWAP_JOB_STATUS" ) { + return Command::JOB_SWAP_JOB_STATUS; + } else if( name == "CASTING_BEGIN" ) { + return Command::CASTING_BEGIN; + } else if( name == "CASTING_INTERRUPT" ) { + return Command::CASTING_INTERRUPT; + } else if( name == "FABER_OPEN" ) { + return Command::FABER_OPEN; + } else if( name == "FABER_CLOSE" ) { + return Command::FABER_CLOSE; + } else if( name == "FABER_EXECUTE" ) { + return Command::FABER_EXECUTE; + } else if( name == "FABER_SET_NUM_ITEM" ) { + return Command::FABER_SET_NUM_ITEM; + } else if( name == "FABER_START_CREATE" ) { + return Command::FABER_START_CREATE; + } else if( name == "FABER_START_REPAIR" ) { + return Command::FABER_START_REPAIR; + } else if( name == "FABER_START_REFINE" ) { + return Command::FABER_START_REFINE; + } else if( name == "FABER_SET_MP_QUALITY" ) { + return Command::FABER_SET_MP_QUALITY; + } else if( name == "FABER_SET_MP_REFINE" ) { + return Command::FABER_SET_MP_REFINE; + } else if( name == "FABER_SET_TOOL" ) { + return Command::FABER_SET_TOOL; + } else if( name == "FABER_RESET_TOOL" ) { + return Command::FABER_RESET_TOOL; + } else if( name == "FABER_INTERRUPT" ) { + return Command::FABER_INTERRUPT; + } else if( name == "COMBAT_ENGAGE" ) { + return Command::COMBAT_ENGAGE; + } else if( name == "COMBAT_DISENGAGE" ) { + return Command::COMBAT_DISENGAGE; + } else if( name == "COMBAT_DEFAULT_ATTACK" ) { + return Command::COMBAT_DEFAULT_ATTACK; + } else if( name == "COMBAT_ENGAGE_FAILED" ) { + return Command::COMBAT_ENGAGE_FAILED; + } else if( name == "COMBAT_VALIDATE_MELEE" ) { + return Command::COMBAT_VALIDATE_MELEE; + } else if( name == "COMBAT_PARRY" ) { + return Command::COMBAT_PARRY; + } else if( name == "COMBAT_DODGE" ) { + return Command::COMBAT_DODGE; + } else if( name == "COMBAT_PROTECTED_SLOT" ) { + return Command::COMBAT_PROTECTED_SLOT; + } else if( name == "COMBAT_FLYING_ChaScore1_DELTA" ) { + return Command::COMBAT_FLYING_ChaScore1_DELTA; + } else if( name == "COMBAT_FLYING_TEXT_ISE" ) { + return Command::COMBAT_FLYING_TEXT_ISE; + } else if( name == "COMBAT_FLYING_TEXT" ) { + return Command::COMBAT_FLYING_TEXT; + } else if( name == "STRING_TELL" ) { + return Command::STRING_TELL; + } else if( name == "STRING_FAR_TELL" ) { + return Command::STRING_FAR_TELL; + } else if( name == "STRING_CHAT" ) { + return Command::STRING_CHAT; + } else if( name == "STRING_CHAT_TEAM" ) { + return Command::STRING_CHAT_TEAM; + } else if( name == "STRING_ADD_DYN_STR" ) { + return Command::STRING_ADD_DYN_STR; + } else if( name == "STRING_FILTER" ) { + return Command::STRING_FILTER; + } else if( name == "STRING_CHAT_MODE" ) { + return Command::STRING_CHAT_MODE; + } else if( name == "STRING_CHAT2" ) { + return Command::STRING_CHAT2; + } else if( name == "STRING_TELL2" ) { + return Command::STRING_TELL2; + } else if( name == "STRING_DYN_STRING" ) { + return Command::STRING_DYN_STRING; + } else if( name == "STRING_DYN_STRING_GROUP" ) { + return Command::STRING_DYN_STRING_GROUP; + } else if( name == "STRING_AFK_TXT" ) { + return Command::STRING_AFK_TXT; + } else if( name == "STUN_STUN" ) { + return Command::STUN_STUN; + } else if( name == "STUN_WAKE_UP" ) { + return Command::STUN_WAKE_UP; + } else if( name == "SENTENCE_EXECUTE" ) { + return Command::SENTENCE_EXECUTE; + } else if( name == "SENTENCE_CANCEL" ) { + return Command::SENTENCE_CANCEL; + } else if( name == "SENTENCE_CANCEL_CURRENT" ) { + return Command::SENTENCE_CANCEL_CURRENT; + } else if( name == "SENTENCE_CANCEL_ALL" ) { + return Command::SENTENCE_CANCEL_ALL; + } else if( name == "SENTENCE_CLEAR" ) { + return Command::SENTENCE_CLEAR; + } else if( name == "SENTENCE_MEMORIZE" ) { + return Command::SENTENCE_MEMORIZE; + } else if( name == "SENTENCE_FORGET" ) { + return Command::SENTENCE_FORGET; + } else if( name == "SENTENCE_EVALUATE" ) { + return Command::SENTENCE_EVALUATE; + } else if( name == "SENTENCE_ADD_BRICK" ) { + return Command::SENTENCE_ADD_BRICK; + } else if( name == "SENTENCE_REMOVE_BRICK" ) { + return Command::SENTENCE_REMOVE_BRICK; + } else if( name == "SENTENCE_START" ) { + return Command::SENTENCE_START; + } else if( name == "SENTENCE_STOP" ) { + return Command::SENTENCE_STOP; + } else if( name == "TEAM_JOIN" ) { + return Command::TEAM_JOIN; + } else if( name == "TEAM_LEAVE" ) { + return Command::TEAM_LEAVE; + } else if( name == "TEAM_INVITATION" ) { + return Command::TEAM_INVITATION; + } else if( name == "TEAM_JOIN_PROPOSAL" ) { + return Command::TEAM_JOIN_PROPOSAL; + } else if( name == "TEAM_JOIN_PROPOSAL_DECLINE" ) { + return Command::TEAM_JOIN_PROPOSAL_DECLINE; + } else if( name == "TEAM_KICK" ) { + return Command::TEAM_KICK; + } else if( name == "TEAM_SET_SUCCESSOR" ) { + return Command::TEAM_SET_SUCCESSOR; + } else if( name == "TEAM_SHARE_OPEN" ) { + return Command::TEAM_SHARE_OPEN; + } else if( name == "TEAM_SHARE_VALID_ITEM" ) { + return Command::TEAM_SHARE_VALID_ITEM; + } else if( name == "TEAM_SHARE_INVALID_ITEM" ) { + return Command::TEAM_SHARE_INVALID_ITEM; + } else if( name == "TEAM_SHARE_VALID" ) { + return Command::TEAM_SHARE_VALID; + } else if( name == "TEAM_SHARE_INVALID" ) { + return Command::TEAM_SHARE_INVALID; + } else if( name == "TEAM_SHARE_CLOSE" ) { + return Command::TEAM_SHARE_CLOSE; + } else if( name == "TEAM_CONTACT_INIT" ) { + return Command::TEAM_CONTACT_INIT; + } else if( name == "TEAM_CONTACT_ADD" ) { + return Command::TEAM_CONTACT_ADD; + } else if( name == "TEAM_CONTACT_DEL" ) { + return Command::TEAM_CONTACT_DEL; + } else if( name == "TEAM_CONTACT_MOVE" ) { + return Command::TEAM_CONTACT_MOVE; + } else if( name == "TEAM_CONTACT_CREATE" ) { + return Command::TEAM_CONTACT_CREATE; + } else if( name == "TEAM_CONTACT_STATUS" ) { + return Command::TEAM_CONTACT_STATUS; + } else if( name == "TEAM_CONTACT_REMOVE" ) { + return Command::TEAM_CONTACT_REMOVE; + } else if( name == "ITEM_DROP" ) { + return Command::ITEM_DROP; + } else if( name == "ITEM_PICK_UP" ) { + return Command::ITEM_PICK_UP; + } else if( name == "ITEM_PICK_UP_CLOSE" ) { + return Command::ITEM_PICK_UP_CLOSE; + } else if( name == "ITEM_SWAP" ) { + return Command::ITEM_SWAP; + } else if( name == "ITEM_ACTIVATE_SHEATH" ) { + return Command::ITEM_ACTIVATE_SHEATH; + } else if( name == "ITEM_HARVEST" ) { + return Command::ITEM_HARVEST; + } else if( name == "ITEM_HARVEST_CLOSE" ) { + return Command::ITEM_HARVEST_CLOSE; + } else if( name == "ITEM_GIVE" ) { + return Command::ITEM_GIVE; + } else if( name == "ITEM_DESTROY" ) { + return Command::ITEM_DESTROY; + } else if( name == "ITEM_EQUIP" ) { + return Command::ITEM_EQUIP; + } else if( name == "ITEM_UNEQUIP" ) { + return Command::ITEM_UNEQUIP; + } else if( name == "ITEM_TEMP_TO_BAG" ) { + return Command::ITEM_TEMP_TO_BAG; + } else if( name == "ITEM_ALL_TEMP" ) { + return Command::ITEM_ALL_TEMP; + } else if( name == "ITEM_NO_TEMP" ) { + return Command::ITEM_NO_TEMP; + } else if( name == "ITEM_ENCHANT" ) { + return Command::ITEM_ENCHANT; + } else if( name == "ITEM_OPEN_ROOM_INVENTORY" ) { + return Command::ITEM_OPEN_ROOM_INVENTORY; + } else if( name == "ITEM_CLOSE_ROOM_INVENTORY" ) { + return Command::ITEM_CLOSE_ROOM_INVENTORY; + } else if( name == "ITEM_USE_ITEM" ) { + return Command::ITEM_USE_ITEM; + } else if( name == "ITEM_STOP_USE_XP_CAT" ) { + return Command::ITEM_STOP_USE_XP_CAT; + } else if( name == "TP_RESPAWN" ) { + return Command::TP_RESPAWN; + } else if( name == "TP_BOT" ) { + return Command::TP_BOT; + } else if( name == "TP_WANTED" ) { + return Command::TP_WANTED; + } else if( name == "TP_DEST" ) { + return Command::TP_DEST; + } else if( name == "TP_DEST_WITH_SEASON" ) { + return Command::TP_DEST_WITH_SEASON; + } else if( name == "TP_ACK" ) { + return Command::TP_ACK; + } else if( name == "TP_CORRECT" ) { + return Command::TP_CORRECT; + } else if( name == "DEATH_RESPAWN_POINT" ) { + return Command::DEATH_RESPAWN_POINT; + } else if( name == "DEATH_ASK_RESPAWN" ) { + return Command::DEATH_ASK_RESPAWN; + } else if( name == "DEATH_RESPAWN" ) { + return Command::DEATH_RESPAWN; + } else if( name == "ANIMALS_BEAST" ) { + return Command::ANIMALS_BEAST; + } else if( name == "ANIMALS_MOUNT_ABORT" ) { + return Command::ANIMALS_MOUNT_ABORT; + } else if( name == "EXCHANGE_INVITATION" ) { + return Command::EXCHANGE_INVITATION; + } else if( name == "EXCHANGE_CLOSE_INVITATION" ) { + return Command::EXCHANGE_CLOSE_INVITATION; + } else if( name == "EXCHANGE_PROPOSAL" ) { + return Command::EXCHANGE_PROPOSAL; + } else if( name == "EXCHANGE_ACCEPT_INVITATION" ) { + return Command::EXCHANGE_ACCEPT_INVITATION; + } else if( name == "EXCHANGE_DECLINE_INVITATION" ) { + return Command::EXCHANGE_DECLINE_INVITATION; + } else if( name == "EXCHANGE_VALIDATE" ) { + return Command::EXCHANGE_VALIDATE; + } else if( name == "EXCHANGE_INVALIDATE" ) { + return Command::EXCHANGE_INVALIDATE; + } else if( name == "EXCHANGE_END" ) { + return Command::EXCHANGE_END; + } else if( name == "EXCHANGE_SEEDS" ) { + return Command::EXCHANGE_SEEDS; + } else if( name == "EXCHANGE_ADD" ) { + return Command::EXCHANGE_ADD; + } else if( name == "EXCHANGE_REMOVE" ) { + return Command::EXCHANGE_REMOVE; + } else if( name == "DEBUG_WHERE" ) { + return Command::DEBUG_WHERE; + } else if( name == "DEBUG_WHO" ) { + return Command::DEBUG_WHO; + } else if( name == "DEBUG_REPLY_WHERE" ) { + return Command::DEBUG_REPLY_WHERE; + } else if( name == "DEBUG_SERVICES" ) { + return Command::DEBUG_SERVICES; + } else if( name == "DEBUG_CMD" ) { + return Command::DEBUG_CMD; + } else if( name == "DEBUG_PING" ) { + return Command::DEBUG_PING; + } else if( name == "DEBUG_COUNTER" ) { + return Command::DEBUG_COUNTER; + } else if( name == "COMMAND_EMOTE" ) { + return Command::COMMAND_EMOTE; + } else if( name == "COMMAND_CUSTOM_EMOTE" ) { + return Command::COMMAND_CUSTOM_EMOTE; + } else if( name == "COMMAND_WHERE" ) { + return Command::COMMAND_WHERE; + } else if( name == "COMMAND_ADMIN" ) { + return Command::COMMAND_ADMIN; + } else if( name == "COMMAND_ADMIN_OFFLINE" ) { + return Command::COMMAND_ADMIN_OFFLINE; + } else if( name == "COMMAND_REMOTE_ADMIN" ) { + return Command::COMMAND_REMOTE_ADMIN; + } else if( name == "COMMAND_REMOTE_ADMIN_ANSWER" ) { + return Command::COMMAND_REMOTE_ADMIN_ANSWER; + } else if( name == "COMMAND_SIT" ) { + return Command::COMMAND_SIT; + } else if( name == "COMMAND_AFK" ) { + return Command::COMMAND_AFK; + } else if( name == "COMMAND_RANDOM" ) { + return Command::COMMAND_RANDOM; + } else if( name == "COMMAND_GUILDMOTD" ) { + return Command::COMMAND_GUILDMOTD; + } else if( name == "MP_EVAL_SET_MP" ) { + return Command::MP_EVAL_SET_MP; + } else if( name == "MP_EVAL_SET_MP_LEVEL" ) { + return Command::MP_EVAL_SET_MP_LEVEL; + } else if( name == "MP_EVAL_SET_MARKET" ) { + return Command::MP_EVAL_SET_MARKET; + } else if( name == "MP_EVAL_EXECUTE" ) { + return Command::MP_EVAL_EXECUTE; + } else if( name == "BOTCHAT_NEXT_PAGE_ITEM" ) { + return Command::BOTCHAT_NEXT_PAGE_ITEM; + } else if( name == "BOTCHAT_NEXT_PAGE_MISSION" ) { + return Command::BOTCHAT_NEXT_PAGE_MISSION; + } else if( name == "BOTCHAT_START_TRADE_ITEM" ) { + return Command::BOTCHAT_START_TRADE_ITEM; + } else if( name == "BOTCHAT_START_TRADE_TELEPORT" ) { + return Command::BOTCHAT_START_TRADE_TELEPORT; + } else if( name == "BOTCHAT_START_TRADE_FACTION" ) { + return Command::BOTCHAT_START_TRADE_FACTION; + } else if( name == "BOTCHAT_START_TRADE_SKILL" ) { + return Command::BOTCHAT_START_TRADE_SKILL; + } else if( name == "BOTCHAT_START_TRADE_PACT" ) { + return Command::BOTCHAT_START_TRADE_PACT; + } else if( name == "BOTCHAT_START_TRADE_ACTION" ) { + return Command::BOTCHAT_START_TRADE_ACTION; + } else if( name == "BOTCHAT_BUY" ) { + return Command::BOTCHAT_BUY; + } else if( name == "BOTCHAT_SELL" ) { + return Command::BOTCHAT_SELL; + } else if( name == "BOTCHAT_DESTROY_ITEM" ) { + return Command::BOTCHAT_DESTROY_ITEM; + } else if( name == "BOTCHAT_REFRESH_TRADE_LIST" ) { + return Command::BOTCHAT_REFRESH_TRADE_LIST; + } else if( name == "BOTCHAT_SET_FILTERS" ) { + return Command::BOTCHAT_SET_FILTERS; + } else if( name == "BOTCHAT_START_CHOOSE_MISSION" ) { + return Command::BOTCHAT_START_CHOOSE_MISSION; + } else if( name == "BOTCHAT_START_DYNAMIC_MISSION" ) { + return Command::BOTCHAT_START_DYNAMIC_MISSION; + } else if( name == "BOTCHAT_CONTINUE_MISSION" ) { + return Command::BOTCHAT_CONTINUE_MISSION; + } else if( name == "BOTCHAT_VALIDATE_PLAYER_GIFT" ) { + return Command::BOTCHAT_VALIDATE_PLAYER_GIFT; + } else if( name == "BOTCHAT_PICK_MISSION" ) { + return Command::BOTCHAT_PICK_MISSION; + } else if( name == "BOTCHAT_DM_CHOICE" ) { + return Command::BOTCHAT_DM_CHOICE; + } else if( name == "BOTCHAT_DM_ACCEPT" ) { + return Command::BOTCHAT_DM_ACCEPT; + } else if( name == "BOTCHAT_START_NEWS" ) { + return Command::BOTCHAT_START_NEWS; + } else if( name == "BOTCHAT_START_CREATE_GUILD" ) { + return Command::BOTCHAT_START_CREATE_GUILD; + } else if( name == "BOTCHAT_END" ) { + return Command::BOTCHAT_END; + } else if( name == "BOTCHAT_FORCE_END" ) { + return Command::BOTCHAT_FORCE_END; + } else if( name == "BOTCHAT_START_CHOOSE_DUTY" ) { + return Command::BOTCHAT_START_CHOOSE_DUTY; + } else if( name == "BOTCHAT_NEXT_PAGE_DUTY" ) { + return Command::BOTCHAT_NEXT_PAGE_DUTY; + } else if( name == "BOTCHAT_DUTY_APPLY" ) { + return Command::BOTCHAT_DUTY_APPLY; + } else if( name == "BOTCHAT_DUTY_CANCEL_APPLY" ) { + return Command::BOTCHAT_DUTY_CANCEL_APPLY; + } else if( name == "BOTCHAT_START_TRADE_GUILD_OPTIONS" ) { + return Command::BOTCHAT_START_TRADE_GUILD_OPTIONS; + } else if( name == "BOTCHAT_BUY_GUILD_OPTION" ) { + return Command::BOTCHAT_BUY_GUILD_OPTION; + } else if( name == "BOTCHAT_START_GUILD_RESEARCH" ) { + return Command::BOTCHAT_START_GUILD_RESEARCH; + } else if( name == "BOTCHAT_DESTROY_BUILDING" ) { + return Command::BOTCHAT_DESTROY_BUILDING; + } else if( name == "BOTCHAT_DYNCHAT_OPEN" ) { + return Command::BOTCHAT_DYNCHAT_OPEN; + } else if( name == "BOTCHAT_DYNCHAT_CLOSE" ) { + return Command::BOTCHAT_DYNCHAT_CLOSE; + } else if( name == "BOTCHAT_DYNCHAT_SEND" ) { + return Command::BOTCHAT_DYNCHAT_SEND; + } else if( name == "JOURNAL_INIT_COMPLETED_MISSIONS" ) { + return Command::JOURNAL_INIT_COMPLETED_MISSIONS; + } else if( name == "JOURNAL_UPDATE_COMPLETED_MISSIONS" ) { + return Command::JOURNAL_UPDATE_COMPLETED_MISSIONS; + } else if( name == "JOURNAL_MISSION_ABANDON" ) { + return Command::JOURNAL_MISSION_ABANDON; + } else if( name == "JOURNAL_GROUP_MISSION_ABANDON" ) { + return Command::JOURNAL_GROUP_MISSION_ABANDON; + } else if( name == "JOURNAL_ADD_COMPASS" ) { + return Command::JOURNAL_ADD_COMPASS; + } else if( name == "JOURNAL_ADD_COMPASS_BOT" ) { + return Command::JOURNAL_ADD_COMPASS_BOT; + } else if( name == "JOURNAL_REMOVE_COMPASS" ) { + return Command::JOURNAL_REMOVE_COMPASS; + } else if( name == "JOURNAL_REMOVE_COMPASS_BOT" ) { + return Command::JOURNAL_REMOVE_COMPASS_BOT; + } else if( name == "STRING_MANAGER_SET_LANGUAGE" ) { + return Command::STRING_MANAGER_SET_LANGUAGE; + } else if( name == "STRING_MANAGER_PHRASE_SEND" ) { + return Command::STRING_MANAGER_PHRASE_SEND; + } else if( name == "STRING_MANAGER_STRING_RQ" ) { + return Command::STRING_MANAGER_STRING_RQ; + } else if( name == "STRING_MANAGER_STRING_RESP" ) { + return Command::STRING_MANAGER_STRING_RESP; + } else if( name == "STRING_MANAGER_RELOAD_CACHE" ) { + return Command::STRING_MANAGER_RELOAD_CACHE; + } else if( name == "GUILD_CREATE" ) { + return Command::GUILD_CREATE; + } else if( name == "GUILD_ABORT_CREATION" ) { + return Command::GUILD_ABORT_CREATION; + } else if( name == "GUILD_OPEN_GUILD_WINDOW" ) { + return Command::GUILD_OPEN_GUILD_WINDOW; + } else if( name == "GUILD_INVITATION" ) { + return Command::GUILD_INVITATION; + } else if( name == "GUILD_ACCEPT_INVITATION" ) { + return Command::GUILD_ACCEPT_INVITATION; + } else if( name == "GUILD_REFUSE_INVITATION" ) { + return Command::GUILD_REFUSE_INVITATION; + } else if( name == "GUILD_JOIN_PROPOSAL" ) { + return Command::GUILD_JOIN_PROPOSAL; + } else if( name == "GUILD_SET_GRADE" ) { + return Command::GUILD_SET_GRADE; + } else if( name == "GUILD_SET_LEADER" ) { + return Command::GUILD_SET_LEADER; + } else if( name == "GUILD_KICK_MEMBER" ) { + return Command::GUILD_KICK_MEMBER; + } else if( name == "GUILD_TELEPORT" ) { + return Command::GUILD_TELEPORT; + } else if( name == "GUILD_ASCENSOR" ) { + return Command::GUILD_ASCENSOR; + } else if( name == "GUILD_FIRST_ASCENSOR_PAGE" ) { + return Command::GUILD_FIRST_ASCENSOR_PAGE; + } else if( name == "GUILD_NEXT_ASCENSOR_PAGE" ) { + return Command::GUILD_NEXT_ASCENSOR_PAGE; + } else if( name == "GUILD_LEAVE_ASCENSOR" ) { + return Command::GUILD_LEAVE_ASCENSOR; + } else if( name == "GUILD_QUIT" ) { + return Command::GUILD_QUIT; + } else if( name == "GUILD_SET_PLAYER_TITLE" ) { + return Command::GUILD_SET_PLAYER_TITLE; + } else if( name == "GUILD_UPDATE_PLAYER_TITLE" ) { + return Command::GUILD_UPDATE_PLAYER_TITLE; + } else if( name == "GUILD_USE_FEMALE_TITLES" ) { + return Command::GUILD_USE_FEMALE_TITLES; + } else if( name == "GUILD_PUT_MONEY" ) { + return Command::GUILD_PUT_MONEY; + } else if( name == "GUILD_TAKE_MONEY" ) { + return Command::GUILD_TAKE_MONEY; + } else if( name == "GUILD_OPEN_INVENTORY" ) { + return Command::GUILD_OPEN_INVENTORY; + } else if( name == "GUILD_CLOSE_INVENTORY" ) { + return Command::GUILD_CLOSE_INVENTORY; + } else if( name == "OUTPOST_GIVEUP_OUTPOST" ) { + return Command::OUTPOST_GIVEUP_OUTPOST; + } else if( name == "OUTPOST_SELECT" ) { + return Command::OUTPOST_SELECT; + } else if( name == "OUTPOST_UNSELECT" ) { + return Command::OUTPOST_UNSELECT; + } else if( name == "OUTPOST_DECLARE_WAR_START" ) { + return Command::OUTPOST_DECLARE_WAR_START; + } else if( name == "OUTPOST_DECLARE_WAR_ACK" ) { + return Command::OUTPOST_DECLARE_WAR_ACK; + } else if( name == "OUTPOST_DECLARE_WAR_VALIDATE" ) { + return Command::OUTPOST_DECLARE_WAR_VALIDATE; + } else if( name == "OUTPOST_SET_DEF_PERIOD" ) { + return Command::OUTPOST_SET_DEF_PERIOD; + } else if( name == "OUTPOST_SET_SQUAD" ) { + return Command::OUTPOST_SET_SQUAD; + } else if( name == "OUTPOST_SET_SQUAD_SPAWN" ) { + return Command::OUTPOST_SET_SQUAD_SPAWN; + } else if( name == "OUTPOST_INSERT_SQUAD" ) { + return Command::OUTPOST_INSERT_SQUAD; + } else if( name == "OUTPOST_REMOVE_SQUAD" ) { + return Command::OUTPOST_REMOVE_SQUAD; + } else if( name == "OUTPOST_SET_SQUAD_CAPITAL" ) { + return Command::OUTPOST_SET_SQUAD_CAPITAL; + } else if( name == "OUTPOST_CHOOSE_SIDE" ) { + return Command::OUTPOST_CHOOSE_SIDE; + } else if( name == "OUTPOST_SIDE_CHOSEN" ) { + return Command::OUTPOST_SIDE_CHOSEN; + } else if( name == "OUTPOST_BANISH_PLAYER" ) { + return Command::OUTPOST_BANISH_PLAYER; + } else if( name == "OUTPOST_BANISH_GUILD" ) { + return Command::OUTPOST_BANISH_GUILD; + } else if( name == "OUTPOST_BUY_BUILDING" ) { + return Command::OUTPOST_BUY_BUILDING; + } else if( name == "OUTPOST_DESTROY_BUILDING" ) { + return Command::OUTPOST_DESTROY_BUILDING; + } else if( name == "PHRASE_DELETE" ) { + return Command::PHRASE_DELETE; + } else if( name == "PHRASE_LEARN" ) { + return Command::PHRASE_LEARN; + } else if( name == "PHRASE_MEMORIZE" ) { + return Command::PHRASE_MEMORIZE; + } else if( name == "PHRASE_FORGET" ) { + return Command::PHRASE_FORGET; + } else if( name == "PHRASE_EXECUTE" ) { + return Command::PHRASE_EXECUTE; + } else if( name == "PHRASE_EXECUTE_CYCLIC" ) { + return Command::PHRASE_EXECUTE_CYCLIC; + } else if( name == "PHRASE_EXECUTE_FABER" ) { + return Command::PHRASE_EXECUTE_FABER; + } else if( name == "PHRASE_DOWNLOAD" ) { + return Command::PHRASE_DOWNLOAD; + } else if( name == "PHRASE_BUY" ) { + return Command::PHRASE_BUY; + } else if( name == "PHRASE_CONFIRM_BUY" ) { + return Command::PHRASE_CONFIRM_BUY; + } else if( name == "PHRASE_BUY_SHEET" ) { + return Command::PHRASE_BUY_SHEET; + } else if( name == "PHRASE_CANCEL_LINK" ) { + return Command::PHRASE_CANCEL_LINK; + } else if( name == "PHRASE_CANCEL_TOP" ) { + return Command::PHRASE_CANCEL_TOP; + } else if( name == "PHRASE_CANCEL_ALL" ) { + return Command::PHRASE_CANCEL_ALL; + } else if( name == "PHRASE_CRISTALIZE" ) { + return Command::PHRASE_CRISTALIZE; + } else if( name == "PHRASE_EXEC_CYCLIC_ACK" ) { + return Command::PHRASE_EXEC_CYCLIC_ACK; + } else if( name == "PHRASE_EXEC_NEXT_ACK" ) { + return Command::PHRASE_EXEC_NEXT_ACK; + } else if( name == "ITEM_INFO_GET" ) { + return Command::ITEM_INFO_GET; + } else if( name == "ITEM_INFO_SET" ) { + return Command::ITEM_INFO_SET; + } else if( name == "ITEM_INFO_REFRESH_VERSION" ) { + return Command::ITEM_INFO_REFRESH_VERSION; + } else if( name == "MISSION_PREREQ_GET" ) { + return Command::MISSION_PREREQ_GET; + } else if( name == "MISSION_PREREQ_SET" ) { + return Command::MISSION_PREREQ_SET; + } else if( name == "MISSION_ENTER_CRITICAL" ) { + return Command::MISSION_ENTER_CRITICAL; + } else if( name == "MISSION_ASK_ENTER_CRITICAL" ) { + return Command::MISSION_ASK_ENTER_CRITICAL; + } else if( name == "MISSION_CLOSE_ENTER_CRITICAL" ) { + return Command::MISSION_CLOSE_ENTER_CRITICAL; + } else if( name == "MISSION_WAKE" ) { + return Command::MISSION_WAKE; + } else if( name == "MISSION_GROUP_WAKE" ) { + return Command::MISSION_GROUP_WAKE; + } else if( name == "DUEL_ASK" ) { + return Command::DUEL_ASK; + } else if( name == "DUEL_ACCEPT" ) { + return Command::DUEL_ACCEPT; + } else if( name == "DUEL_REFUSE" ) { + return Command::DUEL_REFUSE; + } else if( name == "DUEL_ABANDON" ) { + return Command::DUEL_ABANDON; + } else if( name == "DUEL_INVITATION" ) { + return Command::DUEL_INVITATION; + } else if( name == "DUEL_CANCEL_INVITATION" ) { + return Command::DUEL_CANCEL_INVITATION; + } else if( name == "PVP_CHALLENGE_ASK" ) { + return Command::PVP_CHALLENGE_ASK; + } else if( name == "PVP_CHALLENGE_ACCEPT" ) { + return Command::PVP_CHALLENGE_ACCEPT; + } else if( name == "PVP_CHALLENGE_REFUSE" ) { + return Command::PVP_CHALLENGE_REFUSE; + } else if( name == "PVP_CHALLENGE_ABANDON" ) { + return Command::PVP_CHALLENGE_ABANDON; + } else if( name == "PVP_CHALLENGE_INVITATION" ) { + return Command::PVP_CHALLENGE_INVITATION; + } else if( name == "PVP_CHALLENGE_CANCEL_INVITATION" ) { + return Command::PVP_CHALLENGE_CANCEL_INVITATION; + } else if( name == "PVP_PVP_TAG" ) { + return Command::PVP_PVP_TAG; + } else if( name == "PVP_SET_NEUTRAL_ALLEGIANCE" ) { + return Command::PVP_SET_NEUTRAL_ALLEGIANCE; + } else if( name == "PVP_SET_NEUTRAL_ALLEGIANCE_GUILD" ) { + return Command::PVP_SET_NEUTRAL_ALLEGIANCE_GUILD; + } else if( name == "PVP_FACTION_PUSH_FACTION_WAR" ) { + return Command::PVP_FACTION_PUSH_FACTION_WAR; + } else if( name == "PVP_FACTION_POP_FACTION_WAR" ) { + return Command::PVP_FACTION_POP_FACTION_WAR; + } else if( name == "PVP_FACTION_FACTION_WARS" ) { + return Command::PVP_FACTION_FACTION_WARS; + } else if( name == "ENCYCLOPEDIA_UPDATE" ) { + return Command::ENCYCLOPEDIA_UPDATE; + } else if( name == "ENCYCLOPEDIA_INIT" ) { + return Command::ENCYCLOPEDIA_INIT; + } else if( name == "USER_BARS" ) { + return Command::USER_BARS; + } else if( name == "USER_POPUP" ) { + return Command::USER_POPUP; + } else if( name == "EVENT_SET_ITEM_CUSTOM_TEXT" ) { + return Command::EVENT_SET_ITEM_CUSTOM_TEXT; + } else if( name == "EVENT_DUMMY" ) { + return Command::EVENT_DUMMY; + } else if( name == "TOTEM_BUILD" ) { + return Command::TOTEM_BUILD; + } else if( name == "TOTEM_DUMMY" ) { + return Command::TOTEM_DUMMY; + } else if( name == "MODULE_GATEWAY_FEOPEN" ) { + return Command::MODULE_GATEWAY_FEOPEN; + } else if( name == "MODULE_GATEWAY_GATEWAY_MSG" ) { + return Command::MODULE_GATEWAY_GATEWAY_MSG; + } else if( name == "MODULE_GATEWAY_FECLOSE" ) { + return Command::MODULE_GATEWAY_FECLOSE; + } else if( name == "SEASON_SET" ) { + return Command::SEASON_SET; + } else if( name == "SEASON_DUMMY" ) { + return Command::SEASON_DUMMY; + } else if( name == "DM_GIFT_BEGIN" ) { + return Command::DM_GIFT_BEGIN; + } else if( name == "DM_GIFT_VALIDATE" ) { + return Command::DM_GIFT_VALIDATE; + } else if( name == "RING_MISSION_MISSION_RING_SELECT" ) { + return Command::RING_MISSION_MISSION_RING_SELECT; + } else if( name == "RING_MISSION_DSS_DOWN" ) { + return Command::RING_MISSION_DSS_DOWN; + } else if( name == "NPC_ICON_GET_DESC" ) { + return Command::NPC_ICON_GET_DESC; + } else if( name == "NPC_ICON_SET_DESC" ) { + return Command::NPC_ICON_SET_DESC; + } else if( name == "NPC_ICON_SVR_EVENT_MIS_AVL" ) { + return Command::NPC_ICON_SVR_EVENT_MIS_AVL; + } else if( name == "NPC_ICON_SET_TIMER" ) { + return Command::NPC_ICON_SET_TIMER; + } else { + OS::get_singleton()->print("[%s:%d] Ignore unknown keyword command '%s'\n", __FILE__, __LINE__, name.ascii().get_data()); + } + return Command::__LAST_ELEMENT; +} + +void ReferentialMessageCore::read_referential_step(Dictionary step, Vector head, Ref root) +{ + uint32_t i; + Array keys = step.keys(); + String name; + String sep = ":"; + if ( keys.size() == 0 ) + { + Ref ele; + String a; + int ii; + + ele.instance(); + for(ii=0;iiput_serial(head.get(ii).get_pos(), getPowerOf2(_size)); + } + a += head.get(ii).get_name(); + uint32_t _size = head.get(ii).get_size(); + ele->put_serial(head.get(ii).get_pos(), getPowerOf2(_size)); + //OS::get_singleton()->print("[%s:%d] %s - %s....\n", __FILE__, __LINE__, a.ascii().get_data(), ele.show().ascii().get_data()); + //OS::get_singleton()->print("%s\n",a.ascii().get_data()); + int id = get_command(a); + if (id != Command::__LAST_ELEMENT) + { + _encoder[id].copy_ref_bitstream(ele); + root->set_id(id); + } + ele.unref(); + return; + } + root->set_size(keys.size()); + uint32_t nb = keys.size() - 1; + String a; + for(i=0; i <= nb; ++i) + { + name = keys[i]; + Vector info = name.split(sep, false, 2); + if(info.size() == 2 ) + { + uint32_t id = info[0].to_int(); + Ref root_child = root->add_child(Command::__LAST_ELEMENT, i); + Variant child ; + child = step[name]; + ElementHead tmp; + tmp.create(id, nb, info[1].ascii().get_data()); + head.push_back(tmp); + read_referential_step(child, head, root_child); + head.remove(head.size()-1); + } + } +} + +void ReferentialMessageCore::read_referential(Dictionary dictionary_message) +{ + Vector head; + DEBUGLOG(6, "Read Referential Message"); + _decoder->set_id(Command::__LAST_ELEMENT); + read_referential_step(dictionary_message, head, _decoder); +} + +void ReferentialMessageCore::show() +{ + // For fun, list powerOf2 - TODO check is same with server side, and check size is same value for msg.xml + { + for(int i=0;i<67;++i) + DEBUGLOG(6, "%d => powerOf2 = %d.", i, getPowerOf2(i)); + } + // show Element to push data + { + for(int i=0;i_encoder[i].show().ascii().get_data()); + } + } + // show element to read data + _decoder->show(); +} + +void ReferentialMessageCore::clear_session() +{ + if ( ReferentialMessageCore::singleton == nullptr ) + return; + DEBUGLOG(0, "Clear session for Referential Message."); + delete ReferentialMessageCore::singleton; + ReferentialMessageCore::singleton = nullptr; +} \ No newline at end of file diff --git a/modules/referentialmessage/referentialmessagecore.h b/modules/referentialmessage/referentialmessagecore.h new file mode 100644 index 0000000..9daad88 --- /dev/null +++ b/modules/referentialmessage/referentialmessagecore.h @@ -0,0 +1,442 @@ +/* + Header ReferentialMessageCore : Class to store referential to decode message + + Copyright (C) 2019 AleaJactaEst + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#ifndef REFERENTIAL_MESSAGE_CORE_H +#define REFERENTIAL_MESSAGE_CORE_H + +#include "core/reference.h" +#include "core/dictionary.h" +#include "modules/bitstream/bitstream.h" + +inline uint32_t getPowerOf2(uint32_t v) +{ + // See code : khanat-opennel-code/code/nel/src/misc/common.cpp + uint32_t res = 1; + uint32_t ret = 0; + uint32_t limit = 8*sizeof(uint32_t); + while(res < v && res < limit) + { + ret ++; + res <<= 1; // res *= 2; + } + return ret; +} + +class ElementReferential : public Reference +{ + GDCLASS(ElementReferential, Reference) +private: + uint32_t _id; + uint32_t _power2; + Vector> _children; +public: + ElementReferential() {_id=0; _power2=0;} + ~ElementReferential() {_children.clear();} + + void set_id(uint32_t id) {_id=id;} + void set_size(uint32_t size) {_children.resize(size); _power2=getPowerOf2(size);} + int get_size() { return _children.size();} + Ref add_child(uint32_t id, uint32_t pos) { Ref tmp; tmp.instance(); tmp->_id = id; _children.set(pos, tmp); tmp.unref(); return _children[pos]; } + void show(int level=0, int pos=0); +}; + +class ReferentialMessageCore : public Reference +{ + GDCLASS(ReferentialMessageCore, Reference) +protected: + static void _bind_methods(); +public: + enum Command { + TARGET_PARTY, + TARGET_INVENTORY, + TARGET_FOLLOW, + TARGET_NO_FOLLOW, + CONNECTION_USER_CHAR, + CONNECTION_NO_USER_CHAR, + CONNECTION_USER_CHARS, + CONNECTION_CREATE_CHAR, + CONNECTION_SELECT_CHAR, + CONNECTION_DELETE_CHAR, + CONNECTION_RENAME_CHAR, + CONNECTION_ENTER, + CONNECTION_READY, + CONNECTION_TIME_DATE_SYNCHRO, + CONNECTION_ASK_NAME, + CONNECTION_VALID_NAME, + CONNECTION_CREATE_CHAR_ERROR, + CONNECTION_RECONNECT, + CONNECTION_SERVER_RECONNECT_OK, + CONNECTION_SHARD_ID, + CONNECTION_SERVER_QUIT_OK, + CONNECTION_SERVER_QUIT_ABORT, + CONNECTION_CLIENT_QUIT_REQUEST, + CONNECTION_MAIL_AVAILABLE, + CONNECTION_GUILD_MESSAGE_AVAILABLE, + CONNECTION_PERMANENT_BAN, + CONNECTION_UNBAN, + CONNECTION_FAR_TP, + CONNECTION_RET_MAINLAND, + DB_UPD_PLR, + DB_UPD_INV, + DB_INIT_PLR, + DB_INIT_INV, + DB_GROUP_UPDATE_BANK, + DB_GROUP_INIT_BANK, + DB_GROUP_RESET_BANK, + POSITION, + HARVEST_DEPOSIT, + HARVEST_CORPSE, + HARVEST_INTERRUPT, + HARVEST_CLOSE_TEMP_INVENTORY, + TRAINING, + JOB_SET_JOB_STATUS, + JOB_SWAP_JOB_STATUS, + CASTING_BEGIN, + CASTING_INTERRUPT, + FABER_OPEN, + FABER_CLOSE, + FABER_EXECUTE, + FABER_SET_NUM_ITEM, + FABER_START_CREATE, + FABER_START_REPAIR, + FABER_START_REFINE, + FABER_SET_MP_QUALITY, + FABER_SET_MP_REFINE, + FABER_SET_TOOL, + FABER_RESET_TOOL, + FABER_INTERRUPT, + COMBAT_ENGAGE, + COMBAT_DISENGAGE, + COMBAT_DEFAULT_ATTACK, + COMBAT_ENGAGE_FAILED, + COMBAT_VALIDATE_MELEE, + COMBAT_PARRY, + COMBAT_DODGE, + COMBAT_PROTECTED_SLOT, + COMBAT_FLYING_ChaScore1_DELTA, + COMBAT_FLYING_TEXT_ISE, + COMBAT_FLYING_TEXT, + STRING_TELL, + STRING_FAR_TELL, + STRING_CHAT, + STRING_CHAT_TEAM, + STRING_ADD_DYN_STR, + STRING_FILTER, + STRING_CHAT_MODE, + STRING_CHAT2, + STRING_TELL2, + STRING_DYN_STRING, + STRING_DYN_STRING_GROUP, + STRING_AFK_TXT, + STUN_STUN, + STUN_WAKE_UP, + SENTENCE_EXECUTE, + SENTENCE_CANCEL, + SENTENCE_CANCEL_CURRENT, + SENTENCE_CANCEL_ALL, + SENTENCE_CLEAR, + SENTENCE_MEMORIZE, + SENTENCE_FORGET, + SENTENCE_EVALUATE, + SENTENCE_ADD_BRICK, + SENTENCE_REMOVE_BRICK, + SENTENCE_START, + SENTENCE_STOP, + TEAM_JOIN, + TEAM_LEAVE, + TEAM_INVITATION, + TEAM_JOIN_PROPOSAL, + TEAM_JOIN_PROPOSAL_DECLINE, + TEAM_KICK, + TEAM_SET_SUCCESSOR, + TEAM_SHARE_OPEN, + TEAM_SHARE_VALID_ITEM, + TEAM_SHARE_INVALID_ITEM, + TEAM_SHARE_VALID, + TEAM_SHARE_INVALID, + TEAM_SHARE_CLOSE, + TEAM_CONTACT_INIT, + TEAM_CONTACT_ADD, + TEAM_CONTACT_DEL, + TEAM_CONTACT_MOVE, + TEAM_CONTACT_CREATE, + TEAM_CONTACT_STATUS, + TEAM_CONTACT_REMOVE, + ITEM_DROP, + ITEM_PICK_UP, + ITEM_PICK_UP_CLOSE, + ITEM_SWAP, + ITEM_ACTIVATE_SHEATH, + ITEM_HARVEST, + ITEM_HARVEST_CLOSE, + ITEM_GIVE, + ITEM_DESTROY, + ITEM_EQUIP, + ITEM_UNEQUIP, + ITEM_TEMP_TO_BAG, + ITEM_ALL_TEMP, + ITEM_NO_TEMP, + ITEM_ENCHANT, + ITEM_OPEN_ROOM_INVENTORY, + ITEM_CLOSE_ROOM_INVENTORY, + ITEM_USE_ITEM, + ITEM_STOP_USE_XP_CAT, + TP_RESPAWN, + TP_BOT, + TP_WANTED, + TP_DEST, + TP_DEST_WITH_SEASON, + TP_ACK, + TP_CORRECT, + DEATH_RESPAWN_POINT, + DEATH_ASK_RESPAWN, + DEATH_RESPAWN, + ANIMALS_BEAST, + ANIMALS_MOUNT_ABORT, + EXCHANGE_INVITATION, + EXCHANGE_CLOSE_INVITATION, + EXCHANGE_PROPOSAL, + EXCHANGE_ACCEPT_INVITATION, + EXCHANGE_DECLINE_INVITATION, + EXCHANGE_VALIDATE, + EXCHANGE_INVALIDATE, + EXCHANGE_END, + EXCHANGE_SEEDS, + EXCHANGE_ADD, + EXCHANGE_REMOVE, + DEBUG_WHERE, + DEBUG_WHO, + DEBUG_REPLY_WHERE, + DEBUG_SERVICES, + DEBUG_CMD, + DEBUG_PING, + DEBUG_COUNTER, + COMMAND_EMOTE, + COMMAND_CUSTOM_EMOTE, + COMMAND_WHERE, + COMMAND_ADMIN, + COMMAND_ADMIN_OFFLINE, + COMMAND_REMOTE_ADMIN, + COMMAND_REMOTE_ADMIN_ANSWER, + COMMAND_SIT, + COMMAND_AFK, + COMMAND_RANDOM, + COMMAND_GUILDMOTD, + MP_EVAL_SET_MP, + MP_EVAL_SET_MP_LEVEL, + MP_EVAL_SET_MARKET, + MP_EVAL_EXECUTE, + BOTCHAT_NEXT_PAGE_ITEM, + BOTCHAT_NEXT_PAGE_MISSION, + BOTCHAT_START_TRADE_ITEM, + BOTCHAT_START_TRADE_TELEPORT, + BOTCHAT_START_TRADE_FACTION, + BOTCHAT_START_TRADE_SKILL, + BOTCHAT_START_TRADE_PACT, + BOTCHAT_START_TRADE_ACTION, + BOTCHAT_BUY, + BOTCHAT_SELL, + BOTCHAT_DESTROY_ITEM, + BOTCHAT_REFRESH_TRADE_LIST, + BOTCHAT_SET_FILTERS, + BOTCHAT_START_CHOOSE_MISSION, + BOTCHAT_START_DYNAMIC_MISSION, + BOTCHAT_CONTINUE_MISSION, + BOTCHAT_VALIDATE_PLAYER_GIFT, + BOTCHAT_PICK_MISSION, + BOTCHAT_DM_CHOICE, + BOTCHAT_DM_ACCEPT, + BOTCHAT_START_NEWS, + BOTCHAT_START_CREATE_GUILD, + BOTCHAT_END, + BOTCHAT_FORCE_END, + BOTCHAT_START_CHOOSE_DUTY, + BOTCHAT_NEXT_PAGE_DUTY, + BOTCHAT_DUTY_APPLY, + BOTCHAT_DUTY_CANCEL_APPLY, + BOTCHAT_START_TRADE_GUILD_OPTIONS, + BOTCHAT_BUY_GUILD_OPTION, + BOTCHAT_START_GUILD_RESEARCH, + BOTCHAT_DESTROY_BUILDING, + BOTCHAT_DYNCHAT_OPEN, + BOTCHAT_DYNCHAT_CLOSE, + BOTCHAT_DYNCHAT_SEND, + JOURNAL_INIT_COMPLETED_MISSIONS, + JOURNAL_UPDATE_COMPLETED_MISSIONS, + JOURNAL_MISSION_ABANDON, + JOURNAL_GROUP_MISSION_ABANDON, + JOURNAL_ADD_COMPASS, + JOURNAL_ADD_COMPASS_BOT, + JOURNAL_REMOVE_COMPASS, + JOURNAL_REMOVE_COMPASS_BOT, + STRING_MANAGER_SET_LANGUAGE, + STRING_MANAGER_PHRASE_SEND, + STRING_MANAGER_STRING_RQ, + STRING_MANAGER_STRING_RESP, + STRING_MANAGER_RELOAD_CACHE, + GUILD_CREATE, + GUILD_ABORT_CREATION, + GUILD_OPEN_GUILD_WINDOW, + GUILD_INVITATION, + GUILD_ACCEPT_INVITATION, + GUILD_REFUSE_INVITATION, + GUILD_JOIN_PROPOSAL, + GUILD_SET_GRADE, + GUILD_SET_LEADER, + GUILD_KICK_MEMBER, + GUILD_TELEPORT, + GUILD_ASCENSOR, + GUILD_FIRST_ASCENSOR_PAGE, + GUILD_NEXT_ASCENSOR_PAGE, + GUILD_LEAVE_ASCENSOR, + GUILD_QUIT, + GUILD_SET_PLAYER_TITLE, + GUILD_UPDATE_PLAYER_TITLE, + GUILD_USE_FEMALE_TITLES, + GUILD_PUT_MONEY, + GUILD_TAKE_MONEY, + GUILD_OPEN_INVENTORY, + GUILD_CLOSE_INVENTORY, + OUTPOST_GIVEUP_OUTPOST, + OUTPOST_SELECT, + OUTPOST_UNSELECT, + OUTPOST_DECLARE_WAR_START, + OUTPOST_DECLARE_WAR_ACK, + OUTPOST_DECLARE_WAR_VALIDATE, + OUTPOST_SET_DEF_PERIOD, + OUTPOST_SET_SQUAD, + OUTPOST_SET_SQUAD_SPAWN, + OUTPOST_INSERT_SQUAD, + OUTPOST_REMOVE_SQUAD, + OUTPOST_SET_SQUAD_CAPITAL, + OUTPOST_CHOOSE_SIDE, + OUTPOST_SIDE_CHOSEN, + OUTPOST_BANISH_PLAYER, + OUTPOST_BANISH_GUILD, + OUTPOST_BUY_BUILDING, + OUTPOST_DESTROY_BUILDING, + PHRASE_DELETE, + PHRASE_LEARN, + PHRASE_MEMORIZE, + PHRASE_FORGET, + PHRASE_EXECUTE, + PHRASE_EXECUTE_CYCLIC, + PHRASE_EXECUTE_FABER, + PHRASE_DOWNLOAD, + PHRASE_BUY, + PHRASE_CONFIRM_BUY, + PHRASE_BUY_SHEET, + PHRASE_CANCEL_LINK, + PHRASE_CANCEL_TOP, + PHRASE_CANCEL_ALL, + PHRASE_CRISTALIZE, + PHRASE_EXEC_CYCLIC_ACK, + PHRASE_EXEC_NEXT_ACK, + ITEM_INFO_GET, + ITEM_INFO_SET, + ITEM_INFO_REFRESH_VERSION, + MISSION_PREREQ_GET, + MISSION_PREREQ_SET, + MISSION_ENTER_CRITICAL, + MISSION_ASK_ENTER_CRITICAL, + MISSION_CLOSE_ENTER_CRITICAL, + MISSION_WAKE, + MISSION_GROUP_WAKE, + DUEL_ASK, + DUEL_ACCEPT, + DUEL_REFUSE, + DUEL_ABANDON, + DUEL_INVITATION, + DUEL_CANCEL_INVITATION, + PVP_CHALLENGE_ASK, + PVP_CHALLENGE_ACCEPT, + PVP_CHALLENGE_REFUSE, + PVP_CHALLENGE_ABANDON, + PVP_CHALLENGE_INVITATION, + PVP_CHALLENGE_CANCEL_INVITATION, + PVP_PVP_TAG, + PVP_SET_NEUTRAL_ALLEGIANCE, + PVP_SET_NEUTRAL_ALLEGIANCE_GUILD, + PVP_FACTION_PUSH_FACTION_WAR, + PVP_FACTION_POP_FACTION_WAR, + PVP_FACTION_FACTION_WARS, + ENCYCLOPEDIA_UPDATE, + ENCYCLOPEDIA_INIT, + USER_BARS, + USER_POPUP, + EVENT_SET_ITEM_CUSTOM_TEXT, + EVENT_DUMMY, + TOTEM_BUILD, + TOTEM_DUMMY, + MODULE_GATEWAY_FEOPEN, + MODULE_GATEWAY_GATEWAY_MSG, + MODULE_GATEWAY_FECLOSE, + SEASON_SET, + SEASON_DUMMY, + DM_GIFT_BEGIN, + DM_GIFT_VALIDATE, + RING_MISSION_MISSION_RING_SELECT, + RING_MISSION_DSS_DOWN, + NPC_ICON_GET_DESC, + NPC_ICON_SET_DESC, + NPC_ICON_SVR_EVENT_MIS_AVL, + NPC_ICON_SET_TIMER, + __LAST_ELEMENT + }; + class ElementHead + { + private: + uint32_t _size; + uint32_t _pos; + String _name; + public: + ElementHead() {} + ~ElementHead() {} + void set_size(uint32_t size){_size = size;} + void set_pos(uint32_t pos){_pos = pos;} + void set_name(String name){_name = name;} + void create(uint32_t pos, uint32_t size,String name) {set_pos(pos);set_size(size);set_name(name);} + + uint32_t get_size() {return _size;} + uint32_t get_pos() {return _pos;} + String get_name() {return _name;} + }; +private: + static ReferentialMessageCore *singleton; + BitStream _encoder[Command::__LAST_ELEMENT]; + Ref _decoder; + int get_command(String name); + void read_referential_step(Dictionary step, Vector head, Ref root); +public: + + static ReferentialMessageCore * get_singleton(); + + ReferentialMessageCore() {_decoder.instance();} + ~ReferentialMessageCore() {_decoder.unref();} + + void read_referential(Dictionary dictionary_message); + void show(); + + static void clear_session(); +}; + +VARIANT_ENUM_CAST(ReferentialMessageCore::Command); + +#endif \ No newline at end of file diff --git a/modules/referentialmessage/register_types.cpp b/modules/referentialmessage/register_types.cpp new file mode 100644 index 0000000..25bf3d6 --- /dev/null +++ b/modules/referentialmessage/register_types.cpp @@ -0,0 +1,15 @@ +/* register_types.cpp */ + +#include "register_types.h" + +#include "core/class_db.h" +#include "referentialmessage.h" + +void register_referentialmessage_types() { + ClassDB::register_class(); + ClassDB::register_class(); +} + +void unregister_referentialmessage_types() { + // Nothing to do here in this example. +} diff --git a/modules/referentialmessage/register_types.h b/modules/referentialmessage/register_types.h new file mode 100644 index 0000000..2654862 --- /dev/null +++ b/modules/referentialmessage/register_types.h @@ -0,0 +1,5 @@ +/* register_types.h */ + +void register_referentialmessage_types(); +void unregister_referentialmessage_types(); +/* yes, the word in the middle must be the same as the module folder name */