diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 2eee0688..83c10292 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -432,7 +432,7 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string killer_name, in } } GetTrigger()->HpChg(); - room->OnHumanHpChg(this); + room->OnTeamPartChg(this); } void Human::AddToNewObjects(Entity* entity) diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index dcc11a67..f5c4bf39 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2639,9 +2639,21 @@ void Room::SendSMTeamFull(Human* hum) } -void Room::OnHumanHpChg(Human* hum) +void Room::OnTeamPartChg(Human* hum) { - + if (hpchg_human_hash_.empty()) { + hpchg_human_hash_[hum->GetUniId()] = hum; + xtimer.SetTimeoutWpEx + (SERVER_FRAME_RATE * 0.5, + [this] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + hpchg_human_hash_.clear(); + } + }, + &xtimer_attacher_); + hpchg_human_hash_[hum->GetUniId()] = hum; + } } int Room::InitWithCustomBattle(long ip_saddr, int socket_handle, std::shared_ptr msg, diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 8d5847fc..c70dd7d0 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -286,7 +286,7 @@ public: int GetFullLevelIdx() { return ++curr_full_level_idx_;} std::shared_ptr GetRoomOb(); void SendSMTeamFull(Human* hum); - void OnHumanHpChg(Human* hum); + void OnTeamPartChg(Human* hum); private: void ShuaAndroid();