test-client-godot/modules/action/action_factory.cpp
2020-05-02 20:52:28 +02:00

1983 lines
No EOL
56 KiB
C++

/*
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 <http://www.gnu.org/licenses/>.
*/
#include "core/reference.h"
#include "core/array.h"
#include "core/dictionary.h"
#include "core/list.h"
#include "modules/debug/debug.h"
#include "modules/networkconnection/network_data.h"
#include "modules/networkconnection/state_connexion.h"
#include "modules/referentialmessage/referentialmessage.h"
#include "modules/referentialmessage/referentialmessagecore.h"
#include "modules/impulse/impulsebase.h"
#include "action_factory.h"
#include "action_genericmultipart.h"
#include "action.h"
void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
{
Dictionary value;
ReferentialMessage ref_msg;
uint32_t id = ref_msg.read_command(msgin);
DBG_PRINT("Decode message:" + ImpulseBase::get_command_name(id));
value["action"] = Action::CODE::ACTION_GENERIC_CODE;
value["impulse"] = id;
#ifdef DEBUG_ENABLED
value["action_debug"] = "ACTION_GENERIC_CODE";
value["impulse_debug"] = ImpulseBase::get_command_name(id);
#endif
switch(id)
{
case ImpulseBase::Impulse::TARGET_PARTY:
{
break;
}
case ImpulseBase::Impulse::TARGET_INVENTORY:
{
break;
}
case ImpulseBase::Impulse::TARGET_FOLLOW:
{
break;
}
case ImpulseBase::Impulse::TARGET_NO_FOLLOW:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_USER_CHAR:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_NO_USER_CHAR:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_USER_CHARS:
{
// khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void impulseUserChars(NLMISC::CBitMemStream &impulse)
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/entity_manager/entity_callbacks.cpp void sendCharactersSummary( CPlayer *player, bool AllAutorized, uint32 bitfieldOwnerOfActiveAnimSession, uint32 bitfieldOwnerOfEditSession )
uint32_t i;
value["ServerPeopleActive"] = msgin->get_uint8();
value["ServerCareerActive"] = msgin->get_uint8();
uint32_t character_summaries_Len = msgin->get_uint32();
value["CharacterSummaries_Len"] = character_summaries_Len;
Array character_summaries;
for(i=0;i<character_summaries_Len;++i)
{
Dictionary character;
character["Version"] = msgin->get_version();
character["Mainland"] = msgin->get_uint32();
character["Name"] = msgin->get_ustring();
character["People"] = msgin->get_uint32();
character["Location"] = msgin->get_uint32();
character["VisualPropA"] = msgin->get_uint64();
character["VisualPropB"] = msgin->get_uint64();
character["VisualPropC"] = msgin->get_uint64();
character["SheetId"] = msgin->get_uint32();
character["Title"] = msgin->get_sint32();
character["CharacterSlot"] = msgin->get_uint8();
character["InRingSession"] = msgin->get_bool();
character["HasEditSession"] = msgin->get_bool();
character["InNewbieland"] = msgin->get_bool();
character_summaries.append(character);
}
value["CharacterSummaries"] = character_summaries;
uint32_t shard_names_Len = msgin->get_uint32();
value["shardNames_Len"] = shard_names_Len;
Array shard_names;
for(i=0;i<shard_names_Len;++i)
{
Dictionary shard_name;
shard_name["ShardNames"] = msgin->get_string();
shard_names.append(shard_name);
}
value["ShardNames"] = shard_names;
value["Privileges"] = msgin->get_string();
value["FreeTrial"] = msgin->get_bool();
uint32_t mainlands_len = msgin->get_uint32();
value["Mainlands_Len"] = mainlands_len;
Array mainlands;
for(i=0;i<mainlands_len;++i)
{
Dictionary mainland;
mainland["id"] = msgin->get_uint32();
mainland["Name"] = msgin->get_ustring();
mainland["Description"] = msgin->get_ustring();
mainland["LanguageCode"] = msgin->get_string();
mainland["Online"] = msgin->get_bool();
mainlands.append(mainland);
}
value["Mainlands"] = mainlands;
break;
}
case ImpulseBase::Impulse::CONNECTION_CREATE_CHAR:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_SELECT_CHAR:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_DELETE_CHAR:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_RENAME_CHAR:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_ENTER:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_READY:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_TIME_DATE_SYNCHRO:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_ASK_NAME:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_VALID_NAME:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_CREATE_CHAR_ERROR:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_RECONNECT:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_SERVER_RECONNECT_OK:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_SHARD_ID:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_SERVER_QUIT_OK:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_SERVER_QUIT_ABORT:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_CLIENT_QUIT_REQUEST:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_MAIL_AVAILABLE:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_GUILD_MESSAGE_AVAILABLE:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_PERMANENT_BAN:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_UNBAN:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_FAR_TP:
{
break;
}
case ImpulseBase::Impulse::CONNECTION_RET_MAINLAND:
{
break;
}
case ImpulseBase::Impulse::DB_UPD_PLR:
{
break;
}
case ImpulseBase::Impulse::DB_UPD_INV:
{
break;
}
case ImpulseBase::Impulse::DB_INIT_PLR:
{
break;
}
case ImpulseBase::Impulse::DB_INIT_INV:
{
break;
}
case ImpulseBase::Impulse::DB_GROUP_UPDATE_BANK:
{
break;
}
case ImpulseBase::Impulse::DB_GROUP_INIT_BANK:
{
break;
}
case ImpulseBase::Impulse::DB_GROUP_RESET_BANK:
{
break;
}
case ImpulseBase::Impulse::POSITION:
{
break;
}
case ImpulseBase::Impulse::HARVEST_DEPOSIT:
{
break;
}
case ImpulseBase::Impulse::HARVEST_CORPSE:
{
break;
}
case ImpulseBase::Impulse::HARVEST_INTERRUPT:
{
break;
}
case ImpulseBase::Impulse::HARVEST_CLOSE_TEMP_INVENTORY:
{
break;
}
case ImpulseBase::Impulse::TRAINING:
{
break;
}
case ImpulseBase::Impulse::JOB_SET_JOB_STATUS:
{
break;
}
case ImpulseBase::Impulse::JOB_SWAP_JOB_STATUS:
{
break;
}
case ImpulseBase::Impulse::CASTING_BEGIN:
{
break;
}
case ImpulseBase::Impulse::CASTING_INTERRUPT:
{
break;
}
case ImpulseBase::Impulse::FABER_OPEN:
{
break;
}
case ImpulseBase::Impulse::FABER_CLOSE:
{
break;
}
case ImpulseBase::Impulse::FABER_EXECUTE:
{
break;
}
case ImpulseBase::Impulse::FABER_SET_NUM_ITEM:
{
break;
}
case ImpulseBase::Impulse::FABER_START_CREATE:
{
break;
}
case ImpulseBase::Impulse::FABER_START_REPAIR:
{
break;
}
case ImpulseBase::Impulse::FABER_START_REFINE:
{
break;
}
case ImpulseBase::Impulse::FABER_SET_MP_QUALITY:
{
break;
}
case ImpulseBase::Impulse::FABER_SET_MP_REFINE:
{
break;
}
case ImpulseBase::Impulse::FABER_SET_TOOL:
{
break;
}
case ImpulseBase::Impulse::FABER_RESET_TOOL:
{
break;
}
case ImpulseBase::Impulse::FABER_INTERRUPT:
{
break;
}
case ImpulseBase::Impulse::COMBAT_ENGAGE:
{
break;
}
case ImpulseBase::Impulse::COMBAT_DISENGAGE:
{
break;
}
case ImpulseBase::Impulse::COMBAT_DEFAULT_ATTACK:
{
break;
}
case ImpulseBase::Impulse::COMBAT_ENGAGE_FAILED:
{
break;
}
case ImpulseBase::Impulse::COMBAT_VALIDATE_MELEE:
{
break;
}
case ImpulseBase::Impulse::COMBAT_PARRY:
{
break;
}
case ImpulseBase::Impulse::COMBAT_DODGE:
{
break;
}
case ImpulseBase::Impulse::COMBAT_PROTECTED_SLOT:
{
break;
}
case ImpulseBase::Impulse::COMBAT_FLYING_ChaScore1_DELTA:
{
break;
}
case ImpulseBase::Impulse::COMBAT_FLYING_TEXT_ISE:
{
break;
}
case ImpulseBase::Impulse::COMBAT_FLYING_TEXT:
{
break;
}
case ImpulseBase::Impulse::STRING_TELL:
{
break;
}
case ImpulseBase::Impulse::STRING_FAR_TELL:
{
break;
}
case ImpulseBase::Impulse::STRING_CHAT:
{
break;
}
case ImpulseBase::Impulse::STRING_CHAT_TEAM:
{
break;
}
case ImpulseBase::Impulse::STRING_ADD_DYN_STR:
{
break;
}
case ImpulseBase::Impulse::STRING_FILTER:
{
break;
}
case ImpulseBase::Impulse::STRING_CHAT_MODE:
{
break;
}
case ImpulseBase::Impulse::STRING_CHAT2:
{
break;
}
case ImpulseBase::Impulse::STRING_TELL2:
{
break;
}
case ImpulseBase::Impulse::STRING_DYN_STRING:
{
break;
}
case ImpulseBase::Impulse::STRING_DYN_STRING_GROUP:
{
break;
}
case ImpulseBase::Impulse::STRING_AFK_TXT:
{
break;
}
case ImpulseBase::Impulse::STUN_STUN:
{
break;
}
case ImpulseBase::Impulse::STUN_WAKE_UP:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_EXECUTE:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_CANCEL:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_CANCEL_CURRENT:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_CANCEL_ALL:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_CLEAR:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_MEMORIZE:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_FORGET:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_EVALUATE:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_ADD_BRICK:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_REMOVE_BRICK:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_START:
{
break;
}
case ImpulseBase::Impulse::SENTENCE_STOP:
{
break;
}
case ImpulseBase::Impulse::TEAM_JOIN:
{
break;
}
case ImpulseBase::Impulse::TEAM_LEAVE:
{
break;
}
case ImpulseBase::Impulse::TEAM_INVITATION:
{
break;
}
case ImpulseBase::Impulse::TEAM_JOIN_PROPOSAL:
{
break;
}
case ImpulseBase::Impulse::TEAM_JOIN_PROPOSAL_DECLINE:
{
break;
}
case ImpulseBase::Impulse::TEAM_KICK:
{
break;
}
case ImpulseBase::Impulse::TEAM_SET_SUCCESSOR:
{
break;
}
case ImpulseBase::Impulse::TEAM_SHARE_OPEN:
{
break;
}
case ImpulseBase::Impulse::TEAM_SHARE_VALID_ITEM:
{
break;
}
case ImpulseBase::Impulse::TEAM_SHARE_INVALID_ITEM:
{
break;
}
case ImpulseBase::Impulse::TEAM_SHARE_VALID:
{
break;
}
case ImpulseBase::Impulse::TEAM_SHARE_INVALID:
{
break;
}
case ImpulseBase::Impulse::TEAM_SHARE_CLOSE:
{
break;
}
case ImpulseBase::Impulse::TEAM_CONTACT_INIT:
{
break;
}
case ImpulseBase::Impulse::TEAM_CONTACT_ADD:
{
break;
}
case ImpulseBase::Impulse::TEAM_CONTACT_DEL:
{
break;
}
case ImpulseBase::Impulse::TEAM_CONTACT_MOVE:
{
break;
}
case ImpulseBase::Impulse::TEAM_CONTACT_CREATE:
{
break;
}
case ImpulseBase::Impulse::TEAM_CONTACT_STATUS:
{
break;
}
case ImpulseBase::Impulse::TEAM_CONTACT_REMOVE:
{
break;
}
case ImpulseBase::Impulse::ITEM_DROP:
{
break;
}
case ImpulseBase::Impulse::ITEM_PICK_UP:
{
break;
}
case ImpulseBase::Impulse::ITEM_PICK_UP_CLOSE:
{
break;
}
case ImpulseBase::Impulse::ITEM_SWAP:
{
break;
}
case ImpulseBase::Impulse::ITEM_ACTIVATE_SHEATH:
{
break;
}
case ImpulseBase::Impulse::ITEM_HARVEST:
{
break;
}
case ImpulseBase::Impulse::ITEM_HARVEST_CLOSE:
{
break;
}
case ImpulseBase::Impulse::ITEM_GIVE:
{
break;
}
case ImpulseBase::Impulse::ITEM_DESTROY:
{
break;
}
case ImpulseBase::Impulse::ITEM_EQUIP:
{
break;
}
case ImpulseBase::Impulse::ITEM_UNEQUIP:
{
break;
}
case ImpulseBase::Impulse::ITEM_TEMP_TO_BAG:
{
break;
}
case ImpulseBase::Impulse::ITEM_ALL_TEMP:
{
break;
}
case ImpulseBase::Impulse::ITEM_NO_TEMP:
{
break;
}
case ImpulseBase::Impulse::ITEM_ENCHANT:
{
break;
}
case ImpulseBase::Impulse::ITEM_OPEN_ROOM_INVENTORY:
{
break;
}
case ImpulseBase::Impulse::ITEM_CLOSE_ROOM_INVENTORY:
{
break;
}
case ImpulseBase::Impulse::ITEM_USE_ITEM:
{
break;
}
case ImpulseBase::Impulse::ITEM_STOP_USE_XP_CAT:
{
break;
}
case ImpulseBase::Impulse::TP_RESPAWN:
{
break;
}
case ImpulseBase::Impulse::TP_BOT:
{
break;
}
case ImpulseBase::Impulse::TP_WANTED:
{
break;
}
case ImpulseBase::Impulse::TP_DEST:
{
break;
}
case ImpulseBase::Impulse::TP_DEST_WITH_SEASON:
{
break;
}
case ImpulseBase::Impulse::TP_ACK:
{
break;
}
case ImpulseBase::Impulse::TP_CORRECT:
{
break;
}
case ImpulseBase::Impulse::DEATH_RESPAWN_POINT:
{
break;
}
case ImpulseBase::Impulse::DEATH_ASK_RESPAWN:
{
break;
}
case ImpulseBase::Impulse::DEATH_RESPAWN:
{
break;
}
case ImpulseBase::Impulse::ANIMALS_BEAST:
{
break;
}
case ImpulseBase::Impulse::ANIMALS_MOUNT_ABORT:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_INVITATION:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_CLOSE_INVITATION:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_PROPOSAL:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_ACCEPT_INVITATION:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_DECLINE_INVITATION:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_VALIDATE:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_INVALIDATE:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_END:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_SEEDS:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_ADD:
{
break;
}
case ImpulseBase::Impulse::EXCHANGE_REMOVE:
{
break;
}
case ImpulseBase::Impulse::DEBUG_WHERE:
{
break;
}
case ImpulseBase::Impulse::DEBUG_WHO:
{
break;
}
case ImpulseBase::Impulse::DEBUG_REPLY_WHERE:
{
break;
}
case ImpulseBase::Impulse::DEBUG_SERVICES:
{
break;
}
case ImpulseBase::Impulse::DEBUG_CMD:
{
break;
}
case ImpulseBase::Impulse::DEBUG_PING:
{
break;
}
case ImpulseBase::Impulse::DEBUG_COUNTER:
{
break;
}
case ImpulseBase::Impulse::COMMAND_EMOTE:
{
break;
}
case ImpulseBase::Impulse::COMMAND_CUSTOM_EMOTE:
{
break;
}
case ImpulseBase::Impulse::COMMAND_WHERE:
{
break;
}
case ImpulseBase::Impulse::COMMAND_ADMIN:
{
break;
}
case ImpulseBase::Impulse::COMMAND_ADMIN_OFFLINE:
{
break;
}
case ImpulseBase::Impulse::COMMAND_REMOTE_ADMIN:
{
break;
}
case ImpulseBase::Impulse::COMMAND_REMOTE_ADMIN_ANSWER:
{
break;
}
case ImpulseBase::Impulse::COMMAND_SIT:
{
break;
}
case ImpulseBase::Impulse::COMMAND_AFK:
{
break;
}
case ImpulseBase::Impulse::COMMAND_RANDOM:
{
break;
}
case ImpulseBase::Impulse::COMMAND_GUILDMOTD:
{
break;
}
case ImpulseBase::Impulse::MP_EVAL_SET_MP:
{
break;
}
case ImpulseBase::Impulse::MP_EVAL_SET_MP_LEVEL:
{
break;
}
case ImpulseBase::Impulse::MP_EVAL_SET_MARKET:
{
break;
}
case ImpulseBase::Impulse::MP_EVAL_EXECUTE:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_NEXT_PAGE_ITEM:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_NEXT_PAGE_MISSION:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_TRADE_ITEM:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_TRADE_TELEPORT:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_TRADE_FACTION:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_TRADE_SKILL:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_TRADE_PACT:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_TRADE_ACTION:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_BUY:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_SELL:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_DESTROY_ITEM:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_REFRESH_TRADE_LIST:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_SET_FILTERS:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_CHOOSE_MISSION:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_DYNAMIC_MISSION:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_CONTINUE_MISSION:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_VALIDATE_PLAYER_GIFT:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_PICK_MISSION:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_DM_CHOICE:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_DM_ACCEPT:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_NEWS:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_CREATE_GUILD:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_END:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_FORCE_END:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_CHOOSE_DUTY:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_NEXT_PAGE_DUTY:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_DUTY_APPLY:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_DUTY_CANCEL_APPLY:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_TRADE_GUILD_OPTIONS:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_BUY_GUILD_OPTION:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_START_GUILD_RESEARCH:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_DESTROY_BUILDING:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_DYNCHAT_OPEN:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_DYNCHAT_CLOSE:
{
break;
}
case ImpulseBase::Impulse::BOTCHAT_DYNCHAT_SEND:
{
break;
}
case ImpulseBase::Impulse::JOURNAL_INIT_COMPLETED_MISSIONS:
{
break;
}
case ImpulseBase::Impulse::JOURNAL_UPDATE_COMPLETED_MISSIONS:
{
break;
}
case ImpulseBase::Impulse::JOURNAL_MISSION_ABANDON:
{
break;
}
case ImpulseBase::Impulse::JOURNAL_GROUP_MISSION_ABANDON:
{
break;
}
case ImpulseBase::Impulse::JOURNAL_ADD_COMPASS:
{
break;
}
case ImpulseBase::Impulse::JOURNAL_ADD_COMPASS_BOT:
{
break;
}
case ImpulseBase::Impulse::JOURNAL_REMOVE_COMPASS:
{
break;
}
case ImpulseBase::Impulse::JOURNAL_REMOVE_COMPASS_BOT:
{
break;
}
case ImpulseBase::Impulse::STRING_MANAGER_SET_LANGUAGE:
{
break;
}
case ImpulseBase::Impulse::STRING_MANAGER_PHRASE_SEND:
{
int i = 1;
uint32_t dynId = msgin->get_uint32();
value["dynId"] = dynId;
uint32_t StringId = msgin->get_uint32();
value["StringId_0"] = StringId;
while(msgin->number_bit_not_read() > 32)
{
StringId = msgin->get_uint32();
value["StringId_" + itos(i)] = StringId;
++i;
}
break;
}
case ImpulseBase::Impulse::STRING_MANAGER_STRING_RQ:
{
break;
}
case ImpulseBase::Impulse::STRING_MANAGER_STRING_RESP:
{
break;
}
case ImpulseBase::Impulse::STRING_MANAGER_RELOAD_CACHE:
{
uint32_t timestamp = msgin->get_uint32();
DBG_PRINT("Decode message:" + ImpulseBase::get_command_name(id) + " timestamp:" + itos(timestamp));
//param.push_back(timestamp);
value["timestamp"] = timestamp;
//data->_server_messages.push_back(value);
break;
}
case ImpulseBase::Impulse::GUILD_CREATE:
{
break;
}
case ImpulseBase::Impulse::GUILD_ABORT_CREATION:
{
break;
}
case ImpulseBase::Impulse::GUILD_OPEN_GUILD_WINDOW:
{
break;
}
case ImpulseBase::Impulse::GUILD_INVITATION:
{
break;
}
case ImpulseBase::Impulse::GUILD_ACCEPT_INVITATION:
{
break;
}
case ImpulseBase::Impulse::GUILD_REFUSE_INVITATION:
{
break;
}
case ImpulseBase::Impulse::GUILD_JOIN_PROPOSAL:
{
break;
}
case ImpulseBase::Impulse::GUILD_SET_GRADE:
{
break;
}
case ImpulseBase::Impulse::GUILD_SET_LEADER:
{
break;
}
case ImpulseBase::Impulse::GUILD_KICK_MEMBER:
{
break;
}
case ImpulseBase::Impulse::GUILD_TELEPORT:
{
break;
}
case ImpulseBase::Impulse::GUILD_ASCENSOR:
{
break;
}
case ImpulseBase::Impulse::GUILD_FIRST_ASCENSOR_PAGE:
{
break;
}
case ImpulseBase::Impulse::GUILD_NEXT_ASCENSOR_PAGE:
{
break;
}
case ImpulseBase::Impulse::GUILD_LEAVE_ASCENSOR:
{
break;
}
case ImpulseBase::Impulse::GUILD_QUIT:
{
break;
}
case ImpulseBase::Impulse::GUILD_SET_PLAYER_TITLE:
{
break;
}
case ImpulseBase::Impulse::GUILD_UPDATE_PLAYER_TITLE:
{
break;
}
case ImpulseBase::Impulse::GUILD_USE_FEMALE_TITLES:
{
break;
}
case ImpulseBase::Impulse::GUILD_PUT_MONEY:
{
break;
}
case ImpulseBase::Impulse::GUILD_TAKE_MONEY:
{
break;
}
case ImpulseBase::Impulse::GUILD_OPEN_INVENTORY:
{
break;
}
case ImpulseBase::Impulse::GUILD_CLOSE_INVENTORY:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_GIVEUP_OUTPOST:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_SELECT:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_UNSELECT:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_DECLARE_WAR_START:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_DECLARE_WAR_ACK:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_DECLARE_WAR_VALIDATE:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_SET_DEF_PERIOD:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_SET_SQUAD:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_SET_SQUAD_SPAWN:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_INSERT_SQUAD:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_REMOVE_SQUAD:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_SET_SQUAD_CAPITAL:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_CHOOSE_SIDE:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_SIDE_CHOSEN:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_BANISH_PLAYER:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_BANISH_GUILD:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_BUY_BUILDING:
{
break;
}
case ImpulseBase::Impulse::OUTPOST_DESTROY_BUILDING:
{
break;
}
case ImpulseBase::Impulse::PHRASE_DELETE:
{
break;
}
case ImpulseBase::Impulse::PHRASE_LEARN:
{
break;
}
case ImpulseBase::Impulse::PHRASE_MEMORIZE:
{
break;
}
case ImpulseBase::Impulse::PHRASE_FORGET:
{
break;
}
case ImpulseBase::Impulse::PHRASE_EXECUTE:
{
break;
}
case ImpulseBase::Impulse::PHRASE_EXECUTE_CYCLIC:
{
break;
}
case ImpulseBase::Impulse::PHRASE_EXECUTE_FABER:
{
break;
}
case ImpulseBase::Impulse::PHRASE_DOWNLOAD:
{
break;
}
case ImpulseBase::Impulse::PHRASE_BUY:
{
break;
}
case ImpulseBase::Impulse::PHRASE_CONFIRM_BUY:
{
break;
}
case ImpulseBase::Impulse::PHRASE_BUY_SHEET:
{
break;
}
case ImpulseBase::Impulse::PHRASE_CANCEL_LINK:
{
break;
}
case ImpulseBase::Impulse::PHRASE_CANCEL_TOP:
{
break;
}
case ImpulseBase::Impulse::PHRASE_CANCEL_ALL:
{
break;
}
case ImpulseBase::Impulse::PHRASE_CRISTALIZE:
{
break;
}
case ImpulseBase::Impulse::PHRASE_EXEC_CYCLIC_ACK:
{
break;
}
case ImpulseBase::Impulse::PHRASE_EXEC_NEXT_ACK:
{
break;
}
case ImpulseBase::Impulse::ITEM_INFO_GET:
{
break;
}
case ImpulseBase::Impulse::ITEM_INFO_SET:
{
break;
}
case ImpulseBase::Impulse::ITEM_INFO_REFRESH_VERSION:
{
break;
}
case ImpulseBase::Impulse::MISSION_PREREQ_GET:
{
break;
}
case ImpulseBase::Impulse::MISSION_PREREQ_SET:
{
break;
}
case ImpulseBase::Impulse::MISSION_ENTER_CRITICAL:
{
break;
}
case ImpulseBase::Impulse::MISSION_ASK_ENTER_CRITICAL:
{
break;
}
case ImpulseBase::Impulse::MISSION_CLOSE_ENTER_CRITICAL:
{
break;
}
case ImpulseBase::Impulse::MISSION_WAKE:
{
break;
}
case ImpulseBase::Impulse::MISSION_GROUP_WAKE:
{
break;
}
case ImpulseBase::Impulse::DUEL_ASK:
{
break;
}
case ImpulseBase::Impulse::DUEL_ACCEPT:
{
break;
}
case ImpulseBase::Impulse::DUEL_REFUSE:
{
break;
}
case ImpulseBase::Impulse::DUEL_ABANDON:
{
break;
}
case ImpulseBase::Impulse::DUEL_INVITATION:
{
break;
}
case ImpulseBase::Impulse::DUEL_CANCEL_INVITATION:
{
break;
}
case ImpulseBase::Impulse::PVP_CHALLENGE_ASK:
{
break;
}
case ImpulseBase::Impulse::PVP_CHALLENGE_ACCEPT:
{
break;
}
case ImpulseBase::Impulse::PVP_CHALLENGE_REFUSE:
{
break;
}
case ImpulseBase::Impulse::PVP_CHALLENGE_ABANDON:
{
break;
}
case ImpulseBase::Impulse::PVP_CHALLENGE_INVITATION:
{
break;
}
case ImpulseBase::Impulse::PVP_CHALLENGE_CANCEL_INVITATION:
{
break;
}
case ImpulseBase::Impulse::PVP_PVP_TAG:
{
break;
}
case ImpulseBase::Impulse::PVP_SET_NEUTRAL_ALLEGIANCE:
{
break;
}
case ImpulseBase::Impulse::PVP_SET_NEUTRAL_ALLEGIANCE_GUILD:
{
break;
}
case ImpulseBase::Impulse::PVP_FACTION_PUSH_FACTION_WAR:
{
break;
}
case ImpulseBase::Impulse::PVP_FACTION_POP_FACTION_WAR:
{
break;
}
case ImpulseBase::Impulse::PVP_FACTION_FACTION_WARS:
{
break;
}
case ImpulseBase::Impulse::ENCYCLOPEDIA_UPDATE:
{
break;
}
case ImpulseBase::Impulse::ENCYCLOPEDIA_INIT:
{
break;
}
case ImpulseBase::Impulse::USER_BARS:
{
break;
}
case ImpulseBase::Impulse::USER_POPUP:
{
break;
}
case ImpulseBase::Impulse::EVENT_SET_ITEM_CUSTOM_TEXT:
{
break;
}
case ImpulseBase::Impulse::EVENT_DUMMY:
{
break;
}
case ImpulseBase::Impulse::TOTEM_BUILD:
{
break;
}
case ImpulseBase::Impulse::TOTEM_DUMMY:
{
break;
}
case ImpulseBase::Impulse::MODULE_GATEWAY_FEOPEN:
{
break;
}
case ImpulseBase::Impulse::MODULE_GATEWAY_GATEWAY_MSG:
{
break;
}
case ImpulseBase::Impulse::MODULE_GATEWAY_FECLOSE:
{
break;
}
case ImpulseBase::Impulse::SEASON_SET:
{
break;
}
case ImpulseBase::Impulse::SEASON_DUMMY:
{
break;
}
case ImpulseBase::Impulse::DM_GIFT_BEGIN:
{
break;
}
case ImpulseBase::Impulse::DM_GIFT_VALIDATE:
{
break;
}
case ImpulseBase::Impulse::RING_MISSION_MISSION_RING_SELECT:
{
break;
}
case ImpulseBase::Impulse::RING_MISSION_DSS_DOWN:
{
break;
}
case ImpulseBase::Impulse::NPC_ICON_GET_DESC:
{
break;
}
case ImpulseBase::Impulse::NPC_ICON_SET_DESC:
{
break;
}
case ImpulseBase::Impulse::NPC_ICON_SVR_EVENT_MIS_AVL:
{
break;
}
case ImpulseBase::Impulse::NPC_ICON_SET_TIMER:
{
break;
}
default:
{
break;
}
}
data->_server_messages.push_back(value);
#ifdef DEBUG_ENABLED
// Check if we have read all data - only on debug mode
{
uint32_t last_data;
while ( msgin->number_bit_not_read() > 0 )
{
DBG_PRINT("Read : " + itos(msgin->number_bit_not_read()));
if ( msgin->number_bit_not_read() >= 8 )
//last_data = msgin->get_uint8();
last_data = 1;
else
last_data = msgin->get_serial(msgin->number_bit_not_read());
if ( last_data != 0 )
{
ERR_PRINT("Missing some data - we dont' have translate all data : " + msgin->show());
break;
}
}
}
#endif
}
void ActionFactory::encode_message(Dictionary value, Ref<BitStream> msgout)
{
ReferentialMessage ref_msg;
int id = value["impulse"];
ref_msg.write_command((ImpulseBase::Impulse)id, msgout);
DBG_PRINT("[ActionFactory::pack] ACTION_GENERIC_CODE encode_message A:" + itos(id) + " / " + msgout->show_detail());
switch(id)
{
case ImpulseBase::Impulse::TARGET_PARTY:
{
break;
}
case ImpulseBase::Impulse::STRING_MANAGER_STRING_RQ:
{
uint32_t stringId = value["stringId"];
msgout->put_uint32(stringId);
DBG_PRINT("[ActionFactory::pack] ACTION_GENERIC_CODE encode_message B:" + itos(id) + " / " + msgout->show_detail());
break;
}
default:
{
break;
}
}
}
void ActionFactory::code(int code, Ref<BitStream> msgout)
{
if(code < 4)
{
msgout->put_bool(true);
msgout->put_serial(code, 2);
}
else
{
msgout->put_bool(false);
msgout->put_uint8(code);
}
}
void ActionFactory::pack(NetworkData * data)
{
while(data->_command_to_send.size())
{
DBG_PRINT("[ActionFactory::pack]");
Dictionary value = data->_command_to_send.pop_front();
int id = value["action"];
switch(id)
{
case Action::CODE::ACTION_POSITION_CODE:
{
break;
}
case Action::CODE::ACTION_GENERIC_CODE:
case Action::CODE::ACTION_GENERIC_MULTI_PART_CODE:
{
Ref<BitStream> msg;
msg.instance();
encode_message(value, msg);
DBG_PRINT("[ActionFactory::pack] ACTION_GENERIC_CODE encode_message :" + msg->show_detail());
if( msg->size_data() < MAX_IMPULSE_BIT_SIZE ) // 1840 bits= 230*8
{
// ACTION_GENERIC_CODE
Ref<BitStream> msgout;
msgout.instance();
code(Action::CODE::ACTION_GENERIC_CODE, msgout);
msg->complet_byte();
DBG_PRINT("[ActionFactory::pack] ACTION_GENERIC_CODE encode_message (Bis):" + msg->show_detail());
DBG_PRINT("[ActionFactory::pack] ACTION_GENERIC_CODE prepared A :" + msgout->show_detail());
msgout->put_uint32(msg->size());
DBG_PRINT("[ActionFactory::pack] ACTION_GENERIC_CODE prepared B :" + msgout->show_detail());
msgout->put_bitstream(msg.ptr());
DBG_PRINT("[ActionFactory::pack] ACTION_GENERIC_CODE prepared C :" + msgout->show_detail());
data->_client_messages.append(msgout); //data->_client_messages.append(msgout->get_data());
DBG_PRINT("[ActionFactory::pack] ACTION_GENERIC_CODE prepared D :" + msgout->show_detail());
msgout.unref();
}
else
{
// ACTION_GENERIC_MULTI_PART_CODE
uint32_t size;
uint32_t last = 0;
uint32_t minimumBitSizeForMP = 1 + 2 + 2 + 4; // header
uint32_t availableSize = (MAX_IMPULSE_BIT_SIZE - minimumBitSizeForMP); // 8
uint32_t bytelen = msg->size();
uint16_t part;
uint16_t nbBlock = (bytelen + availableSize - 1); // availableSize
uint8_t num = data->_impulse_multi_part_number;
PoolByteArray msgTemp;
data->_impulse_multi_part_number += 1;
msg->complet_byte();
for(part = 0 ; part < nbBlock ; ++part)
{
Ref<BitStream> msgout;
msgout.instance();
code(Action::CODE::ACTION_GENERIC_MULTI_PART_CODE, msgout);
msgout->put_uint8(num);
msgout->put_uint16(part);
msgout->put_uint16(nbBlock);
size = availableSize;
if ( size + last > bytelen)
size = bytelen - last;
last = size;
msgout->put_uint32(size);
msgout->get_array_uint8(size);
//msgout->put_bitstream(msg.ptr());-------TODO
data->_client_messages.append(msgout); // data->_client_messages.append(msgout->get_data());
DBG_PRINT("[ActionFactory::pack] ACTION_GENERIC_MULTI_PART_CODE prepared :" + msgout->show_detail());
msgout.unref();
}
}
msg.unref();
break;
}
case Action::CODE::ACTION_SINT64:
{
break;
}
case Action::CODE::ACTION_SYNC_CODE:
{
// not used, here
break;
}
case Action::CODE::ACTION_DISCONNECTION_CODE:
{
break;
}
case Action::CODE::ACTION_ASSOCIATION_CODE:
{
break;
}
case Action::CODE::ACTION_LOGIN_CODE:
{
// not used, here
break;
}
case Action::CODE::ACTION_TARGET_SLOT_CODE:
{
break;
}
case Action::CODE::ACTION_DUMMY_CODE:
{
break;
}
}
}
}
void ActionFactory::unpack(NetworkData * data, Ref<BitStream> 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 Action::CODE::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_POSITION_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;
Dictionary msg;
msg["action"] = code;
#ifdef DEBUG_ENABLED
msg["action_debug"] = "ACTION_POSITION_CODE";
#endif
msg["px"] = px;
msg["py"] = px;
msg["pz"] = px;
msg["IsRelative"] = IsRelative;
msg["Interior"] = Interior;
data->_server_messages.push_back(msg);
DBG_PRINT("ACTION_POSITION_CODE px:" + uitos(px) + " py:" + uitos(py) + " pz:" + uitos(pz) + " IsRelative:" + uitos(IsRelative) + " Interior:" + uitos(Interior));
break;
}
case Action::CODE::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 )
DBG_PRINT("ACTION_GENERIC_CODE");
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<BitStream> tmp;
tmp.instance();
tmp->put_array_uint8(StreamByte);
decode_message(data, tmp);
tmp.unref();
break;
}
case Action::CODE::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 )
DBG_PRINT("ACTION_GENERIC_MULTI_PART_CODE");
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));
if ( ! data->_block.has(Number) )
{
Dictionary newelement;
data->_block[Number] = newelement;
data->_block_used[Number] = 0;
//data->_block[Number] = new GenericMultiPart(Number, NbBlock);
}
Dictionary ele = data->_block[Number]; //[Part] = StreamByte;
ele[Part] = StreamByte;
{
Ref<BitStream> tmp;
tmp.instance();
tmp->put_array_uint8(StreamByte);
tmp.unref();
}
if( ele.size() == NbBlock)
{
int used = data->_block_used[Number];
if ( used != 0 )
break;
int i;
PoolByteArray full;
for(i = 0;i < NbBlock; ++i)
{
PoolByteArray tmp = ele[i];
full.append_array(ele[i]);
}
Ref<BitStream> tmp;
tmp.instance();
tmp->put_array_uint8(full);
decode_message(data, tmp);
tmp.unref();
data->_block_used[Number] = 20;
}
break;
}
case Action::CODE::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 )
DBG_PRINT("ACTION_SINT64");
uint64_t value = msgin->get_uint64();
Dictionary msg;
msg["action"] = code;
#ifdef DEBUG_ENABLED
msg["action_debug"] = "ACTION_SINT64";
#endif
msg["value"] = value;
data->_server_messages.push_back(msg);
DBG_PRINT("ACTION_SINT64 value:" + uitos(value));
break;
}
case Action::CODE::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]
DBG_PRINT("ACTION_SYNC_CODE");
uint32_t Sync = msgin->get_uint32();
uint64_t BKEntityId = msgin->get_uint64();
Dictionary msg;
msg["action"] = code;
#ifdef DEBUG_ENABLED
msg["action_debug"] = "ACTION_SYNC_CODE";
#endif
msg["Sync"] = Sync;
msg["BKEntityId"] = BKEntityId;
data->_server_messages.push_back(msg);
DBG_PRINT("ACTION_SYNC_CODE Sync:" + uitos(Sync) + " BKEntityId:" + uitos(BKEntityId));
break;
}
case Action::CODE::ACTION_DISCONNECTION_CODE:
{
// khanat-opennel-code/code/ryzom/common/src/game_share/action_disconnection.h
// No data
DBG_PRINT("ACTION_DISCONNECTION_CODE");
Dictionary msg;
msg["action"] = code;
#ifdef DEBUG_ENABLED
msg["action_debug"] = "ACTION_DISCONNECTION_CODE";
#endif
data->_server_messages.push_back(msg);
break;
}
case Action::CODE::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 )
DBG_PRINT("ACTION_ASSOCIATION_CODE");
uint32_t SheetId = msgin->get_uint32();
bool Replace = msgin->get_bool();
Dictionary msg;
msg["action"] = code;
#ifdef DEBUG_ENABLED
msg["action_debug"] = "ACTION_ASSOCIATION_CODE";
#endif
msg["SheetId"] = SheetId;
msg["Replace"] = Replace;
data->_server_messages.push_back(msg);
DBG_PRINT("ACTION_ASSOCIATION_CODE SheetId:" + uitos(SheetId) + " Replace:" + uitos(Replace));
break;
}
case Action::CODE::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 )
DBG_PRINT("ACTION_LOGIN_CODE");
uint32_t ua = msgin->get_uint32();
uint32_t uk = msgin->get_uint32();
uint32_t ui = msgin->get_uint32();
Dictionary msg;
msg["action"] = code;
#ifdef DEBUG_ENABLED
msg["action_debug"] = "ACTION_LOGIN_CODE";
#endif
msg["ua"] = ua;
msg["uk"] = uk;
msg["ui"] = ui;
data->_server_messages.push_back(msg);
DBG_PRINT("ACTION_LOGIN_CODE ua:" + uitos(ua) + " uk:" + uitos(uk)+ " ui:" + uitos(ui));
break;
}
case Action::CODE::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)
DBG_PRINT("ACTION_TARGET_SLOT_CODE");
uint8_t Slot = msgin->get_uint8();
uint32_t TargetOrPickup = msgin->get_serial(2);
Dictionary msg;
msg["action"] = code;
#ifdef DEBUG_ENABLED
msg["action_debug"] = "ACTION_TARGET_SLOT_CODE";
#endif
msg["Slot"] = Slot;
msg["TargetOrPickup"] = TargetOrPickup;
data->_server_messages.push_back(msg);
DBG_PRINT("ACTION_TARGET_SLOT_CODE Slot:" + uitos(Slot) + " TargetOrPickup:" + uitos(TargetOrPickup));
break;
}
case Action::CODE::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 )
DBG_PRINT("ACTION_DUMMY_CODE");
uint32_t Dummy1 = msgin->get_uint32();
uint32_t Dummy2 = msgin->get_uint32();
Dictionary msg;
msg["action"] = code;
#ifdef DEBUG_ENABLED
msg["action_debug"] = "ACTION_DUMMY_CODE";
#endif
msg["Dummy1"] = Dummy1;
msg["Dummy2"] = Dummy2;
data->_server_messages.push_back(msg);
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<BitStream> msgin)
{
// khanat-opennel-code/code/ryzom/client/src/impulse_decoder.cpp:38 void CImpulseDecoder::decode(CBitMemStream &inbox, TPacketNumber receivedPacket, TPacketNumber receivedAck, TPacketNumber nextSentPacket, vector<CLFECOMMON::CAction *> &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();
DBG_PRINT("last_received_ack:" + itos(data->_last_received_ack));
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(data, msgin);
// read next packet
next = msgin->get_bool();
DBG_PRINT("next:" + itos(next));
}
}
clear_old_block(data);
}
void ActionFactory::clear_old_block(NetworkData * data)
{
int i;
i = data->_block.size();
while(i>0)
{
i--;
Variant value = data->_block_used.get_value_at_index(i);
Variant key = data->_block_used.get_key_at_index(i);
int used = data->_block_used[key];
if ( used >= 2 )
{
used --;
data->_block_used[key] = used;
}
else if ( used > 0 )
{
data->_block_used.erase(key);
data->_block.erase(key);
DBG_PRINT("Remove block - key:" + String(key));
}
}
}
void ActionFactory::clear_all_block(NetworkData * data)
{
int i;
DBG_PRINT("Remove all block");
i = data->_block.size();
while(i>0)
{
i--;
Variant key = data->_block_used.get_key_at_index(i);
data->_block_used.erase(key);
data->_block.erase(key);
DBG_PRINT("Remove block: key:" + String(key));
}
}