Originally created by: mik...@noromaa.fi
Problem: Locating items in large FileCaches (tens of MB) took considerable time.
Reason: All offsets in TileList were always zeros. The code to compute these offsets was broken. It used Tile::totalOffset member that was never set. Cache-access worked because of a read loop in FileCache::getTile() that went through the whole MTEFileCache until the requested tile was found. Thus every FileCache access read the whole MTEFileCache from the start, causing items at the end to take a long time to load.
Fix: Removed all static offset-relatic members from the Tile class. The Tile class should handle a single tile only, it shouldn't store data related to tile-storage structures. I moved offset computation to the classes that handle tile storage: FileCache and RMS TileList. I also removed offsets from the MTEFileCache because I see no reason to store offsets which are basically pointers to the object itself. Since you can always get the correct offset directly from the file, storing offsets can only cause trouble as stored Tile objects cannot be freely moved inside the MTEFileCache file (if there would be a need someday).
Also added a warning if a requested tile wasn't found at exactly the specified offset. I believe this should never happen, but in case there is some case I didn't take into account, the warning can be removed.
Please note that this change in MTEFileCache storage format means that previous MTEFileCaches will not work with the patched version. Also note that other tools like CacheCreator must update their MTEFileCache code (very easy).