From f67342df0e185a215a5eb9bdb67cc69b49148fa6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 3 Jun 2023 11:17:50 +0800 Subject: [PATCH] 1 --- server/gameserver/pbutils.cc | 15 +++++++++++++++ server/gameserver/room.cc | 11 +++++++++++ server/gameserver/room.h | 1 + 3 files changed, 27 insertions(+) diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index e43f2aa0..a53b2445 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2156,6 +2156,21 @@ void Room::NotifyNewsTicker(int msg_type, std::vector msg_content) }); } +void Room::NotifyKillList(const std::vector& uniid_list) +{ + cs::SMSyncKillList notify_msg; + for (int obj_uniid : uniid_list) { + auto p = notify_msg.add_kill_list(); + p->set_obj_uniid(obj_uniid); + } + TraversePlayerList + ( + [¬ify_msg] (Player* hum) + { + hum->SendNotifyMsg(notify_msg); + }); +} + void SyncObject::FillSMSyncPosition(cs::SMSyncPosition& sync_msg) { if (!c.Get()) { diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 9a69d57c..54b51db2 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -41,6 +41,7 @@ #include "airraid.h" #include "sandtable.h" #include "batchsync.h" +#include "trigger.h" #include "mt/Param.h" #include "mt/Hero.h" @@ -3334,6 +3335,16 @@ void Room::ForwardGasRing(int n) boss_uniid); if (hero) { batch_sync_->AddGlobalObject(hero); + hero->GetTrigger()->AddListener + ( + kDieEvent, + [this, boss_uniid] (const a8::Args& args) mutable + { + if (!IsGameOver()) { + batch_sync_->RemoveGlobalObject(boss_uniid); + NotifyKillList({boss_uniid}); + } + }); } } }, diff --git a/server/gameserver/room.h b/server/gameserver/room.h index e2dabce4..261461df 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -253,6 +253,7 @@ public: void OpenRoomSwitch(int tag); void CloseRoomSwitch(int tag); void NotifyNewsTicker(int msg_type, std::vector msg_content); + void NotifyKillList(const std::vector& uniid_list); std::shared_ptr GetAirRaid() { return air_raid_; } std::shared_ptr GetBatchSync() { return batch_sync_; }