diff --git a/Assets/Scripts/ServerShared/DatabaseCache.cs b/Assets/Scripts/ServerShared/DatabaseCache.cs index b89b12724..9ca24bc12 100644 --- a/Assets/Scripts/ServerShared/DatabaseCache.cs +++ b/Assets/Scripts/ServerShared/DatabaseCache.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; @@ -66,6 +67,8 @@ public class DatabaseCache public T Get(Guid guid) where T : DatabaseEntry { + if (!_types.ContainsKey(typeof(T))) + return null; DatabaseEntry entry; _types[typeof(T)].TryGetValue(guid, out entry); return (T) entry; @@ -73,7 +76,7 @@ public class DatabaseCache public IEnumerable GetAll() { - return _types[typeof(T)].Values.Cast(); + return !_types.ContainsKey(typeof(T)) ? Enumerable.Empty() : _types[typeof(T)].Values.Cast(); } public void Delete(DatabaseEntry entry, bool remote = false)