Don't attempt to preload more exterior cells than the cache can hold (Bug #3273)

openmw-39
scrawl 9 years ago
parent 83f1ab6d25
commit 5cda89c15d

@ -260,6 +260,11 @@ namespace MWWorld
mMaxCacheSize = num; mMaxCacheSize = num;
} }
unsigned int CellPreloader::getMaxCacheSize() const
{
return mMaxCacheSize;
}
void CellPreloader::setWorkQueue(osg::ref_ptr<SceneUtil::WorkQueue> workQueue) void CellPreloader::setWorkQueue(osg::ref_ptr<SceneUtil::WorkQueue> workQueue)
{ {
mWorkQueue = workQueue; mWorkQueue = workQueue;

@ -44,6 +44,8 @@ namespace MWWorld
/// The maximum number of preloaded cells. /// The maximum number of preloaded cells.
void setMaxCacheSize(unsigned int num); void setMaxCacheSize(unsigned int num);
unsigned int getMaxCacheSize() const;
void setWorkQueue(osg::ref_ptr<SceneUtil::WorkQueue> workQueue); void setWorkQueue(osg::ref_ptr<SceneUtil::WorkQueue> workQueue);
private: private:

@ -737,11 +737,14 @@ namespace MWWorld
{ {
int x = cell->getCell()->getGridX(); int x = cell->getCell()->getGridX();
int y = cell->getCell()->getGridY(); int y = cell->getCell()->getGridY();
unsigned int numpreloaded = 0;
for (int dx = -mHalfGridSize; dx <= mHalfGridSize; ++dx) for (int dx = -mHalfGridSize; dx <= mHalfGridSize; ++dx)
{ {
for (int dy = -mHalfGridSize; dy <= mHalfGridSize; ++dy) for (int dy = -mHalfGridSize; dy <= mHalfGridSize; ++dy)
{ {
mPreloader->preload(MWBase::Environment::get().getWorld()->getExterior(x+dx, y+dy), mRendering.getReferenceTime()); mPreloader->preload(MWBase::Environment::get().getWorld()->getExterior(x+dx, y+dy), mRendering.getReferenceTime());
if (++numpreloaded >= mPreloader->getMaxCacheSize())
break;
} }
} }
} }

Loading…
Cancel
Save