1
This commit is contained in:
parent
49b03c656c
commit
b3c0362a3e
@ -131,9 +131,9 @@ static void Human_FillBodyState(Human* self, ::google::protobuf::RepeatedPtrFiel
|
||||
static Player* InternalCreatePlayer(std::shared_ptr<CustomBattle> p,
|
||||
std::shared_ptr<CustomMember> m,
|
||||
std::shared_ptr<Team> room_team,
|
||||
cs::CMJoin& join_msg,
|
||||
std::function<void (Player*)> on_preadd = nullptr)
|
||||
{
|
||||
cs::CMJoin join_msg;
|
||||
Player* hum = p->GetRoom()->NewPlayer();
|
||||
//hum->ip_saddr = ip_saddr;
|
||||
//hum->socket_handle = socket_handle;
|
||||
@ -2247,7 +2247,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> msg1)
|
||||
{
|
||||
if (!IsPlayer()) {
|
||||
abort();
|
||||
@ -2724,7 +2724,7 @@ int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr
|
||||
(
|
||||
[join_msg, p, room_team] (std::shared_ptr<CustomMember> m) mutable -> bool
|
||||
{
|
||||
Player* hum = InternalCreatePlayer(p, m, room_team, join_msg);
|
||||
Player* hum = InternalCreatePlayer(p, m, room_team);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
@ -2843,7 +2843,6 @@ int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr
|
||||
|
||||
int Room::JoinWithCustomBattle(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
|
||||
@ -2873,139 +2872,46 @@ int Room::JoinWithCustomBattle(std::shared_ptr<CustomBattle> p)
|
||||
auto new_team = NewViewTeam();
|
||||
new_team->SetInitTeamMemberNum(0);
|
||||
new_team->SetAutoFill(true);
|
||||
#if 0
|
||||
Player* hum = InternalCreatePlayer(p, m, new_team, join_msg,
|
||||
Player* hum = InternalCreatePlayer(p, m, new_team,
|
||||
[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
|
||||
(
|
||||
[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;
|
||||
}
|
||||
);
|
||||
}
|
||||
if (IsMobaModeRoom()) {
|
||||
if (room_teams.size() < 2) {
|
||||
auto new_team = NewTeam();
|
||||
new_team->SetInitTeamMemberNum(0);
|
||||
new_team->SetAutoFill(true);
|
||||
room_teams.push_back(new_team);
|
||||
}
|
||||
int side = a8::RandEx(1, 2);
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
auto team = room_teams.at(i);
|
||||
if (team->GetMemberNum() < MAX_TEAM_NUM) {
|
||||
CreateAndroid(MAX_TEAM_NUM - team->GetMemberNum(), team);
|
||||
}
|
||||
if (i == 0) {
|
||||
moba_team_a_ = team.get();
|
||||
} else {
|
||||
moba_team_b_ = team.get();
|
||||
}
|
||||
team->TraverseMembers
|
||||
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
|
||||
(
|
||||
[this, side] (Human* hum) -> bool
|
||||
[this, p, room_team] (std::shared_ptr<CustomMember> m) mutable -> bool
|
||||
{
|
||||
hum->side = side;
|
||||
std::shared_ptr<BornPoint> born_point = std::make_shared<BornPoint>();
|
||||
born_point->wo_meta = std::get<0>(GetMapMeta()->moba_born_points.at(side - 1));
|
||||
hum->SetBornPoint(born_point);
|
||||
hum->InitMobaRoad();
|
||||
#ifdef MYDEBUG
|
||||
a8::XPrintf("moba init uniid:%d team_id:%d side:%d wo_meta:%d\n",
|
||||
{
|
||||
hum->GetUniId(),
|
||||
hum->GetTeam()->GetTeamId(),
|
||||
hum->side,
|
||||
(long long)hum->GetBornPoint()->wo_meta.get()
|
||||
});
|
||||
#endif
|
||||
if (!m->IsAndroid()) {
|
||||
auto hum = GetPlayerByAccountId(m->GetAccountId());
|
||||
if (hum) {
|
||||
hum->ReJoin(m->GetIpSaddr(), m->GetSocketHandle(), nullptr);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (side == 1) {
|
||||
side = 2;
|
||||
} else {
|
||||
side = 1;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
{
|
||||
p->TraverseObList
|
||||
(
|
||||
[this, join_msg, p] (std::shared_ptr<CustomMember> m) mutable -> bool
|
||||
[this, p] (std::shared_ptr<CustomMember> m) mutable -> bool
|
||||
{
|
||||
auto new_team = NewViewTeam();
|
||||
new_team->SetInitTeamMemberNum(0);
|
||||
new_team->SetAutoFill(true);
|
||||
Player* hum = InternalCreatePlayer(p, m, new_team, join_msg,
|
||||
[p] (Player* hum)
|
||||
{
|
||||
a8::SetBitFlag(hum->status, CS_IsOb);
|
||||
p->GetRoom()->GetRoomOb()->AddOb(hum);
|
||||
});
|
||||
if (!m->IsAndroid()) {
|
||||
auto hum = GetRoomOb()->GetByAccountId(m->GetAccountId());
|
||||
if (hum) {
|
||||
hum->ReJoin(m->GetIpSaddr(), m->GetSocketHandle(), nullptr);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
{
|
||||
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
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user