From bdf403485bb332fca5ec675086dc135c3df4a579 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 22 Apr 2019 13:45:48 +0800 Subject: [PATCH] 1 --- server/gameserver/player.cc | 40 ++++++++++++++++--------------- server/gameserver/room.cc | 48 +++++++++++++++++++++---------------- 2 files changed, 48 insertions(+), 40 deletions(-) diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index d06ca9f..28ae5ba 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -404,25 +404,27 @@ void Player::UpdateJump() { if (a8::HasBitFlag(status, HS_Fly)) { DoJump(); - room->xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 3, - a8::XParams() - .SetSender(this), - [] (const a8::XParams& param) - { - Human* hum = (Human*)param.sender.GetUserData(); - hum->room->TouchHumanList( - a8::XParams() - .SetSender(hum), - [] (Human* hum, a8::XParams& param) -> bool - { - if (a8::HasBitFlag(hum->status, HS_Fly)) { - hum->DoJump(); - return false; - } - return true; - }); - }, - &xtimer_attacher.timer_list_); + for (size_t i = 0; i < 4; ++i){ + room->xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE / 10, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Human* hum = (Human*)param.sender.GetUserData(); + hum->room->TouchHumanList( + a8::XParams() + .SetSender(hum), + [] (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_); + } } jump = false; } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 9f7592e..b064005 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -368,6 +368,12 @@ void Room::CollisionDetection(Entity* sender, int detection_flags, std::vectorpos.x - pair.second->pos.x) > 1000 || + std::abs(sender->pos.y - pair.second->pos.y) > 1000){ + continue; + } + #endif if (a8::HasBitFlag(detection_flags, ET_Player) && pair.second->entity_type == ET_Player) { if (sender->entity_type == ET_Bullet) { Bullet* bullet = (Bullet*)sender; @@ -814,27 +820,27 @@ void Room::UpdateGas() gas_data.gas_start_frameno = frame_no; ShuaPlane(); RoomMgr::Instance()->RemoveFromInactiveRoomHash(room_uuid); - #if 1 - xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 3, - 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->DoJump(); - return false; - } - return true; - }); - }, - &xtimer_attacher.timer_list_); - #endif + 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_); + } } } break;