[Scummvm-git-logs] scummvm master -> 062001095e2114cd4ed2f6ca7a796b94a822effa
sev-
noreply at scummvm.org
Thu Oct 9 19:18:51 UTC 2025
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
c3fe29f515 DIRECTOR: Fix Movie::processEvent, memory leaks on exit
d7d295ef26 DIRECTOR: LINGO: Only add window to the windowList if it's new
8947767f54 DIRECTOR: LINGO: Make the keyPress return testable output for arrow keys
7218a92eb7 DIRECTOR: LINGO: Improve accuracy of b_findPosNear
300c783c66 DIRECTOR: Treat invalid palette ID in score same as null
062001095e DIRECTOR: LINGO: Improve accuracy of b_importFileInto
Commit: c3fe29f515b833e561bd95331b4494929aba32be
https://github.com/scummvm/scummvm/commit/c3fe29f515b833e561bd95331b4494929aba32be
Author: Scott Percival (code at moral.net.au)
Date: 2025-10-09T21:18:44+02:00
Commit Message:
DIRECTOR: Fix Movie::processEvent, memory leaks on exit
This reverts commit b97c82b200a8d2dd81fa9089d83cf5025ba73717.
Changed paths:
engines/director/channel.cpp
engines/director/director.cpp
engines/director/director.h
engines/director/lingo/lingo-events.cpp
engines/director/lingo/lingo.cpp
engines/director/window.cpp
engines/director/window.h
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 17a4f5abfd0..ee69f480077 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -104,10 +104,7 @@ Channel& Channel::operator=(const Channel &channel) {
Channel::~Channel() {
if (_widget) {
- if (dynamic_cast<Graphics::MacWindow *>(_widget))
- g_director->_wm->removeWindow((Graphics::MacWindow *)_widget);
- else
- delete _widget;
+ delete _widget;
}
if (_mask)
@@ -663,11 +660,7 @@ void Channel::replaceWidget(CastMemberID previousCastId, bool force) {
}
if (_widget) {
- // Check if _widget is of type window, in which case we need to remove it from the window manager
- if (dynamic_cast<Graphics::MacWindow *>(_widget))
- g_director->_wm->removeWindow((Graphics::MacWindow *)_widget);
- else
- delete _widget;
+ delete _widget;
_widget = nullptr;
}
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index e028d276526..3f120db4bdf 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -86,7 +86,6 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
_mainArchive = nullptr;
_currentWindow = nullptr;
_cursorWindow = nullptr;
- _windowToBeActive = nullptr;
_lingo = nullptr;
_clipBoard = nullptr;
_fixStageSize = false;
@@ -168,26 +167,28 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
}
DirectorEngine::~DirectorEngine() {
+ delete _lingo;
+
+ clearPalettes();
+
for (auto &it : _windowList) {
it->decRefCount();
}
- if (_windowToBeActive) {
- _windowToBeActive->decRefCount();
- _windowToBeActive = nullptr;
+ _stage->decRefCount();
+ _stage = nullptr;
+ if (_currentWindow) {
+ _currentWindow->decRefCount();
+ _currentWindow = nullptr;
}
- delete _lingo;
delete _wm;
- delete _surface;
- delete _primitives;
-
for (auto &it : _allSeenResFiles) {
delete it._value;
}
-
for (uint i = 0; i < _winCursor.size(); i++)
delete _winCursor[i];
- clearPalettes();
+ delete _surface;
+ delete _primitives;
}
Movie *DirectorEngine::getCurrentMovie() const { return _currentWindow->getCurrentMovie(); }
@@ -238,18 +239,6 @@ void DirectorEngine::setCurrentWindow(Window *window) {
_currentWindow->incRefCount();
}
-void DirectorEngine::setWindowToBeActive(Window *window) {
- if (_windowToBeActive == window)
- return;
- if (window)
- window->incRefCount();
- if (_windowToBeActive) {
- _windowToBeActive->decRefCount();
- _windowToBeActive = nullptr;
- }
- _windowToBeActive = window;
-}
-
void DirectorEngine::setVersion(uint16 version) {
if (version == _version)
return;
@@ -308,7 +297,7 @@ Common::Error DirectorEngine::run() {
debugC(1, kDebugImages, "Director pixelformat is: %s", _pixelformat.toString().c_str());
_stage = new Window(_wm->getNextId(), false, false, false, _wm, this, true);
- *_stage->_refCount += 1;
+ _stage->incRefCount();
// Set this as background so it doesn't come to foreground when multiple windows present
_wm->setBackgroundWindow(_stage->getMacWindow());
@@ -379,13 +368,6 @@ Common::Error DirectorEngine::run() {
}
draw();
-
- if (_windowToBeActive) {
- setCurrentWindow(_windowToBeActive);
- _windowToBeActive->decRefCount();
- _windowToBeActive = nullptr;
- }
-
while (!_windowsToForget.empty()) {
Window *window = _windowsToForget.back();
_windowsToForget.pop_back();
diff --git a/engines/director/director.h b/engines/director/director.h
index 1187b6d73c8..120e68900df 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -181,7 +181,6 @@ public:
Window *getOrCreateWindow(Common::String &name);
void forgetWindow(Window *window);
void setCurrentWindow(Window *window);
- void setWindowToBeActive(Window *window);
Window *getCursorWindow() const { return _cursorWindow; }
void setCursorWindow(Window *window) { _cursorWindow = window; }
Movie *getCurrentMovie() const;
@@ -319,7 +318,6 @@ private:
Common::Array<Window *> _windowsToForget;
Window *_currentWindow;
Window *_cursorWindow;
- Window *_windowToBeActive;
Graphics::MacPatterns _director3Patterns;
Graphics::MacPatterns _director3QuickDrawPatterns;
diff --git a/engines/director/lingo/lingo-events.cpp b/engines/director/lingo/lingo-events.cpp
index 9c81c9da334..ce8b119a45b 100644
--- a/engines/director/lingo/lingo-events.cpp
+++ b/engines/director/lingo/lingo-events.cpp
@@ -615,7 +615,7 @@ void Movie::queueInputEvent(LEvent event, int targetId, Common::Point pos) {
void Movie::processEvent(LEvent event, int targetId) {
Common::Queue<LingoEvent> queue;
queueEvent(queue, event, targetId);
- _vm->setWindowToBeActive(this->getWindow());
+ _vm->setCurrentWindow(this->getWindow());
_lingo->processEvents(queue, false);
}
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index a6984f7b2a7..35ac88ed4df 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -232,6 +232,9 @@ Lingo::~Lingo() {
for (auto &it : _openXLibsState) {
delete it._value;
}
+ for (auto &it : _openXtrasState) {
+ delete it._value;
+ }
}
void Lingo::reloadBuiltIns() {
diff --git a/engines/director/window.cpp b/engines/director/window.cpp
index 9c0f6264c9d..0c587b2fe25 100644
--- a/engines/director/window.cpp
+++ b/engines/director/window.cpp
@@ -89,14 +89,9 @@ Window::~Window() {
delete _frozenLingoStates[i];
if (_puppetTransition)
delete _puppetTransition;
-}
-
-void Window::decRefCount() {
- *_refCount -= 1;
- if (*_refCount <= 0) {
- g_director->_wm->removeWindow(_window);
- g_director->_wm->removeMarked();
- }
+ g_director->_wm->removeWindow(_window);
+ g_director->_wm->removeMarked();
+ _window = nullptr;
}
void Window::invertChannel(Channel *channel, const Common::Rect &destRect) {
diff --git a/engines/director/window.h b/engines/director/window.h
index 0de1e663977..af371c39aae 100644
--- a/engines/director/window.h
+++ b/engines/director/window.h
@@ -108,7 +108,6 @@ public:
Window(int id, bool scrollable, bool resizable, bool editable, Graphics::MacWindowManager *wm, DirectorEngine *vm, bool isStage);
~Window();
- void decRefCount() override;
bool render(bool forceRedraw = false, Graphics::ManagedSurface *blitTo = nullptr);
void invertChannel(Channel *channel, const Common::Rect &destRect);
Commit: d7d295ef26ee85a41829082af35bc5d870d329e9
https://github.com/scummvm/scummvm/commit/d7d295ef26ee85a41829082af35bc5d870d329e9
Author: Scott Percival (code at moral.net.au)
Date: 2025-10-09T21:18:44+02:00
Commit Message:
DIRECTOR: LINGO: Only add window to the windowList if it's new
Fixes loss of mouse input when closing the help popup in pingu1.
Changed paths:
engines/director/lingo/lingo-builtins.cpp
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index e6b88e76020..08ad8f156ca 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -4004,7 +4004,15 @@ void LB::b_window(int nargs) {
Common::String windowName = d.asString();
Window *window = g_director->getOrCreateWindow(windowName);
- windowList->arr.push_back(Datum(window));
+ bool isNewWindow = true;
+ for (auto &it : windowList->arr) {
+ if (it.type == OBJECT && it.u.obj == window) {
+ isNewWindow = false;
+ break;
+ }
+ }
+ if (isNewWindow)
+ windowList->arr.push_back(Datum(window));
g_lingo->push(window);
}
Commit: 8947767f5414936e3dedb1ec1371928c1a307550
https://github.com/scummvm/scummvm/commit/8947767f5414936e3dedb1ec1371928c1a307550
Author: Scott Percival (code at moral.net.au)
Date: 2025-10-09T21:18:44+02:00
Commit Message:
DIRECTOR: LINGO: Make the keyPress return testable output for arrow keys
Fixes keyboard movement for the ice flow minigame in pingu1.
Changed paths:
engines/director/events.cpp
diff --git a/engines/director/events.cpp b/engines/director/events.cpp
index 9983b921608..94d1578624a 100644
--- a/engines/director/events.cpp
+++ b/engines/director/events.cpp
@@ -20,6 +20,7 @@
*/
#include "common/events.h"
+#include "common/keyboard.h"
#include "common/system.h"
#include "common/translation.h"
@@ -308,6 +309,24 @@ bool Movie::processEvent(Common::Event &event) {
case Common::EVENT_KEYDOWN:
_keyCode = _vm->_KeyCodes.contains(event.kbd.keycode) ? _vm->_KeyCodes[event.kbd.keycode] : 0;
_key = event.kbd.ascii;
+ // While most non-letter keys don't affect "the keyPress", there
+ // are some that do and (sadly) we have to account for that.
+ switch (event.kbd.keycode) {
+ case Common::KEYCODE_LEFT:
+ _key = 28;
+ break;
+ case Common::KEYCODE_RIGHT:
+ _key = 29;
+ break;
+ case Common::KEYCODE_UP:
+ _key = 30;
+ break;
+ case Common::KEYCODE_DOWN:
+ _key = 31;
+ break;
+ default:
+ break;
+ }
_keyFlags = event.kbd.flags;
if (event.kbd.keycode == Common::KEYCODE_LSHIFT || event.kbd.keycode == Common::KEYCODE_RSHIFT ||
Commit: 7218a92eb7b5ca646fdaede545b629529ef30ebf
https://github.com/scummvm/scummvm/commit/7218a92eb7b5ca646fdaede545b629529ef30ebf
Author: Scott Percival (code at moral.net.au)
Date: 2025-10-09T21:18:44+02:00
Commit Message:
DIRECTOR: LINGO: Improve accuracy of b_findPosNear
Fixes music time minigame in pingu1.
Changed paths:
engines/director/lingo/lingo-builtins.cpp
engines/director/lingo/tests/lists.lingo
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 08ad8f156ca..9eee6f3aa52 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1054,26 +1054,25 @@ void LB::b_findPos(int nargs) {
}
void LB::b_findPosNear(int nargs) {
- Common::String prop = g_lingo->pop().asString();
+ Datum prop = g_lingo->pop();
Datum list = g_lingo->pop();
Datum res;
- TYPECHECK(list, PARRAY);
-
- // FIXME: Integrate with compareTo framework
- prop.toLowercase();
+ TYPECHECK2(list, PARRAY, ARRAY);
// This requires more testing, but D4-D6 test show that it does not work as described.
// The example:
// findPosNear([#Nile:2, #Pharaoh:4, #Raja:0], #Ni) supposed to return 1, for #Nile, but it returns 4
- res = Datum((int)list.u.parr->arr.size() + 1); // Set it to the end of array by default
-
- for (uint i = 0; i < list.u.parr->arr.size(); i++) {
- Datum p = list.u.parr->arr[i].p;
- Common::String tgt = p.asString();
- tgt.toLowercase();
- if (tgt.find(prop.c_str()) == 0) {
- res.u.i = i + 1;
- break;
+ if (list.type == PARRAY) {
+ res = Datum((int)list.u.parr->arr.size() + 1); // Set it to the end of array by default
+ int index = LC::compareArrays(list.u.parr->_sorted ? LC::geData : LC::eqData, list, prop, true).u.i;
+ if (index != 0) {
+ res = index;
+ }
+ } else if (list.type == ARRAY) {
+ res = prop; // set it to the returned value
+ int index = LC::compareArrays(list.u.farr->_sorted ? LC::geData : LC::eqData, list, prop, true).u.i;
+ if (index != 0) {
+ res = index;
}
}
diff --git a/engines/director/lingo/tests/lists.lingo b/engines/director/lingo/tests/lists.lingo
index 016fc4a2035..c0e5d433431 100644
--- a/engines/director/lingo/tests/lists.lingo
+++ b/engines/director/lingo/tests/lists.lingo
@@ -253,9 +253,28 @@ scummvmAssertEqual(findPos(testList, 2), 0)
scummvmAssertEqual(findPos(testList, 4), 0)
-- findPosNear
-set testList to [#a: 1, #b: 2, #bb: 3, #d: 4, #e: 5]
-scummvmAssertEqual(findPosNear(testList, #f), 6)
-scummvmAssertEqual(findPosNear(testList, #d), 4)
+set testList to [#b: 2, #a: 1, #bb: 3, #d: 4, #e: 5]
+scummvmAssertEqual(findPosNear(testList, #b), 1)
+-- if the property list isn't sorted and the value isn't there, return the size of the list + 1
+scummvmAssertEqual(findPosNear(testList, #missing), 6)
+scummvmAssertEqual(findPosNear(testList, #bbb), 6)
+sort testList
+scummvmAssertEqual(findPosNear(testList, #bbb), 4)
+
+set testList to [1: 2, 4: 8, 16: 32]
+scummvmAssertEqual(findPosNear(testList, 4), 2)
+scummvmAssertEqual(findPosNear(testList, 10), 4)
+sort testList
+scummvmAssertEqual(findPosNear(testList, 10), 3)
+
+-- the manual claims that findPosNear throws an error if you give it a regular list. the manual is wrong.
+set testList to [62, 5, 33]
+scummvmAssertEqual(findPosNear(testList, 5), 2)
+-- if the property list isn't sorted and the value isn't there, return the value
+scummvmAssertEqual(findPosNear(testList, 44), 44)
+sort testList
+scummvmAssertEqual(findPosNear(testList, 5), 1)
+scummvmAssertEqual(findPosNear(testList, 44), 3)
-- getaProp
Commit: 300c783c667e4a75207b3ea06eb70a9da57581d7
https://github.com/scummvm/scummvm/commit/300c783c667e4a75207b3ea06eb70a9da57581d7
Author: Scott Percival (code at moral.net.au)
Date: 2025-10-09T21:18:44+02:00
Commit Message:
DIRECTOR: Treat invalid palette ID in score same as null
Occasionally, it was possible for a dev to create a custom palette cast
member, refer to it in the score, then either move or remove the cast
member. In these cases, the invalid index remains, and the engine treats
it the same as a blank space; i.e. use the previous score palette.
Fixes broken palette on the puzzles menu of pingu1.
Changed paths:
engines/director/frame.cpp
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index bdabfa836b6..1c4205f6b8f 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -250,6 +250,8 @@ void Frame::readMainChannelsD2(Common::MemoryReadStreamEndian &stream, uint16 of
} else {
_mainChannels.palette.paletteId = CastMemberID(paletteId, DEFAULT_CAST_LIB);
}
+ if (!g_director->hasPalette(_mainChannels.palette.paletteId))
+ _mainChannels.palette.paletteId = CastMemberID();
if (!_mainChannels.palette.paletteId.isNull())
_mainChannels.scoreCachedPaletteId = _mainChannels.palette.paletteId;
}
@@ -918,6 +920,8 @@ void Frame::readMainChannelsD5(Common::MemoryReadStreamEndian &stream, uint16 of
break;
case 26:
_mainChannels.palette.paletteId.member = stream.readSint16();
+ if (!g_director->hasPalette(_mainChannels.palette.paletteId))
+ _mainChannels.palette.paletteId = CastMemberID();
if (!_mainChannels.palette.paletteId.isNull())
_mainChannels.scoreCachedPaletteId = _mainChannels.palette.paletteId;
break;
@@ -1362,6 +1366,8 @@ void Frame::readMainChannelsD6(Common::MemoryReadStreamEndian &stream, uint16 of
break;
case 120+2:
_mainChannels.palette.paletteId.member = stream.readSint16();
+ if (!g_director->hasPalette(_mainChannels.palette.paletteId))
+ _mainChannels.palette.paletteId = CastMemberID();
if (!_mainChannels.palette.paletteId.isNull())
_mainChannels.scoreCachedPaletteId = _mainChannels.palette.paletteId;
break;
@@ -1837,6 +1843,8 @@ void Frame::readMainChannelsD7(Common::MemoryReadStreamEndian &stream, uint16 of
break;
case 240+2:
_mainChannels.palette.paletteId.member = stream.readSint16();
+ if (!g_director->hasPalette(_mainChannels.palette.paletteId))
+ _mainChannels.palette.paletteId = CastMemberID();
if (!_mainChannels.palette.paletteId.isNull())
_mainChannels.scoreCachedPaletteId = _mainChannels.palette.paletteId;
break;
Commit: 062001095e2114cd4ed2f6ca7a796b94a822effa
https://github.com/scummvm/scummvm/commit/062001095e2114cd4ed2f6ca7a796b94a822effa
Author: Scott Percival (code at moral.net.au)
Date: 2025-10-09T21:18:44+02:00
Commit Message:
DIRECTOR: LINGO: Improve accuracy of b_importFileInto
Fixes intro movie in Mean City.
Changed paths:
engines/director/cast.cpp
engines/director/cast.h
engines/director/castmember/bitmap.h
engines/director/castmember/digitalvideo.cpp
engines/director/castmember/digitalvideo.h
engines/director/castmember/sound.cpp
engines/director/castmember/sound.h
engines/director/lingo/lingo-builtins.cpp
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index a1a5299bcf1..c6e124be85a 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -29,6 +29,8 @@
#include "graphics/macgui/macfontmanager.h"
#include "graphics/macgui/macwindowmanager.h"
+#include "image/image_decoder.h"
+#include "image/pict.h"
#include "video/qt_decoder.h"
#include "director/director.h"
@@ -2188,6 +2190,62 @@ void Cast::loadSord(Common::SeekableReadStreamEndian &stream) {
debugC(1, kDebugLoading, "Cast::loadSord(): number of entries: %d", numEntries);
}
+bool Cast::importFileInto(int castId, const Common::Path &path) {
+ // hold off on overwriting the target until we're sure it is loaded
+ Common::SeekableReadStream *file = Common::MacResManager::openFileOrDataFork(path);
+ if (!file) {
+ warning("Cast::importFileInto: file not found");
+ return false;
+ }
+ CastMember *member = nullptr;
+ uint32 magic1 = file->readUint32BE();
+ uint32 magic2 = file->readUint32BE();
+ uint32 magic3 = file->readUint32BE();
+ file->seek(528, SEEK_SET);
+ uint32 magic4 = file->readUint16BE();
+ file->seek(0, SEEK_SET);
+ if (magic1 == MKTAG('R', 'I', 'F', 'F') &&
+ magic3 == MKTAG('W', 'A', 'V', 'E')) {
+ // WAV file
+ member = new SoundCastMember(this, castId);
+ } else if (magic1 == MKTAG('F', 'O', 'R', 'M') &&
+ (magic3 == MKTAG('A', 'I', 'F', 'F') ||
+ magic3 == MKTAG('A', 'I', 'F', 'C'))) {
+ // AIFF file
+ member = new SoundCastMember(this, castId);
+ } else if (magic2 == MKTAG('m', 'o', 'o', 'v') ||
+ magic2 == MKTAG('m', 'd', 'a', 't')) {
+ // QuickTime file
+ member = new DigitalVideoCastMember(this, castId);
+ ((DigitalVideoCastMember *)member)->_qtmovie = true;
+ } else if (magic1 == MKTAG('R', 'I', 'F', 'F') && (magic3 == MKTAG('A', 'V', 'I', ' '))) {
+ // AVI file
+ member = new DigitalVideoCastMember(this, castId);
+ ((DigitalVideoCastMember *)member)->_avimovie = true;
+ } else if ((magic1 >> 16) == MKTAG16('B', 'M')) {
+ // Windows Bitmap file
+ Image::ImageDecoder *img = new Image::BitmapDecoder();
+ img->loadStream(*file);
+ member = new BitmapCastMember(this, castId, img);
+ } else if ((magic4 == 0xffff) || (magic4 == 0xfffe)) {
+ // Apple PICT file
+ Image::ImageDecoder *img = new Image::PICTDecoder();
+ img->loadStream(*file);
+ member = new BitmapCastMember(this, castId, img);
+ }
+ delete file;
+
+ if (member) {
+ setCastMember(castId, member);
+ CastMemberInfo *info = new CastMemberInfo();
+ info->fileName = path.toString(g_director->_dirSeparator);
+ _castsInfo[castId] = info;
+ return true;
+ }
+
+ return false;
+}
+
// Pattern tiles
//
// Basically, a reference to Bitmap cast accompanied with rectrangle
diff --git a/engines/director/cast.h b/engines/director/cast.h
index 7a27cc1f558..5eeef4221ea 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -105,6 +105,7 @@ public:
void loadLingoContext(Common::SeekableReadStreamEndian &stream);
void loadExternalSound(Common::SeekableReadStreamEndian &stream);
void loadSord(Common::SeekableReadStreamEndian &stream);
+ bool importFileInto(int castId, const Common::Path &path);
void saveConfig(Common::SeekableWriteStream *writeStream, uint32 offset);
void saveCastData(Common::SeekableWriteStream *writeStream, Resource *res);
diff --git a/engines/director/castmember/bitmap.h b/engines/director/castmember/bitmap.h
index f6168bd3832..e346e427ab7 100644
--- a/engines/director/castmember/bitmap.h
+++ b/engines/director/castmember/bitmap.h
@@ -32,6 +32,7 @@ namespace Director {
class BitmapCastMember : public CastMember {
public:
+ BitmapCastMember(Cast *cast, uint16 castId);
BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint32 castTag, uint16 version, uint8 flags1 = 0);
BitmapCastMember(Cast *cast, uint16 castId, Image::ImageDecoder *img, uint8 flags1 = 0);
BitmapCastMember(Cast *cast, uint16 castId, BitmapCastMember &source);
diff --git a/engines/director/castmember/digitalvideo.cpp b/engines/director/castmember/digitalvideo.cpp
index 6d4eb674287..1b439d4eefd 100644
--- a/engines/director/castmember/digitalvideo.cpp
+++ b/engines/director/castmember/digitalvideo.cpp
@@ -81,6 +81,38 @@ public:
};
+DigitalVideoCastMember::DigitalVideoCastMember(Cast *cast, uint16 castId)
+ : CastMember(cast, castId) {
+ _type = kCastDigitalVideo;
+ _video = nullptr;
+ _lastFrame = nullptr;
+ _channel = nullptr;
+
+ _getFirstFrame = false;
+ _duration = 0;
+
+ _vflags = 0;
+ _frameRate = 0;
+
+ _frameRateType = kFrameRateDefault;
+ _videoType = kDVUnknown;
+ _qtmovie = true;
+ _avimovie = false;
+ _preload = false;
+ _enableVideo = true;
+ _pausedAtStart = false;
+ _showControls = false;
+ _directToStage = false;
+ _looping = false;
+ _enableSound = true;
+ _crop = false;
+ _center = false;
+ _dirty = false;
+ _emptyFile = false;
+
+ memset(_ditheringPalette, 0, 256*3);
+}
+
DigitalVideoCastMember::DigitalVideoCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint16 version)
@@ -187,8 +219,6 @@ bool DigitalVideoCastMember::loadVideoFromCast() {
}
bool DigitalVideoCastMember::loadVideo(Common::String path) {
- // TODO: detect file type (AVI, QuickTime, FLIC) based on magic number,
- // insert the right video decoder
if (_filename == path) {
// we've already loaded this video, or not. no point trying again.
return _video ? true : false;
diff --git a/engines/director/castmember/digitalvideo.h b/engines/director/castmember/digitalvideo.h
index 45a57695d96..aef037dc91f 100644
--- a/engines/director/castmember/digitalvideo.h
+++ b/engines/director/castmember/digitalvideo.h
@@ -38,6 +38,7 @@ enum DigitalVideoType {
class DigitalVideoCastMember : public CastMember {
public:
+ DigitalVideoCastMember(Cast *cast, uint16 castId);
DigitalVideoCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint16 version);
DigitalVideoCastMember(Cast *cast, uint16 castId, DigitalVideoCastMember &source);
~DigitalVideoCastMember();
diff --git a/engines/director/castmember/sound.cpp b/engines/director/castmember/sound.cpp
index bb1961ff9ea..b4d50eb37b8 100644
--- a/engines/director/castmember/sound.cpp
+++ b/engines/director/castmember/sound.cpp
@@ -27,6 +27,13 @@
namespace Director {
+SoundCastMember::SoundCastMember(Cast *cast, uint16 castId)
+ : CastMember(cast, castId) {
+ _type = kCastSound;
+ _audio = nullptr;
+ _looping = 0;
+}
+
SoundCastMember::SoundCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint16 version)
: CastMember(cast, castId, stream) {
_type = kCastSound;
diff --git a/engines/director/castmember/sound.h b/engines/director/castmember/sound.h
index 9ae8ae9a1e5..2968096e751 100644
--- a/engines/director/castmember/sound.h
+++ b/engines/director/castmember/sound.h
@@ -30,6 +30,7 @@ class AudioDecoder;
class SoundCastMember : public CastMember {
public:
+ SoundCastMember(Cast *cast, uint16 castId);
SoundCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint16 version);
SoundCastMember(Cast *cast, uint16 castId, SoundCastMember &source);
~SoundCastMember();
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 9eee6f3aa52..7c91b5a696c 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -2684,31 +2684,21 @@ void LB::b_importFileInto(int nargs) {
CastMemberID memberID = *dst.u.cast;
- if (!(file.matchString("*.pic") || file.matchString("*.pict"))) {
- warning("LB::b_importFileInto : %s is not a valid PICT file", file.c_str());
+ Movie *movie = g_director->getCurrentMovie();
+ Score *score = movie->getScore();
+ Cast *cast = movie->getCast(memberID);
+ if (!cast) {
return;
}
Common::Path path = findPath(file);
- Common::File in;
- in.open(path);
-
- if (!in.isOpen()) {
- warning("b_importFileInto(): Cannot open file %s", path.toString().c_str());
+ if (path.empty()) {
+ warning("b_importFileInto(): couldn't find target file %s", file.c_str());
return;
}
- Image::PICTDecoder *img = new Image::PICTDecoder();
- img->loadStream(in);
- in.close();
+ cast->importFileInto(memberID.member, path);
- Movie *movie = g_director->getCurrentMovie();
- Score *score = movie->getScore();
- BitmapCastMember *bitmapCast = new BitmapCastMember(movie->getCast(), memberID.member, img);
- movie->createOrReplaceCastMember(memberID, bitmapCast);
- bitmapCast->setModified(true);
- const Graphics::Surface *surf = img->getSurface();
- bitmapCast->_size = surf->pitch * surf->h + img->getPalette().size() * 3;
score->refreshPointersForCastMemberID(dst.asMemberID());
}
More information about the Scummvm-git-logs
mailing list