Changeset - r13018:7caa31b19a80
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-09-13 17:38:07
rubidium@openttd.org
(svn r17526) -Codechange: use QSortT instead of qsort for sorting the language list in the network GUI
3 files changed with 6 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/network/network_gui.cpp
Show inline comments
 
@@ -28,12 +28,13 @@
 
#include "../settings_type.h"
 
#include "../widgets/dropdown_func.h"
 
#include "../querystring_gui.h"
 
#include "../sortlist_type.h"
 
#include "../company_base.h"
 
#include "../company_func.h"
 
#include "../core/sort_func.hpp"
 

	
 
#include "table/strings.h"
 
#include "../table/sprites.h"
 

	
 

	
 
static void ShowNetworkStartServerWindow();
 
@@ -60,13 +61,13 @@ void SortNetworkLanguages()
 
	if (_language_dropdown[0] == STR_NULL) {
 
		for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown[i] = STR_NETWORK_LANG_ANY + i;
 
		_language_dropdown[NETLANG_COUNT] = INVALID_STRING_ID;
 
	}
 

	
 
	/* Sort the strings (we don't move 'any' and the 'invalid' one) */
 
	qsort(&_language_dropdown[1], NETLANG_COUNT - 1, sizeof(StringID), &StringIDSorter);
 
	QSortT(_language_dropdown, NETLANG_COUNT - 1, &StringIDSorter);
 
}
 

	
 
enum {
 
	NET_PRC__OFFSET_TOP_WIDGET          = 54,
 
	NET_PRC__OFFSET_TOP_WIDGET_COMPANY  = 52,
 
	NET_PRC__SIZE_OF_ROW                = 14,
src/strings.cpp
Show inline comments
 
@@ -1347,20 +1347,18 @@ const char *GetCurrentLocale(const char 
 
	return getenv("LANG");
 
}
 
#else
 
const char *GetCurrentLocale(const char *param);
 
#endif /* !(defined(WIN32) || defined(__APPLE__)) */
 

	
 
int CDECL StringIDSorter(const void *a, const void *b)
 
int CDECL StringIDSorter(const StringID *a, const StringID *b)
 
{
 
	const StringID va = *(const StringID*)a;
 
	const StringID vb = *(const StringID*)b;
 
	char stra[512];
 
	char strb[512];
 
	GetString(stra, va, lastof(stra));
 
	GetString(strb, vb, lastof(strb));
 
	GetString(stra, *a, lastof(stra));
 
	GetString(strb, *b, lastof(strb));
 

	
 
	return strcmp(stra, strb);
 
}
 

	
 
/**
 
 * Checks whether the given language is already found.
src/strings_func.h
Show inline comments
 
@@ -97,13 +97,13 @@ static inline void CopyOutDParam(uint64 
 

	
 
extern DynamicLanguages _dynlang; // defined in strings.cpp
 

	
 
bool ReadLanguagePack(int index);
 
void InitializeLanguagePacks();
 

	
 
int CDECL StringIDSorter(const void *a, const void *b);
 
int CDECL StringIDSorter(const StringID *a, const StringID *b);
 

	
 
/** Key comparison function for std::map */
 
struct StringIDCompare
 
{
 
	bool operator()(StringID s1, StringID s2) const { return StringIDSorter(&s1, &s2) < 0; }
 
};
0 comments (0 inline, 0 general)