From 9038d84c3d448a56540b0af4e5f4653f4a0bab46 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 15 Mar 2021 16:06:39 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 22 +++++++++++++++-- server/gameserver/player.cc | 1 - server/gameserver/room.cc | 47 +++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index af7cb1b..e13e8a2 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1730,18 +1730,36 @@ void Human::RemoveObserver(Human* observer) void Human::SendUpdateMsg() { if (!follow_target_ && !a8::HasBitFlag(status, HS_Disable) && IsPlayer()) { + #ifdef DEBUG + long long begin_tick = a8::XGetTickCount(); + long long end_tick = a8::XGetTickCount(); + #endif cs::MFActivePlayerData* active_player_data_pb = nullptr; if (send_msg_times == 0 || need_sync_active_player) { active_player_data_pb = new cs::MFActivePlayerData(); FillMFActivePlayerData(active_player_data_pb); need_sync_active_player = false; } + #ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + begin_tick = a8::XGetTickCount(); + #endif cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this); if (send_msg_times == 0 || last_sync_gas_frameno < room->GetGasData().gas_start_frameno) { last_sync_gas_frameno = room->GetGasData().gas_start_frameno; FillMFGasData(msg->mutable_gas_data()); } + #ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + begin_tick = a8::XGetTickCount(); + #endif NotifyObservers(msg, active_player_data_pb); delete msg; @@ -2231,7 +2249,7 @@ void Human::ClearFrameData() Human* hum = (Human*)entity; hum->RemovePartObjects(this); } -#ifdef DEBUG +#ifdef DEBUG1 room->CheckPartObjects(); #endif } @@ -2250,7 +2268,7 @@ void Human::ClearFrameData() hum->RemovePartObjects(this); } } -#ifdef DEBUG +#ifdef DEBUG1 room->CheckPartObjects(); #endif } diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 281ad18..dd3d544 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -58,7 +58,6 @@ void Player::InternalUpdate(int delta_time) if (HasBuffEffect(kBET_Fly)) { SetPos(room->plane.curr_pos); room->grid_service->MoveHuman(this); - return; } if (HasSpecMove()) { _UpdateSpecMove(); diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 1ad1ec9..e96227c 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -126,15 +126,39 @@ void Room::Update(int delta_time) elapsed_time_ += delta_time; while (elapsed_time_ >= 50) { + #ifdef DEBUG + long long begin_tick = a8::XGetTickCount(); + long long end_tick = a8::XGetTickCount(); + #endif if (GetFrameNo() % 2 == 0) { UpdateGas(); } + #ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + begin_tick = a8::XGetTickCount(); + #endif for (auto& pair : moveable_hash_) { pair.second->Update(50); } + #ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + begin_tick = a8::XGetTickCount(); + #endif if (GetFrameNo() % 2 == 0) { SyncFrameData(); } + #ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + #endif ++frameno_; elapsed_time_ -= 50; } @@ -1046,6 +1070,7 @@ void Room::UpdateGas() void Room::UpdateGasInactive() { if (GetFrameNo() - gas_data_.gas_start_frameno >= GetGasInactiveTime() * SERVER_FRAME_RATE) { + long long begin_tick = a8::XGetTickCount(); gas_data_.gas_mode = GasJump; gas_data_.gas_start_frameno = GetFrameNo(); if (human_hash_.size() < GetRoomMaxPlayerNum()) { @@ -1088,6 +1113,10 @@ void Room::UpdateGasInactive() } }, &xtimer_attacher_.timer_list_); + #if 1 + a8::XPrintf("max_run_delay:%d %d\n", {PerfMonitor::Instance()->max_run_delay_time, + a8::XGetTickCount() - begin_tick}); + #endif } } @@ -3209,9 +3238,27 @@ bool Room::CanAddToScene(Human* hum) void Room::SyncFrameData() { +#ifdef DEBUG + long long begin_tick = a8::XGetTickCount(); + long long end_tick = a8::XGetTickCount(); +#endif for (auto& pair : human_hash_) { pair.second->SendUpdateMsg(); +#ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 100) { + abort(); + } + begin_tick = a8::XGetTickCount(); +#endif } +#ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + begin_tick = a8::XGetTickCount(); +#endif frame_event.Clear(); }