summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-08-21 11:56:29 +0200
committerGitHub <noreply@github.com>2021-08-21 11:56:29 +0200
commit4066a07d8fec401dfcf275d6a4683ff72344133d (patch)
treebcd32f4e94657f8dad67301b8fda72dfd37884d8
parentb83820e7238a15b385b5aac51d7f29aef8f30bef (diff)
downloadopenttd-4066a07d8fec401dfcf275d6a4683ff72344133d.tar.xz
Fix: [Network] crash when last-joined server that is no longer available (#9503)
If you update the server-list while not having last-joined selected and it is no longer available, the game crashed.
-rw-r--r--src/network/network_gui.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index df2314cd7..6dd6c9c11 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -249,15 +249,21 @@ protected:
this->servers.clear();
bool found_current_server = false;
+ bool found_last_joined = false;
for (NetworkGameList *ngl = _network_game_list; ngl != nullptr; ngl = ngl->next) {
this->servers.push_back(ngl);
if (ngl == this->server) {
found_current_server = true;
}
+ if (ngl == this->last_joined) {
+ found_last_joined = true;
+ }
}
/* A refresh can cause the current server to be delete; so unselect. */
+ if (!found_last_joined) {
+ this->last_joined = nullptr;
+ }
if (!found_current_server) {
- if (this->server == this->last_joined) this->last_joined = nullptr;
this->server = nullptr;
this->list_pos = SLP_INVALID;
}