Decrease RAM usage by at least 200MB

This was quite ridiculous.

TILESTATE_LAST = 1 << 24

Basically we were creating 2^24 Color structures within the array, each
of them has 4 floats (16 bytes) resulting in about 256 MB of extra
wasted memory.
master
Konrad Kuśnierz před 9 roky
rodič e4cdb3834b
revize 53dbbd2ba3

@ -394,6 +394,14 @@ void Map::setZoneColor(tileflags_t zone, const Color& color)
m_zoneColors[zone] = color;
}
Color Map::getZoneColor(tileflags_t flag)
{
auto it = m_zoneColors.find(flag);
if(it == m_zoneColors.end())
return Color::alpha;
return it->second;
}
void Map::setForceShowAnimations(bool force)
{
if(force) {

@ -196,7 +196,7 @@ public:
void setZoneOpacity(float opacity) { m_zoneOpacity = opacity; }
float getZoneOpacity() { return m_zoneOpacity; }
Color getZoneColor(tileflags_t flag) { return m_zoneColors[flag]; }
Color getZoneColor(tileflags_t flag);
tileflags_t getZoneFlags() { return (tileflags_t)m_zoneFlags; }
bool showZones() { return m_zoneFlags != 0; }
bool showZone(tileflags_t zone) { return (m_zoneFlags & zone) == zone; }
@ -257,7 +257,7 @@ private:
uint8 m_animationFlags;
uint32 m_zoneFlags;
std::array<Color, TILESTATE_LAST> m_zoneColors;
std::map<uint32, Color> m_zoneColors;
float m_zoneOpacity;
Light m_light;
@ -272,5 +272,3 @@ private:
extern Map g_map;
#endif
/* vim: set ts=4 sw=4 et: */

Načítá se…
Zrušit
Uložit