[Scummvm-git-logs] scummvm master -> 3a7c0911224adc0d0d467dc530f62f97a8868bee

sev- sev at scummvm.org
Wed Mar 1 10:51:17 CET 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e7842795fe DIRECTOR: Fix debug output
3a7c091122 DIRECTOR: Plug memory leak


Commit: e7842795fe257dd465b2d5e36d71abed77edc244
    https://github.com/scummvm/scummvm/commit/e7842795fe257dd465b2d5e36d71abed77edc244
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2017-03-01T10:50:35+01:00

Commit Message:
DIRECTOR: Fix debug output

Changed paths:
    engines/director/score.cpp


diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index aa4828e..c72fc0c 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -240,7 +240,7 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) {
 
 	while (size != 0) {
 		uint16 frameSize = stream.readUint16();
-		debugC(kDebugLoading, 8, "++++ score frame %d (frameSize %d) size %d", _frames.size() + 1, frameSize, size);
+		debugC(kDebugLoading, 8, "++++ score frame %d (frameSize %d) size %d", _frames.size(), frameSize, size);
 		size -= frameSize;
 		frameSize -= 2;
 
@@ -993,7 +993,7 @@ void Score::processEvents() {
 				// D3 doesn't have both mouse up and down.
 				// But we still want to know if the mouse is down for press effects.
 				_currentMouseDownSpriteId = _frames[_currentFrame]->getSpriteIDFromPos(pos);
-				
+
 				if (_vm->getVersion() > 3) {
 					// TODO: check that this is the order of script execution!
 					_lingo->processEvent(kEventMouseDown, kCastScript, _frames[_currentFrame]->_sprites[_currentMouseDownSpriteId]->_castId);


Commit: 3a7c0911224adc0d0d467dc530f62f97a8868bee
    https://github.com/scummvm/scummvm/commit/3a7c0911224adc0d0d467dc530f62f97a8868bee
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2017-03-01T10:50:35+01:00

Commit Message:
DIRECTOR: Plug memory leak

Changed paths:
    engines/director/director.cpp
    engines/director/director.h
    engines/director/resource.cpp


diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index a1ee253..1f0c897 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -59,7 +59,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
 	// Load Patterns
 	loadPatterns();
 
-	_sharedCasts = nullptr;
+	_sharedScore = nullptr;
 
 	_currentScore = nullptr;
 	_soundManager = nullptr;
@@ -67,7 +67,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
 	_currentPaletteLength = 0;
 	_lingo = nullptr;
 
-	_sharedCasts = nullptr;
+	_sharedScore = nullptr;
 	_sharedSound = nullptr;
 	_sharedBMP = nullptr;
 	_sharedSTXT = nullptr;
@@ -100,6 +100,7 @@ DirectorEngine::~DirectorEngine() {
 	delete _sharedBMP;
 	delete _sharedSTXT;
 	delete _sharedDIB;
+	delete _sharedScore;
 
 	delete _currentScore;
 
@@ -242,4 +243,11 @@ Common::HashMap<Common::String, Score *> *DirectorEngine::scanMovies(const Commo
 	return nameMap;
 }
 
+Common::HashMap<int, Cast *> *DirectorEngine::getSharedCasts() {
+	if (_sharedScore)
+		return &_sharedScore->_casts;
+
+	return &_dummyCast;
+}
+
 } // End of namespace Director
diff --git a/engines/director/director.h b/engines/director/director.h
index 1c3d77f..5b1e9b3 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -105,7 +105,7 @@ public:
 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *getSharedDIB() const { return _sharedDIB; }
 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *getSharedBMP() const { return _sharedBMP; }
 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *getSharedSTXT() const { return _sharedSTXT; }
-	Common::HashMap<int, Cast *> *getSharedCasts() const { return _sharedCasts; }
+	Common::HashMap<int, Cast *> *getSharedCasts();
 
 	Common::HashMap<Common::String, Score *> *_movies;
 
@@ -138,7 +138,7 @@ private:
 	void loadEXERIFX(Common::SeekableReadStream *stream, uint32 offset);
 	void loadMac(const Common::String movie);
 
-	Common::HashMap<int, Cast *> *_sharedCasts;
+	Score *_sharedScore;
 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedDIB;
 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedSTXT;
 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedSound;
@@ -157,6 +157,7 @@ private:
 	Graphics::MacPatterns _director3QuickDrawPatterns;
 
 	Common::String _sharedCastFile;
+	Common::HashMap<int, Cast *> _dummyCast;
 
 private:
 	void testFontScaling();
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index 9ceb95b..3db6d66 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -205,8 +205,6 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
 	if (!shardcst->openFile(filename)) {
 		warning("No shared cast %s", filename.c_str());
 
-		_sharedCasts = new Common::HashMap<int, Cast *>;
-
 		return;
 	}
 
@@ -214,8 +212,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
 	_sharedSTXT = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>;
 	_sharedSound = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>;
 	_sharedBMP = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>;
-
-	Score *castScore = new Score(this, shardcst);
+	_sharedScore = new Score(this, shardcst);
 
 	if (shardcst->hasResource(MKTAG('F', 'O', 'N', 'D'), -1)) {
 		debug("Shared cast has fonts. Loading....");
@@ -223,20 +220,18 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
 		_wm->_fontMan->loadFonts(filename);
 	}
 
-	castScore->loadConfig(*shardcst->getResource(MKTAG('V','W','C','F'), 1024));
+	_sharedScore->loadConfig(*shardcst->getResource(MKTAG('V','W','C','F'), 1024));
 
 	if (getVersion() < 4)
-		castScore->loadCastDataVWCR(*shardcst->getResource(MKTAG('V','W','C','R'), 1024));
+		_sharedScore->loadCastDataVWCR(*shardcst->getResource(MKTAG('V','W','C','R'), 1024));
 
 	Common::Array<uint16> cast = shardcst->getResourceIDList(MKTAG('C','A','S','t'));
 	if (cast.size() > 0) {
 		for (Common::Array<uint16>::iterator iterator = cast.begin(); iterator != cast.end(); ++iterator)
-			castScore->loadCastData(*shardcst->getResource(MKTAG('C','A','S','t'), *iterator), *iterator, NULL);
+			_sharedScore->loadCastData(*shardcst->getResource(MKTAG('C','A','S','t'), *iterator), *iterator, NULL);
 	}
 
-	castScore->setSpriteCasts();
-
-	_sharedCasts = &castScore->_casts;
+	_sharedScore->setSpriteCasts();
 
 	Common::Array<uint16> dib = shardcst->getResourceIDList(MKTAG('D','I','B',' '));
 	if (dib.size() != 0) {





More information about the Scummvm-git-logs mailing list