int DB_Worker::process_save_player(int cid, int status, Block_Buffer &buffer) { //先把两个额外字段读出来,再保存玩家数据,防止buffer错乱 bool logout = false; std::string account = ""; buffer.read_bool(logout); buffer.read_string(account); if (logout) { //离线保存 save_player_data(buffer); Block_Buffer buf; buf.make_server_message(SYNC_DB_GAME_SAVE_PLAYER, 0); buf.write_string(account); buf.finish_message(); DB_MANAGER->send_data_block(cid, buf); } else { //在线定时保存 save_player_data(buffer); } 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; }