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 Gate_Manager::process_list(void) { int32_t cid = 0; Block_Buffer *buf = 0; while (1) { bool all_empty = true; /// 掉线玩家列表 if (! drop_cid_list_.empty()) { all_empty = false; cid = drop_cid_list_.pop_front(); process_drop_cid(cid); } /// client-->gate 消息队列 if ((buf = gate_client_data_list_.pop_front()) != 0) { all_empty = false; if (buf->is_legal()) { cid = buf->peek_int32(); GATE_CLIENT_MESSAGER->process_block(*buf); } else { LOG_ERROR("buf.read_index = %ld, buf.write_index = %ld", buf->get_read_idx(), buf->get_write_idx()); buf->reset(); } GATE_CLIENT_SERVER->push_block(cid, buf); } /// 游戏服内部循环消息队列 if (! self_loop_block_list_.empty()) { all_empty = false; buf = self_loop_block_list_.front(); self_loop_block_list_.pop_front(); GATE_INNER_MESSAGER->process_self_loop_block(*buf); block_pool_.push(buf); } /// login-->gate 消息队列 if ((buf = gate_login_data_list_.pop_front()) != 0) { all_empty = false; if (buf->is_legal()) { cid = buf->peek_int32(); GATE_INNER_MESSAGER->process_login_block(*buf); } else { LOG_ERROR("buf.read_index = %ld, buf.write_index = %ld", buf->get_read_idx(), buf->get_write_idx()); buf->reset(); } GATE_LOGIN_CONNECTOR->push_block(cid, buf); } /// game-->gate 消息队列 if ((buf = gate_game_data_list_.pop_front()) != 0) { all_empty = false; if (buf->is_legal()) { cid = buf->peek_int32(); GATE_INNER_MESSAGER->process_game_block(*buf); } else { LOG_ERROR("buf.read_index = %ld, buf.write_index = %ld", buf->get_read_idx(), buf->get_write_idx()); buf->reset(); } GATE_GAME_CONNECTOR->push_block(cid, buf); } /// master-->gate 消息队列 if ((buf = gate_master_data_list_.pop_front()) != 0) { all_empty = false; if (buf->is_legal()) { cid = buf->peek_int32(); GATE_INNER_MESSAGER->process_master_block(*buf); } else { LOG_ERROR("buf.read_index = %ld, buf.write_index = %ld", buf->get_read_idx(), buf->get_write_idx()); buf->reset(); } GATE_MASTER_CONNECTOR->push_block(cid, buf); } if (all_empty) Time_Value::sleep(Time_Value(0,100)); } return 0; }