int Answer_Manager::data_channle(Block_Buffer& buf) { uint8_t type = 0; buf.read_uint8(type); switch(type) { case ANSWER_DATA_CHANNLE_TYPE_SL_GET_RANK_REWARD: { uint16_t size = 0; buf.read_uint16(size); for(uint16_t i = 0; i < size; ++i) { uint16_t nsize = 0; buf.read_uint16(nsize); for(uint16_t j = 0; j < nsize; ++j) { role_id_t role_id = 0; buf.read_int64(role_id); reward_to_player(role_id, i+1); } //end j }//end i break; }// end case case ANSWER_DATA_CHANNLE_TYPE_SL_SAVE_DATA: { save_data(buf); break; } } return 0; }
int Scene_Server_Request::process_20100403(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { JUDGE_PLAYER_NULL(player, role_id); int8_t type = 0; buf.read_int8(type); uint16_t vec_size = 0; if (buf.read_uint16(vec_size)) { return -1; } Int_Double_Map force_map; player->get_all_pre_force(force_map); int old_val = player->fighter_detail().force; Skill_Info skill_info; for (uint16_t i = 0; i < vec_size; ++i) { skill_info.reset(); skill_info.deserialize(buf); if (type == NPT_ADD) { player->add_skill_extra(skill_info.skill_id, skill_info.skill_lv); } else if (type == NPT_REMOVE) { player->remove_skill_extra(skill_info.skill_id, skill_info.skill_lv); } } if (vec_size > 0) { player->sync_force_to_client(); } int new_val = player->fighter_detail().force; player->print_all_part_force(100, new_val-old_val, force_map); 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 Stronghold::serialize(Block_Buffer &w) const { w.write_uint32(point_id); w.write_int8((int8_t)type); info.serialize(w); 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; }
void Chat::say(Time_Value &now, Location &location) { if(now >= (last_say_time + say_interval)) { last_say_time = now; Robot_Player *player = (Robot_Player*)this; MSG_10300000 msg; msg.chat_type = 1; Chat_Content cc; //人物信息 cc.reset(); cc.type = 2; cc.role_Info.role_name = player->base_detail().role_name; cc.role_Info.career = player->base_detail().career; cc.role_Info.gender = player->base_detail().gender; cc.role_Info.role_id = player->base_detail().role_id; msg.content.push_back(cc); //聊天内容 cc.reset(); cc.type = 0; std::ostringstream text; text << "各位你好!我目前的场景是:" << location.scene_id << ",坐标(x=" << location.coord.x << ",y=" << location.coord.y << "), 过来找我吧~{a" << ((rand()%39)+1) << "}"; cc.text = text.str(); msg.content.push_back(cc); //send Block_Buffer buf; buf.make_client_message(10300000, player->msg_detail().msg_serial++, Time_Value::gettimeofday().sec()); msg.serialize(buf); buf.finish_message(); player->send_to_server(buf); } }
int Record_Monitor::start_monitor_timer(void) { Block_Buffer buf; buf.make_message(TIMER_GLOBAL_MONITOR_SELF); buf.finish_message(); GLOBAL_TIMER->register_loop_handler(buf, Time_Value(Time_Value::ONE_MINUTE_IN_SECS, 0), unit_); return 0; }
int Smelter_Detail::deserialize(Block_Buffer & r) { if(r.read_int8(smelter_idx) || r.read_int8(is_open)) { return -1; } return 0; }
int Gate_Manager::self_close_process(void) { server_status_ = STATUS_CLOSING; Block_Buffer buf; buf.make_inner_message(ACTIVE_DISCONNECT, ERROR_DISCONNECT_SELF); buf.finish_message(); for (Gate_Player_Cid_Map::iterator iter = player_cid_map_.begin(); iter != player_cid_map_.end(); ++iter) { GATE_MANAGER->send_to_client(iter->first, buf); } //等待服务器通知客户端完毕 sleep(2); //关闭客户端连接 for (Gate_Player_Cid_Map::iterator iter = player_cid_map_.begin(); iter != player_cid_map_.end(); ++iter) { iter->second->link_close(); } int i = 0; while (++i < 60) { sleep(1); LOG_DEBUG("gate server has user:%d", player_cid_map_.size()); if (player_cid_map_.size() == 0) break; } 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 Artifact_Detail::deserialize(Block_Buffer & r) { if(r.read_int32(artifact_id) || r.read_int32(artifact_lvl)) { return -1; } return 0; }
void Answer_Manager::save_data(Block_Buffer& buf_) { Block_Buffer buf; buf.make_message(MONGO_SAVE_ANSWER_INFO); buf.copy(&buf_); buf.finish_message(); DB_MANAGER->push_data_block(buf, 0); }
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); } } }
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 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 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; }
int Expedition_Force::deserialize(Block_Buffer &r) { r.read_int64(server_uuid); r.read_string(server_name); r.read_int64(gang_id); r.read_string(gang_name); return 0; }
int Scene_Server_Request::process_20100050(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &inner_buf) { JUDGE_PLAYER_NULL(player, role_id); uint16_t change_info_size = 0; inner_buf.read_uint16(change_info_size); if (change_info_size == 0) { return -1; } MSG_81000066 active_msg; active_msg.change_info.reserve(change_info_size); String_Info_Change string_info_change; for (uint16_t i = 0; i < change_info_size; ++i) { string_info_change.reset(); if (string_info_change.deserialize(inner_buf)) { return -1; } active_msg.change_info.push_back(string_info_change); } inner_buf.read_int64(active_msg.role_id); Block_Buffer active_buf; MAKE_MSG_BUF(active_msg, active_buf); player->scene_broad_around(active_buf,Mover::SCENE_MOVE); 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; }
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 Prop_Setter::serialize(Block_Buffer & w) const { w.write_int32(prop_type); w.write_int32(addi_type); w.write_uint8(operate); w.write_double(basic); w.write_double(fixed); w.write_double(percent); }
void Daemon_Record::stop(void) { if (is_server_running()) { Block_Buffer buf; buf.make_message(SERVER_INNER_SELF_CLOSE); buf.finish_message(); RECORD_MONITOR->push_async_buff(buf); } }
int DB_Worker::process_create_guild(int cid, Create_Guild_Info &guild_info) { Block_Buffer buf; buf.make_server_message(SYNC_DB_MASTER_CREATE_GUILD, 0); guild_info.guild_id = DB_MANAGER->create_guild(guild_info); guild_info.serialize(buf); buf.finish_message(); DB_MANAGER->send_data_block(cid, buf); 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; }
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 Stronghold::deserialize(Block_Buffer &r) { r.read_uint32(point_id); int8_t tp = 0; r.read_int8(tp); type = (Expedition_Build_Type)tp; info.deserialize(r); return 0; }
void Expedition_Drop_Or_Material::deserialize(Block_Buffer &r) { this->birth_time.deserialize(r); uint16_t len = 0; r.read_uint16(len); for (uint16_t i = 0; i < len; ++i) { int64_t role_id = 0; r.read_int64(role_id); had_collected.insert(role_id); } }
void Vip::sync_vip_info_to_chat(void) { MSG_20200024 inner_msg; inner_msg.vip_level = player_self()->base_detail().vip; inner_msg.over_time = player_self()->base_detail().vip_over_time.sec(); Block_Buffer buf; buf.make_message(inner_msg.msg_id); inner_msg.serialize(buf); buf.finish_message(); this->send_to_local_chat(buf); }
void pop_game_buffer(const FunctionCallbackInfo<Value>& args) { Block_Buffer *buf = GAME_MANAGER->pop_block_buffer(); if (buf) { buf->reset(); args.GetReturnValue().Set(wrap_buffer(args.GetIsolate(), buf)); } else { //设置对象为空 args.GetReturnValue().SetNull(); } }
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; }