From 9e917ece8893957c5fa2936a92594a5d022e9987 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 3 Aug 2012 04:42:49 -0300 Subject: [PATCH] Fix glitch caused by grounds with speed 1 --- src/framework/core/eventdispatcher.cpp | 14 ++++++-------- src/otclient/creature.cpp | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/framework/core/eventdispatcher.cpp b/src/framework/core/eventdispatcher.cpp index 47a95903..9417ac41 100644 --- a/src/framework/core/eventdispatcher.cpp +++ b/src/framework/core/eventdispatcher.cpp @@ -42,7 +42,8 @@ void EventDispatcher::shutdown() void EventDispatcher::poll() { - while(!m_scheduledEventList.empty()) { + int loops = 0; + for(int count = 0, max = m_scheduledEventList.size(); count < max && !m_scheduledEventList.empty(); ++count) { ScheduledEventPtr scheduledEvent = m_scheduledEventList.top(); if(scheduledEvent->reamaningTicks() > 0) break; @@ -53,16 +54,14 @@ void EventDispatcher::poll() m_scheduledEventList.push(scheduledEvent); } - // execute events list up to 10 times, this is needed because some events can schedule new events that would + // execute events list until all events are out, this is needed because some events can schedule new events that would // change the UIWidgets layout, in this case we must execute these new events before we continue rendering, - // we can't loop until the event list is empty, because this could lead to infinite loops - // if someone write a module with bad code m_pollEventsSize = m_eventList.size(); - int count = 0; + loops = 0; while(m_pollEventsSize > 0) { - if(count > 50) { + if(loops > 50) { static Timer reportTimer; - if(reportTimer.running() && reportTimer.ticksElapsed() > 250) { + if(reportTimer.running() && reportTimer.ticksElapsed() > 100) { g_logger.error("ATTENTION the event list is not getting empty, this could be caused by some bad code"); reportTimer.restart(); } @@ -75,7 +74,6 @@ void EventDispatcher::poll() event->execute(); } m_pollEventsSize = m_eventList.size(); - count++; } } diff --git a/src/otclient/creature.cpp b/src/otclient/creature.cpp index f5147498..42030118 100644 --- a/src/otclient/creature.cpp +++ b/src/otclient/creature.cpp @@ -621,6 +621,8 @@ int Creature::getStepDuration() m_lastStepDirection == Otc::SouthWest || m_lastStepDirection == Otc::SouthEast) interval *= 3; + interval = std::max(interval, g_game.getServerBeat()); + return interval; }