修复排名问题

This commit is contained in:
aozhiwei 2019-07-25 10:27:32 +08:00
parent c2bee6304b
commit 0d3caaa61e

View File

@ -1061,29 +1061,52 @@ void Room::BattleReport()
std::vector<Human*> human_list;
human_list.reserve(human_hash_.size());
for (auto& pair : human_hash_) {
#if 0
pair.second->stats.kills = rand() % 20;
pair.second->stats.dead_times = rand() % 2010;
pair.second->stats.damage_amount_out = rand() % 20100;
pair.second->stats.last_kill_timeseq = rand() % 20100;
#endif
human_list.push_back(pair.second);
}
std::sort(human_list.begin(), human_list.end(),
[] (Human* a, Human* b) -> bool
{
if (a->stats.kills > b->stats.kills) {
return true;
}
if (a->stats.kills < b->stats.kills) {
return false;
}
if (a->stats.dead_times < b->stats.dead_times) {
return true;
}
if (a->stats.dead_times > b->stats.dead_times) {
return false;
}
if (a->stats.damage_amount_out > b->stats.damage_amount_out) {
return true;
}
if (a->stats.damage_amount_out < b->stats.damage_amount_out) {
return false;
}
if (a->stats.last_kill_timeseq < b->stats.last_kill_timeseq) {
return true;
}
if (a->stats.last_kill_timeseq > b->stats.last_kill_timeseq) {
return false;
}
return false;
return a->entity_uniid < b->entity_uniid;
});
int rank = 1;
for (Human* hum : human_list) {
hum->stats.rank = rank++;
#if 0
a8::XPrintf("rank:%d kills:%d dead_times:%d damage_amount_out:%d last_kill_timeseq:%d\n",
{
hum->stats.rank,
@ -1092,6 +1115,7 @@ void Room::BattleReport()
hum->stats.damage_amount_out,
hum->stats.last_kill_timeseq,
});
#endif
hum->SendGameOver();
}
game_over = true;