Changeset - r9371:012afa66f9f0
[Not reviewed]
master
0 1 0
smatz - 16 years ago 2008-05-26 21:08:03
smatz@openttd.org
(svn r13275) -Fix: sort lists with 2 items, too
-Fix: reset VL_RESORT and resort timer even when no sort was needed
1 file changed with 8 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/sortlist_type.h
Show inline comments
 
@@ -40,7 +40,7 @@ public: // Temporary: public for convers
 
	 */
 
	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 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;
 

	
 
		/* Do not sort if the resort bit is not set */
 
		if (!HASBITS(this->flags, VL_RESORT)) return;
 

	
 
		T *a = this->data;
 
		T *b = a + 1;
 

	
 
@@ -213,10 +217,6 @@ public:
 
				}
 
			}
 
		}
 

	
 
		this->ResetResortTimer();
 

	
 
		CLRBITS(this->flags, VL_RESORT);
 
	}
 

	
 
	/**
0 comments (0 inline, 0 general)