From 7f68e9f2988a552c9a1ca4f4a6aa9cb5cdc145c7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 25 Dec 2022 14:29:48 +0800 Subject: [PATCH] 1 --- server/gameserver/mt/AirRaid.cc | 12 ++++++++++ server/gameserver/mt/AirRaid.h | 2 ++ server/gameserver/room.cc | 33 +++++++++++++------------- server/tools/protobuild/cs_proto.proto | 2 +- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/server/gameserver/mt/AirRaid.cc b/server/gameserver/mt/AirRaid.cc index 70325070..a928c353 100644 --- a/server/gameserver/mt/AirRaid.cc +++ b/server/gameserver/mt/AirRaid.cc @@ -29,4 +29,16 @@ namespace mt } } } + + void AirRaid::Traverse(std::function cb) + { + bool stop = false; + for (auto& itr : raw_list) { + cb(itr, stop); + if (stop) { + break; + } + } + } + } diff --git a/server/gameserver/mt/AirRaid.h b/server/gameserver/mt/AirRaid.h index fb60a4a7..d700d98a 100644 --- a/server/gameserver/mt/AirRaid.h +++ b/server/gameserver/mt/AirRaid.h @@ -15,6 +15,8 @@ namespace mt std::vector> _raid_waves; std::vector _bomb_ids; + + static void Traverse(std::function cb); }; } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index b329dae2..992c205c 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -3429,23 +3429,22 @@ void Room::SetInfiniteBulletMode() void Room::InitAirRaid() { - // 111 - #if 0 - std::list& air_raids = MetaMgr::Instance()->GetAirRaids(); - for (auto& air_raid : air_raids) { - xtimer.SetTimeoutEx - (SERVER_FRAME_RATE * air_raid.pb->time(), - [this, &air_raid] (int event, const a8::Args* args) - { - if (a8::TIMER_EXEC_EVENT == event) { - if (!IsGameOver()) { - AirRaid(air_raid.pb->id()); - } - } - }, - &xtimer_attacher_); - } - #endif + mt::AirRaid::Traverse + ( + [this] (const mt::AirRaid* air_raid, bool& stop) + { + xtimer.SetTimeoutEx + (SERVER_FRAME_RATE * air_raid->time(), + [this, air_raid] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + if (!IsGameOver()) { + AirRaid(air_raid->id()); + } + } + }, + &xtimer_attacher_); + }); } void Room::AirRaid(int airraid_id) diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 34251aed..fecdc966 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -657,7 +657,7 @@ message MFEmote { optional int32 emote_id = 1; //表情id optional int32 player_id = 3; //玩家id - optional string msg = 5; + optional string msg = 5;; } //英雄结算信息