This commit is contained in:
aozhiwei 2024-05-17 16:51:51 +08:00
parent 8c2c5c45de
commit df8a52a8a5
2 changed files with 3 additions and 42 deletions

View File

@ -2266,6 +2266,9 @@ void Human::ReJoin(long ip_saddr, int socket_handle)
if (!IsPlayer()) {
abort();
}
if (socket_handle == 0) {
A8_ABORT();
}
auto old_socket_handle = this->GetSocketHandle();
SetIpSaddr(ip_saddr);
SetSocketHandle(socket_handle);
@ -2698,46 +2701,6 @@ void Room::OnTeamPartChg(Human* hum)
}
}
int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg,
std::shared_ptr<CustomBattle> p)
{
std::vector<std::shared_ptr<Team>> room_teams;
std::vector<std::shared_ptr<CustomTeam>> net_teams;
p->TraverseTeamList
(
[this, &room_teams, &net_teams] (std::shared_ptr<CustomTeam> team) -> bool
{
auto new_team = NewTeam();
new_team->SetInitTeamMemberNum(0);
new_team->SetAutoFill(true);
room_teams.push_back(new_team);
net_teams.push_back(team);
return true;
});
if (room_teams.empty()) {
abort();
}
if (IsMobaModeRoom() &&
room_teams.size() != 2) {
abort();
}
cs::CMJoin join_msg = *msg;
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
(
[join_msg, p, room_team] (std::shared_ptr<CustomMember> m) mutable -> bool
{
Player* hum = InternalCreatePlayer(p, m, room_team);
return true;
}
);
}
return 0;
}
int Room::JoinWithCustomBattle(std::shared_ptr<CustomBattle> p)
{
std::vector<std::shared_ptr<Team>> room_teams;

View File

@ -289,8 +289,6 @@ public:
Team* GetMobaEnemyTeam(Team* self_team);
RoomAgent* GetRoomAgent() { return room_agent_; }
int GenShotUniid() { return ++current_shot_uniid_; }
int InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg,
std::shared_ptr<CustomBattle> p);
int JoinWithCustomBattle(std::shared_ptr<CustomBattle> p);
void CreateAndroid(int android_num, std::shared_ptr<Team> team = nullptr);
Human* CreateAndroidWithCustomMember(std::shared_ptr<CustomMember> custom_member,