This commit is contained in:
aozhiwei 2020-05-29 14:30:35 +08:00
parent 3365577f52
commit 6520fa4697
2 changed files with 9 additions and 16 deletions

View File

@ -80,17 +80,11 @@ void Room::UnInit()
void Room::Update(int delta_time)
{
#ifdef DEBUG
run_in_timer_ = true;
#endif
xtimer.Update();
if (IsGameOver() && GetFrameNo() - game_over_frameno_ > SERVER_FRAME_RATE * 20) {
return;
}
#ifdef DEBUG
run_in_timer_ = false;
#endif
elapsed_time_ += delta_time;
while (elapsed_time_ >= 50) {
if (GetFrameNo() % 2 == 0) {
@ -1794,11 +1788,9 @@ long long Room::GetGasInactiveTime()
void Room::EnableHuman(Human* target)
{
#ifdef DEBUG
if (!run_in_timer_) {
if (!RuningInTimer()) {
abort();
}
#endif
#ifdef DEBUG
CheckPartObjects();
a8::UdpLog::Instance()->Debug("enablehuman %d %d",
@ -1826,11 +1818,9 @@ void Room::EnableHuman(Human* target)
void Room::DisableHuman(Human* target)
{
#ifdef DEBUG
if (!run_in_timer_) {
if (!RuningInTimer()) {
abort();
}
#endif
#ifdef DEBUG
CheckPartObjects();
a8::UdpLog::Instance()->Debug("disablehuman %d %d",
@ -2393,6 +2383,11 @@ void Room::CheckAliveHuman(Human* hum, std::vector<Human*>& alive_humans)
}
}
bool Room::RuningInTimer()
{
return xtimer.GetRunningTimer() != nullptr;
}
#ifdef DEBUG
void Room::InitDebugInfo()
{

View File

@ -43,7 +43,7 @@ public:
FrameEvent frame_event;
FrameMaker frame_maker;
a8::XTimer xtimer;
a8::XTimerAttacher timer_attacher;
a8::TimerAttacher timer_attacher;
GridService* grid_service = nullptr;
MapService* map_service = nullptr;
RoomType_e room_type = RT_NewBrid;
@ -113,6 +113,7 @@ public:
void ShuaNewBieAndroid(Human* target);
void InitAirDrop();
void CheckPartObjects(Human* testa = nullptr, Human* testb = nullptr);
bool RuningInTimer();
private:
int AllocUniid();
@ -197,7 +198,4 @@ private:
std::map<int, Human*> removed_robot_hash_;
std::vector<ObstacleData> obstacle_datas_;
#ifdef DEBUG
bool run_in_timer_ = false;
#endif
};