Changeset - r16378:2be6f7e72c05
[Not reviewed]
master
0 1 0
planetmaker - 14 years ago 2010-11-06 20:12:20
planetmaker@openttd.org
(svn r21104) -Doc: Add doxygen commands to a few functions
1 file changed with 88 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -92,35 +92,53 @@ static const NWidgetPart _nested_build_v
 
};
 

	
 
/** Special cargo filter criteria */
 
static const CargoID CF_ANY  = CT_NO_REFIT; ///< Show all vehicles independent of carried cargo (i.e. no filtering)
 
static const CargoID CF_NONE = CT_INVALID;  ///< Show only vehicles which do not carry cargo (e.g. train engines)
 

	
 
static bool _internal_sort_order; // descending/ascending
 
static bool _internal_sort_order;           ///< false = descending, true = ascending
 
static byte _last_sort_criteria[]      = {0, 0, 0, 0};
 
static bool _last_sort_order[]         = {false, false, false, false};
 
static CargoID _last_filter_criteria[] = {CF_ANY, CF_ANY, CF_ANY, CF_ANY};
 

	
 
/**
 
 * Determines order of engines by engineID
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL EngineNumberSorter(const EngineID *a, const EngineID *b)
 
{
 
	int r = ListPositionOfEngine(*a) - ListPositionOfEngine(*b);
 

	
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/**
 
 * Determines order of engines by introduction date
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL EngineIntroDateSorter(const EngineID *a, const EngineID *b)
 
{
 
	const int va = Engine::Get(*a)->intro_date;
 
	const int vb = Engine::Get(*b)->intro_date;
 
	const int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/**
 
 * Determines order of engines by name
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL EngineNameSorter(const EngineID *a, const EngineID *b)
 
{
 
	static EngineID last_engine[2] = { INVALID_ENGINE, INVALID_ENGINE };
 
	static char     last_name[2][64] = { "\0", "\0" };
 

	
 
	const EngineID va = *a;
 
@@ -142,67 +160,103 @@ static int CDECL EngineNameSorter(const 
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/**
 
 * Determines order of engines by reliability
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL EngineReliabilitySorter(const EngineID *a, const EngineID *b)
 
{
 
	const int va = Engine::Get(*a)->reliability;
 
	const int vb = Engine::Get(*b)->reliability;
 
	const int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/**
 
 * Determines order of engines by purchase cost
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL EngineCostSorter(const EngineID *a, const EngineID *b)
 
{
 
	Money va = Engine::Get(*a)->GetCost();
 
	Money vb = Engine::Get(*b)->GetCost();
 
	int r = ClampToI32(va - vb);
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/**
 
 * Determines order of engines by speed
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL EngineSpeedSorter(const EngineID *a, const EngineID *b)
 
{
 
	int va = Engine::Get(*a)->GetDisplayMaxSpeed();
 
	int vb = Engine::Get(*b)->GetDisplayMaxSpeed();
 
	int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/**
 
 * Determines order of engines by power
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL EnginePowerSorter(const EngineID *a, const EngineID *b)
 
{
 
	int va = Engine::Get(*a)->GetPower();
 
	int vb = Engine::Get(*b)->GetPower();
 
	int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/**
 
 * Determines order of engines by running costs
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL EngineRunningCostSorter(const EngineID *a, const EngineID *b)
 
{
 
	Money va = Engine::Get(*a)->GetRunningCost();
 
	Money vb = Engine::Get(*b)->GetRunningCost();
 
	int r = ClampToI32(va - vb);
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/**
 
 * Determines order of engines by running costs
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL EnginePowerVsRunningCostSorter(const EngineID *a, const EngineID *b)
 
{
 
	const Engine *e_a = Engine::Get(*a);
 
	const Engine *e_b = Engine::Get(*b);
 

	
 
	/* Here we are using a few tricks to get the right sort.
 
@@ -219,12 +273,18 @@ static int CDECL EnginePowerVsRunningCos
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/* Train sorting functions */
 

	
 
/**
 
 * Determines order of train engines by capacity
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL TrainEngineCapacitySorter(const EngineID *a, const EngineID *b)
 
{
 
	const RailVehicleInfo *rvi_a = RailVehInfo(*a);
 
	const RailVehicleInfo *rvi_b = RailVehInfo(*b);
 

	
 
	int va = GetTotalCapacityOfArticulatedParts(*a) * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
 
@@ -233,36 +293,56 @@ static int CDECL TrainEngineCapacitySort
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/**
 
 * Determines order of train engines by engine / wagon
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL TrainEnginesThenWagonsSorter(const EngineID *a, const EngineID *b)
 
{
 
	int val_a = (RailVehInfo(*a)->railveh_type == RAILVEH_WAGON ? 1 : 0);
 
	int val_b = (RailVehInfo(*b)->railveh_type == RAILVEH_WAGON ? 1 : 0);
 
	int r = val_a - val_b;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/* Road vehicle sorting functions */
 

	
 
/**
 
 * Determines order of road vehicles by capacity
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL RoadVehEngineCapacitySorter(const EngineID *a, const EngineID *b)
 
{
 
	int va = GetTotalCapacityOfArticulatedParts(*a);
 
	int vb = GetTotalCapacityOfArticulatedParts(*b);
 
	int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/* Ship vehicle sorting functions */
 

	
 
/**
 
 * Determines order of ships by capacity
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL ShipEngineCapacitySorter(const EngineID *a, const EngineID *b)
 
{
 
	const Engine *e_a = Engine::Get(*a);
 
	const Engine *e_b = Engine::Get(*b);
 

	
 
	int va = e_a->GetDisplayDefaultCapacity();
 
@@ -272,12 +352,19 @@ static int CDECL ShipEngineCapacitySorte
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
 
	return _internal_sort_order ? -r : r;
 
}
 

	
 
/* Aircraft sorting functions */
 

	
 
/**
 
 * Determines order of aircraft by cargo
 
 * @param *a first engine to compare
 
 * @param *b second engine to compare
 
 * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal
 
 */
 
static int CDECL AircraftEngineCargoSorter(const EngineID *a, const EngineID *b)
 
{
 
	const Engine *e_a = Engine::Get(*a);
 
	const Engine *e_b = Engine::Get(*b);
 

	
 
	uint16 mail_a, mail_b;
0 comments (0 inline, 0 general)