Open GrantBartlett opened 1 year ago
This exception is most likely raised by string.Substring
method in Connection.cs
file. https://stackoverflow.com/questions/5633661/length-cannot-be-less-than-zero-on-a-blank-line
Need to attach a debugger and observe which command raises the exception.
Need to attach a debugger and observe which command raises the exception.
+1.
Printing stacktrace might be also helpful:
- Logger.Log("Unable to connect to the server. " + ex.Message);
+ Logger.Log("Unable to connect to the server. " + ex.Message + "\n" + ex.StackTrace);
21.07. 15:37:15.632 Unable to connect to the server. Length cannot be less than zero. (Parameter 'length')
at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
at System.String.Substring(Int32 startIndex, Int32 length)
at DTAClient.Online.Connection.HandleMessage(String message) in C:\Users\p\Desktop\CNCNET CLIENT STUFF\xna-cncnet-client\DXMainClient\Online\Connection.cs:line 515
at DTAClient.Online.Connection.HandleComm() in C:\Users\p\Desktop\CNCNET CLIENT STUFF\xna-cncnet-client\DXMainClient\Online\Connection.cs:line 276
at DTAClient.Online.Connection.ConnectToServer() in C:\Users\p\Desktop\CNCNET CLIENT STUFF\xna-cncnet-client\DXMainClient\Online\Connection.cs:line 204
private void HandleMessage(string message)
{
string msg = overMessage + message;
overMessage = "";
while (true)
{
int commandEndIndex = msg.IndexOf("\n");
if (commandEndIndex == -1) whatever;
else if (msg.Length != commandEndIndex + 1)
{
// throw exception here? so commandEndIndex is 0?
string command = msg.Substring(0, commandEndIndex - 1);
Seems like HandleMessage(message)
would fail when message
ends up with "\n"
diff --git a/DXMainClient/Online/Connection.cs b/DXMainClient/Online/Connection.cs
index ba1341ba..f8e8c570 100644
--- a/DXMainClient/Online/Connection.cs
+++ b/DXMainClient/Online/Connection.cs
@@ -499,7 +499,7 @@ namespace DTAClient.Online
/// <param name="message">The message.</param>
private void HandleMessage(string message)
{
- string msg = overMessage + message;
+ string msg = overMessage + message.Trim();
overMessage = "";
while (true)
{
Problem:
Some players from the RotE client are experiencing connection issues to GameSurge. They did not have this issue with the client before Net7 changes.
Client logs supplied from latest client:
Previous client.log working in cliente before all NET7 changes: