diff --git a/HellionChat/Message.cs b/HellionChat/Message.cs index 2d7420a..804747e 100755 --- a/HellionChat/Message.cs +++ b/HellionChat/Message.cs @@ -49,7 +49,10 @@ public partial class Message ExtraChatChannel = extraChatChannel; Hash = GenerateHash(); - foreach (var chunk in sender.Concat(content)) + // Iterate the processed Content list (returned by CheckMessageContent) + // rather than the raw constructor parameter — chunks added or replaced + // by CheckMessageContent must also have their back-reference set. + foreach (var chunk in Sender.Concat(Content)) chunk.Message = this; } diff --git a/HellionChat/Sheets.cs b/HellionChat/Sheets.cs index 3332f27..c65394e 100644 --- a/HellionChat/Sheets.cs +++ b/HellionChat/Sheets.cs @@ -37,7 +37,7 @@ public static class Sheets public static IEnumerable WorldsOnDatacenter(IPlayerCharacter character) { - var dcRow = character.HomeWorld.Value.DataCenter.Value.Region.RowId; - return WorldSheet.Where(world => world.IsPublic && world.DataCenter.Value.Region.RowId == dcRow); + var dcRow = character.HomeWorld.Value.DataCenter.RowId; + return WorldSheet.Where(world => world.IsPublic && world.DataCenter.RowId == dcRow); } } \ No newline at end of file diff --git a/HellionChat/Util/GlobalParametersCache.cs b/HellionChat/Util/GlobalParametersCache.cs index c4cbe11..adfba4a 100644 --- a/HellionChat/Util/GlobalParametersCache.cs +++ b/HellionChat/Util/GlobalParametersCache.cs @@ -10,10 +10,14 @@ public static class GlobalParametersCache public static int GetValue(int index) { - if (index < 0 || index >= Cache.Length) + // Capture the array reference once so the bounds check and the + // indexed read operate on the same instance, even if Refresh + // reassigns Cache between the two operations. + var cache = Cache; + if (index < 0 || index >= cache.Length) return 0; - return Cache[index]; + return cache[index]; } /// diff --git a/HellionChat/Util/IconUtil.cs b/HellionChat/Util/IconUtil.cs index 2821564..7697d41 100755 --- a/HellionChat/Util/IconUtil.cs +++ b/HellionChat/Util/IconUtil.cs @@ -59,8 +59,14 @@ public readonly unsafe ref struct GfdFileView return false; } + if (entries.Length == 0) + { + entry = default; + return false; + } + var lo = 0; - var hi = entries.Length; + var hi = entries.Length - 1; while (lo <= hi) { var i = lo + ((hi - lo) >> 1); @@ -70,7 +76,7 @@ public readonly unsafe ref struct GfdFileView { iconId = entries[i].Redirect; lo = 0; - hi = entries.Length; + hi = entries.Length - 1; continue; }