summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-05-26 21:08:03 +0000
committersmatz <smatz@openttd.org>2008-05-26 21:08:03 +0000
commit75568d2df90426e037fd6154477da818fedaa243 (patch)
tree2b698ce8e8eca231c93589b338b6d194f0995f58 /src
parentb3d7ca0ceb6a9ba717e1bf0ee85459c6141054fc (diff)
downloadopenttd-75568d2df90426e037fd6154477da818fedaa243.tar.xz
(svn r13275) -Fix: sort lists with 2 items, too
-Fix: reset VL_RESORT and resort timer even when no sort was needed
Diffstat (limited to 'src')
-rw-r--r--src/sortlist_type.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/sortlist_type.h b/src/sortlist_type.h
index 3a8d2f0b9..5fe4a838e 100644
--- a/src/sortlist_type.h
+++ b/src/sortlist_type.h
@@ -40,7 +40,7 @@ public: // Temporary: public for conversion only
*/
bool IsSortable() const
{
- return (this->data != NULL && this->items > 2);
+ return (this->data != NULL && this->items >= 2);
}
/**
@@ -178,12 +178,16 @@ public:
* */
FORCEINLINE void Sort(SortFunction compare)
{
- /* Do not sort when the list is not sortable */
- if (!this->IsSortable()) return;
-
/* Do not sort if the resort bit is not set */
if (!HASBITS(this->flags, VL_RESORT)) return;
+ CLRBITS(this->flags, VL_RESORT);
+
+ this->ResetResortTimer();
+
+ /* Do not sort when the list is not sortable */
+ if (!this->IsSortable()) return;
+
T *a = this->data;
T *b = a + 1;
@@ -213,10 +217,6 @@ public:
}
}
}
-
- this->ResetResortTimer();
-
- CLRBITS(this->flags, VL_RESORT);
}
/**