Changeset 391 for binary-improvements2/7dtd-server-fixes/src/FileCache
- Timestamp:
- Aug 7, 2022, 3:02:24 PM (2 years ago)
- Location:
- binary-improvements2/7dtd-server-fixes/src/FileCache
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/7dtd-server-fixes/src/FileCache/DirectAccess.cs
r351 r391 7 7 public override byte[] GetFileContent (string _filename) { 8 8 try { 9 if (!File.Exists (_filename)) { 10 return null; 11 } 12 13 return File.ReadAllBytes (_filename); 9 return File.Exists (_filename) ? File.ReadAllBytes (_filename) : null; 14 10 } catch (Exception e) { 15 11 Log.Out ("Error in DirectAccess.GetFileContent: " + e); -
binary-improvements2/7dtd-server-fixes/src/FileCache/MapTileCache.cs
r351 r391 36 36 lock (cache) { 37 37 CurrentZoomFile cacheEntry = cache [_zoomlevel]; 38 39 if (cacheEntry.filename == null || !cacheEntry.filename.Equals (_filename)) {40 cacheEntry.filename = _filename;41 38 42 if (!File.Exists (_filename)) { 43 cacheEntry.pngData = null; 44 return null; 45 } 39 if (cacheEntry.filename != null && cacheEntry.filename.Equals (_filename)) { 40 return cacheEntry.pngData; 41 } 46 42 47 Profiler.BeginSample ("ReadPng"); 48 cacheEntry.pngData = ReadAllBytes (_filename); 49 Profiler.EndSample (); 43 cacheEntry.filename = _filename; 44 45 if (!File.Exists (_filename)) { 46 cacheEntry.pngData = null; 47 return null; 50 48 } 49 50 Profiler.BeginSample ("ReadPng"); 51 cacheEntry.pngData = ReadAllBytes (_filename); 52 Profiler.EndSample (); 51 53 52 54 return cacheEntry.pngData; … … 103 105 } 104 106 105 if (!File.Exists (_filename)) { 106 return transparentTile; 107 } 108 109 return ReadAllBytes (_filename); 107 return !File.Exists (_filename) ? transparentTile : ReadAllBytes (_filename); 110 108 } 111 109 } catch (Exception e) { -
binary-improvements2/7dtd-server-fixes/src/FileCache/SimpleCache.cs
r351 r391 11 11 try { 12 12 lock (fileCache) { 13 if (!fileCache.ContainsKey (_filename)) { 14 if (!File.Exists (_filename)) { 15 return null; 16 } 13 if (fileCache.ContainsKey (_filename)) { 14 return fileCache [_filename]; 15 } 17 16 18 fileCache.Add (_filename, File.ReadAllBytes (_filename)); 17 if (!File.Exists (_filename)) { 18 return null; 19 19 } 20 21 fileCache.Add (_filename, File.ReadAllBytes (_filename)); 20 22 21 23 return fileCache [_filename];
Note:
See TracChangeset
for help on using the changeset viewer.