From 12c583f4b88db94d6e321ea81ffd1ded8da01edd Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 6 Apr 2026 00:42:32 -0700
Subject: [PATCH] Don't assume the host player is in slot 0
---
game/gameinfo.cpp | 12 ++++++++++++
game/gameinfo.h | 1 +
game/lobby.cpp | 2 +-
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/game/gameinfo.cpp b/game/gameinfo.cpp
index eca76276..13ece0a3 100644
--- a/game/gameinfo.cpp
+++ b/game/gameinfo.cpp
@@ -521,6 +521,18 @@ GameInfo::BindPlayerToUI(int index, UIElement *element)
UpdateUI(player);
}
+void
+GameInfo::BindHostPlayerToUI(UIElement *element)
+{
+ Uint32 hostNodeID = nodes[HOST_NODE].nodeID;
+ for (int index = 0; index < MAX_PLAYERS; ++index) {
+ if (players[index].nodeID == hostNodeID) {
+ BindPlayerToUI(index, element);
+ break;
+ }
+ }
+}
+
void
GameInfo::UpdateUI()
{
diff --git a/game/gameinfo.h b/game/gameinfo.h
index dc8947b4..1e8193bd 100644
--- a/game/gameinfo.h
+++ b/game/gameinfo.h
@@ -220,6 +220,7 @@ class GameInfo
}
void BindPlayerToUI(int index, UIElement *element);
+ void BindHostPlayerToUI(UIElement *element);
void UpdateUI();
void UpdateUI(GameInfoPlayer *player);
diff --git a/game/lobby.cpp b/game/lobby.cpp
index e711ba8e..e0e28a7a 100644
--- a/game/lobby.cpp
+++ b/game/lobby.cpp
@@ -400,7 +400,7 @@ LobbyDialogDelegate::UpdateUI()
for (unsigned int i = 0; i < SDL_arraysize(m_gameListElements); ++i) {
if (i < m_gameList.length()) {
m_gameListElements[i]->Show();
- m_gameList[i].BindPlayerToUI(0, m_gameListElements[i]);
+ m_gameList[i].BindHostPlayerToUI(m_gameListElements[i]);
} else {
m_gameListElements[i]->Hide();
}