From c2d8811b7320ac00d410c01b1ee1ade5ff0df8c6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 27 Dec 2023 17:37:21 +0800 Subject: [PATCH] 1 --- server/gameserver/mobabattle.cc | 0 server/gameserver/mobabattle.h | 43 +++++++++++++++++++++++++++++++++ server/gameserver/roommgr.cc | 9 +++++-- server/gameserver/roommgr.h | 6 +++-- 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 server/gameserver/mobabattle.cc create mode 100644 server/gameserver/mobabattle.h diff --git a/server/gameserver/mobabattle.cc b/server/gameserver/mobabattle.cc new file mode 100644 index 00000000..e69de29b diff --git a/server/gameserver/mobabattle.h b/server/gameserver/mobabattle.h new file mode 100644 index 00000000..3c22e63e --- /dev/null +++ b/server/gameserver/mobabattle.h @@ -0,0 +1,43 @@ +#pragma once + +class Room; +class MobaTeam; +class MobaMember; +class MobaBattle +{ + public: + + void Init(); + void UnInit(); + + bool GetParseOk() { return parse_ok_; } + Room* GetRoom() { return room_; } + void SetRoom(Room* room) { room_ = room; } + const std::string& GetRoomUuid() { return room_uuid_; } + const std::string& GetSign() { return sign_; } + const std::shared_ptr& GetRawData() { return raw_data_; } + int GetZoneId() { return zone_id_; } + int GetNodeId() { return zone_id_; } + int GetStartTime() { return start_time_; } + void ParseResult(a8::XObject& obj); + bool CanAdd(const std::string& account_id, const std::string& session_id); + std::shared_ptr GetTeamByAccountId(const std::string& account_id); + std::shared_ptr GetMemberByAccountId(const std::string& account_id); + std::shared_ptr GetTeamByTeamUuid(const std::string& team_uuid); + bool AllIsJoined(); + int GetMemberNum(); + void TraverseMemberList(std::function func); + + private: + bool parse_ok_ = false; + Room *room_ = nullptr; + std::string room_uuid_; + int zone_id_ = 0; + int node_id_ = 0; + int start_time_ = 0; + std::string sign_; + std::shared_ptr raw_data_; + std::map> uuid_hash_; + std::map> account_hash_; + std::map> member_id_hash_; +}; diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index ed430fca..ff7b9d1e 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -1158,8 +1158,13 @@ void RoomMgr::_CMJoinMoba(f8::MsgHdr* hdr, const cs::CMJoin& msg) auto socket_handle = hdr->socket_handle; auto cb = [join_msg, ip_saddr, socket_handle] - (int errcode, const std::string errmsg, std::shared_ptr p) + (int errcode, const std::string errmsg, std::shared_ptr p) { + auto& msg = *join_msg; + if (errcode) { + RoomMgr::Instance()->JoinErrorHandle(*join_msg, 2, socket_handle); + return; + } }; SendGetMobaBattleData(join_msg, cb); } @@ -1194,7 +1199,7 @@ void RoomMgr::DispatchSpecRoom(f8::MsgHdr* hdr, const cs::CMJoin& msg) } void RoomMgr::SendGetMobaBattleData(std::shared_ptr join_msg, - std::function)> cb) + std::function)> cb) { } diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index da2ce5c6..d54ae63b 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -25,7 +25,7 @@ class MapService; class MapInstance; class Building; class CustomBattle; -class MobaTeam; +class MobaBattle; struct RoomInitInfo { int room_idx = 0; @@ -126,7 +126,7 @@ class RoomMgr : public a8::Singleton void SendGetCustomBattleData(std::shared_ptr join_msg, std::function)> cb); void SendGetMobaBattleData(std::shared_ptr join_msg, - std::function)> cb); + std::function)> cb); void DispatchSpecRoom(f8::MsgHdr* hdr, const cs::CMJoin& msg); private: @@ -142,4 +142,6 @@ class RoomMgr : public a8::Singleton std::map> team_room_hash_; std::map> custom_room_hash_; std::map> his_custom_room_hash_; + std::map> moba_room_hash_; + std::map> his_moba_room_hash_; };