This commit is contained in:
aozhiwei 2024-01-30 22:22:03 +08:00
parent 118d4a6c14
commit a30b3510b7
3 changed files with 21 additions and 10 deletions

View File

@ -270,8 +270,7 @@ class Human : public Creature
void ObstacleInteraction(Obstacle* entity); void ObstacleInteraction(Obstacle* entity);
void SendMobaTeamNotify(); void SendMobaTeamNotify();
void PushJoinRoomMsg(); void PushJoinRoomMsg();
void ReJoin(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg, void ReJoin(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg);
std::shared_ptr<MobaBattle> p);
const std::shared_ptr<BornPoint> GetBornPoint() { return born_point_; } const std::shared_ptr<BornPoint> GetBornPoint() { return born_point_; }
void SetBornPoint(std::shared_ptr<BornPoint> born_point); void SetBornPoint(std::shared_ptr<BornPoint> born_point);
void SendViewerUiNotify(); void SendViewerUiNotify();

View File

@ -2122,8 +2122,7 @@ void Human::PushJoinRoomMsg()
} }
} }
void Human::ReJoin(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg, void Human::ReJoin(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg)
std::shared_ptr<MobaBattle> p)
{ {
if (!IsPlayer()) { if (!IsPlayer()) {
abort(); abort();
@ -2689,11 +2688,11 @@ int Room::InitWithMobaBattle(long ip_saddr, int socket_handle, std::shared_ptr<c
{ {
auto hum = GetPlayerByAccountId(msg->account_id()); auto hum = GetPlayerByAccountId(msg->account_id());
if (hum) { if (hum) {
hum->ReJoin(ip_saddr, socket_handle, msg, p); hum->ReJoin(ip_saddr, socket_handle, msg);
} else { } else {
auto hum = p->GetRoom()->GetRoomOb()->GetByAccountId(msg->account_id()); auto hum = p->GetRoom()->GetRoomOb()->GetByAccountId(msg->account_id());
if (hum) { 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; return true;
}); });
cs::CMJoin join_msg = *msg; 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 net_team->TraverseMember
( (
[join_msg, p, net_team] (std::shared_ptr<CustomMember> m) mutable -> bool [join_msg, p, net_team, room_team] (std::shared_ptr<CustomMember> m) mutable -> bool
{ {
Player* hum = p->GetRoom()->NewPlayer(); Player* hum = p->GetRoom()->NewPlayer();
//hum->ip_saddr = ip_saddr; //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()); hum->SetMaxHP(hum->GetHP());
PlayerMgr::Instance()->IncAccountNum(join_msg.account_id()); PlayerMgr::Instance()->IncAccountNum(join_msg.account_id());
RoomMgr::Instance()->OnJoinRoomOk(join_msg, hum); RoomMgr::Instance()->OnJoinRoomOk(join_msg, hum);
//_team->AddMember(hum); room_team->AddMember(hum);
#ifdef MYDEBUG #ifdef MYDEBUG
a8::XPrintf("moba init1 uniid:%d team_id:%d side:%d\n", 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) void SyncObject::FillSMSyncPosition(cs::SMSyncPosition& sync_msg)

View File

@ -1259,7 +1259,7 @@ void RoomMgr::_CMJoinMoba(f8::MsgHdr* hdr, const cs::CMJoin& msg)
} }
auto hum = p->GetRoom()->GetPlayerByAccountId(join_msg->account_id()); auto hum = p->GetRoom()->GetPlayerByAccountId(join_msg->account_id());
if (hum) { if (hum) {
hum->ReJoin(ip_saddr, socket_handle, join_msg, p); hum->ReJoin(ip_saddr, socket_handle, join_msg);
} }
return; return;
} }