Skip to content

Commit c02740e

Browse files
committed
try fix russian & chinese characters blocked in chat
1 parent 3b18138 commit c02740e

File tree

1 file changed

+5
-54
lines changed

1 file changed

+5
-54
lines changed

src/ChatPatches.cs

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -181,68 +181,19 @@ public static class AllowAllCharacters_TextBoxTMP_IsCharAllowed_Prefix
181181
/// <param name="__result">Original return value of <c>IsCharAllowed</c>.</param>
182182
/// <param name="i"> The character to check.</param>
183183
/// <returns><c>false</c> to skip the original method, <c>true</c> to allow the original method to run.</returns>
184-
public static bool Prefix(TextBoxTMP __instance, ref bool __result, char i)
184+
public static bool Prefix(TextBoxTMP __instance, char i, ref bool __result)
185185
{
186-
// Original game code:
187-
// public bool IsCharAllowed(char i)
188-
// {
189-
// return this.IpMode ? i >= '0' && i <= '9' || i == '.' : i == ' ' || i >= 'A' && i <= 'Z' || i >= 'a' && i <= 'z' || i >= '0' && i <= '9' || i >= 'À' && i <= 'ÿ' || i >= 'Ѐ' && i <= 'џ' || i >= '\u3040' && i <= '㆟' || i >= 'ⱡ' && i <= '힣' || this.AllowSymbols && TextBoxTMP.SymbolChars.Contains(i) || this.AllowEmail && TextBoxTMP.EmailChars.Contains(i);
190-
// }
191-
192186
if (!AUnlocker.AllowAllCharacters.Value) return true;
193187

194-
if (i is >= 'À' and <= 'ÿ')
195-
{
196-
__result = true;
197-
return false;
198-
}
199-
if (i is >= 'Ѐ' and <= 'џ')
200-
{
201-
__result = true;
202-
return false;
203-
}
204-
if (i is >= '\u3040' and <= '㆟')
205-
{
206-
__result = true;
207-
return false;
208-
}
209-
if (i is >= 'ⱡ' and <= '힣')
210-
{
211-
__result = true;
212-
return false;
213-
}
214-
if (TextBoxTMP.SymbolChars.Contains(i))
215-
{
216-
__result = true;
217-
return false;
218-
}
219-
if (TextBoxTMP.EmailChars.Contains(i))
220-
{
221-
__result = true;
222-
return false;
223-
}
224-
// Bugfix: backspace messing with chat message;
225-
// newline / "enter" to prevent message sending "randomly" (see issue #25)
226-
if (i is '\b' or '\n' or '\r')
188+
// Bugfix: backspace and newline messing with chat message
189+
HashSet<char> blockedSymbols = ['\b', '\r'];
190+
191+
if (blockedSymbols.Contains(i))
227192
{
228193
__result = false;
229194
return false;
230195
}
231196

232-
// // logging
233-
// string charRepresentation = i switch
234-
// {
235-
// '\b' => "\\b",
236-
// '\n' => "\\n",
237-
// '\r' => "\\r",
238-
// _ => i.ToString()
239-
// };
240-
241-
// Debug.Log($"IsCharAllowed({charRepresentation}) (Unicode: {(int)i}) = {__result}");
242-
243-
// accept any other character by default (including emojis, special characters, etc.)
244-
// this can cause issues where we would have to deny certain characters
245-
// that are messing with the chatbox (like we saw in issues #25 and #31)
246197
__result = true;
247198
return false;
248199
}

0 commit comments

Comments
 (0)