From 83f1ab6d25e38ddaad160722099672e8db3ad582 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 29 Mar 2016 00:44:57 +0200 Subject: [PATCH] Add a time threshold to the removing of preloaded cells when the maximum cache size is reached (Bug #3273) --- apps/openmw/mwworld/cellpreloader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/cellpreloader.cpp b/apps/openmw/mwworld/cellpreloader.cpp index 349bc081f..a8f146024 100644 --- a/apps/openmw/mwworld/cellpreloader.cpp +++ b/apps/openmw/mwworld/cellpreloader.cpp @@ -204,6 +204,7 @@ namespace MWWorld // throw out oldest cell to make room PreloadMap::iterator oldestCell = mPreloadCells.begin(); double oldestTimestamp = DBL_MAX; + double threshold = 1.0; // seconds for (PreloadMap::iterator it = mPreloadCells.begin(); it != mPreloadCells.end(); ++it) { if (it->second.mTimeStamp < oldestTimestamp) @@ -213,7 +214,10 @@ namespace MWWorld } } - mPreloadCells.erase(oldestCell); + if (oldestTimestamp + threshold < timestamp) + mPreloadCells.erase(oldestCell); + else + return; } osg::ref_ptr item (new PreloadItem(cell, mResourceSystem->getSceneManager(), mBulletShapeManager, mResourceSystem->getKeyframeManager(), mTerrain));