修复组队结算问题

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

View File

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