This commit is contained in:
aozhiwei 2019-07-05 11:29:20 +08:00
parent 5992e1d938
commit 7bc0d15068

View File

@ -795,15 +795,15 @@ void Room::UpdateGas()
NotifyWxVoip();
RoomMgr::Instance()->ActiveRoom(room_uuid);
battle_start_frameno_ = frame_no;
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * MetaMgr::Instance()->game_duration,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
room->BattleReport();
},
&xtimer_attacher.timer_list_);
battle_report_timer_ = xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * MetaMgr::Instance()->game_duration,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
room->BattleReport();
},
&xtimer_attacher.timer_list_);
}
}
break;
@ -991,5 +991,45 @@ void Room::NotifyWxVoip()
void Room::BattleReport()
{
battle_report_timer_ = nullptr;
std::vector<Human*> human_list;
human_list.reserve(human_hash_.size());
for (auto& pair : human_hash_) {
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.dead_times < b->stats.dead_times) {
return true;
}
if (a->stats.damage_amount_out > b->stats.damage_amount_out) {
return true;
}
return false;
});
cs::SMGameOver msg;
msg.set_room_uuid(a8::XValue(room_uuid).GetString());
int rank = 1;
for (Human* hum : human_list) {
auto p = msg.add_player_stats();
p->set_rank(rank++);
p->set_player_id(hum->entity_uniid);
p->set_player_avatar_url(hum->avatar_url);
p->set_account_id(hum->account_id);
p->set_kills(hum->stats.kills);
p->set_dead_times(hum->stats.dead_times);
}
for (Human* hum : human_list) {
if (hum->entity_subtype == EST_Player) {
hum->SendNotifyMsg(msg);
}
}
game_over = true;
game_over_frameno = frame_no;
RoomMgr::Instance()->AddOverRoom(room_uuid);
}