Skip to content

Commit

Permalink
Improve user feedback for chat filter (#347)
Browse files Browse the repository at this point in the history
* Fix highlighting of prohibited words in chat

* Also highlight subsequent instances of a word
  • Loading branch information
enteryournamehere committed Sep 12, 2023
1 parent d0ccc63 commit 86e1754
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Uchu.World/Packets/Server/ChatModerationResponsePacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public override void SerializePacket(BitWriter writer)
writer.Write(ChatChannel);
writer.Write(ChatMode);

writer.WriteString(PlayerName, 33, true);
writer.WriteString(PlayerName, 42, true);

foreach (var (start, length) in UnacceptedRanges)
{
writer.Write(start);
writer.Write(length);
}

for (var i = 0; i < 32 - UnacceptedRanges.Length; i++)
for (var i = 0; i < 64 - UnacceptedRanges.Length; i++)
{
writer.Write<byte>(0);
writer.Write<byte>(0);
Expand Down
2 changes: 1 addition & 1 deletion Uchu.World/Social/Whitelist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void AddWord(string word)
if (allowed) continue;

// Add the bad word's position and length.
var position = (byte) phrase.IndexOf(word, StringComparison.Ordinal);
var position = (byte) (phrase.Substring(match.Index).IndexOf(word, StringComparison.Ordinal) + match.Index);
redact.Add((position, (byte) word.Length));
}

Expand Down

0 comments on commit 86e1754

Please sign in to comment.