From d72a59f5eaff97a140899b2488e3dc0ebd0034c1 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 15:07:49 +0100 Subject: [PATCH 01/10] Changed: Implement CI18N::setSystemLanguageCode, if we must force it Fixed: CI18N::getSystemLanguageCode under Windows (use 2 different methods) --- code/nel/include/nel/misc/i18n.h | 4 + code/nel/src/misc/i18n.cpp | 124 +++++++++++++++++++++++++++---- 2 files changed, 114 insertions(+), 14 deletions(-) diff --git a/code/nel/include/nel/misc/i18n.h b/code/nel/include/nel/misc/i18n.h index 1102a8907..5f270a490 100644 --- a/code/nel/include/nel/misc/i18n.h +++ b/code/nel/include/nel/misc/i18n.h @@ -127,6 +127,9 @@ public: /// Returns the code of the language ("fr", "en", ...) defined on system static std::string getSystemLanguageCode (); + /// Define the code of the language ("fr", "en", ...) defined on system + static bool setSystemLanguageCode (const std::string &languageCode); + /// Find a string in the selected language and return his association. static const ucstring &get (const std::string &label); @@ -230,6 +233,7 @@ private: static std::vector _LanguageCodes; static std::vector _LanguageNames; + static std::string _SystemLanguageCode; static bool _LanguagesNamesLoaded; diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index 2f1bee325..fc4cbf341 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -43,6 +43,7 @@ string CI18N::_SelectedLanguageCode; CI18N::ILoadProxy *CI18N::_LoadProxy = 0; vector CI18N::_LanguageCodes; vector CI18N::_LanguageNames; +std::string CI18N::_SystemLanguageCode; bool CI18N::noResolution = false; void CI18N::setLoadProxy(ILoadProxy *loadProxy) @@ -248,10 +249,8 @@ bool CI18N::isLanguageCodeSupported(const std::string &lang) std::string CI18N::getSystemLanguageCode () { - static std::string s_cachedSystemLanguage; - - if (!s_cachedSystemLanguage.empty()) - return s_cachedSystemLanguage; + if (!_SystemLanguageCode.empty()) + return _SystemLanguageCode; #ifdef NL_OS_MAC // under OS X, locale is only defined in console, not in UI @@ -317,7 +316,7 @@ std::string CI18N::getSystemLanguageCode () // only keep language code if supported by NeL if (isLanguageCodeSupported(lang)) { - s_cachedSystemLanguage = lang; + _SystemLanguageCode = lang; break; } } @@ -328,21 +327,118 @@ std::string CI18N::getSystemLanguageCode () } #endif - // use system locale (works under Linux and Windows) - if (s_cachedSystemLanguage.empty()) +#ifdef NL_OS_WINDOWS + // use user locale under Windows (since Vista) + if (_SystemLanguageCode.empty() && false) { - std::string lang = NLMISC::toLower(std::string(setlocale(LC_CTYPE, ""))); + // GetUserDefaultLocaleName prototype + typedef int (WINAPI* GetUserDefaultLocaleNamePtr)(LPWSTR lpLocaleName, int cchLocaleName); - // only keep 2 first characters - if (lang.size() > 1) - s_cachedSystemLanguage = lang.substr(0, 2); + // get pointer on GetUserDefaultLocaleName, kernel32.dll is always in memory so no need to call LoadLibrary + GetUserDefaultLocaleNamePtr nlGetUserDefaultLocaleName = (GetUserDefaultLocaleNamePtr)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetUserDefaultLocaleName"); + + // only use it if found + if (nlGetUserDefaultLocaleName) + { + // get user locale + wchar_t buffer[LOCALE_NAME_MAX_LENGTH]; + sint res = nlGetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH); + + // convert wide string to std::string + std::string lang = wideToUtf8(buffer); + + // only keep 2 first characters + if (lang.size() > 1) + _SystemLanguageCode = lang.substr(0, 2); + } + } +#endif + + // use system locale (works under OS X, Linux and Windows) + if (_SystemLanguageCode.empty()) + { + // get default locale + char *locale = setlocale(LC_CTYPE, ""); + + if (locale) + { + std::string lang(locale); + +#ifdef NL_OS_WINDOWS + // be sure supported languages are initialized + initLanguages(); + + // locales names are different under Windows, for example: French_France.1252 + for(uint i = 0; i < _LanguageNames.size(); ++i) + { + std::string name = _LanguageNames[i].toUtf8(); + + // so we compare the language name with the supported ones + if (lang.compare(0, name.length(), name) == 0) + { + // found, so use its code + _SystemLanguageCode = _LanguageCodes[i]; + break; + } + } +#else + std::string lang = NLMISC::toLower(lang); + + // only keep 2 first characters + if (lang.size() > 1) + _SystemLanguageCode = lang.substr(0, 2); +#endif + } } // english is default language - if (s_cachedSystemLanguage.empty()) - s_cachedSystemLanguage = "en"; + if (_SystemLanguageCode.empty()) + _SystemLanguageCode = "en"; - return s_cachedSystemLanguage; + return _SystemLanguageCode; +} + +bool CI18N::setSystemLanguageCode (const std::string &languageCode) +{ + // be sure supported languages are initialized + initLanguages(); + + std::string lang = NLMISC::toLower(languageCode); + + // specified language is really a code (2 characters) + if (lang.length() == 2) + { + // check if language code is supported + for(uint i = 0; i < _LanguageCodes.size(); ++i) + { + std::string code = NLMISC::toLower(_LanguageCodes[i]); + + if (lang == code) + { + // found, so use it + _SystemLanguageCode = lang; + return true; + } + } + } + // specified language is something else + else + { + // check if language name is supported + for(uint i = 0; i < _LanguageNames.size(); ++i) + { + std::string name = NLMISC::toLower(_LanguageNames[i].toUtf8()); + + if (name == lang) + { + // found, so use its code + _SystemLanguageCode = _LanguageCodes[i]; + return true; + } + } + } + + return false; } void CI18N::removeCComment(ucstring &commentedString) From b4de9e66f5243aff50d5f2e1e0120113defbe749 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 15:09:02 +0100 Subject: [PATCH 02/10] Fixed: Possible crashes if ov_info returns NULL --- code/nel/src/sound/audio_decoder_vorbis.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/nel/src/sound/audio_decoder_vorbis.cpp b/code/nel/src/sound/audio_decoder_vorbis.cpp index e438d43cc..1c11c32d7 100644 --- a/code/nel/src/sound/audio_decoder_vorbis.cpp +++ b/code/nel/src/sound/audio_decoder_vorbis.cpp @@ -195,13 +195,17 @@ uint32 CAudioDecoderVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 m uint8 CAudioDecoderVorbis::getChannels() { vorbis_info *vi = ov_info(&_OggVorbisFile, -1); - return (uint8)vi->channels; + if (vi) return (uint8)vi->channels; + nlwarning("ov_info returned NULL"); + return 0; } uint CAudioDecoderVorbis::getSamplesPerSec() { vorbis_info *vi = ov_info(&_OggVorbisFile, -1); - return (uint)vi->rate; + if (vi) return (uint)vi->rate; + nlwarning("ov_info returned NULL"); + return 0; } uint8 CAudioDecoderVorbis::getBitsPerSample() From f5e60a4feaa0f4b7fd175608a95a361273e63604 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 18:10:01 +0100 Subject: [PATCH 03/10] Changed: Init log before calling prelogInit() --- code/ryzom/client/src/client.cpp | 4 ++++ code/ryzom/client/src/init.cpp | 37 +++++++++++++++++++------------- code/ryzom/client/src/init.h | 3 +++ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index e4a77b3c6..1e140d3cc 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -289,6 +289,10 @@ int main(int argc, char **argv) #else // TODO for Linux : splashscreen + + // initialize log + initLog(); + #endif // initialize patch manager and set the ryzom full path, before it's used diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 864451718..18c8ba022 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -796,6 +796,28 @@ static bool addRyzomIconBitmap(const std::string &directory, vector &bi } #endif +//--------------------------------------------------- +// initLog : +// Initialize the client.log file +//--------------------------------------------------- +void initLog() +{ + // Add a displayer for Debug Infos. + createDebug(); + + // Client.Log displayer + nlassert( !ErrorLog->getDisplayer("CLIENT.LOG") ); + CFileDisplayer *ClientLogDisplayer = new CFileDisplayer(getLogDirectory() + "client.log", true, "CLIENT.LOG"); + DebugLog->addDisplayer (ClientLogDisplayer); + InfoLog->addDisplayer (ClientLogDisplayer); + WarningLog->addDisplayer (ClientLogDisplayer); + ErrorLog->addDisplayer (ClientLogDisplayer); + AssertLog->addDisplayer (ClientLogDisplayer); + + // Display the client version. + nlinfo("RYZOM VERSION : %s", getDebugVersion().c_str()); +} + //--------------------------------------------------- // prelogInit : // Initialize the application before login @@ -848,21 +870,6 @@ void prelogInit() // Due to Bug #906, we disable the stl xml allocation // nlverify (xmlMemSetup (XmlFree4NeL, XmlMalloc4NeL, XmlRealloc4NeL, XmlStrdup4NeL) == 0); - // Add a displayer for Debug Infos. - createDebug(); - - // Client.Log displayer - nlassert( !ErrorLog->getDisplayer("CLIENT.LOG") ); - CFileDisplayer *ClientLogDisplayer = new CFileDisplayer(getLogDirectory() + "client.log", true, "CLIENT.LOG"); - DebugLog->addDisplayer (ClientLogDisplayer); - InfoLog->addDisplayer (ClientLogDisplayer); - WarningLog->addDisplayer (ClientLogDisplayer); - ErrorLog->addDisplayer (ClientLogDisplayer); - AssertLog->addDisplayer (ClientLogDisplayer); - - // Display the client version. - nlinfo("RYZOM VERSION : %s", getDebugVersion().c_str()); - // Init the debug memory initDebugMemory(); diff --git a/code/ryzom/client/src/init.h b/code/ryzom/client/src/init.h index cdcdfb418..f179bf13d 100644 --- a/code/ryzom/client/src/init.h +++ b/code/ryzom/client/src/init.h @@ -27,6 +27,9 @@ namespace NLMISC class IProgressCallback; } +// Initialize the log +void initLog(); + // Initialize the application before login step void prelogInit(); From baa490ca9cba6b5241d0162e5c644b6f4ee5c265 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 22:06:20 +0100 Subject: [PATCH 04/10] Changed: Fix clang warnings --- code/nel/include/nel/gui/view_pointer.h | 14 +++++++------- code/ryzom/client/src/entity_cl.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/nel/include/nel/gui/view_pointer.h b/code/nel/include/nel/gui/view_pointer.h index 382135a92..1cc7a4b0c 100644 --- a/code/nel/include/nel/gui/view_pointer.h +++ b/code/nel/include/nel/gui/view_pointer.h @@ -71,13 +71,13 @@ namespace NLGUI private: /// Drawing helpers - virtual bool drawResizer(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawRotate(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawScale(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawColorPicker(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawLink(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawBrowse(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawPan(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawResizer(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawRotate(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawScale(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawColorPicker(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawLink(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawBrowse(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawPan(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } virtual bool drawCustom(CCtrlBase* pCB); protected: diff --git a/code/ryzom/client/src/entity_cl.h b/code/ryzom/client/src/entity_cl.h index fb04576bc..328ec1cc7 100644 --- a/code/ryzom/client/src/entity_cl.h +++ b/code/ryzom/client/src/entity_cl.h @@ -86,7 +86,7 @@ namespace NL3D class CEntitySheet; class CEntityCL; -class CAttackInfo; +struct CAttackInfo; class CItemSheet; From 97979c908310a4dd35a3173dc808a1f4c252d146 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 22:07:52 +0100 Subject: [PATCH 05/10] Changed: Don't need to use Windows functions with locale because the bug also occurs under Linux and OS X --- code/nel/include/nel/misc/i_xml.h | 3 -- code/nel/include/nel/misc/o_xml.h | 3 -- code/nel/src/misc/i_xml.cpp | 63 ++++++------------------------- code/nel/src/misc/o_xml.cpp | 22 ----------- 4 files changed, 12 insertions(+), 79 deletions(-) diff --git a/code/nel/include/nel/misc/i_xml.h b/code/nel/include/nel/misc/i_xml.h index 20ee8a7e0..b078eb7ee 100644 --- a/code/nel/include/nel/misc/i_xml.h +++ b/code/nel/include/nel/misc/i_xml.h @@ -236,9 +236,6 @@ private: // If not NULL, binary mode detected, use this stream in serials IStream *_BinaryStream; - - // System dependant structure for locale - void* _Locale; }; diff --git a/code/nel/include/nel/misc/o_xml.h b/code/nel/include/nel/misc/o_xml.h index 8346a6884..5bafacd60 100644 --- a/code/nel/include/nel/misc/o_xml.h +++ b/code/nel/include/nel/misc/o_xml.h @@ -181,9 +181,6 @@ private: // Error message std::string _ErrorString; - - // System dependant structure for locale - void* _Locale; }; diff --git a/code/nel/src/misc/i_xml.cpp b/code/nel/src/misc/i_xml.cpp index e722f3eee..fbd8f5d9f 100644 --- a/code/nel/src/misc/i_xml.cpp +++ b/code/nel/src/misc/i_xml.cpp @@ -24,11 +24,6 @@ // Include from libxml2 #include -#if defined(NL_OS_WINDOWS) && defined(NL_COMP_VC_VERSION) && NL_COMP_VC_VERSION >= 80 -#define USE_LOCALE_ATOF -#include -#endif - using namespace std; #define NLMISC_READ_BUFFER_SIZE 1024 @@ -46,26 +41,10 @@ const char SEPARATOR = ' '; // *************************************************************************** -#define readnumber(dest,thetype,digits,convfunc) \ +#define readnumber(dest,digits) \ string number_as_string; \ serialSeparatedBufferIn( number_as_string ); \ - dest = (thetype)convfunc( number_as_string.c_str() ); - -#ifdef USE_LOCALE_ATOF - -#define readnumberlocale(dest,thetype,digits,convfunc) \ - string number_as_string; \ - serialSeparatedBufferIn( number_as_string ); \ - dest = (thetype)convfunc( number_as_string.c_str(), (_locale_t)_Locale ); - -#define nl_atof _atof_l - -#else - -#define readnumberlocale(dest,thetype,digits,convfunc) readnumber(dest,thetype,digits,convfunc) -#define nl_atof atof - -#endif + NLMISC::fromString(number_as_string, dest); // *************************************************************************** @@ -91,13 +70,6 @@ CIXml::CIXml () : IStream (true /* Input mode */) _ErrorString = ""; _TryBinaryMode = false; _BinaryStream = NULL; - -#ifdef USE_LOCALE_ATOF - // create C numeric locale - _Locale = _create_locale(LC_NUMERIC, "C"); -#else - _Locale = NULL; -#endif } // *************************************************************************** @@ -113,13 +85,6 @@ CIXml::CIXml (bool tryBinaryMode) : IStream (true /* Input mode */) _ErrorString = ""; _TryBinaryMode = tryBinaryMode; _BinaryStream = NULL; - -#ifdef USE_LOCALE_ATOF - // create C numeric locale - _Locale = _create_locale(LC_NUMERIC, "C"); -#else - _Locale = NULL; -#endif } // *************************************************************************** @@ -128,10 +93,6 @@ CIXml::~CIXml () { // Release release (); - -#ifdef USE_LOCALE_ATOF - if (_Locale) _free_locale((_locale_t)_Locale); -#endif } // *************************************************************************** @@ -468,7 +429,7 @@ void CIXml::serial(uint8 &b) else { // Read the number - readnumber( b, uint8, 3, atoi ); + readnumber( b, 3 ); } } @@ -482,7 +443,7 @@ void CIXml::serial(sint8 &b) } else { - readnumber( b, sint8, 4, atoi ); + readnumber( b, 4 ); } } @@ -496,7 +457,7 @@ void CIXml::serial(uint16 &b) } else { - readnumber( b, uint16, 5, atoi ); + readnumber( b, 5 ); } } @@ -510,7 +471,7 @@ void CIXml::serial(sint16 &b) } else { - readnumber( b, sint16, 6, atoi ); + readnumber( b, 6 ); } } @@ -529,7 +490,7 @@ void CIXml::serial(uint32 &b) } else { - readnumber( b, uint32, 10, atoui ); + readnumber( b, 10 ); } } @@ -543,7 +504,7 @@ void CIXml::serial(sint32 &b) } else { - readnumber( b, sint32, 11, atoi ); + readnumber( b, 11 ); } } @@ -557,7 +518,7 @@ void CIXml::serial(uint64 &b) } else { - readnumber( b, uint64, 20, atoiInt64 ); + readnumber( b, 20 ); } } @@ -571,7 +532,7 @@ void CIXml::serial(sint64 &b) } else { - readnumber( b, sint64, 20, atoiInt64 ); + readnumber( b, 20 ); } } @@ -585,7 +546,7 @@ void CIXml::serial(float &b) } else { - readnumberlocale( b, float, 128, nl_atof ); + readnumber( b, 128 ); } } @@ -599,7 +560,7 @@ void CIXml::serial(double &b) } else { - readnumberlocale( b, double, 128, nl_atof ); + readnumber( b, 128 ); } } diff --git a/code/nel/src/misc/o_xml.cpp b/code/nel/src/misc/o_xml.cpp index d07362904..6df48ef80 100644 --- a/code/nel/src/misc/o_xml.cpp +++ b/code/nel/src/misc/o_xml.cpp @@ -43,22 +43,11 @@ const char SEPARATOR = ' '; // *************************************************************************** -#ifdef USE_LOCALE_SPRINTF - -#define writenumber(src,format,digits) \ - char number_as_cstring [digits+1]; \ - _sprintf_l( number_as_cstring, format, (_locale_t)_Locale, src ); \ - serialSeparatedBufferOut( number_as_cstring ); - -#else - #define writenumber(src,format,digits) \ char number_as_cstring [digits+1]; \ sprintf( number_as_cstring, format, src ); \ serialSeparatedBufferOut( number_as_cstring ); -#endif - // *************************************************************************** // XML callbacks // *************************************************************************** @@ -149,13 +138,6 @@ COXml::COXml () : IStream (false /* Output mode */) // Push begin _PushBegin = false; - -#ifdef USE_LOCALE_SPRINTF - // create C numeric locale - _Locale = _create_locale(LC_NUMERIC, "C"); -#else - _Locale = NULL; -#endif } // *************************************************************************** @@ -215,10 +197,6 @@ COXml::~COXml () { // Flush document to the internal stream flush (); - -#ifdef USE_LOCALE_SPRINTF - if (_Locale) _free_locale((_locale_t)_Locale); -#endif } // *************************************************************************** From b342f11949022b887ddc489e95801965159cbac7 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 22:08:43 +0100 Subject: [PATCH 06/10] Fixed: Set numeric locale in CApplicationContext --- code/nel/src/misc/app_context.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/nel/src/misc/app_context.cpp b/code/nel/src/misc/app_context.cpp index 2383fcda5..5206681f9 100644 --- a/code/nel/src/misc/app_context.cpp +++ b/code/nel/src/misc/app_context.cpp @@ -19,6 +19,8 @@ #include "nel/misc/dynloadlib.h" #include "nel/misc/command.h" +#include + #ifdef DEBUG_NEW #define new DEBUG_NEW #endif @@ -85,6 +87,9 @@ void INelContext::contextReady() _NelContext = this; *(_getInstance()) = this; + // set numeric locale to C to avoid the use of decimal separators different of a dot + char *locale = setlocale(LC_NUMERIC, "C"); + // register any pending thinks // register local instance counter in the global instance counter manager From 03715a64e0fc5c7c6f9ebfb8a25b2454ddd28011 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 22:09:26 +0100 Subject: [PATCH 07/10] Changed: Check if LC_NUMERIC is correct before loading or saving config files --- code/nel/src/misc/config_file/config_file.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/nel/src/misc/config_file/config_file.cpp b/code/nel/src/misc/config_file/config_file.cpp index 093992487..bab1c123b 100644 --- a/code/nel/src/misc/config_file/config_file.cpp +++ b/code/nel/src/misc/config_file/config_file.cpp @@ -316,6 +316,13 @@ CConfigFile::~CConfigFile () void CConfigFile::load (const string &fileName, bool lookupPaths ) { + char *locale = setlocale(LC_NUMERIC, NULL); + + if (!locale || strcmp(locale, "C")) + { + nlerror("Numeric locale not defined to C, an external library possibly redefined it!"); + } + if(fileName.empty()) { nlwarning ("CF: Can't load a empty file name configfile"); @@ -597,8 +604,12 @@ bool CConfigFile::exists (const std::string &varName) void CConfigFile::save () const { - // Avoid any problem, Force Locale to default - setlocale(LC_ALL, "C"); + char *locale = setlocale(LC_NUMERIC, NULL); + + if (!locale || strcmp(locale, "C")) + { + nlerror("Numeric locale not defined to C, an external library possibly redefined it!"); + } FILE *fp = nlfopen (getFilename(), "w"); if (fp == NULL) From bde61427a506b17b4cf017d32dabfd44bcf57ba2 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 22:09:43 +0100 Subject: [PATCH 08/10] Changed: Removed wrong check --- code/nel/src/misc/i18n.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index fc4cbf341..e230eab2d 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -329,7 +329,7 @@ std::string CI18N::getSystemLanguageCode () #ifdef NL_OS_WINDOWS // use user locale under Windows (since Vista) - if (_SystemLanguageCode.empty() && false) + if (_SystemLanguageCode.empty()) { // GetUserDefaultLocaleName prototype typedef int (WINAPI* GetUserDefaultLocaleNamePtr)(LPWSTR lpLocaleName, int cchLocaleName); From f728a518a144671e807e69bc23ec64fa91e2bdb5 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 22:10:19 +0100 Subject: [PATCH 09/10] Fixed: Move setrlimit after initializing logs --- code/ryzom/client/src/client.cpp | 26 +------------------ code/ryzom/client/src/init.cpp | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index 1e140d3cc..dcce43cc0 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -30,13 +30,6 @@ #include #endif -#ifdef NL_OS_MAC -#include -#include -#include "nel/misc/dynloadlib.h" -#include "app_bundle_utils.h" -#endif - #include "nel/misc/debug.h" #include "nel/misc/command.h" #include "nel/net/tcp_sock.h" @@ -226,23 +219,6 @@ int main(int argc, char **argv) } #endif // TEST_CRASH_COUNTER -#ifdef NL_OS_MAC - struct rlimit rlp, rlp2, rlp3; - - getrlimit(RLIMIT_NOFILE, &rlp); - - rlp2.rlim_cur = 1024; - rlp2.rlim_max = rlp.rlim_max; - setrlimit(RLIMIT_NOFILE, &rlp2); - - getrlimit(RLIMIT_NOFILE, &rlp3); - nlinfo("rlimit before %d %d\n", rlp.rlim_cur, rlp.rlim_max); - nlinfo("rlimit after %d %d\n", rlp3.rlim_cur, rlp3.rlim_max); - - // add the bundle's plugins path as library search path (for nel drivers) - CLibrary::addLibPath(getAppBundlePath() + "/Contents/PlugIns/nel/"); -#endif - #if defined(NL_OS_WINDOWS) #ifdef TEST_CRASH_COUNTER @@ -289,11 +265,11 @@ int main(int argc, char **argv) #else // TODO for Linux : splashscreen +#endif // initialize log initLog(); -#endif // initialize patch manager and set the ryzom full path, before it's used CPatchManager *pPM = CPatchManager::getInstance(); diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 18c8ba022..a55a09db9 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -105,6 +105,12 @@ extern HINSTANCE HInstance; extern HWND SlashScreen; #endif // NL_OS_WINDOWS +#ifdef NL_OS_MAC +#include +#include +#include "nel/misc/dynloadlib.h" +#endif + #include "app_bundle_utils.h" #include @@ -816,6 +822,43 @@ void initLog() // Display the client version. nlinfo("RYZOM VERSION : %s", getDebugVersion().c_str()); + +#ifdef NL_OS_MAC + struct rlimit rlp, rlp2, rlp3; + + getrlimit(RLIMIT_NOFILE, &rlp); + + rlim_t value = 1024; + + rlp2.rlim_cur = std::min(value, rlp.rlim_max); + rlp2.rlim_max = rlp.rlim_max; + + if (setrlimit(RLIMIT_NOFILE, &rlp2)) + { + if (errno == EINVAL) + { + nlwarning("Unable to set rlimit with error: the specified limit is invalid"); + } + else if (errno == EPERM) + { + nlwarning("Unable to set rlimit with error: the limit specified would have raised the maximum limit value and the caller is not the super-user"); + } + else + { + nlwarning("Unable to set rlimit with error: unknown error"); + } + } + + getrlimit(RLIMIT_NOFILE, &rlp3); + nlinfo("rlimit before %llu %llu", (uint64)rlp.rlim_cur, (uint64)rlp.rlim_max); + nlinfo("rlimit after %llu %llu", (uint64)rlp3.rlim_cur, (uint64)rlp3.rlim_max); + + // add the bundle's plugins path as library search path (for nel drivers) + if (CFile::isExists(getAppBundlePath() + "/Contents/PlugIns/nel")) + { + CLibrary::addLibPath(getAppBundlePath() + "/Contents/PlugIns/nel/"); + } +#endif } //--------------------------------------------------- From 2a53238ba3296610e41072b2e49fe1990c87e532 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 22:11:03 +0100 Subject: [PATCH 10/10] Changed: Use named arguments in uiFilterMenuDynamic translation --- .../ryzom/client/src/interface_v3/people_interraction.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index 62e6c0990..71cb5f7ec 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -2635,7 +2635,13 @@ public: { ucstring title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); - pMenu->addLineAtIndex(5 + insertion_index, title+" @{T8}/"+s, "chat_target_selected", "dyn"+s, "dyn"+s); + + // replace dynamic channel name and shortcut + ucstring res = CI18N::get("uiFilterMenuDynamic"); + strFindReplace(res, "%channel", title); + strFindReplace(res, "%shortcut", s); + + pMenu->addLineAtIndex(5 + insertion_index, res, "chat_target_selected", "dyn"+s, "dyn"+s); insertion_index++; } }