diff --git a/server/gameserver/ingamevoice.cc b/server/gameserver/ingamevoice.cc index aa37794a..13e3201e 100644 --- a/server/gameserver/ingamevoice.cc +++ b/server/gameserver/ingamevoice.cc @@ -10,7 +10,7 @@ static void IncIntMap(std::map& int_map, int key) { auto itr = int_map.find(key); - if (itr == int_map.end()) { + if (itr != int_map.end()) { ++itr->second; } else { int_map[key] = 1; @@ -20,7 +20,7 @@ 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()) { + if (itr != int_map.end()) { --itr->second; if (itr->second < 0) { itr->second = 0; @@ -28,6 +28,16 @@ static void DecIntMap(std::map& int_map, int key) } } +static int GetIntMap(std::map& int_map, int key) +{ + auto itr = int_map.find(key); + if (itr != int_map.end()) { + return itr->second; + } else { + return 0; + } +} + InGameVoice::InGameVoice(Room* room) { room_ = room; @@ -285,16 +295,106 @@ void InGameVoice::TriggerEvent(Human* killer, Human* deader) { bool is_first_boold = global_kills_ == 1; { + int val = global_kills_; mt::InGameVoice::Traverse ( room_->IsMobaModeRoom(), InGameVoiceEventType_e::kGlobalKills, - [this, killer, deader] (const mt::InGameVoice* meta) -> bool + [this, killer, deader, val] (const mt::InGameVoice* meta) -> bool { - if (meta->MatchCond(global_kills_)) { + if (meta->MatchCond(val)) { Notify(killer, deader, meta); } return true; }); } + { + if (!is_first_boold) { + int val = GetIntMap(personal_kills_, killer->GetUniId()); + mt::InGameVoice::Traverse + ( + room_->IsMobaModeRoom(), + InGameVoiceEventType_e::kPersonalExceptFirstBooldKills, + [this, killer, deader, val] (const mt::InGameVoice* meta) -> bool + { + if (meta->MatchCond(val)) { + Notify(killer, deader, meta); + } + return true; + }); + } + } + { + if (!is_first_boold) { + mt::InGameVoice::Traverse + ( + room_->IsMobaModeRoom(), + InGameVoiceEventType_e::kMyTeamateBeKill, + [this, killer, deader] (const mt::InGameVoice* meta) -> bool + { + Notify(killer, deader, meta); + return true; + }); + } + } + { + if (!is_first_boold) { + mt::InGameVoice::Traverse + ( + room_->IsMobaModeRoom(), + InGameVoiceEventType_e::kEnemyTeamBekill, + [this, killer, deader] (const mt::InGameVoice* meta) -> bool + { + Notify(killer, deader, meta); + return true; + }); + } + } + { + if (!is_first_boold) { + if (deader->GetTeam()->AllIsDead()) { + mt::InGameVoice::Traverse + ( + room_->IsMobaModeRoom(), + InGameVoiceEventType_e::kTeamAllDead, + [this, killer, deader] (const mt::InGameVoice* meta) -> bool + { + Notify(killer, deader, meta); + return true; + }); + } + } + } + { + if (!is_first_boold) { + int val = GetIntMap(personal_series_kills_, killer->GetUniId()); + mt::InGameVoice::Traverse + ( + room_->IsMobaModeRoom(), + InGameVoiceEventType_e::kSeriesKills, + [this, killer, deader, val] (const mt::InGameVoice* meta) -> bool + { + if (meta->MatchCond(val)) { + Notify(killer, deader, meta); + } + return true; + }); + } + } + { + if (!is_first_boold) { + int val = GetIntMap(personal_nodead_series_kills_, killer->GetUniId()); + mt::InGameVoice::Traverse + ( + room_->IsMobaModeRoom(), + InGameVoiceEventType_e::kNoDeadSeriesKills, + [this, killer, deader, val] (const mt::InGameVoice* meta) -> bool + { + if (meta->MatchCond(val)) { + Notify(killer, deader, meta); + } + return true; + }); + } + } }