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

Add log and client output for lobby server latency test result

Open pzhlkj6612 opened this issue 1 year ago • 5 comments

Problem

I got the following messages when joining the lobby in Mental Omega 3.3.6 with Chinese language pack:

[0:00 AM] 正在与 CnCNet 建立连接...
[0:00 AM] 当前网络质量较好的服务器数量:10

The English translation of the above messages is:

[0:00 AM] Connecting to CnCNet...
[0:00 AM] At present, the number of servers with better network quality: 10

The second message is wrong. Let me explain.

Explanation

I didn't write the code to display a message about the number of lobby servers. That Chinese message was added by the friends of the translation group. I guess that they may have misunderstood the code, thinking that the return value of the "GetServerListSortedByLatency()" function means the number of closer servers (i.e., servers with better network quality). But actually, it's the total number of candidates.

Here is the disassembly code from dnSpy/dnSpy:

// Token: 0x0600012D RID: 301 RVA: 0x00006FEC File Offset: 0x000051EC
private void ConnectToServer()
{
	IList<Server> serverListSortedByLatency = this.GetServerListSortedByLatency();
	this.connectionManager.OnGenericServerMessageReceived("当前网络质量较好的服务器数量:" + serverListSortedByLatency.Count.ToString());
	foreach (Server server in serverListSortedByLatency)

Although the message content is wrong, I think telling the player that how many lobby servers are available is a good idea, so I made this PR.

What's new

  • A message about the test result will be wrote to both the client and log file.
  • For the client message, L10N support is applied and the translation should be the value of the "UI:Main:LobbyServerLatencyTestResult" key.

Test

"Translation.ini":

[General]
LanguageTag=foo
LanguageName=bar
CultureInfo=zh-CN

[Translation]
UI:Main:LobbyServerLatencyTestResult=可用的大厅服务器数量为 {0},网络质量较好的有 {1}。

To make Chinese characters display correctly, I copied the "SpriteFont(\d).xnb" font files from MO 3.3.6.

In game:

[0:00 AM] Connecting to CnCNet...
[0:00 AM] 可用的大厅服务器数量为 10,网络质量较好的有 1。
[0:00 AM] Attempting connection to ...

After removing the translation:

[0:00 AM] Connecting to CnCNet...
[0:00 AM] Available lobby servers: 10, closer: 1.
[0:00 AM] Attempting connection to ...

It works.


See also #212 .


Hope this patch can be in the next sooooon version of MO ;)


/cc @SadPencil

pzhlkj6612 avatar Jul 24 '22 05:07 pzhlkj6612

Nightly build for this pull request:

  • artifacts.zip This comment is automatic and is meant to allow guests to get latest automatic builds without registering. It is updated on every successful build.

github-actions[bot] avatar Jul 24 '22 05:07 github-actions[bot]

I wrote that code in the private unofficial Chinese fork of CnCNet Client in MO 3.3.5. At that time "GetServerListSortedByLatency()" would filter out servers that does not allow pings. So in the private Chinese fork more network information is displayed since of course we are live in a country where any cross-country Internet connection may be unstable. In the private fork, the client would first tries these servers first, and then tries every server again as a fallback.

After your previous PR the function get fixed but I didn't realize the changed behavior. So in the private unofficial Chinese fork for MO 3.3.6 this message got preserved and yes it is wrong. Thanks for pointing it out. Since the translation features is now a part of the official client we don't need to distribute a forked exe anymore.

SadPencil avatar Jul 24 '22 05:07 SadPencil

@SadPencil , thank you for the detailed explanation. Now I know the whole story.


There is a question: do you think the word "available" in the "Available lobby servers" sentence is misleading? If so, do you have any suggestion?

pzhlkj6612 avatar Jul 24 '22 06:07 pzhlkj6612

@SadPencil , thank you for the detailed explanation. Now I know the whole story.

There is a question: do you think the word "available" in the "Available lobby servers" sentence is misleading? If so, do you have any suggestion?

I don't have an opinion against available but closer. Suggest: Lobby servers: {0} available, {1} fast.

SadPencil avatar Jul 24 '22 06:07 SadPencil

There is a question: do you think the word "available" in the "Available lobby servers" sentence is misleading? If so, do you have any suggestion?

I don't have an opinion against available but closer. Suggest: Lobby servers: {0} available, {1} fast.

Applied in 3b3a7cccf61bd6abb227c19f37dc5f8bfc6d0bd5 , thank you!


To maintainers:

I didn't make a force-push since I want to preserve the Git history here. If this PR is getting merged, please feel free to squash them.

pzhlkj6612 avatar Jul 24 '22 08:07 pzhlkj6612

To maintainers:

I didn't make a force-push since I want to preserve the Git history here. If this PR is getting merged, please feel free to squash them.

OK, I rebased this branch onto the latest "develop" branch and squashed the two commits. Please review my changes, thanks.

pzhlkj6612 avatar Nov 10 '22 05:11 pzhlkj6612