From a0f4623bd9a9e336e55e394e837c7aff9e3083cd Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 8 Nov 2023 10:38:37 +0800 Subject: [PATCH] 1 --- server/gameserver/app.cc | 4 ++-- server/gameserver/app.h | 2 +- server/gameserver/human.cc | 2 +- server/gameserver/human.h | 2 +- server/gameserver/matchteam.h | 2 +- server/gameserver/netdata.h | 2 +- server/gameserver/pbutils.cc | 2 +- server/gameserver/player.cc | 2 +- server/gameserver/room.h | 4 ++-- server/gameserver/roommgr.cc | 20 ++++++++++---------- server/gameserver/roommgr.h | 20 ++++++++++---------- server/gameserver/team.cc | 8 ++++---- 12 files changed, 35 insertions(+), 35 deletions(-) diff --git a/server/gameserver/app.cc b/server/gameserver/app.cc index ce57d5b1..60f901a2 100644 --- a/server/gameserver/app.cc +++ b/server/gameserver/app.cc @@ -499,9 +499,9 @@ bool App::ParseOpt() return instance_id > 0 && node_id > 0; } -long long App::NewUuid() +std::string App::NewUuid() { - return uuid.Generate(); + return a8::XValue(uuid.Generate()).GetString(); } bool App::HasFlag(int flag) diff --git a/server/gameserver/app.h b/server/gameserver/app.h index ebde2f22..4163af3a 100644 --- a/server/gameserver/app.h +++ b/server/gameserver/app.h @@ -32,7 +32,7 @@ public: void NotifyLoopCond(); - long long NewUuid(); + std::string NewUuid(); bool HasFlag(int flag); void SetFlag(int flag); void UnSetFlag(int flag); diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index b0768ff6..7108b9b1 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1446,7 +1446,7 @@ void Human::SendBattleReport() already_report_battle_ = true; SendGameOver(); } else { - long long room_uuid = room->GetRoomUuid(); + std::string room_uuid = room->GetRoomUuid(); std::string sender_id = account_id; HttpProxy::Instance()->HttpGet ( diff --git a/server/gameserver/human.h b/server/gameserver/human.h index a23905a5..17a901f2 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -59,7 +59,7 @@ class Human : public Creature int today_enter_times = 0; int account_registertime = 0; int channel = 0; - long long battle_uuid = 0; + std::string battle_uuid; int is_valid_battle = 0; std::string payload; HumanBehavior behavior; diff --git a/server/gameserver/matchteam.h b/server/gameserver/matchteam.h index a7915708..0f130779 100644 --- a/server/gameserver/matchteam.h +++ b/server/gameserver/matchteam.h @@ -41,7 +41,7 @@ struct RawTeamMember { class MatchTeam* team = nullptr; std::shared_ptr battle_context; - long long battle_uuid = 0; + std::string battle_uuid; int is_valid_battle = 0; std::string payload; long long add_tick = 0; diff --git a/server/gameserver/netdata.h b/server/gameserver/netdata.h index 264337b5..a503042b 100644 --- a/server/gameserver/netdata.h +++ b/server/gameserver/netdata.h @@ -18,7 +18,7 @@ class Skill; struct BattleDataContext { std::shared_ptr join_msg; - long long battle_uuid = 0; + std::string battle_uuid; int is_valid_battle = 0; std::string payload; int errcode = 0; diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index bc63d405..4973db4b 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -1662,7 +1662,7 @@ void Human::SendBattleSettlement() } } #endif - long long room_uuid = room->GetRoomUuid(); + std::string room_uuid = room->GetRoomUuid(); std::string tmp_account_id = account_id; HttpProxy::Instance()->HttpGet diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 62cbcfe9..fb28f090 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -1325,7 +1325,7 @@ void Player::_CMRevive(f8::MsgHdr& hdr, const cs::CMRevive& msg) url_params->SetVal("target_id", hum->account_id); url_params->SetVal("num", 1); - long long room_uuid = room->GetRoomUuid(); + std::string room_uuid = room->GetRoomUuid(); auto target_uniid = msg.target_uniid(); HttpProxy::Instance()->HttpGet ( diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 50223a86..0814b53e 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -114,7 +114,7 @@ public: const GasData& GetGasData() { return gas_data_; } RoomType_e GetRoomType() { return room_type_; } RoomMode_e GetRoomMode() { return room_mode_; } - long long GetRoomUuid() { return room_uuid_; } + std::string GetRoomUuid() { return room_uuid_; } int GetRoomIdx() { return room_idx_; } std::string GetMapTplName() { return map_tpl_name_; } const mt::Map* GetMapMeta() { return map_meta_; } @@ -359,7 +359,7 @@ private: std::vector poly_ext_datas_; int room_idx_ = 0; RoomMode_e room_mode_ = kPvpMode; - long long room_uuid_ = 0; + std::string room_uuid_; const mt::Map* map_meta_ = nullptr; std::string map_tpl_name_; RoomType_e room_type_ = RoomType_NewBrid; diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 8fce4cce..16a0a425 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -362,7 +362,7 @@ Room* RoomMgr::GetJoinableRoom(MatchTeam* team) nullptr); } -Room* RoomMgr::GetRoomByUuid(long long room_uuid) +Room* RoomMgr::GetRoomByUuid(const std::string& room_uuid) { auto itr = room_hash_.find(room_uuid); return itr != room_hash_.end() ? itr->second : nullptr; @@ -374,7 +374,7 @@ Room* RoomMgr::GetRoomByIdx(int room_idx) return itr != room_idx_hash_.end() ? itr->second : nullptr; } -void RoomMgr::AddOverRoom(long long room_uuid) +void RoomMgr::AddOverRoom(const std::string& room_uuid) { auto callback = [room_uuid] (int event, const a8::Args* args) @@ -400,7 +400,7 @@ void RoomMgr::AddOverRoom(long long room_uuid) } } -void RoomMgr::ActiveRoom(long long room_uuid) +void RoomMgr::ActiveRoom(const std::string& room_uuid) { inactive_room_hash_.erase(room_uuid); } @@ -467,7 +467,7 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po ); } -void RoomMgr::FreeOverRoom(long long room_uuid) +void RoomMgr::FreeOverRoom(const std::string& room_uuid) { auto itr = over_room_hash_.find(room_uuid); if (itr != over_room_hash_.end()) { @@ -626,7 +626,7 @@ void RoomMgr::JoinTeam(MatchTeam* team) room->AddTeam(team); } -std::string RoomMgr::GenTeamHashData(const std::string& team_uuid, std::map* team_hash) +std::string RoomMgr::GenTeamHashData(const std::string& team_uuid, std::map* team_hash) { std::string data; data += a8::Format("team_uuid:%s ", {team_uuid}); @@ -641,15 +641,15 @@ void RoomMgr::OnJoinRoomOk(const cs::CMJoin& msg, Player* hum) if (msg.team_uuid().empty()) { return; } - std::map* team_hash = nullptr; + std::map* team_hash = nullptr; { auto itr = team_room_hash_.find(msg.team_uuid()); if (itr == team_room_hash_.end()) { - team_room_hash_[msg.team_uuid()] = std::map(); + team_room_hash_[msg.team_uuid()] = std::map(); itr = team_room_hash_.find(msg.team_uuid()); team_hash = &itr->second; for (auto& team_member : msg.team_members()) { - team_hash->insert(std::make_pair(team_member.account_id(), 0)); + team_hash->insert(std::make_pair(team_member.account_id(), "")); } std::string team_uuid = msg.team_uuid(); f8::Timer::Instance()->SetTimeout @@ -686,7 +686,7 @@ void RoomMgr::OnJoinRoomOk(const cs::CMJoin& msg, Player* hum) void RoomMgr::TeamRoomTimeOut(const std::string& team_uuid) { - std::map* team_hash = nullptr; + std::map* team_hash = nullptr; { auto itr = team_room_hash_.find(team_uuid); if (itr != team_room_hash_.end()) { @@ -696,7 +696,7 @@ void RoomMgr::TeamRoomTimeOut(const std::string& team_uuid) if (team_hash) { bool ok = true; for (auto pair : *team_hash) { - if (pair.second == 0) { + if (pair.second.empty()) { ok = false; break; } diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index 253bd09d..34023fb6 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -29,7 +29,7 @@ struct RoomInitInfo { int room_idx = 0; RoomMode_e room_mode = kPvpMode; - long long room_uuid = 0; + std::string room_uuid; RoomType_e room_type = RoomType_NewBrid; int creator_game_times = 0; int creator_register_time = 0; @@ -75,11 +75,11 @@ class RoomMgr : public a8::Singleton void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg); void _CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg); void _CMPing(f8::MsgHdr& hdr, const cs::CMPing& msg); - void ActiveRoom(long long room_uuid); + void ActiveRoom(const std::string& room_uuid); int RoomNum(); int OverRoomNum(); - Room* GetRoomByUuid(long long uuid); - void AddOverRoom(long long room_uuid); + Room* GetRoomByUuid(const std::string& uuid); + void AddOverRoom(const std::string& room_uuid); bool IsGM(const std::string& account_id); void JoinTeam(MatchTeam* team); void SendGetBattleData(int mode, @@ -100,7 +100,7 @@ class RoomMgr : public a8::Singleton int channel); Room* GetJoinableRoom(MatchTeam* team); void ReportServerState(int instance_id, const std::string& host, int port); - void FreeOverRoom(long long room_uuid); + void FreeOverRoom(const std::string& room_uuid); bool IsLimitJoin(); int AllocRoomIdx(); @@ -113,7 +113,7 @@ class RoomMgr : public a8::Singleton int map_id, std::shared_ptr custom_battle); void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle); - std::string GenTeamHashData(const std::string& team_uuid, std::map* team_hash); + std::string GenTeamHashData(const std::string& team_uuid, std::map* team_hash); void OnJoinRoomOk(const cs::CMJoin& msg, Player* hum); void TeamRoomTimeOut(const std::string& team_uuid); void AdjustCMJoin(cs::CMJoin* msg); @@ -127,13 +127,13 @@ class RoomMgr : public a8::Singleton int current_room_idx_ = 0; int match_mode_ = 0; - std::map inactive_room_hash_; - std::map room_hash_; + std::map inactive_room_hash_; + std::map room_hash_; std::map room_idx_hash_; - std::map over_room_hash_; + std::map over_room_hash_; f8::Attacher reportstate_timer_attacher_; std::map gm_hash_; - std::map> team_room_hash_; + std::map> team_room_hash_; std::map> custom_room_hash_; std::map> his_custom_room_hash_; }; diff --git a/server/gameserver/team.cc b/server/gameserver/team.cc index a350ea64..354407d0 100644 --- a/server/gameserver/team.cc +++ b/server/gameserver/team.cc @@ -245,7 +245,7 @@ void Team::SendTeamBattleReport(Human* sender) params->SetVal("session_id", player->session_id); params->SetVal("__POST", post_data->ToJsonStr()); - long long room_uuid = room->GetRoomUuid(); + std::string room_uuid = room->GetRoomUuid(); int team_id = GetTeamId(); HttpProxy::Instance()->HttpGet ( @@ -475,14 +475,14 @@ void Team::GenBattleReportData(Human* player, a8::MutableXObject* params) void Team::GenBattleUuid() { - long long battle_uuid = 0; + std::string battle_uuid = 0; for (Human* hum : members_) { - if (hum->battle_uuid) { + if (!hum->battle_uuid.empty()) { battle_uuid = hum->battle_uuid; break; } } - if (!battle_uuid) { + if (!battle_uuid.empty()) { battle_uuid = App::Instance()->NewUuid(); }