summaryrefslogtreecommitdiff
path: root/src/resources/map
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-29 21:03:25 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-29 21:03:25 +0300
commit10b7c4a1313395291a77c50189b31e9daf38a2b0 (patch)
tree8f0eea8bc2567b0431bb03d45126786cddddcf60 /src/resources/map
parent5f6e0176cc64824a28391070ddb249a6efff0b7c (diff)
downloadmanaplus-10b7c4a1313395291a77c50189b31e9daf38a2b0.tar.gz
manaplus-10b7c4a1313395291a77c50189b31e9daf38a2b0.tar.bz2
manaplus-10b7c4a1313395291a77c50189b31e9daf38a2b0.tar.xz
manaplus-10b7c4a1313395291a77c50189b31e9daf38a2b0.zip
Add memory counting into ObjectsLayer.
Diffstat (limited to 'src/resources/map')
-rw-r--r--src/resources/map/map.cpp3
-rw-r--r--src/resources/map/objectslayer.cpp6
-rw-r--r--src/resources/map/objectslayer.h10
3 files changed, 17 insertions, 2 deletions
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index 01f646877..7045706e1 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -1743,7 +1743,8 @@ int Map::calcMemoryChilds(const int level) const
mSpecialLayer->calcMemory(level + 1);
if (mTempLayer)
mTempLayer->calcMemory(level + 1);
- // +++ need calc mObjects
+ if (mObjects)
+ mObjects->calcMemory(level + 1);
// +++ need calc mHeights
return sz;
}
diff --git a/src/resources/map/objectslayer.cpp b/src/resources/map/objectslayer.cpp
index ea4f6a27f..7af758d7f 100644
--- a/src/resources/map/objectslayer.cpp
+++ b/src/resources/map/objectslayer.cpp
@@ -74,3 +74,9 @@ MapObjectList *ObjectsLayer::getAt(const unsigned x, const unsigned y) const
return nullptr;
return mTiles[x + y * mWidth];
}
+
+int ObjectsLayer::calcMemoryLocal() const
+{
+ return sizeof(ObjectsLayer) +
+ (sizeof(MapObjectList) + sizeof(MapObjectList*)) * mWidth * mHeight;
+}
diff --git a/src/resources/map/objectslayer.h b/src/resources/map/objectslayer.h
index 629b46426..09573a627 100644
--- a/src/resources/map/objectslayer.h
+++ b/src/resources/map/objectslayer.h
@@ -21,13 +21,15 @@
#ifndef RESOURCES_MAP_OBJECTSLAYER_H
#define RESOURCES_MAP_OBJECTSLAYER_H
+#include "resources/memorycounter.h"
+
#include <string>
#include "localconsts.h"
class MapObjectList;
-class ObjectsLayer final
+class ObjectsLayer final : public MemoryCounter
{
public:
ObjectsLayer(const unsigned width, const unsigned height);
@@ -42,6 +44,12 @@ class ObjectsLayer final
MapObjectList *getAt(const unsigned x,
const unsigned y) const A_WARN_UNUSED;
+
+ int calcMemoryLocal() const override final;
+
+ std::string getCounterName() const override final
+ { return "objects leyer"; }
+
private:
MapObjectList **mTiles;
unsigned mWidth;