// nothing available to be removed.
long FGNewCache::get_oldest_tile() {
// we need to free the furthest entry
- long max_index = -1;
+ long min_index = -1;
double timestamp = 0.0;
double min_time = 2419200000.0f; // one month should be enough
double max_time = 0;
timestamp = e->get_timestamp();
if ( timestamp < min_time ) {
- max_index = index;
+ min_index = index;
min_time = timestamp;
}
if ( timestamp > max_time ) {
}
SG_LOG( SG_TERRAIN, SG_INFO, " min_time = " << min_time );
- SG_LOG( SG_TERRAIN, SG_INFO, " index = " << max_index );
+ SG_LOG( SG_TERRAIN, SG_INFO, " index = " << min_index );
SG_LOG( SG_TERRAIN, SG_INFO, " max_time = " << max_time );
- return max_index;
+ return min_index;
}
}
}
+
// Note this is the old version of FGNewCache::make_space(), currently disabled
// It uses distance from a center point to determine tiles to be discarded...
#if 0
state( Start ),
current_tile( NULL ),
vis( 16000 ),
- max_cache_size(100),
counter_hack(0)
{
}
if ( t == NULL ) {
// make space in the cache
- while ( (int)tile_cache.get_size() > max_cache_size ) {
+ while ( (int)tile_cache.get_size() > tile_cache.get_max_cache_size() ) {
long index = tile_cache.get_oldest_tile();
if ( index >= 0 ) {
FGTileEntry *old = tile_cache.get_tile( index );
exit(-1);
}
- SG_LOG( SG_TERRAIN, SG_INFO,
- "scheduling needed tiles for " << longitude << " " << latitude );
+ SG_LOG( SG_TERRAIN, SG_INFO,
+ "scheduling needed tiles for " << longitude << " " << latitude );
-// vis = fgGetDouble("/environment/visibility-m");
+ // vis = fgGetDouble("/environment/visibility-m");
double tile_width = curr_bucket.get_width_m();
double tile_height = curr_bucket.get_height_m();
xrange = (int)(vis / tile_width) + 1;
yrange = (int)(vis / tile_height) + 1;
- if ( xrange < 1 ) { xrange = 1; }
+ if ( xrange < 1 ) { xrange /= 1; }
if ( yrange < 1 ) { yrange = 1; }
- // cout << "xrange = " << xrange << " yrange = " << yrange << endl;
// note * 2 at end doubles cache size (for fdm and viewer)
- max_cache_size = (2*xrange + 2) * (2*yrange + 2) * 2;
+ tile_cache.set_max_cache_size( (2*xrange + 2) * (2*yrange + 2) * 2 );
+
+ /*
+ cout << "xrange = " << xrange << " yrange = " << yrange << endl;
+ cout << "max cache size = " << tile_cache.get_max_cache_size()
+ << " current cache size = " << tile_cache.get_size() << endl;
+ */
SGBucket b;