aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNipun Garg2019-07-18 20:11:26 +0530
committerEugene Sandulenko2019-09-03 17:17:23 +0200
commitecefec2f77a2c2af6b956d3f35869605b5aff62d (patch)
treed3fbb77cc8ac8e56f2a07135bdc4182063aa0e1d /engines
parenta8d277be183a2d41b9dd10b3b8b23ef1ddb8d65e (diff)
downloadscummvm-rg350-ecefec2f77a2c2af6b956d3f35869605b5aff62d.tar.gz
scummvm-rg350-ecefec2f77a2c2af6b956d3f35869605b5aff62d.tar.bz2
scummvm-rg350-ecefec2f77a2c2af6b956d3f35869605b5aff62d.zip
HDB: Add _animTiles to fix memory leaks
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/ai-funcs.cpp1
-rw-r--r--engines/hdb/ai-init.cpp37
-rw-r--r--engines/hdb/ai.h3
-rw-r--r--engines/hdb/gfx.cpp2
-rw-r--r--engines/hdb/hdb.cpp1
5 files changed, 33 insertions, 11 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 5c8f929fd2..02c694120b 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -681,6 +681,7 @@ int AI::checkForTouchplate(int x, int y) {
void AI::removeEntity(AIEntity *e) {
for (uint i = 0; i < _ents->size(); i++)
if (_ents->operator[](i) == e) {
+ delete _ents->operator[](i);
_ents->remove_at(i);
return;
}
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index bc6ebeeffc..e69fbc709a 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -941,6 +941,15 @@ AI::~AI() {
// Free Player Graphics
for (int i = 0; i < 8; i++) {
delete _slugAttackGfx[i];
+ _slugAttackGfx[i] = NULL;
+ }
+ if (_weaponSelGfx) {
+ delete _weaponSelGfx;
+ _weaponSelGfx = NULL;
+ }
+ if (_weaponGfx) {
+ delete _weaponGfx;
+ _weaponGfx = NULL;
}
memset(_clubDownGfx, 0, sizeof(_clubDownGfx));
@@ -979,6 +988,9 @@ AI::~AI() {
for (uint i = 0; i < _animTargets.size(); i++) {
delete _animTargets[i];
}
+
+ // Free Animating Tiles
+ freeAnimInfo();
}
bool AI::init() {
@@ -1768,13 +1780,13 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
void AI::initAnimInfo() {
if (g_hdb->_map->checkOneTileExistInRange(_useSwitchOff, 2))
- g_hdb->_gfx->getTile(_useSwitchOn);
+ _animTiles.push_back(g_hdb->_gfx->getTile(_useSwitchOn));
if (g_hdb->_map->checkOneTileExistInRange(_useSwitch2Off, 2))
- g_hdb->_gfx->getTile(_useSwitch2On);
+ _animTiles.push_back(g_hdb->_gfx->getTile(_useSwitch2On));
if (g_hdb->_map->checkOneTileExistInRange(_useHolderEmpty, 2))
- g_hdb->_gfx->getTile(_useHolderFull);
+ _animTiles.push_back(g_hdb->_gfx->getTile(_useHolderFull));
if (g_hdb->_map->checkOneTileExistInRange(_useHandswitchOff, 2))
- g_hdb->_gfx->getTile(_useHandswitchOn);
+ _animTiles.push_back(g_hdb->_gfx->getTile(_useHandswitchOn));
if (g_hdb->_map->checkOneTileExistInRange(_targetDoorN, 4))
g_hdb->_gfx->cacheTileSequence(_targetDoorN, 4);
@@ -1848,17 +1860,22 @@ void AI::initAnimInfo() {
g_hdb->_gfx->cacheTileSequence(_blockpole, 4);
if (g_hdb->_map->checkOneTileExistInRange(_kcHolderWhiteOff, 2))
- g_hdb->_gfx->getTile(_kcHolderWhiteOn);
+ _animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderWhiteOn));
if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlueOff, 2))
- g_hdb->_gfx->getTile(_kcHolderBlueOn);
+ _animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderBlueOn));
if (g_hdb->_map->checkOneTileExistInRange(_kcHolderRedOff, 2))
- g_hdb->_gfx->getTile(_kcHolderRedOn);
+ _animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderRedOn));
if (g_hdb->_map->checkOneTileExistInRange(_kcHolderGreenOff, 2))
- g_hdb->_gfx->getTile(_kcHolderGreenOn);
+ _animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderGreenOn));
if (g_hdb->_map->checkOneTileExistInRange(_kcHolderPurpleOff, 2))
- g_hdb->_gfx->getTile(_kcHolderPurpleOn);
+ _animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderPurpleOn));
if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlackOff, 2))
- g_hdb->_gfx->getTile(_kcHolderBlackOn);
+ _animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderBlackOn));
+}
+
+void AI::freeAnimInfo() {
+ for (uint i = 0; i < _animTiles.size(); i++)
+ delete _animTiles[i];
}
const char *AITypeStr[] = {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 83fe88b9ff..df888b162c 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -821,6 +821,7 @@ public:
void save(Common::OutSaveFile *out);
void loadSaveFile(Common::InSaveFile *in);
void initAnimInfo();
+ void freeAnimInfo();
// Entity Functions
AIEntity *spawn(AIType type, AIDir dir, int x, int y, const char *funcInit, const char *funcAction, const char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);
@@ -1327,6 +1328,8 @@ public:
Tile *_gfxLaserbeamLRLeft[4];
Tile *_gfxLaserbeamLRRight[4];
+ Common::Array<Tile *> _animTiles;
+
private:
// Action Functions
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 94ba77b604..5ebffe2578 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -459,7 +459,7 @@ void Gfx::emptyGfxCaches() {
void Gfx::cacheTileSequence(int tileIndex, int count) {
for (int i = tileIndex; i < tileIndex + count; i++)
- getTile(i);
+ g_hdb->_ai->_animTiles.push_back(getTile(i));
}
int Gfx::getTileIndex(const char *name) {
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3419ac6cee..c8b01855dd 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -79,6 +79,7 @@ HDBGame::~HDBGame() {
delete _fileMan;
delete _gfx;
delete _lua;
+ delete _menu;
delete _map;
delete _ai;
delete _input;