aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Hoops2012-04-06 19:18:41 -0400
committerMatthew Hoops2012-04-06 19:18:41 -0400
commita2454f6563d2a7e7eadb15668e8f2ff76a4a0a28 (patch)
tree98e66ac6c5810c922f4adbe7343961bfd0ed42d1 /engines
parentb07d03dedfdd842a1b55178c5c38a357ae4518c8 (diff)
downloadscummvm-rg350-a2454f6563d2a7e7eadb15668e8f2ff76a4a0a28.tar.gz
scummvm-rg350-a2454f6563d2a7e7eadb15668e8f2ff76a4a0a28.tar.bz2
scummvm-rg350-a2454f6563d2a7e7eadb15668e8f2ff76a4a0a28.zip
PEGASUS: Use an Array instead of a List for NotificationReceivers
Fixes occasional crashes with the norad sub controls. CodeWarrior's iterators used indices unlike our List iterators, thus necessitating the change here.
Diffstat (limited to 'engines')
-rw-r--r--engines/pegasus/notification.cpp26
-rw-r--r--engines/pegasus/notification.h3
2 files changed, 15 insertions, 14 deletions
diff --git a/engines/pegasus/notification.cpp b/engines/pegasus/notification.cpp
index 91a876cb67..4179afa70d 100644
--- a/engines/pegasus/notification.cpp
+++ b/engines/pegasus/notification.cpp
@@ -38,8 +38,8 @@ Notification::Notification(const NotificationID id, NotificationManager *owner)
}
Notification::~Notification() {
- for (ReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
- it->receiver->newNotification(NULL);
+ for (uint i = 0; i < _receivers.size(); i++)
+ _receivers[i].receiver->newNotification(NULL);
if (_owner)
_owner->removeNotification(this);
@@ -49,9 +49,9 @@ Notification::~Notification() {
// Wherever mask is 0, leave existing bits untouched.
// Wherever mask is 1, set bit equivalent to flags.
void Notification::notifyMe(NotificationReceiver *receiver, NotificationFlags flags, NotificationFlags mask) {
- for (ReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++) {
- if (it->receiver == receiver) {
- it->mask = (it->mask & ~mask) | (flags & mask);
+ for (uint i = 0; i < _receivers.size(); i++) {
+ if (_receivers[i].receiver == receiver) {
+ _receivers[i].mask = (_receivers[i].mask & ~mask) | (flags & mask);
receiver->newNotification(this);
return;
}
@@ -66,11 +66,11 @@ void Notification::notifyMe(NotificationReceiver *receiver, NotificationFlags fl
}
void Notification::cancelNotification(NotificationReceiver *receiver) {
- for (ReceiverIterator it = _receivers.begin(); it != _receivers.end();) {
- if (it->receiver == receiver)
- it = _receivers.erase(it);
- else
- it++;
+ for (uint i = 0; i < _receivers.size(); i++) {
+ if (_receivers[i].receiver == receiver) {
+ _receivers.remove_at(i);
+ i--;
+ }
}
}
@@ -82,9 +82,9 @@ void Notification::checkReceivers() {
NotificationFlags currentFlags = _currentFlags;
_currentFlags = kNoNotificationFlags;
- for (ReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
- if (it->mask & currentFlags)
- it->receiver->receiveNotification(this, currentFlags);
+ for (uint i = 0; i < _receivers.size(); i++)
+ if (_receivers[i].mask & currentFlags)
+ _receivers[i].receiver->receiveNotification(this, currentFlags);
}
// Receiver entries are equal if their receivers are equal.
diff --git a/engines/pegasus/notification.h b/engines/pegasus/notification.h
index 142bf8c06d..e795a4b375 100644
--- a/engines/pegasus/notification.h
+++ b/engines/pegasus/notification.h
@@ -26,6 +26,7 @@
#ifndef PEGASUS_NOTIFICATION_H
#define PEGASUS_NOTIFICATION_H
+#include "common/array.h"
#include "common/list.h"
#include "pegasus/types.h"
@@ -44,7 +45,7 @@ struct ReceiverEntry {
int operator==(const ReceiverEntry &entry1, const ReceiverEntry &entry2);
int operator!=(const ReceiverEntry &entry1, const ReceiverEntry &entry2);
-typedef Common::List<ReceiverEntry> ReceiverList;
+typedef Common::Array<ReceiverEntry> ReceiverList;
/*
A notification can have 32 flags associated with it, which can be user-defined.