Skip to content

Commit 8668ae4

Browse files
authored
Fix players starting game on wrong tunnel (CnCNet#837)
1 parent 0ec3482 commit 8668ae4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

DXMainClient/DXGUI/Multiplayer/GameLobby/CnCNetGameLobby.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ protected override void HostLaunchGame()
692692
sb.Append(";");
693693
sb.Append(Players[pId].Name);
694694
sb.Append(";");
695-
sb.Append("0.0.0.0:");
695+
sb.Append(tunnelHandler.CurrentTunnel.Address + ":");
696696
sb.Append(playerPorts[pId]);
697697
}
698698
channel.SendCTCPMessage(sb.ToString(), QueuedMessageType.SYSTEM_MESSAGE, 10);
@@ -1351,6 +1351,24 @@ private void NonHostLaunchGame(string sender, string message)
13511351
if (!success)
13521352
return;
13531353

1354+
if (pName == ProgramConstants.PLAYERNAME)
1355+
{
1356+
var matchedTunnel = tunnelHandler.Tunnels
1357+
.FirstOrDefault(t =>
1358+
string.Equals(t.Address, ipAndPort[0], StringComparison.OrdinalIgnoreCase));
1359+
1360+
if (matchedTunnel != null)
1361+
{
1362+
tunnelHandler.CurrentTunnel = matchedTunnel;
1363+
}
1364+
else
1365+
{
1366+
XNAMessageBox.Show(WindowManager, "Tunnel Error".L10N("Client:Main:TunnelErrorTitle"), "Failed to match the tunnel address provided by the host to any available tunnel. The game cannot be started.".L10N("Client:Main:TunnelErrorMessage"));
1367+
Logger.Log("Failed to match tunnel address: " + ipAndPort[0]);
1368+
return;
1369+
}
1370+
}
1371+
13541372
PlayerInfo pInfo = Players.Find(p => p.Name == pName);
13551373

13561374
if (pInfo == null)

0 commit comments

Comments
 (0)