int Scene_Server_Request::logic_logout_ready(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { if (!player) { MSG_USER("can not find player, role:%ld", role_id); return 0; } Time_Value sign_out_flag; sign_out_flag.deserialize(buf); int out_reason = 0, need_return = 0; buf.read_int32(out_reason); buf.read_int32(need_return); Monitor_Unique_ID logic_muid = player->monitor_link().logic_muid; if (player) { MSG_DEBUG("scene logout success, role:%ld, out_reason:%d, notice_logic:%d, force:%d", role_id, out_reason, need_return, player->fighter_detail().force); player->sign_out(!need_return); monitor()->unbind_scene_player(role_id); } else { MSG_USER("scene logout error, role:%ld, out_reason:%d, notice_logic:%d", role_id, out_reason, need_return); } // 登陆错误时不需要回去 if (need_return) { Block_Buffer inner_buf; inner_buf.make_message(LOGIC_SCENE_LOGOUT_READY); sign_out_flag.serialize(inner_buf); inner_buf.finish_message(); inner_buf.make_head(inner_buf.get_msg_id(), role_id); monitor()->send_to_monitor(logic_muid, inner_buf); } return 0; }
void Map_Team::deserialize(Block_Buffer &buf) { buf.read_int8(type_); buf.read_string(words_); buf.read_int32(scene_id_); buf.read_int8(degree_); buf.read_uint32(team_index_); buf.read_int64(team_id_); buf.read_int64(team_id_for_scene_); buf.read_int64(leader_role_id_); uint16_t len = 0; buf.read_uint16(len); int64_t role_id = 0; for (uint16_t i = 0; i < len; ++i) { buf.read_int64(role_id); team_member_set_.insert(role_id); } buf.read_uint16(len); for (uint16_t i = 0; i < len; ++i) { buf.read_int64(role_id); offline_teamer_map_.insert(std::make_pair(role_id, Online_Teamer_Info())); } buf.read_int8(in_battle_); buf.read_uint16(len); Int_Role_Id int_role_id; Int_Role_Id_Vec lineup; for (uint16_t i = 0; i < len; ++i) { int_role_id.deserialize(buf); lineup.push_back(int_role_id); } this->lineup_replace(lineup); buf.read_int32(enter_level_); buf.read_int16(fail_times_); buf.read_int16(match_fail_); buf.read_bool(is_not_first_team_fb_); }
int Anci_Artifact_Detail::deserialize(Block_Buffer &buffer) { buffer.read_int64(role_id); // buffer.read_int64(perfectPoint); uint16_t len = 0; buffer.read_uint16(len); aa_info_map.clear(); Anci_Artifact_Cond_Info info; for (uint16_t i = 0; i < len; ++i) { info.reset(); buffer.read_int32(info.id); buffer.read_int8(info.state_count); buffer.read_int32(info.data); aa_info_map.insert(std::make_pair(info.id, info)); } buffer.read_uint16(len); complete_ids.clear(); int32_t complete_id = 0; for (uint16_t i = 0; i < len; ++i) { buffer.read_int32(complete_id); complete_ids.insert(complete_id); } aa_unban_info.clear(); Anci_Artifact_Unban_Info aa_ui; for (uint16_t i = 0; i < len; ++i) { aa_ui.reset(); buffer.read_int32(aa_ui.id); buffer.read_int8(aa_ui.state); buffer.read_int8(aa_ui.box_state); aa_unban_info.insert(std::make_pair(aa_ui.id, aa_ui)); } return 0; }
int Artifact_Detail::deserialize(Block_Buffer & r) { if(r.read_int32(artifact_id) || r.read_int32(artifact_lvl)) { return -1; } return 0; }
int Skill_Running_Info::deserialize(Block_Buffer &buf) { uint32_t sec = 0, usec = 0; buf.read_int32(skill_id); buf.read_uint32(sec); buf.read_uint32(usec); last_use_timestamp.sec(sec); last_use_timestamp.usec(usec); buf.read_int32(use_times); uint16_t size; buf.read_uint16(size); buf.read_int32(last_step); buf.read_uint32(sec); buf.read_uint32(usec); config_cache = CONFIG_CACHE_FIGHTER->skill_config_cache(skill_id); if (NULL == config_cache) { return -1; } return 0; }
int Login_Client_Messager::process_block(Block_Buffer &buf) { LOGIN_MANAGER->add_recv_bytes(buf.readable_bytes()); int32_t cid = 0; int16_t len = 0; int32_t msg_id = 0; int32_t status = 0; int32_t serial_cipher = 0; int32_t msg_time_cipher = 0; buf.read_int32(cid); buf.read_int16(len); buf.read_int32(msg_id); buf.read_int32(status); buf.read_int32(serial_cipher); buf.read_int32(msg_time_cipher); LOGIN_MANAGER->add_msg_count(msg_id); switch (msg_id) { case REQ_CONNECT_LOGIN:{ connect_login(cid, msg_id, buf); break; } default: { LOG_ERROR("error msg_id:%d", msg_id); break; } } return 0; }
int Scene_Server_Request::process_20300100(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { Monitor_Unique_ID logic_muid; role_id_t player_role_id = 0; int level = 0; int force = 0; role_id_t gang_id = 0; int8_t remain_income_num = 0; int16_t income_rate = 0; int total_merit = 0; int remain_time = 0; int act_time = 0; std::string server_name; logic_muid.deserialize(buf); buf.read_int64(player_role_id); buf.read_int32(level); buf.read_int32(force); buf.read_int64(gang_id); buf.read_int8(remain_income_num); buf.read_int16(income_rate); buf.read_int32(total_merit); buf.read_int32(remain_time); buf.read_int32(act_time); buf.read_string(server_name); SCENE_WAR_MANAGER->req_enter_war_scene(logic_muid, player_role_id, level, force, gang_id, remain_income_num, income_rate, total_merit, remain_time, act_time, server_name); return 0; }
int Message_Unit::process_timer_msg(uint32_t msg_id, Block_Buffer &buf, Time_Value &now) { if (data_pro_tick_ < Time_Value::gettimeofday()) { server_status(); } switch (msg_id) { case SERVER_INNER_CLIENT_CLOSE: { int cid = 0, close_type = 0; int64_t value = 0; buf.read_int32(cid); buf.read_int32(close_type); buf.read_int64(value); monitor()->close_link_by_cid(cid, Link_Close(close_type, value)); break; } default : { return CALL_CONTINUE; break; } } return CALL_RETURN; }
int Prop_Setter::deserialize(Block_Buffer & r) { int prop_type_ =0, addition_type_ = 0; uint8_t operate_ = 0; if( r.read_int32(prop_type_) || r.read_int32(addition_type_) || r.read_uint8(operate_) || r.read_double(basic) || r.read_double(fixed) || r.read_double(percent) ) return -1; prop_type = Property_Type(prop_type_); addi_type = Addition_Type(addition_type_); operate = Operate_Type(operate_); return 0; }
int Gate_Client_Messager::process_block(Block_Buffer &buf) { GATE_MANAGER->add_recv_bytes(buf.readable_bytes()); int32_t cid = 0; int16_t len = 0; int32_t msg_id = 0; int32_t status = 0; int32_t serial_cipher = 0; int32_t msg_time_cipher = 0; buf.read_int32(cid); buf.read_int16(len); buf.read_int32(msg_id); buf.read_int32(status); buf.read_int32(serial_cipher); buf.read_int32(msg_time_cipher); GATE_MANAGER->add_msg_count(msg_id); if (msg_id >= CLIENT_GATE_MESSAGE_START && msg_id <= CLIENT_GATE_MESSAGE_END) { return process_gate_block(cid, msg_id, buf); } Gate_Player *player = dynamic_cast<Gate_Player*>(GATE_MANAGER->find_cid_player(cid)); if (!player) { LOG_ERROR("cannot find player_cid = %d msg_id = %d ", cid, msg_id); return GATE_MANAGER->close_client(0, cid, ERROR_NOT_LOGIN); } /// 校验包, 用于防截包/自组包/重复发包 if (GATE_MANAGER->verify_pack()) { int result = player->verify_msg_info(serial_cipher, msg_time_cipher); if (result != 0) { LOG_ERROR("msg verify error, player_cid:%d, len:%d, serial_cipher:%d, msg_time_cipher:%d, msg_id:%d, status:%d", cid, len, serial_cipher, msg_time_cipher, msg_id, status); return GATE_MANAGER->close_client(0, cid, result); } } Block_Buffer player_buf; player_buf.reset(); player_buf.make_player_message(msg_id, status, cid); player_buf.copy(&buf); player_buf.finish_message(); if (msg_id >= CLIENT_MASTER_MESSAGE_START && msg_id <= CLIENT_MASTER_MESSAGE_END) { GATE_MANAGER->send_to_master(player_buf); } else if (msg_id >= CLIENT_GAME_MESSAGE_START && msg_id <= CLIENT_GAME_MESSAGE_END) { GATE_MANAGER->send_to_game(player->game_cid(), player_buf); } else { LOG_ERROR("msg_id:%d error", msg_id); } return 0; }
int Talent::deserialize(Block_Buffer &buf) { buf.read_int32(talent_id); buf.read_int32(skill_point); skill_db_info_map.clear(); uint16_t size = 0; buf.read_uint16(size); Skill_DB_Info skill_db_info; for (uint16_t i=0; i<size; ++i) { skill_db_info.reset(); skill_db_info.deserialize(buf); skill_db_info_map[skill_db_info.skill_id] = skill_db_info; } return 0; }
int Honor_Arena_Manager::inner_act_start(const role_id_t gang_id, Block_Buffer& buf){ if(act_state_ != ACT_STATE_START){// act_state_ = ACT_STATE_START; int icon_id = icon_id_; reset(); icon_id_ = icon_id; } int remain_time = 0; int fight_time = 0; buf.read_int32(fight_time); buf.read_int32(remain_time); act_fight_time_ = fight_time; act_end_time_ = Time_Value::gettimeofday() + Time_Value(remain_time); return 0; }
int Scene_Server_Request::process_20100600(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { JUDGE_PLAYER_NULL(player, role_id); int32_t title_id = 0; buf.read_int32(title_id); player->set_title(title_id); return 0; }
int Scene_Server_Request::process_20100032(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { JUDGE_PLAYER_NULL(player, role_id); int skill_id = 0; buf.read_int32(skill_id); player->set_life_skill(skill_id); return 0; }
int Scene_Server_Request::process_20300303(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { //MSG_20300303 msg; //JUDGE_ERROR_RETURN(msg.deserialize(buf)); int act_icon_id = 0; role_id_t gang_id = 0; buf.read_int32(act_icon_id); buf.read_int64(gang_id); switch(act_icon_id){ case 16:{ WORLD_BOSS_MANAGER->inner_act_end(gang_id, buf); break; } case 19:{ GANG_BOSS_MANAGER->inner_act_end(gang_id, buf); break; } case 20:{ VALENTINE_MONSTER_MANAGER->inner_act_end(gang_id, buf); break; } case 22:{ HONOR_ARENA_MANAGER->inner_act_end(gang_id, buf); break; } default:{ break; } } return 0; }
int Scene_Server_Request::process_20100503(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { JUDGE_PLAYER_NULL(player, role_id); int8_t type = 0; uint16_t len = 0; buf.read_int8(type); buf.read_uint16(len); if (len <= 0) { return 0; } // player Hero *hero = SCENE_PUBLIC->find_fight_hero(role_id); if (!hero) { return 0; } if (type == 1) { // add for (uint16_t i = 0; i < len; ++i) { hero->inner_status_insert(buf); } } else { Int_Hash_Set is; int status_id = 0; for (uint16_t i = 0; i < len; ++i) { buf.read_int32(status_id); is.insert(status_id); } hero->erase_status_in_set(is); } return 0; }
int Message_Unit::process_client_buffer(Block_Buffer &buf) { msg_tick_ = Time_Value::gettimeofday(); int cid = 0; uint32_t len = 0; uint32_t msg_id = 0; uint32_t serial_cipher = 0; uint32_t msg_time_cipher = 0; if (buf.read_int32(cid) || buf.read_uint32(len) || buf.read_uint32(msg_id) || buf.read_uint32(serial_cipher) || buf.read_uint32(msg_time_cipher)) { LOG_USER("deserialize error, cid:%d len:%d msg_id:%d", cid, len, msg_id); monitor()->close_client_by_cid(cid, Time_Value(2), 10000101); return -1; } process_client_msg(msg_id, cid, buf, serial_cipher, msg_time_cipher); count_process_time(msg_id); return 0; }
void Team_Arena_Controler::update_role_score(Block_Buffer &buf) { uint8_t type = 0; buf.read_uint8(type); if (type) { int role_size = 0; std::string server_name; buf.read_string(server_name); buf.read_int32(role_size); for (int i = 0; i < role_size; ++i) { role_id_t role_id = 0; int score = 0; int force = 0; std::string name; buf.read_int64(role_id); buf.read_int32(score); buf.read_int32(force); buf.read_string(name); Team_Role_Score_Map::iterator find_it = team_role_score_map.find(role_id); if (find_it != team_role_score_map.end()) { find_it->second.score = score; find_it->second.change = true; } else { Team_Role_Score role_score; role_score.role_id = role_id; role_score.score = score; role_score.force = force; role_score.name = name; role_score.area = server_name; team_role_score_map.insert(std::make_pair(role_id, role_score)); } } if (level_team_role_score_map.empty()) refresh_rank_list(); } else { team_role_score_map.clear(); level_team_role_score_map.clear(); } }
int Scene_Server_Request::process_20420000(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { JUDGE_PLAYER_NULL(player, role_id); role_id_t sender_role_id = 0; int bless_buf_id = 0; buf.read_int64(sender_role_id); buf.read_int32(bless_buf_id); player->inner_send_bless_buf(sender_role_id, bless_buf_id); return 0; }
int Scene_Server_Request::process_20100026(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { JUDGE_PLAYER_NULL(player, role_id); int32_t skill_point = 0; buf.read_int32(skill_point); if (skill_point > 0) { player->add_skill_pointer(skill_point); } return 0; }
int Honor_Arena_Manager::inner_act_end(const role_id_t gang_id, Block_Buffer& buf){ if(act_state_ != ACT_STATE_START){// return 0; } int remain_time = 0; buf.read_int32(remain_time); act_end_time_ = Time_Value::gettimeofday() + Time_Value(remain_time); return 0; }
void Expedition_Scene_Demage_Rank_Data::deserialize(Block_Buffer &r) { r.read_string(role_name); r.read_int64(role_id); r.read_int64(gang_id); r.read_string(gang_name); r.read_int64(uuid); r.read_string(server_name); r.read_int32(force); r.read_int32(level); r.read_double(demage); }
int Public_Detail::deserialize(Block_Buffer &buffer) { buffer.read_string(plot_id); buffer.read_int32(plot_step); buffer.read_bool(plot_switch); uint16_t size = 0; buffer.read_uint16(size); std::string str = ""; int num = 0; for (uint16_t i = 0; i < size; ++i) { buffer.read_string(str); buffer.read_int32(num); plot_info.insert(String_Int_Map::value_type(str, num)); } buffer.read_int32(awake_lvl); Artifact_Detail artifact_detail; buffer.read_uint16(size); for(uint16_t i = 0; i < size; ++i) { artifact_detail.reset(); if (artifact_detail.deserialize(buffer)) { continue; }; artifacts.insert(std::make_pair(artifact_detail.artifact_id, artifact_detail)); } int32_t gift_lvl = 0; int8_t status = 0; buffer.read_uint16(size); for(uint16_t i = 0; i < size; ++i) { buffer.read_int32(gift_lvl); buffer.read_int8(status); fornotice_gifts_status.insert(std::make_pair(gift_lvl, status)); } buffer.read_int32(exploit_val); buffer.read_int32(exploit_lvl); return 0; }
int Heroer_Detail::deserialize_fighter(Block_Buffer &buffer){ this->hero_base_detail_.deserialize(buffer); buffer.read_int32(this->fighter_index); int8_t has_hero = 0; buffer.read_int8(has_hero); if(has_hero != 0){ Hero_Info_Detail info; info.deserialize(buffer); this->hero_map[this->fighter_index] = info; } return 0; }
int Hero_Info_Detail::deserialize(Block_Buffer &r) { if( r.read_int32(hero_id) || r.read_int32(hero_index) || r.read_int32(hero_facade_id) || r.read_string(hero_name) || r.read_int8(is_outer) || r.read_int8(is_fighter) || r.read_int32(level) || r.read_int32(formation) || r.read_int32(awake_lvl) || r.read_double(exp) ) return -1; uint16_t __prop_value_vec_size; if(r.read_uint16(__prop_value_vec_size) ) return -1; prop_value.reserve(__prop_value_vec_size); for(uint16_t i = 0; i < __prop_value_vec_size; ++i) { Int_Double v; if(v.deserialize(r)) return -1; prop_value.push_back(v); } uint16_t size = 0; Artifact_Detail artifact_detail; r.read_uint16(size); for(uint16_t i = 0; i < size; ++i) { artifact_detail.reset(); if (artifact_detail.deserialize(r)) { continue; }; artifacts.insert(std::make_pair(artifact_detail.artifact_id, artifact_detail)); } hero_fighter_detail.deserialize(r); return 0; }
int DB_Worker::process_save_player(int cid, Block_Buffer &buffer) { int32_t status = buffer.read_int32(); if (status == 1) { int rdx = buffer.get_read_idx(); buffer.read_int32(); int64_t role_id = buffer.read_int64(); buffer.set_read_idx(rdx); save_player_data(buffer); Block_Buffer buf; buf.make_inner_message(SYNC_DB_GAME_SAVE_PLAYER); MSG_550003 msg; msg.role_id = role_id; msg.serialize(buf); buf.finish_message(); DB_MANAGER->send_data_block(cid, buf); } else { save_player_data(buffer); } return 0; }
int Honor_Arena_Manager::inner_player_enter(const role_id_t gang_id, Block_Buffer& buf){ role_id_t role_id = 0; std::string role_name = ""; int vip_lv = 0; int career = 0; int force = 0; std::string gang_name; buf.read_int64(role_id); buf.read_string(role_name); buf.read_int32(vip_lv); buf.read_int32(career); buf.read_int32(force); buf.read_string(gang_name); bool is_new = false; Honor_Arena_Player_Info_Map::iterator it = player_info_map_.find(role_id); if(it == player_info_map_.end()){ Honor_Arena_Player_Info player_info; player_info.rank_info.role_id = role_id; player_info.rank_info.score = CONFIG_CACHE_HONOR_ARENA->get_base_score(); player_info.streak_win_state = CONFIG_CACHE_HONOR_ARENA->get_streak_show(); std::pair<Honor_Arena_Player_Info_Map::iterator, bool> result_pair = player_info_map_.insert(std::make_pair(role_id, player_info)); if(result_pair.second == true){ rank_info_.push_back(&(result_pair.first->second)); } is_new = true; } it = player_info_map_.find(role_id); if(it != player_info_map_.end()){ it->second.rank_info.role_name = role_name; it->second.rank_info.guild_name = gang_name; //it->second.rank_info.career = career; it->second.rank_info.force = force; it->second.state = 0; // idle } if(is_new){ refresh_rank(); } return 0; }
int Expedition_Global_Manager_Data::deserialize(Block_Buffer &r) { uint16_t len = 0; int64_t uuid = 0; Time_Value tv = Time_Value::zero; r.read_uint16(len); for (uint16_t i = 0; i < len; ++i) { r.read_int64(uuid); tv.deserialize(r); opened_uuid_opentime_map_.insert(std::make_pair(uuid, tv)); } int inter = 0; r.read_uint16(len); for (uint16_t i = 0; i < len; ++i) { r.read_int64(uuid); r.read_int32(inter); uuid_inter_map_.insert(std::make_pair(uuid, inter)); } r.read_uint16(len); for (uint16_t i = 0; i < len; ++i) { r.read_int32(inter); tv.deserialize(r); opentime_.insert(std::make_pair(inter, tv)); } mmuid_.deserialize(r); // uint32_t inter_u = 0; // Expedition_Manager_Data emd; // r.read_uint16(len); // for (uint16_t i = 0; i < len; ++i) { // emd.reset(); // r.read_uint32(inter_u); // emd.deserialize(r); // inter_manager_data_map_.insert(std::make_pair(inter_u, emd)); // } return 0; }
int Expedition_Occupy_Castle_Data::deserialize(Block_Buffer &r) { r.read_int64(role_id); r.read_int64(gang_id); r.read_int64(server_uuid); r.read_string(role_name); r.read_string(gang_name); r.read_string(server_name); r.read_int32(level); r.read_int32(force); r.read_int16(nums); r.read_int16(get_nums); return 0; }
int Stronghold_Info::deserialize(Block_Buffer &r) { occupier.deserialize(r); uint16_t len = 0; int64_t i_64 = 0; int i_32 = 0; r.read_uint16(len); for (uint16_t i = 0; i < len; ++i) { r.read_int64(i_64); r.read_int32(i_32); defend_id_map.insert(std::make_pair(i_64, i_32)); } return 0; }