From c8edca8e6fd458cc5fcba344a4605cb798ed762e Mon Sep 17 00:00:00 2001 From: AleaJactaEst Date: Sat, 11 Apr 2020 13:56:47 +0200 Subject: [PATCH] update network part --- modules/bitstream/bitstream.cpp | 18 + modules/bitstream/bitstream.h | 2 + modules/command/SCsub | 5 + modules/command/action_factory.cpp | 1602 +++++++++++++++++ modules/command/action_factory.h | 35 + modules/command/config.py | 15 + modules/command/register_types.cpp | 14 + modules/command/register_types.h | 5 + modules/networkconnection/network_data.h | 2 +- modules/networkconnection/state_connexion.cpp | 213 +-- modules/networkconnection/state_connexion.h | 2 - .../referentialmessage/referentialmessage.cpp | 6 + .../referentialmessage/referentialmessage.h | 1 + .../referentialmessagecore.cpp | 15 + .../referentialmessagecore.h | 4 + 15 files changed, 1728 insertions(+), 211 deletions(-) create mode 100644 modules/command/SCsub create mode 100644 modules/command/action_factory.cpp create mode 100644 modules/command/action_factory.h create mode 100644 modules/command/config.py create mode 100644 modules/command/register_types.cpp create mode 100644 modules/command/register_types.h diff --git a/modules/bitstream/bitstream.cpp b/modules/bitstream/bitstream.cpp index fb00764..9037cb8 100644 --- a/modules/bitstream/bitstream.cpp +++ b/modules/bitstream/bitstream.cpp @@ -32,6 +32,8 @@ void BitStream::_bind_methods() ClassDB::bind_method(D_METHOD("is_little_endian"), &BitStream::is_little_endian); ClassDB::bind_method(D_METHOD("size"), &BitStream::size); + ClassDB::bind_method(D_METHOD("size_data"), &BitStream::size_data); + ClassDB::bind_method(D_METHOD("number_bit_not_read"), &BitStream::number_bit_not_read); ClassDB::bind_method(D_METHOD("put_serial", "value", "nbits"), &BitStream::put_serial); ClassDB::bind_method(D_METHOD("put_bool", "value"), &BitStream::put_bool); @@ -108,6 +110,11 @@ int BitStream::size_data() return this->_pos; } +int BitStream::number_bit_not_read() +{ + return this->_pos - this->_read; +} + void BitStream::put_serial(uint32_t value, uint32_t nbits) { uint32_t v; @@ -468,4 +475,15 @@ PoolByteArray BitStream::get_array_uint8(uint32_t length) --length; } return ret; +} + +BitStream BitStream::get_bitstream(uint32_t length) +{ + BitStream a; + while(length != 0) + { + a.put_uint8(this->get_serial(8)); + --length; + } + return a; } \ No newline at end of file diff --git a/modules/bitstream/bitstream.h b/modules/bitstream/bitstream.h index 062e52e..619c07c 100644 --- a/modules/bitstream/bitstream.h +++ b/modules/bitstream/bitstream.h @@ -42,6 +42,7 @@ public: int size(); int size_data(); + int number_bit_not_read(); void put_serial(uint32_t value, uint32_t nbits); void put_bool(bool value); @@ -79,6 +80,7 @@ public: int64_t get_sint64(); uint64_t get_uint64(); PoolByteArray get_array_uint8(uint32_t length); + BitStream get_bitstream(uint32_t length); }; #endif diff --git a/modules/command/SCsub b/modules/command/SCsub new file mode 100644 index 0000000..e208d38 --- /dev/null +++ b/modules/command/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/command/action_factory.cpp b/modules/command/action_factory.cpp new file mode 100644 index 0000000..144b11d --- /dev/null +++ b/modules/command/action_factory.cpp @@ -0,0 +1,1602 @@ +/* + Action Factory + + 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 "core/reference.h" +#include "modules/debug/debug.h" +#include "modules/networkconnection/network_data.h" +#include "modules/networkconnection/state_connexion.h" +#include "modules/command/action_factory.h" +#include "modules/referentialmessage/referentialmessage.h" +#include "modules/referentialmessage/referentialmessagecore.h" + +void ActionFactory::decode_message(Ref msgin) +{ + ReferentialMessage ref_msg; + uint32_t id = ref_msg.read_command(msgin); + DBG_PRINT("Decode message:" + get_command_name(id)); + switch(id) + { + case ReferentialMessageCore::Command::TARGET_PARTY: + { + break; + } + case ReferentialMessageCore::Command::TARGET_INVENTORY: + { + break; + } + case ReferentialMessageCore::Command::TARGET_FOLLOW: + { + break; + } + case ReferentialMessageCore::Command::TARGET_NO_FOLLOW: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_USER_CHAR: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_NO_USER_CHAR: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_USER_CHARS: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_CREATE_CHAR: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_SELECT_CHAR: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_DELETE_CHAR: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_RENAME_CHAR: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_ENTER: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_READY: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_TIME_DATE_SYNCHRO: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_ASK_NAME: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_VALID_NAME: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_CREATE_CHAR_ERROR: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_RECONNECT: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_SERVER_RECONNECT_OK: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_SHARD_ID: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_SERVER_QUIT_OK: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_SERVER_QUIT_ABORT: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_CLIENT_QUIT_REQUEST: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_MAIL_AVAILABLE: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_GUILD_MESSAGE_AVAILABLE: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_PERMANENT_BAN: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_UNBAN: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_FAR_TP: + { + break; + } + case ReferentialMessageCore::Command::CONNECTION_RET_MAINLAND: + { + break; + } + case ReferentialMessageCore::Command::DB_UPD_PLR: + { + break; + } + case ReferentialMessageCore::Command::DB_UPD_INV: + { + break; + } + case ReferentialMessageCore::Command::DB_INIT_PLR: + { + break; + } + case ReferentialMessageCore::Command::DB_INIT_INV: + { + break; + } + case ReferentialMessageCore::Command::DB_GROUP_UPDATE_BANK: + { + break; + } + case ReferentialMessageCore::Command::DB_GROUP_INIT_BANK: + { + break; + } + case ReferentialMessageCore::Command::DB_GROUP_RESET_BANK: + { + break; + } + case ReferentialMessageCore::Command::POSITION: + { + break; + } + case ReferentialMessageCore::Command::HARVEST_DEPOSIT: + { + break; + } + case ReferentialMessageCore::Command::HARVEST_CORPSE: + { + break; + } + case ReferentialMessageCore::Command::HARVEST_INTERRUPT: + { + break; + } + case ReferentialMessageCore::Command::HARVEST_CLOSE_TEMP_INVENTORY: + { + break; + } + case ReferentialMessageCore::Command::TRAINING: + { + break; + } + case ReferentialMessageCore::Command::JOB_SET_JOB_STATUS: + { + break; + } + case ReferentialMessageCore::Command::JOB_SWAP_JOB_STATUS: + { + break; + } + case ReferentialMessageCore::Command::CASTING_BEGIN: + { + break; + } + case ReferentialMessageCore::Command::CASTING_INTERRUPT: + { + break; + } + case ReferentialMessageCore::Command::FABER_OPEN: + { + break; + } + case ReferentialMessageCore::Command::FABER_CLOSE: + { + break; + } + case ReferentialMessageCore::Command::FABER_EXECUTE: + { + break; + } + case ReferentialMessageCore::Command::FABER_SET_NUM_ITEM: + { + break; + } + case ReferentialMessageCore::Command::FABER_START_CREATE: + { + break; + } + case ReferentialMessageCore::Command::FABER_START_REPAIR: + { + break; + } + case ReferentialMessageCore::Command::FABER_START_REFINE: + { + break; + } + case ReferentialMessageCore::Command::FABER_SET_MP_QUALITY: + { + break; + } + case ReferentialMessageCore::Command::FABER_SET_MP_REFINE: + { + break; + } + case ReferentialMessageCore::Command::FABER_SET_TOOL: + { + break; + } + case ReferentialMessageCore::Command::FABER_RESET_TOOL: + { + break; + } + case ReferentialMessageCore::Command::FABER_INTERRUPT: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_ENGAGE: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_DISENGAGE: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_DEFAULT_ATTACK: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_ENGAGE_FAILED: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_VALIDATE_MELEE: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_PARRY: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_DODGE: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_PROTECTED_SLOT: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_FLYING_ChaScore1_DELTA: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_FLYING_TEXT_ISE: + { + break; + } + case ReferentialMessageCore::Command::COMBAT_FLYING_TEXT: + { + break; + } + case ReferentialMessageCore::Command::STRING_TELL: + { + break; + } + case ReferentialMessageCore::Command::STRING_FAR_TELL: + { + break; + } + case ReferentialMessageCore::Command::STRING_CHAT: + { + break; + } + case ReferentialMessageCore::Command::STRING_CHAT_TEAM: + { + break; + } + case ReferentialMessageCore::Command::STRING_ADD_DYN_STR: + { + break; + } + case ReferentialMessageCore::Command::STRING_FILTER: + { + break; + } + case ReferentialMessageCore::Command::STRING_CHAT_MODE: + { + break; + } + case ReferentialMessageCore::Command::STRING_CHAT2: + { + break; + } + case ReferentialMessageCore::Command::STRING_TELL2: + { + break; + } + case ReferentialMessageCore::Command::STRING_DYN_STRING: + { + break; + } + case ReferentialMessageCore::Command::STRING_DYN_STRING_GROUP: + { + break; + } + case ReferentialMessageCore::Command::STRING_AFK_TXT: + { + break; + } + case ReferentialMessageCore::Command::STUN_STUN: + { + break; + } + case ReferentialMessageCore::Command::STUN_WAKE_UP: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_EXECUTE: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_CANCEL: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_CANCEL_CURRENT: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_CANCEL_ALL: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_CLEAR: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_MEMORIZE: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_FORGET: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_EVALUATE: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_ADD_BRICK: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_REMOVE_BRICK: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_START: + { + break; + } + case ReferentialMessageCore::Command::SENTENCE_STOP: + { + break; + } + case ReferentialMessageCore::Command::TEAM_JOIN: + { + break; + } + case ReferentialMessageCore::Command::TEAM_LEAVE: + { + break; + } + case ReferentialMessageCore::Command::TEAM_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::TEAM_JOIN_PROPOSAL: + { + break; + } + case ReferentialMessageCore::Command::TEAM_JOIN_PROPOSAL_DECLINE: + { + break; + } + case ReferentialMessageCore::Command::TEAM_KICK: + { + break; + } + case ReferentialMessageCore::Command::TEAM_SET_SUCCESSOR: + { + break; + } + case ReferentialMessageCore::Command::TEAM_SHARE_OPEN: + { + break; + } + case ReferentialMessageCore::Command::TEAM_SHARE_VALID_ITEM: + { + break; + } + case ReferentialMessageCore::Command::TEAM_SHARE_INVALID_ITEM: + { + break; + } + case ReferentialMessageCore::Command::TEAM_SHARE_VALID: + { + break; + } + case ReferentialMessageCore::Command::TEAM_SHARE_INVALID: + { + break; + } + case ReferentialMessageCore::Command::TEAM_SHARE_CLOSE: + { + break; + } + case ReferentialMessageCore::Command::TEAM_CONTACT_INIT: + { + break; + } + case ReferentialMessageCore::Command::TEAM_CONTACT_ADD: + { + break; + } + case ReferentialMessageCore::Command::TEAM_CONTACT_DEL: + { + break; + } + case ReferentialMessageCore::Command::TEAM_CONTACT_MOVE: + { + break; + } + case ReferentialMessageCore::Command::TEAM_CONTACT_CREATE: + { + break; + } + case ReferentialMessageCore::Command::TEAM_CONTACT_STATUS: + { + break; + } + case ReferentialMessageCore::Command::TEAM_CONTACT_REMOVE: + { + break; + } + case ReferentialMessageCore::Command::ITEM_DROP: + { + break; + } + case ReferentialMessageCore::Command::ITEM_PICK_UP: + { + break; + } + case ReferentialMessageCore::Command::ITEM_PICK_UP_CLOSE: + { + break; + } + case ReferentialMessageCore::Command::ITEM_SWAP: + { + break; + } + case ReferentialMessageCore::Command::ITEM_ACTIVATE_SHEATH: + { + break; + } + case ReferentialMessageCore::Command::ITEM_HARVEST: + { + break; + } + case ReferentialMessageCore::Command::ITEM_HARVEST_CLOSE: + { + break; + } + case ReferentialMessageCore::Command::ITEM_GIVE: + { + break; + } + case ReferentialMessageCore::Command::ITEM_DESTROY: + { + break; + } + case ReferentialMessageCore::Command::ITEM_EQUIP: + { + break; + } + case ReferentialMessageCore::Command::ITEM_UNEQUIP: + { + break; + } + case ReferentialMessageCore::Command::ITEM_TEMP_TO_BAG: + { + break; + } + case ReferentialMessageCore::Command::ITEM_ALL_TEMP: + { + break; + } + case ReferentialMessageCore::Command::ITEM_NO_TEMP: + { + break; + } + case ReferentialMessageCore::Command::ITEM_ENCHANT: + { + break; + } + case ReferentialMessageCore::Command::ITEM_OPEN_ROOM_INVENTORY: + { + break; + } + case ReferentialMessageCore::Command::ITEM_CLOSE_ROOM_INVENTORY: + { + break; + } + case ReferentialMessageCore::Command::ITEM_USE_ITEM: + { + break; + } + case ReferentialMessageCore::Command::ITEM_STOP_USE_XP_CAT: + { + break; + } + case ReferentialMessageCore::Command::TP_RESPAWN: + { + break; + } + case ReferentialMessageCore::Command::TP_BOT: + { + break; + } + case ReferentialMessageCore::Command::TP_WANTED: + { + break; + } + case ReferentialMessageCore::Command::TP_DEST: + { + break; + } + case ReferentialMessageCore::Command::TP_DEST_WITH_SEASON: + { + break; + } + case ReferentialMessageCore::Command::TP_ACK: + { + break; + } + case ReferentialMessageCore::Command::TP_CORRECT: + { + break; + } + case ReferentialMessageCore::Command::DEATH_RESPAWN_POINT: + { + break; + } + case ReferentialMessageCore::Command::DEATH_ASK_RESPAWN: + { + break; + } + case ReferentialMessageCore::Command::DEATH_RESPAWN: + { + break; + } + case ReferentialMessageCore::Command::ANIMALS_BEAST: + { + break; + } + case ReferentialMessageCore::Command::ANIMALS_MOUNT_ABORT: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_CLOSE_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_PROPOSAL: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_ACCEPT_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_DECLINE_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_VALIDATE: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_INVALIDATE: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_END: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_SEEDS: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_ADD: + { + break; + } + case ReferentialMessageCore::Command::EXCHANGE_REMOVE: + { + break; + } + case ReferentialMessageCore::Command::DEBUG_WHERE: + { + break; + } + case ReferentialMessageCore::Command::DEBUG_WHO: + { + break; + } + case ReferentialMessageCore::Command::DEBUG_REPLY_WHERE: + { + break; + } + case ReferentialMessageCore::Command::DEBUG_SERVICES: + { + break; + } + case ReferentialMessageCore::Command::DEBUG_CMD: + { + break; + } + case ReferentialMessageCore::Command::DEBUG_PING: + { + break; + } + case ReferentialMessageCore::Command::DEBUG_COUNTER: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_EMOTE: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_CUSTOM_EMOTE: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_WHERE: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_ADMIN: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_ADMIN_OFFLINE: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_REMOTE_ADMIN: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_REMOTE_ADMIN_ANSWER: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_SIT: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_AFK: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_RANDOM: + { + break; + } + case ReferentialMessageCore::Command::COMMAND_GUILDMOTD: + { + break; + } + case ReferentialMessageCore::Command::MP_EVAL_SET_MP: + { + break; + } + case ReferentialMessageCore::Command::MP_EVAL_SET_MP_LEVEL: + { + break; + } + case ReferentialMessageCore::Command::MP_EVAL_SET_MARKET: + { + break; + } + case ReferentialMessageCore::Command::MP_EVAL_EXECUTE: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_NEXT_PAGE_ITEM: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_NEXT_PAGE_MISSION: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_TRADE_ITEM: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_TRADE_TELEPORT: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_TRADE_FACTION: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_TRADE_SKILL: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_TRADE_PACT: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_TRADE_ACTION: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_BUY: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_SELL: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_DESTROY_ITEM: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_REFRESH_TRADE_LIST: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_SET_FILTERS: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_CHOOSE_MISSION: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_DYNAMIC_MISSION: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_CONTINUE_MISSION: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_VALIDATE_PLAYER_GIFT: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_PICK_MISSION: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_DM_CHOICE: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_DM_ACCEPT: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_NEWS: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_CREATE_GUILD: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_END: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_FORCE_END: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_CHOOSE_DUTY: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_NEXT_PAGE_DUTY: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_DUTY_APPLY: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_DUTY_CANCEL_APPLY: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_TRADE_GUILD_OPTIONS: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_BUY_GUILD_OPTION: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_START_GUILD_RESEARCH: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_DESTROY_BUILDING: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_DYNCHAT_OPEN: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_DYNCHAT_CLOSE: + { + break; + } + case ReferentialMessageCore::Command::BOTCHAT_DYNCHAT_SEND: + { + break; + } + case ReferentialMessageCore::Command::JOURNAL_INIT_COMPLETED_MISSIONS: + { + break; + } + case ReferentialMessageCore::Command::JOURNAL_UPDATE_COMPLETED_MISSIONS: + { + break; + } + case ReferentialMessageCore::Command::JOURNAL_MISSION_ABANDON: + { + break; + } + case ReferentialMessageCore::Command::JOURNAL_GROUP_MISSION_ABANDON: + { + break; + } + case ReferentialMessageCore::Command::JOURNAL_ADD_COMPASS: + { + break; + } + case ReferentialMessageCore::Command::JOURNAL_ADD_COMPASS_BOT: + { + break; + } + case ReferentialMessageCore::Command::JOURNAL_REMOVE_COMPASS: + { + break; + } + case ReferentialMessageCore::Command::JOURNAL_REMOVE_COMPASS_BOT: + { + break; + } + case ReferentialMessageCore::Command::STRING_MANAGER_SET_LANGUAGE: + { + break; + } + case ReferentialMessageCore::Command::STRING_MANAGER_PHRASE_SEND: + { + break; + } + case ReferentialMessageCore::Command::STRING_MANAGER_STRING_RQ: + { + break; + } + case ReferentialMessageCore::Command::STRING_MANAGER_STRING_RESP: + { + break; + } + case ReferentialMessageCore::Command::STRING_MANAGER_RELOAD_CACHE: + { + uint32_t timestamp = msgin->get_uint32(); + DBG_PRINT("Decode message:" + get_command_name(id) + " timestamp:" + itos(timestamp)); + break; + } + case ReferentialMessageCore::Command::GUILD_CREATE: + { + break; + } + case ReferentialMessageCore::Command::GUILD_ABORT_CREATION: + { + break; + } + case ReferentialMessageCore::Command::GUILD_OPEN_GUILD_WINDOW: + { + break; + } + case ReferentialMessageCore::Command::GUILD_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::GUILD_ACCEPT_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::GUILD_REFUSE_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::GUILD_JOIN_PROPOSAL: + { + break; + } + case ReferentialMessageCore::Command::GUILD_SET_GRADE: + { + break; + } + case ReferentialMessageCore::Command::GUILD_SET_LEADER: + { + break; + } + case ReferentialMessageCore::Command::GUILD_KICK_MEMBER: + { + break; + } + case ReferentialMessageCore::Command::GUILD_TELEPORT: + { + break; + } + case ReferentialMessageCore::Command::GUILD_ASCENSOR: + { + break; + } + case ReferentialMessageCore::Command::GUILD_FIRST_ASCENSOR_PAGE: + { + break; + } + case ReferentialMessageCore::Command::GUILD_NEXT_ASCENSOR_PAGE: + { + break; + } + case ReferentialMessageCore::Command::GUILD_LEAVE_ASCENSOR: + { + break; + } + case ReferentialMessageCore::Command::GUILD_QUIT: + { + break; + } + case ReferentialMessageCore::Command::GUILD_SET_PLAYER_TITLE: + { + break; + } + case ReferentialMessageCore::Command::GUILD_UPDATE_PLAYER_TITLE: + { + break; + } + case ReferentialMessageCore::Command::GUILD_USE_FEMALE_TITLES: + { + break; + } + case ReferentialMessageCore::Command::GUILD_PUT_MONEY: + { + break; + } + case ReferentialMessageCore::Command::GUILD_TAKE_MONEY: + { + break; + } + case ReferentialMessageCore::Command::GUILD_OPEN_INVENTORY: + { + break; + } + case ReferentialMessageCore::Command::GUILD_CLOSE_INVENTORY: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_GIVEUP_OUTPOST: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_SELECT: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_UNSELECT: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_DECLARE_WAR_START: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_DECLARE_WAR_ACK: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_DECLARE_WAR_VALIDATE: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_SET_DEF_PERIOD: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_SET_SQUAD: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_SET_SQUAD_SPAWN: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_INSERT_SQUAD: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_REMOVE_SQUAD: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_SET_SQUAD_CAPITAL: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_CHOOSE_SIDE: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_SIDE_CHOSEN: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_BANISH_PLAYER: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_BANISH_GUILD: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_BUY_BUILDING: + { + break; + } + case ReferentialMessageCore::Command::OUTPOST_DESTROY_BUILDING: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_DELETE: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_LEARN: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_MEMORIZE: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_FORGET: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_EXECUTE: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_EXECUTE_CYCLIC: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_EXECUTE_FABER: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_DOWNLOAD: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_BUY: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_CONFIRM_BUY: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_BUY_SHEET: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_CANCEL_LINK: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_CANCEL_TOP: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_CANCEL_ALL: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_CRISTALIZE: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_EXEC_CYCLIC_ACK: + { + break; + } + case ReferentialMessageCore::Command::PHRASE_EXEC_NEXT_ACK: + { + break; + } + case ReferentialMessageCore::Command::ITEM_INFO_GET: + { + break; + } + case ReferentialMessageCore::Command::ITEM_INFO_SET: + { + break; + } + case ReferentialMessageCore::Command::ITEM_INFO_REFRESH_VERSION: + { + break; + } + case ReferentialMessageCore::Command::MISSION_PREREQ_GET: + { + break; + } + case ReferentialMessageCore::Command::MISSION_PREREQ_SET: + { + break; + } + case ReferentialMessageCore::Command::MISSION_ENTER_CRITICAL: + { + break; + } + case ReferentialMessageCore::Command::MISSION_ASK_ENTER_CRITICAL: + { + break; + } + case ReferentialMessageCore::Command::MISSION_CLOSE_ENTER_CRITICAL: + { + break; + } + case ReferentialMessageCore::Command::MISSION_WAKE: + { + break; + } + case ReferentialMessageCore::Command::MISSION_GROUP_WAKE: + { + break; + } + case ReferentialMessageCore::Command::DUEL_ASK: + { + break; + } + case ReferentialMessageCore::Command::DUEL_ACCEPT: + { + break; + } + case ReferentialMessageCore::Command::DUEL_REFUSE: + { + break; + } + case ReferentialMessageCore::Command::DUEL_ABANDON: + { + break; + } + case ReferentialMessageCore::Command::DUEL_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::DUEL_CANCEL_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::PVP_CHALLENGE_ASK: + { + break; + } + case ReferentialMessageCore::Command::PVP_CHALLENGE_ACCEPT: + { + break; + } + case ReferentialMessageCore::Command::PVP_CHALLENGE_REFUSE: + { + break; + } + case ReferentialMessageCore::Command::PVP_CHALLENGE_ABANDON: + { + break; + } + case ReferentialMessageCore::Command::PVP_CHALLENGE_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::PVP_CHALLENGE_CANCEL_INVITATION: + { + break; + } + case ReferentialMessageCore::Command::PVP_PVP_TAG: + { + break; + } + case ReferentialMessageCore::Command::PVP_SET_NEUTRAL_ALLEGIANCE: + { + break; + } + case ReferentialMessageCore::Command::PVP_SET_NEUTRAL_ALLEGIANCE_GUILD: + { + break; + } + case ReferentialMessageCore::Command::PVP_FACTION_PUSH_FACTION_WAR: + { + break; + } + case ReferentialMessageCore::Command::PVP_FACTION_POP_FACTION_WAR: + { + break; + } + case ReferentialMessageCore::Command::PVP_FACTION_FACTION_WARS: + { + break; + } + case ReferentialMessageCore::Command::ENCYCLOPEDIA_UPDATE: + { + break; + } + case ReferentialMessageCore::Command::ENCYCLOPEDIA_INIT: + { + break; + } + case ReferentialMessageCore::Command::USER_BARS: + { + break; + } + case ReferentialMessageCore::Command::USER_POPUP: + { + break; + } + case ReferentialMessageCore::Command::EVENT_SET_ITEM_CUSTOM_TEXT: + { + break; + } + case ReferentialMessageCore::Command::EVENT_DUMMY: + { + break; + } + case ReferentialMessageCore::Command::TOTEM_BUILD: + { + break; + } + case ReferentialMessageCore::Command::TOTEM_DUMMY: + { + break; + } + case ReferentialMessageCore::Command::MODULE_GATEWAY_FEOPEN: + { + break; + } + case ReferentialMessageCore::Command::MODULE_GATEWAY_GATEWAY_MSG: + { + break; + } + case ReferentialMessageCore::Command::MODULE_GATEWAY_FECLOSE: + { + break; + } + case ReferentialMessageCore::Command::SEASON_SET: + { + break; + } + case ReferentialMessageCore::Command::SEASON_DUMMY: + { + break; + } + case ReferentialMessageCore::Command::DM_GIFT_BEGIN: + { + break; + } + case ReferentialMessageCore::Command::DM_GIFT_VALIDATE: + { + break; + } + case ReferentialMessageCore::Command::RING_MISSION_MISSION_RING_SELECT: + { + break; + } + case ReferentialMessageCore::Command::RING_MISSION_DSS_DOWN: + { + break; + } + case ReferentialMessageCore::Command::NPC_ICON_GET_DESC: + { + break; + } + case ReferentialMessageCore::Command::NPC_ICON_SET_DESC: + { + break; + } + case ReferentialMessageCore::Command::NPC_ICON_SVR_EVENT_MIS_AVL: + { + break; + } + case ReferentialMessageCore::Command::NPC_ICON_SET_TIMER: + { + break; + } + default: + { + break; + } + } + #ifdef DEBUG_ENABLED + // Check if we have read all data - only on debug mode + { + uint32_t data; + while ( msgin->number_bit_not_read() > 0 ) + { + DBG_PRINT("Read : " + itos(msgin->number_bit_not_read())); + if ( msgin->number_bit_not_read() >= 8 ) + data = msgin->get_uint8(); + else + data = msgin->get_serial(msgin->number_bit_not_read()); + if ( data != 0 ) + { + ERR_PRINT("Missing some data - we dont' have translate all data : " + msgin->show()); + break; + } + } + } + + #endif +} + +void ActionFactory::unpack(Ref msgin) +{ + bool shortcode = msgin->get_bool(); + uint8_t code; + DBG_PRINT("shortcode:" + itos(shortcode)); + if ( shortcode == true ) + code = msgin->get_serial(2); + else + code = msgin->get_uint8(); + DBG_PRINT("code:" + itos(code)); + switch (code) + { + case ACTIONCODE::ACTION_POSITION_CODE: + { + // khanat-opennel-code/code/ryzom/common/src/game_share/action_position.cpp:34 void CActionPosition::unpack (NLMISC::CBitMemStream &message) + // px ( 16 bit unsigned ) + // py ( 16 bit unsigned ) + // pz ( 16 bit unsigned ) : low bit have other signification + // 0x01 : IsRelative + // 0x02 : Interior + DBG_PRINT("ACTION_GENERIC_CODE"); + uint16_t px = msgin->get_uint16(); + uint16_t py = msgin->get_uint16(); + uint16_t pz = msgin->get_uint16(); + bool IsRelative = (pz & 0x1) != 0; + bool Interior = (pz & 0x2) != 0; + DBG_PRINT("ACTION_GENERIC_CODE px:" + uitos(px) + " py:" + uitos(py) + " pz:" + uitos(pz) + " IsRelative:" + uitos(IsRelative) + " Interior:" + uitos(Interior)); + break; + } + case ACTIONCODE::ACTION_GENERIC_CODE: + { + DBG_PRINT("ACTION_GENERIC_CODE"); + // khanat-opennel-code/code/ryzom/common/src/game_share/action_generic.cpp void CActionGeneric::unpack (NLMISC::CBitMemStream &message) + // size ( 32 bits unsigned ) : if size > 512 we have an error (normally reject by server) + // StreamByte ( Array : size * 8 bits unsigned ) + uint32_t size = msgin->get_uint32(); + DBG_PRINT("ACTION_GENERIC_CODE size:" + uitos(size)); + PoolByteArray StreamByte = msgin->get_array_uint8(size); + //BitStream StreamByte = msgin->get_bitstream(size); + DBG_PRINT("ACTION_GENERIC_CODE size:" + uitos(size)); + Ref tmp; + tmp.instance(); + tmp->put_array_uint8(StreamByte); + decode_message(tmp); + tmp.unref(); + break; + } + case ACTIONCODE::ACTION_GENERIC_MULTI_PART_CODE: + { + DBG_PRINT("ACTION_GENERIC_MULTI_PART_CODE"); + // khanat-opennel-code/code/ryzom/common/src/game_share/action_generic_multi_part.h:46 virtual void unpack (NLMISC::CBitMemStream &message) + // Number ( 8 bits unsigned ) + // Part ( 16 bits unsigned ) + // NbBlock ( 16 bits unsigned ) + // size ( 32 bits unsigned ) + // PartCont ( Array : size * 8 bits unsigned ) + uint8_t Number = msgin->get_uint8(); + uint16_t Part = msgin->get_uint16(); + uint16_t NbBlock = msgin->get_uint16(); + uint32_t size = msgin->get_uint32(); + PoolByteArray StreamByte = msgin->get_array_uint8(size); + //BitStream StreamByte = msgin->get_bitstream(size); + DBG_PRINT("ACTION_GENERIC_MULTI_PART_CODE Number:" + uitos(Number) + " Part:" + uitos(Part) + " NbBlock:" + uitos(NbBlock) + " size:" + uitos(size)); + break; + } + case ACTIONCODE::ACTION_SINT64: + { + DBG_PRINT("ACTION_SINT64"); + // khanat-opennel-code/code/ryzom/common/src/game_share/action_sint64.cpp:86 void CActionSint64::unpack (NLMISC::CBitMemStream &message) + // value ( 64 bits unsigned ) + uint64_t value = msgin->get_uint64(); + DBG_PRINT("ACTION_SINT64 value:" + uitos(value)); + break; + } + case ACTIONCODE::ACTION_SYNC_CODE: + { + DBG_PRINT("ACTION_SYNC_CODE"); + // khanat-opennel-code/code/ryzom/common/src/game_share/action_sync.h:44 virtual void unpack (NLMISC::CBitMemStream &message) + // Sync ( 32 bits unsigned ) + // BKEntityId ( 64 bits unsigned ) [see definition : khanat-opennel-code/code/nel/include/nel/misc/entity_id.h:64] + uint32_t Sync = msgin->get_uint32(); + uint64_t BKEntityId = msgin->get_uint64(); + DBG_PRINT("ACTION_SYNC_CODE Sync:" + uitos(Sync) + " BKEntityId:" + uitos(BKEntityId)); + break; + } + case ACTIONCODE::ACTION_DISCONNECTION_CODE: + { + // khanat-opennel-code/code/ryzom/common/src/game_share/action_disconnection.h + // No data + DBG_PRINT("ACTION_DISCONNECTION_CODE"); + break; + } + case ACTIONCODE::ACTION_ASSOCIATION_CODE: + { + DBG_PRINT("ACTION_ASSOCIATION_CODE"); + // khanat-opennel-code/code/ryzom/common/src/game_share/action_association.h virtual void unpack (NLMISC::CBitMemStream &message) + // IsNewAssociation ( bool / 1 bit ) + // if IsNewAssociation is true: + // SheetId ( 32 bits unsigned ) + // Replace ( bool / 1 bit ) + uint32_t SheetId = msgin->get_uint32(); + bool Replace = msgin->get_bool(); + DBG_PRINT("ACTION_ASSOCIATION_CODE SheetId:" + uitos(SheetId) + " Replace:" + uitos(Replace)); + break; + } + case ACTIONCODE::ACTION_LOGIN_CODE: + { + DBG_PRINT("ACTION_LOGIN_CODE"); + // khanat-opennel-code/code/ryzom/common/src/game_share/action_login.h virtual void unpack (NLMISC::CBitMemStream &message) + // ua ( 32 bits unsigned ) + // uk ( 32 bits unsigned ) + // ui ( 32 bits unsigned ) + uint32_t ua = msgin->get_uint32(); + uint32_t uk = msgin->get_uint32(); + uint32_t ui = msgin->get_uint32(); + DBG_PRINT("ACTION_LOGIN_CODE ua:" + uitos(ua) + " uk:" + uitos(uk)+ " ui:" + uitos(ui)); + break; + } + case ACTIONCODE::ACTION_TARGET_SLOT_CODE: + { + DBG_PRINT("ACTION_TARGET_SLOT_CODE"); + // khanat-opennel-code/code/ryzom/common/src/game_share/action_target_slot.h virtual void unpack (NLMISC::CBitMemStream &message) + // Slot ( 8 bits unsigned ) + // TargetOrPickup (2 bits unsigned) + uint8_t Slot = msgin->get_uint8(); + uint32_t TargetOrPickup = msgin->get_serial(2); + DBG_PRINT("ACTION_TARGET_SLOT_CODE Slot:" + uitos(Slot) + " TargetOrPickup:" + uitos(TargetOrPickup)); + break; + } + case ACTIONCODE::ACTION_DUMMY_CODE: + { + DBG_PRINT("ACTION_DUMMY_CODE"); + // khanat-opennel-code/code/ryzom/common/src/game_share/action_dummy.h virtual void unpack (NLMISC::CBitMemStream &message) + // Dummy1 ( 32 bits unsigned ) + // Dummy2 ( 32 bits unsigned ) + uint32_t Dummy1 = msgin->get_uint32(); + uint32_t Dummy2 = msgin->get_uint32(); + DBG_PRINT("ACTION_DUMMY_CODE Dummy1:" + uitos(Dummy1) + " Dummy2:" + uitos(Dummy2)); + break; + } + default: + { + ERR_PRINT("Impossible to decode message received from server (code:" + uitos(code) + ")"); + break; + } + } +} + +void ActionFactory::decode(NetworkData * data, Ref msgin) +{ + // khanat-opennel-code/code/ryzom/client/src/impulse_decoder.cpp:38 void CImpulseDecoder::decode(CBitMemStream &inbox, TPacketNumber receivedPacket, TPacketNumber receivedAck, TPacketNumber nextSentPacket, vector &actions) + int keep; + bool check_once; + bool next; + uint32_t * last_ack; + int level; + int channel; + int num; + data->_last_received_ack = msgin->get_uint32(); + for( level=0 ; level < 3 ; ++level ) + { + DBG_PRINT("level:" + itos(level)); + switch(level) + { + case 0: + last_ack = data->_last_ack_0; + channel = 0; + break; + case 1: + last_ack = data->_last_ack_1; + channel = data->_current_received_number & 1; + break; + default: // 2 + last_ack = data->_last_ack_2; + channel = data->_current_received_number & 3; + break; + } + DBG_PRINT("channel:" + itos(channel)); + keep = -1; + check_once = false; + num = 0; + next = msgin->get_bool(); + DBG_PRINT("next:" + itos(next)); + while(next == true) + { + if( check_once == false ) + { + check_once = true; + //keep = diff_uint32_circulate(received_ack, last_ack[channel]) >= 0; + keep = data->_last_received_ack >= last_ack[channel]; + if(keep) + last_ack[channel] = data->_current_send_number; + } + num ++; + unpack(msgin); + + // read next packet + next = msgin->get_bool(); + DBG_PRINT("next:" + itos(next)); + } + } +} \ No newline at end of file diff --git a/modules/command/action_factory.h b/modules/command/action_factory.h new file mode 100644 index 0000000..f4a48db --- /dev/null +++ b/modules/command/action_factory.h @@ -0,0 +1,35 @@ +/* + Action Factory + + 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 ACTION_FACTORY_H +#define ACTION_FACTORY_H + +#include "core/object.h" +#include "modules/networkconnection/network_data.h" + +class ActionFactory +{ +public: + void decode_message(Ref msgin); + void unpack(Ref msgin); + void decode(NetworkData * data, Ref msgin); +}; + +#endif \ No newline at end of file diff --git a/modules/command/config.py b/modules/command/config.py new file mode 100644 index 0000000..140ba88 --- /dev/null +++ b/modules/command/config.py @@ -0,0 +1,15 @@ +# config.py + +def can_build(env, platform): + return True + +def configure(env): + pass + +def get_doc_classes(): + return [ + "ActionFactory", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/modules/command/register_types.cpp b/modules/command/register_types.cpp new file mode 100644 index 0000000..578a000 --- /dev/null +++ b/modules/command/register_types.cpp @@ -0,0 +1,14 @@ +/* register_types.cpp */ + +#include "register_types.h" + +#include "core/class_db.h" +#include "action_factory.h" + +void register_command_types() { + // ClassDB::register_class(); +} + +void unregister_command_types() { + // Nothing to do here in this example. +} diff --git a/modules/command/register_types.h b/modules/command/register_types.h new file mode 100644 index 0000000..a7655e2 --- /dev/null +++ b/modules/command/register_types.h @@ -0,0 +1,5 @@ +/* register_types.h */ + +void register_command_types(); +void unregister_command_types(); +/* yes, the word in the middle must be the same as the module folder name */ diff --git a/modules/networkconnection/network_data.h b/modules/networkconnection/network_data.h index ead602d..5650936 100644 --- a/modules/networkconnection/network_data.h +++ b/modules/networkconnection/network_data.h @@ -23,6 +23,7 @@ // #include "core/reference.h" // #include "core/io/packet_peer_udp.h" +#include "core/reference.h" #include "modules/bitset/bitset.h" #include "core/ustring.h" @@ -77,7 +78,6 @@ public: void define_lang(String lang); void define_user(String user_addr, String user_key, String user_id); void define_checksum_msg_xml(Array & checksum_msg_xml); - }; #endif \ No newline at end of file diff --git a/modules/networkconnection/state_connexion.cpp b/modules/networkconnection/state_connexion.cpp index c4cd3fc..30ade29 100644 --- a/modules/networkconnection/state_connexion.cpp +++ b/modules/networkconnection/state_connexion.cpp @@ -23,8 +23,7 @@ #include "network_connection_core.h" #include "modules/debug/debug.h" #include "modules/networkconnection/network_data.h" - - +#include "modules/command/action_factory.h" inline uint32_t diff_uint32_circulate(uint32_t a, uint32_t b) { @@ -83,6 +82,8 @@ StateConnectionBase::StateConnectionBase(NetworkConnectionCore * network) { this->_network = network; this->_data = & (network->_network_data); + //this->_data = new Ref(network->_network_data); + //this->_data.reference_ptr(network->_network_data); } /* @@ -411,211 +412,6 @@ void StateConnectionConnected::receive_system_sync(Ref msgin) ERR_PRINT("MSG.XML is wrong"); } -void StateConnectionConnected::unpack(Ref msgin) -{ - bool shortcode = msgin->get_bool(); - uint8_t code; - DBG_PRINT("shortcode:" + itos(shortcode)); - if ( shortcode == true ) - code = msgin->get_serial(2); - else - code = msgin->get_uint8(); - DBG_PRINT("code:" + itos(code)); - switch (code) - { - case ACTIONCODE::ACTION_POSITION_CODE: - { - // khanat-opennel-code/code/ryzom/common/src/game_share/action_position.cpp:34 void CActionPosition::unpack (NLMISC::CBitMemStream &message) - // px ( 16 bit unsigned ) - // py ( 16 bit unsigned ) - // pz ( 16 bit unsigned ) : low bit have other signification - // 0x01 : IsRelative - // 0x02 : Interior - DBG_PRINT("ACTION_GENERIC_CODE"); - uint16_t px = msgin->get_uint16(); - uint16_t py = msgin->get_uint16(); - uint16_t pz = msgin->get_uint16(); - bool IsRelative = (pz & 0x1) != 0; - bool Interior = (pz & 0x2) != 0; - DBG_PRINT("ACTION_GENERIC_CODE px:" + uitos(px) + " py:" + uitos(py) + " pz:" + uitos(pz) + " IsRelative:" + uitos(IsRelative) + " Interior:" + uitos(Interior)); - break; - } - case ACTIONCODE::ACTION_GENERIC_CODE: - { - DBG_PRINT("ACTION_GENERIC_CODE"); - // khanat-opennel-code/code/ryzom/common/src/game_share/action_generic.cpp void CActionGeneric::unpack (NLMISC::CBitMemStream &message) - // size ( 32 bits unsigned ) : if size > 512 we have an error (normally reject by server) - // StreamByte ( Array : size * 8 bits unsigned ) - uint32_t size = msgin->get_uint32(); - DBG_PRINT("ACTION_GENERIC_CODE size:" + uitos(size)); - PoolByteArray StreamByte = msgin->get_array_uint8(size); - DBG_PRINT("ACTION_GENERIC_CODE size:" + uitos(size)); - break; - } - case ACTIONCODE::ACTION_GENERIC_MULTI_PART_CODE: - { - DBG_PRINT("ACTION_GENERIC_MULTI_PART_CODE"); - // khanat-opennel-code/code/ryzom/common/src/game_share/action_generic_multi_part.h:46 virtual void unpack (NLMISC::CBitMemStream &message) - // Number ( 8 bits unsigned ) - // Part ( 16 bits unsigned ) - // NbBlock ( 16 bits unsigned ) - // size ( 32 bits unsigned ) - // PartCont ( Array : size * 8 bits unsigned ) - uint8_t Number = msgin->get_uint8(); - uint16_t Part = msgin->get_uint16(); - uint16_t NbBlock = msgin->get_uint16(); - uint32_t size = msgin->get_uint32(); - PoolByteArray StreamByte = msgin->get_array_uint8(size); - DBG_PRINT("ACTION_GENERIC_MULTI_PART_CODE Number:" + uitos(Number) + " Part:" + uitos(Part) + " NbBlock:" + uitos(NbBlock) + " size:" + uitos(size)); - break; - } - case ACTIONCODE::ACTION_SINT64: - { - DBG_PRINT("ACTION_SINT64"); - // khanat-opennel-code/code/ryzom/common/src/game_share/action_sint64.cpp:86 void CActionSint64::unpack (NLMISC::CBitMemStream &message) - // value ( 64 bits unsigned ) - uint64_t value = msgin->get_uint64(); - DBG_PRINT("ACTION_SINT64 value:" + uitos(value)); - break; - } - case ACTIONCODE::ACTION_SYNC_CODE: - { - DBG_PRINT("ACTION_SYNC_CODE"); - // khanat-opennel-code/code/ryzom/common/src/game_share/action_sync.h:44 virtual void unpack (NLMISC::CBitMemStream &message) - // Sync ( 32 bits unsigned ) - // BKEntityId ( 64 bits unsigned ) [see definition : khanat-opennel-code/code/nel/include/nel/misc/entity_id.h:64] - uint32_t Sync = msgin->get_uint32(); - uint64_t BKEntityId = msgin->get_uint64(); - DBG_PRINT("ACTION_SYNC_CODE Sync:" + uitos(Sync) + " BKEntityId:" + uitos(BKEntityId)); - break; - } - case ACTIONCODE::ACTION_DISCONNECTION_CODE: - { - // khanat-opennel-code/code/ryzom/common/src/game_share/action_disconnection.h - // No data - DBG_PRINT("ACTION_DISCONNECTION_CODE"); - break; - } - case ACTIONCODE::ACTION_ASSOCIATION_CODE: - { - DBG_PRINT("ACTION_ASSOCIATION_CODE"); - // khanat-opennel-code/code/ryzom/common/src/game_share/action_association.h virtual void unpack (NLMISC::CBitMemStream &message) - // IsNewAssociation ( bool / 1 bit ) - // if IsNewAssociation is true: - // SheetId ( 32 bits unsigned ) - // Replace ( bool / 1 bit ) - uint32_t SheetId = msgin->get_uint32(); - bool Replace = msgin->get_bool(); - DBG_PRINT("ACTION_ASSOCIATION_CODE SheetId:" + uitos(SheetId) + " Replace:" + uitos(Replace)); - break; - } - case ACTIONCODE::ACTION_LOGIN_CODE: - { - DBG_PRINT("ACTION_LOGIN_CODE"); - // khanat-opennel-code/code/ryzom/common/src/game_share/action_login.h virtual void unpack (NLMISC::CBitMemStream &message) - // ua ( 32 bits unsigned ) - // uk ( 32 bits unsigned ) - // ui ( 32 bits unsigned ) - uint32_t ua = msgin->get_uint32(); - uint32_t uk = msgin->get_uint32(); - uint32_t ui = msgin->get_uint32(); - DBG_PRINT("ACTION_LOGIN_CODE ua:" + uitos(ua) + " uk:" + uitos(uk)+ " ui:" + uitos(ui)); - break; - } - case ACTIONCODE::ACTION_TARGET_SLOT_CODE: - { - DBG_PRINT("ACTION_TARGET_SLOT_CODE"); - // khanat-opennel-code/code/ryzom/common/src/game_share/action_target_slot.h virtual void unpack (NLMISC::CBitMemStream &message) - // Slot ( 8 bits unsigned ) - // TargetOrPickup (2 bits unsigned) - uint8_t Slot = msgin->get_uint8(); - uint32_t TargetOrPickup = msgin->get_serial(2); - DBG_PRINT("ACTION_TARGET_SLOT_CODE Slot:" + uitos(Slot) + " TargetOrPickup:" + uitos(TargetOrPickup)); - break; - } - case ACTIONCODE::ACTION_DUMMY_CODE: - { - DBG_PRINT("ACTION_DUMMY_CODE"); - // khanat-opennel-code/code/ryzom/common/src/game_share/action_dummy.h virtual void unpack (NLMISC::CBitMemStream &message) - // Dummy1 ( 32 bits unsigned ) - // Dummy2 ( 32 bits unsigned ) - uint32_t Dummy1 = msgin->get_uint32(); - uint32_t Dummy2 = msgin->get_uint32(); - DBG_PRINT("ACTION_DUMMY_CODE Dummy1:" + uitos(Dummy1) + " Dummy2:" + uitos(Dummy2)); - break; - } - default: - { - ERR_PRINT("Impossible to decode message received from server (code:" + uitos(code) + ")"); - break; - } - } -} - -void StateConnectionConnected::decode(Ref msgin, uint32_t current_received_number, uint32_t received_ack, uint32_t next_sent_packet) -{ - // khanat-opennel-code/code/ryzom/client/src/impulse_decoder.cpp:38 void CImpulseDecoder::decode(CBitMemStream &inbox, TPacketNumber receivedPacket, TPacketNumber receivedAck, TPacketNumber nextSentPacket, vector &actions) - int keep; - bool check_once; - bool next; - uint32_t * last_ack; - int level; - int channel; - int num; - this->_data->_last_received_ack = msgin->get_uint32(); - for( level=0 ; level < 3 ; ++level ) - { - DBG_PRINT("level:" + itos(level)); - switch(level) - { - case 0: - last_ack = this->_data->_last_ack_0; - channel = 0; - break; - case 1: - last_ack = this->_data->_last_ack_1; - channel = current_received_number & 1; - break; - default: // 2 - last_ack = this->_data->_last_ack_2; - channel = current_received_number & 3; - break; - } - DBG_PRINT("channel:" + itos(channel)); - keep = -1; - check_once = false; - num = 0; - next = msgin->get_bool(); - DBG_PRINT("next:" + itos(next)); - while(next == true) - { - if( check_once == false ) - { - check_once = true; - //keep = diff_uint32_circulate(received_ack, last_ack[channel]) >= 0; - keep = received_ack >= last_ack[channel]; - if(keep) - last_ack[channel] = next_sent_packet; - } - num ++; - unpack(msgin); - /* - action = self._CActionFactory.unpack(msgin) - if keep: - logging.getLogger(LOGGER).debug("keep : %s" % str(action)) - actions.append(copy.copy(action)) - elif action: - logging.getLogger(LOGGER).debug("append : %s" % str(action)) - self.removeCAction(copy.copy(action)) - */ - - // read next packet - next = msgin->get_bool(); - DBG_PRINT("next:" + itos(next)); - } - } -} - void StateConnectionConnected::receive_message(int index) { // SHOW_USAGE_MEMORY @@ -669,7 +465,8 @@ void StateConnectionConnected::receive_message(int index) else { DBG_PRINT("Receive application message (current_received_number:" + itos(current_received_number) + ") [queue length:" + uitos(this->_network->_queue.length()) + "]"); - decode(msgin, current_received_number, this->_data->_last_received_ack, this->_data->_current_send_number); + ActionFactory decoder; + decoder.decode(this->_data, msgin); } calculate_ack_bit(this->_data, system_mode); diff --git a/modules/networkconnection/state_connexion.h b/modules/networkconnection/state_connexion.h index 471f136..703a92e 100644 --- a/modules/networkconnection/state_connexion.h +++ b/modules/networkconnection/state_connexion.h @@ -142,9 +142,7 @@ public: void send_system_disconnect(); void send_system_ack_sync(); void send_system_ack_probe(); - void unpack(Ref msgin); void receive_system_sync(Ref msgin); - void decode(Ref msgin, uint32_t current_received_number, uint32_t received_ack, uint32_t next_sent_packet); void receive_message(int index); void send_message(); }; diff --git a/modules/referentialmessage/referentialmessage.cpp b/modules/referentialmessage/referentialmessage.cpp index 6c75d87..d5e7bb9 100644 --- a/modules/referentialmessage/referentialmessage.cpp +++ b/modules/referentialmessage/referentialmessage.cpp @@ -26,6 +26,7 @@ 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("read_command"), &ReferentialMessage::read_command); ClassDB::bind_method(D_METHOD("clear_session"), &ReferentialMessage::clear_session); } @@ -40,6 +41,11 @@ void ReferentialMessage::show() ReferentialMessageCore::get_singleton()->show(); } +int ReferentialMessage::read_command(Ref msgin) +{ + return ReferentialMessageCore::get_singleton()->read_command(msgin); +} + void ReferentialMessage::clear_session() { ReferentialMessageCore::clear_session(); diff --git a/modules/referentialmessage/referentialmessage.h b/modules/referentialmessage/referentialmessage.h index 35f9445..a57e62d 100644 --- a/modules/referentialmessage/referentialmessage.h +++ b/modules/referentialmessage/referentialmessage.h @@ -38,6 +38,7 @@ public: void _init() {}; void read_referential(Dictionary dictionary_message); void show(); + int read_command(Ref msgin); void clear_session(); }; diff --git a/modules/referentialmessage/referentialmessagecore.cpp b/modules/referentialmessage/referentialmessagecore.cpp index eb6ead1..ea778ec 100644 --- a/modules/referentialmessage/referentialmessagecore.cpp +++ b/modules/referentialmessage/referentialmessagecore.cpp @@ -731,6 +731,16 @@ void ElementReferential::show(int level, int pos) } } +int ElementReferential::read_command(Ref msgin) +{ + uint32_t i = msgin->get_serial(_power2); + Ref child = _children[i]; + + if ( child->_id != ReferentialMessageCore::Command::__LAST_ELEMENT ) + return child->_id; + return child->read_command(msgin); +} + /* * ReferentialMessageCore */ @@ -1844,4 +1854,9 @@ void ReferentialMessageCore::clear_session() DBG_PRINT("Clear session for Referential Message."); delete ReferentialMessageCore::singleton; ReferentialMessageCore::singleton = nullptr; +} + +int ReferentialMessageCore::read_command(Ref msgin) +{ + return _decoder->read_command(msgin); } \ No newline at end of file diff --git a/modules/referentialmessage/referentialmessagecore.h b/modules/referentialmessage/referentialmessagecore.h index ffa904a..f9b0e37 100644 --- a/modules/referentialmessage/referentialmessagecore.h +++ b/modules/referentialmessage/referentialmessagecore.h @@ -26,6 +26,8 @@ #include "modules/bitstream/bitstream.h" #include "modules/debug/debug.h" +String get_command_name(uint32_t id); + inline uint32_t getPowerOf2(uint32_t v) { // See code : khanat-opennel-code/code/nel/src/misc/common.cpp @@ -56,6 +58,7 @@ public: 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); + int read_command(Ref msgin); }; class ReferentialMessageCore : public Reference @@ -435,6 +438,7 @@ public: void show(); static void clear_session(); + int read_command(Ref msgin); }; VARIANT_ENUM_CAST(ReferentialMessageCore::Command);