https://github.com/libsdl-org/Maelstrom/commit/87c3cd636307874bc3ac7b55b1aeec927f487475
From 87c3cd636307874bc3ac7b55b1aeec927f487475 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 6 Nov 2011 11:17:07 -0500
Subject: [PATCH] Use the first address we saw for other players, since
presumably that was the fastest response. This isn't always true, but should
be most of the time.
---
netlogic/gameinfo.cpp | 5 ++++-
netlogic/lobby.cpp | 6 +++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/netlogic/gameinfo.cpp b/netlogic/gameinfo.cpp
index 5297c254..bcb873de 100644
--- a/netlogic/gameinfo.cpp
+++ b/netlogic/gameinfo.cpp
@@ -82,7 +82,10 @@ GameInfo::ReadFromPacket(DynamicPacket &packet)
}
// We want to get the public address of the server
- players[0].address = packet.address;
+ // If we already have one, we assume that's the fastest interface
+ if (!players[0].address.host) {
+ players[0].address = packet.address;
+ }
return true;
}
diff --git a/netlogic/lobby.cpp b/netlogic/lobby.cpp
index 00875bf1..42aa66b0 100644
--- a/netlogic/lobby.cpp
+++ b/netlogic/lobby.cpp
@@ -496,8 +496,8 @@ LobbyDialogDelegate::ProcessRequestJoin(DynamicPacket &packet)
int slot;
for (slot = 0; slot < MAX_PLAYERS; ++slot) {
if (playerID == m_game.players[slot].playerID) {
- // We already have this player, just update it.
- break;
+ // We already have this player, ignore it
+ return;
}
}
if (slot == MAX_PLAYERS) {
@@ -564,7 +564,7 @@ LobbyDialogDelegate::ProcessGameInfo(DynamicPacket &packet)
if (m_state == STATE_LISTING) {
// Add or update the game list
int i;
- for (int i = 0; i < m_gameList.length(); ++i) {
+ for (i = 0; i < m_gameList.length(); ++i) {
if (game.gameID == m_gameList[i].gameID) {
m_gameList[i].CopyFrom(game);
break;