diff --git a/server/gameserver/ingamevoice.cc b/server/gameserver/ingamevoice.cc index b0851e77..b9e0c148 100644 --- a/server/gameserver/ingamevoice.cc +++ b/server/gameserver/ingamevoice.cc @@ -17,6 +17,17 @@ static void IncIntMap(std::map& int_map, int key) } } +static void DecIntMap(std::map& int_map, int key) +{ + auto itr = int_map.find(key); + if (itr == int_map.end()) { + --itr->second; + if (itr->second < 0) { + itr->second = 0; + } + } +} + InGameVoice::InGameVoice(Room* room) { room_ = room; @@ -66,50 +77,21 @@ void InGameVoice::OnHumanBeKill(int killer_id, Human* deader) return true; }); } -} - -#if 0 -void InGameVoice::IncPersonalSeriesKills(int killer_id) -{ - auto itr = personal_series_kills_.find(killer_id); - if (itr != personal_series_kills_.end()) { - ++itr->second; - } else { - personal_series_kills_[killer_id] = 1; + { + room_->xtimer.SetTimeoutWpEx + ( + SERVER_FRAME_RATE * 30, + [room = room_, killer_id] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + DecIntMap(room->GetInGameVoice()->personal_series_kills_, killer_id); + DecIntMap(room->GetInGameVoice()->personal_nodead_series_kills_, killer_id); + } + }, + &room_->xtimer_attacher_); } - room_->xtimer.SetTimeoutWpEx - ( - SERVER_FRAME_RATE * 30, - [room = room_, killer_id] (int event, const a8::Args* args) - { - if (a8::TIMER_EXEC_EVENT == event) { - room->GetInGameVoice()->personal_series_kills_.erase(killer_id); - } - }, - &room_->xtimer_attacher_); } -void InGameVoice::IncPersonalNoDeadSeriesKills(int killer_id) -{ - auto itr = personal_nodead_series_kills_.find(killer_id); - if (itr != personal_nodead_series_kills_.end()) { - ++itr->second; - } else { - personal_nodead_series_kills_[killer_id] = 1; - } - room_->xtimer.SetTimeoutWpEx - ( - SERVER_FRAME_RATE * 30, - [room = room_, killer_id] (int event, const a8::Args* args) - { - if (a8::TIMER_EXEC_EVENT == event) { - room->GetInGameVoice()->personal_nodead_series_kills_.erase(killer_id); - } - }, - &room_->xtimer_attacher_); -} -#endif - void InGameVoice::Notify(Human* killer, Human* deader, const mt::InGameVoice* meta) {