Changeset - r24032:2642340de5b9
[Not reviewed]
master
0 1 0
Jonathan G Rennison - 5 years ago 2020-01-07 00:34:17
j.g.rennison@gmail.com
Fix: Non-deterministic name sorting in industry directory window

In the case where multiple industries have the same name, sorting
in the industry directory window is non-deterministic.
This results in the order changing on each re-sort, and is noticeable
when the industries have different production or transported values.
1 file changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/industry_gui.cpp
Show inline comments
 
@@ -1410,7 +1410,9 @@ protected:
 
			GetString(buf_cache, STR_INDUSTRY_NAME, lastof(buf_cache));
 
		}
 

	
 
		return strnatcmp(buf, buf_cache) < 0; // Sort by name (natural sorting).
 
		int r = strnatcmp(buf, buf_cache); // Sort by name (natural sorting).
 
		if (r == 0) return a->index < b->index;
 
		return r < 0;
 
	}
 

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