diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index debefb2..424ee04 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -908,7 +908,7 @@ void Room::UpdateGas() UpdateGasMoving(); break; } - if (gas_data_.gas_mode != GasInactive) { + if (gas_data_.gas_mode != GasInactive && GetRoomMode() == kChiJiMode) { if (!IsGameOver() && alive_count_ <= MAX_TEAM_NUM && GetAliveTeamNum() <= 1) { game_over_ = true; game_over_frameno_ = GetFrameNo(); @@ -1563,6 +1563,13 @@ void Room::NotifyWxVoip() &xtimer_attacher_.timer_list_); } +void Room::BattleReport() +{ + game_over_ = true; + game_over_frameno_ = frameno_; + RoomMgr::Instance()->AddOverRoom(room_uuid_); +} + BornPoint* Room::AllocBornPoint(Human* hum) { BornPoint* born_point = nullptr; @@ -2683,20 +2690,37 @@ void Room::NewBieRoomStart() void Room::ZombieModeStart() { - if (GetRoomMode() == kZombieMode) { - if (human_hash_.size() != GetRoomMaxPlayerNum()) { - abort(); - } - std::vector human_list; - for (auto& pair : human_hash_) { - human_list.push_back(pair.second); - } - std::random_shuffle(human_list.begin(), human_list.end()); - for (size_t i = 0; i < 2; ++i) { - Human* hum = human_list[i]; - hum->ChangeToRace(kZombieRace, 1); - } + if (GetRoomMode() != kZombieMode) { + abort(); } + if (human_hash_.size() != GetRoomMaxPlayerNum()) { + abort(); + } + std::vector human_list; + for (auto& pair : human_hash_) { + human_list.push_back(pair.second); + } + std::random_shuffle(human_list.begin(), human_list.end()); + for (size_t i = 0; i < 2; ++i) { + Human* hum = human_list[i]; + hum->ChangeToRace(kZombieRace, 1); + } + battle_report_timer_ = xtimer.AddDeadLineTimerAndAttach + (SERVER_FRAME_RATE * MetaMgr::Instance()->zbmode_game_duration, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Room* room = (Room*)param.sender.GetUserData(); + room->BattleReport(); + }, + &xtimer_attacher_.timer_list_, + [] (const a8::XParams& param) + { + Room* room = (Room*)param.sender.GetUserData(); + room->battle_report_timer_ = nullptr; + } + ); } Human* Room::GetOneCanEnableAndroid() diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 84da15d..7d172c9 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -153,6 +153,7 @@ private: void OnGameOver(); void RandRemoveAndroid(); void NotifyWxVoip(); + void BattleReport(); BornPoint* AllocBornPoint(Human* hum); BornPoint* GetBornPoint(int point_uniid); void CreateSpawnPoints(); @@ -247,6 +248,7 @@ private: int creator_game_times_ = 0; int creator_register_time_ = 0; bool force_entry_newbie_room_ = false; + xtimer_list* battle_report_timer_ = nullptr; int current_teamid_ = 0; int current_uniid_ = FIXED_OBJECT_MAXID;