summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-02-17 21:05:44 +0000
committerrubidium <rubidium@openttd.org>2011-02-17 21:05:44 +0000
commit1a5087be694a691bfc93390f18d751dc1ad0dea5 (patch)
tree4e28c9165c9ea49bdd9080c391ac32c96730e536 /src
parent848761e3a9928f86b381ff6cbfdaaca81080b487 (diff)
downloadopenttd-1a5087be694a691bfc93390f18d751dc1ad0dea5.tar.xz
(svn r22093) -Fix [FS#4514]: The server list did not get sorted with one item in it, so the "position in the list" variable was never updated causing problems when using the keyboard shortcuts for scrolling
Diffstat (limited to 'src')
-rw-r--r--src/network/network_gui.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 371e4dbe8..e62f2bcae 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -347,7 +347,12 @@ protected:
/** Sort the server list */
void SortNetworkGameList()
{
- if (!this->servers.Sort()) return;
+ bool did_sort = this->servers.Sort();
+ /* In case of 0 or 1 servers there is no sorting, thus this->list_pos
+ * isn't set to a "sane" value. So, we only take the short way out
+ * when we did not (re)sort and we have a valid this->list_pos, or
+ * there are no servers to actually select. */
+ if (!did_sort && (this->list_pos != SLP_INVALID || this->servers.Length() == 0)) return;
/* After sorting ngl->sort_list contains the sorted items. Put these back
* into the original list. Basically nothing has changed, we are only