From 5e0c0457869b0b88b4acd3ecf8a68c50c0af5fac Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 27 Aug 2022 13:19:56 +0800 Subject: [PATCH] 1 --- server/gameserver/roomobstacle.cc | 32 +++++++++++++++++++++++++++++-- server/gameserver/roomobstacle.h | 1 + 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/server/gameserver/roomobstacle.cc b/server/gameserver/roomobstacle.cc index 660fab09..aac2d984 100644 --- a/server/gameserver/roomobstacle.cc +++ b/server/gameserver/roomobstacle.cc @@ -907,15 +907,38 @@ void RoomObstacle::ActiveMedicalStation() } void RoomObstacle::ActivePortal() +{ + room->xtimer.AddRepeatTimerAndAttach + ( + SERVER_FRAME_RATE, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData(); + obstacle->ProcPortal(); + }, + &xtimer_attacher.timer_list_ + ); +} + +void RoomObstacle::ProcPortal() { if (room->IsGameOver()) { return; } + if (room->IsPveRoom()) { + return; + } + if (!grid_list_) { + grid_list_ = new std::set(); + room->grid_service->GetAllCellsByXy(room, GetPos().x, GetPos().y, *grid_list_); + } bool ready = true; - room->TraversePlayerList + room->TraverseHumanList ( a8::XParams(), - [this, &ready] (Player* hum, a8::XParams& param) + [this, &ready] (Human* hum, a8::XParams& param) { if (!a8::IntersectCircleCircle ( @@ -925,10 +948,15 @@ void RoomObstacle::ActivePortal() meta->i->height() )) { ready = false; + return false; } + return true; } ); if (ready) { room->GetIncubator()->NextWave(); + Die(room); + BroadcastFullState(room); + room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer()); } } diff --git a/server/gameserver/roomobstacle.h b/server/gameserver/roomobstacle.h index 0dec335b..0b340a8d 100644 --- a/server/gameserver/roomobstacle.h +++ b/server/gameserver/roomobstacle.h @@ -61,6 +61,7 @@ private: void ProcKeepRangeBuff(); void DetachFromMaster(); void InstallPreExplostionSummonTimer(); + void ProcPortal(); void CalcTempPassObjects();