From f5459a1b9b8443d733c2675ba3e142624e034528 Mon Sep 17 00:00:00 2001 From: SIELA1915 Date: Fri, 12 Feb 2016 18:28:23 +0100 Subject: [PATCH] merge from compatibility-develop --- code/CMakeLists.txt | 8 - code/CMakeModules/FindSteam.cmake | 74 + code/CMakeModules/nel.cmake | 9 +- code/nel/include/nel/misc/common.h | 4 + code/nel/include/nel/misc/path.h | 4 +- code/nel/include/nel/misc/string_common.h | 29 +- code/nel/src/3d/CMakeLists.txt | 2 +- code/nel/src/misc/common.cpp | 108 +- code/nel/src/misc/log.cpp | 6 +- code/nel/src/misc/path.cpp | 36 +- code/nel/src/misc/sheet_id.cpp | 2 +- .../tools/build_gamedata/d1_client_patch.py | 2 +- code/nel/tools/misc/bnp_make/main.cpp | 4 +- .../nel/tools/nel_unit_test/nel_unit_test.cpp | 14 + code/nel/tools/nel_unit_test/ut_misc.h | 2 + code/nel/tools/nel_unit_test/ut_misc_common.h | 171 ++ .../nel_unit_test/ut_misc_string_common.h | 90 +- code/ryzom/client/CMakeLists.txt | 1 - .../data/gamedev/interfaces_v3/compass.xml | 2 +- .../gamedev/interfaces_v3/game_config.xml | 10 +- .../data/gamedev/interfaces_v3/login_main.xml | 236 +- code/ryzom/client/src/CMakeLists.txt | 28 +- code/ryzom/client/src/client.cpp | 11 + code/ryzom/client/src/init.cpp | 19 +- code/ryzom/client/src/input.cpp | 2 +- code/ryzom/client/src/login.cpp | 8 +- code/ryzom/client/src/login.h | 4 +- code/ryzom/client/src/login_patch.cpp | 287 +- code/ryzom/client/src/login_patch.h | 4 - .../ryzom/client/src/seven_zip/CMakeLists.txt | 8 +- code/ryzom/client/src/seven_zip/seven_zip.cpp | 357 +++ code/ryzom/client/src/seven_zip/seven_zip.h | 31 + code/ryzom/client/src/steam_client.cpp | 358 +++ code/ryzom/client/src/steam_client.h | 65 + .../client/client_patcher/CMakeLists.txt | 2 +- .../tools/client/client_patcher/main.cpp | 158 +- .../leveldesign/georges_dll/CMakeLists.txt | 1 + .../world_editor/world_editor/CMakeLists.txt | 2 + .../world_editor/world_editor/stdafx.h | 1 + code/ryzom/tools/patch_gen/CMakeLists.txt | 6 +- .../tools/patch_gen/patch_gen_common.cpp | 34 +- .../translated/creature_words_de.txt | Bin 1489016 -> 1489008 bytes .../translated/creature_words_fr.txt | Bin 728738 -> 728594 bytes .../ryzom/tools/translation/translated/de.uxt | 12 +- .../ryzom/tools/translation/translated/en.uxt | 32 +- .../ryzom/tools/translation/translated/es.uxt | 16 +- .../translated/faction_words_es.txt | Bin 10670 -> 10662 bytes .../ryzom/tools/translation/translated/fr.uxt | 2371 +++++++++-------- .../translation/translated/title_words_de.txt | Bin 324170 -> 323756 bytes .../ryzom/tools/translation/translated/wk.uxt | 32 +- code/ryzom/tools/translation/work/wk.uxt | 14 +- code/tool/CMakeLists.txt | 1 + code/tool/bin2c/CMakeLists.txt | 8 + code/tool/bin2c/bin2c.cpp | 48 +- 54 files changed, 2992 insertions(+), 1742 deletions(-) create mode 100644 code/CMakeModules/FindSteam.cmake create mode 100644 code/nel/tools/nel_unit_test/ut_misc_common.h create mode 100644 code/ryzom/client/src/seven_zip/seven_zip.cpp create mode 100644 code/ryzom/client/src/seven_zip/seven_zip.h create mode 100644 code/ryzom/client/src/steam_client.cpp create mode 100644 code/ryzom/client/src/steam_client.h create mode 100644 code/tool/CMakeLists.txt create mode 100644 code/tool/bin2c/CMakeLists.txt diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 6ace237ed..b229d87a5 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -269,10 +269,6 @@ IF(WITH_QT5) # Gui SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::OpenGL) - IF(WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::WinExtras) - ENDIF() - ADD_QT_LIBRARY(PrintSupport) IF(WIN32) @@ -390,10 +386,6 @@ IF(WITH_QT5) ENDIF() ELSE() SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core) - - IF(WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::WinExtras) - ENDIF() ENDIF() ELSE() MESSAGE(WARNING "Unable to find Qt 5") diff --git a/code/CMakeModules/FindSteam.cmake b/code/CMakeModules/FindSteam.cmake new file mode 100644 index 000000000..44013e6ed --- /dev/null +++ b/code/CMakeModules/FindSteam.cmake @@ -0,0 +1,74 @@ +# - Locate Steam API +# This module defines +# STEAM_LIBRARY, the library to link against +# VORBIS_FOUND, if false, do not try to link to VORBIS +# VORBIS_INCLUDE_DIR, where to find headers. + +IF(STEAM_LIBRARY AND STEAM_INCLUDE_DIR) + # in cache already + SET(Steam_FIND_QUIETLY TRUE) +ENDIF() + + +FIND_PATH(STEAM_INCLUDE_DIR + steam_api.h + PATH_SUFFIXES steam + PATHS + $ENV{STEAM_DIR}/public +) + +IF(WIN32) + IF(TARGET_X64) + SET(STEAM_LIBNAME steam_api64) + SET(STEAM_RUNTIMENAME steam_api64.dll) + SET(STEAM_PATHNAME redistributable_bin/win64) + ELSE() + SET(STEAM_LIBNAME steam_api) + SET(STEAM_RUNTIMENAME steam_api.dll) + SET(STEAM_PATHNAME redistributable_bin) + ENDIF() +ELSEIF(APPLE) + # universal binary + SET(STEAM_LIBNAME steam_api) + SET(STEAM_RUNTIMENAME libsteam_api.dylib) + SET(STEAM_PATHNAME redistributable_bin/osx32) +ELSE() + SET(STEAM_LIBNAME steam_api) + SET(STEAM_RUNTIMENAME libsteam_api.so) + IF(TARGET_X64) + SET(STEAM_PATHNAME redistributable_bin/linux64) + ELSE() + SET(STEAM_PATHNAME redistributable_bin/linux32) + ENDIF() +ENDIF() + +FIND_LIBRARY(STEAM_LIBRARY + NAMES ${STEAM_LIBNAME} + HINTS + $ENV{STEAM_DIR}/${STEAM_PATHNAME} +) + +FIND_FILE(STEAM_RUNTIME + NAMES ${STEAM_RUNTIMENAME} + HINTS + $ENV{STEAM_DIR}/${STEAM_PATHNAME} + PATHS + ${EXTERNAL_BINARY_PATH} + ${CMAKE_LIBRARY_PATH} + /usr/local/lib + /usr/lib +) + +# Don't need to check STEAM_LIBRARY because we're dynamically loading Steam DLL +IF(STEAM_INCLUDE_DIR) + SET(STEAM_FOUND ON) + SET(STEAM_LIBRARIES ${STEAM_LIBRARY}) + SET(STEAM_INCLUDE_DIRS ${STEAM_INCLUDE_DIR}) + IF(NOT Steam_FIND_QUIETLY) + MESSAGE(STATUS "Found Steam: ${STEAM_INCLUDE_DIR} and ${STEAM_RUNTIME}") + ENDIF() +ELSE() + IF(NOT Steam_FIND_QUIETLY) + MESSAGE(STATUS "Warning: Unable to find Steam!") + ENDIF() +ENDIF() diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 1be1a63b9..2888e9a46 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -258,6 +258,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) OPTION(WITH_NELNS "Build NeL Network Services." OFF) OPTION(WITH_RYZOM "Build Ryzom Core." ON ) OPTION(WITH_SNOWBALLS "Build Snowballs." OFF) + OPTION(WITH_TOOLS "Build Tools" OFF) ENDMACRO(NL_SETUP_DEFAULT_OPTIONS) MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) @@ -1083,15 +1084,15 @@ MACRO(SETUP_EXTERNAL) IF(APPLE) IF(WITH_STATIC_EXTERNAL) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) - ELSE(WITH_STATIC_EXTERNAL) + ELSE() SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so .a) - ENDIF(WITH_STATIC_EXTERNAL) + ENDIF() ELSE(APPLE) IF(WITH_STATIC_EXTERNAL) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so) - ELSE(WITH_STATIC_EXTERNAL) + ELSE() SET(CMAKE_FIND_LIBRARY_SUFFIXES .so .a) - ENDIF(WITH_STATIC_EXTERNAL) + ENDIF() ENDIF(APPLE) ENDIF(WIN32) diff --git a/code/nel/include/nel/misc/common.h b/code/nel/include/nel/misc/common.h index 710a9e6df..3b5465eaa 100644 --- a/code/nel/include/nel/misc/common.h +++ b/code/nel/include/nel/misc/common.h @@ -336,6 +336,10 @@ void itoaInt64 (sint64 number, char *str, sint64 base = 10); std::string bytesToHumanReadable (const std::string &bytes); std::string bytesToHumanReadable (uint64 bytes); +/// Convert a number in bytes into a string that is easily readable by an human, for example 105123 -> "102kb" +/// Using units array as string: 0 => B, 1 => KiB, 2 => MiB, 3 => GiB, etc... +std::string bytesToHumanReadableUnits (uint64 bytes, const std::vector &units); + /// Convert a human readable into a bytes, for example "102kb" -> 105123 uint32 humanReadableToBytes (const std::string &str); diff --git a/code/nel/include/nel/misc/path.h b/code/nel/include/nel/misc/path.h index 9c3e2e21b..1fa049fa5 100644 --- a/code/nel/include/nel/misc/path.h +++ b/code/nel/include/nel/misc/path.h @@ -230,7 +230,7 @@ public: /** Get application directory. * \return directory where applications should write files. */ - std::string getApplicationDirectory(const std::string &appName = ""); + std::string getApplicationDirectory(const std::string &appName = "", bool local = false); /** Get a temporary directory. * \return temporary directory where applications should write files. @@ -540,7 +540,7 @@ public: /** Get application directory. * \return directory where applications should write files. */ - static std::string getApplicationDirectory(const std::string &appName = ""); + static std::string getApplicationDirectory(const std::string &appName = "", bool local = false); /** Get a temporary directory. * \return temporary directory where applications should write files. diff --git a/code/nel/include/nel/misc/string_common.h b/code/nel/include/nel/misc/string_common.h index e6d08bdeb..b8a12ad77 100644 --- a/code/nel/include/nel/misc/string_common.h +++ b/code/nel/include/nel/misc/string_common.h @@ -246,27 +246,38 @@ inline bool fromString(const std::string &str, bool &val) { if (str.length() == 1) { - if (str[0] == '1') + const char c = str[0]; + + switch(c) { + case '1': + case 't': + case 'T': + case 'y': + case 'Y': val = true; - } - else if (str[0] == '0') - { + break; + + case '0': + case 'f': + case 'F': + case 'n': + case 'N': val = false; - } - else - { + break; + + default: val = false; return false; } } else { - if (str == "true") + if (str == "true" || str == "yes") { val = true; } - else if (str == "false") + else if (str == "false" || str == "no") { val = false; } diff --git a/code/nel/src/3d/CMakeLists.txt b/code/nel/src/3d/CMakeLists.txt index 1f6ab4a41..821c888ce 100644 --- a/code/nel/src/3d/CMakeLists.txt +++ b/code/nel/src/3d/CMakeLists.txt @@ -715,7 +715,7 @@ SOURCE_GROUP(Stereo FILES NL_TARGET_LIB(nel3d ${HEADERS} ${SRC}) -INCLUDE_DIRECTORIES(BEFORE ${FREETYPE_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${LIBVR_INCLUDE_DIR}) TARGET_LINK_LIBRARIES(nel3d nelmisc ${FREETYPE_LIBRARIES} ${LIBOVR_LIBRARIES} ${LIBVR_LIBRARY}) diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 4c7d4fe02..6ec0261f6 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -380,7 +380,26 @@ string bytesToHumanReadable (uint64 bytes) div++; res = newres; } - return toString ("%" NL_I64 "u%s", res, divTable[div]); + return toString ("%" NL_I64 "u %s", res, divTable[div]); +} + +std::string bytesToHumanReadableUnits (uint64 bytes, const std::vector &units) +{ + if (units.empty()) return ""; + + uint div = 0; + uint last = units.size()-1; + uint64 res = bytes; + uint64 newres = res; + for(;;) + { + newres /= 1024; + if(newres < 8 || div > 3 || div == last) + break; + ++div; + res = newres; + } + return toString ("%" NL_I64 "u %s", res, units[div].c_str()); } uint32 humanReadableToBytes (const string &str) @@ -394,7 +413,8 @@ uint32 humanReadableToBytes (const string &str) if(str[0]<'0' || str[0]>'9') return 0; - res = atoi (str.c_str()); + if (!fromString(str, res)) + return 0; if(str[str.size()-1] == 'B') { @@ -404,10 +424,28 @@ uint32 humanReadableToBytes (const string &str) // there's no break and it's **normal** switch (str[str.size()-2]) { - case 'G': res *= 1024; - case 'M': res *= 1024; - case 'K': res *= 1024; - default: ; + // kB/KB, MB, GB and TB are 1000 multiples + case 'T': res *= 1000; + case 'G': res *= 1000; + case 'M': res *= 1000; + case 'k': res *= 1000; break; // kilo symbol should be a lowercase K + case 'K': res *= 1000; break; + case 'i': + { + // KiB, MiB, GiB and TiB are 1024 multiples + if (str.size()<4) + return res; + + switch (str[str.size()-3]) + { + case 'T': res *= 1024; + case 'G': res *= 1024; + case 'M': res *= 1024; + case 'K': res *= 1024; + default: ; + } + } + default: ; } } @@ -694,8 +732,22 @@ bool launchProgram(const std::string &programName, const std::string &arguments, SetEnvironmentVariable( SE_TRANSLATOR_IN_MAIN_MODULE, NULL ); } - string arg = " " + arguments; - BOOL res = CreateProcessA(programName.c_str(), (char*)arg.c_str(), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL, &si, &pi); + const char *sProgramName = programName.c_str(); + + std::string args; + + // a .bat file must have first parameter to NULL and use 2nd parameter to pass filename + if (CFile::getExtension(programName) == "bat") + { + sProgramName = NULL; + args = "\"" + programName + "\" " + arguments; + } + else + { + args = arguments; + } + + BOOL res = CreateProcessA(sProgramName, (char*)args.c_str(), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL, &si, &pi); if (res) { @@ -716,25 +768,13 @@ bool launchProgram(const std::string &programName, const std::string &arguments, } #elif defined(NL_OS_MAC) - std::string command; + // we need to open bundles with "open" command + std::string command = NLMISC::toString("open \"%s\"", programName.c_str()); - if (CFile::getExtension(programName) == "app") + // append arguments if any + if (!arguments.empty()) { - // we need to open bundles with "open" command - command = NLMISC::toString("open \"%s\"", programName.c_str()); - - // append arguments if any - if (!arguments.empty()) - { - command += NLMISC::toString(" --args %s", arguments.c_str()); - } - } - else - { - command = programName; - - // append arguments if any - if (!arguments.empty()) command += " " + arguments; + command += NLMISC::toString(" --args %s", arguments.c_str()); } int res = system(command.c_str()); @@ -838,8 +878,22 @@ sint launchProgramAndWaitForResult(const std::string &programName, const std::st SetEnvironmentVariable( SE_TRANSLATOR_IN_MAIN_MODULE, NULL ); } - string arg = " " + arguments; - BOOL ok = CreateProcessA(programName.c_str(), (char*)arg.c_str(), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL, &si, &pi); + const char *sProgramName = programName.c_str(); + + std::string args; + + // a .bat file must have first parameter to NULL and use 2nd parameter to pass filename + if (CFile::getExtension(programName) == "bat") + { + sProgramName = NULL; + args = "\"" + programName + "\" " + arguments; + } + else + { + args = arguments; + } + + BOOL ok = CreateProcessA(sProgramName, (char*)args.c_str(), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL, &si, &pi); if (ok) { diff --git a/code/nel/src/misc/log.cpp b/code/nel/src/misc/log.cpp index 2e7146fb6..9e5f0a1bc 100644 --- a/code/nel/src/misc/log.cpp +++ b/code/nel/src/misc/log.cpp @@ -260,7 +260,7 @@ void CLog::displayString (const char *str) TempArgs.FileName = _FileName; TempArgs.Line = _Line; TempArgs.FuncName = _FuncName; - TempArgs.CallstackAndLog = ""; + TempArgs.CallstackAndLog.clear(); TempString = str; } @@ -281,7 +281,7 @@ void CLog::displayString (const char *str) localargs.FileName = _FileName; localargs.Line = _Line; localargs.FuncName = _FuncName; - localargs.CallstackAndLog = ""; + localargs.CallstackAndLog.clear(); disp = str; args = &localargs; @@ -314,7 +314,7 @@ void CLog::displayString (const char *str) (*idi)->display( *args, disp ); } } - TempString = ""; + TempString.clear(); unsetPosition(); } diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index 58370eb2b..077bc18be 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1777,19 +1777,29 @@ std::string CFileContainer::getWindowsDirectory() #endif } -std::string CPath::getApplicationDirectory(const std::string &appName) +std::string CPath::getApplicationDirectory(const std::string &appName, bool local) { - return getInstance()->_FileContainer.getApplicationDirectory(appName); + return getInstance()->_FileContainer.getApplicationDirectory(appName, local); } -std::string CFileContainer::getApplicationDirectory(const std::string &appName) +std::string CFileContainer::getApplicationDirectory(const std::string &appName, bool local) { - static std::string appPath; + static std::string appPaths[2]; + std::string &appPath = appPaths[local ? 1 : 0]; if (appPath.empty()) { #ifdef NL_OS_WINDOWS wchar_t buffer[MAX_PATH]; - SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE); +#ifdef CSIDL_LOCAL_APPDATA + if (local) + { + SHGetSpecialFolderPathW(NULL, buffer, CSIDL_LOCAL_APPDATA, TRUE); + } + else +#endif + { + SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE); + } appPath = CPath::standardizePath(ucstring((ucchar*)buffer).toUtf8()); #elif defined(NL_OS_MAC) appPath = CPath::standardizePath(getenv("HOME")); @@ -2568,13 +2578,13 @@ std::string CPath::makePathAbsolute( const std::string &relativePath, const std: { absolutePath = relativePath; } -#else - // Unix filesystem absolute path + else +#endif + // Unix filesystem absolute path (works also under Windows) if (relativePath[0] == '/') { absolutePath = relativePath; } -#endif else { // Add a slash to the directory if necessary. @@ -2600,14 +2610,15 @@ std::string CPath::makePathAbsolute( const std::string &relativePath, const std: // Now build the new absolute path absolutePath += relativePath; - absolutePath = standardizePath(absolutePath, true); } + absolutePath = standardizePath(absolutePath, true); + if (simplify) { // split all components path to manage parent directories std::vector tokens; - explode(absolutePath, std::string("/"), tokens, true); + explode(absolutePath, std::string("/"), tokens, false); std::vector directoryParts; @@ -2639,7 +2650,10 @@ std::string CPath::makePathAbsolute( const std::string &relativePath, const std: // rebuild the whole absolute path for(uint i = 1, len = directoryParts.size(); i < len; ++i) - absolutePath += "/" + directoryParts[i]; + { + if (!directoryParts[i].empty()) + absolutePath += "/" + directoryParts[i]; + } // add trailing slash absolutePath += "/"; diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index 690d09ab1..1b3ca490f 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -555,7 +555,7 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const } else { - return NLMISC::toString( "", _Id.Id ); + return NLMISC::toString( "", _Id.Id ); } } diff --git a/code/nel/tools/build_gamedata/d1_client_patch.py b/code/nel/tools/build_gamedata/d1_client_patch.py index 600347d0b..449d6e0b7 100755 --- a/code/nel/tools/build_gamedata/d1_client_patch.py +++ b/code/nel/tools/build_gamedata/d1_client_patch.py @@ -136,7 +136,7 @@ else: needUpdateBnp = needUpdateDirNoSubdirFile(log, sourcePath, targetBnp) if (needUpdateBnp): printLog(log, "BNP " + targetBnp) - subprocess.call([ BnpMake, "/p", sourcePath, targetPath ] + package[1]) + subprocess.call([ BnpMake, "-p", sourcePath, "-o", targetBnp ] + package[1][1:]) else: printLog(log, "SKIP " + targetBnp) printLog(log, "") diff --git a/code/nel/tools/misc/bnp_make/main.cpp b/code/nel/tools/misc/bnp_make/main.cpp index 98ddf84d6..868f36f62 100644 --- a/code/nel/tools/misc/bnp_make/main.cpp +++ b/code/nel/tools/misc/bnp_make/main.cpp @@ -134,8 +134,8 @@ int main(int argc, char **argv) args.addArg("u", "unpack", "", "Unpack the BNP file to a directory"); args.addArg("l", "list", "", "List the files contained in the BNP file"); args.addArg("o", "output", "destination", "Output directory or file"); - args.addArg("i", "if", "wildcard", "Add the file if it matches the wilcard (at least one 'if' conditions must be met for a file to be adding)"); - args.addArg("n", "ifnot", "wildcard", "Add the file if it doesn't match the wilcard (all the 'ifnot' conditions must be met for a file to be adding)"); + args.addArg("i", "if", "wildcard", "Add the file if it matches the wilcard (at least one 'if' conditions must be met for a file to be adding)", false); + args.addArg("n", "ifnot", "wildcard", "Add the file if it doesn't match the wilcard (all the 'ifnot' conditions must be met for a file to be adding)", false); args.addAdditionalArg("input", "Input directory or BNP file depending on command"); if (!args.parse(argc, argv)) return 1; diff --git a/code/nel/tools/nel_unit_test/nel_unit_test.cpp b/code/nel/tools/nel_unit_test/nel_unit_test.cpp index 8289ea490..753dfd46a 100644 --- a/code/nel/tools/nel_unit_test/nel_unit_test.cpp +++ b/code/nel/tools/nel_unit_test/nel_unit_test.cpp @@ -114,6 +114,20 @@ int main(int argc, char *argv[]) // init Nel context new NLMISC::CApplicationContext; + // disable nldebug messages in logs in Release +#ifdef NL_RELEASE + NLMISC::DisableNLDebug = true; +#endif + + NLMISC::createDebug(NULL); + +#ifndef NL_DEBUG + NLMISC::INelContext::getInstance().getDebugLog()->removeDisplayer("DEFAULT_SD"); + NLMISC::INelContext::getInstance().getInfoLog()->removeDisplayer("DEFAULT_SD"); + NLMISC::INelContext::getInstance().getWarningLog()->removeDisplayer("DEFAULT_SD"); + NLMISC::INelContext::getInstance().getErrorLog()->removeDisplayer("DEFAULT_SD"); +#endif // NL_DEBUG + bool noerrors = false; try diff --git a/code/nel/tools/nel_unit_test/ut_misc.h b/code/nel/tools/nel_unit_test/ut_misc.h index 8538d3f53..e7a3cc8c6 100644 --- a/code/nel/tools/nel_unit_test/ut_misc.h +++ b/code/nel/tools/nel_unit_test/ut_misc.h @@ -19,6 +19,7 @@ #include "ut_misc_co_task.h" #include "ut_misc_command.h" +#include "ut_misc_common.h" #include "ut_misc_config_file.h" #include "ut_misc_debug.h" #include "ut_misc_dynlibload.h" @@ -38,6 +39,7 @@ struct CUTMisc : public Test::Suite { add(auto_ptr(new CUTMiscCoTask)); add(auto_ptr(new CUTMiscCommand)); + add(auto_ptr(new CUTMiscCommon)); add(auto_ptr(new CUTMiscConfigFile)); add(auto_ptr(new CUTMiscDebug)); add(auto_ptr(new CUTMiscDynLibLoad)); diff --git a/code/nel/tools/nel_unit_test/ut_misc_common.h b/code/nel/tools/nel_unit_test/ut_misc_common.h new file mode 100644 index 000000000..d33d65064 --- /dev/null +++ b/code/nel/tools/nel_unit_test/ut_misc_common.h @@ -0,0 +1,171 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef UT_MISC_COMMON +#define UT_MISC_COMMON + +#include +#include + +struct CUTMiscCommon : public Test::Suite +{ + CUTMiscCommon() + { + TEST_ADD(CUTMiscCommon::bytesToHumanReadableUnits); + TEST_ADD(CUTMiscCommon::humanReadableToBytes); + + // Add a line here when adding a new test METHOD + } + + void bytesToHumanReadableUnits() + { + std::vector units; + + std::string res; + + // no unit, returns an empty string + res = NLMISC::bytesToHumanReadableUnits(0, units); + TEST_ASSERT(res.empty()); + + // support bytes + units.push_back("B"); + + // 0 bytes + res = NLMISC::bytesToHumanReadableUnits(0, units); + TEST_ASSERT(res == "0 B"); + + // 1000 bytes in B + res = NLMISC::bytesToHumanReadableUnits(1000, units); + TEST_ASSERT(res == "1000 B"); + + // 1024 bytes in B + res = NLMISC::bytesToHumanReadableUnits(1024, units); + TEST_ASSERT(res == "1024 B"); + + // support kibibytes + units.push_back("KiB"); + + // 1000 bytes in B or KiB + res = NLMISC::bytesToHumanReadableUnits(1000, units); + TEST_ASSERT(res == "1000 B"); + + // 1024 bytes in B or KiB + res = NLMISC::bytesToHumanReadableUnits(1024, units); + TEST_ASSERT(res == "1024 B"); + + // 1 MB in B or KiB + res = NLMISC::bytesToHumanReadableUnits(1000 * 1000, units); + TEST_ASSERT(res == "976 KiB"); + + // 1 MiB in B or KiB + res = NLMISC::bytesToHumanReadableUnits(1024 * 1024, units); + TEST_ASSERT(res == "1024 KiB"); + + // 1 GB in B or KiB + res = NLMISC::bytesToHumanReadableUnits(1000 * 1000 * 1000, units); + TEST_ASSERT(res == "976562 KiB"); + + // 1 GiB in B or KiB + res = NLMISC::bytesToHumanReadableUnits(1024 * 1024 * 1024, units); + TEST_ASSERT(res == "1048576 KiB"); + + // support mebibytes + units.push_back("MiB"); + + // 1 GB in B, KiB or MiB + res = NLMISC::bytesToHumanReadableUnits(1000 * 1000 * 1000, units); + TEST_ASSERT(res == "953 MiB"); + + // 1 GiB in B, KiB or MiB + res = NLMISC::bytesToHumanReadableUnits(1024 * 1024 * 1024, units); + TEST_ASSERT(res == "1024 MiB"); + } + + void humanReadableToBytes() + { + uint64 bytes = 0; + + // kiB is a wrong unit + bytes = NLMISC::humanReadableToBytes("1kiB"); + TEST_ASSERT(bytes == 1); + + // 1 kibibyte + bytes = NLMISC::humanReadableToBytes("1KiB"); + TEST_ASSERT(bytes == 1024); + + // 1 mebibyte + bytes = NLMISC::humanReadableToBytes("1MiB"); + TEST_ASSERT(bytes == 1024*1024); + + // 1 kilobyte + bytes = NLMISC::humanReadableToBytes("1KB"); + TEST_ASSERT(bytes == 1000); + + // 1 kilobyte + bytes = NLMISC::humanReadableToBytes("1kB"); + TEST_ASSERT(bytes == 1000); + + // 1 megabyte + bytes = NLMISC::humanReadableToBytes("1MB"); + TEST_ASSERT(bytes == 1000*1000); + + // 1 byte + bytes = NLMISC::humanReadableToBytes("1B"); + TEST_ASSERT(bytes == 1); + + // 1 byte + bytes = NLMISC::humanReadableToBytes("1"); + TEST_ASSERT(bytes == 1); + + // kiB is a wrong unit + bytes = NLMISC::humanReadableToBytes("1 kiB"); + TEST_ASSERT(bytes == 1); + + // 1 kibibyte + bytes = NLMISC::humanReadableToBytes("1 KiB"); + TEST_ASSERT(bytes == 1024); + + // 1 mebibyte + bytes = NLMISC::humanReadableToBytes("1 MiB"); + TEST_ASSERT(bytes == 1024*1024); + + // 1 kilobyte + bytes = NLMISC::humanReadableToBytes("1 KB"); + TEST_ASSERT(bytes == 1000); + + // 1 kilobyte + bytes = NLMISC::humanReadableToBytes("1 kB"); + TEST_ASSERT(bytes == 1000); + + // 1 megabyte + bytes = NLMISC::humanReadableToBytes("1 MB"); + TEST_ASSERT(bytes == 1000*1000); + + // 1 byte + bytes = NLMISC::humanReadableToBytes("1 B"); + TEST_ASSERT(bytes == 1); + + // not a number + bytes = NLMISC::humanReadableToBytes("AB"); + TEST_ASSERT(bytes == 0); + + // not a positive number + bytes = NLMISC::humanReadableToBytes("-1 B"); + TEST_ASSERT(bytes == 0); + } +}; + +#endif diff --git a/code/nel/tools/nel_unit_test/ut_misc_string_common.h b/code/nel/tools/nel_unit_test/ut_misc_string_common.h index 2fc646a36..623d2d39e 100644 --- a/code/nel/tools/nel_unit_test/ut_misc_string_common.h +++ b/code/nel/tools/nel_unit_test/ut_misc_string_common.h @@ -444,11 +444,13 @@ struct CUTMiscStringCommon : public Test::Suite // min limit -1, unable to compare with minimum value because no lower type ret = NLMISC::fromString("-9223372036854775809", val); - TEST_ASSERT(ret && val == std::numeric_limits::max()); + // with GCC, it returns min, with VC++ it returns max + TEST_ASSERT(ret && (val == std::numeric_limits::max() || std::numeric_limits::min())); // max limit +1, unable to compare with maximum value because no higher type ret = NLMISC::fromString("9223372036854775808", val); - TEST_ASSERT(ret && val == std::numeric_limits::min()); + // with GCC, it returns max with VC++ it returns min + TEST_ASSERT(ret && (val == std::numeric_limits::min() || std::numeric_limits::max())); // with period ret = NLMISC::fromString("1.2", val); @@ -508,7 +510,8 @@ struct CUTMiscStringCommon : public Test::Suite // max limit +1, unable to compare with maximum value because no higher type ret = NLMISC::fromString("18446744073709551616", val); - TEST_ASSERT(ret && val == std::numeric_limits::min()); + // with GCC, it returns max with VC++ it returns min + TEST_ASSERT(ret && (val == std::numeric_limits::min() || val == std::numeric_limits::max())); // with period ret = NLMISC::fromString("1.2", val); @@ -682,60 +685,59 @@ struct CUTMiscStringCommon : public Test::Suite // tests for bool bool val; - // true value - val = false; + // true values ret = NLMISC::fromString("1", val); - TEST_ASSERT(val); - TEST_ASSERT_MSG(ret, "should succeed"); + TEST_ASSERT(ret && val); - val = false; - NLMISC::fromString("t", val); - TEST_ASSERT(val); + ret = NLMISC::fromString("t", val); + TEST_ASSERT(ret && val); - val = false; - NLMISC::fromString("y", val); - TEST_ASSERT(val); + ret = NLMISC::fromString("y", val); + TEST_ASSERT(ret && val); - val = false; - NLMISC::fromString("T", val); - TEST_ASSERT(val); + ret = NLMISC::fromString("T", val); + TEST_ASSERT(ret && val); - val = false; - NLMISC::fromString("Y", val); - TEST_ASSERT(val); + ret = NLMISC::fromString("Y", val); + TEST_ASSERT(ret && val); - val = true; + ret = NLMISC::fromString("true", val); + TEST_ASSERT(ret && val); + + ret = NLMISC::fromString("yes", val); + TEST_ASSERT(ret && val); + + // false values ret = NLMISC::fromString("0", val); - TEST_ASSERT(!val); - TEST_ASSERT_MSG(ret, "should succeed"); + TEST_ASSERT(ret && !val); - val = true; - NLMISC::fromString("f", val); - TEST_ASSERT(!val); + ret = NLMISC::fromString("f", val); + TEST_ASSERT(ret && !val); - val = true; - NLMISC::fromString("n", val); - TEST_ASSERT(!val); + ret = NLMISC::fromString("n", val); + TEST_ASSERT(ret && !val); - val = true; - NLMISC::fromString("F", val); - TEST_ASSERT(!val); + ret = NLMISC::fromString("F", val); + TEST_ASSERT(ret && !val); - val = true; - NLMISC::fromString("N", val); - TEST_ASSERT(!val); + ret = NLMISC::fromString("N", val); + TEST_ASSERT(ret && !val); + + ret = NLMISC::fromString("false", val); + TEST_ASSERT(ret && !val); + + ret = NLMISC::fromString("no", val); + TEST_ASSERT(ret && !val); + + // wrong values + ret = NLMISC::fromString("YES", val); + TEST_ASSERT(!ret && !val); + + ret = NLMISC::fromString("foo", val); + TEST_ASSERT(!ret && !val); - // bad character ret = NLMISC::fromString("a", val); - TEST_ASSERT_MSG(!ret, "should not succeed"); - - val = true; - NLMISC::fromString("a", val); - TEST_ASSERT_MSG(val, "should not modify the value"); - - val = false; - NLMISC::fromString("a", val); - TEST_ASSERT_MSG(!val, "should not modify the value"); + TEST_ASSERT(!ret && !val); } }; diff --git a/code/ryzom/client/CMakeLists.txt b/code/ryzom/client/CMakeLists.txt index e689b1676..106f553bd 100644 --- a/code/ryzom/client/CMakeLists.txt +++ b/code/ryzom/client/CMakeLists.txt @@ -3,7 +3,6 @@ ADD_SUBDIRECTORY(src) IF(WITH_RYZOM_CLIENT) #ADD_SUBDIRECTORY(data) - #ADD_SUBDIRECTORY(patcher) IF(UNIX AND NOT APPLE) ADD_SUBDIRECTORY(unix) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/compass.xml b/code/ryzom/client/data/gamedev/interfaces_v3/compass.xml index 003c90f00..d04d7fba0 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/compass.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/compass.xml @@ -265,7 +265,7 @@ fontsize="10" line_maxw="182" shadow="true" - hardtext="No File..." /> + hardtext="uiNoFiles" /> diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml index 0995c64c9..38e63cb24 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml @@ -183,7 +183,7 @@ posref="BL BL" scale="true" y="4" - w="110" + w="130" h="2" texture="W_line_hor2.tga" /> @@ -32,35 +32,35 @@ - + - + - + - + - + - - - - + - @@ -73,23 +73,23 @@ - - - + - + @@ -120,7 +120,7 @@ - + - + - + - + - + - + - + - + - - + + - + @@ -224,12 +224,12 @@ on_enter="leave_modal" options="no_bordure" mouse_pos="false" exit_key_pushed="t - + - - + + - + - + @@ -285,28 +285,28 @@ on_enter="leave_modal" options="no_bordure" mouse_pos="false" exit_key_pushed="t - + - + - - + + - + - + - + - + @@ -318,17 +318,17 @@ on_enter="leave_modal" options="no_bordure" mouse_pos="false" exit_key_pushed="t