diff options
author | Eugene Sandulenko | 2019-07-13 00:58:07 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:18 +0200 |
commit | 9903b335e1f833539c6b58bb5811411e5f5bad49 (patch) | |
tree | 84e038b75921fd7c7894800543c4ff16223a5afb | |
parent | 24468bf630dbefb17d72211e5a8cbc67730dcd24 (diff) | |
download | scummvm-rg350-9903b335e1f833539c6b58bb5811411e5f5bad49.tar.gz scummvm-rg350-9903b335e1f833539c6b58bb5811411e5f5bad49.tar.bz2 scummvm-rg350-9903b335e1f833539c6b58bb5811411e5f5bad49.zip |
HDB: Proper memory handling for map features
-rw-r--r-- | engines/hdb/map.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp index 29183c8f16..86bd03fbac 100644 --- a/engines/hdb/map.cpp +++ b/engines/hdb/map.cpp @@ -30,6 +30,11 @@ Map::Map() { _animCycle = 0; _numForegrounds = _numGratings = 0; + + _mapExplosions = NULL; + _mapExpBarrels = NULL; + _mapLaserBeams = NULL; + } Map::~Map() { @@ -214,6 +219,14 @@ int Map::loadTiles() { void Map::restartSystem() { warning("STUB: Map::restartSystem()"); + + free(_mapExplosions); + free(_mapExpBarrels); + free(_mapLaserBeams); + + _mapExplosions = NULL; + _mapExpBarrels = NULL; + _mapLaserBeams = NULL; } bool Map::loadMap(char *name) { @@ -298,12 +311,9 @@ bool Map::load(Common::SeekableReadStream *stream) { TODO: Set the InMapName once its setup */ - _mapExplosions = new byte[_width * _height]; - memset(_mapExplosions, 0, sizeof(_mapExplosions)); - _mapExpBarrels = new byte[_width * _height]; - memset(_mapExpBarrels, 0, sizeof(_mapExpBarrels)); - _mapLaserBeams = new byte[_width * _height]; - memset(_mapLaserBeams, 0, sizeof(_mapLaserBeams)); + _mapExplosions = (byte *)calloc(_width * _height, 1); + _mapExpBarrels = (byte *)calloc(_width * _height, 1); + _mapLaserBeams = (byte *)calloc(_width * _height, 1); int sky = loadTiles(); g_hdb->_gfx->setSky(sky); |