src/industry_gui.cpp
changeset 10836 a9a253c9f626
parent 10775 7061477bfbcf
child 11161 7d0fac8f14cd
equal deleted inserted replaced
10835:976b9d25c2be 10836:a9a253c9f626
   804 
   804 
   805 	/** Sort industries by type and name */
   805 	/** Sort industries by type and name */
   806 	static int CDECL IndustryTypeSorter(const Industry* const *a, const Industry* const *b)
   806 	static int CDECL IndustryTypeSorter(const Industry* const *a, const Industry* const *b)
   807 	{
   807 	{
   808 		int r = (*a)->type - (*b)->type;
   808 		int r = (*a)->type - (*b)->type;
   809 		return (r = 0) ? IndustryNameSorter(a, b) : r;
   809 		return (r == 0) ? IndustryNameSorter(a, b) : r;
   810 	}
   810 	}
   811 
   811 
   812 	/** Sort industries by production and name */
   812 	/** Sort industries by production and name */
   813 	static int CDECL IndustryProductionSorter(const Industry* const *a, const Industry* const *b)
   813 	static int CDECL IndustryProductionSorter(const Industry* const *a, const Industry* const *b)
   814 	{
   814 	{
   815 		int r;
   815 		int r = 0;
   816 
   816 
   817 		if ((*a)->produced_cargo[0] == CT_INVALID) {
   817 		if ((*a)->produced_cargo[0] == CT_INVALID) {
   818 			if ((*b)->produced_cargo[0] != CT_INVALID) return -1;
   818 			if ((*b)->produced_cargo[0] != CT_INVALID) return -1;
   819 		} else {
   819 		} else {
   820 			if ((*b)->produced_cargo[0] == CT_INVALID) return 1;
   820 			if ((*b)->produced_cargo[0] == CT_INVALID) return 1;
   821 
   821 
   822 			r = ((*a)->last_month_production[0] + (*a)->last_month_production[1]) -
   822 			r = ((*a)->last_month_production[0] + (*a)->last_month_production[1]) -
   823 			    ((*b)->last_month_production[0] + (*b)->last_month_production[1]);
   823 			    ((*b)->last_month_production[0] + (*b)->last_month_production[1]);
   824 		}
   824 		}
   825 
   825 
   826 		return (r = 0) ? IndustryNameSorter(a, b) : r;
   826 		return (r == 0) ? IndustryNameSorter(a, b) : r;
   827 	}
   827 	}
   828 
   828 
   829 	/** Sort industries by transported cargo and name */
   829 	/** Sort industries by transported cargo and name */
   830 	static int CDECL IndustryTransportedCargoSorter(const Industry* const *a, const Industry* const *b)
   830 	static int CDECL IndustryTransportedCargoSorter(const Industry* const *a, const Industry* const *b)
   831 	{
   831 	{
   832 		int r = GetCargoTransportedSortValue(*a) - GetCargoTransportedSortValue(*b);
   832 		int r = GetCargoTransportedSortValue(*a) - GetCargoTransportedSortValue(*b);
   833 		return (r = 0) ? IndustryNameSorter(a, b) : r;
   833 		return (r == 0) ? IndustryNameSorter(a, b) : r;
   834 	}
   834 	}
   835 
   835 
   836 	/** Sort the industries list */
   836 	/** Sort the industries list */
   837 	void SortIndustriesList()
   837 	void SortIndustriesList()
   838 	{
   838 	{