This commit is contained in:
aozhiwei 2024-03-25 19:21:52 +08:00
parent 7b6054a962
commit 36b6064ce9
7 changed files with 38 additions and 2 deletions

View File

@ -166,6 +166,16 @@ void App::ProcessGameGateMsg(f8::MsgHdr* hdr)
} }
} }
break; break;
case HID_CustomMember:
{
auto member = RoomMgr::Instance()->GetCustomMemberBySocket(hdr->socket_handle);
if (member) {
ProcessNetMsg(handler, member.get(), hdr);
}
}
break;
default:
break;
} }
} }
} }

View File

@ -21,7 +21,7 @@ enum NetHandler_e
HID_RoomMgr, HID_RoomMgr,
HID_MatchMgr, HID_MatchMgr,
HID_MatchTeam, HID_MatchTeam,
HID_CustomBattle, HID_CustomMember,
HID_GGListener, HID_GGListener,
}; };

View File

@ -19,3 +19,8 @@ bool CustomMember::IsView()
{ {
return team_->IsView(); return team_->IsView();
} }
void CustomMember::_CMBattlePreSetReady(f8::MsgHdr* hdr, const cs::CMBattlePreSetReady& msg)
{
}

View File

@ -1,10 +1,18 @@
#pragma once #pragma once
namespace cs
{
class CMBattlePreSetReady;
}
struct BattleDataContext; struct BattleDataContext;
class Player; class Player;
class CustomTeam; class CustomTeam;
class CustomMember class CustomMember
{ {
public:
enum { HID = HID_CustomMember };
public: public:
int GetSocketHandle() { return socket_handle_; } int GetSocketHandle() { return socket_handle_; }
@ -22,8 +30,9 @@ class CustomMember
int GetHeadFrame() { return head_frame_; } int GetHeadFrame() { return head_frame_; }
int GetSex() { return sex_; } int GetSex() { return sex_; }
std::shared_ptr<BattleDataContext>& GetNetData() { return battle_context_; }; std::shared_ptr<BattleDataContext>& GetNetData() { return battle_context_; };
void _CMBattlePreSetReady(f8::MsgHdr* hdr, const cs::CMBattlePreSetReady& msg);
private: private:
std::shared_ptr<cs::CMJoin> join_msg_; std::shared_ptr<cs::CMJoin> join_msg_;
int socket_handle_ = 0; int socket_handle_ = 0;
long ip_saddr_ = 0; long ip_saddr_ = 0;

View File

@ -13,6 +13,7 @@
#include "player.h" #include "player.h"
#include "playermgr.h" #include "playermgr.h"
#include "roommgr.h" #include "roommgr.h"
#include "custom_member.h"
#include "cs_proto.pb.h" #include "cs_proto.pb.h"
#include "ss_proto.pb.h" #include "ss_proto.pb.h"
#include "jsondatamgr.h" #include "jsondatamgr.h"
@ -106,6 +107,8 @@ void HandlerMgr::RegisterNetMsgHandlers()
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMReconnect); RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMReconnect);
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMPing); RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMPing);
RegisterNetMsgHandler(&ggmsghandler, &CustomMember::_CMBattlePreSetReady);
#if 0 #if 0
RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchCancel); RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchCancel);
RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchChoose); RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchChoose);

View File

@ -752,3 +752,9 @@ bool RoomMgr::HasTask()
{ {
return !room_hash_.empty(); return !room_hash_.empty();
} }
std::shared_ptr<CustomMember> RoomMgr::GetCustomMemberBySocket(int socket_handle)
{
auto itr = socket_hash_.find(socket_handle);
return itr != socket_hash_.end() ? itr->second : nullptr;
}

View File

@ -25,6 +25,7 @@ class GridService;
class MapService; class MapService;
class MapInstance; class MapInstance;
class CustomBattle; class CustomBattle;
class CustomMember;
struct RoomInitInfo struct RoomInitInfo
{ {
int room_idx = 0; int room_idx = 0;
@ -82,6 +83,7 @@ class RoomMgr : public a8::Singleton<RoomMgr>
void SetMatchMode(int mode); void SetMatchMode(int mode);
bool HasTask(); bool HasTask();
void OnJoinRoomOk(const cs::CMJoin& msg, Player* hum); void OnJoinRoomOk(const cs::CMJoin& msg, Player* hum);
std::shared_ptr<CustomMember> GetCustomMemberBySocket(int socket_handle);
private: private:
void InstallReportStateTimer(); void InstallReportStateTimer();
@ -122,4 +124,5 @@ class RoomMgr : public a8::Singleton<RoomMgr>
std::map<std::string, int> gm_hash_; std::map<std::string, int> gm_hash_;
std::map<std::string, std::shared_ptr<CustomBattle>> custom_room_hash_; std::map<std::string, std::shared_ptr<CustomBattle>> custom_room_hash_;
std::map<std::string, std::shared_ptr<CustomBattle>> his_custom_room_hash_; std::map<std::string, std::shared_ptr<CustomBattle>> his_custom_room_hash_;
std::map<int, std::shared_ptr<CustomMember>> socket_hash_;
}; };