From 6ea39711e1ca103726f85afd31acd64a8a2c0b4e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 13 Dec 2013 02:52:37 +0200 Subject: FULLPIPE: Fix crash in MessageQueue::calcDuration(). Some cleanup --- engines/fullpipe/messages.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'engines/fullpipe/messages.cpp') diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp index 742b023ec3..8ed99fce15 100644 --- a/engines/fullpipe/messages.cpp +++ b/engines/fullpipe/messages.cpp @@ -309,7 +309,7 @@ void MessageQueue::update() { if (_counter > 0) _counter--; - if (_exCommands.size()) { + if (getCount()) { sendNextCommand(); } else if (_counter == 0) { _isFinished = 1; @@ -331,7 +331,7 @@ void MessageQueue::addExCommandToEnd(ExCommand *ex) { } ExCommand *MessageQueue::getExCommandByIndex(uint idx) { - if (idx > _exCommands.size()) + if (idx > getCount()) return 0; Common::List::iterator it = _exCommands.begin(); @@ -345,7 +345,7 @@ ExCommand *MessageQueue::getExCommandByIndex(uint idx) { } void MessageQueue::deleteExCommandByIndex(uint idx, bool doFree) { - if (idx > _exCommands.size()) + if (idx > getCount()) return; Common::List::iterator it = _exCommands.begin(); @@ -369,7 +369,7 @@ void MessageQueue::transferExCommands(MessageQueue *mq) { } void MessageQueue::sendNextCommand() { - if (_exCommands.size()) { + if (getCount()) { if (!(_flags & 4) && (_flags & 1)) { messageQueueCallback1(16); } @@ -496,7 +496,8 @@ int MessageQueue::calcDuration(StaticANIObject *obj) { ExCommand *ex; Movement *mov; - for (uint i = 0; (ex = getExCommandByIndex(i)); i++) { + for (uint i = 0; i < getCount(); i++) { + ex = getExCommandByIndex(i); if (ex->_parentId == obj->_id) { if (ex->_messageKind == 1 || ex->_messageKind == 20) { if ((mov = obj->getMovementById(ex->_messageNum)) != 0) { @@ -513,7 +514,7 @@ int MessageQueue::calcDuration(StaticANIObject *obj) { } void MessageQueue::changeParam28ForObjectId(int objId, int oldParam28, int newParam28) { - for (uint i = 0; i < _exCommands.size(); i++) { + for (uint i = 0; i < getCount(); i++) { ExCommand *ex = getExCommandByIndex(i); int k = ex->_messageKind; -- cgit v1.2.3