diff --git a/HellionChat/Ui/Components/ChunkRenderer.cs b/HellionChat/Ui/Components/ChunkRenderer.cs new file mode 100644 index 0000000..9b3a8f7 --- /dev/null +++ b/HellionChat/Ui/Components/ChunkRenderer.cs @@ -0,0 +1,48 @@ +using HellionChat.Themes; +using HellionChat.Util; +using Microsoft.Extensions.Logging; + +namespace HellionChat.Ui.Components; + +internal sealed class ChunkRenderer +{ + private readonly ThemeRegistry _themes; + private readonly FontManager _fonts; + private readonly ILogger _logger; + private readonly GameFunctions.GameFunctions _gameFunctions; + private readonly string _salt; + + public ChunkRenderer( + ThemeRegistry themes, + FontManager fonts, + ILogger logger, + GameFunctions.GameFunctions gameFunctions + ) + { + _themes = themes; + _fonts = fonts; + _logger = logger; + _gameFunctions = gameFunctions; + // Per-ctor random matches v1.5.6 ChatLogWindow behavior — hashed player + // names change every plugin reload to avoid stable cross-session linkage. + _salt = new Random().Next().ToString(); + + // Field references kept for C2 consumption; remove no-ops when DrawChunks lands. + _ = _themes; + _ = _fonts; + _ = _logger; + } + + private string HidePlayerInString(string str, string playerName, uint worldId) + { + var expected = _gameFunctions.Chat.AbbreviatePlayerName(playerName); + var hash = HashPlayer(playerName, worldId); + return str.Replace(playerName, expected).Replace(expected, hash); + } + + private string HashPlayer(string playerName, uint worldId) + { + var hashCode = $"{_salt}{playerName}{worldId}".GetHashCode(); + return $"Player {hashCode:X8}"; + } +}