aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/saga/actor.cpp4
-rw-r--r--engines/saga/events.cpp31
-rw-r--r--engines/saga/font.h2
-rw-r--r--engines/saga/scene.cpp10
-rw-r--r--engines/saga/script.h2
-rw-r--r--engines/saga/sfuncs.cpp2
-rw-r--r--engines/saga/sthread.cpp93
7 files changed, 64 insertions, 80 deletions
diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp
index 8ad719e540..d52aac8b92 100644
--- a/engines/saga/actor.cpp
+++ b/engines/saga/actor.cpp
@@ -944,7 +944,7 @@ uint16 Actor::hitTest(const Point &testPoint, bool skipProtagonist) {
createDrawOrderList();
for (drawOrderIterator = _drawOrderList.begin(); drawOrderIterator != _drawOrderList.end(); ++drawOrderIterator) {
- drawObject = drawOrderIterator.operator*();
+ drawObject = *drawOrderIterator;
if (skipProtagonist && (drawObject == _protagonist)) {
continue;
}
@@ -1070,7 +1070,7 @@ void Actor::drawActors() {
createDrawOrderList();
for (drawOrderIterator = _drawOrderList.begin(); drawOrderIterator != _drawOrderList.end(); ++drawOrderIterator) {
- drawObject = drawOrderIterator.operator*();
+ drawObject = *drawOrderIterator;
if (!getSpriteParams(drawObject, frameNumber, spriteList)) {
continue;
diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp
index cea1d771d7..99eb200f0f 100644
--- a/engines/saga/events.cpp
+++ b/engines/saga/events.cpp
@@ -56,8 +56,6 @@ Events::~Events(void) {
// First advances event times, then processes each event with the appropriate
// handler depending on the type of event.
int Events::handleEvents(long msec) {
- Event *event_p;
-
long delta_time;
int result;
@@ -66,7 +64,7 @@ int Events::handleEvents(long msec) {
// Process each event in list
for (EventList::iterator eventi = _eventList.begin(); eventi != _eventList.end(); ++eventi) {
- event_p = (Event *)eventi.operator->();
+ Event *event_p = &*eventi;
// Call the appropriate event handler for the specific event type
switch (event_p->type) {
@@ -582,7 +580,7 @@ int Events::handleInterval(Event *event) {
Event *Events::queue(Event *event) {
Event *queuedEvent;
- queuedEvent = _eventList.pushBack(*event).operator->();
+ queuedEvent = &*_eventList.pushBack(*event);
initializeEvent(queuedEvent);
return queuedEvent;
@@ -628,25 +626,23 @@ int Events::initializeEvent(Event *event) {
int Events::clearList(bool playQueuedMusic) {
Event *chain_walk;
Event *next_chain;
- Event *event_p;
// Walk down event list
for (EventList::iterator eventi = _eventList.begin(); eventi != _eventList.end(); ++eventi) {
- event_p = (Event *)eventi.operator->();
// Only remove events not marked kEvFNoDestory (engine events)
- if (!(event_p->code & kEvFNoDestory)) {
+ if (!(eventi->code & kEvFNoDestory)) {
// Handle queued music change events before deleting them
// This can happen in IHNM by music events set by sfQueueMusic()
// Fixes bug #2057987 - "IHNM: Music stops in Ellen's chapter"
- if (playQueuedMusic && ((event_p->code & EVENT_MASK) == kMusicEvent)) {
+ if (playQueuedMusic && ((eventi->code & EVENT_MASK) == kMusicEvent)) {
_vm->_music->stop();
- if (event_p->op == kEventPlay)
- _vm->_music->play(event_p->param, (MusicFlags)event_p->param2);
+ if (eventi->op == kEventPlay)
+ _vm->_music->play(eventi->param, (MusicFlags)eventi->param2);
}
// Remove any events chained off this one
- for (chain_walk = event_p->chain; chain_walk != NULL; chain_walk = next_chain) {
+ for (chain_walk = eventi->chain; chain_walk != NULL; chain_walk = next_chain) {
next_chain = chain_walk->chain;
free(chain_walk);
}
@@ -661,19 +657,17 @@ int Events::clearList(bool playQueuedMusic) {
int Events::freeList() {
Event *chain_walk;
Event *next_chain;
- Event *event_p;
// Walk down event list
EventList::iterator eventi = _eventList.begin();
while (eventi != _eventList.end()) {
- event_p = (Event *)eventi.operator->();
// Remove any events chained off this one */
- for (chain_walk = event_p->chain; chain_walk != NULL; chain_walk = next_chain) {
+ for (chain_walk = eventi->chain; chain_walk != NULL; chain_walk = next_chain) {
next_chain = chain_walk->chain;
free(chain_walk);
}
- eventi=_eventList.erase(eventi);
+ eventi = _eventList.erase(eventi);
}
return SUCCESS;
@@ -681,16 +675,13 @@ int Events::freeList() {
// Walks down the event list, updating event times by 'msec'.
int Events::processEventTime(long msec) {
- Event *event_p;
uint16 event_count = 0;
for (EventList::iterator eventi = _eventList.begin(); eventi != _eventList.end(); ++eventi) {
- event_p = (Event *)eventi.operator->();
-
- event_p->time -= msec;
+ eventi->time -= msec;
event_count++;
- if (event_p->type == kEvTImmediate)
+ if (eventi->type == kEvTImmediate)
break;
if (event_count > EVENT_WARNINGCOUNT) {
diff --git a/engines/saga/font.h b/engines/saga/font.h
index c14d7a8b75..84a1ec70ba 100644
--- a/engines/saga/font.h
+++ b/engines/saga/font.h
@@ -94,7 +94,7 @@ class TextList: public SortedList<TextListEntry> {
public:
TextListEntry *addEntry(const TextListEntry &entry) {
- return pushBack(entry).operator->();
+ return &*pushBack(entry);
}
};
diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp
index 86500467d0..03d1726b27 100644
--- a/engines/saga/scene.cpp
+++ b/engines/saga/scene.cpp
@@ -252,10 +252,8 @@ void Scene::getResourceTypes(SAGAResourceTypes *&types, int &typesCount) {
}
void Scene::drawTextList() {
- TextListEntry *entry;
+ for (TextList::iterator entry = _textList.begin(); entry != _textList.end(); ++entry) {
- for (TextList::iterator textIterator = _textList.begin(); textIterator != _textList.end(); ++textIterator) {
- entry = (TextListEntry *)textIterator.operator->();
if (entry->display) {
if (entry->useRect) {
@@ -317,7 +315,7 @@ void Scene::startScene() {
return;
}
- sceneQueue = queueIterator.operator->();
+ sceneQueue = &*queueIterator;
loadScene(sceneQueue);
}
@@ -378,7 +376,7 @@ void Scene::nextScene() {
}
// Load the head in scene queue
- sceneQueue = queueIterator.operator->();
+ sceneQueue = &*queueIterator;
loadScene(sceneQueue);
}
@@ -405,7 +403,7 @@ void Scene::skipScene() {
++queueIterator;
while (queueIterator != _sceneQueue.end()) {
- sceneQueue = queueIterator.operator->();
+ sceneQueue = &*queueIterator;
assert(sceneQueue != NULL);
if (sceneQueue->sceneSkipTarget) {
diff --git a/engines/saga/script.h b/engines/saga/script.h
index 1b5b127d45..3061a31bb3 100644
--- a/engines/saga/script.h
+++ b/engines/saga/script.h
@@ -398,7 +398,7 @@ protected:
void loadModuleBase(ModuleData &module, const byte *resourcePointer, size_t resourceLength);
// runThread returns true if we should break running of other threads
- bool runThread(ScriptThread *thread);
+ bool runThread(ScriptThread &thread);
void setThreadEntrypoint(ScriptThread *thread, int entrypointNumber);
public:
diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp
index 9d298818cd..8c09934ad2 100644
--- a/engines/saga/sfuncs.cpp
+++ b/engines/saga/sfuncs.cpp
@@ -399,7 +399,7 @@ void Script::sfKillActorThreads(SCRIPTFUNC_PARAMS) {
int16 actorId = thread->pop();
for (threadIterator = _threadList.begin(); threadIterator != _threadList.end(); ++threadIterator) {
- anotherThread = threadIterator.operator->();
+ anotherThread = &*threadIterator;
if ((anotherThread != thread) && (anotherThread->_threadVars[kThreadVarActor] == actorId)) {
anotherThread->_flags &= ~kTFlagWaiting;
anotherThread->_flags |= kTFlagAborted;
diff --git a/engines/saga/sthread.cpp b/engines/saga/sthread.cpp
index 3dc6bd57d2..70a73038a9 100644
--- a/engines/saga/sthread.cpp
+++ b/engines/saga/sthread.cpp
@@ -45,10 +45,10 @@ ScriptThread *Script::createThread(uint16 scriptModuleNumber, uint16 scriptEntry
error("Script::createThread wrong scriptEntryPointNumber");
}
- newThread = _threadList.pushFront().operator->();
+ newThread = &(*_threadList.pushFront());
newThread->_flags = kTFlagNone;
newThread->_stackSize = DEFAULT_THREAD_STACK_SIZE;
- newThread->_stackBuf = (uint16 *)malloc(newThread->_stackSize * sizeof(*newThread->_stackBuf));
+ newThread->_stackBuf = (uint16 *)malloc(newThread->_stackSize * sizeof(uint16));
newThread->_stackTopIndex = newThread->_stackSize - 2;
newThread->_instructionOffset = _modules[scriptModuleNumber].entryPoints[scriptEntryPointNumber].offset;
newThread->_commonBase = _commonBuffer;
@@ -67,44 +67,40 @@ ScriptThread *Script::createThread(uint16 scriptModuleNumber, uint16 scriptEntry
}
void Script::wakeUpActorThread(int waitType, void *threadObj) {
- ScriptThread *thread;
ScriptThreadList::iterator threadIterator;
for (threadIterator = _threadList.begin(); threadIterator != _threadList.end(); ++threadIterator) {
- thread = threadIterator.operator->();
- if ((thread->_flags & kTFlagWaiting) && (thread->_waitType == waitType) && (thread->_threadObj == threadObj)) {
- thread->_flags &= ~kTFlagWaiting;
+ ScriptThread &thread = *threadIterator;
+ if ((thread._flags & kTFlagWaiting) && (thread._waitType == waitType) && (thread._threadObj == threadObj)) {
+ thread._flags &= ~kTFlagWaiting;
}
}
}
void Script::wakeUpThreads(int waitType) {
- ScriptThread *thread;
ScriptThreadList::iterator threadIterator;
for (threadIterator = _threadList.begin(); threadIterator != _threadList.end(); ++threadIterator) {
- thread = threadIterator.operator->();
- if ((thread->_flags & kTFlagWaiting) && (thread->_waitType == waitType)) {
- thread->_flags &= ~kTFlagWaiting;
+ ScriptThread &thread = *threadIterator;
+ if ((thread._flags & kTFlagWaiting) && (thread._waitType == waitType)) {
+ thread._flags &= ~kTFlagWaiting;
}
}
}
void Script::wakeUpThreadsDelayed(int waitType, int sleepTime) {
- ScriptThread *thread;
ScriptThreadList::iterator threadIterator;
for (threadIterator = _threadList.begin(); threadIterator != _threadList.end(); ++threadIterator) {
- thread = threadIterator.operator->();
- if ((thread->_flags & kTFlagWaiting) && (thread->_waitType == waitType)) {
- thread->_waitType = kWaitTypeDelay;
- thread->_sleepTime = sleepTime;
+ ScriptThread &thread = *threadIterator;
+ if ((thread._flags & kTFlagWaiting) && (thread._waitType == waitType)) {
+ thread._waitType = kWaitTypeDelay;
+ thread._sleepTime = sleepTime;
}
}
}
void Script::executeThreads(uint msec) {
- ScriptThread *thread;
ScriptThreadList::iterator threadIterator;
if (_vm->_interface->_statusTextInput) {
@@ -114,15 +110,15 @@ void Script::executeThreads(uint msec) {
threadIterator = _threadList.begin();
while (threadIterator != _threadList.end()) {
- thread = threadIterator.operator->();
+ ScriptThread &thread = *threadIterator;
- if (thread->_flags & (kTFlagFinished | kTFlagAborted)) {
- if (thread->_flags & kTFlagFinished)
+ if (thread._flags & (kTFlagFinished | kTFlagAborted)) {
+ if (thread._flags & kTFlagFinished)
setPointerVerb();
if (_vm->getGameId() == GID_IHNM) {
- thread->_flags &= ~kTFlagFinished;
- thread->_flags |= kTFlagAborted;
+ thread._flags &= ~kTFlagFinished;
+ thread._flags |= kTFlagAborted;
++threadIterator;
} else {
threadIterator = _threadList.erase(threadIterator);
@@ -130,38 +126,38 @@ void Script::executeThreads(uint msec) {
continue;
}
- if (thread->_flags & kTFlagWaiting) {
+ if (thread._flags & kTFlagWaiting) {
- switch (thread->_waitType) {
+ switch (thread._waitType) {
case kWaitTypeDelay:
- if (thread->_sleepTime < msec) {
- thread->_sleepTime = 0;
+ if (thread._sleepTime < msec) {
+ thread._sleepTime = 0;
} else {
- thread->_sleepTime -= msec;
+ thread._sleepTime -= msec;
}
- if (thread->_sleepTime == 0)
- thread->_flags &= ~kTFlagWaiting;
+ if (thread._sleepTime == 0)
+ thread._flags &= ~kTFlagWaiting;
break;
case kWaitTypeWalk:
{
ActorData *actor;
- actor = (ActorData *)thread->_threadObj;
+ actor = (ActorData *)thread._threadObj;
if (actor->_currentAction == kActionWait) {
- thread->_flags &= ~kTFlagWaiting;
+ thread._flags &= ~kTFlagWaiting;
}
}
break;
case kWaitTypeWaitFrames: // IHNM
- if (thread->_frameWait < _vm->_frameCount)
- thread->_flags &= ~kTFlagWaiting;
+ if (thread._frameWait < _vm->_frameCount)
+ thread._flags &= ~kTFlagWaiting;
break;
}
}
- if (!(thread->_flags & kTFlagWaiting)) {
+ if (!(thread._flags & kTFlagWaiting)) {
if (runThread(thread)) {
break;
}
@@ -173,14 +169,13 @@ void Script::executeThreads(uint msec) {
}
void Script::abortAllThreads(void) {
- ScriptThread *thread;
ScriptThreadList::iterator threadIterator;
threadIterator = _threadList.begin();
while (threadIterator != _threadList.end()) {
- thread = threadIterator.operator->();
- thread->_flags |= kTFlagAborted;
+ ScriptThread &thread = *threadIterator;
+ thread._flags |= kTFlagAborted;
++threadIterator;
}
executeThreads(0);
@@ -193,44 +188,44 @@ void Script::completeThread(void) {
executeThreads(0);
}
-bool Script::runThread(ScriptThread *thread) {
+bool Script::runThread(ScriptThread &thread) {
uint16 savedInstructionOffset;
bool stopParsing = false;
bool breakOut = false;
int operandChar;
- MemoryReadStream scriptS(thread->_moduleBase, thread->_moduleBaseSize);
+ MemoryReadStream scriptS(thread._moduleBase, thread._moduleBaseSize);
- scriptS.seek(thread->_instructionOffset);
+ scriptS.seek(thread._instructionOffset);
for (uint instructionCount = 0; instructionCount < STHREAD_TIMESLICE; instructionCount++) {
- if (thread->_flags & (kTFlagAsleep))
+ if (thread._flags & (kTFlagAsleep))
break;
- savedInstructionOffset = thread->_instructionOffset;
+ savedInstructionOffset = thread._instructionOffset;
operandChar = scriptS.readByte();
- debug(8, "Executing thread offset: %u (%x) stack: %d", thread->_instructionOffset, operandChar, thread->pushedSize());
+ debug(8, "Executing thread offset: %u (%x) stack: %d", thread._instructionOffset, operandChar, thread.pushedSize());
stopParsing = false;
debug(4, "Calling op %s", this->_scriptOpsList[operandChar].scriptOpName);
- (this->*_scriptOpsList[operandChar].scriptOp)(thread, &scriptS, stopParsing, breakOut);
+ (this->*_scriptOpsList[operandChar].scriptOp)(&thread, &scriptS, stopParsing, breakOut);
if (stopParsing)
return breakOut;
- if (thread->_flags & (kTFlagFinished | kTFlagAborted)) {
- error("Wrong flags %d in thread", thread->_flags);
+ if (thread._flags & (kTFlagFinished | kTFlagAborted)) {
+ error("Wrong flags %d in thread", thread._flags);
}
// Set instruction offset only if a previous instruction didn't branch
- if (savedInstructionOffset == thread->_instructionOffset) {
- thread->_instructionOffset = scriptS.pos();
+ if (savedInstructionOffset == thread._instructionOffset) {
+ thread._instructionOffset = scriptS.pos();
} else {
- if (thread->_instructionOffset >= scriptS.size()) {
+ if (thread._instructionOffset >= scriptS.size()) {
error("Script::runThread() Out of range script execution");
}
- scriptS.seek(thread->_instructionOffset);
+ scriptS.seek(thread._instructionOffset);
}
if (breakOut)