aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNipun Garg2019-07-18 02:19:18 +0530
committerEugene Sandulenko2019-09-03 17:17:23 +0200
commit161f9e67070f38906cd62b7db65d1d6cf2802823 (patch)
treec672e3075942efc60f94e4f1aec2dbd42cd2b90e /engines
parente9e654d7db8c6b865c6f168f6f35663af85fce85 (diff)
downloadscummvm-rg350-161f9e67070f38906cd62b7db65d1d6cf2802823.tar.gz
scummvm-rg350-161f9e67070f38906cd62b7db65d1d6cf2802823.tar.bz2
scummvm-rg350-161f9e67070f38906cd62b7db65d1d6cf2802823.zip
HDB: NULL each tile after calling destructor
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/ai-init.cpp25
-rw-r--r--engines/hdb/ai.h17
-rw-r--r--engines/hdb/gfx.cpp44
-rw-r--r--engines/hdb/gfx.h10
-rw-r--r--engines/hdb/hdb.cpp7
5 files changed, 73 insertions, 30 deletions
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 5a71b4bb17..c0c85e7c76 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -946,6 +946,31 @@ AI::~AI() {
memset(_clubRightGfx, 0, sizeof(_clubRightGfx));
memset(_slugAttackGfx, 0, sizeof(_slugAttackGfx));
+ // Clean up Player Graphics Storage
+ memset(_horrible1Gfx, 0, sizeof(_horrible1Gfx));
+ memset(_horrible2Gfx, 0, sizeof(_horrible2Gfx));
+ memset(_horrible3Gfx, 0, sizeof(_horrible3Gfx));
+ memset(_horrible4Gfx, 0, sizeof(_horrible4Gfx));
+ memset(_plummetGfx, 0, sizeof(_plummetGfx));
+ memset(_dyingGfx, 0, sizeof(_dyingGfx));
+
+ memset(_pushdownGfx, 0, sizeof(_pushdownGfx));
+ memset(_pushupGfx, 0, sizeof(_pushupGfx));
+ memset(_pushleftGfx, 0, sizeof(_pushleftGfx));
+ memset(_pushrightGfx, 0, sizeof(_pushrightGfx));
+ memset(_stunDownGfx, 0, sizeof(_stunDownGfx));
+ memset(_stunUpGfx, 0, sizeof(_stunUpGfx));
+ memset(_stunLeftGfx, 0, sizeof(_stunLeftGfx));
+ memset(_stunRightGfx, 0, sizeof(_stunRightGfx));
+ memset(_slugDownGfx, 0, sizeof(_slugDownGfx));
+ memset(_slugUpGfx, 0, sizeof(_slugUpGfx));
+ memset(_slugLeftGfx, 0, sizeof(_slugLeftGfx));
+ memset(_slugRightGfx, 0, sizeof(_slugRightGfx));
+
+ memset(_waypointGfx, 0, sizeof(_waypointGfx));
+ delete _debugQMark;
+ _debugQMark = NULL;
+
// Free AnimTargets
for (uint i = 0; i < _animTargets.size(); i++) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 8b25008648..533d4310a9 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -550,51 +550,61 @@ struct AIEntity {
blinkFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
delete blinkGfx[i];
+ blinkGfx[i] = NULL;
}
special1Frames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
delete special1Gfx[i];
+ special1Gfx[i] = NULL;
}
standdownFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
delete standdownGfx[i];
+ standdownGfx[i] = NULL;
}
standupFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
delete standupGfx[i];
+ standupGfx[i] = NULL;
}
standleftFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
delete standleftGfx[i];
+ standleftGfx[i] = NULL;
}
standrightFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
delete standrightGfx[i];
+ standrightGfx[i] = NULL;
}
movedownFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
delete movedownGfx[i];
+ movedownGfx[i] = NULL;
}
moveupFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
delete moveupGfx[i];
+ moveupGfx[i] = NULL;
}
moveleftFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
delete moveleftGfx[i];
+ moveleftGfx[i] = NULL;
}
moverightFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
delete moverightGfx[i];
+ moverightGfx[i] = NULL;
}
}
@@ -652,6 +662,7 @@ struct AnimTarget {
~AnimTarget() {
for (int i = 0; i < kMaxAnimTFrames; i++) {
delete gfxList[i];
+ gfxList[i] = NULL;
}
}
};
@@ -680,6 +691,12 @@ struct DlvEnt {
destTextName[0] = 0;
destGfxName[0] = 0;
}
+ ~DlvEnt() {
+ delete itemGfx;
+ itemGfx = NULL;
+ delete destGfx;
+ destGfx = NULL;
+ }
};
struct Waypoint {
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 942fd1d2b6..de897074e0 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -1032,16 +1032,14 @@ void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
}
Picture::Picture() : _width(0), _height(0), _name("") {
- _surface = NULL;
+ _surface.create(_width, _height, g_hdb->_format);
}
Picture::~Picture() {
- if (_surface)
- _surface->free();
- _surface = NULL;
+ _surface.free();
}
-Graphics::ManagedSurface *Picture::load(Common::SeekableReadStream *stream) {
+Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
_width = stream->readUint32LE();
_height = stream->readUint32LE();
stream->read(_name, 64);
@@ -1049,14 +1047,13 @@ Graphics::ManagedSurface *Picture::load(Common::SeekableReadStream *stream) {
debug(8, "Picture: _width: %d, _height: %d", _width, _height);
debug(8, "Picture: _name: %s", _name);
- _surface = new Graphics::ManagedSurface;
- _surface->create(_width, _height, g_hdb->_format);
+ _surface.create(_width, _height, g_hdb->_format);
stream->readUint32LE(); // Skip Win32 Surface
uint16 *ptr;
for (int y = 0; y < _height; y++) {
- ptr = (uint16 *)_surface->getBasePtr(0, y);
+ ptr = (uint16 *)_surface.getBasePtr(0, y);
for (int x = 0; x < _width; x++) {
*ptr = TO_LE_16(stream->readUint16LE());
ptr++;
@@ -1067,9 +1064,9 @@ Graphics::ManagedSurface *Picture::load(Common::SeekableReadStream *stream) {
}
int Picture::draw(int x, int y) {
- g_hdb->_gfx->_globalSurface.blitFrom(*_surface, Common::Point(x, y));
+ g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
- Common::Rect clip(_surface->getBounds());
+ Common::Rect clip(_surface.getBounds());
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
@@ -1080,9 +1077,9 @@ int Picture::draw(int x, int y) {
}
int Picture::drawMasked(int x, int y, int alpha) {
- g_hdb->_gfx->_globalSurface.transBlitFrom(*_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
+ g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
- Common::Rect clip(_surface->getBounds());
+ Common::Rect clip(_surface.getBounds());
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
@@ -1092,26 +1089,25 @@ int Picture::drawMasked(int x, int y, int alpha) {
return 0;
}
-Tile::Tile() : _flags(0), _name(""), _surface(NULL) {}
+Tile::Tile() : _flags(0), _name("") {
+ _surface.create(32, 32, g_hdb->_format);
+}
Tile::~Tile() {
- if (_surface)
- _surface->free();
- _surface = NULL;
+ _surface.free();
}
-Graphics::ManagedSurface *Tile::load(Common::SeekableReadStream *stream) {
+Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
_flags = stream->readUint32LE();
stream->read(_name, 64);
- _surface = new Graphics::ManagedSurface;
- _surface->create(32, 32, g_hdb->_format);
+ _surface.create(32, 32, g_hdb->_format);
stream->readUint32LE(); // Skip Win32 Surface
uint16 *ptr;
for (uint y = 0; y < 32; y++) {
- ptr = (uint16 *)_surface->getBasePtr(0, y);
+ ptr = (uint16 *)_surface.getBasePtr(0, y);
for (uint x = 0; x < 32; x++) {
*ptr = TO_LE_16(stream->readUint16LE());
ptr++;
@@ -1122,9 +1118,9 @@ Graphics::ManagedSurface *Tile::load(Common::SeekableReadStream *stream) {
}
int Tile::draw(int x, int y) {
- g_hdb->_gfx->_globalSurface.blitFrom(*_surface, Common::Point(x, y));
+ g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
- Common::Rect clip(_surface->getBounds());
+ Common::Rect clip(_surface.getBounds());
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
@@ -1135,9 +1131,9 @@ int Tile::draw(int x, int y) {
}
int Tile::drawMasked(int x, int y, int alpha) {
- g_hdb->_gfx->_globalSurface.transBlitFrom(*_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
+ g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
- Common::Rect clip(_surface->getBounds());
+ Common::Rect clip(_surface.getBounds());
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 1c993ec201..ce6ceb6502 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -253,7 +253,7 @@ public:
Picture();
~Picture();
- Graphics::ManagedSurface *load(Common::SeekableReadStream *stream);
+ Graphics::Surface load(Common::SeekableReadStream *stream);
int draw(int x, int y);
int drawMasked(int x, int y, int alpha = 0xff);
@@ -261,12 +261,12 @@ public:
char *getName() { return _name; }
- Graphics::ManagedSurface *getSurface() { return _surface; }
+ Graphics::ManagedSurface *getSurface() { return &_surface; }
private:
char _name[64];
- Graphics::ManagedSurface *_surface;
+ Graphics::ManagedSurface _surface;
};
class Tile {
@@ -275,7 +275,7 @@ public:
Tile();
~Tile();
- Graphics::ManagedSurface *load(Common::SeekableReadStream *stream);
+ Graphics::Surface load(Common::SeekableReadStream *stream);
int draw(int x, int y);
int drawMasked(int x, int y, int alpha = 0xff);
@@ -285,7 +285,7 @@ public:
private:
char _name[64];
- Graphics::ManagedSurface *_surface;
+ Graphics::ManagedSurface _surface;
};
} // End of Namespace HDB
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index c5b91bbb07..49a2f99807 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -87,10 +87,15 @@ HDBGame::~HDBGame() {
delete _rnd;
delete _progressGfx;
+ _progressGfx = NULL;
delete _progressMarkGfx;
+ _progressMarkGfx = NULL;
delete _loadingScreenGfx;
- if (_logoGfx)
+ _loadingScreenGfx = NULL;
+ if (_logoGfx) {
delete _logoGfx;
+ _logoGfx = NULL;
+ }
DebugMan.clearAllDebugChannels();
}