SAGA2: Delete timers on list removal
This commit is contained in:
parent
b72d66a393
commit
1df171e36b
2 changed files with 7 additions and 1 deletions
|
@ -1803,6 +1803,7 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) {
|
|||
assert((*it)->getObject() == this);
|
||||
|
||||
if (newTimer->thisID() == (*it)->thisID()) {
|
||||
delete *it;
|
||||
timerList->_timers.erase(it);
|
||||
|
||||
break;
|
||||
|
@ -1825,6 +1826,7 @@ void GameObject::removeTimer(TimerID id) {
|
|||
if ((timerList = fetchTimerList(this)) != nullptr) {
|
||||
for (Common::List<Timer *>::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it) {
|
||||
if ((*it)->thisID() == id) {
|
||||
delete *it;
|
||||
timerList->_timers.erase(it);
|
||||
|
||||
if (timerList->_timers.empty())
|
||||
|
|
|
@ -111,7 +111,11 @@ TimerList *fetchTimerList(GameObject *obj) {
|
|||
//----------------------------------------------------------------------
|
||||
// Check all active Timers
|
||||
void checkTimers(void) {
|
||||
for (Common::List<Timer *>::iterator it = g_vm->_timers.begin(); it != g_vm->_timers.end(); ++it) {
|
||||
Common::List<Timer *>::iterator nextIt;
|
||||
|
||||
for (Common::List<Timer *>::iterator it = g_vm->_timers.begin(); it != g_vm->_timers.end(); it = nextIt) {
|
||||
nextIt = it;
|
||||
nextIt++;
|
||||
if ((*it)->check()) {
|
||||
debugC(2, kDebugTimers, "Timer tick for %p (%s): %p (duration %d)", (void *)(*it)->getObject(), (*it)->getObject()->objName(), (void *)(*it), (*it)->getInterval());
|
||||
(*it)->reset();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue