diff options
author | Paul Gilbert | 2014-08-10 11:56:14 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-08-10 11:56:14 -0400 |
commit | 0e3f9e983d51759e0d6373e95c71b2130e7f181c (patch) | |
tree | 4bde4a6b2863572447766707cb5a1edbb1301176 /engines | |
parent | ba1f8b2f6bf7362d011d01aa7106e5bd6d38366d (diff) | |
download | scummvm-rg350-0e3f9e983d51759e0d6373e95c71b2130e7f181c.tar.gz scummvm-rg350-0e3f9e983d51759e0d6373e95c71b2130e7f181c.tar.bz2 scummvm-rg350-0e3f9e983d51759e0d6373e95c71b2130e7f181c.zip |
ACCESS: Changed _objectsTable from raw data array to SpriteResource array
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/access.cpp | 10 | ||||
-rw-r--r-- | engines/access/access.h | 2 | ||||
-rw-r--r-- | engines/access/amazon/amazon_game.cpp | 9 | ||||
-rw-r--r-- | engines/access/data.cpp | 6 | ||||
-rw-r--r-- | engines/access/data.h | 4 |
5 files changed, 21 insertions, 10 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index d194d8497f..27300f86a2 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -192,13 +192,17 @@ int AccessEngine::getRandomNumber(int maxNumber) { void AccessEngine::loadCells(Common::Array<RoomInfo::CellIdent> &cells) { for (uint i = 0; i < cells.size(); ++i) { - _objectsTable[cells[i]._cell] = _files->loadFile( - cells[i]._fileNum, cells[i]._subfile); + byte *spriteData = _files->loadFile(cells[i]._fileNum, cells[i]._subfile); + _objectsTable[cells[i]._cell] = new SpriteResource(this, + spriteData, _files->_filesize, DisposeAfterUse::YES); } } void AccessEngine::clearCellTable() { - Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr); + for (int i = 0; i < 100; ++i) { + delete _objectsTable[i]; + _objectsTable[i] = nullptr; + } } void AccessEngine::freeCells() { diff --git a/engines/access/access.h b/engines/access/access.h index 873eb3d0f7..5fa0aed1c7 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -118,7 +118,7 @@ public: ASurface *_current; ASurface _buffer1; ASurface _buffer2; - byte *_objectsTable[100]; + SpriteResource *_objectsTable[100]; int _establishTable[100]; bool _establishFlag; int _establishMode; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 5c2cda61aa..fe158125b5 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -125,8 +125,9 @@ void AmazonEngine::doTitle() { _screen->forceFadeIn(); _sound->playSound(1); - _objectsTable[0] = _files->loadFile(0, 2); - SpriteResource *spr = new SpriteResource(this, _objectsTable[0], _files->_filesize); + byte *spriteData = _files->loadFile(0, 2); + _objectsTable[0] = new SpriteResource(this, spriteData, _files->_filesize, + DisposeAfterUse::YES); _sound->playSound(1); @@ -143,11 +144,11 @@ void AmazonEngine::doTitle() { _buffer2.copyFrom(_buffer1); int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); - _screen->plotImage(spr, id, Common::Point(xp, 71)); + _screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71)); } // TODO: More to do - delete spr; + delete _objectsTable[0]; } void AmazonEngine::doOpening() { diff --git a/engines/access/data.cpp b/engines/access/data.cpp index ed913c9be9..3203020322 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -28,7 +28,8 @@ namespace Access { -SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size) { +SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size, + DisposeAfterUse::Flag disposeMemory) { Common::MemoryReadStream stream(data, size); Common::Array<uint32> offsets; int count = stream.readUint16LE(); @@ -52,6 +53,9 @@ SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size) _frames.push_back(frame); } + + if (disposeMemory == DisposeAfterUse::YES) + delete[] data; } SpriteResource::~SpriteResource() { diff --git a/engines/access/data.h b/engines/access/data.h index bd1e1563fc..bb5ef90e55 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/array.h" #include "common/rect.h" +#include "common/types.h" #include "graphics/surface.h" namespace Access { @@ -71,7 +72,8 @@ class SpriteResource { public: Common::Array<SpriteFrame *> _frames; public: - SpriteResource(AccessEngine *vm, const byte *data, uint32 size); + SpriteResource(AccessEngine *vm, const byte *data, uint32 size, + DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO); ~SpriteResource(); int getCount() { return _frames.size(); } |