diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-10-15 21:36:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-10-15 21:36:52 +0300 |
commit | 870669f856c61c1a9e9c7b782cab412c4859be88 (patch) | |
tree | 8874d8a07977fa2f995fd27cbb057cee3f51294f | |
parent | 7b89705cc5c491b60dab923e2f8079cfc1f4bce1 (diff) | |
download | mv-870669f856c61c1a9e9c7b782cab412c4859be88.tar.gz mv-870669f856c61c1a9e9c7b782cab412c4859be88.tar.bz2 mv-870669f856c61c1a9e9c7b782cab412c4859be88.tar.xz mv-870669f856c61c1a9e9c7b782cab412c4859be88.zip |
Remove old mana forgotten memory allocations from map.
This can reduce memory usage by near 1 MB.
-rw-r--r-- | src/resources/map/map.cpp | 68 | ||||
-rw-r--r-- | src/resources/map/map.h | 5 |
2 files changed, 27 insertions, 46 deletions
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index e1407af91..bf32d9e0c 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -147,14 +147,6 @@ Map::Map(const int width, const int height, mCustom(false), mDrawOnlyFringe(false) { - const int size = mWidth * mHeight; - for (size_t i = 0; i < static_cast<size_t>(BlockType::NB_BLOCKTYPES); i++) - { - mOccupation[i] = new unsigned[static_cast<size_t>(size)]; - memset(mOccupation[i], 0, static_cast<size_t>(size) - * sizeof(unsigned)); - } - config.addListener("OverlayDetail", this); config.addListener("guialpha", this); config.addListener("beingopacity", this); @@ -171,8 +163,6 @@ Map::~Map() CHECKLISTENERS delete [] mMetaTiles; - for (size_t i = 0; i < static_cast<size_t>(BlockType::NB_BLOCKTYPES); i++) - delete [] mOccupation[i]; if (mWalkLayer) { @@ -697,38 +687,34 @@ void Map::blockTile(const int x, const int y, const int tileNum = x + y * mWidth; - if (mOccupation[static_cast<size_t>(type)][tileNum] < UINT_MAX && - (++mOccupation[static_cast<size_t>(type)][tileNum]) > 0) + switch (type) { - switch (type) - { - case BlockType::WALL: - mMetaTiles[tileNum].blockmask |= BlockMask::WALL; - break; - case BlockType::CHARACTER: - mMetaTiles[tileNum].blockmask |= BlockMask::CHARACTER; - break; - case BlockType::MONSTER: - mMetaTiles[tileNum].blockmask |= BlockMask::MONSTER; - break; - case BlockType::AIR: - mMetaTiles[tileNum].blockmask |= BlockMask::AIR; - break; - case BlockType::WATER: - mMetaTiles[tileNum].blockmask |= BlockMask::WATER; - break; - case BlockType::GROUND: - mMetaTiles[tileNum].blockmask |= BlockMask::GROUND; - break; - case BlockType::GROUNDTOP: - mMetaTiles[tileNum].blockmask |= BlockMask::GROUNDTOP; - break; - default: - case BlockType::NONE: - case BlockType::NB_BLOCKTYPES: - // Do nothing. - break; - } + case BlockType::WALL: + mMetaTiles[tileNum].blockmask |= BlockMask::WALL; + break; + case BlockType::CHARACTER: + mMetaTiles[tileNum].blockmask |= BlockMask::CHARACTER; + break; + case BlockType::MONSTER: + mMetaTiles[tileNum].blockmask |= BlockMask::MONSTER; + break; + case BlockType::AIR: + mMetaTiles[tileNum].blockmask |= BlockMask::AIR; + break; + case BlockType::WATER: + mMetaTiles[tileNum].blockmask |= BlockMask::WATER; + break; + case BlockType::GROUND: + mMetaTiles[tileNum].blockmask |= BlockMask::GROUND; + break; + case BlockType::GROUNDTOP: + mMetaTiles[tileNum].blockmask |= BlockMask::GROUNDTOP; + break; + default: + case BlockType::NONE: + case BlockType::NB_BLOCKTYPES: + // Do nothing. + break; } } diff --git a/src/resources/map/map.h b/src/resources/map/map.h index 49e0459f2..80f74e0ae 100644 --- a/src/resources/map/map.h +++ b/src/resources/map/map.h @@ -375,11 +375,6 @@ class Map final : public Properties, public ConfigListener */ bool contains(const int x, const int y) const A_WARN_UNUSED; - /** - * Blockmasks for different entities - */ - unsigned *mOccupation[static_cast<size_t>(BlockType::NB_BLOCKTYPES)]; - const int mWidth; const int mHeight; const int mTileWidth; |