(svn r25043) -Change [FS#3764]: Only display subtypes in the refit GUI which are available for all selected vehicles. Also add a generic list item to refit while keeping the subtypes of individual vehicles.

This commit is contained in:
frosch
2013-02-24 16:43:24 +00:00
parent ddfbe086ed
commit f81b2246fc
2 changed files with 71 additions and 13 deletions

View File

@@ -144,6 +144,20 @@ public:
return &this->data[begin];
}
/**
* Set the size of the vector, effectively truncating items from the end or appending uninitialised ones.
* @param num_items Target size.
*/
inline void Resize(uint num_items)
{
this->items = num_items;
if (this->items > this->capacity) {
this->capacity = Align(this->items, S);
this->data = ReallocT(this->data, this->capacity);
}
}
/**
* Search for the first occurrence of an item.
* The '!=' operator of T is used for comparison.
@@ -212,6 +226,21 @@ public:
*item = this->data[--this->items];
}
/**
* Remove items from the vector while preserving the order of other items.
* @param pos First item to remove.
* @param count Number of consecutive items to remove.
*/
void ErasePreservingOrder(uint pos, uint count = 1)
{
if (count == 0) return;
assert(pos < this->items);
assert(pos + count <= this->items);
this->items -= count;
uint to_move = this->items - pos;
if (to_move > 0) MemMoveT(this->data + pos, this->data + pos + count, to_move);
}
/**
* Tests whether a item is present in the vector, and appends it to the end if not.
* The '!=' operator of T is used for comparison.