1
This commit is contained in:
parent
cd036929c9
commit
49b03c656c
@ -374,7 +374,7 @@ void CustomBattle::GameStart()
|
||||
}
|
||||
}
|
||||
SetRoom(room.get());
|
||||
//room->JoinWithCustomBattle(ip_saddr, socket_handle, join_msg, p);
|
||||
room->JoinWithCustomBattle(shared_from_this());
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
|
@ -2695,6 +2695,40 @@ int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr
|
||||
std::shared_ptr<CustomBattle> p)
|
||||
{
|
||||
#if 1
|
||||
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, join_msg);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
#else
|
||||
std::vector<std::shared_ptr<Team>> room_teams;
|
||||
std::vector<std::shared_ptr<CustomTeam>> net_teams;
|
||||
@ -2807,10 +2841,64 @@ int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Room::JoinWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg,
|
||||
std::shared_ptr<CustomBattle> p)
|
||||
int Room::JoinWithCustomBattle(std::shared_ptr<CustomBattle> p)
|
||||
{
|
||||
std::vector<std::shared_ptr<Team>> room_teams;
|
||||
#if 1
|
||||
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();
|
||||
}
|
||||
|
||||
{
|
||||
p->TraverseObList
|
||||
(
|
||||
[this, p] (std::shared_ptr<CustomMember> m) mutable -> bool
|
||||
{
|
||||
auto new_team = NewViewTeam();
|
||||
new_team->SetInitTeamMemberNum(0);
|
||||
new_team->SetAutoFill(true);
|
||||
#if 0
|
||||
Player* hum = InternalCreatePlayer(p, m, new_team, join_msg,
|
||||
[p] (Player* hum)
|
||||
{
|
||||
a8::SetBitFlag(hum->status, CS_IsOb);
|
||||
p->GetRoom()->GetRoomOb()->AddOb(hum);
|
||||
});
|
||||
#endif
|
||||
return true;
|
||||
});
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
std::vector<std::shared_ptr<Team>> room_teams;
|
||||
std::vector<std::shared_ptr<CustomTeam>> net_teams;
|
||||
p->TraverseTeamList
|
||||
(
|
||||
@ -2917,6 +3005,7 @@ int Room::JoinWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -283,8 +283,7 @@ public:
|
||||
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(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);
|
||||
int GetFullLevelIdx() { return ++curr_full_level_idx_;}
|
||||
std::shared_ptr<RoomOb> GetRoomOb();
|
||||
|
Loading…
x
Reference in New Issue
Block a user