void Player::DoAccountReg(uint64_t seq, uint64_t uid, uint64_t password_hash, const char* account) { LOG(INFO) << "do_account_req"; int32_t player_idx = GetPlayerIdx(); MsgModule* msg_module = FindModule<MsgModule>(App::GetInstance()); ProtoSs::Msg msg; ProtoSs::Head* head = msg.mutable_head(); head->set_cmd(ProtoSs::Msg::kAccountRegReqFieldNumber); head->set_seq(seq); head->set_player_idx(player_idx); ProtoSs::AccountRegReq* account_reg_req = msg.mutable_account_reg_req(); account_reg_req->set_uid(uid); account_reg_req->set_password_hash(password_hash); if (account != NULL) account_reg_req->set_account(account); // 玩家初始化数据 Database::PlayerData player_data; Database::RoleInfo* role_info = player_data.mutable_role_info(); Database::CityInfo* city_info = player_data.add_city_list(); role_info->set_money(1000); role_info->set_level(1); city_info->set_id(1121); static char player_data_buf[PLAYER_DATA_MAX] = {0}; if (player_data.SerializeToArray(player_data_buf, PLAYER_DATA_MAX) == false) { LOG(ERROR) << "player_data SerializeToArray error!"; return; }; account_reg_req->set_player_data(player_data_buf, player_data.ByteSize()); msg_module->SendToDatasvr(&msg); }
void Player::DoAccountVerify(uint64_t seq, uint64_t uid, uint64_t password_hash) { LOG(INFO) << "DoAccountVerify"; int32_t player_idx = GetPlayerIdx(); MsgModule* msg_module = FindModule<MsgModule>(App::GetInstance()); ProtoSs::Msg msg; ProtoSs::Head* head = msg.mutable_head(); head->set_cmd(ProtoSs::Msg::kAccountVerifyReqFieldNumber); head->set_seq(seq); head->set_player_idx(player_idx); ProtoSs::AccountVerifyReq* account_verify_req = msg.mutable_account_verify_req(); account_verify_req->set_uid(uid); account_verify_req->set_password_hash(password_hash); msg_module->SendToDatasvr(&msg); }
void Player::do_get_player_data(uint64_t seq, uint64_t uid, uint64_t password_hash) { LOG(INFO) << "do_get_player_data"; int32_t player_idx = get_player_idx(); MsgModule* msg_module = FindModule<MsgModule>(App::GetInstance()); ProtoSs::Msg msg; ProtoSs::Head* head = msg.mutable_head(); head->set_cmd(ProtoSs::Msg::kGetPlayerDataReqFieldNumber); head->set_seq(seq); head->set_player_idx(player_idx); ProtoSs::GetPlayerDataReq* get_player_data_req = msg.mutable_get_player_data_req(); get_player_data_req->set_uid(uid); get_player_data_req->set_password_hash(password_hash); msg_module->SendToDatasvr(&msg); }
void Player::DoUpdatePlayerData(uint64_t seq) { LOG(INFO) << "DoUpdatePlayerData"; ObjMgrModule* obj_mgr_module = FindModule<ObjMgrModule>(App::GetInstance()); int32_t player_idx = GetPlayerIdx(); MsgModule* msg_module = FindModule<MsgModule>(App::GetInstance()); ProtoSs::Msg msg; ProtoSs::Head* head = msg.mutable_head(); head->set_cmd(ProtoSs::Msg::kSetPlayerDataReqFieldNumber); head->set_seq(seq); head->set_player_idx(player_idx); ProtoSs::SetPlayerDataReq* set_player_data_req = msg.mutable_set_player_data_req(); set_player_data_req->set_uid(uid_); // 玩家数据组装 Database::PlayerData player_data; Database::RoleInfo* role_info = player_data.mutable_role_info(); role_info->set_money(money_); role_info->set_level(level_); for (int32_t i = 1; i < MAX_CITY_NUM_PER_PLAYER; i++) { if (city_list_[i] != 0) { Database::CityInfo* city_info = player_data.add_city_list(); City* city = obj_mgr_module->GetCity(city_list_[i]); city_info->set_population(city->population_); } } static char player_data_buf[PLAYER_DATA_MAX] = {0}; if (player_data.SerializeToArray(player_data_buf, PLAYER_DATA_MAX) == false) { LOG(ERROR) << "player_data SerializeToArray error!"; return; }; set_player_data_req->set_player_data(player_data_buf, player_data.ByteSize()); msg_module->SendToDatasvr(&msg); }