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 Expedition_Force::serialize(Block_Buffer &w) const { w.write_int64(server_uuid); w.write_string(server_name); w.write_int64(gang_id); w.write_string(gang_name); 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_); }
// for db save -- void Expedition_Scene_Demage_Rank_Data::serialize(Block_Buffer &w) const { w.write_string(role_name); w.write_int64(role_id); w.write_int64(gang_id); w.write_string(gang_name); w.write_int64(uuid); w.write_string(server_name); w.write_int32(force); w.write_int32(level); w.write_double(demage); }
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; }
int Expedition_Occupy_Castle_Data::serialize(Block_Buffer &w) const { w.write_int64(role_id); w.write_int64(gang_id); w.write_int64(server_uuid); w.write_string(role_name); w.write_string(gang_name); w.write_string(server_name); w.write_int32(level); w.write_int32(force); w.write_int16(nums); w.write_int16(get_nums); return 0; }
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 Operating::offline_invite_player(role_id_t role_id, const Time_Value &time) { if (!role_id) { MSG_USER("error role id"); return -1; } Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); uint32_t op_type = OPERATING_OFFLINE_INVITE_PLAYER; buf.write_uint32(op_type); buf.write_int64(role_id); buf.write_int64(time.sec()); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
int Operating::offline_firend_handel(role_id_t role_id, role_id_t other_role_id, int8_t handel) { if (!role_id) { MSG_USER("error role id"); return -1; } Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); int type = OPERATING_OFFLINE_APPLY_HANDEL; buf.write_int32(type); buf.write_int64(role_id); buf.write_int64(other_role_id); buf.write_int8(handel); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
int Operating::offline_receive_flowers(role_id_t role_id, std::string &role_name, uint32_t item_id, uint32_t charm, uint32_t friend_num, std::string &msg, role_id_t receive_role_id) { if ( role_id == 0 ) return 0; Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); int type = OPERATING_OFFLINE_RECEIVE_FLOWERS; buf.write_int32(type); buf.write_int64(role_id); buf.write_string(role_name); buf.write_uint32(item_id); buf.write_uint32(charm); buf.write_uint32(friend_num); buf.write_string(msg); buf.write_int64(receive_role_id); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
int Operating::offline_firend_add(role_id_t role_id, role_id_t other_role_id, Time_Value time) { if (!role_id) { MSG_USER("error role id"); return -1; } Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); int type = OPERATING_OFFLINE_FIREND_ADD; buf.write_int32(type); buf.write_int64(role_id); buf.write_int64(other_role_id); buf.write_int64(time.sec()); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
void Msg_Struct::build_buffer_arg(const Field_Info &field_info, Block_Buffer &buffer, Isolate* isolate, v8::Local<v8::Value> value) { if(field_info.field_type == "int8") { int8_t val = 0; if (value->IsInt32()) { val = value->Int32Value(isolate->GetCurrentContext()).FromJust(); } buffer.write_int8(val); } else if(field_info.field_type == "int16") { int16_t val = 0; if (value->IsInt32()) { val = value->Int32Value(isolate->GetCurrentContext()).FromJust(); } buffer.write_int16(val); } else if(field_info.field_type == "int32") { int32_t val = 0; if (value->IsInt32()) { val = value->Int32Value(isolate->GetCurrentContext()).FromJust(); } buffer.write_int32(val); } else if(field_info.field_type == "int64") { int64_t val = 0; if (value->IsNumber()) { val = value->NumberValue(isolate->GetCurrentContext()).FromJust(); } buffer.write_int64(val); } else if(field_info.field_type == "double") { double val = 0; if (value->IsNumber()) { val = value->NumberValue(isolate->GetCurrentContext()).FromJust(); } buffer.write_double(val); } else if(field_info.field_type == "bool") { bool val = 0; if (value->IsBoolean()) { val = value->BooleanValue(isolate->GetCurrentContext()).FromJust(); } buffer.write_bool(val); } else if(field_info.field_type == "string") { std::string val = ""; if (value->IsString()) { String::Utf8Value str(value->ToString(isolate->GetCurrentContext()).ToLocalChecked()); std::stringstream stream; stream << ToCString(str); val = stream.str(); } buffer.write_string(val); } else { LOG_ERROR("Can not find the field_type:%s, struct_name:%s", field_info.field_type.c_str(), struct_name().c_str()); } }
int Operating::offline_team_award(role_id_t role_id, int level_id) { Block_Buffer buf; buf.make_message(OPERATING_OFFLINE_TEAM_AWARD); buf.write_int64(role_id); buf.write_int32(level_id); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
int Operating::offline_arena_seven_day_reward(role_id_t role_id, Arena_Reward_Info &info){ Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); int type = OPERATING_OFFLINE_ARENA_SEVEN_DAY_REWARD; buf.write_int32(type); buf.write_int64(role_id); info.serialize(buf); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
int Operating::offline_ganger_info_update(role_id_t role_id, Ganger_Detail& detail) { if ( role_id == 0 ) return 0; Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); int type = OPERATING_OFFLINE_GANGER_INFO; buf.write_int32(type); buf.write_int64(role_id); detail.serialize( buf ); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); 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; }
void Answer_Manager::send_scene_open_action(void) { Block_Buffer buf; buf.make_message(INNER_ANSWER_DATA_CHANNEL); buf.write_uint8(ANSWER_DATA_CHANNLE_TYPE_LS_OPEN_ACTIVE); buf.write_int64(start_time.sec()); //DATA START answer_info.serialize(buf); //DATA END buf.finish_message(); LOGIC_MONITOR->send_to_scene(ANSWER_INNER_SCENE_ID, 0, buf); }
void Answer_Manager::send_scene_close_action(void) { is_close = true; Block_Buffer buf; buf.make_message(INNER_ANSWER_DATA_CHANNEL); buf.write_uint8(ANSWER_DATA_CHANNLE_TYPE_LS_CLOSE_ACTIVE); //DATA START buf.write_int64(end_time.sec()); //DATA END buf.finish_message(); LOGIC_MONITOR->send_to_scene(ANSWER_INNER_SCENE_ID, 0, buf); }
int Map_Team::sync_info_logic(void) { MSG_20100304 inner_msg; Block_Buffer buf; Time_Value now; now = Time_Value::gettimeofday(); buf.make_message(inner_msg.msg_id); buf.write_int64(team_id_); buf.write_int16(fail_times_); buf.write_int16(match_fail_); now.serialize(buf); buf.finish_message(); this->info_all_online_player(inner_msg.msg_id, &buf); return 0; }
int Operating::offline_like_success(role_id_t role_id) { if (!role_id) { MSG_USER("error role id"); return -1; } Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); uint32_t op_type = OPERATING_OFFLINE_LIKE_SUCCESS; buf.write_uint32(op_type); buf.write_int64(role_id); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
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); }
int Operating::offline_dragon_vale_special_notice(role_id_t role_id, bool is_special) { if (!role_id) { MSG_USER("error role id"); return -1; } Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); uint32_t op_type = OPERATING_OFFLINE_DRAGON_VALE_SPECIAL; buf.write_uint32(op_type); buf.write_int64(role_id); buf.write_bool(is_special); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
int Scene_Outpost_Manager::req_vagrant_buy_item(Scene_Player* player, const int64_t monster_role_id, const int item_index){ if(!player){ return 0; } int scene_id = player->move_scene_id(); Vagrant_Item_Info* item_info = get_vagrant_item_info(scene_id, monster_role_id, item_index); if(!item_info){ return -1; } // 购买数量检测 if(item_info->cfg_num != 0 && item_info->buy_num >= item_info->cfg_num){ // MSG_50211301 msg; msg.item_index = item_index; msg.result = 0; OBJ_SEND_TO_CLIENT(msg, (*player)); // req_vagrant_item_info(player, monster_role_id); return ERROR_SECRET_SHOP_NUM_LIMIT; } // 限购检测 if(item_info->cfg_limit_num != 0 && item_info->player_buy_num(player->role_id()) >= item_info->cfg_limit_num){ return ERROR_SECRET_SHOP_LIMIT_NUM_LIMIT; } { Block_Buffer buf; buf.make_message(INNER_SYNC_SCENE_OUTPOST); buf.write_int8(10); buf.write_int32(scene_id); buf.write_int64(monster_role_id); buf.write_int32(item_index); buf.write_int32(item_info->cfg_item_id); buf.write_int32(1); buf.write_int8(item_info->cfg_cost_type); buf.write_int32(item_info->cfg_cost); buf.finish_message(); player->send_to_logic(buf); } return 0; }
int Operating::offline_active_content_listen_world_boss_end_info(role_id_t role_id , uint32_t damage, uint32_t rank, uint32_t damage_rate) { if (!role_id) { MSG_USER("error role id"); return -1; } Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); uint32_t op_type = OPERATING_OFFLINE_ACTIVE_CONTENT_LISTEN_WORLD_BOSS_END_INFO; buf.write_uint32(op_type); buf.write_int64(role_id); buf.write_uint32(damage); buf.write_uint32(rank); buf.write_uint32(damage_rate); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
int Operating::offline_dragon_vale_building_notice(role_id_t role_id, uint8_t notice_type, uint8_t gold_mine, uint8_t moon_well, uint8_t totem) { if (!role_id) { MSG_USER("error role id"); return -1; } Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); uint32_t op_type = OPERATING_OFFLINE_DRAGON_VALE_BUILDING; buf.write_uint32(op_type); buf.write_int64(role_id); buf.write_uint8(notice_type); buf.write_uint8(gold_mine); buf.write_uint8(moon_well); buf.write_uint8(totem); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
int Operating::offline_dragon_vale_rob_fight_result_notice(role_id_t role_id, uint8_t notice_type, std::string server_name, std::string player_name, uint8_t result) { if (!role_id) { MSG_USER("error role id"); return -1; } Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); uint32_t op_type = OPERATING_OFFLINE_DRAGON_VALE_ROB_FIGHT_RESULT; buf.write_uint32(op_type); buf.write_int64(role_id); buf.write_uint8(notice_type); buf.write_string(server_name); buf.write_string(player_name); buf.write_uint8(result); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
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 Operating::offline_dargon_vale_gain_rob_production_notice(role_id_t role_id, std::string server_name, std::string player_name, uint32_t gold_mine, uint32_t moon_well, uint32_t totem) { if (!role_id) { MSG_USER("error role id"); return -1; } Block_Buffer buf; buf.make_message(MONGO_OPERATING_OFFLINE_DATA); uint32_t op_type = OPERATING_OFFLINE_DRAGON_VALE_GAIN_ROB_PRODUCTION; buf.write_uint32(op_type); buf.write_int64(role_id); buf.write_string(server_name); buf.write_string(player_name); buf.write_uint32(gold_mine); buf.write_uint32(moon_well); buf.write_uint32(totem); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); return 0; }
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 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; }