int Expedition_Global_Manager_Data::serialize(Block_Buffer &w) const { w.write_uint16(opened_uuid_opentime_map_.size()); for (Role_Id_Time_Map::const_iterator it = opened_uuid_opentime_map_.begin(); it != opened_uuid_opentime_map_.end(); ++it) { w.write_int64(it->first); it->second.serialize(w); } w.write_uint16(uuid_inter_map_.size()); for (Role_Int_Map::const_iterator it = uuid_inter_map_.begin(); it != uuid_inter_map_.end(); ++it) { w.write_int64(it->first); w.write_int32(it->second); } w.write_uint16(opentime_.size()); for (Int_Time_Map::const_iterator it = opentime_.begin(); it != opentime_.end(); ++it) { w.write_int32(it->first); it->second.serialize(w); } mmuid_.serialize(w); // w.write_uint16(inter_manager_data_map_.size()); // for (Inter_ExpeditionManagerData_Map::const_iterator it = inter_manager_data_map_.begin(); // it != inter_manager_data_map_.end(); ++it) { // w.write_uint32(it->first); // it->second.serialize(w); // } return 0; }
int Public_Detail::serialize(Block_Buffer &buffer) const { buffer.write_string(plot_id); buffer.write_int32(plot_step); buffer.write_bool(plot_switch); buffer.write_uint16(plot_info.size()); for (String_Int_Map::const_iterator it = plot_info.begin(); it != plot_info.end(); ++it) { buffer.write_string(it->first); buffer.write_int32(it->second); } buffer.write_int32(awake_lvl); buffer.write_uint16(artifacts.size()); for (Artifact_Map::const_iterator it = artifacts.begin(); it != artifacts.end(); ++it) { it->second.serialize(buffer); } buffer.write_uint16(fornotice_gifts_status.size()); for (Fornotice_Gifts_Status_Map::const_iterator it = fornotice_gifts_status.begin(); it != fornotice_gifts_status.end(); ++it) { buffer.write_int32(it->first); buffer.write_int8(it->second); } buffer.write_int32(exploit_val); buffer.write_int32(exploit_lvl); return 0; }
void Map_Team::serialize(Block_Buffer &buf) { buf.write_int8(type_); buf.write_string(words_); buf.write_int32(scene_id_); buf.write_int8(degree_); buf.write_uint32(team_index_); buf.write_int64(team_id_); buf.write_int64(team_id_for_scene_); buf.write_int64(leader_role_id_); uint16_t len = 0; len = team_member_set_.size(); buf.write_uint16(len); for (Role_Hash_Set::iterator it = team_member_set_.begin(); it != team_member_set_.end(); ++it) { buf.write_int64(*it); } len = offline_teamer_map_.size(); buf.write_uint16(len); for (RoleID_OnlineMap_TeamerInfo_Map::iterator it = offline_teamer_map_.begin(); it != offline_teamer_map_.end(); ++it) { buf.write_int64(it->first); } buf.write_int8(in_battle_); len = lineup_.size(); buf.write_uint16(len); for (Int_Role_Id_Vec::iterator it = lineup_.begin(); it != lineup_.end(); ++it) { it->serialize(buf); } buf.write_int32(enter_level_); buf.write_int16(fail_times_); buf.write_int16(match_fail_); buf.write_bool(is_not_first_team_fb_); }
void Msg_Struct::build_buffer_map(const Field_Info &field_info, Block_Buffer &buffer, Isolate* isolate, v8::Local<v8::Value> value) { if (!value->IsMap()) { LOG_ERROR("field_name:%s is not map, struct_name:%s", field_info.field_name.c_str(), struct_name().c_str()); buffer.write_uint16(0); return; } Local<Map> map = Local<Map>::Cast(value); int16_t len = map->Size(); buffer.write_uint16(len); Local<Array> array = map->AsArray(); //index N is the Nth key and index N + 1 is the Nth value. if(is_struct(field_info.field_type)) { for (int i = 0; i < len * 2; i = i + 2) { Local<Value> element = array->Get(isolate->GetCurrentContext(), i + 1).ToLocalChecked(); build_buffer_struct(field_info, buffer, isolate, element); } } else { Field_Info key_info; key_info.field_label = "args"; key_info.field_type = field_info.key_type; key_info.field_name = field_info.key_name; for (int i = 0; i < len * 2; i = i + 2) { Local<Value> key = array->Get(isolate->GetCurrentContext(), i).ToLocalChecked(); Local<Value> element = array->Get(isolate->GetCurrentContext(), i + 1).ToLocalChecked(); build_buffer_struct(key_info, buffer, isolate, key); build_buffer_struct(field_info, buffer, isolate, element); } } }
void Answer_Scene::send_to_logic_get_rank_reward(void) { refresh_rank(); //以下代码;策划要求改跨服需要特殊处理 Block_Buffer buf; buf.make_message(INNER_ANSWER_DATA_CHANNEL); buf.write_uint8(ANSWER_DATA_CHANNLE_TYPE_SL_GET_RANK_REWARD); buf.write_uint16(role_sorce_rank.size()); for(RoleID_Data_Vec_Map::iterator iter = role_sorce_rank.begin(); iter != role_sorce_rank.end(); ++iter) { buf.write_uint16(iter->second.size()); for(RoleID_Data_Vec::iterator it = iter->second.begin(); it != iter->second.end(); ++it) { buf.write_int64(it->role_id); } } SCENE_MONITOR->send_to_logic(CONFIG_CACHE->server_flag(), buf); }
void Expedition_Drop_Or_Material::serialize(Block_Buffer &w) const { this->birth_time.serialize(w); w.write_uint16(had_collected.size()); for (Role_Hash_Set::const_iterator it = had_collected.begin(); it != had_collected.end(); ++it) { w.write_int64(*it); } }
int Logic_Status_Detail::serialize(Block_Buffer &buffer) const { // buffer.write_int64(this->role_id); buffer.write_uint16(status_map.size()); for (Status_Map::const_iterator it = status_map.begin(); it != status_map.end(); ++it) { it->second.serialize(buffer); } running_effect.serialize(buffer); return 0; }
int Talent::serialize(Block_Buffer &buf) const { buf.write_int32(talent_id); buf.write_int32(skill_point); buf.write_uint16(skill_db_info_map.size()); for (Skill_DB_Info_Map::const_iterator it = skill_db_info_map.begin(); it != skill_db_info_map.end(); ++it) { it->second.serialize(buf); } return 0; }
void Msg_Struct::build_buffer_vector(const Field_Info &field_info, Block_Buffer &buffer, Isolate* isolate, v8::Local<v8::Value> value) { if (!value->IsArray()) { LOG_ERROR("field_name:%s is not array, struct_name:%s", field_info.field_name.c_str(), struct_name().c_str()); buffer.write_uint16(0); return; } Local<Array> array = Local<Array>::Cast(value); int16_t len = array->Length(); buffer.write_uint16(len); for (int i = 0; i < len; ++i) { Local<Value> element = array->Get(isolate->GetCurrentContext(), i).ToLocalChecked(); if(is_struct(field_info.field_type)) { build_buffer_struct(field_info, buffer, isolate, element); } else { build_buffer_arg(field_info, buffer, isolate, element); } } }
int Anci_Artifact_Detail::serialize(Block_Buffer &buffer) const { buffer.write_int64(role_id); // buffer.write_int64(perfectPoint); buffer.write_uint16(aa_info_map.size()); for (AA_Info_Map::const_iterator it = aa_info_map.begin(); it != aa_info_map.end(); ++it) { buffer.write_int32(it->second.id); buffer.write_int8(it->second.state_count); buffer.write_int32(it->second.data); } buffer.write_uint16(complete_ids.size()); for (Int_Hash_Set::const_iterator it = complete_ids.begin(); it != complete_ids.end(); ++it) { buffer.write_int32(*it); } buffer.write_uint16(aa_unban_info.size()); for (AA_Unban_Info::const_iterator it = aa_unban_info.begin(); it != aa_unban_info.end(); ++it) { buffer.write_int32(it->second.id); buffer.write_int8(it->second.state); buffer.write_int8(it->second.box_state); } return 0; }
int Rune_Stone_Detail::serialize(Block_Buffer & w) const { w.write_int64(role_id); w.write_int32(points); w.write_int32(remain_double_times); w.write_uint16(smelter_detail_map.size()); for (Smelter_Detail_Map::const_iterator it = smelter_detail_map.begin(); it != smelter_detail_map.end(); ++it) { it->second.serialize(w); } return 0; }
int DragonBuildingInfo::serialize(Block_Buffer &buffer) const { buffer.write_uint32(id); buffer.write_uint8(type); buffer.write_uint16(level); buffer.write_uint8(status); buffer.write_uint32(production); buffer.write_bool(is_gain); buffer.write_uint64((uint64_t)begin_upgrade_time.sec()); buffer.write_uint64((uint64_t)last_output_production_time.sec()); buffer.write_uint8(order); buffer.write_uint8(consume_type); return 0; }
int Expedition_Scene_Data::serialize(Block_Buffer &w) const { w.write_uint16(map_data_.size()); for (Stronghold_Map::const_iterator it = map_data_.begin();//地图的总数据; 是所有据点(大中小城堡,关卡,宝箱点,怪物点)的数据;据点里面包含所有数据(含有攻防的玩家,状态等等) it != map_data_.end(); ++it) { w.write_uint32(it->first); it->second.serialize(w); } w.write_uint16(point_gang_id_.size()); for (Int_Uid::const_iterator it = point_gang_id_.begin(); it != point_gang_id_.end(); ++it) { w.write_int32(it->first); w.write_int64(it->second); } w.write_uint32(map_base_point_num_);//地图数据中基地的总数 w.write_uint32(cur_line_); //场景的当前线 award_time_.serialize(w); w.write_int32(settle_time_); w.write_uint16(occupy_castle_rank_.size()); for (Role_ExpeditionOccupyCastleData_Map::const_iterator it = occupy_castle_rank_.begin(); it != occupy_castle_rank_.end(); ++it) { it->second.serialize(w); } w.write_uint16(demage_rank_.size()); for (Role_ExpeditionSceneDemageRankData_Map::const_iterator it = demage_rank_.begin(); it != demage_rank_.end(); ++it) { w.write_int64(it->first); it->second.serialize(w); } w.write_uint16(refreshed_drop_or_material_.size()); for (Point_ExpeditionDropOrMaterial::const_iterator it = refreshed_drop_or_material_.begin(); it != refreshed_drop_or_material_.end(); ++it) { w.write_int32(it->first); it->second.serialize(w); } w.write_uint16(refreshed_monster_timing_.size()); for (Int_Time_Map::const_iterator it = refreshed_monster_timing_.begin(); it != refreshed_monster_timing_.end(); ++it) { w.write_int32(it->first); it->second.serialize(w); } w.write_uint16(refreshed_monster_kill_gap_.size()); for (Int_Time_Map::const_iterator it = refreshed_monster_kill_gap_.begin(); it != refreshed_monster_kill_gap_.end(); ++it) { w.write_int32(it->first); it->second.serialize(w); } return 0; }
void Hero_Info_Detail::serialize(Block_Buffer &w) const { w.write_int32(hero_id); w.write_int32(hero_index); w.write_int32(hero_facade_id); w.write_string(hero_name); w.write_int8(is_outer); w.write_int8(is_fighter); w.write_int32(level); w.write_int32(formation); w.write_int32(awake_lvl); w.write_double(exp); uint16_t __prop_value_vec_size = prop_value.size(); w.write_uint16(__prop_value_vec_size); for(uint16_t i = 0; i < __prop_value_vec_size; ++i) { prop_value[i].serialize(w); } w.write_uint16(artifacts.size()); for (Artifact_Map::const_iterator it = artifacts.begin(); it != artifacts.end(); ++it) { it->second.serialize(w); } hero_fighter_detail.serialize(w); }
int Stronghold_Info::serialize(Block_Buffer &w) const { occupier.serialize(w); // attacker.serialize(w); // int8_t fight_status; // 0(和平状态) 1(攻占状态) // int8_t belong_status; // 0.未被初始化状态, 1.中立, 2.占领 // ; //防守队列 uint16_t len = 0; for (Soldier_Map::const_iterator it = defend_map.begin(); it != defend_map.end(); ++it) { if (it->second->type == EST_PLAYER) { continue; } ++len; } w.write_uint16(len); for (Soldier_Map::const_iterator it = defend_map.begin(); it != defend_map.end(); ++it) { if (it->second->type == EST_PLAYER) { continue; } w.write_int64(it->second->role_id); w.write_int16(it->second->nums); } // Soldier_Map attack_map; //攻占队列 // Soldier_List defend_list; // Soldier_List attack_list; // uint32_t npc_soldier_aid;//npc怪的id自增长 // Soldier_Map defending_map; // Soldier_Map attacking_map; // Time_Value battle_finish_time; // Soldier_Map looking_defend_map; // GangID_SoldierMap_Map looking_attack_map; // Soldier_List looking_defend_list; // GangID_SoldierList_Map looking_attack_list; return 0; }
int Scene_Gang_Manager::sync_to_logic(void) { MSG_USER("GANG_WAR:sync_to_logic, stage(%d), gang_vec_.size(%d)", stage(), gang_vec_.size()); Block_Buffer buf; buf.make_message(INNER_SYNC_GANG_WAR_INFO); buf.write_int8(stage()); buf.write_uint16(gang_vec_.size()); int64_t index = 0; int8_t camp = 0; Time_Value match_time = Time_Value::zero; int64_t scene_index = 0; std::string zone; std::string gang_name; int8_t rank = 0; int64_t force = 0; for (GangWarMatchedGangsPair_Vec::const_iterator it = gang_vec_.begin(); it != gang_vec_.end(); ++it) { buf.write_int64(it->matched_pair.first); { index = 0; camp = 0; match_time = Time_Value::zero; scene_index = 0; zone.clear(); gang_name.clear(); rank = 0; force = 0; const Gang_War_Matched_Gang_Info *it_index = find_matched_gang_info(it->matched_pair.first); if (it_index) { index = it_index->matched_index; camp = it_index->camp; match_time.set(it_index->match_time); scene_index = it_index->scene_index; zone = it_index->zone; gang_name = it_index->gang_name; rank = it_index->rank; force = it_index->force; } } buf.write_int64(index); buf.write_int8(camp); match_time.serialize(buf); buf.write_int64(scene_index); buf.write_string(zone); buf.write_string(gang_name); buf.write_int8(rank); buf.write_int64(force); buf.write_int64(it->matched_pair.second); { index = 0; camp = 0; match_time = Time_Value::zero; scene_index = 0; zone.clear(); gang_name.clear(); rank = 0; force = 0; const Gang_War_Matched_Gang_Info *it_index = find_matched_gang_info(it->matched_pair.second); if (it_index) { index = it_index->matched_index; camp = it_index->camp; match_time.set(it_index->match_time); scene_index = it_index->scene_index; zone = it_index->zone; gang_name = it_index->gang_name; rank = it_index->rank; force = it_index->force; } } buf.write_int64(index); buf.write_int8(camp); match_time.serialize(buf); buf.write_int64(scene_index); buf.write_string(zone); buf.write_string(gang_name); buf.write_int8(rank); buf.write_int64(force); it->match_time.serialize(buf); buf.write_int8(it->result); buf.write_int8(it->matched_index); buf.write_int64(it->scene_index); } buf.finish_message(); sync_to_logic(buf); return 0; }
int Expedition_Manager_Data::serialize(Block_Buffer &w) const { w.write_uint32(inter_); w.write_uint16(opened_uuid_opentime_map_.size()); for (Role_Id_Time_Map::const_iterator it = opened_uuid_opentime_map_.begin();//服务器的开服时间 it != opened_uuid_opentime_map_.end(); ++it) { w.write_int64(it->first); it->second.serialize(w); } w.write_uint16(gang_id_uuid_map_.size()); for (RoleID_RoleID_Map::const_iterator it = gang_id_uuid_map_.begin(); it != gang_id_uuid_map_.end(); ++it) { w.write_int64(it->first); w.write_int64(it->second); } last_reset_time_.serialize(w); w.write_uint16(first_gang_rank_.size()); for (Role_UInt_Map::const_iterator it = first_gang_rank_.begin(); it != first_gang_rank_.end(); ++it) { w.write_int64(it->first); w.write_uint32(it->second); } w.write_bool(has_init_); w.write_uint16(uuid_has_init_.size()); for (Role_Bool_Map::const_iterator it = uuid_has_init_.begin(); it != uuid_has_init_.end(); ++it) { w.write_int64(it->first); w.write_bool(it->second); } w.write_uint16(gang_rank_map_.size()); for (Gang_ExpeditionGangRankInfo_Map::const_iterator it = gang_rank_map_.begin(); it != gang_rank_map_.end(); ++it) { w.write_int64(it->first); it->second.serialize(w); } w.write_uint16(uuid_gang_rank_map_.size()); for (Role_GangExpeditionGangRankInfoMap_Map::const_iterator it_igrm = uuid_gang_rank_map_.begin(); it_igrm != uuid_gang_rank_map_.end(); ++it_igrm) { w.write_int64(it_igrm->first); w.write_uint16(gang_rank_map_.size()); for (Gang_ExpeditionGangRankInfo_Map::const_iterator it = it_igrm->second.begin(); it != it_igrm->second.end(); ++it) { w.write_int64(it->first); it->second.serialize(w); } } w.write_uint16(gang_rank_sync_success_.size()); for (Role_Hash_Set::iterator it = gang_rank_sync_success_.begin();//公会排名获取成功服务器uuid列表 it != gang_rank_sync_success_.end(); ++it) { w.write_int64(*it); } w.write_uint16(gang_rank_sync_new_vec_.size()); for (Role_Vec::const_iterator it = gang_rank_sync_new_vec_.begin(); it != gang_rank_sync_new_vec_.end(); ++it) { w.write_int64(*it); } w.write_uint16(gang_id_point_id_.size()); for (Role_UInt_Map::const_iterator it = gang_id_point_id_.begin(); it != gang_id_point_id_.end(); ++it) { w.write_int64(it->first); w.write_uint32(it->second); } w.write_uint16(gang_id_cur_line_.size()); for (Role_Int_Map::const_iterator it = gang_id_cur_line_.begin(); it != gang_id_cur_line_.end(); ++it) { w.write_int64(it->first); w.write_int32(it->second); } w.write_uint16(uuid_gang_id_point_id_.size()); for (Role_RoleUIntMap_Map::const_iterator it = uuid_gang_id_point_id_.begin(); it != uuid_gang_id_point_id_.end(); ++it) { w.write_int64(it->first); w.write_uint16(it->second.size()); for (Role_UInt_Map::const_iterator it_t = it->second.begin(); it_t != it->second.end(); ++it_t) { w.write_int64(it_t->first); w.write_uint32(it_t->second); } } w.write_uint16(uuid_gang_id_cur_line_.size()); for (Role_RoleIntMap_Map::const_iterator it = uuid_gang_id_cur_line_.begin(); it != uuid_gang_id_cur_line_.end(); ++it) { w.write_int64(it->first); w.write_uint16(it->second.size()); for (Role_Int_Map::const_iterator it_t = it->second.begin(); it_t != it->second.end(); ++it_t) { w.write_int64(it_t->first); w.write_int32(it_t->second); } } ; // scene-- w.write_uint16(line_scene_map_.size()); for (Line_ExpeditionSceneData_Map::const_iterator it = line_scene_map_.begin(); it != line_scene_map_.end(); ++it) { w.write_uint32(it->first); it->second.serialize(w); } w.write_uint16(uuid_line_scene_map_.size()); for (UUID_LineExpeditionSceneData_Map_Map::const_iterator it_ulsm = uuid_line_scene_map_.begin(); it_ulsm != uuid_line_scene_map_.end(); ++it_ulsm) { w.write_int64(it_ulsm->first); w.write_uint16(it_ulsm->second.size()); for (Line_ExpeditionSceneData_Map::const_iterator it = it_ulsm->second.begin(); it != it_ulsm->second.end(); ++it) { w.write_uint32(it->first); it->second.serialize(w); } } return 0; }
int Fighter_Detail::serialize(Block_Buffer &buffer) const { buffer.write_int64(role_id); power.serialize(buffer); agility.serialize(buffer); dexterity.serialize(buffer); armor.serialize(buffer); stamina.serialize(buffer); physical_attack.serialize(buffer); spell_attack.serialize(buffer); physical_defense.serialize(buffer); spell_defense.serialize(buffer); hit_rate.serialize(buffer); avoid.serialize(buffer); ignore_def.serialize(buffer); blood_max.serialize(buffer); cure.serialize(buffer); cure_rate.serialize(buffer); sing_rate.serialize(buffer); crit.serialize(buffer); crit_def.serialize(buffer); init_morale.serialize(buffer); morale_caps.serialize(buffer); crit_hurt.serialize(buffer); crit_hurt_sub.serialize(buffer); hit_rate_addition.serialize(buffer); avoid_rate_addition.serialize(buffer); crit_rate_addition.serialize(buffer); crit_def_rate_addition.serialize(buffer); speed.serialize(buffer); blood_current.serialize(buffer); morale_current.serialize(buffer); strength_current.serialize(buffer); strength_max.serialize(buffer); blood_pool_current.serialize(buffer); blood_pool_max.serialize(buffer); ignore_def_rate.serialize(buffer); status_hit_rate.serialize(buffer); status_def_rate.serialize(buffer); blood_steal.serialize(buffer); phy_hurt_fix.serialize(buffer); phy_hurt_rate.serialize(buffer); spell_hurt_fix.serialize(buffer); spell_hurt_rate.serialize(buffer); hurt_fix.serialize(buffer); hurt_rate.serialize(buffer); be_hurt_fix.serialize(buffer); be_hurt_rate.serialize(buffer); pk_hurt_add.serialize(buffer); pk_hurt_sub.serialize(buffer); phy_hurt_rate_sub.serialize(buffer); spell_hurt_rate_sub.serialize(buffer); skill_hurt_rate.serialize(buffer); human_add.serialize(buffer); elf_add.serialize(buffer); orc_add.serialize(buffer); dragon_add.serialize(buffer); undead_add.serialize(buffer); demon_add.serialize(buffer); human_sub.serialize(buffer); elf_sub.serialize(buffer); orc_sub.serialize(buffer); dragon_sub.serialize(buffer); undead_sub.serialize(buffer); demon_sub.serialize(buffer); summon_add.serialize(buffer); summon_sub.serialize(buffer); be_cure_rate.serialize(buffer); effect_rate.serialize(buffer); pve_hurt_add.serialize(buffer); pve_hurt_sub.serialize(buffer); dizz_strengthen.serialize(buffer); dizz_weaken.serialize(buffer); buffer.write_int32(phy_power_recover_time); buffer.write_int32(phy_power_buy_times); buffer.write_int32(level); buffer.write_double(experience); buffer.write_double(elite_btl_morale); buffer.write_int32(force); buffer.write_int32(highest_force); buffer.write_int32(ttl_force); buffer.write_int32(ttl_skill_points_); buffer.write_int32(default_skill); buffer.write_int32(cur_used_talent_); buffer.write_int32(reset_skill_times); buffer.write_uint16(talent_map.size()); for (Talent_Map::const_iterator it = talent_map.begin(); it != talent_map.end(); ++it) { it->second.serialize(buffer); } buffer.write_uint16(extra_skill_vec.size()); for (Skill_DB_Info_Vec::const_iterator it = extra_skill_vec.begin(); it != extra_skill_vec.end(); ++it) { it->serialize(buffer); } buffer.write_bool(is_clear_moral_); return 0; }