From 13e2da698a1c3ec840944da5161a90dd3a2bb224 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Tue, 3 Jul 2018 16:09:15 +0800 Subject: [PATCH 01/65] Fix build under Visual Studio 2008 --HG-- branch : develop --- code/CMakeModules/GetRevision.cmake | 2 ++ code/nel/include/nel/gui/http_hsts.h | 4 ++-- code/nel/src/gui/CMakeLists.txt | 4 ++-- code/nel/src/gui/http_hsts.cpp | 16 ++++++++++------ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/code/CMakeModules/GetRevision.cmake b/code/CMakeModules/GetRevision.cmake index b29a8763e..dba90c765 100644 --- a/code/CMakeModules/GetRevision.cmake +++ b/code/CMakeModules/GetRevision.cmake @@ -83,4 +83,6 @@ ENDIF() IF(DEFINED REVISION) MESSAGE(STATUS "Found revision ${REVISION}") +ELSE() + SET(REVISION 0) ENDIF() diff --git a/code/nel/include/nel/gui/http_hsts.h b/code/nel/include/nel/gui/http_hsts.h index 2693461cd..28f1b5f5b 100644 --- a/code/nel/include/nel/gui/http_hsts.h +++ b/code/nel/include/nel/gui/http_hsts.h @@ -42,7 +42,7 @@ namespace NLGUI class CStrictTransportSecurity { public: - typedef std::map THSTSObject; + typedef std::map THSTSObjectMap; static CStrictTransportSecurity* getInstance(); static void release(); @@ -66,7 +66,7 @@ namespace NLGUI ~CStrictTransportSecurity(); std::string _Filename; - THSTSObject _Domains; + THSTSObjectMap _Domains; }; } diff --git a/code/nel/src/gui/CMakeLists.txt b/code/nel/src/gui/CMakeLists.txt index 5233b8ceb..cdd090f0b 100644 --- a/code/nel/src/gui/CMakeLists.txt +++ b/code/nel/src/gui/CMakeLists.txt @@ -6,9 +6,9 @@ SOURCE_GROUP("src" FILES ${SRC}) NL_TARGET_LIB(nelgui ${SRC} ${HEADERS}) -INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES}) +TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI") NL_ADD_RUNTIME_FLAGS(nelgui) diff --git a/code/nel/src/gui/http_hsts.cpp b/code/nel/src/gui/http_hsts.cpp index c69062538..c57bb738c 100644 --- a/code/nel/src/gui/http_hsts.cpp +++ b/code/nel/src/gui/http_hsts.cpp @@ -87,9 +87,12 @@ namespace NLGUI { if (domain.empty() || _Domains.empty()) return false; - if (_Domains.count(domain) > 0) + THSTSObjectMap::const_iterator itHsts; + + itHsts = _Domains.find(domain); + if (itHsts != _Domains.end()) { - hsts = _Domains.at(domain); + hsts = itHsts->second; return true; } @@ -99,11 +102,12 @@ namespace NLGUI { { std::string tmp; tmp = domain.substr(firstOf+1); - if (_Domains.count(tmp)) + itHsts = _Domains.find(tmp); + if (itHsts != _Domains.end()) { - if (_Domains.at(tmp).IncludeSubDomains) + if (itHsts->second.IncludeSubDomains) { - hsts = _Domains.at(tmp); + hsts = itHsts->second; return true; } @@ -182,7 +186,7 @@ namespace NLGUI { { uint32 nbItems = _Domains.size(); f.serial(nbItems); - for (THSTSObject::iterator it = _Domains.begin(); it != _Domains.end(); ++it) + for (THSTSObjectMap::iterator it = _Domains.begin(); it != _Domains.end(); ++it) { std::string domain(it->first); f.serial(domain); From 1f897f6106373cb306bb01d240ee3385f6407034 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Tue, 3 Jul 2018 16:10:04 +0800 Subject: [PATCH 02/65] Fix configuration for Snowballs --HG-- branch : develop --- code/snowballs2/bin/snowballs_client_default.cfg | 3 +++ code/snowballs2/client/src/configuration.cpp | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/code/snowballs2/bin/snowballs_client_default.cfg b/code/snowballs2/bin/snowballs_client_default.cfg index 49ec9e4d5..f8af00386 100755 --- a/code/snowballs2/bin/snowballs_client_default.cfg +++ b/code/snowballs2/bin/snowballs_client_default.cfg @@ -57,6 +57,9 @@ ScreenFull = 1; // Start position of the player (the z is always 0) StartPoint = { 1840.0, -970.0, 0.0 }; +// Anti-Aliasing +EnableFXAA = 0; + ////////////////////////////////////////////////////////////////////////////// // HMD Variables ///////////////////////////////////////////////////////////// diff --git a/code/snowballs2/client/src/configuration.cpp b/code/snowballs2/client/src/configuration.cpp index 303db63ce..bc37448b2 100644 --- a/code/snowballs2/client/src/configuration.cpp +++ b/code/snowballs2/client/src/configuration.cpp @@ -37,7 +37,15 @@ namespace SBCLIENT { void CConfiguration::setAndCallback(const std::string &varName, void (*cb)(CConfigFile::CVar &var)) { ConfigFile->setCallback(varName, cb); - cb(*ConfigFile->getVarPtr(varName)); + CConfigFile::CVar *varPtr = ConfigFile->getVarPtr(varName); + if (!varPtr) + { + nlwarning("Missing config variable '%s'", varName.c_str()); + } + else + { + cb(*varPtr); + } } void CConfiguration::dropCallback(const std::string &varName) From 4444e93bf7b0380ba915780cd68c48a97d2d4f9b Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 10 Jul 2018 17:02:42 +0200 Subject: [PATCH 03/65] Changed: Use CPP11 everywhere if supported --HG-- branch : develop --- code/CMakeModules/PCHSupport.cmake | 4 ++-- code/CMakeModules/nel.cmake | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index c396bd6cf..24b4d5a85 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -209,8 +209,8 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDIF() ENDIF() - IF(USE_CPP0X AND gcc_compiler_version GREATER "6.2.0") - LIST(APPEND _FLAGS "-std=gnu++11") + IF(CMAKE_CXX11_EXTENSION_COMPILE_OPTION) + LIST(APPEND _FLAGS ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}) ENDIF() # Format definitions diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 95b28bb8a..6b5b36745 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -874,7 +874,9 @@ MACRO(NL_SETUP_BUILD) ENDIF() # use c++0x standard to use std::unique_ptr and std::shared_ptr - SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -std=c++0x") + IF(CMAKE_CXX11_EXTENSION_COMPILE_OPTION) + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}") + ENDIF() ADD_PLATFORM_FLAGS("-D_REENTRANT") From f3753a08a8b3780f8d404ade353cce3b999e5d13 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 10 Jul 2018 20:42:37 +0200 Subject: [PATCH 04/65] Changed: Allow to use static C++ runtimes --HG-- branch : develop --- code/CMakeModules/nel.cmake | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 6b5b36745..99d958771 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -238,6 +238,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) OPTION(WITH_EXTERNAL "With provided external." OFF) ENDIF() OPTION(WITH_STATIC_EXTERNAL "With static external libraries" OFF) + OPTION(WITH_STATIC_RUNTIMES "Use only static C++ runtimes" OFF) IF(UNIX AND NOT APPLE) OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" ON ) ELSE() @@ -636,8 +637,14 @@ MACRO(NL_SETUP_BUILD) SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}") ENDIF() - SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}") - SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}") + IF(WITH_STATIC_RUNTIMES) + SET(RUNTIME_FLAG "/MT") + ELSE() + SET(RUNTIME_FLAG "/MD") + ENDIF() + + SET(NL_DEBUG_CFLAGS "/Zi ${RUNTIME_FLAG}d /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}") + SET(NL_RELEASE_CFLAGS "${RUNTIME_FLAG} /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}") SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt ${MSVC_INCREMENTAL_YES_FLAG} ${NL_DEBUG_LINKFLAGS}") SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}") @@ -967,6 +974,10 @@ MACRO(NL_SETUP_BUILD) IF(NOT APPLE) ADD_PLATFORM_LINKFLAGS("-Wl,--no-undefined -Wl,--as-needed") + + IF(WITH_STATIC_RUNTIMES) + ADD_PLATFORM_LINKFLAGS("-static-libstdc++") + ENDIF() ENDIF() IF(NOT APPLE) From 7b23be0c46a07d1005325effdc80dcf605ad465b Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 18 Jul 2018 10:40:36 +0200 Subject: [PATCH 05/65] Fixed: Compilation under Linux with Qt 5.10 --HG-- branch : develop --- code/CMakeLists.txt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 425f296f5..159c63ef2 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -312,12 +312,19 @@ IF(WITH_QT5) ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration) ADD_QT_LIBRARY(XcbQpa) + ADD_QT_LIBRARY(GlxSupport) + ADD_QT_LIBRARY(ServiceSupport) + ADD_QT_LIBRARY(EdidSupport) + ADD_QT_LIBRARY(FontDatabaseSupport) + ADD_QT_LIBRARY(ThemeSupport) + ADD_QT_LIBRARY(EventDispatcherSupport) ADD_QT_LIBRARY(PlatformSupport) - SET(QT_LIBRARIES ${QT_LIBRARIES} -lX11-xcb -lXi -lSM -lICE -lxcb -lGL -lxcb-glx) + + SET(QT_LIBRARIES ${QT_LIBRARIES} -lX11-xcb -lSM -lICE -lxcb -lGL -lxcb-glx) IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a") SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_LIBRARY_DIR}/libxcb-static.a") ENDIF() - SET(QT_LIBRARIES ${QT_LIBRARIES} -lfontconfig) + SET(QT_LIBRARIES ${QT_LIBRARIES} -lfontconfig -lX11 -lXrender) ADD_QT_LIBRARY(DBus) ENDIF() @@ -329,6 +336,9 @@ IF(WITH_QT5) # harfbuzz is needed since Qt 5.3 IF(UNIX) SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzzng.a") + IF(NOT EXISTS ${HB_LIB}) + SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzz.a") + ENDIF() ELSEIF(WIN32) SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib") ENDIF() @@ -373,6 +383,9 @@ IF(WITH_QT5) # pcre is needed since Qt 5.5 IF(UNIX) SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a") + IF(NOT EXISTS ${PCRE_LIB}) + SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre2.a") + ENDIF() ELSEIF(WIN32) SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib") ENDIF() @@ -391,7 +404,7 @@ IF(WITH_QT5) ${CARBON_FRAMEWORK} ${SECURITY_FRAMEWORK}) ELSEIF(UNIX) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -ldl -lrt) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -ldl -lrt) ENDIF() ELSE() SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core) From 728c602bc384c30de15a4fcd78db33e95aa46c28 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 18 Jul 2018 10:41:11 +0200 Subject: [PATCH 06/65] Fixed: Compilation under Ubuntu 16.04 --HG-- branch : develop --- code/CMakeModules/nel.cmake | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 99d958771..3919419be 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -672,7 +672,7 @@ MACRO(NL_SETUP_BUILD) IF(APPLE) SET(OBJC_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch -fobjc-weak) - + IF(NOT XCODE) IF(CMAKE_OSX_ARCHITECTURES) SET(TARGETS_COUNT 0) @@ -959,8 +959,6 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("-fPIC") ENDIF() - SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48") - # hardening ADD_PLATFORM_FLAGS("-fstack-protector --param=ssp-buffer-size=4") From 41d2b26d1a904c5589a5753c3f6d791a4e78c12c Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 18 Jul 2018 22:17:04 +0200 Subject: [PATCH 07/65] Changed: Link dynamically to existing system libs only --HG-- branch : develop --- code/CMakeLists.txt | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 159c63ef2..df71410fb 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -227,6 +227,28 @@ MACRO(ADD_QT_PLUGIN _TYPE _NAME) ENDIF() ENDMACRO() +MACRO(ADD_QT_SYSTEM_LIBRARY _NAME) + # Save default suffixes + SET(_OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + + # Define specific suffixes + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) + + # Find the library with specified suffixes + FIND_LIBRARY(${_NAME}_LIBRARY NAMES ${_NAME}) + + # Restore default suffixes + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_OLD_SUFFIXES}) + + IF(${_NAME}_LIBRARY) + MESSAGE(STATUS "Found ${${_NAME}_LIBRARY} ${_NAME}") + + LIST(APPEND QT_LIBRARIES ${${_NAME}_LIBRARY}) + ELSE() + MESSAGE(STATUS "Didn't find ${_NAME}") + ENDIF() +ENDMACRO() + IF(WITH_QT5) CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR) @@ -320,12 +342,24 @@ IF(WITH_QT5) ADD_QT_LIBRARY(EventDispatcherSupport) ADD_QT_LIBRARY(PlatformSupport) - SET(QT_LIBRARIES ${QT_LIBRARIES} -lX11-xcb -lSM -lICE -lxcb -lGL -lxcb-glx) + ADD_QT_LIBRARY(DBus) + IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a") SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_LIBRARY_DIR}/libxcb-static.a") ENDIF() - SET(QT_LIBRARIES ${QT_LIBRARIES} -lfontconfig -lX11 -lXrender) - ADD_QT_LIBRARY(DBus) + + # always link these in dynamic, API never changes + ADD_QT_SYSTEM_LIBRARY(X11) + ADD_QT_SYSTEM_LIBRARY(Xmu) + ADD_QT_SYSTEM_LIBRARY(X11-xcb) + ADD_QT_SYSTEM_LIBRARY(Xi) + ADD_QT_SYSTEM_LIBRARY(SM) + ADD_QT_SYSTEM_LIBRARY(ICE) + ADD_QT_SYSTEM_LIBRARY(xcb) + ADD_QT_SYSTEM_LIBRARY(GL) + ADD_QT_SYSTEM_LIBRARY(xcb-glx) + ADD_QT_SYSTEM_LIBRARY(fontconfig) + ADD_QT_SYSTEM_LIBRARY(Xrender) ENDIF() ADD_QT_PLUGIN(imageformats qgif) From adb3362b449de84b1d5b897d23775c44faf6bd3a Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 22 Jul 2018 18:37:44 +0200 Subject: [PATCH 08/65] Changed: Always compile ryzom_gameshare if WITH_RYZOM is defined --HG-- branch : develop --- code/ryzom/common/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/ryzom/common/CMakeLists.txt b/code/ryzom/common/CMakeLists.txt index 00eec3097..82e5030a7 100644 --- a/code/ryzom/common/CMakeLists.txt +++ b/code/ryzom/common/CMakeLists.txt @@ -1,7 +1,4 @@ -# only compile game_share for Ryzom client, server and tools -IF(WITH_RYZOM_CLIENT OR WITH_RYZOM_SERVER OR WITH_RYZOM_TOOLS) - ADD_SUBDIRECTORY(src) -ENDIF() +ADD_SUBDIRECTORY(src) #ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_BINARY_DIR}/share/data_common.bnp" # COMMAND bnp_make -p ${CMAKE_CURRENT_SOURCE_DIR}/data_common ${CMAKE_BINARY_DIR}/share > /dev/null) From a2707f93f1e81d01d7135201c259fc4bb8e47dbb Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 26 Jul 2018 20:24:17 +0300 Subject: [PATCH 09/65] Fixed: Wrong resolution saved to config when window receives wm_destroy signal --HG-- branch : develop --- code/ryzom/client/src/main_loop.cpp | 4 ++++ code/ryzom/client/src/release.cpp | 4 +--- code/ryzom/client/src/release.h | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index fe96d4da3..4657f1dff 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -80,6 +80,7 @@ #include "world_database_manager.h" #include "continent_manager.h" #include "ig_callback.h" +#include "release.h" //#include "fog_map.h" #include "movie_shooter.h" #include "sound_manager.h" @@ -2555,6 +2556,9 @@ bool mainLoop() if ( ! FarTP.isReselectingChar() ) // skip some parts if the user wants to quit in the middle of a char reselect { + // Saving ingame resolution when in windowed mode + saveIngameResolution(); + // Release the structure for the ping. Ping.release (); diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index ff569b22a..d5c16bf47 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -136,7 +136,7 @@ extern void selectTipsOfTheDay (uint tips); // *************************************************************************** // Saving ingame resolution when in windowed mode -static void saveIngameResolution() +void saveIngameResolution() { if (ClientCfg.Windowed) { @@ -382,8 +382,6 @@ void releaseMainLoop(bool closeConnection) { ProgressBar.release(); - saveIngameResolution(); - // Release R2 editor if applicable R2::getEditor().autoConfigRelease(IsInRingSession); diff --git a/code/ryzom/client/src/release.h b/code/ryzom/client/src/release.h index 02eae2fa7..56ceca73d 100644 --- a/code/ryzom/client/src/release.h +++ b/code/ryzom/client/src/release.h @@ -22,7 +22,8 @@ #include "nel/misc/types_nl.h" - +// Saving ingame resolution when in windowed mode +void saveIngameResolution(); // called from farTP at reselection void releaseMainLoopReselect(); // Release InGame Data From 5cb3f8426dfb34ac67bf2b5ae66e902dc65257a5 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 28 Jul 2018 11:24:03 +0200 Subject: [PATCH 10/65] Changed: Install Ryzom GameShare headers and libraries --HG-- branch : develop --- .../common/src/game_share/CMakeLists.txt | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/code/ryzom/common/src/game_share/CMakeLists.txt b/code/ryzom/common/src/game_share/CMakeLists.txt index 547b1a470..1a0b0da3f 100644 --- a/code/ryzom/common/src/game_share/CMakeLists.txt +++ b/code/ryzom/common/src/game_share/CMakeLists.txt @@ -1,5 +1,12 @@ -FILE(GLOB SRC *.cpp time_weather_season/*.cpp) -FILE(GLOB PRIV_H *.h time_weather_season/*.h) +FIND_PACKAGE(ZLIB REQUIRED) + +FILE(GLOB SRC *.cpp) +FILE(GLOB SRC_TIME time_weather_season/*.cpp) + +FILE(GLOB PRIV_H *.h) +FILE(GLOB PRIV_TIME_H time_weather_season/*.h) + +SET(HEADER ${PRIV_H}) FILE(GLOB R2 dms.h dms.cpp @@ -17,20 +24,21 @@ FILE(GLOB R2 ring_*.h ring_*.cpp) LIST(REMOVE_ITEM SRC R2) -LIST(REMOVE_ITEM PRIV_H R2) +LIST(REMOVE_ITEM HEADER R2) -SOURCE_GROUP("" FILES ${SRC} ${PRIV_H}) +SOURCE_GROUP("" FILES ${SRC} ${HEADER}) +SOURCE_GROUP("time_weather_season" FILES ${SRC_TIME} ${PRIV_TIME_H}) SOURCE_GROUP("R2" FILES ${R2}) # Filter out the source files not actually compiled. LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/enum_template.cpp) -LIST(REMOVE_ITEM PRIV_H ${CMAKE_CURRENT_SOURCE_DIR}/enum_template.h) +LIST(REMOVE_ITEM HEADER ${CMAKE_CURRENT_SOURCE_DIR}/enum_template.h) -NL_TARGET_LIB(ryzom_gameshare ${PRIV_H} ${SRC} ${R2}) +NL_TARGET_LIB(ryzom_gameshare ${HEADER} ${PRIV_TIME_H} ${SRC} ${SRC_TIME} ${R2}) -INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${NEL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -TARGET_LINK_LIBRARIES(ryzom_gameshare nelmisc nelnet nelligo nelgeorges) +TARGET_LINK_LIBRARIES(ryzom_gameshare ${NELMISC_LIBRARIES} ${NELNET_LIBRARIES} ${NELLIGO_LIBRARIES} ${NELGEORGES_LIBRARIES}) NL_DEFAULT_PROPS(ryzom_gameshare "Ryzom, Library: Game Share") NL_ADD_RUNTIME_FLAGS(ryzom_gameshare) NL_ADD_LIB_SUFFIX(ryzom_gameshare) @@ -44,3 +52,9 @@ ENDIF() IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS ryzom_gameshare LIBRARY DESTINATION ${RYZOM_LIB_PREFIX} ARCHIVE DESTINATION ${RYZOM_LIB_PREFIX} COMPONENT libraries) ENDIF() + +IF(WITH_INSTALL_LIBRARIES) + INSTALL(FILES ${PRIV_H} DESTINATION include/ryzom/game_share COMPONENT headers) + INSTALL(FILES ${PRIV_TIME_H} DESTINATION include/ryzom/game_share/time_weather_season COMPONENT headers) +ENDIF() + From 307eb77e63b44a4900a1647941bcefc851e8ad95 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 28 Jul 2018 11:31:32 +0200 Subject: [PATCH 11/65] Changed: Generate version_nl.h in include/nel/misc --HG-- branch : develop --- code/CMakeLists.txt | 6 +++--- code/CMakeModules/nel.cmake | 7 +++++++ code/nel/include/nel/misc/CMakeLists.txt | 6 +++++- code/nel/include/nel/misc/version_nl.cmake | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 code/nel/include/nel/misc/version_nl.cmake diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index df71410fb..25887a0e6 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -86,12 +86,12 @@ NL_SETUP_NELNS_DEFAULT_OPTIONS() NL_SETUP_RYZOM_DEFAULT_OPTIONS() NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS() -NL_SETUP_PREFIX_PATHS() -RYZOM_SETUP_PREFIX_PATHS() - NL_SETUP_BUILD() NL_SETUP_BUILD_FLAGS() +NL_SETUP_PREFIX_PATHS() +RYZOM_SETUP_PREFIX_PATHS() + #----------------------------------------------------------------------------- #Platform specifics diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 3919419be..258e777aa 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -374,6 +374,13 @@ MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS) SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}") ENDMACRO() +MACRO(CONVERT_VERSION_NUMBER _VERSION_NUMBER _BASE) + SET(${_VERSION_NUMBER} 0) + FOREACH(_ARG ${ARGN}) + MATH(EXPR ${_VERSION_NUMBER} "${${_VERSION_NUMBER}} * ${_BASE} + ${_ARG}") + ENDFOREACH() +ENDMACRO() + MACRO(NL_SETUP_BUILD) #----------------------------------------------------------------------------- diff --git a/code/nel/include/nel/misc/CMakeLists.txt b/code/nel/include/nel/misc/CMakeLists.txt index 4b77b813f..85d8914f5 100644 --- a/code/nel/include/nel/misc/CMakeLists.txt +++ b/code/nel/include/nel/misc/CMakeLists.txt @@ -1,3 +1,7 @@ +CONVERT_VERSION_NUMBER(NL_VERSION_NUM 100 ${NL_VERSION_MAJOR} ${NL_VERSION_MINOR} ${NL_VERSION_PATCH}) + +CONFIGURE_FILE(version_nl.cmake ${CMAKE_BINARY_DIR}/version_nl.h) + FILE(GLOB HEADERS *.h) -INSTALL(FILES ${HEADERS} DESTINATION include/nel/misc COMPONENT headers) +INSTALL(FILES ${HEADERS} ${CMAKE_BINARY_DIR}/version_nl.h DESTINATION include/nel/misc COMPONENT headers) diff --git a/code/nel/include/nel/misc/version_nl.cmake b/code/nel/include/nel/misc/version_nl.cmake new file mode 100644 index 000000000..2e650486e --- /dev/null +++ b/code/nel/include/nel/misc/version_nl.cmake @@ -0,0 +1,14 @@ +#ifndef NL_VERSION_H +#define NL_VERSION_H + +#define NL_VERSION "${NL_VERSION}" +#define NL_VERSION_MAJOR ${NL_VERSION_MAJOR} +#define NL_VERSION_MINOR ${NL_VERSION_MINOR} +#define NL_VERSION_PATCH ${NL_VERSION_PATCH} +#define NL_VERSION_NUM ${NL_VERSION_NUM} + +#define NL_REVISION ${REVISION} + +#define NL_BUILD_DATE "${BUILD_DATE}" + +#endif From d9e509d3ccd0882197cb957b9c78d123d2895104 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 28 Jul 2018 11:38:48 +0200 Subject: [PATCH 12/65] Changed: NeL/Ryzom Core Version 1.0.0 (why to keep a 0.x version for almost 20 years ?) --HG-- branch : develop --- code/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 25887a0e6..c97f269fc 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -53,8 +53,8 @@ ENDIF() CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(RyzomCore CXX C) -SET(NL_VERSION_MAJOR 0) -SET(NL_VERSION_MINOR 12) +SET(NL_VERSION_MAJOR 1) +SET(NL_VERSION_MINOR 0) SET(NL_VERSION_PATCH 0) SET(YEAR "2004-${CURRENT_YEAR}") SET(AUTHOR "Winch Gate and The Ryzom Core Community") From 0bd577310dfa707e0902ee0175abb8f9ba35ac62 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 28 Jul 2018 11:44:33 +0200 Subject: [PATCH 13/65] Added: New CMake modules to find NeL and Ryzom GameShare --HG-- branch : develop --- code/CMakeLists.txt | 255 +----- code/CMakeModules/FindHelpers.cmake | 943 +++++++++++++++++++++ code/CMakeModules/FindNeL.cmake | 398 +++++++++ code/CMakeModules/FindRyzomGameShare.cmake | 10 + 4 files changed, 1353 insertions(+), 253 deletions(-) create mode 100644 code/CMakeModules/FindHelpers.cmake create mode 100644 code/CMakeModules/FindNeL.cmake create mode 100644 code/CMakeModules/FindRyzomGameShare.cmake diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index c97f269fc..87367c98e 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -191,261 +191,10 @@ IF(APPLE) ENDIF() ENDIF() -MACRO(ADD_QT_LIBRARY _NAME) - IF(WIN32) - SET(_PREFIX "Qt5") - SET(_EXT "lib") - ELSE() - SET(_PREFIX "libQt5") - SET(_EXT "a") - ENDIF() - SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}") - IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB}) - ENDIF() - SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}") - IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB}) - ENDIF() -ENDMACRO() - -MACRO(ADD_QT_PLUGIN _TYPE _NAME) - IF(WIN32) - SET(_PREFIX "") - SET(_EXT "lib") - ELSE() - SET(_PREFIX "lib") - SET(_EXT "a") - ENDIF() - SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}") - IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB}) - ENDIF() - SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}") - IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB}) - ENDIF() -ENDMACRO() - -MACRO(ADD_QT_SYSTEM_LIBRARY _NAME) - # Save default suffixes - SET(_OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - - # Define specific suffixes - SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) - - # Find the library with specified suffixes - FIND_LIBRARY(${_NAME}_LIBRARY NAMES ${_NAME}) - - # Restore default suffixes - SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_OLD_SUFFIXES}) - - IF(${_NAME}_LIBRARY) - MESSAGE(STATUS "Found ${${_NAME}_LIBRARY} ${_NAME}") - - LIST(APPEND QT_LIBRARIES ${${_NAME}_LIBRARY}) - ELSE() - MESSAGE(STATUS "Didn't find ${_NAME}") - ENDIF() -ENDMACRO() +INCLUDE(FindHelpers) IF(WITH_QT5) - CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR) - - SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR}) - - FIND_PACKAGE(Qt5Core QUIET) - - IF(Qt5Core_FOUND) - # Check if we are using Qt static or shared libraries - GET_TARGET_PROPERTY(_FILE Qt5::Core IMPORTED_LOCATION_RELEASE) - - SET(QT_VERSION "${Qt5Core_VERSION_STRING}") - SET(_VERSION "${QT_VERSION}") - - IF(_FILE MATCHES "\\.(lib|a)$") - SET(QT_STATIC ON) - SET(_VERSION "${_VERSION} static version") - ELSE() - SET(QT_STATIC OFF) - SET(_VERSION "${_VERSION} shared version") - ENDIF() - - MESSAGE(STATUS "Found Qt ${_VERSION}") - - # These variables are not defined with Qt5 CMake modules - SET(QT_BINARY_DIR "${_qt5Core_install_prefix}/bin") - SET(QT_LIBRARY_DIR "${_qt5Core_install_prefix}/lib") - SET(QT_PLUGINS_DIR "${_qt5Core_install_prefix}/plugins") - SET(QT_TRANSLATIONS_DIR "${_qt5Core_install_prefix}/translations") - - # Fix wrong include directories with Qt 5 under Mac OS X - INCLUDE_DIRECTORIES("${_qt5Core_install_prefix}/include") - - FIND_PACKAGE(Qt5Gui) - FIND_PACKAGE(Qt5Widgets) - FIND_PACKAGE(Qt5OpenGL) - FIND_PACKAGE(Qt5Xml) - FIND_PACKAGE(Qt5LinguistTools) - FIND_PACKAGE(Qt5Network) - - IF(QT_STATIC) - ADD_DEFINITIONS(-DQT_STATICPLUGIN) - - SET(QT_LIBRARIES Qt5::Widgets) - - # Gui - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::OpenGL) - - ADD_QT_LIBRARY(PrintSupport) - - IF(WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${WINSDK_LIBRARY_DIR}/Imm32.lib - ${WINSDK_LIBRARY_DIR}/OpenGL32.lib - ${WINSDK_LIBRARY_DIR}/WinMM.Lib) - ADD_QT_PLUGIN(platforms qwindows) - ADD_QT_LIBRARY(PlatformSupport) - ELSEIF(APPLE) - # Cups needs .dylib - SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib) - FIND_LIBRARY(CUPS_LIBRARY cups) - SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES}) - - FIND_LIBRARY(IOKIT_FRAMEWORK IOKit) - FIND_LIBRARY(COCOA_FRAMEWORK Cocoa) - FIND_LIBRARY(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration) - FIND_LIBRARY(OPENGL_FRAMEWORK NAMES OpenGL) - - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${CUPS_LIBRARY} - ${COCOA_FRAMEWORK} - ${SYSTEMCONFIGURATION_FRAMEWORK} - ${IOKIT_FRAMEWORK} - ${OPENGL_FRAMEWORK}) - - ADD_QT_PLUGIN(printsupport cocoaprintersupport) - ADD_QT_PLUGIN(platforms qcocoa) - ADD_QT_LIBRARY(PlatformSupport) - ELSE() - # order is very important there - ADD_QT_PLUGIN(platforms qxcb) - ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration) - - ADD_QT_LIBRARY(XcbQpa) - ADD_QT_LIBRARY(GlxSupport) - ADD_QT_LIBRARY(ServiceSupport) - ADD_QT_LIBRARY(EdidSupport) - ADD_QT_LIBRARY(FontDatabaseSupport) - ADD_QT_LIBRARY(ThemeSupport) - ADD_QT_LIBRARY(EventDispatcherSupport) - ADD_QT_LIBRARY(PlatformSupport) - - ADD_QT_LIBRARY(DBus) - - IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a") - SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_LIBRARY_DIR}/libxcb-static.a") - ENDIF() - - # always link these in dynamic, API never changes - ADD_QT_SYSTEM_LIBRARY(X11) - ADD_QT_SYSTEM_LIBRARY(Xmu) - ADD_QT_SYSTEM_LIBRARY(X11-xcb) - ADD_QT_SYSTEM_LIBRARY(Xi) - ADD_QT_SYSTEM_LIBRARY(SM) - ADD_QT_SYSTEM_LIBRARY(ICE) - ADD_QT_SYSTEM_LIBRARY(xcb) - ADD_QT_SYSTEM_LIBRARY(GL) - ADD_QT_SYSTEM_LIBRARY(xcb-glx) - ADD_QT_SYSTEM_LIBRARY(fontconfig) - ADD_QT_SYSTEM_LIBRARY(Xrender) - ENDIF() - - ADD_QT_PLUGIN(imageformats qgif) - ADD_QT_PLUGIN(imageformats qicns) - ADD_QT_PLUGIN(imageformats qico) - ADD_QT_PLUGIN(imageformats qjpeg) - - # harfbuzz is needed since Qt 5.3 - IF(UNIX) - SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzzng.a") - IF(NOT EXISTS ${HB_LIB}) - SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzz.a") - ENDIF() - ELSEIF(WIN32) - SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib") - ENDIF() - IF(EXISTS ${HB_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${HB_LIB}) - ENDIF() - - # freetype is needed since Qt 5.5 - FIND_PACKAGE(Freetype) - - IF(FREETYPE_FOUND) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIBRARIES}) - ELSE() - IF(UNIX) - SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a") - ELSEIF(WIN32) - SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib") - ENDIF() - IF(EXISTS ${FREETYPE_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIB}) - ENDIF() - ENDIF() - - ADD_QT_PLUGIN(accessible qtaccessiblewidgets) - - SET(QT_LIBRARIES ${QT_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARY}) - - # Network - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Network Qt5::Xml) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) - - IF(WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${WINSDK_LIBRARY_DIR}/Crypt32.lib - ${WINSDK_LIBRARY_DIR}/WS2_32.Lib - ${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib) - ENDIF() - - # Core - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Core) - - # pcre is needed since Qt 5.5 - IF(UNIX) - SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a") - IF(NOT EXISTS ${PCRE_LIB}) - SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre2.a") - ENDIF() - ELSEIF(WIN32) - SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib") - ENDIF() - IF(EXISTS ${PCRE_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${PCRE_LIB}) - ENDIF() - - IF(APPLE) - FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre) - - FIND_LIBRARY(SECURITY_FRAMEWORK Security) - - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${PCRE_LIBRARY} - ${FOUNDATION_FRAMEWORK} - ${CARBON_FRAMEWORK} - ${SECURITY_FRAMEWORK}) - ELSEIF(UNIX) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -ldl -lrt) - ENDIF() - ELSE() - SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core) - ENDIF() - ELSE() - MESSAGE(WARNING "Unable to find Qt 5") - ENDIF() + FIND_QT5() ENDIF() IF(WITH_QT) diff --git a/code/CMakeModules/FindHelpers.cmake b/code/CMakeModules/FindHelpers.cmake new file mode 100644 index 000000000..d9aa3e75c --- /dev/null +++ b/code/CMakeModules/FindHelpers.cmake @@ -0,0 +1,943 @@ +MACRO(CONVERT_NUMBER_VERSION _VERSION_NUMBER _BASE _OUT) + SET(${_OUT}) + SET(_NUMBER ${_VERSION_NUMBER}) + WHILE(_NUMBER GREATER 0) + MATH(EXPR _TEMP "${_NUMBER} % ${_BASE}") + LIST(APPEND ${_OUT} ${_TEMP}) + MATH(EXPR _NUMBER "${_NUMBER} / ${_BASE}") + ENDWHILE() +ENDMACRO(CONVERT_NUMBER_VERSION) + +FUNCTION(JOIN VALUES GLUE OUTPUT) + STRING(REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}") + STRING(REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping + SET(${OUTPUT} "${_TMP_STR}" PARENT_SCOPE) +ENDFUNCTION() + +MACRO(PARSE_VERSION_OTHER FILENAME) + IF(EXISTS ${FILENAME}) + SET(_FILTER_ARRAY ${ARGN}) + JOIN("${_FILTER_ARRAY}" "|" _FILTER_REGEX) + FILE(STRINGS ${FILENAME} _FILE REGEX "(${_FILTER_REGEX})[: \t=\(\)\"]+([0-9.]+)") + + IF(_FILE) + FOREACH(_LINE ${_FILE}) + FOREACH(_VAR ${_FILTER_ARRAY}) + IF("${${_VAR}}" STREQUAL "") + STRING(REGEX REPLACE "^.*${_VAR}[: \t=\(\)\"]+([0-9.]+).*$" "\\1" ${_VAR} "${_LINE}") + IF(${_VAR} STREQUAL "${_LINE}") + SET(${_VAR}) + ENDIF() + IF(NOT ${_VAR} AND NOT STREQUAL "0") + SET(${_VAR} 0) + ENDIF() + ENDIF() + ENDFOREACH() + ENDFOREACH() + ENDIF() + ENDIF() +ENDMACRO() + +MACRO(FIND_PACKAGE_HELPER NAME INCLUDE) + # Looks for a directory containing NAME. + # + # NAME is the name of the library, lowercase and uppercase can be mixed + # It should be EXACTLY (same case) the same part as XXXX in FindXXXX.cmake + # + # INCLUDE is the file to check for includes + # + # Following parameters are optional variables and must be prefixed by: + # + # RELEASE is the list of libraries to check in release mode + # DEBUG is the list of libraries to check in debug mode + # SUFFIXES is the PATH_SUFFIXES to check for include file + # QUIET don't display anything + # VERBOSE display more details if not found + # REQUIRED throw an error if not found + # DIR is the base directory where to look for + # + # The first match will be used in the specified order and next matches will be ignored + # + # The following values are defined + # NAME_INCLUDE_DIR - where to find NAME + # NAME_LIBRARIES - link against these to use NAME + # NAME_FOUND - True if NAME is available. + + SET(_PARAMS ${ARGN}) + + SET(_RELEASE_LIBRARIES) + SET(_DEBUG_LIBRARIES) + SET(_SUFFIXES) + SET(_BASE_DIRECTORIES) + + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_VERBOSE OFF) + SET(_IS_DIR OFF) + + IF(_PARAMS) + FOREACH(_PARAM ${_PARAMS}) + IF(_PARAM STREQUAL "RELEASE") + SET(_IS_RELEASE ON) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "DEBUG") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG ON) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "SUFFIXES") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + SET(_IS_SUFFIXES ON) + ELSEIF(_PARAM STREQUAL "QUIET") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + SET(${NAME}_FIND_QUIETLY ON) + ELSEIF(_PARAM STREQUAL "VERBOSE") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + SET(_IS_VERBOSE ON) + ELSEIF(_PARAM STREQUAL "REQUIRED") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + SET(${NAME}_FIND_REQUIRED ON) + ELSEIF(_PARAM STREQUAL "DIR") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR ON) + ELSE() + IF(_IS_RELEASE) + LIST(APPEND _RELEASE_LIBRARIES ${_PARAM}) + ELSEIF(_IS_DEBUG) + LIST(APPEND _DEBUG_LIBRARIES ${_PARAM}) + ELSEIF(_IS_SUFFIXES) + LIST(APPEND _SUFFIXES ${_PARAM}) + ELSEIF(_IS_DIR) + LIST(APPEND _BASE_DIRECTORIES ${_PARAM}) + ELSE() + MESSAGE(STATUS "parameter ${_PARAM} with no prefix") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + # Fixes names if invalid characters are found + IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$") + SET(_NAME_FIXED ${NAME}) + ELSE() + # if invalid characters are detected, replace them by valid ones + STRING(REPLACE "+" "p" _NAME_FIXED ${NAME}) + ENDIF() + + # Create uppercase and lowercase versions of NAME + STRING(TOUPPER ${NAME} _UPNAME) + STRING(TOLOWER ${NAME} _LOWNAME) + + STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED) + STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED) + + SET(_SUFFIXES ${_SUFFIXES} ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME}) + +# Don't use pkg-config +# IF(NOT WIN32 AND NOT IOS) +# FIND_PACKAGE(PkgConfig QUIET) +# SET(_MODULES ${_LOWNAME} ${_RELEASE_LIBRARIES}) +# LIST(REMOVE_DUPLICATES _MODULES) +# IF(PKG_CONFIG_EXECUTABLE) +# PKG_SEARCH_MODULE(PKG_${_NAME_FIXED} QUIET ${_MODULES}) +# ENDIF() +# ENDIF() + + SET(_INCLUDE_PATHS) + SET(_LIBRARY_PATHS) + + # Check for root directories passed to CMake with -DXXX_DIR=... + IF(DEFINED ${_UPNAME_FIXED}_DIR) + SET(_TMP ${${_UPNAME_FIXED}_DIR}) + GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE) + LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP}) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(DEFINED ${_UPNAME}_DIR) + SET(_TMP ${${_UPNAME}_DIR}) + LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP}) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(_BASE_DIRECTORIES) + FOREACH(_DIR ${_BASE_DIRECTORIES}) + IF(_DIR) + LIST(APPEND _INCLUDE_PATHS ${_DIR}/include ${_DIR}) + LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_DIR} as root directory") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + IF(UNIX) + # Append UNIX standard include paths + SET(_UNIX_INCLUDE_PATHS) + + # Append multiarch include paths + IF(CMAKE_LIBRARY_ARCHITECTURE) + LIST(APPEND _UNIX_INCLUDE_PATHS + /usr/local/include/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/include/${CMAKE_LIBRARY_ARCHITECTURE}) + ENDIF() + + LIST(APPEND _UNIX_INCLUDE_PATHS + /usr/local/include + /usr/include + /sw/include + /opt/local/include + /opt/csw/include + /opt/include) + ENDIF() + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Searching header ${INCLUDE} in: ${_INCLUDE_PATHS} with suffixes ${_SUFFIXES}") + ENDIF() + + # Search for include directory + FIND_PATH(${_UPNAME_FIXED}_INCLUDE_DIR + NAMES ${INCLUDE} + HINTS + ${PKG_${_NAME_FIXED}_INCLUDE_DIRS} + ${_INCLUDE_PATHS} + $ENV{${_UPNAME}_DIR}/include + $ENV{${_UPNAME_FIXED}_DIR}/include + $ENV{${_UPNAME}_DIR} + $ENV{${_UPNAME_FIXED}_DIR} + PATHS + ${_UNIX_INCLUDE_PATHS} + PATH_SUFFIXES + ${_SUFFIXES} + DOC "Include path for ${NAME}" + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_INCLUDE_DIR) + MESSAGE(STATUS "${INCLUDE} found in ${${_UPNAME_FIXED}_INCLUDE_DIR}") + ELSE() + MESSAGE(STATUS "${INCLUDE} not found") + ENDIF() + ENDIF() + + # Append environment variables XXX_DIR + LIST(APPEND _LIBRARY_PATHS + $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX} + $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX}) + + IF(UNIX) + SET(_UNIX_LIBRARY_PATHS) + + # Append multiarch libraries paths + IF(CMAKE_LIBRARY_ARCHITECTURE) + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}) + ENDIF() + + # Append UNIX standard libraries paths + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib + /usr/lib + /lib + /usr/local/X11R6/lib + /usr/X11R6/lib + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib${LIB_SUFFIX}) + ENDIF() + + LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED}) + LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d) + + # Under Windows, some libs may need the lib prefix + IF(WIN32) + SET(_LIBS ${_RELEASE_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _RELEASE_LIBRARIES lib${_LIB}) + ENDFOREACH() + + SET(_LIBS ${_DEBUG_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _DEBUG_LIBRARIES lib${_LIB}) + ENDFOREACH() + ENDIF() + + LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES) + LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES) + + # Search for release library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE + NAMES + ${_RELEASE_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}") + ELSE() + MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}") + ENDIF() + ENDIF() + + # Search for debug library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG + NAMES + ${_DEBUG_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}") + ELSE() + MESSAGE(STATUS "${NAME} debug library not found") + ENDIF() + ENDIF() + + SET(${_UPNAME_FIXED}_FOUND OFF) + + IF(${_UPNAME_FIXED}_INCLUDE_DIR) + # Set also _INCLUDE_DIRS + SET(${_UPNAME_FIXED}_INCLUDE_DIRS ${${_UPNAME_FIXED}_INCLUDE_DIR}) + ENDIF() + + # Library has been found if at least only one library and include are found + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Release and debug libraries found + SET(${_UPNAME_FIXED}_FOUND ON) + SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + # Release library found + SET(${_UPNAME_FIXED}_FOUND ON) + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Debug library found + SET(${_UPNAME_FIXED}_FOUND ON) + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + ENDIF() + + IF(${_UPNAME_FIXED}_FOUND) + IF(NOT ${NAME}_FIND_QUIETLY) + MESSAGE(STATUS "Found ${NAME}: ${${_UPNAME_FIXED}_LIBRARIES}") + ENDIF() + ELSE() + IF(${NAME}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Error: Unable to find ${NAME}!") + ENDIF() + IF(NOT ${NAME}_FIND_QUIETLY) + MESSAGE(STATUS "Warning: Unable to find ${NAME}!") + ENDIF() + ENDIF() + + MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG) +ENDMACRO() + +MACRO(MESSAGE_VERSION_PACKAGE_HELPER NAME VERSION) + MESSAGE(STATUS "Found ${NAME} ${VERSION}: ${ARGN}") +ENDMACRO() + +MACRO(FIND_LIBRARY_HELPER NAME) + # Looks for libraries. + # + # NAME is the name of the library, lowercase and uppercase can be mixed + # + # Following parameters are optional variables and must be prefixed by: + # + # RELEASE is the list of libraries to check in release mode + # DEBUG is the list of libraries to check in debug mode + # VERBOSE display more details if not found + # REQUIRED throw an error if not found + # DIR is the base directory where to look for + # + # The first match will be used in the specified order and next matches will be ignored + # + # The following values are defined + # NAME_LIBRARIES - link against these to use NAME + + SET(_PARAMS ${ARGN}) + + SET(_RELEASE_LIBRARIES) + SET(_DEBUG_LIBRARIES) + SET(_BASE_DIRECTORIES) + + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_VERBOSE OFF) + SET(_IS_DIR OFF) + + IF(_PARAMS) + FOREACH(_PARAM ${_PARAMS}) + IF(_PARAM STREQUAL "RELEASE") + SET(_IS_RELEASE ON) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "DEBUG") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG ON) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "VERBOSE") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + SET(_IS_VERBOSE ON) + ELSEIF(_PARAM STREQUAL "REQUIRED") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + SET(${NAME}_FIND_REQUIRED ON) + ELSEIF(_PARAM STREQUAL "DIR") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR ON) + ELSE() + IF(_IS_RELEASE) + LIST(APPEND _RELEASE_LIBRARIES ${_PARAM}) + ELSEIF(_IS_DEBUG) + LIST(APPEND _DEBUG_LIBRARIES ${_PARAM}) + ELSEIF(_IS_DIR) + LIST(APPEND _BASE_DIRECTORIES ${_PARAM}) + ELSE() + MESSAGE(STATUS "parameter ${_PARAM} with no prefix") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + # Fixes names if invalid characters are found + IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$") + SET(_NAME_FIXED ${NAME}) + ELSE() + # if invalid characters are detected, replace them by valid ones + STRING(REPLACE "+" "p" _NAME_FIXED ${NAME}) + ENDIF() + + # Create uppercase and lowercase versions of NAME + STRING(TOUPPER ${NAME} _UPNAME) + STRING(TOLOWER ${NAME} _LOWNAME) + + STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED) + STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED) + + SET(_LIBRARY_PATHS) + + # Check for root directories passed to CMake with -DXXX_DIR=... + IF(DEFINED ${_UPNAME_FIXED}_DIR) + SET(_TMP ${${_UPNAME_FIXED}_DIR}) + GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(DEFINED ${_UPNAME}_DIR) + SET(_TMP ${${_UPNAME}_DIR}) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(_BASE_DIRECTORIES) + FOREACH(_DIR ${_BASE_DIRECTORIES}) + IF(_DIR) + LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_DIR} as root directory") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + # Append environment variables XXX_DIR + LIST(APPEND _LIBRARY_PATHS + $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX} + $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX}) + + IF(UNIX) + SET(_UNIX_LIBRARY_PATHS) + + # Append multiarch libraries paths + IF(CMAKE_LIBRARY_ARCHITECTURE) + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}) + ENDIF() + + # Append UNIX standard libraries paths + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib + /usr/lib + /lib + /usr/local/X11R6/lib + /usr/X11R6/lib + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib${LIB_SUFFIX}) + ENDIF() + + LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED}) + LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d) + + # Under Windows, some libs may need the lib prefix + IF(WIN32) + SET(_LIBS ${_RELEASE_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _RELEASE_LIBRARIES lib${_LIB}) + ENDFOREACH() + + SET(_LIBS ${_DEBUG_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _DEBUG_LIBRARIES lib${_LIB}) + ENDFOREACH() + ENDIF() + + LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES) + LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES) + + # Search for release library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE + NAMES + ${_RELEASE_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}") + ELSE() + MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}") + ENDIF() + ENDIF() + + # Search for debug library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG + NAMES + ${_DEBUG_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}") + ELSE() + MESSAGE(STATUS "${NAME} debug library not found") + ENDIF() + ENDIF() + + # Library has been found if at least only one library and include are found + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Release and debug libraries found + SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + # Release library found + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Debug library found + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + ENDIF() + + MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG) +ENDMACRO() + +MACRO(FIND_LIBCURL) + IF(NOT CURL_FOUND) + FIND_PACKAGE(CURL REQUIRED) + + IF(WIN32 OR CURL_LIBRARY MATCHES "\\.a" OR WITH_STATIC_CURL) + SET(CURL_STATIC ON) + ELSE() + SET(CURL_STATIC OFF) + ENDIF() + + IF(CURL_STATIC) + SET(CURL_DEFINITIONS -DCURL_STATICLIB) + + IF(UNIX) + # CURL can depend on libidn + FIND_LIBRARY(IDN_LIBRARY idn) + IF(IDN_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY}) + ENDIF() + + # CURL Macports version can depend on libidn, libintl and libiconv too + IF(APPLE) + FIND_LIBRARY(INTL_LIBRARY intl) + IF(INTL_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY}) + ENDIF() + ELSE() + # Only used by libcurl under Linux + FIND_PACKAGE(OpenSSL REQUIRED) + + #IF(WIN32) + # SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib) + #ENDIF() + + # Only Linux version of libcurl depends on OpenSSL + LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) + LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) + ENDIF() + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() + +MACRO(FIND_LIBXML2) + IF(NOT LIBXML2_FOUND) + FIND_PACKAGE(LibXml2 REQUIRED) + + IF(WIN32 OR WITH_STATIC_LIBXML2) + LIST(APPEND LIBXML2_DEFINITIONS -DLIBXML_STATIC) + ENDIF() + + IF(WITH_LIBXML2_ICONV) + FIND_PACKAGE(Iconv REQUIRED) +# LIST(APPEND CURL_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) + LIST(APPEND LIBXML2_LIBRARIES ${ICONV_LIBRARIES}) + ENDIF() + + IF(WITH_STATIC) + # libxml2 could need winsock2 library + IF(WIN32) + FIND_LIBRARY(WINSOCK2_LIB ws2_32) + + IF(WINSOCK2_LIB) + LIST(APPEND LIBXML2_LIBRARIES ${WINSOCK2_LIB}) + ENDIF() + + FIND_LIBRARY(CRYPT32_LIB Crypt32) + + IF(CRYPT32_LIB) + LIST(APPEND LIBXML2_LIBRARIES ${CRYPT32_LIB}) + ENDIF() + ELSE() + # under Linux and OS X, recent libxml2 versions are linked against liblzma + FIND_PACKAGE(LibLZMA) + + IF(LIBLZMA_LIBRARIES) + LIST(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES}) + ENDIF() + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() + +MACRO(ADD_QT_LIBRARY _NAME) + IF(WIN32) + SET(_PREFIX "Qt5") + SET(_EXT "lib") + ELSE() + SET(_PREFIX "libQt5") + SET(_EXT "a") + ENDIF() + SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}") + IF(EXISTS ${_LIB}) + SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB}) + ENDIF() + SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}") + IF(EXISTS ${_LIB}) + SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB}) + ENDIF() +ENDMACRO() + +MACRO(ADD_QT_PLUGIN _TYPE _NAME) + IF(WIN32) + SET(_PREFIX "") + SET(_EXT "lib") + ELSE() + SET(_PREFIX "lib") + SET(_EXT "a") + ENDIF() + SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}") + IF(EXISTS ${_LIB}) + SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB}) + ENDIF() + SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}") + IF(EXISTS ${_LIB}) + SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB}) + ENDIF() +ENDMACRO() + +MACRO(ADD_QT_SYSTEM_LIBRARY _NAME) + # Save default suffixes + SET(_OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + + # Define specific suffixes + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) + + # Find the library with specified suffixes + FIND_LIBRARY(${_NAME}_LIBRARY NAMES ${_NAME}) + + # Restore default suffixes + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_OLD_SUFFIXES}) + + IF(${_NAME}_LIBRARY) + MESSAGE(STATUS "Found ${${_NAME}_LIBRARY} ${_NAME}") + + LIST(APPEND QT_LIBRARIES ${${_NAME}_LIBRARY}) + ELSE() + MESSAGE(STATUS "Didn't find ${_NAME}") + ENDIF() +ENDMACRO() + +MACRO(FIND_QT5) + CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR) + + SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR}) + + FIND_PACKAGE(Qt5Core QUIET) + + IF(Qt5Core_FOUND) + # Check if we are using Qt static or shared libraries + GET_TARGET_PROPERTY(_FILE Qt5::Core IMPORTED_LOCATION_RELEASE) + + SET(QT_VERSION "${Qt5Core_VERSION_STRING}") + SET(_VERSION "${QT_VERSION}") + + IF(_FILE MATCHES "\\.(lib|a)$") + SET(QT_STATIC ON) + SET(_VERSION "${_VERSION} static version") + ELSE() + SET(QT_STATIC OFF) + SET(_VERSION "${_VERSION} shared version") + ENDIF() + + MESSAGE(STATUS "Found Qt ${_VERSION}") + + # These variables are not defined with Qt5 CMake modules + SET(QT_BINARY_DIR "${_qt5Core_install_prefix}/bin") + SET(QT_LIBRARY_DIR "${_qt5Core_install_prefix}/lib") + SET(QT_PLUGINS_DIR "${_qt5Core_install_prefix}/plugins") + SET(QT_TRANSLATIONS_DIR "${_qt5Core_install_prefix}/translations") + + # Fix wrong include directories with Qt 5 under Mac OS X + INCLUDE_DIRECTORIES("${_qt5Core_install_prefix}/include") + + FIND_PACKAGE(Qt5Gui) + FIND_PACKAGE(Qt5Widgets) + FIND_PACKAGE(Qt5OpenGL) + FIND_PACKAGE(Qt5Xml) + FIND_PACKAGE(Qt5LinguistTools) + FIND_PACKAGE(Qt5Network) + + IF(QT_STATIC) + FIND_PACKAGE(PNG REQUIRED) + FIND_PACKAGE(Jpeg REQUIRED) + + ADD_DEFINITIONS(-DQT_STATICPLUGIN) + + SET(QT_LIBRARIES Qt5::Widgets) + + # Gui + SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::OpenGL) + + ADD_QT_LIBRARY(PrintSupport) + + IF(WIN32) + SET(QT_LIBRARIES ${QT_LIBRARIES} + ${WINSDK_LIBRARY_DIR}/Imm32.lib + ${WINSDK_LIBRARY_DIR}/OpenGL32.lib + ${WINSDK_LIBRARY_DIR}/WinMM.Lib) + ADD_QT_PLUGIN(platforms qwindows) + ADD_QT_LIBRARY(PlatformSupport) + ELSEIF(APPLE) + # Cups needs .dylib + SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib) + FIND_LIBRARY(CUPS_LIBRARY cups) + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES}) + + FIND_LIBRARY(IOKIT_FRAMEWORK IOKit) + FIND_LIBRARY(COCOA_FRAMEWORK Cocoa) + FIND_LIBRARY(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration) + FIND_LIBRARY(OPENGL_FRAMEWORK NAMES OpenGL) + + SET(QT_LIBRARIES ${QT_LIBRARIES} + ${CUPS_LIBRARY} + ${COCOA_FRAMEWORK} + ${SYSTEMCONFIGURATION_FRAMEWORK} + ${IOKIT_FRAMEWORK} + ${OPENGL_FRAMEWORK}) + + ADD_QT_PLUGIN(printsupport cocoaprintersupport) + ADD_QT_PLUGIN(platforms qcocoa) + ADD_QT_LIBRARY(PlatformSupport) + ELSE() + # order is very important there + ADD_QT_PLUGIN(platforms qxcb) + ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration) + + ADD_QT_LIBRARY(XcbQpa) + ADD_QT_LIBRARY(GlxSupport) + ADD_QT_LIBRARY(ServiceSupport) + ADD_QT_LIBRARY(EdidSupport) + ADD_QT_LIBRARY(FontDatabaseSupport) + ADD_QT_LIBRARY(ThemeSupport) + ADD_QT_LIBRARY(EventDispatcherSupport) + ADD_QT_LIBRARY(PlatformSupport) + + ADD_QT_LIBRARY(DBus) + + IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a") + SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_LIBRARY_DIR}/libxcb-static.a") + ENDIF() + + # always link these in dynamic, API never changes + ADD_QT_SYSTEM_LIBRARY(X11) + ADD_QT_SYSTEM_LIBRARY(Xmu) + ADD_QT_SYSTEM_LIBRARY(X11-xcb) + ADD_QT_SYSTEM_LIBRARY(Xi) + ADD_QT_SYSTEM_LIBRARY(SM) + ADD_QT_SYSTEM_LIBRARY(ICE) + ADD_QT_SYSTEM_LIBRARY(xcb) + ADD_QT_SYSTEM_LIBRARY(GL) + ADD_QT_SYSTEM_LIBRARY(xcb-glx) + ADD_QT_SYSTEM_LIBRARY(fontconfig) + ADD_QT_SYSTEM_LIBRARY(Xrender) + ENDIF() + + ADD_QT_PLUGIN(imageformats qgif) + ADD_QT_PLUGIN(imageformats qicns) + ADD_QT_PLUGIN(imageformats qico) + ADD_QT_PLUGIN(imageformats qjpeg) + + # harfbuzz is needed since Qt 5.3 + IF(UNIX) + SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzzng.a") + IF(NOT EXISTS ${HB_LIB}) + SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzz.a") + ENDIF() + ELSEIF(WIN32) + SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib") + ENDIF() + IF(EXISTS ${HB_LIB}) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${HB_LIB}) + ENDIF() + + # freetype is needed since Qt 5.5 + FIND_PACKAGE(Freetype) + + IF(FREETYPE_FOUND) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIBRARIES}) + ELSE() + IF(UNIX) + SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a") + ELSEIF(WIN32) + SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib") + ENDIF() + IF(EXISTS ${FREETYPE_LIB}) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIB}) + ENDIF() + ENDIF() + + ADD_QT_PLUGIN(accessible qtaccessiblewidgets) + + SET(QT_LIBRARIES ${QT_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARY}) + + # Network + SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Network Qt5::Xml) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${ZLIB_LIBRARIES}) + + IF(WIN32) + SET(QT_LIBRARIES ${QT_LIBRARIES} + ${WINSDK_LIBRARY_DIR}/Crypt32.lib + ${WINSDK_LIBRARY_DIR}/WS2_32.Lib + ${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib) + ENDIF() + + # Core + SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Core) + + # pcre is needed since Qt 5.5 + IF(UNIX) + SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a") + IF(NOT EXISTS ${PCRE_LIB}) + SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre2.a") + ENDIF() + ELSEIF(WIN32) + SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib") + ENDIF() + IF(EXISTS ${PCRE_LIB}) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${PCRE_LIB}) + ENDIF() + + IF(APPLE) + FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre) + + FIND_LIBRARY(SECURITY_FRAMEWORK Security) + + SET(QT_LIBRARIES ${QT_LIBRARIES} + ${PCRE_LIBRARY} + ${FOUNDATION_FRAMEWORK} + ${CARBON_FRAMEWORK} + ${SECURITY_FRAMEWORK}) + ELSEIF(UNIX) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -ldl -lrt) + ENDIF() + ELSE() + SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core) + ENDIF() + ELSE() + MESSAGE(WARNING "Unable to find Qt 5") + ENDIF() +ENDMACRO() diff --git a/code/CMakeModules/FindNeL.cmake b/code/CMakeModules/FindNeL.cmake new file mode 100644 index 000000000..e75163cce --- /dev/null +++ b/code/CMakeModules/FindNeL.cmake @@ -0,0 +1,398 @@ +# NEL_DIR can be specified as root directory + +# Returned variables +# NELDRIVER_XXX_BINARY_DEBUG +# NELDRIVER_XXX_BINARY_RELEASE +# NELDRIVER_XXX_LIBRARY_DEBUG +# NELDRIVER_XXX_LIBRARY_RELEASE +# NELDRIVER_XXX_FOUND +# NEL_DEFINITIONS +# NEL_INCLUDE_DIR +# NEL_INCLUDE_DIRS +# NEL_LIBRARIES +# NELXXX_FOUND +# NELXXX_LIBRARIES + + +INCLUDE(FindHelpers) + +# Init all variables we'll set +SET(NEL_LIBRARIES) +SET(NEL_INCLUDE_DIR) +SET(NEL_INCLUDE_DIRS) +SET(NEL_VERSION) +SET(NEL_STATIC) +SET(NEL_STATIC_DRIVERS) +SET(NEL_VERSION_MAJOR) +SET(NEL_VERSION_MINOR) +SET(NEL_VERSION_PATCH) +SET(NEL_REVISION) +SET(NEL_VERSION) + +SET(NEL_MODULES_FOUND) +SET(NEL_MODULES_AVAILABLE 3d georges gui ligo logic net pacs sound) # cegui pipeline + +SET(NEL_DRIVERS_FOUND) +SET(NEL_DRIVERS_AVAILABLE opengl opengles direct3d dsound fmod openal xaudio2) + +SET(NELMISC_FIND_REQUIRED ${NeL_FIND_REQUIRED}) + +# Force search of NELMISC +FIND_PACKAGE_HELPER(nelmisc nel/misc/types_nl.h RELEASE nelmisc_r nelmisc DEBUG nelmisc_d DIR ${NEL_DIR} VERBOSE QUIET) + +IF(NELMISC_FOUND) + # define NEL_DIR if not specified + IF(NOT NEL_DIR) + GET_FILENAME_COMPONENT(NEL_DIR ${NELMISC_INCLUDE_DIR}/.. ABSOLUTE) + ENDIF() + + # Aliases for include directory + SET(NEL_INCLUDE_DIR ${NELMISC_INCLUDE_DIR}) + SET(NEL_INCLUDE_DIRS ${NEL_INCLUDE_DIR}) + + MESSAGE(STATUS "Found NeL headers in ${NEL_INCLUDE_DIR}") + + GET_FILENAME_COMPONENT(NEL_LIBRARY_DIR ${NELMISC_LIBRARY} DIRECTORY) + + MESSAGE(STATUS "Found NeL library in ${NEL_LIBRARY_DIR}") + + # TODO: implement static version checks for Windows + + # static libraries + IF(UNIX) + GET_FILENAME_COMPONENT(_LIBEXT ${NELMISC_LIBRARY} EXT) + + IF(_LIBEXT STREQUAL ".a") + SET(NEL_STATIC ON) + MESSAGE(STATUS "NeL is using static libraries") + ENDIF() + ENDIF() + + IF(WIN32) + SET(NELDRIVER_DIRS_TO_CHECK + ${NEL_DIR}/bin${LIB_SUFFIX} + ${NEL_DIR} + ) + ELSE() + SET(NELDRIVER_DIRS_TO_CHECK + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/nel + /usr/lib + ) + ENDIF() + + # check for static drivers + FOREACH(_DRIVER ${NEL_DRIVERS_AVAILABLE}) + IF(WIN32) + SET(_DRIVER_RELASE_FILE "nel_drv_${_DRIVER}_win_r") + SET(_DRIVER_DEBUG_FILE "nel_drv_${_DRIVER}_win_d") + SET(_DRIVER_SHARED_EXT dll) + SET(_DRIVER_STATIC_EXT lib) + ELSE() + SET(_DRIVER_RELEASE_FILE "nel_drv_${_DRIVER}") + SET(_DRIVER_DEBUG_FILE) + SET(_DRIVER_SHARED_EXT so) + SET(_DRIVER_STATIC_EXT a) + ENDIF() + + STRING(TOUPPER ${_DRIVER} _UPDRIVER) + + FOREACH(_DIR ${NELDRIVER_DIRS_TO_CHECK}) + SET(_FOUND OFF) + + IF(_DRIVER_RELASE_FILE) + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_SHARED_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_BINARY_RELEASE ${_FILE}) + + MESSAGE(STATUS "Found NeL release shared driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS OFF) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_STATIC_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_LIBRARY_RELEASE ${_FILE}) + + MESSAGE(STATUS "Found NeL release static driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS ON) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + ENDIF() + + IF(_DRIVER_DEBUG_FILE) + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_SHARED_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_BINARY_DEBUG ${_FILE}) + + MESSAGE(STATUS "Found NeL debug shared driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS OFF) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_STATIC_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_LIBRARY_DEBUG ${_FILE}) + + MESSAGE(STATUS "Found NeL debug static driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS ON) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + + IF(_FOUND) + SET(NELDRIVER_${_UPDRIVER}_FOUND ON) + LIST(APPEND NEL_DRIVERS_FOUND ${_DRIVER}) + ENDIF() + ENDIF() + ENDFOREACH() + ENDFOREACH() + + MESSAGE(STATUS "Found NeL driver in ${NEL_DRIVER_DIR}") + + PARSE_VERSION_OTHER(${NEL_INCLUDE_DIR}/nel/misc/version_nl.h NL_VERSION_MAJOR NL_VERSION_MINOR NL_VERSION_PATCH NL_REVISION) + + SET(NEL_VERSION_MAJOR ${NL_VERSION_MAJOR}) + SET(NEL_VERSION_MINOR ${NL_VERSION_MINOR}) + SET(NEL_VERSION_PATCH ${NL_VERSION_PATCH}) + SET(NEL_REVISION ${NL_REVISION}) + + IF(NOT NEL_VERSION) + IF(NEL_VERSION_MAJOR OR NEL_VERSION_MINOR} OR NEL_VERSION_PATCH) + SET(NEL_VERSION "${NEL_VERSION_MAJOR}.${NEL_VERSION_MINOR}.${NEL_VERSION_PATCH}") + ELSE() + SET(NEL_VERSION "0.5.0") + ENDIF() + + IF(NEL_REVISION) + SET(NEL_VERSION "${NEL_VERSION}.${NEL_REVISION}") + ENDIF() + ENDIF() + + FIND_PACKAGE(PNG REQUIRED) + IF(PNG_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${PNG_LIBRARIES}) + ENDIF() + + FIND_PACKAGE(Jpeg REQUIRED) + IF(JPEG_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${JPEG_LIBRARY}) + ENDIF() + + FIND_PACKAGE(GIF) + + IF(GIF_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${GIF_LIBRARY}) + ENDIF() + + FIND_LIBXML2() + + IF(LIBXML2_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${LIBXML2_LIBRARIES}) + ENDIF() + + LIST(REMOVE_ITEM NeL_FIND_COMPONENTS misc) + + LIST(APPEND NEL_MODULES_FOUND misc) + LIST(APPEND NEL_LIBRARIES ${NELMISC_LIBRARIES}) +ENDIF() + +IF(NOT NeL_FIND_COMPONENTS) + SET(NeL_FIND_COMPONENTS ${NEL_MODULES_AVAILABLE}) + + # We can skip not installed modules + SET(NeL_FIND_REQUIRED OFF) +ENDIF() + +FOREACH(COMPONENT ${NeL_FIND_COMPONENTS}) + SET(_NAME NeL${COMPONENT}) + STRING(TOUPPER ${_NAME} _UPNAME) + + # module is required + SET(${_NAME}_FIND_REQUIRED ${NeL_FIND_REQUIRED}) + + IF(COMPONENT STREQUAL "3d") + SET(HEADER_FILE shape.h) +# ELSEIF(COMPONENT STREQUAL "cegui") +# SET(HEADER_FILE shape.h) + ELSEIF(COMPONENT STREQUAL "georges") + SET(HEADER_FILE form.h) + ELSEIF(COMPONENT STREQUAL "gui") + SET(HEADER_FILE reflect.h) + ELSEIF(COMPONENT STREQUAL "ligo") + SET(HEADER_FILE primitive.h) + ELSEIF(COMPONENT STREQUAL "logic") + SET(HEADER_FILE logic_state.h) + ELSEIF(COMPONENT STREQUAL "net") + SET(HEADER_FILE sock.h) + ELSEIF(COMPONENT STREQUAL "pacs") + SET(HEADER_FILE primitive_block.h) +# ELSEIF(COMPONENT STREQUAL "pipeline") +# SET(HEADER_FILE shape.h) + ELSEIF(COMPONENT STREQUAL "sound") + SET(HEADER_FILE shape.h) + ELSE() + SET(HEADER_FILE) + ENDIF() + + # display if a component has a wrong name + IF(NOT HEADER_FILE) + MESSAGE(STATUS "NeL module ${COMPONENT} not supported, ignoring it...") + CONTINUE() + ENDIF() + + FIND_PACKAGE_HELPER(${_NAME} nel/${COMPONENT}/${HEADER_FILE} + RELEASE nel${COMPONENT}_r nel${COMPONENT} + DEBUG nel${COMPONENT}_d + QUIET) + + IF(${_UPNAME}_FOUND) + LIST(APPEND NEL_MODULES_FOUND ${COMPONENT}) + + IF(COMPONENT STREQUAL "3d") + IF(NEL_STATIC) + # 3rd party dependencies + FIND_PACKAGE(Freetype REQUIRED) + IF(FREETYPE_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${FREETYPE_LIBRARIES}) + ENDIF() + + # Append static 3D drivers + IF(NEL_STATIC_DRIVERS) + # Direct3D driver (only under Windows) + IF(WIN32) + IF(NELDRIVER_DIRECT3D_LIBRARY_DEBUG) + LIST(APPEND ${_UPNAME}_LIBRARIES debug ${NELDRIVER_DIRECT3D_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_DIRECT3D_LIBRARY_RELEASE) + LIST(APPEND ${_UPNAME}_LIBRARIES optimized ${NELDRIVER_DIRECT3D_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + + # OpenGL driver + IF(NELDRIVER_OPENGL_LIBRARY_DEBUG) + LIST(APPEND ${_UPNAME}_LIBRARIES debug ${NELDRIVER_OPENGL_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_OPENGL_LIBRARY_RELEASE) + LIST(APPEND ${_UPNAME}_LIBRARIES optimized ${NELDRIVER_OPENGL_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + ENDIF() + ELSEIF(COMPONENT STREQUAL "gui") + FIND_PACKAGE(Luabind REQUIRED) + + LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES}) + + FIND_LIBCURL() + + IF(CURL_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${CURL_LIBRARIES}) + LIST(APPEND ${_UPNAME}_DEFINITIONS ${CURL_DEFINITIONS}) + ENDIF() + + # TODO: remove complately OpenSSL requirement on Windows + + # Only used by libcurl under Linux + FIND_PACKAGE(OpenSSL REQUIRED) + + IF(WIN32) + LIST(APPEND OPENSSL_LIBRARIES Crypt32.lib) + ENDIF() + + # Only Linux version of libcurl depends on OpenSSL + LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) + LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) + + LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES} ${CURL_LIBRARIES}) + LIST(APPEND NEL_DEFINITIONS ${${_UPNAME}_DEFINITIONS}) + ELSEIF(COMPONENT STREQUAL "sound") + FIND_PACKAGE(Ogg REQUIRED) + + IF(OGG_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${OGG_LIBRARY}) + ENDIF() + + FIND_PACKAGE(Vorbis REQUIRED) + + IF(VORBIS_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY}) + ENDIF() + + IF(NEL_STATIC) + # Link to snd_lowlevel + FIND_LIBRARY_HELPER(nelsnd_lowlevel RELEASE nelsnd_lowlevel_r DEBUG nelsnd_lowlevel_d DIR ${NEL_DIR} REQUIRED) + + IF(NELSND_LOWLEVEL_LIBRARIES) + MESSAGE(STATUS "Found NeL sound lowlevel ${NELSND_LOWLEVEL_LIBRARIES}") + + LIST(APPEND NELSOUND_LIBRARIES ${NELSND_LOWLEVEL_LIBRARIES}) + + IF(NEL_STATIC_DRIVERS) + # DirectSound, XAudio2 and FMod drivers (only under Windows) + IF(WIN32) + # DirectSound + IF(NELDRIVER_DIRECTSOUND_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_DIRECTSOUND_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_DIRECTSOUND_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_DIRECTSOUND_LIBRARY_RELEASE}) + ENDIF() + + # FMod + IF(NELDRIVER_FMOD_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_FMOD_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_FMOD_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_FMOD_LIBRARY_RELEASE}) + ENDIF() + + # XAudio2 + IF(NELDRIVER_XAUDIO2_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_XAUDIO2_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_XAUDIO2_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_XAUDIO2_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + + # OpenAL driver + IF(NELDRIVER_OPENAL_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_OPENAL_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_OPENAL_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_OPENAL_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + ENDIF() + ENDIF() + ENDIF() + + LIST(APPEND NEL_LIBRARIES ${${_UPNAME}_LIBRARIES}) + ENDIF() +ENDFOREACH() + +MESSAGE_VERSION_PACKAGE_HELPER(NeL ${NEL_VERSION} ${NEL_MODULES_FOUND}) diff --git a/code/CMakeModules/FindRyzomGameShare.cmake b/code/CMakeModules/FindRyzomGameShare.cmake new file mode 100644 index 000000000..56eb94569 --- /dev/null +++ b/code/CMakeModules/FindRyzomGameShare.cmake @@ -0,0 +1,10 @@ +INCLUDE(FindHelpers) + +FIND_PACKAGE_HELPER(RyzomGameShare game_share/continent.h RELEASE ryzom_gameshare_r ryzom_gameshare DEBUG ryzom_gameshare_d DIR ${NEL_DIR} ${RYZOM_DIR} SUFFIXES ryzom) + +IF(RYZOMGAMESHARE_FOUND) + SET(RYZOM_GAMESHARE_LIBRARIES ${RYZOMGAMESHARE_LIBRARIES}) + SET(RYZOM_GAMESHARE_FOUND ${RYZOMGAMESHARE_FOUND}) + SET(RYZOM_GAMESHARE_INCLUDE_DIR ${RYZOMGAMESHARE_INCLUDE_DIR}) + SET(RYZOM_GAMESHARE_INCLUDE_DIRS ${RYZOMGAMESHARE_INCLUDE_DIRS}) +ENDIF() From 4df0fd37f3dd93be1d8bc18d7edc595d503ebf03 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 28 Jul 2018 11:45:49 +0200 Subject: [PATCH 14/65] Changed: Define and use LIB_SUFFIX --HG-- branch : develop --- code/CMakeLists.txt | 13 +++++++++++++ code/CMakeModules/nel.cmake | 24 +++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 87367c98e..022c34659 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -249,6 +249,19 @@ IF(WITH_NEL) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include) ADD_SUBDIRECTORY(nel) + + # Aliases for targets + SET(NELMISC_LIBRARIES nelmisc) + SET(NELNET_LIBRARIES nelnet) + SET(NELLIGO_LIBRARIES nelligo) + SET(NELGEORGES_LIBRARIES nelgeorges) + SET(NEL3D_LIBRARIES nel3d) + SET(NELGUI_LIBRARIES nelgui) + SET(NELSOUND_LIBRARIES nelsound) +ELSE() +# FIND_PACKAGE(NeL COMPONENTS 3d misc pacs sound nimp REQUIRED) + FIND_PACKAGE(NeL REQUIRED) + INCLUDE_DIRECTORIES(${NEL_INCLUDE_DIRS}) ENDIF() IF(WITH_RYZOM) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 258e777aa..453b1fe1a 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -1041,6 +1041,12 @@ MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE) ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX) MACRO(NL_SETUP_PREFIX_PATHS) + IF(TARGET_X64 AND WIN32) + SET(LIB_SUFFIX "64") + ELSE() + SET(LIB_SUFFIX "") + ENDIF() + ## Allow override of install_prefix/etc path. IF(NOT NL_ETC_PREFIX) IF(WITH_UNIX_STRUCTURE) @@ -1064,7 +1070,7 @@ MACRO(NL_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/sbin path. IF(NOT NL_SBIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(NL_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + SET(NL_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.") ELSE() SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") ENDIF() @@ -1074,7 +1080,7 @@ MACRO(NL_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/bin path. IF(NOT NL_BIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(NL_BIN_PREFIX "bin" CACHE PATH "Installation path for tools and applications.") + SET(NL_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools and applications.") ELSE() SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") ENDIF() @@ -1086,7 +1092,7 @@ MACRO(NL_SETUP_PREFIX_PATHS) IF(LIBRARY_ARCHITECTURE) SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") ELSE() - SET(NL_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + SET(NL_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.") ENDIF() ENDIF() NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX) @@ -1097,7 +1103,11 @@ MACRO(NL_SETUP_PREFIX_PATHS) IF(LIBRARY_ARCHITECTURE) SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.") ELSE() - SET(NL_DRIVER_PREFIX "lib/nel" CACHE PATH "Installation path for drivers.") + IF(WIN32) + SET(NL_DRIVER_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for drivers.") + ELSE() + SET(NL_DRIVER_PREFIX "lib${LIB_SUFFIX}/nel" CACHE PATH "Installation path for drivers.") + ENDIF() ENDIF() ELSE() SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.") @@ -1130,7 +1140,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/sbin path. IF(NOT RYZOM_SBIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(RYZOM_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + SET(RYZOM_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.") ELSE() SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") ENDIF() @@ -1140,7 +1150,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/bin path. IF(NOT RYZOM_BIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(RYZOM_BIN_PREFIX "bin" CACHE PATH "Installation path for tools.") + SET(RYZOM_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools.") ELSE() SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") ENDIF() @@ -1152,7 +1162,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) IF(LIBRARY_ARCHITECTURE) SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") ELSE() - SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + SET(RYZOM_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.") ENDIF() ENDIF() NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX) From 7a85eef10bfec9dfe0040c3ab9e1e55736024929 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 28 Jul 2018 11:46:34 +0200 Subject: [PATCH 15/65] Changed: Minor changes --HG-- branch : develop --- code/CMakeModules/nel.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 453b1fe1a..abe41ca1f 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -382,7 +382,6 @@ MACRO(CONVERT_VERSION_NUMBER _VERSION_NUMBER _BASE) ENDMACRO() MACRO(NL_SETUP_BUILD) - #----------------------------------------------------------------------------- # Setup the buildmode variables. # @@ -1238,4 +1237,4 @@ MACRO(SETUP_EXTERNAL) FIND_PACKAGE(MSVC REQUIRED) FIND_PACKAGE(WindowsSDK REQUIRED) ENDIF() -ENDMACRO(SETUP_EXTERNAL) +ENDMACRO() From d4fbb641207bf24d7d4d41d827e442bf83c46be1 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 28 Jul 2018 11:52:16 +0200 Subject: [PATCH 16/65] Added: Steam CMake module --HG-- branch : develop --- code/CMakeModules/FindSteam.cmake | 74 +++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 code/CMakeModules/FindSteam.cmake diff --git a/code/CMakeModules/FindSteam.cmake b/code/CMakeModules/FindSteam.cmake new file mode 100644 index 000000000..5657312eb --- /dev/null +++ b/code/CMakeModules/FindSteam.cmake @@ -0,0 +1,74 @@ +# - Locate Steam API +# This module defines +# STEAM_LIBRARY, the library to link against +# STEAM_FOUND, if false, do not try to link to STEAM +# STEA%_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() From 1000e29a963a7f182deaf0f30f3b3b2c299571b7 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 31 Jul 2018 18:36:36 +0200 Subject: [PATCH 17/65] Fixed: Compilation with VC++ 2013 --HG-- branch : develop --- code/nel/tools/pacs/build_rbank/build_surf.cpp | 2 +- code/ryzom/server/src/ags_test/command_event_manager.h | 2 +- code/ryzom/server/src/ags_test/move_manager.h | 2 +- .../server/src/entity_view_service/entity_view_service.h | 2 +- code/ryzom/tools/pd_parser/parser.cpp | 4 ++-- code/ryzom/tools/pd_parser/parser_rules.h | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/nel/tools/pacs/build_rbank/build_surf.cpp b/code/nel/tools/pacs/build_rbank/build_surf.cpp index 7e873f15f..465f5f94f 100644 --- a/code/nel/tools/pacs/build_rbank/build_surf.cpp +++ b/code/nel/tools/pacs/build_rbank/build_surf.cpp @@ -671,7 +671,7 @@ bool NLPACS::CComputableSurface::checkConsistency() CComputableSurfaceBorder& border = (*BorderKeeper)[BorderIds[i]]; for (j=0; j+1(border.Vertices[j], border.Vertices[j+1])); + edges.push_back(std::make_pair(border.Vertices[j], border.Vertices[j+1])); } for (i=0; i+1 res = _Map.insert(std::make_pair(var, value)); + std::pair res = _Map.insert(std::make_pair(var, value)); if (!res.second) (*(res.first)).second = value; return (*(res.first)).second; diff --git a/code/ryzom/server/src/ags_test/move_manager.h b/code/ryzom/server/src/ags_test/move_manager.h index 9987b0169..ab78cecd4 100644 --- a/code/ryzom/server/src/ags_test/move_manager.h +++ b/code/ryzom/server/src/ags_test/move_manager.h @@ -95,7 +95,7 @@ public: { if (PrimZoneMap.find(primZone.getName()) == PrimZoneMap.end()) { - PrimZoneMap.insert(std::make_pair(primZone.getName(), primZone)); + PrimZoneMap.insert(std::make_pair(primZone.getName(), primZone)); nlinfo("Using PrimZone '%s'", primZone.getName().c_str()); } else diff --git a/code/ryzom/server/src/entity_view_service/entity_view_service.h b/code/ryzom/server/src/entity_view_service/entity_view_service.h index 2b7e47ca1..5656d86eb 100644 --- a/code/ryzom/server/src/entity_view_service/entity_view_service.h +++ b/code/ryzom/server/src/entity_view_service/entity_view_service.h @@ -179,7 +179,7 @@ public: { nlinfo("Create entity %s", id.toString().c_str()); - std::pair res = _Entities.insert(std::make_pair(id, CEntity())); + std::pair res = _Entities.insert(std::make_pair(id, CEntity())); TEntityMap::iterator ite = res.first; nlassert(ite != _Entities.end() && res.second); diff --git a/code/ryzom/tools/pd_parser/parser.cpp b/code/ryzom/tools/pd_parser/parser.cpp index e1c564c33..d4ae04508 100644 --- a/code/ryzom/tools/pd_parser/parser.cpp +++ b/code/ryzom/tools/pd_parser/parser.cpp @@ -4512,11 +4512,11 @@ void CDeclarationNode::generateSetContent(CCallContext *context) if (useReference) { FetchId.add(Type+"*\t"+objectVariable+" = static_cast<"+Type+"*>("+pdslibFunc("create")+"(tableIndex));"); - FetchId.add(cppName()+".insert(std::make_pair<"+keyType->getName()+","+Type+"*>("+keyVariable+", "+objectVariable+"));"); + FetchId.add(cppName()+".insert(std::make_pair("+keyVariable+", "+objectVariable+"));"); } else { - FetchId.add(cppName()+".insert(std::make_pair<"+keyType->getName()+","+Type+">("+keyVariable+", "+Type+"()));"); + FetchId.add(cppName()+".insert(std::make_pair("+keyVariable+", "+Type+"()));"); FetchId.add(Type+"*\t"+objectVariable+" = &("+cppName()+"["+keyVariable+"]);"); } FetchId.add(pdslibFunc("setRowIndex")+"(rowIndex, "+objectVariable+");"); diff --git a/code/ryzom/tools/pd_parser/parser_rules.h b/code/ryzom/tools/pd_parser/parser_rules.h index 9fbc28899..01d7310e6 100644 --- a/code/ryzom/tools/pd_parser/parser_rules.h +++ b/code/ryzom/tools/pd_parser/parser_rules.h @@ -161,7 +161,7 @@ CParseNode *parse##nodename(CTokenizer &tokenizer) \ PARSE_FAIL \ CTokenizer::CToken t2 = tokenizer.currentToken(); \ tokenizer.next(); \ - main->savein.push_back(std::make_pair(tokenizer.get(t1), tokenizer.get(t2))); \ + main->savein.push_back(std::make_pair(tokenizer.get(t1), tokenizer.get(t2))); \ } /* From f04fd9809c42339bcd83b64c49477df4d20f9ce1 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 5 Aug 2018 14:31:53 +0200 Subject: [PATCH 18/65] Fixed: Allow to use custom CA Certificates under all platforms if libcurl compiled with OpenSSL for WebIG and login --HG-- branch : develop --- code/nel/include/nel/gui/curl_certificates.h | 15 +- code/nel/src/gui/curl_certificates.cpp | 219 ++++++++++++++++--- code/nel/src/gui/group_html.cpp | 19 +- code/ryzom/client/src/http_client_curl.cpp | 126 +---------- 4 files changed, 224 insertions(+), 155 deletions(-) diff --git a/code/nel/include/nel/gui/curl_certificates.h b/code/nel/include/nel/gui/curl_certificates.h index 021b13360..dd4e923a0 100644 --- a/code/nel/include/nel/gui/curl_certificates.h +++ b/code/nel/include/nel/gui/curl_certificates.h @@ -17,19 +17,24 @@ #ifndef CL_CURL_CERTIFICATES_HTML_H #define CL_CURL_CERTIFICATES_HTML_H -#include - #include "nel/misc/types_nl.h" +#include + namespace NLGUI { -#if defined(NL_OS_WINDOWS) - class CCurlCertificates { + class CCurlCertificates + { public: + // check if compiled with OpenSSL backend + static void init(CURL *curl); + + // allow to use custom PEM certificates + static void addCertificateFile(const std::string &cert); + // cURL SSL certificate loading static CURLcode sslCtxFunction(CURL *curl, void *sslctx, void *parm); }; -#endif // NL_OS_WINDOWS } // namespace #endif diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index 6cf34c8b8..a279d35f6 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -21,11 +21,7 @@ #include #include - -#if defined(NL_OS_WINDOWS) -#pragma comment(lib, "crypt32.lib") -#pragma comment(lib, "cryptui.lib") -#endif +#include using namespace std; using namespace NLMISC; @@ -36,36 +32,68 @@ using namespace NLMISC; namespace NLGUI { -#if defined(NL_OS_WINDOWS) - static std::vector x509CertList; - // // x509CertList lifetime manager // - class SX509Certificates { + class SX509Certificates + { public: - SX509Certificates() + std::vector CertList; + std::vector FilesList; + + bool isUsingOpenSSLBackend; + bool isInitialized; + + SX509Certificates():isUsingOpenSSLBackend(false), isInitialized(false) { - curl_version_info_data *data; - data = curl_version_info(CURLVERSION_NOW); - if (!(data && data->features & CURL_VERSION_SSPI)) - { - addCertificatesFrom("CA"); - addCertificatesFrom("AuthRoot"); - addCertificatesFrom("ROOT"); - } } ~SX509Certificates() { - for (uint i = 0; i < x509CertList.size(); ++i) + for (uint i = 0; i < CertList.size(); ++i) { - X509_free(x509CertList[i]); + X509_free(CertList[i]); } - x509CertList.clear(); + CertList.clear(); } + void init(CURL *curl) + { + if (isInitialized) return; + + // get information on CURL + curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); + + // get more information on CURL session + curl_tlssessioninfo *sessionInfo; + CURLcode res = curl_easy_getinfo(curl, CURLINFO_TLS_SSL_PTR, &sessionInfo); + + // only use OpenSSL callback if not using Windows SSPI and using OpenSSL backend + if (!res && sessionInfo && sessionInfo->backend == CURLSSLBACKEND_OPENSSL && !(data && data->features & CURL_VERSION_SSPI)) + { +#ifdef NL_OS_WINDOWS + // load native Windows CA Certs + addCertificatesFrom("CA"); + addCertificatesFrom("AuthRoot"); + addCertificatesFrom("ROOT"); + + // we manually loaded native CA Certs, don't need to use custom certificates + isUsingOpenSSLBackend = false; +#else + isUsingOpenSSLBackend = true; +#endif + } + else + { + // if CURL is using SSPI under Windows or SecureChannel under OS X, we'll use native system CA Certs + isUsingOpenSSLBackend = false; + } + + isInitialized = true; + } + +#ifdef NL_OS_WINDOWS void addCertificatesFrom(LPCSTR root) { HCERTSTORE hStore; @@ -80,7 +108,7 @@ namespace NLGUI x509 = d2i_X509(NULL, (const unsigned char **)&pContext->pbCertEncoded, pContext->cbCertEncoded); if (x509) { - x509CertList.push_back(x509); + CertList.push_back(x509); } } CertFreeCertificateContext(pContext); @@ -88,26 +116,157 @@ namespace NLGUI } // this is called before debug context is set and log ends up in log.log - //nlinfo("Loaded %d certificates from '%s' certificate store", List.size(), root); + nlinfo("Loaded %d certificates from '%s' certificate store", (int)CertList.size(), root); + } +#endif + + void addCertificatesFromFile(const std::string &cert) + { + if (!isInitialized) + { + nlwarning("You MUST call NLGUI::CCurlCertificates::init before adding new certificates"); + return; + } + + if (!isUsingOpenSSLBackend) return; + + // this file was already loaded + if (std::find(FilesList.begin(), FilesList.end(), cert) != FilesList.end()) return; + + FilesList.push_back(cert); + + // look for certificate in search paths + string path = CPath::lookup(cert); + nlinfo("Cert path '%s'", path.c_str()); + + if (path.empty()) + { + nlwarning("Unable to find %s", cert.c_str()); + return; + } + + CIFile file; + + // open certificate + if (!file.open(path)) + { + nlwarning("Unable to open %s", path.c_str()); + return; + } + + // load certificate content into memory + std::vector buffer(file.getFileSize()); + file.serialBuffer(&buffer[0], file.getFileSize()); + + // get a BIO + BIO *bio = BIO_new_mem_buf(&buffer[0], file.getFileSize()); + + if (bio) + { + // use it to read the PEM formatted certificate from memory into an X509 + // structure that SSL can use + STACK_OF(X509_INFO) *info = PEM_X509_INFO_read_bio(bio, NULL, NULL, NULL); + + if (info) + { + // iterate over all entries from the PEM file, add them to the x509_store one by one + for (sint i = 0; i < sk_X509_INFO_num(info); ++i) + { + X509_INFO *itmp = sk_X509_INFO_value(info, i); + + if (itmp && itmp->x509) + { + CertList.push_back(X509_dup(itmp->x509)); + } + } + + // cleanup + sk_X509_INFO_pop_free(info, X509_INFO_free); + } + else + { + nlwarning("Unable to read PEM info"); + } + + // decrease reference counts + BIO_free(bio); + } + else + { + nlwarning("Unable to allocate BIO buffer for certificates"); + } } }; /// this will be initialized on startup and cleared on exit static SX509Certificates x509CertListManager; + // *************************************************************************** + // static + void CCurlCertificates::init(CURL *curl) + { + x509CertListManager.init(curl); + } + + // *************************************************************************** + // static + void CCurlCertificates::addCertificateFile(const std::string &cert) + { + x509CertListManager.addCertificatesFromFile(cert); + } + // *************************************************************************** // static CURLcode CCurlCertificates::sslCtxFunction(CURL *curl, void *sslctx, void *parm) { - if (x509CertList.size() > 0) + CURLcode res = CURLE_OK; + + if (x509CertListManager.CertList.size() > 0) { SSL_CTX *ctx = (SSL_CTX*)sslctx; X509_STORE *x509store = SSL_CTX_get_cert_store(ctx); if (x509store) { - for (uint i = 0; i < x509CertList.size(); ++i) + char errorBuffer[1024]; + + for (uint i = 0, ilen = x509CertListManager.CertList.size(); i < ilen; ++i) { - X509_STORE_add_cert(x509store, x509CertList[i]); + X509_NAME *subject = X509_get_subject_name(x509CertListManager.CertList[i]); + + std::string name; + unsigned char *tmp = NULL; + + // construct a multiline string with name + for (int j = 0, jlen = X509_NAME_entry_count(subject); j < jlen; ++j) + { + X509_NAME_ENTRY *e = X509_NAME_get_entry(subject, j); + ASN1_STRING *d = X509_NAME_ENTRY_get_data(e); + + if (ASN1_STRING_to_UTF8(&tmp, d) > 0) + { + name += NLMISC::toString("%s\n", tmp); + + OPENSSL_free(tmp); + } + } + + // add our certificate to this store + if (X509_STORE_add_cert(x509store, x509CertListManager.CertList[i]) == 0) + { + uint errCode = ERR_get_error(); + + // ignore already in hash table errors + if (ERR_GET_LIB(errCode) != ERR_LIB_X509 || ERR_GET_REASON(errCode) != X509_R_CERT_ALREADY_IN_HASH_TABLE) + { + ERR_error_string_n(errCode, errorBuffer, 1024); + nlwarning("Error adding certificate %s: %s", name.c_str(), errorBuffer); + res = CURLE_SSL_CACERT; + } + } + else + { + nldebug("Added certificate %s", name.c_str()); + } } } else @@ -115,9 +274,13 @@ namespace NLGUI nlwarning("SSL_CTX_get_cert_store returned NULL"); } } - return CURLE_OK; + else + { + res = CURLE_SSL_CACERT; + } + + return res; } -#endif // NL_OS_WINDOWS }// namespace diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index e0ed401ce..fe08b6931 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -398,14 +398,21 @@ namespace NLGUI // https:// if (toLower(download.url.substr(0, 8)) == "https://") { -#if defined(NL_OS_WINDOWS) - curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &CCurlCertificates::sslCtxFunction); -#else - if (!options.curlCABundle.empty()) + // check if compiled with OpenSSL backend + CCurlCertificates::init(curl); + + // specify custom CA certs + CCurlCertificates::addCertificateFile(options.curlCABundle); + + // would allow to provide the CA in memory instead of using CURLOPT_CAINFO, but needs to include and link OpenSSL + if (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &CCurlCertificates::sslCtxFunction) != CURLE_OK) { - curl_easy_setopt(curl, CURLOPT_CAINFO, options.curlCABundle.c_str()); + nlwarning("Unable to support CURLOPT_SSL_CTX_FUNCTION, curl not compiled with OpenSSL ?"); } -#endif + + // set both CURLOPT_CAINFO and CURLOPT_CAPATH to NULL to be sure we won't use default values (these files can be missing and generate errors) + curl_easy_setopt(curl, CURLOPT_CAINFO, NULL); + curl_easy_setopt(curl, CURLOPT_CAPATH, NULL); } download.data = new CCurlWWWData(curl, download.url); diff --git a/code/ryzom/client/src/http_client_curl.cpp b/code/ryzom/client/src/http_client_curl.cpp index 2fd5bad81..418fc61bd 100644 --- a/code/ryzom/client/src/http_client_curl.cpp +++ b/code/ryzom/client/src/http_client_curl.cpp @@ -19,8 +19,7 @@ #include -#include -#include +#include "nel/gui/curl_certificates.h" using namespace NLMISC; using namespace NLNET; @@ -64,119 +63,7 @@ bool CCurlHttpClient::authenticate(const std::string &user, const std::string &p return true; } -const char *CAFilename = "ssl_ca_cert.pem"; // this is the certificate "Thawte Server CA" - -// *************************************************************************** -static CURLcode sslctx_function(CURL * /* curl */, void *sslctx, void * /* parm */) -{ - // look for certificate in search paths - string path = CPath::lookup(CAFilename); - nlinfo("Cert path '%s'", path.c_str()); - - if (path.empty()) - { - nlwarning("Unable to find %s", CAFilename); - return CURLE_SSL_CACERT; - } - - CIFile file; - - // open certificate - if (!file.open(path)) - { - nlwarning("Unable to open %s", path.c_str()); - return CURLE_SSL_CACERT; - } - - CURLcode res = CURLE_OK; - - // load certificate content into memory - std::vector buffer(file.getFileSize()); - file.serialBuffer(&buffer[0], file.getFileSize()); - - // get a BIO - BIO *bio = BIO_new_mem_buf(&buffer[0], file.getFileSize()); - - char errorBuffer[1024]; - - if (bio) - { - // get a pointer to the X509 certificate store (which may be empty!) - X509_STORE *store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx); - - // use it to read the PEM formatted certificate from memory into an X509 - // structure that SSL can use - STACK_OF(X509_INFO) *info = PEM_X509_INFO_read_bio(bio, NULL, NULL, NULL); - - if (info) - { - // iterate over all entries from the PEM file, add them to the x509_store one by one - for (sint i = 0; i < sk_X509_INFO_num(info); ++i) - { - X509_INFO *itmp = sk_X509_INFO_value(info, i); - - if (itmp && itmp->x509) - { - X509_NAME *subject = X509_get_subject_name(itmp->x509); - - std::string name; - unsigned char *tmp = NULL; - - // construct a multiline string with name - for (int i = 0, ilen = X509_NAME_entry_count(subject); i < ilen; ++i) - { - X509_NAME_ENTRY *e = X509_NAME_get_entry(subject, i); - ASN1_STRING *d = X509_NAME_ENTRY_get_data(e); - - if (ASN1_STRING_to_UTF8(&tmp, d) > 0) - { - name += NLMISC::toString("%s\n", tmp); - - OPENSSL_free(tmp); - } - } - - // add our certificate to this store - if (X509_STORE_add_cert(store, itmp->x509) == 0) - { - uint errCode = ERR_get_error(); - - // ignore already in hash table errors - if (ERR_GET_LIB(errCode) != ERR_LIB_X509 || ERR_GET_REASON(errCode) != X509_R_CERT_ALREADY_IN_HASH_TABLE) - { - ERR_error_string_n(errCode, errorBuffer, 1024); - nlwarning("Error adding certificate %s: %s", name.c_str(), errorBuffer); - res = CURLE_SSL_CACERT; - } - } - else - { - nlinfo("Added certificate %s", name.c_str()); - } - } - } - - // cleanup - sk_X509_INFO_pop_free(info, X509_INFO_free); - } - else - { - nlwarning("Unable to read PEM info"); - res = CURLE_SSL_CACERT; - } - - // decrease reference counts - BIO_free(bio); - } - else - { - nlwarning("Unable to allocate BIO buffer for certificates"); - res = CURLE_SSL_CACERT; - } - - // all set to go - return res; -} +static const std::string CAFilename = "ssl_ca_cert.pem"; // this is the certificate "Thawte Server CA" // *************************************************************************** bool CCurlHttpClient::verifyServer(bool verify) @@ -184,8 +71,15 @@ bool CCurlHttpClient::verifyServer(bool verify) curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYHOST, verify ? 2 : 0); curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYPEER, verify ? 1 : 0); curl_easy_setopt(_Curl, CURLOPT_SSLCERTTYPE, "PEM"); + + // check if compiled with OpenSSL backend + NLGUI::CCurlCertificates::init(_Curl); + + // specify custom CA certs + NLGUI::CCurlCertificates::addCertificateFile(CAFilename); + // would allow to provide the CA in memory instead of using CURLOPT_CAINFO, but needs to include and link OpenSSL - if (curl_easy_setopt(_Curl, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function) != CURLE_OK) + if (curl_easy_setopt(_Curl, CURLOPT_SSL_CTX_FUNCTION, &NLGUI::CCurlCertificates::sslCtxFunction) != CURLE_OK) { nlwarning("Unable to support CURLOPT_SSL_CTX_FUNCTION, curl not compiled with OpenSSL ?"); } From 1dc5ad039e34797500388572ad37c826b8116d45 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 5 Aug 2018 14:59:06 +0200 Subject: [PATCH 19/65] Fixed: Link NELGUI to Crypt32.lib and Cryptui.lib under Windows --HG-- branch : develop --- code/nel/src/gui/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/nel/src/gui/CMakeLists.txt b/code/nel/src/gui/CMakeLists.txt index cdd090f0b..a5f157c01 100644 --- a/code/nel/src/gui/CMakeLists.txt +++ b/code/nel/src/gui/CMakeLists.txt @@ -9,6 +9,11 @@ NL_TARGET_LIB(nelgui ${SRC} ${HEADERS}) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) + +IF(WIN32) + TARGET_LINK_LIBRARIES(nelgui Crypt32 Cryptui) +ENDIF() + NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI") NL_ADD_RUNTIME_FLAGS(nelgui) From ce31c4c17fd3c8ff7a16399be890c8294419b45e Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 5 Aug 2018 14:59:28 +0200 Subject: [PATCH 20/65] Changed: Minor changes --HG-- branch : develop --- code/nel/src/gui/curl_certificates.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index a279d35f6..e44161882 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -86,7 +86,7 @@ namespace NLGUI } else { - // if CURL is using SSPI under Windows or SecureChannel under OS X, we'll use native system CA Certs + // if CURL is using SSPI or SChannel under Windows or DarwinSSL under OS X, we'll use native system CA Certs isUsingOpenSSLBackend = false; } @@ -122,14 +122,14 @@ namespace NLGUI void addCertificatesFromFile(const std::string &cert) { + if (!isUsingOpenSSLBackend) return; + if (!isInitialized) { nlwarning("You MUST call NLGUI::CCurlCertificates::init before adding new certificates"); return; } - if (!isUsingOpenSSLBackend) return; - // this file was already loaded if (std::find(FilesList.begin(), FilesList.end(), cert) != FilesList.end()) return; From 5385e04bbaaa718d8d0e926141a481b78c3142a5 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 7 Aug 2018 12:09:33 +0200 Subject: [PATCH 21/65] Fixed: Link Qt to OpenSSL --HG-- branch : develop --- code/CMakeModules/FindHelpers.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/CMakeModules/FindHelpers.cmake b/code/CMakeModules/FindHelpers.cmake index d9aa3e75c..a4af37229 100644 --- a/code/CMakeModules/FindHelpers.cmake +++ b/code/CMakeModules/FindHelpers.cmake @@ -896,7 +896,7 @@ MACRO(FIND_QT5) # Network SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Network Qt5::Xml) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${ZLIB_LIBRARIES}) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) IF(WIN32) SET(QT_LIBRARIES ${QT_LIBRARIES} From a0c3a3adc50b55a02f0f9efa45d9a12b939ad967 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 7 Aug 2018 13:29:36 +0200 Subject: [PATCH 22/65] Fixed: Link nelgui to Security framework (fix compilation with curl using DarwinSSL backend) --HG-- branch : develop --- code/CMakeLists.txt | 15 ++++++++++----- code/nel/src/gui/CMakeLists.txt | 4 ---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 022c34659..e10bb54db 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -167,6 +167,7 @@ ENDIF() IF(APPLE) FIND_LIBRARY(CARBON_FRAMEWORK Carbon) FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation) + FIND_LIBRARY(SECURITY_FRAMEWORK Security) IF(APPLE_CERTIFICATE) # Find codesign_allocate @@ -226,22 +227,26 @@ IF(WITH_NEL) IF(CURL_STATIC) SET(CURL_DEFINITIONS -DCURL_STATICLIB) - SET(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) - SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) + LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) + LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) - IF(UNIX) + IF(WIN32) + LIST(APPEND CURL_LIBRARIES Crypt32 Cryptui) + ELSE() # CURL depends on libidn FIND_LIBRARY(IDN_LIBRARY idn) IF(IDN_LIBRARY) - SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${IDN_LIBRARY}) + LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY}) ENDIF() # CURL Macports version depends on libidn, libintl and libiconv too IF(APPLE) FIND_LIBRARY(INTL_LIBRARY intl) IF(INTL_LIBRARY) - SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${INTL_LIBRARY}) + LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY}) ENDIF() + + LIST(APPEND CURL_LIBRARIES ${SECURITY_FRAMEWORK}) ENDIF() ENDIF() ENDIF() diff --git a/code/nel/src/gui/CMakeLists.txt b/code/nel/src/gui/CMakeLists.txt index a5f157c01..cb7bbe23a 100644 --- a/code/nel/src/gui/CMakeLists.txt +++ b/code/nel/src/gui/CMakeLists.txt @@ -10,10 +10,6 @@ INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_ TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) -IF(WIN32) - TARGET_LINK_LIBRARIES(nelgui Crypt32 Cryptui) -ENDIF() - NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI") NL_ADD_RUNTIME_FLAGS(nelgui) From dd517424c79c91a977689096500d27d25ef5619d Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 7 Aug 2018 13:38:00 +0200 Subject: [PATCH 23/65] Fixed: CURL also depends on libidn2 and libpsl under OS X --HG-- branch : develop --- code/CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index e10bb54db..9ba0ebe65 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -239,13 +239,23 @@ IF(WITH_NEL) LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY}) ENDIF() - # CURL Macports version depends on libidn, libintl and libiconv too + # CURL Macports version can depend on libidn, libidn2, libintl, libpsl and libiconv too IF(APPLE) FIND_LIBRARY(INTL_LIBRARY intl) IF(INTL_LIBRARY) LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY}) ENDIF() + FIND_LIBRARY(IDN2_LIBRARY idn2) + IF(IDN2_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${IDN2_LIBRARY}) + ENDIF() + + FIND_LIBRARY(PSL_LIBRARY psl) + IF(PSL_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${PSL_LIBRARY}) + ENDIF() + LIST(APPEND CURL_LIBRARIES ${SECURITY_FRAMEWORK}) ENDIF() ENDIF() From df032e220e52b958b928c9c520320e627e51ceb7 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 7 Aug 2018 16:02:34 +0200 Subject: [PATCH 24/65] Fixed: CURL also depends on libunistring under OS X --HG-- branch : develop --- code/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 9ba0ebe65..681f7a959 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -256,6 +256,11 @@ IF(WITH_NEL) LIST(APPEND CURL_LIBRARIES ${PSL_LIBRARY}) ENDIF() + FIND_LIBRARY(UNISTRING_LIBRARY unistring) + IF(UNISTRING_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${UNISTRING_LIBRARY}) + ENDIF() + LIST(APPEND CURL_LIBRARIES ${SECURITY_FRAMEWORK}) ENDIF() ENDIF() From d9e6d34fcc9112244b8602140ab8639443626ae7 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 7 Aug 2018 18:40:48 +0200 Subject: [PATCH 25/65] Changed: Make sslCtxFunction private and don't include curl.h in header --HG-- branch : develop --- code/nel/include/nel/gui/curl_certificates.h | 7 +-- code/nel/src/gui/curl_certificates.cpp | 55 ++++++++++++++------ code/nel/src/gui/group_html.cpp | 27 ++++------ code/ryzom/client/src/http_client_curl.cpp | 11 +--- 4 files changed, 54 insertions(+), 46 deletions(-) diff --git a/code/nel/include/nel/gui/curl_certificates.h b/code/nel/include/nel/gui/curl_certificates.h index dd4e923a0..ee6938842 100644 --- a/code/nel/include/nel/gui/curl_certificates.h +++ b/code/nel/include/nel/gui/curl_certificates.h @@ -19,7 +19,8 @@ #include "nel/misc/types_nl.h" -#include +// forward declaration to avoid curl.h inclusion everywhere +typedef void CURL; namespace NLGUI { @@ -32,8 +33,8 @@ namespace NLGUI // allow to use custom PEM certificates static void addCertificateFile(const std::string &cert); - // cURL SSL certificate loading - static CURLcode sslCtxFunction(CURL *curl, void *sslctx, void *parm); + // set all CURL options to use custom SSL context function + static void useCertificates(CURL *curl); }; } // namespace diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index e44161882..552ed2a9f 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -23,6 +23,8 @@ #include #include +#include + using namespace std; using namespace NLMISC; @@ -201,23 +203,8 @@ namespace NLGUI /// this will be initialized on startup and cleared on exit static SX509Certificates x509CertListManager; - // *************************************************************************** - // static - void CCurlCertificates::init(CURL *curl) - { - x509CertListManager.init(curl); - } - - // *************************************************************************** - // static - void CCurlCertificates::addCertificateFile(const std::string &cert) - { - x509CertListManager.addCertificatesFromFile(cert); - } - - // *************************************************************************** - // static - CURLcode CCurlCertificates::sslCtxFunction(CURL *curl, void *sslctx, void *parm) + // cURL SSL certificate loading + static CURLcode sslCtxFunction(CURL *curl, void *sslctx, void *parm) { CURLcode res = CURLE_OK; @@ -282,5 +269,39 @@ namespace NLGUI return res; } + // *************************************************************************** + // static + void CCurlCertificates::init(CURL *curl) + { + x509CertListManager.init(curl); + } + + // *************************************************************************** + // static + void CCurlCertificates::addCertificateFile(const std::string &cert) + { + x509CertListManager.addCertificatesFromFile(cert); + } + + // *************************************************************************** + // static + void CCurlCertificates::useCertificates(CURL *curl) + { + // CURL must be valid, using OpenSSL backend and certificates must be loaded, else return + if (!curl || !isUsingOpenSSLBackend || x509CertListManager.CertList.empty()) return; + + curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); + + // would allow to provide the CA in memory instead of using CURLOPT_CAINFO, but needs to include and link OpenSSL + if (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &sslCtxFunction) != CURLE_OK) + { + nlwarning("Unable to support CURLOPT_SSL_CTX_FUNCTION, curl not compiled with OpenSSL ?"); + } + + // set both CURLOPT_CAINFO and CURLOPT_CAPATH to NULL to be sure we won't use default values (these files can be missing and generate errors) + curl_easy_setopt(curl, CURLOPT_CAINFO, NULL); + curl_easy_setopt(curl, CURLOPT_CAPATH, NULL); + } + }// namespace diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index fe08b6931..6f0e612c9 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -404,15 +404,8 @@ namespace NLGUI // specify custom CA certs CCurlCertificates::addCertificateFile(options.curlCABundle); - // would allow to provide the CA in memory instead of using CURLOPT_CAINFO, but needs to include and link OpenSSL - if (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &CCurlCertificates::sslCtxFunction) != CURLE_OK) - { - nlwarning("Unable to support CURLOPT_SSL_CTX_FUNCTION, curl not compiled with OpenSSL ?"); - } - - // set both CURLOPT_CAINFO and CURLOPT_CAPATH to NULL to be sure we won't use default values (these files can be missing and generate errors) - curl_easy_setopt(curl, CURLOPT_CAINFO, NULL); - curl_easy_setopt(curl, CURLOPT_CAPATH, NULL); + // if supported, use custom SSL context function to load certificates + CCurlCertificates::useCertificates(curl); } download.data = new CCurlWWWData(curl, download.url); @@ -5350,14 +5343,14 @@ namespace NLGUI // https:// if (toLower(url.substr(0, 8)) == "https://") { -#if defined(NL_OS_WINDOWS) - curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &CCurlCertificates::sslCtxFunction); -#else - if (!options.curlCABundle.empty()) - { - curl_easy_setopt(curl, CURLOPT_CAINFO, options.curlCABundle.c_str()); - } -#endif + // check if compiled with OpenSSL backend + CCurlCertificates::init(curl); + + // specify custom CA certs + CCurlCertificates::addCertificateFile(options.curlCABundle); + + // if supported, use custom SSL context function to load certificates + CCurlCertificates::useCertificates(curl); } // do not follow redirects, we have own handler diff --git a/code/ryzom/client/src/http_client_curl.cpp b/code/ryzom/client/src/http_client_curl.cpp index 418fc61bd..2887543c3 100644 --- a/code/ryzom/client/src/http_client_curl.cpp +++ b/code/ryzom/client/src/http_client_curl.cpp @@ -70,7 +70,6 @@ bool CCurlHttpClient::verifyServer(bool verify) { curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYHOST, verify ? 2 : 0); curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYPEER, verify ? 1 : 0); - curl_easy_setopt(_Curl, CURLOPT_SSLCERTTYPE, "PEM"); // check if compiled with OpenSSL backend NLGUI::CCurlCertificates::init(_Curl); @@ -78,15 +77,9 @@ bool CCurlHttpClient::verifyServer(bool verify) // specify custom CA certs NLGUI::CCurlCertificates::addCertificateFile(CAFilename); - // would allow to provide the CA in memory instead of using CURLOPT_CAINFO, but needs to include and link OpenSSL - if (curl_easy_setopt(_Curl, CURLOPT_SSL_CTX_FUNCTION, &NLGUI::CCurlCertificates::sslCtxFunction) != CURLE_OK) - { - nlwarning("Unable to support CURLOPT_SSL_CTX_FUNCTION, curl not compiled with OpenSSL ?"); - } + // if supported, use custom SSL context function to load certificates + NLGUI::CCurlCertificates::useCertificates(_Curl); - // set both CURLOPT_CAINFO and CURLOPT_CAPATH to NULL to be sure we won't use default values (these files can be missing and generate errors) - curl_easy_setopt(_Curl, CURLOPT_CAINFO, NULL); - curl_easy_setopt(_Curl, CURLOPT_CAPATH, NULL); return true; } From 6966bc1a12a57f2586221642007706c12412ecc3 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 7 Aug 2018 18:41:04 +0200 Subject: [PATCH 26/65] Fixed: Compilation with older CURL --HG-- branch : develop --- code/nel/src/gui/curl_certificates.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index 552ed2a9f..14a1c3f0a 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -69,7 +69,16 @@ namespace NLGUI // get more information on CURL session curl_tlssessioninfo *sessionInfo; - CURLcode res = curl_easy_getinfo(curl, CURLINFO_TLS_SSL_PTR, &sessionInfo); + + CURLINFO info; + +#if CURL_AT_LEAST_VERSION(7, 48, 0) + info = CURLINFO_TLS_SSL_PTR; +#else + info = CURLINFO_TLS_SESSION; +#endif + + CURLcode res = curl_easy_getinfo(curl, info, &sessionInfo); // only use OpenSSL callback if not using Windows SSPI and using OpenSSL backend if (!res && sessionInfo && sessionInfo->backend == CURLSSLBACKEND_OPENSSL && !(data && data->features & CURL_VERSION_SSPI)) From b4f69007f60fbae3f2bf3f5d0b1a2c36cd854cb4 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 7 Aug 2018 20:29:39 +0200 Subject: [PATCH 27/65] Fixed: Compilation --HG-- branch : develop --- code/nel/src/gui/curl_certificates.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index 14a1c3f0a..f06d92608 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -297,7 +297,7 @@ namespace NLGUI void CCurlCertificates::useCertificates(CURL *curl) { // CURL must be valid, using OpenSSL backend and certificates must be loaded, else return - if (!curl || !isUsingOpenSSLBackend || x509CertListManager.CertList.empty()) return; + if (!curl || !x509CertListManager.isUsingOpenSSLBackend || x509CertListManager.CertList.empty()) return; curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); From 53bae35fc41eda6ba5eea533c5405960738fd76d Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 8 Aug 2018 09:39:40 +0200 Subject: [PATCH 28/65] Fixed: Use GlobalMemoryStatusEx instead of GlobalMemoryStatus (returns 64 bits numbers) --HG-- branch : develop --- code/nel/src/misc/system_info.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/nel/src/misc/system_info.cpp b/code/nel/src/misc/system_info.cpp index 2afa8da09..75d9707b3 100644 --- a/code/nel/src/misc/system_info.cpp +++ b/code/nel/src/misc/system_info.cpp @@ -1470,9 +1470,9 @@ uint64 CSystemInfo::availableHDSpace (const string &filename) uint64 CSystemInfo::availablePhysicalMemory () { #ifdef NL_OS_WINDOWS - MEMORYSTATUS ms; - GlobalMemoryStatus (&ms); - return uint64(ms.dwAvailPhys); + MEMORYSTATUSEX ms; + GlobalMemoryStatusEx(&ms); + return ms.ullAvailPhys; #elif defined NL_OS_MAC return uint64(getsysctlnum64("hw.usermem")); #elif defined NL_OS_UNIX @@ -1485,9 +1485,9 @@ uint64 CSystemInfo::availablePhysicalMemory () uint64 CSystemInfo::totalPhysicalMemory () { #ifdef NL_OS_WINDOWS - MEMORYSTATUS ms; - GlobalMemoryStatus (&ms); - return uint64(ms.dwTotalPhys); + MEMORYSTATUSEX ms; + GlobalMemoryStatusEx(&ms); + return ms.ullTotalPhys; #elif defined NL_OS_MAC return uint64(getsysctlnum64("hw.physmem")); #elif defined NL_OS_UNIX @@ -1867,9 +1867,9 @@ bool CSystemInfo::getVideoInfo (std::string &deviceName, uint64 &driverVersion) uint64 CSystemInfo::virtualMemory () { #ifdef NL_OS_WINDOWS - MEMORYSTATUS ms; - GlobalMemoryStatus (&ms); - return uint64(ms.dwTotalVirtual - ms.dwAvailVirtual); + MEMORYSTATUSEX ms; + GlobalMemoryStatusEx(&ms); + return ms.ullTotalVirtual - ms.ullAvailVirtual; #else return 0; #endif From 675f85c2888825bceb76c6f271f830ff8beea9bf Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 8 Aug 2018 20:37:51 +0200 Subject: [PATCH 29/65] Fixed: Warnings, throw(type) deprecated in C++11 and removed in C++17 --HG-- branch : develop --- code/nel/include/nel/3d/driver.h | 2 +- code/nel/include/nel/3d/dru.h | 6 ++-- code/nel/include/nel/3d/landscape.h | 4 +-- code/nel/include/nel/3d/nelu.h | 4 +-- code/nel/include/nel/gui/lua_ihm.h | 2 +- code/nel/include/nel/gui/lua_object.h | 36 +++++++++---------- code/nel/include/nel/misc/class_registry.h | 4 +-- code/nel/include/nel/misc/file.h | 16 ++++----- code/nel/include/nel/misc/mem_stream.h | 2 +- code/nel/include/nel/misc/string_mapper.h | 4 +-- code/nel/include/nel/net/message.h | 2 +- code/nel/include/nel/net/module.h | 4 +-- code/nel/include/nel/net/module_gateway.h | 4 +-- .../src/3d/driver/direct3d/driver_direct3d.h | 2 +- code/nel/src/3d/driver/opengl/driver_opengl.h | 2 +- code/nel/src/gui/lua_object.cpp | 24 ++++++------- code/nel/src/misc/file.cpp | 2 +- code/nel/src/misc/mem_stream.cpp | 2 +- code/ryzom/client/src/camera_recorder.cpp | 2 +- .../client/src/gateway_fec_transport.cpp | 6 ++-- code/ryzom/client/src/login_patch.cpp | 2 +- code/ryzom/client/src/r2/editor.cpp | 2 +- code/ryzom/client/src/r2/editor.h | 2 +- .../server/src/ai_service/ai_script_comp.h | 2 +- .../server/src/ai_service/script_compiler.h | 2 +- .../entity_manager/entity_base.h | 12 +++---- .../shop_type/item_for_sale.h | 4 +-- .../shop_type/items_for_sale.h | 2 +- 28 files changed, 79 insertions(+), 79 deletions(-) diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 52bda8576..85140b3da 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -224,7 +224,7 @@ public: // @{ // first param is the associated window. // Must be a HWND for Windows (WIN32). - virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show = true, bool resizeable = true) throw(EBadDisplay) = 0; + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show = true, bool resizeable = true) = 0; // Must be called after a setDisplay that initialize the mode virtual bool setMode(const GfxMode &mode) = 0; virtual bool getModes(std::vector &modes) = 0; diff --git a/code/nel/include/nel/3d/dru.h b/code/nel/include/nel/3d/dru.h index fda543ecd..c23d41382 100644 --- a/code/nel/include/nel/3d/dru.h +++ b/code/nel/include/nel/3d/dru.h @@ -134,14 +134,14 @@ class CDRU public: /// Portable Function which create a GL Driver (using gl dll...). - static IDriver *createGlDriver() throw(EDru); + static IDriver *createGlDriver(); /// Portable Function which create a GL ES Driver (using gl dll...). - static IDriver *createGlEsDriver() throw(EDru); + static IDriver *createGlEsDriver(); #ifdef NL_OS_WINDOWS /// Windows Function which create a Direct3d Driver. - static IDriver *createD3DDriver() throw(EDru); + static IDriver *createD3DDriver(); #endif // NL_OS_WINDOWS /// \name 2D render. diff --git a/code/nel/include/nel/3d/landscape.h b/code/nel/include/nel/3d/landscape.h index aa432f88b..a7383963d 100644 --- a/code/nel/include/nel/3d/landscape.h +++ b/code/nel/include/nel/3d/landscape.h @@ -168,9 +168,9 @@ public: void clear(); /// Verify the binding of patchs of all zones. throw EBadBind if error. - void checkBinds() throw(EBadBind); + void checkBinds(); /// Verify the binding of patchs of one zone. throw EBadBind if error. nop if zone not loaded. - void checkBinds(uint16 zoneId) throw(EBadBind); + void checkBinds(uint16 zoneId); /** * Build tileBank. Call this after loading the near and far tile banks. diff --git a/code/nel/include/nel/3d/nelu.h b/code/nel/include/nel/3d/nelu.h index fb30a5012..b64e83672 100644 --- a/code/nel/include/nel/3d/nelu.h +++ b/code/nel/include/nel/3d/nelu.h @@ -64,7 +64,7 @@ public: * * You can access the driver with CNELU::Driver. */ - static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false) throw(EDru); + static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false); /** Init all that we need for a Scene. * - register scene basics models, @@ -108,7 +108,7 @@ public: * - initScene(); * - initEventServer(); */ - static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false) throw(EDru); + static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false); /** Delete all: * - releaseEventServer(); diff --git a/code/nel/include/nel/gui/lua_ihm.h b/code/nel/include/nel/gui/lua_ihm.h index 974ece6f7..e45e1125f 100644 --- a/code/nel/include/nel/gui/lua_ihm.h +++ b/code/nel/include/nel/gui/lua_ihm.h @@ -118,7 +118,7 @@ namespace NLGUI /** read/write between values on a lua stack & a property exported from a 'CReflectable' derived object * (throws on error) */ - static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException); + static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property); // push a reflected property on the stack // NB : no check is done that 'property' is part of the class info of 'reflectedObject' diff --git a/code/nel/include/nel/gui/lua_object.h b/code/nel/include/nel/gui/lua_object.h index 1d3b0d64c..88c011347 100644 --- a/code/nel/include/nel/gui/lua_object.h +++ b/code/nel/include/nel/gui/lua_object.h @@ -110,7 +110,7 @@ namespace NLGUI /** create a sub table for this object, with a string as a key * This object must be a table or an exception if thrown */ - CLuaObject newTable(const char *tableName) throw(ELuaNotATable); + CLuaObject newTable(const char *tableName); /** Set a value in a table. @@ -118,29 +118,29 @@ namespace NLGUI * NB : value should came from the same lua environment * \TODO other type of keys */ - void setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable); - void setValue(const std::string &key, const CLuaObject &value) throw(ELuaNotATable) { setValue(key.c_str(), value); } - void setValue(const char *key, const std::string &value) throw(ELuaNotATable); - void setValue(const char *key, const char *value) throw(ELuaNotATable); - void setValue(const char *key, bool value) throw(ELuaNotATable); - void setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable); - void setValue(const char *key, double value) throw(ELuaNotATable); - void setValue(const char *key, uint32 value) throw(ELuaNotATable); - void setValue(const char *key, sint32 value) throw(ELuaNotATable); - void setValue(const char *key, sint64 value) throw(ELuaNotATable); - void setValue(const std::string &key, const std::string &value) throw(ELuaNotATable) { setValue(key.c_str(), value); } - void setNil(const char *key) throw(ELuaNotATable); - void setNil(const std::string &key) throw(ELuaNotATable) { setNil(key.c_str()); } + void setValue(const char *key, const CLuaObject &value); + void setValue(const std::string &key, const CLuaObject &value) { setValue(key.c_str(), value); } + void setValue(const char *key, const std::string &value); + void setValue(const char *key, const char *value); + void setValue(const char *key, bool value); + void setValue(const char *key, TLuaWrappedFunction value); + void setValue(const char *key, double value); + void setValue(const char *key, uint32 value); + void setValue(const char *key, sint32 value); + void setValue(const char *key, sint64 value); + void setValue(const std::string &key, const std::string &value) { setValue(key.c_str(), value); } + void setNil(const char *key); + void setNil(const std::string &key) { setNil(key.c_str()); } /** Erase a value in a table by its key. * If this object is not a table then an exception is thrown. * \TODO other type of keys */ - void eraseValue(const char *key) throw(ELuaNotATable); - void eraseValue(const std::string &key) throw(ELuaNotATable) { eraseValue(key.c_str()); } + void eraseValue(const char *key); + void eraseValue(const std::string &key) { eraseValue(key.c_str()); } // test is this object is enumerable bool isEnumerable() const; // Enumeration of a table. If the object is not a table, an exception is thrown. - CLuaEnumeration enumerate() throw(ELuaNotATable); + CLuaEnumeration enumerate(); // retrieve metatable of an object (or nil if object has no metatable) CLuaObject getMetaTable() const; // set metatable for this object @@ -155,7 +155,7 @@ namespace NLGUI CLuaObject operator[](const std::string &key) const { return operator[](key.c_str()); } /** Checked access to a sub element of a table. An exception is thrown is the element is not a table. */ - CLuaObject at(const char *key) const throw (ELuaNotATable); + CLuaObject at(const char *key) const; CLuaObject at(const std::string &key) const { return at(key.c_str()); } // Test is that table has the given key. The object must be a table or an exception is thrown diff --git a/code/nel/include/nel/misc/class_registry.h b/code/nel/include/nel/misc/class_registry.h index 5c1fe8cd6..98139f5dc 100644 --- a/code/nel/include/nel/misc/class_registry.h +++ b/code/nel/include/nel/misc/class_registry.h @@ -86,10 +86,10 @@ public: static void release(); /// Register your class for future Instanciation. - static void registerClass(const std::string &className, IClassable* (*creator)(), const std::string &typeidCheck) throw(ERegistry); + static void registerClass(const std::string &className, IClassable* (*creator)(), const std::string &typeidCheck); /// Create an object from his class name. - static IClassable *create(const std::string &className) throw(ERegistry); + static IClassable *create(const std::string &className); /// check if the object has been correctly registered. Must be used for debug only, and Must compile with RTTI. static bool checkObject(IClassable* obj); diff --git a/code/nel/include/nel/misc/file.h b/code/nel/include/nel/misc/file.h index 17154e6be..78dba95c6 100644 --- a/code/nel/include/nel/misc/file.h +++ b/code/nel/include/nel/misc/file.h @@ -108,9 +108,9 @@ public: // Advanced Usage. /// flush the file. void flush(); /// Seek the file - bool seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStream); + bool seek (sint32 offset, IStream::TSeekOrigin origin) const; /// Get the location of the file pointer - sint32 getPos () const throw(EStream); + sint32 getPos () const; // Imp the Name of the stream as the name of the file. virtual std::string getStreamName() const; @@ -125,7 +125,7 @@ public: // Advanced Usage. // return true if there's nothing more to read (same as ifstream) bool eof (); - virtual void serialBuffer(uint8 *buf, uint len)throw(EReadError); + virtual void serialBuffer(uint8 *buf, uint len); /// \name Statistics @@ -148,7 +148,7 @@ public: // Advanced Usage. static void clearDump (); protected: - virtual void serialBit(bool &bit) throw(EReadError); + virtual void serialBit(bool &bit); virtual uint getDbgStreamSize() const; @@ -223,20 +223,20 @@ public: // Advanced Usage. /// flush the file. void flush(); /// Seek the file - bool seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStream); + bool seek (sint32 offset, IStream::TSeekOrigin origin) const; /// Get the location of the file pointer - sint32 getPos () const throw(EStream); + sint32 getPos () const; // Imp the Name of the stream as the name of the file. virtual std::string getStreamName() const; // very useful to serialize string in text mode (without the size) - virtual void serialBuffer(uint8 *buf, uint len) throw(EWriteError); + virtual void serialBuffer(uint8 *buf, uint len); protected: /// Internal close. void internalClose(bool success); - virtual void serialBit(bool &bit) throw(EWriteError); + virtual void serialBit(bool &bit); private: FILE *_F; diff --git a/code/nel/include/nel/misc/mem_stream.h b/code/nel/include/nel/misc/mem_stream.h index f614cc040..a9e8aacfc 100644 --- a/code/nel/include/nel/misc/mem_stream.h +++ b/code/nel/include/nel/misc/mem_stream.h @@ -197,7 +197,7 @@ public: * \return true if seek sucessfull. * \see ESeekNotSupported SeekOrigin getPos */ - virtual bool seek (sint32 offset, TSeekOrigin origin) const throw(EStream); + virtual bool seek (sint32 offset, TSeekOrigin origin) const; /** * Get the location of the stream pointer. diff --git a/code/nel/include/nel/misc/string_mapper.h b/code/nel/include/nel/misc/string_mapper.h index a20489f1c..aeaccf959 100644 --- a/code/nel/include/nel/misc/string_mapper.h +++ b/code/nel/include/nel/misc/string_mapper.h @@ -177,10 +177,10 @@ public: uint32 getCount() { return _IdCounter; } // helper serialize a string id as a string - void serial(NLMISC::IStream &f, TSStringId &strId) throw(EStream); + void serial(NLMISC::IStream &f, TSStringId &strId); // helper serialize a string id vector - void serial(NLMISC::IStream &f, std::vector &strIdVect) throw(EStream); + void serial(NLMISC::IStream &f, std::vector &strIdVect); }; diff --git a/code/nel/include/nel/net/message.h b/code/nel/include/nel/net/message.h index e96cb50d3..f1c571d44 100644 --- a/code/nel/include/nel/net/message.h +++ b/code/nel/include/nel/net/message.h @@ -146,7 +146,7 @@ public: return _LengthR; } - virtual sint32 getPos () const throw(NLMISC::EStream) + virtual sint32 getPos() const { // return (_BufPos - _Buffer.getPtr()) - _SubMessagePosR; return _Buffer.Pos - _SubMessagePosR; diff --git a/code/nel/include/nel/net/module.h b/code/nel/include/nel/net/module.h index 4493dd966..0b5b158d2 100644 --- a/code/nel/include/nel/net/module.h +++ b/code/nel/include/nel/net/module.h @@ -779,10 +779,10 @@ namespace NLNET // Init base module, init module name bool initModule(const TParsedCommandLine &initInfo); - void plugModule(IModuleSocket *moduleSocket) throw (EModuleAlreadyPluggedHere); + void plugModule(IModuleSocket *moduleSocket); void unplugModule(IModuleSocket *moduleSocket) throw (EModuleNotPluggedHere); void getPluggedSocketList(std::vector &resultList); - void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) throw (EInvokeFailed); + void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg); void _onModuleUp(IModuleProxy *removedProxy); void _onModuleDown(IModuleProxy *removedProxy); diff --git a/code/nel/include/nel/net/module_gateway.h b/code/nel/include/nel/net/module_gateway.h index a097f8de0..75d386162 100644 --- a/code/nel/include/nel/net/module_gateway.h +++ b/code/nel/include/nel/net/module_gateway.h @@ -346,9 +346,9 @@ namespace NLNET virtual const std::string &getClassName() const =0; /// The gateway send a command message to the transport - virtual void onCommand(const CMessage &command) throw (EInvalidCommand) = 0; + virtual void onCommand(const CMessage &command) = 0; /// The gateway send a textual command to the transport - virtual bool onCommand(const TParsedCommandLine &command) throw (EInvalidCommand) = 0; + virtual bool onCommand(const TParsedCommandLine &command) = 0; /// The gateway update the transport regularly virtual void update() =0; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index a4d9dbaeb..6621ab6cb 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -849,7 +849,7 @@ public: // Mode initialisation, requests virtual bool init (uintptr_t windowIcon = 0, emptyProc exitFunc = 0); - virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable virtual bool release(); virtual bool setMode(const GfxMode& mode); virtual bool getModes(std::vector &modes); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 68e6b0edf..a03077544 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -325,7 +325,7 @@ public: virtual void disableHardwareVertexArrayAGP(); virtual void disableHardwareTextureShader(); - virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable); virtual bool setMode(const GfxMode& mode); virtual bool getModes(std::vector &modes); virtual bool getCurrentScreenMode(GfxMode &mode); diff --git a/code/nel/src/gui/lua_object.cpp b/code/nel/src/gui/lua_object.cpp index c957c3f2c..5417ba0c5 100644 --- a/code/nel/src/gui/lua_object.cpp +++ b/code/nel/src/gui/lua_object.cpp @@ -271,7 +271,7 @@ namespace NLGUI } // ************************************************* - CLuaObject CLuaObject::at(const char *key) const throw(ELuaNotATable) + CLuaObject CLuaObject::at(const char *key) const { if (!isEnumerable()) throw ELuaNotATable(NLMISC::toString("Can't get key '%s' in object '%s' because type is '%s', it is not a table.", key, getId().c_str(), getTypename()).c_str()); return operator[](key); @@ -286,7 +286,7 @@ namespace NLGUI } // ************************************************* - CLuaObject CLuaObject::newTable(const char *tableName) throw(ELuaNotATable) + CLuaObject CLuaObject::newTable(const char *tableName) { nlassert(tableName); nlassert(isValid()); @@ -301,7 +301,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, const CLuaObject &value) { nlassert(key); nlassert(isValid()); @@ -331,7 +331,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, const char *value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, const char *value) { nlassert(value); nlassert(key); @@ -346,13 +346,13 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, const std::string &value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, const std::string &value) { setValue(key, value.c_str()); } // ************************************************* - void CLuaObject::setValue(const char *key, bool value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, bool value) { nlassert(key); nlassert(isValid()); @@ -366,7 +366,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, TLuaWrappedFunction value) { nlassert(key); nlassert(isValid()); @@ -380,7 +380,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, double value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, double value) { nlassert(key); nlassert(isValid()); @@ -394,7 +394,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, uint32 value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, uint32 value) { nlassert(key); nlassert(isValid()); @@ -408,7 +408,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, sint32 value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, sint32 value) { nlassert(key); nlassert(isValid()); @@ -422,7 +422,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, sint64 value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, sint64 value) { nlassert(key); nlassert(isValid()); @@ -436,7 +436,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::eraseValue(const char *key) throw(ELuaNotATable) + void CLuaObject::eraseValue(const char *key) { nlassert(isValid()); nlassert(key); diff --git a/code/nel/src/misc/file.cpp b/code/nel/src/misc/file.cpp index 727c02f83..722043fd8 100644 --- a/code/nel/src/misc/file.cpp +++ b/code/nel/src/misc/file.cpp @@ -453,7 +453,7 @@ void CIFile::serialBit(bool &bit) throw(EReadError) } // ====================================================================================================== -bool CIFile::seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStream) +bool CIFile::seek (sint32 offset, IStream::TSeekOrigin origin) const { if ((_CacheFileOnOpen) && (_Cache == NULL)) return false; diff --git a/code/nel/src/misc/mem_stream.cpp b/code/nel/src/misc/mem_stream.cpp index 49e19f523..dd81334d1 100644 --- a/code/nel/src/misc/mem_stream.cpp +++ b/code/nel/src/misc/mem_stream.cpp @@ -107,7 +107,7 @@ void CMemStream::serialBit(bool &bit) * (to prevent from an "inside serial" to increment it). * Then a seek(end) would get back to the pointer. */ -bool CMemStream::seek (sint32 offset, TSeekOrigin origin) const throw(EStream) +bool CMemStream::seek (sint32 offset, TSeekOrigin origin) const { switch (origin) { diff --git a/code/ryzom/client/src/camera_recorder.cpp b/code/ryzom/client/src/camera_recorder.cpp index 12cd4ff01..8f427c321 100644 --- a/code/ryzom/client/src/camera_recorder.cpp +++ b/code/ryzom/client/src/camera_recorder.cpp @@ -56,7 +56,7 @@ public: CVector Heading; //CVMatrix Matrix; public: - void serial(NLMISC::IStream &f) throw(EStream) + void serial(NLMISC::IStream &f) { f.serial(Date); f.serial(Pos); diff --git a/code/ryzom/client/src/gateway_fec_transport.cpp b/code/ryzom/client/src/gateway_fec_transport.cpp index 26104216e..fa15c465b 100644 --- a/code/ryzom/client/src/gateway_fec_transport.cpp +++ b/code/ryzom/client/src/gateway_fec_transport.cpp @@ -216,13 +216,13 @@ public: } } - void onCommand(const CMessage &/* command */) throw (IGatewayTransport::EInvalidCommand) + void onCommand(const CMessage &/* command */) { // nothing done for now throw EInvalidCommand(); } /// The gateway send a textual command to the transport - bool onCommand(const TParsedCommandLine &command) throw (IGatewayTransport::EInvalidCommand) + bool onCommand(const TParsedCommandLine &command) { if (command.SubParams.size() < 1) throw EInvalidCommand(); @@ -256,7 +256,7 @@ public: } /// Open the connection by intercepting client gateway message - void open() throw (ETransportError) + void open() { if (_Open) { diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index 5cf77aae7..6a3500ae0 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -101,7 +101,7 @@ struct EPatchDownloadException : public Exception { EPatchDownloadException() : Exception( "Download Error" ) {} EPatchDownloadException( const std::string& str ) : Exception( str ) {} - virtual ~EPatchDownloadException() throw() {} + virtual ~EPatchDownloadException() {} }; diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index dc81eeb38..68214151c 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -4370,7 +4370,7 @@ void CEditor::setCurrentTool(CTool *tool) } // ********************************************************************************************************* -CLuaObject CEditor::getClasses() throw(ELuaError) +CLuaObject CEditor::getClasses() { //H_AUTO(R2_getClasses_throw) CHECK_EDITOR diff --git a/code/ryzom/client/src/r2/editor.h b/code/ryzom/client/src/r2/editor.h index 48a9c6a50..cd19f6c71 100644 --- a/code/ryzom/client/src/r2/editor.h +++ b/code/ryzom/client/src/r2/editor.h @@ -421,7 +421,7 @@ public: // get table for registry in lua environment CLuaObject &getRegistry() { return _Registry; } // get lua classes (the r2.Classes table) - CLuaObject getClasses() throw(ELuaError); + CLuaObject getClasses(); // get R2 environment (the 'r2' table into lua global environment) CLuaObject &getEnv(); // get the config table (that is the 'r2.Config' table) diff --git a/code/ryzom/server/src/ai_service/ai_script_comp.h b/code/ryzom/server/src/ai_service/ai_script_comp.h index 834bbacd7..0b02cc722 100644 --- a/code/ryzom/server/src/ai_service/ai_script_comp.h +++ b/code/ryzom/server/src/ai_service/ai_script_comp.h @@ -54,7 +54,7 @@ public: virtual CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) = 0; virtual std::string getName () const =0; - static CFightScriptCompReader *getScriptReader (const std::string &str) throw (ReadFightActionException); + static CFightScriptCompReader *getScriptReader (const std::string &str); static CFightScriptComp *createScriptComp (const std::string &str) throw (ReadFightActionException); protected: diff --git a/code/ryzom/server/src/ai_service/script_compiler.h b/code/ryzom/server/src/ai_service/script_compiler.h index 80d83a860..a03de1f8d 100644 --- a/code/ryzom/server/src/ai_service/script_compiler.h +++ b/code/ryzom/server/src/ai_service/script_compiler.h @@ -298,7 +298,7 @@ public: static CToken* getToken (std::string const& tokenName); static NLMISC::CSmartPtr getRule (std::string const& ruleName); - static bool getNextToken (std::string const& text, size_t& index, std::string& tokenName, std::string& textValue) throw (EScriptError); + static bool getNextToken (std::string const& text, size_t& index, std::string& tokenName, std::string& textValue); static std::string const& getOpcodeName (AIVM::CScriptVM::EOpcode const& op); static AIVM::CScriptVM::EOpcode getOpcodeAndValue (std::string const& str, std::string& value); static CScriptNativeFuncParams* getNativeFunc (std::string const& funcName, std::string const& inparams, std::string const& outparams); diff --git a/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.h b/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.h index 05342be92..89d3271ae 100644 --- a/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.h +++ b/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.h @@ -521,36 +521,36 @@ public: * \param var is the name of the variable * \return ref on the stat value */ - sint32& lookupStat( const std::string& stat ) throw (EInvalidStat); + sint32& lookupStat( const std::string& stat); /** * get a reference on a characterristics value * \param c is enum of characteristic, st is enum of subtype of characterisitics (like max, current..) * \return ref on the stat value */ - sint32& lookupStat( CHARACTERISTICS::TCharacteristics c, SCharacteristicsAndScores::TCharacteristicsAndScoreSubType st ) throw (CEntityBase::EInvalidStat); + sint32& lookupStat( CHARACTERISTICS::TCharacteristics c, SCharacteristicsAndScores::TCharacteristicsAndScoreSubType st); /** * get a reference on a scores value * \param score is enum of score, st is enum of subtype of score (like max, current..) * \return ref on the stat value */ - sint32& lookupStat( SCORES::TScores score, SCharacteristicsAndScores::TCharacteristicsAndScoreSubType st ) throw (CEntityBase::EInvalidStat); + sint32& lookupStat( SCORES::TScores score, SCharacteristicsAndScores::TCharacteristicsAndScoreSubType st); /** * get a reference on a skill value * \param skill is enum of Skills, st is enum of subtype of skill (like base, current..) * \return ref on the stat value */ - sint32& lookupStat( SKILLS::ESkills skill, SSkill::ESkillSubType st ) throw (CEntityBase::EInvalidStat); + sint32& lookupStat( SKILLS::ESkills skill, SSkill::ESkillSubType st); /** * get a reference on a SpecialModifiers value * \param sm is enum of SpecialModifiers * \return ref on the stat value */ - sint32& lookupStat( CSpecialModifiers::ESpecialModifiers sm ) throw (CEntityBase::EInvalidStat); - const sint32& lookupStat( CSpecialModifiers::ESpecialModifiers sm ) const throw (CEntityBase::EInvalidStat); + sint32& lookupStat( CSpecialModifiers::ESpecialModifiers sm); + const sint32& lookupStat( CSpecialModifiers::ESpecialModifiers sm) const; /// accessors on hp (read only) inline sint32 currentHp() const { return _PhysScores._PhysicalScores[SCORES::hit_points].Current;} diff --git a/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h b/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h index 834c27dd1..3fffe22e7 100644 --- a/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h +++ b/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h @@ -83,7 +83,7 @@ public: virtual void setContinent( CONTINENT::TContinent continent ) = 0; // // serial -// virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream ) = 0; +// virtual void serial(NLMISC::IStream &f) = 0; // set item for sale virtual void itemForSale( uint32 price, uint32 retirePrice, CGameItemPtr item, uint32 quantity, const NLMISC::CEntityId& id, CONTINENT::TContinent continent, uint32 identifier ) = 0; @@ -190,7 +190,7 @@ public: void itemForSale( uint32 price, uint32 retirePrice, CGameItemPtr item, uint32 quantity, const NLMISC::CEntityId& id, CONTINENT::TContinent continent, uint32 identifier ); // serial -// void serial(NLMISC::IStream &f) throw(NLMISC::EStream ); +// void serial(NLMISC::IStream &f); // cast operator // const IItemTrade * operator = ( CItemForSale * i ) const { return (IItemTrade *) i; } diff --git a/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.h b/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.h index d8e02b4f6..6de4e8380 100644 --- a/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.h +++ b/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.h @@ -55,7 +55,7 @@ public: const std::vector< TItemTradePtr >& getContent() const { return _ItemsForSale; } // serial - void serial(NLMISC::IStream &f) throw(NLMISC::EStream ); + void serial(NLMISC::IStream &f); // check coherency between CDynamicItems and CItemsForSale of character, assume CItemsForSale is a reference void checkSellStore( NLMISC::CEntityId charId ); From c4888b2d5b82a9426b17e9d07d5986e4fe044a0c Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 8 Aug 2018 20:54:09 +0200 Subject: [PATCH 30/65] Fixed: Warnings, throw(type) deprecated in C++11 and removed in C++17 --HG-- branch : develop --- code/nel/include/nel/misc/smart_ptr.h | 6 +++--- .../nel/src/3d/driver/direct3d/driver_direct3d.cpp | 2 +- .../src/3d/driver/opengl/driver_opengl_window.cpp | 2 +- code/nel/src/3d/dru.cpp | 6 +++--- code/nel/src/3d/landscape.cpp | 4 ++-- code/nel/src/3d/nelu.cpp | 4 ++-- code/nel/src/gui/lua_ihm.cpp | 2 +- code/nel/src/gui/lua_object.cpp | 4 ++-- code/nel/src/misc/file.cpp | 14 +++++++------- code/nel/src/misc/string_mapper.cpp | 4 ++-- code/nel/src/net/module.cpp | 6 +++--- code/nel/src/net/module_gateway_transport.cpp | 10 +++++----- code/nel/src/net/module_l5_transport.cpp | 6 +++--- .../tools/3d/object_viewer/particle_workspace.h | 2 +- .../ryzom/server/src/ai_service/ai_script_comp.cpp | 2 +- .../server/src/ai_service/script_compiler.cpp | 2 +- .../entity_manager/entity_base.cpp | 12 ++++++------ .../shop_type/item_for_sale.cpp | 2 +- .../shop_type/item_for_sale.h | 2 +- .../shop_type/items_for_sale.cpp | 2 +- .../src/frontend_service/gateway_fes_transport.cpp | 6 +++--- .../server/src/input_output_service/chat_manager.h | 2 +- .../server/build_spell_sheet/build_spell_sheet.cpp | 6 +++--- .../object_viewer/particle_system/particle_node.h | 2 +- 24 files changed, 55 insertions(+), 55 deletions(-) diff --git a/code/nel/include/nel/misc/smart_ptr.h b/code/nel/include/nel/misc/smart_ptr.h index 2273cebeb..b0fc1c301 100644 --- a/code/nel/include/nel/misc/smart_ptr.h +++ b/code/nel/include/nel/misc/smart_ptr.h @@ -226,7 +226,7 @@ public: std::string toString() { if(Ptr) return toString(*Ptr); else return ""; } // serial using serialPtr - void serialPtr(NLMISC::IStream &f) throw(NLMISC::EStream ) + void serialPtr(NLMISC::IStream &f) { T* obj= NULL; if(f.isReading()) @@ -242,7 +242,7 @@ public: } } // serial using serialPloyPtr - void serialPolyPtr(NLMISC::IStream &f) throw(NLMISC::EStream ) + void serialPolyPtr(NLMISC::IStream &f) { T* obj= NULL; if(f.isReading()) @@ -337,7 +337,7 @@ public: void kill(); // serial using serialPloyPtr - void serialPolyPtr(NLMISC::IStream &f) throw(NLMISC::EStream ) + void serialPolyPtr(NLMISC::IStream &f) { T* obj= NULL; if(f.isReading()) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index be7a74722..7a4618683 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -1328,7 +1328,7 @@ const D3DFORMAT FinalPixelFormat[ITexture::UploadFormatCount][CDriverD3D::FinalP // *************************************************************************** -bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay) +bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) { H_AUTO_D3D(CDriver3D_setDisplay); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index a7eb6e62a..3d1803a2a 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -611,7 +611,7 @@ void CDriverGL::setWindowIcon(const std::vector &bitmaps) } // -------------------------------------------------- -bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable) throw(EBadDisplay) +bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable) { H_AUTO_OGL(CDriverGL_setDisplay) diff --git a/code/nel/src/3d/dru.cpp b/code/nel/src/3d/dru.cpp index 15ccbfe01..54248c001 100644 --- a/code/nel/src/3d/dru.cpp +++ b/code/nel/src/3d/dru.cpp @@ -77,7 +77,7 @@ extern IDriver* createGlEsDriverInstance (); #endif // *************************************************************************** -IDriver *CDRU::createGlDriver() throw (EDru) +IDriver *CDRU::createGlDriver() { #ifdef NL_STATIC @@ -131,7 +131,7 @@ IDriver *CDRU::createGlDriver() throw (EDru) } // *************************************************************************** -IDriver *CDRU::createGlEsDriver() throw (EDru) +IDriver *CDRU::createGlEsDriver() { #ifdef NL_STATIC @@ -188,7 +188,7 @@ IDriver *CDRU::createGlEsDriver() throw (EDru) #ifdef NL_OS_WINDOWS -IDriver *CDRU::createD3DDriver() throw (EDru) +IDriver *CDRU::createD3DDriver() { #ifdef NL_STATIC diff --git a/code/nel/src/3d/landscape.cpp b/code/nel/src/3d/landscape.cpp index 4b597fc2d..75e71920a 100644 --- a/code/nel/src/3d/landscape.cpp +++ b/code/nel/src/3d/landscape.cpp @@ -2423,7 +2423,7 @@ void CLandscape::checkZoneBinds(CZone &curZone, EBadBind &bindError) // *************************************************************************** -void CLandscape::checkBinds() throw(EBadBind) +void CLandscape::checkBinds() { EBadBind bindError; @@ -2439,7 +2439,7 @@ void CLandscape::checkBinds() throw(EBadBind) // *************************************************************************** -void CLandscape::checkBinds(uint16 zoneId) throw(EBadBind) +void CLandscape::checkBinds(uint16 zoneId) { EBadBind bindError; diff --git a/code/nel/src/3d/nelu.cpp b/code/nel/src/3d/nelu.cpp index 8cb6e0968..7807a5ef7 100644 --- a/code/nel/src/3d/nelu.cpp +++ b/code/nel/src/3d/nelu.cpp @@ -51,7 +51,7 @@ CEventServer CNELU::EventServer; CEventListenerAsync CNELU::AsyncListener; -bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru) +bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) { // Init debug system // NLMISC::InitDebug(); @@ -183,7 +183,7 @@ void CNELU::releaseDriver() } } -bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru) +bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) { NL3D::registerSerial3d(); if (initDriver(w,h,bpp,windowed,systemWindow,offscreen,direct3d)) diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index 0b4a1d0dc..4a51d221f 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -1434,7 +1434,7 @@ namespace NLGUI } // *************************************************************************** - void CLuaIHM::luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException) + void CLuaIHM::luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) { //H_AUTO(Lua_property_throw) if(ls.isNil(stackIndex)) diff --git a/code/nel/src/gui/lua_object.cpp b/code/nel/src/gui/lua_object.cpp index 5417ba0c5..805e38ceb 100644 --- a/code/nel/src/gui/lua_object.cpp +++ b/code/nel/src/gui/lua_object.cpp @@ -222,7 +222,7 @@ namespace NLGUI } // ************************************************* - CLuaEnumeration CLuaObject::enumerate() throw(ELuaNotATable) + CLuaEnumeration CLuaObject::enumerate() { if (!isEnumerable()) { @@ -317,7 +317,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setNil(const char *key) throw(ELuaNotATable) + void CLuaObject::setNil(const char *key) { nlassert(key); nlassert(isValid()); diff --git a/code/nel/src/misc/file.cpp b/code/nel/src/misc/file.cpp index 722043fd8..414a10e5a 100644 --- a/code/nel/src/misc/file.cpp +++ b/code/nel/src/misc/file.cpp @@ -401,7 +401,7 @@ bool CIFile::eof () } // ====================================================================================================== -void CIFile::serialBuffer(uint8 *buf, uint len) throw(EReadError) +void CIFile::serialBuffer(uint8 *buf, uint len) { if (len == 0) return; @@ -444,7 +444,7 @@ void CIFile::serialBuffer(uint8 *buf, uint len) throw(EReadError) } // ====================================================================================================== -void CIFile::serialBit(bool &bit) throw(EReadError) +void CIFile::serialBit(bool &bit) { // Simple for now. uint8 v=bit; @@ -485,7 +485,7 @@ bool CIFile::seek (sint32 offset, IStream::TSeekOrigin origin) const } // ====================================================================================================== -sint32 CIFile::getPos () const throw(EStream) +sint32 CIFile::getPos () const { return _ReadPos; } @@ -652,7 +652,7 @@ void COFile::flush() // ====================================================================================================== -void COFile::serialBuffer(uint8 *buf, uint len) throw(EWriteError) +void COFile::serialBuffer(uint8 *buf, uint len) { if(!_F) throw EFileNotOpened(_FileName); @@ -667,14 +667,14 @@ void COFile::serialBuffer(uint8 *buf, uint len) throw(EWriteError) } } // ====================================================================================================== -void COFile::serialBit(bool &bit) throw(EWriteError) +void COFile::serialBit(bool &bit) { // Simple for now. uint8 v=bit; serialBuffer(&v, 1); } // ====================================================================================================== -bool COFile::seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStream) +bool COFile::seek (sint32 offset, IStream::TSeekOrigin origin) const { if (_F) { @@ -701,7 +701,7 @@ bool COFile::seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStr return false; } // ====================================================================================================== -sint32 COFile::getPos () const throw(EStream) +sint32 COFile::getPos () const { if (_F) { diff --git a/code/nel/src/misc/string_mapper.cpp b/code/nel/src/misc/string_mapper.cpp index 6e59f7bab..39931efd2 100644 --- a/code/nel/src/misc/string_mapper.cpp +++ b/code/nel/src/misc/string_mapper.cpp @@ -211,7 +211,7 @@ void CStaticStringMapper::clear() } // **************************************************************************** -void CStaticStringMapper::serial(IStream &f, TSStringId &strId) throw(EStream) +void CStaticStringMapper::serial(IStream &f, TSStringId &strId) { std::string tmp; if (f.isReading()) @@ -227,7 +227,7 @@ void CStaticStringMapper::serial(IStream &f, TSStringId &strId) throw(EStream) } // **************************************************************************** -void CStaticStringMapper::serial(IStream &f, std::vector &strIdVect) throw(EStream) +void CStaticStringMapper::serial(IStream &f, std::vector &strIdVect) { std::vector vsTmp; std::string sTmp; diff --git a/code/nel/src/net/module.cpp b/code/nel/src/net/module.cpp index 1b5e03bec..b5707fea3 100644 --- a/code/nel/src/net/module.cpp +++ b/code/nel/src/net/module.cpp @@ -397,7 +397,7 @@ namespace NLNET } - void CModuleBase::plugModule(IModuleSocket *moduleSocket) throw (EModuleAlreadyPluggedHere) + void CModuleBase::plugModule(IModuleSocket *moduleSocket) { CModuleSocket *sock = dynamic_cast(moduleSocket); nlassert(sock != NULL); @@ -415,7 +415,7 @@ namespace NLNET _ModuleSockets.insert(moduleSocket); } - void CModuleBase::unplugModule(IModuleSocket *moduleSocket) throw (EModuleNotPluggedHere) + void CModuleBase::unplugModule(IModuleSocket *moduleSocket) { CModuleSocket *sock = dynamic_cast(moduleSocket); nlassert(sock != NULL); @@ -443,7 +443,7 @@ namespace NLNET * The call is blocking until receptions of the operation * result message (or a module down) */ - void CModuleBase::invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) throw (EInvokeFailed) + void CModuleBase::invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) { H_AUTO(CModuleBase_invokeModuleOperation); diff --git a/code/nel/src/net/module_gateway_transport.cpp b/code/nel/src/net/module_gateway_transport.cpp index d9029285f..08ff51eeb 100644 --- a/code/nel/src/net/module_gateway_transport.cpp +++ b/code/nel/src/net/module_gateway_transport.cpp @@ -184,13 +184,13 @@ namespace NLNET } } - void onCommand(const CMessage &/* command */) throw (EInvalidCommand) + void onCommand(const CMessage &/* command */) { // nothing done for now throw EInvalidCommand(); } /// The gateway send a textual command to the transport - bool onCommand(const TParsedCommandLine &command) throw (EInvalidCommand) + bool onCommand(const TParsedCommandLine &command) { if (command.SubParams.size() < 1) throw EInvalidCommand(); @@ -218,7 +218,7 @@ namespace NLNET } /// Open the server by starting listing for incoming connection on the specified port - void openServer(uint16 port) throw (ETransportError) + void openServer(uint16 port) { if (_CallbackServer.get() != NULL) throw ETransportError("openServer : The server is already open"); @@ -607,13 +607,13 @@ namespace NLNET } } - void onCommand(const CMessage &/* command */) throw (EInvalidCommand) + void onCommand(const CMessage &/* command */) { // nothing done for now throw EInvalidCommand(); } /// The gateway send a textual command to the transport - bool onCommand(const TParsedCommandLine &command) throw (EInvalidCommand) + bool onCommand(const TParsedCommandLine &command) { if (command.SubParams.size() < 1) throw EInvalidCommand(); diff --git a/code/nel/src/net/module_l5_transport.cpp b/code/nel/src/net/module_l5_transport.cpp index 5eddabc9f..e902263c7 100644 --- a/code/nel/src/net/module_l5_transport.cpp +++ b/code/nel/src/net/module_l5_transport.cpp @@ -218,13 +218,13 @@ namespace NLNET } } - void onCommand(const CMessage &/* command */) throw (EInvalidCommand) + void onCommand(const CMessage &/* command */) { // nothing done for now throw EInvalidCommand(); } /// The gateway send a textual command to the transport - bool onCommand(const TParsedCommandLine &command) throw (EInvalidCommand) + bool onCommand(const TParsedCommandLine &command) { if (command.SubParams.size() < 1) throw EInvalidCommand(); @@ -255,7 +255,7 @@ namespace NLNET /// Open the server by establishing route with all known services - void open(const std::string &subNetName) throw (ETransportError) + void open(const std::string &subNetName) { H_AUTO(L5_open); diff --git a/code/nel/tools/3d/object_viewer/particle_workspace.h b/code/nel/tools/3d/object_viewer/particle_workspace.h index 694aab986..3508746d5 100644 --- a/code/nel/tools/3d/object_viewer/particle_workspace.h +++ b/code/nel/tools/3d/object_viewer/particle_workspace.h @@ -186,7 +186,7 @@ public: * * \return pointer to new node, or NULL if already inserted */ - CNode *addNode(const std::string &filenameWithFullPath) throw( NLMISC::Exception); + CNode *addNode(const std::string &filenameWithFullPath); // remove a node by its index void removeNode(uint index); // remove a node by its pointer diff --git a/code/ryzom/server/src/ai_service/ai_script_comp.cpp b/code/ryzom/server/src/ai_service/ai_script_comp.cpp index 87cbb939d..d076e6832 100644 --- a/code/ryzom/server/src/ai_service/ai_script_comp.cpp +++ b/code/ryzom/server/src/ai_service/ai_script_comp.cpp @@ -1066,7 +1066,7 @@ void CFightScript::add(CFightScriptCompReader *reader) } -CFightScriptCompReader *CFightScriptCompReader::getScriptReader (const string &str) throw (ReadFightActionException) +CFightScriptCompReader *CFightScriptCompReader::getScriptReader (const string &str) { CFightScript::TFightScriptMap::iterator it=CFightScript::_ScriptCompList.find(str); if (it==CFightScript::_ScriptCompList.end()) diff --git a/code/ryzom/server/src/ai_service/script_compiler.cpp b/code/ryzom/server/src/ai_service/script_compiler.cpp index 7ba10f149..bafdefd92 100644 --- a/code/ryzom/server/src/ai_service/script_compiler.cpp +++ b/code/ryzom/server/src/ai_service/script_compiler.cpp @@ -1279,7 +1279,7 @@ static void displayErrorLinesForIndex(const string &text, size_t &index) } -bool CCompiler::getNextToken(const string &text, size_t &index, string &tokenName, string &textValue) throw (EScriptError) +bool CCompiler::getNextToken(const string &text, size_t &index, string &tokenName, string &textValue) { char c=text.at(index); while (c==' '||c=='\n'||c=='\r'||c=='\t') // to avoid blanks, returns and Tabs. diff --git a/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.cpp b/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.cpp index 374b00295..069933e2b 100644 --- a/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.cpp +++ b/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.cpp @@ -394,7 +394,7 @@ void CEntityBase::setTarget( const NLMISC::CEntityId& targetId, bool sendMessage // lookupStat : // //--------------------------------------------------- -sint32& CEntityBase::lookupStat( const string& var ) throw (CEntityBase::EInvalidStat) +sint32& CEntityBase::lookupStat( const string& var) { // TODO Alain: optimize this... uint i; @@ -562,7 +562,7 @@ sint32& CEntityBase::lookupStat( const string& var ) throw (CEntityBase::EInvali // lookupStat for Characteristics: // //--------------------------------------------------- -sint32& CEntityBase::lookupStat( CHARACTERISTICS::TCharacteristics c, SCharacteristicsAndScores::TCharacteristicsAndScoreSubType st ) throw (CEntityBase::EInvalidStat) +sint32& CEntityBase::lookupStat( CHARACTERISTICS::TCharacteristics c, SCharacteristicsAndScores::TCharacteristicsAndScoreSubType st) { if( c < CHARACTERISTICS::NUM_CHARACTERISTICS ) { @@ -601,7 +601,7 @@ sint32& CEntityBase::lookupStat( CHARACTERISTICS::TCharacteristics c, SCharacter // lookupStat for Scores: // //--------------------------------------------------- -sint32& CEntityBase::lookupStat( SCORES::TScores score, SCharacteristicsAndScores::TCharacteristicsAndScoreSubType st ) throw (CEntityBase::EInvalidStat) +sint32& CEntityBase::lookupStat( SCORES::TScores score, SCharacteristicsAndScores::TCharacteristicsAndScoreSubType st) { if( score < SCORES::NUM_SCORES ) { @@ -640,7 +640,7 @@ sint32& CEntityBase::lookupStat( SCORES::TScores score, SCharacteristicsAndScore // lookupStat for Skills: // //--------------------------------------------------- -sint32& CEntityBase::lookupStat( SKILLS::ESkills skill, SSkill::ESkillSubType st ) throw (CEntityBase::EInvalidStat) +sint32& CEntityBase::lookupStat( SKILLS::ESkills skill, SSkill::ESkillSubType st) { /* enum ESkillSubType { @@ -675,7 +675,7 @@ sint32& CEntityBase::lookupStat( SKILLS::ESkills skill, SSkill::ESkillSubType st // lookupStat for SpecialModifiers: // //--------------------------------------------------- -sint32& CEntityBase::lookupStat( CSpecialModifiers::ESpecialModifiers sm ) throw (CEntityBase::EInvalidStat) +sint32& CEntityBase::lookupStat( CSpecialModifiers::ESpecialModifiers sm) { switch( sm ) { @@ -738,7 +738,7 @@ sint32& CEntityBase::lookupStat( CSpecialModifiers::ESpecialModifiers sm ) throw throw CEntityBase::EInvalidStat() ; } // lookupStat // -const sint32& CEntityBase::lookupStat( CSpecialModifiers::ESpecialModifiers sm ) const throw (CEntityBase::EInvalidStat) +const sint32& CEntityBase::lookupStat( CSpecialModifiers::ESpecialModifiers sm) const { return const_cast(this)->lookupStat(sm); } diff --git a/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.cpp b/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.cpp index 2844db92c..c2464c0ee 100644 --- a/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.cpp +++ b/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.cpp @@ -93,7 +93,7 @@ void CItemForSale::setAvailable( bool a ) } //----------------------------------------------------------------------------- -//void CItemForSale::serial(NLMISC::IStream &f) throw(NLMISC::EStream ) +//void CItemForSale::serial(NLMISC::IStream &f) //{ // f.serial( _PriceInfo ); // f.serial( _RetirePrice ); diff --git a/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h b/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h index 3fffe22e7..7387a9a10 100644 --- a/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h +++ b/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h @@ -312,7 +312,7 @@ public: void setContinent( CONTINENT::TContinent ) {} // serial - void serial(NLMISC::IStream &f) throw(NLMISC::EStream ) {} + void serial(NLMISC::IStream &f) {} // set item for sale void itemForSale( uint32 price, uint32 retirePrice, CGameItemPtr item, uint32 quantity, const NLMISC::CEntityId& id, CONTINENT::TContinent continent, uint32 identifier ) {} diff --git a/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp b/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp index c247b93ac..61538b674 100644 --- a/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp +++ b/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp @@ -96,7 +96,7 @@ NLMISC::CSmartPtr< IItemTrade > CItemsForSale::removeItem( uint32 identifier, ui } //----------------------------------------------------------------------------- -void CItemsForSale::serial(NLMISC::IStream &f) throw(NLMISC::EStream ) +void CItemsForSale::serial(NLMISC::IStream &f) { // YOYO: we should not be here. OLD serial was very buggy. // AlainS ensure me this code is no more called (no write, use PDS instead, and old version diff --git a/code/ryzom/server/src/frontend_service/gateway_fes_transport.cpp b/code/ryzom/server/src/frontend_service/gateway_fes_transport.cpp index a24fd8d51..40cb4dde2 100644 --- a/code/ryzom/server/src/frontend_service/gateway_fes_transport.cpp +++ b/code/ryzom/server/src/frontend_service/gateway_fes_transport.cpp @@ -179,13 +179,13 @@ public: } } - void onCommand(const CMessage &command) throw (EInvalidCommand) + void onCommand(const CMessage &command) { // nothing done for now throw EInvalidCommand(); } /// The gateway send a textual command to the transport - bool onCommand(const TParsedCommandLine &command) throw (EInvalidCommand) + bool onCommand(const TParsedCommandLine &command) { if (command.SubParams.size() < 1) throw EInvalidCommand(); @@ -212,7 +212,7 @@ public: } /// Open the server by intercepting client gateway message - void openServer() throw (ETransportError) + void openServer() { if (OpenTransport() != NULL) throw ETransportError("openServer : a transport is already open !"); diff --git a/code/ryzom/server/src/input_output_service/chat_manager.h b/code/ryzom/server/src/input_output_service/chat_manager.h index 544dbfa2c..658a72d81 100644 --- a/code/ryzom/server/src/input_output_service/chat_manager.h +++ b/code/ryzom/server/src/input_output_service/chat_manager.h @@ -145,7 +145,7 @@ public : * \param gId is the group's id * \return the group */ - CChatGroup& getGroup( const TGroupId& gId );// throw (EChatGroup); + CChatGroup& getGroup( const TGroupId& gId ); /** * Transmit a chat message diff --git a/code/ryzom/tools/server/build_spell_sheet/build_spell_sheet.cpp b/code/ryzom/tools/server/build_spell_sheet/build_spell_sheet.cpp index 5e892410b..6a8383485 100644 --- a/code/ryzom/tools/server/build_spell_sheet/build_spell_sheet.cpp +++ b/code/ryzom/tools/server/build_spell_sheet/build_spell_sheet.cpp @@ -65,7 +65,7 @@ public: return true; } public: - void serial(IStream &f) throw(EStream) + void serial(IStream &f) { for(uint k = 0; k < NumUserParams; ++k) { @@ -87,7 +87,7 @@ public: { return PSName.empty() && UserParams.empty(); } - void serial(IStream &f) throw(EStream) + void serial(IStream &f) { if (!PSName.empty()) writeAtom(f, "PSName", PSName); UserParams.serial(f); @@ -111,7 +111,7 @@ public: } return true; } - void serial(IStream &f) throw(EStream) + void serial(IStream &f) { for(uint k = 0; k < NumFX; ++k) { diff --git a/code/studio/src/plugins/object_viewer/particle_system/particle_node.h b/code/studio/src/plugins/object_viewer/particle_system/particle_node.h index 033802a44..7b164580d 100644 --- a/code/studio/src/plugins/object_viewer/particle_system/particle_node.h +++ b/code/studio/src/plugins/object_viewer/particle_system/particle_node.h @@ -283,7 +283,7 @@ public: /// The node is in the 'unloaded' state, so caller must load it afterward. /// NB : no lookup is done, full path must be provided. /// @return pointer to new node, or NULL if already inserted - CWorkspaceNode *addNode(const std::string &filenameWithFullPath) throw( NLMISC::Exception); + CWorkspaceNode *addNode(const std::string &filenameWithFullPath); /// Remove a node by it's index void removeNode(uint index); From 8a1588c1471b3161248bee5f0b6d3555bb02ecb9 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 8 Aug 2018 20:55:14 +0200 Subject: [PATCH 31/65] Fixed: Also use SSL context callback when manually using Windows CA certs --HG-- branch : develop --- code/nel/src/gui/curl_certificates.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index f06d92608..5cec3c511 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -88,12 +88,9 @@ namespace NLGUI addCertificatesFrom("CA"); addCertificatesFrom("AuthRoot"); addCertificatesFrom("ROOT"); - - // we manually loaded native CA Certs, don't need to use custom certificates - isUsingOpenSSLBackend = false; -#else - isUsingOpenSSLBackend = true; #endif + + isUsingOpenSSLBackend = true; } else { From 443cc7df65aa5fcc070624fa8b1bbe523b6b9aa2 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 8 Aug 2018 20:55:40 +0200 Subject: [PATCH 32/65] Fixed: Don't throw an exception when a certifcate can't be found --HG-- branch : develop --- code/nel/src/gui/curl_certificates.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index 5cec3c511..7d26e7e5a 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -144,7 +144,7 @@ namespace NLGUI FilesList.push_back(cert); // look for certificate in search paths - string path = CPath::lookup(cert); + string path = CPath::lookup(cert, false); nlinfo("Cert path '%s'", path.c_str()); if (path.empty()) From facc5f6d288724fce12c9ab03810032249e2f037 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 9 Aug 2018 14:27:42 +0200 Subject: [PATCH 33/65] Fixed: Warnings, throw(type) deprecated in C++11 and removed in C++17 --HG-- branch : develop --- code/nel/include/nel/misc/mem_stream.h | 2 +- code/nel/include/nel/net/module.h | 2 +- .../src/3d/driver/direct3d/driver_direct3d.h | 2 +- code/nel/src/misc/class_registry.cpp | 4 +-- .../3d/object_viewer/particle_workspace.cpp | 2 +- .../server/src/ai_service/ai_script_comp.cpp | 32 +++++++++---------- .../server/src/ai_service/ai_script_comp.h | 6 ++-- .../src/input_output_service/chat_manager.h | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/code/nel/include/nel/misc/mem_stream.h b/code/nel/include/nel/misc/mem_stream.h index a9e8aacfc..4222e1672 100644 --- a/code/nel/include/nel/misc/mem_stream.h +++ b/code/nel/include/nel/misc/mem_stream.h @@ -210,7 +210,7 @@ public: * \return the new offset regarding from the origin. * \see ESeekNotSupported SeekOrigin seek */ - virtual sint32 getPos () const throw(EStream) + virtual sint32 getPos () const { return sint32(_Buffer.Pos); } diff --git a/code/nel/include/nel/net/module.h b/code/nel/include/nel/net/module.h index 0b5b158d2..05cd48fed 100644 --- a/code/nel/include/nel/net/module.h +++ b/code/nel/include/nel/net/module.h @@ -780,7 +780,7 @@ namespace NLNET bool initModule(const TParsedCommandLine &initInfo); void plugModule(IModuleSocket *moduleSocket); - void unplugModule(IModuleSocket *moduleSocket) throw (EModuleNotPluggedHere); + void unplugModule(IModuleSocket *moduleSocket); void getPluggedSocketList(std::vector &resultList); void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg); void _onModuleUp(IModuleProxy *removedProxy); diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index 6621ab6cb..51c21bbc9 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -849,7 +849,7 @@ public: // Mode initialisation, requests virtual bool init (uintptr_t windowIcon = 0, emptyProc exitFunc = 0); - virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable); virtual bool release(); virtual bool setMode(const GfxMode& mode); virtual bool getModes(std::vector &modes); diff --git a/code/nel/src/misc/class_registry.cpp b/code/nel/src/misc/class_registry.cpp index 91c603c90..c703e45d0 100644 --- a/code/nel/src/misc/class_registry.cpp +++ b/code/nel/src/misc/class_registry.cpp @@ -49,7 +49,7 @@ void CClassRegistry::release() } // ====================================================================================================== -IClassable *CClassRegistry::create(const string &className) throw(ERegistry) +IClassable *CClassRegistry::create(const string &className) { init(); @@ -72,7 +72,7 @@ IClassable *CClassRegistry::create(const string &className) throw(ERegistry) } // ====================================================================================================== -void CClassRegistry::registerClass(const string &className, IClassable* (*creator)(), const string &typeidCheck) throw(ERegistry) +void CClassRegistry::registerClass(const string &className, IClassable* (*creator)(), const string &typeidCheck) { init(); diff --git a/code/nel/tools/3d/object_viewer/particle_workspace.cpp b/code/nel/tools/3d/object_viewer/particle_workspace.cpp index 43be30812..1a289d2b0 100644 --- a/code/nel/tools/3d/object_viewer/particle_workspace.cpp +++ b/code/nel/tools/3d/object_viewer/particle_workspace.cpp @@ -357,7 +357,7 @@ void CParticleWorkspace::setName(const std::string &name) //*********************************************************************************************** -CParticleWorkspace::CNode *CParticleWorkspace::addNode(const std::string &filenameWithFullPath) throw( NLMISC::EStream) +CParticleWorkspace::CNode *CParticleWorkspace::addNode(const std::string &filenameWithFullPath) { nlassert(_OV); // Check that file is not already inserted diff --git a/code/ryzom/server/src/ai_service/ai_script_comp.cpp b/code/ryzom/server/src/ai_service/ai_script_comp.cpp index d076e6832..69c4c9bab 100644 --- a/code/ryzom/server/src/ai_service/ai_script_comp.cpp +++ b/code/ryzom/server/src/ai_service/ai_script_comp.cpp @@ -83,7 +83,7 @@ std::string CFightSelectFilter::toString() const -CFightScriptComp *CFightSelectFilterReader::create (const std::string &inStr) throw (ReadFightActionException) +CFightScriptComp *CFightSelectFilterReader::create (const std::string &inStr) { std::vector params; explodeSubStrings(inStr, params, -1); @@ -151,7 +151,7 @@ public: CFightOnceReader() {} virtual ~CFightOnceReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector params; explodeSubStrings(inStr, params, -1); @@ -229,7 +229,7 @@ public: CFightTimedFilterReader() {} virtual ~CFightTimedFilterReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector params; explodeSubStrings(inStr, params, -1); @@ -302,7 +302,7 @@ public: CFightHPLessFilterReader() {} virtual ~CFightHPLessFilterReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector params; explodeSubStrings(inStr, params, -1); @@ -372,7 +372,7 @@ public: CFightHPMoreFilterReader() {} virtual ~CFightHPMoreFilterReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector params; explodeSubStrings(inStr, params, -1); @@ -443,7 +443,7 @@ public: CFightRandomFilterReader() {} virtual ~CFightRandomFilterReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector params; explodeSubStrings(inStr, params, -1); @@ -523,7 +523,7 @@ public: CFightSendActionReader() {} virtual ~CFightSendActionReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector strings; explodeSubStrings(inStr, strings, -1); @@ -588,7 +588,7 @@ public: CFightSendSelfActionReader() {} virtual ~CFightSendSelfActionReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector strings; explodeSubStrings(inStr, strings, -1); @@ -647,7 +647,7 @@ public: CFightAggroBlockReader() {} virtual ~CFightAggroBlockReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector strings; explodeSubStrings(inStr, strings, -1); @@ -705,7 +705,7 @@ public: CFightAggroChangeReader() {} virtual ~CFightAggroChangeReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { return new CFightAggroChange(); } @@ -751,7 +751,7 @@ public: CFightDamageCoefReader() {} virtual ~CFightDamageCoefReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector strings; explodeSubStrings(inStr, strings, -1); @@ -818,7 +818,7 @@ public: CFightGroupDamageCoefReader() {} virtual ~CFightGroupDamageCoefReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector strings; explodeSubStrings(inStr, strings, -1); @@ -871,7 +871,7 @@ public: CFightDamageSpeedCoefReader() {} virtual ~CFightDamageSpeedCoefReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector strings; explodeSubStrings(inStr, strings, -1); @@ -933,7 +933,7 @@ public: CFightSetRandomTargetReader() {} virtual ~CFightSetRandomTargetReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector strings; explodeSubStrings(inStr, strings, -1); @@ -1003,7 +1003,7 @@ public: CFightMultReader() {} virtual ~CFightMultReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) + CFightScriptComp *create (const std::string &inStr) { vector params; explodeSubStrings(inStr, params, -1); @@ -1075,7 +1075,7 @@ CFightScriptCompReader *CFightScriptCompReader::getScriptReader (const string &s return &(*(it->second)); } -CFightScriptComp *CFightScriptCompReader::createScriptComp (const string &str) throw (ReadFightActionException) +CFightScriptComp *CFightScriptCompReader::createScriptComp (const string &str) { string scriptCompName; { diff --git a/code/ryzom/server/src/ai_service/ai_script_comp.h b/code/ryzom/server/src/ai_service/ai_script_comp.h index 0b02cc722..a35253d66 100644 --- a/code/ryzom/server/src/ai_service/ai_script_comp.h +++ b/code/ryzom/server/src/ai_service/ai_script_comp.h @@ -51,12 +51,12 @@ public: {} virtual ~CFightScriptCompReader() {} - virtual CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException) = 0; + virtual CFightScriptComp *create (const std::string &inStr) = 0; virtual std::string getName () const =0; static CFightScriptCompReader *getScriptReader (const std::string &str); - static CFightScriptComp *createScriptComp (const std::string &str) throw (ReadFightActionException); + static CFightScriptComp *createScriptComp (const std::string &str) protected: private: }; @@ -116,7 +116,7 @@ public: CFightSelectFilterReader() {} virtual ~CFightSelectFilterReader() {} - CFightScriptComp *create (const std::string &inStr) throw (ReadFightActionException); + CFightScriptComp *create (const std::string &inStr) std::string getName () const { return std::string("SELECT"); diff --git a/code/ryzom/server/src/input_output_service/chat_manager.h b/code/ryzom/server/src/input_output_service/chat_manager.h index 658a72d81..a64b68d52 100644 --- a/code/ryzom/server/src/input_output_service/chat_manager.h +++ b/code/ryzom/server/src/input_output_service/chat_manager.h @@ -101,7 +101,7 @@ public : * Get the client infos * \param id is the client character id */ - CChatClient& getClient( const TDataSetRow& id ); //throw (EChatClient); + CChatClient& getClient( const TDataSetRow& id ); /** * Return a reference on the static database From f39c6ed3c64a205475ada0dff0da819808396c9d Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 9 Aug 2018 14:30:13 +0200 Subject: [PATCH 34/65] Fixed: Warnings --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 4 +-- code/ryzom/client/src/item_group_manager.cpp | 26 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 6f0e612c9..9c022934a 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -459,7 +459,7 @@ namespace NLGUI #endif // Display cached image while downloading new - if (type != TImageType::OverImage && CFile::fileExists(dest)) + if (type != OverImage && CFile::fileExists(dest)) { setImage(img, dest, type); setImageSize(img, style); @@ -4711,7 +4711,7 @@ namespace NLGUI if (overBitmap != normalBitmap) { over = localImageName(overBitmap); - addImageDownload(overBitmap, ctrlButton, style, TImageType::OverImage); + addImageDownload(overBitmap, ctrlButton, style, OverImage); } } diff --git a/code/ryzom/client/src/item_group_manager.cpp b/code/ryzom/client/src/item_group_manager.cpp index e72f2d730..d4a7a4ba0 100644 --- a/code/ryzom/client/src/item_group_manager.cpp +++ b/code/ryzom/client/src/item_group_manager.cpp @@ -83,8 +83,8 @@ void CItemGroup::addItem(sint32 createTime, sint32 serial, SLOT_EQUIPMENT::TSlot nldebug("Not adding duplicate item, createTime: %d, serial: %d", createTime, serial); //In this case, we are adding the duplicate item for a 2 hands item //If it's saved as a left hand item, save it as a right hand item instead (so we have only 1 correct item) - if(Items[i].slot == SLOT_EQUIPMENT::TSlotEquipment::HANDL && slot == SLOT_EQUIPMENT::TSlotEquipment::HANDR) - Items[i].slot = SLOT_EQUIPMENT::TSlotEquipment::HANDR; + if(Items[i].slot == SLOT_EQUIPMENT::HANDL && slot == SLOT_EQUIPMENT::HANDR) + Items[i].slot = SLOT_EQUIPMENT::HANDR; return; } } @@ -389,7 +389,7 @@ CItemGroup CItemGroupManager::migrateGroup(CItemGroup group) //Get all matching items from all inventory CItemGroup out; out.name = group.name; - for (int i=0; i < INVENTORIES::TInventory::NUM_ALL_INVENTORY; i++) + for (int i=0; i < INVENTORIES::NUM_ALL_INVENTORY; i++) { INVENTORIES::TInventory inventory = (INVENTORIES::TInventory)i; std::vector items = matchingItems(&group, inventory); @@ -501,7 +501,7 @@ bool CItemGroupManager::moveGroup(std::string name, INVENTORIES::TInventory dst) std::string moveParams = "to=lists|nblist=1|listsheet0=" + toDbPath(dst); // Grab all matching item from all available inventory and put it in dst - for (int i=0; i< INVENTORIES::TInventory::NUM_ALL_INVENTORY; i ++) + for (int i=0; i< INVENTORIES::NUM_ALL_INVENTORY; i ++) { INVENTORIES::TInventory inventory = (INVENTORIES::TInventory)i; if (inventory != dst && pIM->isInventoryAvailable(inventory)) @@ -531,7 +531,7 @@ bool CItemGroupManager::equipGroup(std::string name, bool pullBefore) return false; } - if(pullBefore) moveGroup(name, INVENTORIES::TInventory::bag); + if(pullBefore) moveGroup(name, INVENTORIES::bag); //Start by unequipping all slot that user wants to unequip for(int i=0; i < group->removeBeforeEquip.size(); i++) { @@ -555,7 +555,7 @@ bool CItemGroupManager::equipGroup(std::string name, bool pullBefore) {ITEM_TYPE::RING, false}, }; std::vector duals; - std::vector items = matchingItems(group, INVENTORIES::TInventory::bag); + std::vector items = matchingItems(group, INVENTORIES::bag); for(int i=0; i < items.size(); i++) { CInventoryItem item = items[i]; @@ -713,19 +713,19 @@ std::string CItemGroupManager::toDbPath(INVENTORIES::TInventory inventory) { switch(inventory) { - case INVENTORIES::TInventory::bag: + case INVENTORIES::bag: return LIST_BAG_TEXT; break; - case INVENTORIES::TInventory::pet_animal1: + case INVENTORIES::pet_animal1: return LIST_PA0_TEXT; break; - case INVENTORIES::TInventory::pet_animal2: + case INVENTORIES::pet_animal2: return LIST_PA1_TEXT; break; - case INVENTORIES::TInventory::pet_animal3: + case INVENTORIES::pet_animal3: return LIST_PA2_TEXT; break; - case INVENTORIES::TInventory::pet_animal4: + case INVENTORIES::pet_animal4: return LIST_PA3_TEXT; break; - case INVENTORIES::TInventory::player_room: + case INVENTORIES::player_room: return LIST_ROOM_TEXT;break; - case INVENTORIES::TInventory::guild: + case INVENTORIES::guild: return ClientCfg.ItemGroupAllowGuild ? LIST_GUILD_TEXT : ""; break; default: return ""; From 78670dfdda3f33c4151890747e6ef8624e7181b8 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 9 Aug 2018 14:31:17 +0200 Subject: [PATCH 35/65] Fixed: Compilation with VC++ 2010 --HG-- branch : develop --- code/nel/include/nel/misc/types_nl.h | 3 +++ .../src/interface_v3/chat_text_manager.cpp | 16 +++++++++++++++- code/ryzom/client/src/item_group_manager.cpp | 10 ++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 71702bce5..2851759de 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -79,6 +79,9 @@ # elif _MSC_VER >= 1600 # define NL_COMP_VC10 # define NL_COMP_VC_VERSION 100 +# ifdef _HAS_CPP0X +# undef _HAS_CPP0X // VC++ 2010 doesn't implement C++11 stuff we need +# endif # elif _MSC_VER >= 1500 # define NL_COMP_VC9 # define NL_COMP_VC_VERSION 90 diff --git a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp index e21872018..a9a682bf1 100644 --- a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -187,7 +187,21 @@ static inline bool isUrlTag(const ucstring &s, ucstring::size_type index, ucstri if (isUrl && i > 0 && !markdown) { // '}' is in the list because of color tags, ie "@{FFFF}http://..." - const vector chars {' ', '"', '\'', '(', '[', '}'}; +#ifdef NL_ISO_CPP0X_AVAILABLE + const vector chars{ ' ', '"', '\'', '(', '[', '}' }; +#else + static std::vector chars; + + if (chars.empty()) + { + chars.push_back(' '); + chars.push_back('"'); + chars.push_back('\''); + chars.push_back('('); + chars.push_back('['); + chars.push_back('}'); + } +#endif isUrl = std::find(chars.begin(), chars.end(), s[i - 1]) != chars.end(); } return isUrl; diff --git a/code/ryzom/client/src/item_group_manager.cpp b/code/ryzom/client/src/item_group_manager.cpp index d4a7a4ba0..fddba873f 100644 --- a/code/ryzom/client/src/item_group_manager.cpp +++ b/code/ryzom/client/src/item_group_manager.cpp @@ -547,6 +547,7 @@ bool CItemGroupManager::equipGroup(std::string name, bool pullBefore) uint32 maxEquipTime = 0; +#ifdef NL_ISO_CPP0X_AVAILABLE std::map possiblyDual = { {ITEM_TYPE::ANKLET, false}, @@ -554,6 +555,15 @@ bool CItemGroupManager::equipGroup(std::string name, bool pullBefore) {ITEM_TYPE::EARING, false}, {ITEM_TYPE::RING, false}, }; +#else + std::map possiblyDual; + + possiblyDual[ITEM_TYPE::ANKLET] = false; + possiblyDual[ITEM_TYPE::BRACELET] = false; + possiblyDual[ITEM_TYPE::EARING] = false; + possiblyDual[ITEM_TYPE::RING] = false; +#endif + std::vector duals; std::vector items = matchingItems(group, INVENTORIES::bag); for(int i=0; i < items.size(); i++) From cc6ed038b91b1e2b811f972ea74aca5bfc4237f8 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 9 Aug 2018 14:32:00 +0200 Subject: [PATCH 36/65] Fixed: Don't use memory aligned functions while debugging with VC++ --HG-- branch : develop --- code/nel/include/nel/misc/types_nl.h | 14 +++++++++++--- code/nel/src/misc/common.cpp | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 2851759de..6431701fe 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -412,8 +412,16 @@ typedef unsigned int uint; // at least 32bits (depend of processor) #define NL_DEFAULT_MEMORY_ALIGNMENT 16 #define NL_ALIGN_SSE2 NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT) -#ifndef NL_CPU_X86_64 +#ifdef NL_CPU_X86_64 // on x86_64, new and delete are already aligned on 16 bytes +#elif (defined(NL_COMP_VC) && defined(NL_DEBUG)) +// don't use aligned memory if debugging with VC++ in 32 bits +#else +// use aligned memory in all other cases +#define NL_USE_ALIGNED_MEMORY_OPERATORS +#endif + +#ifdef NL_USE_ALIGNED_MEMORY_OPERATORS #ifdef NL_NO_EXCEPTION_SPECS extern void *operator new(size_t size); @@ -425,9 +433,9 @@ extern void *operator new(size_t size) throw(std::bad_alloc); extern void *operator new[](size_t size) throw(std::bad_alloc); extern void operator delete(void *p) throw(); extern void operator delete[](void *p) throw(); -#endif +#endif /* NL_NO_EXCEPTION_SPECS */ -#endif +#endif /* NL_USE_ALIGNED_MEMORY_OPERATORS */ #else /* NL_HAS_SSE2 */ diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index db605f4f1..599f3cfb2 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -80,7 +80,7 @@ extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource ); } #endif // !NL_COMP_MINGW -#if defined(NL_HAS_SSE2) && !defined(NL_CPU_X86_64) +#ifdef NL_USE_ALIGNED_MEMORY_OPERATORS #ifdef NL_NO_EXCEPTION_SPECS void *operator new(size_t size) From dcaf417aeea1d778444671eedb635f6d927ed69f Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 9 Aug 2018 14:34:28 +0200 Subject: [PATCH 37/65] Changed: Minor changes --HG-- branch : develop --- code/nel/src/3d/water_height_map.cpp | 2 +- code/ryzom/server/src/ai_service/event_reaction.h | 2 +- code/ryzom/server/src/ai_service/event_reaction_include.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/nel/src/3d/water_height_map.cpp b/code/nel/src/3d/water_height_map.cpp index 5f67ffce3..6fe88a8bc 100644 --- a/code/nel/src/3d/water_height_map.cpp +++ b/code/nel/src/3d/water_height_map.cpp @@ -677,7 +677,7 @@ void CWaterHeightMap::setWaves(float intensity, float period, uint radius, bool void CWaterHeightMap::serial(NLMISC::IStream &f) { f.xmlPushBegin("WaterHeightMap"); - f.xmlSetAttrib ("NAME") ; + f.xmlSetAttrib ("NAME"); f.serial (_Name); f.xmlPushEnd(); (void)f.serialVersion(0); diff --git a/code/ryzom/server/src/ai_service/event_reaction.h b/code/ryzom/server/src/ai_service/event_reaction.h index 1f92d3047..57dcf22d0 100644 --- a/code/ryzom/server/src/ai_service/event_reaction.h +++ b/code/ryzom/server/src/ai_service/event_reaction.h @@ -90,7 +90,7 @@ public: // the following routine shouldn't be needed it should be superceded by a better alternative // in the event manager template - bool testCompatibility(CStateInstance *const stateInstance, const TState *const state) const; + bool testCompatibility(const CStateInstance *stateInstance, const TState *state) const protected: // protected data --------------------------------------------------- diff --git a/code/ryzom/server/src/ai_service/event_reaction_include.h b/code/ryzom/server/src/ai_service/event_reaction_include.h index 3c44b03dc..04fd2c16f 100644 --- a/code/ryzom/server/src/ai_service/event_reaction_include.h +++ b/code/ryzom/server/src/ai_service/event_reaction_include.h @@ -28,7 +28,7 @@ #include "continent.h"*/ template -bool CAIEventReaction::testCompatibility(CStateInstance *const stateInstance, const TState *const state) const +bool CAIEventReaction::testCompatibility(const CStateInstance *stateInstance, const TState *state) const { if (!stateInstance) return false; From 184d3698c99c41d8c51477a50436134c6951a9fa Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 9 Aug 2018 19:38:33 +0200 Subject: [PATCH 38/65] Fixed: Warnings, throw(type) deprecated in C++11 and removed in C++17 --HG-- branch : develop --- code/nel/include/nel/net/module.h | 15 ++++----------- code/nel/include/nel/net/module_socket.h | 22 ++++++---------------- code/nel/src/net/module.cpp | 1 - code/nel/src/net/module_gateway.cpp | 3 +-- code/nel/src/net/module_local_gateway.cpp | 4 +--- 5 files changed, 12 insertions(+), 33 deletions(-) diff --git a/code/nel/include/nel/net/module.h b/code/nel/include/nel/net/module.h index 05cd48fed..803fe458c 100644 --- a/code/nel/include/nel/net/module.h +++ b/code/nel/include/nel/net/module.h @@ -213,18 +213,14 @@ namespace NLNET * Note that a module can be plugged in several socket at the same * time, but not twice in the same socket. */ - virtual void plugModule(IModuleSocket *moduleSocket) - throw (EModuleAlreadyPluggedHere) - =0; + virtual void plugModule(IModuleSocket *moduleSocket) =0; /** Unplug this module from the specified socket. * Note that a module can be plugged in several socket at the same * time, but not twice in the same socket. * Throw an exception if the socket is not currently plug into * the specified socket. */ - virtual void unplugModule(IModuleSocket *moduleSocket) - throw (EModuleNotPluggedHere) - =0; + virtual void unplugModule(IModuleSocket *moduleSocket) =0; /** Fill resultList vector with the list of socket into * witch this module is currently plugged. * This method don't clear the result vector before filling it. @@ -448,9 +444,7 @@ namespace NLNET * This method do the job of finding a valid socket to effectively send * the message. */ - virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotReachable) - =0; + virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message) =0; /** Return the first item of the security item list * If no security data are available, the method @@ -879,8 +873,7 @@ namespace NLNET /** Send a message to the module. */ - virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotReachable); + virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message); virtual const TSecurityData *getFirstSecurityData() const { diff --git a/code/nel/include/nel/net/module_socket.h b/code/nel/include/nel/net/module_socket.h index f4bad56d4..a60836656 100644 --- a/code/nel/include/nel/net/module_socket.h +++ b/code/nel/include/nel/net/module_socket.h @@ -42,15 +42,11 @@ namespace NLNET * If the destination module is not accessible through this socket, * an exception is thrown. */ - virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotPluggedHere) - =0; + virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) =0; /** A plugged module send a message to all the module reachable * with this socket. */ - virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotPluggedHere) - =0; + virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) =0; /** Fill the resultList with the list of module that are * reachable with this socket. @@ -95,21 +91,15 @@ namespace NLNET virtual void _onModulePlugged(const TModulePtr &pluggedModule); virtual void _onModuleUnplugged(const TModulePtr &pluggedModule); - virtual void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotPluggedHere, NLNET::EModuleNotReachable) - =0; + virtual void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) =0; - virtual void _broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotPluggedHere) - =0; + virtual void _broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) =0; - virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotPluggedHere); + virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message); /** A plugged module send a message to all the module reachable * with this socket. */ - virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotPluggedHere); + virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message); }; diff --git a/code/nel/src/net/module.cpp b/code/nel/src/net/module.cpp index b5707fea3..23f618973 100644 --- a/code/nel/src/net/module.cpp +++ b/code/nel/src/net/module.cpp @@ -867,7 +867,6 @@ namespace NLNET } void CModuleProxy::sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotReachable) { H_AUTO(CModuleProxy_sendModuleMessage); diff --git a/code/nel/src/net/module_gateway.cpp b/code/nel/src/net/module_gateway.cpp index 81ba76859..0acb4375d 100644 --- a/code/nel/src/net/module_gateway.cpp +++ b/code/nel/src/net/module_gateway.cpp @@ -1560,8 +1560,7 @@ namespace NLNET return getModuleName(); } - void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotReachable, EModuleNotPluggedHere) + void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) { // the socket implementation already checked that the module is plugged here // just check that the destination module effectively from here diff --git a/code/nel/src/net/module_local_gateway.cpp b/code/nel/src/net/module_local_gateway.cpp index 3446c0663..292a6cafe 100644 --- a/code/nel/src/net/module_local_gateway.cpp +++ b/code/nel/src/net/module_local_gateway.cpp @@ -364,8 +364,7 @@ namespace NLNET return getModuleName(); } - void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotReachable, EModuleNotPluggedHere) + void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) { TModuleProxies::TAToBMap::const_iterator first(_ModuleProxies.getAToBMap().begin()), last(_ModuleProxies.getAToBMap().end()); for (; first != last && first->first->getModuleProxyId() != destModuleProxyId; ++first) {} @@ -373,7 +372,6 @@ namespace NLNET throw EModuleNotReachable(); } virtual void _broadcastModuleMessage(IModule * /* senderModule */, const NLNET::CMessage &/* message */) - throw (EModuleNotPluggedHere) { nlstop; } From c13b758be9215c1d1a936134af0d2bd8a25bfd02 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 9 Aug 2018 19:47:44 +0200 Subject: [PATCH 39/65] Fixed: Warnings, throw(type) deprecated in C++11 and removed in C++17 --HG-- branch : develop --- code/nel/include/nel/net/module.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/code/nel/include/nel/net/module.h b/code/nel/include/nel/net/module.h index 803fe458c..790a49199 100644 --- a/code/nel/include/nel/net/module.h +++ b/code/nel/include/nel/net/module.h @@ -261,9 +261,7 @@ namespace NLNET * The call is blocking until receptions of the operation * result message (or detection of the dest module module is down) */ - virtual void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) - throw (EInvokeFailed) - =0; + virtual void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) =0; //@} From 91fa4d3f5fba8884d5494c41ce096516e9793fcc Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 9 Aug 2018 19:54:08 +0200 Subject: [PATCH 40/65] Fixed: Warnings, throw(type) deprecated in C++11 and removed in C++17 --HG-- branch : develop --- code/nel/src/net/module_socket.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/code/nel/src/net/module_socket.cpp b/code/nel/src/net/module_socket.cpp index 068567761..6ea16e8d6 100644 --- a/code/nel/src/net/module_socket.cpp +++ b/code/nel/src/net/module_socket.cpp @@ -85,8 +85,7 @@ namespace NLNET _PluggedModules.removeWithB(pluggedModule); } - void CModuleSocket::sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotPluggedHere) + void CModuleSocket::sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) { TPluggedModules::TBToAMap::const_iterator it(_PluggedModules.getBToAMap().find(senderModule)); if (it == _PluggedModules.getBToAMap().end()) @@ -100,7 +99,6 @@ namespace NLNET } void CModuleSocket::broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotPluggedHere) { TPluggedModules::TBToAMap::const_iterator it(_PluggedModules.getBToAMap().find(senderModule)); if (it == _PluggedModules.getBToAMap().end()) From d32877ddc98f3349612c029b0918184b82f05b55 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 10 Aug 2018 16:00:43 +0300 Subject: [PATCH 41/65] Changed: Keep track of style states in a single struct --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 86 ++---- code/nel/src/gui/group_html.cpp | 366 +++++++++++--------------- 2 files changed, 175 insertions(+), 277 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 35ba3e40e..0ccd227b7 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -505,78 +505,32 @@ namespace NLGUI // IL mode bool _LI; - // Current text color - std::vector _TextColor; - inline const NLMISC::CRGBA &getTextColor() const + // Current active style + CStyleParams _Style; + // Default style + CStyleParams _StyleDefault; + // Nested style stack + std::vector _StyleParams; + inline void pushStyle() { - if (_TextColor.empty()) - return TextColor; - return _TextColor.back(); + _StyleParams.push_back(_Style); + } + inline void popStyle() + { + if (_StyleParams.empty()) + _Style = _StyleDefault; + else + { + _Style = _StyleParams.back(); + _StyleParams.pop_back(); + } } - // Current global color flag - std::vector _GlobalColor; - inline bool getGlobalColor() const - { - if (_GlobalColor.empty()) - return false; - return _GlobalColor.back(); - } - - // Current font name - std::vector _FontFamily; - inline const char* getFontFamily() const - { - if (_FontFamily.empty()) - return ""; - return _FontFamily.back().c_str(); - } - - // Current font size - std::vector _FontSize; - inline uint getFontSize() const - { - if (_FontSize.empty()) - return TextFontSize; - return _FontSize.back(); - } inline uint getFontSizeSmaller() const { - if (getFontSize() < 5) + if (_Style.FontSize < 5) return 3; - return getFontSize()-2; - } - - std::vector _FontWeight; - inline uint getFontWeight() const - { - if (_FontWeight.empty()) - return 400; - return _FontWeight.back(); - } - - std::vector _FontOblique; - inline bool getFontOblique() const - { - if (_FontOblique.empty()) - return false; - return _FontOblique.back(); - } - - std::vector _FontUnderlined; - inline bool getFontUnderlined() const - { - if (_FontUnderlined.empty()) - return false; - return _FontUnderlined.back(); - } - - std::vector _FontStrikeThrough; - inline bool getFontStrikeThrough() const - { - if (_FontStrikeThrough.empty()) - return false; - return _FontStrikeThrough.back(); + return _Style.FontSize-2; } // Current link diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 9c022934a..46a32fb13 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1485,23 +1485,14 @@ namespace NLGUI { registerAnchorName(MY_HTML_A); - CStyleParams style; - style.FontFamily = getFontFamily(); - style.FontSize = getFontSize(); - style.TextColor = LinkColor; - style.Underlined = true; - style.StrikeThrough = getFontStrikeThrough(); - style.GlobalColor = LinkColorGlobalColor; + pushStyle(); + _Style.TextColor = LinkColor; + _Style.Underlined = true; + _Style.GlobalColor = LinkColorGlobalColor; if (present[HTML_A_STYLE] && value[HTML_A_STYLE]) - getStyleParams(value[HTML_A_STYLE], style); + getStyleParams(value[HTML_A_STYLE], _Style); - _FontFamily.push_back(style.FontFamily); - _FontSize.push_back(style.FontSize); - _TextColor.push_back(style.TextColor); - _FontUnderlined.push_back(style.Underlined); - _FontStrikeThrough.push_back(style.StrikeThrough); - _GlobalColor.push_back(style.GlobalColor); _A.push_back(true); _Link.push_back (""); _LinkTitle.push_back(""); @@ -1625,30 +1616,19 @@ namespace NLGUI break; case HTML_FONT: { - bool found = false; + pushStyle(); if (present[HTML_FONT_COLOR] && value[HTML_FONT_COLOR]) { CRGBA color; if (scanHTMLColor(value[HTML_FONT_COLOR], color)) - { - _TextColor.push_back(color); - found = true; - } - } - if (!found) - { - _TextColor.push_back(_TextColor.empty() ? CRGBA::White : _TextColor.back()); + _Style.TextColor = color; } if (present[HTML_FONT_SIZE] && value[HTML_FONT_SIZE]) { uint fontsize; fromString(value[HTML_FONT_SIZE], fontsize); - _FontSize.push_back(fontsize); - } - else - { - _FontSize.push_back(_FontSize.empty() ? TextFontSize : _FontSize.back()); + _Style.FontSize = fontsize; } } break; @@ -1720,46 +1700,64 @@ namespace NLGUI } break; case HTML_H1: - registerAnchorName(MY_HTML_H1); - newParagraph(PBeginSpace); - _FontSize.push_back(H1FontSize); - _TextColor.push_back(H1Color); - _GlobalColor.push_back(H1ColorGlobalColor); + { + registerAnchorName(MY_HTML_H1); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H1FontSize; + _Style.TextColor = H1Color; + _Style.GlobalColor = H1ColorGlobalColor; + } break; case HTML_H2: - registerAnchorName(MY_HTML_H2); - newParagraph(PBeginSpace); - _FontSize.push_back(H2FontSize); - _TextColor.push_back(H2Color); - _GlobalColor.push_back(H2ColorGlobalColor); + { + registerAnchorName(MY_HTML_H2); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H2FontSize; + _Style.TextColor = H2Color; + _Style.GlobalColor = H2ColorGlobalColor; + } break; case HTML_H3: - registerAnchorName(MY_HTML_H3); - newParagraph(PBeginSpace); - _FontSize.push_back(H3FontSize); - _TextColor.push_back(H3Color); - _GlobalColor.push_back(H3ColorGlobalColor); + { + registerAnchorName(MY_HTML_H3); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H3FontSize; + _Style.TextColor = H3Color; + _Style.GlobalColor = H3ColorGlobalColor; + } break; case HTML_H4: - registerAnchorName(MY_HTML_H4); - newParagraph(PBeginSpace); - _FontSize.push_back(H4FontSize); - _TextColor.push_back(H4Color); - _GlobalColor.push_back(H4ColorGlobalColor); + { + registerAnchorName(MY_HTML_H4); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H4FontSize; + _Style.TextColor = H4Color; + _Style.GlobalColor = H4ColorGlobalColor; + } break; case HTML_H5: - registerAnchorName(MY_HTML_H5); - newParagraph(PBeginSpace); - _FontSize.push_back(H5FontSize); - _TextColor.push_back(H5Color); - _GlobalColor.push_back(H5ColorGlobalColor); + { + registerAnchorName(MY_HTML_H5); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H5FontSize; + _Style.TextColor = H5Color; + _Style.GlobalColor = H5ColorGlobalColor; + } break; case HTML_H6: - registerAnchorName(MY_HTML_H6); - newParagraph(PBeginSpace); - _FontSize.push_back(H6FontSize); - _TextColor.push_back(H6Color); - _GlobalColor.push_back(H6ColorGlobalColor); + { + registerAnchorName(MY_HTML_H6); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H6FontSize; + _Style.TextColor = H6Color; + _Style.GlobalColor = H6ColorGlobalColor; + } break; case HTML_IMG: { @@ -1857,15 +1855,15 @@ namespace NLGUI if (present[MY_HTML_INPUT_TYPE] && value[MY_HTML_INPUT_TYPE]) { // by default not inherited, font family defaults to system font - CStyleParams style; - style.TextColor = TextColor; - style.FontSize = TextFontSize; - style.FontWeight = FONT_WEIGHT_NORMAL; - style.FontOblique = false; + pushStyle(); + _Style.TextColor = TextColor; + _Style.FontSize = TextFontSize; + _Style.FontWeight = FONT_WEIGHT_NORMAL; + _Style.FontOblique = false; // Global color flag if (present[MY_HTML_INPUT_GLOBAL_COLOR]) - style.GlobalColor = true; + _Style.GlobalColor = true; // Tooltip const char *tooltip = NULL; @@ -1873,13 +1871,7 @@ namespace NLGUI tooltip = value[MY_HTML_INPUT_ALT]; if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE]) - getStyleParams(value[MY_HTML_INPUT_STYLE], style); - - _TextColor.push_back(style.TextColor); - _FontFamily.push_back(style.FontFamily); - _FontSize.push_back(style.FontSize); - _FontWeight.push_back(style.FontWeight); - _FontOblique.push_back(style.FontOblique); + getStyleParams(value[MY_HTML_INPUT_STYLE], _Style); string type = toLower(value[MY_HTML_INPUT_TYPE]); if (type == "image") @@ -1899,7 +1891,7 @@ namespace NLGUI // Add the ctrl button addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over, - "html_submit_form", param.c_str(), tooltip, style); + "html_submit_form", param.c_str(), tooltip, _Style); } if (type == "button" || type == "submit") { @@ -1954,7 +1946,7 @@ namespace NLGUI if (!ctrlButton) ctrlButton = dynamic_cast(buttonGroup->getCtrl("b")); if (ctrlButton) { - ctrlButton->setModulateGlobalColorAll (style.GlobalColor); + ctrlButton->setModulateGlobalColorAll (_Style.GlobalColor); // Translate the tooltip if (tooltip) @@ -2037,7 +2029,7 @@ namespace NLGUI checked = (present[MY_HTML_INPUT_CHECKED] && value[MY_HTML_INPUT_CHECKED]); // Add the ctrl button - CCtrlButton *checkbox = addButton (btnType, name, normal, pushed, over, "", "", tooltip, style); + CCtrlButton *checkbox = addButton (btnType, name, normal, pushed, over, "", "", tooltip, _Style); if (checkbox) { if (btnType == CCtrlButton::RadioButton) @@ -2091,11 +2083,7 @@ namespace NLGUI } } - popIfNotEmpty(_FontFamily); - popIfNotEmpty(_FontSize); - popIfNotEmpty(_TextColor); - popIfNotEmpty(_FontWeight); - popIfNotEmpty(_FontOblique); + popStyle(); } } break; @@ -2210,25 +2198,12 @@ namespace NLGUI break; case HTML_PRE: { - CStyleParams style; - style.TextColor = getTextColor(); - style.FontFamily = "monospace"; - style.FontSize = getFontSize(); - style.FontWeight = getFontWeight(); - style.FontOblique = getFontOblique(); - style.Underlined = getFontUnderlined(); - style.StrikeThrough = getFontStrikeThrough(); + pushStyle(); + _Style.FontFamily = "monospace"; if (present[HTML_PRE_STYLE] && value[HTML_PRE_STYLE]) - getStyleParams(value[HTML_PRE_STYLE], style); + getStyleParams(value[HTML_PRE_STYLE], _Style); - _TextColor.push_back(style.TextColor); - _FontFamily.push_back(style.FontFamily); - _FontSize.push_back(style.FontSize); - _FontWeight.push_back(style.FontWeight); - _FontOblique.push_back(style.FontOblique); - _FontUnderlined.push_back(style.Underlined); - _FontStrikeThrough.push_back(style.StrikeThrough); _PRE.push_back(true); } @@ -2274,7 +2249,8 @@ namespace NLGUI if (element_number == HTML_TH) { - _FontWeight.push_back(FONT_WEIGHT_BOLD); + pushStyle(); + _Style.FontWeight = FONT_WEIGHT_BOLD; // center if not specified otherwise. TD/TH present/value arrays have same indices if (!(present[MY_HTML_TD_ALIGN] && value[MY_HTML_TD_ALIGN])) _CellParams.back().Align = CGroupCell::Center; @@ -2365,20 +2341,14 @@ namespace NLGUI if (!(_Forms.empty())) { // not inherited by default, font family defaults to system font - CStyleParams style; - style.TextColor = TextColor; - style.FontWeight = FONT_WEIGHT_NORMAL; - style.FontOblique = false; - style.FontSize = TextFontSize; + pushStyle(); + _Style.TextColor = TextColor; + _Style.FontWeight = FONT_WEIGHT_NORMAL; + _Style.FontOblique = false; + _Style.FontSize = TextFontSize; if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) - getStyleParams(value[MY_HTML_TEXTAREA_STYLE], style); - - _TextColor.push_back(style.TextColor); - _FontFamily.push_back(style.FontFamily); - _FontSize.push_back(style.FontSize); - _FontWeight.push_back(style.FontWeight); - _FontOblique.push_back(style.FontOblique); + getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); // read general property string templateName; @@ -2460,43 +2430,41 @@ namespace NLGUI break; case HTML_SPAN: { - CStyleParams style; - style.TextColor = getTextColor(); - style.FontFamily = getFontFamily(); - style.FontSize = getFontSize(); - style.FontWeight = getFontWeight(); - style.FontOblique = getFontOblique(); - style.Underlined = getFontUnderlined(); - style.StrikeThrough = getFontStrikeThrough(); - style.GlobalColor = getGlobalColor(); + pushStyle(); if (present[MY_HTML_SPAN_STYLE] && value[MY_HTML_SPAN_STYLE]) - getStyleParams(value[MY_HTML_SPAN_STYLE], style); - - _TextColor.push_back(style.TextColor); - _FontFamily.push_back(style.FontFamily); - _FontSize.push_back(style.FontSize); - _FontWeight.push_back(style.FontWeight); - _FontOblique.push_back(style.FontOblique); - _FontUnderlined.push_back(style.Underlined); - _FontStrikeThrough.push_back(style.StrikeThrough); - _GlobalColor.push_back(style.GlobalColor); + getStyleParams(value[MY_HTML_SPAN_STYLE], _Style); } break; case HTML_DEL: - _FontStrikeThrough.push_back(true); + { + pushStyle(); + _Style.StrikeThrough = true; + } break; case HTML_U: - _FontUnderlined.push_back(true); + { + pushStyle(); + _Style.Underlined = true; + } break; case HTML_EM: - _FontOblique.push_back(true); + { + pushStyle(); + _Style.FontOblique = true; + } break; case HTML_STRONG: - _FontWeight.push_back(FONT_WEIGHT_BOLD); + { + pushStyle(); + _Style.FontWeight = FONT_WEIGHT_BOLD; + } break; case HTML_SMALL: - _FontSize.push_back(getFontSizeSmaller()); + { + pushStyle(); + _Style.FontSize = getFontSizeSmaller(); + } break; case HTML_STYLE: case HTML_SCRIPT: @@ -2521,7 +2489,8 @@ namespace NLGUI if (!_DL.back().DT) { _DL.back().DT = true; - _FontWeight.push_back(FONT_WEIGHT_BOLD); + pushStyle(); + _Style.FontWeight = FONT_WEIGHT_BOLD; } if (!_LI) @@ -2542,7 +2511,7 @@ namespace NLGUI if (_DL.back().DT) { _DL.back().DT = false; - popIfNotEmpty (_FontWeight); + popStyle(); } if (!_DL.back().DD) @@ -2633,16 +2602,10 @@ namespace NLGUI _ReadingHeadTag = false; break; case HTML_FONT: - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontSize); + popStyle(); break; case HTML_A: - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontUnderlined); - popIfNotEmpty (_FontStrikeThrough); - popIfNotEmpty (_GlobalColor); + popStyle(); popIfNotEmpty (_A); popIfNotEmpty (_Link); popIfNotEmpty (_LinkTitle); @@ -2654,22 +2617,14 @@ namespace NLGUI case HTML_H4: case HTML_H5: case HTML_H6: - popIfNotEmpty (_FontSize); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_GlobalColor); + popStyle(); endParagraph(); break; case HTML_P: endParagraph(); break; case HTML_PRE: - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_FontWeight); - popIfNotEmpty (_FontOblique); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontUnderlined); - popIfNotEmpty (_FontStrikeThrough); + popStyle(); popIfNotEmpty (_PRE); break; case HTML_DIV: @@ -2692,7 +2647,7 @@ namespace NLGUI // Add a cell break; case HTML_TH: - popIfNotEmpty (_FontWeight); + popStyle(); // no break; case HTML_TD: popIfNotEmpty (_CellParams); @@ -2717,11 +2672,7 @@ namespace NLGUI _Forms.back().Entries.push_back (entry); } - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_FontWeight); - popIfNotEmpty (_FontOblique); - popIfNotEmpty (_TextColor); + popStyle(); } popIfNotEmpty (_PRE); @@ -2843,7 +2794,7 @@ namespace NLGUI // unclosed DT if (_DL.back().DT) { - popIfNotEmpty (_FontWeight); + popStyle(); } // unclosed DD @@ -2859,7 +2810,7 @@ namespace NLGUI if (!_DL.empty()) { _DL.back().DT = false; - popIfNotEmpty (_FontWeight); + popStyle(); } break; case HTML_DD: @@ -2874,29 +2825,22 @@ namespace NLGUI } break; case HTML_SPAN: - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_FontWeight); - popIfNotEmpty (_FontOblique); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontUnderlined); - popIfNotEmpty (_FontStrikeThrough); - popIfNotEmpty (_GlobalColor); + popStyle(); break; case HTML_DEL: - popIfNotEmpty (_FontStrikeThrough); + popStyle(); break; case HTML_U: - popIfNotEmpty (_FontUnderlined); + popStyle(); break; case HTML_EM: - popIfNotEmpty (_FontOblique); + popStyle(); break; case HTML_STRONG: - popIfNotEmpty (_FontWeight); + popStyle(); break; case HTML_SMALL: - popIfNotEmpty (_FontSize); + popStyle(); break; case HTML_STYLE: case HTML_SCRIPT: @@ -4325,7 +4269,7 @@ namespace NLGUI // Text added ? bool added = false; - bool embolden = getFontWeight() >= FONT_WEIGHT_BOLD; + bool embolden = _Style.FontWeight >= FONT_WEIGHT_BOLD; // Number of child in this paragraph if (_CurrentViewLink) @@ -4333,15 +4277,15 @@ namespace NLGUI bool skipLine = !_CurrentViewLink->getText().empty() && *(_CurrentViewLink->getText().rbegin()) == (ucchar) '\n'; // Compatible with current parameters ? if (!skipLine && - (getTextColor() == _CurrentViewLink->getColor()) && - (getFontFamily() == _CurrentViewLink->getFontName()) && - (getFontSize() == (uint)_CurrentViewLink->getFontSize()) && - (getFontUnderlined() == _CurrentViewLink->getUnderlined()) && - (getFontStrikeThrough() == _CurrentViewLink->getStrikeThrough()) && + (_Style.TextColor == _CurrentViewLink->getColor()) && + (_Style.FontFamily == _CurrentViewLink->getFontName()) && + (_Style.FontSize == (uint)_CurrentViewLink->getFontSize()) && + (_Style.Underlined == _CurrentViewLink->getUnderlined()) && + (_Style.StrikeThrough == _CurrentViewLink->getStrikeThrough()) && (embolden == _CurrentViewLink->getEmbolden()) && - (getFontOblique() == _CurrentViewLink->getOblique()) && + (_Style.FontOblique == _CurrentViewLink->getOblique()) && (getLink() == _CurrentViewLink->Link) && - (getGlobalColor() == _CurrentViewLink->getModulateGlobalColor())) + (_Style.GlobalColor == _CurrentViewLink->getModulateGlobalColor())) { // Concat the text _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr); @@ -4401,16 +4345,16 @@ namespace NLGUI } } newLink->setText(tmpStr); - newLink->setColor(getTextColor()); - newLink->setFontName(getFontFamily()); - newLink->setFontSize(getFontSize()); + newLink->setColor(_Style.TextColor); + newLink->setFontName(_Style.FontFamily); + newLink->setFontSize(_Style.FontSize); newLink->setEmbolden(embolden); - newLink->setOblique(getFontOblique()); - newLink->setUnderlined(getFontUnderlined()); - newLink->setStrikeThrough(getFontStrikeThrough()); - newLink->setMultiLineSpace((uint)((float)getFontSize()*LineSpaceFontFactor)); + newLink->setOblique(_Style.FontOblique); + newLink->setUnderlined(_Style.Underlined); + newLink->setStrikeThrough(_Style.StrikeThrough); + newLink->setMultiLineSpace((uint)((float)(_Style.FontSize)*LineSpaceFontFactor)); newLink->setMultiLine(true); - newLink->setModulateGlobalColor(getGlobalColor()); + newLink->setModulateGlobalColor(_Style.GlobalColor); // newLink->setLineAtBottom (true); registerAnchor(newLink); @@ -4517,15 +4461,15 @@ namespace NLGUI { // Not added ? std::vector > templateParams; - templateParams.push_back (std::pair ("w", toString (cols*getFontSize()))); + templateParams.push_back (std::pair ("w", toString (cols*_Style.FontSize))); templateParams.push_back (std::pair ("id", name)); templateParams.push_back (std::pair ("prompt", "")); templateParams.push_back (std::pair ("multiline", multiLine?"true":"false")); - templateParams.push_back (std::pair ("fontsize", toString (getFontSize()))); - templateParams.push_back (std::pair ("color", getTextColor().toString())); - if (getFontWeight() >= FONT_WEIGHT_BOLD) + templateParams.push_back (std::pair ("fontsize", toString (_Style.FontSize))); + templateParams.push_back (std::pair ("color", _Style.TextColor.toString())); + if (_Style.FontWeight >= FONT_WEIGHT_BOLD) templateParams.push_back (std::pair ("fontweight", "bold")); - if (getFontOblique()) + if (_Style.FontOblique) templateParams.push_back (std::pair ("fontstyle", "oblique")); if (multiLine) templateParams.push_back (std::pair ("multi_min_line", toString(rows))); @@ -4767,13 +4711,6 @@ namespace NLGUI { _Paragraph = NULL; _PRE.clear(); - _TextColor.clear(); - _GlobalColor.clear(); - _FontSize.clear(); - _FontWeight.clear(); - _FontOblique.clear(); - _FontUnderlined.clear(); - _FontStrikeThrough.clear(); _Indent.clear(); _LI = false; _UL.clear(); @@ -4797,6 +4734,11 @@ namespace NLGUI _IgnoreHeadTag = false; _IgnoreBaseUrlTag = false; + // reset style + _StyleDefault = CStyleParams(); + _Style = _StyleDefault; + _StyleParams.clear(); + // TR paragraphChange (); @@ -6118,6 +6060,8 @@ namespace NLGUI // style.StrikeThrough; // text-decoration: line-through; text-decoration-line: line-through; void CGroupHTML::getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit) { + const CStyleParams current = _Style; + float tmpf; TStyle styles = parseStyle(styleString); TStyle::iterator it; @@ -6126,7 +6070,7 @@ namespace NLGUI if (it->first == "font-size") { if (it->second == "inherit") - style.FontSize = getFontSize(); + style.FontSize = current.FontSize; else { float tmp; @@ -6140,7 +6084,7 @@ namespace NLGUI if (it->first == "font-style") { if (it->second == "inherit") - style.FontOblique = getFontOblique(); + style.FontOblique = current.FontOblique; else if (it->second == "italic" || it->second == "oblique") style.FontOblique = true; @@ -6149,7 +6093,7 @@ namespace NLGUI if (it->first == "font-family") { if (it->second == "inherit") - style.FontFamily = getFontFamily(); + style.FontFamily = current.FontFamily; else if (it->second == "monospace") style.FontFamily = "monospace"; @@ -6162,7 +6106,7 @@ namespace NLGUI // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight uint weight = 400; if (it->second == "inherit") - weight = getFontWeight(); + weight = current.FontWeight; else if (it->second == "normal") weight = 400; @@ -6173,7 +6117,7 @@ namespace NLGUI if (it->second == "lighter") { const uint lighter[] = {100, 100, 100, 100, 100, 400, 400, 700, 700}; - uint index = getFontWeight() / 100 - 1; + uint index = current.FontWeight / 100 - 1; clamp(index, 1u, 9u); weight = lighter[index-1]; } @@ -6181,7 +6125,7 @@ namespace NLGUI if (it->second == "bolder") { const uint bolder[] = {400, 400, 400, 700, 700, 900, 900, 900, 900}; - uint index = getFontWeight() / 100 + 1; + uint index = current.FontWeight / 100 + 1; clamp(index, 1u, 9u); weight = bolder[index-1]; } @@ -6197,7 +6141,7 @@ namespace NLGUI else if (it->first == "color") if (it->second == "inherit") - style.TextColor = getTextColor(); + style.TextColor = current.TextColor; else scanHTMLColor(it->second.c_str(), style.TextColor); else @@ -6224,7 +6168,7 @@ namespace NLGUI { bool b; if (it->second == "inherit") - style.GlobalColor = getGlobalColor(); + style.GlobalColor = current.GlobalColor; else if (fromString(it->second, b)) style.GlobalColor = b; @@ -6232,8 +6176,8 @@ namespace NLGUI } if (inherit) { - style.Underlined = getFontUnderlined() || style.Underlined; - style.StrikeThrough = getFontStrikeThrough() || style.StrikeThrough; + style.Underlined = current.Underlined || style.Underlined; + style.StrikeThrough = current.StrikeThrough || style.StrikeThrough; } } From 1525b03a83321bd207c8171757208d25d1c3ff95 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 11 Aug 2018 09:59:01 +0300 Subject: [PATCH 42/65] Changed: Extend style attribute to other tags --HG-- branch : develop --- code/nel/include/nel/gui/libwww.h | 1 + code/nel/src/gui/group_html.cpp | 145 +++++++++++++++++++++++------- code/nel/src/gui/libwww.cpp | 1 + 3 files changed, 113 insertions(+), 34 deletions(-) diff --git a/code/nel/include/nel/gui/libwww.h b/code/nel/include/nel/gui/libwww.h index 0825779f2..892e07eb2 100644 --- a/code/nel/include/nel/gui/libwww.h +++ b/code/nel/include/nel/gui/libwww.h @@ -102,6 +102,7 @@ namespace NLGUI HTML_ATTR(TR,L_MARGIN), HTML_ATTR(TR,NOWRAP), HTML_ATTR(TR,VALIGN), + HTML_ATTR(TR,STYLE), }; enum diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 46a32fb13..970178947 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1530,6 +1530,7 @@ namespace NLGUI { _BlockLevelElement.push_back(true); registerAnchorName(MY_HTML_DIV); + pushStyle(); if (present[MY_HTML_DIV_NAME] && value[MY_HTML_DIV_NAME]) _DivName = value[MY_HTML_DIV_NAME]; @@ -1538,6 +1539,13 @@ namespace NLGUI if (present[MY_HTML_DIV_CLASS] && value[MY_HTML_DIV_CLASS]) instClass = value[MY_HTML_DIV_CLASS]; + string style; + if (present[MY_HTML_DIV_STYLE] && value[MY_HTML_DIV_STYLE]) + style = value[MY_HTML_DIV_STYLE]; + + if (!style.empty()) + getStyleParams(style, _Style); + // use generic template system if (_TrustedDomain && !instClass.empty() && instClass == "ryzom-ui-grouptemplate") { @@ -1545,10 +1553,6 @@ namespace NLGUI if (present[MY_HTML_DIV_ID] && value[MY_HTML_DIV_ID]) id = value[MY_HTML_DIV_ID]; - string style; - if (present[MY_HTML_DIV_STYLE] && value[MY_HTML_DIV_STYLE]) - style = value[MY_HTML_DIV_STYLE]; - typedef pair TTmplParam; vector tmplParams; @@ -1679,6 +1683,10 @@ namespace NLGUI image = image.substr(4, image.size()-5); setBackground (image, scale, repeat); } + + // set default text style from + getStyleParams(style, _StyleDefault); + _Style = _StyleDefault; } } break; @@ -1707,6 +1715,8 @@ namespace NLGUI _Style.FontSize = H1FontSize; _Style.TextColor = H1Color; _Style.GlobalColor = H1ColorGlobalColor; + if (present[MY_HTML_H1_STYLE] && value[MY_HTML_H1_STYLE]) + getStyleParams(value[MY_HTML_H1_STYLE], _Style); } break; case HTML_H2: @@ -1717,6 +1727,8 @@ namespace NLGUI _Style.FontSize = H2FontSize; _Style.TextColor = H2Color; _Style.GlobalColor = H2ColorGlobalColor; + if (present[MY_HTML_H2_STYLE] && value[MY_HTML_H2_STYLE]) + getStyleParams(value[MY_HTML_H2_STYLE], _Style); } break; case HTML_H3: @@ -1727,6 +1739,8 @@ namespace NLGUI _Style.FontSize = H3FontSize; _Style.TextColor = H3Color; _Style.GlobalColor = H3ColorGlobalColor; + if (present[MY_HTML_H3_STYLE] && value[MY_HTML_H3_STYLE]) + getStyleParams(value[MY_HTML_H3_STYLE], _Style); } break; case HTML_H4: @@ -1737,6 +1751,8 @@ namespace NLGUI _Style.FontSize = H4FontSize; _Style.TextColor = H4Color; _Style.GlobalColor = H4ColorGlobalColor; + if (present[MY_HTML_H4_STYLE] && value[MY_HTML_H4_STYLE]) + getStyleParams(value[MY_HTML_H4_STYLE], _Style); } break; case HTML_H5: @@ -1747,6 +1763,8 @@ namespace NLGUI _Style.FontSize = H5FontSize; _Style.TextColor = H5Color; _Style.GlobalColor = H5ColorGlobalColor; + if (present[MY_HTML_H5_STYLE] && value[MY_HTML_H5_STYLE]) + getStyleParams(value[MY_HTML_H5_STYLE], _Style); } break; case HTML_H6: @@ -1757,6 +1775,8 @@ namespace NLGUI _Style.FontSize = H6FontSize; _Style.TextColor = H6Color; _Style.GlobalColor = H6ColorGlobalColor; + if (present[MY_HTML_H6_STYLE] && value[MY_HTML_H6_STYLE]) + getStyleParams(value[MY_HTML_H6_STYLE], _Style); } break; case HTML_IMG: @@ -2177,6 +2197,10 @@ namespace NLGUI if (present[HTML_LI_VALUE] && value[HTML_LI_VALUE]) fromString(value[HTML_LI_VALUE], _UL.back().Value); + pushStyle(); + if (present[HTML_LI_STYLE] && value[HTML_LI_STYLE]) + getStyleParams(value[HTML_LI_STYLE], _Style); + ucstring str; str.fromUtf8(_UL.back().getListMarkerText()); addString (str); @@ -2194,7 +2218,12 @@ namespace NLGUI } break; case HTML_P: - newParagraph(PBeginSpace); + { + newParagraph(PBeginSpace); + pushStyle(); + if (present[HTML_BLOCK_STYLE] && value[HTML_BLOCK_STYLE]) + getStyleParams(value[HTML_BLOCK_STYLE], _Style); + } break; case HTML_PRE: { @@ -2210,6 +2239,7 @@ namespace NLGUI break; case HTML_TABLE: { + pushStyle(); registerAnchorName(MY_HTML_TABLE); // Get cells parameters @@ -2228,6 +2258,8 @@ namespace NLGUI fromString(value[MY_HTML_TABLE_CELLSPACING], table->CellSpacing); if (present[MY_HTML_TABLE_CELLPADDING] && value[MY_HTML_TABLE_CELLPADDING]) fromString(value[MY_HTML_TABLE_CELLPADDING], table->CellPadding); + if (present[MY_HTML_TABLE_STYLE] && value[MY_HTML_TABLE_STYLE]) + getStyleParams(value[MY_HTML_TABLE_STYLE], _Style); table->setMarginLeft(getIndent()); addHtmlGroup (table, 0); @@ -2247,15 +2279,18 @@ namespace NLGUI // Get cells parameters getCellsParameters (MY_HTML_TD, true); + pushStyle(); if (element_number == HTML_TH) { - pushStyle(); _Style.FontWeight = FONT_WEIGHT_BOLD; // center if not specified otherwise. TD/TH present/value arrays have same indices if (!(present[MY_HTML_TD_ALIGN] && value[MY_HTML_TD_ALIGN])) _CellParams.back().Align = CGroupCell::Center; } + if (present[MY_HTML_TD_STYLE] && value[MY_HTML_TD_STYLE]) + getStyleParams(value[MY_HTML_TD_STYLE], _Style); + CGroupTable *table = getTable(); if (table) { @@ -2335,21 +2370,21 @@ namespace NLGUI } break; case HTML_TEXTAREA: + pushStyle(); _PRE.push_back(true); + // not inherited by default, font family defaults to system font + _Style.TextColor = TextColor; + _Style.FontWeight = FONT_WEIGHT_NORMAL; + _Style.FontOblique = false; + _Style.FontSize = TextFontSize; + + if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) + getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); + // Got one form ? if (!(_Forms.empty())) { - // not inherited by default, font family defaults to system font - pushStyle(); - _Style.TextColor = TextColor; - _Style.FontWeight = FONT_WEIGHT_NORMAL; - _Style.FontOblique = false; - _Style.FontSize = TextFontSize; - - if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) - getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); - // read general property string templateName; @@ -2398,6 +2433,10 @@ namespace NLGUI // Set TR flag if (!_TR.empty()) _TR.back() = true; + + pushStyle(); + if (present[MY_HTML_TR_STYLE] && value[MY_HTML_TR_STYLE]) + getStyleParams(value[MY_HTML_TR_STYLE], _Style); } break; case HTML_UL: @@ -2411,6 +2450,10 @@ namespace NLGUI _LI = _UL.size() > 1 || _DL.size() > 1; _Indent.push_back(getIndent() + ULIndent); endParagraph(); + + pushStyle(); + if (present[HTML_UL_STYLE] && value[HTML_UL_STYLE]) + getStyleParams(value[HTML_UL_STYLE], _Style); break; case HTML_OBJECT: _ObjectType.clear(); @@ -2471,27 +2514,36 @@ namespace NLGUI _IgnoreText = true; break; case HTML_DL: - _DL.push_back(HTMLDListElement()); - _LI = _DL.size() > 1 || !_UL.empty(); - endParagraph(); + { + _DL.push_back(HTMLDListElement()); + _LI = _DL.size() > 1 || !_UL.empty(); + endParagraph(); + pushStyle(); + if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) + getStyleParams(value[HTML_GEN_STYLE], _Style); + } break; case HTML_DT: if (!_DL.empty()) { - // close DT if still open + // close if still open if (_DL.back().DD) { _DL.back().DD = false; popIfNotEmpty(_Indent); + popStyle(); } - // see if this is the first
, closing tag not required - if (!_DL.back().DT) - { - _DL.back().DT = true; - pushStyle(); - _Style.FontWeight = FONT_WEIGHT_BOLD; - } + // close if still open + if (_DL.back().DT) + popStyle(); + + _DL.back().DT = true; + + pushStyle(); + _Style.FontWeight = FONT_WEIGHT_BOLD; + if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) + getStyleParams(value[HTML_GEN_STYLE], _Style); if (!_LI) { @@ -2514,12 +2566,20 @@ namespace NLGUI popStyle(); } - if (!_DL.back().DD) + if (_DL.back().DD) { - _DL.back().DD = true; - _Indent.push_back(getIndent() + ULIndent); + _DL.back().DD = false; + popStyle(); + popIfNotEmpty(_Indent); } + _DL.back().DD = true; + _Indent.push_back(getIndent() + ULIndent); + + pushStyle(); + if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) + getStyleParams(value[HTML_GEN_STYLE], _Style); + if (!_LI) { _LI = true; @@ -2533,6 +2593,7 @@ namespace NLGUI break; case HTML_OL: { + pushStyle(); sint32 start = 1; std::string type("1"); @@ -2540,6 +2601,8 @@ namespace NLGUI fromString(value[HTML_OL_START], start); if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE]) type = value[HTML_OL_TYPE]; + if (present[HTML_OL_STYLE] && value[HTML_OL_STYLE]) + getStyleParams(value[HTML_OL_STYLE], _Style); _UL.push_back(HTMLOListElement(start, type)); // if LI is already present @@ -2621,6 +2684,7 @@ namespace NLGUI endParagraph(); break; case HTML_P: + popStyle(); endParagraph(); break; case HTML_PRE: @@ -2628,6 +2692,7 @@ namespace NLGUI popIfNotEmpty (_PRE); break; case HTML_DIV: + popStyle(); if (isBlockLevelElement()) { endParagraph(); @@ -2638,6 +2703,7 @@ namespace NLGUI break; case HTML_TABLE: + popStyle(); popIfNotEmpty (_CellParams); popIfNotEmpty (_TR); popIfNotEmpty (_Cells); @@ -2647,14 +2713,15 @@ namespace NLGUI // Add a cell break; case HTML_TH: - popStyle(); // no break; case HTML_TD: + popStyle(); popIfNotEmpty (_CellParams); if (!_Cells.empty()) _Cells.back() = NULL; break; case HTML_TR: + popStyle(); popIfNotEmpty (_CellParams); break; case HTML_TEXTAREA: @@ -2671,10 +2738,9 @@ namespace NLGUI entry.TextArea = textArea; _Forms.back().Entries.push_back (entry); } - - popStyle(); } + popStyle(); popIfNotEmpty (_PRE); } break; @@ -2782,10 +2848,16 @@ namespace NLGUI if (!_UL.empty()) { endParagraph(); + popStyle(); popIfNotEmpty(_UL); popIfNotEmpty(_Indent); } break; + case HTML_LI: + { + popStyle(); + } + break; case HTML_DL: if (!_DL.empty()) { @@ -2801,16 +2873,19 @@ namespace NLGUI if (_DL.back().DD) { popIfNotEmpty(_Indent); + popStyle(); } popIfNotEmpty (_DL); + popStyle(); } break; case HTML_DT: if (!_DL.empty()) { + if (_DL.back().DT) + popStyle(); _DL.back().DT = false; - popStyle(); } break; case HTML_DD: @@ -2821,6 +2896,7 @@ namespace NLGUI { _DL.back().DD = false; popIfNotEmpty(_Indent); + popStyle(); } } break; @@ -4477,6 +4553,7 @@ namespace NLGUI templateParams.push_back (std::pair ("enter_recover_focus", "false")); if (maxlength > 0) templateParams.push_back (std::pair ("max_num_chars", toString(maxlength))); + CInterfaceGroup *textArea = CWidgetManager::getInstance()->getParser()->createGroupInstance (templateName.c_str(), getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index c8b41a38f..fef3d788e 100644 --- a/code/nel/src/gui/libwww.cpp +++ b/code/nel/src/gui/libwww.cpp @@ -101,6 +101,7 @@ namespace NLGUI HTML_ATTR(TR,L_MARGIN), HTML_ATTR(TR,NOWRAP), HTML_ATTR(TR,VALIGN), + HTML_ATTR(TR,STYLE), { 0 } }; From 33f6b64bb999969eb15390ea6d9d1ffd44b89201 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 10 Aug 2018 14:09:34 +0300 Subject: [PATCH 43/65] Changed: Add text-shadow and text-stroke style properties --HG-- branch : develop --- code/nel/include/nel/3d/text_context.h | 110 +++++++------- code/nel/include/nel/3d/text_context_user.h | 2 +- code/nel/include/nel/3d/u_text_context.h | 2 +- code/nel/include/nel/gui/group_html.h | 28 +++- code/nel/include/nel/gui/view_text.h | 4 + code/nel/src/3d/text_context.cpp | 3 +- code/nel/src/3d/text_context_user.cpp | 4 +- code/nel/src/gui/group_html.cpp | 159 +++++++++++++++++++- code/nel/src/gui/view_text.cpp | 24 +++ 9 files changed, 276 insertions(+), 60 deletions(-) diff --git a/code/nel/include/nel/3d/text_context.h b/code/nel/include/nel/3d/text_context.h index 156ea9f79..a95916da4 100644 --- a/code/nel/include/nel/3d/text_context.h +++ b/code/nel/include/nel/3d/text_context.h @@ -88,7 +88,7 @@ public: void setShadeOutline (bool b) { _ShadeOutline = b; } - void setShadeExtent (float shext) { _ShadeExtent = shext; } + void setShadeExtent (float x, float y) { _ShadeExtentX = x; _ShadeExtentY = y; } /// The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255) void setShadeColor (NLMISC::CRGBA color) { _ShadeColor = color; } @@ -157,19 +157,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2D(*_Driver, x+rext, z-rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-rext, z-rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-rext, z+rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x+rext, z+rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x+_ShadeExtent, z, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-_ShadeExtent, z, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2D(*_Driver, x+rextX, z-rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-rextX, z-rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-rextX, z+rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+rextX, z+rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+_ShadeExtentX, z, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-_ShadeExtentX, z, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } else { - rCS.render2D(*_Driver, x+_ShadeExtent, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } rCS.Color= bkup; } @@ -190,19 +191,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2DClip(*_Driver, rdrBuffer, x+rext, z-rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-rext, z-rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-rext, z+rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x+rext, z+rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtent, z, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x, z+_ShadeExtent, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x, z-_ShadeExtent, xmin, ymin, xmax, ymax); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2DClip(*_Driver, rdrBuffer, x+rextX, z-rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-rextX, z-rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-rextX, z+rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+rextX, z+rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtentX, z, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtentX, z, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x, z+_ShadeExtentY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x, z-_ShadeExtentY, xmin, ymin, xmax, ymax); } else { - rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z-_ShadeExtent, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtentX, z-_ShadeExtentY, xmin, ymin, xmax, ymax); } rCS.Color= bkup; } @@ -223,19 +225,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rext, y-rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rext, y-rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rext, y+rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rext, y+rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtent, y, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y+_ShadeExtent, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rextX, y-rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rextX, y-rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rextX, y+rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rextX, y+rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtentX, y, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtentX, y, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y+_ShadeExtentY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y-_ShadeExtentY, depth, xmin, ymin, xmax, ymax); } else { - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtentX, y-_ShadeExtentY, depth, xmin, ymin, xmax, ymax); } rCS.Color= bkup; } @@ -258,19 +261,20 @@ public: _TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - _TempString.render2D(*_Driver,x+rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + _TempString.render2D(*_Driver,x+rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z+_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z-_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); } else { - _TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } _TempString.Color = bkup; } @@ -297,19 +301,20 @@ public: _TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - _TempString.render2D(*_Driver,x+rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + _TempString.render2D(*_Driver,x+rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z+_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z-_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); } else { - _TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } _TempString.Color = bkup; } @@ -412,7 +417,8 @@ private: bool _ShadeOutline; /// shade's extent (shadow size) - float _ShadeExtent; + float _ShadeExtentX; + float _ShadeExtentY; /// Shade color (default is black) NLMISC::CRGBA _ShadeColor; diff --git a/code/nel/include/nel/3d/text_context_user.h b/code/nel/include/nel/3d/text_context_user.h index b05238dbf..15e93c3f2 100644 --- a/code/nel/include/nel/3d/text_context_user.h +++ b/code/nel/include/nel/3d/text_context_user.h @@ -80,7 +80,7 @@ public: bool getShaded() const; void setShadeOutline(bool b); bool getShadeOutline() const; - void setShadeExtent(float shext) ; + void setShadeExtent(float x, float y); void setShadeColor (NLMISC::CRGBA sc); NLMISC::CRGBA getShadeColor () const; void setKeep800x600Ratio(bool keep); diff --git a/code/nel/include/nel/3d/u_text_context.h b/code/nel/include/nel/3d/u_text_context.h index 0aa9ea2f9..4c1dfea47 100644 --- a/code/nel/include/nel/3d/u_text_context.h +++ b/code/nel/include/nel/3d/u_text_context.h @@ -205,7 +205,7 @@ public: * set the shadow's size * \param the shade extent */ - virtual void setShadeExtent (float shext) = 0; + virtual void setShadeExtent (float x, float y) = 0; /** * set the shadow's color * The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 0ccd227b7..811cd3503 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -75,11 +75,26 @@ namespace NLGUI }; static SWebOptions options; - + + // text-shadow + struct STextShadow + { + public: + STextShadow(bool enabled = false, bool outline = false, sint32 x=1, sint32 y=1, NLMISC::CRGBA color=NLMISC::CRGBA::Black) + : Enabled(enabled), Outline(outline), X(x), Y(y), Color(color) + { } + + bool Enabled; + bool Outline; + sint32 X; + sint32 Y; + NLMISC::CRGBA Color; + }; + class CStyleParams { public: - CStyleParams () : FontFamily(""), TextColor(255,255,255,255) + CStyleParams () : FontFamily(""), TextColor(255,255,255,255), TextShadow() { FontSize=10; FontWeight=400; @@ -97,6 +112,7 @@ namespace NLGUI bool FontOblique; std::string FontFamily; NLMISC::CRGBA TextColor; + STextShadow TextShadow; bool GlobalColor; bool Underlined; bool StrikeThrough; @@ -595,6 +611,14 @@ namespace NLGUI return _TR.back(); } + std::vector _TextShadow; + inline STextShadow getTextShadow() const + { + if (_TextShadow.empty()) + return STextShadow(); + return _TextShadow.back(); + } + // Forms class CForm { diff --git a/code/nel/include/nel/gui/view_text.h b/code/nel/include/nel/gui/view_text.h index 8b8e1a7cf..cf53b5207 100644 --- a/code/nel/include/nel/gui/view_text.h +++ b/code/nel/include/nel/gui/view_text.h @@ -88,6 +88,7 @@ namespace NLGUI void setShadow (bool bShadow); void setShadowOutline (bool bShadowOutline); void setShadowColor (const NLMISC::CRGBA &color); + void setShadowOffset (sint x, sint y); void setLineMaxW (sint nMaxW, bool invalidate=true); void setMultiLine (bool bMultiLine); void setMultiLineSpace (sint nMultiLineSpace); @@ -112,6 +113,7 @@ namespace NLGUI bool getShadow() { return _Shadow; } bool getShadowOutline() { return _ShadowOutline; } NLMISC::CRGBA getShadowColor() { return _ShadowColor; } + void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; } sint getLineMaxW() const { return _LineMaxW; } bool getMultiLine() const { return _MultiLine; } sint getMultiLineSpace() const { return _MultiLineSpace; } @@ -247,6 +249,8 @@ namespace NLGUI /// the shadow mode bool _Shadow; bool _ShadowOutline; + sint32 _ShadowX; + sint32 _ShadowY; /// the case mode TCaseMode _CaseMode; /// the text shadow color diff --git a/code/nel/src/3d/text_context.cpp b/code/nel/src/3d/text_context.cpp index 8cee144ca..5fcc43daa 100644 --- a/code/nel/src/3d/text_context.cpp +++ b/code/nel/src/3d/text_context.cpp @@ -47,7 +47,8 @@ CTextContext::CTextContext() _Shaded = false; _ShadeOutline = false; - _ShadeExtent = 0.001f; + _ShadeExtentX = 0.001f; + _ShadeExtentY = 0.001f; _ShadeColor = NLMISC::CRGBA(0,0,0); _Keep800x600Ratio= true; diff --git a/code/nel/src/3d/text_context_user.cpp b/code/nel/src/3d/text_context_user.cpp index 1834a93ce..ae2cc2417 100644 --- a/code/nel/src/3d/text_context_user.cpp +++ b/code/nel/src/3d/text_context_user.cpp @@ -187,11 +187,11 @@ bool CTextContextUser::getShadeOutline() const return _TextContext.getShadeOutline(); } -void CTextContextUser::setShadeExtent(float shext) +void CTextContextUser::setShadeExtent(float x, float y) { H_AUTO2; - _TextContext.setShadeExtent(shext); + _TextContext.setShadeExtent(x, y); } void CTextContextUser::setShadeColor (NLMISC::CRGBA sc) { diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 970178947..e8a2ac889 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1057,6 +1057,29 @@ namespace NLGUI _CellParams.push_back (cellParams); \ } + static bool scanCssLength(const std::string& str, uint32 &px) + { + if (fromString(str, px)) + return true; + + if (str == "thin") + { + px = 1; + return true; + } + if (str == "medium") + { + px = 3; + return true; + } + if (str == "thick") + { + px = 5; + return true; + } + + return false; + } static bool isHexa(char c) { @@ -2378,6 +2401,7 @@ namespace NLGUI _Style.FontWeight = FONT_WEIGHT_NORMAL; _Style.FontOblique = false; _Style.FontSize = TextFontSize; + _Style.TextShadow = STextShadow(true); if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); @@ -4351,8 +4375,17 @@ namespace NLGUI if (_CurrentViewLink) { bool skipLine = !_CurrentViewLink->getText().empty() && *(_CurrentViewLink->getText().rbegin()) == (ucchar) '\n'; + bool sameShadow = _Style.TextShadow.Enabled && _CurrentViewLink->getShadow(); + if (sameShadow && _Style.TextShadow.Enabled) + { + sint sx, sy; + _CurrentViewLink->getShadowOffset(sx, sy); + sameShadow = (_Style.TextShadow.Color == _CurrentViewLink->getShadowColor()); + sameShadow = sameShadow && (_Style.TextShadow.Outline == _CurrentViewLink->getShadowOutline()); + sameShadow = sameShadow && (_Style.TextShadow.X == sx) && (_Style.TextShadow.Y == sy); + } // Compatible with current parameters ? - if (!skipLine && + if (!skipLine && sameShadow && (_Style.TextColor == _CurrentViewLink->getColor()) && (_Style.FontFamily == _CurrentViewLink->getFontName()) && (_Style.FontSize == (uint)_CurrentViewLink->getFontSize()) && @@ -4431,6 +4464,13 @@ namespace NLGUI newLink->setMultiLineSpace((uint)((float)(_Style.FontSize)*LineSpaceFontFactor)); newLink->setMultiLine(true); newLink->setModulateGlobalColor(_Style.GlobalColor); + if (_Style.TextShadow.Enabled) + { + newLink->setShadow(true); + newLink->setShadowColor(_Style.TextShadow.Color); + newLink->setShadowOutline(_Style.TextShadow.Outline); + newLink->setShadowOffset(_Style.TextShadow.X, _Style.TextShadow.Y); + } // newLink->setLineAtBottom (true); registerAnchor(newLink); @@ -4553,6 +4593,14 @@ namespace NLGUI templateParams.push_back (std::pair ("enter_recover_focus", "false")); if (maxlength > 0) templateParams.push_back (std::pair ("max_num_chars", toString(maxlength))); + templateParams.push_back (std::pair ("shadow", toString(_Style.TextShadow.Enabled))); + if (_Style.TextShadow.Enabled) + { + templateParams.push_back (std::pair ("shadow_x", toString(_Style.TextShadow.X))); + templateParams.push_back (std::pair ("shadow_y", toString(_Style.TextShadow.Y))); + templateParams.push_back (std::pair ("shadow_color", _Style.TextShadow.Color.toString())); + templateParams.push_back (std::pair ("shadow_outline", toString(_Style.TextShadow.Outline))); + } CInterfaceGroup *textArea = CWidgetManager::getInstance()->getParser()->createGroupInstance (templateName.c_str(), getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); @@ -6229,6 +6277,115 @@ namespace NLGUI style.StrikeThrough = (prop.find("line-through") != std::string::npos); } else + if (it->first == "text-stroke" || it->first == "-webkit-text-stroke") + { + // text-stroke: length || color + bool success = false; + uint px = 0; + CRGBA color; + std::vector parts; + NLMISC::splitString(it->second, " ", parts); + if (parts.size() == 1) + { + success = scanCssLength(parts[0], px); + if (!success) + success = scanHTMLColor(parts[0].c_str(), color); + } + else if (parts.size() == 2) + { + success = scanCssLength(parts[0], px); + if (success) + success = scanHTMLColor(parts[1].c_str(), color); + else + { + success = scanHTMLColor(parts[0].c_str(), color); + success = success && scanCssLength(parts[1], px); + } + } + + // do not disable shadow if one is already set + if (success) + { + style.TextShadow.Enabled = (px > 0); + style.TextShadow.Color = color; + style.TextShadow.X = px; + style.TextShadow.Y = px; + style.TextShadow.Outline = true; + } + } + else + if (it->first == "text-shadow") + { + if (it->second == "none") + style.TextShadow = STextShadow(false); + else + if (it->second == "inherit") + style.TextShadow = current.TextShadow; + else + { + // text-shadow: offset-x offset-y | blur | #color + // text-shadow: #color | offset-x offset-y + bool success = true; + std::string prop(it->second); + size_t pos; + pos = prop.find_first_of(",\n\r"); + if (pos != std::string::npos) + prop = prop.substr(0, pos); + + std::vector parts; + NLMISC::splitString(prop, " ", parts); + switch(parts.size()) + { + case 1: + { + success = scanHTMLColor(it->second.c_str(), style.TextShadow.Color); + break; + } + // no case 2: + case 3: + { + if (!fromString(parts[0], style.TextShadow.X)) + { + success = scanHTMLColor(parts[0].c_str(), style.TextShadow.Color); + success = success && fromString(parts[1], style.TextShadow.X); + success = success && fromString(parts[2], style.TextShadow.Y); + } + else + { + success = fromString(parts[1], style.TextShadow.Y); + success = success && scanHTMLColor(parts[2].c_str(), style.TextShadow.Color); + } + break; + } + case 4: + { + if (!fromString(parts[0], style.TextShadow.X)) + { + success = scanHTMLColor(parts[0].c_str(), style.TextShadow.Color); + success = success && fromString(parts[1], style.TextShadow.X); + success = success && fromString(parts[2], style.TextShadow.Y); + // ignore blur [3] + } + else + { + success = fromString(parts[0], style.TextShadow.X); + success = success && fromString(parts[1], style.TextShadow.Y); + // ignore blur [2] + success = success && scanHTMLColor(parts[3].c_str(), style.TextShadow.Color); + } + break; + } + default: + { + // unsupported rule + break; + } + } + + style.TextShadow.Enabled = success; + } + } + else if (it->first == "width") getPercentage(style.Width, tmpf, it->second.c_str()); else diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index c14a7f9a1..bd10afbb9 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -72,6 +72,8 @@ namespace NLGUI _Shadow = false; _ShadowOutline = false; _ShadowColor = CRGBA(0,0,0,255); + _ShadowX = 1; + _ShadowY = 1; _MultiLine = false; _TextMode = DontClipWord; @@ -955,6 +957,19 @@ namespace NLGUI ((_YReal) > (ClipY+ClipH)) || ((_YReal+_HReal) < ClipY)) return; + // hack: allow shadow to overflow outside parent box. + // In CGroupHTML context, clip is set for row + if (std::abs(_ShadowX) > 0) + { + ClipX -= 3; + ClipW += 3; + } + if (std::abs(_ShadowY) > 0) + { + ClipY -= 3; + ClipH += 3; + } + // *** Screen Minimized? uint32 w, h; float oow, ooh; @@ -992,6 +1007,7 @@ namespace NLGUI TextContext->setShaded (_Shadow); TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeColor (shcol); + TextContext->setShadeExtent (_ShadowX*oow, _ShadowY*ooh); TextContext->setFontSize (_FontSize); TextContext->setEmbolden (_Embolden); TextContext->setOblique (_Oblique); @@ -1119,6 +1135,7 @@ namespace NLGUI TextContext->setShaded (_Shadow); TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeColor (shcol); + TextContext->setShadeExtent (_ShadowX*oow, _ShadowY*ooh); TextContext->setFontSize (_FontSize); TextContext->setEmbolden (_Embolden); TextContext->setOblique (_Oblique); @@ -1339,6 +1356,13 @@ namespace NLGUI _ShadowColor = color; } + // *************************************************************************** + void CViewText::setShadowOffset(sint32 x, sint32 y) + { + _ShadowX = x; + _ShadowY = y; + } + // *************************************************************************** void CViewText::setLineMaxW (sint nMaxW, bool invalidate) { From 15355e3815f3d3380da1a6d744481b8766ada8a3 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 11 Aug 2018 15:33:01 +0300 Subject: [PATCH 44/65] Changed: shadow attributes for CViewText and editbox templates --HG-- branch : develop --- code/nel/src/gui/view_text.cpp | 28 +++++++++++++++ .../gamedev/interfaces_v3/login_widgets.xml | 35 ++++++++++++++++--- .../data/gamedev/interfaces_v3/widgets.xml | 22 ++++++++++-- 3 files changed, 78 insertions(+), 7 deletions(-) diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index bd10afbb9..34f8fd3e1 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -438,6 +438,22 @@ namespace NLGUI return true; } else + if( name == "shadow_x" ) + { + sint sx; + if( fromString( value, sx ) ) + _ShadowX = sx; + return true; + } + else + if( name == "shadow_y" ) + { + sint sy; + if( fromString( value, sy ) ) + _ShadowY = sy; + return true; + } + else if( name == "multi_line" ) { bool b; @@ -618,6 +634,8 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "shadow", BAD_CAST toString( _Shadow ).c_str() ); xmlSetProp( node, BAD_CAST "shadow_outline", BAD_CAST toString( _ShadowOutline ).c_str() ); xmlSetProp( node, BAD_CAST "shadow_color", BAD_CAST toString( _ShadowColor ).c_str() ); + xmlSetProp( node, BAD_CAST "shadow_x", BAD_CAST toString( _ShadowX ).c_str() ); + xmlSetProp( node, BAD_CAST "shadow_y", BAD_CAST toString( _ShadowY ).c_str() ); xmlSetProp( node, BAD_CAST "multi_line", BAD_CAST toString( _MultiLine ).c_str() ); std::string just; @@ -729,6 +747,16 @@ namespace NLGUI if (prop) _ShadowColor = convertColor(prop); + prop= (char*) xmlGetProp( cur, (xmlChar*)"shadow_x" ); + _ShadowX = 1; + if (prop) + fromString( (const char *)prop, _ShadowX); + + prop= (char*) xmlGetProp( cur, (xmlChar*)"shadow_y" ); + _ShadowY = 1; + if (prop) + fromString( (const char *)prop, _ShadowY); + prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_line" ); _MultiLine = false; if (prop) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml b/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml index 660cb4f9d..6d7ac1fa7 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml @@ -75,6 +75,11 @@ keep="true" max_historic="0" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -93,7 +98,7 @@ - + @@ -114,6 +119,11 @@ fontsize="10" fontweight="" fontstyle="" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -124,7 +134,7 @@ - + @@ -153,6 +163,11 @@ keep="true" max_historic="40" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -162,7 +177,7 @@ - + @@ -397,6 +412,11 @@ keep="true" max_historic="40" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -407,7 +427,7 @@ - + @@ -435,6 +455,11 @@ keep="true" max_historic="40" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -444,7 +469,7 @@ - + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml index e5ece5680..62c202815 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml @@ -2653,6 +2653,11 @@ keep="true" max_historic="40" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" clear_on_escape="false" @@ -2722,7 +2727,11 @@ multi_line_space="0" fontsize="#fontsize" color="#color" - shadow="true" + shadow="#shadow" + shadow_x="#shadow_x" + shadow_y="#shadow_y" + shadow_color="#shadow_color" + shadow_outline="#shadow_outline" hardtext="" global_color="false" /> @@ -2826,6 +2835,11 @@ keep="true" max_historic="40" fontsize="10" + shadow="true" + shadow_x="1" + shadow_y="1" + shadow_color="0 0 0 255" + shadow_outline="false" backup_father_container_pos="false" want_return="false" color="255 255 255 255" @@ -2886,7 +2900,11 @@ multi_min_line="#multi_min_line" fontsize="#fontsize" color="#color" - shadow="true" + shadow="#shadow" + shadow_x="#shadow_x" + shadow_y="#shadow_y" + shadow_color="#shadow_color" + shadow_outline="#shadow_outline" hardtext="" global_color="false" render_layer="#render_layer" /> From c7ded068d9c93c13fa440f2dabe90d64f8307afc Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Aug 2018 15:34:42 +0200 Subject: [PATCH 45/65] Fixed: Compilation (reverted back some changes) --HG-- branch : develop --- code/ryzom/server/src/ai_service/event_reaction.h | 2 +- code/ryzom/server/src/ai_service/event_reaction_include.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/server/src/ai_service/event_reaction.h b/code/ryzom/server/src/ai_service/event_reaction.h index 57dcf22d0..31689f613 100644 --- a/code/ryzom/server/src/ai_service/event_reaction.h +++ b/code/ryzom/server/src/ai_service/event_reaction.h @@ -90,7 +90,7 @@ public: // the following routine shouldn't be needed it should be superceded by a better alternative // in the event manager template - bool testCompatibility(const CStateInstance *stateInstance, const TState *state) const + bool testCompatibility(CStateInstance *const stateInstance, const TState *const state) const; protected: // protected data --------------------------------------------------- diff --git a/code/ryzom/server/src/ai_service/event_reaction_include.h b/code/ryzom/server/src/ai_service/event_reaction_include.h index 04fd2c16f..3c44b03dc 100644 --- a/code/ryzom/server/src/ai_service/event_reaction_include.h +++ b/code/ryzom/server/src/ai_service/event_reaction_include.h @@ -28,7 +28,7 @@ #include "continent.h"*/ template -bool CAIEventReaction::testCompatibility(const CStateInstance *stateInstance, const TState *state) const +bool CAIEventReaction::testCompatibility(CStateInstance *const stateInstance, const TState *const state) const { if (!stateInstance) return false; From ad99c2afb79180f94d8d1833ba2755b3fde4c968 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Aug 2018 15:35:13 +0200 Subject: [PATCH 46/65] Fixed: Warning (missing return) --HG-- branch : develop --- code/ryzom/server/src/ai_service/fx_entity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/server/src/ai_service/fx_entity.h b/code/ryzom/server/src/ai_service/fx_entity.h index 74ea07f91..028ee3ad9 100644 --- a/code/ryzom/server/src/ai_service/fx_entity.h +++ b/code/ryzom/server/src/ai_service/fx_entity.h @@ -32,7 +32,7 @@ public: NLMISC::CEntityId const& id() const; bool spawn(); void despawn(); - bool update() { } + bool update() { return false; } void set(std::string const& prop, std::string const& value, bool reportChange=false) { } std::string get(std::string const& prop); std::string getIndexString() const { return _EntityId.toString(); } From ad98b1414a5cbf344775f59fc85eb93014180f7f Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Aug 2018 15:35:40 +0200 Subject: [PATCH 47/65] Changed: Minor changes --HG-- branch : develop --- code/ryzom/server/src/ai_service/ai_bot.cpp | 1 - code/ryzom/server/src/ai_service/ai_grp_npc.h | 2 +- code/ryzom/server/src/ai_service/ai_script_comp.h | 8 ++------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/code/ryzom/server/src/ai_service/ai_bot.cpp b/code/ryzom/server/src/ai_service/ai_bot.cpp index 2fb47023a..6698de755 100644 --- a/code/ryzom/server/src/ai_service/ai_bot.cpp +++ b/code/ryzom/server/src/ai_service/ai_bot.cpp @@ -88,7 +88,6 @@ void CSpawnBot::setVisualPropertiesName() return; // the npc name is displayed as a fauna } - CVisualPropertiesInterface::setName(dataSetRow(), name); } diff --git a/code/ryzom/server/src/ai_service/ai_grp_npc.h b/code/ryzom/server/src/ai_service/ai_grp_npc.h index bac75d1a9..1f838584d 100644 --- a/code/ryzom/server/src/ai_service/ai_grp_npc.h +++ b/code/ryzom/server/src/ai_service/ai_grp_npc.h @@ -190,7 +190,7 @@ public: uint32 getAggroDist() { return _AggroDist; } uint32& despawnTime() { return _DespawnTime; } - uint32& respawnTime() { return _RespawnTime; } + uint32& respawnTime() { return _RespawnTime; } AITYPES::CPropertySetWithExtraList& faction() { return _faction; } AITYPES::CPropertySetWithExtraList& ennemyFaction() { return _ennemyFaction; } diff --git a/code/ryzom/server/src/ai_service/ai_script_comp.h b/code/ryzom/server/src/ai_service/ai_script_comp.h index a35253d66..d4782ac18 100644 --- a/code/ryzom/server/src/ai_service/ai_script_comp.h +++ b/code/ryzom/server/src/ai_service/ai_script_comp.h @@ -56,9 +56,7 @@ public: static CFightScriptCompReader *getScriptReader (const std::string &str); - static CFightScriptComp *createScriptComp (const std::string &str) -protected: -private: + static CFightScriptComp *createScriptComp(const std::string &str); }; @@ -74,8 +72,6 @@ public: typedef CHashMap > TFightScriptMap; static TFightScriptMap _ScriptCompList; -protected: -private: }; @@ -116,7 +112,7 @@ public: CFightSelectFilterReader() {} virtual ~CFightSelectFilterReader() {} - CFightScriptComp *create (const std::string &inStr) + CFightScriptComp *create(const std::string &inStr); std::string getName () const { return std::string("SELECT"); From b86bf43090444ef92e789b1bd93f7064b288a634 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 11 Aug 2018 21:47:50 +0200 Subject: [PATCH 48/65] Fixed: Simplify certificates management --HG-- branch : develop --- code/nel/include/nel/gui/curl_certificates.h | 3 - code/nel/include/nel/gui/group_html.h | 2 - code/nel/src/gui/curl_certificates.cpp | 121 +++++++++++------- code/nel/src/gui/group_html.cpp | 12 -- code/ryzom/client/src/http_client_curl.cpp | 3 - .../src/interface_v3/interface_manager.cpp | 12 +- 6 files changed, 78 insertions(+), 75 deletions(-) diff --git a/code/nel/include/nel/gui/curl_certificates.h b/code/nel/include/nel/gui/curl_certificates.h index ee6938842..9d5ad4855 100644 --- a/code/nel/include/nel/gui/curl_certificates.h +++ b/code/nel/include/nel/gui/curl_certificates.h @@ -27,9 +27,6 @@ namespace NLGUI class CCurlCertificates { public: - // check if compiled with OpenSSL backend - static void init(CURL *curl); - // allow to use custom PEM certificates static void addCertificateFile(const std::string &cert); diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 811cd3503..c96b67456 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -66,8 +66,6 @@ namespace NLGUI std::vector< std::string > trustedDomains; /// Maximum concurrent MultiCurl connections per CGroupHTML instance sint32 curlMaxConnections; - /// cacert.pem location - std::string curlCABundle; SWebOptions(): curlMaxConnections(2) { diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index 7d26e7e5a..fa3cd10f0 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -40,29 +40,43 @@ namespace NLGUI class SX509Certificates { public: - std::vector CertList; - std::vector FilesList; + struct CertEntry + { + X509 *cert; + std::string name; + std::string file; + + bool operator == (const std::string &str) + { + return file == str; + } + }; + + std::vector CertList; bool isUsingOpenSSLBackend; bool isInitialized; SX509Certificates():isUsingOpenSSLBackend(false), isInitialized(false) { + init(); } ~SX509Certificates() { for (uint i = 0; i < CertList.size(); ++i) { - X509_free(CertList[i]); + X509_free(CertList[i].cert); } CertList.clear(); } - void init(CURL *curl) + void init() { - if (isInitialized) return; + // init CURL + CURL *curl = curl_easy_init(); + if (!curl) return; // get information on CURL curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); @@ -98,9 +112,39 @@ namespace NLGUI isUsingOpenSSLBackend = false; } + // clean up CURL + curl_easy_cleanup(curl); + isInitialized = true; } + static std::string getCertName(X509 *cert) + { + // NULL certificate + if (!cert) return ""; + + X509_NAME *subject = X509_get_subject_name(cert); + + std::string name; + unsigned char *tmp = NULL; + + // construct a multiline string with name + for (int j = 0, jlen = X509_NAME_entry_count(subject); j < jlen; ++j) + { + X509_NAME_ENTRY *e = X509_NAME_get_entry(subject, j); + ASN1_STRING *d = X509_NAME_ENTRY_get_data(e); + + if (ASN1_STRING_to_UTF8(&tmp, d) > 0) + { + name += NLMISC::toString("%s\n", tmp); + + OPENSSL_free(tmp); + } + } + + return name; + } + #ifdef NL_OS_WINDOWS void addCertificatesFrom(LPCSTR root) { @@ -114,38 +158,36 @@ namespace NLGUI { x509 = NULL; x509 = d2i_X509(NULL, (const unsigned char **)&pContext->pbCertEncoded, pContext->cbCertEncoded); + if (x509) { - CertList.push_back(x509); + CertEntry entry; + entry.cert = x509; + entry.file = root; + entry.name = getCertName(x509); + + CertList.push_back(entry); } } + CertFreeCertificateContext(pContext); CertCloseStore(hStore, 0); } // this is called before debug context is set and log ends up in log.log - nlinfo("Loaded %d certificates from '%s' certificate store", (int)CertList.size(), root); + //nlinfo("Loaded %d certificates from '%s' certificate store", (int)CertList.size(), root); } #endif void addCertificatesFromFile(const std::string &cert) { - if (!isUsingOpenSSLBackend) return; - - if (!isInitialized) - { - nlwarning("You MUST call NLGUI::CCurlCertificates::init before adding new certificates"); - return; - } + if (!isInitialized || !isUsingOpenSSLBackend) return; // this file was already loaded - if (std::find(FilesList.begin(), FilesList.end(), cert) != FilesList.end()) return; - - FilesList.push_back(cert); + if (std::find(CertList.begin(), CertList.end(), cert) != CertList.end()) return; // look for certificate in search paths string path = CPath::lookup(cert, false); - nlinfo("Cert path '%s'", path.c_str()); if (path.empty()) { @@ -153,6 +195,8 @@ namespace NLGUI return; } + nlinfo("CURL CA bundle '%s'", path.c_str()); + CIFile file; // open certificate @@ -184,7 +228,12 @@ namespace NLGUI if (itmp && itmp->x509) { - CertList.push_back(X509_dup(itmp->x509)); + CertEntry entry; + entry.cert = X509_dup(itmp->x509); + entry.file = cert; + entry.name = getCertName(entry.cert); + + CertList.push_back(entry); } } @@ -224,27 +273,10 @@ namespace NLGUI for (uint i = 0, ilen = x509CertListManager.CertList.size(); i < ilen; ++i) { - X509_NAME *subject = X509_get_subject_name(x509CertListManager.CertList[i]); - - std::string name; - unsigned char *tmp = NULL; - - // construct a multiline string with name - for (int j = 0, jlen = X509_NAME_entry_count(subject); j < jlen; ++j) - { - X509_NAME_ENTRY *e = X509_NAME_get_entry(subject, j); - ASN1_STRING *d = X509_NAME_ENTRY_get_data(e); - - if (ASN1_STRING_to_UTF8(&tmp, d) > 0) - { - name += NLMISC::toString("%s\n", tmp); - - OPENSSL_free(tmp); - } - } + SX509Certificates::CertEntry entry = x509CertListManager.CertList[i]; // add our certificate to this store - if (X509_STORE_add_cert(x509store, x509CertListManager.CertList[i]) == 0) + if (X509_STORE_add_cert(x509store, entry.cert) == 0) { uint errCode = ERR_get_error(); @@ -252,13 +284,13 @@ namespace NLGUI if (ERR_GET_LIB(errCode) != ERR_LIB_X509 || ERR_GET_REASON(errCode) != X509_R_CERT_ALREADY_IN_HASH_TABLE) { ERR_error_string_n(errCode, errorBuffer, 1024); - nlwarning("Error adding certificate %s: %s", name.c_str(), errorBuffer); + nlwarning("Error adding certificate %s: %s", entry.name.c_str(), errorBuffer); res = CURLE_SSL_CACERT; } } else { - nldebug("Added certificate %s", name.c_str()); + nldebug("Added certificate %s", entry.name.c_str()); } } } @@ -275,13 +307,6 @@ namespace NLGUI return res; } - // *************************************************************************** - // static - void CCurlCertificates::init(CURL *curl) - { - x509CertListManager.init(curl); - } - // *************************************************************************** // static void CCurlCertificates::addCertificateFile(const std::string &cert) @@ -294,7 +319,7 @@ namespace NLGUI void CCurlCertificates::useCertificates(CURL *curl) { // CURL must be valid, using OpenSSL backend and certificates must be loaded, else return - if (!curl || !x509CertListManager.isUsingOpenSSLBackend || x509CertListManager.CertList.empty()) return; + if (!curl || !x509CertListManager.isInitialized || !x509CertListManager.isUsingOpenSSLBackend || x509CertListManager.CertList.empty()) return; curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index e8a2ac889..9a987d450 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -398,12 +398,6 @@ namespace NLGUI // https:// if (toLower(download.url.substr(0, 8)) == "https://") { - // check if compiled with OpenSSL backend - CCurlCertificates::init(curl); - - // specify custom CA certs - CCurlCertificates::addCertificateFile(options.curlCABundle); - // if supported, use custom SSL context function to load certificates CCurlCertificates::useCertificates(curl); } @@ -5410,12 +5404,6 @@ namespace NLGUI // https:// if (toLower(url.substr(0, 8)) == "https://") { - // check if compiled with OpenSSL backend - CCurlCertificates::init(curl); - - // specify custom CA certs - CCurlCertificates::addCertificateFile(options.curlCABundle); - // if supported, use custom SSL context function to load certificates CCurlCertificates::useCertificates(curl); } diff --git a/code/ryzom/client/src/http_client_curl.cpp b/code/ryzom/client/src/http_client_curl.cpp index 2887543c3..16436516b 100644 --- a/code/ryzom/client/src/http_client_curl.cpp +++ b/code/ryzom/client/src/http_client_curl.cpp @@ -71,9 +71,6 @@ bool CCurlHttpClient::verifyServer(bool verify) curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYHOST, verify ? 2 : 0); curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYPEER, verify ? 1 : 0); - // check if compiled with OpenSSL backend - NLGUI::CCurlCertificates::init(_Curl); - // specify custom CA certs NLGUI::CCurlCertificates::addCertificateFile(CAFilename); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 53eddd7b9..6ec32a34d 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -113,6 +113,8 @@ #include "nel/gui/lua_helper.h" using namespace NLGUI; #include "nel/gui/lua_ihm.h" +#include "nel/gui/curl_certificates.h" + #include "lua_ihm_ryzom.h" #include "add_on_manager.h" @@ -471,15 +473,11 @@ CInterfaceManager::CInterfaceManager() CGroupHTML::options.appName = getUserAgentName(); CGroupHTML::options.appVersion = getUserAgentVersion(); CGroupHTML::options.curlMaxConnections = ClientCfg.CurlMaxConnections; + if (!ClientCfg.CurlCABundle.empty()) { - string filename = CPath::lookup(ClientCfg.CurlCABundle, false); - if (!filename.empty()) - { - filename = CPath::getFullPath(filename, false); - CGroupHTML::options.curlCABundle = filename; - nlinfo("curl ca bundle '%s'", filename.c_str()); - } + // specify custom CA certs, lookup will be made in this function + NLGUI::CCurlCertificates::addCertificateFile(ClientCfg.CurlCABundle); } NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); From adc89b3a82410bce94ed9525faf170b7aa076f27 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 18 Aug 2018 09:16:14 +0300 Subject: [PATCH 49/65] Fixed: style inheritance for underline, strikethrough --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 9a987d450..45398102b 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -6175,6 +6175,12 @@ namespace NLGUI { const CStyleParams current = _Style; + if (inherit) + { + style.Underlined = current.Underlined; + style.StrikeThrough = current.StrikeThrough; + } + float tmpf; TStyle styles = parseStyle(styleString); TStyle::iterator it; @@ -6396,11 +6402,6 @@ namespace NLGUI style.GlobalColor = b; } } - if (inherit) - { - style.Underlined = current.Underlined || style.Underlined; - style.StrikeThrough = current.StrikeThrough || style.StrikeThrough; - } } // *************************************************************************** From 40dc2188f268f71d9488c1efb42ce90079b195b6 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 18 Aug 2018 10:53:04 +0200 Subject: [PATCH 50/65] Fixed: Check CURL backend on old CURL versions (tested with 7.22) --HG-- branch : develop --- code/nel/src/gui/curl_certificates.cpp | 51 +++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index fa3cd10f0..11053545a 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -25,6 +25,14 @@ #include +// for compatibility with older versions +#ifndef CURL_AT_LEAST_VERSION +#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z) +#define CURL_AT_LEAST_VERSION(x,y,z) \ + (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) +#endif + + using namespace std; using namespace NLMISC; @@ -81,6 +89,9 @@ namespace NLGUI // get information on CURL curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); + bool useOpenSSLBackend = false; + +#if CURL_AT_LEAST_VERSION(7, 34, 0) // get more information on CURL session curl_tlssessioninfo *sessionInfo; @@ -94,8 +105,30 @@ namespace NLGUI CURLcode res = curl_easy_getinfo(curl, info, &sessionInfo); + // CURL using OpenSSL backend + if ((res == CURLE_OK) && sessionInfo && sessionInfo->backend == CURLSSLBACKEND_OPENSSL) useOpenSSLBackend = true; +#elif CURL_AT_LEAST_VERSION(7, 12, 3) + // get a list of OpenSSL engines + struct curl_slist *engines; + + CURLcode res = curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines); + + // CURL using OpenSSL backend + // With OpenSSL compiled without any engine, engines will too return NULL + // Fortunately, if OpenSSL isn't compiled with engines means we compiled it ourself and CURL is a recent version + if ((res == CURLE_OK) && engine) + { + // free engines + curl_slist_free_all(engines); + + useOpenSSLBackend = true; + } +#else + // TODO: implement an equivalent, but CURL 7.12 was released in 2004 +#endif + // only use OpenSSL callback if not using Windows SSPI and using OpenSSL backend - if (!res && sessionInfo && sessionInfo->backend == CURLSSLBACKEND_OPENSSL && !(data && data->features & CURL_VERSION_SSPI)) + if (useOpenSSLBackend && !(data && data->features & CURL_VERSION_SSPI)) { #ifdef NL_OS_WINDOWS // load native Windows CA Certs @@ -181,7 +214,21 @@ namespace NLGUI void addCertificatesFromFile(const std::string &cert) { - if (!isInitialized || !isUsingOpenSSLBackend) return; + if (!isInitialized) + { + nlwarning("CURL not initialized! Check if there are another errors"); + return; + } + + if (!isUsingOpenSSLBackend) + { + nlinfo("CURL not using OpenSSL backend! Unable to use custom certificates"); + return; + } + else + { + nlinfo("CURL using OpenSSL backend!"); + } // this file was already loaded if (std::find(CertList.begin(), CertList.end(), cert) != CertList.end()) return; From 58efd082c112c552660e33c43775acef872c6058 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 18 Aug 2018 10:57:33 +0200 Subject: [PATCH 51/65] Changed: Don't include curl.h in headers to avoid dependencies on CURL for more files that required --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 10 +- code/nel/include/nel/gui/libwww.h | 5 +- code/nel/src/gui/group_html.cpp | 91 ++++++++++--------- code/nel/src/gui/libwww.cpp | 2 + .../src/interface_v3/group_html_webig.cpp | 2 + 5 files changed, 57 insertions(+), 53 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index c96b67456..9c48149bf 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -17,8 +17,6 @@ #ifndef CL_GROUP_HTML_H #define CL_GROUP_HTML_H -#include - #include "nel/misc/types_nl.h" #include "nel/gui/interface_group.h" #include "nel/gui/group_scrolltext.h" @@ -27,6 +25,9 @@ #include "nel/gui/group_table.h" #include "nel/gui/libwww_types.h" +// forward declaration +typedef void CURLM; + typedef std::map TStyle; namespace NLGUI @@ -856,11 +857,6 @@ namespace NLGUI // HtmlType download finished void htmlDownloadFinished(const std::string &content, const std::string &type, long code); - - // cURL transfer callbacks - static size_t curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData); - static size_t curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData); - static size_t curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow); }; // adapter group that store y offset for inputs inside an html form diff --git a/code/nel/include/nel/gui/libwww.h b/code/nel/include/nel/gui/libwww.h index 892e07eb2..64258608e 100644 --- a/code/nel/include/nel/gui/libwww.h +++ b/code/nel/include/nel/gui/libwww.h @@ -20,11 +20,12 @@ #ifndef CL_LIB_WWW_H #define CL_LIB_WWW_H -#include - #include "nel/misc/rgba.h" #include "nel/gui/libwww_types.h" +// forward declaration to avoid curl.h inclusion everywhere +typedef void CURL; + namespace NLGUI { class CCtrlBaseButton; diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 45398102b..fdf32f44c 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -49,6 +49,8 @@ #include "nel/gui/http_hsts.h" #include "nel/gui/curl_certificates.h" +#include + using namespace std; using namespace NLMISC; @@ -205,6 +207,47 @@ namespace NLGUI std::map HeadersRecv; }; + // cURL transfer callbacks + // *************************************************************************** + static size_t curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData) + { + CCurlWWWData * me = static_cast(pCCurlWWWData); + if (me) + { + std::string header; + header.append(buffer, size * nmemb); + me->setRecvHeader(header.substr(0, header.find_first_of("\n\r"))); + } + + return size * nmemb; + } + + // *************************************************************************** + static size_t curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData) + { + CCurlWWWData * me = static_cast(pCCurlWWWData); + if (me) + me->Content.append(buffer, size * nmemb); + + return size * nmemb; + } + + // *************************************************************************** + static size_t curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) + { + CCurlWWWData * me = static_cast(pCCurlWWWData); + if (me) + { + if (dltotal > 0 || dlnow > 0 || ultotal > 0 || ulnow > 0) + { + nlwarning("> dltotal %d, dlnow %d, ultotal %d, ulnow %d, url '%s'", dltotal, dlnow, ultotal, ulnow, me->Url.c_str()); + } + } + + // return 1 to cancel download + return 0; + } + // Check if domain is on TrustedDomain bool CGroupHTML::isTrustedDomain(const string &domain) { @@ -423,7 +466,7 @@ namespace NLGUI download.data->sendHeaders(headers); // catch headers - curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curlHeaderCallback); + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, NLGUI::curlHeaderCallback); curl_easy_setopt(curl, CURLOPT_WRITEHEADER, download.data); std::string userAgent = options.appName + "/" + options.appVersion; @@ -5476,17 +5519,17 @@ namespace NLGUI _CurlWWW->sendHeaders(headers); // catch headers for redirect - curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curlHeaderCallback); + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, NLGUI::curlHeaderCallback); curl_easy_setopt(curl, CURLOPT_WRITEHEADER, _CurlWWW); // catch body - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlDataCallback); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NLGUI::curlDataCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, _CurlWWW); #if LOG_DL // progress callback curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); - curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, curlProgressCallback); + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, NLGUI::curlProgressCallback); curl_easy_setopt(curl, CURLOPT_XFERINFODATA, _CurlWWW); #else // progress off @@ -6472,46 +6515,6 @@ namespace NLGUI } } - // *************************************************************************** - size_t CGroupHTML::curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData) - { - CCurlWWWData * me = static_cast(pCCurlWWWData); - if (me) - { - std::string header; - header.append(buffer, size * nmemb); - me->setRecvHeader(header.substr(0, header.find_first_of("\n\r"))); - } - - return size * nmemb; - } - - // *************************************************************************** - size_t CGroupHTML::curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData) - { - CCurlWWWData * me = static_cast(pCCurlWWWData); - if (me) - me->Content.append(buffer, size * nmemb); - - return size * nmemb; - } - - // *************************************************************************** - size_t CGroupHTML::curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) - { - CCurlWWWData * me = static_cast(pCCurlWWWData); - if (me) - { - if (dltotal > 0 || dlnow > 0 || ultotal > 0 || ulnow > 0) - { - nlwarning("> dltotal %d, dlnow %d, ultotal %d, ulnow %d, url '%s'", dltotal, dlnow, ultotal, ulnow, me->Url.c_str()); - } - } - - // return 1 to cancel download - return 0; - } - // *************************************************************************** std::string CGroupHTML::HTMLOListElement::getListMarkerText() const { diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index fef3d788e..2e9b4451a 100644 --- a/code/nel/src/gui/libwww.cpp +++ b/code/nel/src/gui/libwww.cpp @@ -19,6 +19,8 @@ #include "nel/gui/libwww.h" #include "nel/gui/group_html.h" +#include + using namespace NLMISC; #ifdef DEBUG_NEW diff --git a/code/ryzom/client/src/interface_v3/group_html_webig.cpp b/code/ryzom/client/src/interface_v3/group_html_webig.cpp index 58d27c851..fe2fa5229 100644 --- a/code/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -28,6 +28,8 @@ #include "../net_manager.h" #include "../connection.h" +#include + using namespace std; using namespace NLMISC; From 1380a94f5d9db9ac70e265010736662bc2f9282f Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 18 Aug 2018 11:12:26 +0200 Subject: [PATCH 52/65] Changed: Use LIST(APPEND instead of SET --HG-- branch : develop --- code/CMakeModules/FindHelpers.cmake | 36 +++++++++++++-------------- code/CMakeModules/FindSteam.cmake | 2 +- code/ryzom/client/src/login_patch.cpp | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/code/CMakeModules/FindHelpers.cmake b/code/CMakeModules/FindHelpers.cmake index a4af37229..874555820 100644 --- a/code/CMakeModules/FindHelpers.cmake +++ b/code/CMakeModules/FindHelpers.cmake @@ -692,11 +692,11 @@ MACRO(ADD_QT_LIBRARY _NAME) ENDIF() SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}") IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB}) + LIST(APPEND QT_LIBRARIES optimized ${_LIB}) ENDIF() SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}") IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB}) + LIST(APPEND QT_LIBRARIES debug ${_LIB}) ENDIF() ENDMACRO() @@ -710,11 +710,11 @@ MACRO(ADD_QT_PLUGIN _TYPE _NAME) ENDIF() SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}") IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB}) + LIST(APPEND QT_LIBRARIES optimized ${_LIB}) ENDIF() SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}") IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB}) + LIST(APPEND QT_LIBRARIES debug ${_LIB}) ENDIF() ENDMACRO() @@ -789,12 +789,12 @@ MACRO(FIND_QT5) SET(QT_LIBRARIES Qt5::Widgets) # Gui - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::OpenGL) + LIST(APPEND QT_LIBRARIES Qt5::Gui Qt5::OpenGL) ADD_QT_LIBRARY(PrintSupport) IF(WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} + LIST(APPEND QT_LIBRARIES ${WINSDK_LIBRARY_DIR}/Imm32.lib ${WINSDK_LIBRARY_DIR}/OpenGL32.lib ${WINSDK_LIBRARY_DIR}/WinMM.Lib) @@ -812,7 +812,7 @@ MACRO(FIND_QT5) FIND_LIBRARY(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration) FIND_LIBRARY(OPENGL_FRAMEWORK NAMES OpenGL) - SET(QT_LIBRARIES ${QT_LIBRARIES} + LIST(APPEND QT_LIBRARIES ${CUPS_LIBRARY} ${COCOA_FRAMEWORK} ${SYSTEMCONFIGURATION_FRAMEWORK} @@ -839,7 +839,7 @@ MACRO(FIND_QT5) ADD_QT_LIBRARY(DBus) IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a") - SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_LIBRARY_DIR}/libxcb-static.a") + LIST(APPEND QT_LIBRARIES "${QT_LIBRARY_DIR}/libxcb-static.a") ENDIF() # always link these in dynamic, API never changes @@ -871,14 +871,14 @@ MACRO(FIND_QT5) SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib") ENDIF() IF(EXISTS ${HB_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${HB_LIB}) + LIST(APPEND QT_LIBRARIES ${HB_LIB}) ENDIF() # freetype is needed since Qt 5.5 FIND_PACKAGE(Freetype) IF(FREETYPE_FOUND) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIBRARIES}) + LIST(APPEND QT_LIBRARIES ${FREETYPE_LIBRARIES}) ELSE() IF(UNIX) SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a") @@ -886,27 +886,27 @@ MACRO(FIND_QT5) SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib") ENDIF() IF(EXISTS ${FREETYPE_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIB}) + LIST(APPEND QT_LIBRARIES ${FREETYPE_LIB}) ENDIF() ENDIF() ADD_QT_PLUGIN(accessible qtaccessiblewidgets) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARY}) + LIST(APPEND QT_LIBRARIES ${PNG_LIBRARIES} ${JPEG_LIBRARY}) # Network - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Network Qt5::Xml) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) + LIST(APPEND QT_LIBRARIES Qt5::Network Qt5::Xml) + LIST(APPEND QT_LIBRARIES ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) IF(WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} + LIST(APPEND QT_LIBRARIES ${WINSDK_LIBRARY_DIR}/Crypt32.lib ${WINSDK_LIBRARY_DIR}/WS2_32.Lib ${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib) ENDIF() # Core - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Core) + LIST(APPEND QT_LIBRARIES Qt5::Core) # pcre is needed since Qt 5.5 IF(UNIX) @@ -918,7 +918,7 @@ MACRO(FIND_QT5) SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib") ENDIF() IF(EXISTS ${PCRE_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${PCRE_LIB}) + LIST(APPEND QT_LIBRARIES ${PCRE_LIB}) ENDIF() IF(APPLE) @@ -926,7 +926,7 @@ MACRO(FIND_QT5) FIND_LIBRARY(SECURITY_FRAMEWORK Security) - SET(QT_LIBRARIES ${QT_LIBRARIES} + LIST(APPEND QT_LIBRARIES ${PCRE_LIBRARY} ${FOUNDATION_FRAMEWORK} ${CARBON_FRAMEWORK} diff --git a/code/CMakeModules/FindSteam.cmake b/code/CMakeModules/FindSteam.cmake index 5657312eb..8d9b12372 100644 --- a/code/CMakeModules/FindSteam.cmake +++ b/code/CMakeModules/FindSteam.cmake @@ -2,7 +2,7 @@ # This module defines # STEAM_LIBRARY, the library to link against # STEAM_FOUND, if false, do not try to link to STEAM -# STEA%_INCLUDE_DIR, where to find headers. +# STEAM_INCLUDE_DIR, where to find headers. IF(STEAM_LIBRARY AND STEAM_INCLUDE_DIR) # in cache already diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index 6a3500ae0..f4e7e237f 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -101,7 +101,7 @@ struct EPatchDownloadException : public Exception { EPatchDownloadException() : Exception( "Download Error" ) {} EPatchDownloadException( const std::string& str ) : Exception( str ) {} - virtual ~EPatchDownloadException() {} + virtual ~EPatchDownloadException() throw(){} }; From 6da051e1a82832b791c843a6b8187de6539500b4 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 18 Aug 2018 11:12:47 +0200 Subject: [PATCH 53/65] Changed: New macro FIX_PACKAGE_OPTIONS --HG-- branch : develop --- code/CMakeModules/FindHelpers.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/code/CMakeModules/FindHelpers.cmake b/code/CMakeModules/FindHelpers.cmake index 874555820..ab8df32a6 100644 --- a/code/CMakeModules/FindHelpers.cmake +++ b/code/CMakeModules/FindHelpers.cmake @@ -38,6 +38,21 @@ MACRO(PARSE_VERSION_OTHER FILENAME) ENDIF() ENDMACRO() +# macro to define FIND_PACKAGE options with a different package name +MACRO(FIX_PACKAGE_OPTIONS OLDNAME NEWNAME) + # append other options if needed + SET(_OPTIONS COMPONENTS REQUIRED QUIETLY) + + # process each options + FOREACH(_OPTION ${_OPTIONS}) + SET(OLD_OPTION ${OLDNAME}_FIND_${_OPTION}) + IF(DEFINED ) + SET(NEW_OPTION ${NEWNAME}_FIND_${_OPTION}) + SET(${NEW_OPTION} ${OLD_OPTION}) + ENDIF() + ENDFOREACH() +ENDMACRO() + MACRO(FIND_PACKAGE_HELPER NAME INCLUDE) # Looks for a directory containing NAME. # From 964e32cd93b5e44d90e6154617999b14303a1a6d Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 18 Aug 2018 11:13:10 +0200 Subject: [PATCH 54/65] Changed: Use Threads CMake module and CMAKE_DL_LIBS --HG-- branch : develop --- code/CMakeModules/FindHelpers.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/CMakeModules/FindHelpers.cmake b/code/CMakeModules/FindHelpers.cmake index ab8df32a6..bc38354f4 100644 --- a/code/CMakeModules/FindHelpers.cmake +++ b/code/CMakeModules/FindHelpers.cmake @@ -947,7 +947,8 @@ MACRO(FIND_QT5) ${CARBON_FRAMEWORK} ${SECURITY_FRAMEWORK}) ELSEIF(UNIX) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -ldl -lrt) + FIND_PACKAGE(Threads) + LIST(APPEND QT_LIBRARIES ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} -lrt) ENDIF() ELSE() SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core) From 06a4244df36c1d6ac8af63f86f3d4db60436287a Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 18 Aug 2018 11:14:14 +0200 Subject: [PATCH 55/65] Changed: Include NeL in RyzomGameShare CMake module --HG-- branch : develop --- code/CMakeModules/FindRyzomGameShare.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/CMakeModules/FindRyzomGameShare.cmake b/code/CMakeModules/FindRyzomGameShare.cmake index 56eb94569..f76e4dd93 100644 --- a/code/CMakeModules/FindRyzomGameShare.cmake +++ b/code/CMakeModules/FindRyzomGameShare.cmake @@ -3,6 +3,10 @@ INCLUDE(FindHelpers) FIND_PACKAGE_HELPER(RyzomGameShare game_share/continent.h RELEASE ryzom_gameshare_r ryzom_gameshare DEBUG ryzom_gameshare_d DIR ${NEL_DIR} ${RYZOM_DIR} SUFFIXES ryzom) IF(RYZOMGAMESHARE_FOUND) + FIND_PACKAGE(NeL REQUIRED) + LIST(APPEND RYZOMGAMESHARE_INCLUDE_DIRS ${NEL_INCLUDE_DIRS}) + LIST(APPEND RYZOMGAMESHARE_LIBRARIES ${NELMISC_LIBRARIES} ${NELLIGO_LIBRARIES} ${NELNET_LIBRARIES} ${NELGEORGES_LIBRARIES}) + SET(RYZOM_GAMESHARE_LIBRARIES ${RYZOMGAMESHARE_LIBRARIES}) SET(RYZOM_GAMESHARE_FOUND ${RYZOMGAMESHARE_FOUND}) SET(RYZOM_GAMESHARE_INCLUDE_DIR ${RYZOMGAMESHARE_INCLUDE_DIR}) From 6097ada1fa52c347561c4cf7bce52972741aff0e Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 18 Aug 2018 11:20:37 +0200 Subject: [PATCH 56/65] Changed: Removed other throws --HG-- branch : develop --- code/nel/include/nel/net/module_gateway.h | 7 ++----- code/nel/src/net/module_gateway.cpp | 3 --- code/nel/src/net/module_local_gateway.cpp | 4 ---- .../object_viewer/particle_system/particle_node.cpp | 2 +- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/code/nel/include/nel/net/module_gateway.h b/code/nel/include/nel/net/module_gateway.h index 75d386162..40da736a3 100644 --- a/code/nel/include/nel/net/module_gateway.h +++ b/code/nel/include/nel/net/module_gateway.h @@ -171,8 +171,7 @@ namespace NLNET virtual void setTransportPeerInvisible(const std::string &transportInstanceName, bool peerInvisible) =0; /// Activate/stop firewalling mode on a transport - virtual void setTransportFirewallMode(const std::string &transportInstanceName, bool firewalled) - throw (EGatewayFirewallBreak) =0; + virtual void setTransportFirewallMode(const std::string &transportInstanceName, bool firewalled) =0; /// Send a command to a transport virtual void transportCommand(const TParsedCommandLine &commandLine) =0; @@ -233,9 +232,7 @@ namespace NLNET /** Disclose module information to a connected gateway. * This can also be this gateway itself. */ - virtual void discloseModule(IModuleProxy *moduleProxy) - throw (EGatewayNotConnected) - =0; + virtual void discloseModule(IModuleProxy *moduleProxy) =0; /** Retrieve the proxy for a locally plugged module. * Each local module plugged in a gateway has an associated diff --git a/code/nel/src/net/module_gateway.cpp b/code/nel/src/net/module_gateway.cpp index 0acb4375d..d4d07ea61 100644 --- a/code/nel/src/net/module_gateway.cpp +++ b/code/nel/src/net/module_gateway.cpp @@ -448,7 +448,6 @@ namespace NLNET /// Activate/stop firewalling mode on a transport virtual void setTransportFirewallMode(const std::string &transportInstanceName, bool firewalled) - throw (EGatewayFirewallBreak) { TTransportList::iterator it(_Transports.find(transportInstanceName)); if (it == _Transports.end()) @@ -1246,7 +1245,6 @@ namespace NLNET } virtual void discloseModule(IModuleProxy *moduleProxy) - throw (EGatewayNotConnected) { nlassert(moduleProxy->getModuleGateway() == this); @@ -1584,7 +1582,6 @@ namespace NLNET } virtual void _broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotPluggedHere) { H_AUTO(CModuleGetaway__broadcastModuleMessage); // send the message to all proxies (except the sender module) diff --git a/code/nel/src/net/module_local_gateway.cpp b/code/nel/src/net/module_local_gateway.cpp index 292a6cafe..0782c2d2c 100644 --- a/code/nel/src/net/module_local_gateway.cpp +++ b/code/nel/src/net/module_local_gateway.cpp @@ -102,7 +102,6 @@ namespace NLNET /// Activate/stop firewalling mode on a transport virtual void setTransportFirewallMode(const std::string &/* transportInstanceName */, bool /* firewalled */) - throw (EGatewayFirewallBreak) { // unsupported nlstop; @@ -174,12 +173,10 @@ namespace NLNET // return; // } // virtual void openGatewayServer(uint16 listeningPort) -// throw (EGatewayAlreadyOpen, EGatewayPortInUse) // { // nlstop; // } // virtual void closeGatewayServer() -// throw (EGatewayNotOpen) // { // nlstop; // } @@ -233,7 +230,6 @@ namespace NLNET { } virtual void discloseModule(IModuleProxy *moduleProxy) - throw (EGatewayNotConnected) { // check that the module is plugged here nlassert(_ModuleProxies.getB(moduleProxy) != NULL); diff --git a/code/studio/src/plugins/object_viewer/particle_system/particle_node.cpp b/code/studio/src/plugins/object_viewer/particle_system/particle_node.cpp index 7bffe2fa3..d8a7573ec 100644 --- a/code/studio/src/plugins/object_viewer/particle_system/particle_node.cpp +++ b/code/studio/src/plugins/object_viewer/particle_system/particle_node.cpp @@ -340,7 +340,7 @@ std::string CParticleWorkspace::getFilename() const return CFile::getFilename(_Filename); } -CWorkspaceNode *CParticleWorkspace::addNode(const std::string &filenameWithFullPath) throw( NLMISC::Exception) +CWorkspaceNode *CParticleWorkspace::addNode(const std::string &filenameWithFullPath) { // Check that file is not already inserted std::string fileName = NLMISC::CFile::getFilename(filenameWithFullPath); From 729ba2ebbda876f58079632a87c53c4e5d6eaf64 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 18 Aug 2018 11:51:55 +0200 Subject: [PATCH 57/65] Fixed: Typo --HG-- branch : develop --- code/nel/src/gui/curl_certificates.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index 11053545a..6d1bc86ee 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -116,7 +116,7 @@ namespace NLGUI // CURL using OpenSSL backend // With OpenSSL compiled without any engine, engines will too return NULL // Fortunately, if OpenSSL isn't compiled with engines means we compiled it ourself and CURL is a recent version - if ((res == CURLE_OK) && engine) + if ((res == CURLE_OK) && engines) { // free engines curl_slist_free_all(engines); From dd03e1f0b1130fbc570d0e71563b8c5408ac927b Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 18 Aug 2018 14:15:32 +0300 Subject: [PATCH 58/65] Fixed: Remove onenter callback from html textarea --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index fdf32f44c..b606a093d 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -4627,6 +4627,7 @@ namespace NLGUI if (multiLine) templateParams.push_back (std::pair ("multi_min_line", toString(rows))); templateParams.push_back (std::pair ("want_return", multiLine?"true":"false")); + templateParams.push_back (std::pair ("onenter", "")); templateParams.push_back (std::pair ("enter_recover_focus", "false")); if (maxlength > 0) templateParams.push_back (std::pair ("max_num_chars", toString(maxlength))); From fc32dc92b9b6085f1602531caa0c9760c84d80a9 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Mon, 20 Aug 2018 20:06:36 +0800 Subject: [PATCH 59/65] Test two-way github sync --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6d75a91f5..1d7b8efd4 100644 --- a/.gitignore +++ b/.gitignore @@ -216,6 +216,7 @@ code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service code/ryzom/server/src/ryzom_naming_service/ryzom_naming_service code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service code/ryzom/server/src/tick_service/tick_service + # WebTT temp dir code/ryzom/tools/server/www/webtt/app/tmp @@ -236,13 +237,13 @@ code/ryzom/tools/server/ryzom_ams/old -#tools and external dir's +# Tools and external directories external external_stlport nel_tools* ryzom_tools* -#Dumps +# Dumps *.dmp code/nel/tools/build_gamedata/processes/ai_wmap/ai_build_wmap.cfg From 0f44a7da27fc5dd261db83d5d85abda8596ebbd7 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Fri, 24 Aug 2018 09:30:56 +0800 Subject: [PATCH 60/65] Fix pointer accessed after delete --- code/ryzom/client/src/r2/dmc/client_edition_module.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp index a3da447dc..66dd94c9f 100644 --- a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -1312,8 +1312,8 @@ void CClientEditionModule::onUserComponentDownloaded(NLNET::IModuleProxy *sender if (decompressionState != Z_OK) { - delete component; - nlwarning("Error: the downloaded user component is corrupted '%s' ", component->Filename.c_str()); + nlwarning("Error: the downloaded user component is corrupted '%s'", component->Filename.c_str()); + delete component; return; } component->UncompressedData[component->UncompressedDataLength] = '\0'; From 37c567c88c57b3bd8442507a7f24469d94e0684a Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sat, 25 Aug 2018 15:31:58 +0800 Subject: [PATCH 61/65] File ai_instance.cpp uses inline processStateEvent from state_instance.h which uses inline testCompatibility from event_reaction_include.h https://gist.github.com/sjvs/8795aae6671734ff991033b510e62de5 --- code/ryzom/server/src/ai_service/ai_instance.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/ryzom/server/src/ai_service/ai_instance.cpp b/code/ryzom/server/src/ai_service/ai_instance.cpp index ef7c4aea9..a4da91956 100644 --- a/code/ryzom/server/src/ai_service/ai_instance.cpp +++ b/code/ryzom/server/src/ai_service/ai_instance.cpp @@ -1566,3 +1566,5 @@ NLMISC_COMMAND(simulateMsgDespawnEasterEgg, "", " Date: Sat, 25 Aug 2018 16:18:24 +0800 Subject: [PATCH 62/65] Change travis options --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ec12c9989..20f9ef43e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ os: matrix: fast_finish: true env: - - CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_LUA51=ON -DWITH_RYZOM_SERVER=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_NEL_TOOLS=OFF" + - CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS=OFF -DWITH_NEL_SAMPLES=ON -DWITH_LUA51=ON -DWITH_RYZOM_SERVER=ON -DWITH_RYZOM_TOOLS=OFF -DWITH_NEL_TOOLS=OFF" - CMAKE_CONFIGURE_OPTIONS="-DCPPTEST_LIBRARY_DEBUG:STRING=/usr/lib/libcpptest.so" CMAKE_BUILD_OPTIONS="--target nel_unit_test -- -j 2" RUN="build/bin/nel_unit_test" From df129ed657844b38465b0a3c3a0c4ab77937a272 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sat, 25 Aug 2018 17:36:22 +0800 Subject: [PATCH 63/65] Put previous config back since it exceeds time limit --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 20f9ef43e..33b3d0f8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ os: matrix: fast_finish: true env: - - CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS=OFF -DWITH_NEL_SAMPLES=ON -DWITH_LUA51=ON -DWITH_RYZOM_SERVER=ON -DWITH_RYZOM_TOOLS=OFF -DWITH_NEL_TOOLS=OFF" + - CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS=OFF -DWITH_NEL_SAMPLES=ON -DWITH_LUA51=ON -DWITH_RYZOM_SERVER=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_NEL_TOOLS=OFF" - CMAKE_CONFIGURE_OPTIONS="-DCPPTEST_LIBRARY_DEBUG:STRING=/usr/lib/libcpptest.so" CMAKE_BUILD_OPTIONS="--target nel_unit_test -- -j 2" RUN="build/bin/nel_unit_test" From ea95d8e0919f933001c17edbd204c5551d406e0b Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sun, 26 Aug 2018 22:58:48 +0300 Subject: [PATCH 64/65] Fixed: HTML list element invalidates content on each frame --HG-- branch : develop --- code/nel/include/nel/gui/interface_element.h | 3 +++ code/nel/include/nel/gui/interface_group.h | 1 + code/nel/src/gui/group_paragraph.cpp | 4 ++-- code/nel/src/gui/group_table.cpp | 10 ++++++++-- code/nel/src/gui/interface_element.cpp | 10 ++++++++-- code/nel/src/gui/interface_group.cpp | 15 ++++++++++++--- code/nel/src/gui/view_text.cpp | 3 +-- 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index cd82417d6..1a360bbc6 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -182,6 +182,9 @@ namespace NLGUI void setMarginLeft(sint32 m) { _MarginLeft = m; } sint32 getMarginLeft() const { return _MarginLeft; } + // Return inner width for child elements + virtual sint32 getInnerWidth() const; + /** * Get the max width used by the window. * diff --git a/code/nel/include/nel/gui/interface_group.h b/code/nel/include/nel/gui/interface_group.h index b9efd3357..01f2b9701 100644 --- a/code/nel/include/nel/gui/interface_group.h +++ b/code/nel/include/nel/gui/interface_group.h @@ -164,6 +164,7 @@ namespace NLGUI sint32 getMaxH () const { return _MaxH; } sint32 getMaxWReal () const { return _Active ? _MaxWReal : 0; } sint32 getMaxHReal () const { return _Active ? _MaxHReal : 0; } + sint32 getInnerWidth () const; sint32 getOfsX () const { return _OffsetX; } sint32 getOfsY () const { return _OffsetY; } bool getResizeFromChildW() const { return _ResizeFromChildW; } diff --git a/code/nel/src/gui/group_paragraph.cpp b/code/nel/src/gui/group_paragraph.cpp index b2635b52e..d7d50af2e 100644 --- a/code/nel/src/gui/group_paragraph.cpp +++ b/code/nel/src/gui/group_paragraph.cpp @@ -1410,7 +1410,7 @@ namespace NLGUI // Get the child width maxWidth += _Elements[k].Element->getMaxUsedW(); } - return maxWidth; + return maxWidth + _MarginLeft; } // ---------------------------------------------------------------------------- @@ -1425,7 +1425,7 @@ namespace NLGUI if (width > minWidth) minWidth = width; } - return minWidth; + return minWidth + _MarginLeft; } diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index ef3eca57a..4408bc9c3 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -703,7 +703,7 @@ namespace NLGUI { if (ContinuousUpdate) { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); + sint parentWidth = _Parent->getInnerWidth(); if (_LastParentW != (sint) parentWidth) { _LastParentW = parentWidth; @@ -1163,7 +1163,7 @@ namespace NLGUI { if (_Parent != NULL) { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); + sint parentWidth = _Parent->getInnerWidth(); if (_LastParentW != (sint) parentWidth) { if (ContinuousUpdate) @@ -1311,6 +1311,9 @@ namespace NLGUI // ---------------------------------------------------------------------------- void CGroupTable::draw () { + // move X for clip and borders + _XReal += _MarginLeft; + // search a parent container CInterfaceGroup *gr = getParent(); while (gr) @@ -1391,6 +1394,9 @@ namespace NLGUI } CInterfaceGroup::draw (); + + // restore + _XReal -= _MarginLeft; } std::string CGroupTable::getProperties( const std::string &name ) const diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 2e13d80e6..d3ed2d01c 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -506,10 +506,16 @@ namespace NLGUI } } + // ------------------------------------------------------------------------------------------------ + sint32 CInterfaceElement::getInnerWidth() const + { + return _WReal - _MarginLeft; + } + // ------------------------------------------------------------------------------------------------ void CInterfaceElement::updateCoords() { - _XReal = _X + _MarginLeft; + _XReal = _X; _YReal = _Y; _WReal = getW(); _HReal = getH(); @@ -526,7 +532,7 @@ namespace NLGUI if (el == NULL) return; - _XReal += el->_XReal - el->_MarginLeft; + _XReal += el->_XReal; _YReal += el->_YReal; THotSpot hsParent = _ParentPosRef; diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index d349411e1..5640da530 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -1397,6 +1397,13 @@ namespace NLGUI restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); } + // ------------------------------------------------------------------------------------------------ + sint32 CInterfaceGroup::getInnerWidth() const + { + sint width = CInterfaceElement::getInnerWidth(); + return std::min(width, _MaxWReal - _MarginLeft); + } + // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::checkCoords() { @@ -1468,7 +1475,7 @@ namespace NLGUI pIE->updateCoords(); } - _XReal -= _OffsetX - _MarginLeft; + _XReal -= (_OffsetX + _MarginLeft); _YReal -= _OffsetY; } @@ -1958,9 +1965,11 @@ namespace NLGUI newSciH = newSciH - ((newSciY+newSciH)-(oldSciY+oldSciH)); } - newSciXDest = newSciX - _MarginLeft; + // Don't apply margins because HTML list marker is drawn outside group paragraph inner content. + // Should not be an issue because horizontal scolling not used. + newSciXDest = newSciX/* + _MarginLeft*/; newSciYDest = newSciY; - newSciWDest = newSciW + _MarginLeft; + newSciWDest = newSciW/* - _MarginLeft*/; newSciHDest = newSciH; } diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index 34f8fd3e1..805143f32 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -916,8 +916,7 @@ namespace NLGUI return _LineMaxW; else { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal() - _Parent->getMarginLeft()); - return std::min(parentWidth-(sint)(_XReal-(_Parent->getXReal()-_Parent->getMarginLeft())), (sint)_LineMaxW); + return std::min(_Parent->getInnerWidth(), (sint)_LineMaxW); } } From f5c8335fa985a8ef2b609d8bac6fb882bbd7ecee Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sun, 26 Aug 2018 22:58:48 +0300 Subject: [PATCH 65/65] Fixed: Wrong table width if colspan is used --HG-- branch : develop --- code/nel/src/gui/group_table.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index 4408bc9c3..b10114a18 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -813,10 +813,6 @@ namespace NLGUI for(sint span = 0; span < cell->ColSpan -1; ++span) { ++column; - _Columns[column].Width = std::max(_Columns[column].Width, _Columns[column-1].Width); - _Columns[column].WidthMax = std::max(_Columns[column].WidthMax, _Columns[column-1].WidthMax); - _Columns[column].TableRatio = std::max(_Columns[column].TableRatio, _Columns[column-1].TableRatio); - _Columns[column].WidthWanted = std::max(_Columns[column].WidthWanted, _Columns[column-1].WidthWanted); _Columns[column].RowSpan = _Columns[column-1].RowSpan; } }