From 870669f856c61c1a9e9c7b782cab412c4859be88 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 15 Oct 2015 21:36:52 +0300 Subject: Remove old mana forgotten memory allocations from map. This can reduce memory usage by near 1 MB. --- src/resources/map/map.cpp | 68 +++++++++++++++++++---------------------------- src/resources/map/map.h | 5 ---- 2 files changed, 27 insertions(+), 46 deletions(-) (limited to 'src/resources/map') 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(BlockType::NB_BLOCKTYPES); i++) - { - mOccupation[i] = new unsigned[static_cast(size)]; - memset(mOccupation[i], 0, static_cast(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(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(type)][tileNum] < UINT_MAX && - (++mOccupation[static_cast(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(BlockType::NB_BLOCKTYPES)]; - const int mWidth; const int mHeight; const int mTileWidth; -- cgit v1.2.3-70-g09d2