diff options
author | Nipun Garg | 2019-07-18 20:12:01 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:23 +0200 |
commit | d0248243d2cbb9729ee6f6367784d8fd6be2c719 (patch) | |
tree | 77c73692dc0f5d7d18707d9eb77413fdd6ecf800 /engines | |
parent | ecefec2f77a2c2af6b956d3f35869605b5aff62d (diff) | |
download | scummvm-rg350-d0248243d2cbb9729ee6f6367784d8fd6be2c719.tar.gz scummvm-rg350-d0248243d2cbb9729ee6f6367784d8fd6be2c719.tar.bz2 scummvm-rg350-d0248243d2cbb9729ee6f6367784d8fd6be2c719.zip |
HDB: Refactor getPicGfx(), getTileGfx() and fix...
... memory leaks
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hdb/ai-player.cpp | 38 | ||||
-rw-r--r-- | engines/hdb/gfx.cpp | 18 |
2 files changed, 21 insertions, 35 deletions
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp index ba887db4ef..25f371202c 100644 --- a/engines/hdb/ai-player.cpp +++ b/engines/hdb/ai-player.cpp @@ -56,25 +56,25 @@ void aiPlayerInit(AIEntity *e) { void aiPlayerInit2(AIEntity *e) { if (!g_hdb->_ai->_clubUpGfx[0]) { g_hdb->_ai->_weaponSelGfx = g_hdb->_gfx->loadTile(TILE_WEAPON_EQUIPPED); - g_hdb->_ai->_clubUpGfx[0] = g_hdb->_gfx->loadPic(CLUBUP1); - g_hdb->_ai->_clubUpGfx[1] = g_hdb->_gfx->loadPic(CLUBUP2); - g_hdb->_ai->_clubUpGfx[2] = g_hdb->_gfx->loadPic(CLUBUP3); - g_hdb->_ai->_clubUpGfx[3] = g_hdb->_gfx->loadPic(CLUBUP3); - - g_hdb->_ai->_clubDownGfx[0] = g_hdb->_gfx->loadPic(CLUBDOWN1); - g_hdb->_ai->_clubDownGfx[1] = g_hdb->_gfx->loadPic(CLUBDOWN2); - g_hdb->_ai->_clubDownGfx[2] = g_hdb->_gfx->loadPic(CLUBDOWN3); - g_hdb->_ai->_clubDownGfx[3] = g_hdb->_gfx->loadPic(CLUBDOWN3); - - g_hdb->_ai->_clubLeftGfx[0] = g_hdb->_gfx->loadPic(CLUBLEFT1); - g_hdb->_ai->_clubLeftGfx[1] = g_hdb->_gfx->loadPic(CLUBLEFT2); - g_hdb->_ai->_clubLeftGfx[2] = g_hdb->_gfx->loadPic(CLUBLEFT3); - g_hdb->_ai->_clubLeftGfx[3] = g_hdb->_gfx->loadPic(CLUBLEFT3); - - g_hdb->_ai->_clubRightGfx[0] = g_hdb->_gfx->loadPic(CLUBRIGHT1); - g_hdb->_ai->_clubRightGfx[1] = g_hdb->_gfx->loadPic(CLUBRIGHT2); - g_hdb->_ai->_clubRightGfx[2] = g_hdb->_gfx->loadPic(CLUBRIGHT3); - g_hdb->_ai->_clubRightGfx[3] = g_hdb->_gfx->loadPic(CLUBRIGHT3); + g_hdb->_ai->_clubUpGfx[0] = g_hdb->_gfx->getPicGfx(CLUBUP1, -1); + g_hdb->_ai->_clubUpGfx[1] = g_hdb->_gfx->getPicGfx(CLUBUP2, -1); + g_hdb->_ai->_clubUpGfx[2] = g_hdb->_gfx->getPicGfx(CLUBUP3, -1); + g_hdb->_ai->_clubUpGfx[3] = g_hdb->_gfx->getPicGfx(CLUBUP3, -1); + + g_hdb->_ai->_clubDownGfx[0] = g_hdb->_gfx->getPicGfx(CLUBDOWN1, -1); + g_hdb->_ai->_clubDownGfx[1] = g_hdb->_gfx->getPicGfx(CLUBDOWN2, -1); + g_hdb->_ai->_clubDownGfx[2] = g_hdb->_gfx->getPicGfx(CLUBDOWN3, -1); + g_hdb->_ai->_clubDownGfx[3] = g_hdb->_gfx->getPicGfx(CLUBDOWN3, -1); + + g_hdb->_ai->_clubLeftGfx[0] = g_hdb->_gfx->getPicGfx(CLUBLEFT1, -1); + g_hdb->_ai->_clubLeftGfx[1] = g_hdb->_gfx->getPicGfx(CLUBLEFT2, -1); + g_hdb->_ai->_clubLeftGfx[2] = g_hdb->_gfx->getPicGfx(CLUBLEFT3, -1); + g_hdb->_ai->_clubLeftGfx[3] = g_hdb->_gfx->getPicGfx(CLUBLEFT3, -1); + + g_hdb->_ai->_clubRightGfx[0] = g_hdb->_gfx->getPicGfx(CLUBRIGHT1, -1); + g_hdb->_ai->_clubRightGfx[1] = g_hdb->_gfx->getPicGfx(CLUBRIGHT2, -1); + g_hdb->_ai->_clubRightGfx[2] = g_hdb->_gfx->getPicGfx(CLUBRIGHT3, -1); + g_hdb->_ai->_clubRightGfx[3] = g_hdb->_gfx->getPicGfx(CLUBRIGHT3, -1); g_hdb->_ai->_clubUpFrames = g_hdb->_ai->_clubDownFrames = g_hdb->_ai->_clubLeftFrames = g_hdb->_ai->_clubRightFrames = 4; diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp index 5ebffe2578..d3e5e75df2 100644 --- a/engines/hdb/gfx.cpp +++ b/engines/hdb/gfx.cpp @@ -542,14 +542,7 @@ Tile *Gfx::getTileGfx(const char *name, int32 size) { GfxCache *gc = new GfxCache; strcpy(gc->name, name); - - Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_TILE32); - - Tile *gfxTile = new Tile; - gfxTile->load(stream); - delete stream; - - gc->tileGfx = gfxTile; + gc->tileGfx = loadTile(name); gc->status = false; if (size == -1) size = g_hdb->_fileMan->getLength(name, TYPE_TILE32); @@ -583,14 +576,7 @@ Picture *Gfx::getPicGfx(const char *name, int32 size) { GfxCache *gc = new GfxCache; strcpy(gc->name, name); - - Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_TILE32); - - Picture *gfxPic = new Picture; - gfxPic->load(stream); - delete stream; - - gc->picGfx = gfxPic; + gc->picGfx = loadPic(name); gc->status = true; if (size == -1) size = g_hdb->_fileMan->getLength(name, TYPE_PIC); |