diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 59f04d2..e3faf36 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -711,27 +711,31 @@ void Room::UpdateGas() gas_data.gas_start_frameno = frame_no; ShuaPlane(); RoomMgr::Instance()->RemoveFromInactiveRoomHash(room_uuid); - for (size_t i = 1; i < 7; ++i) { - xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 3 * i, - a8::XParams() - .SetSender(this), - [] (const a8::XParams& param) - { - Room* room = (Room*)param.sender.GetUserData(); - room->TouchHumanList( - a8::XParams() - .SetSender(room), - [] (Human* hum, a8::XParams& param) -> bool - { - if (a8::HasBitFlag(hum->status, HS_Fly) && hum->entity_subtype != EST_Player) { - hum->DoJump(); - return false; - } - return true; - }); - }, - &xtimer_attacher.timer_list_); - } + int auto_jump_interval = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_interval"); + auto_jump_timer_ = xtimer.AddRepeatTimerAndAttach(SERVER_FRAME_RATE * auto_jump_interval, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Room* room = (Room*)param.sender.GetUserData(); + int auto_jump_min_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_min_num"); + int auto_jump_max_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_max_num"); + int jump_num = a8::RandEx(auto_jump_min_num, auto_jump_max_num); + for (int i = 0; i < jump_num; ++i) { + room->TouchHumanList( + a8::XParams() + .SetSender(room), + [] (Human* hum, a8::XParams& param) -> bool + { + if (a8::HasBitFlag(hum->status, HS_Fly) && hum->entity_subtype != EST_Player) { + hum->DoJump(); + return false; + } + return true; + }); + } + }, + &xtimer_attacher.timer_list_); } } break; @@ -794,6 +798,8 @@ void Room::UpdateGas() gas_data.rad_old = gas_data.old_area_meta->i->rad(); gas_data.rad_new = gas_data.new_area_meta->i->rad(); battle_start_frameno_ = frame_no; + xtimer.DeleteTimer(auto_jump_timer_); + auto_jump_timer_ = nullptr; } } break; diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 8ce5505..4775a5b 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -21,6 +21,7 @@ struct RoomProfile }; struct timer_list; +struct xtimer_list; class Entity; class Obstacle; class Bullet; @@ -115,6 +116,7 @@ private: int alive_count_ = 0; MetaData::AirLine* airline_ = nullptr; a8::XTimerAttacher xtimer_attacher; + xtimer_list* auto_jump_timer_ = nullptr; int current_teamid = 0; unsigned short current_uniid = 0;