Changeset - r14925:076ddfff1625
[Not reviewed]
master
0 1 0
yexo - 15 years ago 2010-04-02 11:03:56
yexo@openttd.org
(svn r19538) -Fix: sorting industries by production was broken for newgrf industries
1 file changed with 7 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/industry_gui.cpp
Show inline comments
 
@@ -1009,18 +1009,14 @@ protected:
 
	/** Sort industries by production and name */
 
	static int CDECL IndustryProductionSorter(const Industry * const *a, const Industry * const *b)
 
	{
 
		int r = 0;
 
		uint prod_a = 0, prod_b = 0;
 
		for (uint i = 0; i < lengthof((*a)->produced_cargo); i++) {
 
			if ((*a)->produced_cargo[i] != CT_INVALID) prod_a += (*a)->last_month_production[i];
 
			if ((*b)->produced_cargo[i] != CT_INVALID) prod_b += (*b)->last_month_production[i];
 
		}
 
		int r = prod_a - prod_b;
 

	
 
		if ((*a)->produced_cargo[0] == CT_INVALID) {
 
			if ((*b)->produced_cargo[0] != CT_INVALID) return -1;
 
		} else {
 
			if ((*b)->produced_cargo[0] == CT_INVALID) return 1;
 

	
 
			r = ((*a)->last_month_production[0] + (*a)->last_month_production[1]) -
 
			    ((*b)->last_month_production[0] + (*b)->last_month_production[1]);
 
		}
 

	
 
		return (r == 0) ? IndustryNameSorter(a, b) : r;
 
		return (r == 0) ? IndustryTypeSorter(a, b) : r;
 
	}
 

	
 
	/** Sort industries by transported cargo and name */
0 comments (0 inline, 0 general)