diff options
author | skidd13 <skidd13@openttd.org> | 2008-05-27 10:27:30 +0000 |
---|---|---|
committer | skidd13 <skidd13@openttd.org> | 2008-05-27 10:27:30 +0000 |
commit | 831343435c1b5d9bdf932ad81e4144f8aa4bdcec (patch) | |
tree | fd62823c74718a114d36433d78d65548e47df97f | |
parent | 49010369d26d5749251d47e6bef313e9d92cef0f (diff) | |
download | openttd-831343435c1b5d9bdf932ad81e4144f8aa4bdcec.tar.xz |
(svn r13286) -Codechange: GUIList Sort returns now if the list sequence has been altered
-rw-r--r-- | src/sortlist_type.h | 16 | ||||
-rw-r--r-- | src/station_gui.cpp | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/sortlist_type.h b/src/sortlist_type.h index 7ae99dd6b..6e6d9c7fa 100644 --- a/src/sortlist_type.h +++ b/src/sortlist_type.h @@ -188,18 +188,19 @@ public: * sorted data. * * @param compare The function to compare two list items + * @return true if the list sequence has been altered * */ - FORCEINLINE void Sort(SortFunction *compare) + FORCEINLINE bool Sort(SortFunction *compare) { /* Do not sort if the resort bit is not set */ - if (!HASBITS(this->flags, VL_RESORT)) return; + if (!HASBITS(this->flags, VL_RESORT)) return false; CLRBITS(this->flags, VL_RESORT); this->ResetResortTimer(); /* Do not sort when the list is not sortable */ - if (!this->IsSortable()) return; + if (!this->IsSortable()) return false; const bool desc = HASBITS(this->flags, VL_DESC); @@ -207,7 +208,7 @@ public: qsort(this->data, this->items, sizeof(T), (int (CDECL *)(const void *, const void *))compare); if (desc) this->Reverse(); - return; + return true; } T *a = this->data; @@ -238,6 +239,7 @@ public: } } } + return true; } /** @@ -253,11 +255,13 @@ public: /** * Overload of Sort() * Overloaded to reduce external code + * + * @return true if the list sequence has been altered */ - void Sort() + bool Sort() { assert(this->func_list != NULL); - this->Sort(this->func_list[this->sort_type]); + return this->Sort(this->func_list[this->sort_type]); } /** diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 0f7cdf6e7..0d8f481d9 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -197,7 +197,7 @@ protected: /** Sort the stations list */ void SortStationsList() { - this->stations.Sort(); + if (!this->stations.Sort()) return; /* Reset name sorter sort cache */ this->last_station = NULL; |