xna-cncnet-client icon indicating copy to clipboard operation
xna-cncnet-client copied to clipboard

Refine name checking code and Add feature AutoRemoveNonASCIIFromName

Open SadPencil opened this issue 4 years ago • 6 comments

This PR changes the behavior of DTA client:

  • If the player name contains non-ASCII characters, replace them with '?'. This can be turned off by set AutoRemoveNonASCIIFromName as false in the ini file.
  • Remove the unwanted invisible control characters.
  • Will also check the new player name saved from the setting dialog.
  • Refactor the code of checking offline player name, so that the code can be invoked in two places, i.e. when the client is starting as well as when user saved a new player name.

Explanation of AutoRemoveNonASCIIFromName:

When the player name contains any non-ASCII characters, one of the following things happens:

  • The name is not correctly displayed. Example: DTA, YR
  • The game crashed. Example: Ares 3.0

Merging this PR to the repo solves this issue with minimal changes. And it's mostly benifiticial to users in East Asian.

SadPencil avatar Dec 12 '20 14:12 SadPencil

Tiberian Sun (DTA) at least uses Windows-1252 encoding for the names rather than ASCII, so it might be preferable to support Windows-1252 characters instead of ASCII only for offline play.

Rampastring avatar Dec 13 '20 09:12 Rampastring

YR has full Unicode support internally, it's just that the font file is missing some codepages. I don't think that should be fixed here for YR, we just need to provide correct font files. I am not sure how did you get Ares to crash with Unicode characters.

Metadorius avatar Dec 13 '20 10:12 Metadorius

YR has full Unicode support internally, it's just that the font file is missing some codepages. I don't think that should be fixed here for YR, we just need to provide correct font files. I am not sure how did you get Ares to crash with Unicode characters.

An example is Mental Omega 3.3.5 which includes Ares 3.0. Ares 3.0 will ignore any non-ASCII characters, so that the player name can be empty (all characters are ignored by Ares), and then Ares crashes.

Take the following player name as an example. You can copy&paste it to the DTA client.

中文测试

SadPencil avatar Dec 13 '20 13:12 SadPencil

Tiberian Sun (DTA) at least uses Windows-1252 encoding for the names rather than ASCII, so it might be preferable to support Windows-1252 characters instead of ASCII only for offline play.

Currently, the DTA client writes the spawn.ini file with UTF-8 encoding, which means that any characters that takes more than one byte in UTF-8 (i.e. any non-ASCII characters) will be corrupted as long as the game doesn't recognize UTF-8.

SadPencil avatar Dec 13 '20 13:12 SadPencil

Tiberian Sun (DTA) at least uses Windows-1252 encoding for the names rather than ASCII, so it might be preferable to support Windows-1252 characters instead of ASCII only for offline play.

Take an example. The following text is supported by Windows-1252 encoding.

an example pain— if you’re

So, choose pain†as the player name. Is the player name displayed correctly after entering the game? (not in the DTA client)

SadPencil avatar Dec 13 '20 16:12 SadPencil

I set the default value of AutoRemoveNonASCIIFromName to false, so that the rest changes of this PR can be merged:

  • Remove the unwanted invisible control characters.
  • Will also check the new player name saved from the setting dialog.
  • Refactor the code of checking offline player name, so that the code can be invoked in two places, i.e. when the client is starting as well as when user saved a new player name.

And move the discussion of AutoRemoveNonASCIIFromName into an issue.

Currently, a user may enter the disallowed characters like , by setting the username at the setting dialog. This PR fixed it so that user can't bypass the name policy for offline playing.

SadPencil avatar Jan 04 '21 15:01 SadPencil