修复组队结算问题

This commit is contained in:
aozhiwei 2019-06-26 17:54:57 +08:00
parent e15d50950a
commit 8bd922db5b
2 changed files with 42 additions and 35 deletions

View File

@ -560,39 +560,45 @@ void Human::ResetAction()
void Human::FillSMGameOver(cs::SMGameOver& msg)
{
std::vector<Human*> human_list;
room->TouchHumanList(a8::XParams(),
[&human_list] (Human* hum, a8::XParams& param) -> bool
{
if (hum->leave_frameno_ == 0 ||
hum->leave_frameno_ > hum->room->battle_start_frameno_) {
human_list.push_back(hum);
}
return true;
});
std::sort(human_list.begin(), human_list.end(),
[] (Human* a, Human* b )
{
if (a->dead_frameno == b->dead_frameno) {
return a->entity_uniid < b->entity_uniid;
} else {
return a->dead_frameno == 0 ||
(b->dead_frameno != 0 && a->dead_frameno > b->dead_frameno);
}
});
int rank = human_list.size();
for (size_t i = 0; i < human_list.size(); ++i) {
if (human_list[i] == this) {
rank = i + 1;
break;
if (stats.rank <= 0) {
std::vector<Human*> human_list;
room->TouchHumanList(a8::XParams(),
[&human_list] (Human* hum, a8::XParams& param) -> bool
{
if (hum->leave_frameno_ == 0 ||
hum->leave_frameno_ > hum->room->battle_start_frameno_) {
human_list.push_back(hum);
}
return true;
});
std::sort(human_list.begin(), human_list.end(),
[] (Human* a, Human* b )
{
if (a->dead_frameno == b->dead_frameno) {
return a->entity_uniid < b->entity_uniid;
} else {
return a->dead_frameno == 0 ||
(b->dead_frameno != 0 && a->dead_frameno > b->dead_frameno);
}
});
int rank = human_list.size();
for (size_t i = 0; i < human_list.size(); ++i) {
if (human_list[i] == this) {
rank = i + 1;
break;
}
}
}
if (!dead && room->GetAliveTeamNum() == 1) {
rank = 1;
if (room->GetAliveTeamNum() == 1) {
std::set<Human*>* alive_team = room->GetAliveTeam();
if (alive_team == team_members) {
rank = 1;
}
}
stats.rank = rank;
}
msg.set_team_id(team_id);
msg.set_team_rank(rank);
msg.set_team_rank(stats.rank);
msg.set_team_allcnt(1);
msg.set_game_over(room->game_over);
msg.set_victory(!dead);
@ -713,15 +719,15 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
}
}
if (room->GetAliveTeamNum() == 1) {
std::set<Human*>* members = room->GetAliveTeam();
if (members) {
for (Human* member : *members) {
std::set<Human*>* alive_team = room->GetAliveTeam();
if (team_members != alive_team) {
SendGameOver();
}
if (alive_team) {
for (Human* member : *alive_team) {
member->SendGameOver();
}
}
if (team_members != members) {
SendGameOver();
}
}
DeadDrop();
}

View File

@ -87,6 +87,7 @@ struct PlayerStats
std::string killer_name;
int weapon_id = 0;
int rank = 0;
};
struct Plane