diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 281209aa..47427290 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -270,8 +270,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, - std::shared_ptr p); + void ReJoin(long ip_saddr, int socket_handle, std::shared_ptr msg); 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 284dbe21..80d078d3 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2122,8 +2122,7 @@ void Human::PushJoinRoomMsg() } } -void Human::ReJoin(long ip_saddr, int socket_handle, std::shared_ptr msg, - std::shared_ptr p) +void Human::ReJoin(long ip_saddr, int socket_handle, std::shared_ptr msg) { if (!IsPlayer()) { abort(); @@ -2689,11 +2688,11 @@ int Room::InitWithMobaBattle(long ip_saddr, int socket_handle, std::shared_ptraccount_id()); if (hum) { - hum->ReJoin(ip_saddr, socket_handle, msg, p); + hum->ReJoin(ip_saddr, socket_handle, msg); } else { auto hum = p->GetRoom()->GetRoomOb()->GetByAccountId(msg->account_id()); if (hum) { - hum->ReJoin(ip_saddr, socket_handle, msg, p); + hum->ReJoin(ip_saddr, socket_handle, msg); } } } @@ -2721,10 +2720,12 @@ int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr return true; }); cs::CMJoin join_msg = *msg; - for (auto net_team : net_teams) { + for (size_t i = 0; i < net_teams.size(); ++i) { + auto net_team = net_teams.at(i); + auto room_team = room_teams.at(i); net_team->TraverseMember ( - [join_msg, p, net_team] (std::shared_ptr m) mutable -> bool + [join_msg, p, net_team, room_team] (std::shared_ptr m) mutable -> bool { Player* hum = p->GetRoom()->NewPlayer(); //hum->ip_saddr = ip_saddr; @@ -2773,7 +2774,7 @@ int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr hum->SetMaxHP(hum->GetHP()); PlayerMgr::Instance()->IncAccountNum(join_msg.account_id()); RoomMgr::Instance()->OnJoinRoomOk(join_msg, hum); - //_team->AddMember(hum); + room_team->AddMember(hum); #ifdef MYDEBUG a8::XPrintf("moba init1 uniid:%d team_id:%d side:%d\n", { @@ -2786,6 +2787,17 @@ 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); + } else { + auto hum = p->GetRoom()->GetRoomOb()->GetByAccountId(msg->account_id()); + if (hum) { + hum->ReJoin(ip_saddr, socket_handle, msg); + } + } + } } void SyncObject::FillSMSyncPosition(cs::SMSyncPosition& sync_msg) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 294d99b5..8781dd3c 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -1259,7 +1259,7 @@ void RoomMgr::_CMJoinMoba(f8::MsgHdr* hdr, const cs::CMJoin& msg) } auto hum = p->GetRoom()->GetPlayerByAccountId(join_msg->account_id()); if (hum) { - hum->ReJoin(ip_saddr, socket_handle, join_msg, p); + hum->ReJoin(ip_saddr, socket_handle, join_msg); } return; }