1
This commit is contained in:
parent
c69b492f58
commit
3365577f52
@ -17,6 +17,12 @@ void MapMgr::Init()
|
|||||||
if (!map_meta_) {
|
if (!map_meta_) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
if (map_meta_->i->map_width() < 1) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
if (map_meta_->i->map_height() < 1) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
map_service_ = new MapService();
|
map_service_ = new MapService();
|
||||||
grid_service_ = new GridService();
|
grid_service_ = new GridService();
|
||||||
grid_service_->Init(map_meta_->i->map_width(),
|
grid_service_->Init(map_meta_->i->map_width(),
|
||||||
|
@ -39,43 +39,24 @@ Room::~Room()
|
|||||||
|
|
||||||
void Room::Init()
|
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.Init(RoomXGetTickCount, this, 100, 100);
|
||||||
xtimer_attacher_.xtimer = &xtimer;
|
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();
|
CreateSpawnPoints();
|
||||||
CreateLoots();
|
CreateLoots();
|
||||||
CreateDropObjs();
|
CreateDropObjs();
|
||||||
InitObstacleDatas();
|
InitObstacleDatas();
|
||||||
ShuaAndroid();
|
ShuaAndroid();
|
||||||
|
#ifdef DEBUG
|
||||||
|
InitDebugInfo();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::UnInit()
|
void Room::UnInit()
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
UnInitDebugInfo();
|
||||||
|
#endif
|
||||||
App::Instance()->perf.alive_count -= alive_count_;
|
App::Instance()->perf.alive_count -= alive_count_;
|
||||||
timer_attacher.ClearTimerList();
|
timer_attacher.ClearTimerList();
|
||||||
xtimer_attacher_.ClearTimerList();
|
xtimer_attacher_.ClearTimerList();
|
||||||
@ -95,12 +76,6 @@ void Room::UnInit()
|
|||||||
}
|
}
|
||||||
removed_robot_hash_.clear();
|
removed_robot_hash_.clear();
|
||||||
grid_service->ClearRoomData(this);
|
grid_service->ClearRoomData(this);
|
||||||
#ifdef DEBUG
|
|
||||||
a8::UdpLog::Instance()->Debug("destroy room_idx:%d",
|
|
||||||
{
|
|
||||||
room_idx
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::Update(int delta_time)
|
void Room::Update(int delta_time)
|
||||||
@ -2417,3 +2392,31 @@ void Room::CheckAliveHuman(Human* hum, std::vector<Human*>& alive_humans)
|
|||||||
alive_humans.push_back(hum);
|
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
|
||||||
|
@ -160,6 +160,10 @@ private:
|
|||||||
void OnHumanGridChg(Human* target);
|
void OnHumanGridChg(Human* target);
|
||||||
void ShuaGridRound(Human* target);
|
void ShuaGridRound(Human* target);
|
||||||
void CheckAliveHuman(Human* hum, std::vector<Human*>& alive_humans);
|
void CheckAliveHuman(Human* hum, std::vector<Human*>& alive_humans);
|
||||||
|
#ifdef DEBUG
|
||||||
|
void InitDebugInfo();
|
||||||
|
void UnInitDebugInfo();
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool waiting_start_ = false;
|
bool waiting_start_ = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user