@@ -497,33 +497,39 @@ uint ShowRefitOptionsList(int x, int y,
* so, invert the cargo types to list those that we can't refit to. */
if (CountBits(cmask ^ lmask) < CountBits(cmask)) {
cmask ^= lmask;
b = InlineString(b, STR_PURCHASE_INFO_ALL_BUT);
}
bool first = true;
/* Add each cargo type to the list */
for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
if (!HasBit(cmask, cid)) continue;
if (b >= lastof(_userstring) - (2 + 2 * 4)) break; // ", " and two calls to Utf8Encode()
if (!first) b = strecpy(b, ", ", lastof(_userstring));
first = false;
b = InlineString(b, GetCargo(cid)->name);
/* Terminate and display the completed string */
*b = '\0';
/* Make sure we detect any buffer overflow */
assert(b < endof(_userstring));
return DrawStringMultiLine(x, y, STR_SPEC_USERSTRING, w);
/* if the sorting criteria had the same value, sort vehicle by unitnumber */
#define VEHICLEUNITNUMBERSORTER(r, a, b) {if (r == 0) {r = a->unitnumber - b->unitnumber;}}
static int CDECL VehicleNumberSorter(const void *a, const void *b)
{
const Vehicle* va = *(const Vehicle**)a;
const Vehicle* vb = *(const Vehicle**)b;
int r = va->unitnumber - vb->unitnumber;