mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
(svn r13275) -Fix: sort lists with 2 items, too
-Fix: reset VL_RESORT and resort timer even when no sort was needed
This commit is contained in:
parent
6e6014918e
commit
a509746288
@ -40,7 +40,7 @@ public: // Temporary: public for conversion only
|
|||||||
*/
|
*/
|
||||||
bool IsSortable() const
|
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)
|
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 */
|
/* Do not sort if the resort bit is not set */
|
||||||
if (!HASBITS(this->flags, VL_RESORT)) return;
|
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 *a = this->data;
|
||||||
T *b = a + 1;
|
T *b = a + 1;
|
||||||
|
|
||||||
@ -213,10 +217,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->ResetResortTimer();
|
|
||||||
|
|
||||||
CLRBITS(this->flags, VL_RESORT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user