diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 8dd604b..b1f4e38 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -80,17 +80,11 @@ void Room::UnInit() void Room::Update(int delta_time) { -#ifdef DEBUG - run_in_timer_ = true; -#endif xtimer.Update(); if (IsGameOver() && GetFrameNo() - game_over_frameno_ > SERVER_FRAME_RATE * 20) { return; } -#ifdef DEBUG - run_in_timer_ = false; -#endif elapsed_time_ += delta_time; while (elapsed_time_ >= 50) { if (GetFrameNo() % 2 == 0) { @@ -1794,11 +1788,9 @@ long long Room::GetGasInactiveTime() void Room::EnableHuman(Human* target) { -#ifdef DEBUG - if (!run_in_timer_) { + if (!RuningInTimer()) { abort(); } -#endif #ifdef DEBUG CheckPartObjects(); a8::UdpLog::Instance()->Debug("enablehuman %d %d", @@ -1826,11 +1818,9 @@ void Room::EnableHuman(Human* target) void Room::DisableHuman(Human* target) { -#ifdef DEBUG - if (!run_in_timer_) { + if (!RuningInTimer()) { abort(); } -#endif #ifdef DEBUG CheckPartObjects(); a8::UdpLog::Instance()->Debug("disablehuman %d %d", @@ -2393,6 +2383,11 @@ void Room::CheckAliveHuman(Human* hum, std::vector& alive_humans) } } +bool Room::RuningInTimer() +{ + return xtimer.GetRunningTimer() != nullptr; +} + #ifdef DEBUG void Room::InitDebugInfo() { diff --git a/server/gameserver/room.h b/server/gameserver/room.h index c46602f..1e3ab20 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -43,7 +43,7 @@ public: FrameEvent frame_event; FrameMaker frame_maker; a8::XTimer xtimer; - a8::XTimerAttacher timer_attacher; + a8::TimerAttacher timer_attacher; GridService* grid_service = nullptr; MapService* map_service = nullptr; RoomType_e room_type = RT_NewBrid; @@ -113,6 +113,7 @@ public: void ShuaNewBieAndroid(Human* target); void InitAirDrop(); void CheckPartObjects(Human* testa = nullptr, Human* testb = nullptr); + bool RuningInTimer(); private: int AllocUniid(); @@ -197,7 +198,4 @@ private: std::map removed_robot_hash_; std::vector obstacle_datas_; -#ifdef DEBUG - bool run_in_timer_ = false; -#endif };