diff options
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/videoplayer.cpp | 35 | ||||
-rw-r--r-- | engines/gob/videoplayer.h | 2 |
2 files changed, 27 insertions, 10 deletions
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index c435136b75..f421646ee2 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -348,15 +348,30 @@ int VideoPlayer::slotOpen(const char *videoFile, Type which) { video->getVideo()->setVideoMemory(); video->getVideo()->enableSound(*_vm->_mixer); - _videoSlots.push_back(video); + int slot = getNextFreeSlot(); + + _videoSlots[slot] = video; WRITE_VAR(7, video->getVideo()->getFramesCount()); - return _videoSlots.size() - 1; + return slot; +} + +int VideoPlayer::getNextFreeSlot() { + uint slot; + + for (slot = 0; slot < _videoSlots.size(); slot++) + if (!_videoSlots[slot]) + break; + + if (slot == _videoSlots.size()) + _videoSlots.push_back(0); + + return slot; } void VideoPlayer::slotPlay(int slot, int16 frame) { - if ((slot < 0) || (((uint) slot) >= _videoSlots.size())) + if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot]) return; CoktelVideo &video = *(_videoSlots[slot]->getVideo()); @@ -377,18 +392,18 @@ void VideoPlayer::slotPlay(int slot, int16 frame) { } void VideoPlayer::slotClose(int slot) { - if ((slot < 0) || (((uint) slot) >= _videoSlots.size())) + if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot]) return; delete _videoSlots[slot]; - _videoSlots.remove_at(slot); + _videoSlots[slot] = 0; } void VideoPlayer::slotCopyFrame(int slot, byte *dest, uint16 left, uint16 top, uint16 width, uint16 height, uint16 x, uint16 y, uint16 pitch, int16 transp) { - if ((slot < 0) || (((uint) slot) >= _videoSlots.size())) + if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot]) return; _videoSlots[slot]->getVideo()->copyCurrentFrame(dest, @@ -396,14 +411,14 @@ void VideoPlayer::slotCopyFrame(int slot, byte *dest, } void VideoPlayer::slotCopyPalette(int slot, int16 palStart, int16 palEnd) { - if ((slot < 0) || (((uint) slot) >= _videoSlots.size())) + if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot]) return; copyPalette(*(_videoSlots[slot]->getVideo()), palStart, palEnd); } void VideoPlayer::slotWaitEndFrame(int slot, bool onlySound) { - if ((slot < 0) || (((uint) slot) >= _videoSlots.size())) + if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot]) return; CoktelVideo &video = *(_videoSlots[slot]->getVideo()); @@ -413,7 +428,7 @@ void VideoPlayer::slotWaitEndFrame(int slot, bool onlySound) { } bool VideoPlayer::slotIsOpen(int slot) const { - if ((slot >= 0) && (((uint) slot) < _videoSlots.size())) + if ((slot >= 0) && (((uint) slot) < _videoSlots.size()) && _videoSlots[slot]) return true; return false; @@ -423,7 +438,7 @@ const VideoPlayer::Video *VideoPlayer::getVideoBySlot(int slot) const { if (slot < 0) { if (_primaryVideo->isOpen()) return _primaryVideo; - } else if (((uint) slot) < _videoSlots.size()) + } else if (((uint) slot) < _videoSlots.size() && _videoSlots[slot]) return _videoSlots[slot]; return 0; diff --git a/engines/gob/videoplayer.h b/engines/gob/videoplayer.h index 29531f7ce2..278045b9e5 100644 --- a/engines/gob/videoplayer.h +++ b/engines/gob/videoplayer.h @@ -128,6 +128,8 @@ private: const Video *getVideoBySlot(int slot = -1) const; + int getNextFreeSlot(); + void copyPalette(CoktelVideo &video, int16 palStart = -1, int16 palEnd = -1); bool doPlay(int16 frame, int16 breakKey, uint16 palCmd, int16 palStart, int16 palEnd, |