aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorDmitry Iskrich2016-07-01 16:31:15 +0300
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commit061f868d7917f3104c294041ab51ac08f1fd0e38 (patch)
treea669e47d8c0f45eaca3d2a9a94bfb2525221b9cd /engines/director
parent2ad3d3a236d579565d74f67863fc8a78c0882b64 (diff)
downloadscummvm-rg350-061f868d7917f3104c294041ab51ac08f1fd0e38.tar.gz
scummvm-rg350-061f868d7917f3104c294041ab51ac08f1fd0e38.tar.bz2
scummvm-rg350-061f868d7917f3104c294041ab51ac08f1fd0e38.zip
DIRECTOR: Free memory, fix render text ID
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/director.cpp23
-rw-r--r--engines/director/score.cpp31
-rw-r--r--engines/director/score.h4
3 files changed, 43 insertions, 15 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index a6422df519..8616317d60 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -52,28 +52,37 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
// Setup mixer
syncSoundSettings();
-
- _mainArchive = 0;
- _macBinary = 0;
- _currentPalette = 0;
- //FIXME
- _sharedMMM = "SHARDCST.MMM";
_sharedCasts = new Common::HashMap<int, Cast *>();
_sharedDIB = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>();
_sharedBMP = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>();
_sharedSTXT = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>();
_sharedSound = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>();
+ _mainArchive = 0;
+ _macBinary = 0;
+ //FIXME
+ _sharedMMM = "SHARDCST.MMM";
_movies = new Common::HashMap<Common::String, Score *>();
+
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "data");
SearchMan.addSubDirectoryMatching(gameDataDir, "install");
}
DirectorEngine::~DirectorEngine() {
+ delete[] _sharedCasts;
+ delete[] _sharedSound;
+ delete[] _sharedBMP;
+ delete[] _sharedSTXT;
+ delete[] _sharedDIB;
+ delete[] _movies;
+
delete _mainArchive;
delete _macBinary;
- delete[] _currentPalette;
+ delete _soundManager;
+ delete _lingo;
+ delete _currentScore;
+ delete _currentPalette;
}
Common::Error DirectorEngine::run() {
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 82b7ebf79b..fc24de77c8 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -125,7 +125,19 @@ Score::~Score() {
delete _trailSurface;
_movieArchive->close();
+
+ delete _surface;
+ delete _trailSurface;
+
+ delete _font;
delete _movieArchive;
+
+ delete[] _labels;
+ delete[] &_frames;
+ delete[] &_casts;
+ delete[] &_castsInfo;
+ delete[] &_actions;
+ delete[] &_fontMap;
}
void Score::loadPalette(Common::SeekableSubReadStreamEndian &stream) {
@@ -810,9 +822,9 @@ Frame::Frame(const Frame &frame) {
}
Frame::~Frame() {
- for (uint16 i = 0; i < _sprites.size(); i++) {
- delete _sprites[i];
- }
+ delete[] &_sprites;
+ delete[] &_drawRects;
+ delete _palette;
}
void Frame::readChannel(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size) {
@@ -1166,6 +1178,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
Image::ImageDecoder *img = getImageFrom(_sprites[i]->_castId);
if (!img) {
+ warning("Image with id %d not found", _sprites[i]->_castId);
continue;
}
@@ -1241,11 +1254,12 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) {
void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteID) {
- Cast *textCast = _vm->_currentScore->_casts[_sprites[spriteID]->_castId];
+ uint16 castID = _sprites[spriteID]->_castId;
+ Cast *textCast = _vm->_currentScore->_casts[castID];
Common::SeekableSubReadStreamEndian *textStream;
- if (_vm->_currentScore->_movieArchive->hasResource(MKTAG('S','T','X','T'), spriteID + 1024)) {
- textStream = _vm->_currentScore->_movieArchive->getResource(MKTAG('S','T','X','T'), spriteID + 1024);
+ if (_vm->_currentScore->_movieArchive->hasResource(MKTAG('S','T','X','T'), castID + 1024)) {
+ textStream = _vm->_currentScore->_movieArchive->getResource(MKTAG('S','T','X','T'), castID + 1024);
} else {
textStream = _vm->getSharedSTXT()->getVal(spriteID + 1024);
}
@@ -1410,4 +1424,9 @@ Sprite::Sprite(const Sprite &sprite) {
_startPoint.y = sprite._startPoint.y;
}
+Sprite::~Sprite() {
+ delete _cast;
+ delete &_startPoint;
+}
+
} //End of namespace Director
diff --git a/engines/director/score.h b/engines/director/score.h
index b616e11ff0..459d2e9462 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -274,7 +274,7 @@ class Sprite {
public:
Sprite();
Sprite(const Sprite &sprite);
-
+ ~Sprite();
bool _enabled;
byte _castId;
InkType _ink;
@@ -299,7 +299,7 @@ private:
void playTransition(Score *score);
void playSoundChannel();
void renderSprites(Graphics::ManagedSurface &surface, bool renderTrail);
- void renderText(Graphics::ManagedSurface &surface, uint16 spriteID);
+ void renderText(Graphics::ManagedSurface &surface, uint16 castId);
void readPaletteInfo(Common::SeekableSubReadStreamEndian &stream);
void readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size);
void readMainChannels(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size);