From 60d1291e434d81f2b01641ad11d53b1b2fceaf19 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 26 Mar 2024 10:38:02 +0800 Subject: [PATCH] 1 --- server/gameserver/custom_battle.cc | 2 +- server/gameserver/human.h | 2 +- server/gameserver/pbutils.cc | 31 +++++++++++++++++++++++++----- server/gameserver/room.cc | 6 ++++++ server/gameserver/room.h | 3 +++ server/gameserver/roommgr.cc | 2 +- 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/server/gameserver/custom_battle.cc b/server/gameserver/custom_battle.cc index 278fc664..29e9ef17 100644 --- a/server/gameserver/custom_battle.cc +++ b/server/gameserver/custom_battle.cc @@ -324,7 +324,7 @@ void CustomBattle::OnEnter(std::shared_ptr join_msg, long ip_saddr, NotifyState(); auto hum = GetRoom()->GetPlayerByAccountId(join_msg->account_id()); if (hum) { - hum->ReJoin(ip_saddr, socket_handle, join_msg); + hum->ReJoin(ip_saddr, socket_handle); } } } diff --git a/server/gameserver/human.h b/server/gameserver/human.h index e8f8d492..1b8c0a2c 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -289,7 +289,7 @@ class Human : public Creature void ObstacleInteraction(Obstacle* entity); void SendMobaTeamNotify(); void PushJoinRoomMsg(); - void ReJoin(long ip_saddr, int socket_handle, std::shared_ptr msg); + void ReJoin(long ip_saddr, int socket_handle); const std::shared_ptr GetBornPoint() { return born_point_; } void SetBornPoint(std::shared_ptr born_point); void SendViewerUiNotify(); diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index da32a015..b396841a 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2247,7 +2247,7 @@ void Human::PushJoinRoomMsg() } } -void Human::ReJoin(long ip_saddr, int socket_handle, std::shared_ptr msg1) +void Human::ReJoin(long ip_saddr, int socket_handle) { if (!IsPlayer()) { abort(); @@ -2829,11 +2829,11 @@ int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr { auto hum = GetPlayerByAccountId(msg->account_id()); if (hum) { - hum->ReJoin(ip_saddr, socket_handle, msg); + hum->ReJoin(ip_saddr, socket_handle); } else { auto hum = p->GetRoom()->GetRoomOb()->GetByAccountId(msg->account_id()); if (hum) { - hum->ReJoin(ip_saddr, socket_handle, msg); + hum->ReJoin(ip_saddr, socket_handle); } } } @@ -2865,6 +2865,27 @@ int Room::JoinWithCustomBattle(std::shared_ptr p) } { + if (IsMobaModeRoom()) { + + } else { + for (size_t i = 0; i < net_teams.size(); ++i) { + auto net_team = net_teams.at(i); + auto room_team = room_teams.at(i); + room_team->SetInitTeamMemberNum(net_team->GetMemberNum()); + net_team->TraverseMember + ( + [this, p, room_team] (std::shared_ptr m) mutable -> bool + { + if (!m->IsAndroid()) { + Player* hum = InternalCreatePlayer(p, m, room_team); + } else { + Human* hum = CreateAndroidWithCustomMember(m, room_team); + } + return true; + } + ); + } + } p->TraverseObList ( [this, p] (std::shared_ptr m) mutable -> bool @@ -2892,7 +2913,7 @@ int Room::JoinWithCustomBattle(std::shared_ptr p) if (!m->IsAndroid()) { auto hum = GetPlayerByAccountId(m->GetAccountId()); if (hum) { - hum->ReJoin(m->GetIpSaddr(), m->GetSocketHandle(), nullptr); + hum->ReJoin(m->GetIpSaddr(), m->GetSocketHandle()); } } return true; @@ -2906,7 +2927,7 @@ int Room::JoinWithCustomBattle(std::shared_ptr p) if (!m->IsAndroid()) { auto hum = GetRoomOb()->GetByAccountId(m->GetAccountId()); if (hum) { - hum->ReJoin(m->GetIpSaddr(), m->GetSocketHandle(), nullptr); + hum->ReJoin(m->GetIpSaddr(), m->GetSocketHandle()); } } return true; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 5518aa4b..76cbe81d 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -533,6 +533,12 @@ void Room::CreateAndroid(int robot_num, std::shared_ptr team) NotifyUiUpdate(); } +Human* Room::CreateAndroidWithCustomMember(std::shared_ptr custom_member, + std::shared_ptr team) +{ + +} + void Room::FillSMJoinedNotify(Human* self_hum, cs::SMJoinedNotify& msg) { msg.set_team_mode(msg.team_mode()); diff --git a/server/gameserver/room.h b/server/gameserver/room.h index d72a2d36..9c0fffa5 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -42,6 +42,7 @@ struct FrameEventData; class SandTable; class BatchSync; class CustomBattle; +class CustomMember; class RoomAgent; class RoomOb; @@ -285,6 +286,8 @@ public: std::shared_ptr p); int JoinWithCustomBattle(std::shared_ptr p); void CreateAndroid(int android_num, std::shared_ptr team = nullptr); + Human* CreateAndroidWithCustomMember(std::shared_ptr custom_member, + std::shared_ptr team = nullptr); int GetFullLevelIdx() { return ++curr_full_level_idx_;} std::shared_ptr GetRoomOb(); void SendSMTeamFull(Human* hum); diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index af9cabb3..29c49b4d 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -542,7 +542,7 @@ void RoomMgr::_CMJoinCustomBattle(f8::MsgHdr* hdr, const cs::CMJoin& msg, int cu } auto hum = p->GetRoom()->GetPlayerByAccountId(join_msg->account_id()); if (hum) { - hum->ReJoin(ip_saddr, socket_handle, join_msg); + hum->ReJoin(ip_saddr, socket_handle); } return; }