summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-12-20 18:29:53 +0000
committerfrosch <frosch@openttd.org>2013-12-20 18:29:53 +0000
commit62c0d42f929cca70402c074de7dc7e76e0c68a6c (patch)
tree41e32792891b79a6ab1e0def5132886642e0d75f /src/network
parentec492bfb7700b719e41553417cbe77c5d10549ae (diff)
downloadopenttd-62c0d42f929cca70402c074de7dc7e76e0c68a6c.tar.xz
(svn r26167) -Fix [FS#5834]: Certain hotkeys crashed the content GUI when the list was empty.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_content_gui.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 3297b0071..808c3ea23 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -750,7 +750,7 @@ public:
case WID_NCL_NAME:
if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
this->content.ToggleSortOrder();
- this->list_pos = this->content.Length() - this->list_pos - 1;
+ if (this->content.Length() > 0) this->list_pos = this->content.Length() - this->list_pos - 1;
} else {
this->content.SetSortType(widget - WID_NCL_CHECKBOX);
this->content.ForceResort();
@@ -844,7 +844,10 @@ public:
return ES_NOT_HANDLED;
}
- if (_network_content_client.Length() == 0) return ES_HANDLED;
+ if (this->content.Length() == 0) {
+ this->list_pos = 0; // above stuff may result in "-1".
+ return ES_HANDLED;
+ }
this->selected = *this->content.Get(this->list_pos);