From 3365577f52cf0bbdfa399a7378a5673bce046ec0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 29 May 2020 14:15:02 +0800 Subject: [PATCH] 1 --- server/gameserver/mapmgr.cc | 6 ++++ server/gameserver/room.cc | 65 +++++++++++++++++++------------------ server/gameserver/room.h | 4 +++ 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/server/gameserver/mapmgr.cc b/server/gameserver/mapmgr.cc index 3642d04..ea2df94 100644 --- a/server/gameserver/mapmgr.cc +++ b/server/gameserver/mapmgr.cc @@ -17,6 +17,12 @@ void MapMgr::Init() if (!map_meta_) { abort(); } + if (map_meta_->i->map_width() < 1) { + abort(); + } + if (map_meta_->i->map_height() < 1) { + abort(); + } map_service_ = new MapService(); grid_service_ = new GridService(); grid_service_->Init(map_meta_->i->map_width(), diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index d5c3f02..8dd604b 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -39,43 +39,24 @@ Room::~Room() void Room::Init() { - if (map_meta->i->map_width() < 1) { - abort(); - } - if (map_meta->i->map_height() < 1) { - abort(); - } - xtimer.Init(RoomXGetTickCount, this, 100, 100); xtimer_attacher_.xtimer = &xtimer; - #ifdef DEBUG - { - xtimer.AddRepeatTimer - ( - SERVER_FRAME_RATE * 3, - a8::XParams() - .SetSender(this), - [] (const a8::XParams& param) - { - Room* room = (Room*)param.sender.GetUserData(); - a8::UdpLog::Instance()->Debug("room_idx:%d real_alive_count:%d", - { - room->room_idx, - room->RealAliveCount() - }); - }); - } - #endif CreateSpawnPoints(); CreateLoots(); CreateDropObjs(); InitObstacleDatas(); ShuaAndroid(); + #ifdef DEBUG + InitDebugInfo(); + #endif } void Room::UnInit() { + #ifdef DEBUG + UnInitDebugInfo(); + #endif App::Instance()->perf.alive_count -= alive_count_; timer_attacher.ClearTimerList(); xtimer_attacher_.ClearTimerList(); @@ -95,12 +76,6 @@ void Room::UnInit() } removed_robot_hash_.clear(); grid_service->ClearRoomData(this); -#ifdef DEBUG - a8::UdpLog::Instance()->Debug("destroy room_idx:%d", - { - room_idx - }); -#endif } void Room::Update(int delta_time) @@ -2417,3 +2392,31 @@ void Room::CheckAliveHuman(Human* hum, std::vector& alive_humans) alive_humans.push_back(hum); } } + +#ifdef DEBUG +void Room::InitDebugInfo() +{ + xtimer.AddRepeatTimer + ( + SERVER_FRAME_RATE * 3, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Room* room = (Room*)param.sender.GetUserData(); + a8::UdpLog::Instance()->Debug("room_idx:%d real_alive_count:%d", + { + room->room_idx, + room->RealAliveCount() + }); + }); +} + +void Room::UnInitDebugInfo() +{ + a8::UdpLog::Instance()->Debug("destroy room_idx:%d", + { + room_idx + }); +} +#endif diff --git a/server/gameserver/room.h b/server/gameserver/room.h index ccb9b26..c46602f 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -160,6 +160,10 @@ private: void OnHumanGridChg(Human* target); void ShuaGridRound(Human* target); void CheckAliveHuman(Human* hum, std::vector& alive_humans); + #ifdef DEBUG + void InitDebugInfo(); + void UnInitDebugInfo(); + #endif private: bool waiting_start_ = false;