1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Issue #225: Fix for memleak when loading terrain.

This commit is contained in:
Lukasz Gromanowski 2012-04-01 21:29:49 +02:00
parent da5207f8e3
commit ae989040e5
3 changed files with 30 additions and 2 deletions

View File

@ -98,7 +98,10 @@ namespace MWRender
ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY);
if ( land != NULL ) if ( land != NULL )
{ {
land->loadData(); if (!land->dataLoaded)
{
land->loadData();
}
} }
//split the cell terrain into four segments //split the cell terrain into four segments
@ -420,7 +423,11 @@ namespace MWRender
ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY);
if ( land != NULL ) if ( land != NULL )
{ {
land->loadData(); if (!land->dataLoaded)
{
land->loadData();
}
return land->landData return land->landData
->textures[y * ESM::Land::LAND_TEXTURE_SIZE + x]; ->textures[y * ESM::Land::LAND_TEXTURE_SIZE + x];
} }

View File

@ -2,6 +2,24 @@
namespace ESM namespace ESM
{ {
Land::Land()
: flags(0)
, X(0)
, Y(0)
, mEsm(NULL)
, hasData(false)
, dataLoaded(false)
, landData(NULL)
{
}
Land::~Land()
{
delete landData;
}
void Land::load(ESMReader &esm) void Land::load(ESMReader &esm)
{ {
mEsm = &esm; mEsm = &esm;

View File

@ -11,6 +11,9 @@ namespace ESM
struct Land struct Land
{ {
Land();
~Land();
int flags; // Only first four bits seem to be used, don't know what int flags; // Only first four bits seem to be used, don't know what
// they mean. // they mean.
int X, Y; // Map coordinates. int X, Y; // Map coordinates.