diff --git a/.hgtags b/.hgtags index f13a14cd9..5ff627e15 100644 --- a/.hgtags +++ b/.hgtags @@ -8,3 +8,7 @@ e3fe4855f22c3e75722e015dc33c091c340b3ad7 ryzomcore/v0.11.1 9e583b717fd63be0be9fd60b99087abf1691ea49 ryzomcore/v0.11.2 bfe5628e14a024ba7ea32e4b326ae433a07856b9 ryzomcore/v0.11.3 9a6120735daa97c96ac5d85ca35c7f21f607bd87 ryzomcore/v0.12.0 +3e17907af67e8d66d80e6b714707bbf912607f2a ryzom-patch-3.0.0 +153e0b605c9e0c83ba05b6428c62838b49cc84b2 ryzom-patch-3.0.1 +4300cc14aad098b1f86ea4c55577b7fa4a4cb5d2 ryzom-patch-3.1.0 +043aaeb3d8a2a54177581b57bda87a9deaad510e ryzom-patch-3.1.0-april_patch diff --git a/.travis.yml b/.travis.yml index c3835f23b..ec12c9989 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,7 @@ os: matrix: fast_finish: true env: - - CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS:BOOL=off -DWITH_LUA51:BOOL=on -DWITH_LUA52:BOOL=off -DWITH_LUA53:BOOL=off" - - CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS:BOOL=off -DWITH_LUA51:BOOL=off -DWITH_LUA52:BOOL=on -DWITH_LUA53:BOOL=off" - - CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS:BOOL=off -DWITH_LUA51:BOOL=off -DWITH_LUA52:BOOL=off -DWITH_LUA53:BOOL=on" + - 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="-DCPPTEST_LIBRARY_DEBUG:STRING=/usr/lib/libcpptest.so" CMAKE_BUILD_OPTIONS="--target nel_unit_test -- -j 2" RUN="build/bin/nel_unit_test" @@ -19,10 +17,7 @@ env: addons: apt: packages: - - liblua5.1-0-dev - - liblua5.1-0-dbg - - liblua5.2-0-dev - - liblua5.2-0-dbg + - liblua5.1-dev - libluabind-dev - libcpptest-dev - libogg-dev diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 67076ffa8..0e72cc5f9 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -28,15 +28,11 @@ IF(COMMAND cmake_policy) # have absolute paths (e.g. -lpthread) cmake_policy(SET CMP0003 NEW) - # Works around warnings about escaped quotes in ADD_DEFINITIONS - # statements - cmake_policy(SET CMP0005 OLD) - # allow to link to qtmain automatically under Windows IF(POLICY CMP0020) CMAKE_POLICY(SET CMP0020 NEW) ENDIF() -ENDIF(COMMAND cmake_policy) +ENDIF() INCLUDE(nel) INCLUDE(ConfigureChecks) @@ -71,15 +67,15 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) # DLL should be in the same directory as EXE under Windows IF(WIN32) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -ELSE(WIN32) +ELSE() SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -ENDIF(WIN32) +ENDIF() IF(WIN32) IF(WITH_MFC) FIND_PACKAGE(MFC QUIET) - ENDIF(WITH_MFC) -ENDIF(WIN32) + ENDIF() +ENDIF() #----------------------------------------------------------------------------- # Set default config options @@ -93,8 +89,6 @@ NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS() NL_SETUP_PREFIX_PATHS() RYZOM_SETUP_PREFIX_PATHS() -NL_CONFIGURE_CHECKS() - NL_SETUP_BUILD() NL_SETUP_BUILD_FLAGS() @@ -108,8 +102,8 @@ IF(WIN32) IF(WITH_MFC) FIND_PACKAGE(CustomMFC REQUIRED) - ENDIF(WITH_MFC) -ENDIF(WIN32) + ENDIF() +ENDIF() FIND_PACKAGE(ZLIB REQUIRED) FIND_PACKAGE(LibXml2 REQUIRED) @@ -118,15 +112,29 @@ FIND_PACKAGE(OpenSSL REQUIRED) FIND_PACKAGE(GIF) FIND_PACKAGE(Jpeg) +IF(WIN32) + SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib) +ENDIF() + +IF(WITH_LIBOVR) + FIND_PACKAGE(LibOVR) +ENDIF() + +IF(WITH_LIBVR) + FIND_PACKAGE(LibVR) +ENDIF() + +NL_CONFIGURE_CHECKS() + IF(WITH_STATIC_LIBXML2) SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC) -ENDIF(WITH_STATIC_LIBXML2) +ENDIF() IF(WITH_LIBXML2_ICONV) FIND_PACKAGE(Iconv REQUIRED) INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR}) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES}) -ENDIF(WITH_LIBXML2_ICONV) +ENDIF() IF(WITH_STATIC) # libxml2 could need winsock2 library @@ -141,40 +149,45 @@ IF(WITH_STATIC) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBLZMA_LIBRARIES}) ENDIF() ENDIF() -ENDIF(WITH_STATIC) +ENDIF() INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/PCHSupport.cmake) IF(FINAL_VERSION) ADD_DEFINITIONS(-DFINAL_VERSION=1) -ENDIF(FINAL_VERSION) +ENDIF() IF(WITH_SSE2) ADD_DEFINITIONS(-DNL_HAS_SSE2) IF(WITH_SSE3) ADD_DEFINITIONS(-DNL_HAS_SSE3) - ENDIF(WITH_SSE3) -ENDIF(WITH_SSE2) - -IF(APPLE_CERTIFICATE) - # Find codesign_allocate - - # Xcode 7.0 and later versions - SET(CODESIGN_ALLOCATE ${OSX_DEVELOPER_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate) - - IF(NOT EXISTS "${CODESIGN_ALLOCATE}") - # Xcode 6.4 and previous versions - SET(CODESIGN_ALLOCATE ${CMAKE_OSX_SYSROOT}/usr/bin/codesign_allocate) ENDIF() +ENDIF() - IF(NOT EXISTS "${CODESIGN_ALLOCATE}") - # System path - SET(CODESIGN_ALLOCATE /usr/bin/codesign_allocate) - ENDIF() +IF(APPLE) + FIND_LIBRARY(CARBON_FRAMEWORK Carbon) + FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation) - IF(NOT EXISTS "${CODESIGN_ALLOCATE}") - MESSAGE(WARNING "Unable to find codesign_allocate in standard directories") - SET(CODESIGN_ALLOCATE) + IF(APPLE_CERTIFICATE) + # Find codesign_allocate + + # Xcode 7.0 and later versions + SET(CODESIGN_ALLOCATE ${OSX_DEVELOPER_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate) + + IF(NOT EXISTS "${CODESIGN_ALLOCATE}") + # Xcode 6.4 and previous versions + SET(CODESIGN_ALLOCATE ${CMAKE_OSX_SYSROOT}/usr/bin/codesign_allocate) + ENDIF() + + IF(NOT EXISTS "${CODESIGN_ALLOCATE}") + # System path + SET(CODESIGN_ALLOCATE /usr/bin/codesign_allocate) + ENDIF() + + IF(NOT EXISTS "${CODESIGN_ALLOCATE}") + MESSAGE(WARNING "Unable to find codesign_allocate in standard directories") + SET(CODESIGN_ALLOCATE) + ENDIF() ENDIF() ENDIF() @@ -300,7 +313,7 @@ IF(WITH_QT5) ADD_QT_LIBRARY(XcbQpa) ADD_QT_LIBRARY(PlatformSupport) - SET(QT_LIBRARIES ${QT_LIBRARIES} -lX11-xcb -lXi -lSM -lICE -lxcb -lGL) + SET(QT_LIBRARIES ${QT_LIBRARIES} -lX11-xcb -lXi -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() @@ -324,7 +337,7 @@ IF(WITH_QT5) ENDIF() # freetype is needed since Qt 5.5 - FIND_PACKAGE(FreeType) + FIND_PACKAGE(Freetype) IF(FREETYPE_FOUND) SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIBRARIES}) @@ -370,8 +383,6 @@ IF(WITH_QT5) IF(APPLE) FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre) - FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation) - FIND_LIBRARY(CARBON_FRAMEWORK Carbon) FIND_LIBRARY(SECURITY_FRAMEWORK Security) SET(QT_LIBRARIES ${QT_LIBRARIES} @@ -395,16 +406,16 @@ IF(WITH_QT) # Use Qt 4 FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtOpenGL REQUIRED) -ENDIF(WITH_QT) +ENDIF() IF(WITH_ASSIMP) FIND_PACKAGE(assimp REQUIRED) -ENDIF(WITH_ASSIMP) +ENDIF() IF(WITH_NEL) IF(WITH_NEL_TESTS) FIND_PACKAGE(CppTest) - ENDIF(WITH_NEL_TESTS) + ENDIF() IF(WITH_GUI) FIND_PACKAGE(Luabind REQUIRED) @@ -442,19 +453,19 @@ IF(WITH_NEL) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include) ADD_SUBDIRECTORY(nel) -ENDIF(WITH_NEL) +ENDIF() IF(WITH_RYZOM) ADD_SUBDIRECTORY(ryzom) -ENDIF(WITH_RYZOM) +ENDIF() IF(WITH_NELNS) ADD_SUBDIRECTORY(nelns) -ENDIF(WITH_NELNS) +ENDIF() IF(WITH_SNOWBALLS) ADD_SUBDIRECTORY(snowballs2) -ENDIF(WITH_SNOWBALLS) +ENDIF() IF(WITH_TOOLS) ADD_SUBDIRECTORY(tool) @@ -462,22 +473,22 @@ ENDIF() IF(WITH_STUDIO) ADD_SUBDIRECTORY(studio) -ENDIF(WITH_STUDIO) +ENDIF() # To build the documention, you will have to enable it # and then do the equivalent of "make DoxygenDoc". IF(BUILD_DOCUMENTATION) IF(DOT) SET(HAVE_DOT YES) - ELSE(DOT) + ELSE() SET(HAVE_DOT NO) - ENDIF(DOT) + ENDIF() # This processes our Doxyfile.in and substitutes paths to generate # a final Doxyfile CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/doc/Doxyfile.cmake.in ${CMAKE_BINARY_DIR}/doc/Doxyfile) ADD_CUSTOM_TARGET(DoxygenDoc ${DOXYGEN} ${CMAKE_BINARY_DIR}/doc/Doxyfile) -ENDIF(BUILD_DOCUMENTATION) +ENDIF() IF(WITH_NEL_TESTS) ENABLE_TESTING() @@ -487,8 +498,8 @@ IF(WITH_NEL_TESTS) SET(SVNCOMMAND svn) SET(SVNSOURCEDIR http://dev.ryzom.com/svn/trunk/nel) SET(GENERATELOGS svn2cl) - ENDIF(BUILD_DASHBOARD) -ENDIF(WITH_NEL_TESTS) + ENDIF() +ENDIF() # packaging information SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ryzom Core MMORPG Framework") @@ -520,10 +531,10 @@ IF(WIN32) #SET(CPACK_GENERATOR "NSIS") SET(CPACK_GENERATOR "NSIS;ZIP") SET(CPACK_SOURCE_GENERATOR "ZIP") -ELSE(WIN32) +ELSE() SET(CPACK_GENERATOR "TGZ") SET(CPACK_SOURCE_GENERATOR "TGZ") -ENDIF(WIN32) +ENDIF() set(CPACK_SOURCE_IGNORE_FILES "~$" "\\\\.cvsignore$" @@ -541,8 +552,8 @@ IF(WIN32) "${QT_LIBRARY_DIR}/../bin/QtXmld4.dll" "${QT_LIBRARY_DIR}/../bin/QtCored4.dll" DESTINATION ${NL_BIN_PREFIX}) - ENDIF(WITH_QT) - ELSE(NOT CMAKE_BUILD_TYPE STREQUAL "Release") + ENDIF() + ELSE() IF(WITH_QT) INCLUDE(${QT_USE_FILE}) INSTALL(FILES @@ -550,8 +561,8 @@ IF(WIN32) "${QT_LIBRARY_DIR}/../bin/QtXml4.dll" "${QT_LIBRARY_DIR}/../bin/QtCore4.dll" DESTINATION ${NL_BIN_PREFIX}) - ENDIF(WITH_QT) - ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "Release") + ENDIF() + ENDIF() # Install CEGUI and its dependencies. IF(WITH_NEL_CEGUI) @@ -561,14 +572,14 @@ IF(WIN32) INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIFalagardWRBase.dll" DESTINATION ${NL_BIN_PREFIX}) INSTALL(FILES "${CEGUI_LIB_DIR}/Devil.dll" DESTINATION ${NL_BIN_PREFIX}) INSTALL(FILES "${CEGUI_LIB_DIR}/ILU.dll" DESTINATION ${NL_BIN_PREFIX}) - ENDIF(WITH_NEL_CEGUI) + ENDIF() # Only the tools require MFC. IF(WITH_TOOLS) SET(CMAKE_INSTALL_MFC_LIBRARIES TRUE) - ENDIF(WITH_TOOLS) + ENDIF() #INCLUDE(InstallRequiredSystemLibraries) -ENDIF(WIN32) +ENDIF() INCLUDE(CPack) @@ -578,4 +589,4 @@ INCLUDE(CMakePackaging.txt) #INCLUDE(UseDebian) #IF(DEBIAN_FOUND) # ADD_DEBIAN_TARGETS(nel) -#ENDIF(DEBIAN_FOUND) +#ENDIF() diff --git a/code/CMakeModules/AndroidToolChain.cmake b/code/CMakeModules/AndroidToolChain.cmake index 7135400e2..4ca702295 100644 --- a/code/CMakeModules/AndroidToolChain.cmake +++ b/code/CMakeModules/AndroidToolChain.cmake @@ -28,14 +28,14 @@ IF(TARGET_CPU STREQUAL "armv7") SET(TOOLCHAIN_ARCH "arm") SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi") SET(TOOLCHAIN_BIN_PREFIX "arm-linux-androideabi") - SET(MINIMUM_NDK_TARGET 4) + SET(MINIMUM_NDK_TARGET 9) ELSEIF(TARGET_CPU STREQUAL "armv5") SET(LIBRARY_ARCHITECTURE "armeabi") SET(CMAKE_SYSTEM_PROCESSOR "armv5") SET(TOOLCHAIN_ARCH "arm") SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi") SET(TOOLCHAIN_BIN_PREFIX "arm-linux-androideabi") - SET(MINIMUM_NDK_TARGET 4) + SET(MINIMUM_NDK_TARGET 9) ELSEIF(TARGET_CPU STREQUAL "arm64") SET(LIBRARY_ARCHITECTURE "arm64-v8a") SET(CMAKE_SYSTEM_PROCESSOR "arm64") @@ -76,14 +76,9 @@ ELSE() ENDIF() SET(CLANG_TOOLCHAIN_PREFIX "llvm") -SET(ANDROID_COMPILER "GCC") - -IF(NDK_TOOLCHAIN_VERSION STREQUAL "clang") - SET(ANDROID_COMPILER "clang") - SET(CLANG ON) -ELSE() - SET(GCC_TOOLCHAIN_VERSION ${NDK_TOOLCHAIN_VERSION}) -ENDIF() +SET(ANDROID_COMPILER "clang") +SET(ANDROID_COMPILER "clang") +SET(CLANG ON) IF(NOT NDK_TARGET) SET(NDK_TARGET ${MINIMUM_NDK_TARGET}) @@ -94,88 +89,71 @@ ELSE() ENDIF() IF(CMAKE_HOST_WIN32) - SET(TOOLCHAIN_HOST "windows") + SET(TOOLCHAIN_HOST "windows-x86_64") SET(TOOLCHAIN_BIN_SUFFIX ".exe") ELSEIF(CMAKE_HOST_APPLE) SET(TOOLCHAIN_HOST "apple") SET(TOOLCHAIN_BIN_SUFFIX "") ELSEIF(CMAKE_HOST_UNIX) - SET(TOOLCHAIN_HOST "linux") + SET(TOOLCHAIN_HOST "linux-x86_64") SET(TOOLCHAIN_BIN_SUFFIX "") ENDIF() -MACRO(SEARCH_TOOLCHAIN _COMPILER) - SET(${_COMPILER}_TOOLCHAIN_VERSIONS) - FILE(GLOB _TOOLCHAIN_VERSIONS "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}-*") - IF(_TOOLCHAIN_VERSIONS) - LIST(SORT _TOOLCHAIN_VERSIONS) - LIST(REVERSE _TOOLCHAIN_VERSIONS) - FOREACH(_TOOLCHAIN_VERSION ${_TOOLCHAIN_VERSIONS}) - STRING(REGEX REPLACE ".+${_PREFIX}-([0-9.]+)" "\\1" _TOOLCHAIN_VERSION "${_TOOLCHAIN_VERSION}") - IF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$") - LIST(APPEND ${_COMPILER}_TOOLCHAIN_VERSIONS ${_TOOLCHAIN_VERSION}) - ENDIF() - ENDFOREACH() - ENDIF() +# clang +SET(CLANG_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${CLANG_TOOLCHAIN_PREFIX}/prebuilt/${TOOLCHAIN_HOST}") - # try prefixes without version - SET(_TOOLCHAIN_WITHOUT_VERSION "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}") - IF(EXISTS ${_TOOLCHAIN_WITHOUT_VERSION}) - LIST(APPEND ${_COMPILER}_TOOLCHAIN_VERSIONS "default") - ENDIF() +IF(EXISTS ${CLANG_TOOLCHAIN_ROOT}) + MESSAGE(STATUS "Found LLVM toolchain in ${CLANG_TOOLCHAIN_ROOT}") +ELSE() + MESSAGE(FATAL_ERROR "No LLVM toolchain found in default search path ${CLANG_TOOLCHAIN_ROOT}") +ENDIF() - IF(NOT ${_COMPILER}_TOOLCHAIN_VERSIONS) - MESSAGE(FATAL_ERROR "No Android ${_COMPILER} toolchain found in default search path ${NDK_ROOT}/toolchains") - ENDIF() - - IF(${_COMPILER}_TOOLCHAIN_VERSIONS) - LIST(FIND ${_COMPILER}_TOOLCHAIN_VERSIONS "${${_COMPILER}_TOOLCHAIN_VERSION}" _INDEX) - IF(_INDEX EQUAL -1) - LIST(GET ${_COMPILER}_TOOLCHAIN_VERSIONS 0 ${_COMPILER}_TOOLCHAIN_VERSION) +# gcc +SET(GCC_TOOLCHAIN_VERSIONS) +FILE(GLOB _TOOLCHAIN_VERSIONS "${NDK_ROOT}/toolchains/${GCC_TOOLCHAIN_PREFIX}-*") +IF(_TOOLCHAIN_VERSIONS) + LIST(SORT _TOOLCHAIN_VERSIONS) + LIST(REVERSE _TOOLCHAIN_VERSIONS) + FOREACH(_TOOLCHAIN_VERSION ${_TOOLCHAIN_VERSIONS}) + STRING(REGEX REPLACE ".+${_PREFIX}-([0-9.]+)" "\\1" _TOOLCHAIN_VERSION "${_TOOLCHAIN_VERSION}") + IF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$") + LIST(APPEND GCC_TOOLCHAIN_VERSIONS ${_TOOLCHAIN_VERSION}) ENDIF() - ELSE() - LIST(GET ${_COMPILER}_TOOLCHAIN_VERSIONS 0 ${_COMPILER}_TOOLCHAIN_VERSION) - ENDIF() - - MESSAGE(STATUS "TOOLCHAIN_PREFIX = ${${_COMPILER}_TOOLCHAIN_VERSION}") - - IF("${${_COMPILER}_TOOLCHAIN_VERSION}" STREQUAL "default") - MESSAGE(STATUS "default") - SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}/prebuilt/${TOOLCHAIN_HOST}") - ELSE() - MESSAGE(STATUS "not default") - SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}-${${_COMPILER}_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}") - ENDIF() - - IF(NOT EXISTS "${${_COMPILER}_TOOLCHAIN_ROOT}") - FILE(GLOB _TOOLCHAIN_PREFIXES "${${_COMPILER}_TOOLCHAIN_ROOT}*") - IF(_TOOLCHAIN_PREFIXES) - LIST(GET _TOOLCHAIN_PREFIXES 0 ${_COMPILER}_TOOLCHAIN_ROOT) - ENDIF() - ENDIF() -ENDMACRO() - -IF(CLANG) - SEARCH_TOOLCHAIN(CLANG) - - MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use clang ${CLANG_TOOLCHAIN_VERSION}") + ENDFOREACH() ENDIF() -SEARCH_TOOLCHAIN(GCC) - -MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use GCC ${GCC_TOOLCHAIN_VERSION}") - -IF(CLANG_TOOLCHAIN_ROOT) - MESSAGE(STATUS "Found Android LLVM toolchain in ${CLANG_TOOLCHAIN_ROOT}") +IF(NOT GCC_TOOLCHAIN_VERSIONS) + MESSAGE(FATAL_ERROR "No GCC version found in default search path ${NDK_ROOT}/toolchains") ENDIF() -IF(GCC_TOOLCHAIN_ROOT) - MESSAGE(STATUS "Found Android GCC toolchain in ${GCC_TOOLCHAIN_ROOT}") +IF(GCC_TOOLCHAIN_VERSIONS) + LIST(FIND GCC_TOOLCHAIN_VERSIONS "${GCC_TOOLCHAIN_VERSION}" _INDEX) + IF(_INDEX EQUAL -1) + LIST(GET GCC_TOOLCHAIN_VERSIONS 0 GCC_TOOLCHAIN_VERSION) + ENDIF() +ELSE() + LIST(GET GCC_TOOLCHAIN_VERSIONS 0 GCC_TOOLCHAIN_VERSION) ENDIF() +SET(GCC_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${GCC_TOOLCHAIN_PREFIX}-${GCC_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}") + +IF(NOT EXISTS "${GCC_TOOLCHAIN_ROOT}") + FILE(GLOB _TOOLCHAIN_PREFIXES "${GCC_TOOLCHAIN_ROOT}*") + IF(_TOOLCHAIN_PREFIXES) + LIST(GET _TOOLCHAIN_PREFIXES 0 GCC_TOOLCHAIN_ROOT) + ENDIF() +ENDIF() + +IF(EXISTS "${GCC_TOOLCHAIN_ROOT}") + MESSAGE(STATUS "Found GCC toolchain in ${GCC_TOOLCHAIN_ROOT}") +ELSE() + MESSAGE(FATAL_ERROR "No GCC toolchain found in default search path ${GCC_TOOLCHAIN_ROOT}") +ENDIF() + +# NDK SET(PLATFORM_ROOT "${NDK_ROOT}/platforms/android-${NDK_TARGET}/arch-${TOOLCHAIN_ARCH}") -MESSAGE(STATUS "Found Android platform in ${PLATFORM_ROOT}") +MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} found in ${PLATFORM_ROOT}") # include dirs SET(PLATFORM_INCLUDE_DIR "${PLATFORM_ROOT}/usr/include") @@ -208,41 +186,29 @@ MACRO(SET_TOOLCHAIN_BINARY_GCC _NAME _BINARY) SET(${_NAME} ${GCC_TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE) ENDMACRO() -# Force the compilers to GCC for Android -include (CMakeForceCompiler) +SET(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) -IF(CLANG) - MESSAGE(STATUS "Using clang compiler") +SET_TOOLCHAIN_BINARY_LLVM(CMAKE_C_COMPILER clang) +SET_TOOLCHAIN_BINARY_LLVM(CMAKE_CXX_COMPILER clang++) - SET_TOOLCHAIN_BINARY_LLVM(CMAKE_C_COMPILER clang) - SET_TOOLCHAIN_BINARY_LLVM(CMAKE_CXX_COMPILER clang++) +SET(CMAKE_C_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN_BIN_PREFIX}) +SET(CMAKE_C_COMPILER_FORCED TRUE) - CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} clang) - CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} clang) +SET(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER}) +SET(CMAKE_CXX_COMPILER_TARGET ${TOOLCHAIN_BIN_PREFIX}) +SET(CMAKE_CXX_COMPILER_FORCED TRUE) - SET_TOOLCHAIN_BINARY_LLVM(CMAKE_ASM_COMPILER llvm-as) - SET_TOOLCHAIN_BINARY_LLVM(CMAKE_AR llvm-ar) - SET_TOOLCHAIN_BINARY_LLVM(CMAKE_LINKER clang++) - - IF(NOT EXISTS "${CMAKE_ASM_COMPILER}") - SET_TOOLCHAIN_BINARY_GCC(CMAKE_ASM_COMPILER as) - ENDIF() - - IF(NOT EXISTS "${CMAKE_AR}") - SET_TOOLCHAIN_BINARY_GCC(CMAKE_AR ar) - ENDIF() -ELSE() - MESSAGE(STATUS "Using GCC compiler") - - SET_TOOLCHAIN_BINARY_GCC(CMAKE_C_COMPILER gcc) - SET_TOOLCHAIN_BINARY_GCC(CMAKE_CXX_COMPILER g++) - - CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} GNU) - CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} GNU) +SET_TOOLCHAIN_BINARY_LLVM(CMAKE_ASM_COMPILER llvm-as) +SET_TOOLCHAIN_BINARY_LLVM(CMAKE_AR llvm-ar) +SET_TOOLCHAIN_BINARY_LLVM(CMAKE_LINKER clang++) +IF(NOT EXISTS "${CMAKE_ASM_COMPILER}") SET_TOOLCHAIN_BINARY_GCC(CMAKE_ASM_COMPILER as) +ENDIF() + +IF(NOT EXISTS "${CMAKE_AR}") SET_TOOLCHAIN_BINARY_GCC(CMAKE_AR ar) - SET_TOOLCHAIN_BINARY_GCC(CMAKE_LINKER ld) ENDIF() SET_TOOLCHAIN_BINARY_GCC(CMAKE_STRIP strip) diff --git a/code/CMakeModules/CheckDepends.cmake b/code/CMakeModules/CheckDepends.cmake index d2fbe06e1..701dcd48b 100644 --- a/code/CMakeModules/CheckDepends.cmake +++ b/code/CMakeModules/CheckDepends.cmake @@ -24,8 +24,8 @@ MACRO(CHECK_UNDEFINED_SYMBOL MYLIBRARY SYMBOL SYMBOL_FOUND) IF(NOT NM_SYMBOL MATCHES ${SYMBOL}) SET(${SYMBOL_FOUND} FALSE) # MESSAGE(STATUS "Defined symbol ${SYMBOL} detected in ${${MYLIBRARY}}") - ENDIF(NOT NM_SYMBOL MATCHES ${SYMBOL}) - ENDIF(CMAKE_NM) + ENDIF() + ENDIF() ELSEIF(UNIX) SET(CMAKE_OBJDUMP objdump) IF(CMAKE_OBJDUMP) @@ -35,11 +35,11 @@ MACRO(CHECK_UNDEFINED_SYMBOL MYLIBRARY SYMBOL SYMBOL_FOUND) IF(NOT OBJDUMP_SYMBOL MATCHES "UND") #MESSAGE(STATUS "${${MYLIBRARY}} does not use symbol ${SYMBOL}") SET(${SYMBOL_FOUND} FALSE) - ELSE(NOT OBJDUMP_SYMBOL MATCHES "UND") + ELSE() #MESSAGE(STATUS "${${MYLIBRARY}} uses symbol ${SYMBOL}") - ENDIF(NOT OBJDUMP_SYMBOL MATCHES "UND") - ENDIF(CMAKE_OBJDUMP) - ENDIF(WIN32) + ENDIF() + ENDIF() + ENDIF() ENDMACRO(CHECK_UNDEFINED_SYMBOL) # CHECK_LINKED_LIBRARY @@ -66,8 +66,8 @@ MACRO(CHECK_LINKED_LIBRARY MYLIBRARY OTHERLIBRARY LIBRARY_FOUND) IF(OTOOL_LIBRARY MATCHES "${LIBNAME}") SET(${LIBRARY_FOUND} TRUE) # MESSAGE(STATUS "Library ${LIBNAME} already linked to ${${MYLIBRARY}}") - ENDIF(OTOOL_LIBRARY MATCHES "${LIBNAME}") - ENDIF(CMAKE_OTOOL) + ENDIF() + ENDIF() ELSEIF(UNIX) SET(CMAKE_OBJDUMP objdump) IF(CMAKE_OBJDUMP) @@ -79,11 +79,11 @@ MACRO(CHECK_LINKED_LIBRARY MYLIBRARY OTHERLIBRARY LIBRARY_FOUND) IF(OBJDUMP_LIBRARY MATCHES "NEEDED") #MESSAGE(STATUS "${${MYLIBRARY}} references to ${LIBNAME}.") SET(${LIBRARY_FOUND} TRUE) - ELSE(OBJDUMP_LIBRARY MATCHES "NEEDED") + ELSE() #MESSAGE(STATUS "${${MYLIBRARY}} does not reference to ${LIBNAME}!") - ENDIF(OBJDUMP_LIBRARY MATCHES "NEEDED") - ENDIF(CMAKE_OBJDUMP) - ENDIF(WIN32) + ENDIF() + ENDIF() + ENDIF() ENDMACRO(CHECK_LINKED_LIBRARY) MACRO(CHECK_DEPENDS MYLIBRARY OTHERLIBRARY SYMBOL MUSTLINK) @@ -91,13 +91,13 @@ MACRO(CHECK_DEPENDS MYLIBRARY OTHERLIBRARY SYMBOL MUSTLINK) IF(SYMBOL_FOUND) CHECK_LINKED_LIBRARY(MYLIBRARY OTHERLIBRARY LIBRARY_FOUND) - ENDIF(SYMBOL_FOUND) + ENDIF() IF(SYMBOL_FOUND AND NOT LIBRARY_FOUND) SET(${MUSTLINK} YES) - ELSE(SYMBOL_FOUND AND NOT LIBRARY_FOUND) + ELSE() SET(${MUSTLINK} NO) - ENDIF(SYMBOL_FOUND AND NOT LIBRARY_FOUND) + ENDIF() ENDMACRO(CHECK_DEPENDS) # LINK_DEPENDS @@ -116,23 +116,23 @@ MACRO(LINK_DEPENDS LIBRARIES MYLIBRARY OTHERLIBRARY SYMBOL) IF(WIN32 OR WITH_STATIC) # In static, we link all libraries because it will keep only used symbols SET(MUST_LINK TRUE) - ELSE(WIN32 OR WITH_STATIC) + ELSE() CHECK_UNDEFINED_SYMBOL(${MYLIBRARY} ${SYMBOL} SYMBOL_FOUND) IF(SYMBOL_FOUND) CHECK_LINKED_LIBRARY(${MYLIBRARY} ${OTHERLIBRARY} LIBRARY_FOUND) - ENDIF(SYMBOL_FOUND) + ENDIF() IF(SYMBOL_FOUND AND NOT LIBRARY_FOUND) MESSAGE(STATUS "Underlinking found: ${${MYLIBRARY}} needs ${${OTHERLIBRARY}} but is not linked to, manually linking...") SET(MUST_LINK TRUE) - ENDIF(SYMBOL_FOUND AND NOT LIBRARY_FOUND) - ENDIF(WIN32 OR WITH_STATIC) - ENDIF(${MYLIBRARY} AND ${OTHERLIBRARY} AND NOT ${OTHERLIBRARY}_LINKED) + ENDIF() + ENDIF() + ENDIF() IF(MUST_LINK) MESSAGE(STATUS "Linking with ${${OTHERLIBRARY}}") SET(${LIBRARIES} ${${LIBRARIES}} ${${OTHERLIBRARY}}) SET(${OTHERLIBRARY}_LINKED TRUE) - ENDIF(MUST_LINK) + ENDIF() ENDMACRO(LINK_DEPENDS) diff --git a/code/CMakeModules/ConfigureChecks.cmake b/code/CMakeModules/ConfigureChecks.cmake index 3929d65c9..1eade142c 100644 --- a/code/CMakeModules/ConfigureChecks.cmake +++ b/code/CMakeModules/ConfigureChecks.cmake @@ -40,7 +40,8 @@ MACRO(NL_CONFIGURE_CHECKS) SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}.${REVISION}") SET(NL_VERSION_RC "${NL_VERSION_MAJOR},${NL_VERSION_MINOR},${NL_VERSION_PATCH},${REVISION}") - SET(RYZOM_VERSION "${RYZOM_VERSION_MAJOR}.${RYZOM_VERSION_MINOR}.${RYZOM_VERSION_PATCH}.${REVISION}") + SET(RYZOM_VERSION_SHORT "${RYZOM_VERSION_MAJOR}.${RYZOM_VERSION_MINOR}.${RYZOM_VERSION_PATCH}") + SET(RYZOM_VERSION "${RYZOM_VERSION_SHORT}.${REVISION}") SET(RYZOM_VERSION_RC "${RYZOM_VERSION_MAJOR},${RYZOM_VERSION_MINOR},${RYZOM_VERSION_PATCH},${REVISION}") NOW(BUILD_DATE) diff --git a/code/CMakeModules/Find3dsMaxSDK.cmake b/code/CMakeModules/Find3dsMaxSDK.cmake index bde126208..cf49a90d3 100644 --- a/code/CMakeModules/Find3dsMaxSDK.cmake +++ b/code/CMakeModules/Find3dsMaxSDK.cmake @@ -18,6 +18,7 @@ FIND_PATH(MAXSDK_DIR PATHS "$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk" "$ENV{3DSMAX_2011_SDK_PATH}/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2017 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk" @@ -36,12 +37,12 @@ FIND_PATH(MAXSDK_CS_INCLUDE_DIR bipexp.h ) IF(TARGET_X64) - SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/x64/lib) + SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/x64/lib ${MAXSDK_DIR}/lib/x64/Release) ELSE() SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/lib) ENDIF() -MACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME) +MACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME) FIND_LIBRARY(${MYLIBRARY} NAMES ${MYLIBRARYNAME} HINTS @@ -73,10 +74,28 @@ if(MAXSDK_FOUND) ${MAXSDK_MAXUTIL_LIBRARY} ${MAXSDK_MAXSCRIPT_LIBRARY} ${MAXSDK_PARAMBLK2_LIBRARY} - ${MAXSDK_BMM_LIBRARY} ) + ${MAXSDK_BMM_LIBRARY}) -else(MAXSDK_FOUND) + # parse maxversion.h to determine SDK version + IF(EXISTS "${MAXSDK_DIR}/include/maxversion.h") + FILE(STRINGS "${MAXSDK_DIR}/include/maxversion.h" LINES REGEX "#define MAX_PRODUCT_YEAR_NUMBER ([0-9]+)") + + STRING(REGEX REPLACE ".+MAX_PRODUCT_YEAR_NUMBER ([0-9]+)" "\\1" MAXSDK_VERSION "${LINES}") + UNSET(LINES) + ELSE() + SET(MAXSDK_VERSION "Unknown") + ENDIF() + + MESSAGE(STATUS "Found 3dsmax version ${MAXSDK_VERSION} in ${MAXSDK_DIR}") + + # 3ds Max 2013 and later are always Unicode + IF(MAXSDK_VERSION VERSION_GREATER 2012) + SET(MAXSDK_DEFINITIONS -DUNICODE -D_UNICODE) + ELSE() + SET(MAXSDK_DEFINITIONS) + ENDIF() +ELSE() set(MAXSDK_LIBRARIES) -endif(MAXSDK_FOUND) +ENDIF() mark_as_advanced(MAXSDK_INCLUDE_DIR MAXSDK_LIBRARY) diff --git a/code/CMakeModules/FindCEGUI.cmake b/code/CMakeModules/FindCEGUI.cmake index a939ebfb7..3259574fc 100644 --- a/code/CMakeModules/FindCEGUI.cmake +++ b/code/CMakeModules/FindCEGUI.cmake @@ -7,7 +7,7 @@ IF(CEGUI_LIBRARY AND CEGUI_INCLUDE_DIRS) # in cache already SET(CEGUI_FIND_QUIETLY TRUE) -ENDIF(CEGUI_LIBRARY AND CEGUI_INCLUDE_DIRS) +ENDIF() FIND_PATH(CEGUI_INCLUDE_DIRS @@ -45,9 +45,9 @@ IF(CEGUI_LIBRARY AND CEGUI_INCLUDE_DIRS) SET(CEGUI_INCLUDE_DIRS "${CEGUI_INCLUDE_DIRS}/CEGUI") IF(NOT CEGUI_FIND_QUIETLY) MESSAGE(STATUS "Found CEGUI: ${CEGUI_LIBRARY}") - ENDIF(NOT CEGUI_FIND_QUIETLY) -ELSE(CEGUI_LIBRARY AND CEGUI_INCLUDE_DIRS) + ENDIF() +ELSE() IF(NOT CEGUI_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find CEGUI!") - ENDIF(NOT CEGUI_FIND_QUIETLY) -ENDIF(CEGUI_LIBRARY AND CEGUI_INCLUDE_DIRS) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/FindCppTest.cmake b/code/CMakeModules/FindCppTest.cmake index f5f823f69..7dc2aa35d 100644 --- a/code/CMakeModules/FindCppTest.cmake +++ b/code/CMakeModules/FindCppTest.cmake @@ -10,7 +10,7 @@ IF(CPPTEST_LIBRARIES AND CPPTEST_INCLUDE_DIR) # in cache already SET(CPPTEST_FIND_QUIETLY TRUE) -ENDIF(CPPTEST_LIBRARIES AND CPPTEST_INCLUDE_DIR) +ENDIF() FIND_PATH(CPPTEST_INCLUDE_DIR cpptest.h @@ -30,7 +30,7 @@ SET(LIBRARY_NAME_DEBUG cpptestd) IF(WITH_STLPORT) SET(LIBRARY_NAME_RELEASE cpptest_stlport ${LIBRARY_NAME_RELEASE}) SET(LIBRARY_NAME_DEBUG cpptest_stlportd ${LIBRARY_NAME_DEBUG}) -ENDIF(WITH_STLPORT) +ENDIF() FIND_LIBRARY(CPPTEST_LIBRARY_RELEASE ${LIBRARY_NAME_RELEASE} @@ -67,18 +67,18 @@ IF(CPPTEST_INCLUDE_DIR) SET(CPPTEST_LIBRARIES "optimized;${CPPTEST_LIBRARY_RELEASE}") IF(CPPTEST_LIBRARY_DEBUG) SET(CPPTEST_LIBRARIES "${CPPTEST_LIBRARIES};debug;${CPPTEST_LIBRARY_DEBUG}") - ENDIF(CPPTEST_LIBRARY_DEBUG) - ENDIF(CPPTEST_LIBRARY_RELEASE) -ENDIF(CPPTEST_INCLUDE_DIR) + ENDIF() + ENDIF() +ENDIF() IF(CPPTEST_FOUND) IF(NOT CPPTEST_FIND_QUIETLY) MESSAGE(STATUS "Found CppTest: ${CPPTEST_LIBRARIES}") - ENDIF(NOT CPPTEST_FIND_QUIETLY) -ELSE(CPPTEST_FOUND) + ENDIF() +ELSE() IF(NOT CPPTEST_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find CppTest!") - ENDIF(NOT CPPTEST_FIND_QUIETLY) -ENDIF(CPPTEST_FOUND) + ENDIF() +ENDIF() MARK_AS_ADVANCED(CPPTEST_LIBRARY_RELEASE CPPTEST_LIBRARY_DEBUG) diff --git a/code/CMakeModules/FindCustomMFC.cmake b/code/CMakeModules/FindCustomMFC.cmake index 45d5b8cce..b71e4a8d8 100644 --- a/code/CMakeModules/FindCustomMFC.cmake +++ b/code/CMakeModules/FindCustomMFC.cmake @@ -6,20 +6,20 @@ IF(CustomMFC_FIND_REQUIRED) SET(MFC_FIND_REQUIRED TRUE) -ENDIF(CustomMFC_FIND_REQUIRED) +ENDIF() IF(NOT MFC_DIR) # If MFC have been found, remember their directory IF(VC_DIR) SET(MFC_STANDARD_DIR "${VC_DIR}/atlmfc") - ENDIF(VC_DIR) + ENDIF() FIND_PATH(MFC_DIR include/afxwin.h HINTS ${MFC_STANDARD_DIR} ) -ENDIF(NOT MFC_DIR) +ENDIF() # Display an error message if MFC are not found, MFC_FOUND is updated # User will be able to update MFC_DIR to the correct directory @@ -33,15 +33,15 @@ IF(MFC_FOUND) # Using 32 or 64 bits libraries IF(TARGET_X64) SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64") - ELSE(TARGET_X64) + ELSE() SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib") - ENDIF(TARGET_X64) + ENDIF() # Add MFC libraries directory to default library path LINK_DIRECTORIES(${MFC_LIBRARY_DIR}) # Set definitions for using MFC in DLL - SET(MFC_DEFINITIONS -D_AFXDLL) + SET(MFC_DEFINITIONS -D_AFXDLL -DUNICODE -D_UNICODE) # Set CMake flag to use MFC DLL SET(CMAKE_MFC_FLAG 2) diff --git a/code/CMakeModules/FindDSound.cmake b/code/CMakeModules/FindDSound.cmake index beddf7f99..dde5212ab 100644 --- a/code/CMakeModules/FindDSound.cmake +++ b/code/CMakeModules/FindDSound.cmake @@ -8,7 +8,7 @@ if(DSOUND_INCLUDE_DIR) # Already in cache, be silent set(DSOUND_FIND_QUIETLY TRUE) -endif(DSOUND_INCLUDE_DIR) +ENDIF() find_path(DSOUND_INCLUDE_DIR dsound.h "$ENV{DXSDK_DIR}" @@ -29,8 +29,8 @@ find_package_handle_standard_args(DSOUND DEFAULT_MSG if(DSOUND_FOUND) set(DSOUND_LIBRARIES ${DSOUND_LIBRARY}) -else(DSOUND_FOUND) +ELSE() set(DSOUND_LIBRARIES) -endif(DSOUND_FOUND) +ENDIF() mark_as_advanced(DSOUND_INCLUDE_DIR DSOUND_LIBRARY) diff --git a/code/CMakeModules/FindDirectXSDK.cmake b/code/CMakeModules/FindDirectXSDK.cmake index 847a6d596..4519ef16d 100644 --- a/code/CMakeModules/FindDirectXSDK.cmake +++ b/code/CMakeModules/FindDirectXSDK.cmake @@ -8,7 +8,7 @@ IF(DXSDK_DIR) # Already in cache, be silent SET(DXSDK_FIND_QUIETLY TRUE) -ENDIF(DXSDK_DIR) +ENDIF() FIND_PATH(DXSDK_DIR "Include/dxsdkver.h" diff --git a/code/CMakeModules/FindEFXUtil.cmake b/code/CMakeModules/FindEFXUtil.cmake index 5e2f410b0..628a0eba5 100644 --- a/code/CMakeModules/FindEFXUtil.cmake +++ b/code/CMakeModules/FindEFXUtil.cmake @@ -7,7 +7,7 @@ IF(EFXUTIL_LIBRARY AND EFXUTIL_INCLUDE_DIR) # in cache already SET(EFXUTIL_FIND_QUIETLY TRUE) -ENDIF(EFXUTIL_LIBRARY AND EFXUTIL_INCLUDE_DIR) +ENDIF() FIND_PATH(EFXUTIL_INCLUDE_DIR @@ -42,9 +42,9 @@ IF(EFXUTIL_LIBRARY AND EFXUTIL_INCLUDE_DIR) SET(EFXUTIL_FOUND "YES") IF(NOT EFXUTIL_FIND_QUIETLY) MESSAGE(STATUS "Found EFX-Util: ${EFXUTIL_LIBRARY}") - ENDIF(NOT EFXUTIL_FIND_QUIETLY) -ELSE(EFXUTIL_LIBRARY AND EFXUTIL_INCLUDE_DIR) + ENDIF() +ELSE() IF(NOT EFXUTIL_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find EFX-Util!") - ENDIF(NOT EFXUTIL_FIND_QUIETLY) -ENDIF(EFXUTIL_LIBRARY AND EFXUTIL_INCLUDE_DIR) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/FindExternal.cmake b/code/CMakeModules/FindExternal.cmake index 80b3eda0c..8364026cd 100644 --- a/code/CMakeModules/FindExternal.cmake +++ b/code/CMakeModules/FindExternal.cmake @@ -16,7 +16,7 @@ IF(WITH_STLPORT) SET(EXTERNAL_TEMP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external_stlport ${CMAKE_CURRENT_SOURCE_DIR}/../external_stlport ${EXTERNAL_TEMP_PATH}) SET(EXTERNAL_TEMP_FILE "include/stlport/string") SET(EXTERNAL_NAME "external with STLport") -ENDIF(WITH_STLPORT) +ENDIF() FIND_PATH(EXTERNAL_PATH ${EXTERNAL_TEMP_FILE} diff --git a/code/CMakeModules/FindFMOD.cmake b/code/CMakeModules/FindFMOD.cmake index f85795142..b28f77b1e 100644 --- a/code/CMakeModules/FindFMOD.cmake +++ b/code/CMakeModules/FindFMOD.cmake @@ -7,7 +7,7 @@ IF(FMOD_LIBRARY AND FMOD_INCLUDE_DIR) # in cache already SET(FMOD_FIND_QUIETLY TRUE) -ENDIF(FMOD_LIBRARY AND FMOD_INCLUDE_DIR) +ENDIF() FIND_PATH(FMOD_INCLUDE_DIR @@ -25,9 +25,9 @@ FIND_PATH(FMOD_INCLUDE_DIR IF(TARGET_X64) SET(FMOD_LIBRARY_NAMES fmod64 fmod) -ELSE(TARGET_X64) +ELSE() SET(FMOD_LIBRARY_NAMES fmodvc fmod) -ENDIF(TARGET_X64) +ENDIF() FIND_LIBRARY(FMOD_LIBRARY NAMES @@ -49,9 +49,9 @@ IF(FMOD_LIBRARY AND FMOD_INCLUDE_DIR) SET(FMOD_FOUND "YES") IF(NOT FMOD_FIND_QUIETLY) MESSAGE(STATUS "Found FMOD: ${FMOD_LIBRARY}") - ENDIF(NOT FMOD_FIND_QUIETLY) -ELSE(FMOD_LIBRARY AND FMOD_INCLUDE_DIR) + ENDIF() +ELSE() IF(NOT FMOD_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find FMOD!") - ENDIF(NOT FMOD_FIND_QUIETLY) -ENDIF(FMOD_LIBRARY AND FMOD_INCLUDE_DIR) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/FindFreeType.cmake b/code/CMakeModules/FindFreeType.cmake index f6b827899..d101607b4 100644 --- a/code/CMakeModules/FindFreeType.cmake +++ b/code/CMakeModules/FindFreeType.cmake @@ -7,7 +7,7 @@ IF(FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIRS) # in cache already SET(Freetype_FIND_QUIETLY TRUE) -ENDIF(FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIRS) +ENDIF() FIND_PATH(FREETYPE_INCLUDE_DIRS freetype @@ -24,7 +24,7 @@ FIND_PATH(FREETYPE_INCLUDE_DIRS IF(NOT FREETYPE_INCLUDE_DIRS) SET(FREETYPE_INCLUDE_DIRS "") -ENDIF(NOT FREETYPE_INCLUDE_DIRS) +ENDIF() # ft2build.h does not reside in the freetype include dir FIND_PATH(FREETYPE_ADDITIONAL_INCLUDE_DIR @@ -42,7 +42,7 @@ FIND_PATH(FREETYPE_ADDITIONAL_INCLUDE_DIR # combine both include directories into one variable IF(FREETYPE_ADDITIONAL_INCLUDE_DIR) SET(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS} ${FREETYPE_ADDITIONAL_INCLUDE_DIR}) -ENDIF(FREETYPE_ADDITIONAL_INCLUDE_DIR) +ENDIF() FIND_LIBRARY(FREETYPE_LIBRARY_RELEASE NAMES freetype libfreetype freetype219 freetype246 @@ -89,8 +89,8 @@ IF(FREETYPE_INCLUDE_DIRS) # Case where Freetype is compiled from sources (debug version is compiled by default) SET(FREETYPE_FOUND ON) SET(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY_DEBUG}) - ENDIF(FREETYPE_LIBRARY_RELEASE AND FREETYPE_LIBRARY_DEBUG) -ENDIF(FREETYPE_INCLUDE_DIRS) + ENDIF() +ENDIF() IF(FREETYPE_FOUND) IF(WITH_STATIC_EXTERNAL AND APPLE) @@ -98,13 +98,13 @@ IF(FREETYPE_FOUND) IF(BZIP2_FOUND) SET(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS} ${BZIP2_INCLUDE_DIR}) SET(FREETYPE_LIBRARIES ${FREETYPE_LIBRARIES} ${BZIP2_LIBRARIES}) - ENDIF(BZIP2_FOUND) - ENDIF(WITH_STATIC_EXTERNAL AND APPLE) + ENDIF() + ENDIF() IF(NOT Freetype_FIND_QUIETLY) MESSAGE(STATUS "Found FreeType: ${FREETYPE_LIBRARIES}") - ENDIF(NOT Freetype_FIND_QUIETLY) -ELSE(FREETYPE_LIBRARY AND FREETYPE_INCLUDE_DIRS) + ENDIF() +ELSE() IF(NOT Freetype_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find FreeType!") - ENDIF(NOT Freetype_FIND_QUIETLY) -ENDIF(FREETYPE_FOUND) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/FindIconv.cmake b/code/CMakeModules/FindIconv.cmake index 092b35702..e96fe4054 100644 --- a/code/CMakeModules/FindIconv.cmake +++ b/code/CMakeModules/FindIconv.cmake @@ -20,7 +20,7 @@ FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c PATHS /opt/local) IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) SET(ICONV_FOUND TRUE) -ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) +ENDIF() set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) @@ -29,7 +29,7 @@ IF(ICONV_FOUND) set (CMAKE_C_FLAGS_BACKUP "${CMAKE_C_FLAGS}") if(ICONV_HAVE_WERROR) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") - endif(ICONV_HAVE_WERROR) + ENDIF() check_c_source_compiles(" #include int main(){ @@ -43,19 +43,19 @@ IF(ICONV_FOUND) } " ICONV_SECOND_ARGUMENT_IS_CONST ) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BACKUP}") -ENDIF(ICONV_FOUND) +ENDIF() set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_LIBRARIES) IF(ICONV_FOUND) IF(NOT ICONV_FIND_QUIETLY) MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}") - ENDIF(NOT ICONV_FIND_QUIETLY) -ELSE(ICONV_FOUND) + ENDIF() +ELSE() IF(Iconv_FIND_REQUIRED) MESSAGE(FATAL_ERROR "Could not find Iconv") - ENDIF(Iconv_FIND_REQUIRED) -ENDIF(ICONV_FOUND) + ENDIF() +ENDIF() MARK_AS_ADVANCED( ICONV_INCLUDE_DIR diff --git a/code/CMakeModules/FindJpeg.cmake b/code/CMakeModules/FindJpeg.cmake index 454f0fdc2..b77eba41b 100644 --- a/code/CMakeModules/FindJpeg.cmake +++ b/code/CMakeModules/FindJpeg.cmake @@ -7,7 +7,7 @@ IF(JPEG_LIBRARY AND JPEG_INCLUDE_DIR) # in cache already SET(JPEG_FIND_QUIETLY TRUE) -ENDIF(JPEG_LIBRARY AND JPEG_INCLUDE_DIR) +ENDIF() FIND_PATH(JPEG_INCLUDE_DIR @@ -42,9 +42,9 @@ IF(JPEG_LIBRARY AND JPEG_INCLUDE_DIR) SET(JPEG_FOUND "YES") IF(NOT JPEG_FIND_QUIETLY) MESSAGE(STATUS "Found Jpeg: ${JPEG_LIBRARY}") - ENDIF(NOT JPEG_FIND_QUIETLY) -ELSE(JPEG_LIBRARY AND JPEG_INCLUDE_DIR) + ENDIF() +ELSE() IF(NOT JPEG_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find Jpeg!") - ENDIF(NOT JPEG_FIND_QUIETLY) -ENDIF(JPEG_LIBRARY AND JPEG_INCLUDE_DIR) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/FindLibOVR.cmake b/code/CMakeModules/FindLibOVR.cmake index b182da00c..081fa0bca 100644 --- a/code/CMakeModules/FindLibOVR.cmake +++ b/code/CMakeModules/FindLibOVR.cmake @@ -7,10 +7,11 @@ IF(LIBOVR_LIBRARIES AND LIBOVR_INCLUDE_DIR) # in cache already SET(LIBOVR_FIND_QUIETLY TRUE) -ENDIF(LIBOVR_LIBRARIES AND LIBOVR_INCLUDE_DIR) +ENDIF() FIND_PATH(LIBOVR_INCLUDE_DIR - OVR.h + NAMES + OVR.h OVR_CAPI.h PATHS $ENV{LIBOVR_DIR}/Include /usr/local/include @@ -24,18 +25,18 @@ FIND_PATH(LIBOVR_INCLUDE_DIR IF(UNIX) IF(TARGET_X64) SET(LIBOVR_LIBRARY_BUILD_PATH "Lib/Linux/Release/x86_64") - ELSE(TARGET_X64) + ELSE() SET(LIBOVR_LIBRARY_BUILD_PATH "Lib/Linux/Release/i386") - ENDIF(TARGET_X64) + ENDIF() ELSEIF(APPLE) SET(LIBOVR_LIBRARY_BUILD_PATH "Lib/MacOS/Release") ELSEIF(WIN32) IF(TARGET_X64) SET(LIBOVR_LIBRARY_BUILD_PATH "Lib/x64") - ELSE(TARGET_X64) + ELSE() SET(LIBOVR_LIBRARY_BUILD_PATH "Lib/Win32") - ENDIF(TARGET_X64) -ENDIF(UNIX) + ENDIF() +ENDIF() FIND_LIBRARY(LIBOVR_LIBRARY NAMES ovr libovr @@ -55,17 +56,17 @@ FIND_LIBRARY(LIBOVR_LIBRARY IF(LIBOVR_LIBRARY AND LIBOVR_INCLUDE_DIR) IF(NOT LIBOVR_FIND_QUIETLY) MESSAGE(STATUS "Found LibOVR: ${LIBOVR_LIBRARY}") - ENDIF(NOT LIBOVR_FIND_QUIETLY) + ENDIF() SET(LIBOVR_FOUND "YES") SET(LIBOVR_DEFINITIONS "-DHAVE_LIBOVR") SET(NL_STEREO_AVAILABLE ON) IF(UNIX) SET(LIBOVR_LIBRARIES ${LIBOVR_LIBRARY} X11 Xinerama udev pthread) - ELSE(UNIX) + ELSE() SET(LIBOVR_LIBRARIES ${LIBOVR_LIBRARY}) - ENDIF(UNIX) -ELSE(LIBOVR_LIBRARY AND LIBOVR_INCLUDE_DIR) + ENDIF() +ELSE() IF(NOT LIBOVR_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find LibOVR!") - ENDIF(NOT LIBOVR_FIND_QUIETLY) -ENDIF(LIBOVR_LIBRARY AND LIBOVR_INCLUDE_DIR) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/FindLibVR.cmake b/code/CMakeModules/FindLibVR.cmake index e8bcf2fde..5e9da0342 100644 --- a/code/CMakeModules/FindLibVR.cmake +++ b/code/CMakeModules/FindLibVR.cmake @@ -7,7 +7,7 @@ IF(LIBVR_LIBRARIES AND LIBVR_INCLUDE_DIR) # in cache already SET(LIBVR_FIND_QUIETLY TRUE) -ENDIF(LIBVR_LIBRARIES AND LIBVR_INCLUDE_DIR) +ENDIF() FIND_PATH(LIBVR_INCLUDE_DIR hmd.h PATH_SUFFIXES include/LibVR @@ -22,12 +22,12 @@ FIND_LIBRARY(LIBVR_LIBRARY IF(LIBVR_LIBRARY AND LIBVR_INCLUDE_DIR) IF(NOT LIBVR_FIND_QUIETLY) MESSAGE(STATUS "Found LibVR: ${LIBVR_LIBRARY}") - ENDIF(NOT LIBVR_FIND_QUIETLY) + ENDIF() SET(LIBVR_FOUND "YES") SET(LIBVR_DEFINITIONS "-DHAVE_LIBVR") SET(NL_STEREO_AVAILABLE ON) -ELSE(LIBVR_LIBRARY AND LIBVR_INCLUDE_DIR) +ELSE() IF(NOT LIBVR_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find LibVR!") - ENDIF(NOT LIBVR_FIND_QUIETLY) -ENDIF(LIBVR_LIBRARY AND LIBVR_INCLUDE_DIR) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/FindLuabind.cmake b/code/CMakeModules/FindLuabind.cmake index c21d64e4f..5511379a3 100644 --- a/code/CMakeModules/FindLuabind.cmake +++ b/code/CMakeModules/FindLuabind.cmake @@ -143,7 +143,7 @@ ENDIF() IF(WITH_STLPORT) LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport) LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlportd) -ENDIF(WITH_STLPORT) +ENDIF() # generic libraries names LIST(APPEND LIBRARY_NAME_RELEASE luabind libluabind) @@ -194,7 +194,7 @@ IF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR) # Case where Luabind is compiled from sources (debug version is compiled by default) SET(LUABIND_FOUND TRUE) SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_DEBUG}) - ENDIF(LUABIND_LIBRARY_RELEASE AND LUABIND_LIBRARY_DEBUG) + ENDIF() ENDIF() IF(LUABIND_FOUND) @@ -209,11 +209,11 @@ IF(LUABIND_FOUND) IF(NOT Luabind_FIND_QUIETLY) MESSAGE(STATUS "Found Luabind: ${LUABIND_LIBRARIES}") - ENDIF(NOT Luabind_FIND_QUIETLY) + ENDIF() ELSE() IF(NOT Luabind_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find Luabind!") ENDIF() -ENDIF(LUABIND_FOUND) +ENDIF() MARK_AS_ADVANCED(LUABIND_LIBRARY_RELEASE LUABIND_LIBRARY_DEBUG Boost_LIB_DIAGNOSTIC_DEFINITIONS) diff --git a/code/CMakeModules/FindMSVC.cmake b/code/CMakeModules/FindMSVC.cmake index 6a8bdd33a..5dbc4f6a8 100644 --- a/code/CMakeModules/FindMSVC.cmake +++ b/code/CMakeModules/FindMSVC.cmake @@ -5,6 +5,24 @@ # VC_LIBRARY_DIR - where to find libraries # VC_FOUND - True if MSVC found. +MACRO(ADD_TRAILING_SLASH _FILENAME_VAR) + # put content in a new variable + SET(_FILENAME ${${_FILENAME_VAR}}) + # get length of the string + STRING(LENGTH ${_FILENAME} _LEN) + # convert length to last pos + MATH(EXPR _POS "${_LEN}-1") + # get last character of the string + STRING(SUBSTRING ${_FILENAME} ${_POS} 1 _FILENAME_END) + # compare it with a slash + IF(NOT _FILENAME_END STREQUAL "/") + # not a slash, append it + SET(${_FILENAME_VAR} "${_FILENAME}/") + ELSE() + # already a slash + ENDIF() +ENDMACRO() + MACRO(DETECT_VC_VERSION_HELPER _ROOT _VERSION) # Software/Wow6432Node/... GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;${_VERSION}]" ABSOLUTE) @@ -12,7 +30,11 @@ MACRO(DETECT_VC_VERSION_HELPER _ROOT _VERSION) IF(VC${_VERSION}_DIR AND VC${_VERSION}_DIR STREQUAL "/registry") SET(VC${_VERSION}_DIR) GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;${_VERSION}]" ABSOLUTE) + IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") + # be sure it's finishing by a / + ADD_TRAILING_SLASH(VC${_VERSION}_DIR) + SET(VC${_VERSION}_DIR "${VC${_VERSION}_DIR}VC/") ENDIF() ENDIF() @@ -34,16 +56,18 @@ MACRO(DETECT_VC_VERSION_HELPER _ROOT _VERSION) ENDMACRO() MACRO(DETECT_VC_VERSION _VERSION) - SET(VC${_VERSION}_FOUND OFF) - DETECT_VC_VERSION_HELPER("HKEY_CURRENT_USER" ${_VERSION}) + IF(NOT VC_FOUND) + SET(VC${_VERSION}_FOUND OFF) + DETECT_VC_VERSION_HELPER("HKEY_CURRENT_USER" ${_VERSION}) - IF(NOT VC${_VERSION}_FOUND) - DETECT_VC_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION}) - ENDIF() + IF(NOT VC${_VERSION}_FOUND) + DETECT_VC_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION}) + ENDIF() - IF(VC${_VERSION}_FOUND) - SET(VC_FOUND ON) - SET(VC_DIR "${VC${_VERSION}_DIR}") + IF(VC${_VERSION}_FOUND) + SET(VC_FOUND ON) + SET(VC_DIR "${VC${_VERSION}_DIR}") + ENDIF() ENDIF() ENDMACRO() @@ -55,30 +79,39 @@ MACRO(DETECT_EXPRESS_VERSION _VERSION) ENDIF() ENDMACRO() -IF(MSVC12) +IF(MSVC_VERSION GREATER 1909) + DETECT_VC_VERSION("15.0") + SET(MSVC_TOOLSET "140") + + SET(VC_DIR "${VC_DIR}Tools/MSVC") + + FILE(GLOB MSVC_TOOLCHAIN_VERSIONS RELATIVE ${VC_DIR} "${VC_DIR}/*") + + IF(MSVC_TOOLCHAIN_VERSIONS) + LIST(SORT MSVC_TOOLCHAIN_VERSIONS) + LIST(REVERSE MSVC_TOOLCHAIN_VERSIONS) + ENDIF() + + IF(NOT MSVC_TOOLCHAIN_VERSIONS) + MESSAGE(FATAL_ERROR "No MSVC version found in default search path ${VC_DIR}") + ENDIF() + + LIST(GET MSVC_TOOLCHAIN_VERSIONS 0 MSVC_TOOLCHAIN_VERSION) + + SET(VC_DIR "${VC_DIR}/${MSVC_TOOLCHAIN_VERSION}") + SET(VC_INCLUDE_DIR "${VC_DIR}/include") +ELSEIF(MSVC14) + DETECT_VC_VERSION("14.0") + SET(MSVC_TOOLSET "140") +ELSEIF(MSVC12) DETECT_VC_VERSION("12.0") SET(MSVC_TOOLSET "120") - - IF(NOT MSVC12_REDIST_DIR) - # If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist - SET(MSVC12_REDIST_DIR "${EXTERNAL_PATH}/redist") - ENDIF() ELSEIF(MSVC11) DETECT_VC_VERSION("11.0") SET(MSVC_TOOLSET "110") - - IF(NOT MSVC11_REDIST_DIR) - # If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist - SET(MSVC11_REDIST_DIR "${EXTERNAL_PATH}/redist") - ENDIF() ELSEIF(MSVC10) DETECT_VC_VERSION("10.0") SET(MSVC_TOOLSET "100") - - IF(NOT MSVC10_REDIST_DIR) - # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist - SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist") - ENDIF() ELSEIF(MSVC90) DETECT_VC_VERSION("9.0") SET(MSVC_TOOLSET "90") @@ -90,6 +123,8 @@ ENDIF() # If you plan to use VC++ compilers with WINE, set VC_DIR environment variable IF(NOT VC_DIR) SET(VC_DIR $ENV{VC_DIR}) + # Fix path + FILE(TO_CMAKE_PATH ${VC_DIR} VC_DIR) ENDIF() IF(NOT VC_DIR) @@ -98,9 +133,50 @@ IF(NOT VC_DIR) ELSE() SET(_COMPILER ${CMAKE_C_COMPILER}) ENDIF() - STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${_COMPILER}) + STRING(REGEX REPLACE "/(bin|BIN|Bin)/.+" "" VC_DIR ${_COMPILER}) ENDIF() -SET(VC_INCLUDE_DIR "${VC_DIR}/include") +IF(NOT VC_INCLUDE_DIR AND VC_DIR AND EXISTS "${VC_DIR}") + SET(VC_INCLUDE_DIR "${VC_DIR}/include") + IF(EXISTS "${VC_INCLUDE_DIR}") + SET(VC_FOUND ON) + ENDIF() +ENDIF() + +SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist") + +IF(NOT EXISTS "${MSVC_REDIST_DIR}") + SET(MSVC_REDIST_DIR "${VC_DIR}/redist") + + IF(NOT EXISTS "${MSVC_REDIST_DIR}") + SET(MSVC_REDIST_DIR) + ENDIF() +ENDIF() + +IF(MSVC_REDIST_DIR) + IF(MSVC1411 OR MSVC1410) + # If you have VC++ 2017 Express, put x64/Microsoft.VC141.CRT/*.dll in ${EXTERNAL_PATH}/redist + # original files whould be in ${VC_DIR}/Redist/MSVC/14.11.25325/x64/Microsoft.VC141.CRT + SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}") + ELSEIF(MSVC14) + SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}") + ELSEIF(MSVC12) + # If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist + SET(MSVC12_REDIST_DIR "${MSVC_REDIST_DIR}") + ELSEIF(MSVC11) + # If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist + SET(MSVC11_REDIST_DIR "${MSVC_REDIST_DIR}") + ELSEIF(MSVC10) + # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist + SET(MSVC10_REDIST_DIR "${MSVC_REDIST_DIR}") + ELSEIF(MSVC90) + SET(MSVC90_REDIST_DIR "${MSVC_REDIST_DIR}") + ELSEIF(MSVC80) + SET(MSVC80_REDIST_DIR "${MSVC_REDIST_DIR}") + ENDIF() +ENDIF() + +MESSAGE(STATUS "Using headers from ${VC_INCLUDE_DIR}") + SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR}) diff --git a/code/CMakeModules/FindMercurial.cmake b/code/CMakeModules/FindMercurial.cmake index f85952557..4e6429357 100644 --- a/code/CMakeModules/FindMercurial.cmake +++ b/code/CMakeModules/FindMercurial.cmake @@ -60,12 +60,12 @@ IF(Mercurial_HG_EXECUTABLE) EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} --version OUTPUT_VARIABLE Mercurial_VERSION_HG OUTPUT_STRIP_TRAILING_WHITESPACE) - + STRING(REGEX REPLACE ".*version ([\\.0-9]+).*" "\\1" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}") MACRO(Mercurial_WC_INFO dir prefix) - EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} tip --template "{rev};{node};{tags};{author}" + EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} log -r . --template "{rev};{node};{tags};{author}" WORKING_DIRECTORY ${dir} OUTPUT_VARIABLE ${prefix}_WC_INFO ERROR_VARIABLE Mercurial_hg_info_error @@ -73,7 +73,7 @@ IF(Mercurial_HG_EXECUTABLE) OUTPUT_STRIP_TRAILING_WHITESPACE) IF(NOT ${Mercurial_hg_info_result} EQUAL 0) - MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} tip\" failed with output:\n${Mercurial_hg_info_error}") + MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} log\" failed with output:\n${Mercurial_hg_info_error}") ELSE() LIST(LENGTH ${prefix}_WC_INFO _COUNT) IF(_COUNT EQUAL 4) diff --git a/code/CMakeModules/FindMySQL.cmake b/code/CMakeModules/FindMySQL.cmake index f2b62fc59..8a92cb0c4 100644 --- a/code/CMakeModules/FindMySQL.cmake +++ b/code/CMakeModules/FindMySQL.cmake @@ -69,6 +69,9 @@ ELSE() ENDIF() FIND_PACKAGE(OpenSSL) IF(OPENSSL_FOUND) + IF(WIN32) + SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib) + ENDIF() SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} ${OPENSSL_LIBRARIES}) ENDIF() ENDIF() diff --git a/code/CMakeModules/FindOgg.cmake b/code/CMakeModules/FindOgg.cmake index 8762afc5d..c1f4492e1 100644 --- a/code/CMakeModules/FindOgg.cmake +++ b/code/CMakeModules/FindOgg.cmake @@ -7,7 +7,7 @@ IF(OGG_LIBRARY AND OGG_INCLUDE_DIR) # in cache already SET(OGG_FIND_QUIETLY TRUE) -ENDIF(OGG_LIBRARY AND OGG_INCLUDE_DIR) +ENDIF() FIND_PATH(OGG_INCLUDE_DIR @@ -41,9 +41,9 @@ IF(OGG_LIBRARY AND OGG_INCLUDE_DIR) SET(OGG_FOUND "YES") IF(NOT OGG_FIND_QUIETLY) MESSAGE(STATUS "Found Ogg: ${OGG_LIBRARY}") - ENDIF(NOT OGG_FIND_QUIETLY) -ELSE(OGG_LIBRARY AND OGG_INCLUDE_DIR) + ENDIF() +ELSE() IF(NOT OGG_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find Ogg!") - ENDIF(NOT OGG_FIND_QUIETLY) -ENDIF(OGG_LIBRARY AND OGG_INCLUDE_DIR) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/FindOpenGLES.cmake b/code/CMakeModules/FindOpenGLES.cmake index 35157b95b..74a5b4021 100644 --- a/code/CMakeModules/FindOpenGLES.cmake +++ b/code/CMakeModules/FindOpenGLES.cmake @@ -43,7 +43,7 @@ IF(OPENGLES_GLES_LIBRARY) IF(OPENGLES_EGL_LIBRARY) SET(OPENGLES_EGL_FOUND "YES") SET(OPENGLES_LIBRARIES ${OPENGLES_EGL_LIBRARY} ${OPENGLES_LIBRARIES}) - ELSE(OPENGLES_EGL_LIBRARY) + ELSE() SET(OPENGLES_EGL_FOUND "NO") - ENDIF(OPENGLES_EGL_LIBRARY) -ENDIF(OPENGLES_GLES_LIBRARY) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/FindSTLport.cmake b/code/CMakeModules/FindSTLport.cmake index 22e0745ba..68e542ea5 100644 --- a/code/CMakeModules/FindSTLport.cmake +++ b/code/CMakeModules/FindSTLport.cmake @@ -9,7 +9,7 @@ IF(STLPORT_LIBRARIES AND STLPORT_INCLUDE_DIR) # in cache already SET(STLPORT_FIND_QUIETLY TRUE) -ENDIF(STLPORT_LIBRARIES AND STLPORT_INCLUDE_DIR) +ENDIF() FIND_PATH(STLPORT_INCLUDE_DIR iostream @@ -74,18 +74,18 @@ IF(STLPORT_INCLUDE_DIR) SET(STLPORT_LIBRARIES ${STLPORT_LIBRARY_RELEASE}) IF(STLPORT_LIBRARY_DEBUG) SET(STLPORT_LIBRARIES optimized ${STLPORT_LIBRARIES} debug ${STLPORT_LIBRARY_DEBUG}) - ENDIF(STLPORT_LIBRARY_DEBUG) - ENDIF(STLPORT_LIBRARY_RELEASE) -ENDIF(STLPORT_INCLUDE_DIR) + ENDIF() + ENDIF() +ENDIF() IF(STLPORT_FOUND) IF(NOT STLPORT_FIND_QUIETLY) MESSAGE(STATUS "Found STLport: ${STLPORT_LIBRARIES}") - ENDIF(NOT STLPORT_FIND_QUIETLY) -ELSE(STLPORT_FOUND) + ENDIF() +ELSE() IF(NOT STLPORT_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find STLport!") - ENDIF(NOT STLPORT_FIND_QUIETLY) -ENDIF(STLPORT_FOUND) + ENDIF() +ENDIF() MARK_AS_ADVANCED(STLPORT_LIBRARY_RELEASE STLPORT_LIBRARY_DEBUG) diff --git a/code/CMakeModules/FindSquish.cmake b/code/CMakeModules/FindSquish.cmake index 61250fec1..4242f4055 100644 --- a/code/CMakeModules/FindSquish.cmake +++ b/code/CMakeModules/FindSquish.cmake @@ -10,7 +10,7 @@ IF(SQUISH_LIBRARIES AND SQUISH_INCLUDE_DIR) # in cache already SET(SQUISH_FIND_QUIETLY TRUE) -ENDIF(SQUISH_LIBRARIES AND SQUISH_INCLUDE_DIR) +ENDIF() FIND_PATH(SQUISH_INCLUDE_DIR squish.h @@ -58,26 +58,26 @@ IF(SQUISH_INCLUDE_DIR) SET(SQUISH_LIBRARIES "optimized;${SQUISH_LIBRARY_RELEASE}") IF(SQUISH_LIBRARY_DEBUG) SET(SQUISH_LIBRARIES "${SQUISH_LIBRARIES};debug;${SQUISH_LIBRARY_DEBUG}") - ELSE(SQUISH_LIBRARY_DEBUG) + ELSE() SET(SQUISH_LIBRARIES "${SQUISH_LIBRARIES};debug;${SQUISH_LIBRARY_RELEASE}") MESSAGE("Debug Squish NOT found, using the release version!") - ENDIF(SQUISH_LIBRARY_DEBUG) - ENDIF(SQUISH_LIBRARY_RELEASE) -ENDIF(SQUISH_INCLUDE_DIR) + ENDIF() + ENDIF() +ENDIF() IF(SQUISH_FOUND) IF(NOT SQUISH_FIND_QUIETLY) MESSAGE(STATUS "Found Squish: ${SQUISH_LIBRARIES}") - ENDIF(NOT SQUISH_FIND_QUIETLY) + ENDIF() FILE(STRINGS ${SQUISH_INCLUDE_DIR}/squish.h METRIC REGEX "metric = 0") IF(METRIC) SET(SQUISH_COMPRESS_HAS_METRIC ON) SET(SQUISH_DEFINITIONS -DSQUISH_COMPRESS_HAS_METRIC) - ENDIF(METRIC) -ELSE(SQUISH_FOUND) + ENDIF() +ELSE() IF(NOT SQUISH_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find Squish!") - ENDIF(NOT SQUISH_FIND_QUIETLY) -ENDIF(SQUISH_FOUND) + ENDIF() +ENDIF() MARK_AS_ADVANCED(SQUISH_LIBRARY_RELEASE SQUISH_LIBRARY_DEBUG) diff --git a/code/CMakeModules/FindVorbis.cmake b/code/CMakeModules/FindVorbis.cmake index 95883fa59..234d2d31a 100644 --- a/code/CMakeModules/FindVorbis.cmake +++ b/code/CMakeModules/FindVorbis.cmake @@ -7,7 +7,7 @@ IF(VORBIS_LIBRARY AND VORBIS_INCLUDE_DIR) # in cache already SET(VORBIS_FIND_QUIETLY TRUE) -ENDIF(VORBIS_LIBRARY AND VORBIS_INCLUDE_DIR) +ENDIF() FIND_PATH(VORBIS_INCLUDE_DIR @@ -57,9 +57,9 @@ IF(VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBIS_INCLUDE_DIR) SET(VORBIS_LIBRARIES ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY}) IF(NOT VORBIS_FIND_QUIETLY) MESSAGE(STATUS "Found Vorbis: ${VORBIS_LIBRARY}") - ENDIF(NOT VORBIS_FIND_QUIETLY) -ELSE(VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBIS_INCLUDE_DIR) + ENDIF() +ELSE() IF(NOT VORBIS_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find Vorbis!") - ENDIF(NOT VORBIS_FIND_QUIETLY) -ENDIF(VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBIS_INCLUDE_DIR) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/FindWindowsSDK.cmake b/code/CMakeModules/FindWindowsSDK.cmake index 43864c6a6..3d9c43bd9 100644 --- a/code/CMakeModules/FindWindowsSDK.cmake +++ b/code/CMakeModules/FindWindowsSDK.cmake @@ -35,7 +35,7 @@ MACRO(DETECT_WINKIT_VERSION _VERSION _SUFFIX) SET(WINSDK${_VERSION}_FOUND ON) SET(WINSDK${_VERSION}_VERSION_FULL "${_VERSION}") IF(NOT WindowsSDK_FIND_QUIETLY) - MESSAGE(STATUS "Found Windows SDK ${_VERSION} in ${WINSDK${_VERSION}_DIR}") + MESSAGE(STATUS "Found Windows Kit ${_VERSION} in ${WINSDK${_VERSION}_DIR}") ENDIF() LIST(APPEND WINSDK_DETECTED_VERSIONS ${_VERSION}) ELSE() @@ -240,7 +240,11 @@ MACRO(USE_CURRENT_WINSDK) IF(NOT WINSDK_DIR) # Use Windows SDK versions installed with VC++ when possible - IF(MSVC14) + IF(MSVC_VERSION GREATER 1909) + # Special case, use Kits for SDK + SET(WINSDK_VERSION "10.0") + SET(WINSDK_DIR ${WINSDK_UCRT_DIR}) + ELSEIF(MSVC14) SET(WINSDK_VERSION "8.1") ELSEIF(MSVC12) SET(WINSDK_VERSION "8.1") @@ -255,8 +259,19 @@ MACRO(USE_CURRENT_WINSDK) SET(WINSDK_VERSION "6.0A") ENDIF() ELSEIF(MSVC80) - IF(NOT MSVC_EXPRESS) - # TODO: fix this version + SET(WINSDK_MSVC80_COMPATIBLES "7.1" "7.1A" "7.0" "7.0A" "6.1" "6.0" "6.0A" "5.2A") + + # look for each Windows SDK supported by VC++ 2005 (7.1 is the latest) + FOREACH(_VERSION ${WINSDK_DETECTED_VERSIONS}) + # look if this version of Windows SDK is installed + LIST(FIND WINSDK_MSVC80_COMPATIBLES ${_VERSION} _FOUND) + IF(NOT _FOUND EQUAL -1) + SET(WINSDK_VERSION "${_VERSION}") + BREAK() + ENDIF() + ENDFOREACH() + + IF(NOT MSVC_EXPRESS AND NOT WINSDK_VERSION) SET(WINSDK_VERSION "5.2A") ENDIF() ELSE() @@ -294,7 +309,7 @@ MACRO(USE_CURRENT_WINSDK) ENDMACRO() IF(MSVC14) - # Under VC++ 2015, stdio.h, stdlib.h, etc... are part of UCRT + # Under VC++ 2015 and 2017, stdio.h, stdlib.h, etc... are part of UCRT SET(WINSDK_UCRT_VERSION "10.0") ENDIF() @@ -303,6 +318,40 @@ IF(WINSDK_UCRT_VERSION AND WINSDK${WINSDK_UCRT_VERSION}_FOUND) SET(WINSDK_UCRT_DIR "${WINSDK${WINSDK_UCRT_VERSION}_DIR}") ENDIF() +IF(WINSDK_UCRT_DIR) + # determine exact UCRT version + SET(WINSDK_UCRT_INCLUDE_ROOT_DIR ${WINSDK_UCRT_DIR}/Include) + SET(WINSDK_UCRT_LIB_ROOT_DIR ${WINSDK_UCRT_DIR}/Lib) + + FILE(GLOB UCRT_SUBDIRS RELATIVE ${WINSDK_UCRT_INCLUDE_ROOT_DIR} ${WINSDK_UCRT_INCLUDE_ROOT_DIR}/*) + SET(UCRT_VERSION) + + FOREACH(UCRT_SUBDIR ${UCRT_SUBDIRS}) + IF(NOT UCRT_VERSION OR UCRT_SUBDIR VERSION_GREATER UCRT_VERSION) + SET(UCRT_VERSION ${UCRT_SUBDIR}) + ENDIF() + ENDFOREACH() + + IF(UCRT_VERSION) + MESSAGE(STATUS "Using Windows UCRT ${UCRT_VERSION}") + + SET(WINSDK10_INCLUDE_DIR ${WINSDK_UCRT_INCLUDE_ROOT_DIR}/${UCRT_VERSION}) + SET(WINSDK10_LIBRARY_DIR ${WINSDK_UCRT_LIB_ROOT_DIR}/${UCRT_VERSION}) + + # directory where UCRT headers are found + FIND_PATH(WINSDK_UCRT_INCLUDE_DIR corecrt.h + HINTS + ${WINSDK10_INCLUDE_DIR}/ucrt + ) + + # directory where UCRT libraries are found + FIND_PATH(WINSDK_UCRT_LIBRARY_DIR ucrt.lib + HINTS + ${WINSDK10_LIBRARY_DIR}/ucrt/${WINSDK8_SUFFIX} + ) + ENDIF() +ENDIF() + IF(WINSDK_VERSION STREQUAL "CURRENT") USE_CURRENT_WINSDK() ELSE() @@ -323,93 +372,87 @@ ENDIF() # directory where Win32 headers are found FIND_PATH(WINSDK_INCLUDE_DIR Windows.h HINTS + ${WINSDK_DIR}/Include/${UCRT_VERSION}/um ${WINSDK_DIR}/Include/um ${WINSDK_DIR}/Include + NO_DEFAULT_PATH ) +MESSAGE(STATUS "Found Windows.h in ${WINSDK_INCLUDE_DIR}") + # directory where WinRT headers are found FIND_PATH(WINSDK_WINRT_INCLUDE_DIR winstring.h HINTS + ${WINSDK_DIR}/Include/${UCRT_VERSION}/winrt ${WINSDK_DIR}/Include/winrt + NO_DEFAULT_PATH ) +MESSAGE(STATUS "Found winstring.h in ${WINSDK_WINRT_INCLUDE_DIR}") + # directory where DirectX headers are found FIND_PATH(WINSDK_SHARED_INCLUDE_DIR d3d9.h HINTS + ${WINSDK_DIR}/Include/${UCRT_VERSION}/shared ${WINSDK_DIR}/Include/shared + NO_DEFAULT_PATH ) +MESSAGE(STATUS "Found d3d9.h in ${WINSDK_SHARED_INCLUDE_DIR}") + # directory where OpenGL headers are found FIND_PATH(WINSDK_OPENGL_INCLUDE_DIR GL.h HINTS + ${WINSDK_INCLUDE_DIR}/gl ${WINSDK_DIR}/Include/um/gl ${WINSDK_DIR}/Include/gl + NO_DEFAULT_PATH ) +MESSAGE(STATUS "Found GL.h in ${WINSDK_OPENGL_INCLUDE_DIR}") + SET(WINSDK_LIBRARY_DIRS + ${WINSDK_DIR}/Lib/${UCRT_VERSION}/um/${WINSDK8_SUFFIX} ${WINSDK_DIR}/Lib/winv6.3/um/${WINSDK8_SUFFIX} ${WINSDK_DIR}/Lib/win8/um/${WINSDK8_SUFFIX} ) IF(WINSDK_SUFFIXES) FOREACH(_SUFFIX ${WINSDK_SUFFIXES}) - SET(WINSDK_LIBRARY_DIRS ${WINSDK_LIBRARY_DIRS} ${WINSDK_DIR}/Lib/${_SUFFIX}) + LIST(APPEND WINSDK_LIBRARY_DIRS ${WINSDK_DIR}/Lib/${_SUFFIX}) ENDFOREACH() ELSE() - SET(WINSDK_LIBRARY_DIRS ${WINSDK_LIBRARY_DIRS} ${WINSDK_DIR}/Lib) + LIST(APPEND WINSDK_LIBRARY_DIRS ${WINSDK_DIR}/Lib) ENDIF() # directory where all libraries are found FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib HINTS ${WINSDK_LIBRARY_DIRS} + NO_DEFAULT_PATH ) -IF(WINSDK_UCRT_DIR) - # determine exact UCRT version - SET(WINSDK_UCRT_INCLUDE_ROOT_DIR ${WINSDK_UCRT_DIR}/Include) - SET(WINSDK_UCRT_LIB_ROOT_DIR ${WINSDK_UCRT_DIR}/Lib) +MESSAGE(STATUS "Found ComCtl32.lib in ${WINSDK_LIBRARY_DIR}") - FILE(GLOB UCRT_SUBDIRS RELATIVE ${WINSDK_UCRT_INCLUDE_ROOT_DIR} ${WINSDK_UCRT_INCLUDE_ROOT_DIR}/*) - SET(UCRT_VERSION) - - FOREACH(UCRT_SUBDIR ${UCRT_SUBDIRS}) - IF(NOT UCRT_VERSION OR UCRT_SUBDIR VERSION_GREATER UCRT_VERSION) - SET(UCRT_VERSION ${UCRT_SUBDIR}) - ENDIF() - ENDFOREACH() - - IF(UCRT_VERSION) - MESSAGE(STATUS "Using Windows UCRT ${UCRT_VERSION}") - - # directory where UCRT headers are found - FIND_PATH(WINSDK_UCRT_INCLUDE_DIR corecrt.h - HINTS - ${WINSDK_UCRT_INCLUDE_ROOT_DIR}/${UCRT_VERSION}/ucrt - ) - - # directory where UCRT libraries are found - FIND_PATH(WINSDK_UCRT_LIBRARY_DIR ucrt.lib - HINTS - ${WINSDK_UCRT_LIB_ROOT_DIR}/${UCRT_VERSION}/ucrt/${WINSDK8_SUFFIX} - ) - ENDIF() -ENDIF() +SET(WINSDK_BINARY_DIRS + ${WINSDK_DIR}/Bin/${UCRT_VERSION}/${WINSDK8_SUFFIX} + ${WINSDK_DIR}/Bin/${WINSDK8_SUFFIX} + ${WINSDK_DIR}/Bin/x86 + ${WINSDK_DIR}/Bin +) # signtool is used to sign executables FIND_PROGRAM(WINSDK_SIGNTOOL signtool HINTS - ${WINSDK_DIR}/Bin/${WINSDK8_SUFFIX} - ${WINSDK_DIR}/Bin/x86 - ${WINSDK_DIR}/Bin + ${WINSDK_BINARY_DIRS} + NO_DEFAULT_PATH ) # midl is used to generate IDL interfaces FIND_PROGRAM(WINSDK_MIDL midl HINTS - ${WINSDK_DIR}/Bin/${WINSDK8_SUFFIX} - ${WINSDK_DIR}/Bin/x86 - ${WINSDK_DIR}/Bin + ${WINSDK_BINARY_DIRS} + NO_DEFAULT_PATH ) IF(WINSDK_INCLUDE_DIR) @@ -433,7 +476,7 @@ IF(WINSDK_INCLUDE_DIR) SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIRS} ${WINSDK_WINRT_INCLUDE_DIR}) ENDIF() - INCLUDE_DIRECTORIES(${WINSDK_INCLUDE_DIRS}) # TODO: Move this after all other includes somehow... + INCLUDE_DIRECTORIES(${WINSDK_INCLUDE_DIRS}) IF(WINSDK_UCRT_LIBRARY_DIR) SET(CMAKE_LIBRARY_PATH ${WINSDK_UCRT_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH}) @@ -441,8 +484,8 @@ IF(WINSDK_INCLUDE_DIR) SET(CMAKE_LIBRARY_PATH ${WINSDK_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH}) - # Fix for using Windows SDK 7.1 with Visual C++ 2012 - IF(WINSDK_VERSION STREQUAL "7.1" AND MSVC11) + # Fix for using Windows SDK 7.1 with Visual C++ 2012, 2013, 2015 and 2017 + IF(WINSDK_VERSION STREQUAL "7.1" AND (MSVC11 OR MSVC12 OR MSVC14)) ADD_DEFINITIONS(-D_USING_V110_SDK71_) ENDIF() ELSE() diff --git a/code/CMakeModules/FindXF86VidMode.cmake b/code/CMakeModules/FindXF86VidMode.cmake index 88fa40ad7..15dae03de 100644 --- a/code/CMakeModules/FindXF86VidMode.cmake +++ b/code/CMakeModules/FindXF86VidMode.cmake @@ -7,7 +7,7 @@ IF(XF86VidMode_LIBRARY AND XF86VidMode_INCLUDE_DIR) # in cache already SET(XF86VidMode_FIND_QUIETLY TRUE) -ENDIF(XF86VidMode_LIBRARY AND XF86VidMode_INCLUDE_DIR) +ENDIF() FIND_PATH(XF86VidMode_INCLUDE_DIR @@ -37,10 +37,10 @@ IF(XF86VidMode_LIBRARY AND XF86VidMode_INCLUDE_DIR) SET(XF86VidMode_DEFINITIONS -DXF86VIDMODE) IF(NOT XF86VidMode_FIND_QUIETLY) MESSAGE(STATUS "Found XF86VidMode: ${XF86VidMode_LIBRARY}") - ENDIF(NOT XF86VidMode_FIND_QUIETLY) -ELSE(XF86VidMode_LIBRARY AND XF86VidMode_INCLUDE_DIR) + ENDIF() +ELSE() IF(NOT XF86VidMode_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find XF86VidMode!") - ENDIF(NOT XF86VidMode_FIND_QUIETLY) -ENDIF(XF86VidMode_LIBRARY AND XF86VidMode_INCLUDE_DIR) + ENDIF() +ENDIF() diff --git a/code/CMakeModules/Findassimp.cmake b/code/CMakeModules/Findassimp.cmake index 41e53cf94..b4bf0da99 100644 --- a/code/CMakeModules/Findassimp.cmake +++ b/code/CMakeModules/Findassimp.cmake @@ -1,29 +1,63 @@ +IF(assimp_FIND_REQUIRED) + SET(ASSIMP_FIND_REQUIRED ON) +ENDIF() + FIND_PATH( - assimp_INCLUDE_DIRS + ASSIMP_INCLUDE_DIRS NAMES assimp/postprocess.h assimp/scene.h assimp/version.h assimp/config.h assimp/cimport.h PATHS /usr/local/include/ ) FIND_LIBRARY( - assimp_LIBRARIES + ASSIMP_LIBRARY_RELEASE NAMES assimp PATHS /usr/local/lib/ ) -IF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES) - SET(assimp_FOUND TRUE) +FIND_LIBRARY( + IRRXML_LIBRARY_RELEASE + NAMES IrrXML + PATHS /usr/local/lib/ +) + +FIND_LIBRARY( + ASSIMP_LIBRARY_DEBUG + NAMES assimpd + PATHS /usr/local/lib/ +) + +FIND_LIBRARY( + IRRXML_LIBRARY_DEBUG + NAMES IrrXMLd + PATHS /usr/local/lib/ +) + +IF (ASSIMP_INCLUDE_DIRS) + SET(ASSIMP_FOUND TRUE) + IF(ASSIMP_LIBRARY_RELEASE) + SET(ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES} optimized ${ASSIMP_LIBRARY_RELEASE}) + ENDIF() + IF(ASSIMP_LIBRARY_DEBUG) + SET(ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES} debug ${ASSIMP_LIBRARY_DEBUG}) + ENDIF() FIND_PACKAGE(ZLIB) IF(ZLIB_FOUND) - SET(assimp_LIBRARIES ${assimp_LIBRARIES} ${ZLIB_LIBRARIES}) + SET(ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES} ${ZLIB_LIBRARIES}) ENDIF() -ENDIF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES) + IF(IRRXML_LIBRARY_RELEASE) + SET(ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES} optimized ${IRRXML_LIBRARY_RELEASE}) + ENDIF() + IF(IRRXML_LIBRARY_DEBUG) + SET(ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES} debug ${IRRXML_LIBRARY_DEBUG}) + ENDIF() +ENDIF() -IF (assimp_FOUND) - IF (NOT assimp_FIND_QUIETLY) - MESSAGE(STATUS "Found asset importer library: ${assimp_LIBRARIES}") - ENDIF (NOT assimp_FIND_QUIETLY) -ELSE (assimp_FOUND) - IF (assimp_FIND_REQUIRED) +IF (ASSIMP_FOUND) + IF (NOT ASSIMP_FIND_QUIETLY) + MESSAGE(STATUS "Found asset importer library: ${ASSIMP_LIBRARIES}") + ENDIF () +ELSE (ASSIMP_FOUND) + IF (ASSIMP_FIND_REQUIRED) MESSAGE(FATAL_ERROR "Could not find asset importer library") - ENDIF (assimp_FIND_REQUIRED) -ENDIF (assimp_FOUND) + ENDIF () +ENDIF () diff --git a/code/CMakeModules/OSXToolChain.cmake b/code/CMakeModules/OSXToolChain.cmake new file mode 100644 index 000000000..3169aec78 --- /dev/null +++ b/code/CMakeModules/OSXToolChain.cmake @@ -0,0 +1,131 @@ +# Define OSX_SDK to force a specific version such as : -DOSX_SDK=10.11 +# +# Example: +# cmake ../code -DCMAKE_TOOLCHAIN_FILE=../code/CMakeModules/OSXToolChain.cmake -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_SERVER=OFF -DWITH_NEL_TOOLS=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_LUA51=OFF -DWITH_LUA53=ON -DCMAKE_BUILD_TYPE=Release -DWITH_RYZOM_INSTALLER=OFF -DWITH_RYZOM_PATCH=ON -DWITH_NEL_TESTS=OFF -DWITH_NEL_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_WARNINGS=OFF -DWITH_QT5=OFF -DWITH_STATIC=ON -DWITH_STATIC_DRIVERS=ON -DWITH_STATIC_EXTERNAL=ON -DWITH_UNIX_STRUCTURE=OFF -DWITH_INSTALL_LIBRARIES=OFF -DWITH_RYZOM_SANDBOX=OFF -DOSX_SDK=10.11 + +# Don't forget to define environment variables: +# +# export MACOSX_DEPLOYMENT_TARGET=10.7 +# export OSXCROSS_GCC_NO_STATIC_RUNTIME=1 +# export PATH=$PATH:/home/src/osxcross/target/bin +# +# ln -s /usr/bin/hg /home/src/osxcross/target/bin/hg +# +# To install all dependencies: +# ./osxcross-macports install libxml2 jpeg curl libogg libvorbis freetype boost openssl zlib lua-5.3 giflib + +# to compile Luabind +# export CMAKE_MODULE_PATH=$HOME/shard/tools/external/cmake/modules +# cmake .. -DCMAKE_TOOLCHAIN_FILE=$HOME/ryzomcore/code/CMakeModules/OSXToolChain.cmake -DWITH_SHARED=OFF -DWITH_STATIC=ON -DWITH_LUA51=OFF -DWITH_LUA53=ON -DCMAKE_INSTALL_PREFIX=$HOME/osxcross/target/external + +IF(DEFINED CMAKE_CROSSCOMPILING) + # subsequent toolchain loading is not really needed + RETURN() +ENDIF() + +# Force the compilers to Clang for OS X + +# C +SET(CMAKE_C_COMPILER x86_64-apple-darwin15-clang) +SET(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11") +SET(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert") +SET(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes") +SET(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros") +SET(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert") + +# C++ +SET(CMAKE_CXX_COMPILER x86_64-apple-darwin15-clang++) +SET(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17") +SET(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters") +SET(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates") +SET(CMAKE_CXX14_COMPILE_FEATURES "cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates") +SET(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17") + +# make +SET(CMAKE_MAKE_PROGRAM make) + +# Skip the platform compiler checks for cross compiling. +SET(CMAKE_CXX_COMPILER_FORCED TRUE) +SET(CMAKE_C_COMPILER_FORCED TRUE) + +# Check if osxcross is installed +EXECUTE_PROCESS(COMMAND which ${CMAKE_CXX_COMPILER} OUTPUT_VARIABLE COMPILER_FULLPATH OUTPUT_STRIP_TRAILING_WHITESPACE) + +IF(NOT COMPILER_FULLPATH) + MESSAGE(FATAL_ERROR "Unable to find ${CMAKE_CXX_COMPILER}, are you sure osxcross is installed and is in PATH?") +ENDIF() + +# Default paths +GET_FILENAME_COMPONENT(CMAKE_OSX_TOOLCHAIN_ROOT ${COMPILER_FULLPATH} DIRECTORY) + +# Parent directory +GET_FILENAME_COMPONENT(CMAKE_OSX_TOOLCHAIN_ROOT ${CMAKE_OSX_TOOLCHAIN_ROOT} DIRECTORY) + +SET(CMAKE_OSX_SYSROOT ${CMAKE_OSX_TOOLCHAIN_ROOT}/SDK) +SET(MACPORTS_ROOT_DIR ${CMAKE_OSX_TOOLCHAIN_ROOT}/macports/pkgs/opt/local) +SET(EXTERNAL_OSX_PATH ${CMAKE_OSX_TOOLCHAIN_ROOT}/external) + +# List of all SDKs that have been found +SET(OSX_SDKS) + +FILE(GLOB _CMAKE_OSX_SDKS "${CMAKE_OSX_SYSROOT}/MacOSX*") +IF(_CMAKE_OSX_SDKS) + LIST(SORT _CMAKE_OSX_SDKS) + LIST(REVERSE _CMAKE_OSX_SDKS) + FOREACH(_CMAKE_OSX_SDK ${_CMAKE_OSX_SDKS}) + STRING(REGEX REPLACE ".+MacOSX([0-9.]+)\\.sdk" "\\1" _OSX_SDK "${_CMAKE_OSX_SDK}") + LIST(APPEND OSX_SDKS ${_OSX_SDK}) + ENDFOREACH() +ENDIF() + +# Find and use the most recent OS X sdk +IF(NOT OSX_SDKS) + MESSAGE(FATAL_ERROR "No OS X SDK's found in default search path ${CMAKE_OSX_SYSROOT}.") +ENDIF() + +# if a specific SDK is defined, try to use it +IF(OSX_SDK) + LIST(FIND OSX_SDKS "${OSX_SDK}" _INDEX) + IF(_INDEX EQUAL -1) + # if specified SDK doesn't exist, use the last one + LIST(GET OSX_SDKS 0 OSX_SDK) + ENDIF() +ELSE() + # use the last SDK + LIST(GET OSX_SDKS 0 OSX_SDK) +ENDIF() + +MESSAGE(STATUS "Using OS X SDK ${OSX_SDK}") + +# Define final OS X sysroot +SET(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT}/MacOSX${OSX_SDK}.sdk) + +# Standard settings +SET(CMAKE_SYSTEM_NAME Darwin) +SET(CMAKE_SYSTEM "Darwin-15.0.0") +SET(CMAKE_SYSTEM_VERSION "15.0.0") +SET(CMAKE_SYSTEM_PROCESSOR "x86_64") + +SET(UNIX ON) +SET(APPLE ON) + +# Set the find root to the OS X developer roots and to user defined paths +SET(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_TOOLCHAIN_ROOT} ${CMAKE_OSX_SYSROOT} ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} ${MACPORTS_ROOT_DIR} ${EXTERNAL_OSX_PATH} $ENV{EXTERNAL_OSX_PATH} CACHE STRING "OS X find search path root") + +# default to searching for frameworks first +SET(CMAKE_FIND_FRAMEWORK FIRST) + +# set up the default search directories for frameworks +SET(CMAKE_SYSTEM_FRAMEWORK_PATH + ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks + ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks + ${CMAKE_OSX_SYSROOT}/Developer/Library/Frameworks +) + +# only search the OS X sdks, not the remainder of the host filesystem +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# determinate location for bin utils based on CMAKE_FIND_ROOT_PATH +INCLUDE(CMakeFindBinUtils) diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index 20539e87f..c396bd6cf 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -27,23 +27,45 @@ ELSE() ENDIF() ENDIF() +MACRO(APPEND_DEFINITION _NAME _VAL) + IF(CMAKE_VERSION VERSION_LESS "2.8.12") + # don't support logical expressions, append definition + LIST(APPEND ${_NAME} "-D${_VAL}") + ELSE() + # support logical expressions, use them + LIST(APPEND ${_NAME} "$<$:-D$>") + ENDIF() +ENDMACRO() + # Set PCH_FLAGS for common flags, PCH_ARCH_XXX_FLAGS for specific archs flags and PCH_ARCHS for archs MACRO(PCH_SET_COMPILE_FLAGS _target) SET(PCH_FLAGS) SET(PCH_ARCHS) SET(_FLAGS) - LIST(APPEND _FLAGS ${CMAKE_CXX_FLAGS}) + # C++ flags + SET(_FLAG ${CMAKE_CXX_FLAGS}) + SEPARATE_ARGUMENTS(_FLAG) + + LIST(APPEND _FLAGS ${_FLAG}) + + # C++ config flags STRING(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPER_BUILD) - LIST(APPEND _FLAGS " ${CMAKE_CXX_FLAGS_${_UPPER_BUILD}}") + + SET(_FLAG ${CMAKE_CXX_FLAGS_${_UPPER_BUILD}}) + SEPARATE_ARGUMENTS(_FLAG) + + LIST(APPEND _FLAGS ${_FLAG}) GET_TARGET_PROPERTY(_targetType ${_target} TYPE) SET(_USE_PIC OFF) IF(${_targetType} STREQUAL "SHARED_LIBRARY" OR ${_targetType} STREQUAL "MODULE_LIBRARY") - LIST(APPEND _FLAGS " ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") + SET(_FLAG ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) + SEPARATE_ARGUMENTS(_FLAG) + LIST(APPEND _FLAGS ${_FLAG}) ELSE() GET_TARGET_PROPERTY(_pic ${_target} POSITION_INDEPENDENT_CODE) IF(_pic) @@ -53,67 +75,75 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES) FOREACH(item ${DIRINC}) - LIST(APPEND _FLAGS " -I\"${item}\"") + LIST(APPEND _FLAGS -I"${item}") ENDFOREACH() + # NOTE: As cmake files (eg FindQT4) may now use generator expressions around their defines that evaluate + # to an empty string, wrap all "items" in an expression that outputs a -D IFF the generated + # expression is not empty. + # Required for CMake 2.6 SET(GLOBAL_DEFINITIONS) GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") + APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD}) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") + APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") + APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD}) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") + APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() GET_TARGET_PROPERTY(oldProps ${_target} COMPILE_FLAGS) IF(oldProps) - LIST(APPEND _FLAGS " ${oldProps}") + SET(_FLAG ${oldProps}) + SEPARATE_ARGUMENTS(_FLAG) + LIST(APPEND _FLAGS ${_FLAG}) ENDIF() GET_TARGET_PROPERTY(oldPropsBuild ${_target} COMPILE_FLAGS_${_UPPER_BUILD}) IF(oldPropsBuild) - LIST(APPEND _FLAGS " ${oldPropsBuild}") + SET(_FLAG ${oldPropsBuild}) + SEPARATE_ARGUMENTS(_FLAG) + LIST(APPEND _FLAGS ${_FLAG}) ENDIF() GET_TARGET_PROPERTY(DIRINC ${_target} INCLUDE_DIRECTORIES) IF(DIRINC) FOREACH(item ${DIRINC}) - LIST(APPEND _FLAGS " -I\"${item}\"") + LIST(APPEND _FLAGS -I"${item}") ENDFOREACH() ENDIF() GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") + APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD}) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") + APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() @@ -126,7 +156,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) IF(_DIRS) FOREACH(item ${_DIRS}) - LIST(APPEND GLOBAL_DEFINITIONS " -I\"${item}\"") + LIST(APPEND GLOBAL_DEFINITIONS -I"${item}") ENDFOREACH() ENDIF() @@ -135,10 +165,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) IF(_DEFINITIONS) FOREACH(item ${_DEFINITIONS}) - # don't use dynamic expressions - IF(NOT item MATCHES "\\$<") - LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") - ENDIF() + APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() ENDIF() @@ -149,7 +176,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) IF(GLOBAL_DEFINITIONS MATCHES "QT_CORE_LIB") # Hack to define missing QT_NO_DEBUG with Qt 5.2 IF(_UPPER_BUILD STREQUAL "RELEASE") - LIST(APPEND GLOBAL_DEFINITIONS " -DQT_NO_DEBUG") + LIST(APPEND GLOBAL_DEFINITIONS "-DQT_NO_DEBUG") ENDIF() # Qt5_POSITION_INDEPENDENT_CODE should be true if Qt was compiled with PIC @@ -158,28 +185,43 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDIF() IF(_USE_PIC) - LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIC}") + LIST(APPEND _FLAGS ${CMAKE_CXX_COMPILE_OPTIONS_PIC}) ENDIF() ENDIF() - LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}") - IF(CMAKE_VERSION VERSION_LESS "3.3.0") - GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) - GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS) - LIST(APPEND _FLAGS " ${_directory_flags}") - LIST(APPEND _FLAGS " ${_directory_definitions}") + GET_DIRECTORY_PROPERTY(_DIRECTORY_FLAGS DEFINITIONS) + + IF(_DIRECTORY_FLAGS) + SEPARATE_ARGUMENTS(_DIRECTORY_FLAGS) + FOREACH(item ${_DIRECTORY_FLAGS}) + LIST(APPEND _FLAGS "${item}") + ENDFOREACH() + ENDIF() + + GET_DIRECTORY_PROPERTY(_DIRECTORY_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS) + + IF(_DIRECTORY_DEFINITIONS) + SEPARATE_ARGUMENTS(_DIRECTORY_DEFINITIONS) + FOREACH(item ${_DIRECTORY_DEFINITIONS}) + LIST(APPEND _FLAGS "${item}") + ENDFOREACH() + ENDIF() + ENDIF() + + IF(USE_CPP0X AND gcc_compiler_version GREATER "6.2.0") + LIST(APPEND _FLAGS "-std=gnu++11") ENDIF() # Format definitions IF(MSVC) # Fix path with space SEPARATE_ARGUMENTS(_FLAGS UNIX_COMMAND "${_FLAGS}") - ELSE() - STRING(REGEX REPLACE " +" " " _FLAGS ${_FLAGS}) - SEPARATE_ARGUMENTS(_FLAGS) ENDIF() + # Already in list form and items may contain non-leading spaces that should not be split on + LIST(INSERT _FLAGS 0 "${GLOBAL_DEFINITIONS}") + IF(CLANG) # Determining all architectures and get common flags SET(_ARCH_NEXT) @@ -236,6 +278,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDIF() IF(PCH_FLAGS) + LIST(REMOVE_ITEM PCH_FLAGS "") LIST(REMOVE_DUPLICATES PCH_FLAGS) ENDIF() ENDMACRO() @@ -247,16 +290,16 @@ MACRO(GET_PDB_FILENAME _out_filename _target) SET(_targetOutput ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) ELSEIF(${_targetType} STREQUAL STATIC_LIBRARY) SET(_targetOutput ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) - ELSE(${_targetType} STREQUAL EXECUTABLE) + ELSE() SET(_targetOutput ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) - ENDIF(${_targetType} STREQUAL EXECUTABLE) + ENDIF() # determine target postfix STRING(TOUPPER "${CMAKE_BUILD_TYPE}_POSTFIX" _postfix_var_name) GET_TARGET_PROPERTY(_targetPostfix ${_target} ${_postfix_var_name}) IF(${_targetPostfix} MATCHES NOTFOUND) SET(_targetPostfix "") - ENDIF(${_targetPostfix} MATCHES NOTFOUND) + ENDIF() SET(${_out_filename} "${_targetOutput}/${_target}${_targetPostfix}.pdb") ENDMACRO(GET_PDB_FILENAME) @@ -270,8 +313,9 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS) ENDIF() IF(MSVC) - GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target}) - SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj") + GET_PDB_FILENAME(_PDB_FILE ${_PCH_current_target}) + SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${_PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj") + # Ninja PCH Support # http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES OBJECT_OUTPUTS "${PCH_OUTPUT}.obj") @@ -280,7 +324,7 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS) SET(_FLAGS "") IF(APPLE) SET(HEADER_FORMAT "objective-${HEADER_FORMAT}") - SET(_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch) + SET(_FLAGS ${OBJC_FLAGS}) ENDIF() SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} ${_FLAGS} -x ${HEADER_FORMAT} -o ${PCH_OUTPUT} -c ${PCH_INPUT}) ENDIF() @@ -366,7 +410,8 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName) ENDIF() IF(APPLE) - SET(PCH_ADDITIONAL_COMPILER_FLAGS "-fobjc-abi-version=2 -fobjc-legacy-dispatch -x objective-c++ ${PCH_ADDITIONAL_COMPILER_FLAGS}") + STRING(REPLACE ";" " " OBJC_FLAGS_STR "${OBJC_FLAGS}") + SET(PCH_ADDITIONAL_COMPILER_FLAGS "${OBJC_FLAGS_STR} -x objective-c++ ${PCH_ADDITIONAL_COMPILER_FLAGS}") ENDIF() IF(WITH_PCH_DEBUG) diff --git a/code/CMakeModules/iOSToolChain.cmake b/code/CMakeModules/iOSToolChain.cmake index 610045e33..7bcb57227 100644 --- a/code/CMakeModules/iOSToolChain.cmake +++ b/code/CMakeModules/iOSToolChain.cmake @@ -35,23 +35,6 @@ SET(UNIX ON) SET(APPLE ON) SET(IOS ON) -# Force the compilers to Clang for iOS -include (CMakeForceCompiler) -CMAKE_FORCE_C_COMPILER (clang Clang) -CMAKE_FORCE_CXX_COMPILER (clang++ Clang) - -IF(CMAKE_CXX_COMPILER) - EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} --version - OUTPUT_VARIABLE CLANG_VERSION_RAW - OUTPUT_STRIP_TRAILING_WHITESPACE) - - STRING(REGEX REPLACE "Apple LLVM version ([\\.0-9]+).*" - "\\1" CMAKE_CXX_COMPILER_VERSION "${CLANG_VERSION_RAW}") - - SET(CMAKE_C_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION}) - SET(CMAKE_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION}) -ENDIF() - # Setup iOS platform IF(NOT DEFINED IOS_PLATFORM) SET(IOS_PLATFORM "OS") @@ -162,14 +145,14 @@ IF(CMAKE_GENERATOR MATCHES Xcode) ENDIF() ELSE() IF(${IOS_PLATFORM} STREQUAL "OS") - SET(ARCHS "armv7;arm64") + SET(ARCHS armv7 arm64) SET(CMAKE_SYSTEM_PROCESSOR "armv7") ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR") # iPhone simulator targets i386 SET(ARCHS "i386") SET(CMAKE_SYSTEM_PROCESSOR "x86") ELSEIF(${IOS_PLATFORM} STREQUAL "ALL") - SET(ARCHS "armv7;arm64;i386;x86_64") + SET(ARCHS armv7 arm64 i386 x86_64) SET(CMAKE_SYSTEM_PROCESSOR "armv7") ENDIF() ENDIF() @@ -198,5 +181,13 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +# Force the compilers to Clang for iOS +SET(CMAKE_C_COMPILER clang) +SET(CMAKE_CXX_COMPILER clang++) + +# Skip the platform compiler checks for cross compiling. +SET(CMAKE_CXX_COMPILER_FORCED TRUE) +SET(CMAKE_C_COMPILER_FORCED TRUE) + # determinate location for bin utils based on CMAKE_FIND_ROOT_PATH -include(CMakeFindBinUtils) +INCLUDE(CMakeFindBinUtils) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 5c2d99d30..95b28bb8a 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -4,7 +4,7 @@ SET(CMAKE_TRY_COMPILE_CONFIGURATION "Release") # Force Release configuration by default IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) -ENDIF(NOT CMAKE_BUILD_TYPE) +ENDIF() # Declare CMAKE_CONFIGURATION_TYPES before PROJECT SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) @@ -17,7 +17,7 @@ MACRO(NL_GEN_PC name) IF(NOT WIN32 AND WITH_INSTALL_LIBRARIES) CONFIGURE_FILE(${name}.in "${CMAKE_CURRENT_BINARY_DIR}/${name}") INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION ${NL_LIB_PREFIX}/pkgconfig) - ENDIF(NOT WIN32 AND WITH_INSTALL_LIBRARIES) + ENDIF() ENDMACRO(NL_GEN_PC) ### @@ -26,9 +26,9 @@ ENDMACRO(NL_GEN_PC) MACRO(NL_TARGET_LIB name) IF(WITH_STATIC) ADD_LIBRARY(${name} STATIC ${ARGN}) - ELSE(WITH_STATIC) + ELSE() ADD_LIBRARY(${name} SHARED ${ARGN}) - ENDIF(WITH_STATIC) + ENDIF() ENDMACRO(NL_TARGET_LIB) ### @@ -37,9 +37,9 @@ ENDMACRO(NL_TARGET_LIB) MACRO(NL_TARGET_DRIVER name) IF(WITH_STATIC_DRIVERS) ADD_LIBRARY(${name} STATIC ${ARGN}) - ELSE(WITH_STATIC_DRIVERS) + ELSE() ADD_LIBRARY(${name} MODULE ${ARGN}) - ENDIF(WITH_STATIC_DRIVERS) + ENDIF() ENDMACRO(NL_TARGET_DRIVER) ### @@ -64,16 +64,35 @@ MACRO(NL_DEFAULT_PROPS name label) VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR}) IF(NL_LIB_PREFIX) SET_TARGET_PROPERTIES(${name} PROPERTIES INSTALL_NAME_DIR ${NL_LIB_PREFIX}) - ENDIF(NL_LIB_PREFIX) - ENDIF(${type} STREQUAL SHARED_LIBRARY) + ENDIF() + ENDIF() IF(${type} STREQUAL EXECUTABLE AND WIN32 AND NOT MINGW) + # check if using a GUI + GET_TARGET_PROPERTY(_VALUE ${name} WIN32_EXECUTABLE) + + IF(TARGET_X64) + # Target Windows XP 64 bits + SET(_SUBSYSTEM_VERSION "5.02") + ELSE() + # Target Windows XP + SET(_SUBSYSTEM_VERSION "5.01") + ENDIF() + + IF(_VALUE) + # GUI + SET(_SUBSYSTEM "WINDOWS") + ELSE() + # Console + SET(_SUBSYSTEM "CONSOLE") + ENDIF() + SET_TARGET_PROPERTIES(${name} PROPERTIES VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR} COMPILE_FLAGS "/GA" - LINK_FLAGS "/VERSION:${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}") - ENDIF(${type} STREQUAL EXECUTABLE AND WIN32 AND NOT MINGW) + LINK_FLAGS "/VERSION:${NL_VERSION_MAJOR}.${NL_VERSION_MINOR} /SUBSYSTEM:${_SUBSYSTEM},${_SUBSYSTEM_VERSION}") + ENDIF() ENDMACRO(NL_DEFAULT_PROPS) ### @@ -83,7 +102,7 @@ ENDMACRO(NL_DEFAULT_PROPS) MACRO(NL_ADD_LIB_SUFFIX name) IF(WIN32) SET_TARGET_PROPERTIES(${name} PROPERTIES DEBUG_POSTFIX "_d" RELEASE_POSTFIX "_r") - ENDIF(WIN32) + ENDIF() ENDMACRO(NL_ADD_LIB_SUFFIX) ### @@ -95,10 +114,10 @@ MACRO(NL_ADD_RUNTIME_FLAGS name) # SET_TARGET_PROPERTIES(${name} PROPERTIES # LINK_FLAGS_DEBUG "${CMAKE_LINK_FLAGS_DEBUG}" # LINK_FLAGS_RELEASE "${CMAKE_LINK_FLAGS_RELEASE}") - ENDIF(WIN32) + ENDIF() IF(WITH_STLPORT) TARGET_LINK_LIBRARIES(${name} ${STLPORT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) - ENDIF(WITH_STLPORT) + ENDIF() ENDMACRO(NL_ADD_RUNTIME_FLAGS) MACRO(NL_ADD_STATIC_VID_DRIVERS name) @@ -106,25 +125,25 @@ MACRO(NL_ADD_STATIC_VID_DRIVERS name) IF(WIN32) IF(WITH_DRIVER_DIRECT3D) TARGET_LINK_LIBRARIES(${name} nel_drv_direct3d_win) - ENDIF(WITH_DRIVER_DIRECT3D) - ENDIF(WIN32) + ENDIF() + ENDIF() IF(WITH_DRIVER_OPENGL) IF(WIN32) TARGET_LINK_LIBRARIES(${name} nel_drv_opengl_win) - ELSE(WIN32) + ELSE() TARGET_LINK_LIBRARIES(${name} nel_drv_opengl) - ENDIF(WIN32) - ENDIF(WITH_DRIVER_OPENGL) + ENDIF() + ENDIF() IF(WITH_DRIVER_OPENGLES) IF(WIN32) TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win) - ELSE(WIN32) + ELSE() TARGET_LINK_LIBRARIES(${name} nel_drv_opengles) - ENDIF(WIN32) - ENDIF(WITH_DRIVER_OPENGLES) - ENDIF(WITH_STATIC_DRIVERS) + ENDIF() + ENDIF() + ENDIF() ENDMACRO(NL_ADD_STATIC_VID_DRIVERS) MACRO(NL_ADD_STATIC_SND_DRIVERS name) @@ -132,30 +151,30 @@ MACRO(NL_ADD_STATIC_SND_DRIVERS name) IF(WIN32) IF(WITH_DRIVER_DSOUND) TARGET_LINK_LIBRARIES(${name} nel_drv_dsound_win) - ENDIF(WITH_DRIVER_DSOUND) + ENDIF() IF(WITH_DRIVER_XAUDIO2) TARGET_LINK_LIBRARIES(${name} nel_drv_xaudio2_win) - ENDIF(WITH_DRIVER_XAUDIO2) + ENDIF() IF(WITH_DRIVER_OPENAL) TARGET_LINK_LIBRARIES(${name} nel_drv_openal_win) - ENDIF(WITH_DRIVER_OPENAL) + ENDIF() IF(WITH_DRIVER_FMOD) TARGET_LINK_LIBRARIES(${name} nel_drv_fmod_win) - ENDIF(WITH_DRIVER_FMOD) - ELSE(WIN32) + ENDIF() + ELSE() IF(WITH_DRIVER_OPENAL) TARGET_LINK_LIBRARIES(${name} nel_drv_openal) - ENDIF(WITH_DRIVER_OPENAL) + ENDIF() IF(WITH_DRIVER_FMOD) TARGET_LINK_LIBRARIES(${name} nel_drv_fmod) - ENDIF(WITH_DRIVER_FMOD) - ENDIF(WIN32) + ENDIF() + ENDIF() - ENDIF(WITH_STATIC_DRIVERS) + ENDIF() ENDMACRO(NL_ADD_STATIC_SND_DRIVERS) ### @@ -173,14 +192,14 @@ Remove the CMakeCache.txt file and try again from another folder, e.g.: cd cmake cmake .. ") - ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + ENDIF() ENDMACRO(CHECK_OUT_OF_SOURCE) MACRO(NL_SETUP_DEFAULT_OPTIONS) IF(WITH_QT) OPTION(WITH_STUDIO "Build Core Studio" OFF ) - ENDIF(WITH_QT) + ENDIF() ### # Features @@ -194,30 +213,30 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) # Default to static building on Windows. IF(WIN32) OPTION(WITH_STATIC "With static libraries." ON ) - ELSE(WIN32) + ELSE() OPTION(WITH_STATIC "With static libraries." OFF) - ENDIF(WIN32) + ENDIF() IF (WITH_STATIC) OPTION(WITH_STATIC_LIBXML2 "With static libxml2" ON ) - ELSE(WITH_STATIC) + ELSE() OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF) - ENDIF(WITH_STATIC) + ENDIF() IF (WITH_STATIC) OPTION(WITH_STATIC_CURL "With static curl" ON ) - ELSE(WITH_STATIC) + ELSE() OPTION(WITH_STATIC_CURL "With static curl" OFF) - ENDIF(WITH_STATIC) + ENDIF() IF(APPLE) OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" ON ) - ELSE(APPLE) + ELSE() OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" OFF) - ENDIF(APPLE) + ENDIF() OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF) IF(WIN32) OPTION(WITH_EXTERNAL "With provided external." ON ) - ELSE(WIN32) + ELSE() OPTION(WITH_EXTERNAL "With provided external." OFF) - ENDIF(WIN32) + ENDIF() OPTION(WITH_STATIC_EXTERNAL "With static external libraries" OFF) IF(UNIX AND NOT APPLE) OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" ON ) @@ -237,9 +256,9 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) IF(WIN32 AND MFC_FOUND) OPTION(WITH_MFC "With MFC Support" ON ) - ELSE(WIN32 AND MFC_FOUND) + ELSE() OPTION(WITH_MFC "With MFC Support" OFF) - ENDIF(WIN32 AND MFC_FOUND) + ENDIF() ### # Optional support @@ -304,7 +323,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) IF(NOT MSVC) OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF) - ENDIF(NOT MSVC) + ENDIF() ENDMACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) MACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS) @@ -333,6 +352,8 @@ MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF) OPTION(WITH_RYZOM_PATCH "Enable Ryzom in-game patch support" OFF) OPTION(WITH_RYZOM_CUSTOM_PATCH_SERVER "Only use patch server from CFG file" OFF) + OPTION(WITH_RYZOM_STEAM "Enable Steam features" OFF) + OPTION(WITH_RYZOM_SANDBOX "Enable Sandbox under OS X" OFF) ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS) @@ -346,7 +367,11 @@ ENDMACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS) MACRO(ADD_PLATFORM_FLAGS _FLAGS) SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${_FLAGS}") SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${_FLAGS}") -ENDMACRO(ADD_PLATFORM_FLAGS) +ENDMACRO() + +MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS) + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}") +ENDMACRO() MACRO(NL_SETUP_BUILD) @@ -359,51 +384,60 @@ MACRO(NL_SETUP_BUILD) IF(CMAKE_BUILD_TYPE MATCHES "Debug") SET(NL_BUILD_MODE "NL_DEBUG") - ELSE(CMAKE_BUILD_TYPE MATCHES "Debug") + ELSE() IF(CMAKE_BUILD_TYPE MATCHES "Release") SET(NL_BUILD_MODE "NL_RELEASE") - ELSE(CMAKE_BUILD_TYPE MATCHES "Release") + ELSE() SET(NL_BUILD_MODE "NL_RELEASE") # enforce release mode if it's neither Debug nor Release SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) - ENDIF(CMAKE_BUILD_TYPE MATCHES "Release") - ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug") + ENDIF() + ENDIF() - SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR}) + IF(CMAKE_CXX_LIBRARY_ARCHITECTURE) + SET(HOST_CPU ${CMAKE_CXX_LIBRARY_ARCHITECTURE}) + ELSE() + SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR}) + ENDIF() - IF(HOST_CPU MATCHES "(amd|AMD)64") + IF(HOST_CPU MATCHES "(amd|AMD|x86_)64") SET(HOST_CPU "x86_64") ELSEIF(HOST_CPU MATCHES "i.86") SET(HOST_CPU "x86") - ENDIF(HOST_CPU MATCHES "(amd|AMD)64") + ENDIF() # Determine target CPU # If not specified, use the same CPU as host IF(NOT TARGET_CPU) - SET(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) - ENDIF(NOT TARGET_CPU) + SET(TARGET_CPU ${HOST_CPU}) + ENDIF() - IF(TARGET_CPU MATCHES "(amd|AMD)64") + IF(TARGET_CPU MATCHES "(amd|AMD|x86_)64") SET(TARGET_CPU "x86_64") ELSEIF(TARGET_CPU MATCHES "i.86") SET(TARGET_CPU "x86") - ENDIF(TARGET_CPU MATCHES "(amd|AMD)64") + ENDIF() IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") SET(CLANG ON) - MESSAGE(STATUS "Using Clang compiler") - ENDIF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + MESSAGE(STATUS "Using Clang ${CMAKE_CXX_COMPILER_VERSION} compiler") + ENDIF() IF(CMAKE_GENERATOR MATCHES "Xcode") SET(XCODE ON) MESSAGE(STATUS "Generating Xcode project") - ENDIF(CMAKE_GENERATOR MATCHES "Xcode") + ENDIF() IF(CMAKE_GENERATOR MATCHES "NMake") SET(NMAKE ON) MESSAGE(STATUS "Generating NMake project") - ENDIF(CMAKE_GENERATOR MATCHES "NMake") + ENDIF() + + IF(CMAKE_GENERATOR MATCHES "Ninja") + SET(NINJA ON) + MESSAGE(STATUS "Generating Ninja project") + ENDIF() # If target and host CPU are the same IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING) @@ -412,24 +446,24 @@ MACRO(NL_SETUP_BUILD) IF(NOT CMAKE_SIZEOF_VOID_P) INCLUDE (CheckTypeSize) CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P) - ENDIF(NOT CMAKE_SIZEOF_VOID_P) + ENDIF() # Using 32 or 64 bits libraries IF(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(TARGET_CPU "x86_64") - ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) + ELSE() SET(TARGET_CPU "x86") - ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) + ENDIF() ELSEIF(HOST_CPU MATCHES "arm") SET(TARGET_CPU "arm") - ELSE(HOST_CPU MATCHES "x86") + ELSE() SET(TARGET_CPU "unknown") MESSAGE(STATUS "Unknown architecture: ${HOST_CPU}") - ENDIF(HOST_CPU MATCHES "x86") + ENDIF() # TODO: add checks for PPC - ELSE("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING) + ELSE() MESSAGE(STATUS "Compiling on ${HOST_CPU} for ${TARGET_CPU}") - ENDIF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING) + ENDIF() # Use values from environment variables SET(PLATFORM_CFLAGS "$ENV{CFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CFLAGS}") @@ -453,6 +487,9 @@ MACRO(NL_SETUP_BUILD) SET(TARGET_X86 1) ELSEIF(TARGET_CPU STREQUAL "x86") SET(TARGET_X86 1) + ELSEIF(TARGET_CPU STREQUAL "arm64") + SET(TARGET_ARM 1) + SET(TARGET_ARM64 1) ELSEIF(TARGET_CPU STREQUAL "armv7s") SET(TARGET_ARM 1) SET(TARGET_ARMV7S 1) @@ -469,36 +506,40 @@ MACRO(NL_SETUP_BUILD) SET(TARGET_ARM 1) ELSEIF(TARGET_CPU STREQUAL "mips") SET(TARGET_MIPS 1) - ENDIF(TARGET_CPU STREQUAL "x86_64") + ENDIF() IF(TARGET_ARM) + IF(TARGET_ARM64) + ADD_PLATFORM_FLAGS("-DHAVE_ARM64") + ENDIF() + IF(TARGET_ARMV7S) ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S") - ENDIF(TARGET_ARMV7S) + ENDIF() IF(TARGET_ARMV7) ADD_PLATFORM_FLAGS("-DHAVE_ARMV7") - ENDIF(TARGET_ARMV7) + ENDIF() IF(TARGET_ARMV6) ADD_PLATFORM_FLAGS("-HAVE_ARMV6") - ENDIF(TARGET_ARMV6) + ENDIF() ADD_PLATFORM_FLAGS("-DHAVE_ARM") - ENDIF(TARGET_ARM) + ENDIF() IF(TARGET_X86) ADD_PLATFORM_FLAGS("-DHAVE_X86") - ENDIF(TARGET_X86) + ENDIF() IF(TARGET_X64) ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64") - ENDIF(TARGET_X64) + ENDIF() IF(TARGET_MIPS) ADD_PLATFORM_FLAGS("-DHAVE_MIPS") - ENDIF(TARGET_MIPS) - ENDIF(NOT CMAKE_OSX_ARCHITECTURES) + ENDIF() + ENDIF() # Fix library paths suffixes for Debian MultiArch IF(LIBRARY_ARCHITECTURE) @@ -507,77 +548,83 @@ MACRO(NL_SETUP_BUILD) SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64) ELSEIF(TARGET_X86) SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32) - ENDIF(TARGET_X64) - ENDIF(LIBRARY_ARCHITECTURE) + ENDIF() + ENDIF() IF(APPLE AND NOT IOS) SET(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH}) SET(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH}) - ENDIF(APPLE AND NOT IOS) + ENDIF() IF(WITH_LOGGING) ADD_PLATFORM_FLAGS("-DENABLE_LOGS") - ENDIF(WITH_LOGGING) + ENDIF() IF(MSVC) - IF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11) - SET(MSVC11 ON) - ENDIF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11) - # Ignore default include paths ADD_PLATFORM_FLAGS("/X") IF(MSVC14) - ADD_PLATFORM_FLAGS("/Gy- /MP") - # /Ox is working with VC++ 2015, but custom optimizations don't exist + ADD_PLATFORM_FLAGS("/Gy-") + # /Ox is working with VC++ 2015 and 2017, but custom optimizations don't exist SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") # without inlining it's unusable, use custom optimizations again SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") + + # Special cases for VC++ 2017 + IF(MSVC_VERSION EQUAL "1911") + SET(MSVC1411 ON) + ELSEIF(MSVC_VERSION EQUAL "1910") + SET(MSVC1410 ON) + ENDIF() ELSEIF(MSVC12) - ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") + ADD_PLATFORM_FLAGS("/Gy-") # /Ox is working with VC++ 2013, but custom optimizations don't exist SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") # without inlining it's unusable, use custom optimizations again SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") ELSEIF(MSVC11) - ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") + ADD_PLATFORM_FLAGS("/Gy-") # /Ox is working with VC++ 2012, but custom optimizations don't exist SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") # without inlining it's unusable, use custom optimizations again SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") ELSEIF(MSVC10) - ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") + ADD_PLATFORM_FLAGS("/Gy-") # /Ox is working with VC++ 2010, but custom optimizations don't exist SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") # without inlining it's unusable, use custom optimizations again SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") ELSEIF(MSVC90) - ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") + ADD_PLATFORM_FLAGS("/Gy-") # don't use a /O[012x] flag if you want custom optimizations SET(RELEASE_CFLAGS "/Ob2 /Oi /Ot /Oy /GT /GF /GS- ${RELEASE_CFLAGS}") # without inlining it's unusable, use custom optimizations again SET(DEBUG_CFLAGS "/Ob1 /GF- ${DEBUG_CFLAGS}") ELSEIF(MSVC80) - ADD_PLATFORM_FLAGS("/Gy- /Wp64 /Zm1000") + ADD_PLATFORM_FLAGS("/Gy- /Wp64") # don't use a /O[012x] flag if you want custom optimizations SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") # without inlining it's unusable, use custom optimizations again SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}") - ELSE(MSVC12) + ELSE() MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") - ENDIF(MSVC14) + ENDIF() - ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /wd4250") + ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WIN32 /DWIN32 /D_WINDOWS /wd4250") + + # huge PCH + ADD_PLATFORM_FLAGS("/Zm1000") IF(TARGET_X64) # Fix a bug with Intellisense ADD_PLATFORM_FLAGS("/D_WIN64") # Fix a compilation error for some big C++ files - SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} /bigobj") - ELSE(TARGET_X64) + ADD_PLATFORM_FLAGS("/bigobj") + ELSE() # Allows 32 bits applications to use 3 GB of RAM - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /LARGEADDRESSAWARE") - ENDIF(TARGET_X64) + ADD_PLATFORM_LINKFLAGS("/LARGEADDRESSAWARE") + ENDIF() # Exceptions are only set for C++ SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} /EHa") @@ -585,9 +632,9 @@ MACRO(NL_SETUP_BUILD) IF(WITH_SYMBOLS) SET(NL_RELEASE_CFLAGS "/Zi ${NL_RELEASE_CFLAGS}") SET(NL_RELEASE_LINKFLAGS "/DEBUG ${NL_RELEASE_LINKFLAGS}") - ELSE(WITH_SYMBOLS) + ELSE() SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}") - ENDIF(WITH_SYMBOLS) + 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}") @@ -596,27 +643,29 @@ MACRO(NL_SETUP_BUILD) IF(WITH_WARNINGS) SET(DEBUG_CFLAGS "/W4 ${DEBUG_CFLAGS}") - ELSE(WITH_WARNINGS) + ELSE() SET(DEBUG_CFLAGS "/W3 ${DEBUG_CFLAGS}") - ENDIF(WITH_WARNINGS) - ELSE(MSVC) + ENDIF() + ELSE() IF(WIN32) ADD_PLATFORM_FLAGS("-DWIN32 -D_WIN32") IF(CLANG) ADD_PLATFORM_FLAGS("-nobuiltininc") - ENDIF(CLANG) - ENDIF(WIN32) + ENDIF() + ENDIF() IF(WITH_SSE3) ADD_PLATFORM_FLAGS("-msse3") - ENDIF(WITH_SSE3) + ENDIF() IF(WITH_GCC_FPMATH_BOTH) ADD_PLATFORM_FLAGS("-mfpmath=both") - ENDIF(WITH_GCC_FPMATH_BOTH) + ENDIF() 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) @@ -649,97 +698,97 @@ MACRO(NL_SETUP_BUILD) SET(_ARCHS "${_ARCHS} mips") SET(TARGET_MIPS 1) MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") - ELSE(_ARCH STREQUAL "i386") + ELSE() SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})") - ENDIF(_ARCH STREQUAL "i386") + ENDIF() ENDFOREACH(_ARCH) MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}") - ELSE(CMAKE_OSX_ARCHITECTURES) + ELSE() SET(TARGETS_COUNT 0) - ENDIF(CMAKE_OSX_ARCHITECTURES) + ENDIF() IF(TARGETS_COUNT EQUAL 1) IF(TARGET_ARM) IF(TARGET_ARMV7S) ADD_PLATFORM_FLAGS("-arch armv7s -DHAVE_ARMV7S") - ENDIF(TARGET_ARMV7S) + ENDIF() IF(TARGET_ARMV7) ADD_PLATFORM_FLAGS("-arch armv7 -DHAVE_ARMV7") - ENDIF(TARGET_ARMV7) + ENDIF() IF(TARGET_ARMV6) ADD_PLATFORM_FLAGS("-arch armv6 -DHAVE_ARMV6") - ENDIF(TARGET_ARMV6) + ENDIF() IF(TARGET_ARMV5) ADD_PLATFORM_FLAGS("-arch armv5 -DHAVE_ARMV5") - ENDIF(TARGET_ARMV5) + ENDIF() ADD_PLATFORM_FLAGS("-mthumb -DHAVE_ARM") - ENDIF(TARGET_ARM) + ENDIF() IF(TARGET_X64) ADD_PLATFORM_FLAGS("-arch x86_64 -DHAVE_X64 -DHAVE_X86_64 -DHAVE_X86") ELSEIF(TARGET_X86) ADD_PLATFORM_FLAGS("-arch i386 -DHAVE_X86") - ENDIF(TARGET_X64) + ENDIF() IF(TARGET_MIPS) ADD_PLATFORM_FLAGS("-arch mips -DHAVE_MIPS") - ENDIF(TARGET_MIPS) + ENDIF() ELSEIF(TARGETS_COUNT EQUAL 0) # Not using CMAKE_OSX_ARCHITECTURES, HAVE_XXX already defined before IF(TARGET_ARM) IF(TARGET_ARMV7S) ADD_PLATFORM_FLAGS("-arch armv7s") - ENDIF(TARGET_ARMV7S) + ENDIF() IF(TARGET_ARMV7) ADD_PLATFORM_FLAGS("-arch armv7") - ENDIF(TARGET_ARMV7) + ENDIF() IF(TARGET_ARMV6) ADD_PLATFORM_FLAGS("-arch armv6") - ENDIF(TARGET_ARMV6) + ENDIF() IF(TARGET_ARMV5) ADD_PLATFORM_FLAGS("-arch armv5") - ENDIF(TARGET_ARMV5) + ENDIF() ADD_PLATFORM_FLAGS("-mthumb") - ENDIF(TARGET_ARM) + ENDIF() IF(TARGET_X64) ADD_PLATFORM_FLAGS("-arch x86_64") ELSEIF(TARGET_X86) ADD_PLATFORM_FLAGS("-arch i386") - ENDIF(TARGET_X64) + ENDIF() IF(TARGET_MIPS) ADD_PLATFORM_FLAGS("-arch mips") - ENDIF(TARGET_MIPS) - ELSE(TARGETS_COUNT EQUAL 1) + ENDIF() + ELSE() IF(TARGET_ARMV6) ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6") - ENDIF(TARGET_ARMV6) + ENDIF() IF(TARGET_ARMV7) ADD_PLATFORM_FLAGS("-Xarch_armv7 -mthumb -Xarch_armv7 -DHAVE_ARM -Xarch_armv7 -DHAVE_ARMV7") - ENDIF(TARGET_ARMV7) + ENDIF() IF(TARGET_X86) ADD_PLATFORM_FLAGS("-Xarch_i386 -DHAVE_X86") - ENDIF(TARGET_X86) + ENDIF() IF(TARGET_X64) ADD_PLATFORM_FLAGS("-Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64") - ENDIF(TARGET_X64) + ENDIF() IF(TARGET_MIPS) ADD_PLATFORM_FLAGS("-Xarch_mips -DHAVE_MIPS") - ENDIF(TARGET_MIPS) - ENDIF(TARGETS_COUNT EQUAL 1) + ENDIF() + ENDIF() IF(IOS) SET(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE) @@ -749,75 +798,88 @@ MACRO(NL_SETUP_BUILD) CONVERT_VERSION_NUMBER(${IOS_VERSION_MAJOR} ${IOS_VERSION_MINOR} ${IOS_VERSION_PATCH} IOS_VERSION_NUMBER) ADD_PLATFORM_FLAGS("-D__IPHONE_OS_VERSION_MIN_REQUIRED=${IOS_VERSION_NUMBER}") - ENDIF(IOS_VERSION) + ENDIF() IF(CMAKE_IOS_SYSROOT) IF(TARGET_ARMV7S) IF(TARGETS_COUNT GREATER 1) SET(XARCH "-Xarch_armv7s ") - ENDIF(TARGETS_COUNT GREATER 1) + ENDIF() ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") - ENDIF(TARGET_ARMV7S) + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") + ENDIF() IF(TARGET_ARMV7) IF(TARGETS_COUNT GREATER 1) SET(XARCH "-Xarch_armv7 ") - ENDIF(TARGETS_COUNT GREATER 1) + ENDIF() ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") - ENDIF(TARGET_ARMV7) + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") + ENDIF() IF(TARGET_ARMV6) IF(TARGETS_COUNT GREATER 1) SET(XARCH "-Xarch_armv6 ") - ENDIF(TARGETS_COUNT GREATER 1) + ENDIF() ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") - ENDIF(TARGET_ARMV6) - ENDIF(CMAKE_IOS_SYSROOT) + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") + ENDIF() + ENDIF() IF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86) IF(TARGETS_COUNT GREATER 1) SET(XARCH "-Xarch_i386 ") - ENDIF(TARGETS_COUNT GREATER 1) + ENDIF() ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SIMULATOR_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-mios-simulator-version-min=${IOS_VERSION}") IF(CMAKE_OSX_DEPLOYMENT_TARGET) - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") - ENDIF(CMAKE_OSX_DEPLOYMENT_TARGET) - ENDIF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86) - ELSE(IOS) + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") + ENDIF() + ENDIF() + ELSE() # Always force -mmacosx-version-min to override environement variable IF(CMAKE_OSX_DEPLOYMENT_TARGET) - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") - ENDIF(CMAKE_OSX_DEPLOYMENT_TARGET) - ENDIF(IOS) + IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.7") + MESSAGE(FATAL_ERROR "Minimum target for OS X is 10.7 but you're using ${CMAKE_OSX_DEPLOYMENT_TARGET}") + ENDIF() + ADD_PLATFORM_LINKFLAGS("-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") + ENDIF() + ENDIF() - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-headerpad_max_install_names") + # use libc++ under OX X to be able to use new C++ features (and else it'll use GCC 4.2.1 STL) + # minimum target is now OS X 10.7 + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -stdlib=libc++") + + ADD_PLATFORM_LINKFLAGS("-Wl,-headerpad_max_install_names") IF(HAVE_FLAG_SEARCH_PATHS_FIRST) - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-search_paths_first") - ENDIF(HAVE_FLAG_SEARCH_PATHS_FIRST) - ENDIF(NOT XCODE) - ELSE(APPLE) + ADD_PLATFORM_LINKFLAGS("-Wl,-search_paths_first") + ENDIF() + ENDIF() + ELSE() IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86") ADD_PLATFORM_FLAGS("-m32 -march=i686") - ENDIF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86") + ENDIF() IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") ADD_PLATFORM_FLAGS("-m64") - ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") - ENDIF(APPLE) + ENDIF() + ENDIF() - ADD_PLATFORM_FLAGS("-D_REENTRANT -fno-strict-aliasing") + # use c++0x standard to use std::unique_ptr and std::shared_ptr + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -std=c++0x") + + ADD_PLATFORM_FLAGS("-D_REENTRANT") + + # hardening + ADD_PLATFORM_FLAGS("-D_FORTIFY_SOURCE=2") IF(NOT WITH_LOW_MEMORY) ADD_PLATFORM_FLAGS("-pipe") @@ -825,11 +887,23 @@ MACRO(NL_SETUP_BUILD) IF(WITH_COVERAGE) ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage") - ENDIF(WITH_COVERAGE) + ENDIF() IF(WITH_WARNINGS) - ADD_PLATFORM_FLAGS("-Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused") - ENDIF(WITH_WARNINGS) + ADD_PLATFORM_FLAGS("-Wall") + ELSE() + # Check wrong formats in printf-like functions + ADD_PLATFORM_FLAGS("-Wformat -Werror=format-security") + ENDIF() + + # never display these warnings because they are minor + ADD_PLATFORM_FLAGS("-Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-value") + + IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "6.0.0") + ADD_PLATFORM_FLAGS("-Wno-unused-local-typedefs") + ELSEIF(CLANG) + ADD_PLATFORM_FLAGS("-Wno-unused-private-field -Wno-unused-local-typedef") + ENDIF() IF(ANDROID) ADD_PLATFORM_FLAGS("--sysroot=${PLATFORM_ROOT}") @@ -838,68 +912,80 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("-Wa,--noexecstack") IF(TARGET_ARM) - ADD_PLATFORM_FLAGS("-fpic -fstack-protector") + ADD_PLATFORM_FLAGS("-fpic") ADD_PLATFORM_FLAGS("-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__") IF(TARGET_ARMV7) ADD_PLATFORM_FLAGS("-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -march=armv7-a -Wl,--fix-cortex-a8") + ADD_PLATFORM_LINKFLAGS("-march=armv7-a -Wl,--fix-cortex-a8") ELSEIF(TARGET_ARMV5) ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float") - ENDIF(TARGET_ARMV7) + ENDIF() SET(TARGET_THUMB ON) IF(TARGET_THUMB) - ADD_PLATFORM_FLAGS("-mthumb -fno-strict-aliasing -finline-limit=64") + ADD_PLATFORM_FLAGS("-mthumb -finline-limit=64") SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm") - ELSE(TARGET_THUMB) + ELSE() ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300") - SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -fno-strict-aliasing") - SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -fstrict-aliasing") - ENDIF(TARGET_THUMB) + ENDIF() ELSEIF(TARGET_X86) # Optimizations for Intel Atom ADD_PLATFORM_FLAGS("-march=i686 -mtune=atom -mstackrealign -msse3 -mfpmath=sse -m32 -flto -ffast-math -funroll-loops") - ADD_PLATFORM_FLAGS("-fstack-protector -funswitch-loops -finline-limit=300") - SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -fstrict-aliasing") - SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -fno-strict-aliasing") + ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300") ELSEIF(TARGET_MIPS) - ADD_PLATFORM_FLAGS("-fpic -finline-functions -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -fno-strict-aliasing") + ADD_PLATFORM_FLAGS("-fpic -finline-functions -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers") SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300") - ENDIF(TARGET_ARM) - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -L${PLATFORM_ROOT}/usr/lib") - ENDIF(ANDROID) + ENDIF() + ADD_PLATFORM_LINKFLAGS("-Wl,-z,noexecstack") + ADD_PLATFORM_LINKFLAGS("-L${PLATFORM_ROOT}/usr/lib") + ENDIF() IF(APPLE) ADD_PLATFORM_FLAGS("-gdwarf-2 -D_DARWIN_UNLIMITED_STREAMS") - ENDIF(APPLE) + ENDIF() # Fix "relocation R_X86_64_32 against.." error on x64 platforms - IF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS AND NOT MINGW) + IF(NOT MINGW) ADD_PLATFORM_FLAGS("-fPIC") - ENDIF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS AND NOT MINGW) + ENDIF() SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48") + # hardening + ADD_PLATFORM_FLAGS("-fstack-protector --param=ssp-buffer-size=4") + + # If -fstack-protector or -fstack-protector-all enabled, enable too new warnings and fix possible link problems + IF(WITH_WARNINGS) + ADD_PLATFORM_FLAGS("-Wstack-protector") + ENDIF() + + # Fix undefined reference to `__stack_chk_fail' error + ADD_PLATFORM_LINKFLAGS("-lc") + IF(NOT APPLE) - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--no-undefined -Wl,--as-needed") - ENDIF(NOT APPLE) + ADD_PLATFORM_LINKFLAGS("-Wl,--no-undefined -Wl,--as-needed") + ENDIF() + + IF(NOT APPLE) + # hardening + ADD_PLATFORM_LINKFLAGS("-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now") + ENDIF() IF(WITH_SYMBOLS) SET(NL_RELEASE_CFLAGS "${NL_RELEASE_CFLAGS} -g") - ELSE(WITH_SYMBOLS) + ELSE() IF(APPLE) SET(NL_RELEASE_LINKFLAGS "-Wl,-dead_strip ${NL_RELEASE_LINKFLAGS}") - ELSE(APPLE) + ELSE() SET(NL_RELEASE_LINKFLAGS "-Wl,-s ${NL_RELEASE_LINKFLAGS}") - ENDIF(APPLE) - ENDIF(WITH_SYMBOLS) + ENDIF() + ENDIF() SET(NL_DEBUG_CFLAGS "-g -DNL_DEBUG -D_DEBUG ${NL_DEBUG_CFLAGS}") SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O3 ${NL_RELEASE_CFLAGS}") - ENDIF(MSVC) -ENDMACRO(NL_SETUP_BUILD) + ENDIF() +ENDMACRO() MACRO(NL_SETUP_BUILD_FLAGS) SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE) @@ -933,7 +1019,7 @@ MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE) ELSE() SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}}) ENDIF() - ENDIF(IS_ABSOLUTE "${${NAME_RELATIVE}}") + ENDIF() ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX) MACRO(NL_SETUP_PREFIX_PATHS) @@ -1010,7 +1096,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) ELSE() SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations") ENDIF() - ENDIF(NOT RYZOM_ETC_PREFIX) + ENDIF() NL_MAKE_ABSOLUTE_PREFIX(RYZOM_ETC_PREFIX RYZOM_ETC_ABSOLUTE_PREFIX) ## Allow override of install_prefix/share path. @@ -1050,7 +1136,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) ELSE() SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") ENDIF() - ENDIF(NOT RYZOM_LIB_PREFIX) + ENDIF() NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX) ## Allow override of install_prefix/games path. @@ -1068,7 +1154,7 @@ ENDMACRO(RYZOM_SETUP_PREFIX_PATHS) MACRO(SETUP_EXTERNAL) IF(WITH_EXTERNAL) FIND_PACKAGE(External REQUIRED) - ENDIF(WITH_EXTERNAL) + ENDIF() IF(WIN32) FIND_PACKAGE(External REQUIRED) @@ -1077,38 +1163,40 @@ MACRO(SETUP_EXTERNAL) IF(DEFINED BOOST_DIR) SET(BOOST_INCLUDEDIR ${BOOST_DIR}/include) SET(BOOST_LIBRARYDIR ${BOOST_DIR}/lib) - ENDIF(DEFINED BOOST_DIR) - ELSE(WIN32) + ENDIF() + ELSE() FIND_PACKAGE(External QUIET) IF(APPLE) IF(WITH_STATIC_EXTERNAL) + # Look only for static libraries because systems libraries are using Frameworks SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) ELSE() SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so .a) ENDIF() - ELSE(APPLE) + ELSE() IF(WITH_STATIC_EXTERNAL) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so) ELSE() SET(CMAKE_FIND_LIBRARY_SUFFIXES .so .a) ENDIF() - ENDIF(APPLE) - ENDIF(WIN32) + ENDIF() + ENDIF() - # Android and iOS have pthread - IF(ANDROID OR IOS) + # Android, iOS and Mac OS X have pthread, but no need to link to libpthread + IF(ANDROID OR APPLE) SET(CMAKE_USE_PTHREADS_INIT 1) SET(Threads_FOUND TRUE) - ELSE(ANDROID OR IOS) - FIND_PACKAGE(Threads REQUIRED) + ELSE() + SET(THREADS_HAVE_PTHREAD_ARG ON) + FIND_PACKAGE(Threads) # TODO: replace all -l by absolute path to in CMAKE_THREAD_LIBS_INIT - ENDIF(ANDROID OR IOS) + ENDIF() IF(WITH_STLPORT) FIND_PACKAGE(STLport REQUIRED) INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR}) - ENDIF(WITH_STLPORT) + ENDIF() IF(WIN32) # Must include DXSDK before WINSDK @@ -1116,10 +1204,10 @@ MACRO(SETUP_EXTERNAL) # IF(DXSDK_INCLUDE_DIR) # INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) # ENDIF() - ENDIF(WIN32) + ENDIF() IF(MSVC) FIND_PACKAGE(MSVC REQUIRED) FIND_PACKAGE(WindowsSDK REQUIRED) - ENDIF(MSVC) + ENDIF() ENDMACRO(SETUP_EXTERNAL) diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index b538feb4d..84b820d33 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -1,24 +1,21 @@ -PROJECT(NeL CXX C) - IF(WITH_STATIC_DRIVERS) ADD_DEFINITIONS(-DNL_STATIC) -ENDIF(WITH_STATIC_DRIVERS) +ENDIF() IF(WIN32) # On Win32 we can also build the MAX plugins. IF(WITH_NEL_MAXPLUGIN) FIND_PACKAGE(3dsMaxSDK) - ENDIF(WITH_NEL_MAXPLUGIN) -ENDIF(WIN32) + ENDIF() +ENDIF() IF(WITH_3D) FIND_PACKAGE(FreeType) IF(WITH_NEL_CEGUI) FIND_PACKAGE(CEGUI) - ENDIF(WITH_NEL_CEGUI) - -ENDIF(WITH_3D) + ENDIF() +ENDIF() IF(WITH_SOUND) FIND_PACKAGE(Ogg) @@ -26,24 +23,16 @@ IF(WITH_SOUND) IF(WITH_DRIVER_OPENAL) FIND_PACKAGE(OpenAL) - ENDIF(WITH_DRIVER_OPENAL) + ENDIF() IF(WITH_DRIVER_FMOD) FIND_PACKAGE(FMOD) - ENDIF(WITH_DRIVER_FMOD) -ENDIF(WITH_SOUND) + ENDIF() +ENDIF() IF(WITH_GTK) FIND_PACKAGE(GTK2) -ENDIF(WITH_GTK) - -IF(WITH_LIBOVR) - FIND_PACKAGE(LibOVR) -ENDIF(WITH_LIBOVR) - -IF(WITH_LIBVR) - FIND_PACKAGE(LibVR) -ENDIF(WITH_LIBVR) +ENDIF() IF(WITH_INSTALL_LIBRARIES) IF(UNIX) @@ -61,7 +50,7 @@ IF(WITH_INSTALL_LIBRARIES) CONFIGURE_FILE(nel-config.in ${CMAKE_CURRENT_BINARY_DIR}/nel-config) INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/nel-config DESTINATION ${NL_BIN_PREFIX}) - ENDIF(UNIX) + ENDIF() ADD_SUBDIRECTORY(include) ENDIF() diff --git a/code/nel/include/nel/3d/animatable.h b/code/nel/include/nel/3d/animatable.h index 09297ab2b..6e4a7b39f 100644 --- a/code/nel/include/nel/3d/animatable.h +++ b/code/nel/include/nel/3d/animatable.h @@ -19,6 +19,8 @@ #include "nel/misc/types_nl.h" #include "nel/misc/bit_set.h" +#include "nel/misc/smart_ptr.h" + #include #include #include diff --git a/code/nel/include/nel/3d/animated_lightmap.h b/code/nel/include/nel/3d/animated_lightmap.h index 51f1c909e..b8b887d7a 100644 --- a/code/nel/include/nel/3d/animated_lightmap.h +++ b/code/nel/include/nel/3d/animated_lightmap.h @@ -21,13 +21,17 @@ #include "nel/misc/types_nl.h" #include "nel/misc/smart_ptr.h" #include "nel/3d/animatable.h" + #include "nel/3d/track.h" + #include namespace NL3D { +class CScene; + // *************************************************************************** /** * An animated lightmap diff --git a/code/nel/include/nel/3d/animation_set_user.h b/code/nel/include/nel/3d/animation_set_user.h index b0e863297..39477891e 100644 --- a/code/nel/include/nel/3d/animation_set_user.h +++ b/code/nel/include/nel/3d/animation_set_user.h @@ -93,7 +93,7 @@ public: uint addAnimation (const char* fileName, const char* animName, bool displayMissingFileWarning = true) { // Allocate an animation - std::auto_ptr anim (new CAnimation); + CUniquePtr anim (new CAnimation); // Read it NLMISC::CIFile file; @@ -130,7 +130,7 @@ public: virtual uint addSkeletonWeight (const char* fileName, const char* skelName) { // Allocate an animation - std::auto_ptr skeletonWeight (new CSkeletonWeight); + CUniquePtr skeletonWeight (new CSkeletonWeight); // Read it NLMISC::CIFile file; diff --git a/code/nel/include/nel/3d/async_file_manager_3d.h b/code/nel/include/nel/3d/async_file_manager_3d.h index dede1b419..4e86f10b1 100644 --- a/code/nel/include/nel/3d/async_file_manager_3d.h +++ b/code/nel/include/nel/3d/async_file_manager_3d.h @@ -88,7 +88,7 @@ private: public: std::string MeshName; public: - CMeshLoad (const std::string &meshName, IShape **ppShp, IDriver *pDriver, const CVector &position, uint selectedTexture); + CMeshLoad (const std::string &meshName, IShape **ppShp, IDriver *pDriver, const NLMISC::CVector &position, uint selectedTexture); void run (void); void getName (std::string &result) const; }; @@ -122,7 +122,7 @@ private: CTextureFile *TextureFile; bool *Signal; public: - CTextureLoad(CTextureFile *textureFile, bool *psgn, const CVector &position) + CTextureLoad(CTextureFile *textureFile, bool *psgn, const NLMISC::CVector &position) : TextureFile(textureFile), Signal(psgn) { Position = position; diff --git a/code/nel/include/nel/3d/async_texture_manager.h b/code/nel/include/nel/3d/async_texture_manager.h index 8a848cb52..af27c3fde 100644 --- a/code/nel/include/nel/3d/async_texture_manager.h +++ b/code/nel/include/nel/3d/async_texture_manager.h @@ -152,7 +152,7 @@ private: struct CTextureLodToSort { CTextureLod *Lod; - CVector Position; + NLMISC::CVector Position; bool operator<(const CTextureLodToSort &other) const { return Lod->WeightWeight; diff --git a/code/nel/include/nel/3d/camera_col.h b/code/nel/include/nel/3d/camera_col.h index 9151b0a22..6b5a30517 100644 --- a/code/nel/include/nel/3d/camera_col.h +++ b/code/nel/include/nel/3d/camera_col.h @@ -20,6 +20,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/vector.h" #include "nel/misc/plane.h" +#include "nel/misc/aabbox.h" namespace NL3D { @@ -39,16 +40,16 @@ public: /** build the camera collision as a cone or a cylinder */ - void build(const CVector &start, const CVector &end, float radius, bool cone); + void build(const NLMISC::CVector &start, const NLMISC::CVector &end, float radius, bool cone); /** build the camera collision as a simple ray */ - void buildRay(const CVector &start, const CVector &end); + void buildRay(const NLMISC::CVector &start, const NLMISC::CVector &end); /** compute the intersection of the Camera Volume against the triangle, and minimize * minDist (actual square of distance) with min sqr distance of the poly. */ - void minimizeDistanceAgainstTri(const CVector &p0, const CVector &p1, const CVector &p2, float &sqrMinDist); + void minimizeDistanceAgainstTri(const NLMISC::CVector &p0, const NLMISC::CVector &p1, const NLMISC::CVector &p2, float &sqrMinDist); /** Compute into this the camera collision 'other' mul by 'matrix' * NB: for cone Radius, suppose uniform scale, else will have strange result (a uniform scale is deduced) @@ -69,9 +70,9 @@ private: enum {MaxNPlanes=6}; // The start of the camera raycast - CVector _Start; + NLMISC::CVector _Start; // The end of the camera raycast - CVector _End; + NLMISC::CVector _End; // The radius (at end only if cone) float _Radius; // cone or cylinder? @@ -83,8 +84,8 @@ private: NLMISC::CAABBox _BBox; // Temp Data for minimizeDistanceAgainstTri - CVector _ArrayIn[3+MaxNPlanes]; - CVector _ArrayOut[3+MaxNPlanes]; + NLMISC::CVector _ArrayIn[3+MaxNPlanes]; + NLMISC::CVector _ArrayOut[3+MaxNPlanes]; // The pyramid representing the camera collision volume. Nb: local to start for precision problems NLMISC::CPlane _Pyramid[MaxNPlanes]; @@ -97,10 +98,10 @@ private: float _MaxRadiusProj; float _OODeltaRadiusProj; float _RayLen; - CVector _RayNorm; + NLMISC::CVector _RayNorm; // simpler method for simple ray - void intersectRay(const CVector &p0, const CVector &p1, const CVector &p2, float &sqrMinDist); + void intersectRay(const NLMISC::CVector &p0, const NLMISC::CVector &p1, const NLMISC::CVector &p2, float &sqrMinDist); }; diff --git a/code/nel/include/nel/3d/cloud_scape_user.h b/code/nel/include/nel/3d/cloud_scape_user.h index 15c926927..9e2a88376 100644 --- a/code/nel/include/nel/3d/cloud_scape_user.h +++ b/code/nel/include/nel/3d/cloud_scape_user.h @@ -22,6 +22,7 @@ namespace NL3D class UDriver; class UCamera; class CCloudScape; +class CScene; /// implementation of UWaterInstance methods class CCloudScapeUser : public UCloudScape diff --git a/code/nel/include/nel/3d/cluster.h b/code/nel/include/nel/3d/cluster.h index 552d7474a..b038a34c4 100644 --- a/code/nel/include/nel/3d/cluster.h +++ b/code/nel/include/nel/3d/cluster.h @@ -120,7 +120,7 @@ public: void setWorldMatrix (const NLMISC::CMatrix &WM); - bool isRoot() { return _LocalVolume.size() == 0; } + bool isRoot() { return _LocalVolume.empty(); } //\name Sound related. //@{ diff --git a/code/nel/include/nel/3d/coarse_mesh_manager.h b/code/nel/include/nel/3d/coarse_mesh_manager.h index ce571cbd1..feaad9e05 100644 --- a/code/nel/include/nel/3d/coarse_mesh_manager.h +++ b/code/nel/include/nel/3d/coarse_mesh_manager.h @@ -84,7 +84,7 @@ public: void setTextureFile (const char* file); /** - * Add a coarse mesh in the manager. If an error occured, it returns CantAddCoarseMesh. + * Add a coarse mesh in the manager. If an error occurred, it returns CantAddCoarseMesh. * \param vBuffer the VertexBuffer pre-transformed / Colored. Size MUST be numVertices*NL3D_COARSEMESH_VERTEX_FORMAT_MGR * \param indexBuffer containing triangles that will be inserted. * \return false if the mesh can't be added to this pass BECAUSE OF TOO MANY VERTICES or TOO MANY PRIMITIVES reason diff --git a/code/nel/include/nel/3d/fasthls_modifier.h b/code/nel/include/nel/3d/fasthls_modifier.h index b5ec7ad82..de8f22a3d 100644 --- a/code/nel/include/nel/3d/fasthls_modifier.h +++ b/code/nel/include/nel/3d/fasthls_modifier.h @@ -48,7 +48,7 @@ public: static void releaseInstance(); /// convert a HLS (0..255) to a RGBA. - CRGBA convert(uint H, uint L, uint S); + NLMISC::CRGBA convert(uint H, uint L, uint S); /// convert a RGBA bitmap into another RGBA, with HLS decal (0..255, -255..+255, -255..+255). void convertRGBABitmap(NLMISC::CBitmap &dst, const NLMISC::CBitmap &src, uint8 dh, sint dl, sint ds); @@ -75,7 +75,7 @@ private: uint8 H,L,S,A; }; - CRGBA _HueTable[HueTableSize]; + NLMISC::CRGBA _HueTable[HueTableSize]; CHLSA _Color16ToHLS[65536]; /// Constructor diff --git a/code/nel/include/nel/3d/flare_shape.h b/code/nel/include/nel/3d/flare_shape.h index 044c53c11..b0c35257b 100644 --- a/code/nel/include/nel/3d/flare_shape.h +++ b/code/nel/include/nel/3d/flare_shape.h @@ -55,7 +55,7 @@ public: CFlareShape(); /// serial this shape - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); //@} diff --git a/code/nel/include/nel/3d/gpu_program_params.h b/code/nel/include/nel/3d/gpu_program_params.h index ce6b8b2f0..4615c58d9 100644 --- a/code/nel/include/nel/3d/gpu_program_params.h +++ b/code/nel/include/nel/3d/gpu_program_params.h @@ -27,7 +27,8 @@ #ifndef NL3D_GPU_PROGRAM_PARAMS_H #define NL3D_GPU_PROGRAM_PARAMS_H -#include + +#include "nel/misc/types_nl.h" // STL includes #include @@ -167,7 +168,7 @@ private: std::map m_MapName; // map from name to offset size_t m_First; size_t m_Last; - static const size_t s_End = -1; + static const size_t s_End; }; /* class CGPUProgramParams */ diff --git a/code/nel/include/nel/3d/ig_surface_light_build.h b/code/nel/include/nel/3d/ig_surface_light_build.h index e6b37b25c..77046dabb 100644 --- a/code/nel/include/nel/3d/ig_surface_light_build.h +++ b/code/nel/include/nel/3d/ig_surface_light_build.h @@ -26,6 +26,7 @@ namespace NL3D { + class CInstanceGroup; // *************************************************************************** /** @@ -106,14 +107,14 @@ public: public: /// Debug: build a colored Grid mesh of SunContribution. - void buildSunDebugMesh(CMesh::CMeshBuild &meshBuild, CMeshBase::CMeshBaseBuild &meshBaseBuild, const CVector &deltaPos=CVector::Null); + void buildSunDebugMesh(CMesh::CMeshBuild &meshBuild, CMeshBase::CMeshBaseBuild &meshBaseBuild, const NLMISC::CVector &deltaPos= NLMISC::CVector::Null); /// Debug: build a colored Grid mesh of PointLight. R= pointLight1 id. G= PointLight2 id. B= The multiplier used to show Ids. - void buildPLDebugMesh(CMesh::CMeshBuild &meshBuild, CMeshBase::CMeshBaseBuild &meshBaseBuild, const CVector &deltaPos, const CInstanceGroup &igOut); + void buildPLDebugMesh(CMesh::CMeshBuild &meshBuild, CMeshBase::CMeshBaseBuild &meshBaseBuild, const NLMISC::CVector &deltaPos, const CInstanceGroup &igOut); private: void addDebugMeshFaces(CMesh::CMeshBuild &meshBuild, CSurface &surface, uint vId0, - const std::vector &colors); + const std::vector &colors); }; diff --git a/code/nel/include/nel/3d/key.h b/code/nel/include/nel/3d/key.h index d30bfcd6e..6982dc98b 100644 --- a/code/nel/include/nel/3d/key.h +++ b/code/nel/include/nel/3d/key.h @@ -47,7 +47,7 @@ public: public: /// Serial - void serial (NLMISC::IStream& f) throw (NLMISC::EStream) + void serial (NLMISC::IStream& f) { // Version number (void)f.serialVersion (0); @@ -83,7 +83,7 @@ class CKeyTCB : public CKey public: /// Serial - void serial (NLMISC::IStream& f) throw (NLMISC::EStream) + void serial (NLMISC::IStream& f) { // Version number (void)f.serialVersion (0); @@ -130,7 +130,7 @@ class CKeyBezier : public CKey public: /// Serial - void serial (NLMISC::IStream& f) throw (NLMISC::EStream) + void serial (NLMISC::IStream& f) { // Version number (void)f.serialVersion (0); @@ -180,7 +180,7 @@ template<> class CKeyTCB : public CKey public: /// Serial - void serial (NLMISC::IStream& f) throw (NLMISC::EStream) + void serial (NLMISC::IStream& f) { // Version number (void)f.serialVersion (0); @@ -228,7 +228,7 @@ template<> class CKeyBezier : public CKey public: /// Serial - void serial (NLMISC::IStream& f) throw (NLMISC::EStream) + void serial (NLMISC::IStream& f) { // Version number (void)f.serialVersion (0); diff --git a/code/nel/include/nel/3d/landscape.h b/code/nel/include/nel/3d/landscape.h index 66dec0f64..aa432f88b 100644 --- a/code/nel/include/nel/3d/landscape.h +++ b/code/nel/include/nel/3d/landscape.h @@ -716,7 +716,7 @@ private: bool _RefineMode; float _FarTransition; uint _TileMaxSubdivision; - // For VertexProgram. true if change has occured in threshold since the last render(). + // For VertexProgram. true if change has occurred in threshold since the last render(). float _VPThresholdChange; /// \name VertexBuffer mgt. diff --git a/code/nel/include/nel/3d/material.h b/code/nel/include/nel/3d/material.h index 671f3339a..7a300da45 100644 --- a/code/nel/include/nel/3d/material.h +++ b/code/nel/include/nel/3d/material.h @@ -692,7 +692,7 @@ private: { NLMISC::CMatrix TexMat[IDRV_MAT_MAXTEXTURES]; }; - std::auto_ptr _TexUserMat; // user texture matrix + CUniquePtr _TexUserMat; // user texture matrix public: // Private. For Driver only. diff --git a/code/nel/include/nel/3d/matrix_3x4.h b/code/nel/include/nel/3d/matrix_3x4.h index 45901c20e..7b8d6dcf6 100644 --- a/code/nel/include/nel/3d/matrix_3x4.h +++ b/code/nel/include/nel/3d/matrix_3x4.h @@ -47,7 +47,7 @@ public: float a31, a32, a33, a34; // Copy from a matrix. - void set(const CMatrix &mat) + void set(const NLMISC::CMatrix &mat) { const float *m =mat.get(); a11= m[0]; a12= m[4]; a13= m[8] ; a14= m[12]; @@ -57,14 +57,14 @@ public: // mulSetvector. NB: in should be different as v!! (else don't work). - void mulSetVector(const CVector &in, CVector &out) + void mulSetVector(const NLMISC::CVector &in, NLMISC::CVector &out) { out.x= (a11*in.x + a12*in.y + a13*in.z); out.y= (a21*in.x + a22*in.y + a23*in.z); out.z= (a31*in.x + a32*in.y + a33*in.z); } // mulSetpoint. NB: in should be different as v!! (else don't work). - void mulSetPoint(const CVector &in, CVector &out) + void mulSetPoint(const NLMISC::CVector &in, NLMISC::CVector &out) { out.x= (a11*in.x + a12*in.y + a13*in.z + a14); out.y= (a21*in.x + a22*in.y + a23*in.z + a24); @@ -73,14 +73,14 @@ public: // mulSetvector. NB: in should be different as v!! (else don't work). - void mulSetVector(const CVector &in, float scale, CVector &out) + void mulSetVector(const NLMISC::CVector &in, float scale, NLMISC::CVector &out) { out.x= (a11*in.x + a12*in.y + a13*in.z) * scale; out.y= (a21*in.x + a22*in.y + a23*in.z) * scale; out.z= (a31*in.x + a32*in.y + a33*in.z) * scale; } // mulSetpoint. NB: in should be different as v!! (else don't work). - void mulSetPoint(const CVector &in, float scale, CVector &out) + void mulSetPoint(const NLMISC::CVector &in, float scale, NLMISC::CVector &out) { out.x= (a11*in.x + a12*in.y + a13*in.z + a14) * scale; out.y= (a21*in.x + a22*in.y + a23*in.z + a24) * scale; @@ -89,14 +89,14 @@ public: // mulAddvector. NB: in should be different as v!! (else don't work). - void mulAddVector(const CVector &in, float scale, CVector &out) + void mulAddVector(const NLMISC::CVector &in, float scale, NLMISC::CVector &out) { out.x+= (a11*in.x + a12*in.y + a13*in.z) * scale; out.y+= (a21*in.x + a22*in.y + a23*in.z) * scale; out.z+= (a31*in.x + a32*in.y + a33*in.z) * scale; } // mulAddpoint. NB: in should be different as v!! (else don't work). - void mulAddPoint(const CVector &in, float scale, CVector &out) + void mulAddPoint(const NLMISC::CVector &in, float scale, NLMISC::CVector &out) { out.x+= (a11*in.x + a12*in.y + a13*in.z + a14) * scale; out.y+= (a21*in.x + a22*in.y + a23*in.z + a24) * scale; diff --git a/code/nel/include/nel/3d/mesh.h b/code/nel/include/nel/3d/mesh.h index 780a455aa..25872a063 100644 --- a/code/nel/include/nel/3d/mesh.h +++ b/code/nel/include/nel/3d/mesh.h @@ -85,7 +85,7 @@ public: // This is slow but doesn't matter since used at mesh building.... CCorner(); - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); }; /// A Triangle face. @@ -94,7 +94,7 @@ public: CCorner Corner[3]; sint32 MaterialId; sint32 SmoothGroup; - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); }; @@ -118,7 +118,7 @@ public: } } - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); }; struct CVertLink @@ -203,7 +203,7 @@ public: CMeshBuild(); // Serialization - //void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); }; //@} @@ -257,7 +257,7 @@ public: virtual void render(IDriver *drv, CTransformShape *trans, bool opaquePass); /// serial this mesh. - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CMesh); /// get trinagle count. @@ -370,7 +370,7 @@ public: virtual float getNumTriangles (float distance); /// serial this mesh. - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CMeshGeom); // profile diff --git a/code/nel/include/nel/3d/mesh_base.h b/code/nel/include/nel/3d/mesh_base.h index 816d8b7a4..9fb4f9029 100644 --- a/code/nel/include/nel/3d/mesh_base.h +++ b/code/nel/include/nel/3d/mesh_base.h @@ -146,7 +146,7 @@ public: CMeshBaseBuild(); // Serialization is not used - //void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); }; //@} @@ -201,7 +201,7 @@ public: // @} /// serial the base Part of this mesh. - void serialMeshBase(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialMeshBase(NLMISC::IStream &f); /// Flush textures void flushTextures (IDriver &driver, uint selectedTexture); diff --git a/code/nel/include/nel/3d/mesh_morpher.h b/code/nel/include/nel/3d/mesh_morpher.h index b9d8879e2..909d60586 100644 --- a/code/nel/include/nel/3d/mesh_morpher.h +++ b/code/nel/include/nel/3d/mesh_morpher.h @@ -43,7 +43,7 @@ public: std::vector VertRefs; // Array of vertices reference - void serial (NLMISC::IStream &f) throw(NLMISC::EStream); + void serial (NLMISC::IStream &f); }; // *************************************************************************** @@ -90,7 +90,7 @@ public: NLMISC::CObjectVector &vertexRemap, std::vector *pBSFactor); - void serial (NLMISC::IStream &f) throw(NLMISC::EStream); + void serial (NLMISC::IStream &f); private: diff --git a/code/nel/include/nel/3d/mesh_mrm.h b/code/nel/include/nel/3d/mesh_mrm.h index d0ce7d952..619908499 100644 --- a/code/nel/include/nel/3d/mesh_mrm.h +++ b/code/nel/include/nel/3d/mesh_mrm.h @@ -115,7 +115,7 @@ public: virtual float getNumTriangles (float distance); /// serial this meshGeom. - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CMeshMRMGeom); /// Scene profile @@ -579,11 +579,11 @@ private: /// load the header of this mesh. return the version of the header. - sint loadHeader(NLMISC::IStream &f) throw(NLMISC::EStream); + sint loadHeader(NLMISC::IStream &f); /// load this mesh. - void load(NLMISC::IStream &f) throw(NLMISC::EStream); + void load(NLMISC::IStream &f); /// save the entire mesh. - void save(NLMISC::IStream &f) throw(NLMISC::EStream); + void save(NLMISC::IStream &f); // Build bone Usage information for serialized mesh <= version 2. void buildBoneUsageVer2 (); @@ -702,7 +702,7 @@ public: virtual float getNumTriangles (float distance); /// serial this mesh. - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CMeshMRM); /// Get bbox. diff --git a/code/nel/include/nel/3d/mesh_multi_lod.h b/code/nel/include/nel/3d/mesh_multi_lod.h index 445941ed6..a79d5a63e 100644 --- a/code/nel/include/nel/3d/mesh_multi_lod.h +++ b/code/nel/include/nel/3d/mesh_multi_lod.h @@ -125,7 +125,7 @@ public: virtual void getAABBox(NLMISC::CAABBox &bbox) const; /// serial this mesh. - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); /// Declare name of the shape NLMISC_DECLARE_CLASS(CMeshMultiLod); @@ -238,7 +238,7 @@ private: std::vector CoarseTriangles; /// Serial - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); /// Is Opaque ? bool isOpaque() { return (Flags&IsOpaque)!=0; } diff --git a/code/nel/include/nel/3d/meshvp_per_pixel_light.h b/code/nel/include/nel/3d/meshvp_per_pixel_light.h index a234feddd..4533464a9 100644 --- a/code/nel/include/nel/3d/meshvp_per_pixel_light.h +++ b/code/nel/include/nel/3d/meshvp_per_pixel_light.h @@ -65,7 +65,7 @@ public: const NLMISC::CMatrix &invertedModelMat, const NLMISC::CVector &viewerPos); virtual void end(IDriver *drv); - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); virtual void setupForMaterial(const CMaterial &mat, IDriver *drv, CScene *scene, diff --git a/code/nel/include/nel/3d/meshvp_wind_tree.h b/code/nel/include/nel/3d/meshvp_wind_tree.h index e2c790d6d..790a2f774 100644 --- a/code/nel/include/nel/3d/meshvp_wind_tree.h +++ b/code/nel/include/nel/3d/meshvp_wind_tree.h @@ -90,7 +90,7 @@ public: virtual float getMaxVertexMove(); // Serial. - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CMeshVPWindTree); // @} @@ -124,7 +124,7 @@ private: double _LastSceneTime; // maximum amplitude vector for each level. Stored in mesh because same for all instances. - CVector _MaxDeltaPos[HrcDepth]; + NLMISC::CVector _MaxDeltaPos[HrcDepth]; float _MaxVertexMove; // MBR Cache diff --git a/code/nel/include/nel/3d/packed_world.h b/code/nel/include/nel/3d/packed_world.h index d76c180ba..a091c61fb 100644 --- a/code/nel/include/nel/3d/packed_world.h +++ b/code/nel/include/nel/3d/packed_world.h @@ -54,9 +54,9 @@ public: void build(std::vector &packesZones); bool raytrace(const NLMISC::CVector &start, const NLMISC::CVector &end, NLMISC::CVector &inter, std::vector *testedTriangles = NULL, NLMISC::CVector *normal = NULL); void getZones(std::vector &zones); - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); // just serialize the header, containing name of the zones this CPackedWorld was built from - void serialZoneNames(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialZoneNames(NLMISC::IStream &f); /** Roughly select triangles that are within a convex 2D polygon (world coordinates) * Selection is not exact, because limited to the resolution of the grid into which is packed each zone. * Triangle that are within are guaranteed to be selected, however. @@ -68,7 +68,7 @@ private: public: TPackedZoneBaseSPtr Zone; uint32 RaytraceCounter; - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serialVersion(1); CPackedZoneBase *pz = Zone; @@ -81,7 +81,7 @@ private: { public: std::vector IDs; // make a class from this vector just for serialization - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serialCont(IDs); } diff --git a/code/nel/include/nel/3d/packed_zone.h b/code/nel/include/nel/3d/packed_zone.h index 2beb5f5ed..52f76097a 100644 --- a/code/nel/include/nel/3d/packed_zone.h +++ b/code/nel/include/nel/3d/packed_zone.h @@ -52,7 +52,7 @@ class CPackedVertex public: uint16 X, Y, Z; public: - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serial(X, Y, Z); } @@ -68,7 +68,7 @@ class CPackedTri public: uint32 V0, V1, V2; public: - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serial(V0, V1, V2); } @@ -79,7 +79,7 @@ class CPackedTri16 public: uint16 V0, V1, V2; public: - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serial(V0, V1, V2); } @@ -101,7 +101,7 @@ public: sint32 ZoneY; public: virtual ~CPackedZoneBase() {} - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) = 0; + virtual void serial(NLMISC::IStream &f) = 0; // TMP For debug : render position covered by a frustum virtual void render(CVertexBuffer &vb, IDriver &drv, CMaterial &mat, CMaterial &wiredMaterial, const NLMISC::CMatrix &camMat, uint batchSize, const NLMISC::CVector localFrustCorners[8]) = 0; // raytracing test @@ -138,7 +138,7 @@ public: sint32 zoneX, sint32 zoneY ); - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); // TMP For debug : render porition covered by a frustum void render(CVertexBuffer &vb, IDriver &drv, CMaterial &mat, CMaterial &wiredMaterial, const NLMISC::CMatrix &camMat, uint batchSize, const NLMISC::CVector localFrustCorners[8]); // try to build a 16 bit version of this packed zone to save some more place @@ -183,7 +183,7 @@ public: NLMISC_DECLARE_CLASS(CPackedZone16) CPackedZone16(); // - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); // TMP For debug : render position covered by a frustum void render(CVertexBuffer &vb, IDriver &drv, CMaterial &mat, CMaterial &wiredMaterial, const NLMISC::CMatrix &camMat, uint batchSize, const NLMISC::CVector localFrustCorners[8]); // raytracing test diff --git a/code/nel/include/nel/3d/particle_system.h b/code/nel/include/nel/3d/particle_system.h index 7255cfec9..bd50514fc 100644 --- a/code/nel/include/nel/3d/particle_system.h +++ b/code/nel/include/nel/3d/particle_system.h @@ -84,7 +84,7 @@ public: /// dtor virtual ~CParticleSystem(); /// serialize this particle system - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); /** Merge this system with a system instanciated from the given shape * NB : This is for edition purpose, this is slow * \return true if the operation could be performed. It can fail when this cause the system the system to last forever, @@ -841,7 +841,7 @@ public: /// return true when there are still emitters in the system - bool hasEmitters(void) const; + bool hasEmitters() const; /// return true when there are still particles bool hasParticles() const; diff --git a/code/nel/include/nel/3d/particle_system_manager.h b/code/nel/include/nel/3d/particle_system_manager.h index f48b17f1b..1e02963bb 100644 --- a/code/nel/include/nel/3d/particle_system_manager.h +++ b/code/nel/include/nel/3d/particle_system_manager.h @@ -87,7 +87,7 @@ private: { public: CParticleSystemModel *Model; - CMatrix OldAncestorMatOrRelPos; // last matrix of ancestor skeleton or relative matrix of ps to its ancestor (see flag below) + NLMISC::CMatrix OldAncestorMatOrRelPos; // last matrix of ancestor skeleton or relative matrix of ps to its ancestor (see flag below) bool IsRelMatrix; // gives usage of the field OldAncestorMatOrRelPos bool HasAncestorSkeleton; // has the system an ancestor skeleton ? public: diff --git a/code/nel/include/nel/3d/particle_system_process.h b/code/nel/include/nel/3d/particle_system_process.h index 1ff031a5a..0e52228ee 100644 --- a/code/nel/include/nel/3d/particle_system_process.h +++ b/code/nel/include/nel/3d/particle_system_process.h @@ -102,7 +102,7 @@ class CParticleSystemProcess : public NLMISC::IStreamable * Everything is saved, except for the fontManager and the fontGenerator. * They must be set again if the PSToolRender pass is used. */ - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) ; + virtual void serial(NLMISC::IStream &f); /// @} @@ -163,10 +163,10 @@ class CParticleSystemProcess : public NLMISC::IStreamable virtual void setMatrixMode(TPSMatrixMode matrixMode); /// tells whether there are alive entities / particles in the system - virtual bool hasParticles(void) const { return false ; } + virtual bool hasParticles() const { return false ; } /// tells whether there are alive emitters / particles in the system - virtual bool hasEmitters(void) const { return false ; } + virtual bool hasEmitters() const { return false ; } /// max number of faces wanted by this process (for load balancing) diff --git a/code/nel/include/nel/3d/particle_system_shape.h b/code/nel/include/nel/3d/particle_system_shape.h index a1c397975..c8fbc8a17 100644 --- a/code/nel/include/nel/3d/particle_system_shape.h +++ b/code/nel/include/nel/3d/particle_system_shape.h @@ -90,7 +90,7 @@ public: // @} /// serial the shape - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CParticleSystemShape); diff --git a/code/nel/include/nel/3d/portal.h b/code/nel/include/nel/3d/portal.h index 0531f9eb5..51fd99913 100644 --- a/code/nel/include/nel/3d/portal.h +++ b/code/nel/include/nel/3d/portal.h @@ -92,9 +92,9 @@ public: void setWorldMatrix (const NLMISC::CMatrix &WM); - void setName (std::string &name) { _Name = name; } + void setName (const std::string &name) { _Name = name; } - std::string getName () { return _Name; } + std::string getName () const { return _Name; } void open (bool opened) { _Opened = opened; } bool isOpened () { return _Opened; } diff --git a/code/nel/include/nel/3d/ps_attrib.h b/code/nel/include/nel/3d/ps_attrib.h index cd691e719..8a0dcdda6 100644 --- a/code/nel/include/nel/3d/ps_attrib.h +++ b/code/nel/include/nel/3d/ps_attrib.h @@ -202,7 +202,7 @@ public: uint size() const { return _Size; } /// serialization - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { if (f.isReading()) { @@ -262,7 +262,7 @@ public: CPSAttrib(); /// Serialization method - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); // swap with another vector void swap(CPSAttrib &other); @@ -429,7 +429,7 @@ void CPSAttrib::remove(uint32 index) } template -void CPSAttrib::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSAttrib::serial(NLMISC::IStream &f) { // version 4 to 5 => bug with size being > capacity sint ver = f.serialVersion(5); diff --git a/code/nel/include/nel/3d/ps_attrib_maker.h b/code/nel/include/nel/3d/ps_attrib_maker.h index 56b393c2e..fb96cb86e 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker.h +++ b/code/nel/include/nel/3d/ps_attrib_maker.h @@ -60,7 +60,7 @@ struct CPSInputType uint32 UserParamNum; }; - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serialEnum(InputType); switch(InputType) @@ -124,7 +124,7 @@ public: } /// serialisation of the object. Derivers MUST call this, (if they use the attribute of this class at least) - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { f.serialVersion(1); f.serial(_NbCycles); diff --git a/code/nel/include/nel/3d/ps_attrib_maker_bin_op.h b/code/nel/include/nel/3d/ps_attrib_maker_bin_op.h index f59d9c4e4..597b47457 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker_bin_op.h +++ b/code/nel/include/nel/3d/ps_attrib_maker_bin_op.h @@ -103,7 +103,7 @@ public: uint32 srcStep = (1 << 16) ) const; - virtual void serial (NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial (NLMISC::IStream &f); virtual void deleteElement (uint32 index); virtual void newElement (const CPSEmitterInfo &info); virtual void resize (uint32 capacity, uint32 nbPresentElements); diff --git a/code/nel/include/nel/3d/ps_attrib_maker_bin_op_inline.h b/code/nel/include/nel/3d/ps_attrib_maker_bin_op_inline.h index 2a9cbff45..00d675e4e 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker_bin_op_inline.h +++ b/code/nel/include/nel/3d/ps_attrib_maker_bin_op_inline.h @@ -282,7 +282,7 @@ inline float CPSAttribMakerBinOp::getMaxValue(void) const template inline CPSAttribMakerBinOp::CPSAttribMakerBinOp(const CPSAttribMakerBinOp &other) : CPSAttribMaker(other) // parent copy ctor { - std::auto_ptr > a0(NLMISC::safe_cast *>(other._Arg[0]->clone())) + CUniquePtr > a0(NLMISC::safe_cast *>(other._Arg[0]->clone())) , a1(NLMISC::safe_cast *>(other._Arg[1]->clone())); this->_Op = other._Op; this->_Size = other._Size; @@ -729,7 +729,7 @@ inline void CPSAttribMakerBinOp::makeN(CPSLocated *loc, //================================================================================================================= template -inline void CPSAttribMakerBinOp::serial (NLMISC::IStream &f) throw(NLMISC::EStream) +inline void CPSAttribMakerBinOp::serial (NLMISC::IStream &f) { if (f.isReading()) { diff --git a/code/nel/include/nel/3d/ps_attrib_maker_helper.h b/code/nel/include/nel/3d/ps_attrib_maker_helper.h index 10d29fe52..2a4f243b6 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker_helper.h +++ b/code/nel/include/nel/3d/ps_attrib_maker_helper.h @@ -96,7 +96,7 @@ template class CPSAttribMakerT : public CPSAttribMaker /// serialization of the object - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { sint ver = f.serialVersion(2); CPSAttribMaker::serial(f); @@ -1463,7 +1463,7 @@ public: CPSAttribMakerMemoryBase(const CPSAttribMakerMemoryBase &src) : CPSAttribMaker(src) // parent copy ctor { nlassert(src._Scheme); - std::auto_ptr > s(NLMISC::safe_cast *>(src._Scheme->clone())); + CUniquePtr > s(NLMISC::safe_cast *>(src._Scheme->clone())); this->_T = src._T; this->_DefaultValue = src._DefaultValue; this->_Scheme = s.release(); @@ -1624,7 +1624,7 @@ public: } /// serialisation of the object. Derivers MUST call this, (if they use the attribute of this class at least) - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { f.serialVersion(1); @@ -1744,7 +1744,7 @@ public: _MaxValue = other._MaxValue; } // serial. Should update min / max when reading - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); virtual uint32 getMinValue(void) const { return _MinValue; } virtual uint32 getMaxValue(void) const { return _MaxValue; } virtual void newElement(const CPSEmitterInfo &info); @@ -1767,7 +1767,7 @@ public: _MaxValue = other._MaxValue; } // serial. Should update min / max when reading - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); virtual sint32 getMinValue(void) const { return _MinValue; } virtual sint32 getMaxValue(void) const { return _MaxValue; } virtual void newElement(const CPSEmitterInfo &info); @@ -1790,7 +1790,7 @@ public: _MaxValue = other._MaxValue; } // serial. Should update min / max when reading - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); virtual float getMinValue(void) const { return _MinValue; } virtual float getMaxValue(void) const { return _MaxValue; } virtual void newElement(const CPSEmitterInfo &info); diff --git a/code/nel/include/nel/3d/ps_attrib_maker_template.h b/code/nel/include/nel/3d/ps_attrib_maker_template.h index 92953b86f..86213880c 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker_template.h +++ b/code/nel/include/nel/3d/ps_attrib_maker_template.h @@ -24,6 +24,8 @@ #include "nel/misc/rgba.h" #include "nel/misc/traits_nl.h" +#include + namespace NL3D { /* @@ -91,7 +93,7 @@ public: CPSValueBlendFunc() {} /// serialization - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serialVersion(1); f.serial(_StartValue, _EndValue); @@ -226,7 +228,7 @@ public: CPSValueBlendSampleFunc() {} /// serialization - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serialVersion(1); if (f.isReading()) @@ -351,7 +353,7 @@ public: } /// serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); T getMaxValue(void) const @@ -480,14 +482,18 @@ void CPSValueGradientFunc::setValuesUnpacked(const T *valueTab, uint32 numVal _MaxValue = _MinValue = valueTab[0]; _NbValues = (numValues - 1) * nbStages; _Tab.resize(_NbValues + 1); +#ifdef NL_COMP_VC14 + std::copy(valueTab, valueTab + _NbValues + 1, stdext::make_checked_array_iterator(&_Tab[0], _Tab.size())); +#else std::copy(valueTab, valueTab + _NbValues + 1, &_Tab[0]); +#endif } template -void CPSValueGradientFunc::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSValueGradientFunc::serial(NLMISC::IStream &f) { f.serialVersion(1); f.serial(_NbStages); diff --git a/code/nel/include/nel/3d/ps_color.h b/code/nel/include/nel/3d/ps_color.h index d05d9cf11..1be8fb329 100644 --- a/code/nel/include/nel/3d/ps_color.h +++ b/code/nel/include/nel/3d/ps_color.h @@ -66,7 +66,7 @@ public: { CPSValueBlendFunc::setValues(convertVBColor(startValue, _ColorType), convertVBColor(endValue, _ColorType)); } - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { setColorType(CVertexBuffer::TRGBA); CPSValueBlendFunc::serial(f); @@ -100,7 +100,7 @@ public: { CPSValueBlendSampleFunc::setValues(convertVBColor(startValue, _ColorType), convertVBColor(endValue, _ColorType)); } - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { setColorType(CVertexBuffer::TRGBA); CPSValueBlendSampleFunc::serial(f); @@ -124,7 +124,7 @@ public: NLMISC::CRGBA getValue(uint index) const; void setValues(const NLMISC::CRGBA *valueTab, uint32 numValues, uint32 nbStages); void setValuesUnpacked(const NLMISC::CRGBA *valueTab, uint32 numValues, uint32 nbStages); - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { setColorType(CVertexBuffer::TRGBA); CPSValueGradientFunc::serial(f); @@ -153,7 +153,7 @@ public: this->_F.setColorType(colorType); } // serialisation should always be done in RGBA mode, so enforce that - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { setColorType(CVertexBuffer::TRGBA); CPSAttribMakerT::serial(f); @@ -229,7 +229,7 @@ public: virtual void setColorType(CVertexBuffer::TVertexColorType colorType); virtual void setDefaultValue(NLMISC::CRGBA defaultValue); virtual NLMISC::CRGBA getDefaultValue(void) const; - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); protected: CVertexBuffer::TVertexColorType _ColorType; }; @@ -244,7 +244,7 @@ public: NLMISC_DECLARE_CLASS(CPSColorBinOp); CPSAttribMakerBase *clone() const { return new CPSColorBinOp(*this); } virtual void setColorType(CVertexBuffer::TVertexColorType colorType); - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); }; diff --git a/code/nel/include/nel/3d/ps_dot.h b/code/nel/include/nel/3d/ps_dot.h index d5201ab3b..2bdb7603a 100644 --- a/code/nel/include/nel/3d/ps_dot.h +++ b/code/nel/include/nel/3d/ps_dot.h @@ -46,7 +46,7 @@ public: NLMISC_DECLARE_CLASS(CPSDot); ///serialisation - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); /// return true if there are transparent faces in the object virtual bool hasTransparentFaces(void); diff --git a/code/nel/include/nel/3d/ps_emitter.h b/code/nel/include/nel/3d/ps_emitter.h index 00163c48e..b8d82bb45 100644 --- a/code/nel/include/nel/3d/ps_emitter.h +++ b/code/nel/include/nel/3d/ps_emitter.h @@ -51,14 +51,14 @@ public: //@} /// Return this bindable type - uint32 getType(void) const { return PSEmitter; } + uint32 getType() const { return PSEmitter; } /// Return priority for emitters - virtual uint32 getPriority(void) const { return 500; } + virtual uint32 getPriority() const { return 500; } /// Return true if this located bindable derived class holds alive emitters - virtual bool hasEmitters(void) { nlassert(_Owner); return _Owner->getSize() != 0; } + virtual bool hasEmitters() const { nlassert(_Owner); return _Owner->getSize() != 0; } virtual void step(TPSProcessPass pass); @@ -76,7 +76,7 @@ public: /// Display the emitter in edition mode - virtual void showTool(void); + virtual void showTool(); /** Set the type of located to be emitted. The default is NULL which mean that no emission will occur * \return true if the operation could be performed. It can fail when this cause the system the system to last forever, @@ -90,9 +90,9 @@ public: virtual void notifyTargetRemoved(CPSLocated *ptr); /// Get emitted type. - CPSLocated *getEmittedType(void) { return _EmittedType; } + CPSLocated *getEmittedType() { return _EmittedType; } /// Get const ptr on emitted type - const CPSLocated *getEmittedType(void) const { return _EmittedType; } + const CPSLocated *getEmittedType() const { return _EmittedType; } /** The type of emission. @@ -171,7 +171,7 @@ public: const CPSAttribMaker *getGenNbScheme(void) const { return _GenNbScheme; } /// Serialization - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); ///\name Speed vector options //@{ @@ -336,7 +336,7 @@ protected: * should not be called directly. Call CPSLocated::resize instead */ virtual void resize(uint32 size); - virtual void bounceOccured(uint32 index, TAnimationTime timeToNextSimStep); + virtual void bounceOccurred(uint32 index, TAnimationTime timeToNextSimStep); void updateMaxCountVect(); @@ -424,7 +424,7 @@ class CPSModulatedEmitter bool useEmitteeSpeedScheme(void) const { return _EmitteeSpeedScheme != NULL; } /// serialization - void serialEmitteeSpeedScheme(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialEmitteeSpeedScheme(NLMISC::IStream &f); protected: @@ -470,7 +470,7 @@ public: } /// Serialisation - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSEmitterDirectionnal); @@ -506,7 +506,7 @@ class CPSRadialEmitter : public CPSEmitterDirectionnal if (CParticleSystem::getSerializeIdentifierFlag()) _Name = std::string("RadialEmitter"); } /// Serialisation - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSRadialEmitter); virtual void emit(const NLMISC::CVector &srcPos, uint32 index, NLMISC::CVector &pos, NLMISC::CVector &speed); }; @@ -527,7 +527,7 @@ public: } /// Serialisation - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSEmitterOmni); @@ -561,7 +561,7 @@ class CPSEmitterRectangle : public CPSEmitter, public CPSModulatedEmitter, publi } /// Serialisation - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSEmitterRectangle); @@ -636,7 +636,7 @@ public: } /// Serialisation - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSEmitterConic); @@ -675,7 +675,7 @@ public: } /// Serialisation - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSSphericalEmitter); diff --git a/code/nel/include/nel/3d/ps_face.h b/code/nel/include/nel/3d/ps_face.h index b46299eb1..b62a9d50b 100644 --- a/code/nel/include/nel/3d/ps_face.h +++ b/code/nel/include/nel/3d/ps_face.h @@ -69,7 +69,7 @@ public: */ CPSFace(CSmartPtr tex = NULL); - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSFace); /** Tells that all faces are turning in the same manner, and only have a rotationnal bias diff --git a/code/nel/include/nel/3d/ps_face_look_at.h b/code/nel/include/nel/3d/ps_face_look_at.h index 3ae6a59e3..1d9b38a36 100644 --- a/code/nel/include/nel/3d/ps_face_look_at.h +++ b/code/nel/include/nel/3d/ps_face_look_at.h @@ -40,7 +40,7 @@ public: */ CPSFaceLookAt(CSmartPtr tex = NULL); - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSFaceLookAt); diff --git a/code/nel/include/nel/3d/ps_fan_light.h b/code/nel/include/nel/3d/ps_fan_light.h index 19f5baaa5..1de8beaa9 100644 --- a/code/nel/include/nel/3d/ps_fan_light.h +++ b/code/nel/include/nel/3d/ps_fan_light.h @@ -47,7 +47,7 @@ public: CPSFanLight(uint32 nbFans = 7); /// Dtor ~CPSFanLight(); - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); //@} // Set the number of fans used for drawing (minimum is 3, maximum is 128) diff --git a/code/nel/include/nel/3d/ps_float.h b/code/nel/include/nel/3d/ps_float.h index da8978af1..be5044d2d 100644 --- a/code/nel/include/nel/3d/ps_float.h +++ b/code/nel/include/nel/3d/ps_float.h @@ -104,7 +104,7 @@ class CPSFloatCurveFunctor CCtrlPoint(float date, float value) : Date(date), Value(value) { nlassert(Date >= 0 && Date <= 1); } float Date; float Value; - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serial(Date, Value); } @@ -166,7 +166,7 @@ class CPSFloatCurveFunctor float getValue(float date) const; /// serialization - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); float getMinValue() const { return _MinValue; } float getMaxValue() const { return _MaxValue; } diff --git a/code/nel/include/nel/3d/ps_force.h b/code/nel/include/nel/3d/ps_force.h index e93c21361..14be72150 100644 --- a/code/nel/include/nel/3d/ps_force.h +++ b/code/nel/include/nel/3d/ps_force.h @@ -70,7 +70,7 @@ public: virtual void show() = 0; /// Serial the force definition. MUST be called by deriver during their serialisation - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); /// check whether this force is integrable over time. The default is false virtual bool isIntegrable(void) const { return false; } @@ -175,7 +175,7 @@ public: /// get the attribute maker for a non constant intensity CPSAttribMaker *getIntensityScheme(void) { return _IntensityScheme; } const CPSAttribMaker *getIntensityScheme(void) const { return _IntensityScheme; } - void serialForceIntensity(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialForceIntensity(NLMISC::IStream &f); protected: @@ -209,7 +209,7 @@ protected: class CPSForceIntensityHelper : public CPSForce, public CPSForceIntensity { public: - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) ; + void serial(NLMISC::IStream &f); protected: virtual CPSLocated *getForceIntensityOwner(void) { return _Owner; } @@ -241,7 +241,7 @@ protected: * * // you can provide a serialization method. Note that that if the functor parameters are set before each use, * // it useless to serial something ... - * void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + * void serial(NLMISC::IStream &f) * * protected: * ... @@ -275,7 +275,7 @@ public: /// serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { f.serialVersion(1); CPSForce::serial(f); @@ -354,7 +354,7 @@ class CPSDirectionnalForce : public CPSForceIntensityHelper, public CPSDirection } /// serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSDirectionnalForce); @@ -397,7 +397,7 @@ public: } /// serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSGravity); @@ -443,7 +443,7 @@ public: } /// serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSCentralGravity); @@ -464,7 +464,7 @@ public: /// serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); /// Compute the force on the targets @@ -498,7 +498,7 @@ public: speed -= (CParticleSystem::EllapsedTime * _K * invMass * speed); } - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { f.serialVersion(1); // we don't save intensity info : it is saved by the owning object (and set before each use of this functor) @@ -539,7 +539,7 @@ public: NLMISC_DECLARE_CLASS(CPSFluidFriction) - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { f.serialVersion(1); CIsotropicForceT::serial(f); @@ -571,7 +571,7 @@ public: NLMISC_DECLARE_CLASS(CPSBrownianForce) - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); /// We provide a kind of integration on a predefined sequence virtual bool isIntegrable(void) const; @@ -648,7 +648,7 @@ struct CPSTurbulForceFunc */ } - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { f.serialVersion(1); f.serial(_Scale, _NumOctaves); @@ -686,7 +686,7 @@ public: NLMISC_DECLARE_CLASS(CPSTurbul) - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { f.serialVersion(1); CIsotropicForceT::serial(f); @@ -758,7 +758,7 @@ public: // serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); @@ -801,7 +801,7 @@ class CPSMagneticForce : public CPSDirectionnalForce } virtual void computeForces(CPSLocated &target); /// serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSMagneticForce); }; diff --git a/code/nel/include/nel/3d/ps_light.h b/code/nel/include/nel/3d/ps_light.h index 31e159ae1..016dddaf9 100644 --- a/code/nel/include/nel/3d/ps_light.h +++ b/code/nel/include/nel/3d/ps_light.h @@ -42,7 +42,7 @@ public: ~CPSLight(); NLMISC_DECLARE_CLASS(CPSLight); /// Serialisation. Derivers must override this, and call their parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); //@} virtual uint32 getType(void) const; virtual uint32 getPriority(void) const { return 600; } diff --git a/code/nel/include/nel/3d/ps_located.h b/code/nel/include/nel/3d/ps_located.h index 30fa7defa..e8bd62a20 100644 --- a/code/nel/include/nel/3d/ps_located.h +++ b/code/nel/include/nel/3d/ps_located.h @@ -66,14 +66,14 @@ class CParticleSystem; /// This structure helps to perform the collision step, by telling which collisionner is the nearest if there are several candidate -/// a distance of -1 indicates that no collisions occured +/// a distance of -1 indicates that no collisions occurred struct CPSCollisionInfo { CPSCollisionInfo *Next; - float Dist; // Distance to the nearest collider, or -1 if not collision occured + float Dist; // Distance to the nearest collider, or -1 if not collision occurred NLMISC::CVector NewPos; - NLMISC::CVector NewSpeed; // The speed of particle after a collision occured. After the updated of collision it is swapped with the post-collision speed - CPSZone *CollisionZone; // The zone on which the bounce occured, can be useful to check the behaviour in case of collision + NLMISC::CVector NewSpeed; // The speed of particle after a collision occurred. After the updated of collision it is swapped with the post-collision speed + CPSZone *CollisionZone; // The zone on which the bounce occurred, can be useful to check the behaviour in case of collision uint32 Index; CPSCollisionInfo() { @@ -356,7 +356,7 @@ public: void resize(uint32 newSize); /// serialization - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); /// Shortcut to get an instance of the 3d driver IDriver *getDriver() const; @@ -449,14 +449,14 @@ public: void setName(const std::string &name) { _Name = name; } /// get the located bindable name (edition purpose) - std::string getName(void) const { return _Name; } + std::string getName() const { return _Name; } /// tells whether there are alive entities / particles in the system - virtual bool hasParticles(void) const; + virtual bool hasParticles() const; /// tells whether there are alive emitters / particles in the system - virtual bool hasEmitters(void) const; + virtual bool hasEmitters() const; /** Enable the to force LOD degradation. This will suppress instances immediately, (during the motion pass) so that * there won't be more than maxNbInstance * dist / maxDist instances. This may not be desirable @@ -468,7 +468,7 @@ public: /** Test whether LOD degradation was activated * \see forceLODDegradation() */ - bool hasLODDegradation(void) const { return _LODDegradation; } + bool hasLODDegradation() const { return _LODDegradation; } /// for the CPSLocated to reevaluate the max number of faces it may need @@ -730,7 +730,7 @@ public: /// ctor CPSLocatedBindable(); /// serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); /** this should be called before to delete any bindable inserted in a system, but this is done * by the system, so you should never need calling it. This has been introduced because calls in dtor are not polymorphic * to derived class (which are already destroyed anyway), and some infos are needed in some dtor. The default behaviour does nothing @@ -853,11 +853,11 @@ public: */ void setLOD(TPSLod lod) { _LOD = lod; } /// get the valid lods for that object - TPSLod getLOD(void) const { return _LOD; } + TPSLod getLOD() const { return _LOD; } /// tells whether there are alive entities / particles - virtual bool hasParticles(void) const { return false; } + virtual bool hasParticles() const { return false; } /// tells whether there are alive emitters - virtual bool hasEmitters(void) const { return false; } + virtual bool hasEmitters() const { return false; } /** set the extern ID of this located bindable. 0 means no extern access. The map of ID-locatedBindable. Is in th * particle system, so this located bindable must have been attached to a particle system, otherwise an assertion is raised */ @@ -906,10 +906,10 @@ protected: */ virtual void resize(uint32 size) = 0; - /** a bounce occured, so some action could be done. The default behaviour does nothing + /** a bounce occurred, so some action could be done. The default behaviour does nothing * \param index the index of the element that bounced */ - virtual void bounceOccured(uint32 /* index */, TAnimationTime /* timeToNextsimStep */) {} + virtual void bounceOccurred(uint32 /* index */, TAnimationTime /* timeToNextsimStep */) {} /** show an drawing to represent the object, and in red if it is selected * \param tab : a table of 2 * nbSeg vector. only the x and y coordinates are used @@ -1010,7 +1010,7 @@ public: */ virtual void releaseTargetRsc(CPSLocated * /* target */) {} /// Seralization, must be called by derivers - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); /// Finalize this object : the default is to call releaseTargetRsc on targets virtual void finalize(void); virtual ~CPSTargetLocatedBindable(); diff --git a/code/nel/include/nel/3d/ps_mesh.h b/code/nel/include/nel/3d/ps_mesh.h index 72ba76f4d..7eef01012 100644 --- a/code/nel/include/nel/3d/ps_mesh.h +++ b/code/nel/include/nel/3d/ps_mesh.h @@ -82,7 +82,7 @@ public: std::string getShape(void) const { return _Shape; } /// serialisation. Derivers must override this, and call their parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); virtual ~CPSMesh(); @@ -271,7 +271,7 @@ public: /// serialisation. Derivers must override this, and call their parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSConstraintMesh); @@ -334,7 +334,7 @@ public: float WRotSpeed; /* = 0 */ float WRotAccel; /* = 0 */ CGlobalTexAnim(); - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); /// Build a texture matrix from a date and this obj. void buildMatrix(TAnimationTime date, NLMISC::CMatrix &dest); }; @@ -587,10 +587,10 @@ protected: struct CGlobalTexAnims { CGlobalTexAnim Anims[IDRV_MAT_MAXTEXTURES]; - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); }; - typedef std::auto_ptr PGlobalTexAnims; + typedef CUniquePtr PGlobalTexAnims; PGlobalTexAnims _GlobalTexAnims; float _GlobalAnimDate; diff --git a/code/nel/include/nel/3d/ps_particle_basic.h b/code/nel/include/nel/3d/ps_particle_basic.h index 3674e6d9c..c7bdc242a 100644 --- a/code/nel/include/nel/3d/ps_particle_basic.h +++ b/code/nel/include/nel/3d/ps_particle_basic.h @@ -107,7 +107,7 @@ public: virtual uint32 getNumWantedTris() const = 0; /// serialisation. Derivers must override this, and call their parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { /// version 3 : global color lighting /// version 2 : auto-lod saved @@ -210,7 +210,7 @@ class CPSColoredParticle virtual ~CPSColoredParticle(); /// serialization. - void serialColorScheme(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialColorScheme(NLMISC::IStream &f); protected: @@ -273,7 +273,7 @@ class CPSSizedParticle virtual ~CPSSizedParticle(); /// serialization. We choose a different name because of multiple-inheritance - void serialSizeScheme(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialSizeScheme(NLMISC::IStream &f); protected: @@ -335,7 +335,7 @@ class CPSRotated2DParticle virtual ~CPSRotated2DParticle(); /// serialization. We choose a different name because of multiple-inheritance - void serialAngle2DScheme(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialAngle2DScheme(NLMISC::IStream &f); @@ -453,7 +453,7 @@ class CPSTexturedParticle virtual ~CPSTexturedParticle(); /// serialization. We choose a different name because of multiple-inheritance - void serialTextureScheme(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialTextureScheme(NLMISC::IStream &f); void enumTexs(std::vector > &dest); @@ -576,7 +576,7 @@ public: } /// serial this object - void serialMultiTex(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialMultiTex(NLMISC::IStream &f); /** setup a material from this object and a primary texture * drv is used to check the device caps. @@ -683,7 +683,7 @@ class CPSRotated3DPlaneParticle virtual ~CPSRotated3DPlaneParticle(); /// serialization. We choose a different name because of multiple-inheritance - void serialPlaneBasisScheme(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialPlaneBasisScheme(NLMISC::IStream &f); protected: /// if this is false, constant size will be used instead of a scheme @@ -806,7 +806,7 @@ public: enum TBlendingMode { add, modulate, alphaBlend, alphaTest }; /// serialization (not named 'serial' because it will be used via multiple-inheritance) - void serialMaterial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialMaterial(NLMISC::IStream &f); /// set the blending mode. The default is ass void setBlendingMode(CPSMaterial::TBlendingMode mode); diff --git a/code/nel/include/nel/3d/ps_plane_basis.h b/code/nel/include/nel/3d/ps_plane_basis.h index 41882e148..3a36876f7 100644 --- a/code/nel/include/nel/3d/ps_plane_basis.h +++ b/code/nel/include/nel/3d/ps_plane_basis.h @@ -66,7 +66,7 @@ struct CPlaneBasis } - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serial(X, Y) ; } diff --git a/code/nel/include/nel/3d/ps_plane_basis_maker.h b/code/nel/include/nel/3d/ps_plane_basis_maker.h index 54770c9c9..e798c9885 100644 --- a/code/nel/include/nel/3d/ps_plane_basis_maker.h +++ b/code/nel/include/nel/3d/ps_plane_basis_maker.h @@ -128,7 +128,7 @@ class CPSPlaneBasisFollowSpeed : public CPSAttribMaker NLMISC_DECLARE_CLASS(CPSPlaneBasisFollowSpeed); /// serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + virtual void serial(NLMISC::IStream &f) { // version 2 : added projection plane // version 1 : nothing to save here @@ -192,7 +192,7 @@ public: /// get the number of samples for the rotation uint32 getNumSamples(void) const; /// serial this object - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); protected: CPSVector::V _PBTab; uint32 _NbSamples; diff --git a/code/nel/include/nel/3d/ps_quad.h b/code/nel/include/nel/3d/ps_quad.h index 000ff32cc..76e9562e2 100644 --- a/code/nel/include/nel/3d/ps_quad.h +++ b/code/nel/include/nel/3d/ps_quad.h @@ -114,7 +114,7 @@ protected: void updateVbColNUVForRender(CVertexBuffer &vb, uint32 startIndex, uint32 numQuad, uint32 srcStep, IDriver &drv); /// DERIVERS MUST CALL this - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); virtual CPSLocated *getColorOwner(void) { return _Owner; } virtual CPSLocated *getSizeOwner(void) { return _Owner; } virtual CPSLocated *getTextureIndexOwner(void) { return _Owner; } diff --git a/code/nel/include/nel/3d/ps_ribbon.h b/code/nel/include/nel/3d/ps_ribbon.h index ccda62021..5383a1b4b 100644 --- a/code/nel/include/nel/3d/ps_ribbon.h +++ b/code/nel/include/nel/3d/ps_ribbon.h @@ -55,7 +55,7 @@ public: /// dtor ~CPSRibbon(); /// serialisation. Derivers must override this, and call their parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); // NLMISC_DECLARE_CLASS(CPSRibbon); ///@} diff --git a/code/nel/include/nel/3d/ps_ribbon_base.h b/code/nel/include/nel/3d/ps_ribbon_base.h index ea3443060..5670a2d31 100644 --- a/code/nel/include/nel/3d/ps_ribbon_base.h +++ b/code/nel/include/nel/3d/ps_ribbon_base.h @@ -52,7 +52,7 @@ public: ///@{ CPSRibbonBase(); /// serialisation. Derivers must override this, and call their parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); ///@} ///\name Behaviour diff --git a/code/nel/include/nel/3d/ps_ribbon_look_at.h b/code/nel/include/nel/3d/ps_ribbon_look_at.h index 2494fe04c..6da38694b 100644 --- a/code/nel/include/nel/3d/ps_ribbon_look_at.h +++ b/code/nel/include/nel/3d/ps_ribbon_look_at.h @@ -38,7 +38,7 @@ public: /// dtor ~CPSRibbonLookAt(); /// serialisation. Derivers must override this, and call their parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); // NLMISC_DECLARE_CLASS(CPSRibbonLookAt); ///@} diff --git a/code/nel/include/nel/3d/ps_shockwave.h b/code/nel/include/nel/3d/ps_shockwave.h index b8329a239..54774c58f 100644 --- a/code/nel/include/nel/3d/ps_shockwave.h +++ b/code/nel/include/nel/3d/ps_shockwave.h @@ -54,7 +54,7 @@ public: float getRadiusCut(void) const { return _RadiusCut; } /// serialisation. Derivers must override this, and call their parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CPSShockWave); diff --git a/code/nel/include/nel/3d/ps_sound.h b/code/nel/include/nel/3d/ps_sound.h index af5a7cc94..d1c990770 100644 --- a/code/nel/include/nel/3d/ps_sound.h +++ b/code/nel/include/nel/3d/ps_sound.h @@ -50,7 +50,7 @@ public: /// dtor ~CPSSound(); /// serialisation. Derivers must override this, and call their parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); //@} /// return this bindable type diff --git a/code/nel/include/nel/3d/ps_tail_dot.h b/code/nel/include/nel/3d/ps_tail_dot.h index 3caf5fa96..a2aae6e83 100644 --- a/code/nel/include/nel/3d/ps_tail_dot.h +++ b/code/nel/include/nel/3d/ps_tail_dot.h @@ -37,7 +37,7 @@ public: /// dtor ~CPSTailDot(); /// serialisation. Derivers must override this, and call their parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); // NLMISC_DECLARE_CLASS(CPSTailDot); ///@} diff --git a/code/nel/include/nel/3d/ps_zone.h b/code/nel/include/nel/3d/ps_zone.h index 7289e64e0..032d5db62 100644 --- a/code/nel/include/nel/3d/ps_zone.h +++ b/code/nel/include/nel/3d/ps_zone.h @@ -82,7 +82,7 @@ public: /// serialization, DERIVER must override this, and call the parent version - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); /** Inherited from CPSTargetLocatedBindable. It's called when one of the targets has been detroyed or detached @@ -120,7 +120,7 @@ protected: /** * This set speed of a located so that it looks like bouncing on a surface * \param locatedIndex the index - * \param bouncePoint the position where the collision occured + * \param bouncePoint the position where the collision occurred * \param surfNormal the normal of the surface at the collision point (this must be a unit vector) * \elasticity 1 = full bounce, 0 = no bounce (contact) * \ellapsedTime the time ellapsed @@ -155,7 +155,7 @@ class CPSZonePlane : public CPSZone, public IPSMover virtual NLMISC::CVector getNormal(uint32 index); virtual void setNormal(uint32 index, NLMISC::CVector n); - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); protected: TPSAttribVector _Normal; @@ -176,7 +176,7 @@ struct CRadiusPair { // the adius, and the square radius float R, R2; - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { f.serial(R, R2); } @@ -205,7 +205,7 @@ class CPSZoneSphere : public CPSZone, public IPSMover - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); // inherited from IPSMover @@ -257,7 +257,7 @@ class CPSZoneDisc : public CPSZone, public IPSMover virtual NLMISC::CVector getNormal(uint32 index); virtual void setNormal(uint32 index, NLMISC::CVector n); - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); @@ -303,7 +303,7 @@ class CPSZoneCylinder : public CPSZone, public IPSMover virtual NLMISC::CVector getScale(uint32 k) const; // serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); @@ -350,7 +350,7 @@ class CPSZoneRectangle : public CPSZone, public IPSMover // serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); // inherited from IPSMover virtual bool supportUniformScaling(void) const { return true; } diff --git a/code/nel/include/nel/3d/quad_grid.h b/code/nel/include/nel/3d/quad_grid.h index 12160b540..b03164520 100644 --- a/code/nel/include/nel/3d/quad_grid.h +++ b/code/nel/include/nel/3d/quad_grid.h @@ -654,7 +654,7 @@ template typename CQuadGrid::CIterator CQuadGrid::erase(typename if(!ptr->Selected) next= NULL; // delete the object. - _NodeBlockMemory.free(ptr); + _NodeBlockMemory.freeBlock(ptr); return CIterator((CNode*)next); diff --git a/code/nel/include/nel/3d/ray_mesh.h b/code/nel/include/nel/3d/ray_mesh.h index 80671a49c..70a25c2be 100644 --- a/code/nel/include/nel/3d/ray_mesh.h +++ b/code/nel/include/nel/3d/ray_mesh.h @@ -53,7 +53,7 @@ public: public: // Simple Definition of a mesh used to test against Ray - std::vector Vertices; + std::vector Vertices; std::vector Triangles; /// Empty? diff --git a/code/nel/include/nel/3d/render_trav.h b/code/nel/include/nel/3d/render_trav.h index 6e41d8282..41570c2ca 100644 --- a/code/nel/include/nel/3d/render_trav.h +++ b/code/nel/include/nel/3d/render_trav.h @@ -28,6 +28,8 @@ #include "nel/3d/shadow_map_manager.h" #include "nel/3d/u_scene.h" #include "nel/3d/vertex_program.h" +#include "nel/3d/transform.h" + #include diff --git a/code/nel/include/nel/3d/seg_remanence_shape.h b/code/nel/include/nel/3d/seg_remanence_shape.h index 6a1f2cb5e..2f8a159ff 100644 --- a/code/nel/include/nel/3d/seg_remanence_shape.h +++ b/code/nel/include/nel/3d/seg_remanence_shape.h @@ -22,7 +22,7 @@ #include "nel/misc/smart_ptr.h" #include "nel/misc/vector.h" #include "nel/misc/aabbox.h" - +#include "nel/misc/class_id.h" #include "nel/3d/texture.h" #include "nel/3d/shape.h" @@ -70,7 +70,7 @@ public: // assignement CSegRemanenceShape &operator = (const CSegRemanenceShape &other); - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CSegRemanenceShape); //@} diff --git a/code/nel/include/nel/3d/shadow_map.h b/code/nel/include/nel/3d/shadow_map.h index aa4921594..84cc32af1 100644 --- a/code/nel/include/nel/3d/shadow_map.h +++ b/code/nel/include/nel/3d/shadow_map.h @@ -51,7 +51,7 @@ public: * The usage of this matrix is for UV projection: XYZ= WorldProjectionMatrix * UVW. * NB: Vj (ie for W) is mapped such that Vp means NearClip of the shadow and Vp+Vj means FarClip of the shadow */ - CMatrix LocalProjectionMatrix; + NLMISC::CMatrix LocalProjectionMatrix; /** Computed at shadow casting time. They are clipping planes used to clip receivers (mirror of the OBB). * Receivers may use them to clip sub received parts (as they which) @@ -63,7 +63,7 @@ public: /** Computed at shadow casting time. This is the LocalPos Bouding Box containing the shadow (AxisAligned). * \see generateClipInfoFromMatrix() */ - CAABBox LocalBoundingBox; + NLMISC::CAABBox LocalBoundingBox; // Filled by ShadowMapManager. This is the Last Frame Id we had update the texture. @@ -114,13 +114,13 @@ public: * driver->setupModelMatrix(localPosMatrix); * Then render his mesh. */ - void buildCasterCameraMatrix(const CVector &lightDir, const CMatrix &localPosMatrix, const CAABBox &bbShape, CMatrix &cameraMatrix); + void buildCasterCameraMatrix(const NLMISC::CVector &lightDir, const NLMISC::CMatrix &localPosMatrix, const NLMISC::CAABBox &bbShape, NLMISC::CMatrix &cameraMatrix); /** From the Camera matrix computed with buildCasterCameraMatrix, compute the LocalProjectionMatrix, which modify the * J axis according to backPoint and Shadow Depth. * NB: automatically calls the buildClipInfoFromMatrix() method */ - void buildProjectionInfos(const CMatrix &cameraMatrix, const CVector &backPoint, float shadowMaxDepth); + void buildProjectionInfos(const NLMISC::CMatrix &cameraMatrix, const NLMISC::CVector &backPoint, float shadowMaxDepth); /** The ShadowMap Caster can call this method after setting LocalProjectionMatrix. It computes auto the * LocalClipPlanes and LocalBoundingBox from it. NB: don't use it if you use buildProjectionInfos(). @@ -158,13 +158,13 @@ class CShadowMapProjector { public: CShadowMapProjector(); - void setWorldSpaceTextMat(const CMatrix &ws); - void applyToMaterial(const CMatrix &receiverWorldMatrix, CMaterial &material); + void setWorldSpaceTextMat(const NLMISC::CMatrix &ws); + void applyToMaterial(const NLMISC::CMatrix &receiverWorldMatrix, CMaterial &material); private: - CMatrix _WsTextMat; - CMatrix _XYZToUWVMatrix; - CMatrix _XYZToWUVMatrix; + NLMISC::CMatrix _WsTextMat; + NLMISC::CMatrix _XYZToUWVMatrix; + NLMISC::CMatrix _XYZToWUVMatrix; }; diff --git a/code/nel/include/nel/3d/shadow_map_manager.h b/code/nel/include/nel/3d/shadow_map_manager.h index d52c0fb03..8f8267492 100644 --- a/code/nel/include/nel/3d/shadow_map_manager.h +++ b/code/nel/include/nel/3d/shadow_map_manager.h @@ -29,7 +29,8 @@ namespace NL3D { -class CTransform; +class CTransform; +class CScene; // *************************************************************************** diff --git a/code/nel/include/nel/3d/shadow_skin.h b/code/nel/include/nel/3d/shadow_skin.h index 2b63a635d..7560e0c50 100644 --- a/code/nel/include/nel/3d/shadow_skin.h +++ b/code/nel/include/nel/3d/shadow_skin.h @@ -33,9 +33,9 @@ namespace NL3D class CShadowVertex { public: - CVector Vertex; - uint32 MatrixId; - void serial(NLMISC::IStream &f) + NLMISC::CVector Vertex; + uint32 MatrixId; + void serial(NLMISC::IStream &f) { (void)f.serialVersion(0); @@ -82,7 +82,7 @@ public: * if don't intersect, dist2D="nearest distance to the ray", and distZ=0 * \param computeDist2D if false and don't intersect, then return dist2D=FLT_MAX, and distZ=0 */ - bool getRayIntersection(const CMatrix &toRaySpace, class CSkeletonModel &skeleton, + bool getRayIntersection(const NLMISC::CMatrix &toRaySpace, class CSkeletonModel &skeleton, const std::vector &matrixInfluences, float &dist2D, float &distZ, bool computeDist2D); private: diff --git a/code/nel/include/nel/3d/shape.h b/code/nel/include/nel/3d/shape.h index a8038e593..ec359aa7f 100644 --- a/code/nel/include/nel/3d/shape.h +++ b/code/nel/include/nel/3d/shape.h @@ -201,7 +201,7 @@ public: IShape* getShapePointer () const; /// serial the shape. - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); private: IShape* _Shape; }; diff --git a/code/nel/include/nel/3d/skeleton_shape.h b/code/nel/include/nel/3d/skeleton_shape.h index a47be7f17..359a51fd3 100644 --- a/code/nel/include/nel/3d/skeleton_shape.h +++ b/code/nel/include/nel/3d/skeleton_shape.h @@ -49,7 +49,7 @@ public: std::vector ActiveBones; public: - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); }; public: @@ -94,7 +94,7 @@ public: virtual float getNumTriangles (float distance); /// serial this skeletonshape. - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CSkeletonShape); /// flush textures used by this shape. diff --git a/code/nel/include/nel/3d/stereo_hmd.h b/code/nel/include/nel/3d/stereo_hmd.h index 3276e78fe..69f8e60dd 100644 --- a/code/nel/include/nel/3d/stereo_hmd.h +++ b/code/nel/include/nel/3d/stereo_hmd.h @@ -54,7 +54,7 @@ public: virtual NLMISC::CQuat getOrientation() const = 0; /// Set the GUI reference - virtual void setInterfaceMatrix(const NL3D::CMatrix &matrix) = 0; + virtual void setInterfaceMatrix(const NLMISC::CMatrix &matrix) = 0; /// Get GUI center (1 = width, 1 = height, 0 = center) virtual void getInterface2DShift(uint cid, float &x, float &y, float distance) const = 0; diff --git a/code/nel/include/nel/3d/target_anim_ctrl.h b/code/nel/include/nel/3d/target_anim_ctrl.h index b2edf9f84..19aae3c20 100644 --- a/code/nel/include/nel/3d/target_anim_ctrl.h +++ b/code/nel/include/nel/3d/target_anim_ctrl.h @@ -44,16 +44,16 @@ public: public: /// Target controled or direction controled. Default to DirectionMode - TMode Mode; + TMode Mode; /// \name Target and Direction specific // @{ /// For TargetMode, the world Position of the target. - CVector WorldTarget; + NLMISC::CVector WorldTarget; /// For TargetMode only, the Pos of eyes relative to the bone controlled. Default to (0,0,0) - CVector EyePos; + NLMISC::CVector EyePos; /// For DirectionMode, the WorldRotation to apply to the bone. NB: modified in execute() if TargetMode - CQuat CurrentWorldDirection; + NLMISC::CQuat CurrentWorldDirection; // @} /// \name Common @@ -61,13 +61,13 @@ public: /** This enable or disable the ctrl. When disabled or enabled, the ctrl ensure * that the movement does not "pop", respecting MaxAngularVelocity. Default to true. */ - bool Enabled; + bool Enabled; /// This give The World Orientation when the Mesh is in bind Pos (default to "LookBack"). - CQuat DefaultWorldDirection; + NLMISC::CQuat DefaultWorldDirection; /// The Maximum angle of rotation that can be performed between the Default Direction and Current Direction. Default to Pi/3 - float MaxAngle; + float MaxAngle; /// The Maximum Angular Velocity the ctrl can perform. Default to 2*Pi per second. - float MaxAngularVelocity; + float MaxAngularVelocity; // @} @@ -77,19 +77,19 @@ public: virtual ~CTargetAnimCtrl(); /// Called at compute() time. - virtual void execute(CSkeletonModel *model, CBone *bone); + virtual void execute(CSkeletonModel *model, CBone *bone); private: /// The last rotation computed (in LocalSkeleton Space). Used to smooth transition - CQuat _LastLSRotation; + NLMISC::CQuat _LastLSRotation; /// This tells that a Enable/Disable transition is in progress. - bool _LastEnabled; - bool _EnableToDisableTransition; + bool _LastEnabled; + bool _EnableToDisableTransition; - CQuat getCurrentLSRotationFromBone(CSkeletonModel *model, CBone *bone); + NLMISC::CQuat getCurrentLSRotationFromBone(CSkeletonModel *model, CBone *bone); }; diff --git a/code/nel/include/nel/3d/texture.h b/code/nel/include/nel/3d/texture.h index bb9b9165a..5b8e7ef37 100644 --- a/code/nel/include/nel/3d/texture.h +++ b/code/nel/include/nel/3d/texture.h @@ -359,7 +359,7 @@ public: virtual bool allowDegradation() const { return false; } /// serial ITexture basic infos (clamp ...). - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); /** Select a texture among several other (if this texture is a set of texture such as CTextureMultiFile) * The default does nothing diff --git a/code/nel/include/nel/3d/texture_blend.h b/code/nel/include/nel/3d/texture_blend.h index 7a910d91e..5dcc7c6ea 100644 --- a/code/nel/include/nel/3d/texture_blend.h +++ b/code/nel/include/nel/3d/texture_blend.h @@ -74,7 +74,7 @@ public: virtual void release(); // serial this texture datas - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); private: uint16 _BlendFactor; diff --git a/code/nel/include/nel/3d/texture_bump.h b/code/nel/include/nel/3d/texture_bump.h index 7e4a099c9..1fb6152de 100644 --- a/code/nel/include/nel/3d/texture_bump.h +++ b/code/nel/include/nel/3d/texture_bump.h @@ -47,7 +47,7 @@ public: const ITexture *getHeightMap() const { return _HeightMap; }; // serial this texture datas - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); virtual bool supportSharing() const; diff --git a/code/nel/include/nel/3d/texture_cube.h b/code/nel/include/nel/3d/texture_cube.h index 979defa1c..4958f6628 100644 --- a/code/nel/include/nel/3d/texture_cube.h +++ b/code/nel/include/nel/3d/texture_cube.h @@ -77,7 +77,7 @@ public: virtual bool isTextureCube() const { return true; } /// Save the texture file name. - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CTextureCube); /// If the face support multiple texture (such has CTextureMultiFile), this allow to select the active set diff --git a/code/nel/include/nel/3d/texture_dlm.h b/code/nel/include/nel/3d/texture_dlm.h index 18cf125a0..0c16d95f6 100644 --- a/code/nel/include/nel/3d/texture_dlm.h +++ b/code/nel/include/nel/3d/texture_dlm.h @@ -81,7 +81,7 @@ public: /// TextureDLM are system. Do not need to serialize them... // default ctor is required for compilation with NLMISC_DECLARE_CLASS, but never called... CTextureDLM() {nlstop;} - virtual void serial(NLMISC::IStream &/* f */) throw(NLMISC::EStream) {nlstop;} + virtual void serial(NLMISC::IStream &/* f */) {nlstop;} NLMISC_DECLARE_CLASS(CTextureDLM); diff --git a/code/nel/include/nel/3d/texture_emboss.h b/code/nel/include/nel/3d/texture_emboss.h index a4c469a5c..fed99f52a 100644 --- a/code/nel/include/nel/3d/texture_emboss.h +++ b/code/nel/include/nel/3d/texture_emboss.h @@ -46,7 +46,7 @@ public: const ITexture *getHeightMap() const { return _HeightMap; }; // serial this texture datas - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); virtual bool supportSharing() const; virtual std::string getShareName() const; // @@ -54,16 +54,16 @@ public: bool isSharingEnabled() const { return !_DisableSharing; } // set the ambiant/ diffuse color to be added to the embossed texture - void setAmbient(CRGBA ambient) { _Ambient = ambient; touch(); } - void setDiffuse(CRGBA diffuse) { _Diffuse = diffuse; touch(); } + void setAmbient(NLMISC::CRGBA ambient) { _Ambient = ambient; touch(); } + void setDiffuse(NLMISC::CRGBA diffuse) { _Diffuse = diffuse; touch(); } // Set the direction of light (usually should be normalized). The bitmap is in the x,y plane void setLightDir(const NLMISC::CVector &lightDir) { _LightDir = lightDir; touch(); } // set a factor for the slope void setSlopeFactor(float factor) { _SlopeFactor = factor; touch(); } // - CRGBA getAmbient() const { return _Ambient; } - CRGBA getDiffuse() const { return _Diffuse; } - const CVector &getLightDir() const { return _LightDir; } + NLMISC::CRGBA getAmbient() const { return _Ambient; } + NLMISC::CRGBA getDiffuse() const { return _Diffuse; } + const NLMISC::CVector &getLightDir() const { return _LightDir; } float getSlopeFactor() const { return _SlopeFactor; } @@ -75,8 +75,8 @@ protected: // inherited from ITexture. Generate this bumpmap pixels virtual void doGenerate(bool async = false); NLMISC::CSmartPtr _HeightMap; - CRGBA _Ambient; - CRGBA _Diffuse; + NLMISC::CRGBA _Ambient; + NLMISC::CRGBA _Diffuse; NLMISC::CVector _LightDir; bool _DisableSharing; float _SlopeFactor; diff --git a/code/nel/include/nel/3d/texture_far.h b/code/nel/include/nel/3d/texture_far.h index a55308b19..6fdb59f30 100644 --- a/code/nel/include/nel/3d/texture_far.h +++ b/code/nel/include/nel/3d/texture_far.h @@ -185,7 +185,7 @@ private: void rebuildPatch (const CVector2s texturePos, const CPatchIdent &pid); /// From IStreamable - virtual void serial(NLMISC::IStream &/* f */) throw(NLMISC::EStream) {} + virtual void serial(NLMISC::IStream &/* f */) {} // Some static buffers static NLMISC::CRGBA _LightmapExpanded[]; diff --git a/code/nel/include/nel/3d/texture_file.h b/code/nel/include/nel/3d/texture_file.h index c758b1d6c..6f3620f47 100644 --- a/code/nel/include/nel/3d/texture_file.h +++ b/code/nel/include/nel/3d/texture_file.h @@ -122,7 +122,7 @@ public: void doGenerate(bool async = false); /// Save the texture file name. - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CTextureFile); diff --git a/code/nel/include/nel/3d/texture_font.h b/code/nel/include/nel/3d/texture_font.h index 3aeb77b65..e743bb137 100644 --- a/code/nel/include/nel/3d/texture_font.h +++ b/code/nel/include/nel/3d/texture_font.h @@ -61,6 +61,10 @@ public: sint32 Top; // Distance between origin and top of the texture sint32 Left; // Distance between origin and left of the texture sint32 AdvX; // Advance to the next caracter + + SLetterInfo():Char(0), FontGenerator(NULL), Size(0), Embolden(false), Oblique(false), Next(NULL), Prev(NULL), Cat(0), CharWidth(0), CharHeight(0), GlyphIndex(0), Top(0), Left(0), AdvX(0) + { + } }; struct SLetterKey @@ -74,6 +78,10 @@ public: uint32 getVal(); //bool operator < (const SLetterKey&k) const; //bool operator == (const SLetterKey&k) const; + + SLetterKey():Char(0), FontGenerator(NULL), Size(0), Embolden(false), Oblique(false) + { + } }; public: @@ -104,7 +112,7 @@ private: /// Todo: serialize a font texture. public: - virtual void serial(NLMISC::IStream &/* f */) throw(NLMISC::EStream) {nlstop;} + virtual void serial(NLMISC::IStream &/* f */) {nlstop;} NLMISC_DECLARE_CLASS(CTextureFont); }; diff --git a/code/nel/include/nel/3d/texture_grouped.h b/code/nel/include/nel/3d/texture_grouped.h index 247dd455a..f6f9515a0 100644 --- a/code/nel/include/nel/3d/texture_grouped.h +++ b/code/nel/include/nel/3d/texture_grouped.h @@ -111,7 +111,7 @@ public: void doGenerate(bool async = false); /// serialization - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); /// a group of 4 uvs diff --git a/code/nel/include/nel/3d/texture_mem.h b/code/nel/include/nel/3d/texture_mem.h index 01ea393f1..d28218151 100644 --- a/code/nel/include/nel/3d/texture_mem.h +++ b/code/nel/include/nel/3d/texture_mem.h @@ -160,7 +160,7 @@ public: void setAllowDegradation(bool allow); /// Todo: serialize a mem texture. - virtual void serial(NLMISC::IStream &/* f */) throw(NLMISC::EStream) {nlstop;} + virtual void serial(NLMISC::IStream &/* f */) {nlstop;} NLMISC_DECLARE_CLASS(CTextureMem); /** This create a white square texture of 1x1 diff --git a/code/nel/include/nel/3d/texture_multi_file.h b/code/nel/include/nel/3d/texture_multi_file.h index 37549b997..a32207995 100644 --- a/code/nel/include/nel/3d/texture_multi_file.h +++ b/code/nel/include/nel/3d/texture_multi_file.h @@ -70,7 +70,7 @@ public: /// Generate the current selected texture, looking in CPath if necessary. virtual void doGenerate(bool async = false); /// Serial this object - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + virtual void serial(NLMISC::IStream &f); NLMISC_DECLARE_CLASS(CTextureMultiFile); private: diff --git a/code/nel/include/nel/3d/texture_near.h b/code/nel/include/nel/3d/texture_near.h index 5a124b53b..0c47ecec7 100644 --- a/code/nel/include/nel/3d/texture_near.h +++ b/code/nel/include/nel/3d/texture_near.h @@ -77,7 +77,7 @@ public: /// TextureNear are system. Do not need to serialize them... // default ctor is required for compilation with NLMISC_DECLARE_CLASS, but never called... CTextureNear() {nlstop;} - virtual void serial(NLMISC::IStream &/* f */) throw(NLMISC::EStream) {nlstop;} + virtual void serial(NLMISC::IStream &/* f */) {nlstop;} NLMISC_DECLARE_CLASS(CTextureNear); private: diff --git a/code/nel/include/nel/3d/tile_bank.h b/code/nel/include/nel/3d/tile_bank.h index 32a205e6d..7d4eda3a7 100644 --- a/code/nel/include/nel/3d/tile_bank.h +++ b/code/nel/include/nel/3d/tile_bank.h @@ -77,7 +77,7 @@ public: { return (_Flags&NL3D_CTILE_FREE_FLAG)!=0; } - void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); void setFileName (TBitmap bitmapType, const std::string& name) { // not free @@ -140,7 +140,7 @@ public: private: void clearTile (CTile::TBitmap type); - void free () + void freeBlock () { nlassert ((_Flags&=NL3D_CTILE_FREE_FLAG)==0); _Flags|=NL3D_CTILE_FREE_FLAG; @@ -180,7 +180,7 @@ public: void clear(){ _TileSet.clear(); } - void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); private: // internal use @@ -210,7 +210,7 @@ public: { return _Tile; } - void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); private: sint32 _Tile; @@ -236,7 +236,7 @@ public: void doubleSize (); bool operator== (const CTileBorder& border) const; void operator= (const CTileBorder& border); - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); bool isSet() const { return _Set; @@ -320,7 +320,7 @@ public: // For edition: change the tileVegetableDesc. NB: only the TileVegetableDescFileName is serialised. void setTileVegetableDesc (const CTileVegetableDesc &tvd); /** try to load the vegetable tile desc associated with the fileName (nlinfo() if can't) - * lookup into CPath. no-op if string=="". + * lookup into CPath. no-op if string empty */ void loadTileVegetableDesc(); @@ -416,7 +416,7 @@ public: { return _ChildName.find(name)!=_ChildName.end(); } - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); private: static TFlagBorder getComplementaryBorder (TFlagBorder border); @@ -629,7 +629,7 @@ public: /// Postfix tile vegetable desc void postfixTileVegetableDesc (const char *filename); - void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); private: sint createTile (); void freeTile (int tileIndex); diff --git a/code/nel/include/nel/3d/tile_far_bank.h b/code/nel/include/nel/3d/tile_far_bank.h index 35c04be8b..52f380439 100644 --- a/code/nel/include/nel/3d/tile_far_bank.h +++ b/code/nel/include/nel/3d/tile_far_bank.h @@ -94,7 +94,7 @@ public: } /// Serial this tile - void serial (class NLMISC::IStream &f) throw(NLMISC::EStream); + void serial (NLMISC::IStream &f); private: /// RGBA Pixels vector @@ -141,7 +141,7 @@ public: } /// Serial this bank - void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); /// The far tile vector std::vector _TileVector; diff --git a/code/nel/include/nel/3d/track.h b/code/nel/include/nel/3d/track.h index e3c88f800..1ef8a4f1e 100644 --- a/code/nel/include/nel/3d/track.h +++ b/code/nel/include/nel/3d/track.h @@ -166,7 +166,7 @@ public: /// Serial the template - virtual void serial (NLMISC::IStream& f) throw (NLMISC::EStream) + virtual void serial (NLMISC::IStream& f) { // Serial version (void)f.serialVersion (0); @@ -217,7 +217,7 @@ public: /// Serial the template - virtual void serial (NLMISC::IStream& f) throw (NLMISC::EStream) + virtual void serial (NLMISC::IStream& f) { // Serial version (void)f.serialVersion (0); diff --git a/code/nel/include/nel/3d/track_keyframer.h b/code/nel/include/nel/3d/track_keyframer.h index 6cfb6736a..c49e63404 100644 --- a/code/nel/include/nel/3d/track_keyframer.h +++ b/code/nel/include/nel/3d/track_keyframer.h @@ -237,7 +237,7 @@ public: /// Serial the template - virtual void serial (NLMISC::IStream& f) throw (NLMISC::EStream) + virtual void serial (NLMISC::IStream& f) { // Serial version (void)f.serialVersion (0); diff --git a/code/nel/include/nel/3d/u_transform.h b/code/nel/include/nel/3d/u_transform.h index 556be7908..66315fa40 100644 --- a/code/nel/include/nel/3d/u_transform.h +++ b/code/nel/include/nel/3d/u_transform.h @@ -32,6 +32,7 @@ using NLMISC::CQuat; class ILogicInfo; class CCluster; +class ITransformable; // *************************************************************************** /** diff --git a/code/nel/include/nel/3d/vegetable_light_ex.h b/code/nel/include/nel/3d/vegetable_light_ex.h index a513dbeab..d9c1f2f0b 100644 --- a/code/nel/include/nel/3d/vegetable_light_ex.h +++ b/code/nel/include/nel/3d/vegetable_light_ex.h @@ -48,7 +48,7 @@ public: /// PointLights. Used at CVegetableManager::updateLighting() to get current colors of pointLights. CPointLightNamed *PointLight[MaxNumLight]; /// Direction of the light. the direction to the instance should be precomputed. - CVector Direction[MaxNumLight]; + NLMISC::CVector Direction[MaxNumLight]; /// Factor to be multiplied by color of the light. Actually it is the attenuation factor. uint PointLightFactor[MaxNumLight]; diff --git a/code/nel/include/nel/3d/vertex_buffer_heap.h b/code/nel/include/nel/3d/vertex_buffer_heap.h index c87426f7b..009d72489 100644 --- a/code/nel/include/nel/3d/vertex_buffer_heap.h +++ b/code/nel/include/nel/3d/vertex_buffer_heap.h @@ -69,7 +69,7 @@ public: bool allocate(uint numVertices, uint &indexStart); /// free a subset of the VB. nlstop if subset not found... - void free(uint indexStart); + void freeBlock(uint indexStart); // @} diff --git a/code/nel/include/nel/3d/water_env_map.h b/code/nel/include/nel/3d/water_env_map.h index 50fca18ec..2282610d7 100644 --- a/code/nel/include/nel/3d/water_env_map.h +++ b/code/nel/include/nel/3d/water_env_map.h @@ -21,6 +21,7 @@ // #include "nel/3d/texture_cube.h" #include "nel/3d/texture_blank.h" +#include "nel/3d/animation_time.h" namespace NL3D diff --git a/code/nel/include/nel/3d/water_height_map.h b/code/nel/include/nel/3d/water_height_map.h index f705c0368..003aaac53 100644 --- a/code/nel/include/nel/3d/water_height_map.h +++ b/code/nel/include/nel/3d/water_height_map.h @@ -79,7 +79,7 @@ public: /** Set the userPos (relative to the height map coordinates). This is needed because a height map can't be used with large surface (such as a sea). * As a consequence, the height map is only valid below the user (e.g from user.x - 0.5 * size to user.x + 0.5 *size). - * When setPos is called, and if a move has occured, new area of the height field are set to 0 + * When setPos is called, and if a move has occurred, new area of the height field are set to 0 * The pos set will be taken in account when buffers have been swapped (e.g when the propagation time as ellapsed) */ void setUserPos(sint x, sint y); @@ -168,7 +168,7 @@ public: sint64 Date; /// serial the pools data's - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); /// Set this pool name. void setName(const std::string &name) { _Name = name; } diff --git a/code/nel/include/nel/3d/water_pool_manager.h b/code/nel/include/nel/3d/water_pool_manager.h index 569b5d59a..c8a0885c9 100644 --- a/code/nel/include/nel/3d/water_pool_manager.h +++ b/code/nel/include/nel/3d/water_pool_manager.h @@ -97,7 +97,7 @@ public: /// serial the pools data's - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); private: friend class CWaterShape; diff --git a/code/nel/include/nel/3d/water_shape.h b/code/nel/include/nel/3d/water_shape.h index dc7f20426..633da8611 100644 --- a/code/nel/include/nel/3d/water_shape.h +++ b/code/nel/include/nel/3d/water_shape.h @@ -108,7 +108,7 @@ public: /// serial this shape - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); //@} @@ -299,7 +299,7 @@ public: /// serial this shape - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); //@} diff --git a/code/nel/include/nel/CMakeLists.txt b/code/nel/include/nel/CMakeLists.txt index b695104ae..4df9413b5 100644 --- a/code/nel/include/nel/CMakeLists.txt +++ b/code/nel/include/nel/CMakeLists.txt @@ -2,36 +2,36 @@ SUBDIRS(misc) IF(WITH_3D) SUBDIRS(3d) -ENDIF(WITH_3D) +ENDIF() IF(WITH_GUI) ADD_SUBDIRECTORY(gui) -ENDIF(WITH_GUI) +ENDIF() IF(WITH_GEORGES) SUBDIRS(georges) -ENDIF(WITH_GEORGES) +ENDIF() IF(WITH_LIGO) SUBDIRS(ligo) -ENDIF(WITH_LIGO) +ENDIF() IF(WITH_LOGIC) SUBDIRS(logic) -ENDIF(WITH_LOGIC) +ENDIF() IF(WITH_NET) SUBDIRS(net) -ENDIF(WITH_NET) +ENDIF() IF(WITH_SOUND) SUBDIRS(sound) -ENDIF(WITH_SOUND) +ENDIF() IF(WITH_PACS) SUBDIRS(pacs) -ENDIF(WITH_PACS) +ENDIF() IF(WITH_NEL_CEGUI) SUBDIRS(cegui) -ENDIF(WITH_NEL_CEGUI) +ENDIF() diff --git a/code/nel/include/nel/georges/form.h b/code/nel/include/nel/georges/form.h index d2b6a2f2d..da5c0ea88 100644 --- a/code/nel/include/nel/georges/form.h +++ b/code/nel/include/nel/georges/form.h @@ -22,7 +22,7 @@ #include "form_elm.h" #include "header.h" -extern bool convertFormFile (const char *oldFileName, const char *newFileName); +extern bool convertFormFile (const std::string &oldFileName, const std::string &newFileName); namespace NLGEORGES { @@ -35,7 +35,7 @@ class UFormElm; class CForm : public UForm { friend class CFormLoader; - friend bool convertFormFile (const char *oldFileName, const char *newFileName); + friend bool convertFormFile (const std::string &oldFileName, const std::string &newFileName); public: enum { HeldElementCount = 4 }; @@ -73,12 +73,12 @@ public: // ** IO functions // Set the filename before saving the form - void write (xmlDocPtr doc, const char *filename); + void write (xmlDocPtr doc, const std::string &filename); // ** Parent access // Insert parent before parent indexed "before". - bool insertParent (uint before, const char *filename, CForm *parent); + bool insertParent (uint before, const std::string &filename, CForm *parent); // Remove a parent from parent list void removeParent (uint parent); @@ -97,7 +97,7 @@ public: const std::string &getFilename () const; // Error handling - void warning (bool exception, const char *function, const char *format, ... ) const; + void warning (bool exception, const std::string &function, const char *format, ... ) const; private: @@ -114,7 +114,7 @@ private: // CFormLoader call it // Set the filename before reading the form - void read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const char *filename); + void read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const std::string &filename); // Called by read void readParent (const char *parent, CFormLoader &loader); diff --git a/code/nel/include/nel/georges/form_dfn.h b/code/nel/include/nel/georges/form_dfn.h index a93dcbe48..4e9870043 100644 --- a/code/nel/include/nel/georges/form_dfn.h +++ b/code/nel/include/nel/georges/form_dfn.h @@ -24,7 +24,7 @@ #include "header.h" #include "type.h" -bool convertDfnFile (const char *oldFileName, const char *newFileName); +bool convertDfnFile (const std::string &oldFileName, const std::string &newFileName); namespace NLGEORGES { @@ -41,7 +41,7 @@ class CFormDfn : public UFormDfn friend class CFormElm; friend class CFormLoader; friend class CFormElmStruct; - friend bool convertDfnFile (const char *oldFileName, const char *newFileName); + friend bool convertDfnFile (const std::string &oldFileName, const std::string &newFileName); public: // Default cstr @@ -60,7 +60,7 @@ public: friend class CFormElm; friend class CFormDfn; friend class CFormElmStruct; - friend bool convertDfnFile (const char *oldFileName, const char *newFileName); + friend bool convertDfnFile (const std::string &oldFileName, const std::string &newFileName); public: CEntry () @@ -85,12 +85,12 @@ public: TEntryType getType () const; // Set as a type - void setType (CFormLoader &loader, const char *filename); + void setType (CFormLoader &loader, const std::string &filename); void setType (TEntryType type); // Set as a dfn - void setDfn (CFormLoader &loader, const char *filename); + void setDfn (CFormLoader &loader, const std::string &filename); // Set as a dfn pointer void setDfnPointer (); @@ -99,7 +99,7 @@ public: const std::string &getName () const; // Set element Name - void setName (const char *name); + void setName (const std::string &name); // Get the filename const std::string &getFilename() const; @@ -108,16 +108,16 @@ public: const std::string &getFilenameExt() const; // Set the filename - void setFilename (const char *def); + void setFilename (const std::string &def); // Set the filename extension - void setFilenameExt (const char *ext); + void setFilenameExt (const std::string &ext); // Get default value const std::string &getDefault () const; // Set default value - void setDefault (const char *def); + void setDefault (const std::string &def); // Set array flag void setArrayFlag (bool flag); @@ -167,7 +167,7 @@ public: void removeEntry( uint idx ); // ** IO functions - void write (xmlDocPtr root, const char *filename); + void write (xmlDocPtr root, const std::string &filename); // Count parent DFN uint countParentDfn (uint32 round=0) const; @@ -185,7 +185,7 @@ public: void setNumParent (uint size); // Set a parent - void setParent (uint parent, CFormLoader &loader, const char *filename); + void setParent (uint parent, CFormLoader &loader, const std::string &filename); // Get a parent CFormDfn *getParent (uint parent) const; @@ -232,7 +232,7 @@ public: CFileHeader Header; // Error handling - void warning (bool exception, const char *function, const char *format, ... ) const; + void warning (bool exception, const std::string &function, const char *format, ... ) const; private: // The parents array @@ -249,7 +249,7 @@ private: private: // Read method called by the form loader - void read (xmlNodePtr doc, CFormLoader &loader, bool forceLoad, const char *filename); + void read (xmlNodePtr doc, CFormLoader &loader, bool forceLoad, const std::string &filename); }; } // NLGEORGES diff --git a/code/nel/include/nel/georges/form_elm.h b/code/nel/include/nel/georges/form_elm.h index 2d9e76630..738e6a55a 100644 --- a/code/nel/include/nel/georges/form_elm.h +++ b/code/nel/include/nel/georges/form_elm.h @@ -62,30 +62,30 @@ public: virtual void getFormName (std::string &result, const CFormElm *child=NULL) const = 0; // From UFormElm - virtual bool getNodeByName (const UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round=0) const; - virtual bool getNodeByName (UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round=0); - virtual bool getValueByName (std::string &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (sint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (uint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (sint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (uint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (sint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (uint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (float &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (double &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (bool &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (NLMISC::CRGBA &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool setValueByName (const char *value, const char *name, bool *created); - virtual bool setValueByName (sint8 value, const char *name, bool *created); - virtual bool setValueByName (uint8 value, const char *name, bool *created); - virtual bool setValueByName (sint16 value, const char *name, bool *created); - virtual bool setValueByName (uint16 value, const char *name, bool *created); - virtual bool setValueByName (sint32 value, const char *name, bool *created); - virtual bool setValueByName (uint32 value, const char *name, bool *created); - virtual bool setValueByName (float value, const char *name, bool *created); - virtual bool setValueByName (double value, const char *name, bool *created); - virtual bool setValueByName (bool value, const char *name, bool *created); - virtual bool setValueByName (NLMISC::CRGBA value, const char *name, bool *created); + virtual bool getNodeByName (const UFormElm **result, const std::string &name, TWhereIsNode *where, bool verbose, uint32 round=0) const; + virtual bool getNodeByName (UFormElm **result, const std::string &name, TWhereIsNode *where, bool verbose, uint32 round=0); + virtual bool getValueByName (std::string &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (sint8 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (uint8 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (sint16 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (uint16 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (sint32 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (uint32 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (float &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (double &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (bool &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (NLMISC::CRGBA &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool setValueByName (const std::string &value, const std::string &name, bool *created); + virtual bool setValueByName (sint8 value, const std::string &name, bool *created); + virtual bool setValueByName (uint8 value, const std::string &name, bool *created); + virtual bool setValueByName (sint16 value, const std::string &name, bool *created); + virtual bool setValueByName (uint16 value, const std::string &name, bool *created); + virtual bool setValueByName (sint32 value, const std::string &name, bool *created); + virtual bool setValueByName (uint32 value, const std::string &name, bool *created); + virtual bool setValueByName (float value, const std::string &name, bool *created); + virtual bool setValueByName (double value, const std::string &name, bool *created); + virtual bool setValueByName (bool value, const std::string &name, bool *created); + virtual bool setValueByName (NLMISC::CRGBA value, const std::string &name, bool *created); virtual UFormElm *getParent () const; virtual const CType *getType (); virtual bool isArray () const; @@ -127,16 +127,16 @@ public: // ** Convert functions - inline bool convertValue (sint8 &result, const char *value) const; - inline bool convertValue (uint8 &result, const char *value) const; - inline bool convertValue (sint16 &result, const char *value) const; - inline bool convertValue (uint16 &result, const char *value) const; - inline bool convertValue (sint32 &result, const char *value) const; - inline bool convertValue (uint32 &result, const char *value) const; - inline bool convertValue (float &result, const char *value) const; - inline bool convertValue (double &result, const char *value) const; - inline bool convertValue (bool &result, const char *value) const; - inline bool convertValue (NLMISC::CRGBA &result, const char *value) const; + inline bool convertValue (sint8 &result, const std::string &value) const; + inline bool convertValue (uint8 &result, const std::string &value) const; + inline bool convertValue (sint16 &result, const std::string &value) const; + inline bool convertValue (uint16 &result, const std::string &value) const; + inline bool convertValue (sint32 &result, const std::string &value) const; + inline bool convertValue (uint32 &result, const std::string &value) const; + inline bool convertValue (float &result, const std::string &value) const; + inline bool convertValue (double &result, const std::string &value) const; + inline bool convertValue (bool &result, const std::string &value) const; + inline bool convertValue (NLMISC::CRGBA &result, const std::string &value) const; // ** Get dependencies virtual void getDependencies (std::set &dependencies) const = 0; @@ -144,7 +144,7 @@ public: // ** Internal node access // Create a node by name. If the node already exists, return it - bool createNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, + bool createNodeByName (const std::string &, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool &created); @@ -153,13 +153,13 @@ public: * Delete a node by name. If the node already exists, return it *Delete its parent if not used */ - bool deleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, + bool deleteNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array); // Search for a node by name - bool getNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, + bool getNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool &parentVDfnArray, bool verbose, uint32 round) const; @@ -168,7 +168,7 @@ public: * Insert an array node by name * The index asked must be < the size of the array. */ - bool arrayInsertNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, + bool arrayInsertNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool verbose, uint arrayIndex) const; @@ -177,7 +177,7 @@ public: * Delete an array node by name * The index asked must be < the size of the array. */ - bool arrayDeleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, + bool arrayDeleteNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool verbose, uint arrayIndex) const; @@ -199,7 +199,7 @@ protected: * Then, else (*parentDfn / indexDfn ) or *node must be defined. * Other values are for result only. */ - static bool getInternalNodeByName (CForm *form, const char *name, const CFormDfn **parentDfn, uint &indexDfn, + static bool getInternalNodeByName (CForm *form, const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, TNodeAction action, bool &created, bool &parentVDfnArray, bool verbose, uint32 round); @@ -215,7 +215,7 @@ public: static const char* tokenize (const char *name, std::string &str, uint &errorIndex, uint &code); // ** IO functions - virtual xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName = NULL, bool forceWrite = false) const = 0; + virtual xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName = "", bool forceWrite = false) const = 0; protected: @@ -235,8 +235,8 @@ protected: uint32 Round; // Error handling - static void warning (bool exception, const char *formName, const char *formFileName, const char *function, const char *format, ... ); - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + static void warning (bool exception, const std::string &formName, const std::string &formFileName, const std::string &function, const char *format, ... ); + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; private: // Tokens @@ -298,7 +298,7 @@ public: // From CFormElm bool isUsed (const CForm *form) const; - xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; + xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const; void unlink (CFormElm *child); void getFormName (std::string &result, const CFormElm *child) const; void getDependencies (std::set &dependencies) const; @@ -310,7 +310,7 @@ public: std::vector Elements; // Error handling - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; }; /** @@ -332,13 +332,13 @@ public: // From CFormElm bool isUsed (const CForm *form) const; - xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; + xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const; // Call by CFormLoader void read (xmlNodePtr node, CFormLoader &loader, CForm *form); // Error handling - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; }; /** @@ -377,7 +377,7 @@ public: bool getArrayValue (NLMISC::CRGBA &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const; // From CFormElm - xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; + xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const; bool setParent (CFormElm *parent); void unlink (CFormElm *child); bool isUsed (const CForm *form) const; @@ -406,7 +406,7 @@ public: std::vector Elements; // Error handling - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; }; /** @@ -429,7 +429,7 @@ public: const CType *Type; // From CFormElm - xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; + xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const; bool setParent (CFormElm *parent); void getFormName (std::string &result, const CFormElm *child) const; void getDependencies (std::set &dependencies) const; @@ -453,7 +453,7 @@ public: bool getValue (NLMISC::CRGBA &result, TEval evaluate) const; // Set the value, the elt been used - void setValue (const char *value); + void setValue (const std::string &value); // Get the raw value. Does not care about any parent or default values void getValue (std::string &result) const; @@ -463,14 +463,14 @@ private: std::string Value; // Error handling - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; }; // *************************************************************************** // CFormElm inlines // *************************************************************************** -inline bool CFormElm::convertValue (sint8 &result, const char *value) const +inline bool CFormElm::convertValue (sint8 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -482,14 +482,14 @@ inline bool CFormElm::convertValue (sint8 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in sint8.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in sint8.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (uint8 &result, const char *value) const +inline bool CFormElm::convertValue (uint8 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -501,14 +501,14 @@ inline bool CFormElm::convertValue (uint8 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in uint8.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in uint8.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (sint16 &result, const char *value) const +inline bool CFormElm::convertValue (sint16 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -520,14 +520,14 @@ inline bool CFormElm::convertValue (sint16 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in sint16.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in sint16.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (uint16 &result, const char *value) const +inline bool CFormElm::convertValue (uint16 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -539,14 +539,14 @@ inline bool CFormElm::convertValue (uint16 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in uint16.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in uint16.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (sint32 &result, const char *value) const +inline bool CFormElm::convertValue (sint32 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -558,14 +558,14 @@ inline bool CFormElm::convertValue (sint32 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in sint32.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in sint32.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (uint32 &result, const char *value) const +inline bool CFormElm::convertValue (uint32 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -577,14 +577,14 @@ inline bool CFormElm::convertValue (uint32 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in uint32.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in uint32.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (float &result, const char *value) const +inline bool CFormElm::convertValue (float &result, const std::string &value) const { if (NLMISC::fromString(value, result)) { @@ -593,16 +593,16 @@ inline bool CFormElm::convertValue (float &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in float.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in float.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (double &result, const char *value) const +inline bool CFormElm::convertValue (double &result, const std::string &value) const { - float tmp; + double tmp; if (NLMISC::fromString(value, tmp)) { result = tmp; @@ -611,14 +611,14 @@ inline bool CFormElm::convertValue (double &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in double.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in double.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (bool &result, const char *value) const +inline bool CFormElm::convertValue (bool &result, const std::string &value) const { int tmp; if (NLMISC::fromString(value, tmp)) @@ -628,7 +628,7 @@ inline bool CFormElm::convertValue (bool &result, const char *value) const } else { - std::string temp = NLMISC::toLower(std::string(value)); + std::string temp = NLMISC::toLower(value); if (strcmp (temp.c_str (), "true") == 0) { result = true; @@ -642,17 +642,17 @@ inline bool CFormElm::convertValue (bool &result, const char *value) const } // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in boolean.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in boolean.", value.c_str()); return false; } // *************************************************************************** -inline bool CFormElm::convertValue (NLMISC::CRGBA &result, const char *value) const +inline bool CFormElm::convertValue (NLMISC::CRGBA &result, const std::string &value) const { float r, g, b; - if (sscanf (value, "%f,%f,%f", &r, &g, &b) == 3) + if (sscanf (value.c_str(), "%f,%f,%f", &r, &g, &b) == 3) { NLMISC::clamp (r, 0.f, 255.f); NLMISC::clamp (g, 0.f, 255.f); @@ -664,7 +664,7 @@ inline bool CFormElm::convertValue (NLMISC::CRGBA &result, const char *value) co } // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in RGB color.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in RGB color.", value.c_str()); return false; } diff --git a/code/nel/include/nel/georges/form_loader.h b/code/nel/include/nel/georges/form_loader.h index 75d7152ec..c46d79f22 100644 --- a/code/nel/include/nel/georges/form_loader.h +++ b/code/nel/include/nel/georges/form_loader.h @@ -42,18 +42,18 @@ class CFormLoader : public UFormLoader public: virtual ~CFormLoader(); // From UFormLoader - UForm *loadForm (const char *filename); - UFormDfn *loadFormDfn (const char *filename); - UType *loadFormType (const char *filename); + UForm *loadForm (const std::string &filename); + UFormDfn *loadFormDfn (const std::string &filename); + UType *loadFormType (const std::string &filename); // Load type and formDfn - CType *loadType (const char *filename); - CFormDfn *loadFormDfn (const char *filename, bool forceLoad); + CType *loadType (const std::string &filename); + CFormDfn *loadFormDfn (const std::string &filename, bool forceLoad); private: // Error handling - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; typedef std::map > TTypeMap; typedef std::map > TFormDfnMap; diff --git a/code/nel/include/nel/georges/header.h b/code/nel/include/nel/georges/header.h index 343b2baa1..82a094b3d 100644 --- a/code/nel/include/nel/georges/header.h +++ b/code/nel/include/nel/georges/header.h @@ -44,10 +44,10 @@ public: }; /// Add a log - void addLog (const char *log); + void addLog(const std::string &log); /// Set the comment - void setComments (const char *comments); + void setComments (const std::string &comments); /// Major version number uint32 MajorVersion; @@ -72,7 +72,7 @@ public: static const char *getStateString (TState state); // Error handling - void warning (bool exception, const char *function, const char *format, ... ) const; + void warning (bool exception, const std::string &function, const char *format, ... ) const; }; } // NLGEORGES diff --git a/code/nel/include/nel/georges/load_form.h b/code/nel/include/nel/georges/load_form.h index 4aaab43d0..a927d21e0 100644 --- a/code/nel/include/nel/georges/load_form.h +++ b/code/nel/include/nel/georges/load_form.h @@ -385,7 +385,7 @@ void loadForm (const std::vector &sheetFilters, const std::string & } } - if(NeededToRecompute.size() > 0) + if(!NeededToRecompute.empty()) nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); // free the georges loader if necessary @@ -748,7 +748,7 @@ void loadForm2(const std::vector &sheetFilters, const std::string & } } - if(NeededToRecompute.size() > 0) + if(!NeededToRecompute.empty()) nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); // free the georges loader if necessary @@ -1304,7 +1304,7 @@ void loadFormNoPackedSheet (const std::vector &sheetFilters, std::m } } - if(NeededToRecompute.size() > 0) + if(!NeededToRecompute.empty()) nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); // free the georges loader if necessary @@ -1393,7 +1393,7 @@ void loadFormNoPackedSheet2 (const std::vector &sheetFilters, std:: } } - if(NeededToRecompute.size() > 0) + if(!NeededToRecompute.empty()) nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); // free the georges loader if necessary diff --git a/code/nel/include/nel/georges/type.h b/code/nel/include/nel/georges/type.h index 936506c7c..e1bad7934 100644 --- a/code/nel/include/nel/georges/type.h +++ b/code/nel/include/nel/georges/type.h @@ -80,7 +80,7 @@ public: // Evaluate a node bool getValue (std::string &result, const class CForm *form, const class CFormElmAtom *node, const class CFormDfn &parentDfn, - uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const char *formName) const; + uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const std::string &formName) const; // Definitions class CDefinition @@ -114,8 +114,8 @@ public: private: // Error handling - virtual void warning (bool exception, const char *formName, const char *formFilename, const char *function, const char *format, ... ) const; - virtual void warning2 (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &formName, const std::string &formFilename, const std::string &function, const char *format, ... ) const; + virtual void warning2 (bool exception, const std::string &function, const char *format, ... ) const; // Type names static const char *TypeNames[]; diff --git a/code/nel/include/nel/georges/u_form_elm.h b/code/nel/include/nel/georges/u_form_elm.h index 6ec80938f..f50582a04 100644 --- a/code/nel/include/nel/georges/u_form_elm.h +++ b/code/nel/include/nel/georges/u_form_elm.h @@ -78,8 +78,8 @@ public: * "position.x" : get the element named x in the struct named position * "entities[2].color" : get the node named color in the second element of the entities array */ - virtual bool getNodeByName (const UFormElm **result, const char *name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) const = 0; - virtual bool getNodeByName (UFormElm **result, const char *name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) = 0; + virtual bool getNodeByName (const UFormElm **result, const std::string &name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) const = 0; + virtual bool getNodeByName (UFormElm **result, const std::string &name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) = 0; /// Where a value has been found @@ -104,19 +104,19 @@ public: * \return true if the result has been filled, false if the value has not been found or the cast has failed or the evaluation has failed. * \see getNodeByName () */ - virtual bool getValueByName (std::string &result, const char *namename, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (sint8 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (uint8 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (sint16 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (uint16 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (sint32 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (uint32 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (float &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (double &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (bool &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (std::string &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (sint8 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (uint8 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (sint16 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (uint16 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (sint32 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (uint32 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (float &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (double &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (bool &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; /// Warning, only R, G and B members are filled, not A. - virtual bool getValueByName (NLMISC::CRGBA &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (NLMISC::CRGBA &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; /** * Set a form value with its name. If the node doesn't exist, it is created. @@ -129,17 +129,17 @@ public: * true if the value has been created, false it the value has been filled. * \return true if the value has been set, false if the value has not been found or hasn't been created. */ - virtual bool setValueByName (const char *value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (sint8 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (uint8 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (sint16 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (uint16 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (sint32 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (uint32 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (float value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (double value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (bool value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (NLMISC::CRGBA value, const char *name, bool *created = NULL) = 0; + virtual bool setValueByName (const std::string &value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (sint8 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (uint8 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (sint16 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (uint16 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (sint32 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (uint32 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (float value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (double value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (bool value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (NLMISC::CRGBA value, const std::string &name, bool *created = NULL) = 0; // ** Array element methods diff --git a/code/nel/include/nel/georges/u_form_loader.h b/code/nel/include/nel/georges/u_form_loader.h index b32f358e0..c1cb30cfb 100644 --- a/code/nel/include/nel/georges/u_form_loader.h +++ b/code/nel/include/nel/georges/u_form_loader.h @@ -43,19 +43,19 @@ public: * * The pointer on the form must be held in a CSmartPtr. Returns NULL if the form can't be loaded. */ - virtual UForm *loadForm (const char *filename) = 0; + virtual UForm *loadForm (const std::string &filename) = 0; /** Load a DFN, use NMISC::CPath to find the file. * * The pointer on the form must be held in a CSmartPtr. Returns NULL if the DFN can't be loaded. */ - virtual UFormDfn *loadFormDfn (const char *filename) = 0; + virtual UFormDfn *loadFormDfn (const std::string &filename) = 0; /** Load a type, use NMISC::CPath to find the file. * * The pointer on the form must be held in a CSmartPtr. Returns NULL if the type can't be loaded. */ - virtual UType *loadFormType (const char *filename) = 0; + virtual UType *loadFormType (const std::string &filename) = 0; /// Create a form loader static UFormLoader *createLoader (); diff --git a/code/ryzom/tools/sheets_packer/sheets_packer_init.h b/code/nel/include/nel/gui/curl_certificates.h similarity index 71% rename from code/ryzom/tools/sheets_packer/sheets_packer_init.h rename to code/nel/include/nel/gui/curl_certificates.h index 4015679ea..021b13360 100644 --- a/code/ryzom/tools/sheets_packer/sheets_packer_init.h +++ b/code/nel/include/nel/gui/curl_certificates.h @@ -14,22 +14,22 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#ifndef CL_CURL_CERTIFICATES_HTML_H +#define CL_CURL_CERTIFICATES_HTML_H - - -#ifndef TL_SHEETS_PACKER_INIT_H -#define TL_SHEETS_PACKER_INIT_H - - +#include #include "nel/misc/types_nl.h" -// Initialize the application. -bool init(); +namespace NLGUI +{ +#if defined(NL_OS_WINDOWS) + class CCurlCertificates { + public: + // cURL SSL certificate loading + static CURLcode sslCtxFunction(CURL *curl, void *sslctx, void *parm); + }; +#endif // NL_OS_WINDOWS -// Release all. -void release(); - -#endif // TL_SHEETS_PACKER_INIT_H - -/* End of sheets_packer_init.h */ +} // namespace +#endif diff --git a/code/nel/include/nel/gui/group_editbox.h b/code/nel/include/nel/gui/group_editbox.h index 771bdc482..14d9d55a5 100644 --- a/code/nel/include/nel/gui/group_editbox.h +++ b/code/nel/include/nel/gui/group_editbox.h @@ -264,6 +264,7 @@ namespace NLGUI // because of multiline, thz parent container will be moved to top // The good position can be restored by a press on enter then bool _WantReturn : 1; // Want return char, don't call the enter action handler + bool _ClearOnEscape : 1; // clear content when ESC is pressed? bool _Savable : 1; // should content be saved ? bool _DefaultInputString : 1; // Is the current input string the default one (should not be edited) bool _Frozen : 1; // is the control frozen? (cannot edit in it) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 6b8212c6e..8d3478579 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -84,6 +84,7 @@ namespace NLGUI FontOblique=false; Underlined=false; StrikeThrough=false; + GlobalColor=false; Width=-1; Height=-1; MaxWidth=-1; @@ -94,6 +95,7 @@ namespace NLGUI bool FontOblique; std::string FontFamily; NLMISC::CRGBA TextColor; + bool GlobalColor; bool Underlined; bool StrikeThrough; sint32 Width; @@ -253,6 +255,7 @@ namespace NLGUI int luaEndElement(CLuaState &ls); int luaShowDiv(CLuaState &ls); int luaParseHtml(CLuaState &ls); + int luaRenderHtml(CLuaState &ls); REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText) REFLECT_LUA_METHOD("browse", luaBrowse) @@ -265,6 +268,7 @@ namespace NLGUI REFLECT_LUA_METHOD("endElement", luaEndElement) REFLECT_LUA_METHOD("showDiv", luaShowDiv) REFLECT_LUA_METHOD("parseHtml", luaParseHtml) + REFLECT_LUA_METHOD("renderHtml", luaRenderHtml) REFLECT_STRING("url", getURL, setURL) REFLECT_FLOAT("timeout", getTimeout, setTimeout) REFLECT_EXPORT_END @@ -319,7 +323,7 @@ namespace NLGUI // \name internal methods // Add a group in the current parent group - void addGroup (CInterfaceGroup *group, uint beginSpace); + void addHtmlGroup (CInterfaceGroup *group, uint beginSpace); // Get the current parent group CInterfaceGroup *getCurrentGroup(); @@ -337,7 +341,7 @@ namespace NLGUI void addString(const ucstring &str); // Add an image in the current paragraph - void addImage(const char *image, bool globalColor, bool reloadImg=false, const CStyleParams &style = CStyleParams()); + void addImage(const char *image, bool reloadImg=false, const CStyleParams &style = CStyleParams()); // Add a text area in the current paragraph CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength); @@ -348,7 +352,7 @@ namespace NLGUI // Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL. CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap, - const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip, + const std::string &overBitmap, const char *actionHandler, const char *actionHandlerParams, const char *tooltip, const CStyleParams &style = CStyleParams()); // Set the background color @@ -710,7 +714,12 @@ namespace NLGUI std::vector _CellParams; // Indentation - uint _Indent; + std::vector _Indent; + inline uint getIndent() const { + if (_Indent.empty()) + return 0; + return _Indent.back(); + } // Current node is a title bool _Title; @@ -789,7 +798,7 @@ namespace NLGUI void doBrowseLocalFile(const std::string &filename); // load remote content using either GET or POST - void doBrowseRemoteUrl(const std::string &url, const std::string &referer, bool doPost = false, const SFormFields &formfields = SFormFields()); + void doBrowseRemoteUrl(std::string url, const std::string &referer, bool doPost = false, const SFormFields &formfields = SFormFields()); // render html string as new browser page bool renderHtmlString(const std::string &html); @@ -803,33 +812,37 @@ namespace NLGUI // ImageDownload system enum TDataType {ImgType= 0, BnpType}; + enum TImageType {NormalImage=0, OverImage}; struct CDataImageDownload { public: - CDataImageDownload(CViewBase *img, CStyleParams style): Image(img), Style(style) + CDataImageDownload(CViewBase *img, CStyleParams style, TImageType type): Image(img), Style(style), Type(type) { } public: CViewBase * Image; CStyleParams Style; + TImageType Type; }; struct CDataDownload { public: - CDataDownload(CURL *c, const std::string &u, const std::string &d, FILE *f, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams()) : curl(c), url(u), dest(d), luaScript(s), md5sum(m), type(t), fp(f) + CDataDownload(const std::string &u, const std::string &d, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams(), const TImageType imagetype = NormalImage) + : data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0) { - if (t == ImgType) imgs.push_back(CDataImageDownload(i, style)); + if (t == ImgType) imgs.push_back(CDataImageDownload(i, style, imagetype)); } public: - CURL *curl; + CCurlWWWData *data; std::string url; std::string dest; std::string luaScript; std::string md5sum; TDataType type; + uint32 redirects; FILE *fp; std::vector imgs; }; @@ -838,20 +851,22 @@ namespace NLGUI CURLM *MultiCurl; int RunningCurls; + bool startCurlDownload(CDataDownload &download); + void initImageDownload(); void checkImageDownload(); - void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams()); + void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage); std::string localImageName(const std::string &url); std::string getAbsoluteUrl(const std::string &url); bool isTrustedDomain(const std::string &domain); - void setImage(CViewBase *view, const std::string &file); + void setImage(CViewBase *view, const std::string &file, const TImageType type); void setImageSize(CViewBase *view, const CStyleParams &style = CStyleParams()); // BnpDownload system void initBnpDownload(); void checkBnpDownload(); - bool addBnpDownload(const std::string &url, const std::string &action, const std::string &script, const std::string &md5sum); + bool addBnpDownload(std::string url, const std::string &action, const std::string &script, const std::string &md5sum); std::string localBnpName(const std::string &url); void releaseDownloads(); diff --git a/code/nel/include/nel/gui/group_menu.h b/code/nel/include/nel/gui/group_menu.h index e55bed751..d4f940088 100644 --- a/code/nel/include/nel/gui/group_menu.h +++ b/code/nel/include/nel/gui/group_menu.h @@ -191,6 +191,7 @@ namespace NLGUI int luaGetLineFromId(CLuaState &ls); int luaIsSeparator(CLuaState &ls); int luaAddLine(CLuaState &ls); + int luaAddIconLine(CLuaState &ls); int luaAddLineAtIndex(CLuaState &ls); int luaAddSeparator(CLuaState &ls); int luaAddSeparatorAtIndex(CLuaState &ls); @@ -210,6 +211,7 @@ namespace NLGUI REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu); REFLECT_LUA_METHOD("isSeparator", luaIsSeparator); REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id + REFLECT_LUA_METHOD("addIconLine", luaAddIconLine); // name, ah, ah_params, id, texture REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id REFLECT_LUA_METHOD("addSeparator", luaAddSeparator); REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex); @@ -278,6 +280,7 @@ namespace NLGUI */ CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const; void initOptions(CInterfaceGroup *parent); + CViewBitmap *createIcon(CInterfaceElement *parentPos, const std::string &texture); CViewBitmap *createCheckBox(bool checked); CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center); }; diff --git a/code/nel/include/nel/gui/group_paragraph.h b/code/nel/include/nel/gui/group_paragraph.h index b8792ece1..0004850fa 100644 --- a/code/nel/include/nel/gui/group_paragraph.h +++ b/code/nel/include/nel/gui/group_paragraph.h @@ -206,12 +206,6 @@ namespace NLGUI invalidateContent(); } - // Set the HTML group used for links - void setBrowseGroup (CInterfaceElement *group) - { - _BrowseGroup = group; - } - /// \from CInterfaceElement void onInvalidateContent(); sint32 getMaxUsedW() const; @@ -293,9 +287,6 @@ namespace NLGUI // The links std::vector _Links; - // The HTML group used - CInterfaceElement *_BrowseGroup; - private: std::string _HardText; uint32 _TextId; diff --git a/code/nel/include/nel/gui/group_table.h b/code/nel/include/nel/gui/group_table.h index 746078908..2be9ef98c 100644 --- a/code/nel/include/nel/gui/group_table.h +++ b/code/nel/include/nel/gui/group_table.h @@ -64,7 +64,7 @@ namespace NLGUI xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; // to be called by CGroupTable - bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex); + bool parseCell (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex); // If the cell is a new line. This is the first after a bool NewLine; diff --git a/code/nel/include/nel/gui/group_tree.h b/code/nel/include/nel/gui/group_tree.h index 1b64122f3..ae4bcb3d0 100644 --- a/code/nel/include/nel/gui/group_tree.h +++ b/code/nel/include/nel/gui/group_tree.h @@ -97,6 +97,7 @@ namespace NLGUI void addChildSortedByBitmap(SNode *pNode); void setParentTree(CGroupTree *parent); void setFather(SNode *father); + void openAll(); void closeAll(); void makeOrphan(); bool parse (xmlNodePtr cur, CGroupTree *parentGroup); diff --git a/code/nel/include/nel/gui/http_cache.h b/code/nel/include/nel/gui/http_cache.h new file mode 100644 index 000000000..0921b2f64 --- /dev/null +++ b/code/nel/include/nel/gui/http_cache.h @@ -0,0 +1,77 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_HTTP_CACHE_H +#define CL_HTTP_CACHE_H + +#include "nel/misc/types_nl.h" + +namespace NLGUI +{ + struct CHttpCacheObject + { + CHttpCacheObject(uint32 expires = 0, const std::string& lastModified = "", const std::string& etag = "") + : Expires(expires) + , LastModified(lastModified) + , Etag(etag){}; + + uint32 Expires; + std::string LastModified; + std::string Etag; + + void serial(NLMISC::IStream& f); + }; + + /** + * Keeping track of downloaded files cache related headers + * \author Meelis Mägi (nimetu) + * \date 2017 + */ + class CHttpCache + { + typedef std::map THttpCacheMap; + + public: + static CHttpCache* getInstance(); + static void release(); + + public: + void setCacheIndex(const std::string& fname); + void init(); + + CHttpCacheObject lookup(const std::string& fname); + void store(const std::string& fname, const CHttpCacheObject& data); + + void flushCache(); + + void serial(NLMISC::IStream& f); + + private: + CHttpCache(); + ~CHttpCache(); + + void pruneCache(); + + static CHttpCache* instance; + + THttpCacheMap _List; + + std::string _IndexFilename; + bool _Initialized; + size_t _MaxObjects; + }; +} +#endif diff --git a/code/nel/include/nel/gui/http_hsts.h b/code/nel/include/nel/gui/http_hsts.h new file mode 100644 index 000000000..2693461cd --- /dev/null +++ b/code/nel/include/nel/gui/http_hsts.h @@ -0,0 +1,73 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_HTTP_HSTS_H +#define CL_HTTP_HSTS_H + +#include "nel/misc/types_nl.h" + +namespace NLGUI +{ + // ******************************************************************************** + struct SHSTSObject + { + public: + SHSTSObject(uint64 expires = 0, bool includeSubDomains = false) + : Expires(expires) + , IncludeSubDomains(includeSubDomains) + { } + + uint64 Expires; + bool IncludeSubDomains; + }; + + /** + * Keeping track of HSTS header + * \author Meelis Mägi (nimetu) + * \date 2017 + */ + class CStrictTransportSecurity + { + public: + typedef std::map THSTSObject; + + static CStrictTransportSecurity* getInstance(); + static void release(); + + public: + bool isSecureHost(const std::string &domain) const; + + // ************************************************************************ + void init(const std::string& fname); + void save(); + + void erase(const std::string &domain); + void set(const std::string &domain, uint64 expires, bool includeSubDomains); + bool get(const std::string &domain, SHSTSObject &hsts) const; + void setFromHeader(const std::string &domain, const std::string &header); + + void serial(NLMISC::IStream& f); + private: + static CStrictTransportSecurity* instance; + + ~CStrictTransportSecurity(); + + std::string _Filename; + THSTSObject _Domains; + }; + +} +#endif diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index 5177e322a..1d84f4a4f 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -104,6 +104,7 @@ namespace NLGUI _XReal = _YReal = _WReal = _HReal = 0; _X = _Y = _W = _H = 0; //_Snap = 1; + _MarginLeft = 0; _PosRef = Hotspot_BL; _ParentPosRef = Hotspot_BL; @@ -188,6 +189,9 @@ namespace NLGUI sint32 getH() const { return (_Active?_H:0); } sint32 getH(bool bTestActive) const { return (bTestActive?(_Active?_H:0):_H); } + void setMarginLeft(sint32 m) { _MarginLeft = m; } + sint32 getMarginLeft() const { return _MarginLeft; } + /** * Get the max width used by the window. * @@ -582,6 +586,8 @@ namespace NLGUI sint32 _W; sint32 _H; + sint32 _MarginLeft; + //sint32 _Snap; // position references e.g. : _PosRef=BL, _ParentPosref=MM : the bottom left corner of the element diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 0a2d107fb..bfc951ce2 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -208,7 +208,7 @@ namespace NLGUI CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, const std::pair *templateParams, uint numParams, bool updateLinks = true); CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, std::vector > &templateParams, bool updateLinks = true) { - if (templateParams.size() > 0) + if (!templateParams.empty()) return createGroupInstance(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks); else return createGroupInstance(templateName, parentID, NULL, 0, updateLinks); @@ -222,7 +222,7 @@ namespace NLGUI CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, const std::pair *templateParams, uint numParams, bool updateLinks /* = true */); CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, std::vector > &templateParams, bool updateLinks = true) { - if (templateParams.size() > 0) + if (!templateParams.empty()) return createUIElement(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks); else return createUIElement(templateName, parentID, NULL, 0, updateLinks); diff --git a/code/nel/include/nel/gui/interface_property.h b/code/nel/include/nel/gui/interface_property.h index 4ed6e701e..b506ec7a9 100644 --- a/code/nel/include/nel/gui/interface_property.h +++ b/code/nel/include/nel/gui/interface_property.h @@ -72,8 +72,8 @@ namespace NLGUI bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL ); /// float operations - void setDouble (double value) {setSInt64((sint64&) value);} - double getDouble () const {sint64 i = getSInt64(); return (double &) i; } + void setDouble(double value); + double getDouble() const; void readDouble (const char* value, const std::string& id); /// sint32 operations diff --git a/code/nel/include/nel/gui/libwww.h b/code/nel/include/nel/gui/libwww.h index 22eba2f02..0825779f2 100644 --- a/code/nel/include/nel/gui/libwww.h +++ b/code/nel/include/nel/gui/libwww.h @@ -149,6 +149,8 @@ namespace NLGUI HTML_ATTR(IMG,USEMAP), HTML_ATTR(IMG,VSPACE), HTML_ATTR(IMG,WIDTH), + // not sorted to keep enum values + HTML_ATTR(IMG,DATA_OVER_SRC), }; enum diff --git a/code/nel/include/nel/gui/lua_helper.h b/code/nel/include/nel/gui/lua_helper.h index 50896b30c..7388c729d 100644 --- a/code/nel/include/nel/gui/lua_helper.h +++ b/code/nel/include/nel/gui/lua_helper.h @@ -90,7 +90,7 @@ namespace NLGUI virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());} }; - // A parse error occured + // A parse error occurred class ELuaParseError : public ELuaError { public: @@ -117,7 +117,7 @@ namespace NLGUI std::string _Reason; }; - // A execution error occured + // A execution error occurred class ELuaExecuteError : public ELuaError { public: @@ -128,7 +128,7 @@ namespace NLGUI virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());} }; - // A bad cast occured when using lua_checkcast + // A bad cast occurred when using lua_checkcast class ELuaBadCast : public ELuaError { public: diff --git a/code/nel/include/nel/gui/view_link.h b/code/nel/include/nel/gui/view_link.h index 1cc40a883..0fbca1065 100644 --- a/code/nel/include/nel/gui/view_link.h +++ b/code/nel/include/nel/gui/view_link.h @@ -50,10 +50,21 @@ namespace NLGUI void setHTMLView( CGroupHTML *html); bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col); + void setActionOnLeftClick(const std::string &actionHandler) { _AHOnLeftClick = actionHandler; }; + void setParamsOnLeftClick(const std::string &actionParams) { _AHOnLeftClickParams = actionParams; }; + + const std::string &getActionOnLeftClick() const { return _AHOnLeftClick; } + const std::string &getParamsOnLeftClick() const { return _AHOnLeftClickParams; } protected: // The main HTML group CGroupHTML *HTML; + + // Left mouse click action + // Don't use CStringShared as URLs change past values would be permanently remembered. + std::string _AHOnLeftClick; + std::string _AHOnLeftClickParams; + }; } diff --git a/code/nel/include/nel/gui/view_pointer_base.h b/code/nel/include/nel/gui/view_pointer_base.h index e772d934f..5468ba6d5 100644 --- a/code/nel/include/nel/gui/view_pointer_base.h +++ b/code/nel/include/nel/gui/view_pointer_base.h @@ -38,14 +38,17 @@ namespace NLGUI void resetPointerPos (); void setPointerDown (bool pd); + void setPointerMiddleDown (bool pd); + void setPointerRightDown (bool pd); void setPointerDownString (const std::string &s); void getPointerPos (sint32 &x, sint32 &y); void getPointerDispPos (sint32 &x, sint32 &y); void getPointerOldPos (sint32 &x, sint32 &y); - void getPointerDownPos (sint32 &x, sint32 &y); - bool getPointerDown (); + bool getPointerDown (sint32 &x, sint32 &y); + bool getPointerMiddleDown (sint32 &x, sint32 &y); + bool getPointerRightDown (sint32 &x, sint32 &y); std::string getPointerDownString (); bool getPointerDrag (); @@ -70,6 +73,12 @@ namespace NLGUI bool _PointerDown; // Is the pointer down ? sint32 _PointerDownX; // Pointer down position sint32 _PointerDownY; + bool _PointerMiddleDown; // Is the middle pointer down ? + sint32 _PointerMiddleDownX; // Pointer middle down position + sint32 _PointerMiddleDownY; + bool _PointerRightDown; // Is the right pointer down ? + sint32 _PointerRightDownX; // Pointer right down position + sint32 _PointerRightDownY; std::string _PointerDownString; // What is under the pointer at the down position bool _PointerDrag; // Is the pointer down and we have moved ? bool _PointerVisible; // Is the pointer visible or hidden ? diff --git a/code/nel/include/nel/gui/view_text.h b/code/nel/include/nel/gui/view_text.h index e0603895c..e5c5d7e10 100644 --- a/code/nel/include/nel/gui/view_text.h +++ b/code/nel/include/nel/gui/view_text.h @@ -95,7 +95,7 @@ namespace NLGUI void setMultiLineSpace (sint nMultiLineSpace); void setMultiLineMaxWOnly (bool state); void setMultiLineClipEndSpace (bool state); // use it for multiline edit box for instance - void setFirstLineX (uint firstLineX); + void setFirstLineX (sint firstLineX); void setMultiMaxLine(uint l) { _MultiMaxLine = l; } void setMultiMinLine(uint l) { _MultiMinLine = l; } @@ -404,7 +404,7 @@ namespace NLGUI uint _TextSelectionEnd; // First line X coordinate - uint _FirstLineX; + sint _FirstLineX; /// Dynamic tooltips std::vector _Tooltips; diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 827e35224..68576ce0f 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -503,7 +503,7 @@ namespace NLGUI const CEventDescriptorKey& getLastKeyEvent() const{ return lastKeyEvent; } - IParser* getParser() const{ return parser; } + IParser* getParser() const{ return _Parser; } /// Retrieves the Id of the currently selected widgets void getEditorSelection( std::vector< std::string > &selection ); @@ -542,7 +542,7 @@ namespace NLGUI CWidgetManager(); ~CWidgetManager(); - IParser *parser; + IParser *_Parser; static CWidgetManager *instance; std::vector< SMasterGroup > _MasterGroups; diff --git a/code/nel/include/nel/ligo/ligo_config.h b/code/nel/include/nel/ligo/ligo_config.h index 8e2c38e25..092f6caba 100644 --- a/code/nel/include/nel/ligo/ligo_config.h +++ b/code/nel/include/nel/ligo/ligo_config.h @@ -49,13 +49,13 @@ public: * This file will try to open the file ligo class description file (XML) using the LigoClass as file name. * It will try first to load directly the file and then to lookup the file in NLMISC::CPath. */ - bool readConfigFile (const char *fileName, bool parsePrimitiveComboContent); + bool readConfigFile (const std::string &fileName, bool parsePrimitiveComboContent); /** * This file will read the file ligo class description file (XML) using the LigoClass as file name. * It will try first to load directly the file and then to lookup the file in NLMISC::CPath. */ - bool readPrimitiveClass (const char *fileName, bool parsePrimitiveComboContent); + bool readPrimitiveClass (const std::string &fileName, bool parsePrimitiveComboContent); bool reloadIndexFile(const std::string &indexFileName = std::string()); @@ -100,14 +100,14 @@ public: /// Build a standard human readable alias string std::string aliasToString(uint32 fullAlias); /// Read a standard human readable alias string - uint32 aliasFromString(std::string fullAlias); + uint32 aliasFromString(const std::string &fullAlias); // Get a primitive class const CPrimitiveClass *getPrimitiveClass (const NLLIGO::IPrimitive &primitive) const; // Get a primitive class - const CPrimitiveClass *getPrimitiveClass (const char *className) const; + const CPrimitiveClass *getPrimitiveClass (const std::string &className) const; // Get the primitive color NLMISC::CRGBA getPrimitiveColor (const NLLIGO::IPrimitive &primitive); @@ -134,10 +134,10 @@ public: bool canBeRoot (const NLLIGO::IPrimitive &primitive); // Read a property from an XML file - bool getPropertyString (std::string &result, const char *filename, xmlNodePtr xmlNode, const char *propName); + bool getPropertyString (std::string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &propName); // Output error message - void syntaxError (const char *filename, xmlNodePtr xmlNode, const char *format, ...); + void syntaxError (const std::string &filename, xmlNodePtr xmlNode, const char *format, ...); virtual void errorMessage (const char *format, ... ); // Access to the config string @@ -157,7 +157,7 @@ public: private: // Init primitive class manager - bool initPrimitiveClass (const char *filename); + bool initPrimitiveClass (const std::string &ilename); // The primitive class manager std::map _PrimitiveClasses; diff --git a/code/nel/src/ligo/ligo_error.h b/code/nel/include/nel/ligo/ligo_error.h similarity index 100% rename from code/nel/src/ligo/ligo_error.h rename to code/nel/include/nel/ligo/ligo_error.h diff --git a/code/nel/src/ligo/ligo_material.h b/code/nel/include/nel/ligo/ligo_material.h similarity index 97% rename from code/nel/src/ligo/ligo_material.h rename to code/nel/include/nel/ligo/ligo_material.h index 16b236cb7..986a020f1 100644 --- a/code/nel/src/ligo/ligo_material.h +++ b/code/nel/include/nel/ligo/ligo_material.h @@ -18,7 +18,7 @@ #define NL_MATERIAL_LIGO_H #include "nel/misc/types_nl.h" -#include "zone_template.h" +#include "nel/ligo/zone_template.h" // NeL include //#include "3d/zone.h" diff --git a/code/nel/include/nel/ligo/primitive.h b/code/nel/include/nel/ligo/primitive.h index c5aa26b02..d964ac125 100644 --- a/code/nel/include/nel/ligo/primitive.h +++ b/code/nel/include/nel/ligo/primitive.h @@ -83,9 +83,8 @@ class CPropertyString : public IProperty { public: CPropertyString () {} - CPropertyString (const char *str); CPropertyString (const std::string &str); - CPropertyString (const char *str, bool _default); + CPropertyString (const std::string &str, bool _default); virtual ~CPropertyString () {} std::string String; @@ -287,42 +286,42 @@ public: * If the property already exist, the method does nothing and returns false. * The pointer will be deleted by the primitive using the ::delete operator. **/ - bool addPropertyByName (const char *property_name, IProperty *result); + bool addPropertyByName (const std::string &property_name, IProperty *result); /** * Get a property with its name **/ - bool getPropertyByName (const char *property_name, const IProperty *&result) const; + bool getPropertyByName (const std::string &property_name, const IProperty *&result) const; /** * Get a property with its name **/ - bool getPropertyByName (const char *property_name, IProperty *&result) const; + bool getPropertyByName (const std::string &property_name, IProperty *&result) const; /** * Get a string property with its name. Return false if the property is not found or is not a string property. **/ - bool getPropertyByName (const char *property_name, std::string *&result) const; + bool getPropertyByName (const std::string &property_name, std::string *&result) const; /** * Get a string array property with its name. Return false if the property is not found or is not a string array property. **/ - bool getPropertyByName (const char *property_name, std::vector *&result) const; + bool getPropertyByName (const std::string &property_name, std::vector *&result) const; /** * Get a string property with its name. Return false if the property is not found or is not a string property. **/ - bool getPropertyByName (const char *property_name, std::string &result) const; + bool getPropertyByName (const std::string &property_name, std::string &result) const; /** * Get a string array property with its name. Return false if the property is not found or is not a string array property. **/ - bool getPropertyByName (const char *property_name, const std::vector *&result) const; + bool getPropertyByName (const std::string &property_name, const std::vector *&result) const; /** * Get a color property with its name. Return false if the property is not found or is not a string array property. **/ - bool getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const; + bool getPropertyByName (const std::string &property_name, NLMISC::CRGBA &result) const; /** * Remove a property @@ -333,7 +332,7 @@ public: /** * Remove a property by its name **/ - bool removePropertyByName (const char *property_name); + bool removePropertyByName (const std::string &property_name); /** * Remove all the properties @@ -347,10 +346,10 @@ public: void initDefaultValues (CLigoConfig &config); // Read the primitive, calls initDefaultValue (CLigoConfig &config) - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &property_name, uint version, CLigoConfig &config); // Write the primitive - virtual void write (xmlNodePtr xmlNode, const char *filename) const; + virtual void write (xmlNodePtr xmlNode, const std::string &property_name) const; // Get the vertices virtual uint getNumVector () const = 0; @@ -435,7 +434,7 @@ protected: virtual CPrimVector *getPrimVector (); // Read the primitive - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); // \name From IPrimitive virtual IPrimitive *copy () const; @@ -474,10 +473,10 @@ protected: virtual CPrimVector *getPrimVector (); // Read the primitive - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); // Write the primitive - virtual void write (xmlNodePtr xmlNode, const char *filename) const; + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; // \name From IPrimitive virtual IPrimitive *copy () const; @@ -509,10 +508,10 @@ protected: virtual CPrimVector *getPrimVector (); // Read the primitive - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); // Write the primitive - virtual void write (xmlNodePtr xmlNode, const char *filename) const; + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; // \name From IPrimitive virtual IPrimitive *copy () const; @@ -568,10 +567,10 @@ protected: virtual CPrimVector *getPrimVector (); // Read the primitive - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); // Write the primitive - virtual void write (xmlNodePtr xmlNode, const char *filename) const; + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; // \name From IPrimitive virtual IPrimitive *copy () const; @@ -632,9 +631,9 @@ public: uint32 getFullAlias() const; // Read the primitive - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); // Write the primitive - virtual void write (xmlNodePtr xmlNode, const char *filename) const; + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; // Create a copy of this primitive virtual IPrimitive *copy () const; // serial for binary save @@ -686,13 +685,13 @@ public: void convert (const CPrimRegion ®ion); // Read the primitive - bool read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &config); + bool read (xmlNodePtr xmlNode, const std::string &filename, CLigoConfig &config); // Write the primitive - void write (xmlDocPtr xmlNode, const char *filename) const; + void write (xmlDocPtr xmlNode, const std::string &filename) const; // Write the primitive - void write (xmlNodePtr root, const char *filename) const; + void write (xmlNodePtr root, const std::string &filename) const; // serial the primitive. Used for binary files. void serial(NLMISC::IStream &f); diff --git a/code/nel/src/ligo/transition.h b/code/nel/include/nel/ligo/transition.h similarity index 100% rename from code/nel/src/ligo/transition.h rename to code/nel/include/nel/ligo/transition.h diff --git a/code/nel/src/ligo/zone_edge.h b/code/nel/include/nel/ligo/zone_edge.h similarity index 100% rename from code/nel/src/ligo/zone_edge.h rename to code/nel/include/nel/ligo/zone_edge.h diff --git a/code/nel/src/ligo/zone_template.h b/code/nel/include/nel/ligo/zone_template.h similarity index 100% rename from code/nel/src/ligo/zone_template.h rename to code/nel/include/nel/ligo/zone_template.h diff --git a/code/nel/include/nel/logic/logic_condition.h b/code/nel/include/nel/logic/logic_condition.h index bb2af30ce..30c9d7c08 100644 --- a/code/nel/include/nel/logic/logic_condition.h +++ b/code/nel/include/nel/logic/logic_condition.h @@ -79,7 +79,7 @@ public: /** * serial */ - //void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); void write (xmlNodePtr node) const; void read (xmlNodePtr node); @@ -160,7 +160,7 @@ public: /** * serial */ - //void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); void write (xmlNodePtr node) const; void read (xmlNodePtr node); @@ -239,7 +239,7 @@ public: /** * serial */ - //void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); /** * Destructor @@ -323,7 +323,7 @@ public: /** * serial */ - //void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); void write (xmlNodePtr node) const; void read (xmlNodePtr node); diff --git a/code/nel/include/nel/logic/logic_event.h b/code/nel/include/nel/logic/logic_event.h index 66c125260..9f15d2f34 100644 --- a/code/nel/include/nel/logic/logic_event.h +++ b/code/nel/include/nel/logic/logic_event.h @@ -79,7 +79,7 @@ public: /** * serial */ - //void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); void write (xmlNodePtr node, const char *subName = "") const; void read (xmlNodePtr node, const char *subName = ""); @@ -122,7 +122,7 @@ public: /** * serial */ - //void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); void write (xmlNodePtr node) const; void read (xmlNodePtr node); @@ -181,7 +181,7 @@ public: /** * serial */ - //void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); void write (xmlNodePtr node) const; void read (xmlNodePtr node); diff --git a/code/nel/include/nel/logic/logic_state.h b/code/nel/include/nel/logic/logic_state.h index dd9678f13..75e8572ac 100644 --- a/code/nel/include/nel/logic/logic_state.h +++ b/code/nel/include/nel/logic/logic_state.h @@ -149,7 +149,7 @@ public: /** * serial */ - //void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); void write (xmlNodePtr node) const; void read (xmlNodePtr node); diff --git a/code/nel/include/nel/logic/logic_state_machine.h b/code/nel/include/nel/logic/logic_state_machine.h index f976ad405..7e87890b7 100644 --- a/code/nel/include/nel/logic/logic_state_machine.h +++ b/code/nel/include/nel/logic/logic_state_machine.h @@ -182,7 +182,7 @@ public: /** * serial */ - //void serial( NLMISC::IStream &f ) throw(NLMISC::EStream); + //void serial( NLMISC::IStream &f ); /** * Display the variables diff --git a/code/nel/include/nel/logic/logic_variable.h b/code/nel/include/nel/logic/logic_variable.h index 8ccc0923e..f64a9e775 100644 --- a/code/nel/include/nel/logic/logic_variable.h +++ b/code/nel/include/nel/logic/logic_variable.h @@ -104,7 +104,7 @@ public: /** * serial */ - //virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + //virtual void serial(NLMISC::IStream &f); virtual void write (xmlNodePtr node) const; virtual void read (xmlNodePtr node); @@ -186,7 +186,7 @@ public: /** * serial */ - //void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + //void serial(NLMISC::IStream &f); virtual void write (xmlNodePtr node) const; virtual void read (xmlNodePtr node); diff --git a/code/nel/include/nel/misc/algo.h b/code/nel/include/nel/misc/algo.h index 72d9ae3ae..50493538f 100644 --- a/code/nel/include/nel/misc/algo.h +++ b/code/nel/include/nel/misc/algo.h @@ -211,6 +211,14 @@ bool strFindReplace(T &str, const char *strFind, const U &strReplace) return strFindReplace(str, tempStr, strReplace); } +template +T strFindReplaceAll(const T &str, const T &search, const T &replace) +{ + T ret = str; + while (strFindReplace(ret, search, replace)); + return ret; +} + // set flags in a bit set template inline void setFlags(T &dest, U mask, bool on) diff --git a/code/nel/include/nel/misc/app_context.h b/code/nel/include/nel/misc/app_context.h index df9165baf..bf73ddb83 100644 --- a/code/nel/include/nel/misc/app_context.h +++ b/code/nel/include/nel/misc/app_context.h @@ -108,6 +108,7 @@ namespace NLMISC { public: CApplicationContext(); + virtual ~CApplicationContext(); virtual void *getSingletonPointer(const std::string &singletonName); virtual void setSingletonPointer(const std::string &singletonName, void *ptr); diff --git a/code/nel/include/nel/misc/array_2d.h b/code/nel/include/nel/misc/array_2d.h index e5492986d..3c65ffa4c 100644 --- a/code/nel/include/nel/misc/array_2d.h +++ b/code/nel/include/nel/misc/array_2d.h @@ -132,7 +132,7 @@ public: // See which parts of array will be discarded if the array is displaced by the given offset void getDiscardRects(sint moveOffsetX, sint moveOffsetY, std::vector &discardedRects); // - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); private: TArrayContainer _Array; uint _Width; @@ -157,7 +157,7 @@ void CArray2D::clear() //********************************************************************************* template -void CArray2D::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CArray2D::serial(NLMISC::IStream &f) { f.serialCont(_Array); uint32 width = _Width; diff --git a/code/nel/include/nel/misc/big_file.h b/code/nel/include/nel/misc/big_file.h index 14851d69e..95fc09b41 100644 --- a/code/nel/include/nel/misc/big_file.h +++ b/code/nel/include/nel/misc/big_file.h @@ -112,7 +112,8 @@ public: // A BNP structure struct BNP { - BNP() : FileNames(NULL), ThreadFileId(0), CacheFileOnOpen(false), AlwaysOpened(false), InternalUse(false), OffsetFromBeginning(0) { } + BNP(); + ~BNP(); // FileName of the BNP. important to open it in getFile() (for other threads or if not always opened). std::string BigFileName; @@ -163,6 +164,7 @@ private: { public: CThreadFileArray(); + ~CThreadFileArray(); // Allocate a FileId for a BNP. uint32 allocate(); diff --git a/code/nel/include/nel/misc/bitmap.h b/code/nel/include/nel/misc/bitmap.h index 0466cd673..7e5994152 100644 --- a/code/nel/include/nel/misc/bitmap.h +++ b/code/nel/include/nel/misc/bitmap.h @@ -375,6 +375,12 @@ public: void makeOpaque(); + /** + * Make fully transparent pixels (alpha 0) black. + */ + void makeTransparentPixelsBlack(); + + /** * Return if the bitmap has uniform alpha values for all pixels. * \param alpha return the uniform value if return is true @@ -609,7 +615,7 @@ public: /** * Extended version of blit. The destinaion of the blit is 'this' bitmap * Source and dest rect are clamped as necessary. - * For now, only RGBA is uspported (an asertion occurs otherwise) + * For now, only RGBA is supported (an asertion occurs otherwise) * mipmap are not updated. * IMPORTANT : copy to self is not handled correctly */ @@ -630,11 +636,17 @@ public: - /** Get the pixel at the given coorrdinate. + /** Get the pixel at the given coordinate. * Works in RGBA and DXTC modes. * Outside of the bitmap it returns Black (or if mipmap is not found) */ CRGBA getPixelColor(sint x, sint y, uint32 numMipMap = 0) const; + + /** Set the pixel at the given coordinate. + * Works in RGBA mode only. + */ + void setPixelColor(sint x, sint y, CRGBA c, uint32 numMipMap = 0); + /** * Horizontal flip (all the columns are flipped) * Works only with RGBA, and DXTC formats (only if w/h is a power of 2) diff --git a/code/nel/include/nel/misc/block_memory.h b/code/nel/include/nel/misc/block_memory.h index 65fb36c46..912f92d1c 100644 --- a/code/nel/include/nel/misc/block_memory.h +++ b/code/nel/include/nel/misc/block_memory.h @@ -132,7 +132,7 @@ public: } /// delete an element allocated with this manager. dtor is called. NULL is tested. - void free(T* ptr) + void freeBlock(T* ptr) { if(!ptr) return; diff --git a/code/nel/include/nel/misc/cdb_leaf.h b/code/nel/include/nel/misc/cdb_leaf.h index e3df6f8b3..c80ec903a 100644 --- a/code/nel/include/nel/misc/cdb_leaf.h +++ b/code/nel/include/nel/misc/cdb_leaf.h @@ -40,20 +40,20 @@ public: /// Return the value of the property. - inline sint64 getValue64() { return _Property; } + inline sint64 getValue64() const { return _Property; } /// Set the value of the property (set '_Changed' flag with 'true'). void setValue64 (sint64 prop); - inline sint32 getValue32() { return *((sint32*)&_Property); } + inline sint32 getValue32() const { return (sint32)(_Property & 0xffffffff); } void setValue32 (sint32 prop); - inline sint16 getValue16() { return *((sint16*)&_Property); } + inline sint16 getValue16() const { return (sint16)(_Property & 0xffff); } void setValue16 (sint16 prop); - inline sint8 getValue8() { return *((sint8*)&_Property); } + inline sint8 getValue8() const { return (sint8)(_Property & 0xff); } void setValue8 (sint8 prop); - inline bool getValueBool() { return (_Property!=(sint64)0 ); } + inline bool getValueBool() const { return (_Property!=(sint64)0 ); } void setValueBool (bool prop); - inline CRGBA getValueRGBA() + inline CRGBA getValueRGBA() const { CRGBA col; col.R = (uint8)(_Property&0xff); @@ -65,11 +65,11 @@ public: void setValueRGBA (const CRGBA &color); /// Return the value of the property before the database change - inline sint64 getOldValue64() { return _oldProperty; } - inline sint32 getOldValue32() { return *((sint32*)&_oldProperty); } - inline sint16 getOldValue16() { return *((sint16*)&_oldProperty); } - inline sint8 getOldValue8() { return *((sint8*)&_oldProperty); } - inline bool getOldValueBool() { return (_oldProperty!=(sint64)0 ); } + inline sint64 getOldValue64() const { return _oldProperty; } + inline sint32 getOldValue32() const { return (sint32)(_oldProperty & 0xffffffff); } + inline sint16 getOldValue16() const { return (sint16)(_oldProperty & 0xffff); } + inline sint8 getOldValue8() const { return (sint8)(_oldProperty & 0xff); } + inline bool getOldValueBool() const { return (_oldProperty!=(sint64)0 ); } /// Return the type of the property. diff --git a/code/nel/include/nel/misc/co_task.h b/code/nel/include/nel/misc/co_task.h index bfd8f9ef0..80542834e 100644 --- a/code/nel/include/nel/misc/co_task.h +++ b/code/nel/include/nel/misc/co_task.h @@ -201,7 +201,9 @@ namespace NLMISC */ void sleep(uint milliseconds); - + /** Release internal instance. + */ + static void releaseInstance(); }; diff --git a/code/nel/include/nel/misc/common.h b/code/nel/include/nel/misc/common.h index 4ddc88076..eb70fce9e 100644 --- a/code/nel/include/nel/misc/common.h +++ b/code/nel/include/nel/misc/common.h @@ -233,6 +233,26 @@ char toLower ( const char ch ); // convert only one character std::string toUpper ( const std::string &str); void toUpper ( char *str); + +/** + * Convert to an hexadecimal std::string + */ +std::string toHexa(const uint8 &b); +std::string toHexa(const uint8 *data, uint size); +std::string toHexa(const std::string &str); +std::string toHexa(const char *str); + +/** +* Convert from an hexadecimal std::string +*/ +bool fromHexa(const std::string &hexa, uint8 &b); +bool fromHexa(const std::string &hexa, uint8 *data); +bool fromHexa(const std::string &hexa, std::string &str); +bool fromHexa(const char *hexa, uint8 &b); +bool fromHexa(const char *hexa, uint8 *data); +bool fromHexa(const char *hexa, std::string &str); +bool fromHexa(const char hexa, uint8 &b); + // Remove all the characters <= 32 (tab, space, new line, return, vertical tab etc..) at the beginning and at the end of a string template T trim (const T &str) { @@ -286,6 +306,15 @@ inline sint nlstricmp(const char *lhs, const std::string &rhs) { return stricmp( #define wideToUtf8(str) (ucstring((ucchar*)str).toUtf8()) #define utf8ToWide(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str()) +// macros helper to convert UTF-8 std::string and TCHAR* +#ifdef _UNICODE +#define tStrToUtf8(str) (ucstring((ucchar*)(LPCWSTR)str).toUtf8()) +#define utf8ToTStr(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str()) +#else +#define tStrToUtf8(str) (std::string((LPCSTR)str)) +#define utf8ToTStr(str) (str.c_str()) +#endif + // wrapper for fopen to be able to open files with an UTF-8 filename FILE* nlfopen(const std::string &filename, const std::string &mode); @@ -385,6 +414,9 @@ std::string expandEnvironmentVariables(const std::string &s); bool explodeArguments(const std::string &str, std::vector &args); std::string joinArguments(const std::vector &args); +/// Escape an argument to not evaluate environment variables or special cases +std::string escapeArgument(const std::string &arg); + /// This function kills a program using his pid (on unix, it uses the kill() POSIX function) bool killProgram(uint32 pid); @@ -469,6 +501,22 @@ template void explode (const T &src, const T &sep, std::vector &res while(pos != std::string::npos); } +/** Join a string (or ucstring) from a vector of strings with *sep* as separator. If sep can be more than 1 char, in this case, +* we find the entire sep to separator (it s not a set of possible separator) +*/ +template void join(const std::vector& strings, const U& separator, T &res) +{ + res.clear(); + + for (uint i = 0, len = strings.size(); i> with all NeL simple types (except for ucchar and ucstring) @@ -665,10 +713,10 @@ inline int nlisprint(int c) #endif // Open an url in a browser -bool openURL (const char *url); +bool openURL (const std::string &url); // Open a document -bool openDoc (const char *document); +bool openDoc (const std::string &document); // AntiBug method that return an epsilon if x==0, else x inline float favoid0(float x) @@ -689,6 +737,25 @@ inline T iavoid0(T x) return x; } +// Helper to convert in memory between types of different sizes +union C64BitsParts +{ + // unsigned + uint64 u64[1]; + uint32 u32[2]; + uint16 u16[4]; + uint8 u8[8]; + + // signed + sint64 i64[1]; + sint32 i32[2]; + sint16 i16[4]; + sint8 i8[8]; + + // floats + double d[1]; + float f[2]; +}; } // NLMISC diff --git a/code/nel/include/nel/misc/contiguous_block_allocator.h b/code/nel/include/nel/misc/contiguous_block_allocator.h index 7a15d296d..43d6fac09 100644 --- a/code/nel/include/nel/misc/contiguous_block_allocator.h +++ b/code/nel/include/nel/misc/contiguous_block_allocator.h @@ -55,7 +55,7 @@ public: // allocated a block of n bytes void *alloc(uint numBytes); // deallocate a block - void free(void *block, uint numBytes); + void freeBlock(void *block, uint numBytes); // compute the total number of bytes allocated since init // NB : freed block are not subtracted from that total !! uint getNumAllocatedBytes() const { return _NumAllocatedBytes; } diff --git a/code/nel/include/nel/misc/debug.h b/code/nel/include/nel/misc/debug.h index 54e22880d..d01c85f1c 100644 --- a/code/nel/include/nel/misc/debug.h +++ b/code/nel/include/nel/misc/debug.h @@ -151,8 +151,8 @@ void setCrashAlreadyReported(bool state); * Note 2 : To show a warning under GCC, use #warning "Your warning here", * see nel/net/net_manager.h for an example on how to use these correctly. */ -#define NL_LOC_MSG __FILE__"("NL_MACRO_TO_STR(__LINE__)") : Message: " -#define NL_LOC_WRN __FILE__"("NL_MACRO_TO_STR(__LINE__)") : Warning Msg: " +#define NL_LOC_MSG __FILE__ "(" NL_MACRO_TO_STR(__LINE__) ") : Message: " +#define NL_LOC_WRN __FILE__ "(" NL_MACRO_TO_STR(__LINE__) ") : Warning Msg: " /** diff --git a/code/nel/include/nel/misc/diff_tool.h b/code/nel/include/nel/misc/diff_tool.h index 75a3f181b..e122137cf 100644 --- a/code/nel/include/nel/misc/diff_tool.h +++ b/code/nel/include/nel/misc/diff_tool.h @@ -21,7 +21,7 @@ namespace STRING_MANAGER { - const ucstring nl("\r\n"); + const ucstring nl("\n"); struct TStringInfo diff --git a/code/nel/include/nel/misc/entity_id.h b/code/nel/include/nel/misc/entity_id.h index 46561a512..8999b170a 100644 --- a/code/nel/include/nel/misc/entity_id.h +++ b/code/nel/include/nel/misc/entity_id.h @@ -450,8 +450,8 @@ public: } - void serial (NLMISC::IStream &f) throw (NLMISC::EStream) -// virtual void serial (NLMISC::IStream &f) throw (NLMISC::EStream) + void serial (NLMISC::IStream &f) +// virtual void serial (NLMISC::IStream &f) { if (f.isReading ()) { diff --git a/code/nel/include/nel/misc/fixed_size_allocator.h b/code/nel/include/nel/misc/fixed_size_allocator.h index 079c54bc0..643217f5d 100644 --- a/code/nel/include/nel/misc/fixed_size_allocator.h +++ b/code/nel/include/nel/misc/fixed_size_allocator.h @@ -45,7 +45,7 @@ public: /// alloc a block void *alloc(); /// destroy and dealloc a block - void free(void *block); + void freeBlock(void *block); // uint getNumBytesPerBlock() const { return _NumBytesPerBlock; } uint getNumBlockPerChunk() const { return _NumBlockPerChunk; } @@ -53,7 +53,7 @@ public: uint getNumAllocatedBlocks() const { return _NumAlloc; } private: class CChunk; - + class NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT) CNode { public: diff --git a/code/nel/include/nel/misc/heap_memory.h b/code/nel/include/nel/misc/heap_memory.h index cd1a4ab2b..0aeb3aec5 100644 --- a/code/nel/include/nel/misc/heap_memory.h +++ b/code/nel/include/nel/misc/heap_memory.h @@ -65,7 +65,7 @@ public: */ void *allocate(uint size); /// free a block allocated with alloate(). no-op if NULL. nlstop() if don't find this block. - void free(void *ptr); + void freeBlock(void *ptr); // ********************* diff --git a/code/nel/include/nel/misc/i18n.h b/code/nel/include/nel/misc/i18n.h index 5f270a490..d50313357 100644 --- a/code/nel/include/nel/misc/i18n.h +++ b/code/nel/include/nel/misc/i18n.h @@ -144,12 +144,10 @@ public: * 16 bits encoding can be recognized by the official header : * FF, FE, witch can be reversed if the data are MSB first. * - * Optionally, you can force the reader to consider the file as - * UTF-8 encoded. * Optionally, you can ask the reader to interpret #include commands. */ static void readTextFile(const std::string &filename, - ucstring &result, bool forceUtf8 = false, + ucstring &result, bool fileLookup = true, bool preprocess = false, TLineFormat lineFmt = LINE_FMT_NO_CARE, @@ -162,11 +160,8 @@ public: * EF,BB, BF. * 16 bits encoding can be recognized by the official header : * FF, FE, witch can be reversed if the data are MSB first. - * - * Optionally, you can force the reader to consider the file as - * UTF-8 encoded. */ - static void readTextBuffer(uint8 *buffer, uint size, ucstring &result, bool forceUtf8 = false); + static void readTextBuffer(uint8 *buffer, uint size, ucstring &result); /** Remove any C style comment from the passed string. */ @@ -262,7 +257,7 @@ private: /// The internal read function, it does the real job of readTextFile static void _readTextFile(const std::string &filename, - ucstring &result, bool forceUtf8, + ucstring &result, bool fileLookup, bool preprocess, TLineFormat lineFmt, diff --git a/code/nel/include/nel/misc/i_xml.h b/code/nel/include/nel/misc/i_xml.h index b078eb7ee..75d4e9bde 100644 --- a/code/nel/include/nel/misc/i_xml.h +++ b/code/nel/include/nel/misc/i_xml.h @@ -110,6 +110,11 @@ public: */ bool init (IStream &stream); + /** Return the error string. + * if not empty, something wrong appends + */ + static std::string getErrorString(); + /** Release the resources used by the stream. */ void release (); @@ -120,11 +125,11 @@ public: /** Get the first child node pointer named childName. NULL if no node named childName. */ - static xmlNodePtr getFirstChildNode (xmlNodePtr parent, const char *childName); + static xmlNodePtr getFirstChildNode (xmlNodePtr parent, const std::string &childName); /** Get the next child node pointer name childName, brother of previous. NULL if no node named childName. */ - static xmlNodePtr getNextChildNode (xmlNodePtr last, const char *childName); + static xmlNodePtr getNextChildNode (xmlNodePtr last, const std::string &childName); /** Get the first child node pointer of type. NULL if no node of type. */ @@ -136,7 +141,7 @@ public: /** Count number of sub node named with a given name for a given node. */ - static uint countChildren (xmlNodePtr node, const char *childName); + static uint countChildren (xmlNodePtr node, const std::string &childName); /** Count number of sub node of type for a given node. */ @@ -147,22 +152,22 @@ public: * * Returns true and the result if the property has been found, else false. */ - static bool getPropertyString (std::string &result, xmlNodePtr node, const char *property); + static bool getPropertyString (std::string &result, xmlNodePtr node, const std::string &property); /** * Read an integer property - if the property is not found the default value is returned */ - static int getIntProperty(xmlNodePtr node, const char *property, int defaultValue); + static int getIntProperty(xmlNodePtr node, const std::string &property, int defaultValue); /** * Read a floating point property - if the property is not found the default value is returned */ - static double getFloatProperty(xmlNodePtr node, const char *property, float defaultValue); + static double getFloatProperty(xmlNodePtr node, const std::string &property, float defaultValue); /** * Read a string property - if the property is not found the default value is returned */ - static std::string getStringProperty(xmlNodePtr node, const char *property, const std::string& defaultValue); + static std::string getStringProperty(xmlNodePtr node, const std::string &property, const std::string& defaultValue); /** * Read the content of the node as a string @@ -171,6 +176,16 @@ public: */ static bool getContentString (std::string &result, xmlNodePtr node); + /** + * Init all structures used by libxml2, to only call once. + */ + static void initLibXml(); + + /** + * Release memory used by libxml2, to only call before exit. + */ + static void releaseLibXml(); + private: /// From IStream @@ -193,12 +208,12 @@ private: virtual void serialBuffer(uint8 *buf, uint len); virtual void serialBit(bool &bit); - virtual bool xmlPushBeginInternal (const char *nodeName); + virtual bool xmlPushBeginInternal (const std::string &nodeName); virtual bool xmlPushEndInternal (); virtual bool xmlPopInternal (); - virtual bool xmlSetAttribInternal (const char *attribName); + virtual bool xmlSetAttribInternal (const std::string &attribName); virtual bool xmlBreakLineInternal (); - virtual bool xmlCommentInternal (const char *comment); + virtual bool xmlCommentInternal (const std::string &comment); // Internal functions void serialSeparatedBufferIn ( std::string &value, bool checkSeparator = true ); @@ -229,13 +244,16 @@ private: uint _ContentStringIndex; // Error message - std::string _ErrorString; + static std::string _ErrorString; // Try binary mode bool _TryBinaryMode; // If not NULL, binary mode detected, use this stream in serials IStream *_BinaryStream; + + // LibXml has been initialized + static bool _LibXmlIntialized; }; diff --git a/code/nel/include/nel/misc/mouse_smoother.h b/code/nel/include/nel/misc/mouse_smoother.h index 86a75b7f1..18d741996 100644 --- a/code/nel/include/nel/misc/mouse_smoother.h +++ b/code/nel/include/nel/misc/mouse_smoother.h @@ -46,7 +46,7 @@ public: double getSamplingPeriod() const { return _SamplingPeriod; } // Reset smoother. The next returned position will be the exact position of mouse (no smoothing with previous position is done) void reset(); - // \return trueif no sampling has occured since last resetor construction + // \return true if no sampling has occurred since last resetor construction bool isReseted() const { return !_Init; } // Sample pos, and return smoothed position CVector2f samplePos(const CVector2f &wantedPos, double date); diff --git a/code/nel/include/nel/misc/o_xml.h b/code/nel/include/nel/misc/o_xml.h index 5bafacd60..80b60149d 100644 --- a/code/nel/include/nel/misc/o_xml.h +++ b/code/nel/include/nel/misc/o_xml.h @@ -80,7 +80,6 @@ class COXml : public IStream { friend int xmlOutputWriteCallbackForNeL ( void *context, const char *buffer, int len ); friend int xmlOutputCloseCallbackForNeL ( void *context ); - friend void xmlGenericErrorFuncWrite (void *ctx, const char *msg, ...); public: /** Stream ctor @@ -95,12 +94,12 @@ public: * \param version is the version to write in the XML header. Default is 1.0. * \return true if initialisation is successful, false if the stream passed is not an output stream. */ - bool init (IStream *stream, const char *version="1.0"); + bool init (IStream *stream, const std::string &version = "1.0"); /** Return the error string. * if not empty, something wrong appends */ - const char *getErrorString () const; + static std::string getErrorString (); /** Default dstor * @@ -120,7 +119,7 @@ public: /** Return true if the string is valid to be stored in a XML property without modification. */ - static bool isStringValidForProperties (const char *str); + static bool isStringValidForProperties (const std::string &str); private: @@ -144,15 +143,15 @@ private: virtual void serialBuffer(uint8 *buf, uint len); virtual void serialBit(bool &bit); - virtual bool xmlPushBeginInternal (const char *nodeName); + virtual bool xmlPushBeginInternal (const std::string &nodeName); virtual bool xmlPushEndInternal (); virtual bool xmlPopInternal (); - virtual bool xmlSetAttribInternal (const char *attribName); + virtual bool xmlSetAttribInternal (const std::string &attribName); virtual bool xmlBreakLineInternal (); - virtual bool xmlCommentInternal (const char *comment); + virtual bool xmlCommentInternal (const std::string &comment); // Internal functions - void serialSeparatedBufferOut( const char *value ); + void serialSeparatedBufferOut( const std::string &value ); inline void flushContentString (); // Push mode @@ -178,9 +177,6 @@ private: // Current content string std::string _ContentString; - - // Error message - std::string _ErrorString; }; diff --git a/code/nel/include/nel/misc/object_arena_allocator.h b/code/nel/include/nel/misc/object_arena_allocator.h index 6d318aca8..09216aada 100644 --- a/code/nel/include/nel/misc/object_arena_allocator.h +++ b/code/nel/include/nel/misc/object_arena_allocator.h @@ -49,7 +49,7 @@ public: */ void *alloc(uint size); // free an object that has previously been allocated with alloc. size should be remembered by the caller. - void free(void *); + void freeBlock(void *); // get the number of allocated objects uint getNumAllocatedBlocks() const; # ifdef NL_DEBUG @@ -82,7 +82,11 @@ private: // NL_USES_DEFAULT_ARENA_OBJECT_ALLOCATOR // for fast alloc # define NL_USES_DEFAULT_ARENA_OBJECT_ALLOCATOR \ void *operator new(size_t size) { return NLMISC::CObjectArenaAllocator::getDefaultAllocator().alloc((uint) size); }\ - void operator delete(void *block) { NLMISC::CObjectArenaAllocator::getDefaultAllocator().free(block); } + void *operator new(size_t size, int _BlockUse, char const* _FileName, int _LineNumber) { return NLMISC::CObjectArenaAllocator::getDefaultAllocator().alloc((uint) size); }\ + void *operator new(size_t size, char const* _FileName, int _LineNumber) { return NLMISC::CObjectArenaAllocator::getDefaultAllocator().alloc((uint) size); }\ + void operator delete(void *block) { NLMISC::CObjectArenaAllocator::getDefaultAllocator().freeBlock(block); }\ + void operator delete(void *block, int _BlockUse, char const* _FileName, int _LineNumber) { NLMISC::CObjectArenaAllocator::getDefaultAllocator().freeBlock(block); } \ + void operator delete(void *block, char const* _FileName, int _LineNumber) { NLMISC::CObjectArenaAllocator::getDefaultAllocator().freeBlock(block); } } diff --git a/code/nel/include/nel/misc/path.h b/code/nel/include/nel/misc/path.h index a16b03f15..f42acc91b 100644 --- a/code/nel/include/nel/misc/path.h +++ b/code/nel/include/nel/misc/path.h @@ -209,7 +209,7 @@ public: * \param relativePath is the path to make relative to basePath. * return true if relativePath as been done relative to basePath, false is relativePath has not been changed. */ - bool makePathRelative (const char *basePath, std::string &relativePath); + bool makePathRelative (const std::string &basePath, std::string &relativePath); /** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning. */ @@ -505,7 +505,7 @@ public: * \param relativePath is the path to make relative to basePath. * return true if relativePath as been done relative to basePath, false is relativePath has not been changed. */ - static bool makePathRelative (const char *basePath, std::string &relativePath); + static bool makePathRelative(const std::string &basePath, std::string &relativePath); /** Make path absolute * \param relativePath - The relative path diff --git a/code/nel/include/nel/misc/polygon.h b/code/nel/include/nel/misc/polygon.h index a0183d20d..08889c26d 100644 --- a/code/nel/include/nel/misc/polygon.h +++ b/code/nel/include/nel/misc/polygon.h @@ -66,7 +66,7 @@ public: float computeArea() const; /// Serial this polygon - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); /** * Convert a concave polygon into a list of convex polygons using a 2d projection. @@ -156,7 +156,7 @@ public: void getBestTriplet(uint &index0, uint &index1, uint &index2); /// Serial this polygon - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); typedef std::pair TRaster; typedef std::vector TRasterVect; diff --git a/code/nel/include/nel/misc/pool_memory.h b/code/nel/include/nel/misc/pool_memory.h index def4125dc..1bd3dbda9 100644 --- a/code/nel/include/nel/misc/pool_memory.h +++ b/code/nel/include/nel/misc/pool_memory.h @@ -90,7 +90,7 @@ public: /* * Free all the elements allocated since last free(). Memory is kept for next allocations. */ - void free () + void freeBlock () { typename std::list< std::vector >::iterator ite=_BlockList.begin(); while (ite!=_BlockList.end()) diff --git a/code/nel/include/nel/misc/resource_ptr.h b/code/nel/include/nel/misc/resource_ptr.h index 5773b7249..d11404f2c 100644 --- a/code/nel/include/nel/misc/resource_ptr.h +++ b/code/nel/include/nel/misc/resource_ptr.h @@ -108,7 +108,7 @@ template class CResourcePtr { private: - CRefCount::CPtrInfo *pinfo; // A ptr to the handle of the object. + CRefCount::CPtrInfoBase *pinfo; // A ptr to the handle of the object. TKey Key; // The key used to find the pointer mutable TPtr *Ptr; // A cache for pinfo->Ptr. Useful to speed up ope->() and ope*() diff --git a/code/nel/include/nel/misc/resource_ptr_inline.h b/code/nel/include/nel/misc/resource_ptr_inline.h index b287e9b18..a2309e5a6 100644 --- a/code/nel/include/nel/misc/resource_ptr_inline.h +++ b/code/nel/include/nel/misc/resource_ptr_inline.h @@ -61,7 +61,7 @@ template SMART_INLINE void CReso if(pinfo->Ptr) { // Inform the Object that no more CResourcePtr points on it. - ((TPtr*)(pinfo->Ptr))->pinfo= static_cast(&CRefCount::NullPtrInfo); + ((TPtr*)(pinfo->Ptr))->pinfo = &CRefCount::NullPtrInfo; } // Then delete the pinfo. delete pinfo; @@ -74,7 +74,7 @@ template SMART_INLINE void CReso // Cons - dest. template inline CResourcePtr::CResourcePtr() { - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; REF_TRACE("Smart()"); @@ -95,7 +95,7 @@ template inline CResourcePtrRefCount++; } else - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; REF_TRACE("Smart(TPtr*)"); } @@ -117,7 +117,7 @@ template inline CResourcePtr(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; } @@ -142,7 +142,7 @@ template CResourcePtr(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; } @@ -179,7 +179,7 @@ template void CResourcePtr::k // First, release the refptr. unRef(); - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; // Then delete the pointer. @@ -196,7 +196,7 @@ template inline CResourcePtrPtr; - if (pinfo != static_cast(&CRefCount::NullPtrInfo)) + if (pinfo != &CRefCount::NullPtrInfo) { // Does the pointer has been deleted ? if (Ptr == NULL) @@ -310,7 +310,7 @@ template void CStaticResourcePtr // First, release the refptr. unRef(); - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; // Then delete the pointer. diff --git a/code/nel/include/nel/misc/rgba.h b/code/nel/include/nel/misc/rgba.h index e4fc6b61e..006b1f102 100644 --- a/code/nel/include/nel/misc/rgba.h +++ b/code/nel/include/nel/misc/rgba.h @@ -86,7 +86,7 @@ public: * Serialisation. * \param f Stream used for serialisation. */ - void serial (class NLMISC::IStream &f); + void serial (NLMISC::IStream &f); /** * Blend two colors. @@ -451,7 +451,7 @@ public: * Serialisation. * \param f Stream used for serialisation. */ - void serial(class NLMISC::IStream &f); + void serial(NLMISC::IStream &f); /** * Blend two colors. @@ -676,7 +676,7 @@ public: * Serialisation. * \param f Stream used for serialisation. */ - void serial(class NLMISC::IStream &f); + void serial(NLMISC::IStream &f); /** * Set colors. diff --git a/code/nel/include/nel/misc/sha1.h b/code/nel/include/nel/misc/sha1.h index d4c630c22..ae42c3c1e 100644 --- a/code/nel/include/nel/misc/sha1.h +++ b/code/nel/include/nel/misc/sha1.h @@ -29,7 +29,7 @@ struct CHashKey CHashKey (const unsigned char Message_Digest[20]) { - HashKeyString = ""; + HashKeyString.clear(); for(sint i = 0; i < 20 ; ++i) { HashKeyString += Message_Digest[i]; @@ -45,7 +45,7 @@ struct CHashKey } else if (str.size() == 40) { - HashKeyString = ""; + HashKeyString.clear(); for(uint i = 0; i < str.size(); i+=2) { uint8 val; diff --git a/code/nel/include/nel/misc/sheet_id.h b/code/nel/include/nel/misc/sheet_id.h index 7a735d3a4..8db0470af 100644 --- a/code/nel/include/nel/misc/sheet_id.h +++ b/code/nel/include/nel/misc/sheet_id.h @@ -146,8 +146,8 @@ public : /** * Serial */ - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); - void serialString(NLMISC::IStream &f, const std::string &defaultType = "") throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); + void serialString(NLMISC::IStream &f, const std::string &defaultType = ""); /** * Display the list of valid sheet ids with their associated file names diff --git a/code/nel/include/nel/misc/smart_ptr.h b/code/nel/include/nel/misc/smart_ptr.h index 016097a3c..2273cebeb 100644 --- a/code/nel/include/nel/misc/smart_ptr.h +++ b/code/nel/include/nel/misc/smart_ptr.h @@ -43,7 +43,7 @@ public: /// Destructor which release pinfo if necessary. ~CRefCount(); /// Default constructor init crefs to 0. - CRefCount() { crefs = 0; pinfo=static_cast(&NullPtrInfo); } + CRefCount() { crefs = 0; pinfo = &NullPtrInfo; } /* The instance handle. Can't put those to private since must be used by CRefPtr (and friend doesn't work with template). @@ -56,6 +56,7 @@ public: sint RefCount; // RefCount of ptrinfo (!= instance) bool IsNullPtrInfo; // For dll problems, must use a flag to mark NullPtrInfo. }; + struct CPtrInfo : public CPtrInfoBase { CPtrInfo(CRefCount const* p) {Ptr=p; RefCount=0; IsNullPtrInfo=false;} @@ -75,13 +76,13 @@ public: // Can't put this to private since must be used by CSmartPtr (and friend doesn't work with template). // Provide incref()/decref() function doen't work since decref() can't do a delete this on a non virtual dtor. // So Ptr gestion can only be used via CSmartPtr. - mutable sint crefs; // The ref counter for SmartPtr use. - mutable CPtrInfo *pinfo; // The ref ptr for RefPtr use. + mutable sint crefs; // The ref counter for SmartPtr use. + mutable CPtrInfoBase *pinfo; // The ref ptr for RefPtr use. /// operator= must NOT copy crefs/pinfo!! CRefCount &operator=(const CRefCount &) {return *this;} /// copy cons must NOT copy crefs/pinfo!! - CRefCount(const CRefCount &) {crefs = 0; pinfo=static_cast(&NullPtrInfo);} + CRefCount(const CRefCount &) { crefs = 0; pinfo = &NullPtrInfo; } }; // To use CVirtualRefPtr (or if you just want to have a RefCount with virtual destructor), derive from this class. @@ -99,7 +100,7 @@ public: #define SMART_TRACE(_s) ((void)0) #define REF_TRACE(_s) ((void)0) //#define SMART_TRACE(_s) printf("%s: %d \n", _s, Ptr?Ptr->crefs:0) -//#define REF_TRACE(_s) printf("%s: %d \n", _s, pinfo!=&CRefCount::NullPtrInfo?pinfo->RefCount:0) +//#define REF_TRACE(_s) printf("%s: %d \n", _s, pinfo != &CRefCount::NullPtrInfo?pinfo->RefCount:0) /** @@ -294,7 +295,8 @@ template class CRefPtr { private: - CRefCount::CPtrInfo *pinfo; // A ptr to the handle of the object. + CRefCount::CPtrInfoBase *pinfo; // A ptr to the handle of the object. + mutable T *Ptr; // A cache for pinfo->Ptr. Useful to speed up ope->() and ope*() void unRef() const; // Just release the handle pinfo, but do not update pinfo/Ptr, if deleted. @@ -380,7 +382,7 @@ template class CVirtualRefPtr { private: - CRefCount::CPtrInfo *pinfo; // A ptr to the handle of the object. + CRefCount::CPtrInfoBase *pinfo; // A ptr to the handle of the object. mutable T *Ptr; // A cache for pinfo->Ptr. Useful to speed up ope->() and ope*() void unRef() const; // Just release the handle pinfo, but do not update pinfo/Ptr, if deleted. diff --git a/code/nel/include/nel/misc/smart_ptr_inline.h b/code/nel/include/nel/misc/smart_ptr_inline.h index f6665825a..1e950d710 100644 --- a/code/nel/include/nel/misc/smart_ptr_inline.h +++ b/code/nel/include/nel/misc/smart_ptr_inline.h @@ -134,7 +134,7 @@ SMART_INLINE void CRefPtr::unRef() const if(pinfo->Ptr) { // Inform the Object that no more CRefPtr points on it. - pinfo->Ptr->pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo->Ptr->pinfo = &CRefCount::NullPtrInfo; } // Then delete the pinfo. delete pinfo; @@ -148,7 +148,7 @@ SMART_INLINE void CRefPtr::unRef() const // Cons - dest. template inline CRefPtr::CRefPtr() { - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; REF_TRACE("Smart()"); @@ -170,7 +170,7 @@ template inline CRefPtr::CRefPtr(T *v) #endif } else - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; REF_TRACE("Smart(T*)"); } @@ -187,7 +187,7 @@ template inline CRefPtr::~CRefPtr(void) REF_TRACE("~Smart()"); unRef(); - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; } @@ -216,7 +216,7 @@ template CRefPtr &CRefPtr::operator=(T *v) else { unRef(); - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; } @@ -250,7 +250,7 @@ template void CRefPtr::kill() // First, release the refptr. unRef(); - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; // Then delete the pointer. @@ -316,7 +316,7 @@ SMART_INLINE void CVirtualRefPtr::unRef() const if(pinfo->Ptr) { // Inform the Object that no more CVirtualRefPtr points on it. - pinfo->Ptr->pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo->Ptr->pinfo = &CRefCount::NullPtrInfo; } // Then delete the pinfo. delete pinfo; @@ -330,7 +330,7 @@ SMART_INLINE void CVirtualRefPtr::unRef() const // Cons - dest. template inline CVirtualRefPtr::CVirtualRefPtr() { - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; REF_TRACE("Smart()"); @@ -352,7 +352,7 @@ template inline CVirtualRefPtr::CVirtualRefPtr(T *v) #endif } else - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; REF_TRACE("Smart(T*)"); } @@ -370,7 +370,7 @@ template inline CVirtualRefPtr::~CVirtualRefPtr(void) REF_TRACE("~Smart()"); unRef(); - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; } @@ -399,7 +399,7 @@ template CVirtualRefPtr &CVirtualRefPtr::operator=(T *v) else { unRef(); - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; } @@ -435,7 +435,7 @@ template void CVirtualRefPtr::kill() // First, release the refptr. unRef(); - pinfo= static_cast(&CRefCount::NullPtrInfo); + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; // Then delete the pointer. diff --git a/code/nel/include/nel/misc/stream.h b/code/nel/include/nel/misc/stream.h index 5a342643d..da9f2835e 100644 --- a/code/nel/include/nel/misc/stream.h +++ b/code/nel/include/nel/misc/stream.h @@ -724,7 +724,7 @@ public: * xmlSerial() serial a values into a node. */ template - void xmlSerial (T& value0, const char *nodeName) + void xmlSerial (T& value0, const std::string &nodeName) { // Open the node xmlPush (nodeName); @@ -736,7 +736,7 @@ public: xmlPop (); } template - void xmlSerial (T& value0, T& value1, const char *nodeName) + void xmlSerial (T& value0, T& value1, const std::string &nodeName) { // Open the node xmlPush (nodeName); @@ -748,7 +748,7 @@ public: xmlPop (); } template - void xmlSerial (T& value0, T& value1, T& value2, const char *nodeName) + void xmlSerial (T& value0, T& value1, T& value2, const std::string &nodeName) { // Open the node xmlPush (nodeName); @@ -760,7 +760,7 @@ public: xmlPop (); } template - void xmlSerial (T& value0, T& value1, T& value2, T& value3, const char *nodeName) + void xmlSerial (T& value0, T& value1, T& value2, T& value3, const std::string &nodeName) { // Open the node xmlPush (nodeName); @@ -778,7 +778,7 @@ public: * \name is the name of the node to open * \return true if you can open the node, false if the stream is between a xmlPushBegin() and a xmlPushEnd() call. */ - bool xmlPush (const char *name) + bool xmlPush (const std::string &name) { // XML Mode ? if (_XML) @@ -802,7 +802,7 @@ public: * \name is the name of the node to open * \return true if you can open the node header, false if the stream is between a xmlPushBegin() and a xmlPushEnd() call. */ - bool xmlPushBegin (const char *name) + bool xmlPushBegin (const std::string &name) { // XML Mode ? if (_XML) @@ -854,7 +854,7 @@ public: * \param name is the name of the node header attribute serialised. * \return true if the attribute name have been set, false if the node header is not open (the call is not between xmlPushBegin and xmlPushEnd) */ - bool xmlSetAttrib (const char *name) + bool xmlSetAttrib (const std::string &name) { // XML Mode ? if (_XML) @@ -888,7 +888,7 @@ public: * * \return true if the comment is added, return false if no node is opened. */ - bool xmlComment (const char *comment) + bool xmlComment (const std::string &comment) { // XML Mode ? if (_XML) @@ -910,7 +910,7 @@ protected: void setXMLMode (bool on); /// xmlPushBegin implementation - virtual bool xmlPushBeginInternal (const char * /* name */) { return true; }; + virtual bool xmlPushBeginInternal (const std::string &/* name */) { return true; }; /// xmlPushEnd implementation virtual bool xmlPushEndInternal () { return true; }; @@ -919,13 +919,13 @@ protected: virtual bool xmlPopInternal () { return true; }; /// xmlBreakLine implementation - virtual bool xmlSetAttribInternal (const char * /* name */) { return true; }; + virtual bool xmlSetAttribInternal (const std::string &/* name */) { return true; }; /// xmlBreakLine implementation virtual bool xmlBreakLineInternal () { return true; }; /// xmlComment implementation - virtual bool xmlCommentInternal (const char * /* comment */) { return true; }; + virtual bool xmlCommentInternal (const std::string &/* comment */) { return true; }; /** * for Deriver: reset the PtrTable in the stream. diff --git a/code/nel/include/nel/misc/string_common.h b/code/nel/include/nel/misc/string_common.h index b8a12ad77..2839c2bfc 100644 --- a/code/nel/include/nel/misc/string_common.h +++ b/code/nel/include/nel/misc/string_common.h @@ -28,8 +28,8 @@ namespace NLMISC { // get a string and add \r before \n if necessary -std::string addSlashR (std::string str); -std::string removeSlashR (std::string str); +std::string addSlashR (const std::string &str); +std::string removeSlashR (const std::string &str); /** * \def MaxCStringSize diff --git a/code/nel/include/nel/misc/timeout_assertion_thread.h b/code/nel/include/nel/misc/timeout_assertion_thread.h index 1d329ed2b..82b07b0dc 100644 --- a/code/nel/include/nel/misc/timeout_assertion_thread.h +++ b/code/nel/include/nel/misc/timeout_assertion_thread.h @@ -81,7 +81,7 @@ public: } //nldebug("active, leave sleep, test assert"); - // If this assert occured, it means that a checked part of the code was + // If this assert occurred, it means that a checked part of the code was // to slow and then I decided to assert to display the problem. nlassert(!(_Control==ACTIVE && _Counter==lastCounter)); } diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 5f25387f5..71702bce5 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -162,10 +162,14 @@ # define NL_COMP_GCC #endif -#if defined(_HAS_CPP0X) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#if defined(_HAS_CPP0X) || defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(NL_COMP_VC_VERSION) && NL_COMP_VC_VERSION >= 110) # define NL_ISO_CPP0X_AVAILABLE #endif +#if defined(NL_COMP_GCC) && (__cplusplus >= 201103L) +# define NL_NO_EXCEPTION_SPECS +#endif + // gcc 3.4 introduced ISO C++ with tough template rules // // NL_ISO_SYNTAX can be used using #if NL_ISO_SYNTAX or #if !NL_ISO_SYNTAX @@ -386,17 +390,17 @@ typedef unsigned int uint; // at least 32bits (depend of processor) #include #include #include -inline void *aligned_malloc(size_t size, size_t alignment) { return _aligned_malloc(size, alignment); } -inline void aligned_free(void *ptr) { _aligned_free(ptr); } +#define aligned_malloc(size, alignment) _aligned_malloc(size, alignment) +#define aligned_free(ptr) _aligned_free(ptr) #elif defined(NL_OS_MAC) #include // under Mac OS X, malloc is already aligned for SSE and Altivec (16 bytes alignment) -inline void *aligned_malloc(size_t size, size_t /* alignment */) { return malloc(size); } -inline void aligned_free(void *ptr) { free(ptr); } +#define aligned_malloc(size, alignment) malloc(size) +#define aligned_free(ptr) free(ptr) #else #include -inline void *aligned_malloc(size_t size, size_t alignment) { return memalign(alignment, size); } -inline void aligned_free(void *ptr) { free(ptr); } +#define aligned_malloc(size, alignment) memalign(alignment, size) +#define aligned_free(ptr) free(ptr) #endif /* NL_COMP_ */ @@ -407,12 +411,21 @@ inline void aligned_free(void *ptr) { free(ptr); } #ifndef NL_CPU_X86_64 // on x86_64, new and delete are already aligned on 16 bytes + +#ifdef NL_NO_EXCEPTION_SPECS +extern void *operator new(size_t size); +extern void *operator new[](size_t size); +extern void operator delete(void *p) noexcept; +extern void operator delete[](void *p) noexcept; +#else 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 + #else /* NL_HAS_SSE2 */ #define NL_DEFAULT_MEMORY_ALIGNMENT 4 @@ -430,30 +443,40 @@ extern void operator delete[](void *p) throw(); # define CHashSet ::std::hash_set # define CHashMultiMap ::std::hash_multimap # endif // _STLP_HASH_MAP +# define CUniquePtr ::std::auto_ptr +# define CUniquePtrMove +#elif defined(NL_ISO_CPP0X_AVAILABLE) || (defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 100)) +# include +# include +# define CHashMap ::std::unordered_map +# define CHashSet ::std::unordered_set +# define CHashMultiMap ::std::unordered_multimap +# define CUniquePtr ::std::unique_ptr +# define CUniquePtrMove ::std::move #elif defined(NL_ISO_STDTR1_AVAILABLE) // use std::tr1 for CHash* classes, if available (gcc 4.1+ and VC9 with TR1 feature pack) # include NL_ISO_STDTR1_HEADER(unordered_map) # include NL_ISO_STDTR1_HEADER(unordered_set) # define CHashMap NL_ISO_STDTR1_NAMESPACE::unordered_map # define CHashSet NL_ISO_STDTR1_NAMESPACE::unordered_set # define CHashMultiMap NL_ISO_STDTR1_NAMESPACE::unordered_multimap +# define CUniquePtr ::std::auto_ptr +# define CUniquePtrMove #elif defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 70 && NL_COMP_VC_VERSION <= 90) // VC7 through 9 # include # include # define CHashMap stdext::hash_map # define CHashSet stdext::hash_set # define CHashMultiMap stdext::hash_multimap -#elif defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 100) -# include -# include -# define CHashMap ::std::unordered_map -# define CHashSet ::std::unordered_set -# define CHashMultiMap ::std::unordered_multimap +# define CUniquePtr ::std::auto_ptr +# define CUniquePtrMove #elif defined(NL_COMP_GCC) // GCC4 # include # include # define CHashMap ::__gnu_cxx::hash_map # define CHashSet ::__gnu_cxx::hash_set # define CHashMultiMap ::__gnu_cxx::hash_multimap +# define CUniquePtr ::std::auto_ptr +# define CUniquePtrMove namespace __gnu_cxx { diff --git a/code/nel/include/nel/misc/win_tray.h b/code/nel/include/nel/misc/win_tray.h deleted file mode 100644 index 42b6d78e6..000000000 --- a/code/nel/include/nel/misc/win_tray.h +++ /dev/null @@ -1,15 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . diff --git a/code/nel/include/nel/net/buf_client.h b/code/nel/include/nel/net/buf_client.h index a540f78d9..c85e2f1ba 100644 --- a/code/nel/include/nel/net/buf_client.h +++ b/code/nel/include/nel/net/buf_client.h @@ -159,7 +159,7 @@ public: /** Force to send data pending in the send queue now. If all the data could not be sent immediately, * the returned nbBytesRemaining value is non-zero. * \param nbBytesRemaining If the pointer is not NULL, the method sets the number of bytes still pending after the flush attempt. - * \returns False if an error has occured (e.g. the remote host is disconnected). + * \returns False if an error has occurred (e.g. the remote host is disconnected). * To retrieve the reason of the error, call CSock::getLastError() and/or CSock::errorString() */ bool flush( uint *nbBytesRemaining=NULL ) { return _BufSock->flush( nbBytesRemaining ); } diff --git a/code/nel/include/nel/net/buf_server.h b/code/nel/include/nel/net/buf_server.h index 70c56d2c8..ba92cdced 100644 --- a/code/nel/include/nel/net/buf_server.h +++ b/code/nel/include/nel/net/buf_server.h @@ -235,7 +235,7 @@ public: * the returned nbBytesRemaining value is non-zero. * \param destid The identifier of the destination connection. * \param nbBytesRemaining If the pointer is not NULL, the method sets the number of bytes still pending after the flush attempt. - * \returns False if an error has occured (e.g. the remote host is disconnected). + * \returns False if an error has occurred (e.g. the remote host is disconnected). * To retrieve the reason of the error, call CSock::getLastError() and/or CSock::errorString() */ bool flush( TSockId destid, uint *nbBytesRemaining=NULL ); diff --git a/code/nel/include/nel/net/buf_sock.h b/code/nel/include/nel/net/buf_sock.h index 5a2f3c074..1a491d45d 100644 --- a/code/nel/include/nel/net/buf_sock.h +++ b/code/nel/include/nel/net/buf_sock.h @@ -84,7 +84,7 @@ protected: ///@name Sending data //@{ - /// Update the network sending (call this method evenly). Returns false if an error occured. + /// Update the network sending (call this method evenly). Returns false if an error occurred. bool update(); /** Sets the time flush trigger (in millisecond). When this time is elapsed, @@ -101,7 +101,7 @@ protected: * (see CNonBlockingBufSock), if all the data could not be sent immediately, * the returned nbBytesRemaining value is non-zero. * \param nbBytesRemaining If the pointer is not NULL, the method sets the number of bytes still pending after the flush attempt. - * \returns False if an error has occured (e.g. the remote host is disconnected). + * \returns False if an error has occurred (e.g. the remote host is disconnected). * To retrieve the reason of the error, call CSock::getLastError() and/or CSock::errorString() */ bool flush( uint *nbBytesRemaining=NULL ); @@ -170,7 +170,7 @@ protected: } /** Pushes a buffer to the send queue and update, - * or returns false if the socket is not physically connected the or an error occured during sending + * or returns false if the socket is not physically connected the or an error occurred during sending */ bool pushBuffer( const NLMISC::CMemStream& buffer ) { diff --git a/code/nel/include/nel/net/message_recorder.h b/code/nel/include/nel/net/message_recorder.h index 5874aca4c..92fee29fa 100644 --- a/code/nel/include/nel/net/message_recorder.h +++ b/code/nel/include/nel/net/message_recorder.h @@ -61,7 +61,7 @@ struct TMessageRecord { nlassert( stream.stringMode() ); - uint32 len; + uint32 len = 0; std::string s_event; stream.serial( UpdateCounter ); if ( stream.isReading() ) diff --git a/code/nel/include/nel/net/module_gateway.h b/code/nel/include/nel/net/module_gateway.h index 27fb2784d..a097f8de0 100644 --- a/code/nel/include/nel/net/module_gateway.h +++ b/code/nel/include/nel/net/module_gateway.h @@ -264,7 +264,7 @@ namespace NLNET /** Send a message to a module. */ - virtual void sendModuleMessage(IModuleProxy *senderProxy, IModuleProxy *addresseeProxy, const NLNET::CMessage &message) =0; + virtual void sendModuleProxyMessage(IModuleProxy *senderProxy, IModuleProxy *addresseeProxy, const NLNET::CMessage &message) =0; /** Send a message to the module plugged in this gateway. * You can override this method to change the dispatching, add filtering, diff --git a/code/nel/include/nel/net/pacs_client.h b/code/nel/include/nel/net/pacs_client.h index 058d1fc63..7cc61deba 100644 --- a/code/nel/include/nel/net/pacs_client.h +++ b/code/nel/include/nel/net/pacs_client.h @@ -48,7 +48,7 @@ public: /// Constructor CPacsClient() { - // No connexion + // No connection _Server=NULL; } @@ -553,7 +553,7 @@ static void cbPacsAnswer (CMessage &msgin, TSockId from, CCallbackNetBase &netba client->getPositionSpeedCallback (id, position, speed); } else - NLMISC::nlError ("Pacs client: unkown sub message string"); + NLMISC::nlError ("Pacs client: unknown sub message string"); // Next message ? msgin.serial (again); @@ -567,7 +567,7 @@ static TCallbackItem PacsCallbackArray[] = inline bool CPacsClient::connect () { - // Create a connexion + // Create a connection _Server = new CCallbackClient; // Look up for PACS service diff --git a/code/nel/include/nel/net/service.h b/code/nel/include/nel/net/service.h index 8c7a52c63..02967d317 100644 --- a/code/nel/include/nel/net/service.h +++ b/code/nel/include/nel/net/service.h @@ -124,7 +124,7 @@ int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL scn->setArgs (lpCmdLine); \ createDebug(NULL,!scn->haveLongArg("nolog"));\ scn->setCallbackArray (__ServiceCallbackArray, sizeof(__ServiceCallbackArray)/sizeof(__ServiceCallbackArray[0])); \ - sint retval = scn->main (__ServiceShortName, __ServiceLongName, __ServicePort, __ConfigDir, __LogDir, __DATE__" "__TIME__); \ + sint retval = scn->main (__ServiceShortName, __ServiceLongName, __ServicePort, __ConfigDir, __LogDir, __DATE__ " " __TIME__); \ delete scn; \ return retval; \ } @@ -139,7 +139,7 @@ int main(int argc, const char **argv) \ scn->setArgs (argc, argv); \ createDebug(NULL,!scn->haveLongArg("nolog"));\ scn->setCallbackArray (__ServiceCallbackArray, sizeof(__ServiceCallbackArray)/sizeof(__ServiceCallbackArray[0])); \ - sint retval = scn->main (__ServiceShortName, __ServiceLongName, __ServicePort, __ConfigDir, __LogDir, __DATE__" "__TIME__); \ + sint retval = scn->main (__ServiceShortName, __ServiceLongName, __ServicePort, __ConfigDir, __LogDir, __DATE__ " " __TIME__); \ delete scn; \ return retval; \ } diff --git a/code/nel/include/nel/net/sock.h b/code/nel/include/nel/net/sock.h index 8f7201013..5ff2ea94c 100644 --- a/code/nel/include/nel/net/sock.h +++ b/code/nel/include/nel/net/sock.h @@ -121,7 +121,7 @@ public: /// Releases the network engine static void releaseNetwork(); - /** Returns the code of the last error that has occured. + /** Returns the code of the last error that has occurred. * Note: This code is platform-dependant. On Unix, it is errno; on Windows it is the Winsock error code. * See also errorString() */ diff --git a/code/nel/include/nel/net/unitime.h b/code/nel/include/nel/net/unitime.h index 21e8b68e4..43bf7a5a3 100644 --- a/code/nel/include/nel/net/unitime.h +++ b/code/nel/include/nel/net/unitime.h @@ -52,7 +52,7 @@ public: static const char *getStringUniTime (NLMISC::TTime ut); - /** You need to call this function before calling getUniTime or an assert will occured. + /** You need to call this function before calling getUniTime or an assert will occurred. * This function will connect to the time service and synchronize your computer. * This function assumes that all services run on server that are time synchronized with NTP for example. * If addr is NULL, the function will connect to the Time Service via the Naming Service. In this case, @@ -87,11 +87,11 @@ public: */ static void simulate() { nlstop; _Simulate = true; } - static bool Sync; // true if the synchronization occured + static bool Sync; // true if the synchronization occurred private: static NLMISC::TTime _SyncUniTime; // time in millisecond when the universal time received - static NLMISC::TTime _SyncLocalTime; // time in millisecond when the syncro with universal time occured + static NLMISC::TTime _SyncLocalTime; // time in millisecond when the syncro with universal time occurred // If true, do not synchronize static bool _Simulate; diff --git a/code/nel/include/nel/pacs/move_container.h b/code/nel/include/nel/pacs/move_container.h index 8cea65b3e..5193e8386 100644 --- a/code/nel/include/nel/pacs/move_container.h +++ b/code/nel/include/nel/pacs/move_container.h @@ -282,7 +282,7 @@ private: // Free world image pointers void freeWorldImage (CPrimitiveWorldImage *worldImage); - // Called by CMovePrimitive when a change occured on the primitive BB + // Called by CMovePrimitive when a change occurred on the primitive BB void changed (CMovePrimitive* primitive, uint8 worldImage); // Remove the collisionable primitive from the modified list diff --git a/code/nel/include/nel/sound/audio_decoder.h b/code/nel/include/nel/sound/audio_decoder.h index f7ae5ab31..f1dfdfc2c 100644 --- a/code/nel/include/nel/sound/audio_decoder.h +++ b/code/nel/include/nel/sound/audio_decoder.h @@ -67,7 +67,7 @@ public: static IAudioDecoder *createAudioDecoder(const std::string &type, NLMISC::IStream *stream, bool loop); /// Get information on a music file (only artist and title at the moment). - static bool getInfo(const std::string &filepath, std::string &artist, std::string &title); + static bool getInfo(const std::string &filepath, std::string &artist, std::string &title, float &length); /// Get audio/container extensions that are currently supported by the nel sound library. static void getMusicExtensions(std::vector &extensions); diff --git a/code/nel/include/nel/sound/audio_decoder_vorbis.h b/code/nel/include/nel/sound/audio_decoder_vorbis.h index 19d058d4a..4efcba255 100644 --- a/code/nel/include/nel/sound/audio_decoder_vorbis.h +++ b/code/nel/include/nel/sound/audio_decoder_vorbis.h @@ -77,7 +77,7 @@ public: inline sint32 getStreamOffset() { return _StreamOffset; } /// Get information on a music file (only artist and title at the moment). - static bool getInfo(NLMISC::IStream *stream, std::string &artist, std::string &title); + static bool getInfo(NLMISC::IStream *stream, std::string &artist, std::string &title, float &length); /// Get how many bytes the music buffer requires for output minimum. virtual uint32 getRequiredBytes(); diff --git a/code/nel/include/nel/sound/audio_mixer_user.h b/code/nel/include/nel/sound/audio_mixer_user.h index d8949c3d3..4163bf616 100644 --- a/code/nel/include/nel/sound/audio_mixer_user.h +++ b/code/nel/include/nel/sound/audio_mixer_user.h @@ -332,7 +332,7 @@ public: virtual bool isMusicEnded(); virtual void setMusicVolume(float gain); virtual float getMusicLength(); - virtual bool getSongTitle(const std::string &filename, std::string &result); + virtual bool getSongTitle(const std::string &filename, std::string &result, float &length); virtual void enableBackgroundMusic(bool enable); virtual void enableBackgroundMusicTimeConstraint(bool enable); CMusicSoundManager *getBackgroundMusicManager() const {return _BackgroundMusicManager;} diff --git a/code/nel/include/nel/sound/driver/sound_driver.h b/code/nel/include/nel/sound/driver/sound_driver.h index b5549e5bf..e38126fff 100644 --- a/code/nel/include/nel/sound/driver/sound_driver.h +++ b/code/nel/include/nel/sound/driver/sound_driver.h @@ -192,7 +192,7 @@ public: * \param artist returns the song artist (empty if not available) * \param title returns the title (empty if not available) */ - virtual bool getMusicInfo(const std::string &/* filepath */, std::string &artist, std::string &title) { artist.clear(); title.clear(); return false; } + virtual bool getMusicInfo(const std::string &/* filepath */, std::string &artist, std::string &title, float &length) { artist.clear(); title.clear(); length = 0.f; return false; } /// Get audio/container extensions that are supported natively by the driver implementation. virtual void getMusicExtensions(std::vector &extensions) const = 0; /// Return if a music extension is supported by the driver's music channel. diff --git a/code/nel/include/nel/sound/u_audio_mixer.h b/code/nel/include/nel/sound/u_audio_mixer.h index 0d845f9c3..c3059152c 100644 --- a/code/nel/include/nel/sound/u_audio_mixer.h +++ b/code/nel/include/nel/sound/u_audio_mixer.h @@ -432,7 +432,7 @@ public: /** Get the song title. Returns false if the song is not found or the function is not implemented. * If the song as no name, result is filled with the filename. */ - virtual bool getSongTitle(const std::string &filename, std::string &result) =0; + virtual bool getSongTitle(const std::string &filename, std::string &result, float &length) =0; /** enable or disable the background music system. disable it when you want to play your own mp3 for instance */ virtual void enableBackgroundMusic(bool enable) =0; diff --git a/code/nel/samples/3d/CMakeLists.txt b/code/nel/samples/3d/CMakeLists.txt index 6cd2e49ef..772ab0056 100644 --- a/code/nel/samples/3d/CMakeLists.txt +++ b/code/nel/samples/3d/CMakeLists.txt @@ -4,8 +4,8 @@ ADD_SUBDIRECTORY(shape_viewer) IF(WITH_NEL_CEGUI) ADD_SUBDIRECTORY(cegui) -ENDIF(WITH_NEL_CEGUI) +ENDIF() #IF(WITH_QT) # ADD_SUBDIRECTORY(qtnel) -#ENDIF(WITH_QT) +#ENDIF() diff --git a/code/nel/samples/CMakeLists.txt b/code/nel/samples/CMakeLists.txt index 9f98df488..84c4e3f11 100644 --- a/code/nel/samples/CMakeLists.txt +++ b/code/nel/samples/CMakeLists.txt @@ -2,20 +2,20 @@ ADD_SUBDIRECTORY(misc) IF(WITH_3D) ADD_SUBDIRECTORY(3d) -ENDIF(WITH_3D) +ENDIF() IF(WITH_GEORGES) ADD_SUBDIRECTORY(georges) -ENDIF(WITH_GEORGES) +ENDIF() IF(WITH_NET) ADD_SUBDIRECTORY(net) -ENDIF(WITH_NET) +ENDIF() IF(WITH_PACS) ADD_SUBDIRECTORY(pacs) -ENDIF(WITH_PACS) +ENDIF() IF(WITH_SOUND) ADD_SUBDIRECTORY(sound) -ENDIF(WITH_SOUND) +ENDIF() diff --git a/code/nel/samples/net/udp/CMakeLists.txt b/code/nel/samples/net/udp/CMakeLists.txt index a4528c4db..21ef87015 100644 --- a/code/nel/samples/net/udp/CMakeLists.txt +++ b/code/nel/samples/net/udp/CMakeLists.txt @@ -8,7 +8,7 @@ ADD_DEFINITIONS(-DUDP_DIR="\\"${NL_SHARE_ABSOLUTE_PREFIX}/nl_sample_udp/\\"") IF(WITH_3D) ADD_DEFINITIONS(-DUSE_3D) -ENDIF(WITH_3D) +ENDIF() TARGET_LINK_LIBRARIES(nl_sample_udpclient nelmisc nelnet nel3d) TARGET_LINK_LIBRARIES(nl_sample_udpserver nelmisc nelnet) @@ -22,4 +22,4 @@ INSTALL(FILES bench_service.cfg client.cfg readme.txt DESTINATION ${NL_SHARE_PRE IF(WITH_3D) INSTALL(FILES n019003l.pfb DESTINATION ${NL_SHARE_PREFIX}/nl_sample_udp COMPONENT samplesnet) -ENDIF(WITH_3D) +ENDIF() diff --git a/code/nel/src/3d/CMakeLists.txt b/code/nel/src/3d/CMakeLists.txt index 821c888ce..e79d26f57 100644 --- a/code/nel/src/3d/CMakeLists.txt +++ b/code/nel/src/3d/CMakeLists.txt @@ -730,12 +730,12 @@ ADD_DEFINITIONS(${LIBVR_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nel3d ${CMAKE_CURRENT_SOURCE_DIR}/std3d.h ${CMAKE_CURRENT_SOURCE_DIR}/std3d.cpp) -ENDIF(WITH_PCH) +ENDIF() NL_GEN_PC(nel-3d.pc) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nel3d LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() ADD_SUBDIRECTORY(driver) diff --git a/code/nel/src/3d/anim_ctrl.cpp b/code/nel/src/3d/anim_ctrl.cpp deleted file mode 100644 index 507d1dc6e..000000000 --- a/code/nel/src/3d/anim_ctrl.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" -#include "nel/3d/anim_ctrl.h" - - -namespace NL3D -{ - - - - -} // NL3D diff --git a/code/nel/src/3d/anim_detail_trav.cpp b/code/nel/src/3d/anim_detail_trav.cpp index dc825b849..563e95da8 100644 --- a/code/nel/src/3d/anim_detail_trav.cpp +++ b/code/nel/src/3d/anim_detail_trav.cpp @@ -26,6 +26,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/animatable.cpp b/code/nel/src/3d/animatable.cpp index c36df64d6..a40a2a0c8 100644 --- a/code/nel/src/3d/animatable.cpp +++ b/code/nel/src/3d/animatable.cpp @@ -19,6 +19,9 @@ #include "nel/3d/animatable.h" #include "nel/3d/channel_mixer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/animated_lightmap.cpp b/code/nel/src/3d/animated_lightmap.cpp index 4493168ed..0c3564969 100644 --- a/code/nel/src/3d/animated_lightmap.cpp +++ b/code/nel/src/3d/animated_lightmap.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/animated_material.cpp b/code/nel/src/3d/animated_material.cpp index dff998863..8e33a3a9f 100644 --- a/code/nel/src/3d/animated_material.cpp +++ b/code/nel/src/3d/animated_material.cpp @@ -21,6 +21,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/animated_morph.cpp b/code/nel/src/3d/animated_morph.cpp index 040fe1484..fcad597f4 100644 --- a/code/nel/src/3d/animated_morph.cpp +++ b/code/nel/src/3d/animated_morph.cpp @@ -21,6 +21,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/animated_value.cpp b/code/nel/src/3d/animated_value.cpp deleted file mode 100644 index e5175b922..000000000 --- a/code/nel/src/3d/animated_value.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/animated_value.h" - - -namespace NL3D -{ - -/* -// Some compilation check: force Visual to compile to template -CAnimatedValueBool atoto1; -CAnimatedValueInt atoto2; -CAnimatedValueFloat atoto3; -CAnimatedValueVector atoto4; -CAnimatedValueString atoto5; -CAnimatedValueQuat atoto6; -CAnimatedValueRGBA atoto7; -*/ - -} // NL3D diff --git a/code/nel/src/3d/animation.cpp b/code/nel/src/3d/animation.cpp index a604d2bde..157ca5427 100644 --- a/code/nel/src/3d/animation.cpp +++ b/code/nel/src/3d/animation.cpp @@ -30,6 +30,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -315,7 +318,7 @@ UAnimation* UAnimation::createAnimation (const char* sPath) NL3D_HAUTO_UI_ANIMATION; // Allocate an animation - std::auto_ptr anim (new CAnimation); + CUniquePtr anim (new CAnimation); // Read it NLMISC::CIFile file; diff --git a/code/nel/src/3d/animation_optimizer.cpp b/code/nel/src/3d/animation_optimizer.cpp index 726086f8b..9205fde39 100644 --- a/code/nel/src/3d/animation_optimizer.cpp +++ b/code/nel/src/3d/animation_optimizer.cpp @@ -29,6 +29,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/animation_playlist.cpp b/code/nel/src/3d/animation_playlist.cpp index 26e84e1e4..336d8d44b 100644 --- a/code/nel/src/3d/animation_playlist.cpp +++ b/code/nel/src/3d/animation_playlist.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/animation_set.cpp b/code/nel/src/3d/animation_set.cpp index 05db8a7be..0b4c096c0 100644 --- a/code/nel/src/3d/animation_set.cpp +++ b/code/nel/src/3d/animation_set.cpp @@ -29,6 +29,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -221,7 +225,7 @@ bool CAnimationSet::loadFromFiles(const std::string &path, bool recurse /* = tru { NLMISC::CIFile iFile; iFile.open(anims[k]); - std::auto_ptr anim(new CAnimation); + CUniquePtr anim(new CAnimation); anim->serial(iFile); addAnimation(NLMISC::CFile::getFilenameWithoutExtension(anims[k]).c_str(), anim.release()); iFile.close(); diff --git a/code/nel/src/3d/animation_set_user.cpp b/code/nel/src/3d/animation_set_user.cpp index 9ad16c46a..c1e83f7f3 100644 --- a/code/nel/src/3d/animation_set_user.cpp +++ b/code/nel/src/3d/animation_set_user.cpp @@ -19,6 +19,9 @@ #include "nel/3d/animation_set_user.h" #include "nel/3d/driver_user.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/animation_time.cpp b/code/nel/src/3d/animation_time.cpp deleted file mode 100644 index 0cda680a6..000000000 --- a/code/nel/src/3d/animation_time.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/animation_time.h" - - -namespace NL3D { - - - -} // NL3D diff --git a/code/nel/src/3d/async_file_manager_3d.cpp b/code/nel/src/3d/async_file_manager_3d.cpp index 9f94b5260..cbb3f5e5d 100644 --- a/code/nel/src/3d/async_file_manager_3d.cpp +++ b/code/nel/src/3d/async_file_manager_3d.cpp @@ -31,6 +31,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/async_texture_block.cpp b/code/nel/src/3d/async_texture_block.cpp deleted file mode 100644 index c0abc4704..000000000 --- a/code/nel/src/3d/async_texture_block.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "std3d.h" -#include "nel/3d/async_texture_block.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/async_texture_manager.cpp b/code/nel/src/3d/async_texture_manager.cpp index a30bd6eb6..a962c9991 100644 --- a/code/nel/src/3d/async_texture_manager.cpp +++ b/code/nel/src/3d/async_texture_manager.cpp @@ -25,6 +25,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/bezier_patch.cpp b/code/nel/src/3d/bezier_patch.cpp index 7181630f6..099a532d2 100644 --- a/code/nel/src/3d/bezier_patch.cpp +++ b/code/nel/src/3d/bezier_patch.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // *************************************************************************** diff --git a/code/nel/src/3d/bloom_effect.cpp b/code/nel/src/3d/bloom_effect.cpp index c468349ac..18a6ac303 100644 --- a/code/nel/src/3d/bloom_effect.cpp +++ b/code/nel/src/3d/bloom_effect.cpp @@ -33,6 +33,10 @@ using namespace NLMISC; using namespace NL3D; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/bone.cpp b/code/nel/src/3d/bone.cpp index 9adf64fcd..98d26c6ce 100644 --- a/code/nel/src/3d/bone.cpp +++ b/code/nel/src/3d/bone.cpp @@ -20,6 +20,9 @@ #include "nel/3d/anim_ctrl.h" #include "nel/misc/hierarchical_timer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/camera.cpp b/code/nel/src/3d/camera.cpp index b2c02fe2f..012402b74 100644 --- a/code/nel/src/3d/camera.cpp +++ b/code/nel/src/3d/camera.cpp @@ -19,6 +19,9 @@ #include "nel/3d/camera.h" #include "nel/3d/scene.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/camera_col.cpp b/code/nel/src/3d/camera_col.cpp index 538cb1695..7f7e349d3 100644 --- a/code/nel/src/3d/camera_col.cpp +++ b/code/nel/src/3d/camera_col.cpp @@ -22,6 +22,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/channel_mixer.cpp b/code/nel/src/3d/channel_mixer.cpp index 6e7ab7ba7..bd8a4dff5 100644 --- a/code/nel/src/3d/channel_mixer.cpp +++ b/code/nel/src/3d/channel_mixer.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/clip_trav.cpp b/code/nel/src/3d/clip_trav.cpp index b75abe61e..f26c84273 100644 --- a/code/nel/src/3d/clip_trav.cpp +++ b/code/nel/src/3d/clip_trav.cpp @@ -37,6 +37,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -130,7 +133,7 @@ bool CClipTrav::fullSearch (vector& vCluster, const CVector& pos) if (pIG->_ClusterInstances[i]->isIn(pos)) vCluster.push_back (pIG->_ClusterInstances[i]); } - if (vCluster.size() > 0) + if (!vCluster.empty()) return true;*/ return true; diff --git a/code/nel/src/3d/cloud.cpp b/code/nel/src/3d/cloud.cpp index eb53589ce..bfd83ba80 100644 --- a/code/nel/src/3d/cloud.cpp +++ b/code/nel/src/3d/cloud.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/cloud_scape.cpp b/code/nel/src/3d/cloud_scape.cpp index 77d046eec..5c40d89ec 100644 --- a/code/nel/src/3d/cloud_scape.cpp +++ b/code/nel/src/3d/cloud_scape.cpp @@ -23,6 +23,10 @@ // ------------------------------------------------------------------------------------------------ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/cloud_scape_user.cpp b/code/nel/src/3d/cloud_scape_user.cpp index 5570ed7eb..1a18a26fa 100644 --- a/code/nel/src/3d/cloud_scape_user.cpp +++ b/code/nel/src/3d/cloud_scape_user.cpp @@ -22,6 +22,9 @@ #include "nel/3d/cloud_scape.h" #include "nel/3d/scene.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/cluster.cpp b/code/nel/src/3d/cluster.cpp index 76ed153e1..312042364 100644 --- a/code/nel/src/3d/cluster.cpp +++ b/code/nel/src/3d/cluster.cpp @@ -28,6 +28,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -319,7 +323,7 @@ void CCluster::serial (NLMISC::IStream&f) // write the env fx name std::string envFxName = CStringMapper::unmap(_EnvironmentFxId); if (envFxName == "no fx") - envFxName = ""; + envFxName.clear(); f.serial(envFxName); } diff --git a/code/nel/src/3d/coarse_mesh_build.cpp b/code/nel/src/3d/coarse_mesh_build.cpp index 8a712a57f..966f389b4 100644 --- a/code/nel/src/3d/coarse_mesh_build.cpp +++ b/code/nel/src/3d/coarse_mesh_build.cpp @@ -19,9 +19,14 @@ #include "nel/3d/coarse_mesh_build.h" #include "nel/3d/mesh.h" +#include "nel/3d/debug_vb.h" using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/coarse_mesh_manager.cpp b/code/nel/src/3d/coarse_mesh_manager.cpp index f45ca7675..2d4792263 100644 --- a/code/nel/src/3d/coarse_mesh_manager.cpp +++ b/code/nel/src/3d/coarse_mesh_manager.cpp @@ -21,11 +21,17 @@ #include "nel/3d/texture_file.h" #include "nel/misc/hierarchical_timer.h" #include "nel/3d/clip_trav.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/fast_mem.h" using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/computed_string.cpp b/code/nel/src/3d/computed_string.cpp index 1a9fefba5..a8f7743b3 100644 --- a/code/nel/src/3d/computed_string.cpp +++ b/code/nel/src/3d/computed_string.cpp @@ -22,6 +22,7 @@ #include "nel/3d/material.h" #include "nel/3d/frustum.h" #include "nel/3d/viewport.h" +#include "nel/3d/debug_vb.h" #include "nel/misc/smart_ptr.h" #include "nel/misc/debug.h" @@ -31,6 +32,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/cube_grid.cpp b/code/nel/src/3d/cube_grid.cpp deleted file mode 100644 index 2826a087f..000000000 --- a/code/nel/src/3d/cube_grid.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/cube_grid.h" - - -namespace NL3D -{ - -} // NL3D diff --git a/code/nel/src/3d/cube_map_builder.cpp b/code/nel/src/3d/cube_map_builder.cpp index 8d8e016b7..60aec6cdd 100644 --- a/code/nel/src/3d/cube_map_builder.cpp +++ b/code/nel/src/3d/cube_map_builder.cpp @@ -26,6 +26,9 @@ +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -89,8 +92,8 @@ static uint8 *BuildCubeMapTexLuminance(const NLMISC::CVector &start, CTextureCube *BuildCubeMap(sint mapSize, ICubeMapFunctor &f, bool luminanceOnly /* = false*/, const std::string &shareName /* = "" */) { - std::auto_ptr cubeMap(new CTextureCube); - std::auto_ptr faces[6]; + CUniquePtr cubeMap(new CTextureCube); + CUniquePtr faces[6]; /// this gives the start (unormalized normal for each face for u,v = 0, 0) static const NLMISC::CVector start[] = diff --git a/code/nel/src/3d/debug_vb.cpp b/code/nel/src/3d/debug_vb.cpp index 39e01b646..b1aebe6e0 100644 --- a/code/nel/src/3d/debug_vb.cpp +++ b/code/nel/src/3d/debug_vb.cpp @@ -19,6 +19,10 @@ #include "nel/3d/vertex_buffer.h" #include "nel/3d/index_buffer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/deform_2d.cpp b/code/nel/src/3d/deform_2d.cpp index 7a4ffb507..f36f61820 100644 --- a/code/nel/src/3d/deform_2d.cpp +++ b/code/nel/src/3d/deform_2d.cpp @@ -27,6 +27,10 @@ #include "nel/3d/dru.h" #include "nel/3d/material.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/driver.cpp b/code/nel/src/3d/driver.cpp index 3ba0178f2..36d783e78 100644 --- a/code/nel/src/3d/driver.cpp +++ b/code/nel/src/3d/driver.cpp @@ -28,6 +28,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/driver/CMakeLists.txt b/code/nel/src/3d/driver/CMakeLists.txt index 1004e5824..8f1693716 100644 --- a/code/nel/src/3d/driver/CMakeLists.txt +++ b/code/nel/src/3d/driver/CMakeLists.txt @@ -1,13 +1,13 @@ IF(WITH_DRIVER_OPENGL) ADD_SUBDIRECTORY(opengl) -ENDIF(WITH_DRIVER_OPENGL) +ENDIF() IF(WITH_DRIVER_OPENGLES) ADD_SUBDIRECTORY(opengles) -ENDIF(WITH_DRIVER_OPENGLES) +ENDIF() IF(WIN32) IF(WITH_DRIVER_DIRECT3D) ADD_SUBDIRECTORY(direct3d) - ENDIF(WITH_DRIVER_DIRECT3D) -ENDIF(WIN32) + ENDIF() +ENDIF() diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 2b90ea1ed..be7a74722 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -32,6 +32,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; @@ -1265,7 +1269,7 @@ bool CDriverD3D::init (uintptr_t windowIcon, emptyProc exitFunc) if (error != ERROR_CLASS_ALREADY_EXISTS) { nlwarning("CDriverD3D::init: Can't register window class %s (error code %i)", _WindowClass.c_str(), (sint)error); - _WindowClass = ""; + _WindowClass.clear(); return false; } } @@ -2267,7 +2271,10 @@ bool CDriverD3D::getCurrentScreenMode(GfxMode &gfxMode) // *************************************************************************** void CDriverD3D::setWindowTitle(const ucstring &title) { - SetWindowTextW(_HWnd,(WCHAR*)title.c_str()); + if (!SetWindowTextW(_HWnd, (WCHAR*)title.c_str())) + { + nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str()); + } } // *************************************************************************** diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index c497230aa..a4d9dbaeb 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -480,12 +480,21 @@ public: virtual ~CStateRecord() {} // use STL allocator for fast alloc. this works because objects are small ( < 128 bytes) void *operator new(size_t size) { return CStateRecord::Allocator.allocate(size); } + void *operator new(size_t size, int /* blockUse */, char const * /* fileName */, int /* lineNumber */) + { + // TODO: add memory leaks detector + return CStateRecord::Allocator.allocate(size); + } void operator delete(void *block) { CStateRecord::Allocator.deallocate((uint8 *) block, 1); } + void operator delete(void *block, int /* blockUse */, char const* /* fileName */, int /* lineNumber */) + { + // TODO: add memory leaks detector + CStateRecord::Allocator.deallocate((uint8 *)block, 1); + } static std::allocator Allocator; }; - // record of a single .fx pass class CFXPassRecord { diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_index.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_index.cpp index dfdc48670..d7ee84303 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_index.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_index.cpp @@ -25,6 +25,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp index f754b6357..d26741faf 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp @@ -17,6 +17,10 @@ #include "stddirect3d.h" #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_light.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_light.cpp index d3bb62e64..f68caab3a 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_light.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_light.cpp @@ -26,6 +26,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp index 1e8878fb9..e6622f61d 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp @@ -27,6 +27,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; @@ -568,7 +572,7 @@ bool CDriverD3D::setupMaterial(CMaterial &mat) if (_PixelProgram) { #ifdef NL_DEBUG_D3D - // Check, should not occured + // Check, should not occur nlassertex (_PixelShader, ("STOP : no pixel shader available. Can't render this material.")); #endif // NL_DEBUG_D3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_matrix.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_matrix.cpp index c5b479de0..6e7520fb7 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_matrix.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_matrix.cpp @@ -26,6 +26,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp index e0a2cd4a4..7d79eb1a7 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp @@ -29,6 +29,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_profile.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_profile.cpp index 4ff29481c..b574fff54 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_profile.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_profile.cpp @@ -19,6 +19,10 @@ #include "driver_direct3d.h" #include "nel/misc/hierarchical_timer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_render.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_render.cpp index 939dc1dc9..6b9d2ce0c 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_render.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_render.cpp @@ -27,6 +27,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp index 5cc6c283c..3f11f8bce 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp @@ -20,6 +20,10 @@ #include "nel/misc/path.h" #include "nel/misc/file.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; @@ -62,7 +66,7 @@ void CD3DShaderFX::setName (const char *name) bool CD3DShaderFX::loadShaderFile (const char *filename) { - _Text = ""; + _Text.clear(); // Lookup string _filename = NLMISC::CPath::lookup(filename, false, true, true); if (!_filename.empty()) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp index ad5de53c1..a10732c64 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp @@ -26,6 +26,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; @@ -270,7 +274,7 @@ uint getPixelFormatSize (D3DFORMAT destFormat) case D3DFMT_DXT3: bits=8; break; case D3DFMT_DXT4: bits=8; break; case D3DFMT_DXT5: bits=8; break; - default: nlstop; break; // unkown pixel format + default: nlstop; break; // unknown pixel format } return bits; } diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp index e44780e89..a936d5b46 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp @@ -18,6 +18,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp index 2b7fa8fa9..ba726fcc9 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp @@ -26,6 +26,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex_program.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex_program.cpp index d4af02592..265468125 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex_program.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex_program.cpp @@ -18,6 +18,10 @@ #include "driver_direct3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; @@ -109,7 +113,7 @@ void dumpWriteMask(uint mask, std::string &out) H_AUTO_D3D(dumpWriteMask) if (mask == 0xf) { - out = ""; + out.clear(); return; } out = "."; @@ -126,7 +130,7 @@ void dumpSwizzle(const CVPSwizzle &swz, std::string &out) H_AUTO_D3D(dumpSwizzle) if (swz.isIdentity()) { - out = ""; + out.clear(); return; } out = "."; diff --git a/code/nel/src/3d/driver/direct3d/stddirect3d.h b/code/nel/src/3d/driver/direct3d/stddirect3d.h index c7b6f7f3e..366627b44 100644 --- a/code/nel/src/3d/driver/direct3d/stddirect3d.h +++ b/code/nel/src/3d/driver/direct3d/stddirect3d.h @@ -14,15 +14,14 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -// Default NeL includes -#include "nel/misc/types_nl.h" +#ifndef STDDIRECT3D_H +#define STDDIRECT3D_H -#ifdef NL_OS_WINDOWS -# define WIN32_LEAN_AND_MEAN -# ifndef NL_COMP_MINGW -# define NOMINMAX -# endif -# include +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #endif // System includes @@ -42,16 +41,14 @@ #include #include +// Default NeL includes +#include "nel/misc/types_nl.h" #ifdef NL_DEBUG // add Direct3D debug infos #define D3D_DEBUG_INFO #endif -// Directx includes -#include -#include - // NeL includes #include "nel/misc/common.h" #include "nel/misc/debug.h" @@ -59,3 +56,17 @@ #include "nel/misc/mem_stream.h" #include "nel/misc/time_nl.h" #include "nel/misc/command.h" + +#ifdef NL_OS_WINDOWS +# define WIN32_LEAN_AND_MEAN +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif +# include +#endif + +// Directx includes +#include +#include + +#endif diff --git a/code/nel/src/3d/driver/opengl/CMakeLists.txt b/code/nel/src/3d/driver/opengl/CMakeLists.txt index 21d790668..8b5aabeb1 100644 --- a/code/nel/src/3d/driver/opengl/CMakeLists.txt +++ b/code/nel/src/3d/driver/opengl/CMakeLists.txt @@ -30,6 +30,14 @@ ELSE() SET(NLDRV_OGL_LIB "nel_drv_opengl") ENDIF() +# This helps to debug issue 310 +IF(DEBUG_OGL_SPECULAR_FALLBACK) + ADD_DEFINITIONS(-DDEBUG_OGL_SPECULAR_FALLBACK) +ENDIF() +IF(DEBUG_OGL_COMBINE43_DISABLE) + ADD_DEFINITIONS(-DDEBUG_OGL_COMBINE43_DISABLE) +ENDIF() + NL_TARGET_DRIVER(${NLDRV_OGL_LIB} ${SRC}) INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/code/nel/src/3d/driver/opengl/GL/glext.h b/code/nel/src/3d/driver/opengl/GL/glext.h index 47b435bce..0021d6b1e 100644 --- a/code/nel/src/3d/driver/opengl/GL/glext.h +++ b/code/nel/src/3d/driver/opengl/GL/glext.h @@ -33,7 +33,7 @@ extern "C" { ** used to make the header, and the header can be found at ** http://www.opengl.org/registry/ ** -** Khronos $Revision: 32957 $ on $Date: 2016-06-09 17:03:08 -0400 (Thu, 09 Jun 2016) $ +** Khronos $Revision: 33061 $ on $Date: 2016-07-14 20:14:13 -0400 (Thu, 14 Jul 2016) $ */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -53,7 +53,7 @@ extern "C" { #define GLAPI extern #endif -#define GL_GLEXT_VERSION 20160609 +#define GL_GLEXT_VERSION 20160714 /* Generated C header for: * API: gl @@ -4657,8 +4657,13 @@ GLAPI void APIENTRY glVertexBlendARB (GLint count); #ifndef GL_ARB_vertex_buffer_object #define GL_ARB_vertex_buffer_object 1 +#if defined(__APPLE__) +typedef intptr_t GLsizeiptrARB; +typedef intptr_t GLintptrARB; +#else typedef ptrdiff_t GLsizeiptrARB; typedef ptrdiff_t GLintptrARB; +#endif #define GL_BUFFER_SIZE_ARB 0x8764 #define GL_BUFFER_USAGE_ARB 0x8765 #define GL_ARRAY_BUFFER_ARB 0x8892 @@ -8831,6 +8836,11 @@ GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRG #define GL_INTERLACE_READ_INGR 0x8568 #endif /* GL_INGR_interlace_read */ +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + #ifndef GL_INTEL_fragment_shader_ordering #define GL_INTEL_fragment_shader_ordering 1 #endif /* GL_INTEL_fragment_shader_ordering */ diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 6ab0e3336..023997065 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -36,6 +36,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif @@ -196,18 +199,6 @@ CDriverGL::CDriverGL() _backBufferHeight = 0; _backBufferWidth = 0; - // autorelease pool for memory management - _autoreleasePool = [[NSAutoreleasePool alloc] init]; - - // init the application object - [NSApplication sharedApplication]; - - // create the menu in the top screen bar - setupApplicationMenu(); - - // finish the application launching - [NSApp finishLaunching]; - #elif defined (NL_OS_UNIX) _dpy = 0; @@ -373,10 +364,6 @@ CDriverGL::~CDriverGL() { H_AUTO_OGL(CDriverGL_CDriverGLDtor) release(); - -#if defined(NL_OS_MAC) - [_autoreleasePool release]; -#endif } // -------------------------------------------------- @@ -638,7 +625,7 @@ bool CDriverGL::setupDisplay() checkForPerPixelLightingSupport(); #ifndef USE_OPENGLES - // if EXTVertexShader is used, bind the standard GL arrays, and allocate constant + // if EXTVertexShader is used, bind the standard GL arrays, and allocate constant if (!_Extensions.NVVertexProgram && !_Extensions.ARBVertexProgram && _Extensions.EXTVertexShader) { _EVSPositionHandle = nglBindParameterEXT(GL_CURRENT_VERTEX_EXT); @@ -942,13 +929,6 @@ bool CDriverGL::swapBuffers() #elif defined(NL_OS_MAC) - // TODO: maybe do this somewhere else? - if(_DestroyWindow) - { - [_autoreleasePool release]; - _autoreleasePool = [[NSAutoreleasePool alloc] init]; - } - [_ctx flushBuffer]; #elif defined (NL_OS_UNIX) @@ -1215,11 +1195,11 @@ sint CDriverGL::getTotalVideoMemory() const if (_Extensions.ATIMeminfo) { - GLint memoryInKiB = 0; - glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &memoryInKiB); + GLint params[4]; + glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, params); - nlinfo("3D: GL_TEXTURE_FREE_MEMORY_ATI returned %d KiB", memoryInKiB); - return memoryInKiB; + nlinfo("3D: GL_TEXTURE_FREE_MEMORY_ATI returned %d KiB", params[0]); + return params[0]; } #if defined(NL_OS_WINDOWS) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index 373c501bf..d386dd85f 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -61,6 +61,9 @@ void (*nglGetProcAddress(const char *procName))() } #endif // NL_OS_WINDOWS +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif // *************************************************************************** // The exported function names @@ -783,7 +786,13 @@ static bool setupNVTextureEnvCombine4(const char *glext) { H_AUTO_OGL(setupNVTextureEnvCombine4); CHECK_EXT("GL_NV_texture_env_combine4"); +#ifdef DEBUG_OGL_COMBINE43_DISABLE + // issue 310: disable extension to debug bug around CDriverGL::setupSpecularPass() + nlwarning("GL_NV_texture_env_combine4 disabled by request (DEBUG_OGL_COMBINE43_DISABLE)"); + return false; +#else return true; +#endif } // ********************************* @@ -799,7 +808,13 @@ static bool setupATITextureEnvCombine3(const char *glext) // #endif CHECK_EXT("GL_ATI_texture_env_combine3"); +#ifdef DEBUG_OGL_COMBINE43_DISABLE + // issue 310: disable extension to debug bug around CDriverGL::setupSpecularPass() + nlwarning("GL_ATI_texture_env_combine3 disabled by request (DEBUG_OGL_COMBINE43_DISABLE)"); + return false; +#else return true; +#endif } // ********************************* @@ -1676,7 +1691,7 @@ void registerGlExtensions(CGlExtensions &ext) // Check pixel program // Disable feature ??? if (!ext.DisableHardwarePixelProgram) - { + { ext.ARBFragmentProgram = setupARBFragmentProgram(glext); ext.NVFragmentProgram2 = setupNVFragmentProgram2(glext); ext.ARBFragmentShader = setupARBFragmentShader(glext); @@ -1685,6 +1700,7 @@ void registerGlExtensions(CGlExtensions &ext) { ext.ARBFragmentProgram = false; ext.NVFragmentProgram2 = false; + ext.ARBFragmentShader = false; } ext.OESDrawTexture = setupOESDrawTexture(glext); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp index cbd1bcd9a..0d27166fc 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp @@ -33,6 +33,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef NL_STATIC @@ -491,7 +495,7 @@ void CDriverGL::showCursor(bool b) } else { - _CurrName = ""; + _CurrName.clear(); } // update current hardware icon to avoid to have the plain arrow diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_light.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_light.cpp index 7b52e3225..a9b62b6b6 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_light.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_light.cpp @@ -19,6 +19,10 @@ #include "driver_opengl.h" #include "nel/3d/light.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef NL_STATIC diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_material.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_material.cpp index e5375a49c..e28521310 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_material.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_material.cpp @@ -21,6 +21,10 @@ #include "nel/3d/texture_bump.h" #include "nel/3d/material.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef NL_STATIC @@ -1421,6 +1425,11 @@ void CDriverGL::setupSpecularPass(uint pass) } else { +// Disabled because of Intel GPU texture bug (issue 310) +// CMake options to debug +// -DDEBUG_OGL_SPECULAR_FALLBACK=ON enables this +// -DDEBUG_OGL_COMBINE43_DISABLE=ON disables GL_NV_texture_env_combine4/GL_ATI_texture_env_combine3 +#ifdef DEBUG_OGL_SPECULAR_FALLBACK // Multiply texture1 by alpha_texture0 and display with add _DriverGLStates.enableBlend(true); _DriverGLStates.blendFunc(GL_ONE, GL_ONE); @@ -1453,6 +1462,7 @@ void CDriverGL::setupSpecularPass(uint pass) } activateTexEnvMode(1, env); +#endif // DEBUG_OGL_SPECULAR_FALLBACK } } } diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_matrix.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_matrix.cpp index 41575024c..392aa3f5d 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_matrix.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_matrix.cpp @@ -17,6 +17,10 @@ #include "stdopengl.h" #include "driver_opengl.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef NL_STATIC diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp index dd66328e9..67af0df64 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp @@ -38,6 +38,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_states.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_states.cpp index 8ec7a6bc8..5fd9e6416 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_states.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_states.cpp @@ -22,6 +22,10 @@ // define it For Debug purpose only. Normal use is to hide this line //#define NL3D_GLSTATE_DISABLE_CACHE +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef NL_STATIC diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp index a46f7ef12..edd3943ef 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp @@ -28,6 +28,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif //#define NEL_DUMP_UPLOAD_TIME @@ -97,7 +100,7 @@ CTextureDrvInfosGL::~CTextureDrvInfosGL() CDepthStencilFBO::CDepthStencilFBO(CDriverGL *driver, uint width, uint height) { - nldebug("3D: Init shared FBO"); + //nldebug("3D: Init shared FBO"); m_Driver = driver; Width = width; @@ -139,7 +142,7 @@ CDepthStencilFBO::~CDepthStencilFBO() if (DepthFBOId) { - nldebug("3D: Release shared FBO"); + //nldebug("3D: Release shared FBO"); nglDeleteRenderbuffersEXT(1, &DepthFBOId); if (StencilFBOId == DepthFBOId) StencilFBOId = 0; @@ -188,10 +191,10 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex) } nglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, DepthStencilFBO->DepthFBOId); - nldebug("3D: glFramebufferRenderbufferExt(depth:24) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); + //nldebug("3D: glFramebufferRenderbufferExt(depth:24) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); nglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, DepthStencilFBO->StencilFBOId); - nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); + //nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); } // check status diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp index f981ae3ba..bd945c1a1 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp @@ -21,6 +21,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef NL_STATIC diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_vertex.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_vertex.cpp index 39f71d77a..b3a3e5194 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_vertex.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_vertex.cpp @@ -26,6 +26,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif @@ -632,7 +635,7 @@ bool CDriverGL::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQuad nlerror("not available in OpenGL ES 1.0, only use 16 bits indices"); #else // indices fits on 32 bits - GLint indices[QUAD_BATCH_SIZE]; + GLint indices[QUAD_BATCH_SIZE * 6]; GLint *curr = indices; GLint *end = indices + 6 * numQuadsToDraw; uint32 vertexIndex = currIndex; @@ -1710,9 +1713,9 @@ void CDriverGL::resetVertexArrayRange() // After, Clear the 2 vertexArrayRange, if any. if(_AGPVertexArrayRange) - _AGPVertexArrayRange->free(); + _AGPVertexArrayRange->freeBlock(); if(_VRAMVertexArrayRange) - _VRAMVertexArrayRange->free(); + _VRAMVertexArrayRange->freeBlock(); } diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp index 25c7da614..b625af7f2 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef NL_STATIC @@ -163,7 +167,7 @@ uint CVertexArrayRangeNVidia::sizeAllocated() const // *************************************************************************** -void CVertexArrayRangeNVidia::free() +void CVertexArrayRangeNVidia::freeBlock() { H_AUTO_OGL(CVertexArrayRangeNVidia_free) // release the ptr. @@ -240,7 +244,7 @@ void *CVertexArrayRangeNVidia::allocateVB(uint32 size) void CVertexArrayRangeNVidia::freeVB(void *ptr) { H_AUTO_OGL(CVertexArrayRangeNVidia_freeVB) - _HeapMemory.free(ptr); + _HeapMemory.freeBlock(ptr); } @@ -541,7 +545,7 @@ uint CVertexArrayRangeATI::sizeAllocated() const return _VertexArraySize; } // *************************************************************************** -void CVertexArrayRangeATI::free() +void CVertexArrayRangeATI::freeBlock() { H_AUTO_OGL(CVertexArrayRangeATI_free) // release the ptr. @@ -619,7 +623,7 @@ void *CVertexArrayRangeATI::allocateVB(uint32 size) void CVertexArrayRangeATI::freeVB(void *ptr) { H_AUTO_OGL(CVertexArrayRangeATI_freeVB) - _HeapMemory.free(ptr); + _HeapMemory.freeBlock(ptr); } @@ -849,7 +853,7 @@ bool CVertexArrayRangeMapObjectATI::allocate(uint32 size, CVertexBuffer::TPrefer } // *************************************************************************** -void CVertexArrayRangeMapObjectATI::free() +void CVertexArrayRangeMapObjectATI::freeBlock() { H_AUTO_OGL(CVertexArrayRangeMapObjectATI_free) _SizeAllocated = 0; @@ -1201,7 +1205,7 @@ bool CVertexArrayRangeARB::allocate(uint32 size, CVertexBuffer::TPreferredMemory } // *************************************************************************** -void CVertexArrayRangeARB::free() +void CVertexArrayRangeARB::freeBlock() { H_AUTO_OGL(CVertexArrayRangeARB_free) _SizeAllocated = 0; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.h b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.h index 1ec64ccf2..302ff0de8 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.h @@ -57,7 +57,7 @@ public: /// allocate a vertex array space. false if error. client must free before re-allocate. virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType)= 0; /// free this space. - virtual void free()= 0; + virtual void freeBlock()= 0; /// create a IVertexBufferHardGL virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb) =0; /// return the size allocated. 0 if not allocated or failure @@ -141,7 +141,7 @@ public: /// allocate a vertex array sapce. false if error. must free before re-allocate. virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); /// free this space. - virtual void free(); + virtual void freeBlock(); /// create a IVertexBufferHardGL virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); /// return the size allocated. 0 if not allocated or failure @@ -258,7 +258,7 @@ public: /// allocate a vertex array sapce. false if error. must free before re-allocate. virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); /// free this space. - virtual void free(); + virtual void freeBlock(); /// create a IVertexBufferHardGL virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); /// return the size allocated. 0 if not allocated or failure @@ -367,7 +367,7 @@ public: */ virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); /// free this space. - virtual void free(); + virtual void freeBlock(); /// create a IVertexBufferHardGL virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); /// return the size allocated. 0 if not allocated or failure @@ -480,7 +480,7 @@ public: */ virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); /// free this space. - virtual void free(); + virtual void freeBlock(); /// create a IVertexBufferHardGL virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); /// return the size allocated. 0 if not allocated or failure diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp index 93d281fec..e9ac4814a 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp @@ -28,6 +28,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + //#define DEBUG_SETUP_EXT_VERTEX_SHADER namespace NL3D { @@ -1270,7 +1274,7 @@ static void ARBVertexProgramDumpWriteMask(uint mask, std::string &out) H_AUTO_OGL(ARBVertexProgramDumpWriteMask) if (mask == 0xf) { - out = ""; + out.clear(); return; } out = "."; @@ -1286,7 +1290,7 @@ static void ARBVertexProgramDumpSwizzle(const CVPSwizzle &swz, std::string &out) H_AUTO_OGL(ARBVertexProgramDumpSwizzle) if (swz.isIdentity()) { - out = ""; + out.clear(); return; } out = "."; 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 db6400042..a7eb6e62a 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -44,6 +44,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef NL_STATIC @@ -343,9 +347,14 @@ bool CDriverGL::init (uintptr_t windowIcon, emptyProc exitFunc) retrieveATIDriverVersion(); #elif defined(NL_OS_MAC) - // nothing to do nlunreferenced(windowIcon); + // autorelease pool for memory management + _autoreleasePool = [[NSAutoreleasePool alloc] init]; + + // init the application object + [NSApplication sharedApplication]; + #elif defined (NL_OS_UNIX) nlunreferenced(windowIcon); @@ -468,32 +477,35 @@ bool CDriverGL::unInit() // Restore monitor color parameters if (_NeedToRestoreGammaRamp) { - HDC dc = CreateDCA ("DISPLAY", NULL, NULL, NULL); + HDC dc = CreateDCA("DISPLAY", NULL, NULL, NULL); if (dc) { - if (!SetDeviceGammaRamp (dc, _GammaRampBackuped)) - nlwarning ("(CDriverGL::release): SetDeviceGammaRamp failed"); + if (!SetDeviceGammaRamp(dc, _GammaRampBackuped)) + nlwarning("(CDriverGL::release): SetDeviceGammaRamp failed"); // Release the DC - ReleaseDC (NULL, dc); + ReleaseDC(NULL, dc); } else { - nlwarning ("(CDriverGL::release): can't create DC"); + nlwarning("(CDriverGL::release): can't create DC"); } } #elif defined(NL_OS_MAC) - // nothing to do + [_autoreleasePool release]; #elif defined (NL_OS_UNIX) // restore default X errors handler XSetErrorHandler(NULL); - XCloseDisplay(_dpy); - _dpy = NULL; + if (_dpy) + { + XCloseDisplay(_dpy); + _dpy = NULL; + } #endif // NL_OS_UNIX @@ -1454,7 +1466,7 @@ bool CDriverGL::createWindow(const GfxMode &mode) pos = 0; hwndParent = NULL; } - window = CreateWindowW(L"NLClass", L"NeL Window", dwStyle, + window = CreateWindowW(L"NLClass", L"NeL Window", dwStyle, pos, pos, mode.Width, mode.Height, hwndParent, NULL, GetModuleHandle(NULL), NULL); if (window == EmptyWindow) @@ -1466,6 +1478,12 @@ bool CDriverGL::createWindow(const GfxMode &mode) #elif defined(NL_OS_MAC) + // create the menu in the top screen bar + setupApplicationMenu(); + + // finish the application launching + [NSApp finishLaunching]; + // describe how the window should look like and behave unsigned int styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask; @@ -1486,7 +1504,7 @@ bool CDriverGL::createWindow(const GfxMode &mode) [[CocoaApplicationDelegate alloc] initWithDriver:this]; // set the application delegate, this will handle window/app close events - [NSApp setDelegate:(id)appDelegate]; + [NSApp setDelegate:(id)appDelegate]; // bind the close button of the window to applicationShouldTerminate id closeButton = [cocoa_window standardWindowButton:NSWindowCloseButton]; @@ -1642,6 +1660,7 @@ bool CDriverGL::destroyWindow() } #elif defined(NL_OS_MAC) + #elif defined(NL_OS_UNIX) if (_DestroyWindow && _ctx) // FIXME: _DestroyWindow may need to be removed here as well @@ -2299,7 +2318,10 @@ void CDriverGL::setWindowTitle(const ucstring &title) #ifdef NL_OS_WINDOWS - SetWindowTextW(_win, (WCHAR*)title.c_str()); + if (!SetWindowTextW(_win, (WCHAR*)title.c_str())) + { + nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str()); + } #elif defined(NL_OS_MAC) @@ -2732,7 +2754,7 @@ void CDriverGL::setWindowSize(uint32 width, uint32 height) setWindowStyle(EWSFullscreen); // set the back buffer manually to match the desired rendering resolution - GLint dim[2] = { width, height }; + GLint dim[2] = { (GLint)width, (GLint)height }; CGLError error = CGLSetParameter( (CGLContextObj)[_ctx CGLContextObj], kCGLCPSurfaceBackingSize, dim); diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp b/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp index e4a531b9b..f33667082 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp @@ -153,9 +153,9 @@ bool CCocoaEventEmitter::pasteTextFromClipboard(ucstring &text) NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; NSArray *classArray = [NSArray arrayWithObject:[NSString class]]; NSDictionary *options = [NSDictionary dictionary]; - + BOOL ok = [pasteboard canReadObjectForClasses:classArray options:options]; - if (ok) + if (ok) { NSArray *objectsToPaste = [pasteboard readObjectsForClasses:classArray options:options]; NSString *nstext = [objectsToPaste objectAtIndex:0]; @@ -264,8 +264,8 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server) mousePos.y /= (float)viewRect.size.height; // if the mouse event was placed outside the view, don't tell NeL :) - if((mousePos.x < 0.0 || mousePos.x > 1.0 || - mousePos.y < 0.0 || mousePos.y > 1.0) && + if((mousePos.x < 0.0 || mousePos.x > 1.0 || + mousePos.y < 0.0 || mousePos.y > 1.0) && event.type != NSKeyDown && event.type != NSKeyUp) { return false; @@ -415,7 +415,7 @@ typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e); void CCocoaEventEmitter::submitEvents(CEventServer& server, bool /* allWins */) { - // break if there was no event to handle + // break if there was no event to handle // if running embedded in e.g. qt, _eventLoop will be false while(_eventLoop) { @@ -442,8 +442,15 @@ void CCocoaEventEmitter::submitEvents(CEventServer& server, bool /* allWins */) processMessage(event, &server); } - // forward the event to the cocoa application - [NSApp sendEvent:event]; + @try + { + // forward the event to the cocoa application + [NSApp sendEvent:event]; + } + @catch(NSException *e) + { + nlwarning("Exception when sending event: %s", [[e reason] UTF8String]); + } } _server = &server; diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m b/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.mm similarity index 100% rename from code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m rename to code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.mm diff --git a/code/nel/src/3d/driver/opengl/stdopengl.h b/code/nel/src/3d/driver/opengl/stdopengl.h index 3066a778a..28ed25fc9 100644 --- a/code/nel/src/3d/driver/opengl/stdopengl.h +++ b/code/nel/src/3d/driver/opengl/stdopengl.h @@ -17,7 +17,12 @@ #ifndef STDOPENGL_H #define STDOPENGL_H -#include "nel/misc/types_nl.h" +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif #include #include @@ -35,6 +40,8 @@ #include #include +#include "nel/misc/types_nl.h" + #ifdef NL_OS_WINDOWS # define WIN32_LEAN_AND_MEAN # ifndef NL_COMP_MINGW diff --git a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp index 4da55a009..a43a251a9 100644 --- a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp +++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp @@ -26,6 +26,9 @@ #include #include "nel/misc/debug.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e); @@ -80,8 +83,6 @@ void CUnixEventEmitter::createIM() { #ifdef X_HAVE_UTF8_STRING - XModifierKeymap *g_mod_map = XGetModifierMapping(_dpy); - _im = XOpenIM(_dpy, NULL, NULL, NULL); if (_im == NULL) @@ -626,7 +627,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) } case SelectionClear: _SelectionOwned = false; - _CopiedString = ""; + _CopiedString.clear(); break; case SelectionNotify: { diff --git a/code/nel/src/3d/driver_user.cpp b/code/nel/src/3d/driver_user.cpp index 812bb52a9..d1a747478 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -33,11 +33,17 @@ #include "nel/3d/water_env_map_user.h" #include "nel/3d/water_pool_manager.h" #include "nel/3d/u_camera.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/hierarchical_timer.h" #include "nel/misc/event_emitter.h" using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/driver_user2.cpp b/code/nel/src/3d/driver_user2.cpp index 1b46ab607..e24391a1c 100644 --- a/code/nel/src/3d/driver_user2.cpp +++ b/code/nel/src/3d/driver_user2.cpp @@ -37,6 +37,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/dru.cpp b/code/nel/src/3d/dru.cpp index fd3e77404..15ccbfe01 100644 --- a/code/nel/src/3d/dru.cpp +++ b/code/nel/src/3d/dru.cpp @@ -46,6 +46,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/event_mouse_listener.cpp b/code/nel/src/3d/event_mouse_listener.cpp index cb9fb142e..d81b2bfd4 100644 --- a/code/nel/src/3d/event_mouse_listener.cpp +++ b/code/nel/src/3d/event_mouse_listener.cpp @@ -24,6 +24,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/fast_ptr_list.cpp b/code/nel/src/3d/fast_ptr_list.cpp index 753824dae..c9cab1069 100644 --- a/code/nel/src/3d/fast_ptr_list.cpp +++ b/code/nel/src/3d/fast_ptr_list.cpp @@ -20,6 +20,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/fasthls_modifier.cpp b/code/nel/src/3d/fasthls_modifier.cpp index 2790e1442..cae414f2c 100644 --- a/code/nel/src/3d/fasthls_modifier.cpp +++ b/code/nel/src/3d/fasthls_modifier.cpp @@ -26,6 +26,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/flare_model.cpp b/code/nel/src/3d/flare_model.cpp index f964a9102..f070bdcec 100644 --- a/code/nel/src/3d/flare_model.cpp +++ b/code/nel/src/3d/flare_model.cpp @@ -26,9 +26,13 @@ #include "nel/3d/occlusion_query.h" #include "nel/3d/mesh.h" #include "nel/3d/viewport.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/common.h" - +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/flare_shape.cpp b/code/nel/src/3d/flare_shape.cpp index a3a1d135f..1c4b864cd 100644 --- a/code/nel/src/3d/flare_shape.cpp +++ b/code/nel/src/3d/flare_shape.cpp @@ -24,6 +24,9 @@ #include "nel/3d/shape_bank.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -60,7 +63,7 @@ CFlareShape::CFlareShape() : _Color(NLMISC::CRGBA::White), // *************************************************************************************************************** -void CFlareShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CFlareShape::serial(NLMISC::IStream &f) { // Version 4 : - added occlusion test mesh, size reduction, angle modification when object is occluded // - added lookat mode for first flare diff --git a/code/nel/src/3d/font_generator.cpp b/code/nel/src/3d/font_generator.cpp index cdbaf8834..f50b61c5b 100644 --- a/code/nel/src/3d/font_generator.cpp +++ b/code/nel/src/3d/font_generator.cpp @@ -58,6 +58,10 @@ const char* err_msg; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { FT_Library CFontGenerator::_Library = NULL; @@ -267,7 +271,14 @@ void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &hei error = FT_Load_Glyph (_Face, glyph_index, FT_LOAD_DEFAULT); if (error) { - nlerror ("FT_Load_Glyph() failed: %s", getFT2Error(error)); + // use fallback for glyph/character errors (composite char limit for example) + nlwarning ("FT_Load_Glyph() failed: %s", getFT2Error(error)); + + error = FT_Load_Glyph (_Face, 0, FT_LOAD_DEFAULT); + if (error) + { + nlerror("FT_Load_Glyph() fallback failed: %s", getFT2Error(error)); + } } // convert 24.6 fixed point into integer @@ -298,7 +309,14 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl error = FT_Load_Glyph (_Face, glyph_index, FT_LOAD_DEFAULT); if (error) { - nlerror ("FT_Load_Glyph() failed: %s", getFT2Error(error)); + // use fallback for glyph/character errors (composite char limit for example) + nlwarning ("FT_Load_Glyph() failed: %s", getFT2Error(error)); + + error = FT_Load_Glyph (_Face, 0, FT_LOAD_DEFAULT); + if (error) + { + nlerror("FT_Load_Glyph() fallback failed: %s", getFT2Error(error)); + } } if (size == 0) @@ -457,7 +475,7 @@ CFontGenerator::CFontGenerator (const std::string &fontFileName, const std::stri nlerror ("FT_New_Face() failed with file '%s': %s", fontFileName.c_str(), getFT2Error(error)); } - if (fontExFileName != "") + if (!fontExFileName.empty()) { error = FT_Attach_File (_Face, fontExFileName.c_str ()); if (error) diff --git a/code/nel/src/3d/font_manager.cpp b/code/nel/src/3d/font_manager.cpp index 7b503099b..3b77a2100 100644 --- a/code/nel/src/3d/font_manager.cpp +++ b/code/nel/src/3d/font_manager.cpp @@ -32,6 +32,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/frustum.cpp b/code/nel/src/3d/frustum.cpp index 356673a92..36d28ebb0 100644 --- a/code/nel/src/3d/frustum.cpp +++ b/code/nel/src/3d/frustum.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/fxaa.cpp b/code/nel/src/3d/fxaa.cpp index 1eff22501..d37a159ef 100644 --- a/code/nel/src/3d/fxaa.cpp +++ b/code/nel/src/3d/fxaa.cpp @@ -49,11 +49,17 @@ using namespace std; namespace NL3D { namespace { - #include "fxaa_program.h" - } /* anonymous namespace */ +} + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + +namespace NL3D { + CFXAA::CFXAA(NL3D::UDriver *driver) : m_Driver(driver), m_VP(NULL), m_PP(NULL), m_Width(~0), m_Height(~0) { nldebug("3D: Create FXAA"); diff --git a/code/nel/src/3d/geometry_program.cpp b/code/nel/src/3d/geometry_program.cpp index 8f785b6c6..985309a55 100644 --- a/code/nel/src/3d/geometry_program.cpp +++ b/code/nel/src/3d/geometry_program.cpp @@ -27,6 +27,10 @@ #include "nel/3d/driver.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/gpu_program_params.cpp b/code/nel/src/3d/gpu_program_params.cpp index 9e84865be..f7cc6654d 100644 --- a/code/nel/src/3d/gpu_program_params.cpp +++ b/code/nel/src/3d/gpu_program_params.cpp @@ -26,7 +26,6 @@ */ #include "std3d.h" -#include "nel/misc/types_nl.h" #include "nel/3d/gpu_program_params.h" // STL includes @@ -42,16 +41,20 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { +const size_t CGPUProgramParams::s_End = -1; + CGPUProgramParams::CGPUProgramParams() : m_First(s_End), m_Last(s_End) { - } CGPUProgramParams::~CGPUProgramParams() { - } void CGPUProgramParams::copy(CGPUProgramParams *params) diff --git a/code/nel/src/3d/heat_haze.cpp b/code/nel/src/3d/heat_haze.cpp index c42942fe7..03ea4dc06 100644 --- a/code/nel/src/3d/heat_haze.cpp +++ b/code/nel/src/3d/heat_haze.cpp @@ -22,6 +22,10 @@ #include "nel/3d/deform_2d.h" #include "nel/misc/vector_2f.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/height_map.cpp b/code/nel/src/3d/height_map.cpp index 505145376..4236cd15e 100644 --- a/code/nel/src/3d/height_map.cpp +++ b/code/nel/src/3d/height_map.cpp @@ -21,6 +21,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/hls_color_texture.cpp b/code/nel/src/3d/hls_color_texture.cpp index 4afd1c5ea..16766b202 100644 --- a/code/nel/src/3d/hls_color_texture.cpp +++ b/code/nel/src/3d/hls_color_texture.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/hls_texture_bank.cpp b/code/nel/src/3d/hls_texture_bank.cpp index bc7cc7c1f..d7e213cf4 100644 --- a/code/nel/src/3d/hls_texture_bank.cpp +++ b/code/nel/src/3d/hls_texture_bank.cpp @@ -21,6 +21,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/hls_texture_manager.cpp b/code/nel/src/3d/hls_texture_manager.cpp index 147238ae7..586ec53ce 100644 --- a/code/nel/src/3d/hls_texture_manager.cpp +++ b/code/nel/src/3d/hls_texture_manager.cpp @@ -22,6 +22,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/hrc_trav.cpp b/code/nel/src/3d/hrc_trav.cpp index 9d79ac55d..a4cbc525a 100644 --- a/code/nel/src/3d/hrc_trav.cpp +++ b/code/nel/src/3d/hrc_trav.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ig_surface_light.cpp b/code/nel/src/3d/ig_surface_light.cpp index efd5e89a4..ef4a59a46 100644 --- a/code/nel/src/3d/ig_surface_light.cpp +++ b/code/nel/src/3d/ig_surface_light.cpp @@ -18,6 +18,9 @@ #include "nel/3d/ig_surface_light.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ig_surface_light_build.cpp b/code/nel/src/3d/ig_surface_light_build.cpp index 33a5a33b0..70d66c388 100644 --- a/code/nel/src/3d/ig_surface_light_build.cpp +++ b/code/nel/src/3d/ig_surface_light_build.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/index_buffer.cpp b/code/nel/src/3d/index_buffer.cpp index 7bb2e1cd5..e99b1e1e3 100644 --- a/code/nel/src/3d/index_buffer.cpp +++ b/code/nel/src/3d/index_buffer.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // *************************************************************************** diff --git a/code/nel/src/3d/init_3d.cpp b/code/nel/src/3d/init_3d.cpp index b2bf2c05e..e34702b74 100644 --- a/code/nel/src/3d/init_3d.cpp +++ b/code/nel/src/3d/init_3d.cpp @@ -22,6 +22,10 @@ #include "nel/3d/scene.h" #include "nel/3d/register_3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace { static bool _Initialized = false; diff --git a/code/nel/src/3d/instance_group_user.cpp b/code/nel/src/3d/instance_group_user.cpp index 651e54094..536e14e94 100644 --- a/code/nel/src/3d/instance_group_user.cpp +++ b/code/nel/src/3d/instance_group_user.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/instance_lighter.cpp b/code/nel/src/3d/instance_lighter.cpp index d21f80e4e..8e7c16294 100644 --- a/code/nel/src/3d/instance_lighter.cpp +++ b/code/nel/src/3d/instance_lighter.cpp @@ -28,6 +28,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/key.cpp b/code/nel/src/3d/key.cpp index e1722bf23..561041175 100644 --- a/code/nel/src/3d/key.cpp +++ b/code/nel/src/3d/key.cpp @@ -18,6 +18,9 @@ #include "nel/3d/key.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/landscape.cpp b/code/nel/src/3d/landscape.cpp index d588fa424..4b597fc2d 100644 --- a/code/nel/src/3d/landscape.cpp +++ b/code/nel/src/3d/landscape.cpp @@ -41,6 +41,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D @@ -136,7 +139,7 @@ public: } // Dummy serial... - virtual void serial(NLMISC::IStream &/* f */) throw(NLMISC::EStream) {nlstop;} + virtual void serial(NLMISC::IStream &/* f */) { nlstop; } NLMISC_DECLARE_CLASS(CTextureCross); }; @@ -1831,9 +1834,9 @@ void CLandscape::loadTile(uint16 tileId) if(tile) textName= tile->getRelativeFileName(CTile::additive); else - textName= ""; + textName.clear(); // If no additive for this tile, rdrpass is NULL. - if(textName=="") + if(textName.empty()) tileInfo->AdditiveRdrPass= NULL; else { @@ -1844,7 +1847,7 @@ void CLandscape::loadTile(uint16 tileId) // We may have an alpha part for additive. textName= tile->getRelativeFileName (CTile::alpha); - if(textName!="") + if(!textName.empty()) // Must Use clamp for alpha (although NVidia drivers are buggy), because the texture doesn't tile at all pass.TextureAlpha= findTileTexture(TileBank.getAbsPath()+textName, true); @@ -1866,7 +1869,7 @@ void CLandscape::loadTile(uint16 tileId) if(tile) { textName= tile->getRelativeFileName(CTile::diffuse); - if(textName!="") + if(!textName.empty()) // Avoid using Clamp for diffuse, because of recent NVidia GL drivers Bugs in 77.72 pass.TextureDiffuse= findTileTexture(TileBank.getAbsPath()+textName, false); else @@ -1880,7 +1883,7 @@ void CLandscape::loadTile(uint16 tileId) if(tile) { textName= tile->getRelativeFileName (CTile::alpha); - if(textName!="") + if(!textName.empty()) // Must Use clamp for alpha (although NVidia drivers are buggy), because the texture doesn't tile at all pass.TextureAlpha= findTileTexture(TileBank.getAbsPath()+textName, true); } @@ -3216,37 +3219,37 @@ void CLandscape::deleteTessFace(CTessFace *f) // for refine() mgt, must remove from refine priority list, or from the temp rootTessFaceToUpdate list. f->unlinkInPList(); - TessFaceAllocator.free(f); + TessFaceAllocator.freeBlock(f); } // *************************************************************************** void CLandscape::deleteTessVertex(CTessVertex *v) { - TessVertexAllocator.free(v); + TessVertexAllocator.freeBlock(v); } // *************************************************************************** void CLandscape::deleteTessNearVertex(CTessNearVertex *v) { - TessNearVertexAllocator.free(v); + TessNearVertexAllocator.freeBlock(v); } // *************************************************************************** void CLandscape::deleteTessFarVertex(CTessFarVertex *v) { - TessFarVertexAllocator.free(v); + TessFarVertexAllocator.freeBlock(v); } // *************************************************************************** void CLandscape::deleteTileMaterial(CTileMaterial *tm) { - TileMaterialAllocator.free(tm); + TileMaterialAllocator.freeBlock(tm); } // *************************************************************************** void CLandscape::deleteTileFace(CTileFace *tf) { - TileFaceAllocator.free(tf); + TileFaceAllocator.freeBlock(tf); } diff --git a/code/nel/src/3d/landscape_collision_grid.cpp b/code/nel/src/3d/landscape_collision_grid.cpp index 07b509a68..1636fc6bd 100644 --- a/code/nel/src/3d/landscape_collision_grid.cpp +++ b/code/nel/src/3d/landscape_collision_grid.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/landscape_def.cpp b/code/nel/src/3d/landscape_def.cpp index ac545d04b..0c463e167 100644 --- a/code/nel/src/3d/landscape_def.cpp +++ b/code/nel/src/3d/landscape_def.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/landscape_face_vector_manager.cpp b/code/nel/src/3d/landscape_face_vector_manager.cpp index 955ac3587..0ba4b07cf 100644 --- a/code/nel/src/3d/landscape_face_vector_manager.cpp +++ b/code/nel/src/3d/landscape_face_vector_manager.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/landscape_model.cpp b/code/nel/src/3d/landscape_model.cpp index ca90bae2e..017b82e51 100644 --- a/code/nel/src/3d/landscape_model.cpp +++ b/code/nel/src/3d/landscape_model.cpp @@ -23,9 +23,14 @@ #include "nel/3d/cluster.h" #include "nel/3d/scene.h" #include "nel/3d/light_trav.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/landscape_profile.cpp b/code/nel/src/3d/landscape_profile.cpp index 97ccba0b5..3f20ac4d8 100644 --- a/code/nel/src/3d/landscape_profile.cpp +++ b/code/nel/src/3d/landscape_profile.cpp @@ -18,6 +18,9 @@ #include "nel/3d/landscape_profile.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/landscape_user.cpp b/code/nel/src/3d/landscape_user.cpp index d6de7df9e..76d73583f 100644 --- a/code/nel/src/3d/landscape_user.cpp +++ b/code/nel/src/3d/landscape_user.cpp @@ -24,6 +24,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -213,9 +217,9 @@ void CLandscapeUser::refreshAllZonesAround(const CVector &pos, float radius, std refreshZonesAround (pos, radius, za, zr); // some zone added or removed?? - if(za != "") + if(!za.empty()) zonesAdded.push_back(za); - if(zr != "") + if(!zr.empty()) zonesRemoved.push_back(zr); _ZoneManager.checkZonesAround ((uint)pos.x, (uint)(-pos.y), (uint)radius); @@ -262,8 +266,8 @@ void CLandscapeUser::refreshZonesAround(const CVector &pos, float radius, std::s { NL3D_HAUTO_LOAD_LANDSCAPE; - zoneRemoved= ""; - zoneAdded= ""; + zoneRemoved.clear(); + zoneAdded.clear(); CZoneManager::SZoneManagerWork Work; // Check if new zone must be added to landscape if (_ZoneManager.isWorkComplete(Work)) diff --git a/code/nel/src/3d/landscape_vegetable_block.cpp b/code/nel/src/3d/landscape_vegetable_block.cpp index 593725828..ec015916b 100644 --- a/code/nel/src/3d/landscape_vegetable_block.cpp +++ b/code/nel/src/3d/landscape_vegetable_block.cpp @@ -27,6 +27,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/landscapeig_manager.cpp b/code/nel/src/3d/landscapeig_manager.cpp index f4388f9fa..10eab0f60 100644 --- a/code/nel/src/3d/landscapeig_manager.cpp +++ b/code/nel/src/3d/landscapeig_manager.cpp @@ -36,6 +36,10 @@ H_AUTO_DECL ( NL3D_Unload_Zone_IG ) #define NL3D_HAUTO_LAND_MNGR_LOAD_ZONEIG H_AUTO_USE( NL3D_Load_Zone_IG ) #define NL3D_HAUTO_LAND_MNGR_UNLOAD_ZONEIG H_AUTO_USE( NL3D_Unload_Zone_IG ) +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -174,7 +178,7 @@ UInstanceGroup *CLandscapeIGManager::loadZoneIG(const std::string &name) { NL3D_HAUTO_LAND_MNGR_LOAD_ZONEIG - if(name=="") + if(name.empty()) return NULL; // try to find this InstanceGroup. @@ -232,7 +236,7 @@ void CLandscapeIGManager::unloadArrayZoneIG(const std::vector &name void CLandscapeIGManager::unloadZoneIG(const std::string &name) { NL3D_HAUTO_LAND_MNGR_UNLOAD_ZONEIG - if(name=="") + if(name.empty()) return; // try to find this InstanceGroup. @@ -255,7 +259,7 @@ void CLandscapeIGManager::unloadZoneIG(const std::string &name) // *************************************************************************** bool CLandscapeIGManager::isIGAddedToScene(const std::string &name) const { - if(name=="") + if(name.empty()) return false; // try to find this InstanceGroup. @@ -272,7 +276,7 @@ bool CLandscapeIGManager::isIGAddedToScene(const std::string &name) const // *************************************************************************** UInstanceGroup *CLandscapeIGManager::getIG(const std::string &name) const { - if(name=="") + if(name.empty()) return NULL; // try to find this InstanceGroup. diff --git a/code/nel/src/3d/landscapevb_allocator.cpp b/code/nel/src/3d/landscapevb_allocator.cpp index c6815ea05..81a91fb12 100644 --- a/code/nel/src/3d/landscapevb_allocator.cpp +++ b/code/nel/src/3d/landscapevb_allocator.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/landscapevb_info.cpp b/code/nel/src/3d/landscapevb_info.cpp index 46d666ea7..f5955e622 100644 --- a/code/nel/src/3d/landscapevb_info.cpp +++ b/code/nel/src/3d/landscapevb_info.cpp @@ -20,6 +20,9 @@ #include "nel/3d/vertex_buffer.h" #include "nel/3d/landscapevb_allocator.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/light.cpp b/code/nel/src/3d/light.cpp index bd190dc00..ba887a447 100644 --- a/code/nel/src/3d/light.cpp +++ b/code/nel/src/3d/light.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/light_contribution.cpp b/code/nel/src/3d/light_contribution.cpp index 9e7e3d1ce..240b540b9 100644 --- a/code/nel/src/3d/light_contribution.cpp +++ b/code/nel/src/3d/light_contribution.cpp @@ -18,6 +18,9 @@ #include "nel/3d/light_contribution.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/light_influence_interpolator.cpp b/code/nel/src/3d/light_influence_interpolator.cpp index 2875abaac..d6e90bd18 100644 --- a/code/nel/src/3d/light_influence_interpolator.cpp +++ b/code/nel/src/3d/light_influence_interpolator.cpp @@ -20,6 +20,9 @@ #include "nel/misc/debug.h" #include "nel/3d/point_light_named.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/light_trav.cpp b/code/nel/src/3d/light_trav.cpp index 0e31d1558..42c2e2aa5 100644 --- a/code/nel/src/3d/light_trav.cpp +++ b/code/nel/src/3d/light_trav.cpp @@ -27,12 +27,13 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { -using namespace NLMISC; - // *************************************************************************** CLightTrav::CLightTrav(bool bSmallScene) : LightingManager(bSmallScene) { diff --git a/code/nel/src/3d/light_user.cpp b/code/nel/src/3d/light_user.cpp index 14f5b463a..a74e2bd02 100644 --- a/code/nel/src/3d/light_user.cpp +++ b/code/nel/src/3d/light_user.cpp @@ -18,6 +18,9 @@ #include "nel/3d/light_user.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/lighting_manager.cpp b/code/nel/src/3d/lighting_manager.cpp index 0f528d5fb..dcf6eff80 100644 --- a/code/nel/src/3d/lighting_manager.cpp +++ b/code/nel/src/3d/lighting_manager.cpp @@ -28,6 +28,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/load_balancing_trav.cpp b/code/nel/src/3d/load_balancing_trav.cpp index a9f289d11..1e983a2a5 100644 --- a/code/nel/src/3d/load_balancing_trav.cpp +++ b/code/nel/src/3d/load_balancing_trav.cpp @@ -32,6 +32,10 @@ using namespace NLMISC; #define NL3D_DEFAULT_LOADBALANCING_VALUE_SMOOTHER 50 #define NL3D_LOADBALANCING_SMOOTHER_MAX_RATIO 1.1f +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/lod_character_builder.cpp b/code/nel/src/3d/lod_character_builder.cpp index 6b0b6e51b..05eef0b30 100644 --- a/code/nel/src/3d/lod_character_builder.cpp +++ b/code/nel/src/3d/lod_character_builder.cpp @@ -27,6 +27,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/lod_character_instance.cpp b/code/nel/src/3d/lod_character_instance.cpp index 7c0d7a0b9..09940184b 100644 --- a/code/nel/src/3d/lod_character_instance.cpp +++ b/code/nel/src/3d/lod_character_instance.cpp @@ -18,6 +18,9 @@ #include "nel/3d/lod_character_instance.h" #include "nel/3d/lod_character_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/lod_character_manager.cpp b/code/nel/src/3d/lod_character_manager.cpp index 48c2a500f..92dee846a 100644 --- a/code/nel/src/3d/lod_character_manager.cpp +++ b/code/nel/src/3d/lod_character_manager.cpp @@ -34,6 +34,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/lod_character_shape.cpp b/code/nel/src/3d/lod_character_shape.cpp index 02d15ce03..21e1cce7f 100644 --- a/code/nel/src/3d/lod_character_shape.cpp +++ b/code/nel/src/3d/lod_character_shape.cpp @@ -28,6 +28,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/lod_character_shape_bank.cpp b/code/nel/src/3d/lod_character_shape_bank.cpp index 018b336f3..f8fdd1a22 100644 --- a/code/nel/src/3d/lod_character_shape_bank.cpp +++ b/code/nel/src/3d/lod_character_shape_bank.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/lod_character_texture.cpp b/code/nel/src/3d/lod_character_texture.cpp index 5876da48f..2f91861d2 100644 --- a/code/nel/src/3d/lod_character_texture.cpp +++ b/code/nel/src/3d/lod_character_texture.cpp @@ -18,6 +18,9 @@ #include "std3d.h" #include "nel/3d/lod_character_texture.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/logic_info.cpp b/code/nel/src/3d/logic_info.cpp index 4202eb863..7599b0917 100644 --- a/code/nel/src/3d/logic_info.cpp +++ b/code/nel/src/3d/logic_info.cpp @@ -18,6 +18,9 @@ #include "nel/3d/logic_info.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/material.cpp b/code/nel/src/3d/material.cpp index 886f45308..3cae5dd30 100644 --- a/code/nel/src/3d/material.cpp +++ b/code/nel/src/3d/material.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -105,9 +109,9 @@ CMaterial &CMaterial::operator=(const CMaterial &mat) // copy texture matrix if there. if (mat._TexUserMat.get()) { - std::auto_ptr texMatClone( new CUserTexMat(*(mat._TexUserMat))); // make cpy + CUniquePtr texMatClone(new CUserTexMat(*(mat._TexUserMat))); // make cpy //std::swap(texMatClone, _TexUserMat); // swap with old - _TexUserMat = texMatClone; + _TexUserMat = CUniquePtrMove(texMatClone); } else { @@ -265,9 +269,9 @@ void CMaterial::serial(NLMISC::IStream &f) if ((_Flags & IDRV_MAT_USER_TEX_MAT_ALL)) // are there user textrue coordinates matrix ? { - std::auto_ptr newPtr(new CUserTexMat); // create new + CUniquePtr newPtr(new CUserTexMat); // create new //std::swap(_TexUserMat, newPtr); // replace old - _TexUserMat = newPtr; + _TexUserMat = CUniquePtrMove(newPtr); } } diff --git a/code/nel/src/3d/matrix_3x4.cpp b/code/nel/src/3d/matrix_3x4.cpp deleted file mode 100644 index a8384c332..000000000 --- a/code/nel/src/3d/matrix_3x4.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/matrix_3x4.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/mesh.cpp b/code/nel/src/3d/mesh.cpp index 0d3095182..51b07fdec 100644 --- a/code/nel/src/3d/mesh.cpp +++ b/code/nel/src/3d/mesh.cpp @@ -36,6 +36,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -538,7 +541,7 @@ void CMeshGeom::render(IDriver *drv, CTransformShape *trans, float polygonCount, skeleton= mi->getSkeletonModel(); // The mesh must not be skinned for render() nlassert(!(_Skinned && mi->isSkinned() && skeleton)); - bool bMorphApplied = _MeshMorpher->BlendShapes.size() > 0; + bool bMorphApplied = !_MeshMorpher->BlendShapes.empty(); bool useTangentSpace = _MeshVertexProgram && _MeshVertexProgram->needTangentSpace(); @@ -730,7 +733,7 @@ void CMeshGeom::renderSkin(CTransformShape *trans, float alphaMRM) skeleton= mi->getSkeletonModel(); // must be skinned for renderSkin() nlassert(_Skinned && mi->isSkinned() && skeleton); - bool bMorphApplied = _MeshMorpher->BlendShapes.size() > 0; + bool bMorphApplied = !_MeshMorpher->BlendShapes.empty(); bool useTangentSpace = _MeshVertexProgram && _MeshVertexProgram->needTangentSpace(); @@ -858,7 +861,7 @@ void CMeshGeom::renderSimpleWithMaterial(IDriver *drv, const CMatrix &worldMatri // *************************************************************************** -void CMeshGeom::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMeshGeom::serial(NLMISC::IStream &f) { /* *********************************************** * WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance @@ -1101,7 +1104,11 @@ bool CMeshGeom::retrieveTriangles(std::vector &indices) const else { // std::copy will convert from 16 bits index to 32 bit index - std::copy((uint16 *) iba.getPtr(), ((uint16 *) iba.getPtr()) + pb.getNumIndexes(), &indices[triIdx*3]); +#ifdef NL_COMP_VC14 + std::copy((uint16 *)iba.getPtr(), ((uint16 *)iba.getPtr()) + pb.getNumIndexes(), stdext::make_checked_array_iterator(&indices[triIdx * 3], indices.size() - triIdx * 3)); +#else + std::copy((uint16 *)iba.getPtr(), ((uint16 *)iba.getPtr()) + pb.getNumIndexes(), &indices[triIdx * 3]); +#endif } // next triIdx+= pb.getNumIndexes()/3; @@ -2382,7 +2389,7 @@ CMesh::CCorner::CCorner() // *************************************************************************** -void CMesh::CCorner::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMesh::CCorner::serial(NLMISC::IStream &f) { nlassert(0); // not used f.serial(Vertex); @@ -2393,7 +2400,7 @@ void CMesh::CCorner::serial(NLMISC::IStream &f) throw(NLMISC::EStream) } // *************************************************************************** -void CMesh::CFace::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMesh::CFace::serial(NLMISC::IStream &f) { for(int i=0;i<3;++i) f.serial(Corner[i]); @@ -2402,7 +2409,7 @@ void CMesh::CFace::serial(NLMISC::IStream &f) throw(NLMISC::EStream) } // *************************************************************************** -void CMesh::CSkinWeight::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMesh::CSkinWeight::serial(NLMISC::IStream &f) { for(int i=0;i *pBSFactor) if (_VBOri == NULL) return; - if (BlendShapes.size() == 0) + if (BlendShapes.empty()) return; if (_VBOri->getNumVertices() != _VBDst->getNumVertices()) @@ -161,21 +164,21 @@ void CMeshMorpher::update (std::vector *pBSFactor) // Modify Pos/Norm/TgSpace. //------------ if (_VBDst->getVertexFormat() & CVertexBuffer::PositionFlag) - if (rBS.deltaPos.size() > 0) + if (!rBS.deltaPos.empty()) { CVector *pV = dstvba.getVertexCoordPointer (vp); *pV += rBS.deltaPos[j] * rFactor; } if (_VBDst->getVertexFormat() & CVertexBuffer::NormalFlag) - if (rBS.deltaNorm.size() > 0) + if (!rBS.deltaNorm.empty()) { CVector *pV = dstvba.getNormalCoordPointer (vp); *pV += rBS.deltaNorm[j] * rFactor; } if (_UseTgSpace) - if (rBS.deltaTgSpace.size() > 0) + if (!rBS.deltaTgSpace.empty()) { CVector *pV = (CVector*)dstvba.getTexCoordPointer (vp, tgSpaceStage); *pV += rBS.deltaTgSpace[j] * rFactor; @@ -184,14 +187,14 @@ void CMeshMorpher::update (std::vector *pBSFactor) // Modify UV0 / Color //------------ if (_VBDst->getVertexFormat() & CVertexBuffer::TexCoord0Flag) - if (rBS.deltaUV.size() > 0) + if (!rBS.deltaUV.empty()) { CUV *pUV = dstvba.getTexCoordPointer (vp); *pUV += rBS.deltaUV[j] * rFactor; } if (_VBDst->getVertexFormat() & CVertexBuffer::PrimaryColorFlag) - if (rBS.deltaCol.size() > 0) + if (!rBS.deltaCol.empty()) { // todo hulud d3d vertex color RGBA / BGRA CRGBA *pRGBA = (CRGBA*)dstvba.getColorPointer (vp); @@ -221,7 +224,7 @@ void CMeshMorpher::updateSkinned (std::vector *pBSFactor) if (_VBOri == NULL) return; - if (BlendShapes.size() == 0) + if (BlendShapes.empty()) return; if (_VBOri->getNumVertices() != _VBDst->getNumVertices()) @@ -289,21 +292,21 @@ void CMeshMorpher::updateSkinned (std::vector *pBSFactor) // Modify Pos/Norm/TgSpace. //------------ if (_Vertices != NULL) - if (rBS.deltaPos.size() > 0) + if (!rBS.deltaPos.empty()) { CVector *pV = &(_Vertices->operator[](vp)); *pV += rBS.deltaPos[j] * rFactor; } if (_Normals != NULL) - if (rBS.deltaNorm.size() > 0) + if (!rBS.deltaNorm.empty()) { CVector *pV = &(_Normals->operator[](vp)); *pV += rBS.deltaNorm[j] * rFactor; } if (_UseTgSpace && _TgSpace != NULL) - if (rBS.deltaTgSpace.size() > 0) + if (!rBS.deltaTgSpace.empty()) { CVector *pV = &((*_TgSpace)[vp]); *pV += rBS.deltaTgSpace[j] * rFactor; @@ -312,14 +315,14 @@ void CMeshMorpher::updateSkinned (std::vector *pBSFactor) // Modify UV0 / Color //------------ if (_VBDst->getVertexFormat() & CVertexBuffer::TexCoord0Flag) - if (rBS.deltaUV.size() > 0) + if (!rBS.deltaUV.empty()) { CUV *pUV = dstvba.getTexCoordPointer (vp); *pUV += rBS.deltaUV[j] * rFactor; } if (_VBDst->getVertexFormat() & CVertexBuffer::PrimaryColorFlag) - if (rBS.deltaCol.size() > 0) + if (!rBS.deltaCol.empty()) { // todo hulud d3d vertex color RGBA / BGRA CRGBA *pRGBA = (CRGBA*)dstvba.getColorPointer (vp); @@ -342,7 +345,7 @@ void CMeshMorpher::updateSkinned (std::vector *pBSFactor) } // *************************************************************************** -void CMeshMorpher::serial (NLMISC::IStream &f) throw(NLMISC::EStream) +void CMeshMorpher::serial (NLMISC::IStream &f) { /* *********************************************** * WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance @@ -368,7 +371,7 @@ void CMeshMorpher::updateRawSkin (CVertexBuffer *vbOri, if (vbOri == NULL) return; - if (BlendShapes.size() == 0) + if (BlendShapes.empty()) return; nlassert(vbOri->getVertexFormat() == (CVertexBuffer::PositionFlag | CVertexBuffer::NormalFlag |CVertexBuffer::TexCoord0Flag) ); diff --git a/code/nel/src/3d/mesh_mrm.cpp b/code/nel/src/3d/mesh_mrm.cpp index e5b61c966..f31720f35 100644 --- a/code/nel/src/3d/mesh_mrm.cpp +++ b/code/nel/src/3d/mesh_mrm.cpp @@ -38,6 +38,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -935,7 +938,7 @@ void CMeshMRMGeom::render(IDriver *drv, CTransformShape *trans, float polygonCou skeleton = mi->getSkeletonModel(); // The mesh must not be skinned for render() nlassert(!(_Skinned && mi->isSkinned() && skeleton)); - bool bMorphApplied = _MeshMorpher.BlendShapes.size() > 0; + bool bMorphApplied = !_MeshMorpher.BlendShapes.empty(); bool useTangentSpace = _MeshVertexProgram && _MeshVertexProgram->needTangentSpace(); @@ -1143,7 +1146,7 @@ void CMeshMRMGeom::renderSkin(CTransformShape *trans, float alphaMRM) skeleton = mi->getSkeletonModel(); // must be skinned for renderSkin() nlassert(_Skinned && mi->isSkinned() && skeleton); - bool bMorphApplied = _MeshMorpher.BlendShapes.size() > 0; + bool bMorphApplied = !_MeshMorpher.BlendShapes.empty(); bool useNormal= (_VBufferFinal.getVertexFormat() & CVertexBuffer::NormalFlag)!=0; bool useTangentSpace = _MeshVertexProgram && _MeshVertexProgram->needTangentSpace(); @@ -1309,7 +1312,7 @@ sint CMeshMRMGeom::renderSkinGroupGeom(CMeshMRMInstance *mi, float alphaMRM, uin skeleton = mi->getSkeletonModel(); // must be skinned for renderSkin() nlassert(_Skinned && mi->isSkinned() && skeleton); - bool bMorphApplied = _MeshMorpher.BlendShapes.size() > 0; + bool bMorphApplied = !_MeshMorpher.BlendShapes.empty(); bool useNormal= (_VBufferFinal.getVertexFormat() & CVertexBuffer::NormalFlag)!=0; nlassert(useNormal); @@ -1601,7 +1604,7 @@ void CMeshMRMGeom::updateShiftedTriangleCache(CMeshMRMInstance *mi, sint curLodI // *************************************************************************** -void CMeshMRMGeom::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMeshMRMGeom::serial(NLMISC::IStream &f) { // because of complexity, serial is separated in save / load. @@ -1615,7 +1618,7 @@ void CMeshMRMGeom::serial(NLMISC::IStream &f) throw(NLMISC::EStream) // *************************************************************************** -sint CMeshMRMGeom::loadHeader(NLMISC::IStream &f) throw(NLMISC::EStream) +sint CMeshMRMGeom::loadHeader(NLMISC::IStream &f) { /* Version 5: @@ -1745,7 +1748,7 @@ sint CMeshMRMGeom::loadHeader(NLMISC::IStream &f) throw(NLMISC::EStream) // *************************************************************************** -void CMeshMRMGeom::load(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMeshMRMGeom::load(NLMISC::IStream &f) { // Load the header of the stream. // ================== @@ -1775,7 +1778,7 @@ void CMeshMRMGeom::load(NLMISC::IStream &f) throw(NLMISC::EStream) // *************************************************************************** -void CMeshMRMGeom::save(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMeshMRMGeom::save(NLMISC::IStream &f) { /* Version 5: @@ -2965,7 +2968,7 @@ void CMeshMRM::render(IDriver *drv, CTransformShape *trans, bool passOpaque) // *************************************************************************** -void CMeshMRM::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMeshMRM::serial(NLMISC::IStream &f) { /* Version 0: diff --git a/code/nel/src/3d/mesh_mrm_instance.cpp b/code/nel/src/3d/mesh_mrm_instance.cpp index d97de135f..94acd1fe8 100644 --- a/code/nel/src/3d/mesh_mrm_instance.cpp +++ b/code/nel/src/3d/mesh_mrm_instance.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/mesh_mrm_skin_template.cpp b/code/nel/src/3d/mesh_mrm_skin_template.cpp index 63a0b67e8..792b8c5dc 100644 --- a/code/nel/src/3d/mesh_mrm_skin_template.cpp +++ b/code/nel/src/3d/mesh_mrm_skin_template.cpp @@ -20,6 +20,10 @@ #include "std3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // ace: before including this, #define this define to use it // the goal is to be able to compile every .cpp file with no // special case (GNU/Linux needs) diff --git a/code/nel/src/3d/mesh_mrm_skinned.cpp b/code/nel/src/3d/mesh_mrm_skinned.cpp index 11a1b41fc..a9d51a591 100644 --- a/code/nel/src/3d/mesh_mrm_skinned.cpp +++ b/code/nel/src/3d/mesh_mrm_skinned.cpp @@ -39,6 +39,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -301,7 +304,7 @@ void CMeshMRMSkinnedGeom::build(CMesh::CMeshBuild &m, // No Blend Shapes //================================================ - nlassert (meshBuildMRM.BlendShapes.size() == 0); + nlassert (meshBuildMRM.BlendShapes.empty()); // Compact bone id and build a bone id names //================================================ diff --git a/code/nel/src/3d/mesh_mrm_skinned_instance.cpp b/code/nel/src/3d/mesh_mrm_skinned_instance.cpp index a07cb5875..02c277571 100644 --- a/code/nel/src/3d/mesh_mrm_skinned_instance.cpp +++ b/code/nel/src/3d/mesh_mrm_skinned_instance.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/mesh_mrm_skinned_template.cpp b/code/nel/src/3d/mesh_mrm_skinned_template.cpp index 5d1b2f582..c6d25810e 100644 --- a/code/nel/src/3d/mesh_mrm_skinned_template.cpp +++ b/code/nel/src/3d/mesh_mrm_skinned_template.cpp @@ -20,6 +20,10 @@ #include "std3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // *************************************************************************** // *************************************************************************** // Raw "Vertex/Normal only" ApplySkin methods. diff --git a/code/nel/src/3d/mesh_multi_lod.cpp b/code/nel/src/3d/mesh_multi_lod.cpp index e26632f6e..b3d51cc52 100644 --- a/code/nel/src/3d/mesh_multi_lod.cpp +++ b/code/nel/src/3d/mesh_multi_lod.cpp @@ -35,6 +35,9 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -285,7 +288,7 @@ void CMeshMultiLod::render(IDriver *drv, CTransformShape *trans, bool passOpaque // *************************************************************************** -void CMeshMultiLod::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMeshMultiLod::serial(NLMISC::IStream &f) { /* *********************************************** * WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance @@ -402,7 +405,7 @@ void CMeshMultiLod::clear () // *************************************************************************** -void CMeshMultiLod::CMeshSlot::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMeshMultiLod::CMeshSlot::serial(NLMISC::IStream &f) { // Check version (void)f.serialVersion (0); diff --git a/code/nel/src/3d/mesh_multi_lod_instance.cpp b/code/nel/src/3d/mesh_multi_lod_instance.cpp index c6c8fa237..cf7805788 100644 --- a/code/nel/src/3d/mesh_multi_lod_instance.cpp +++ b/code/nel/src/3d/mesh_multi_lod_instance.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/mesh_vertex_program.cpp b/code/nel/src/3d/mesh_vertex_program.cpp deleted file mode 100644 index 6c46cec5f..000000000 --- a/code/nel/src/3d/mesh_vertex_program.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/mesh_vertex_program.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/meshvp_per_pixel_light.cpp b/code/nel/src/3d/meshvp_per_pixel_light.cpp index 9c5285bbd..3449d57d2 100644 --- a/code/nel/src/3d/meshvp_per_pixel_light.cpp +++ b/code/nel/src/3d/meshvp_per_pixel_light.cpp @@ -29,6 +29,9 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -570,7 +573,7 @@ void CMeshVPPerPixelLight::end(IDriver *drv) //================================================================================= -void CMeshVPPerPixelLight::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMeshVPPerPixelLight::serial(NLMISC::IStream &f) { (void)f.serialVersion(0); f.serial(SpecularLighting); diff --git a/code/nel/src/3d/meshvp_wind_tree.cpp b/code/nel/src/3d/meshvp_wind_tree.cpp index 1e3d215a3..620465a0a 100644 --- a/code/nel/src/3d/meshvp_wind_tree.cpp +++ b/code/nel/src/3d/meshvp_wind_tree.cpp @@ -28,6 +28,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -191,7 +194,7 @@ CMeshVPWindTree::~CMeshVPWindTree() // *************************************************************************** -void CMeshVPWindTree::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CMeshVPWindTree::serial(NLMISC::IStream &f) { (void)f.serialVersion(0); @@ -223,7 +226,8 @@ void CMeshVPWindTree::initVertexPrograms() { // setup of the VPLight fragment uint numPls= i/4; - bool normalize= (i&1)!=0; + // FIXME: normalize=true makes trees dance, workaround for issue #160 + bool normalize= false; //(i&1)!=0; bool specular= (i&2)!=0; // combine diff --git a/code/nel/src/3d/mini_col.cpp b/code/nel/src/3d/mini_col.cpp index 8b847afbf..e2c266349 100644 --- a/code/nel/src/3d/mini_col.cpp +++ b/code/nel/src/3d/mini_col.cpp @@ -19,9 +19,13 @@ #include "nel/3d/mini_col.h" #include "nel/misc/aabbox.h" #include "nel/3d/quad_grid.h" + using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/motion_blur.cpp b/code/nel/src/3d/motion_blur.cpp index e9fe1fdab..410ac8610 100644 --- a/code/nel/src/3d/motion_blur.cpp +++ b/code/nel/src/3d/motion_blur.cpp @@ -23,6 +23,9 @@ #include "nel/3d/texture_blank.h" #include "nel/3d/material.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mrm_builder.cpp b/code/nel/src/3d/mrm_builder.cpp index 3035aa78b..b035cae88 100644 --- a/code/nel/src/3d/mrm_builder.cpp +++ b/code/nel/src/3d/mrm_builder.cpp @@ -18,9 +18,13 @@ #include "nel/3d/mrm_builder.h" #include "nel/3d/mrm_parameters.h" + using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mrm_internal.cpp b/code/nel/src/3d/mrm_internal.cpp index b524fcf08..75a83874d 100644 --- a/code/nel/src/3d/mrm_internal.cpp +++ b/code/nel/src/3d/mrm_internal.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mrm_level_detail.cpp b/code/nel/src/3d/mrm_level_detail.cpp index 3314ec76e..4943b6e09 100644 --- a/code/nel/src/3d/mrm_level_detail.cpp +++ b/code/nel/src/3d/mrm_level_detail.cpp @@ -19,6 +19,9 @@ #include "nel/3d/mrm_level_detail.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mrm_mesh.cpp b/code/nel/src/3d/mrm_mesh.cpp index 0ad2f127f..03cdebeee 100644 --- a/code/nel/src/3d/mrm_mesh.cpp +++ b/code/nel/src/3d/mrm_mesh.cpp @@ -21,6 +21,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/mrm_parameters.cpp b/code/nel/src/3d/mrm_parameters.cpp deleted file mode 100644 index 8210475a5..000000000 --- a/code/nel/src/3d/mrm_parameters.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/mrm_parameters.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/nelu.cpp b/code/nel/src/3d/nelu.cpp index 6417e5abc..8cb6e0968 100644 --- a/code/nel/src/3d/nelu.cpp +++ b/code/nel/src/3d/nelu.cpp @@ -30,6 +30,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/noise_3d.cpp b/code/nel/src/3d/noise_3d.cpp index 5900e4750..3c5257c49 100644 --- a/code/nel/src/3d/noise_3d.cpp +++ b/code/nel/src/3d/noise_3d.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/packed_world.cpp b/code/nel/src/3d/packed_world.cpp index 15d59c724..830dc218e 100644 --- a/code/nel/src/3d/packed_world.cpp +++ b/code/nel/src/3d/packed_world.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -149,7 +153,7 @@ void CPackedWorld::getZones(std::vector &zones) } // ************************************************************************************************* -void CPackedWorld::serialZoneNames(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPackedWorld::serialZoneNames(NLMISC::IStream &f) { f.serialVersion(1); f.serialCheck(NELID("OWPA")); @@ -157,7 +161,7 @@ void CPackedWorld::serialZoneNames(NLMISC::IStream &f) throw(NLMISC::EStream) } // ************************************************************************************************* -void CPackedWorld::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPackedWorld::serial(NLMISC::IStream &f) { serialZoneNames(f); f.serialCont(_Zones); diff --git a/code/nel/src/3d/packed_zone.cpp b/code/nel/src/3d/packed_zone.cpp index 1c6bf4817..aa3eff11f 100644 --- a/code/nel/src/3d/packed_zone.cpp +++ b/code/nel/src/3d/packed_zone.cpp @@ -35,6 +35,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -586,7 +590,7 @@ CPackedZone32::CPackedZone32() } // *************************************************************************************** -void CPackedZone32::serial(NLMISC::IStream &f) throw (NLMISC::EStream) +void CPackedZone32::serial(NLMISC::IStream &f) { f.serialVersion(0); f.serial(Box); @@ -1082,7 +1086,7 @@ CSmartPtr CPackedZone32::buildPackedZone16() } // *************************************************************************************** -void CPackedZone16::serial(NLMISC::IStream &f) throw (NLMISC::EStream) +void CPackedZone16::serial(NLMISC::IStream &f) { f.serialVersion(0); f.serial(Box); diff --git a/code/nel/src/3d/particle_system.cpp b/code/nel/src/3d/particle_system.cpp index 34b75d427..2c10f279b 100644 --- a/code/nel/src/3d/particle_system.cpp +++ b/code/nel/src/3d/particle_system.cpp @@ -45,6 +45,9 @@ #define CHECK_INTEGRITY #endif +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif @@ -317,7 +320,7 @@ void CParticleSystem::setViewMat(const NLMISC::CMatrix &m) } ///======================================================================================= -bool CParticleSystem::hasEmitters(void) const +bool CParticleSystem::hasEmitters() const { NL_PS_FUNC_MAIN(CParticleSystem_hasEmitters) for (TProcessVect::const_iterator it = _ProcessVect.begin(); it != _ProcessVect.end(); ++it) @@ -749,7 +752,7 @@ void CParticleSystem::step(TPass pass, TAnimationTime ellapsedTime, CParticleSys ///======================================================================================= -void CParticleSystem::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CParticleSystem::serial(NLMISC::IStream &f) { CHECK_INTEGRITY NL_PS_FUNC_MAIN(CParticleSystem_serial) diff --git a/code/nel/src/3d/particle_system_manager.cpp b/code/nel/src/3d/particle_system_manager.cpp index e2e0eed8d..5778b2898 100644 --- a/code/nel/src/3d/particle_system_manager.cpp +++ b/code/nel/src/3d/particle_system_manager.cpp @@ -21,6 +21,9 @@ #include "nel/3d/scene.h" #include "nel/3d/skeleton_model.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/particle_system_model.cpp b/code/nel/src/3d/particle_system_model.cpp index 8b7f7d142..7736b7233 100644 --- a/code/nel/src/3d/particle_system_model.cpp +++ b/code/nel/src/3d/particle_system_model.cpp @@ -32,6 +32,9 @@ +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/particle_system_process.cpp b/code/nel/src/3d/particle_system_process.cpp index b0340ea0b..9317f6a6b 100644 --- a/code/nel/src/3d/particle_system_process.cpp +++ b/code/nel/src/3d/particle_system_process.cpp @@ -19,6 +19,10 @@ #include "nel/3d/particle_system_process.h" #include "nel/3d/particle_system.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + uint PSEnterLeaveDepth = 0; uint PSEnterLeaveMaxDepth = 1; std::string PSCurrName; @@ -125,7 +129,7 @@ const CFontManager *CParticleSystemProcess::getFontManager(void) const // *********************************************************************************************************** -void CParticleSystemProcess::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CParticleSystemProcess::serial(NLMISC::IStream &f) { NL_PS_FUNC(CParticleSystemProcess_serial) // version 2 : added matrix mode (just not fx world matrix or identity) diff --git a/code/nel/src/3d/particle_system_shape.cpp b/code/nel/src/3d/particle_system_shape.cpp index 7acbea6d4..7da2e85f1 100644 --- a/code/nel/src/3d/particle_system_shape.cpp +++ b/code/nel/src/3d/particle_system_shape.cpp @@ -33,6 +33,10 @@ #include "nel/3d/ps_face_look_at.h" #include "nel/3d/ps_force.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -113,7 +117,7 @@ CParticleSystemShape::CParticleSystemShape() : _MaxViewDist(100.f), } ///=========================================================================== -void CParticleSystemShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CParticleSystemShape::serial(NLMISC::IStream &f) { /* *********************************************** * WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance diff --git a/code/nel/src/3d/particle_system_sound_user.cpp b/code/nel/src/3d/particle_system_sound_user.cpp index b2ea9587e..5916bc964 100644 --- a/code/nel/src/3d/particle_system_sound_user.cpp +++ b/code/nel/src/3d/particle_system_sound_user.cpp @@ -23,6 +23,9 @@ #include "nel/3d/u_ps_sound_interface.h" #include "nel/3d/u_ps_sound_impl.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/patch.cpp b/code/nel/src/3d/patch.cpp index 4b0253ead..29f960a28 100644 --- a/code/nel/src/3d/patch.cpp +++ b/code/nel/src/3d/patch.cpp @@ -38,6 +38,10 @@ using namespace NLMISC; // Define this to remove user color (debug) // #define NEL_FORCE_NO_USER_COLOR +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/patch_lightmap.cpp b/code/nel/src/3d/patch_lightmap.cpp index bc14c7917..7a47085dd 100644 --- a/code/nel/src/3d/patch_lightmap.cpp +++ b/code/nel/src/3d/patch_lightmap.cpp @@ -30,9 +30,13 @@ #include "nel/misc/fast_floor.h" #include "nel/3d/light_influence_interpolator.h" #include "nel/3d/patchdlm_context.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/patch_noise.cpp b/code/nel/src/3d/patch_noise.cpp index ed87f2fe0..f0a491346 100644 --- a/code/nel/src/3d/patch_noise.cpp +++ b/code/nel/src/3d/patch_noise.cpp @@ -26,9 +26,13 @@ #include "nel/misc/common.h" #include "nel/3d/tile_noise_map.h" #include "nel/3d/patchuv_locator.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/patch_rdr_pass.cpp b/code/nel/src/3d/patch_rdr_pass.cpp index ada89ce35..607d8b4cf 100644 --- a/code/nel/src/3d/patch_rdr_pass.cpp +++ b/code/nel/src/3d/patch_rdr_pass.cpp @@ -19,6 +19,9 @@ #include "nel/3d/patch_rdr_pass.h" #include "nel/3d/index_buffer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/patch_render.cpp b/code/nel/src/3d/patch_render.cpp index ee916a3fe..de5d0b4ec 100644 --- a/code/nel/src/3d/patch_render.cpp +++ b/code/nel/src/3d/patch_render.cpp @@ -24,11 +24,17 @@ #include "nel/3d/landscape.h" #include "nel/3d/landscape_profile.h" #include "nel/3d/patchdlm_context.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/vector.h" #include "nel/misc/common.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/patch_vegetable.cpp b/code/nel/src/3d/patch_vegetable.cpp index 6729d3625..385b6f615 100644 --- a/code/nel/src/3d/patch_vegetable.cpp +++ b/code/nel/src/3d/patch_vegetable.cpp @@ -33,6 +33,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/patchdlm_context.cpp b/code/nel/src/3d/patchdlm_context.cpp index f7d2236e8..54a34dd92 100644 --- a/code/nel/src/3d/patchdlm_context.cpp +++ b/code/nel/src/3d/patchdlm_context.cpp @@ -31,6 +31,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/patchuv_locator.cpp b/code/nel/src/3d/patchuv_locator.cpp index 697ccfb72..b4743c4c1 100644 --- a/code/nel/src/3d/patchuv_locator.cpp +++ b/code/nel/src/3d/patchuv_locator.cpp @@ -21,6 +21,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/pixel_program.cpp b/code/nel/src/3d/pixel_program.cpp index 120e7def6..a11344055 100644 --- a/code/nel/src/3d/pixel_program.cpp +++ b/code/nel/src/3d/pixel_program.cpp @@ -27,6 +27,10 @@ #include "nel/3d/driver.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/play_list_manager.cpp b/code/nel/src/3d/play_list_manager.cpp index 636336cf3..0648984c5 100644 --- a/code/nel/src/3d/play_list_manager.cpp +++ b/code/nel/src/3d/play_list_manager.cpp @@ -18,6 +18,9 @@ #include "nel/3d/play_list_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/play_list_manager_user.cpp b/code/nel/src/3d/play_list_manager_user.cpp index c6991e914..4248a753f 100644 --- a/code/nel/src/3d/play_list_manager_user.cpp +++ b/code/nel/src/3d/play_list_manager_user.cpp @@ -21,6 +21,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/play_list_user.cpp b/code/nel/src/3d/play_list_user.cpp index 0a80a1076..6f2a2773d 100644 --- a/code/nel/src/3d/play_list_user.cpp +++ b/code/nel/src/3d/play_list_user.cpp @@ -19,12 +19,17 @@ #include "nel/3d/play_list_user.h" #include "nel/3d/animation_set_user.h" #include "nel/3d/u_transform.h" -#include "nel/misc/hierarchical_timer.h" +#include "nel/3d/transform.h" +#include "nel/misc/hierarchical_timer.h" #include "nel/misc/debug.h" using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/point_light.cpp b/code/nel/src/3d/point_light.cpp index e441e198e..ff0527689 100644 --- a/code/nel/src/3d/point_light.cpp +++ b/code/nel/src/3d/point_light.cpp @@ -24,6 +24,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/point_light_model.cpp b/code/nel/src/3d/point_light_model.cpp index df7e38234..17bb18619 100644 --- a/code/nel/src/3d/point_light_model.cpp +++ b/code/nel/src/3d/point_light_model.cpp @@ -25,6 +25,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/point_light_named.cpp b/code/nel/src/3d/point_light_named.cpp index ffee29eb8..f4a6a9cac 100644 --- a/code/nel/src/3d/point_light_named.cpp +++ b/code/nel/src/3d/point_light_named.cpp @@ -18,6 +18,9 @@ #include "nel/3d/point_light_named.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/point_light_named_array.cpp b/code/nel/src/3d/point_light_named_array.cpp index 0b91d7c46..0c6c34cc9 100644 --- a/code/nel/src/3d/point_light_named_array.cpp +++ b/code/nel/src/3d/point_light_named_array.cpp @@ -23,6 +23,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -92,7 +96,7 @@ void CPointLightNamedArray::build(const std::vector &pointLi // Regroup. // --------- _PointLightGroupMap.clear(); - if(_PointLights.size() > 0 ) + if (!_PointLights.empty()) { bool first= true; string precName; diff --git a/code/nel/src/3d/portal.cpp b/code/nel/src/3d/portal.cpp index deb80c5c5..096dcd129 100644 --- a/code/nel/src/3d/portal.cpp +++ b/code/nel/src/3d/portal.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -242,11 +246,11 @@ void CPortal::serial (NLMISC::IStream& f) { std::string occName = CStringMapper::unmap(_OcclusionModelId); if (occName == "no occlusion") - occName = ""; + occName.clear(); f.serial(occName); occName = CStringMapper::unmap(_OpenOcclusionModelId); if (occName == "no occlusion") - occName = ""; + occName.clear(); f.serial(occName); } } diff --git a/code/nel/src/3d/primitive_profile.cpp b/code/nel/src/3d/primitive_profile.cpp index ea23dbe1d..06b0c3bae 100644 --- a/code/nel/src/3d/primitive_profile.cpp +++ b/code/nel/src/3d/primitive_profile.cpp @@ -18,6 +18,9 @@ #include "nel/3d/primitive_profile.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/program.cpp b/code/nel/src/3d/program.cpp index 738b57550..7758feec6 100644 --- a/code/nel/src/3d/program.cpp +++ b/code/nel/src/3d/program.cpp @@ -42,6 +42,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // *************************************************************************** diff --git a/code/nel/src/3d/ps_allocator.cpp b/code/nel/src/3d/ps_allocator.cpp index dd79c750f..eb01e4754 100644 --- a/code/nel/src/3d/ps_allocator.cpp +++ b/code/nel/src/3d/ps_allocator.cpp @@ -18,6 +18,10 @@ #include "nel/3d/particle_system_process.h" #include "nel/3d/ps_allocator.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef PS_FAST_ALLOC diff --git a/code/nel/src/3d/ps_attrib_maker_bin_op.cpp b/code/nel/src/3d/ps_attrib_maker_bin_op.cpp index 8c029e407..a4e91163d 100644 --- a/code/nel/src/3d/ps_attrib_maker_bin_op.cpp +++ b/code/nel/src/3d/ps_attrib_maker_bin_op.cpp @@ -18,6 +18,9 @@ #include "nel/3d/ps_attrib_maker_bin_op.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_attrib_maker_helper.cpp b/code/nel/src/3d/ps_attrib_maker_helper.cpp index da1b96f94..aaa6b5a4d 100644 --- a/code/nel/src/3d/ps_attrib_maker_helper.cpp +++ b/code/nel/src/3d/ps_attrib_maker_helper.cpp @@ -17,12 +17,16 @@ #include "std3d.h" #include "nel/3d/ps_attrib_maker_helper.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // *********************************************************************************** -void CPSAttribMakerMemory::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSAttribMakerMemory::serial(NLMISC::IStream &f) { CPSAttribMakerMemoryBase::serial(f); if (f.isReading()) @@ -55,7 +59,7 @@ void CPSAttribMakerMemory::newElement(const CPSEmitterInfo &info) } // *********************************************************************************** -void CPSAttribMakerMemory::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSAttribMakerMemory::serial(NLMISC::IStream &f) { CPSAttribMakerMemoryBase::serial(f); if (f.isReading()) @@ -88,7 +92,7 @@ void CPSAttribMakerMemory::newElement(const CPSEmitterInfo &info) } // *********************************************************************************** -void CPSAttribMakerMemory::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSAttribMakerMemory::serial(NLMISC::IStream &f) { CPSAttribMakerMemoryBase::serial(f); if (f.isReading()) diff --git a/code/nel/src/3d/ps_attrib_maker_template.cpp b/code/nel/src/3d/ps_attrib_maker_template.cpp index 7790b8052..66fe5912d 100644 --- a/code/nel/src/3d/ps_attrib_maker_template.cpp +++ b/code/nel/src/3d/ps_attrib_maker_template.cpp @@ -18,6 +18,9 @@ #include "nel/3d/ps_attrib_maker_template.h" #include "nel/misc/system_info.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_color.cpp b/code/nel/src/3d/ps_color.cpp index f8014fe67..e93a85e4e 100644 --- a/code/nel/src/3d/ps_color.cpp +++ b/code/nel/src/3d/ps_color.cpp @@ -19,6 +19,9 @@ #include "nel/3d/ps_color.h" #include "nel/3d/ps_register_color_attribs.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -73,7 +76,7 @@ NLMISC::CRGBA CPSColorMemory::getDefaultValue(void) const } ///====================================================================================== -void CPSColorMemory::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSColorMemory::serial(NLMISC::IStream &f) { setColorType(CVertexBuffer::TRGBA); CPSAttribMakerMemory::serial(f); @@ -87,7 +90,7 @@ void CPSColorBinOp::setColorType(CVertexBuffer::TVertexColorType colorType) } ///====================================================================================== -void CPSColorBinOp::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSColorBinOp::serial(NLMISC::IStream &f) { setColorType(CVertexBuffer::TRGBA); CPSAttribMakerBinOp::serial(f); diff --git a/code/nel/src/3d/ps_dot.cpp b/code/nel/src/3d/ps_dot.cpp index 516cac8f1..3082e506b 100644 --- a/code/nel/src/3d/ps_dot.cpp +++ b/code/nel/src/3d/ps_dot.cpp @@ -21,8 +21,14 @@ #include "nel/3d/ps_iterator.h" #include "nel/3d/driver.h" #include "nel/3d/particle_system.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/fast_mem.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -284,7 +290,7 @@ void CPSDot::resize(uint32 size) } ///=================================================================== -void CPSDot::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSDot::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSDot_IStream ) diff --git a/code/nel/src/3d/ps_emitter.cpp b/code/nel/src/3d/ps_emitter.cpp index c9806722f..240be6f51 100644 --- a/code/nel/src/3d/ps_emitter.cpp +++ b/code/nel/src/3d/ps_emitter.cpp @@ -22,6 +22,10 @@ #include "nel/3d/dru.h" #include "nel/3d/particle_system.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -1901,9 +1905,9 @@ void CPSEmitter::resize(uint32 size) } ///========================================================================== -void CPSEmitter::bounceOccured(uint32 index, TAnimationTime timeToNextSimStep) +void CPSEmitter::bounceOccurred(uint32 index, TAnimationTime timeToNextSimStep) { - NL_PS_FUNC(CPSEmitter_bounceOccured) + NL_PS_FUNC(CPSEmitter_bounceOccurred) // TODO : avoid duplication with deleteElement if (_EmittedType && _EmissionType == CPSEmitter::onBounce) { @@ -1913,7 +1917,7 @@ void CPSEmitter::bounceOccured(uint32 index, TAnimationTime timeToNextSimStep) } ///========================================================================== -void CPSEmitter::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSEmitter::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSEmitter_serial) /// version 6 : the flag _EmitDirBasis no longer exist, it has been replaced by _UserMatrixModeForEmissionDirection @@ -2180,7 +2184,7 @@ bool CPSEmitter::testEmitForever() const // implementation of CPSModulatedEmitter // //////////////////////////////////////////// -void CPSModulatedEmitter::serialEmitteeSpeedScheme(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSModulatedEmitter::serialEmitteeSpeedScheme(NLMISC::IStream &f) { NL_PS_FUNC(CPSModulatedEmitter_IStream ) bool useScheme; @@ -2224,7 +2228,7 @@ void CPSEmitterOmni::emit(const NLMISC::CVector &srcPos, uint32 index, CVector & } ///========================================================================== -void CPSEmitterOmni::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSEmitterOmni::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSEmitterOmni_serial) f.serialVersion(1); @@ -2328,7 +2332,7 @@ void CPSEmitterDirectionnal::resize(uint32 capacity) } ///========================================================================== -void CPSEmitterDirectionnal::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSEmitterDirectionnal::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSEmitterDirectionnal_IStream ) f.serialVersion(1); @@ -2342,7 +2346,7 @@ void CPSEmitterDirectionnal::serial(NLMISC::IStream &f) throw(NLMISC::EStream) //////////////////////////////////////////// ///========================================================================== -void CPSEmitterRectangle::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSEmitterRectangle::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSEmitterRectangle_IStream ) f.serialVersion(1); @@ -2502,7 +2506,7 @@ void CPSEmitterRectangle::showTool(void) //////////////////////////////////// ///========================================================================== -void CPSEmitterConic::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSEmitterConic::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSEmitterConic_serial) f.serialVersion(1); @@ -2607,7 +2611,7 @@ CMatrix CPSSphericalEmitter::getMatrix(uint32 index) const } ///========================================================================== -void CPSSphericalEmitter::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSSphericalEmitter::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSSphericalEmitter_serial) f.serialVersion(1); @@ -2664,7 +2668,7 @@ void CPSSphericalEmitter::resize(uint32 size) ///////////////////////////////////// ///========================================================================== -void CPSRadialEmitter::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSRadialEmitter::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSRadialEmitter_serial) f.serialVersion(1); @@ -2797,7 +2801,7 @@ void CPSEmitter::doEmitOnce(uint firstInstanceIndex) startPos = _Owner->getParametricInfos()[k].Pos; } float currTime = _Owner->getTime()[k]; - _Owner->getTime()[k] = 0.f; // when emit occured, time was 0 + _Owner->getTime()[k] = 0.f; // when emit occurred, time was 0 sint32 nbToGenerate = (sint32) (emitLOD * *numToEmitPtr); if (nbToGenerate > 0) { @@ -2830,7 +2834,7 @@ void CPSEmitter::doEmitOnce(uint firstInstanceIndex) startPos = _Owner->getParametricInfos()[k].Pos; } float currTime = _Owner->getTime()[k]; - _Owner->getTime()[k] = 0.f; // when emit occured, time was 0 + _Owner->getTime()[k] = 0.f; // when emit occurred, time was 0 processEmitConsistent(startPos, k, nbToGenerate, _Owner->getAgeInSeconds(k) / CParticleSystem::RealEllapsedTimeRatio); // restore time & pos _Owner->getTime()[k] = currTime; diff --git a/code/nel/src/3d/ps_face.cpp b/code/nel/src/3d/ps_face.cpp index e87459acf..43bd921ab 100644 --- a/code/nel/src/3d/ps_face.cpp +++ b/code/nel/src/3d/ps_face.cpp @@ -21,9 +21,13 @@ #include "nel/3d/driver.h" #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/quat.h" - +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -289,7 +293,7 @@ void CPSFace::step(TPSProcessPass pass) ///====================================================================================== -void CPSFace::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSFace::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSFace_IStream ) f.serialVersion(1); diff --git a/code/nel/src/3d/ps_face_look_at.cpp b/code/nel/src/3d/ps_face_look_at.cpp index 5b06f6eb5..000db78e6 100644 --- a/code/nel/src/3d/ps_face_look_at.cpp +++ b/code/nel/src/3d/ps_face_look_at.cpp @@ -21,8 +21,13 @@ #include "nel/3d/driver.h" #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/fast_floor.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -991,7 +996,7 @@ void CPSFaceLookAt::resize(uint32 capacity) ///=========================================================================================== -void CPSFaceLookAt::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSFaceLookAt::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSFaceLookAt_serial) // version 4 : added 'align on z-axis' flag diff --git a/code/nel/src/3d/ps_fan_light.cpp b/code/nel/src/3d/ps_fan_light.cpp index 055826749..a2a0dcf0b 100644 --- a/code/nel/src/3d/ps_fan_light.cpp +++ b/code/nel/src/3d/ps_fan_light.cpp @@ -22,8 +22,12 @@ #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" #include "nel/3d/driver.h" +#include "nel/3d/debug_vb.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -389,7 +393,7 @@ void CPSFanLight::draw(bool opaque) } ///==================================================================================== -void CPSFanLight::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSFanLight::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSFanLight_serial) sint ver = f.serialVersion(2); diff --git a/code/nel/src/3d/ps_float.cpp b/code/nel/src/3d/ps_float.cpp index 079b98e43..7c364f2b8 100644 --- a/code/nel/src/3d/ps_float.cpp +++ b/code/nel/src/3d/ps_float.cpp @@ -20,6 +20,10 @@ #include "nel/3d/ps_register_float_attribs.h" #include "nel/misc/fast_floor.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -147,7 +151,7 @@ void CPSFloatCurveFunctor::updateTab(void) } ///======================================================================================= -void CPSFloatCurveFunctor::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSFloatCurveFunctor::serial(NLMISC::IStream &f) { f.serialVersion(1); f.serial(_NumSamples, _Smoothing); diff --git a/code/nel/src/3d/ps_force.cpp b/code/nel/src/3d/ps_force.cpp index bbef28663..fa42766b1 100644 --- a/code/nel/src/3d/ps_force.cpp +++ b/code/nel/src/3d/ps_force.cpp @@ -28,6 +28,10 @@ #include "nel/3d/ps_util.h" #include "nel/3d/ps_misc.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -41,7 +45,7 @@ CPSForce::CPSForce() -void CPSForce::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSForce::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSForce_serial) f.serialVersion(1); @@ -185,7 +189,7 @@ void CPSForceIntensity::setIntensityScheme(CPSAttribMaker *scheme) if (getForceIntensityOwner() && scheme->hasMemory()) scheme->resize(getForceIntensityOwner()->getMaxSize(), getForceIntensityOwner()->getSize()); } -void CPSForceIntensity::serialForceIntensity(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSForceIntensity::serialForceIntensity(NLMISC::IStream &f) { NL_PS_FUNC(CPSForceIntensity_IStream ) f.serialVersion(1); @@ -225,7 +229,7 @@ void CPSForceIntensity::serialForceIntensity(NLMISC::IStream &f) throw(NLMISC::E //////////////////////////////////////// -void CPSForceIntensityHelper::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSForceIntensityHelper::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSForceIntensityHelper_serial) f.serialVersion(1); @@ -316,7 +320,7 @@ void CPSDirectionnalForce::show() } } -void CPSDirectionnalForce::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSDirectionnalForce::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSDirectionnalForce_serial) // Version 2 : added link to a global vector value @@ -484,7 +488,7 @@ void CPSGravity::show() } -void CPSGravity::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSGravity::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSGravity_IStream ) f.serialVersion(1); @@ -743,7 +747,7 @@ void CPSCentralGravity::show() displayIcon2d(tab, tabSize, sSize); } -void CPSCentralGravity::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSCentralGravity::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSCentralGravity_IStream ) f.serialVersion(1); @@ -781,7 +785,7 @@ void CPSSpring::computeForces(CPSLocated &target) } -void CPSSpring::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSSpring::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSSpring_serial) f.serialVersion(1); @@ -917,7 +921,7 @@ CMatrix CPSCylindricVortex::getMatrix(uint32 index) const } -void CPSCylindricVortex::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSCylindricVortex::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSCylindricVortex_IStream ) f.serialVersion(1); @@ -956,7 +960,7 @@ void CPSCylindricVortex::resize(uint32 size) * a magnetic field that has the given direction */ -void CPSMagneticForce::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSMagneticForce::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSMagneticForce_serial) f.serialVersion(1); @@ -1365,7 +1369,7 @@ void CPSBrownianForce::computeForces(CPSLocated &target) } ///======================================================================= -void CPSBrownianForce::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSBrownianForce::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSBrownianForce_serial) sint ver = f.serialVersion(3); diff --git a/code/nel/src/3d/ps_int.cpp b/code/nel/src/3d/ps_int.cpp index 8c19bb0c0..ff1f3cc4a 100644 --- a/code/nel/src/3d/ps_int.cpp +++ b/code/nel/src/3d/ps_int.cpp @@ -19,6 +19,9 @@ #include "nel/3d/ps_int.h" #include "nel/3d/ps_register_int_attribs.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_light.cpp b/code/nel/src/3d/ps_light.cpp index 3cbe644be..48e579283 100644 --- a/code/nel/src/3d/ps_light.cpp +++ b/code/nel/src/3d/ps_light.cpp @@ -25,6 +25,10 @@ #include "nel/misc/matrix.h" #include "nel/misc/vector.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -68,7 +72,7 @@ CPSLight::~CPSLight() } // *************************************************************************************************************** -void CPSLight::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSLight::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSLight_serial) CPSLocatedBindable::serial(f); diff --git a/code/nel/src/3d/ps_located.cpp b/code/nel/src/3d/ps_located.cpp index 5409f3480..1af7b370d 100644 --- a/code/nel/src/3d/ps_located.cpp +++ b/code/nel/src/3d/ps_located.cpp @@ -48,6 +48,10 @@ #define CHECK_PS_INTEGRITY #endif +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -235,7 +239,7 @@ void CPSLocated::releaseAllRef() // If this happen, you can register with the registerDTorObserver // (observer pattern) // and override notifyTargetRemove to call releaseCollisionInfo - nlassert(_IntegrableForces.size() == 0); + nlassert(_IntegrableForces.empty()); nlassert(_NonIntegrableForceNbRefs == 0); CHECK_PS_INTEGRITY } @@ -476,7 +480,7 @@ uint CPSLocated::querryMaxWantedNumFaces(void) /// *************************************************************************************** /// tells whether there are alive entities / particles in the system -bool CPSLocated::hasParticles(void) const +bool CPSLocated::hasParticles() const { NL_PS_FUNC(CPSLocated_hasParticles) CHECK_PS_INTEGRITY @@ -490,7 +494,7 @@ bool CPSLocated::hasParticles(void) const /// *************************************************************************************** /// tells whether there are alive emitters -bool CPSLocated::hasEmitters(void) const +bool CPSLocated::hasEmitters() const { NL_PS_FUNC(CPSLocated_hasEmitters) CHECK_PS_INTEGRITY @@ -835,7 +839,7 @@ CPSLocated::~CPSLocated() // If this happen, you can register with the registerDTorObserver // (observer pattern) // and override notifyTargetRemove to call releaseCollisionInfo - nlassert(_IntegrableForces.size() == 0); + nlassert(_IntegrableForces.empty()); nlassert(_NonIntegrableForceNbRefs == 0); // delete all bindable @@ -1004,7 +1008,7 @@ void CPSLocated::postNewElement(const NLMISC::CVector &pos, const CPSCollisionInfo &ci = _Collisions[indexInEmitter]; if (ci.Dist != -1.f) { - // a collision occured, check time from collision to next time step + // a collision occurred, check time from collision to next time step if ((emitterLocated.getPos()[indexInEmitter] - ci.NewPos) * (pos - ci.NewPos) > 0.f) return; // discard emit that are farther than the collision } } @@ -1407,7 +1411,7 @@ void CPSLocated::resize(uint32 newSize) class CDummyCollision { public: - void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + void serial(NLMISC::IStream &f) { NL_PS_FUNC(CDummyCollision_serial) f.serialVersion(1); @@ -1418,7 +1422,7 @@ public: }; /// *************************************************************************************** -void CPSLocated::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSLocated::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSLocated_serial) @@ -1839,10 +1843,10 @@ void CPSLocated::updateCollisions() { _Pos[currCollision->Index] = currCollision->NewPos; std::swap(_Speed[currCollision->Index], currCollision->NewSpeed); // keep speed because may be needed when removing particles - // notify each located bindable that a bounce occured ... + // notify each located bindable that a bounce occurred ... for (TLocatedBoundCont::iterator it = _LocatedBoundCont.begin(); it != _LocatedBoundCont.end(); ++it) { - (*it)->bounceOccured(currCollision->Index, computeDateFromCollisionToNextSimStep(currCollision->Index, getAgeInSeconds(currCollision->Index))); + (*it)->bounceOccurred(currCollision->Index, computeDateFromCollisionToNextSimStep(currCollision->Index, getAgeInSeconds(currCollision->Index))); } if (currCollision->CollisionZone->getCollisionBehaviour() == CPSZone::destroy) { @@ -1878,13 +1882,13 @@ void CPSLocated::updateCollisions() // if particle is too old, check whether it died before the collision _Pos[currCollision->Index] = currCollision->NewPos; std::swap(_Speed[currCollision->Index], currCollision->NewSpeed); - // notify each located bindable that a bounce occured ... + // notify each located bindable that a bounce occurred ... if (!_LocatedBoundCont.empty()) { TAnimationTime timeFromcollisionToNextSimStep = computeDateFromCollisionToNextSimStep(currCollision->Index, getAgeInSeconds(currCollision->Index)); for (TLocatedBoundCont::iterator it = _LocatedBoundCont.begin(); it != _LocatedBoundCont.end(); ++it) { - (*it)->bounceOccured(currCollision->Index, timeFromcollisionToNextSimStep); + (*it)->bounceOccurred(currCollision->Index, timeFromcollisionToNextSimStep); } } if (currCollision->CollisionZone->getCollisionBehaviour() == CPSZone::destroy) @@ -2190,7 +2194,7 @@ void CPSLocated::removeOldParticles() TAnimationTime timeUntilNextSimStep; if (_Collisions[*it].Dist == -1.f) { - // no collision occured + // no collision occurred if (_Time[*it] > 1.f) { @@ -2213,18 +2217,18 @@ void CPSLocated::removeOldParticles() } else { - // a collision occured before particle died, so pos is already good + // a collision occurred before particle died, so pos is already good if (_LifeScheme) { timeUntilNextSimStep = computeDateFromCollisionToNextSimStep(*it, _Time[*it] / _TimeIncrement[*it]); - // compute age of particle when collision occured + // compute age of particle when collision occurred _Time[*it] -= timeUntilNextSimStep * _TimeIncrement[*it]; NLMISC::clamp(_Time[*it], 0.f, 1.f); // avoid imprecisions } else { timeUntilNextSimStep = computeDateFromCollisionToNextSimStep(*it, _Time[*it] * _InitialLife); - // compute age of particle when collision occured + // compute age of particle when collision occurred _Time[*it] -= timeUntilNextSimStep / (_InitialLife == 0.f ? 1.f : _InitialLife); NLMISC::clamp(_Time[*it], 0.f, 1.f); // avoid imprecisions } @@ -2706,7 +2710,7 @@ void CPSLocatedBindable::notifyTargetRemoved(CPSLocated *ptr) } /// *************************************************************************************** -void CPSLocatedBindable::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSLocatedBindable::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSLocatedBindable_IStream ) sint ver = f.serialVersion(4); @@ -2898,7 +2902,7 @@ void CPSLocatedBindable::releaseAllRef() ///////////////////////////////////////////// /// *************************************************************************************** -void CPSTargetLocatedBindable::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSTargetLocatedBindable::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSTargetLocatedBindable_serial) (void)f.serialVersion(1); diff --git a/code/nel/src/3d/ps_mesh.cpp b/code/nel/src/3d/ps_mesh.cpp index 5002f0054..6f21e2c25 100644 --- a/code/nel/src/3d/ps_mesh.cpp +++ b/code/nel/src/3d/ps_mesh.cpp @@ -29,11 +29,14 @@ #include "nel/3d/particle_system_shape.h" #include "nel/3d/particle_system_model.h" #include "nel/3d/ps_iterator.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/stream.h" #include "nel/misc/path.h" - - +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -155,7 +158,7 @@ static CMesh *CreateDummyMesh(void) //==================================================================================== -void CPSMesh::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSMesh::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSMesh_IStream ) (void)f.serialVersion(3); @@ -1113,11 +1116,13 @@ void CPSConstraintMesh::getShapesNames(std::string *shapesNames) const { const_cast(this)->update(); } +#ifdef NL_COMP_VC14 + std::copy(_MeshShapeFileName.begin(), _MeshShapeFileName.end(), stdext::make_unchecked_array_iterator(shapesNames)); +#else std::copy(_MeshShapeFileName.begin(), _MeshShapeFileName.end(), shapesNames); +#endif } - - //==================================================================================== void CPSConstraintMesh::setShape(uint index, const std::string &shapeName) { @@ -1128,7 +1133,6 @@ void CPSConstraintMesh::setShape(uint index, const std::string &shapeName) _ValidBuild = 0; } - //==================================================================================== const std::string &CPSConstraintMesh::getShape(uint index) const { @@ -1230,7 +1234,7 @@ bool CPSConstraintMesh::update(std::vector *numVertsVect /*= NULL*/) uint numVerts = 0; uint8 uvRouting[CVertexBuffer::MaxStage]; - if (_MeshShapeFileName.size() == 0) + if (_MeshShapeFileName.empty()) { _MeshShapeFileName.resize(1); _MeshShapeFileName[0] = DummyShapeName; @@ -1382,7 +1386,7 @@ bool CPSConstraintMesh::update(std::vector *numVertsVect /*= NULL*/) _GlobalAnimDate = _Owner->getOwner()->getSystemDate(); _Touched = 0; _ValidBuild = ok ? 1 : 0; - nlassert(_Meshes.size() > 0); + nlassert(!_Meshes.empty()); return ok; @@ -1444,7 +1448,7 @@ void CPSConstraintMesh::fillIndexesInPrecompBasis(void) //==================================================================================== /// serialisation. Derivers must override this, and call their parent version -void CPSConstraintMesh::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSConstraintMesh::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSConstraintMesh_IStream ) @@ -1487,7 +1491,7 @@ void CPSConstraintMesh::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { if (!f.isReading()) { - if (_MeshShapeFileName.size() > 0) + if (!_MeshShapeFileName.empty()) { f.serial(_MeshShapeFileName[0]); } @@ -1533,7 +1537,7 @@ void CPSConstraintMesh::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { PGlobalTexAnims newPtr(new CGlobalTexAnims); // create new //std::swap(_GlobalTexAnims, newPtr); // replace old - _GlobalTexAnims = newPtr; + _GlobalTexAnims = CUniquePtrMove(newPtr); f.serial(*_GlobalTexAnims); } @@ -1747,7 +1751,7 @@ void CPSConstraintMesh::draw(bool opaque) _Owner->incrementNbDrawnParticles(numToProcess); // for benchmark purpose - if (_PrecompBasis.size() == 0) /// do we deal with prerotated meshs ? + if (_PrecompBasis.empty()) /// do we deal with prerotated meshs ? { if (step == (1 << 16)) { @@ -2263,7 +2267,7 @@ CPSConstraintMesh::CGlobalTexAnim::CGlobalTexAnim() : TransOffset(NLMISC::CVecto } //===================================================================================== -void CPSConstraintMesh::CGlobalTexAnim::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSConstraintMesh::CGlobalTexAnim::serial(NLMISC::IStream &f) { NL_PS_FUNC(CGlobalTexAnim_IStream ) // version 1 : added offset @@ -2352,7 +2356,7 @@ void CPSConstraintMesh::setTexAnimType(TTexAnimType type) { PGlobalTexAnims newPtr(new CGlobalTexAnims); //std::swap(_GlobalTexAnims, newPtr); - _GlobalTexAnims = newPtr; + _GlobalTexAnims = CUniquePtrMove(newPtr); _GlobalAnimationEnabled = 1; } break; @@ -2361,7 +2365,7 @@ void CPSConstraintMesh::setTexAnimType(TTexAnimType type) } //===================================================================================== -void CPSConstraintMesh::CGlobalTexAnims::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSConstraintMesh::CGlobalTexAnims::serial(NLMISC::IStream &f) { NL_PS_FUNC(CGlobalTexAnims_IStream ) f.serialVersion(0); diff --git a/code/nel/src/3d/ps_particle.cpp b/code/nel/src/3d/ps_particle.cpp deleted file mode 100644 index fcab19f48..000000000 --- a/code/nel/src/3d/ps_particle.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/ps_particle.h" - -namespace NL3D -{ - /// NOTE : implementation of particles rendering has now been split accross vrious files... - -} // NL3D diff --git a/code/nel/src/3d/ps_particle2.cpp b/code/nel/src/3d/ps_particle2.cpp deleted file mode 100644 index 22e374620..000000000 --- a/code/nel/src/3d/ps_particle2.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/ps_particle2.h" - -namespace NL3D -{ - -} // NL3D diff --git a/code/nel/src/3d/ps_particle_basic.cpp b/code/nel/src/3d/ps_particle_basic.cpp index c2d6b6357..110b5963b 100644 --- a/code/nel/src/3d/ps_particle_basic.cpp +++ b/code/nel/src/3d/ps_particle_basic.cpp @@ -25,6 +25,9 @@ #include "nel/3d/particle_system.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -149,7 +152,7 @@ CPSColoredParticle::~CPSColoredParticle() } //======================================= -void CPSColoredParticle::serialColorScheme(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSColoredParticle::serialColorScheme(NLMISC::IStream &f) { NL_PS_FUNC(CPSColoredParticle_IStream ) f.serialVersion(1); @@ -210,7 +213,7 @@ CPSSizedParticle::~CPSSizedParticle() } //======================================= -void CPSSizedParticle::serialSizeScheme(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSSizedParticle::serialSizeScheme(NLMISC::IStream &f) { NL_PS_FUNC(CPSSizedParticle_serialSizeScheme) f.serialVersion(1); @@ -274,7 +277,7 @@ CPSRotated2DParticle::~CPSRotated2DParticle() } ///=================================================================================== -void CPSRotated2DParticle::serialAngle2DScheme(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSRotated2DParticle::serialAngle2DScheme(NLMISC::IStream &f) { NL_PS_FUNC(CPSRotated2DParticle_serialAngle2DScheme) f.serialVersion(1); @@ -384,7 +387,7 @@ CPSTexturedParticle::~CPSTexturedParticle() } ///=================================================================================== -void CPSTexturedParticle::serialTextureScheme(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSTexturedParticle::serialTextureScheme(NLMISC::IStream &f) { NL_PS_FUNC(CPSTexturedParticle_serialTextureScheme) f.serialVersion(1); @@ -486,7 +489,7 @@ CPSRotated3DPlaneParticle::~CPSRotated3DPlaneParticle() } ///=================================================================================== -void CPSRotated3DPlaneParticle::serialPlaneBasisScheme(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSRotated3DPlaneParticle::serialPlaneBasisScheme(NLMISC::IStream &f) { NL_PS_FUNC(CPSRotated3DPlaneParticle_serialPlaneBasisScheme) f.serialVersion(1); @@ -512,7 +515,7 @@ CPSMaterial::CPSMaterial() } ///=================================================================================== -void CPSMaterial::serialMaterial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSMaterial::serialMaterial(NLMISC::IStream &f) { NL_PS_FUNC(CPSMaterial_IStream ) // version 3 : added zbias @@ -723,7 +726,7 @@ void CPSMultiTexturedParticle::enableAlternateTex(bool enabled /*= true*/) } //======================================= -void CPSMultiTexturedParticle::serialMultiTex(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSMultiTexturedParticle::serialMultiTex(NLMISC::IStream &f) { NL_PS_FUNC(CPSMultiTexturedParticle_serialMultiTex) /// version 1 : bump factor diff --git a/code/nel/src/3d/ps_plane_basis_maker.cpp b/code/nel/src/3d/ps_plane_basis_maker.cpp index f1ca718b9..05df5821b 100644 --- a/code/nel/src/3d/ps_plane_basis_maker.cpp +++ b/code/nel/src/3d/ps_plane_basis_maker.cpp @@ -20,6 +20,10 @@ #include "nel/3d/ps_plane_basis_maker.h" #include "nel/3d/ps_register_plane_basis_attribs.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -316,7 +320,7 @@ uint32 CSpinnerFunctor::getNumSamples(void) const } ///============================================================================ -void CSpinnerFunctor::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CSpinnerFunctor::serial(NLMISC::IStream &f) { f.serialVersion(1); f.serial(_Axis, _NbSamples); diff --git a/code/nel/src/3d/ps_quad.cpp b/code/nel/src/3d/ps_quad.cpp index c517063e0..8ce6ce821 100644 --- a/code/nel/src/3d/ps_quad.cpp +++ b/code/nel/src/3d/ps_quad.cpp @@ -24,6 +24,10 @@ #include "nel/3d/particle_system.h" #include "nel/3d/ps_iterator.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -378,7 +382,7 @@ void CPSQuad::updateMatAndVbForColor(void) } //============================================================== -void CPSQuad::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSQuad::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSQuad_serial) sint ver = f.serialVersion(2); diff --git a/code/nel/src/3d/ps_register_attribs.cpp b/code/nel/src/3d/ps_register_attribs.cpp index 184c2f467..7fb616178 100644 --- a/code/nel/src/3d/ps_register_attribs.cpp +++ b/code/nel/src/3d/ps_register_attribs.cpp @@ -25,7 +25,9 @@ #include "nel/3d/ps_register_plane_basis_attribs.h" - +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_register_emitters.cpp b/code/nel/src/3d/ps_register_emitters.cpp index f5c0def3a..e2793f388 100644 --- a/code/nel/src/3d/ps_register_emitters.cpp +++ b/code/nel/src/3d/ps_register_emitters.cpp @@ -21,6 +21,9 @@ #include "nel/3d/ps_emitter.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_register_forces.cpp b/code/nel/src/3d/ps_register_forces.cpp index cb41f1fb8..7d9b1bcff 100644 --- a/code/nel/src/3d/ps_register_forces.cpp +++ b/code/nel/src/3d/ps_register_forces.cpp @@ -19,6 +19,10 @@ #include "nel/3d/ps_util.h" #include "nel/3d/ps_force.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { void CPSUtil::registerForces() diff --git a/code/nel/src/3d/ps_register_particles.cpp b/code/nel/src/3d/ps_register_particles.cpp index 6809d8c66..adbce5d36 100644 --- a/code/nel/src/3d/ps_register_particles.cpp +++ b/code/nel/src/3d/ps_register_particles.cpp @@ -22,6 +22,9 @@ #include "nel/3d/ps_particle2.h" #include "nel/3d/ps_mesh.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_register_zones.cpp b/code/nel/src/3d/ps_register_zones.cpp index 8996eaf99..73b28c0fb 100644 --- a/code/nel/src/3d/ps_register_zones.cpp +++ b/code/nel/src/3d/ps_register_zones.cpp @@ -21,6 +21,9 @@ #include "nel/3d/ps_zone.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_ribbon.cpp b/code/nel/src/3d/ps_ribbon.cpp index af907313f..499991b5e 100644 --- a/code/nel/src/3d/ps_ribbon.cpp +++ b/code/nel/src/3d/ps_ribbon.cpp @@ -24,6 +24,10 @@ #include "nel/3d/texture_mem.h" #include "nel/misc/matrix.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -36,7 +40,7 @@ CPSRibbon::TVBMap CPSRibbon::_VBMaps[16]; static ITexture *CreateGradientTexture() { NL_PS_FUNC(CreateGradientTexture) - std::auto_ptr tex(new CTextureMem((uint8 *) &GradientB2W, + CUniquePtr tex(new CTextureMem((uint8 *) &GradientB2W, sizeof(GradientB2W), false, /* dont delete */ false, /* not a file */ @@ -132,7 +136,7 @@ struct CDummy2DAngle : CPSRotated2DParticle }; ///================================================================================================================== -void CPSRibbon::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSRibbon::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSRibbon_serial) // Version 3 : - added brace mode @@ -1463,8 +1467,13 @@ void CPSRibbon::setShape(const CVector *shape, uint32 nbPointsInShape, bool brac ///================================================================================================================== void CPSRibbon::getShape(CVector *shape) const { - NL_PS_FUNC(CPSRibbon_getShape) + NL_PS_FUNC(CPSRibbon_getShape); + +#ifdef NL_COMP_VC14 + std::copy(_Shape.begin(), _Shape.end(), stdext::make_unchecked_array_iterator(shape)); +#else std::copy(_Shape.begin(), _Shape.end(), shape); +#endif } ///================================================================================================================== diff --git a/code/nel/src/3d/ps_ribbon_base.cpp b/code/nel/src/3d/ps_ribbon_base.cpp index 8f2a64932..e56ebc4d4 100644 --- a/code/nel/src/3d/ps_ribbon_base.cpp +++ b/code/nel/src/3d/ps_ribbon_base.cpp @@ -20,6 +20,12 @@ #include "nel/3d/ps_ribbon_base.h" #include "nel/3d/particle_system.h" +using namespace NLMISC; + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -744,7 +750,7 @@ void CPSRibbonBase::initDateVect() //======================================================= -void CPSRibbonBase::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSRibbonBase::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSRibbonBase_serial) CPSParticle::serial(f); diff --git a/code/nel/src/3d/ps_ribbon_look_at.cpp b/code/nel/src/3d/ps_ribbon_look_at.cpp index 966e5a5b1..d7c646fc9 100644 --- a/code/nel/src/3d/ps_ribbon_look_at.cpp +++ b/code/nel/src/3d/ps_ribbon_look_at.cpp @@ -20,6 +20,11 @@ #include "nel/3d/particle_system.h" #include "nel/3d/ps_macro.h" #include "nel/3d/driver.h" +#include "nel/3d/debug_vb.h" + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -56,7 +61,7 @@ CPSRibbonLookAt::~CPSRibbonLookAt() } //======================================================= -void CPSRibbonLookAt::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSRibbonLookAt::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSRibbonLookAt_serial) /** Version 4 : added CPSRibbonBase has a base class instead of CPSParticle diff --git a/code/nel/src/3d/ps_shockwave.cpp b/code/nel/src/3d/ps_shockwave.cpp index 20069e175..cc7547c45 100644 --- a/code/nel/src/3d/ps_shockwave.cpp +++ b/code/nel/src/3d/ps_shockwave.cpp @@ -22,7 +22,11 @@ #include "nel/3d/texture_grouped.h" #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" +#include "nel/3d/debug_vb.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -258,7 +262,7 @@ void CPSShockWave::setUFactor(float value) } ///================================================================================= -void CPSShockWave::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSShockWave::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSShockWave_serial) sint ver = f.serialVersion(2); diff --git a/code/nel/src/3d/ps_sound.cpp b/code/nel/src/3d/ps_sound.cpp index a5ae6ad26..d0b82adb2 100644 --- a/code/nel/src/3d/ps_sound.cpp +++ b/code/nel/src/3d/ps_sound.cpp @@ -21,6 +21,12 @@ #include "nel/3d/u_ps_sound_interface.h" #include "nel/3d/ps_attrib_maker.h" +using namespace NLMISC; + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -255,7 +261,7 @@ void CPSSound::setPitchScheme(CPSAttribMaker *pitch) } // *************************************************************************************************** -void CPSSound::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSSound::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSSound_serial) CPSLocatedBindable::serial(f); diff --git a/code/nel/src/3d/ps_tail_dot.cpp b/code/nel/src/3d/ps_tail_dot.cpp index 075c9a598..e8146e582 100644 --- a/code/nel/src/3d/ps_tail_dot.cpp +++ b/code/nel/src/3d/ps_tail_dot.cpp @@ -25,6 +25,10 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { static NLMISC::CRGBA GradientB2W[] = {NLMISC::CRGBA(0, 0, 0, 0), NLMISC::CRGBA(255, 255, 255, 255) }; @@ -33,7 +37,7 @@ static NLMISC::CRGBA GradientB2W[] = {NLMISC::CRGBA(0, 0, 0, 0), NLMISC::CRGBA(2 static ITexture *CreateGradientTexture() { NL_PS_FUNC(CreateGradientTexture) - std::auto_ptr tex(new CTextureMem((uint8 *) &GradientB2W, + CUniquePtr tex(new CTextureMem((uint8 *) &GradientB2W, sizeof(GradientB2W), false, /* dont delete */ false, /* not a file */ @@ -75,7 +79,7 @@ CPSTailDot::~CPSTailDot() } //======================================================= -void CPSTailDot::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSTailDot::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSTailDot_serial) diff --git a/code/nel/src/3d/ps_util.cpp b/code/nel/src/3d/ps_util.cpp index 94d67c777..b25f10e10 100644 --- a/code/nel/src/3d/ps_util.cpp +++ b/code/nel/src/3d/ps_util.cpp @@ -39,6 +39,9 @@ #include "nel/3d/particle_system_shape.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_zone.cpp b/code/nel/src/3d/ps_zone.cpp index 30349906f..7adf48b8f 100644 --- a/code/nel/src/3d/ps_zone.cpp +++ b/code/nel/src/3d/ps_zone.cpp @@ -32,6 +32,10 @@ #include #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -43,7 +47,7 @@ CPSZone::CPSZone() : _BounceFactor(1.f), _CollisionBehaviour(bounce) NL_PS_FUNC(CPSZone_CPSZone) } -void CPSZone::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSZone::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSZone_serial) f.serialVersion(1); @@ -276,7 +280,7 @@ void CPSZonePlane::setNormal(uint32 index, CVector n) -void CPSZonePlane::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSZonePlane::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSZonePlane_serial) f.serialVersion(1); @@ -416,7 +420,7 @@ CVector CPSZoneSphere::getScale(uint32 k) const } -void CPSZoneSphere::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSZoneSphere::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSZoneSphere_serial) f.serialVersion(1); @@ -596,7 +600,7 @@ CVector CPSZoneDisc::getScale(uint32 k) const } -void CPSZoneDisc::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSZoneDisc::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSZoneDisc_serial) f.serialVersion(1); @@ -1085,7 +1089,7 @@ void CPSZoneCylinder::setScale(uint32 index, const CVector &s) } -void CPSZoneCylinder::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSZoneCylinder::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSZoneCylinder_serial) f.serialVersion(1); @@ -1265,7 +1269,7 @@ CVector CPSZoneRectangle::getScale(uint32 index) const -void CPSZoneRectangle::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPSZoneRectangle::serial(NLMISC::IStream &f) { NL_PS_FUNC(CPSZoneRectangle_IStream ) f.serialVersion(1); diff --git a/code/nel/src/3d/ptr_set.cpp b/code/nel/src/3d/ptr_set.cpp deleted file mode 100644 index 57abfeaab..000000000 --- a/code/nel/src/3d/ptr_set.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/ptr_set.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/quad_effect.cpp b/code/nel/src/3d/quad_effect.cpp index a6c75c99d..63fd0565c 100644 --- a/code/nel/src/3d/quad_effect.cpp +++ b/code/nel/src/3d/quad_effect.cpp @@ -20,6 +20,10 @@ #include #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/quad_grid.cpp b/code/nel/src/3d/quad_grid.cpp index fca3ab95e..0240b4d0f 100644 --- a/code/nel/src/3d/quad_grid.cpp +++ b/code/nel/src/3d/quad_grid.cpp @@ -17,6 +17,10 @@ #include "std3d.h" #include "nel/3d/quad_grid.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { NLMISC::CPolygon2D CQuadGridBase::_ScaledPoly; diff --git a/code/nel/src/3d/quad_grid_clip_cluster.cpp b/code/nel/src/3d/quad_grid_clip_cluster.cpp index a6ab799c8..dd52ed111 100644 --- a/code/nel/src/3d/quad_grid_clip_cluster.cpp +++ b/code/nel/src/3d/quad_grid_clip_cluster.cpp @@ -25,6 +25,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/quad_grid_clip_manager.cpp b/code/nel/src/3d/quad_grid_clip_manager.cpp index 02c4fed62..0fe69e46e 100644 --- a/code/nel/src/3d/quad_grid_clip_manager.cpp +++ b/code/nel/src/3d/quad_grid_clip_manager.cpp @@ -28,6 +28,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/radix_sort.cpp b/code/nel/src/3d/radix_sort.cpp deleted file mode 100644 index 1143305c1..000000000 --- a/code/nel/src/3d/radix_sort.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/radix_sort.h" - - -namespace NL3D { - - -// To test compiling. -/*struct Pipo -{ - uint32 a; - uint32 getRadixKey() const {return a;} -}; - - -CRadixSort PipoSort; - -static void pipo() -{ - PipoSort.sort(NULL, NULL, 30); -}*/ - - -} // NL3D diff --git a/code/nel/src/3d/raw_skin.cpp b/code/nel/src/3d/raw_skin.cpp index 5ed069d50..e6788aa71 100644 --- a/code/nel/src/3d/raw_skin.cpp +++ b/code/nel/src/3d/raw_skin.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/raw_skinned.cpp b/code/nel/src/3d/raw_skinned.cpp index 3625ea928..5f05d5fb2 100644 --- a/code/nel/src/3d/raw_skinned.cpp +++ b/code/nel/src/3d/raw_skinned.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ray_mesh.cpp b/code/nel/src/3d/ray_mesh.cpp index b315979b1..3ba3461ee 100644 --- a/code/nel/src/3d/ray_mesh.cpp +++ b/code/nel/src/3d/ray_mesh.cpp @@ -19,11 +19,17 @@ #include "nel/3d/ray_mesh.h" #include "nel/misc/vector_2f.h" #include "nel/misc/fast_mem.h" +#include "nel/misc/plane.h" + #include "nel/3d/matrix_3x4.h" using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/register_3d.cpp b/code/nel/src/3d/register_3d.cpp index 2e9edbf41..82ac4502e 100644 --- a/code/nel/src/3d/register_3d.cpp +++ b/code/nel/src/3d/register_3d.cpp @@ -45,6 +45,9 @@ #include "nel/3d/packed_zone.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/render_target_manager.cpp b/code/nel/src/3d/render_target_manager.cpp index 4b552c62e..6012eeb8e 100644 --- a/code/nel/src/3d/render_target_manager.cpp +++ b/code/nel/src/3d/render_target_manager.cpp @@ -46,6 +46,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { struct CRenderTargetDescInt @@ -146,6 +150,7 @@ void CRenderTargetManager::cleanup() desc->TextureUser = NULL; desc->TextureInterface = NULL; // CSmartPtr m_RenderTargets.erase(m_RenderTargets.begin() + i); + delete desc; --i; } else diff --git a/code/nel/src/3d/render_trav.cpp b/code/nel/src/3d/render_trav.cpp index 0a9aa7a5f..cab2e3c00 100644 --- a/code/nel/src/3d/render_trav.cpp +++ b/code/nel/src/3d/render_trav.cpp @@ -39,6 +39,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/root_model.cpp b/code/nel/src/3d/root_model.cpp index cf6d68876..b1ff66cc8 100644 --- a/code/nel/src/3d/root_model.cpp +++ b/code/nel/src/3d/root_model.cpp @@ -19,6 +19,9 @@ #include "nel/3d/root_model.h" #include "nel/3d/scene.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/scene.cpp b/code/nel/src/3d/scene.cpp index 7c552efd4..25d9695c0 100644 --- a/code/nel/src/3d/scene.cpp +++ b/code/nel/src/3d/scene.cpp @@ -66,6 +66,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + #define NL3D_SCENE_COARSE_MANAGER_TEXTURE "nel_coarse_texture.tga" diff --git a/code/nel/src/3d/scene_group.cpp b/code/nel/src/3d/scene_group.cpp index fa67230d4..50e1f0171 100644 --- a/code/nel/src/3d/scene_group.cpp +++ b/code/nel/src/3d/scene_group.cpp @@ -36,6 +36,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -451,7 +455,6 @@ void CInstanceGroup::serial (NLMISC::IStream& f) _PointLightArray.clear(); } - if (version >= 2) f.serial(_GlobalPos); @@ -574,10 +577,11 @@ bool CInstanceGroup::addToScene (CScene& scene, IDriver *driver, uint selectedTe else { _Instances[i] = scene.createInstance (shapeName); - } - if( _Instances[i] == NULL ) - { - nlwarning("Not found '%s' file", shapeName.c_str()); + + if (_Instances[i] == NULL) + { + nlwarning("Not found '%s' file", shapeName.c_str()); + } } } } @@ -749,7 +753,7 @@ bool CInstanceGroup::addToSceneWhenAllShapesLoaded (CScene& scene, IDriver *driv for (i = 0; i < _Instances.size(); ++i) if (_Instances[i] != NULL && !_InstancesInfos[i].DontAddToScene) { - if (_InstancesInfos[i].Clusters.size() > 0) + if (!_InstancesInfos[i].Clusters.empty()) { _Instances[i]->clipUnlinkFromAll(); for (j = 0; j < _InstancesInfos[i].Clusters.size(); ++j) @@ -808,7 +812,7 @@ bool CInstanceGroup::addToSceneWhenAllShapesLoaded (CScene& scene, IDriver *driv // Register the instanceGroup for light animation // ----------------- // If some PointLight to animate - if(_PointLightArray.getPointLights().size() > 0) + if(!_PointLightArray.getPointLights().empty()) scene.addInstanceGroupForLightAnimation(this); _AddToSceneState = StateAdded; @@ -1036,7 +1040,7 @@ bool CInstanceGroup::removeFromScene (CScene& scene) // UnRegister the instanceGroup for light animation // ----------------- // If some PointLight to animate - if(_PointLightArray.getPointLights().size() > 0) + if(!_PointLightArray.getPointLights().empty()) scene.removeInstanceGroupForLightAnimation(this); if (_AddRemoveInstance) @@ -1113,7 +1117,7 @@ void CInstanceGroup::setClusterSystemForInstances(CInstanceGroup *pIG) { _ClusterSystemForInstances = pIG; for (uint32 i = 0; i < _Instances.size(); ++i) - if (_Instances[i] && _InstancesInfos[i].Clusters.size() == 0) + if (_Instances[i] && _InstancesInfos[i].Clusters.empty()) _Instances[i]->setClusterSystem (_ClusterSystemForInstances); } @@ -1121,7 +1125,7 @@ void CInstanceGroup::setClusterSystemForInstances(CInstanceGroup *pIG) void CInstanceGroup::getDynamicPortals (std::vector &names) { for (uint32 i = 0; i < _Portals.size(); ++i) - if (_Portals[i].getName() != "") + if (!_Portals[i].getName().empty()) names.push_back (_Portals[i].getName()); } diff --git a/code/nel/src/3d/scene_user.cpp b/code/nel/src/3d/scene_user.cpp index 0df2439de..c581c5c68 100644 --- a/code/nel/src/3d/scene_user.cpp +++ b/code/nel/src/3d/scene_user.cpp @@ -34,6 +34,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/scissor.cpp b/code/nel/src/3d/scissor.cpp deleted file mode 100644 index 99b39389f..000000000 --- a/code/nel/src/3d/scissor.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/scissor.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/seg_remanence.cpp b/code/nel/src/3d/seg_remanence.cpp index e0f9a52ae..be0b0d0cf 100644 --- a/code/nel/src/3d/seg_remanence.cpp +++ b/code/nel/src/3d/seg_remanence.cpp @@ -29,7 +29,9 @@ - +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/seg_remanence_shape.cpp b/code/nel/src/3d/seg_remanence_shape.cpp index cb70f8baa..eb546177c 100644 --- a/code/nel/src/3d/seg_remanence_shape.cpp +++ b/code/nel/src/3d/seg_remanence_shape.cpp @@ -24,6 +24,9 @@ #include "nel/misc/bsphere.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -44,7 +47,7 @@ CSegRemanenceShape::CSegRemanenceShape() : _GeomTouched(true), } //=========================================================== -void CSegRemanenceShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CSegRemanenceShape::serial(NLMISC::IStream &f) { // version 2 : added default tracks // version 1 : rollup ratio diff --git a/code/nel/src/3d/shadow_map.cpp b/code/nel/src/3d/shadow_map.cpp index 15f9b28e4..a9cad0496 100644 --- a/code/nel/src/3d/shadow_map.cpp +++ b/code/nel/src/3d/shadow_map.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/shadow_map_manager.cpp b/code/nel/src/3d/shadow_map_manager.cpp index e3f8fde99..c592b5a07 100644 --- a/code/nel/src/3d/shadow_map_manager.cpp +++ b/code/nel/src/3d/shadow_map_manager.cpp @@ -31,6 +31,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/shadow_poly_receiver.cpp b/code/nel/src/3d/shadow_poly_receiver.cpp index 3c832209e..7091310f7 100644 --- a/code/nel/src/3d/shadow_poly_receiver.cpp +++ b/code/nel/src/3d/shadow_poly_receiver.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/shadow_skin.cpp b/code/nel/src/3d/shadow_skin.cpp index 717d81f74..204e39d91 100644 --- a/code/nel/src/3d/shadow_skin.cpp +++ b/code/nel/src/3d/shadow_skin.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/shape.cpp b/code/nel/src/3d/shape.cpp index cf61185cd..93e0cccd7 100644 --- a/code/nel/src/3d/shape.cpp +++ b/code/nel/src/3d/shape.cpp @@ -25,6 +25,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -113,7 +116,7 @@ IShape* CShapeStream::getShapePointer () const // *************************************************************************** -void CShapeStream::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CShapeStream::serial(NLMISC::IStream &f) { // First, serial an header or checking if it is correct f.serialCheck (NELID("PAHS")); diff --git a/code/nel/src/3d/shape_bank.cpp b/code/nel/src/3d/shape_bank.cpp index 08eb867b5..61a65c423 100644 --- a/code/nel/src/3d/shape_bank.cpp +++ b/code/nel/src/3d/shape_bank.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -585,10 +589,7 @@ void CShapeBank::cancelLoadAsync (const std::string &shapeNameNotLwr) bool CShapeBank::isShapeWaiting () { - if (WaitingShapes.size() == 0) - return false; - else - return true; + return !WaitingShapes.empty(); } // *************************************************************************** diff --git a/code/nel/src/3d/shape_bank_user.cpp b/code/nel/src/3d/shape_bank_user.cpp index eb059d51b..5ded42d0d 100644 --- a/code/nel/src/3d/shape_bank_user.cpp +++ b/code/nel/src/3d/shape_bank_user.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/shape_info.cpp b/code/nel/src/3d/shape_info.cpp index 8a4d9cf80..d3a8a4df3 100644 --- a/code/nel/src/3d/shape_info.cpp +++ b/code/nel/src/3d/shape_info.cpp @@ -28,6 +28,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/shifted_triangle_cache.cpp b/code/nel/src/3d/shifted_triangle_cache.cpp index c98c5b103..85cf1313a 100644 --- a/code/nel/src/3d/shifted_triangle_cache.cpp +++ b/code/nel/src/3d/shifted_triangle_cache.cpp @@ -17,6 +17,9 @@ #include "std3d.h" #include "nel/3d/shifted_triangle_cache.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/skeleton_model.cpp b/code/nel/src/3d/skeleton_model.cpp index 8fbab5568..94b6fb896 100644 --- a/code/nel/src/3d/skeleton_model.cpp +++ b/code/nel/src/3d/skeleton_model.cpp @@ -36,6 +36,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/skeleton_shape.cpp b/code/nel/src/3d/skeleton_shape.cpp index 386b9ad1f..afa7701af 100644 --- a/code/nel/src/3d/skeleton_shape.cpp +++ b/code/nel/src/3d/skeleton_shape.cpp @@ -24,12 +24,16 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // *************************************************************************** -void CSkeletonShape::CLod::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CSkeletonShape::CLod::serial(NLMISC::IStream &f) { (void)f.serialVersion(0); @@ -171,7 +175,7 @@ CTransformShape *CSkeletonShape::createInstance(CScene &scene) } // *************************************************************************** -void CSkeletonShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CSkeletonShape::serial(NLMISC::IStream &f) { /* Version 1: diff --git a/code/nel/src/3d/skeleton_spawn_script.cpp b/code/nel/src/3d/skeleton_spawn_script.cpp index b77d044fc..d950b43a3 100644 --- a/code/nel/src/3d/skeleton_spawn_script.cpp +++ b/code/nel/src/3d/skeleton_spawn_script.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/skeleton_weight.cpp b/code/nel/src/3d/skeleton_weight.cpp index ba037236a..2f9c412c1 100644 --- a/code/nel/src/3d/skeleton_weight.cpp +++ b/code/nel/src/3d/skeleton_weight.cpp @@ -19,6 +19,9 @@ #include "nel/3d/skeleton_weight.h" #include "nel/misc/stream.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/static_quad_grid.cpp b/code/nel/src/3d/static_quad_grid.cpp deleted file mode 100644 index e45fca011..000000000 --- a/code/nel/src/3d/static_quad_grid.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/static_quad_grid.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/std3d.h b/code/nel/src/3d/std3d.h index 3fc5b55d6..d41f281ec 100644 --- a/code/nel/src/3d/std3d.h +++ b/code/nel/src/3d/std3d.h @@ -14,7 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "nel/misc/types_nl.h" +#ifndef NL_STD3D_H +#define NL_STD3D_H + +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif #include #include @@ -34,6 +42,9 @@ #include #include #include +#include + +#include "nel/misc/types_nl.h" #include "nel/misc/rgba.h" #include "nel/misc/debug.h" @@ -44,7 +55,4 @@ #include "nel/misc/matrix.h" #include "nel/misc/time_nl.h" -#include "nel/3d/debug_vb.h" -#include "nel/3d/transform.h" -#include "nel/3d/quad_grid.h" - +#endif diff --git a/code/nel/src/3d/stereo_debugger.cpp b/code/nel/src/3d/stereo_debugger.cpp index 138f8e3ae..c0c36eb74 100644 --- a/code/nel/src/3d/stereo_debugger.cpp +++ b/code/nel/src/3d/stereo_debugger.cpp @@ -47,6 +47,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { namespace { diff --git a/code/nel/src/3d/stereo_display.cpp b/code/nel/src/3d/stereo_display.cpp index dede3fbf6..6ff13b54c 100644 --- a/code/nel/src/3d/stereo_display.cpp +++ b/code/nel/src/3d/stereo_display.cpp @@ -42,6 +42,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { IStereoDisplay::IStereoDisplay() diff --git a/code/nel/src/3d/stereo_hmd.cpp b/code/nel/src/3d/stereo_hmd.cpp index 207965636..d5f29d107 100644 --- a/code/nel/src/3d/stereo_hmd.cpp +++ b/code/nel/src/3d/stereo_hmd.cpp @@ -38,6 +38,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { IStereoHMD::IStereoHMD() diff --git a/code/nel/src/3d/stereo_libvr.cpp b/code/nel/src/3d/stereo_libvr.cpp index 2f31beac4..d8c843dbf 100644 --- a/code/nel/src/3d/stereo_libvr.cpp +++ b/code/nel/src/3d/stereo_libvr.cpp @@ -54,6 +54,10 @@ extern "C" { using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { extern const char *g_StereoOVR_fp40; //TODO: what? diff --git a/code/nel/src/3d/stereo_ovr.cpp b/code/nel/src/3d/stereo_ovr.cpp index 103b44696..69a2b0db0 100644 --- a/code/nel/src/3d/stereo_ovr.cpp +++ b/code/nel/src/3d/stereo_ovr.cpp @@ -68,6 +68,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { extern const char *g_StereoOVR_fp40; diff --git a/code/nel/src/3d/stereo_ovr_04.cpp b/code/nel/src/3d/stereo_ovr_04.cpp index fcccc2f6b..2f382a176 100644 --- a/code/nel/src/3d/stereo_ovr_04.cpp +++ b/code/nel/src/3d/stereo_ovr_04.cpp @@ -68,6 +68,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { namespace { diff --git a/code/nel/src/3d/stereo_ovr_fp.cpp b/code/nel/src/3d/stereo_ovr_fp.cpp index 84a74598e..c9ca3c1cc 100644 --- a/code/nel/src/3d/stereo_ovr_fp.cpp +++ b/code/nel/src/3d/stereo_ovr_fp.cpp @@ -23,6 +23,10 @@ limitations under the License. #include "std3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { const char *g_StereoOVR_fp40 = "!!ARBfp1.0\n" diff --git a/code/nel/src/3d/stripifier.cpp b/code/nel/src/3d/stripifier.cpp index 96ac4e211..6453cbd1b 100644 --- a/code/nel/src/3d/stripifier.cpp +++ b/code/nel/src/3d/stripifier.cpp @@ -25,6 +25,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/surface_light_grid.cpp b/code/nel/src/3d/surface_light_grid.cpp index 9a4731c00..deec090a4 100644 --- a/code/nel/src/3d/surface_light_grid.cpp +++ b/code/nel/src/3d/surface_light_grid.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/tangent_space_build.cpp b/code/nel/src/3d/tangent_space_build.cpp index 8a1b1100a..f99a7537b 100644 --- a/code/nel/src/3d/tangent_space_build.cpp +++ b/code/nel/src/3d/tangent_space_build.cpp @@ -23,6 +23,9 @@ #include "nel/misc/triangle.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/target_anim_ctrl.cpp b/code/nel/src/3d/target_anim_ctrl.cpp index ea1eeeca0..8145fdb93 100644 --- a/code/nel/src/3d/target_anim_ctrl.cpp +++ b/code/nel/src/3d/target_anim_ctrl.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/tess_block.cpp b/code/nel/src/3d/tess_block.cpp index 3b3c7ec92..917e06a23 100644 --- a/code/nel/src/3d/tess_block.cpp +++ b/code/nel/src/3d/tess_block.cpp @@ -20,6 +20,9 @@ #include "nel/3d/patch_rdr_pass.h" #include "nel/3d/landscape_face_vector_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/tess_face_priority_list.cpp b/code/nel/src/3d/tess_face_priority_list.cpp index 8746a4791..a49c9af75 100644 --- a/code/nel/src/3d/tess_face_priority_list.cpp +++ b/code/nel/src/3d/tess_face_priority_list.cpp @@ -26,6 +26,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/tess_list.cpp b/code/nel/src/3d/tess_list.cpp deleted file mode 100644 index f5b8dc2b5..000000000 --- a/code/nel/src/3d/tess_list.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/tess_list.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/tessellation.cpp b/code/nel/src/3d/tessellation.cpp index 58171c40f..451e1013b 100644 --- a/code/nel/src/3d/tessellation.cpp +++ b/code/nel/src/3d/tessellation.cpp @@ -23,9 +23,13 @@ #include "nel/3d/landscape_profile.h" #include "nel/3d/landscape.h" #include "nel/3d/patchdlm_context.h" + using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -2530,7 +2534,7 @@ void CTessFace::refreshTesselationGeometry() // *************************************************************************** bool CTessFace::updateBindEdge(CTessFace *&edgeFace, bool &splitWanted) { - // Return true, when the bind should be Ok, or if a split has occured. + // Return true, when the bind should be Ok, or if a split has occurred. // Return false only if pointers are updated, without splits. if(edgeFace==NULL) diff --git a/code/nel/src/3d/text_context.cpp b/code/nel/src/3d/text_context.cpp index 1cca5145a..8cee144ca 100644 --- a/code/nel/src/3d/text_context.cpp +++ b/code/nel/src/3d/text_context.cpp @@ -19,6 +19,10 @@ #include "nel/3d/text_context.h" #include "nel/3d/font_generator.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // ------------------------------------------------------------------------------------------------ @@ -74,7 +78,7 @@ uint32 CTextContext::textPush (const char *format, ...) CComputedString csTmp; _CacheStrings.push_back (csTmp); - if (_CacheFreePlaces.size() == 0) + if (_CacheFreePlaces.empty()) _CacheFreePlaces.resize (1); _CacheFreePlaces[0] = (uint32)_CacheStrings.size()-1; _CacheNbFreePlaces = 1; @@ -100,7 +104,7 @@ uint32 CTextContext::textPush (const ucstring &str) CComputedString csTmp; _CacheStrings.push_back (csTmp); - if (_CacheFreePlaces.size() == 0) + if (_CacheFreePlaces.empty()) _CacheFreePlaces.resize (1); _CacheFreePlaces[0] = (uint32)_CacheStrings.size()-1; _CacheNbFreePlaces = 1; diff --git a/code/nel/src/3d/text_context_user.cpp b/code/nel/src/3d/text_context_user.cpp index 441d463f5..1834a93ce 100644 --- a/code/nel/src/3d/text_context_user.cpp +++ b/code/nel/src/3d/text_context_user.cpp @@ -19,6 +19,9 @@ #include "nel/3d/text_context_user.h" #include "nel/misc/hierarchical_timer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture.cpp b/code/nel/src/3d/texture.cpp index bd01f7650..c31fecdea 100644 --- a/code/nel/src/3d/texture.cpp +++ b/code/nel/src/3d/texture.cpp @@ -20,6 +20,9 @@ #include "nel/3d/driver.h" #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -133,7 +136,7 @@ ITextureDrvInfos::~ITextureDrvInfos() // *************************************************************************** -void ITexture::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void ITexture::serial(NLMISC::IStream &f) { /* Version 1: diff --git a/code/nel/src/3d/texture_blank.cpp b/code/nel/src/3d/texture_blank.cpp index f9b2b1210..febf30079 100644 --- a/code/nel/src/3d/texture_blank.cpp +++ b/code/nel/src/3d/texture_blank.cpp @@ -18,6 +18,9 @@ #include "nel/3d/texture_blank.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture_blend.cpp b/code/nel/src/3d/texture_blend.cpp index 765766119..aad39cc6d 100644 --- a/code/nel/src/3d/texture_blend.cpp +++ b/code/nel/src/3d/texture_blend.cpp @@ -19,6 +19,10 @@ #include "nel/3d/texture_blend.h" #include "nel/misc/common.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -108,7 +112,7 @@ void CTextureBlend::doGenerate(bool async) // ************************************************************************ -void CTextureBlend::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTextureBlend::serial(NLMISC::IStream &f) { f.serialVersion(0); ITexture::serial(f); diff --git a/code/nel/src/3d/texture_bloom.cpp b/code/nel/src/3d/texture_bloom.cpp deleted file mode 100644 index 52b0ce61c..000000000 --- a/code/nel/src/3d/texture_bloom.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/texture_bloom.h" - - -namespace NL3D { - - -} // NL3D diff --git a/code/nel/src/3d/texture_bump.cpp b/code/nel/src/3d/texture_bump.cpp index 887167de6..3707476b2 100644 --- a/code/nel/src/3d/texture_bump.cpp +++ b/code/nel/src/3d/texture_bump.cpp @@ -20,6 +20,9 @@ +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -159,7 +162,7 @@ void CTextureBump::setHeightMap(ITexture *heightMap) ///============================================================================================== -void CTextureBump::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTextureBump::serial(NLMISC::IStream &f) { /// version 2 : normalization flag sint ver = f.serialVersion(3); diff --git a/code/nel/src/3d/texture_cube.cpp b/code/nel/src/3d/texture_cube.cpp index fbcd425f9..34737af4f 100644 --- a/code/nel/src/3d/texture_cube.cpp +++ b/code/nel/src/3d/texture_cube.cpp @@ -25,6 +25,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -144,7 +147,7 @@ void CTextureCube::release() } // *************************************************************************** -void CTextureCube::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTextureCube::serial(NLMISC::IStream &f) { sint ver= f.serialVersion(2); @@ -193,7 +196,7 @@ bool CTextureCube::isSelectable() const ITexture *CTextureCube::buildNonSelectableVersion(uint index) { if (!isSelectable()) return this; - std::auto_ptr tc(new CTextureCube); + CUniquePtr tc(new CTextureCube); // copy basic texture parameters (ITexture &) *tc.get() = (ITexture &) *this; // invoke ITexture = op for basics parameters diff --git a/code/nel/src/3d/texture_dlm.cpp b/code/nel/src/3d/texture_dlm.cpp index 3e7695936..ab7168827 100644 --- a/code/nel/src/3d/texture_dlm.cpp +++ b/code/nel/src/3d/texture_dlm.cpp @@ -24,6 +24,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture_emboss.cpp b/code/nel/src/3d/texture_emboss.cpp index 414f93093..a106454f4 100644 --- a/code/nel/src/3d/texture_emboss.cpp +++ b/code/nel/src/3d/texture_emboss.cpp @@ -17,6 +17,12 @@ #include "std3d.h" #include "nel/3d/texture_emboss.h" +using namespace NLMISC; + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // *********************************************************************************************************** @@ -41,7 +47,7 @@ void CTextureEmboss::setHeightMap(ITexture *heightMap) } // *********************************************************************************************************** -void CTextureEmboss::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTextureEmboss::serial(NLMISC::IStream &f) { f.serialVersion(0); ITexture::serial(f); diff --git a/code/nel/src/3d/texture_far.cpp b/code/nel/src/3d/texture_far.cpp index d51d8fe43..594a79131 100644 --- a/code/nel/src/3d/texture_far.cpp +++ b/code/nel/src/3d/texture_far.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; using namespace NL3D; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { CRGBA CTextureFar::_LightmapExpanded[NL_NUM_PIXELS_ON_FAR_TILE_EDGE*NL_MAX_TILES_BY_PATCH_EDGE*NL_NUM_PIXELS_ON_FAR_TILE_EDGE*NL_MAX_TILES_BY_PATCH_EDGE]; diff --git a/code/nel/src/3d/texture_file.cpp b/code/nel/src/3d/texture_file.cpp index bed3b36d7..0e343ec8e 100644 --- a/code/nel/src/3d/texture_file.cpp +++ b/code/nel/src/3d/texture_file.cpp @@ -21,9 +21,13 @@ #include "nel/misc/path.h" #include "nel/misc/debug.h" #include "nel/misc/hierarchical_timer.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -236,7 +240,7 @@ void CTextureFile::doGenerate(bool async) // *************************************************************************** -void CTextureFile::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTextureFile::serial(NLMISC::IStream &f) { /* Version 1: diff --git a/code/nel/src/3d/texture_font.cpp b/code/nel/src/3d/texture_font.cpp index 4e9e3a0a4..cf46d025d 100644 --- a/code/nel/src/3d/texture_font.cpp +++ b/code/nel/src/3d/texture_font.cpp @@ -28,6 +28,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/texture_grouped.cpp b/code/nel/src/3d/texture_grouped.cpp index 1df0c7c7d..273d383e8 100644 --- a/code/nel/src/3d/texture_grouped.cpp +++ b/code/nel/src/3d/texture_grouped.cpp @@ -23,6 +23,10 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { std::map CTextureGrouped::_NameToSize; @@ -305,7 +309,7 @@ std::string CTextureGrouped::getShareName() const } ///===================================================================================================== -void CTextureGrouped::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTextureGrouped::serial(NLMISC::IStream &f) { f.serialVersion(1); diff --git a/code/nel/src/3d/texture_mem.cpp b/code/nel/src/3d/texture_mem.cpp index 9a51bd9ab..e2881e88e 100644 --- a/code/nel/src/3d/texture_mem.cpp +++ b/code/nel/src/3d/texture_mem.cpp @@ -21,6 +21,9 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture_multi_file.cpp b/code/nel/src/3d/texture_multi_file.cpp index 5968df550..cd05beb55 100644 --- a/code/nel/src/3d/texture_multi_file.cpp +++ b/code/nel/src/3d/texture_multi_file.cpp @@ -19,6 +19,9 @@ #include "nel/3d/texture_multi_file.h" #include "nel/3d/texture_file.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -79,7 +82,7 @@ void CTextureMultiFile::doGenerate(bool async) } ///=========================================================== -void CTextureMultiFile::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTextureMultiFile::serial(NLMISC::IStream &f) { (void)f.serialVersion(0); diff --git a/code/nel/src/3d/texture_near.cpp b/code/nel/src/3d/texture_near.cpp index 6c430f74e..e39279dd1 100644 --- a/code/nel/src/3d/texture_near.cpp +++ b/code/nel/src/3d/texture_near.cpp @@ -15,11 +15,14 @@ // along with this program. If not, see . #include "std3d.h" - - #include "nel/3d/texture_near.h" + using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/texture_user.cpp b/code/nel/src/3d/texture_user.cpp deleted file mode 100644 index 730becc22..000000000 --- a/code/nel/src/3d/texture_user.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/texture_user.h" - - -namespace NL3D -{ - - -void dummyToAvoidStupidCompilerWarning_texture_user_cpp() -{ -} - - -} // NL3D diff --git a/code/nel/src/3d/tile_bank.cpp b/code/nel/src/3d/tile_bank.cpp index d4e26ab06..e2c488fe5 100644 --- a/code/nel/src/3d/tile_bank.cpp +++ b/code/nel/src/3d/tile_bank.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -43,7 +47,7 @@ namespace NL3D // *************************************************************************** const sint CTileLand::_Version=0; // *************************************************************************** -void CTileLand::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTileLand::serial(NLMISC::IStream &f) { (void)f.serialVersion(_Version); @@ -87,7 +91,7 @@ CTileBank::CTileBank () _DisplacementMap[0].setEmpty (); } // *************************************************************************** -void CTileBank::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTileBank::serial(NLMISC::IStream &f) { f.serialCheck (std::string ("BANK")); @@ -134,7 +138,7 @@ void CTileBank::serial(NLMISC::IStream &f) throw(NLMISC::EStream) nlassert (f.isReading()); // Reset _AbsPath - _AbsPath=""; + _AbsPath.clear(); // Remove diffuse and additive in transition uint tileCount=(uint)getTileCount (); @@ -243,7 +247,7 @@ void CTileBank::freeTile (int tileIndex) nlassert (tileIndex<(sint)_TileVector.size()); // Free - _TileVector[tileIndex].free(); + _TileVector[tileIndex].freeBlock(); // Resize tile table int i; @@ -264,7 +268,7 @@ sint CTileBank::getNumBitmap (CTile::TBitmap bitmap) const if (!_TileVector[i].isFree()) { const std::string &str=_TileVector[i].getRelativeFileName (bitmap); - if (str!="") + if (!str.empty()) { std::vector vect (str.length()+1); memcpy (&*vect.begin(), str.c_str(), str.length()+1); @@ -437,7 +441,7 @@ void CTileBank::cleanUnusedData () // *************************************************************************** CTileNoiseMap *CTileBank::getTileNoiseMap (uint tileNumber, uint tileSubNoise) { - if (_DisplacementMap.size() == 0) + if (_DisplacementMap.empty()) { // it happens when serial a tile bank with version < 4 return NULL; @@ -583,7 +587,7 @@ void CTileBank::removeDisplacementMap (uint mapId) if (mapId==_DisplacementMap.size()-1) { // Resize the array ? - while ((mapId>0)&&(_DisplacementMap[mapId]._FileName=="")) + while ((mapId>0)&&(_DisplacementMap[mapId]._FileName.empty())) _DisplacementMap.resize (mapId--); } } @@ -608,7 +612,7 @@ uint CTileBank::getDisplacementMap (const string &fileName) for (noiseTile=0; noiseTile<_DisplacementMap.size(); noiseTile++) { // Same name ? - if (_DisplacementMap[noiseTile]._FileName=="") + if (_DisplacementMap[noiseTile]._FileName.empty()) break; } if (noiseTile==_DisplacementMap.size()) @@ -749,7 +753,7 @@ void CTileBank::postfixTileVegetableDesc (const char *postfix) // *************************************************************************** const sint CTile::_Version=4; // *************************************************************************** -void CTile::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTile::serial(NLMISC::IStream &f) { sint streamver = f.serialVersion(_Version); @@ -782,7 +786,7 @@ void CTile::serial(NLMISC::IStream &f) throw(NLMISC::EStream) _Flags=0; // Initialize alpha name - _BitmapName[alpha]=""; + _BitmapName[alpha].clear(); // Read free flag f.serial (tmp); @@ -804,7 +808,7 @@ void CTile::serial(NLMISC::IStream &f) throw(NLMISC::EStream) // *************************************************************************** void CTile::clearTile (CTile::TBitmap type) { - _BitmapName[type]=""; + _BitmapName[type].clear(); } @@ -912,7 +916,7 @@ const std::string& CTileSet::getName () const return _Name; } // *************************************************************************** -void CTileSet::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTileSet::serial(NLMISC::IStream &f) { sint streamver = f.serialVersion(_Version); @@ -1433,7 +1437,7 @@ void CTileSet::deleteBordersIfLast (const CTileBank& bank, CTile::TBitmap type) while (ite!=_Tile128.end()) { // If the file name is valid - if (bank.getTile (*ite)->getRelativeFileName(type)!="") + if (!bank.getTile (*ite)->getRelativeFileName(type).empty()) { // Don't delete, bDelete=false; @@ -1450,7 +1454,7 @@ void CTileSet::deleteBordersIfLast (const CTileBank& bank, CTile::TBitmap type) while (ite!=_Tile256.end()) { // If the file name is valid - if (bank.getTile (*ite)->getRelativeFileName(type)!="") + if (!bank.getTile (*ite)->getRelativeFileName(type).empty()) { // Don't delete, bDelete=false; @@ -1474,7 +1478,7 @@ void CTileSet::deleteBordersIfLast (const CTileBank& bank, CTile::TBitmap type) if (nTile!=-1) { // If the file name is valid - if (bank.getTile (nTile)->getRelativeFileName(type)!="") + if (!bank.getTile (nTile)->getRelativeFileName(type).empty()) { // Don't delete, bDelete=false; @@ -1521,7 +1525,7 @@ void CTileSet::setDisplacement (TDisplacement displacement, const std::string& f // *************************************************************************** void CTileSet::cleanUnusedData () { - _Name=""; + _Name.clear(); _ChildName.clear(); _Border128[0].reset (); _Border128[1].reset (); @@ -1564,7 +1568,7 @@ const CTileVegetableDesc &CTileSet::getTileVegetableDesc() const // *************************************************************************** void CTileSet::loadTileVegetableDesc() { - if(_TileVegetableDescFileName!="") + if(!_TileVegetableDescFileName.empty()) { try { @@ -1591,7 +1595,7 @@ void CTileSet::loadTileVegetableDesc() // *************************************************************************** const sint CTileBorder::_Version=0; // *************************************************************************** -void CTileBorder::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTileBorder::serial(NLMISC::IStream &f) { (void)f.serialVersion(_Version); @@ -1820,7 +1824,7 @@ void CTileBorder::rotate() // *************************************************************************** const sint CTileSetTransition::_Version=1; // *************************************************************************** -void CTileSetTransition::serial(class NLMISC::IStream &f) throw(EStream) +void CTileSetTransition::serial(NLMISC::IStream &f) { sint streamver = f.serialVersion(_Version); @@ -1853,14 +1857,12 @@ CTileNoise::CTileNoise () { // Not loaded _TileNoiseMap=NULL; - _FileName=""; } // *************************************************************************** CTileNoise::CTileNoise (const CTileNoise &src) { // Default ctor _TileNoiseMap=NULL; - _FileName=""; // Copy *this=src; @@ -1932,7 +1934,7 @@ void CTileNoise::reset() } // Erase filename - _FileName=""; + _FileName.clear(); } // *************************************************************************** diff --git a/code/nel/src/3d/tile_color.cpp b/code/nel/src/3d/tile_color.cpp deleted file mode 100644 index 41ee6d0c3..000000000 --- a/code/nel/src/3d/tile_color.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/tile_color.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/tile_element.cpp b/code/nel/src/3d/tile_element.cpp index 52216749e..6f89abf61 100644 --- a/code/nel/src/3d/tile_element.cpp +++ b/code/nel/src/3d/tile_element.cpp @@ -19,6 +19,9 @@ #include "nel/3d/tile_element.h" #include "nel/misc/debug.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/tile_far_bank.cpp b/code/nel/src/3d/tile_far_bank.cpp index e62903904..e86f18389 100644 --- a/code/nel/src/3d/tile_far_bank.cpp +++ b/code/nel/src/3d/tile_far_bank.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; // Define this to force white far texture (debug) // #define NEL_FORCE_WHITE_FAR_TEXTURE +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -35,7 +39,7 @@ namespace NL3D { // *************************************************************************** const sint CTileFarBank::CTileFar::_Version=0x0; // *************************************************************************** -void CTileFarBank::CTileFar::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTileFarBank::CTileFar::serial(NLMISC::IStream &f) { // Serial version (void)f.serialVersion(_Version); @@ -101,7 +105,7 @@ CTileFarBank::CTileFarBank() // *************************************************************************** const sint CTileFarBank::_Version=0x0; // *************************************************************************** -void CTileFarBank::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CTileFarBank::serial(NLMISC::IStream &f) { // Write/Check "FAR_BANK" in header of the stream f.serialCheck (NELID("_RAF")); diff --git a/code/nel/src/3d/tile_light_influence.cpp b/code/nel/src/3d/tile_light_influence.cpp index 55a44af66..53bc2e096 100644 --- a/code/nel/src/3d/tile_light_influence.cpp +++ b/code/nel/src/3d/tile_light_influence.cpp @@ -19,6 +19,9 @@ #include "nel/3d/tile_light_influence.h" #include "nel/misc/debug.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/tile_lumel.cpp b/code/nel/src/3d/tile_lumel.cpp index 41f770b6e..7eaa80199 100644 --- a/code/nel/src/3d/tile_lumel.cpp +++ b/code/nel/src/3d/tile_lumel.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/tile_noise_map.cpp b/code/nel/src/3d/tile_noise_map.cpp index 7d68d6a71..7b0d22dda 100644 --- a/code/nel/src/3d/tile_noise_map.cpp +++ b/code/nel/src/3d/tile_noise_map.cpp @@ -18,6 +18,9 @@ #include "nel/3d/tile_noise_map.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/tile_vegetable_desc.cpp b/code/nel/src/3d/tile_vegetable_desc.cpp index bad4ed517..849f19503 100644 --- a/code/nel/src/3d/tile_vegetable_desc.cpp +++ b/code/nel/src/3d/tile_vegetable_desc.cpp @@ -24,6 +24,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/track.cpp b/code/nel/src/3d/track.cpp index bf4dcddf5..a73186525 100644 --- a/code/nel/src/3d/track.cpp +++ b/code/nel/src/3d/track.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/track_keyframer.cpp b/code/nel/src/3d/track_keyframer.cpp index a3af79f1a..d3b5f6fb4 100644 --- a/code/nel/src/3d/track_keyframer.cpp +++ b/code/nel/src/3d/track_keyframer.cpp @@ -18,6 +18,9 @@ #include "nel/3d/track_keyframer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/track_sampled_common.cpp b/code/nel/src/3d/track_sampled_common.cpp index 372cf4f45..2fb7fc132 100644 --- a/code/nel/src/3d/track_sampled_common.cpp +++ b/code/nel/src/3d/track_sampled_common.cpp @@ -25,6 +25,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/track_sampled_quat.cpp b/code/nel/src/3d/track_sampled_quat.cpp index 1ef4e35b8..d49d63aa7 100644 --- a/code/nel/src/3d/track_sampled_quat.cpp +++ b/code/nel/src/3d/track_sampled_quat.cpp @@ -24,6 +24,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/track_sampled_quat_small_header.cpp b/code/nel/src/3d/track_sampled_quat_small_header.cpp index c9826d423..cb0a28f3b 100644 --- a/code/nel/src/3d/track_sampled_quat_small_header.cpp +++ b/code/nel/src/3d/track_sampled_quat_small_header.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/track_sampled_vector.cpp b/code/nel/src/3d/track_sampled_vector.cpp index 2e52764d2..3e19cac64 100644 --- a/code/nel/src/3d/track_sampled_vector.cpp +++ b/code/nel/src/3d/track_sampled_vector.cpp @@ -22,6 +22,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/transform.cpp b/code/nel/src/3d/transform.cpp index 0ec65360d..559a3c355 100644 --- a/code/nel/src/3d/transform.cpp +++ b/code/nel/src/3d/transform.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/transform_shape.cpp b/code/nel/src/3d/transform_shape.cpp index 5c9f730b7..014e997ab 100644 --- a/code/nel/src/3d/transform_shape.cpp +++ b/code/nel/src/3d/transform_shape.cpp @@ -31,6 +31,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/transformable.cpp b/code/nel/src/3d/transformable.cpp index 0061975bf..30ef19e36 100644 --- a/code/nel/src/3d/transformable.cpp +++ b/code/nel/src/3d/transformable.cpp @@ -19,6 +19,9 @@ #include "nel/3d/transformable.h" #include "nel/3d/channel_mixer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/trav_scene.cpp b/code/nel/src/3d/trav_scene.cpp deleted file mode 100644 index b909493cb..000000000 --- a/code/nel/src/3d/trav_scene.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/trav_scene.h" -#include "nel/3d/scene.h" - - - -namespace NL3D -{ - - -} // NL3D - - - - -/* End of trav_scene.cpp */ diff --git a/code/nel/src/3d/u_bone.cpp b/code/nel/src/3d/u_bone.cpp index 680411af7..1f0369929 100644 --- a/code/nel/src/3d/u_bone.cpp +++ b/code/nel/src/3d/u_bone.cpp @@ -19,6 +19,9 @@ #include "nel/3d/bone.h" #include "nel/3d/u_bone.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_camera.cpp b/code/nel/src/3d/u_camera.cpp index ec1a88eda..0a052205f 100644 --- a/code/nel/src/3d/u_camera.cpp +++ b/code/nel/src/3d/u_camera.cpp @@ -19,6 +19,9 @@ #include "nel/3d/u_camera.h" #include "nel/3d/camera.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_instance.cpp b/code/nel/src/3d/u_instance.cpp index 08ecb9933..cb2a273ed 100644 --- a/code/nel/src/3d/u_instance.cpp +++ b/code/nel/src/3d/u_instance.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/u_instance_material.cpp b/code/nel/src/3d/u_instance_material.cpp index b22cd5301..ba870a7fe 100644 --- a/code/nel/src/3d/u_instance_material.cpp +++ b/code/nel/src/3d/u_instance_material.cpp @@ -23,6 +23,9 @@ #include "nel/3d/texture_mem.h" #include "nel/3d/texture_file.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_material.cpp b/code/nel/src/3d/u_material.cpp index e881bbada..b6b9dccc4 100644 --- a/code/nel/src/3d/u_material.cpp +++ b/code/nel/src/3d/u_material.cpp @@ -22,6 +22,9 @@ #include "nel/3d/texture_user.h" #include "nel/3d/driver_user.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_particle_system_instance.cpp b/code/nel/src/3d/u_particle_system_instance.cpp index 77dee0ded..ea5794b19 100644 --- a/code/nel/src/3d/u_particle_system_instance.cpp +++ b/code/nel/src/3d/u_particle_system_instance.cpp @@ -22,6 +22,9 @@ #include "nel/3d/ps_emitter.h" #include "nel/3d/particle_system_model.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_point_light.cpp b/code/nel/src/3d/u_point_light.cpp index 8643a1ae0..5f4d8da97 100644 --- a/code/nel/src/3d/u_point_light.cpp +++ b/code/nel/src/3d/u_point_light.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/u_shape.cpp b/code/nel/src/3d/u_shape.cpp index 9f746dad0..eb179375e 100644 --- a/code/nel/src/3d/u_shape.cpp +++ b/code/nel/src/3d/u_shape.cpp @@ -25,6 +25,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_skeleton.cpp b/code/nel/src/3d/u_skeleton.cpp index b470f879c..e5dd29f4d 100644 --- a/code/nel/src/3d/u_skeleton.cpp +++ b/code/nel/src/3d/u_skeleton.cpp @@ -27,6 +27,9 @@ #include "nel/3d/scene.h" #include "nel/3d/shape_bank.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_transform.cpp b/code/nel/src/3d/u_transform.cpp index 8466c1e38..141986782 100644 --- a/code/nel/src/3d/u_transform.cpp +++ b/code/nel/src/3d/u_transform.cpp @@ -30,6 +30,10 @@ H_AUTO_DECL( NL3D_Transform_Set_Cluster_System ) using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/u_transformable.cpp b/code/nel/src/3d/u_transformable.cpp index 26f84c746..4561cce32 100644 --- a/code/nel/src/3d/u_transformable.cpp +++ b/code/nel/src/3d/u_transformable.cpp @@ -19,6 +19,9 @@ #include "nel/3d/u_transformable.h" #include "nel/3d/transformable.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_visual_collision_mesh.cpp b/code/nel/src/3d/u_visual_collision_mesh.cpp index 92f8d4af6..e51c89105 100644 --- a/code/nel/src/3d/u_visual_collision_mesh.cpp +++ b/code/nel/src/3d/u_visual_collision_mesh.cpp @@ -19,6 +19,9 @@ #include "nel/3d/u_visual_collision_mesh.h" #include "nel/3d/visual_collision_mesh.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_water.cpp b/code/nel/src/3d/u_water.cpp index 138a1f340..69326c87c 100644 --- a/code/nel/src/3d/u_water.cpp +++ b/code/nel/src/3d/u_water.cpp @@ -22,6 +22,9 @@ #include "nel/3d/water_model.h" #include "nel/3d/driver_user.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable.cpp b/code/nel/src/3d/vegetable.cpp index b1c708900..b6acf831f 100644 --- a/code/nel/src/3d/vegetable.cpp +++ b/code/nel/src/3d/vegetable.cpp @@ -25,6 +25,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable_blend_layer_model.cpp b/code/nel/src/3d/vegetable_blend_layer_model.cpp index 44754add2..9c3b9dd54 100644 --- a/code/nel/src/3d/vegetable_blend_layer_model.cpp +++ b/code/nel/src/3d/vegetable_blend_layer_model.cpp @@ -28,6 +28,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/vegetable_clip_block.cpp b/code/nel/src/3d/vegetable_clip_block.cpp index cf0d60e59..87d7b7535 100644 --- a/code/nel/src/3d/vegetable_clip_block.cpp +++ b/code/nel/src/3d/vegetable_clip_block.cpp @@ -18,6 +18,9 @@ #include "nel/3d/vegetable_clip_block.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable_def.cpp b/code/nel/src/3d/vegetable_def.cpp deleted file mode 100644 index 74182b413..000000000 --- a/code/nel/src/3d/vegetable_def.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/vegetable_def.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/vegetable_instance_group.cpp b/code/nel/src/3d/vegetable_instance_group.cpp index debd78763..2e48f740a 100644 --- a/code/nel/src/3d/vegetable_instance_group.cpp +++ b/code/nel/src/3d/vegetable_instance_group.cpp @@ -18,6 +18,9 @@ #include "nel/3d/vegetable_instance_group.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable_light_ex.cpp b/code/nel/src/3d/vegetable_light_ex.cpp index e663bddda..dc2109e96 100644 --- a/code/nel/src/3d/vegetable_light_ex.cpp +++ b/code/nel/src/3d/vegetable_light_ex.cpp @@ -19,6 +19,9 @@ #include "nel/3d/vegetable_light_ex.h" #include "nel/3d/point_light_named.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable_manager.cpp b/code/nel/src/3d/vegetable_manager.cpp index e479a5e62..8946bc67b 100644 --- a/code/nel/src/3d/vegetable_manager.cpp +++ b/code/nel/src/3d/vegetable_manager.cpp @@ -35,6 +35,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -747,7 +750,7 @@ void CVegetableManager::deleteClipBlock(CVegetableClipBlock *clipBlock) _EmptyClipBlockList.remove(clipBlock); // delete - _ClipBlockMemory.free(clipBlock); + _ClipBlockMemory.freeBlock(clipBlock); } @@ -782,7 +785,7 @@ void CVegetableManager::deleteSortBlock(CVegetableSortBlock *sortBlock) sortBlock->_Owner->_SortBlockList.remove(sortBlock); // delete - _SortBlockMemory.free(sortBlock); + _SortBlockMemory.freeBlock(sortBlock); } @@ -878,7 +881,7 @@ void CVegetableManager::deleteIg(CVegetableInstanceGroup *ig) // unlink from sortBlock, and delete. sortBlock->_InstanceGroupList.remove(ig); - _InstanceGroupMemory.free(ig); + _InstanceGroupMemory.freeBlock(ig); // decRef the clipBlock diff --git a/code/nel/src/3d/vegetable_quadrant.cpp b/code/nel/src/3d/vegetable_quadrant.cpp index 1246a1a0c..ac83e0a99 100644 --- a/code/nel/src/3d/vegetable_quadrant.cpp +++ b/code/nel/src/3d/vegetable_quadrant.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/vegetable_shape.cpp b/code/nel/src/3d/vegetable_shape.cpp index 7d9991b65..3e4c2b7f0 100644 --- a/code/nel/src/3d/vegetable_shape.cpp +++ b/code/nel/src/3d/vegetable_shape.cpp @@ -24,6 +24,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable_sort_block.cpp b/code/nel/src/3d/vegetable_sort_block.cpp index cbd82aa2b..1ba562cda 100644 --- a/code/nel/src/3d/vegetable_sort_block.cpp +++ b/code/nel/src/3d/vegetable_sort_block.cpp @@ -25,6 +25,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/vegetable_uv8.cpp b/code/nel/src/3d/vegetable_uv8.cpp deleted file mode 100644 index a1d1fec32..000000000 --- a/code/nel/src/3d/vegetable_uv8.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/vegetable_uv8.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/vegetablevb_allocator.cpp b/code/nel/src/3d/vegetablevb_allocator.cpp index f5c833d8a..ff5dc293f 100644 --- a/code/nel/src/3d/vegetablevb_allocator.cpp +++ b/code/nel/src/3d/vegetablevb_allocator.cpp @@ -19,11 +19,16 @@ #include "nel/3d/vegetablevb_allocator.h" #include "nel/3d/vegetable_def.h" +#include "nel/3d/debug_vb.h" using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/vertex_buffer.cpp b/code/nel/src/3d/vertex_buffer.cpp index fc09dc956..bdc9d495f 100644 --- a/code/nel/src/3d/vertex_buffer.cpp +++ b/code/nel/src/3d/vertex_buffer.cpp @@ -20,8 +20,12 @@ #include "nel/misc/vector.h" #include "nel/misc/fast_mem.h" #include "nel/3d/driver.h" + using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -885,7 +889,7 @@ void CVertexBuffer::serialHeader(NLMISC::IStream &f) if(f.isReading()) { _PreferredMemory = RAMPreferred; - _Name = ""; + _Name.clear(); } } } diff --git a/code/nel/src/3d/vertex_buffer_heap.cpp b/code/nel/src/3d/vertex_buffer_heap.cpp index 178efc9a8..e33a6757c 100644 --- a/code/nel/src/3d/vertex_buffer_heap.cpp +++ b/code/nel/src/3d/vertex_buffer_heap.cpp @@ -21,6 +21,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // This code is not used actually and doesn't compile // just preproc comment it #if 0 diff --git a/code/nel/src/3d/vertex_program.cpp b/code/nel/src/3d/vertex_program.cpp index d0c0cfb79..dc717b825 100644 --- a/code/nel/src/3d/vertex_program.cpp +++ b/code/nel/src/3d/vertex_program.cpp @@ -20,6 +20,9 @@ #include "nel/3d/driver.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vertex_program_parse.cpp b/code/nel/src/3d/vertex_program_parse.cpp index 0e144d54f..f4598659b 100644 --- a/code/nel/src/3d/vertex_program_parse.cpp +++ b/code/nel/src/3d/vertex_program_parse.cpp @@ -17,6 +17,10 @@ #include "std3d.h" #include "nel/3d/vertex_program_parse.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + enum TArguments { #ifdef NL_LITTLE_ENDIAN @@ -1110,7 +1114,7 @@ static void dumpWriteMask(uint mask, std::string &out) { if (mask == 0xf) { - out = ""; + out.clear(); return; } out = "."; @@ -1125,7 +1129,7 @@ static void dumpSwizzle(const CVPSwizzle &swz, std::string &out) { if (swz.isIdentity()) { - out = ""; + out.clear(); return; } out = "."; diff --git a/code/nel/src/3d/vertex_stream_manager.cpp b/code/nel/src/3d/vertex_stream_manager.cpp index 0acb54144..74d2727dd 100644 --- a/code/nel/src/3d/vertex_stream_manager.cpp +++ b/code/nel/src/3d/vertex_stream_manager.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/viewport.cpp b/code/nel/src/3d/viewport.cpp index b84d1d713..6eccdeaca 100644 --- a/code/nel/src/3d/viewport.cpp +++ b/code/nel/src/3d/viewport.cpp @@ -21,6 +21,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/visual_collision_entity.cpp b/code/nel/src/3d/visual_collision_entity.cpp index dcae15aef..8f3b97e68 100644 --- a/code/nel/src/3d/visual_collision_entity.cpp +++ b/code/nel/src/3d/visual_collision_entity.cpp @@ -29,6 +29,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/visual_collision_entity_user.cpp b/code/nel/src/3d/visual_collision_entity_user.cpp index 89b44f22f..d13ca57c2 100644 --- a/code/nel/src/3d/visual_collision_entity_user.cpp +++ b/code/nel/src/3d/visual_collision_entity_user.cpp @@ -20,6 +20,9 @@ #include "nel/3d/driver_user.h" #include "nel/misc/hierarchical_timer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/visual_collision_manager.cpp b/code/nel/src/3d/visual_collision_manager.cpp index cafc9948e..6d914464f 100644 --- a/code/nel/src/3d/visual_collision_manager.cpp +++ b/code/nel/src/3d/visual_collision_manager.cpp @@ -28,6 +28,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -98,7 +101,7 @@ CVisualTileDescNode *CVisualCollisionManager::newVisualTileDescNode() // *************************************************************************** void CVisualCollisionManager::deleteVisualTileDescNode(CVisualTileDescNode *ptr) { - _TileDescNodeAllocator.free(ptr); + _TileDescNodeAllocator.freeBlock(ptr); } // *************************************************************************** @@ -110,7 +113,7 @@ CPatchQuadBlock *CVisualCollisionManager::newPatchQuadBlock() // *************************************************************************** void CVisualCollisionManager::deletePatchQuadBlock(CPatchQuadBlock *ptr) { - _PatchQuadBlockAllocator.free(ptr); + _PatchQuadBlockAllocator.freeBlock(ptr); } diff --git a/code/nel/src/3d/visual_collision_manager_user.cpp b/code/nel/src/3d/visual_collision_manager_user.cpp index 800080706..b1ae7923d 100644 --- a/code/nel/src/3d/visual_collision_manager_user.cpp +++ b/code/nel/src/3d/visual_collision_manager_user.cpp @@ -19,6 +19,9 @@ #include "nel/3d/visual_collision_manager_user.h" #include "nel/3d/u_visual_collision_mesh.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/visual_collision_mesh.cpp b/code/nel/src/3d/visual_collision_mesh.cpp index 3217a560f..8de722a2b 100644 --- a/code/nel/src/3d/visual_collision_mesh.cpp +++ b/code/nel/src/3d/visual_collision_mesh.cpp @@ -26,6 +26,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif // TestYoyo. external debug flag bool TESTYOYO_VCM_RedShadow= false; diff --git a/code/nel/src/3d/water_env_map.cpp b/code/nel/src/3d/water_env_map.cpp index a1b954764..9592f2948 100644 --- a/code/nel/src/3d/water_env_map.cpp +++ b/code/nel/src/3d/water_env_map.cpp @@ -24,6 +24,10 @@ #include "nel/misc/common.h" #include "nel/3d/viewport.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/water_env_map_user.cpp b/code/nel/src/3d/water_env_map_user.cpp index d1f9e9961..446ade3b8 100644 --- a/code/nel/src/3d/water_env_map_user.cpp +++ b/code/nel/src/3d/water_env_map_user.cpp @@ -19,6 +19,10 @@ #include "nel/3d/u_scene.h" #include "nel/3d/u_camera.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { ////////////////////// diff --git a/code/nel/src/3d/water_height_map.cpp b/code/nel/src/3d/water_height_map.cpp index 9ab5a31f3..5f67ffce3 100644 --- a/code/nel/src/3d/water_height_map.cpp +++ b/code/nel/src/3d/water_height_map.cpp @@ -24,6 +24,9 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -73,7 +76,7 @@ void CWaterHeightMap::updateUserPos() nlassert(_Size != 0); if ((uint) x == _X && (uint) y == _Y) return; - if ((uint) abs((long int)(x - _X)) < _Size && (uint) abs((long int)(y - _Y)) < _Size) // are there common pixels with the previous location? + if ((uint) std::abs((sint)(x - _X)) < _Size && (uint) std::abs((sint)(y - _Y)) < _Size) // are there common pixels with the previous location? { // compute zone @@ -305,7 +308,11 @@ void CWaterHeightMap::makeCpy(uint buffer, uint dX, uint dY, uint sX, uint sY, { if (dest < src) { +#ifdef NL_COMP_VC14 + std::copy(src, src + width, stdext::make_unchecked_array_iterator(dest)); +#else std::copy(src, src + width, dest); +#endif } else { @@ -667,7 +674,7 @@ void CWaterHeightMap::setWaves(float intensity, float period, uint radius, bool //=========================================================================================== -void CWaterHeightMap::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CWaterHeightMap::serial(NLMISC::IStream &f) { f.xmlPushBegin("WaterHeightMap"); f.xmlSetAttrib ("NAME") ; diff --git a/code/nel/src/3d/water_model.cpp b/code/nel/src/3d/water_model.cpp index e6ae132e1..d65ad582d 100644 --- a/code/nel/src/3d/water_model.cpp +++ b/code/nel/src/3d/water_model.cpp @@ -36,6 +36,9 @@ using NLMISC::CVector2f; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/water_pool_manager.cpp b/code/nel/src/3d/water_pool_manager.cpp index c377ff1f3..361264f81 100644 --- a/code/nel/src/3d/water_pool_manager.cpp +++ b/code/nel/src/3d/water_pool_manager.cpp @@ -23,6 +23,9 @@ #include "nel/3d/water_height_map.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -211,7 +214,7 @@ void CWaterPoolManager::removePool(uint32 ID) } //=============================================================================================== -void CWaterPoolManager::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CWaterPoolManager::serial(NLMISC::IStream &f) { f.xmlPush("WaterPoolManager"); (void)f.serialVersion(0); diff --git a/code/nel/src/3d/water_shape.cpp b/code/nel/src/3d/water_shape.cpp index f5e26b8d7..6df5acb4c 100644 --- a/code/nel/src/3d/water_shape.cpp +++ b/code/nel/src/3d/water_shape.cpp @@ -26,6 +26,9 @@ #include "nel/3d/water_height_map.h" #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -520,7 +523,7 @@ const ITexture *CWaterShape::getHeightMap(uint k) const } //============================================ -void CWaterShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CWaterShape::serial(NLMISC::IStream &f) { /* *********************************************** * WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance @@ -760,7 +763,7 @@ CWaveMakerShape::~CWaveMakerShape() } //============================================ -void CWaveMakerShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CWaveMakerShape::serial(NLMISC::IStream &f) { f.serialVersion(0); f.serial(_Period, _Radius, _Intensity, _PoolID, _ImpulsionMode); diff --git a/code/nel/src/3d/zone.cpp b/code/nel/src/3d/zone.cpp index 263c61539..029f6da81 100644 --- a/code/nel/src/3d/zone.cpp +++ b/code/nel/src/3d/zone.cpp @@ -30,6 +30,9 @@ using namespace std; // define it only for debug bind. //#define NL3D_DEBUG_DONT_BIND_PATCH +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/zone_corner_smoother.cpp b/code/nel/src/3d/zone_corner_smoother.cpp index 430c6929f..568d4c6a3 100644 --- a/code/nel/src/3d/zone_corner_smoother.cpp +++ b/code/nel/src/3d/zone_corner_smoother.cpp @@ -19,6 +19,9 @@ #include "nel/3d/zone_corner_smoother.h" #include "nel/3d/patchuv_locator.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/zone_lighter.cpp b/code/nel/src/3d/zone_lighter.cpp index c70ad0ba2..4e8b32430 100644 --- a/code/nel/src/3d/zone_lighter.cpp +++ b/code/nel/src/3d/zone_lighter.cpp @@ -51,6 +51,10 @@ using namespace std; // Define this to render the zbuffers into a bitmap zbuffer and save it into a jpeg // #define SAVE_ZBUFFER "c:/temp" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + #define DEFAULT_JITTER 0.4f #define DEFAULT_ZBUFFER_LANDSCAPE_SIZE 32768 #define DEFAULT_ZBUFFER_OBJECT_SIZE (32768*3) @@ -2847,7 +2851,7 @@ bool CZoneLighter::isLightableShape(IShape &shape) void CZoneLighter::lightShapes(uint zoneID, const CLightDesc& description) { /// compute light for the lightable shapes in the given zone - if (_LightableShapes.size() == 0) return; + if (_LightableShapes.empty()) return; uint numShapePerThread = 1 + ((uint)_LightableShapes.size() / _ProcessCount); uint currShapeIndex = 0; @@ -3781,7 +3785,7 @@ uint CZoneLighter::getAPatch (uint process) nlassert(index < _PatchInfo.size()); - if (access.value().size() == 0) + if (access.value().empty()) // no more patches return 0xffffffff; diff --git a/code/nel/src/3d/zone_manager.cpp b/code/nel/src/3d/zone_manager.cpp index efa36fa66..1ba32806d 100644 --- a/code/nel/src/3d/zone_manager.cpp +++ b/code/nel/src/3d/zone_manager.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -170,7 +173,7 @@ bool CZoneManager::isWorkComplete (CZoneManager::SZoneManagerWork &rWork) rWork.NameZoneAdded = ite->ZoneToAddName; rWork.ZoneRemoved = false; rWork.IdZoneToRemove = 0; - rWork.NameZoneRemoved = ""; + rWork.NameZoneRemoved.clear(); rWork.Zone = const_cast(ite->Zone); _LoadedZones.push_back (ite->ZoneToAddId); @@ -187,7 +190,7 @@ bool CZoneManager::isWorkComplete (CZoneManager::SZoneManagerWork &rWork) { _RemovingZone = false; rWork.ZoneAdded = false; - rWork.NameZoneAdded = ""; + rWork.NameZoneAdded.clear(); rWork.ZoneRemoved = true; rWork.IdZoneToRemove = _IdZoneToRemove; rWork.NameZoneRemoved = getZoneNameFromId(_IdZoneToRemove); @@ -211,7 +214,7 @@ bool CZoneManager::isWorkComplete (CZoneManager::SZoneManagerWork &rWork) // ------------------------------------------------------------------------------------------------ void CZoneManager::clear() { - nlassert(_LoadingZones.size() == 0); + nlassert(_LoadingZones.empty()); _LoadedZones.clear(); _RemovingZone = false; } diff --git a/code/nel/src/3d/zone_search.cpp b/code/nel/src/3d/zone_search.cpp index f850d4377..71704d37f 100644 --- a/code/nel/src/3d/zone_search.cpp +++ b/code/nel/src/3d/zone_search.cpp @@ -23,6 +23,9 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -58,8 +61,6 @@ CZoneSearch::CZoneSearch() */ pair CZoneSearch::getZoneName(uint x, uint y, uint cx, uint cy) { - char name[13]; - uint zoneY = y / _SizeZoneY + 1; uint zoneX = x / _SizeZoneX; @@ -71,9 +72,7 @@ pair CZoneSearch::getZoneName(uint x, uint y, uint cx, uint cy) char firstLetter = zoneX / 26 + 'A'; char secondLetter = zoneX % 26 + 'A'; - sprintf(name, "%d_%c%c.zonel", zoneY, firstLetter, secondLetter); - - return std::pair(string(name), distance); + return std::pair(NLMISC::toString("%u_%c%c.zonel", zoneY, firstLetter, secondLetter), distance); } @@ -211,12 +210,9 @@ void CZoneSearch::getListZoneId (uint x, uint y, uint sizeArea, vector & std::string CZoneSearch::getZoneNameFromId (uint16 zoneid) { - char name[16]; - sint x = zoneid & 255; sint y = zoneid >> 8; - sprintf (name, "%d_%c%c.zonel", y+1, (char)('A'+(x/26)), (char)('A'+(x%26))); - return string(name); + return NLMISC::toString("%d_%c%c.zonel", y + 1, (char)('A' + (x / 26)), (char)('A' + (x % 26))); } diff --git a/code/nel/src/3d/zone_smoother.cpp b/code/nel/src/3d/zone_smoother.cpp index 2ae360933..6fd108ac7 100644 --- a/code/nel/src/3d/zone_smoother.cpp +++ b/code/nel/src/3d/zone_smoother.cpp @@ -18,6 +18,9 @@ #include "nel/3d/zone_smoother.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/zone_symmetrisation.cpp b/code/nel/src/3d/zone_symmetrisation.cpp index a12daa972..51b00b3f3 100644 --- a/code/nel/src/3d/zone_symmetrisation.cpp +++ b/code/nel/src/3d/zone_symmetrisation.cpp @@ -22,6 +22,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/zone_tgt_smoother.cpp b/code/nel/src/3d/zone_tgt_smoother.cpp index 865d72609..1a4902203 100644 --- a/code/nel/src/3d/zone_tgt_smoother.cpp +++ b/code/nel/src/3d/zone_tgt_smoother.cpp @@ -18,9 +18,14 @@ #include "nel/3d/zone_tgt_smoother.h" #include "nel/misc/plane.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/CMakeLists.txt b/code/nel/src/CMakeLists.txt index 60e5afccb..2b140340a 100644 --- a/code/nel/src/CMakeLists.txt +++ b/code/nel/src/CMakeLists.txt @@ -2,40 +2,40 @@ ADD_SUBDIRECTORY(misc) IF(WITH_3D) ADD_SUBDIRECTORY(3d) -ENDIF(WITH_3D) +ENDIF() IF(WITH_GUI) ADD_SUBDIRECTORY(gui) -ENDIF(WITH_GUI) +ENDIF() IF(WITH_GEORGES) ADD_SUBDIRECTORY(georges) -ENDIF(WITH_GEORGES) +ENDIF() IF(WITH_LIGO) ADD_SUBDIRECTORY(ligo) -ENDIF(WITH_LIGO) +ENDIF() IF(WITH_LOGIC) ADD_SUBDIRECTORY(logic) -ENDIF(WITH_LOGIC) +ENDIF() IF(WITH_NET) ADD_SUBDIRECTORY(net) -ENDIF(WITH_NET) +ENDIF() IF(WITH_SOUND) ADD_SUBDIRECTORY(sound) -ENDIF(WITH_SOUND) +ENDIF() IF(WITH_NEL_CEGUI) ADD_SUBDIRECTORY(cegui) -ENDIF(WITH_NEL_CEGUI) +ENDIF() IF(WITH_PACS) ADD_SUBDIRECTORY(pacs) -ENDIF(WITH_PACS) +ENDIF() IF(WITH_NEL_TOOLS) ADD_SUBDIRECTORY(pipeline) -ENDIF(WITH_NEL_TOOLS) +ENDIF() diff --git a/code/nel/src/cegui/CMakeLists.txt b/code/nel/src/cegui/CMakeLists.txt index 20fbb60d8..0a94d7892 100644 --- a/code/nel/src/cegui/CMakeLists.txt +++ b/code/nel/src/cegui/CMakeLists.txt @@ -14,4 +14,4 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DNEL_CEGUIRENDERER_EXPORTS) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nelceguirenderer RUNTIME DESTINATION ${NL_BIN_PREFIX} LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/src/georges/CMakeLists.txt b/code/nel/src/georges/CMakeLists.txt index 07ee701b3..802324d31 100644 --- a/code/nel/src/georges/CMakeLists.txt +++ b/code/nel/src/georges/CMakeLists.txt @@ -17,10 +17,10 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nelgeorges ${CMAKE_CURRENT_SOURCE_DIR}/stdgeorges.h ${CMAKE_CURRENT_SOURCE_DIR}/stdgeorges.cpp) -ENDIF(WITH_PCH) +ENDIF() NL_GEN_PC(nel-georges.pc) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nelgeorges LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/src/georges/form.cpp b/code/nel/src/georges/form.cpp index 5a23441ee..a02b9e8cd 100644 --- a/code/nel/src/georges/form.cpp +++ b/code/nel/src/georges/form.cpp @@ -24,6 +24,10 @@ #include "nel/georges/form.h" #include "nel/georges/form_loader.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; namespace NLGEORGES @@ -104,10 +108,10 @@ CForm::~CForm () // *************************************************************************** -void CForm::write (xmlDocPtr doc, const char *filename) +void CForm::write (xmlDocPtr doc, const std::string &filename) { // Save the filename - if (filename) + if (!filename.empty()) _Filename = CFile::getFilename (filename); // Create the first node @@ -176,7 +180,7 @@ void CForm::readParent (const char *parent, CFormLoader &loader) // *************************************************************************** -void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const char *filename) +void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const std::string &filename) { // Save the filename _Filename = CFile::getFilename (filename); @@ -188,8 +192,8 @@ void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const cha if ( ((const char*)node->name == NULL) || (strcmp ((const char*)node->name, "FORM") != 0) ) { // Make an error message - warning (true, "read", "XML Syntax error in block line %p, node (%s) should be FORM.", - node->content, node->name); + warning (true, "read", "XML Syntax error in block line %d, node (%s) should be FORM.", + (sint)node->line, node->name); } // Get first struct node @@ -197,8 +201,8 @@ void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const cha if (child == NULL) { // Throw exception - warning (true, "read", "Syntax error in block line %p, node (%s) should have a STRUCT child node.", - node->content, node->name); + warning (true, "read", "Syntax error in block line %d, node (%s) should have a STRUCT child node.", + (sint)node->line, node->name); } // Read the struct @@ -259,7 +263,7 @@ const std::string &CForm::getComment () const // *************************************************************************** -void CForm::write (class NLMISC::IStream &stream) +void CForm::write (NLMISC::IStream &stream) { // Xml stream COXml xmlStream; @@ -271,7 +275,7 @@ void CForm::write (class NLMISC::IStream &stream) // *************************************************************************** -bool CForm::insertParent (uint before, const char *filename, CForm *parent) +bool CForm::insertParent (uint before, const std::string &filename, CForm *parent) { // Set or reset ? nlassert (parent); @@ -289,7 +293,7 @@ bool CForm::insertParent (uint before, const char *filename, CForm *parent) else { // Output an error - warning (false, "insertParent", "Can't insert parent form (%s) that has not the same DFN.", filename); + warning (false, "insertParent", "Can't insert parent form (%s) that has not the same DFN.", filename.c_str()); } return false; @@ -346,7 +350,7 @@ const std::string &CForm::getFilename () const // *************************************************************************** -void CForm::warning (bool exception, const char *function, const char *format, ... ) const +void CForm::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -356,7 +360,7 @@ void CForm::warning (bool exception, const char *function, const char *format, . va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CForm::%s) in form (%s) : %s", function, _Filename.c_str (), buffer); + NLGEORGES::warning (exception, "(CForm::%s) in form (%s) : %s", function.c_str(), _Filename.c_str (), buffer); } // *************************************************************************** diff --git a/code/nel/src/georges/form_dfn.cpp b/code/nel/src/georges/form_dfn.cpp index 16ee74d5b..629c17f86 100644 --- a/code/nel/src/georges/form_dfn.cpp +++ b/code/nel/src/georges/form_dfn.cpp @@ -24,6 +24,10 @@ #include "nel/georges/form_loader.h" #include "nel/georges/form_elm.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; using namespace std; @@ -56,7 +60,7 @@ void CFormDfn::removeEntry( uint idx ) // *************************************************************************** -void CFormDfn::write (xmlDocPtr doc, const char *filename) +void CFormDfn::write (xmlDocPtr doc, const std::string &filename) { // Save filename _Filename = CFile::getFilename (filename); @@ -121,7 +125,7 @@ void CFormDfn::write (xmlDocPtr doc, const char *filename) // *************************************************************************** -void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const char *filename) +void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const std::string &filename) { // Save filename _Filename = CFile::getFilename (filename); @@ -130,7 +134,7 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const if ( ((const char*)root->name == NULL) || (strcmp ((const char*)root->name, "DFN") != 0) ) { // Throw exception - warning (true, "read", "XML Syntax error in block line %p, node (%s) should be DFN.", root->content, root->name); + warning (true, "read", "XML Syntax error in block line %d, node (%s) should be DFN.", (sint)root->line, root->name); } // Count the parent @@ -162,8 +166,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, aguments Name not found.", - parent->name, parent->content); + warning (true, "read", "XML Syntax error in block (%s) line %d, aguments Name not found.", + parent->name, (sint)parent->line); } // Next parent @@ -245,8 +249,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const if ((Entries[childNumber].Type == NULL) && !forceLoad) { // Throw exception - warning (true, "read", "In XML block (%s) line %p, file not found %s.", - child->name, child->content, Entries[childNumber].Filename.c_str ()); + warning (true, "read", "In XML block (%s) line %d, file not found %s.", + child->name, (sint)child->line, Entries[childNumber].Filename.c_str ()); } // Read the default value @@ -262,8 +266,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML In block (%s) line %p, no filename found for the .typ file.", - child->name, child->content); + warning (true, "read", "XML In block (%s) line %d, no filename found for the .typ file.", + child->name, (sint)child->line); } } else if (stricmp (typeName, "Dfn") == 0) @@ -279,15 +283,15 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const if ((Entries[childNumber].Dfn == NULL) && !forceLoad) { // Throw exception - warning (true, "read", "XML In block (%s) line %p, file not found %s.", - child->name, child->content, Entries[childNumber].Filename.c_str ()); + warning (true, "read", "XML In block (%s) line %d, file not found %s.", + child->name, (sint)child->line, Entries[childNumber].Filename.c_str ()); } } else { // Throw exception - warning (true, "read", "XML In block (%s) line %p, no filename found for the .typ file.", - child->name, child->content); + warning (true, "read", "XML In block (%s) line %d, no filename found for the .typ file.", + child->name, (sint)child->line); } } else if (stricmp (typeName, "DfnPointer") == 0) @@ -297,8 +301,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, element has not a valid type name attribut \"Type = %s\".", - child->name, child->content, typeName); + warning (true, "read", "XML Syntax error in block (%s) line %d, element has not a valid type name attribut \"Type = %s\".", + child->name, (sint)child->line, typeName); } // Delete the value @@ -307,8 +311,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, element has no type name attribut \"Type = [Type][Dfn][DfnPointer]\".", - child->name, child->content); + warning (true, "read", "XML Syntax error in block (%s) line %d, element has no type name attribut \"Type = [Type][Dfn][DfnPointer]\".", + child->name, (sint)child->line); } // Get the array attrib @@ -325,8 +329,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, aguments Name not found.", - root->name, root->content); + warning (true, "read", "XML Syntax error in block (%s) line %d, aguments Name not found.", + root->name, (sint)root->line); } // Next child @@ -459,9 +463,9 @@ void CFormDfn::setNumParent (uint size) // *************************************************************************** -void CFormDfn::setParent (uint parent, CFormLoader &loader, const char *filename) +void CFormDfn::setParent (uint parent, CFormLoader &loader, const std::string &filename) { - if (strcmp (filename, "")==0) + if (filename.empty()) Parents[parent].Parent = NULL; else Parents[parent].Parent = loader.loadFormDfn (filename, false); @@ -470,7 +474,7 @@ void CFormDfn::setParent (uint parent, CFormLoader &loader, const char *filename // *************************************************************************** -void CFormDfn::CEntry::setType (CFormLoader &loader, const char *filename) +void CFormDfn::CEntry::setType (CFormLoader &loader, const std::string &filename) { TypeElement = EntryType; Dfn = NULL; @@ -485,7 +489,7 @@ void CFormDfn::CEntry::setType( TEntryType type ) // *************************************************************************** -void CFormDfn::CEntry::setDfn (CFormLoader &loader, const char *filename) +void CFormDfn::CEntry::setDfn (CFormLoader &loader, const std::string &filename) { TypeElement = EntryDfn; Filename = filename; @@ -498,7 +502,7 @@ void CFormDfn::CEntry::setDfn (CFormLoader &loader, const char *filename) void CFormDfn::CEntry::setDfnPointer () { TypeElement = EntryVirtualDfn; - Filename = ""; + Filename.clear(); Type = NULL; Dfn = NULL; } @@ -512,7 +516,7 @@ const std::string &CFormDfn::CEntry::getName () const // *************************************************************************** -void CFormDfn::CEntry::setName (const char *name) +void CFormDfn::CEntry::setName (const std::string &name) { Name = name; } @@ -526,7 +530,7 @@ const std::string &CFormDfn::CEntry::getDefault () const // *************************************************************************** -void CFormDfn::CEntry::setDefault (const char *def) +void CFormDfn::CEntry::setDefault (const std::string &def) { Default = def; } @@ -561,7 +565,7 @@ const std::string &CFormDfn::CEntry::getFilename() const // *************************************************************************** -void CFormDfn::CEntry::setFilename (const char *def) +void CFormDfn::CEntry::setFilename (const std::string &def) { Filename = def; } @@ -849,14 +853,14 @@ const std::string &CFormDfn::CEntry::getFilenameExt() const // *************************************************************************** -void CFormDfn::CEntry::setFilenameExt (const char *ext) +void CFormDfn::CEntry::setFilenameExt (const std::string &ext) { FilenameExt = ext; } // *************************************************************************** -void CFormDfn::warning (bool exception, const char *function, const char *format, ... ) const +void CFormDfn::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -866,7 +870,7 @@ void CFormDfn::warning (bool exception, const char *function, const char *format va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CFormDfn::%s) in form DFN (%s) : %s", function, _Filename.c_str (), buffer); + NLGEORGES::warning (exception, "(CFormDfn::%s) in form DFN (%s) : %s", function.c_str(), _Filename.c_str (), buffer); } // *************************************************************************** diff --git a/code/nel/src/georges/form_elm.cpp b/code/nel/src/georges/form_elm.cpp index 01e4010e2..48368cc38 100644 --- a/code/nel/src/georges/form_elm.cpp +++ b/code/nel/src/georges/form_elm.cpp @@ -25,6 +25,10 @@ #include "nel/georges/form_loader.h" #include "nel/georges/type.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; using namespace std; @@ -356,7 +360,7 @@ CForm *CFormElm::getForm () const // *************************************************************************** -bool CFormElm::getNodeByName (UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round) +bool CFormElm::getNodeByName (UFormElm **result, const std::string &name, TWhereIsNode *where, bool verbose, uint32 round) { const UFormElm *resultConst = NULL; if (((const UFormElm*)this)->getNodeByName (&resultConst, name, where, verbose, round)) @@ -369,7 +373,7 @@ bool CFormElm::getNodeByName (UFormElm **result, const char *name, TWhereIsNode // *************************************************************************** -bool CFormElm::getNodeByName (const UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round) const +bool CFormElm::getNodeByName (const UFormElm **result, const std::string &name, TWhereIsNode *where, bool verbose, uint32 round) const { // The parent Dfn const CFormDfn *parentDfn; @@ -402,7 +406,7 @@ bool CFormElm::getNodeByName (const UFormElm **result, const char *name, TWhereI // *************************************************************************** -bool CFormElm::getValueByName (string& result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (string& result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // The parent Dfn const CFormDfn *parentDfn; @@ -430,13 +434,13 @@ bool CFormElm::getValueByName (string& result, const char *name, TEval evaluate, else { // Error message - warning (false, "getValueByName", "The node (%s) is not an atom element. Can't return a value.", name); + warning (false, "getValueByName", "The node (%s) is not an atom element. Can't return a value.", name.c_str()); } } else { // Error message - warning (false, "getValueByName", "Can't find the node (%s).", name); + warning (false, "getValueByName", "Can't find the node (%s).", name.c_str()); } // Error @@ -445,13 +449,13 @@ bool CFormElm::getValueByName (string& result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (sint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (sint8 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -459,13 +463,13 @@ bool CFormElm::getValueByName (sint8 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (uint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (uint8 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -473,13 +477,13 @@ bool CFormElm::getValueByName (uint8 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (sint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (sint16 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -487,13 +491,13 @@ bool CFormElm::getValueByName (sint16 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (uint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (uint16 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -501,13 +505,13 @@ bool CFormElm::getValueByName (uint16 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (sint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (sint32 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -515,13 +519,13 @@ bool CFormElm::getValueByName (sint32 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (uint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (uint32 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -529,13 +533,13 @@ bool CFormElm::getValueByName (uint32 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (float &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (float &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -543,13 +547,13 @@ bool CFormElm::getValueByName (float &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (double &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName(double &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -557,13 +561,13 @@ bool CFormElm::getValueByName (double &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (bool &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (bool &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -571,13 +575,13 @@ bool CFormElm::getValueByName (bool &result, const char *name, TEval evaluate, T // *************************************************************************** -bool CFormElm::getValueByName (NLMISC::CRGBA &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (NLMISC::CRGBA &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -592,7 +596,7 @@ UFormElm *CFormElm::getParent () const // *************************************************************************** -bool CFormElm::createNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, +bool CFormElm::createNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool &created) @@ -608,7 +612,7 @@ bool CFormElm::createNodeByName (const char *name, const CFormDfn **parentDfn, u // *************************************************************************** -bool CFormElm::deleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, +bool CFormElm::deleteNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array) @@ -625,7 +629,7 @@ bool CFormElm::deleteNodeByName (const char *name, const CFormDfn **parentDfn, u // *************************************************************************** -bool CFormElm::getNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, +bool CFormElm::getNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool &parentVDfnArray, bool verbose, uint32 round) const @@ -641,7 +645,7 @@ bool CFormElm::getNodeByName (const char *name, const CFormDfn **parentDfn, uint // *************************************************************************** -bool CFormElm::arrayInsertNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, +bool CFormElm::arrayInsertNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool verbose, uint arrayIndex) const @@ -715,7 +719,7 @@ bool CFormElm::arrayInsertNodeByName (const char *name, const CFormDfn **parentD // *************************************************************************** -bool CFormElm::arrayDeleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, +bool CFormElm::arrayDeleteNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool verbose, uint arrayIndex) const @@ -760,7 +764,7 @@ bool CFormElm::arrayDeleteNodeByName (const char *name, const CFormDfn **parentD // *************************************************************************** -bool CFormElm::getInternalNodeByName (CForm *form, const char *name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, TNodeAction action, bool &created, bool &parentVDfnArray, bool verbose, uint32 round) +bool CFormElm::getInternalNodeByName (CForm *form, const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, TNodeAction action, bool &created, bool &parentVDfnArray, bool verbose, uint32 round) { // *** Init output variables created = false; @@ -815,7 +819,7 @@ bool CFormElm::getInternalNodeByName (CForm *form, const char *name, const CForm // *** Parsing variables // Current token start and end - const char *startToken = name; + const char *startToken = name.c_str(); const char *endToken; // Current token start @@ -836,7 +840,7 @@ bool CFormElm::getInternalNodeByName (CForm *form, const char *name, const CForm bool inArrayIndex = false; // Index in the array - uint arrayIndex; + uint arrayIndex = 0; // Bool next token must be an array index bool wantArrayIndex = false; @@ -909,7 +913,7 @@ bool CFormElm::getInternalNodeByName (CForm *form, const char *name, const CForm // Get the virtual node by name UFormElm *uelm; - if (parentPtr->getRootNode ().getNodeByName (&uelm, formName.c_str (), NULL, verbose, round+1) && uelm) + if (parentPtr->getRootNode ().getNodeByName (&uelm, formName, NULL, verbose, round+1) && uelm) { // Value node ? if (uelm->isVirtualStruct ()) @@ -1134,7 +1138,7 @@ bool CFormElm::getInternalNodeByName (CForm *form, const char *name, const CForm case TokenString: { // To int - if (sscanf (token.c_str(), "%d", &arrayIndex)!=1) + if (!fromString(token, arrayIndex)) { // Error message smprintf (error, 512, "Keyword (%s) is not an array index.", token.c_str()); @@ -1406,7 +1410,7 @@ exit:; bool arrayParent; bool createdParent; bool parentVDfnArray; - if (getInternalNodeByName (parentPtr, formName.c_str (), &parentDfnParent, indexDfnParent, &nodeDfnParent, &nodeTypeParent, &nodeParent, typeParent, arrayParent, action, createdParent, parentVDfnArray, false, round+1)) + if (getInternalNodeByName (parentPtr, formName, &parentDfnParent, indexDfnParent, &nodeDfnParent, &nodeTypeParent, &nodeParent, typeParent, arrayParent, action, createdParent, parentVDfnArray, false, round+1)) { // Node found ? if (nodeParent) @@ -1466,7 +1470,7 @@ exit:; // Turn around.. string formName; (*node)->getFormName (formName); - warning (false, formName.c_str (), form->getFilename ().c_str(), "getInternalNodeByName", "Recursive call on the same node (%s), look for loop references or inheritances.", name); + warning (false, formName, form->getFilename (), "getInternalNodeByName", "Recursive call on the same node (%s), look for loop references or inheritances.", name.c_str()); return false; } } @@ -1476,7 +1480,7 @@ exit:; nlassert (*error); // Get the best form name - warning (false, currentName.c_str (), form->getFilename ().c_str(), "getInternalNodeByName", "Getting the node (%s) : %s", name, error); + warning (false, currentName, form->getFilename (), "getInternalNodeByName", "Getting the node (%s) : %s", name.c_str(), error); } return !errorAppend; @@ -1512,7 +1516,7 @@ const char* CFormElm::tokenize (const char *name, string &str, uint &/* errorInd return name+1; } - str = ""; + str.clear(); while ( (*name != '.') && (*name != '[') && (*name != ']') && (*name != 0) ) { // Add a char @@ -1534,7 +1538,7 @@ void CFormElm::unlink (CFormElm * /* child */) // *************************************************************************** -bool CFormElm::setValueByName (const char *value, const char *name, bool *created) +bool CFormElm::setValueByName(const std::string &value, const std::string &name, bool *created) { // The parent Dfn const CFormDfn *parentDfn; @@ -1567,13 +1571,13 @@ bool CFormElm::setValueByName (const char *value, const char *name, bool *create else { // Error message - warning (false, "setValueByName", "The node (%s) is not an atom element. Can't set the value.", name); + warning (false, "setValueByName", "The node (%s) is not an atom element. Can't set the value.", name.c_str()); } } else { // Error message - warning (false, "setValueByName", "Can't created / set the node (%s).", name); + warning (false, "setValueByName", "Can't created / set the node (%s).", name.c_str()); // Created flag if (created) @@ -1586,79 +1590,79 @@ bool CFormElm::setValueByName (const char *value, const char *name, bool *create // *************************************************************************** -bool CFormElm::setValueByName (sint8 value, const char *name, bool *created) +bool CFormElm::setValueByName (sint8 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (uint8 value, const char *name, bool *created) +bool CFormElm::setValueByName (uint8 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (sint16 value, const char *name, bool *created) +bool CFormElm::setValueByName (sint16 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (uint16 value, const char *name, bool *created) +bool CFormElm::setValueByName (uint16 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (sint32 value, const char *name, bool *created) +bool CFormElm::setValueByName(sint32 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (uint32 value, const char *name, bool *created) +bool CFormElm::setValueByName (uint32 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (float value, const char *name, bool *created) +bool CFormElm::setValueByName (float value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (double value, const char *name, bool *created) +bool CFormElm::setValueByName (double value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (bool value, const char *name, bool *created) +bool CFormElm::setValueByName (bool value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (NLMISC::CRGBA value, const char *name, bool *created) +bool CFormElm::setValueByName (NLMISC::CRGBA value, const std::string &name, bool *created) { char tmp[512]; smprintf (tmp, 512, "%d,%d,%d", value.R, value.G, value.B); - return setValueByName (tmp, name, created); + return setValueByName(std::string(tmp), name, created); } // *************************************************************************** -void CFormElm::warning (bool exception, const char *formName, const char *formFileName, const char *function, const char *format, ... ) +void CFormElm::warning (bool exception, const std::string &formName, const std::string &formFileName, const std::string &function, const char *format, ... ) { // Make a buffer string va_list args; @@ -1668,19 +1672,19 @@ void CFormElm::warning (bool exception, const char *formName, const char *formFi va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CFormElm::%s) on node (%s) in form (%s) : %s", function, formName, formFileName, buffer); + NLGEORGES::warning (exception, "(CFormElm::%s) on node (%s) in form (%s) : %s", function.c_str(), formName.c_str(), formFileName.c_str(), buffer); } // *************************************************************************** -void CFormElm::warning (bool exception, const char *function, const char *format, ... ) const +void CFormElm::warning (bool exception, const std::string &function, const char *format, ... ) const { va_list args; va_start( args, format ); string formName; getFormName (formName); - warning (exception, formName.c_str (), getForm ()->getFilename ().c_str (), function, format, args); + warning (exception, formName, getForm ()->getFilename (), function, format, args); va_end( args ); } @@ -1741,7 +1745,7 @@ bool CFormElmStruct::getStructNodeName (uint element, string &result) const } else { - warning (false, "getStructNodeName", "Index (%d) out of bound (%d).", element, Elements.size() ); + warning (false, "getStructNodeName", "Index (%u) out of bound (%u).", element, (uint)Elements.size() ); return false; } } @@ -1757,7 +1761,7 @@ bool CFormElmStruct::getStructNode (uint element, const UFormElm **result) const } else { - warning (false, "getStructNode", "Index (%d) out of bound (%d).", element, Elements.size() ); + warning (false, "getStructNode", "Index (%u) out of bound (%u).", element, (uint)Elements.size() ); return false; } } @@ -1780,14 +1784,14 @@ bool CFormElmStruct::getStructNode (uint element, UFormElm **result) } else { - warning (false, "getStructNode", "Index (%d) out of bound (%d).", element, Elements.size() ); + warning (false, "getStructNode", "Index (%u) out of bound (%u).", element, (uint)Elements.size() ); return false; } } // *************************************************************************** -xmlNodePtr CFormElmStruct::write (xmlNodePtr root, const CForm *form, const char *structName, bool forceWrite) const +xmlNodePtr CFormElmStruct::write (xmlNodePtr root, const CForm *form, const std::string &structName, bool forceWrite) const { // Is used ? if (isUsed (form) || forceWrite) @@ -1796,10 +1800,10 @@ xmlNodePtr CFormElmStruct::write (xmlNodePtr root, const CForm *form, const cha xmlNodePtr node = xmlNewChild ( root, NULL, (const xmlChar*)"STRUCT", NULL); // Element name - if (structName != NULL) + if (!structName.empty()) { // Struct name - xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName); + xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName.c_str()); } // For each elements of the structure @@ -1808,7 +1812,7 @@ xmlNodePtr CFormElmStruct::write (xmlNodePtr root, const CForm *form, const cha { // Create a node if it exist if (Elements[elm].Element) - Elements[elm].Element->write (node, form, Elements[elm].Name.c_str()); + Elements[elm].Element->write (node, form, Elements[elm].Name); } // Return the new node @@ -1905,8 +1909,8 @@ void CFormElmStruct::read (xmlNodePtr node, CFormLoader &loader, const CFormDfn else { // Make a warning message - warning (false, "read", "In block line %p, node (%s) type in DFN have changed.", - child->content, child->name); + warning (false, "read", "In block line %u, node (%s) type in DFN have changed.", + (uint)child->line, child->name); } } else @@ -1918,8 +1922,8 @@ void CFormElmStruct::read (xmlNodePtr node, CFormLoader &loader, const CFormDfn } // Throw exception - warning (true, "read", "XML Syntax error in block line %p, node (%s) name should be STRUCT, ATOM or ARRAY.", - child->content, child->name); + warning (true, "read", "XML Syntax error in block line %u, node (%s) name should be STRUCT, ATOM or ARRAY.", + (uint)child->line, child->name); } } @@ -2066,7 +2070,7 @@ void CFormElmStruct::getFormName (std::string &result, const CFormElm *child) co // Reset the result if (child == NULL) { - result = ""; + result.clear(); result.reserve (50); } @@ -2101,7 +2105,7 @@ void CFormElmStruct::getFormName (std::string &result, const CFormElm *child) co // *************************************************************************** -void CFormElmStruct::warning (bool exception, const char *function, const char *format, ... ) const +void CFormElmStruct::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -2113,7 +2117,7 @@ void CFormElmStruct::warning (bool exception, const char *function, const char * // Set the warning string formName; getFormName (formName, NULL); - NLGEORGES::warning (exception, "(CFormElmStruct::%s) on node (%s) in form (%s) : %s", function, formName.c_str (), Form->getFilename ().c_str (), buffer); + NLGEORGES::warning (exception, "(CFormElmStruct::%s) on node (%s) in form (%s) : %s", function.c_str(), formName.c_str (), Form->getFilename ().c_str (), buffer); } // *************************************************************************** @@ -2142,7 +2146,7 @@ CFormElmVirtualStruct::CFormElmVirtualStruct (CForm *form, CFormElm *parentNode, // *************************************************************************** -xmlNodePtr CFormElmVirtualStruct::write (xmlNodePtr root, const CForm *form, const char *structName, bool forceWrite) const +xmlNodePtr CFormElmVirtualStruct::write (xmlNodePtr root, const CForm *form, const std::string &structName, bool forceWrite) const { // Is used ? if (isUsed (form) || forceWrite) @@ -2154,10 +2158,10 @@ xmlNodePtr CFormElmVirtualStruct::write (xmlNodePtr root, const CForm *form, co xmlSetProp (node, (const xmlChar*)"DfnName", (const xmlChar*)DfnFilename.c_str()); // Element name - if (structName != NULL) + if (!structName.empty()) { // Struct name - xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName); + xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName.c_str()); } // For each elements of the structure @@ -2166,7 +2170,7 @@ xmlNodePtr CFormElmVirtualStruct::write (xmlNodePtr root, const CForm *form, co { // Create a node if it exist if (Elements[elm].Element) - Elements[elm].Element->write (node, form, Elements[elm].Name.c_str()); + Elements[elm].Element->write (node, form, Elements[elm].Name); } // Return the new node @@ -2190,7 +2194,7 @@ void CFormElmVirtualStruct::read (xmlNodePtr node, CFormLoader &loader, CForm *f xmlFree ((void*)filename); // Load the dfn - FormDfn = loader.loadFormDfn (DfnFilename.c_str (), false); + FormDfn = loader.loadFormDfn (DfnFilename, false); if (!FormDfn) { // Throw exception @@ -2200,8 +2204,8 @@ void CFormElmVirtualStruct::read (xmlNodePtr node, CFormLoader &loader, CForm *f else { // Throw exception - warning (true, "read", "XML Syntax error in virtual struct in block line %p, should have a DfnName property.", - node->content); + warning (true, "read", "XML Syntax error in virtual struct in block line %u, should have a DfnName property.", + (uint)node->line); } // Read the parent @@ -2232,7 +2236,7 @@ bool CFormElmVirtualStruct::isUsed (const CForm * /* form */) const // *************************************************************************** -void CFormElmVirtualStruct::warning (bool exception, const char *function, const char *format, ... ) const +void CFormElmVirtualStruct::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -2244,7 +2248,7 @@ void CFormElmVirtualStruct::warning (bool exception, const char *function, const // Set the warning string formName; getFormName (formName, NULL); - NLGEORGES::warning (exception, "(CFormElmVirtualStruct::%s) on node (%s) in form (%s) : %s", function, formName.c_str (), Form->getFilename ().c_str (), buffer); + NLGEORGES::warning (exception, "(CFormElmVirtualStruct::%s) on node (%s) in form (%s) : %s", function.c_str(), formName.c_str (), Form->getFilename ().c_str (), buffer); } // *************************************************************************** @@ -2304,7 +2308,7 @@ bool CFormElmArray::getArrayNode (const UFormElm **result, uint arrayIndex) cons } else { - warning (false, "getArrayNode", "Index (%d) out of bound (%d).", arrayIndex, Elements.size() ); + warning (false, "getArrayNode", "Index (%u) out of bound (%u).", arrayIndex, (uint)Elements.size() ); return false; } } @@ -2323,7 +2327,7 @@ bool CFormElmArray::getArrayNodeName (std::string &result, uint arrayIndex) cons } else { - warning (false, "getArrayNodeName", "Index (%d) out of bound (%d).", arrayIndex, Elements.size() ); + warning (false, "getArrayNodeName", "Index (%u) out of bound (%u).", arrayIndex, (uint)Elements.size() ); return false; } } @@ -2339,7 +2343,7 @@ bool CFormElmArray::getArrayNode (UFormElm **result, uint arrayIndex) } else { - warning (false, "getArrayNode", "Index (%d) out of bound (%d).", arrayIndex, Elements.size() ); + warning (false, "getArrayNode", "Index (%u) out of bound (%u).", arrayIndex, (uint)Elements.size() ); return false; } } @@ -2351,11 +2355,11 @@ bool CFormElmArray::getArrayValue (std::string &result, uint arrayIndex, TEval e { if (arrayIndex >= Elements.size()) { - warning (false, "getArrayValue", "Access out of bound, trying to access array index %u, array size is %u.", arrayIndex, Elements.size()); + warning (false, "getArrayValue", "Access out of bound, trying to access array index %u, array size is %u.", arrayIndex, (uint)Elements.size()); } else if (Type) { - return (Type->getValue (result, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)); + return (Type->getValue (result, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")); } else { @@ -2372,9 +2376,9 @@ bool CFormElmArray::getArrayValue (sint8 &result, uint arrayIndex, TEval evaluat if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2392,9 +2396,9 @@ bool CFormElmArray::getArrayValue (uint8 &result, uint arrayIndex, TEval evaluat if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2412,9 +2416,9 @@ bool CFormElmArray::getArrayValue (sint16 &result, uint arrayIndex, TEval evalua if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2432,9 +2436,9 @@ bool CFormElmArray::getArrayValue (uint16 &result, uint arrayIndex, TEval evalua if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2452,9 +2456,9 @@ bool CFormElmArray::getArrayValue (sint32 &result, uint arrayIndex, TEval evalua if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2472,9 +2476,9 @@ bool CFormElmArray::getArrayValue (uint32 &result, uint arrayIndex, TEval evalua if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2492,9 +2496,9 @@ bool CFormElmArray::getArrayValue (float &result, uint arrayIndex, TEval evaluat if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2512,9 +2516,9 @@ bool CFormElmArray::getArrayValue (double &result, uint arrayIndex, TEval evalua if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2532,9 +2536,9 @@ bool CFormElmArray::getArrayValue (bool &result, uint arrayIndex, TEval evaluate if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2552,9 +2556,9 @@ bool CFormElmArray::getArrayValue (NLMISC::CRGBA &result, uint arrayIndex, TEval if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2567,7 +2571,7 @@ bool CFormElmArray::getArrayValue (NLMISC::CRGBA &result, uint arrayIndex, TEval // *************************************************************************** -xmlNodePtr CFormElmArray::write (xmlNodePtr root, const CForm *form, const char *structName, bool forceWrite) const +xmlNodePtr CFormElmArray::write (xmlNodePtr root, const CForm *form, const std::string &structName, bool forceWrite) const { // Arrau is used ? if (isUsed (form) || forceWrite) @@ -2576,10 +2580,10 @@ xmlNodePtr CFormElmArray::write (xmlNodePtr root, const CForm *form, const char xmlNodePtr node = xmlNewChild ( root, NULL, (const xmlChar*)"ARRAY", NULL); // Element name - if (structName != NULL) + if (!structName.empty()) { // Struct name - xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName); + xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName.c_str()); } // For each elements of the structure @@ -2588,7 +2592,7 @@ xmlNodePtr CFormElmArray::write (xmlNodePtr root, const CForm *form, const char { // Create a node if (Elements[elm].Element) - Elements[elm].Element->write (node, form, Elements[elm].Name.empty ()?NULL:Elements[elm].Name.c_str (), true); + Elements[elm].Element->write (node, form, Elements[elm].Name, true); } // Return the new node @@ -2723,7 +2727,7 @@ void CFormElmArray::getFormName (std::string &result, const CFormElm *child) con // Reset the result if (child == NULL) { - result = ""; + result.clear(); result.reserve (50); } @@ -2760,7 +2764,7 @@ void CFormElmArray::getFormName (std::string &result, const CFormElm *child) con // *************************************************************************** -void CFormElmArray::warning (bool exception, const char *function, const char *format, ... ) const +void CFormElmArray::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -2772,7 +2776,7 @@ void CFormElmArray::warning (bool exception, const char *function, const char *f // Set the warning string formName; getFormName (formName, NULL); - NLGEORGES::warning (exception, "(CFormElmArray::%s) on node (%s) in form (%s) : %s", function, formName.c_str (), Form->getFilename ().c_str (), buffer); + NLGEORGES::warning (exception, "(CFormElmArray::%s) on node (%s) in form (%s) : %s", function.c_str(), formName.c_str (), Form->getFilename ().c_str (), buffer); } // *************************************************************************** @@ -2979,7 +2983,7 @@ bool CFormElmAtom::getValue (NLMISC::CRGBA &result, TEval evaluate) const // *************************************************************************** -xmlNodePtr CFormElmAtom::write (xmlNodePtr root, const CForm *form, const char *structName, bool forceWrite) const +xmlNodePtr CFormElmAtom::write (xmlNodePtr root, const CForm *form, const std::string &structName, bool forceWrite) const { // Atom is used ? if (isUsed (form) || forceWrite) @@ -2988,16 +2992,16 @@ xmlNodePtr CFormElmAtom::write (xmlNodePtr root, const CForm *form, const char xmlNodePtr node = xmlNewChild ( root, NULL, (const xmlChar*)"ATOM", NULL); // Element name - if (structName != NULL) + if (!structName.empty()) { // Struct name - xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName); + xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName.c_str()); } // The value if (!Value.empty ()) { - if (COXml::isStringValidForProperties (Value.c_str ())) + if (COXml::isStringValidForProperties (Value)) xmlSetProp (node, (const xmlChar*)"Value", (const xmlChar*)Value.c_str()); else { @@ -3049,7 +3053,7 @@ void CFormElmAtom::read (xmlNodePtr node, CFormLoader &/* loader */, const CType // *************************************************************************** -void CFormElmAtom::setValue (const char *value) +void CFormElmAtom::setValue (const std::string &value) { Value = value; } @@ -3067,7 +3071,7 @@ void CFormElmAtom::getFormName (std::string &result, const CFormElm *child) cons { // Must be NULL nlassert (child == NULL); - result = ""; + result.clear(); result.reserve (50); // Get parent form name @@ -3077,7 +3081,7 @@ void CFormElmAtom::getFormName (std::string &result, const CFormElm *child) cons // *************************************************************************** -void CFormElmAtom::warning (bool exception, const char *function, const char *format, ... ) const +void CFormElmAtom::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -3089,7 +3093,7 @@ void CFormElmAtom::warning (bool exception, const char *function, const char *fo // Set the warning string formName; getFormName (formName, NULL); - NLGEORGES::warning (exception, "(CFormElmAtom::%s) on node (%s) in form (%s) : %s", function, formName.c_str (), Form->getFilename ().c_str (), buffer); + NLGEORGES::warning (exception, "(CFormElmAtom::%s) on node (%s) in form (%s) : %s", function.c_str(), formName.c_str (), Form->getFilename ().c_str (), buffer); } // *************************************************************************** diff --git a/code/nel/src/georges/form_loader.cpp b/code/nel/src/georges/form_loader.cpp index dd0becf62..877c587ed 100644 --- a/code/nel/src/georges/form_loader.cpp +++ b/code/nel/src/georges/form_loader.cpp @@ -27,6 +27,10 @@ #include "nel/georges/form.h" #include "nel/georges/form_dfn.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; using namespace std; @@ -60,10 +64,10 @@ CFormLoader::~CFormLoader() { } -CType *CFormLoader::loadType (const char *filename) +CType *CFormLoader::loadType (const std::string &filename) { // Lower string filename - string lowerStr = toLower((string)filename); + string lowerStr = toLower(filename); lowerStr = CFile::getFilename (lowerStr); // Already in the map ? @@ -98,7 +102,7 @@ CType *CFormLoader::loadType (const char *filename) else { // Output error - warning (false, "loadType", "Can't open the form file (%s).", filename); + warning (false, "loadType", "Can't open the form file (%s).", filename.c_str()); // Delete the type delete type; @@ -108,7 +112,7 @@ CType *CFormLoader::loadType (const char *filename) catch (const Exception &e) { // Output error - warning (false, "loadType", "Error while loading the form (%s): %s", filename, e.what()); + warning (false, "loadType", "Error while loading the form (%s): %s", filename.c_str(), e.what()); // Delete the type delete type; @@ -130,10 +134,10 @@ CType *CFormLoader::loadType (const char *filename) // *************************************************************************** -CFormDfn *CFormLoader::loadFormDfn (const char *filename, bool forceLoad) +CFormDfn *CFormLoader::loadFormDfn (const std::string &filename, bool forceLoad) { // Lower string filename - string lowerStr = toLower((string)filename); + string lowerStr = toLower(filename); lowerStr = CFile::getFilename (lowerStr); // Already in the map ? @@ -171,7 +175,7 @@ CFormDfn *CFormLoader::loadFormDfn (const char *filename, bool forceLoad) else { // Output error - warning (false, "loadFormDfn", "Can't open the form file (%s).", filename); + warning (false, "loadFormDfn", "Can't open the form file (%s).", filename.c_str()); // Delete the formDfn delete formDfn; @@ -182,7 +186,7 @@ CFormDfn *CFormLoader::loadFormDfn (const char *filename, bool forceLoad) catch (const Exception &e) { // Output error - warning (false, "loadFormDfn", "Error while loading the form (%s): %s", filename, e.what()); + warning (false, "loadFormDfn", "Error while loading the form (%s): %s", filename.c_str(), e.what()); // Delete the formDfn delete formDfn; @@ -196,7 +200,7 @@ CFormDfn *CFormLoader::loadFormDfn (const char *filename, bool forceLoad) // *************************************************************************** -UForm *CFormLoader::loadForm (const char *filename) +UForm *CFormLoader::loadForm (const std::string &filename) { // Lower string filename string lowerStr = toLower((string)filename); @@ -237,7 +241,7 @@ UForm *CFormLoader::loadForm (const char *filename) name += ".dfn"; // Load the dfn - CFormDfn *dfn = loadFormDfn (name.c_str (), false); + CFormDfn *dfn = loadFormDfn (name, false); if (dfn) { // Open the file @@ -257,7 +261,7 @@ UForm *CFormLoader::loadForm (const char *filename) else { // Output error - warning (false, "loadForm", "Can't open the form file (%s).", filename); + warning (false, "loadForm", "Can't open the form file (%s).", filename.c_str()); // Delete the form delete form; @@ -279,7 +283,7 @@ UForm *CFormLoader::loadForm (const char *filename) catch (const Exception &e) { // Output error - warning (false, "loadForm", "Error while loading the form (%s): %s", filename, e.what()); + warning (false, "loadForm", "Error while loading the form (%s): %s", filename.c_str(), e.what()); // Delete the form delete form; @@ -293,21 +297,21 @@ UForm *CFormLoader::loadForm (const char *filename) // *************************************************************************** -UFormDfn *CFormLoader::loadFormDfn (const char *filename) +UFormDfn *CFormLoader::loadFormDfn (const std::string &filename) { return loadFormDfn (filename, false); } // *************************************************************************** -UType *CFormLoader::loadFormType (const char *filename) +UType *CFormLoader::loadFormType (const std::string &filename) { return loadType (filename); } // *************************************************************************** -void CFormLoader::warning (bool exception, const char *function, const char *format, ... ) const +void CFormLoader::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -317,7 +321,7 @@ void CFormLoader::warning (bool exception, const char *function, const char *for va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CFormLoader::%s) : %s", function, buffer); + NLGEORGES::warning (exception, "(CFormLoader::%s) : %s", function.c_str(), buffer); } // *************************************************************************** diff --git a/code/nel/src/georges/header.cpp b/code/nel/src/georges/header.cpp index ff92d60ea..40617e6d5 100644 --- a/code/nel/src/georges/header.cpp +++ b/code/nel/src/georges/header.cpp @@ -22,6 +22,10 @@ #include "nel/georges/header.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; namespace NLGEORGES @@ -76,7 +80,7 @@ void CFileHeader::write (xmlNodePtr node) const // *************************************************************************** -void CFileHeader::addLog (const char *log) +void CFileHeader::addLog (const std::string &log) { time_t t; time (&t); @@ -92,7 +96,7 @@ void CFileHeader::addLog (const char *log) // *************************************************************************** -void CFileHeader::setComments (const char *comments) +void CFileHeader::setComments (const std::string &comments) { Comments = comments; } @@ -112,8 +116,8 @@ void CFileHeader::read (xmlNodePtr root) xmlFree ((void*)value); // Throw exception - warning (true, "read", "XML Syntax error in TYPE block line %p, the Version argument is invalid.", - root->content); + warning (true, "read", "XML Syntax error in TYPE block line %d, the Version argument is invalid.", + (sint)root->line); } // Delete the value @@ -145,8 +149,8 @@ void CFileHeader::read (xmlNodePtr root) xmlFree ((void*)value); // Throw exception - warning (true, "read", "XML Syntax error in TYPE block line %p, the State argument is invalid.", - root->content); + warning (true, "read", "XML Syntax error in TYPE block line %d, the State argument is invalid.", + (sint)root->line); } // Delete the value @@ -159,7 +163,7 @@ void CFileHeader::read (xmlNodePtr root) } // Look for the comment node - Comments = ""; + Comments.clear(); xmlNodePtr node = CIXml::getFirstChildNode (root, "COMMENTS"); if (node) { @@ -181,7 +185,7 @@ void CFileHeader::read (xmlNodePtr root) } // Look for the log node - Log = ""; + Log.clear(); node = CIXml::getFirstChildNode (root, "LOG"); if (node) { @@ -215,7 +219,7 @@ const char *CFileHeader::getStateString (TState state) // *************************************************************************** -void CFileHeader::warning (bool exception, const char *function, const char *format, ... ) const +void CFileHeader::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -225,7 +229,7 @@ void CFileHeader::warning (bool exception, const char *function, const char *for va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CFileHeader::%s) : %s", function, buffer); + NLGEORGES::warning (exception, "(CFileHeader::%s) : %s", function.c_str(), buffer); } // *************************************************************************** diff --git a/code/nel/src/georges/load_form.cpp b/code/nel/src/georges/load_form.cpp deleted file mode 100644 index e420b63ae..000000000 --- a/code/nel/src/georges/load_form.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdgeorges.h" diff --git a/code/nel/src/georges/stdgeorges.h b/code/nel/src/georges/stdgeorges.h index a11169d27..fa0bf0819 100644 --- a/code/nel/src/georges/stdgeorges.h +++ b/code/nel/src/georges/stdgeorges.h @@ -14,6 +14,16 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#ifndef STDGEORGES_H +#define STDGEORGES_H + +#if defined(_MSC_VER) && defined(_DEBUG) +#define _CRTDBG_MAP_ALLOC +#include +#include +#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif + #include "nel/misc/types_nl.h" #include #include @@ -27,3 +37,5 @@ // Include from libxml2 #include + +#endif diff --git a/code/nel/src/georges/type.cpp b/code/nel/src/georges/type.cpp index f401c7ee8..0dd2b9457 100644 --- a/code/nel/src/georges/type.cpp +++ b/code/nel/src/georges/type.cpp @@ -27,6 +27,10 @@ #include "nel/georges/form_loader.h" #include "nel/georges/type.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; using namespace std; @@ -109,8 +113,8 @@ void CType::read (xmlNodePtr root) if ( ((const char*)root->name == NULL) || (strcmp ((const char*)root->name, "TYPE") != 0) ) { // Throw exception - warning2 (true, "read", "XML Syntax error in block line %p, node (%s) should be TYPE.", - root->content, root->name); + warning2 (true, "read", "XML Syntax error in block line %d, node (%s) should be TYPE.", + (sint)root->line, root->name); } // Read the type @@ -137,8 +141,8 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); // Throw exception - warning2 (true, "read", "XML Syntax error in TYPE block line %p, the Type value is unknown (%s).", - root->content, valueStr.c_str ()); + warning2 (true, "read", "XML Syntax error in TYPE block line %d, the Type value is unknown (%s).", + (sint)root->line, valueStr.c_str ()); } // Delete the value @@ -147,8 +151,8 @@ void CType::read (xmlNodePtr root) else { // Throw exception - warning2 (true, "read", "XML Syntax error in TYPE block line %p, the Type argument was not found.", - root->content); + warning2 (true, "read", "XML Syntax error in TYPE block line %d, the Type argument was not found.", + (sint)root->line); } // Read the UI @@ -185,7 +189,7 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); } else - Default = ""; + Default.clear(); // Read Min value = (const char*)xmlGetProp (root, (xmlChar*)"Min"); @@ -197,7 +201,7 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); } else - Min = ""; + Min.clear(); // Read Max value = (const char*)xmlGetProp (root, (xmlChar*)"Max"); @@ -209,7 +213,7 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); } else - Max = ""; + Max.clear(); // Read Increment value = (const char*)xmlGetProp (root, (xmlChar*)"Increment"); @@ -221,7 +225,7 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); } else - Increment = ""; + Increment.clear(); // Read the definitions uint childrenCount = CIXml::countChildren (root, "DEFINITION"); @@ -255,8 +259,8 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)label); // Throw exception - warning2 (true, "read", "XML Syntax error in DEFINITION block line %p, the Value argument was not found.", - childPtr->content); + warning2 (true, "read", "XML Syntax error in DEFINITION block line %d, the Value argument was not found.", + (sint)childPtr->line); } // Delete the value @@ -265,8 +269,8 @@ void CType::read (xmlNodePtr root) else { // Throw exception - warning2 (true, "read", "XML Syntax error in DEFINITION block line %p, the Label argument was not found.", - childPtr->content); + warning2 (true, "read", "XML Syntax error in DEFINITION block line %d, the Label argument was not found.", + (sint)childPtr->line); } // One more @@ -326,6 +330,7 @@ public: Type = type; Form = form; } + virtual CEvalNumExpr::TReturnState evalValue (const char *value, double &result, uint32 round) { // If a form is available @@ -412,7 +417,7 @@ public: result = res.empty ()?0:1; return CEvalNumExpr::NoError; } - else if (((const CFormElm&)Form->getRootNode ()).convertValue (result, res.c_str ())) + else if (((const CFormElm&)Form->getRootNode ()).convertValue (result, res)) { return CEvalNumExpr::NoError; } @@ -465,7 +470,7 @@ uint getNextToken (const char *startString, string &token, uint &offset) offset += 9; return NL_TOKEN_NAME; } - token = ""; + token.clear(); while (startString[offset]) { if (startString[offset] == '\\') @@ -535,7 +540,7 @@ void buildError (char *msg, uint offset) // *************************************************************************** -bool CType::getValue (string &result, const CForm *form, const CFormElmAtom *node, const CFormDfn &parentDfn, uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const char *formName) const +bool CType::getValue (string &result, const CForm *form, const CFormElmAtom *node, const CFormDfn &parentDfn, uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const std::string &formName) const { if (round > NLGEORGES_MAX_RECURSION) { @@ -721,7 +726,7 @@ bool CType::getValue (string &result, const CForm *form, const CFormElmAtom *nod UFormDfn::TEntryType type; // Search for the node - if (((const CFormElm&)form->getRootNode ()).getNodeByName (valueName.c_str (), &parentDfn, parentIndex, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, false, round+1)) + if (((const CFormElm&)form->getRootNode ()).getNodeByName (valueName, &parentDfn, parentIndex, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, false, round+1)) { // End, return the current index if (type == UFormDfn::EntryType) @@ -809,7 +814,7 @@ bool CType::uiCompatible (TType type, TUI ui) // *************************************************************************** -void CType::warning (bool exception, const char *formName, const char *formFilename, const char *function, const char *format, ... ) const +void CType::warning (bool exception, const std::string &formName, const std::string &formFilename, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -819,12 +824,12 @@ void CType::warning (bool exception, const char *formName, const char *formFilen va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CType::%s) In form (%s) in node (%s) : %s", function, formFilename, formName, buffer); + NLGEORGES::warning (exception, "(CType::%s) In form (%s) in node (%s) : %s", function.c_str(), formFilename.c_str(), formName.c_str(), buffer); } // *************************************************************************** -void CType::warning2 (bool exception, const char *function, const char *format, ... ) const +void CType::warning2 (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -834,7 +839,7 @@ void CType::warning2 (bool exception, const char *function, const char *format, va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CType::%s) : %s", function, buffer); + NLGEORGES::warning (exception, "(CType::%s) : %s", function.c_str(), buffer); } // *************************************************************************** diff --git a/code/nel/src/gui/CMakeLists.txt b/code/nel/src/gui/CMakeLists.txt index 091e9e5da..5233b8ceb 100644 --- a/code/nel/src/gui/CMakeLists.txt +++ b/code/nel/src/gui/CMakeLists.txt @@ -18,8 +18,8 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${CURL_DEFINITIONS} ${LUABIND_DEFINITIONS IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nelgui ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.h ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.cpp) -ENDIF(WITH_PCH) +ENDIF() IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nelgui LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/src/gui/action_handler.cpp b/code/nel/src/gui/action_handler.cpp index d7214ef06..2d2246937 100644 --- a/code/nel/src/gui/action_handler.cpp +++ b/code/nel/src/gui/action_handler.cpp @@ -23,10 +23,15 @@ #include "nel/gui/db_manager.h" #include "nel/gui/interface_link.h" #include "nel/gui/widget_manager.h" +#include "nel/gui/view_renderer.h" using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -65,7 +70,7 @@ namespace NLGUI string allparam = Params; skipBlankAtStart (allparam); string param = toLower (ParamName); - while (allparam.size() > 0) + while (!allparam.empty()) { std::string::size_type e = allparam.find('='); if (e == std::string::npos || e == 0) break; @@ -91,7 +96,7 @@ namespace NLGUI { string allparam = Params; skipBlankAtStart (allparam); - while (allparam.size() > 0) + while (!allparam.empty()) { std::string::size_type e = allparam.find('='); if (e == std::string::npos || e == 0) break; @@ -738,4 +743,14 @@ namespace NLGUI }; REGISTER_ACTION_HANDLER (CAHUnlockAllContainer, "unlock_all_container"); -} \ No newline at end of file + // ------------------------------------------------------------------------------------------------ + class CAHCopyToClipboard : public IActionHandler + { + virtual void execute (CCtrlBase *pCaller, const std::string ¶ms) + { + if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(params)) + nlwarning("Copy to clipboard failed: '%s'", params.c_str()); + } + }; + REGISTER_ACTION_HANDLER(CAHCopyToClipboard, "copy_to_clipboard"); +} diff --git a/code/nel/src/gui/ctrl_base.cpp b/code/nel/src/gui/ctrl_base.cpp index 475761e89..9fdeff8c2 100644 --- a/code/nel/src/gui/ctrl_base.cpp +++ b/code/nel/src/gui/ctrl_base.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { std::map< std::string, std::map< std::string, std::string > > CCtrlBase::AHCache; diff --git a/code/nel/src/gui/ctrl_base_button.cpp b/code/nel/src/gui/ctrl_base_button.cpp index 673ea906d..d60824295 100644 --- a/code/nel/src/gui/ctrl_base_button.cpp +++ b/code/nel/src/gui/ctrl_base_button.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace { const uint KEY_REPEAT_MIN = 100; diff --git a/code/nel/src/gui/ctrl_button.cpp b/code/nel/src/gui/ctrl_button.cpp index d689dd71c..457010859 100644 --- a/code/nel/src/gui/ctrl_button.cpp +++ b/code/nel/src/gui/ctrl_button.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlButton, std::string, "button"); namespace NLGUI @@ -442,6 +446,9 @@ namespace NLGUI // *************************************************************************** sint32 CCtrlButton::getMaxUsedW() const { + if (_Scale) + return _WReal; + sint32 txw, txh; CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh); diff --git a/code/nel/src/gui/ctrl_col_pick.cpp b/code/nel/src/gui/ctrl_col_pick.cpp index 2d62b6e74..4079388c2 100644 --- a/code/nel/src/gui/ctrl_col_pick.cpp +++ b/code/nel/src/gui/ctrl_col_pick.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlColPick, std::string, "colpick"); namespace NLGUI diff --git a/code/nel/src/gui/ctrl_draggable.cpp b/code/nel/src/gui/ctrl_draggable.cpp index 39872ab18..781585083 100644 --- a/code/nel/src/gui/ctrl_draggable.cpp +++ b/code/nel/src/gui/ctrl_draggable.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/ctrl_draggable.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/ctrl_polygon.cpp b/code/nel/src/gui/ctrl_polygon.cpp index 86059087d..c7ce984d2 100644 --- a/code/nel/src/gui/ctrl_polygon.cpp +++ b/code/nel/src/gui/ctrl_polygon.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/ctrl_quad.cpp b/code/nel/src/gui/ctrl_quad.cpp index 47346692c..22f4d4ae6 100644 --- a/code/nel/src/gui/ctrl_quad.cpp +++ b/code/nel/src/gui/ctrl_quad.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/ctrl_scroll.cpp b/code/nel/src/gui/ctrl_scroll.cpp index ad2ca14f5..9c9585fcc 100644 --- a/code/nel/src/gui/ctrl_scroll.cpp +++ b/code/nel/src/gui/ctrl_scroll.cpp @@ -28,6 +28,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlScroll, std::string, "scroll"); namespace NLGUI diff --git a/code/nel/src/gui/ctrl_scroll_base.cpp b/code/nel/src/gui/ctrl_scroll_base.cpp index f95cac5d7..2813b997a 100644 --- a/code/nel/src/gui/ctrl_scroll_base.cpp +++ b/code/nel/src/gui/ctrl_scroll_base.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/ctrl_scroll_base.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/ctrl_sheet_selection.cpp b/code/nel/src/gui/ctrl_sheet_selection.cpp index bdbe0e73d..d0202547f 100644 --- a/code/nel/src/gui/ctrl_sheet_selection.cpp +++ b/code/nel/src/gui/ctrl_sheet_selection.cpp @@ -23,6 +23,10 @@ #include "nel/gui/ctrl_sheet_selection.h" #include "nel/gui/view_renderer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index c292d5473..81dfcc953 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -30,6 +30,9 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif NLMISC_REGISTER_OBJECT(CViewBase, CCtrlTextButton, std::string, "text_button"); diff --git a/code/nel/src/gui/ctrl_tooltip.cpp b/code/nel/src/gui/ctrl_tooltip.cpp index 8a0427751..da42084ac 100644 --- a/code/nel/src/gui/ctrl_tooltip.cpp +++ b/code/nel/src/gui/ctrl_tooltip.cpp @@ -23,6 +23,10 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlToolTip, std::string, "tooltip"); REGISTER_UI_CLASS(CCtrlToolTip) diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp new file mode 100644 index 000000000..6cf34c8b8 --- /dev/null +++ b/code/nel/src/gui/curl_certificates.cpp @@ -0,0 +1,123 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +//#include + +#include "stdpch.h" +#include "nel/gui/curl_certificates.h" + +#include +#include + +#if defined(NL_OS_WINDOWS) +#pragma comment(lib, "crypt32.lib") +#pragma comment(lib, "cryptui.lib") +#endif + +using namespace std; +using namespace NLMISC; + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + +namespace NLGUI +{ +#if defined(NL_OS_WINDOWS) + static std::vector x509CertList; + + // + // x509CertList lifetime manager + // + class SX509Certificates { + public: + SX509Certificates() + { + 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) + { + X509_free(x509CertList[i]); + } + + x509CertList.clear(); + } + + void addCertificatesFrom(LPCSTR root) + { + HCERTSTORE hStore; + PCCERT_CONTEXT pContext = NULL; + X509 *x509; + hStore = CertOpenSystemStore(NULL, root); + if (hStore) + { + while (pContext = CertEnumCertificatesInStore(hStore, pContext)) + { + x509 = NULL; + x509 = d2i_X509(NULL, (const unsigned char **)&pContext->pbCertEncoded, pContext->cbCertEncoded); + if (x509) + { + x509CertList.push_back(x509); + } + } + 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", List.size(), root); + } + }; + + /// this will be initialized on startup and cleared on exit + static SX509Certificates x509CertListManager; + + // *************************************************************************** + // static + CURLcode CCurlCertificates::sslCtxFunction(CURL *curl, void *sslctx, void *parm) + { + if (x509CertList.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) + { + X509_STORE_add_cert(x509store, x509CertList[i]); + } + } + else + { + nlwarning("SSL_CTX_get_cert_store returned NULL"); + } + } + return CURLE_OK; + } +#endif // NL_OS_WINDOWS + +}// namespace + diff --git a/code/nel/src/gui/db_manager.cpp b/code/nel/src/gui/db_manager.cpp index a169adf8d..7896cbde3 100644 --- a/code/nel/src/gui/db_manager.cpp +++ b/code/nel/src/gui/db_manager.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/db_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { CDBManager* CDBManager::instance = NULL; diff --git a/code/nel/src/gui/dbgroup_combo_box.cpp b/code/nel/src/gui/dbgroup_combo_box.cpp index 184829e4c..2afd8c570 100644 --- a/code/nel/src/gui/dbgroup_combo_box.cpp +++ b/code/nel/src/gui/dbgroup_combo_box.cpp @@ -28,6 +28,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupComboBox, std::string, "combo_box"); diff --git a/code/nel/src/gui/dbgroup_select_number.cpp b/code/nel/src/gui/dbgroup_select_number.cpp index b3dc2e8f1..22afa4d0e 100644 --- a/code/nel/src/gui/dbgroup_select_number.cpp +++ b/code/nel/src/gui/dbgroup_select_number.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NL3D; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupSelectNumber, std::string, "select_number"); diff --git a/code/nel/src/gui/dbview_bar.cpp b/code/nel/src/gui/dbview_bar.cpp index f4befb389..e2256444f 100644 --- a/code/nel/src/gui/dbview_bar.cpp +++ b/code/nel/src/gui/dbview_bar.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NL3D; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CDBViewBar, std::string, "bar"); namespace NLGUI diff --git a/code/nel/src/gui/dbview_bar3.cpp b/code/nel/src/gui/dbview_bar3.cpp index 32d3e9eaf..187a52f99 100644 --- a/code/nel/src/gui/dbview_bar3.cpp +++ b/code/nel/src/gui/dbview_bar3.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NL3D; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { NLMISC_REGISTER_OBJECT(CViewBase, CDBViewBar3, std::string, "bar3"); diff --git a/code/nel/src/gui/dbview_digit.cpp b/code/nel/src/gui/dbview_digit.cpp index 318327a77..81063d519 100644 --- a/code/nel/src/gui/dbview_digit.cpp +++ b/code/nel/src/gui/dbview_digit.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NL3D; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CDBViewDigit, std::string, "digit"); namespace NLGUI diff --git a/code/nel/src/gui/dbview_number.cpp b/code/nel/src/gui/dbview_number.cpp index e844bf4c0..36f5523f2 100644 --- a/code/nel/src/gui/dbview_number.cpp +++ b/code/nel/src/gui/dbview_number.cpp @@ -24,6 +24,9 @@ using namespace std; using namespace NL3D; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif NLMISC_REGISTER_OBJECT(CViewBase, CDBViewNumber, std::string, "text_number"); diff --git a/code/nel/src/gui/dbview_quantity.cpp b/code/nel/src/gui/dbview_quantity.cpp index 12dfce4b8..4685fc23d 100644 --- a/code/nel/src/gui/dbview_quantity.cpp +++ b/code/nel/src/gui/dbview_quantity.cpp @@ -24,6 +24,9 @@ using namespace std; using namespace NL3D; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif NLMISC_REGISTER_OBJECT(CViewBase, CDBViewQuantity, std::string, "text_quantity"); diff --git a/code/nel/src/gui/event_descriptor.cpp b/code/nel/src/gui/event_descriptor.cpp index fd1856ed3..356e75aec 100644 --- a/code/nel/src/gui/event_descriptor.cpp +++ b/code/nel/src/gui/event_descriptor.cpp @@ -19,6 +19,10 @@ #include "nel/misc/events.h" #include "nel/gui/event_descriptor.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/event_listener.cpp b/code/nel/src/gui/event_listener.cpp index 4f4d7a17d..b1e53c374 100644 --- a/code/nel/src/gui/event_listener.cpp +++ b/code/nel/src/gui/event_listener.cpp @@ -21,6 +21,10 @@ #include "nel/gui/interface_group.h" #include "nel/gui/widget_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { CEventListener::CEventListener() diff --git a/code/nel/src/gui/group_container.cpp b/code/nel/src/gui/group_container.cpp index 818c71278..1922db221 100644 --- a/code/nel/src/gui/group_container.cpp +++ b/code/nel/src/gui/group_container.cpp @@ -39,6 +39,10 @@ using namespace std; using namespace NL3D; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace { const sint SIZE_W_LEFT = 16; diff --git a/code/nel/src/gui/group_container_base.cpp b/code/nel/src/gui/group_container_base.cpp index 974964955..c031cec7e 100644 --- a/code/nel/src/gui/group_container_base.cpp +++ b/code/nel/src/gui/group_container_base.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/group_container_base.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index 48347aed1..e7ed22583 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -33,6 +33,9 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLGUI { @@ -74,6 +77,7 @@ namespace NLGUI _ResetFocusOnHide(false), _BackupFatherContainerPos(false), _WantReturn(false), + _ClearOnEscape(false), _Savable(true), _DefaultInputString(false), _Frozen(false), @@ -236,6 +240,11 @@ namespace NLGUI return toString( _WantReturn ); } else + if( name == "clear_on_escape" ) + { + return toString( _ClearOnEscape ); + } + else if( name == "savable" ) { return toString( _Savable ); @@ -410,6 +419,14 @@ namespace NLGUI return; } else + if( name == "clear_on_escape" ) + { + bool b; + if( fromString( value, b ) ) + _ClearOnEscape = b; + return; + } + else if( name == "savable" ) { bool b; @@ -511,6 +528,7 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "backup_father_container_pos", BAD_CAST toString( _BackupFatherContainerPos ).c_str() ); xmlSetProp( node, BAD_CAST "want_return", BAD_CAST toString( _WantReturn ).c_str() ); + xmlSetProp( node, BAD_CAST "clear_on_escape", BAD_CAST toString( _ClearOnEscape ).c_str() ); xmlSetProp( node, BAD_CAST "savable", BAD_CAST toString( _Savable ).c_str() ); xmlSetProp( node, BAD_CAST "max_float_prec", BAD_CAST toString( _MaxFloatPrec ).c_str() ); @@ -617,6 +635,9 @@ namespace NLGUI prop = (char*) xmlGetProp( cur, (xmlChar*)"want_return" ); if (prop) _WantReturn = convertBool(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"clear_on_escape" ); + if (prop) _ClearOnEscape = convertBool(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"savable" ); if (prop) _Savable = convertBool(prop); @@ -988,6 +1009,11 @@ namespace NLGUI // stop selection _CurrSelection = NULL; _CursorAtPreviousLineEnd = false; + if (_ClearOnEscape) + { + setInputString(ucstring("")); + triggerOnChangeAH(); + } break; case KeyTAB: makeTopWindow(); @@ -1768,7 +1794,7 @@ namespace NLGUI // *************************************************************************** void CGroupEditBox::clearAllEditBox() { - _InputString = ""; + _InputString.clear(); _CursorPos = 0; _CursorAtPreviousLineEnd = false; if (!_ViewText) return; diff --git a/code/nel/src/gui/group_editbox_base.cpp b/code/nel/src/gui/group_editbox_base.cpp index 133af0b83..d3c001c34 100644 --- a/code/nel/src/gui/group_editbox_base.cpp +++ b/code/nel/src/gui/group_editbox_base.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/group_editbox_base.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index 07e07ddf3..6d1e500ae 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -20,6 +20,10 @@ #include "nel/gui/view_bitmap.h" #include "nel/gui/view_text.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { class EBDPrivate diff --git a/code/nel/src/gui/group_frame.cpp b/code/nel/src/gui/group_frame.cpp index d0a652092..747ca454e 100644 --- a/code/nel/src/gui/group_frame.cpp +++ b/code/nel/src/gui/group_frame.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -145,7 +149,7 @@ namespace NLGUI } // The first type in display type struct is the default display type - if (_DispTypes.size() == 0) + if (_DispTypes.empty()) { SDisplayType dt; dt.Name = "default"; diff --git a/code/nel/src/gui/group_header.cpp b/code/nel/src/gui/group_header.cpp index 908aa183e..dbc990447 100644 --- a/code/nel/src/gui/group_header.cpp +++ b/code/nel/src/gui/group_header.cpp @@ -24,6 +24,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index f64fc631c..7b2621b18 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -45,10 +45,16 @@ #include "nel/3d/texture_file.h" #include "nel/misc/big_file.h" #include "nel/gui/url_parser.h" +#include "nel/gui/http_cache.h" +#include "nel/gui/http_hsts.h" +#include "nel/gui/curl_certificates.h" using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif // Default maximum time the request is allowed to take #define DEFAULT_RYZOM_CONNECTION_TIMEOUT (300.0) @@ -66,6 +72,25 @@ namespace NLGUI CGroupHTML::SWebOptions CGroupHTML::options; + // Return URL with https is host is in HSTS list + static std::string upgradeInsecureUrl(const std::string &url) + { + if (toLower(url.substr(0, 7)) != "http://") { + return url; + } + + CUrlParser uri(url); + if (!CStrictTransportSecurity::getInstance()->isSecureHost(uri.host)){ + return url; + } + + #ifdef LOG_DL + nlwarning("HSTS url : '%s', using https", url.c_str()); + #endif + uri.scheme = "https"; + + return uri.toString(); + } // Active cURL www transfer class CCurlWWWData @@ -84,6 +109,15 @@ namespace NLGUI curl_slist_free_all(HeadersSent); } + void sendHeaders(const std::vector headers) + { + for(uint i = 0; i < headers.size(); ++i) + { + HeadersSent = curl_slist_append(HeadersSent, headers[i].c_str()); + } + curl_easy_setopt(Request, CURLOPT_HTTPHEADER, HeadersSent); + } + void setRecvHeader(const std::string &header) { size_t pos = header.find(": "); @@ -107,12 +141,63 @@ namespace NLGUI return ""; } + const uint32 getExpires() + { + time_t ret = 0; + if (HeadersRecv.count("expires") > 0) + ret = curl_getdate(HeadersRecv["expires"].c_str(), NULL); + + return ret > -1 ? ret : 0; + } + + const std::string getLastModified() + { + if (HeadersRecv.count("last-modified") > 0) + { + return HeadersRecv["last-modified"]; + } + + return ""; + } + + const std::string getEtag() + { + if (HeadersRecv.count("etag") > 0) + { + return HeadersRecv["etag"]; + } + + return ""; + } + + bool hasHSTSHeader() + { + // ignore header if not secure connection + if (toLower(Url.substr(0, 8)) != "https://") + { + return false; + } + + return HeadersRecv.count("strict-transport-security") > 0; + } + + const std::string getHSTSHeader() + { + if (hasHSTSHeader()) + { + return HeadersRecv["strict-transport-security"]; + } + + return ""; + } + public: CURL *Request; std::string Url; std::string Content; + private: // headers sent with curl request, must be released after transfer curl_slist * HeadersSent; @@ -129,18 +214,23 @@ namespace NLGUI } // Update view after download has finished - void CGroupHTML::setImage(CViewBase * view, const string &file) + void CGroupHTML::setImage(CViewBase * view, const string &file, const TImageType type) { CCtrlButton *btn = dynamic_cast(view); if(btn) { - btn->setTexture (file); - btn->setTexturePushed(file); - btn->invalidateCoords(); - btn->invalidateContent(); - btn->resetInvalidCoords(); - btn->updateCoords(); - paragraphChange(); + if (type == NormalImage) + { + btn->setTexture (file); + btn->setTexturePushed(file); + btn->invalidateCoords(); + btn->invalidateContent(); + paragraphChange(); + } + else + { + btn->setTextureOver(file); + } } else { @@ -150,8 +240,6 @@ namespace NLGUI btm->setTexture (file); btm->invalidateCoords(); btm->invalidateContent(); - btm->resetInvalidCoords(); - btm->updateCoords(); paragraphChange(); } else @@ -162,14 +250,12 @@ namespace NLGUI btgc->setTexture (file); btgc->invalidateCoords(); btgc->invalidateContent(); - btgc->resetInvalidCoords(); - btgc->updateCoords(); paragraphChange(); } } } } - + // Force image width, height void CGroupHTML::setImageSize(CViewBase *view, const CStyleParams &style) { @@ -262,10 +348,117 @@ namespace NLGUI return dest; } - // Add a image download request in the multi_curl - void CGroupHTML::addImageDownload(const string &url, CViewBase *img, const CStyleParams &style) + // Add url to MultiCurl queue and return cURL handle + bool CGroupHTML::startCurlDownload(CDataDownload &download) { - string finalUrl = getAbsoluteUrl(url); + if (!MultiCurl) + { + nlwarning("Invalid MultiCurl handle, unable to download '%s'", download.url.c_str()); + return false; + } + + time_t currentTime; + time(¤tTime); + + CHttpCacheObject cache; + if (CFile::fileExists(download.dest)) + cache = CHttpCache::getInstance()->lookup(download.dest); + + if (cache.Expires > currentTime) + { + #ifdef LOG_DL + nlwarning("Cache for (%s) is not expired (%s, expires:%d)", download.url.c_str(), download.dest.c_str(), cache.Expires - currentTime); + #endif + return false; + } + + string tmpdest = download.dest + ".tmp"; + + // erase the tmp file if exists + if (CFile::fileExists(tmpdest)) + CFile::deleteFile(tmpdest); + + FILE *fp = nlfopen (tmpdest, "wb"); + if (fp == NULL) + { + nlwarning("Can't open file '%s' for writing: code=%d '%s'", tmpdest.c_str (), errno, strerror(errno)); + return false; + } + + CURL *curl = curl_easy_init(); + if (!curl) + { + fclose(fp); + CFile::deleteFile(tmpdest); + + nlwarning("Creating cURL handle failed, unable to download '%s'", download.url.c_str()); + return false; + } + +#if defined(NL_OS_WINDOWS) + // https:// + if (toLower(download.url.substr(0, 8)) == "https://") + { + curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &CCurlCertificates::sslCtxFunction); + } +#endif + + download.data = new CCurlWWWData(curl, download.url); + download.fp = fp; + + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true); + curl_easy_setopt(curl, CURLOPT_URL, download.url.c_str()); + + // limit curl to HTTP and HTTPS protocols only + curl_easy_setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + + std::vector headers; + if (!cache.Etag.empty()) + headers.push_back("If-None-Match: " + cache.Etag); + + if (!cache.LastModified.empty()) + headers.push_back("If-Modified-Since: " + cache.LastModified); + + if (headers.size() > 0) + download.data->sendHeaders(headers); + + // catch headers + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curlHeaderCallback); + curl_easy_setopt(curl, CURLOPT_WRITEHEADER, download.data); + + std::string userAgent = options.appName + "/" + options.appVersion; + curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); + + CUrlParser uri(download.url); + if (!uri.host.empty()) + sendCookies(curl, uri.host, isTrustedDomain(uri.host)); + + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); + + curl_multi_add_handle(MultiCurl, curl); + + return true; + } + + // Add a image download request in the multi_curl + void CGroupHTML::addImageDownload(const string &url, CViewBase *img, const CStyleParams &style, TImageType type) + { + string finalUrl = upgradeInsecureUrl(getAbsoluteUrl(url)); + + // use requested url for local name (cache) + string dest = localImageName(url); + #ifdef LOG_DL + nlwarning("add to download '%s' dest '%s' img %p", finalUrl.c_str(), dest.c_str(), img); + #endif + + // Display cached image while downloading new + if (type != TImageType::OverImage && CFile::fileExists(dest)) + { + setImage(img, dest, type); + setImageSize(img, style); + } // Search if we are not already downloading this url. for(uint i = 0; i < Curls.size(); i++) @@ -275,67 +468,27 @@ namespace NLGUI #ifdef LOG_DL nlwarning("already downloading '%s' img %p", finalUrl.c_str(), img); #endif - Curls[i].imgs.push_back(CDataImageDownload(img, style)); + Curls[i].imgs.push_back(CDataImageDownload(img, style, type)); return; } } - // use requested url for local name - string dest = localImageName(url); - string tmpdest = localImageName(url)+".tmp"; - #ifdef LOG_DL - nlwarning("add to download '%s' dest '%s' img %p", finalUrl.c_str(), dest.c_str(), img); - #endif - - // erase the tmp file if exists - if (NLMISC::CFile::fileExists(tmpdest)) - NLMISC::CFile::deleteFile(tmpdest); - - if (!NLMISC::CFile::fileExists(dest)) - { - if (!MultiCurl) + Curls.push_back(CDataDownload(finalUrl, dest, ImgType, img, "", "", style, type)); + if (Curls.size() < options.curlMaxConnections) { + if (!startCurlDownload(Curls.back())) { - nlwarning("Invalid MultiCurl handle, unable to download '%s'", finalUrl.c_str()); + Curls.pop_back(); return; } - CURL *curl = curl_easy_init(); - if (!curl) - { - nlwarning("Creating cURL handle failed, unable to download '%s'", finalUrl.c_str()); - return; - } - - FILE *fp = nlfopen(tmpdest, "wb"); - if (fp == NULL) - { - curl_easy_cleanup(curl); - - nlwarning("Can't open file '%s' for writing: code=%d '%s'", tmpdest.c_str (), errno, strerror(errno)); - return; - } - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true); - curl_easy_setopt(curl, CURLOPT_URL, finalUrl.c_str()); - - std::string userAgent = options.appName + "/" + options.appVersion; - curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); - - sendCookies(curl, _DocumentDomain, _TrustedDomain); - - curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); - - curl_multi_add_handle(MultiCurl, curl); - Curls.push_back(CDataDownload(curl, finalUrl, dest, fp, ImgType, img, "", "", style)); - #ifdef LOG_DL - nlwarning("adding handle %x, %d curls", curl, Curls.size()); - #endif RunningCurls++; + #ifdef LOG_DL + nlwarning("(%s) adding handle %x, %d curls", _Id.c_str(), Curls.back().data->Request, Curls.size()); } else { - setImage(img, dest); - setImageSize(img, style); + nlwarning("(%s) download queued, %d curls", _Id.c_str(), Curls.size()); + #endif } } @@ -360,8 +513,10 @@ namespace NLGUI } // Add a bnp download request in the multi_curl, return true if already downloaded - bool CGroupHTML::addBnpDownload(const string &url, const string &action, const string &script, const string &md5sum) + bool CGroupHTML::addBnpDownload(string url, const string &action, const string &script, const string &md5sum) { + url = upgradeInsecureUrl(getAbsoluteUrl(url)); + // Search if we are not already downloading this url. for(uint i = 0; i < Curls.size(); i++) { @@ -375,14 +530,9 @@ namespace NLGUI } string dest = localBnpName(url); - string tmpdest = localBnpName(url)+".tmp"; #ifdef LOG_DL nlwarning("add to download '%s' dest '%s'", url.c_str(), dest.c_str()); #endif - - // erase the tmp file if exists - if (NLMISC::CFile::fileExists(tmpdest)) - NLMISC::CFile::deleteFile(tmpdest); // create/delete the local file if (NLMISC::CFile::fileExists(dest)) @@ -399,39 +549,23 @@ namespace NLGUI } if (action != "delete") { - if (!MultiCurl) + Curls.push_back(CDataDownload(url, dest, BnpType, NULL, script, md5sum)); + if (Curls.size() < options.curlMaxConnections) { - nlwarning("Invalid MultiCurl handle, unable to download '%s'", url.c_str()); - return false; - } - - CURL *curl = curl_easy_init(); - if (!curl) - { - nlwarning("Creating cURL handle failed, unable to download '%s'", url.c_str()); - return false; - } - - FILE *fp = nlfopen (tmpdest, "wb"); - if (fp == NULL) - { - curl_easy_cleanup(curl); - nlwarning("Can't open file '%s' for writing: code=%d '%s'", tmpdest.c_str (), errno, strerror(errno)); - return false; - } - - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true); - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - - curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); - - curl_multi_add_handle(MultiCurl, curl); - Curls.push_back(CDataDownload(curl, url, dest, fp, BnpType, NULL, script, md5sum)); + if (!startCurlDownload(Curls.back())) + { + Curls.pop_back(); + return false; + } + RunningCurls++; #ifdef LOG_DL - nlwarning("adding handle %x, %d curls", curl, Curls.size()); + nlwarning("(%s) adding handle %x, %d curls", _Id.c_str(), Curls.back().data->Request, Curls.size()); + } + else + { + nlwarning("(%s) download queued, %d curls", _Id.c_str(), Curls.size()); #endif - RunningCurls++; + } } else return true; @@ -491,10 +625,20 @@ namespace NLGUI #ifdef LOG_DL nlwarning("(%s) web transfer '%p' completed with status %d, http %d, url (len %d) '%s'", _Id.c_str(), _CurlWWW->Request, res, code, _CurlWWW->Url.size(), _CurlWWW->Url.c_str()); #endif + // save HSTS header from all requests regardless of HTTP code + if (res == CURLE_OK && _CurlWWW->hasHSTSHeader()) + { + CUrlParser uri(_CurlWWW->Url); + CStrictTransportSecurity::getInstance()->setFromHeader(uri.host, _CurlWWW->getHSTSHeader()); + } if (res != CURLE_OK) { - browseError(string("Connection failed with curl error " + string(curl_easy_strerror(res))).c_str()); + std::string err; + err = "Connection failed with cURL error: "; + err += curl_easy_strerror(res); + err += "\nURL '" + _CurlWWW->Url + "'"; + browseError(err.c_str()); } else if ((code >= 301 && code <= 303) || code == 307 || code == 308) @@ -510,7 +654,7 @@ namespace NLGUI // redirect, get the location and try browse again // we cant use curl redirection because 'addHTTPGetParams()' must be called on new destination std::string location(_CurlWWW->getLocationHeader()); - if (location.size() > 0) + if (!location.empty()) { #ifdef LOG_DL nlwarning("(%s) request (%d) redirected to (len %d) '%s'", _Id.c_str(), _RedirectsRemaining, location.size(), location.c_str()); @@ -538,14 +682,14 @@ namespace NLGUI if ( (code < 200 || code >= 300) ) { - browseError(string("Connection failed (curl code " + toString((sint32)res) + "), http code " + toString((sint32)code) + ") : " + _CurlWWW->Url).c_str()); + browseError(string("Connection failed (curl code " + toString((sint32)res) + ")\nhttp code " + toString((sint32)code) + ")\nURL '" + _CurlWWW->Url + "'").c_str()); } else { char *ch; std::string contentType; res = curl_easy_getinfo(_CurlWWW->Request, CURLINFO_CONTENT_TYPE, &ch); - if (res == CURLE_OK) + if (res == CURLE_OK && ch != NULL) { contentType = ch; } @@ -554,30 +698,93 @@ namespace NLGUI } requestTerminated(); } + + continue; } for (vector::iterator it=Curls.begin(); iteasy_handle == it->curl) + if(it->data && it->data->Request == msg->easy_handle) { CURLcode res = msg->data.result; long r; - curl_easy_getinfo(it->curl, CURLINFO_RESPONSE_CODE, &r); + curl_easy_getinfo(it->data->Request, CURLINFO_RESPONSE_CODE, &r); fclose(it->fp); + CUrlParser uri(it->url); + if (!uri.host.empty()) + receiveCookies(it->data->Request, uri.host, isTrustedDomain(uri.host)); #ifdef LOG_DL - nlwarning("(%s) transfer '%p' completed with status %d, http %d, url (len %d) '%s'", _Id.c_str(), it->curl, res, r, it->url.size(), it->url.c_str()); + nlwarning("(%s) transfer '%p' completed with status %d, http %d, url (len %d) '%s'", _Id.c_str(), it->data->Request, res, r, it->url.size(), it->url.c_str()); #endif - curl_multi_remove_handle(MultiCurl, it->curl); - curl_easy_cleanup(it->curl); + curl_multi_remove_handle(MultiCurl, it->data->Request); + + // save HSTS header from all requests regardless of HTTP code + if (res == CURLE_OK && it->data->hasHSTSHeader()) + { + CStrictTransportSecurity::getInstance()->setFromHeader(uri.host, it->data->getHSTSHeader()); + } string tmpfile = it->dest + ".tmp"; - if(res != CURLE_OK || r < 200 || r >= 300 || ((it->md5sum != "") && (it->md5sum != getMD5(tmpfile).toString()))) + if(res != CURLE_OK || r < 200 || r >= 300 || (!it->md5sum.empty() && (it->md5sum != getMD5(tmpfile).toString()))) { - NLMISC::CFile::deleteFile(tmpfile.c_str()); + if (it->redirects < DEFAULT_RYZOM_REDIRECT_LIMIT && ((r >= 301 && r <= 303) || r == 307 || r == 308)) + { + std::string location(it->data->getLocationHeader()); + if (!location.empty()) + { + CUrlParser uri(location); + if (!uri.isAbsolute()) + { + uri.inherit(it->url); + location = uri.toString(); + } + + it->url = location; + it->fp = NULL; + + // release CCurlWWWData + delete it->data; + it->data = NULL; + + it->redirects++; + #ifdef LOG_DL + nlwarning("Redirect '%s'", location.c_str()); + #endif + // keep the request in queue + continue; + } + else + nlwarning("Redirected to empty url '%s'", it->url.c_str()); + } + else + { + if (it->redirects >= DEFAULT_RYZOM_REDIRECT_LIMIT) + nlwarning("Redirect limit reached for '%s'", it->url.c_str()); + + NLMISC::CFile::deleteFile(tmpfile.c_str()); + + // 304 Not Modified + if (res == CURLE_OK && r == 304) + { + CHttpCacheObject obj; + obj.Expires = it->data->getExpires(); + obj.Etag = it->data->getEtag(); + obj.LastModified = it->data->getLastModified(); + + CHttpCache::getInstance()->store(it->dest, obj); + } + } } else { + CHttpCacheObject obj; + obj.Expires = it->data->getExpires(); + obj.Etag = it->data->getEtag(); + obj.LastModified = it->data->getLastModified(); + + CHttpCache::getInstance()->store(it->dest, obj); + string finalUrl; if (it->type == ImgType) { @@ -585,11 +792,28 @@ namespace NLGUI // second instance deletes first tmpfile and creates new file for itself. if (CFile::getFileSize(tmpfile) > 0) { - CFile::moveFile(it->dest, tmpfile); - for(uint i = 0; i < it->imgs.size(); i++) + try { - setImage(it->imgs[i].Image, it->dest); - setImageSize(it->imgs[i].Image, it->imgs[i].Style); + // verify that image is not corrupted + uint32 w, h; + CBitmap::loadSize(tmpfile, w, h); + if (w != 0 && h != 0) + { + if (CFile::fileExists(it->dest)) + CFile::deleteFile(it->dest); + + CFile::moveFile(it->dest, tmpfile); + for(uint i = 0; i < it->imgs.size(); i++) + { + setImage(it->imgs[i].Image, it->dest, it->imgs[i].Type); + setImageSize(it->imgs[i].Image, it->imgs[i].Style); + } + } + } + catch(const NLMISC::Exception &e) + { + // exception message has .tmp file name, so keep it for further analysis + nlwarning("Invalid image (%s): %s", it->url.c_str(), e.what()); } } } @@ -603,6 +827,9 @@ namespace NLGUI } } + // release CCurlWWWData + delete it->data; + Curls.erase(it); break; } @@ -610,9 +837,32 @@ namespace NLGUI } } } + RunningCurls = NewRunningCurls; + + if (RunningCurls < options.curlMaxConnections) + { + for (vector::iterator it=Curls.begin(); itdata == NULL) { #ifdef LOG_DL - if (RunningCurls > 0 || Curls.size() > 0) + nlwarning("(%s) starting new download '%s'", _Id.c_str(), it->url.c_str()); + #endif + if (!startCurlDownload(*it)) + { + Curls.erase(it); + break; + } + + RunningCurls++; + if (RunningCurls >= options.curlMaxConnections) + break; + } + } + } + + #ifdef LOG_DL + if (RunningCurls > 0 || !Curls.empty()) nlwarning("(%s) RunningCurls %d, _Curls %d", _Id.c_str(), RunningCurls, Curls.size()); #endif } @@ -623,8 +873,20 @@ namespace NLGUI #ifdef LOG_DL nlwarning("Release Downloads"); #endif - if(MultiCurl) - curl_multi_cleanup(MultiCurl); + + // remove all queued and already started downloads + for (uint i = 0; i < Curls.size(); ++i) + { + if (Curls[i].data) + { + if (MultiCurl) + curl_multi_remove_handle(MultiCurl, Curls[i].data->Request); + + // release CCurlWWWData + delete Curls[i].data; + } + } + Curls.clear(); } class CGroupListAdaptor : public CInterfaceGroup @@ -835,6 +1097,7 @@ namespace NLGUI result.R = 255 * hueToRgb(m1, m2, h + 1.0f/3.0f); result.G = 255 * hueToRgb(m1, m2, h); result.B = 255 * hueToRgb(m1, m2, h - 1.0f/3.0f); + result.A = 255; } class CNameToCol @@ -1223,6 +1486,7 @@ namespace NLGUI style.TextColor = LinkColor; style.Underlined = true; style.StrikeThrough = getFontStrikeThrough(); + style.GlobalColor = LinkColorGlobalColor; if (present[HTML_A_STYLE] && value[HTML_A_STYLE]) getStyleParams(value[HTML_A_STYLE], style); @@ -1232,7 +1496,7 @@ namespace NLGUI _TextColor.push_back(style.TextColor); _FontUnderlined.push_back(style.Underlined); _FontStrikeThrough.push_back(style.StrikeThrough); - _GlobalColor.push_back(LinkColorGlobalColor); + _GlobalColor.push_back(style.GlobalColor); _A.push_back(true); _Link.push_back (""); _LinkTitle.push_back(""); @@ -1382,7 +1646,14 @@ namespace NLGUI } break; case HTML_BR: - addString(ucstring ("\n")); + { + endParagraph(); + + // insert zero-width-space (0x200B) to prevent removal of empty lines + ucstring tmp; + tmp.fromUtf8("\xe2\x80\x8b"); + addString(tmp); + } break; case HTML_BODY: { @@ -1495,31 +1766,49 @@ namespace NLGUI getPercentage(style.Width, tmpf, value[MY_HTML_IMG_WIDTH]); if (present[MY_HTML_IMG_HEIGHT] && value[MY_HTML_IMG_HEIGHT]) getPercentage(style.Height, tmpf, value[MY_HTML_IMG_HEIGHT]); + + // Get the global color name + if (present[MY_HTML_IMG_GLOBAL_COLOR]) + style.GlobalColor = true; + // width, height from inline css if (present[MY_HTML_IMG_STYLE] && value[MY_HTML_IMG_STYLE]) getStyleParams(value[MY_HTML_IMG_STYLE], style); - - // Get the global color name - bool globalColor = false; - if (present[MY_HTML_IMG_GLOBAL_COLOR]) - globalColor = true; + + // Tooltip + const char *tooltip = NULL; + // keep "alt" attribute for backward compatibility + if (present[MY_HTML_IMG_ALT] && value[MY_HTML_IMG_ALT]) + tooltip = value[MY_HTML_IMG_ALT]; + // tooltip + if (present[MY_HTML_IMG_TITLE] && value[MY_HTML_IMG_TITLE]) + tooltip = value[MY_HTML_IMG_TITLE]; + + // Mouse over image + string overSrc; + if (present[MY_HTML_IMG_DATA_OVER_SRC] && value[MY_HTML_IMG_DATA_OVER_SRC]) + { + overSrc = value[MY_HTML_IMG_DATA_OVER_SRC]; + } + if (getA() && getParent () && getParent ()->getParent()) { - // Tooltip - const char *tooltip = NULL; - if (present[MY_HTML_IMG_ALT] && value[MY_HTML_IMG_ALT]) - tooltip = value[MY_HTML_IMG_ALT]; - string params = "name=" + getId() + "|url=" + getLink (); addButton(CCtrlButton::PushButton, value[MY_HTML_IMG_SRC], value[MY_HTML_IMG_SRC], value[MY_HTML_IMG_SRC], - "", globalColor, "browse", params.c_str(), tooltip, style); + overSrc, "browse", params.c_str(), tooltip, style); + } + else + if (tooltip || !overSrc.empty()) + { + addButton(CCtrlButton::PushButton, value[MY_HTML_IMG_SRC], value[MY_HTML_IMG_SRC], value[MY_HTML_IMG_SRC], + overSrc, "", "", tooltip, style); } else { // Get the option to reload (class==reload) bool reloadImg = false; - + string styleString; if (present[MY_HTML_IMG_STYLE] && value[MY_HTML_IMG_STYLE]) styleString = value[MY_HTML_IMG_STYLE]; @@ -1533,8 +1822,8 @@ namespace NLGUI if (it != styles.end() && (*it).second == "1") reloadImg = true; } - - addImage (value[MY_HTML_IMG_SRC], globalColor, reloadImg, style); + + addImage (value[MY_HTML_IMG_SRC], reloadImg, style); } } } @@ -1560,16 +1849,6 @@ namespace NLGUI // Get the type if (present[MY_HTML_INPUT_TYPE] && value[MY_HTML_INPUT_TYPE]) { - // Global color flag - bool globalColor = false; - if (present[MY_HTML_INPUT_GLOBAL_COLOR]) - globalColor = true; - - // Tooltip - const char *tooltip = NULL; - if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT]) - tooltip = value[MY_HTML_INPUT_ALT]; - // by default not inherited, font family defaults to system font CStyleParams style; style.TextColor = TextColor; @@ -1577,6 +1856,15 @@ namespace NLGUI style.FontWeight = FONT_WEIGHT_NORMAL; style.FontOblique = false; + // Global color flag + if (present[MY_HTML_INPUT_GLOBAL_COLOR]) + style.GlobalColor = true; + + // Tooltip + const char *tooltip = NULL; + if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT]) + tooltip = value[MY_HTML_INPUT_ALT]; + if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE]) getStyleParams(value[MY_HTML_INPUT_STYLE], style); @@ -1604,7 +1892,7 @@ namespace NLGUI // Add the ctrl button addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over, - globalColor, "html_submit_form", param.c_str(), tooltip, style); + "html_submit_form", param.c_str(), tooltip, style); } if (type == "button" || type == "submit") { @@ -1625,7 +1913,7 @@ namespace NLGUI // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=submit"; - if (text.size() > 0) + if (!text.empty()) { // escape AH param separator string tmp = text; @@ -1659,7 +1947,7 @@ namespace NLGUI if (!ctrlButton) ctrlButton = dynamic_cast(buttonGroup->getCtrl("b")); if (ctrlButton) { - ctrlButton->setModulateGlobalColorAll (globalColor); + ctrlButton->setModulateGlobalColorAll (style.GlobalColor); // Translate the tooltip if (tooltip) @@ -1742,8 +2030,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, - globalColor, "", "", tooltip); + CCtrlButton *checkbox = addButton (btnType, name, normal, pushed, over, "", "", tooltip, style); if (checkbox) { if (btnType == CCtrlButton::RadioButton) @@ -1902,8 +2189,9 @@ namespace NLGUI sint32 indent = LIIndent; // list-style-type: outside if (_CurrentViewLink) - indent -= _CurrentViewLink->getMaxUsedW(); - getParagraph()->setFirstViewIndent(indent); + { + getParagraph()->setFirstViewIndent(-_CurrentViewLink->getMaxUsedW()); + } flushString (); @@ -1959,15 +2247,15 @@ namespace NLGUI if (present[MY_HTML_TABLE_CELLPADDING] && value[MY_HTML_TABLE_CELLPADDING]) fromString(value[MY_HTML_TABLE_CELLPADDING], table->CellPadding); - // Table must fit the container size - - addGroup (table, 0); + table->setMarginLeft(getIndent()); + addHtmlGroup (table, 0); _Tables.push_back(table); // Add a cell pointer _Cells.push_back(NULL); _TR.push_back(false); + _Indent.push_back(0); } break; case HTML_TH: @@ -2011,7 +2299,6 @@ namespace NLGUI it = styles.find("background-image"); if (it != styles.end()) { - nlinfo("found background-image %s", it->second.c_str()); string image = (*it).second; string::size_type texExt = toLower(image).find("url("); // Url image @@ -2050,7 +2337,12 @@ namespace NLGUI _Cells.back()->NewLine = getTR(); table->addChild (_Cells.back()); + + // reusing indent pushed by table + _Indent.back() = 0; + newParagraph(TDBeginSpace); + // indent is already 0, getParagraph()->setMarginLeft(0); // maybe setIndent(0) if LI is using one // Reset TR flag if (!_TR.empty()) @@ -2089,10 +2381,10 @@ namespace NLGUI templateName = value[MY_HTML_TEXTAREA_Z_INPUT_TMPL]; // Get the string name - _TextAreaName = ""; + _TextAreaName.clear(); _TextAreaRow = 1; _TextAreaCols = 10; - _TextAreaContent = ""; + _TextAreaContent.clear(); _TextAreaMaxLength = 1024; if (present[MY_HTML_TEXTAREA_NAME] && value[MY_HTML_TEXTAREA_NAME]) _TextAreaName = value[MY_HTML_TEXTAREA_NAME]; @@ -2112,7 +2404,7 @@ namespace NLGUI if(!_TitlePrefix.empty()) _TitleString = _TitlePrefix + " - "; else - _TitleString = ""; + _TitleString.clear(); _Title = true; } break; @@ -2140,14 +2432,14 @@ namespace NLGUI _UL.push_back(HTMLOListElement(1, "square")); // if LI is already present _LI = _UL.size() > 1 || _DL.size() > 1; - _Indent += ULIndent; + _Indent.push_back(getIndent() + ULIndent); endParagraph(); break; case HTML_OBJECT: - _ObjectType = ""; - _ObjectData = ""; - _ObjectMD5Sum = ""; - _ObjectAction = ""; + _ObjectType.clear(); + _ObjectData.clear(); + _ObjectMD5Sum.clear(); + _ObjectAction.clear(); if (present[HTML_OBJECT_TYPE] && value[HTML_OBJECT_TYPE]) _ObjectType = value[HTML_OBJECT_TYPE]; if (present[HTML_OBJECT_DATA] && value[HTML_OBJECT_DATA]) @@ -2169,6 +2461,7 @@ namespace NLGUI style.FontOblique = getFontOblique(); style.Underlined = getFontUnderlined(); style.StrikeThrough = getFontStrikeThrough(); + style.GlobalColor = getGlobalColor(); if (present[MY_HTML_SPAN_STYLE] && value[MY_HTML_SPAN_STYLE]) getStyleParams(value[MY_HTML_SPAN_STYLE], style); @@ -2180,6 +2473,7 @@ namespace NLGUI _FontOblique.push_back(style.FontOblique); _FontUnderlined.push_back(style.Underlined); _FontStrikeThrough.push_back(style.StrikeThrough); + _GlobalColor.push_back(style.GlobalColor); } break; case HTML_DEL: @@ -2209,6 +2503,13 @@ namespace NLGUI case HTML_DT: if (!_DL.empty()) { + // close DT if still open + if (_DL.back().DD) + { + _DL.back().DD = false; + popIfNotEmpty(_Indent); + } + // see if this is the first
, closing tag not required if (!_DL.back().DT) { @@ -2239,8 +2540,8 @@ namespace NLGUI if (!_DL.back().DD) { - _Indent += ULIndent; _DL.back().DD = true; + _Indent.push_back(getIndent() + ULIndent); } if (!_LI) @@ -2267,7 +2568,7 @@ namespace NLGUI _UL.push_back(HTMLOListElement(start, type)); // if LI is already present _LI = _UL.size() > 1 || _DL.size() > 1; - _Indent += ULIndent; + _Indent.push_back(getIndent() + ULIndent); endParagraph(); } break; @@ -2369,7 +2670,7 @@ namespace NLGUI { endParagraph(); } - _DivName = ""; + _DivName.clear(); popIfNotEmpty (_Divs); popIfNotEmpty (_BlockLevelElement); break; @@ -2379,6 +2680,7 @@ namespace NLGUI popIfNotEmpty (_TR); popIfNotEmpty (_Cells); popIfNotEmpty (_Tables); + popIfNotEmpty (_Indent); endParagraph(); // Add a cell break; @@ -2444,6 +2746,7 @@ namespace NLGUI } break; case HTML_OPTION: + if (!(_Forms.empty()) && !(_Forms.back().Entries.empty())) { // insert the parsed text into the select control CDBGroupComboBox *cb = _Forms.back().Entries.back().ComboBox; @@ -2520,13 +2823,9 @@ namespace NLGUI case HTML_UL: if (!_UL.empty()) { - if (_Indent > ULIndent) - _Indent = _Indent - ULIndent; - else - _Indent = 0; - endParagraph(); popIfNotEmpty(_UL); + popIfNotEmpty(_Indent); } break; case HTML_DL: @@ -2543,10 +2842,7 @@ namespace NLGUI // unclosed DD if (_DL.back().DD) { - if (_Indent > ULIndent) - _Indent = _Indent - ULIndent; - else - _Indent = 0; + popIfNotEmpty(_Indent); } popIfNotEmpty (_DL); @@ -2565,12 +2861,8 @@ namespace NLGUI // parser will process two DD in a row as nested when first DD is not closed if (_DL.back().DD) { - if (_Indent > ULIndent) - _Indent = _Indent - ULIndent; - else - _Indent = 0; - _DL.back().DD = false; + popIfNotEmpty(_Indent); } } break; @@ -2582,6 +2874,7 @@ namespace NLGUI popIfNotEmpty (_TextColor); popIfNotEmpty (_FontUnderlined); popIfNotEmpty (_FontStrikeThrough); + popIfNotEmpty (_GlobalColor); break; case HTML_DEL: popIfNotEmpty (_FontStrikeThrough); @@ -2613,7 +2906,7 @@ namespace NLGUI { CLuaManager::getInstance().executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true); } - _ObjectScript = ""; + _ObjectScript.clear(); } } _Object = false; @@ -2631,7 +2924,7 @@ namespace NLGUI { // we receive an embeded lua script _ParsingLua = _TrustedDomain; // Only parse lua if TrustedDomain - _LuaScript = ""; + _LuaScript.clear(); } } @@ -2682,12 +2975,10 @@ namespace NLGUI _Connecting = false; _CurrentViewLink = NULL; _CurrentViewImage = NULL; - _Indent = 0; + _Indent.clear(); _LI = false; _SelectOption = false; _GroupListAdaptor = NULL; - _DocumentUrl = ""; - _DocumentDomain = ""; _UrlFragment.clear(); _RefreshUrl.clear(); _NextRefreshTime = 0.0; @@ -2740,7 +3031,6 @@ namespace NLGUI DefaultCheckBoxBitmapOver = "checkbox_over.tga"; DefaultRadioButtonBitmapNormal = "w_radiobutton.png"; DefaultRadioButtonBitmapPushed = "w_radiobutton_pushed.png"; - DefaultRadioButtonBitmapOver = ""; DefaultBackgroundBitmapView = "bg"; clearContext(); @@ -2783,8 +3073,13 @@ namespace NLGUI // this is why the call to 'updateRefreshButton' has been removed from stopBrowse clearContext(); + releaseDownloads(); + if (_CurlWWW) delete _CurlWWW; + + if(MultiCurl) + curl_multi_cleanup(MultiCurl); } std::string CGroupHTML::getProperty( const std::string &name ) const @@ -3754,11 +4049,10 @@ namespace NLGUI CGroupParagraph *newParagraph = new CGroupParagraph(CViewBase::TCtorParam()); newParagraph->setResizeFromChildH(true); - newParagraph->setBrowseGroup (this); - newParagraph->setIndent(_Indent); + newParagraph->setMarginLeft(getIndent()); // Add to the group - addGroup (newParagraph, beginSpace); + addHtmlGroup (newParagraph, beginSpace); _Paragraph = newParagraph; paragraphChange (); @@ -3805,7 +4099,7 @@ namespace NLGUI CUrlParser uri(url); - if (uri.hash.size() > 0) + if (!uri.hash.empty()) { // Anchor to scroll after page has loaded _UrlFragment = uri.hash; @@ -3951,7 +4245,7 @@ namespace NLGUI void CGroupHTML::registerAnchor(CInterfaceElement* elm) { - if (_AnchorName.size() > 0) + if (!_AnchorName.empty()) { for(uint32 i=0; i < _AnchorName.size(); ++i) { @@ -4108,6 +4402,9 @@ namespace NLGUI if (!newLink->Link.empty()) { newLink->setHTMLView (this); + + newLink->setActionOnLeftClick("browse"); + newLink->setParamsOnLeftClick("name=" + getId() + "|url=" + newLink->Link); } } newLink->setText(tmpStr); @@ -4141,7 +4438,7 @@ namespace NLGUI // *************************************************************************** - void CGroupHTML::addImage(const char *img, bool globalColor, bool reloadImg, const CStyleParams &style) + void CGroupHTML::addImage(const char *img, bool reloadImg, const CStyleParams &style) { // In a paragraph ? if (!_Paragraph) @@ -4173,32 +4470,40 @@ namespace NLGUI // 2/ if it doesn't work, try to load the image in cache // image = localImageName(img); - if (!reloadImg && lookupLocalFile (finalUrl, image.c_str(), false)) + + if (reloadImg && CFile::fileExists(image)) + CFile::deleteFile(image); + + if (lookupLocalFile (finalUrl, image.c_str(), false)) { // don't display image that are not power of 2 - uint32 w, h; - CBitmap::loadSize (image, w, h); - if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures())) + try + { + uint32 w, h; + CBitmap::loadSize (image, w, h); + if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures())) + image = "web_del.tga"; + } + catch(const NLMISC::Exception &e) + { + nlwarning(e.what()); image = "web_del.tga"; + } } else { - // - // 3/ if it doesn't work, display a placeholder and ask to dl the image into the cache - // - if (reloadImg && CFile::fileExists(image)) - CFile::deleteFile(image); - + // no image in cache image = "web_del.tga"; - addImageDownload(img, newImage, style); } + + addImageDownload(img, newImage, style); } newImage->setTexture (image); - newImage->setModulateGlobalColor(globalColor); + newImage->setModulateGlobalColor(style.GlobalColor); - getParagraph()->addChild(newImage); + getParagraph()->addChild(newImage); paragraphChange (); - + setImageSize(newImage, style); } @@ -4342,7 +4647,7 @@ namespace NLGUI // *************************************************************************** CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/* name */, const std::string &normalBitmap, const std::string &pushedBitmap, - const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, + const std::string &overBitmap, const char *actionHandler, const char *actionHandlerParams, const char *tooltip, const CStyleParams &style) { // In a paragraph ? @@ -4371,15 +4676,24 @@ namespace NLGUI if(!CFile::fileExists(normal)) { normal = "web_del.tga"; - addImageDownload(normalBitmap, ctrlButton, style); } else { - uint32 w, h; - CBitmap::loadSize(normal, w, h); - if (w == 0 || h == 0) + try + { + uint32 w, h; + CBitmap::loadSize(normal, w, h); + if (w == 0 || h == 0) + normal = "web_del.tga"; + } + catch(const NLMISC::Exception &e) + { + nlwarning(e.what()); normal = "web_del.tga"; + } } + + addImageDownload(normalBitmap, ctrlButton, style); } } @@ -4398,6 +4712,15 @@ namespace NLGUI } string over = overBitmap.empty()?"":CFile::getPath(overBitmap) + CFile::getFilenameWithoutExtension(overBitmap) + ".tga"; + // schedule mouseover bitmap for download if its different from normal + if (!over.empty() && !CPath::exists(over)) + { + if (overBitmap != normalBitmap) + { + over = localImageName(overBitmap); + addImageDownload(overBitmap, ctrlButton, style, TImageType::OverImage); + } + } ctrlButton->setType (type); if (!normal.empty()) @@ -4406,7 +4729,7 @@ namespace NLGUI ctrlButton->setTexturePushed (pushed); if (!over.empty()) ctrlButton->setTextureOver (over); - ctrlButton->setModulateGlobalColorAll (useGlobalColor); + ctrlButton->setModulateGlobalColorAll (style.GlobalColor); ctrlButton->setActionOnLeftClick (actionHandler); ctrlButton->setParamsOnLeftClick (actionHandlerParams); @@ -4458,7 +4781,7 @@ namespace NLGUI _FontOblique.clear(); _FontUnderlined.clear(); _FontStrikeThrough.clear(); - _Indent = 0; + _Indent.clear(); _LI = false; _UL.clear(); _DL.clear(); @@ -4494,6 +4817,18 @@ namespace NLGUI Curls[i].imgs.clear(); } + // remove download that are still queued + for (vector::iterator it=Curls.begin(); itdata == NULL) { + #ifdef LOG_DL + nlwarning("Remove waiting curl download (%s)", it->url.c_str()); + #endif + it = Curls.erase(it); + } else { + ++it; + } + } } // *************************************************************************** @@ -4544,7 +4879,7 @@ namespace NLGUI // *************************************************************************** - void CGroupHTML::addGroup (CInterfaceGroup *group, uint beginSpace) + void CGroupHTML::addHtmlGroup (CInterfaceGroup *group, uint beginSpace) { if (!group) return; @@ -4624,34 +4959,21 @@ namespace NLGUI result = url; string tmp; - // folder used for images cache - static const string cacheDir = "cache"; - - string::size_type protocolPos = toLower(result).find("://"); - - if (protocolPos != string::npos) + if (toLower(result).find("file:") == 0 && result.size() > 5) { - // protocol present, it's an url so file must be searched in cache folder - // TODO: case of special characters & and ? - result = cacheDir + result.substr(protocolPos+2); - - // if the file is already cached, use it - if (CFile::fileExists(result)) tmp = result; + result = result.substr(5, result.size()-5); } - else + else if (result.find("://") != string::npos || result.find("//") == 0) { - // Url is a file ? - if (toLower(result).find("file:") == 0) - { - result = result.substr(5, result.size()-5); - } + // http://, https://, etc or protocol-less url "//domain.com/image.png" + return false; + } - tmp = CPath::lookup (CFile::getFilename(result), false, false, false); - if (tmp.empty()) - { - // try to find in local directory - tmp = CPath::lookup (result, false, false, true); - } + tmp = CPath::lookup (CFile::getFilename(result), false, false, false); + if (tmp.empty()) + { + // try to find in local directory + tmp = CPath::lookup (result, false, false, true); } if (!tmp.empty()) @@ -4961,7 +5283,7 @@ namespace NLGUI } #if LOG_DL - nlwarning("(%s) browse local file '%s'", filename.c_str()); + nlwarning("browse local file '%s'", filename.c_str()); #endif _TrustedDomain = true; @@ -4997,7 +5319,7 @@ namespace NLGUI } // *************************************************************************** - void CGroupHTML::doBrowseRemoteUrl(const std::string &url, const std::string &referer, bool doPost, const SFormFields &formfields) + void CGroupHTML::doBrowseRemoteUrl(std::string url, const std::string &referer, bool doPost, const SFormFields &formfields) { // Stop previous request and remove content stopBrowse (); @@ -5011,6 +5333,8 @@ namespace NLGUI else setTitle (_TitlePrefix + " - " + CI18N::get("uiPleaseWait")); + url = upgradeInsecureUrl(url); + #if LOG_DL nlwarning("(%s) browse url (trusted=%s) '%s', referer='%s', post='%s', nb form values %d", _Id.c_str(), (_TrustedDomain ? "true" :"false"), url.c_str(), referer.c_str(), (doPost ? "true" : "false"), formfields.Values.size()); @@ -5030,6 +5354,14 @@ namespace NLGUI return; } +#if defined(NL_OS_WINDOWS) + // https:// + if (toLower(url.substr(0, 8)) == "https://") + { + curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &CCurlCertificates::sslCtxFunction); + } +#endif + // do not follow redirects, we have own handler curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0); // after redirect @@ -5095,11 +5427,7 @@ namespace NLGUI std::vector headers; headers.push_back("Accept-Language: "+options.languageCode); headers.push_back("Accept-Charset: utf-8"); - for(uint i=0; i< headers.size(); ++i) - { - _CurlWWW->HeadersSent = curl_slist_append(_CurlWWW->HeadersSent, headers[i].c_str()); - } - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, _CurlWWW->HeadersSent); + _CurlWWW->sendHeaders(headers); // catch headers for redirect curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curlHeaderCallback); @@ -5136,7 +5464,7 @@ namespace NLGUI #endif // create markup for image downloads - if (type.find("image/") == 0 && content.size() > 0) + if (type.find("image/") == 0 && !content.empty()) { try { @@ -5198,6 +5526,11 @@ namespace NLGUI void CGroupHTML::doBrowseAnchor(const std::string &anchor) { + if (_Anchors.count(anchor) == 0) + { + return; + } + CInterfaceElement *pIE = _Anchors.find(anchor)->second; if (pIE) { @@ -5500,6 +5833,19 @@ namespace NLGUI return 0; } + // *************************************************************************** + int CGroupHTML::luaRenderHtml(CLuaState &ls) + { + const char *funcName = "renderHtml"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + std::string html = ls.toString(1); + + renderHtmlString(html); + + return 0; + } + // *************************************************************************** int CGroupHTML::luaInsertText(CLuaState &ls) { @@ -5558,16 +5904,20 @@ namespace NLGUI newParagraph(0); paragraphChange(); } + + CStyleParams style; + style.GlobalColor = ls.toBoolean(2); + string url = getLink(); if (!url.empty()) { string params = "name=" + getId() + "|url=" + getLink (); addButton(CCtrlButton::PushButton, ls.toString(1), ls.toString(1), ls.toString(1), - "", ls.toBoolean(2), "browse", params.c_str(), ""); + "", "browse", params.c_str(), "", style); } else { - addImage(ls.toString(1), ls.toBoolean(2)); + addImage(ls.toString(1), false, style); } @@ -5811,7 +6161,7 @@ namespace NLGUI if (it->second == "monospace") style.FontFamily = "monospace"; else - style.FontFamily = ""; + style.FontFamily.clear(); } else if (it->first == "font-weight") @@ -5876,6 +6226,16 @@ namespace NLGUI else if (it->first == "max-height") getPercentage(style.MaxHeight, tmpf, it->second.c_str()); + else + if (it->first == "-ryzom-modulate-color") + { + bool b; + if (it->second == "inherit") + style.GlobalColor = getGlobalColor(); + else + if (fromString(it->second, b)) + style.GlobalColor = b; + } } if (inherit) { diff --git a/code/nel/src/gui/group_html_parser.cpp b/code/nel/src/gui/group_html_parser.cpp index 5f6873477..b2a61c4f9 100644 --- a/code/nel/src/gui/group_html_parser.cpp +++ b/code/nel/src/gui/group_html_parser.cpp @@ -28,6 +28,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { // *************************************************************************** diff --git a/code/nel/src/gui/group_list.cpp b/code/nel/src/gui/group_list.cpp index e75f8787e..216c8f682 100644 --- a/code/nel/src/gui/group_list.cpp +++ b/code/nel/src/gui/group_list.cpp @@ -30,6 +30,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CGroupList, std::string, "list"); namespace NLGUI @@ -363,7 +367,7 @@ namespace NLGUI uint32 i; if( fromString( value, i ) ) _TextId = i; - _HardText = ""; + _HardText.clear(); onTextChanged(); return; } @@ -736,13 +740,11 @@ namespace NLGUI CInterfaceGroup::updateCoords(); - sint32 nCurrentX = 0; // Current offset of an element - EAlign addElt = _AddElt; if ((addElt == Top) || (addElt == Bottom)) { // Calculate size - sint32 newH = 0, newW = 0; + sint32 newH = 0; bool bFirst = true; for (uint32 i = 0; i < _Elements.size(); ++i) @@ -752,10 +754,7 @@ namespace NLGUI if (!bFirst) newH += _Space; bFirst = false; - nCurrentX += _Elements[i].Element->getX(); - newW = max (newW, _Elements[i].Element->getW()+(sint32)abs(nCurrentX)); } - _W = max(newW, _MinW); _H = max(newH, _MinH); if (_DynamicDisplaySize) { @@ -763,10 +762,13 @@ namespace NLGUI _MaxH = _H; } if (_H < _MaxH) setOfsY(0); + + // if width is not from parent, then ensure minimum size + if ((_SizeRef & 1) == 0) _W = max(_W, _MinW); } else { - sint32 newW = 0, newH = 0; + sint32 newW = 0; bool bFirst = true; for (uint32 i = 0; i < _Elements.size(); ++i) @@ -776,16 +778,17 @@ namespace NLGUI if (!bFirst) newW += _Space; bFirst = false; - newH = max (newH, _Elements[i].Element->getH()); } _W = max(newW, _MinW); - _H = max(newH, _MinH); if (_DynamicDisplaySize) { _MaxW = _W; _MaxH = _H; } if (_W < _MaxW) setOfsX(0); + + // if height is not from parent, then ensure minimum size + if ((_SizeRef & 2) == 0) _H = max(_H, _MinH); } CInterfaceElement::updateCoords(); @@ -1059,7 +1062,7 @@ namespace NLGUI { // update the list size sint32 newH = _H + child->getH(); - if (_Elements.size() > 0) + if (!_Elements.empty()) newH += _Space; _H = newH; @@ -1073,7 +1076,7 @@ namespace NLGUI { // Update the list coords sint32 newW = _W + child->getW(); - if (_Elements.size() > 0) + if (!_Elements.empty()) newW += _Space; _W = newW; @@ -1408,7 +1411,7 @@ namespace NLGUI void CGroupList::onTextChanged() { - if( _Elements.size() == 0 ) + if( _Elements.empty() ) return; CElementInfo &e = _Elements[ 0 ]; diff --git a/code/nel/src/gui/group_menu.cpp b/code/nel/src/gui/group_menu.cpp index 7ab5db84c..7d002cfd6 100644 --- a/code/nel/src/gui/group_menu.cpp +++ b/code/nel/src/gui/group_menu.cpp @@ -32,6 +32,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace { @@ -237,6 +240,7 @@ namespace NLGUI _GroupList->setY (4); _GroupList->setSpace (_GroupMenu->_Space); _GroupList->setSerializable( false ); + _GroupList->setResizeFromChildW(true); addGroup (_GroupList); } } @@ -266,7 +270,7 @@ namespace NLGUI else if (stricmp((char*)cur->name, "action") == 0) { - string strId, strAh, strParams, strCond, strTexture=""; + string strId, strAh, strParams, strCond, strTexture; ucstring ucstrName; if (id) strId = (const char*)id; @@ -381,6 +385,22 @@ namespace NLGUI return true; } + // ------------------------------------------------------------------------------------------------ + CViewBitmap *CGroupSubMenu::createIcon(CInterfaceElement *parentPos, const string &texture) + { + // Add an icon to the line + CViewBitmap *pVB = new CViewBitmap(CViewBase::TCtorParam()); + pVB->setSerializable( false ); + pVB->setParent (this); + pVB->setParentPos (parentPos); + pVB->setParentPosRef (Hotspot_ML); + pVB->setPosRef (Hotspot_MR); + pVB->setTexture(texture); + pVB->setModulateGlobalColor(false); + pVB->setX (-2); + addView (pVB); + return pVB; + } // ------------------------------------------------------------------------------------------------ CViewBitmap *CGroupSubMenu::createCheckBox(bool checked) @@ -1077,7 +1097,7 @@ namespace NLGUI for (uint32 i = 0; i < pCurGSM->_Lines.size(); ++i) if (sRest == pCurGSM->_Lines[i].Id) return pCurGSM->_Lines[i].ViewText; - sRest = ""; + sRest.clear(); } else // no a lot of token left { @@ -1226,13 +1246,22 @@ namespace NLGUI pV->setCheckBox(checkBox); } + CViewBitmap *icon = NULL; + if (!texture.empty()) + { + if (_GroupList->getNumChildren() == 1) + pV->setX(20); + icon = createIcon(pV, texture); + } + + tmp.ViewText = pV; tmp.Separator = NULL; tmp.AHName = ah; tmp.AHParams = params; tmp.Cond = cond; tmp.CheckBox = checkBox; - tmp.RightArrow = NULL; + tmp.RightArrow = icon; if (id.empty()) tmp.Id = NLMISC::toString (_Lines.size()); else @@ -1773,6 +1802,22 @@ namespace NLGUI return 0; } + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaAddIconLine(CLuaState &ls) + { + const char *funcName = "addIconLine"; + CLuaIHM::checkArgCount(ls, funcName, 5); + CLuaIHM::checkArgTypeUCString(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); + ucstring arg1; + nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); + addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5)); + return 0; + } + // ------------------------------------------------------------------------------------------------ int CGroupSubMenu::luaAddLineAtIndex(CLuaState &ls) { diff --git a/code/nel/src/gui/group_modal.cpp b/code/nel/src/gui/group_modal.cpp index fb4c6d129..95ca783eb 100644 --- a/code/nel/src/gui/group_modal.cpp +++ b/code/nel/src/gui/group_modal.cpp @@ -24,6 +24,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/group_paragraph.cpp b/code/nel/src/gui/group_paragraph.cpp index 9e065c878..b2635b52e 100644 --- a/code/nel/src/gui/group_paragraph.cpp +++ b/code/nel/src/gui/group_paragraph.cpp @@ -31,6 +31,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlLink, std::string, "button_link"); namespace NLGUI @@ -55,7 +59,6 @@ namespace NLGUI _TopSpace = 0; _Indent = 0; _FirstViewIndentView = false; - _BrowseGroup = NULL; _TextId = 0; } @@ -337,7 +340,7 @@ namespace NLGUI if( fromString( value, i ) ) { _TextId = i; - _HardText = ""; + _HardText.clear(); } onTextChanged(); return; @@ -864,11 +867,8 @@ namespace NLGUI ctrl->setParentPosRef (Hotspot_TL); ctrl->setPosRef (Hotspot_TL); ctrl->setActive(true); - if (_BrowseGroup) - { - ctrl->setActionOnLeftClick("browse"); - ctrl->setParamsOnLeftClick("name="+_BrowseGroup->getId()+"|url="+link.Link->Link); - } + ctrl->setActionOnLeftClick(link.Link->getActionOnLeftClick()); + ctrl->setParamsOnLeftClick(link.Link->getParamsOnLeftClick()); ctrl->setScale(true); addCtrl(ctrl); } @@ -1208,7 +1208,7 @@ namespace NLGUI { // update the list size sint32 newH = _H + child->getH(); - if (_Elements.size() > 0) + if (!_Elements.empty()) newH += _Space; _H = newH; @@ -1222,7 +1222,7 @@ namespace NLGUI { // Update the list coords sint32 newW = _W + child->getW(); - if (_Elements.size() > 0) + if (!_Elements.empty()) newW += _Space; _W = newW; @@ -1452,7 +1452,7 @@ namespace NLGUI void CGroupParagraph::onTextChanged() { - if( _Elements.size() == 0 ) + if( _Elements.empty() ) return; CElementInfo &e = _Elements[ 0 ]; diff --git a/code/nel/src/gui/group_scrolltext.cpp b/code/nel/src/gui/group_scrolltext.cpp index c82bd40bf..aff59e5c2 100644 --- a/code/nel/src/gui/group_scrolltext.cpp +++ b/code/nel/src/gui/group_scrolltext.cpp @@ -25,6 +25,10 @@ #include "nel/misc/i18n.h" #include "nel/gui/widget_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CGroupScrollText, std::string, "scroll_text"); namespace NLGUI diff --git a/code/nel/src/gui/group_submenu_base.cpp b/code/nel/src/gui/group_submenu_base.cpp index 1c98fe643..8b26a7d85 100644 --- a/code/nel/src/gui/group_submenu_base.cpp +++ b/code/nel/src/gui/group_submenu_base.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/group_submenu_base.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/group_tab.cpp b/code/nel/src/gui/group_tab.cpp index 69ccce046..d79efdad3 100644 --- a/code/nel/src/gui/group_tab.cpp +++ b/code/nel/src/gui/group_tab.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CGroupTab, std::string, "tab"); namespace NLGUI diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index a82ad5617..ef3eca57a 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -29,6 +29,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -336,7 +340,7 @@ namespace NLGUI } // ---------------------------------------------------------------------------- - bool CGroupCell::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex) + bool CGroupCell::parseCell(xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex) { CXMLAutoPtr ptr; ptr = (char*) xmlGetProp( cur, (xmlChar*)"id"); @@ -1205,6 +1209,13 @@ namespace NLGUI // ---------------------------------------------------------------------------- sint32 CGroupTable::getMaxUsedW() const { + // Return table width if its requested by user. + // Need to do this because width of long line of text in here is calculated + // differently than final cell width in updateCoords() + // This will break tables with too narrow width set by user. + if (ForceWidthMin > 0) + return ForceWidthMin; + uint i; uint column = 0; vector columns; @@ -1558,7 +1569,7 @@ namespace NLGUI if (strcmp((char*)currCol->name,"TD") == 0) { CGroupCell *cell = new CGroupCell(CViewBase::TCtorParam()); - if (cell->parse(currCol, this, column, row)) + if (cell->parseCell(currCol, this, column, row)) { cell->NewLine = newLine; newLine = false; diff --git a/code/nel/src/gui/group_tree.cpp b/code/nel/src/gui/group_tree.cpp index 1b80ee84b..e1fa8292a 100644 --- a/code/nel/src/gui/group_tree.cpp +++ b/code/nel/src/gui/group_tree.cpp @@ -33,6 +33,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -267,6 +271,14 @@ namespace NLGUI pNode->setFather(this); } + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::openAll() + { + Opened = true; + for (uint i = 0; i < Children.size(); ++i) + Children[i]->openAll(); + } + // ---------------------------------------------------------------------------- void CGroupTree::SNode::closeAll() { @@ -765,7 +777,7 @@ namespace NLGUI rVR.getTextureSizeFromId(id, _XExtend, dummy); else // if not found, reset, to avoid errors - _ArboXExtend= ""; + _ArboXExtend.clear(); } // ---------------------------------------------------------------------------- @@ -1078,7 +1090,9 @@ namespace NLGUI } } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) + bool toggleOne = (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown); + bool toggleAll = (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown); + if (toggleOne || toggleAll) { // line selection if (bText) @@ -1114,6 +1128,13 @@ namespace NLGUI { // open/close the node changedNode->Opened = !changedNode->Opened; + if (toggleAll) + { + if (changedNode->Opened) + changedNode->openAll(); + else + changedNode->closeAll(); + } } // else must close all necessary nodes. else diff --git a/code/nel/src/gui/group_wheel.cpp b/code/nel/src/gui/group_wheel.cpp index e242a98e7..a8d57c089 100644 --- a/code/nel/src/gui/group_wheel.cpp +++ b/code/nel/src/gui/group_wheel.cpp @@ -18,6 +18,9 @@ #include "stdpch.h" #include "nel/gui/group_wheel.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif NLMISC_REGISTER_OBJECT(CViewBase, CInterfaceGroupWheel, std::string, "group_wheel"); diff --git a/code/nel/src/gui/http_cache.cpp b/code/nel/src/gui/http_cache.cpp new file mode 100644 index 000000000..a032247fc --- /dev/null +++ b/code/nel/src/gui/http_cache.cpp @@ -0,0 +1,212 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdpch.h" +#include "nel/gui/http_cache.h" + +using namespace std; +using namespace NLMISC; + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + +#if defined(GCC_VERSION) && !defined(CLANG_VERSION) && defined(NL_ISO_CPP0X_AVAILABLE) && (GCC_VERSION <= 40804) +// hack to fix std::map::erase wrong return type (void instead of iterator in C++11) in GCC 4.8.4 +#undef NL_ISO_CPP0X_AVAILABLE +#endif + +namespace NLGUI +{ + CHttpCache* CHttpCache::instance = NULL; + + CHttpCache* CHttpCache::getInstance() + { + if (!instance) + { + instance = new CHttpCache(); + } + + return instance; + } + + void CHttpCache::release() + { + delete instance; + instance = NULL; + } + + CHttpCache::CHttpCache() + : _Initialized(false) + , _MaxObjects(100) + { }; + + CHttpCache::~CHttpCache() + { + flushCache(); + } + + void CHttpCache::setCacheIndex(const std::string& fname) + { + _IndexFilename = fname; + _Initialized = false; + } + + CHttpCacheObject CHttpCache::lookup(const std::string& fname) + { + if (!_Initialized) + init(); + + if (_List.count(fname) > 0) + return _List[fname]; + + return CHttpCacheObject(); + } + + void CHttpCache::store(const std::string& fname, const CHttpCacheObject& data) + { + if (!_Initialized) + init(); + + _List[fname] = data; + } + + void CHttpCache::init() + { + if (_Initialized) + return; + + _Initialized = true; + + if (_IndexFilename.empty() || !CFile::fileExists(_IndexFilename)) + return; + + CIFile in; + if (!in.open(_IndexFilename)) { + nlwarning("Unable to open %s for reading", _IndexFilename.c_str()); + return; + } + + serial(in); + } + + void CHttpCacheObject::serial(NLMISC::IStream& f) + { + f.serialVersion(1); + f.serial(Expires); + f.serial(LastModified); + f.serial(Etag); + } + + void CHttpCache::serial(NLMISC::IStream& f) + { + // saved state is ignored when version checks fail + try { + f.serialVersion(1); + + // CacheIdx + f.serialCheck(NELID("hcaC")); + f.serialCheck(NELID("xdIe")); + + if (f.isReading()) + { + uint32 numFiles; + f.serial(numFiles); + + _List.clear(); + for (uint k = 0; k < numFiles; ++k) + { + std::string fname; + f.serial(fname); + + CHttpCacheObject obj; + obj.serial(f); + + _List[fname] = obj; + } + } + else + { + uint32 numFiles = _List.size(); + f.serial(numFiles); + + for (THttpCacheMap::iterator it = _List.begin(); it != _List.end(); ++it) + { + std::string fname(it->first); + f.serial(fname); + + (*it).second.serial(f); + } + } + } catch (...) { + _List.clear(); + nlwarning("Invalid cache index format (%s)", _IndexFilename.c_str()); + return; + } + } + + void CHttpCache::pruneCache() + { + if (_List.size() < _MaxObjects) + return; + + size_t mustDrop = _List.size() - _MaxObjects; + + time_t currentTime; + time(¤tTime); + + // if we over object limit, then start removing expired objects + // this does not guarantee that max limit is reached + for (THttpCacheMap::iterator it = _List.begin(); it != _List.end();) + { + if (it->second.Expires <= currentTime) + { +#ifdef NL_ISO_CPP0X_AVAILABLE + it = _List.erase(it); +#else + THttpCacheMap::iterator itToErase = it++; + _List.erase(itToErase); +#endif + + --mustDrop; + if (mustDrop == 0) + break; + } + else + { + ++it; + } + } + } + + void CHttpCache::flushCache() + { + if (_IndexFilename.empty()) + return; + + pruneCache(); + + COFile out; + if (!out.open(_IndexFilename)) + { + nlwarning("Unable to open %s for writing", _IndexFilename.c_str()); + return; + } + + serial(out); + out.close(); + } +} diff --git a/code/nel/src/gui/http_hsts.cpp b/code/nel/src/gui/http_hsts.cpp new file mode 100644 index 000000000..c69062538 --- /dev/null +++ b/code/nel/src/gui/http_hsts.cpp @@ -0,0 +1,245 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdpch.h" +#include "nel/gui/http_hsts.h" + +using namespace std; +using namespace NLMISC; + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + +namespace NLGUI { + CStrictTransportSecurity* CStrictTransportSecurity::instance = NULL; + CStrictTransportSecurity* CStrictTransportSecurity::getInstance() + { + if (!instance) + { + instance= new CStrictTransportSecurity(); + } + return instance; + } + + void CStrictTransportSecurity::release() + { + delete instance; + instance = NULL; + } + + CStrictTransportSecurity::~CStrictTransportSecurity() + { + save(); + } + + // ************************************************************************ + bool CStrictTransportSecurity::isSecureHost(const std::string &domain) const + { + SHSTSObject hsts; + if (get(domain, hsts)) + { + time_t currentTime; + time(¤tTime); + + return (hsts.Expires > currentTime); + } + + return false; + } + + // ************************************************************************ + void CStrictTransportSecurity::erase(const std::string &domain) + { + if (_Domains.count(domain) > 0) + { + _Domains.erase(domain); + } + } + + void CStrictTransportSecurity::set(const std::string &domain, uint64 expires, bool includeSubDomains) + { + if (expires == 0) + { + erase(domain); + return; + } + + _Domains[domain].Expires = expires; + _Domains[domain].IncludeSubDomains = includeSubDomains; + } + + bool CStrictTransportSecurity::get(const std::string &domain, SHSTSObject &hsts) const + { + if (domain.empty() || _Domains.empty()) + return false; + + if (_Domains.count(domain) > 0) + { + hsts = _Domains.at(domain); + return true; + } + + size_t firstOf = domain.find_first_of("."); + size_t lastOf = domain.find_last_of("."); + while(firstOf != lastOf) + { + std::string tmp; + tmp = domain.substr(firstOf+1); + if (_Domains.count(tmp)) + { + if (_Domains.at(tmp).IncludeSubDomains) + { + hsts = _Domains.at(tmp); + return true; + } + + return false; + } + + firstOf = domain.find_first_of(".", firstOf + 1); + } + + return false; + } + + void CStrictTransportSecurity::init(const std::string &fname) + { + _Domains.clear(); + _Filename = fname; + + if (_Filename.empty() || !CFile::fileExists(_Filename)) + { + return; + } + + CIFile in; + if (!in.open(_Filename)) + { + nlwarning("Unable to open %s for reading", _Filename.c_str()); + return; + } + + serial(in); + } + + void CStrictTransportSecurity::save() + { + if (_Filename.empty()) + return; + + if (_Domains.empty()) + { + CFile::deleteFile(_Filename); + return; + } + + COFile out; + if (!out.open(_Filename)) + { + nlwarning("Unable to open %s for writing", _Filename.c_str()); + return; + } + + serial(out); + out.close(); + } + + void CStrictTransportSecurity::serial(NLMISC::IStream& f) + { + try + { + f.serialVersion(1); + // HSTS + f.serialCheck(NELID("STSH")); + + if (f.isReading()) + { + uint32 nbItems; + f.serial(nbItems); + for(uint32 k = 0; k < nbItems; ++k) + { + std::string domain; + f.serial(domain); + f.serial(_Domains[domain].Expires); + f.serial(_Domains[domain].IncludeSubDomains); + } + } + else + { + uint32 nbItems = _Domains.size(); + f.serial(nbItems); + for (THSTSObject::iterator it = _Domains.begin(); it != _Domains.end(); ++it) + { + std::string domain(it->first); + f.serial(domain); + f.serial(_Domains[domain].Expires); + f.serial(_Domains[domain].IncludeSubDomains); + } + } + } + catch (...) + { + _Domains.clear(); + nlwarning("Invalid HTST file format (%s)", _Filename.c_str()); + } + } + + // *************************************************************************** + void CStrictTransportSecurity::setFromHeader(const std::string &domain, const std::string &header) + { + // max-age=; includeSubdomains; preload; + std::vector elements; + NLMISC::splitString(toLower(header), ";", elements); + if (elements.empty()) return; + + time_t currentTime; + time(¤tTime); + + uint64 expire = 0; + bool includeSubDomains = false; + + for(uint i=0; i< elements.size(); ++i) + { + std::string str(trim(elements[i])); + if (str.substr(0, 8) == "max-age=") + { + uint64 ttl; + if (fromString(str.substr(8), ttl)) + { + if (ttl > 0) + { + expire = currentTime + ttl; + } + } + } + else if (str == "includesubdomains") + { + includeSubDomains = true; + } + } + + if (expire == 0) + { + erase(domain); + } + else + { + set(domain, expire, includeSubDomains); + } + } + +} diff --git a/code/nel/src/gui/input_handler.cpp b/code/nel/src/gui/input_handler.cpp index 920636079..9e4864caa 100644 --- a/code/nel/src/gui/input_handler.cpp +++ b/code/nel/src/gui/input_handler.cpp @@ -17,6 +17,10 @@ #include "stdpch.h" #include "nel/gui/input_handler.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { CInputHandler::CInputHandler() diff --git a/code/nel/src/gui/interface_anim.cpp b/code/nel/src/gui/interface_anim.cpp index 4b230bb25..2fb190e85 100644 --- a/code/nel/src/gui/interface_anim.cpp +++ b/code/nel/src/gui/interface_anim.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NL3D; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 66eee038e..2e13d80e6 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -31,6 +31,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { bool CInterfaceElement::editorMode = false; @@ -505,7 +509,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ void CInterfaceElement::updateCoords() { - _XReal = _X; + _XReal = _X + _MarginLeft; _YReal = _Y; _WReal = getW(); _HReal = getH(); @@ -522,7 +526,7 @@ namespace NLGUI if (el == NULL) return; - _XReal += el->_XReal; + _XReal += el->_XReal - el->_MarginLeft; _YReal += el->_YReal; THotSpot hsParent = _ParentPosRef; diff --git a/code/nel/src/gui/interface_expr.cpp b/code/nel/src/gui/interface_expr.cpp index cbf3cace3..77d48906e 100644 --- a/code/nel/src/gui/interface_expr.cpp +++ b/code/nel/src/gui/interface_expr.cpp @@ -25,6 +25,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -745,7 +749,7 @@ namespace NLGUI std::string str; for (;;) { - if (expr == '\0') + if (*expr == '\0') { nlwarning("CInterfaceExprValue::evalString : end of buffer encountered in a string"); return NULL; diff --git a/code/nel/src/gui/interface_expr_node.cpp b/code/nel/src/gui/interface_expr_node.cpp index 895cb169e..2a32c09db 100644 --- a/code/nel/src/gui/interface_expr_node.cpp +++ b/code/nel/src/gui/interface_expr_node.cpp @@ -24,6 +24,10 @@ using NLMISC::ICDBNode; using NLMISC::CCDBNodeBranch; using NLMISC::CCDBNodeLeaf; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/interface_expr_user_fct.cpp b/code/nel/src/gui/interface_expr_user_fct.cpp index b60f0b01c..a2467809d 100644 --- a/code/nel/src/gui/interface_expr_user_fct.cpp +++ b/code/nel/src/gui/interface_expr_user_fct.cpp @@ -25,6 +25,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -206,7 +210,7 @@ namespace NLGUI static DECLARE_INTERFACE_USER_FCT(userFctIdentity) { - if (args.size() > 0) + if (!args.empty()) { result = args[0]; return true; @@ -350,9 +354,9 @@ namespace NLGUI static DECLARE_INTERFACE_USER_FCT(userFctStr) { - if (args.size() > 0) + if (!args.empty()) { - ucstring res(""); + ucstring res; for (uint32 i = 0; i < args.size(); ++i) { args[i].toString(); diff --git a/code/nel/src/gui/interface_factory.cpp b/code/nel/src/gui/interface_factory.cpp index ec914baa6..7f0fe76ee 100644 --- a/code/nel/src/gui/interface_factory.cpp +++ b/code/nel/src/gui/interface_factory.cpp @@ -18,6 +18,10 @@ #include "nel/gui/view_base.h" #include "nel/misc/factory.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { CViewBase* CInterfaceFactory::createClass( const std::string &name ) diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index 5f4366981..dce9fc266 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -32,6 +32,10 @@ using namespace std; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + #define IG_UNIQUE_ID(this) ((void*)&((this)->_GroupSizeRef)) // NB nico : use some pointer *inside* CInterfaceGroup as a unique id for lua registry (any field but // the first), instead of using 'this'. 'this' is already used by // CLuaIHM::pushReflectableOnStack as unique id to CInterfaceElement's ref pointers @@ -999,7 +1003,7 @@ namespace NLGUI { string idTmp = id, lidTmp = lid; // bool isFound = true; - while (idTmp.size() > 0) + while (!idTmp.empty()) { string tokid, toklid; @@ -1031,12 +1035,12 @@ namespace NLGUI if (posid > 0) idTmp = idTmp.substr (0, posid); else - idTmp = ""; + idTmp.clear(); if (poslid > 0) lidTmp = lidTmp.substr (0, poslid); else - lidTmp = ""; + lidTmp.clear(); } return true; } @@ -1453,7 +1457,7 @@ namespace NLGUI } CViewBase::updateCoords(); - _XReal += _OffsetX; + _XReal += _OffsetX + _MarginLeft; _YReal += _OffsetY; //update all children elements @@ -1464,7 +1468,7 @@ namespace NLGUI pIE->updateCoords(); } - _XReal -= _OffsetX; + _XReal -= _OffsetX - _MarginLeft; _YReal -= _OffsetY; } @@ -1778,7 +1782,7 @@ namespace NLGUI { // bool bUnder = pChild->getViewsUnder (x, y, clipX, clipY, clipW, clipH, vVB); - // if (bUnder && (vICL.size() > 0)) + // if (bUnder && !vICL.empty()) // return true; } } @@ -1833,7 +1837,7 @@ namespace NLGUI { // bool bUnder = pChild->getCtrlsUnder (x, y, clipX, clipY, clipW, clipH, vICL); - // if (bUnder && (vICL.size() > 0)) + // if (bUnder && !vICL.empty()) // return true; } } @@ -1889,7 +1893,7 @@ namespace NLGUI { // bool bUnder = pChild->getGroupsUnder (x, y, clipX, clipY, clipW, clipH, vIGL); - // if (bUnder && (vICL.size() > 0)) + // if (bUnder && !vICL.empty()) // return true; } } @@ -1954,9 +1958,9 @@ namespace NLGUI newSciH = newSciH - ((newSciY+newSciH)-(oldSciY+oldSciH)); } - newSciXDest = newSciX; + newSciXDest = newSciX - _MarginLeft; newSciYDest = newSciY; - newSciWDest = newSciW; + newSciWDest = newSciW + _MarginLeft; newSciHDest = newSciH; } diff --git a/code/nel/src/gui/interface_link.cpp b/code/nel/src/gui/interface_link.cpp index 282199ee7..4266797f4 100644 --- a/code/nel/src/gui/interface_link.cpp +++ b/code/nel/src/gui/interface_link.cpp @@ -33,6 +33,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -664,7 +668,7 @@ namespace NLGUI { std::vector vTargets; splitLinkTargets(Target, pIG, vTargets); - if ((vTargets.size() > 0) && (vTargets[0].Elem)) + if (!vTargets.empty() && (vTargets[0].Elem)) { vTargets[0].affect(val); } diff --git a/code/nel/src/gui/interface_options.cpp b/code/nel/src/gui/interface_options.cpp index 1daef83cb..9a71e3709 100644 --- a/code/nel/src/gui/interface_options.cpp +++ b/code/nel/src/gui/interface_options.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 068d827bf..63eb165e3 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -42,6 +42,11 @@ #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger #endif + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + const uint32 UI_CACHE_SERIAL_CHECK = NELID("IUG_"); using namespace NLMISC; @@ -665,10 +670,10 @@ namespace NLGUI if (strchr(ptr, '#') != NULL) { string LastProp = ptr.str(); - string NewProp =""; + string NewProp; string RepProp; - while (LastProp.size() > 0) + while (!LastProp.empty()) { string::size_type diesPos = LastProp.find("#"); if (diesPos != string::npos) @@ -709,7 +714,7 @@ namespace NLGUI else { NewProp += LastProp; - LastProp = ""; + LastProp.clear(); } } xmlSetProp(node,props->name, (const xmlChar*)NewProp.c_str()); diff --git a/code/nel/src/gui/interface_property.cpp b/code/nel/src/gui/interface_property.cpp index 694bd6c36..5b11c9b74 100644 --- a/code/nel/src/gui/interface_property.cpp +++ b/code/nel/src/gui/interface_property.cpp @@ -20,13 +20,17 @@ #include "nel/gui/interface_property.h" #include "nel/gui/interface_common.h" #include "nel/gui/db_manager.h" +#include "nel/misc/common.h" using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { - bool CInterfaceProperty::link( CCDBNodeLeaf *dbNode ) { _VolatileValue = dbNode; @@ -66,6 +70,20 @@ namespace NLGUI } + void CInterfaceProperty::setDouble(double value) + { + C64BitsParts parts; + parts.d[0] = value; + setSInt64(parts.i64[0]); + } + + double CInterfaceProperty::getDouble() const + { + C64BitsParts parts; + parts.i64[0] = getSInt64(); + return parts.d[0]; + } + // ***************** // sint64 operations // ***************** @@ -104,10 +122,9 @@ namespace NLGUI if ( isdigit(*ptr) || *ptr=='-') { _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - double buf; - fromString(ptr, buf); - sint64 i = *(sint64*)&buf; - _VolatileValue->setValue64( i ); + C64BitsParts buf; + fromString(ptr, buf.d[0]); + _VolatileValue->setValue64(buf.i64[0]); } else { diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index 53cc9e403..c8b41a38f 100644 --- a/code/nel/src/gui/libwww.cpp +++ b/code/nel/src/gui/libwww.cpp @@ -21,6 +21,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -146,6 +150,8 @@ namespace NLGUI HTML_ATTR(IMG,USEMAP), HTML_ATTR(IMG,VSPACE), HTML_ATTR(IMG,WIDTH), + // not sorted to keep enum values + HTML_ATTR(IMG,DATA-OVER-SRC), { 0 } }; diff --git a/code/nel/src/gui/libwww_types.cpp b/code/nel/src/gui/libwww_types.cpp index 31e05f456..9731e9aca 100644 --- a/code/nel/src/gui/libwww_types.cpp +++ b/code/nel/src/gui/libwww_types.cpp @@ -29,8 +29,13 @@ ****************************************************************************/ +#include "stdpch.h" #include "nel/gui/libwww_types.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/link_hack.cpp b/code/nel/src/gui/link_hack.cpp index 3ecc6fb0a..9ae97910d 100644 --- a/code/nel/src/gui/link_hack.cpp +++ b/code/nel/src/gui/link_hack.cpp @@ -22,6 +22,10 @@ #include "nel/gui/view_pointer.h" #include "nel/gui/group_editbox_decor.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { void ifexprufct_forcelink(); diff --git a/code/nel/src/gui/lua_helper.cpp b/code/nel/src/gui/lua_helper.cpp index 0e2b9ba71..4e776e0b9 100644 --- a/code/nel/src/gui/lua_helper.cpp +++ b/code/nel/src/gui/lua_helper.cpp @@ -49,6 +49,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index d55bda42d..0b4a1d0dc 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -92,6 +92,10 @@ Compilation is VERY SLOW using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // declare ostream << operator for ucstring -> registration of ucstring iin luabind will build a 'tostring' function from it std::ostream &operator<<(std::ostream &str, const ucstring &value) { @@ -107,11 +111,11 @@ namespace NLGUI { return NLMISC::CPath::lookup(fileName, false); } - static void shellExecute(const char *operation, const char *fileName, const char *parameters) + static void shellExecute(const std::string &operation, const std::string &fileName, const std::string ¶meters) { #if !FINAL_VERSION #ifdef NL_OS_WINDOWS - ShellExecute(NULL, operation, fileName, parameters, NULL, SW_SHOWDEFAULT); + ShellExecuteW(NULL, utf8ToWide(operation), utf8ToWide(fileName), utf8ToWide(parameters), NULL, SW_SHOWDEFAULT); #endif #endif } @@ -1516,7 +1520,7 @@ namespace NLGUI CSString s = str; // Create table recursively (ex: 'game.TPVPClan' will check/create the table 'game' and 'game.TPVPClan') p = s.splitTo('.', true); - while (p.size() > 0) + while (!p.empty()) { if (path.empty() ) path = p; @@ -1701,8 +1705,20 @@ namespace NLGUI void *ptr= ls.newUserData(sizeof(CReflectableLuaRef)); nlassert(ptr); //ls.dumpStack(); - // initialize it, and copy the given element + +// disable memory leaks detection for placement new +#ifdef new + #undef new +#endif + + // initialize it, and copy the given element new (ptr) CReflectableLuaRef(pRPT); + +// reenable memory leaks detection for placement new +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + // Assign to this user data the __ui_metatable //ls.dumpStack(); ls.push(IHM_LUA_METATABLE); // userdata "__ui_metatable" @@ -1801,9 +1817,7 @@ namespace NLGUI ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace) { //H_AUTO(Lua_CLuaIHM_findReplaceAll) - ucstring ret= str; - while(strFindReplace(ret, search, replace)); - return ret; + return strFindReplaceAll(str, search, replace); } // *************************************************************************** diff --git a/code/nel/src/gui/lua_manager.cpp b/code/nel/src/gui/lua_manager.cpp index 2b354b0e4..d3f5dd81e 100644 --- a/code/nel/src/gui/lua_manager.cpp +++ b/code/nel/src/gui/lua_manager.cpp @@ -19,6 +19,10 @@ #include "nel/gui/lua_manager.h" #include "nel/gui/lua_helper.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/lua_object.cpp b/code/nel/src/gui/lua_object.cpp index dc7abff52..c957c3f2c 100644 --- a/code/nel/src/gui/lua_object.cpp +++ b/code/nel/src/gui/lua_object.cpp @@ -20,6 +20,10 @@ #include "nel/gui/lua_ihm.h" #include "nel/gui/lua_helper.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -422,7 +426,7 @@ namespace NLGUI { nlassert(key); nlassert(isValid()); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%d" NL_I64 "' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%" NL_I64 "d' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); CLuaStackChecker lsc(_LuaState); push(); _LuaState->push(key); diff --git a/code/nel/src/gui/parser.cpp b/code/nel/src/gui/parser.cpp index eae7d3667..0d521b726 100644 --- a/code/nel/src/gui/parser.cpp +++ b/code/nel/src/gui/parser.cpp @@ -21,6 +21,10 @@ #include "nel/gui/interface_group.h" #include "nel/gui/interface_parser.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { IParser::IParser() diff --git a/code/nel/src/gui/proc.cpp b/code/nel/src/gui/proc.cpp index df9d6b8e9..2974a861e 100644 --- a/code/nel/src/gui/proc.cpp +++ b/code/nel/src/gui/proc.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/reflect.cpp b/code/nel/src/gui/reflect.cpp index 961c855e6..7ef321b6e 100644 --- a/code/nel/src/gui/reflect.cpp +++ b/code/nel/src/gui/reflect.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/reflect.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { // Yoyo: Act like a singleton, else registerClass may crash. diff --git a/code/nel/src/gui/reflect_register.cpp b/code/nel/src/gui/reflect_register.cpp index f7f47b1f9..86abc0cd5 100644 --- a/code/nel/src/gui/reflect_register.cpp +++ b/code/nel/src/gui/reflect_register.cpp @@ -49,6 +49,10 @@ #include "nel/gui/group_html.h" #include "nel/gui/group_header.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { void CReflectableRegister::registerClasses() diff --git a/code/nel/src/gui/root_group.cpp b/code/nel/src/gui/root_group.cpp index bffdd5579..756fb1096 100644 --- a/code/nel/src/gui/root_group.cpp +++ b/code/nel/src/gui/root_group.cpp @@ -14,10 +14,14 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - +#include "stdpch.h" #include "nel/gui/root_group.h" #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/stdpch.h b/code/nel/src/gui/stdpch.h index 51f1b1657..a4ba0ecac 100644 --- a/code/nel/src/gui/stdpch.h +++ b/code/nel/src/gui/stdpch.h @@ -17,8 +17,16 @@ #ifndef NELGUI_H #define NELGUI_H +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif + #include #include +#include #include "nel/misc/types_nl.h" #include "nel/misc/algo.h" diff --git a/code/nel/src/gui/string_case.cpp b/code/nel/src/gui/string_case.cpp index b678d35c9..06936b393 100644 --- a/code/nel/src/gui/string_case.cpp +++ b/code/nel/src/gui/string_case.cpp @@ -17,6 +17,10 @@ #include "stdpch.h" #include "nel/gui/string_case.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { inline bool isSeparator (ucchar c) diff --git a/code/nel/src/gui/url_parser.cpp b/code/nel/src/gui/url_parser.cpp index 5db7f6d72..da222f807 100644 --- a/code/nel/src/gui/url_parser.cpp +++ b/code/nel/src/gui/url_parser.cpp @@ -14,11 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "stdpch.h" #include "nel/misc/common.h" #include "nel/gui/url_parser.h" using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLGUI { @@ -224,15 +228,21 @@ namespace NLGUI // path already has leading slash if (!path.empty()) + { result += path; + } if (!query.empty()) - if (query.find_first_of("?") != 0) - result += "?"; + { + if (query.find_first_of("?") != 0) result += "?"; + result += query; + } if (!hash.empty()) + { result += "#" + hash; + } return result; } diff --git a/code/nel/src/gui/view_base.cpp b/code/nel/src/gui/view_base.cpp index 2b09061a9..6b0201858 100644 --- a/code/nel/src/gui/view_base.cpp +++ b/code/nel/src/gui/view_base.cpp @@ -20,6 +20,10 @@ #include "nel/gui/interface_group.h" #include "nel/gui/widget_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/view_bitmap.cpp b/code/nel/src/gui/view_bitmap.cpp index 21c0c2cd4..b479cb889 100644 --- a/code/nel/src/gui/view_bitmap.cpp +++ b/code/nel/src/gui/view_bitmap.cpp @@ -26,6 +26,9 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif NLMISC_REGISTER_OBJECT(CViewBase, CViewBitmap, std::string, "bitmap"); REGISTER_UI_CLASS(CViewBitmap) @@ -508,6 +511,9 @@ namespace NLGUI // *************************************************************************** sint32 CViewBitmap::getMaxUsedW() const { + if (_Scale) + return _WReal; + sint32 txw, txh; CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.getTextureSizeFromId (_TextureId, txw, txh); diff --git a/code/nel/src/gui/view_bitmap_combo.cpp b/code/nel/src/gui/view_bitmap_combo.cpp index 3fc54c89a..8fbc7609c 100644 --- a/code/nel/src/gui/view_bitmap_combo.cpp +++ b/code/nel/src/gui/view_bitmap_combo.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -411,7 +415,7 @@ namespace NLGUI } } - if (_TexsId.size() == 0) + if (_TexsId.empty()) { for (i = 0; i < _Texs.size(); ++i) _TexsId.push_back(rVR.getTextureIdFromName(_Texs[i])); diff --git a/code/nel/src/gui/view_link.cpp b/code/nel/src/gui/view_link.cpp index 1db08f583..7de4e3a01 100644 --- a/code/nel/src/gui/view_link.cpp +++ b/code/nel/src/gui/view_link.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/view_pointer.cpp b/code/nel/src/gui/view_pointer.cpp index da8d730fc..aa5dff6d2 100644 --- a/code/nel/src/gui/view_pointer.cpp +++ b/code/nel/src/gui/view_pointer.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CViewPointer, std::string, "generic_pointer"); namespace NLGUI diff --git a/code/nel/src/gui/view_pointer_base.cpp b/code/nel/src/gui/view_pointer_base.cpp index e29af7858..9589afd9c 100644 --- a/code/nel/src/gui/view_pointer_base.cpp +++ b/code/nel/src/gui/view_pointer_base.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/view_pointer_base.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -76,16 +80,39 @@ namespace NLGUI { _PointerDown = pd; - if (_PointerDown == true) + if (_PointerDown) { _PointerDownX = _PointerX; _PointerDownY = _PointerY; } - - if (_PointerDown == false) + else _PointerDrag = false; } + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::setPointerMiddleDown (bool pd) + { + _PointerMiddleDown = pd; + + if (_PointerMiddleDown) + { + _PointerMiddleDownX = _PointerX; + _PointerMiddleDownY = _PointerY; + } + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::setPointerRightDown (bool pd) + { + _PointerRightDown = pd; + + if (_PointerRightDown) + { + _PointerRightDownX = _PointerX; + _PointerRightDownY = _PointerY; + } + } + // -------------------------------------------------------------------------------------------------------------------- void CViewPointerBase::setPointerDownString (const std::string &s) { @@ -116,16 +143,30 @@ namespace NLGUI } // -------------------------------------------------------------------------------------------------------------------- - void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y) + bool CViewPointerBase::getPointerDown (sint32 &x, sint32 &y) { x = _PointerDownX; y = _PointerDownY; + + return _PointerDown; } // -------------------------------------------------------------------------------------------------------------------- - bool CViewPointerBase::getPointerDown () + bool CViewPointerBase::getPointerMiddleDown (sint32 &x, sint32 &y) { - return _PointerDown; + x = _PointerMiddleDownX; + y = _PointerMiddleDownY; + + return _PointerMiddleDown; + } + + // -------------------------------------------------------------------------------------------------------------------- + bool CViewPointerBase::getPointerRightDown (sint32 &x, sint32 &y) + { + x = _PointerRightDownX; + y = _PointerRightDownY; + + return _PointerRightDown; } // -------------------------------------------------------------------------------------------------------------------- diff --git a/code/nel/src/gui/view_polygon.cpp b/code/nel/src/gui/view_polygon.cpp index baacf94a0..f3fd8efa2 100644 --- a/code/nel/src/gui/view_polygon.cpp +++ b/code/nel/src/gui/view_polygon.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/view_quad.cpp b/code/nel/src/gui/view_quad.cpp index 426a19f08..2724fe3b3 100644 --- a/code/nel/src/gui/view_quad.cpp +++ b/code/nel/src/gui/view_quad.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/view_renderer.cpp b/code/nel/src/gui/view_renderer.cpp index 5c7403cfc..66da2800b 100644 --- a/code/nel/src/gui/view_renderer.cpp +++ b/code/nel/src/gui/view_renderer.cpp @@ -26,6 +26,10 @@ using namespace NLMISC; using namespace std; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -287,7 +291,7 @@ namespace NLGUI // *************************************************************************** NL3D::UTextContext* CViewRenderer::getTextContext(const std::string &name) { - if (name.size() > 0 && fonts.count(name) > 0) + if (!name.empty() && fonts.count(name) > 0) return fonts[name]; return textcontext; @@ -303,7 +307,7 @@ namespace NLGUI driver->deleteTextContext(fonts[name]); std::string fontFile = CPath::lookup(font, false); - if (fontFile.size() == 0) + if (fontFile.empty()) { nlwarning("Font file '%s' not found", font.c_str()); return false; diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index 02b2600b4..7bd537fc0 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -32,6 +32,10 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + typedef std::string::size_type TCharPos; // index of a chracter in a string REGISTER_UI_CLASS(CViewText) @@ -903,7 +907,7 @@ namespace NLGUI if ((_MultiLine)&&(_Parent != NULL)) { // If never setuped, and if text is not empty - if (_Lines.size() == 0 && !_Text.empty()) + if (_Lines.empty() && !_Text.empty()) invalidateContent (); sint currentMaxW= getCurrentMultiLineMaxW(); @@ -989,7 +993,7 @@ namespace NLGUI // *** Draw multiline if ((_MultiLine)&&(_Parent != NULL)) { - if (_Lines.size() == 0) return; + if (_Lines.empty()) return; TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); @@ -1432,7 +1436,7 @@ namespace NLGUI // Append to the last line _Lines.back()->addWord(ucCurrentWord, 0, wordFormat, _FontWidth, *TextContext, _Scale); // reset the word - ucCurrentWord = ucstring(""); + ucCurrentWord.clear(); } @@ -1667,7 +1671,7 @@ namespace NLGUI { if (expandSpaces) { - nlassert(_Lines.size() > 0); + nlassert(!_Lines.empty()); nlassert(_Lines.back()->getNumWords() > 0); // Yoyo: if the line has tab, then don't justify @@ -1874,7 +1878,7 @@ namespace NLGUI } // Special case for multiline limited in number of lines - if ((_Lines.size() > 0) && (_MultiMaxLine > 0) && (_Lines.size() > _MultiMaxLine)) + if (!_Lines.empty() && (_MultiMaxLine > 0) && (_Lines.size() > _MultiMaxLine)) { while (_Lines.size() > _MultiMaxLine) { @@ -1906,7 +1910,7 @@ namespace NLGUI _H = std::max(_H, sint(_FontHeight * _MultiMinLine + (_MultiMinLine - 1) * _MultiLineSpace)); // Compute tooltips size - if (_Tooltips.size() > 0) + if (!_Tooltips.empty()) for (uint i=0 ; i<_Lines.size() ; ++i) { for (uint j=0 ; j<_Lines[i]->getNumWords() ; ++j) @@ -2515,7 +2519,7 @@ namespace NLGUI } // *************************************************************************** - void CViewText::setFirstLineX(uint firstLineX) + void CViewText::setFirstLineX(sint firstLineX) { _FirstLineX = firstLineX; } diff --git a/code/nel/src/gui/view_text_formated.cpp b/code/nel/src/gui/view_text_formated.cpp index f0bda2add..56a0b2e74 100644 --- a/code/nel/src/gui/view_text_formated.cpp +++ b/code/nel/src/gui/view_text_formated.cpp @@ -20,6 +20,10 @@ #include "nel/misc/xml_auto_ptr.h" #include "nel/misc/i18n.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CViewTextFormated, std::string, "text_formated"); namespace NLGUI diff --git a/code/nel/src/gui/view_text_id.cpp b/code/nel/src/gui/view_text_id.cpp index 23b939f91..b7e276a10 100644 --- a/code/nel/src/gui/view_text_id.cpp +++ b/code/nel/src/gui/view_text_id.cpp @@ -24,6 +24,10 @@ using namespace std; using NLMISC::CCDBNodeLeaf; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CViewTextID, std::string, "text_id"); namespace NLGUI diff --git a/code/nel/src/gui/view_text_id_formated.cpp b/code/nel/src/gui/view_text_id_formated.cpp index 1c91b3c0a..848bea21b 100644 --- a/code/nel/src/gui/view_text_id_formated.cpp +++ b/code/nel/src/gui/view_text_id_formated.cpp @@ -21,6 +21,10 @@ #include "nel/misc/xml_auto_ptr.h" #include "nel/misc/i18n.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CViewTextIDFormated, std::string, "text_id_formated"); namespace NLGUI diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index a215dbf08..e1cd14ab0 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -37,6 +37,10 @@ #include "nel/misc/events.h" #include "nel/gui/root_group.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { void LinkHack(); @@ -442,7 +446,7 @@ namespace NLGUI if (sZeStart[sZeStart.size()-1] == ':') sZeStart = sZeStart.substr(0, sZeStart.size()-1); - while (sZeStart != "") + while (!sZeStart.empty()) { if (sEltId[0] == ':') sTmp = sZeStart + sEltId; @@ -462,7 +466,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ CInterfaceElement* CWidgetManager::getElementFromDefine( const std::string &defineId ) { - return getElementFromId( parser->getDefine( defineId ) ); + return getElementFromId( _Parser->getDefine( defineId ) ); } // ------------------------------------------------------------------------------------------------ @@ -1758,16 +1762,12 @@ namespace NLGUI // *** According to best matching hotspot, and new screen resolution, move the window // x - if(bestXHotSpot==Hotspot_xL) - x= x; - else if(bestXHotSpot==Hotspot_xM) + if(bestXHotSpot==Hotspot_xM) x= newScreenW/2 + posXToMiddle - w/2; else if(bestXHotSpot==Hotspot_xR) x= newScreenW - posXToRight - w; // y - if(bestYHotSpot==Hotspot_Bx) - y= y; - else if(bestYHotSpot==Hotspot_Mx) + if(bestYHotSpot==Hotspot_Mx) y= newScreenH/2 + posYToMiddle + h/2; else if(bestYHotSpot==Hotspot_Tx) y= newScreenH - posYToTop; @@ -2116,8 +2116,6 @@ namespace NLGUI bool handled = false; - CViewPointer *_Pointer = static_cast< CViewPointer* >( getPointer() ); - if( evnt.getType() == CEventDescriptor::system ) { handleSystemEvent( evnt ); @@ -3279,7 +3277,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ void CWidgetManager::startAnim( const std::string &animId ) { - CInterfaceAnim *pIT = parser->getAnim( animId ); + CInterfaceAnim *pIT = _Parser->getAnim( animId ); if( pIT == NULL ) return; @@ -3305,7 +3303,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ void CWidgetManager::stopAnim( const std::string &animId ) { - CInterfaceAnim *pIT = parser->getAnim( animId ); + CInterfaceAnim *pIT = _Parser->getAnim( animId ); for( uint i = 0; i < activeAnims.size(); ++i ) if( activeAnims[ i ] == pIT ) @@ -3328,7 +3326,7 @@ namespace NLGUI void CWidgetManager::runProcedure( const std::string &procName, CCtrlBase *pCaller, const std::vector< std::string> ¶mList ) { - CProcedure *procp = parser->getProc( procName ); + CProcedure *procp = _Parser->getProc( procName ); if( procp == NULL ) return; @@ -3339,7 +3337,7 @@ namespace NLGUI { const CProcAction &action = proc.Actions[i]; // test if the condition for the action is valid - if( action.CondBlocks.size() > 0 ) + if (!action.CondBlocks.empty()) { CInterfaceExprValue result; result.setBool( false ); @@ -3364,7 +3362,7 @@ namespace NLGUI void CWidgetManager::setProcedureAction( const std::string &procName, uint actionIndex, const std::string &ah, const std::string ¶ms ) { - CProcedure *procp = parser->getProc( procName ); + CProcedure *procp = _Parser->getProc( procName ); if( procp == NULL ) return; @@ -3740,7 +3738,7 @@ namespace NLGUI CReflectableRegister::registerClasses(); - parser = IParser::createParser(); + _Parser = IParser::createParser(); _Pointer = NULL; curContextHelp = NULL; @@ -3783,6 +3781,9 @@ namespace NLGUI delete _MasterGroups[i].Group; } + delete _Parser; + _Parser = NULL; + _Pointer = NULL; curContextHelp = NULL; diff --git a/code/nel/src/ligo/CMakeLists.txt b/code/nel/src/ligo/CMakeLists.txt index 83b6c1fc0..39823c4d5 100644 --- a/code/nel/src/ligo/CMakeLists.txt +++ b/code/nel/src/ligo/CMakeLists.txt @@ -15,10 +15,10 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nelligo ${CMAKE_CURRENT_SOURCE_DIR}/stdligo.h ${CMAKE_CURRENT_SOURCE_DIR}/stdligo.cpp) -ENDIF(WITH_PCH) +ENDIF() NL_GEN_PC(nel-ligo.pc) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nelligo LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/src/ligo/ligo_config.cpp b/code/nel/src/ligo/ligo_config.cpp index f836c808e..d898e44ed 100644 --- a/code/nel/src/ligo/ligo_config.cpp +++ b/code/nel/src/ligo/ligo_config.cpp @@ -39,7 +39,7 @@ CLigoConfig::CLigoConfig() // *************************************************************************** -bool CLigoConfig::readConfigFile (const char *fileName, bool parsePrimitiveComboContent) +bool CLigoConfig::readConfigFile (const std::string &fileName, bool parsePrimitiveComboContent) { // The CF CConfigFile cf; @@ -73,7 +73,7 @@ bool CLigoConfig::readConfigFile (const char *fileName, bool parsePrimitiveCombo // *************************************************************************** -bool CLigoConfig::readPrimitiveClass (const char *_fileName, bool parsePrimitiveComboContent) +bool CLigoConfig::readPrimitiveClass (const std::string &_fileName, bool parsePrimitiveComboContent) { // File exist ? string filename = _fileName; @@ -508,13 +508,13 @@ bool CLigoConfig::canBeRoot (const NLLIGO::IPrimitive &child) // *************************************************************************** -bool CLigoConfig::getPropertyString (std::string &result, const char *filename, xmlNodePtr xmlNode, const char *propName) +bool CLigoConfig::getPropertyString(std::string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &propName) { // Call the CIXml version if (!CIXml::getPropertyString (result, xmlNode, propName)) { // Output a formated error - syntaxError (filename, xmlNode, "Missing XML node property (%s)", propName); + syntaxError (filename, xmlNode, "Missing XML node property (%s)", propName.c_str()); return false; } return true; @@ -522,7 +522,7 @@ bool CLigoConfig::getPropertyString (std::string &result, const char *filename, // *************************************************************************** -void CLigoConfig::syntaxError (const char *filename, xmlNodePtr xmlNode, const char *format, ...) +void CLigoConfig::syntaxError (const std::string &filename, xmlNodePtr xmlNode, const char *format, ...) { va_list args; va_start( args, format ); @@ -530,7 +530,7 @@ void CLigoConfig::syntaxError (const char *filename, xmlNodePtr xmlNode, const c vsnprintf( buffer, 1024, format, args ); va_end( args ); - errorMessage ("(%s), node (%s), line (%p) :\n%s", filename, xmlNode->name, xmlNode->content, buffer); + errorMessage ("(%s), node (%s), line (%d) :\n%s", filename.c_str(), xmlNode->name, (sint)xmlNode->line, buffer); } // *************************************************************************** @@ -589,7 +589,7 @@ const CPrimitiveClass *CLigoConfig::getPrimitiveClass (const IPrimitive &primiti // *************************************************************************** -const CPrimitiveClass *CLigoConfig::getPrimitiveClass (const char *className) const +const CPrimitiveClass *CLigoConfig::getPrimitiveClass(const std::string &className) const { std::map::const_iterator ite = _PrimitiveClasses.find (className); if (ite != _PrimitiveClasses.end ()) @@ -785,7 +785,7 @@ std::string CLigoConfig::aliasToString(uint32 fullAlias) } -uint32 CLigoConfig::aliasFromString(std::string fullAlias) +uint32 CLigoConfig::aliasFromString(const std::string &fullAlias) { uint32 staticPart; uint32 dynPart; diff --git a/code/nel/src/ligo/ligo_error.cpp b/code/nel/src/ligo/ligo_error.cpp index fdca7a2c2..30315b3e6 100644 --- a/code/nel/src/ligo/ligo_error.cpp +++ b/code/nel/src/ligo/ligo_error.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . #include "stdligo.h" -#include "ligo_error.h" +#include "nel/ligo/ligo_error.h" namespace NLLIGO { diff --git a/code/nel/src/ligo/ligo_material.cpp b/code/nel/src/ligo/ligo_material.cpp index c5e7541a3..2c46e6977 100644 --- a/code/nel/src/ligo/ligo_material.cpp +++ b/code/nel/src/ligo/ligo_material.cpp @@ -15,13 +15,17 @@ // along with this program. If not, see . #include "stdligo.h" -#include "ligo_material.h" +#include "nel/ligo/ligo_material.h" // Ligo include -#include "ligo_error.h" +#include "nel/ligo/ligo_error.h" //using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLLIGO { diff --git a/code/nel/src/ligo/primitive.cpp b/code/nel/src/ligo/primitive.cpp index 3fc97fdf5..cc6555222 100644 --- a/code/nel/src/ligo/primitive.cpp +++ b/code/nel/src/ligo/primitive.cpp @@ -28,6 +28,10 @@ using namespace std; const uint32 NLLIGO_PRIMITIVE_VERSION = 1; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLLIGO { @@ -38,7 +42,7 @@ CPrimitiveContext *CPrimitiveContext::_Instance = NULL; // XML helpers // *************************************************************************** -void Error (const char *filename, const char *format, ...) +void Error (const std::string &filename, const char *format, ...) { va_list args; va_start( args, format ); @@ -46,12 +50,12 @@ void Error (const char *filename, const char *format, ...) vsnprintf( buffer, 1024, format, args ); va_end( args ); - nlwarning ("In File (%s) %s", filename, buffer); + nlwarning ("In File (%s) %s", filename.c_str(), buffer); } // *************************************************************************** -void XMLError (xmlNodePtr xmlNode, const char *filename, const char *format, ... ) +void XMLError (xmlNodePtr xmlNode, const std::string &filename, const char *format, ... ) { va_list args; va_start( args, format ); @@ -59,32 +63,32 @@ void XMLError (xmlNodePtr xmlNode, const char *filename, const char *format, ... vsnprintf( buffer, 1024, format, args ); va_end( args ); - Error (filename, "node (%s), line (%p) : %s", xmlNode->name, xmlNode->content, buffer); + Error (filename, "node (%s), line (%d) : %s", xmlNode->name, xmlNode->line, buffer); } // *************************************************************************** -xmlNodePtr GetFirstChildNode (xmlNodePtr xmlNode, const char *filename, const char *childName) +xmlNodePtr GetFirstChildNode (xmlNodePtr xmlNode, const std::string &filename, const std::string &childName) { // Call the CIXml version xmlNodePtr result = CIXml::getFirstChildNode (xmlNode, childName); if (result) return result; // Output a formated error - XMLError (xmlNode, filename, "Can't find XML node named (%s)", childName); + XMLError (xmlNode, filename.c_str(), "Can't find XML node named (%s)", childName.c_str()); return NULL; } // *************************************************************************** -bool GetPropertyString (string &result, const char *filename, xmlNodePtr xmlNode, const char *propName) +bool GetPropertyString (string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &propName) { // Call the CIXml version if (!CIXml::getPropertyString (result, xmlNode, propName)) { // Output a formated error - XMLError (xmlNode, filename, "Can't find XML node property (%s)", propName); + XMLError (xmlNode, filename, "Can't find XML node property (%s)", propName.c_str()); return false; } return true; @@ -92,7 +96,7 @@ bool GetPropertyString (string &result, const char *filename, xmlNodePtr xmlNode // *************************************************************************** -bool ReadInt (const char *propName, int &result, const char *filename, xmlNodePtr xmlNode) +bool ReadInt (const std::string &propName, int &result, const std::string &filename, xmlNodePtr xmlNode) { string value; if (GetPropertyString (value, filename, xmlNode, propName)) @@ -105,15 +109,15 @@ bool ReadInt (const char *propName, int &result, const char *filename, xmlNodePt // *************************************************************************** -void WriteInt (const char *propName, int value, xmlNodePtr xmlNode) +void WriteInt (const std::string &propName, int value, xmlNodePtr xmlNode) { // Set properties - xmlSetProp (xmlNode, (const xmlChar*)propName, (const xmlChar*)(toString (value).c_str ())); + xmlSetProp (xmlNode, (const xmlChar*)propName.c_str(), (const xmlChar*)(toString (value).c_str ())); } // *************************************************************************** -bool ReadUInt (const char *propName, uint &result, const char *filename, xmlNodePtr xmlNode) +bool ReadUInt (const std::string &propName, uint &result, const std::string &filename, xmlNodePtr xmlNode) { string value; if (GetPropertyString (value, filename, xmlNode, propName)) @@ -126,15 +130,15 @@ bool ReadUInt (const char *propName, uint &result, const char *filename, xmlNode // *************************************************************************** -void WriteUInt (const char *propName, uint value, xmlNodePtr xmlNode) +void WriteUInt (const std::string &propName, uint value, xmlNodePtr xmlNode) { // Set properties - xmlSetProp (xmlNode, (const xmlChar*)propName, (const xmlChar*)(toString (value).c_str ())); + xmlSetProp (xmlNode, (const xmlChar*)propName.c_str(), (const xmlChar*)(toString (value).c_str ())); } // *************************************************************************** -bool ReadFloat (const char *propName, float &result, const char *filename, xmlNodePtr xmlNode) +bool ReadFloat (const std::string &propName, float &result, const std::string &filename, xmlNodePtr xmlNode) { string value; if (GetPropertyString (value, filename, xmlNode, propName)) @@ -147,15 +151,15 @@ bool ReadFloat (const char *propName, float &result, const char *filename, xmlNo // *************************************************************************** -void WriteFloat (const char *propName, float value, xmlNodePtr xmlNode) +void WriteFloat (const std::string &propName, float value, xmlNodePtr xmlNode) { // Set properties - xmlSetProp (xmlNode, (const xmlChar*)propName, (const xmlChar*)(toString (value).c_str ())); + xmlSetProp (xmlNode, (const xmlChar*)propName.c_str(), (const xmlChar*)(toString (value).c_str ())); } // *************************************************************************** -bool ReadVector (CPrimVector &point, const char *filename, xmlNodePtr xmlNode) +bool ReadVector (CPrimVector &point, const std::string &filename, xmlNodePtr xmlNode) { CPrimVector pos; if (ReadFloat ("X", pos.x, filename, xmlNode)) @@ -194,20 +198,20 @@ void WriteVector (const CPrimVector &point, xmlNodePtr xmlNode) // *************************************************************************** -bool GetNodeString (string &result, const char *filename, xmlNodePtr xmlNode, const char *nodeName) +bool GetNodeString (string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &nodeName) { // Look for the node xmlNodePtr node = CIXml::getFirstChildNode (xmlNode, nodeName); if (!node) { - XMLError (xmlNode, filename, "Can't find XML node named (%s)", nodeName); + XMLError (xmlNode, filename, "Can't find XML node named (%s)", nodeName.c_str()); return false; } // Get the node string if (!CIXml::getContentString (result, node)) { - XMLError (xmlNode, filename, "Can't find any text in the node named (%s)", nodeName); + XMLError (xmlNode, filename, "Can't find any text in the node named (%s)", nodeName.c_str()); return false; } @@ -216,7 +220,7 @@ bool GetNodeString (string &result, const char *filename, xmlNodePtr xmlNode, co // *************************************************************************** -bool GetContentString (string &result, const char *filename, xmlNodePtr xmlNode) +bool GetContentString (string &result, const std::string &filename, xmlNodePtr xmlNode) { // Get the node string if (!CIXml::getContentString (result, xmlNode)) @@ -232,11 +236,6 @@ bool GetContentString (string &result, const char *filename, xmlNodePtr xmlNode) // CPropertyString // *************************************************************************** -CPropertyString::CPropertyString (const char *str) -{ - String = str; -} - CPropertyString::CPropertyString (const std::string &str) { String = str; @@ -244,7 +243,7 @@ CPropertyString::CPropertyString (const std::string &str) // *************************************************************************** -CPropertyString::CPropertyString (const char *str, bool _default) +CPropertyString::CPropertyString (const std::string &str, bool _default) { String = str; Default = _default; @@ -386,7 +385,7 @@ bool CPrimZone::contains (const NLMISC::CVector &v, const std::vector::const_iterator ite = _Properties.find (property_name); @@ -1324,7 +1323,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, const IProperty * // *************************************************************************** -bool IPrimitive::getPropertyByName (const char *property_name, IProperty *&result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, IProperty *&result) const { // Look for the property std::map::const_iterator ite = _Properties.find (property_name); @@ -1338,7 +1337,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, IProperty *&resul // *************************************************************************** -bool IPrimitive::getPropertyByName (const char *property_name, std::string *&result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, std::string *&result) const { // Get the property IProperty *prop; @@ -1352,7 +1351,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string *&res } else { - nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); + nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name.c_str()); } } return false; @@ -1360,7 +1359,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string *&res // *************************************************************************** -bool IPrimitive::getPropertyByName (const char *property_name, std::string &result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, std::string &result) const { // Get the property const IProperty *prop; @@ -1374,7 +1373,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string &resu } else { - nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); + nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name.c_str()); } } return false; @@ -1382,7 +1381,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string &resu // *************************************************************************** -bool IPrimitive::getPropertyByName (const char *property_name, std::vector *&result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, std::vector *&result) const { // Get the property IProperty *prop; @@ -1396,7 +1395,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::vector *&result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, const std::vector *&result) const { // Get the property IProperty *prop; @@ -1418,7 +1417,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, const std::vector } else { - nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); + nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name.c_str()); } } return false; @@ -1426,7 +1425,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, const std::vector // *************************************************************************** -bool IPrimitive::getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, NLMISC::CRGBA &result) const { // Get the property IProperty *prop; @@ -1440,7 +1439,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, NLMISC::CRGBA &re } else { - nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a color.", property_name); + nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a color.", property_name.c_str()); } } return false; @@ -1462,13 +1461,13 @@ bool IPrimitive::removeProperty (uint index) index--; ite ++; } - nlwarning ("NLLIGO::IPrimitive::removeProperty : invalid index (index : %d, size : %d).", index, _Properties.size ()); + nlwarning ("NLLIGO::IPrimitive::removeProperty : invalid index (index : %u, size : %u).", index, (uint)_Properties.size ()); return false; } // *************************************************************************** -bool IPrimitive::removePropertyByName (const char *property_name) +bool IPrimitive::removePropertyByName (const std::string &property_name) { // Look for the property std::map::iterator ite = _Properties.find (property_name); @@ -1504,7 +1503,7 @@ bool IPrimitive::getChild (const IPrimitive *&result, uint childId) const } else { - nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %d, size %d).", childId, _Children.size ()); + nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %u, size %u).", childId, (uint)_Children.size ()); } return false; } @@ -1520,7 +1519,7 @@ bool IPrimitive::getChild (IPrimitive *&result, uint childId) } else { - nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %d, size %d).", childId, _Children.size ()); + nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %u, size %u).", childId, (uint)_Children.size ()); } return false; } @@ -1554,7 +1553,7 @@ bool IPrimitive::removeChild (uint childId) } else { - nlwarning ("NLLIGO::IPrimitive::removeChild : invalid index (index : %d, size %d).", childId, _Children.size ()); + nlwarning ("NLLIGO::IPrimitive::removeChild : invalid index (index : %u, size %u).", childId, (uint)_Children.size ()); } return false; } @@ -1642,7 +1641,7 @@ bool IPrimitive::checkProperty(const std::string &property_name) const // *************************************************************************** -bool IPrimitive::addPropertyByName (const char *property_name, IProperty *result) +bool IPrimitive::addPropertyByName (const std::string &property_name, IProperty *result) { bool inserted = _Properties.insert (std::map::value_type (property_name, result)).second; if (inserted) @@ -1654,7 +1653,7 @@ bool IPrimitive::addPropertyByName (const char *property_name, IProperty *result // *************************************************************************** -bool IPrimitive::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) +bool IPrimitive::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config) { // Erase old properties _Properties.clear (); @@ -1664,7 +1663,7 @@ bool IPrimitive::read (xmlNodePtr xmlNode, const char *filename, uint version, C if (commentNode) { if (!CIXml::getContentString(_UnparsedProperties, commentNode)) - _UnparsedProperties = ""; + _UnparsedProperties.clear(); } // Read the expanded flag @@ -1915,7 +1914,7 @@ void IPrimitive::initDefaultValues (CLigoConfig &config) // *************************************************************************** -void IPrimitive::write (xmlNodePtr xmlNode, const char *filename) const +void IPrimitive::write (xmlNodePtr xmlNode, const std::string &filename) const { // Save the expanded flag // if (!Expanded) @@ -2112,7 +2111,7 @@ void CPrimAlias::regenAlias() // Read the primitive -bool CPrimAlias::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) +bool CPrimAlias::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config) { // Read alias xmlNodePtr ptNode = CIXml::getFirstChildNode (xmlNode, "ALIAS"); @@ -2146,7 +2145,7 @@ bool CPrimAlias::read (xmlNodePtr xmlNode, const char *filename, uint version, C return IPrimitive::read (xmlNode, filename, version, config); } // Write the primitive -void CPrimAlias::write (xmlNodePtr xmlNode, const char *filename) const +void CPrimAlias::write (xmlNodePtr xmlNode, const std::string &filename) const { // Write alias xmlNodePtr ptNode = xmlNewChild(xmlNode, NULL, (const xmlChar*)"ALIAS", NULL); @@ -2458,7 +2457,7 @@ CPrimitives& CPrimitives::operator= (const CPrimitives &other) // *************************************************************************** -bool CPrimitives::read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &config) +bool CPrimitives::read (xmlNodePtr xmlNode, const std::string &filename, CLigoConfig &config) { nlassert (xmlNode); @@ -2511,7 +2510,7 @@ bool CPrimitives::read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &c } else { - Error (filename, "CPrimitives::read : Unknown file version (%d)", version); + Error (filename, "CPrimitives::read : Unknown file version (%u)", version); return false; } } @@ -2531,7 +2530,7 @@ bool CPrimitives::read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &c // *************************************************************************** -void CPrimitives::write (xmlDocPtr doc, const char *filename) const +void CPrimitives::write (xmlDocPtr doc, const std::string &filename) const { nlassert (doc); @@ -2544,7 +2543,7 @@ void CPrimitives::write (xmlDocPtr doc, const char *filename) const // *************************************************************************** -void CPrimitives::write (xmlNodePtr root, const char *filename) const +void CPrimitives::write (xmlNodePtr root, const std::string &filename) const { nlassert (root); diff --git a/code/nel/src/ligo/primitive_class.cpp b/code/nel/src/ligo/primitive_class.cpp index 2b32cadec..02923285c 100644 --- a/code/nel/src/ligo/primitive_class.cpp +++ b/code/nel/src/ligo/primitive_class.cpp @@ -183,8 +183,8 @@ bool CPrimitiveClass::read (xmlNodePtr primitiveNode, // init default parameters AutoInit = false; Deletable = true; - FileExtension = ""; - FileType = ""; + FileExtension.clear(); + FileType.clear(); Collision = false; LinkBrothers = false; ShowArrow = true; @@ -351,16 +351,16 @@ bool CPrimitiveClass::read (xmlNodePtr primitiveNode, parameter.WidgetHeight = (uint)temp; // Read the file extension - parameter.FileExtension = ""; + parameter.FileExtension.clear(); CIXml::getPropertyString (parameter.FileExtension, paramNode, "FILE_EXTENSION"); parameter.FileExtension = toLower(parameter.FileExtension); // Autonaming preference - parameter.Autoname = ""; + parameter.Autoname.clear(); CIXml::getPropertyString (parameter.Autoname, paramNode, "AUTONAME"); // Read the file extension - parameter.Folder = ""; + parameter.Folder.clear(); CIXml::getPropertyString (parameter.Folder, paramNode, "FOLDER"); parameter.Folder = toLower(parameter.Folder); @@ -650,7 +650,7 @@ void CPrimitiveClass::CParameter::CConstStringValue::getPrimitivesForPrimPath (s bool CPrimitiveClass::CParameter::translateAutoname (std::string &result, const IPrimitive &primitive, const CPrimitiveClass &primitiveClass) const { - result = ""; + result.clear(); string::size_type strBegin = 0; string::size_type strEnd = 0; while (strBegin != Autoname.size()) @@ -745,7 +745,7 @@ bool CPrimitiveClass::CParameter::translateAutoname (std::string &result, const bool CPrimitiveClass::CParameter::getDefaultValue (std::string &result, const IPrimitive &primitive, const CPrimitiveClass &primitiveClass, std::string *fromWhere) const { - result = ""; + result.clear(); if (!Autoname.empty()) { if (fromWhere) diff --git a/code/nel/src/ligo/stdligo.h b/code/nel/src/ligo/stdligo.h index 85e7a2120..adc3887cf 100644 --- a/code/nel/src/ligo/stdligo.h +++ b/code/nel/src/ligo/stdligo.h @@ -14,7 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "nel/misc/types_nl.h" +#ifndef STDLIGO_H +#define STDLIGO_H + +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif #include #include @@ -44,6 +52,7 @@ // Include from libxml2 #include +#include "nel/misc/types_nl.h" #include "nel/misc/debug.h" #include "nel/misc/common.h" #include "nel/misc/fast_mem.h" @@ -67,3 +76,5 @@ #endif #include #endif + +#endif diff --git a/code/nel/src/ligo/transition.cpp b/code/nel/src/ligo/transition.cpp index ee6921c78..2a2e7b813 100644 --- a/code/nel/src/ligo/transition.cpp +++ b/code/nel/src/ligo/transition.cpp @@ -15,12 +15,16 @@ // along with this program. If not, see . #include "stdligo.h" -#include "transition.h" +#include "nel/ligo/transition.h" // Ligo include -#include "zone_template.h" -#include "ligo_error.h" -#include "ligo_material.h" +#include "nel/ligo/zone_template.h" +#include "nel/ligo/ligo_error.h" +#include "nel/ligo/ligo_material.h" + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLLIGO { diff --git a/code/nel/src/ligo/zone_bank.cpp b/code/nel/src/ligo/zone_bank.cpp index 6d5de79e8..b1c6b73c6 100644 --- a/code/nel/src/ligo/zone_bank.cpp +++ b/code/nel/src/ligo/zone_bank.cpp @@ -28,6 +28,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLLIGO { @@ -88,7 +91,7 @@ void CZoneBankElement::convertSize() } fromString(sTmp, _SizeX); - ++i; sTmp = ""; + ++i; sTmp.clear(); for (; i < sizeString.size(); ++i) { sTmp += sizeString[i]; @@ -493,32 +496,25 @@ void CZoneBank::reset () _Selection.clear (); } -#ifdef NL_OS_WINDOWS // --------------------------------------------------------------------------- bool CZoneBank::initFromPath(const std::string &sPathName, std::string &error) { - char sDirBackup[512]; - GetCurrentDirectory (512, sDirBackup); - SetCurrentDirectory (sPathName.c_str()); - WIN32_FIND_DATA findData; - HANDLE hFind; - hFind = FindFirstFile ("*.ligozone", &findData); + std::vector files; + NLMISC::CPath::getPathContent(sPathName, false, false, true, files); - while (hFind != INVALID_HANDLE_VALUE) + for (uint i = 0, len = files.size(); i < len; ++i) { - // If the name of the file is not . or .. then its a valid entry in the DataBase - if (!((strcmp (findData.cFileName, ".") == 0) || (strcmp (findData.cFileName, "..") == 0))) + std::string ext = NLMISC::CFile::getExtension(files[i]); + + if (ext == "ligozone") { - if (!addElement (findData.cFileName, error)) + if (!addElement(NLMISC::CFile::getFilename(files[i]), error)) return false; } - if (FindNextFile (hFind, &findData) == 0) - break; } - SetCurrentDirectory (sDirBackup); + return true; } -#endif // NL_OS_WINDOWS // --------------------------------------------------------------------------- bool CZoneBank::addElement (const std::string &elementName, std::string &error) diff --git a/code/nel/src/ligo/zone_edge.cpp b/code/nel/src/ligo/zone_edge.cpp index 8bd2c7fa2..f34d43cd1 100644 --- a/code/nel/src/ligo/zone_edge.cpp +++ b/code/nel/src/ligo/zone_edge.cpp @@ -16,15 +16,19 @@ #include "stdligo.h" // Ligo include -#include "zone_edge.h" +#include "nel/ligo/zone_edge.h" #include "nel/ligo/ligo_config.h" -#include "ligo_error.h" +#include "nel/ligo/ligo_error.h" // NeL include #include "nel/misc/matrix.h" using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLLIGO { diff --git a/code/nel/src/ligo/zone_template.cpp b/code/nel/src/ligo/zone_template.cpp index 9f51c3c8e..e21cde438 100644 --- a/code/nel/src/ligo/zone_template.cpp +++ b/code/nel/src/ligo/zone_template.cpp @@ -15,8 +15,8 @@ // along with this program. If not, see . #include "stdligo.h" -#include "zone_template.h" -#include "ligo_error.h" +#include "nel/ligo/zone_template.h" +#include "nel/ligo/ligo_error.h" #include "nel/ligo/ligo_config.h" #include "nel/misc/stream.h" diff --git a/code/nel/src/logic/CMakeLists.txt b/code/nel/src/logic/CMakeLists.txt index 1d4691a40..0b5bc443b 100644 --- a/code/nel/src/logic/CMakeLists.txt +++ b/code/nel/src/logic/CMakeLists.txt @@ -15,8 +15,8 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nellogic ${CMAKE_CURRENT_SOURCE_DIR}/stdlogic.h ${CMAKE_CURRENT_SOURCE_DIR}/stdlogic.cpp) -ENDIF(WITH_PCH) +ENDIF() IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nellogic LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/src/logic/logic_condition.cpp b/code/nel/src/logic/logic_condition.cpp index 2afe26ad6..ab6b22822 100644 --- a/code/nel/src/logic/logic_condition.cpp +++ b/code/nel/src/logic/logic_condition.cpp @@ -337,7 +337,7 @@ bool CLogicConditionNode::testLogic() } // if there's no subtree we assess the subtree is true - if( _Nodes.size() == 0 ) + if( _Nodes.empty() ) { return true; } diff --git a/code/nel/src/logic/stdlogic.h b/code/nel/src/logic/stdlogic.h index 67c7231c1..cdfe3f6f7 100644 --- a/code/nel/src/logic/stdlogic.h +++ b/code/nel/src/logic/stdlogic.h @@ -14,8 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#ifndef NL_STDMISC_H -#define NL_STDMISC_H +#ifndef NL_STDLOGIC_H +#define NL_STDLOGIC_H + +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif #include #include @@ -24,6 +31,12 @@ #include +#include "nel/misc/types_nl.h" +#include "nel/misc/entity_id.h" +#include "nel/misc/i_xml.h" +#include "nel/misc/o_xml.h" +#include "nel/misc/stream.h" + #ifdef NL_OS_WINDOWS # define WIN32_LEAN_AND_MEAN # define _WIN32_WINDOWS 0x0500 diff --git a/code/nel/src/misc/CMakeLists.txt b/code/nel/src/misc/CMakeLists.txt index 53993161c..ec0dcd357 100644 --- a/code/nel/src/misc/CMakeLists.txt +++ b/code/nel/src/misc/CMakeLists.txt @@ -42,18 +42,18 @@ FILE(GLOB NLMISC_MATH plane.cpp ../../include/nel/misc/plane.h ../../include/nel/misc/plane_inline.h polygon.cpp ../../include/nel/misc/polygon.h - quad.cpp ../../include/nel/misc/quad.h + ../../include/nel/misc/quad.h quat.cpp ../../include/nel/misc/quat.h rect.cpp ../../include/nel/misc/rect.h rgba.cpp ../../include/nel/misc/rgba.h triangle.cpp ../../include/nel/misc/triangle.h - uv.cpp ../../include/nel/misc/uv.h + ../../include/nel/misc/uv.h vector*.cpp ../../include/nel/misc/vector*.h aabbox.cpp ../../include/nel/misc/aabbox.h algo.cpp ../../include/nel/misc/algo.h bsphere.cpp ../../include/nel/misc/bsphere.h fast_floor.cpp ../../include/nel/misc/fast_floor.h - geom_ext.cpp ../../include/nel/misc/geom_ext.h + ../../include/nel/misc/geom_ext.h line.cpp ../../include/nel/misc/line.h matrix.cpp ../../include/nel/misc/matrix.h ) @@ -70,7 +70,6 @@ FILE(GLOB NLMISC_PLATFORM inter_window_msg_queue.cpp ../../include/nel/misc/inter_window_msg_queue.h system_*.cpp ../../include/nel/misc/system_*.h win32_util.cpp ../../include/nel/misc/win32_util.h - win_tray.cpp ../../include/nel/misc/win_tray.h ) FILE(GLOB NLMISC_GENERIC @@ -80,7 +79,7 @@ FILE(GLOB NLMISC_GENERIC ../../include/nel/misc/callback.h *_allocator.cpp ../../include/nel/misc/*_allocator.h ../../include/nel/misc/enum_bitset.h - fast_id_map.cpp ../../include/nel/misc/fast_id_map.h + ../../include/nel/misc/fast_id_map.h hierarchical_timer.cpp ../../include/nel/misc/hierarchical_timer.h ../../include/nel/misc/historic.h ../../include/nel/misc/mutable_container.h @@ -92,11 +91,11 @@ FILE(GLOB NLMISC_GENERIC bit_set.cpp ../../include/nel/misc/bit_set.h stop_watch.cpp ../../include/nel/misc/stop_watch.h ../../include/nel/misc/twin_map.h - object_vector.cpp ../../include/nel/misc/object_vector.h + ../../include/nel/misc/object_vector.h ../../include/nel/misc/singleton.h speaker_listener.cpp ../../include/nel/misc/speaker_listener.h ../../include/nel/misc/static_map.h - stl_block_list.cpp ../../include/nel/misc/stl_block_list.h + ../../include/nel/misc/stl_block_list.h ) FILE(GLOB NLMISC_UTILITY @@ -118,7 +117,7 @@ FILE(GLOB NLMISC_UTILITY progress_callback.cpp ../../include/nel/misc/progress_callback.h sheet_id.cpp ../../include/nel/misc/sheet_id.h variable.cpp ../../include/nel/misc/variable.h - value_smoother.cpp ../../include/nel/misc/value_smoother.h + ../../include/nel/misc/value_smoother.h ) FILE(GLOB NLMISC_STRING @@ -179,34 +178,36 @@ IF(WITH_GTK) INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS}) ADD_DEFINITIONS(-DNL_USE_GTK) TARGET_LINK_LIBRARIES(nelmisc ${GTK2_LIBRARIES}) - ENDIF(GTK2_FOUND) -ENDIF(WITH_GTK) + ENDIF() +ENDIF() IF(JPEG_FOUND) INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR}) ADD_DEFINITIONS(-DUSE_JPEG) TARGET_LINK_LIBRARIES(nelmisc ${JPEG_LIBRARY}) -ENDIF(JPEG_FOUND) +ENDIF() IF(GIF_FOUND) INCLUDE_DIRECTORIES(${GIF_INCLUDE_DIR}) ADD_DEFINITIONS(-DUSE_GIF) TARGET_LINK_LIBRARIES(nelmisc ${GIF_LIBRARY}) -ENDIF(GIF_FOUND) +ENDIF() IF(WITH_STATIC OR WIN32) TARGET_LINK_LIBRARIES(nelmisc ${PNG_LIBRARIES}) -ELSE(WITH_STATIC OR WIN32) +ELSE() # Link only with libpng shared library TARGET_LINK_LIBRARIES(nelmisc ${PNG_LIBRARY}) -ENDIF(WITH_STATIC OR WIN32) +ENDIF() IF(UNIX) TARGET_LINK_LIBRARIES(nelmisc -lc -ldl) - IF(NOT APPLE) + IF(APPLE) + TARGET_LINK_LIBRARIES(nelmisc ${CARBON_FRAMEWORK}) + ELSE() TARGET_LINK_LIBRARIES(nelmisc -lrt) - ENDIF(NOT APPLE) -ENDIF(UNIX) + ENDIF() +ENDIF() INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${PNG_INCLUDE_DIR} config_file) @@ -220,10 +221,10 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nelmisc ${CMAKE_CURRENT_SOURCE_DIR}/stdmisc.h ${CMAKE_CURRENT_SOURCE_DIR}/stdmisc.cpp) -ENDIF(WITH_PCH) +ENDIF() NL_GEN_PC(nel-misc.pc) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nelmisc LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/src/misc/app_context.cpp b/code/nel/src/misc/app_context.cpp index 68ca720ed..a7381d026 100644 --- a/code/nel/src/misc/app_context.cpp +++ b/code/nel/src/misc/app_context.cpp @@ -18,7 +18,6 @@ #include "nel/misc/app_context.h" #include "nel/misc/dynloadlib.h" #include "nel/misc/command.h" -#include "nel/misc/system_utils.h" #include @@ -72,9 +71,6 @@ INelContext::~INelContext() CInstanceCounterLocalManager::releaseInstance(); - // uninit some systems stuff - CSystemUtils::uninit(); - _NelContext = NULL; *(_getInstance()) = NULL; } @@ -94,9 +90,6 @@ void INelContext::contextReady() // set numeric locale to C to avoid the use of decimal separators different of a dot char *locale = setlocale(LC_NUMERIC, "C"); - // init some systems stuff - CSystemUtils::init(); - // register any pending thinks // register local instance counter in the global instance counter manager @@ -131,6 +124,27 @@ CApplicationContext::CApplicationContext() contextReady(); } +CApplicationContext::~CApplicationContext() +{ +#ifdef NL_DEBUG + TSingletonRegistry::iterator it = _SingletonRegistry.begin(), iend = _SingletonRegistry.end(); + + while (it != iend) + { + // can't use nldebug there because it'll create new displayers + std::string message = toString("Instance '%s' still allocated at %p", it->first.c_str(), it->second); + +#ifdef NL_OS_WINDOWS + OutputDebugStringW(utf8ToWide(message)); +#else + printf("%s\n", message.c_str()); +#endif + + ++it; + } +#endif +} + void *CApplicationContext::getSingletonPointer(const std::string &singletonName) { TSingletonRegistry::iterator it(_SingletonRegistry.find(singletonName)); diff --git a/code/nel/src/misc/big_file.cpp b/code/nel/src/misc/big_file.cpp index a458b602d..9713610cb 100644 --- a/code/nel/src/misc/big_file.cpp +++ b/code/nel/src/misc/big_file.cpp @@ -45,8 +45,16 @@ void CBigFile::releaseInstance() // *************************************************************************** CBigFile::CThreadFileArray::CThreadFileArray() { - _CurrentId= 0; + _CurrentId = 0; } + +// *************************************************************************** +CBigFile::CThreadFileArray::~CThreadFileArray() +{ + vector *ptr = (vector*)_TDS.getPointer(); + if (ptr) delete ptr; +} + // *************************************************************************** uint32 CBigFile::CThreadFileArray::allocate() { @@ -186,11 +194,24 @@ void CBigFile::remove (const std::string &sBigFileName) fclose (handle.File); handle.File= NULL; } - delete [] rbnp.FileNames; + _BNPs.erase (it); } } +CBigFile::BNP::BNP() : FileNames(NULL), ThreadFileId(0), CacheFileOnOpen(false), AlwaysOpened(false), InternalUse(false), OffsetFromBeginning(0) +{ +} + +CBigFile::BNP::~BNP() +{ + if (FileNames) + { + delete[] FileNames; + FileNames = NULL; + } +} + //// *************************************************************************** bool CBigFile::BNP::readHeader() { @@ -318,6 +339,9 @@ bool CBigFile::BNP::readHeader(FILE *file) it++; } + if (FileNames) + delete[] FileNames; + FileNames = new char[nSize]; memset(FileNames, 0, nSize); Files.resize(nNb); @@ -629,7 +653,7 @@ bool CBigFile::getFileInternal (const std::string &sFileName, BNP *&zeBnp, BNPFi } BNP &rbnp = _BNPs.find (zeBigFileName)->second; - if (rbnp.Files.size() == 0) + if (rbnp.Files.empty()) { return false; } @@ -722,7 +746,7 @@ char *CBigFile::getFileNamePtr(const std::string &sFileName, const std::string & { BNP &rbnp = _BNPs.find (bigfilenamealone)->second; vector::iterator itNBPFile; - if (rbnp.Files.size() == 0) + if (rbnp.Files.empty()) return NULL; string lwrFileName = toLower(sFileName); diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index 5574a8597..47bdf3886 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -136,7 +136,8 @@ uint8 CBitmap::load(NLMISC::IStream &f, uint mipMapSkip) } #ifdef USE_JPEG - if (fileType == JPG_HEADER) + // only compare fist word + if (memcmp(&fileType, &JPG_HEADER, 2) == 0) { #ifdef NEL_ALL_BITMAP_WHITE uint8 result = readJPG(f); @@ -369,6 +370,51 @@ void CBitmap::makeOpaque() } +/*-------------------------------------------------------------------*\ + makeTransparentPixelsBlack +\*-------------------------------------------------------------------*/ +void CBitmap::makeTransparentPixelsBlack() +{ + if (_Width*_Height == 0) return; + + uint pixelSize; + + switch (PixelFormat) + { + case RGBA: pixelSize = 4; break; + case AlphaLuminance: pixelSize = 2; break; + default: return; + } + + uint colorsSize = pixelSize - 1; + + for (uint8 m = 0; m < _MipMapCount; ++m) + { + // get a pointer on original data + uint8 *data = _Data[m].getPtr(); + + // end of data + uint8 *endData = data + _Data[m].size(); + + // first alpha + data += pixelSize - 1; + + // replace all alpha values by 255 + while (data < endData) + { + // fully transparent pixel + if (*data == 0) + { + // make colors black + memset(data - colorsSize, 0, colorsSize); + } + + data += pixelSize; + } + } +} + + /*-------------------------------------------------------------------*\ isAlphaUniform \*-------------------------------------------------------------------*/ @@ -1792,7 +1838,7 @@ void CBitmap::releaseMipMaps() \*-------------------------------------------------------------------*/ void CBitmap::resample(sint32 nNewWidth, sint32 nNewHeight) { - nlassert(PixelFormat == RGBA || PixelFormat == Luminance); + nlassert(PixelFormat == RGBA || PixelFormat == Luminance || PixelFormat == AlphaLuminance); bool needRebuild = false; // Deleting mipmaps @@ -1832,6 +1878,58 @@ void CBitmap::resample(sint32 nNewWidth, sint32 nNewHeight) resamplePicture8 (&_Data[0][0], pDestGray, _Width, _Height, nNewWidth, nNewHeight); //logResample("Resample: 60"); } + else if (PixelFormat == AlphaLuminance) + { + pDestui.resize(nNewWidth*nNewHeight*2); + + uint16 *pSrc = (uint16*)&_Data[0][0]; + uint16 *pDest = (uint16*)&pDestui[0]; + + size_t srcSize = _Width*_Width; + uint8 *pSrcGray = new uint8[srcSize]; + uint8 *pSrcAlpha = new uint8[srcSize]; + + // set iterators + uint16 *i = (uint16*)pSrc; + uint16 *iEnd = (uint16*)i + srcSize; + uint8 *iGray = pSrcGray; + uint8 *iAlpha = pSrcAlpha; + + // copy alpha and gray in distinct arrays + while (i < iEnd) + { + *(iGray++) = (*i) & 0xff; + *(iAlpha++) = ((*i) >> 8) & 0xff; + ++i; + } + + size_t destSize = nNewWidth*nNewHeight; + + // resample gray values array + uint8 *pDestGray = new uint8[destSize]; + resamplePicture8(pSrcGray, pDestGray, _Width, _Height, nNewWidth, nNewHeight); + delete[] pSrcGray; + + // resample alpha values array + uint8 *pDestAlpha = new uint8[destSize]; + resamplePicture8(pSrcAlpha, pDestAlpha, _Width, _Height, nNewWidth, nNewHeight); + delete[] pSrcAlpha; + + // set iterators + i = (uint16*)pDest; + iEnd = (uint16*)i + destSize; + iGray = pDestGray; + iAlpha = pDestAlpha; + + // merge alpha and gray in destination array + while (i < iEnd) + { + *(i++) = *(iGray++) | (*(iAlpha++) << 8); + } + + delete[] pDestGray; + delete[] pDestAlpha; + } NLMISC::contReset(_Data[0]); // free memory //logResample("Resample: 70"); @@ -2148,7 +2246,7 @@ void CBitmap::resamplePicture32Fast (const NLMISC::CRGBA *pSrc, NLMISC::CRGBA *p /*-------------------------------------------------------------------*\ - resamplePicture32 + resamplePicture8 \*-------------------------------------------------------------------*/ void CBitmap::resamplePicture8 (const uint8 *pSrc, uint8 *pDest, sint32 nSrcWidth, sint32 nSrcHeight, @@ -4412,6 +4510,20 @@ CRGBA CBitmap::getPixelColor(sint x, sint y, uint32 numMipMap /*=0*/) const return CRGBA::Black; } +//----------------------------------------------- +void CBitmap::setPixelColor(sint x, sint y, CRGBA c, uint32 numMipMap) +{ + nlassert(PixelFormat == RGBA); + + uint w = getWidth(numMipMap); + uint h = getHeight(numMipMap); + + if (w == 0 || x < 0 || y < 0 || x >= (sint)w || y >= (sint)h) return; + + uint8 *pix = &getPixels(numMipMap)[(x + y * w) << 2]; + + memcpy(pix, &c, sizeof(CRGBA)); +} //----------------------------------------------- void CBitmap::swap(CBitmap &other) diff --git a/code/nel/src/misc/bitmap_gif.cpp b/code/nel/src/misc/bitmap_gif.cpp index 4ae9dd0cf..653942d08 100644 --- a/code/nel/src/misc/bitmap_gif.cpp +++ b/code/nel/src/misc/bitmap_gif.cpp @@ -23,6 +23,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLMISC { @@ -61,7 +65,7 @@ static int readGIFData(GifFileType *gif, GifByteType *data, int length) } catch(...) { - nlwarning("error while reading JPEG image"); + nlwarning("error while reading GIF image"); return 0; } @@ -211,9 +215,6 @@ uint8 CBitmap::readGIF( NLMISC::IStream &f ) for (uint32 x = 0; x < width; x++) { - srcOffset++; - dstOffset+= dstChannels; - uint32 index = curFrame->RasterBits[srcOffset]; if ((sint32)index != transparency) @@ -246,6 +247,9 @@ uint8 CBitmap::readGIF( NLMISC::IStream &f ) _Data[0][dstOffset+1] = g; _Data[0][dstOffset+2] = b; _Data[0][dstOffset+3] = a; + + srcOffset++; + dstOffset+= dstChannels; } // x loop } // y loop } // pass loop @@ -258,9 +262,6 @@ uint8 CBitmap::readGIF( NLMISC::IStream &f ) uint32 dstOffset = (y + offset_y)*gif->SWidth*dstChannels + offset_x*dstChannels; for (uint32 x = 0; x < width; x++) { - srcOffset++; - dstOffset+= dstChannels; - uint32 index = curFrame->RasterBits[srcOffset]; if ((sint32)index != transparency) @@ -293,6 +294,9 @@ uint8 CBitmap::readGIF( NLMISC::IStream &f ) _Data[0][dstOffset+1] = g; _Data[0][dstOffset+2] = b; _Data[0][dstOffset+3] = a; + + srcOffset++; + dstOffset+= dstChannels; } // x loop } // y loop } diff --git a/code/nel/src/misc/bitmap_png.cpp b/code/nel/src/misc/bitmap_png.cpp index 459437f5c..2e700787c 100644 --- a/code/nel/src/misc/bitmap_png.cpp +++ b/code/nel/src/misc/bitmap_png.cpp @@ -37,8 +37,16 @@ namespace NLMISC static void readPNGData(png_structp png_ptr, png_bytep data, png_size_t length) { IStream *stream = static_cast(png_get_io_ptr(png_ptr)); - if (stream) - stream->serialBuffer((uint8*)data, (uint)length); + + try + { + if (stream) + stream->serialBuffer((uint8*)data, (uint)length); + } + catch (...) + { + png_error(png_ptr, "Read error while decoding PNG file"); + } } static void writePNGData(png_structp png_ptr, png_bytep data, png_size_t length) @@ -91,7 +99,7 @@ uint8 CBitmap::readPNG( NLMISC::IStream &f ) // free all of the memory associated with the png_ptr and info_ptr png_destroy_read_struct(&png_ptr, &info_ptr, NULL); // if we get here, we had a problem reading the file - nlwarning("failed to setjump"); + nlwarning("Error while reading PNG"); return 0; } @@ -241,6 +249,21 @@ uint8 CBitmap::readPNG( NLMISC::IStream &f ) return imageDepth; } +// small helper to avoid local variables +static bool writePNGSetJmp(png_struct *png_ptr) +{ + if (setjmp(png_jmpbuf(png_ptr))) + { + // free all of the memory associated with the png_ptr + png_destroy_write_struct(&png_ptr, (png_info**)NULL); + // if we get here, we had a problem writing the file + nlwarning("Error while writing PNG"); + return false; + } + + return true; +} + /*-------------------------------------------------------------------*\ writePNG \*-------------------------------------------------------------------*/ @@ -274,12 +297,7 @@ bool CBitmap::writePNG( NLMISC::IStream &f, uint32 d) return false; } - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct( &png_ptr, (png_info**)NULL ); - nlwarning("couldn't set setjmp"); - return false; - } + if (!writePNGSetJmp(png_ptr)) return false; // set the write function png_set_write_fn(png_ptr, (void*)&f, writePNGData, NULL); diff --git a/code/nel/src/misc/cdb.cpp b/code/nel/src/misc/cdb.cpp index 0a38dc71d..60f6801bd 100644 --- a/code/nel/src/misc/cdb.cpp +++ b/code/nel/src/misc/cdb.cpp @@ -28,6 +28,10 @@ //////////////// using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLMISC{ CStringMapper *ICDBNode::_DBSM = NULL; diff --git a/code/nel/src/misc/cdb_bank_handler.cpp b/code/nel/src/misc/cdb_bank_handler.cpp index 58843455d..78102498f 100644 --- a/code/nel/src/misc/cdb_bank_handler.cpp +++ b/code/nel/src/misc/cdb_bank_handler.cpp @@ -17,6 +17,10 @@ #include "stdmisc.h" #include "nel/misc/cdb_bank_handler.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLMISC{ CCDBBankHandler::CCDBBankHandler(uint maxbanks) : _CDBBankToUnifiedIndexMapping( maxbanks, std::vector< uint >() ), diff --git a/code/nel/src/misc/cdb_branch.cpp b/code/nel/src/misc/cdb_branch.cpp index 55b36a645..a15eac930 100644 --- a/code/nel/src/misc/cdb_branch.cpp +++ b/code/nel/src/misc/cdb_branch.cpp @@ -56,6 +56,9 @@ using namespace std; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLMISC{ @@ -207,7 +210,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, } else { - if ( _Nodes.size() > 0 ) + if (!_Nodes.empty()) for ( _IdBits=1; _Nodes.size() > unsigned(1<<_IdBits) ; _IdBits++ ) {} else _IdBits = 0; diff --git a/code/nel/src/misc/cdb_branch_observing_handler.cpp b/code/nel/src/misc/cdb_branch_observing_handler.cpp index 8e6335533..b64862a18 100644 --- a/code/nel/src/misc/cdb_branch_observing_handler.cpp +++ b/code/nel/src/misc/cdb_branch_observing_handler.cpp @@ -17,6 +17,10 @@ #include "stdmisc.h" #include "nel/misc/cdb_branch_observing_handler.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLMISC{ CCDBBranchObservingHandler::CCDBBranchObservingHandler() { diff --git a/code/nel/src/misc/cdb_check_sum.cpp b/code/nel/src/misc/cdb_check_sum.cpp index d3619299d..7ec6614b2 100644 --- a/code/nel/src/misc/cdb_check_sum.cpp +++ b/code/nel/src/misc/cdb_check_sum.cpp @@ -17,6 +17,9 @@ #include "stdmisc.h" #include "nel/misc/cdb_check_sum.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLMISC{ diff --git a/code/nel/src/misc/cdb_leaf.cpp b/code/nel/src/misc/cdb_leaf.cpp index f74fb2d3d..c996b78f3 100644 --- a/code/nel/src/misc/cdb_leaf.cpp +++ b/code/nel/src/misc/cdb_leaf.cpp @@ -35,6 +35,10 @@ //////////////// using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLMISC{ diff --git a/code/nel/src/misc/cdb_manager.cpp b/code/nel/src/misc/cdb_manager.cpp index db743416d..1b19f4141 100644 --- a/code/nel/src/misc/cdb_manager.cpp +++ b/code/nel/src/misc/cdb_manager.cpp @@ -17,6 +17,10 @@ #include "stdmisc.h" #include "nel/misc/cdb_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLMISC{ CCDBManager::CCDBManager( const char *rootNodeName, uint maxBanks ) : bankHandler( maxBanks ) diff --git a/code/nel/src/misc/check_fpu.cpp b/code/nel/src/misc/check_fpu.cpp index 0f2359eeb..0ceb3af2b 100644 --- a/code/nel/src/misc/check_fpu.cpp +++ b/code/nel/src/misc/check_fpu.cpp @@ -24,6 +24,9 @@ #pragma optimize("", off ) +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/cmd_args.cpp b/code/nel/src/misc/cmd_args.cpp index d9370b831..e6211faaf 100644 --- a/code/nel/src/misc/cmd_args.cpp +++ b/code/nel/src/misc/cmd_args.cpp @@ -141,7 +141,7 @@ bool CCmdArgs::needAdditionalArg() const const TArg &arg = _Args[i]; // they don't have any short or long name, but need a name in help - if (arg.shortName.empty() && arg.longName.empty() && !arg.helpName.empty() && arg.required) + if (arg.shortName.empty() && arg.longName.empty() && !arg.helpName.empty() && arg.required && !arg.found) return true; } @@ -363,7 +363,7 @@ bool CCmdArgs::parse(const std::vector &argv) } // process help if requested or if required arguments are missing - if (haveLongArg("help") || (needAdditionalArg() && !haveAdditionalArg())) + if (haveLongArg("help") || needAdditionalArg()) { displayHelp(); return false; @@ -418,7 +418,7 @@ void CCmdArgs::displayHelp() if (!_Description.empty()) { - printf("\n%s", _Description.c_str()); + printf("\n%s\n", _Description.c_str()); } printf("\nWhere options are:\n"); @@ -443,7 +443,6 @@ void CCmdArgs::displayHelp() if (!arg.helpName.empty()) { syntaxes.push_back(toString("-%s <%s>", arg.shortName.c_str(), arg.helpName.c_str())); - syntaxes.push_back(toString("-%s<%s>", arg.shortName.c_str(), arg.helpName.c_str())); } else { @@ -459,12 +458,6 @@ void CCmdArgs::displayHelp() // display first syntax for long argument, --arg syntaxes.push_back(toString("--%s <%s>", arg.longName.c_str(), arg.helpName.c_str())); } - - if (!arg.helpName.empty()) - { - // display second syntax for long argument, --arg= - syntaxes.push_back(toString("--%s=<%s>", arg.longName.c_str(), arg.helpName.c_str())); - } else { syntaxes.push_back(toString("--%s", arg.longName.c_str())); diff --git a/code/nel/src/misc/co_task.cpp b/code/nel/src/misc/co_task.cpp index 97a9e1e23..f817e3a5f 100644 --- a/code/nel/src/misc/co_task.cpp +++ b/code/nel/src/misc/co_task.cpp @@ -213,6 +213,16 @@ namespace NLMISC return _ThreadMainFiber.getPointer(); } #endif + + static void releaseInstance() + { + if (_Instance) + { + NLMISC::INelContext::getInstance().releaseSingletonPointer("CCurrentCoTask", _Instance); + delete _Instance; + _Instance = NULL; + } + } }; NLMISC_SAFE_SINGLETON_IMPL(CCurrentCoTask); @@ -560,5 +570,10 @@ namespace NLMISC } } + void CCoTask::releaseInstance() + { + CCurrentCoTask::releaseInstance(); + } + } // namespace NLMISC diff --git a/code/nel/src/misc/command.cpp b/code/nel/src/misc/command.cpp index 30e3defe2..a3d9d79ed 100644 --- a/code/nel/src/misc/command.cpp +++ b/code/nel/src/misc/command.cpp @@ -666,7 +666,7 @@ NLMISC_CATEGORISED_COMMAND(nel,help,"display help on a specific variable/command CCommandRegistry &cr = CCommandRegistry::getInstance(); // treat the case where we have no parameters - if (args.size() == 0) + if (args.empty()) { // display a list of all command categories log.displayNL("Help commands:"); diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 5954ac9c9..db605f4f1 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -82,6 +82,31 @@ extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource ); } #if defined(NL_HAS_SSE2) && !defined(NL_CPU_X86_64) +#ifdef NL_NO_EXCEPTION_SPECS +void *operator new(size_t size) +{ + void *p = aligned_malloc(size, NL_DEFAULT_MEMORY_ALIGNMENT); + if (p == NULL) throw std::bad_alloc(); + return p; +} + +void *operator new[](size_t size) +{ + void *p = aligned_malloc(size, NL_DEFAULT_MEMORY_ALIGNMENT); + if (p == NULL) throw std::bad_alloc(); + return p; +} + +void operator delete(void *p) noexcept +{ + aligned_free(p); +} + +void operator delete[](void *p) noexcept +{ + aligned_free(p); +} +#else void *operator new(size_t size) throw(std::bad_alloc) { void *p = aligned_malloc(size, NL_DEFAULT_MEMORY_ALIGNMENT); @@ -105,6 +130,7 @@ void operator delete[](void *p) throw() { aligned_free(p); } +#endif #endif /* NL_HAS_SSE2 */ @@ -523,7 +549,7 @@ std::string timestampToHumanReadable(uint32 timestamp) uint32 fromHumanReadable (const std::string &str) { - if (str.size() == 0) + if (str.empty()) return 0; uint32 val; @@ -607,7 +633,7 @@ void toLower(char *str) } } -std::string toUpper(const std::string &str) +std::string toUpper(const std::string &str) { string res; res.reserve(str.size()); @@ -621,7 +647,7 @@ std::string toUpper(const std::string &str) return res; } -void toUpper(char *str) +void toUpper(char *str) { if (str == 0) return; @@ -636,6 +662,109 @@ void toUpper(char *str) } } +std::string toHexa(const uint8 &b) +{ + return toString("%02hhx", b); +} + +std::string toHexa(const uint8 *data, uint size) +{ + std::string res; + + // hexadecimal string will be always twice the original size + res.reserve(size * 2); + + // process each byte + for (uint i = 0; i < size; ++i) + { + res += toHexa(data[i]); + } + + return res; +} + +std::string toHexa(const std::string &str) +{ + return toHexa((uint8*)str.c_str(), (uint)str.length()); +} + +std::string toHexa(const char *str) +{ + return toHexa((uint8*)str, (uint)strlen(str)); +} + +bool fromHexa(const std::string &hexa, uint8 &b) +{ + return fromHexa(hexa.c_str(), b); +} + +bool fromHexa(const std::string &hexa, uint8 *data) +{ + return fromHexa(hexa.c_str(), data); +} + +bool fromHexa(const std::string &hexa, std::string &str) +{ + return fromHexa(hexa.c_str(), str); +} + +bool fromHexa(const char *hexa, uint8 &b) +{ + char c1 = *hexa; + char c2 = *(hexa+1); + uint8 x1, x2; + if (!fromHexa(c1, x1)) return false; + if (!fromHexa(c2, x2)) return false; + + b = (x1 << 4) | x2; + + return true; +} + +bool fromHexa(const char *hexa, uint8 *data) +{ + // length of the string + uint len = strlen(hexa); + + // process each byte + for (uint i = 0; i < len; i += 2) + { + if (!fromHexa(hexa + i, *(data++))) return false; + } + + return true; +} + +bool fromHexa(const char *hexa, std::string &str) +{ + str.resize(strlen(hexa) * 2); + + return fromHexa(hexa, (uint8*)str.c_str()); +} + +bool fromHexa(const char hexa, uint8 &b) +{ + if (hexa >= '0' && hexa <= '9') + { + b = hexa - '0'; + return true; + } + + if (hexa >= 'A' && hexa <= 'F') + { + b = hexa - 'A' + 10; + return true; + } + + if (hexa >= 'a' && hexa <= 'f') + { + b = hexa - 'a' + 10; + return true; + } + + return false; +} + std::string formatThousands(const std::string& s) { sint i, k; @@ -761,10 +890,12 @@ static bool createProcess(const std::string &programName, const std::string &arg sProgramName = new wchar_t[MAX_PATH]; wcscpy(sProgramName, (wchar_t*)ucProgramName.c_str()); - args = arguments; + // important! we need to specify the executable full path as first argument + args = toString("\"%s\" ", programName.c_str()) + arguments; } - BOOL res = CreateProcessW(sProgramName, utf8ToWide(args), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL, &si, &pi); + // or 0 for a window + BOOL res = CreateProcessW(sProgramName, utf8ToWide(args), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL /* current dir */, &si, &pi); if (sProgramName) { @@ -866,8 +997,8 @@ bool launchProgram(const std::string &programName, const std::string &arguments, int status = vfork (); ///////////////////////////////////////////////////////// - /// WARNING : NO MORE INSTRUCTION AFTER VFORK ! - /// READ VFORK manual + // WARNING : NO MORE INSTRUCTION AFTER VFORK ! + // READ VFORK manual ///////////////////////////////////////////////////////// if (status == -1) { @@ -972,8 +1103,8 @@ bool launchProgramArray (const std::string &programName, const std::vector &args) return res; } +std::string escapeArgument(const std::string &arg) +{ +#ifdef NL_OS_WINDOWS + // we can't escape %VARIABLE% on command-line under Windows + return arg; +#else + // characters to escape, only " and $ (to prevent a $something replaced by an environment variable) + static const char s_charsToEscape[] = "\"$"; + + std::string res; + std::string::size_type pos = 0, lastPos = 0; + + // to avoid reallocations + res.reserve(arg.size() * 2); + + while ((pos = arg.find_first_of(s_charsToEscape, lastPos)) != std::string::npos) + { + // add previous part + res += arg.substr(lastPos, pos - lastPos); + + // not already escaped + if (!pos || arg[pos - 1] != '\\') res += '\\'; + + // add escaped character + res += arg[pos]; + + lastPos = pos+1; + } + + res += arg.substr(lastPos); + + return res; +#endif +} + /* * Display the bits (with 0 and 1) composing a byte (from right to left) */ @@ -1416,17 +1594,17 @@ NLMISC_CATEGORISED_COMMAND(nel, killProgram, "kill a program given the pid", "

31); + // create process + PROCESS_INFORMATION pi; + return createProcess(program, document, false, pi); } } } @@ -1488,7 +1670,7 @@ static bool openDocWithExtension (const char *document, const char *ext) return true; } #elif defined(NL_OS_MAC) - CFURLRef url = CFURLCreateWithBytes(NULL, (const UInt8 *)document, strlen(document), kCFStringEncodingUTF8, NULL); + CFURLRef url = CFURLCreateWithBytes(NULL, (const UInt8 *)document.c_str(), document.length(), kCFStringEncodingUTF8, NULL); if (url) { @@ -1497,7 +1679,7 @@ static bool openDocWithExtension (const char *document, const char *ext) if (res != 0) { - nlwarning("LSOpenCFURLRef %s returned %d", document, (sint)res); + nlwarning("LSOpenCFURLRef %s returned %d", document.c_str(), (sint)res); return false; } @@ -1505,7 +1687,7 @@ static bool openDocWithExtension (const char *document, const char *ext) } else { - nlwarning("Unable to create URL from %s", document); + nlwarning("Unable to create URL from %s", document.c_str()); return false; } #else @@ -1513,7 +1695,7 @@ static bool openDocWithExtension (const char *document, const char *ext) if (!CFile::fileExists(command)) { - if (strcmp(ext, "htm") == 0) + if (ext == "htm") { command = "/etc/alternatives/x-www-browser"; @@ -1530,7 +1712,7 @@ static bool openDocWithExtension (const char *document, const char *ext) if (command.empty()) { - nlwarning("Unable to open %s", document); + nlwarning("Unable to open %s", document.c_str()); return false; } @@ -1551,18 +1733,18 @@ static bool openDocWithExtension (const char *document, const char *ext) return false; } -bool openURL (const char *url) +bool openURL(const std::string &url) { return openDocWithExtension(url, "htm"); } -bool openDoc (const char *document) +bool openDoc(const std::string &document) { // get extension from document fullpath string ext = CFile::getExtension(document); // try to open document - return openDocWithExtension(document, ext.c_str()); + return openDocWithExtension(document, ext); } } // NLMISC diff --git a/code/nel/src/misc/config_file/cf_gramatical.cpp b/code/nel/src/misc/config_file/cf_gramatical.cpp index 1d8c568b7..d386b72ad 100644 --- a/code/nel/src/misc/config_file/cf_gramatical.cpp +++ b/code/nel/src/misc/config_file/cf_gramatical.cpp @@ -50,6 +50,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + /* Constantes */ #define YYPARSE_PARAM pvararray diff --git a/code/nel/src/misc/config_file/cf_lexical.cpp b/code/nel/src/misc/config_file/cf_lexical.cpp index 8c39112a6..fd43a03ce 100644 --- a/code/nel/src/misc/config_file/cf_lexical.cpp +++ b/code/nel/src/misc/config_file/cf_lexical.cpp @@ -1938,6 +1938,10 @@ char *yytext; using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + /* Constantes */ // WARNING!!!! DEBUG_PRINTF are commented using // so IT MUST HAVE NO INSTRUCTION AFTER A DEBUG_PRINTF OR THEY LL BE COMMENTED diff --git a/code/nel/src/misc/config_file/config_file.cpp b/code/nel/src/misc/config_file/config_file.cpp index bab1c123b..b1ef3bef6 100644 --- a/code/nel/src/misc/config_file/config_file.cpp +++ b/code/nel/src/misc/config_file/config_file.cpp @@ -412,7 +412,7 @@ void CConfigFile::reparse (bool lookupPaths) if (!CPath::lookup(fn, false).empty()) { ucstring content; - CI18N::readTextFile(fn, content, true, true, true); + CI18N::readTextFile(fn, content, true, true); string utf8 = content.toUtf8(); CMemStream stream; diff --git a/code/nel/src/misc/contiguous_block_allocator.cpp b/code/nel/src/misc/contiguous_block_allocator.cpp index 6db4b0d63..b99c6b090 100644 --- a/code/nel/src/misc/contiguous_block_allocator.cpp +++ b/code/nel/src/misc/contiguous_block_allocator.cpp @@ -90,7 +90,7 @@ void *CContiguousBlockAllocator::alloc(uint numBytes) } // ********************************************************************************************************* -void CContiguousBlockAllocator::free(void *block, uint numBytes) +void CContiguousBlockAllocator::freeBlock(void *block, uint numBytes) { if (!block) return; #ifdef NL_DEBUG diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 1f0bb4fd1..c6d10b700 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -23,7 +23,9 @@ # include # include # pragma comment(lib, "imagehlp.lib") -# define getcwd(_a, _b) (_getcwd(_a,_b)) +# ifndef getcwd +# define getcwd(_a, _b) (_getcwd(_a,_b)) +# endif # ifdef NL_OS_WIN64 # define DWORD_TYPE DWORD64 # else @@ -178,7 +180,7 @@ void nlFatalError (const char *format, ...) char *str; NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/); - INelContext::getInstance().setDebugNeedAssert( NLMISC::DefaultMsgBoxDisplayer==0 ); + INelContext::getInstance().setDebugNeedAssert( NLMISC::DefaultMsgBoxDisplayer == NULL ); NLMISC::ErrorLog->displayNL (str); @@ -197,7 +199,7 @@ void nlError (const char *format, ...) char *str; NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/); - INelContext::getInstance().setDebugNeedAssert( NLMISC::DefaultMsgBoxDisplayer==0 ); + INelContext::getInstance().setDebugNeedAssert( NLMISC::DefaultMsgBoxDisplayer == NULL ); NLMISC::ErrorLog->displayNL (str); @@ -453,7 +455,7 @@ public: string shortExc, longExc, subject; string addr, ext; ULONG_PTR skipNFirst = 0; - _Reason = ""; + _Reason.clear(); if (m_pexp == NULL) { @@ -491,25 +493,25 @@ public: case EXCEPTION_STACK_OVERFLOW : shortExc="Stack Overflow"; longExc="Stack overflow. Can occur during errant recursion, or when a function creates a particularly large array on the stack"; break; case EXCEPTION_INVALID_DISPOSITION : shortExc="Invalid Disposition"; longExc="Whatever number the exception filter returned, it wasn't a value the OS knows about"; break; case EXCEPTION_GUARD_PAGE : shortExc="Guard Page"; longExc="Memory Allocated as PAGE_GUARD by VirtualAlloc() has been accessed"; break; - case EXCEPTION_INVALID_HANDLE : shortExc="Invalid Handle"; longExc=""; break; + case EXCEPTION_INVALID_HANDLE : shortExc="Invalid Handle"; longExc.clear(); break; case CONTROL_C_EXIT : shortExc="Control-C"; longExc="Lets the debugger know the user hit Ctrl-C. Seemingly for console apps only"; break; case STATUS_NO_MEMORY : shortExc="No Memory"; longExc="Called by HeapAlloc() if you specify HEAP_GENERATE_EXCEPTIONS and there is no memory or heap corruption"; ext = ", unable to allocate "; ext += toString ("%d bytes", m_pexp->ExceptionRecord->ExceptionInformation [0]); break; - case STATUS_WAIT_0 : shortExc="Wait 0"; longExc=""; break; - case STATUS_ABANDONED_WAIT_0 : shortExc="Abandoned Wait 0"; longExc=""; break; + case STATUS_WAIT_0 : shortExc="Wait 0"; longExc.clear(); break; + case STATUS_ABANDONED_WAIT_0 : shortExc="Abandoned Wait 0"; longExc.clear(); break; case STATUS_USER_APC : shortExc="User APC"; longExc="A user APC was delivered to the current thread before the specified Timeout interval expired"; break; - case STATUS_TIMEOUT : shortExc="Timeout"; longExc=""; break; - case STATUS_PENDING : shortExc="Pending"; longExc=""; break; - case STATUS_SEGMENT_NOTIFICATION : shortExc="Segment Notification"; longExc=""; break; - case STATUS_FLOAT_MULTIPLE_FAULTS : shortExc="Float Multiple Faults"; longExc=""; break; - case STATUS_FLOAT_MULTIPLE_TRAPS : shortExc="Float Multiple Traps"; longExc=""; break; + case STATUS_TIMEOUT : shortExc="Timeout"; longExc.clear(); break; + case STATUS_PENDING : shortExc="Pending"; longExc.clear(); break; + case STATUS_SEGMENT_NOTIFICATION : shortExc="Segment Notification"; longExc.clear(); break; + case STATUS_FLOAT_MULTIPLE_FAULTS : shortExc="Float Multiple Faults"; longExc.clear(); break; + case STATUS_FLOAT_MULTIPLE_TRAPS : shortExc="Float Multiple Traps"; longExc.clear(); break; #ifdef NL_COMP_VC6 - case STATUS_ILLEGAL_VLM_REFERENCE : shortExc="Illegal VLM Reference"; longExc=""; break; + case STATUS_ILLEGAL_VLM_REFERENCE : shortExc="Illegal VLM Reference"; longExc.clear(); break; #endif case 0xE06D7363 : shortExc="Microsoft C++ Exception"; longExc="Microsoft C++ Exception"; break; // cpp exception - case 0xACE0ACE : shortExc=""; longExc=""; + case 0xACE0ACE : shortExc.clear(); longExc.clear(); if (m_pexp->ExceptionRecord->NumberParameters == 1) skipNFirst = m_pexp->ExceptionRecord->ExceptionInformation [0]; break; // just want the stack @@ -824,7 +826,7 @@ public: // replace param with the value of the stack for this param string parse = str; - str = ""; + str.clear(); uint pos2 = 0; sint stop = 0; @@ -943,7 +945,7 @@ public: str += tmp; } str += parse[i]; - type = ""; + type.clear(); } else { @@ -1429,22 +1431,27 @@ int getLastError() std::string formatErrorMessage(int errorCode) { #ifdef NL_OS_WINDOWS - LPVOID lpMsgBuf; - FormatMessage( + LPVOID lpMsgBuf = NULL; + DWORD len = FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, + (LPWSTR) &lpMsgBuf, 0, NULL ); - string ret = (char*)lpMsgBuf; + // empty buffer, an error occurred + if (len == 0) return toString("FormatMessage returned error %d", getLastError()); + + // convert wchar_t* to std::string + string ret = wideToUtf8(lpMsgBuf); + // Free the buffer. - LocalFree( lpMsgBuf ); + LocalFree(lpMsgBuf); return ret; #else @@ -1497,7 +1504,7 @@ NLMISC_CATEGORISED_COMMAND(nel, displayMemlog, "displays the last N line of the { uint nbLines; - if (args.size() == 0) nbLines = 100; + if (args.empty()) nbLines = 100; else if (args.size() == 1) NLMISC::fromString(args[0], nbLines); else return false; @@ -1521,7 +1528,7 @@ NLMISC_CATEGORISED_COMMAND(nel, displayMemlog, "displays the last N line of the NLMISC_CATEGORISED_COMMAND(nel, resetFilters, "disable all filters on Nel loggers", "[debug|info|warning|error|assert]") { - if(args.size() == 0) + if(args.empty()) { DebugLog->resetFilters(); InfoLog->resetFilters(); @@ -1561,7 +1568,7 @@ NLMISC_CATEGORISED_COMMAND(nel, addNegativeFilterDebug, "add a negative filter o NLMISC_CATEGORISED_COMMAND(nel, removeFilterDebug, "remove a filter on DebugLog", "[]") { - if(args.size() == 0) + if(args.empty()) DebugLog->removeFilter(); else if(args.size() == 1) DebugLog->removeFilter( args[0].c_str() ); @@ -1571,7 +1578,7 @@ NLMISC_CATEGORISED_COMMAND(nel, removeFilterDebug, "remove a filter on DebugLog" NLMISC_CATEGORISED_COMMAND(nel, displayFilterDebug, "display filter on DebugLog", "") { - if(args.size() != 0) return false; + if(!args.empty()) return false; DebugLog->displayFilter(log); return true; } @@ -1592,7 +1599,7 @@ NLMISC_CATEGORISED_COMMAND(nel, addNegativeFilterInfo, "add a negative filter on NLMISC_CATEGORISED_COMMAND(nel, removeFilterInfo, "remove a filter on InfoLog", "[]") { - if(args.size() == 0) + if(args.empty()) InfoLog->removeFilter(); else if(args.size() == 1) InfoLog->removeFilter( args[0].c_str() ); @@ -1639,7 +1646,7 @@ NLMISC_CATEGORISED_COMMAND(nel, addNegativeFilterWarning, "add a negative filter NLMISC_CATEGORISED_COMMAND(nel, removeFilterWarning, "remove a filter on WarningLog", "[]") { - if(args.size() == 0) + if(args.empty()) WarningLog->removeFilter(); else if(args.size() == 1) WarningLog->removeFilter( args[0].c_str() ); @@ -1649,7 +1656,7 @@ NLMISC_CATEGORISED_COMMAND(nel, removeFilterWarning, "remove a filter on Warning NLMISC_CATEGORISED_COMMAND(nel, displayFilterWarning, "display filter on WarningLog", "") { - if(args.size() != 0) return false; + if(!args.empty()) return false; WarningLog->displayFilter(log); return true; } diff --git a/code/nel/src/misc/diff_tool.cpp b/code/nel/src/misc/diff_tool.cpp index f57746b1a..2b2a490bc 100644 --- a/code/nel/src/misc/diff_tool.cpp +++ b/code/nel/src/misc/diff_tool.cpp @@ -117,7 +117,7 @@ bool loadStringFile(const std::string filename, vector &stringInfos */ ucstring text; - CI18N::readTextFile(filename, text, false, false, true, CI18N::LINE_FMT_CRLF); + CI18N::readTextFile(filename, text, false, true, CI18N::LINE_FMT_LF); // CI18N::readTextBuffer(buffer, size, text); // delete [] buffer; @@ -154,7 +154,7 @@ bool loadStringFile(const std::string filename, vector &stringInfos if (!CI18N::parseLabel(first, last, si.Identifier)) { uint32 line = countLine(text, first); - nlwarning("DT: Fatal : In '%s', line %u: Invalid label after '%s'\n", + nlwarning("DT: Fatal : In '%s', line %u: Invalid label after '%s'", filename.c_str(), line, lastLabel.c_str()); @@ -167,7 +167,7 @@ bool loadStringFile(const std::string filename, vector &stringInfos if (!CI18N::parseMarkedString(openMark, closeMark, first, last, si.Text)) { uint32 line = countLine(text, first); - nlwarning("DT: Fatal : In '%s', line %u: Invalid text value for label %s\n", + nlwarning("DT: Fatal : In '%s', line %u: Invalid text value for label %s", filename.c_str(), line, lastLabel.c_str()); @@ -181,7 +181,7 @@ bool loadStringFile(const std::string filename, vector &stringInfos if (!CI18N::parseMarkedString(openMark, closeMark, first, last, si.Text2)) { uint32 line = countLine(text, first); - nlwarning("DT: Fatal: In '%s' line %u: Invalid text2 value label %s\n", + nlwarning("DT: Fatal: In '%s' line %u: Invalid text2 value label %s", filename.c_str(), line, lastLabel.c_str()); @@ -313,7 +313,7 @@ bool readPhraseFile(const std::string &filename, vector &phrases, bool { ucstring doc; - CI18N::readTextFile(filename, doc, false, false, true, CI18N::LINE_FMT_CRLF); + CI18N::readTextFile(filename, doc, false, true, CI18N::LINE_FMT_LF); return readPhraseFileFromString(doc, filename, phrases, forceRehash); } @@ -416,9 +416,14 @@ bool readPhraseFileFromString(ucstring const& doc, const std::string &filename, phrase.Clauses.size()+1); return false; } - clause.Conditions += "(" + cond + ") "; + + // only prepend a space if required + if (!clause.Conditions.empty()) clause.Conditions += " "; + + clause.Conditions += "(" + cond + ")"; CI18N::skipWhiteSpace(first, last, &clause.Comments); } + if (first == last) { nlwarning("DT: in '%s': Found end of file in non closed block for phrase %s\n", @@ -577,7 +582,7 @@ ucstring preparePhraseFile(const vector &phrases, bool removeDiffCommen if (!c.Comments.empty()) { ucstring comment = tabLines(1, c.Comments); - ret += comment; // + '\r'+'\n'; + ret += comment; // + '\n'; } if (!c.Conditions.empty()) { @@ -626,7 +631,7 @@ bool loadExcelSheet(const string filename, TWorksheet &worksheet, bool checkUniq fp.close(); ucstring str; - CI18N::readTextFile(filename, str, false, false, false, CI18N::LINE_FMT_CRLF); + CI18N::readTextFile(filename, str, false, false, CI18N::LINE_FMT_LF); if (!readExcelSheet(str, worksheet, checkUnique)) return false; @@ -646,6 +651,8 @@ bool readExcelSheet(const ucstring &str, TWorksheet &worksheet, bool checkUnique strArray[strArray.size()-1]= 0; memcpy(&strArray[0], &str[0], str.size()*sizeof(ucchar)); + // size of new line characters + size_t sizeOfNl = nl.length(); // **** Build array of lines. just point to strArray, and fill 0 where appropriated vector lines; @@ -660,10 +667,10 @@ bool readExcelSheet(const ucstring &str, TWorksheet &worksheet, bool checkUnique // nldebug("Found line : [%s]", ucstring(&strArray[lastPos]).toString().c_str()); lines.push_back(&strArray[lastPos]); } - lastPos = pos + 2; + lastPos = pos + sizeOfNl; } - // Must add last line if no \r\n ending + // Must add last line if no \n ending if (lastPos < str.size()) { pos= str.size(); diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 798a4f80a..8feaa9358 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -495,15 +495,30 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes if (_NeedHeader) { const char *hs = HeaderString(); - fwrite (hs, strlen (hs), 1, _FilePointer); + + if (fwrite(hs, strlen(hs), 1, _FilePointer) != 1) + { + printf("Unable to write header: %s\n", hs); + } + _NeedHeader = false; } - if(!str.empty()) - fwrite (str.c_str(), str.size(), 1, _FilePointer); + if (!str.empty()) + { + if (fwrite(str.c_str(), str.size(), 1, _FilePointer) != 1) + { + printf("Unable to write string: %s\n", str.c_str()); + } + } - if(!args.CallstackAndLog.empty()) - fwrite (args.CallstackAndLog.c_str(), args.CallstackAndLog.size (), 1, _FilePointer); + if (!args.CallstackAndLog.empty()) + { + if (fwrite(args.CallstackAndLog.c_str(), args.CallstackAndLog.size(), 1, _FilePointer) != 1) + { + printf("Unable to write call stack: %s\n", args.CallstackAndLog.c_str()); + } + } fflush (_FilePointer); } diff --git a/code/nel/src/misc/dynloadlib.cpp b/code/nel/src/misc/dynloadlib.cpp index fadf2e249..66f774fa2 100644 --- a/code/nel/src/misc/dynloadlib.cpp +++ b/code/nel/src/misc/dynloadlib.cpp @@ -255,7 +255,7 @@ void CLibrary::freeLibrary() _PureNelLibrary = NULL; _LibHandle = NULL; _Ownership = false; - _LibFileName = ""; + _LibFileName.clear(); } } diff --git a/code/nel/src/misc/eid_translator.cpp b/code/nel/src/misc/eid_translator.cpp index 591b9db7a..0d126de50 100644 --- a/code/nel/src/misc/eid_translator.cpp +++ b/code/nel/src/misc/eid_translator.cpp @@ -587,10 +587,10 @@ void CEntityIdTranslator::getEntityIdInfo (const CEntityId &eid, ucstring &entit if (it == RegisteredEntities.end ()) { nlwarning ("EIT: %s is not registered in CEntityIdTranslator", reid.toString().c_str()); - entityName = ""; + entityName.clear(); entitySlot = -1; uid = std::numeric_limits::max(); - userName = ""; + userName.clear(); online = false; } else diff --git a/code/nel/src/misc/eval_num_expr.cpp b/code/nel/src/misc/eval_num_expr.cpp index 1bfad17eb..42298c1fa 100644 --- a/code/nel/src/misc/eval_num_expr.cpp +++ b/code/nel/src/misc/eval_num_expr.cpp @@ -632,6 +632,9 @@ CEvalNumExpr::TReturnState CEvalNumExpr::evalExpression (double &finalResult, TT TOperator resultUnaryOp[InternalOperator]; vector resultUnaryOpSup; + // init table + for (uint i = 0; i < (uint)InternalOperator; ++i) resultUnaryOp[i] = NotOperator; + // Current value double value; diff --git a/code/nel/src/misc/event_emitter.cpp b/code/nel/src/misc/event_emitter.cpp deleted file mode 100644 index 0cf3aad72..000000000 --- a/code/nel/src/misc/event_emitter.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -// remove stupid VC6 warnings -void foo_event_emitter_cpp() {} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - -} // NLMISC diff --git a/code/nel/src/misc/fast_id_map.cpp b/code/nel/src/misc/fast_id_map.cpp deleted file mode 100644 index 5ba919b09..000000000 --- a/code/nel/src/misc/fast_id_map.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/** - * \file fast_id_map.cpp - * \brief CFastIdMap - * \date 2012-04-10 19:28GMT - * \author Jan Boon (Kaetemi) - * CFastIdMap - */ - -/* - * Copyright (C) 2012 by authors - * - * This file is part of RYZOM CORE. - * RYZOM CORE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * RYZOM CORE is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with RYZOM CORE. If not, see - * . - */ - -#include -#include - -// STL includes - -// NeL includes -// #include - -// Project includes - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - -void dummytoavoidthecompilerwarningfastidmap() { } - -} /* namespace NLMISC */ - -/* end of file */ diff --git a/code/nel/src/misc/file.cpp b/code/nel/src/misc/file.cpp index 01c417635..727c02f83 100644 --- a/code/nel/src/misc/file.cpp +++ b/code/nel/src/misc/file.cpp @@ -550,7 +550,6 @@ uint CIFile::getDbgStreamSize() const COFile::COFile() : IStream(false) { _F=NULL; - _FileName = ""; } // ====================================================================================================== diff --git a/code/nel/src/misc/fixed_size_allocator.cpp b/code/nel/src/misc/fixed_size_allocator.cpp index 30693ddfd..6ec664db4 100644 --- a/code/nel/src/misc/fixed_size_allocator.cpp +++ b/code/nel/src/misc/fixed_size_allocator.cpp @@ -73,7 +73,7 @@ void *CFixedSizeAllocator::alloc() #define aligned_offsetof(s, m) ((offsetof(s, m) + (NL_DEFAULT_MEMORY_ALIGNMENT - 1)) & ~(NL_DEFAULT_MEMORY_ALIGNMENT - 1)) // ***************************************************************************************************************** -void CFixedSizeAllocator::free(void *block) +void CFixedSizeAllocator::freeBlock(void *block) { if (!block) return; /// get the node from the object diff --git a/code/nel/src/misc/geom_ext.cpp b/code/nel/src/misc/geom_ext.cpp deleted file mode 100644 index 32dba1d60..000000000 --- a/code/nel/src/misc/geom_ext.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/geom_ext.h" - - -// leave not static else this workaround don't work -void dummyToAvoidStupidCompilerWarning_misc_geom_ext_cpp() -{ -} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC -{ - - - -} // NLMISC diff --git a/code/nel/src/misc/heap_memory.cpp b/code/nel/src/misc/heap_memory.cpp index 0c3918ba0..89ce75e50 100644 --- a/code/nel/src/misc/heap_memory.cpp +++ b/code/nel/src/misc/heap_memory.cpp @@ -165,7 +165,7 @@ void *CHeapMemory::allocate(uint size) } // *************************************************************************** -void CHeapMemory::free(void *ptr) +void CHeapMemory::freeBlock(void *ptr) { if(ptr==NULL) return; diff --git a/code/nel/src/misc/hierarchical_timer.cpp b/code/nel/src/misc/hierarchical_timer.cpp index 62dc0786a..55eba958a 100644 --- a/code/nel/src/misc/hierarchical_timer.cpp +++ b/code/nel/src/misc/hierarchical_timer.cpp @@ -521,7 +521,7 @@ void CHTimer::displayByExecutionPath(CLog *log, TSortCriterion criterion, bool std::copy(currTimer->_Name, currTimer->_Name + (endIndex - startIndex), resultName.begin() + startIndex); } TNodeVect &execNodes = nodeMap[currTimer]; - if (execNodes.size() > 0) + if (!execNodes.empty()) { currNodeStats.buildFromNodes(&execNodes[0], (uint)execNodes.size(), _MsPerTick); currNodeStats.getStats(resultStats, displayEx, rootStats.TotalTime, _WantStandardDeviation); @@ -1082,7 +1082,7 @@ NLMISC_CATEGORISED_COMMAND(nel,displayMeasures, "display hierarchical timer", "[ } sint depth = 0; - bool hasDepth = (sscanf(args[0].c_str(), "%d", &depth) == 1 || (args.size() > 1 && sscanf(args[1].c_str(), "%d", &depth) == 1)); + bool hasDepth = (fromString(args[0], depth) || (args.size() > 1 && fromString(args[1], depth))); CASE_DISPLAYMEASURES(NoSort, -3) CASE_DISPLAYMEASURES(TotalTime, -2) diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index b64116c1c..f61bcddf6 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -502,25 +502,39 @@ void CI18N::skipWhiteSpace(ucstring::const_iterator &it, ucstring::const_iterato if (storeComments && *it == '/' && it+1 != last && *(it+1) == '/') { // found a one line C comment. Store it until end of line. - while (it != last && *it != '\n') + while (it != last && (*it != '\n' && *it != '\r')) storeComments->push_back(*it++); + // store the final '\n' if (it != last) - storeComments->push_back(*it++); + storeComments->push_back('\n'); } else if (storeComments && *it == '/' && it+1 != last && *(it+1) == '*') { // found a multi line C++ comment. store until we found the closing '*/' - while (it != last && !(*it == '*' && it+1 != last && *(it+1) == '/')) - storeComments->push_back(*it++); + while (it != last && !(*it == '*' && it + 1 != last && *(it + 1) == '/')) + { + // don't put \r + if (*it == '\r') + { + // skip it + ++it; + } + else + { + storeComments->push_back(*it++); + } + } + // store the final '*' if (it != last) storeComments->push_back(*it++); + // store the final '/' if (it != last) storeComments->push_back(*it++); + // and a new line. - storeComments->push_back('\r'); storeComments->push_back('\n'); } else @@ -656,7 +670,6 @@ bool CI18N::parseMarkedString(ucchar openMark, ucchar closeMark, ucstring::const void CI18N::readTextFile(const string &filename, ucstring &result, - bool forceUtf8, bool fileLookup, bool preprocess, TLineFormat lineFmt, @@ -666,7 +679,7 @@ void CI18N::readTextFile(const string &filename, TReadContext readContext; // call the inner function - _readTextFile(filename, result, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); + _readTextFile(filename, result, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); if (!readContext.IfStack.empty()) { @@ -709,7 +722,6 @@ void CI18N::skipLine(ucstring::const_iterator &it, ucstring::const_iterator end, void CI18N::_readTextFile(const string &filename, ucstring &result, - bool forceUtf8, bool fileLookup, bool preprocess, TLineFormat lineFmt, @@ -743,7 +755,7 @@ void CI18N::_readTextFile(const string &filename, // Transform the string in ucstring according to format header if (!text.empty()) - readTextBuffer((uint8*)&text[0], (uint)text.size(), result, forceUtf8); + readTextBuffer((uint8*)&text[0], (uint)text.size(), result); if (preprocess) { @@ -819,7 +831,7 @@ void CI18N::_readTextFile(const string &filename, subFilename.c_str()); ucstring inserted; - _readTextFile(subFilename, inserted, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); + _readTextFile(subFilename, inserted, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); final += inserted; } } @@ -873,7 +885,7 @@ void CI18N::_readTextFile(const string &filename, subFilename.c_str()); ucstring inserted; - _readTextFile(subFilename, inserted, forceUtf8, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); + _readTextFile(subFilename, inserted, fileLookup, preprocess, lineFmt, warnIfIncludesNotFound, readContext); final += inserted; } } @@ -1109,7 +1121,7 @@ void CI18N::_readTextFile(const string &filename, temp.append(result.begin()+lastPos, result.end()); result.swap(temp); - temp = ""; + temp.clear(); // second loop with the '\n' pos = 0; @@ -1137,28 +1149,13 @@ void CI18N::_readTextFile(const string &filename, } } -void CI18N::readTextBuffer(uint8 *buffer, uint size, ucstring &result, bool forceUtf8) +void CI18N::readTextBuffer(uint8 *buffer, uint size, ucstring &result) { static uint8 utf16Header[] = { 0xffu, 0xfeu }; static uint8 utf16RevHeader[] = { 0xfeu, 0xffu }; static uint8 utf8Header[] = { 0xefu, 0xbbu, 0xbfu }; - if (forceUtf8) - { - if (size>=3 && - buffer[0]==utf8Header[0] && - buffer[1]==utf8Header[1] && - buffer[2]==utf8Header[2] - ) - { - // remove utf8 header - buffer+= 3; - size-=3; - } - string text((char*)buffer, size); - result.fromUtf8(text); - } - else if (size>=3 && + if (size>=3 && buffer[0]==utf8Header[0] && buffer[1]==utf8Header[1] && buffer[2]==utf8Header[2] @@ -1211,10 +1208,9 @@ void CI18N::readTextBuffer(uint8 *buffer, uint size, ucstring &result, bool forc } else { - // hum.. ascii read ? - // so, just do a direct conversion + // all text files without BOM are now parsed as UTF-8 by default string text((char*)buffer, size); - result = text; + result.fromUtf8(text); } } diff --git a/code/nel/src/misc/i_xml.cpp b/code/nel/src/misc/i_xml.cpp index fbd8f5d9f..ae5c8615e 100644 --- a/code/nel/src/misc/i_xml.cpp +++ b/code/nel/src/misc/i_xml.cpp @@ -17,7 +17,6 @@ #include "stdmisc.h" #include "nel/misc/i_xml.h" -#include "nel/misc/sstring.h" #ifndef NL_DONT_USE_EXTERNAL_CODE @@ -39,6 +38,10 @@ namespace NLMISC const char SEPARATOR = ' '; +std::string CIXml::_ErrorString; + +bool CIXml::_LibXmlIntialized = false; + // *************************************************************************** #define readnumber(dest,digits) \ @@ -67,7 +70,6 @@ CIXml::CIXml () : IStream (true /* Input mode */) _CurrentNode = NULL; _PushBegin = false; _AttribPresent = false; - _ErrorString = ""; _TryBinaryMode = false; _BinaryStream = NULL; } @@ -82,7 +84,6 @@ CIXml::CIXml (bool tryBinaryMode) : IStream (true /* Input mode */) _CurrentNode = NULL; _PushBegin = false; _AttribPresent = false; - _ErrorString = ""; _TryBinaryMode = tryBinaryMode; _BinaryStream = NULL; } @@ -105,18 +106,16 @@ void CIXml::release () // Free it xmlClearParserCtxt (_Parser); xmlFreeParserCtxt (_Parser); - // commented due to the bug #857 xmlCleanupParser (); _Parser = NULL; } // Not initialized - _Parser = NULL; _CurrentElement = NULL; _CurrentNode = NULL; _PushBegin = false; _AttribPresent = false; - _ErrorString = ""; + _ErrorString.clear(); resetPtrTable(); } @@ -128,7 +127,7 @@ void xmlGenericErrorFuncRead (void *ctx, const char *msg, ...) // Get the error string string str; NLMISC_CONVERT_VARGS (str, msg, NLMISC::MaxCStringSize); - ((CIXml*)ctx)->_ErrorString += str; + CIXml::_ErrorString += str; } // *************************************************************************** @@ -138,7 +137,7 @@ bool CIXml::init (IStream &stream) // Release release (); - xmlInitParser(); + initLibXml(); // Default : XML mode _BinaryStream = NULL; @@ -194,12 +193,7 @@ bool CIXml::init (IStream &stream) } } - // Set error handler - _ErrorString = ""; - xmlSetGenericErrorFunc (this, xmlGenericErrorFuncRead); - - // Ask to get debug info - xmlLineNumbersDefault(1); + _ErrorString.clear(); // The parser context _Parser = xmlCreatePushParserCtxt(NULL, NULL, buffer, 4, NULL); @@ -319,7 +313,7 @@ void CIXml::serialSeparatedBufferIn ( string &value, bool checkSeparator ) // If no more node, empty string if (_CurrentNode == NULL) { - value = ""; + value.clear(); _ContentStringIndex = 0; _ContentString.erase (); return; @@ -719,7 +713,7 @@ void CIXml::serialBuffer(uint8 *buf, uint len) // *************************************************************************** -bool CIXml::xmlPushBeginInternal (const char *nodeName) +bool CIXml::xmlPushBeginInternal (const std::string &nodeName) { nlassert( isReading() ); @@ -748,12 +742,12 @@ bool CIXml::xmlPushBeginInternal (const char *nodeName) nlassert (_CurrentNode->name); // Node element with the good name ? - if ( (_CurrentNode->type != XML_ELEMENT_NODE) || ( (const char*)_CurrentNode->name != string(nodeName)) ) + if ( (_CurrentNode->type != XML_ELEMENT_NODE) || ( (const char*)_CurrentNode->name != nodeName) ) { // Make an error message char tmp[512]; smprintf (tmp, 512, "NeL XML Syntax error : root node has the wrong name : \"%s\" should have \"%s\"", - _CurrentNode->name, nodeName); + _CurrentNode->name, nodeName.c_str()); throw EXmlParsingError (tmp); } } @@ -773,7 +767,7 @@ bool CIXml::xmlPushBeginInternal (const char *nodeName) nlassert (_CurrentNode->name); // Node with the good name - if ( (_CurrentNode->type == XML_ELEMENT_NODE) && ( (const char*)_CurrentNode->name == string(nodeName)) ) + if ( (_CurrentNode->type == XML_ELEMENT_NODE) && ( (const char*)_CurrentNode->name == nodeName) ) { // Save current element _CurrentElement = _CurrentNode; @@ -793,7 +787,7 @@ bool CIXml::xmlPushBeginInternal (const char *nodeName) // Make an error message char tmp[512]; smprintf (tmp, 512, "NeL XML Syntax error in block line %d \nCan't open the node named %s in node named %s", - (int)_CurrentElement->line, nodeName, _CurrentElement->name); + (int)_CurrentElement->line, nodeName.c_str(), _CurrentElement->name); throw EXmlParsingError (tmp); } @@ -906,7 +900,7 @@ bool CIXml::xmlPopInternal () // *************************************************************************** -bool CIXml::xmlSetAttribInternal (const char *attribName) +bool CIXml::xmlSetAttribInternal (const std::string &attribName) { nlassert( isReading() ); @@ -955,7 +949,7 @@ bool CIXml::xmlBreakLineInternal () // *************************************************************************** -bool CIXml::xmlCommentInternal (const char * /* comment */) +bool CIXml::xmlCommentInternal (const std::string &/* comment */) { // Ok return true; @@ -963,12 +957,12 @@ bool CIXml::xmlCommentInternal (const char * /* comment */) // *************************************************************************** -xmlNodePtr CIXml::getFirstChildNode (xmlNodePtr parent, const char *childName) +xmlNodePtr CIXml::getFirstChildNode (xmlNodePtr parent, const std::string &childName) { xmlNodePtr child = parent->children; while (child) { - if (strcmp ((const char*)child->name, childName) == 0) + if (childName == (const char*)child->name) return child; child = child->next; } @@ -977,12 +971,12 @@ xmlNodePtr CIXml::getFirstChildNode (xmlNodePtr parent, const char *childName) // *************************************************************************** -xmlNodePtr CIXml::getNextChildNode (xmlNodePtr last, const char *childName) +xmlNodePtr CIXml::getNextChildNode (xmlNodePtr last, const std::string &childName) { last = last->next; while (last) { - if (strcmp ((const char*)last->name, childName) == 0) + if (childName == (const char*)last->name) return last; last = last->next; } @@ -1019,7 +1013,7 @@ xmlNodePtr CIXml::getNextChildNode (xmlNodePtr last, sint /* xmlElementType */ t // *************************************************************************** -uint CIXml::countChildren (xmlNodePtr node, const char *childName) +uint CIXml::countChildren (xmlNodePtr node, const std::string &childName) { uint count=0; xmlNodePtr child = getFirstChildNode (node, childName); @@ -1057,10 +1051,10 @@ xmlNodePtr CIXml::getRootNode () const // *************************************************************************** -bool CIXml::getPropertyString (std::string &result, xmlNodePtr node, const char *property) +bool CIXml::getPropertyString (std::string &result, xmlNodePtr node, const std::string &property) { // Get the value - const char *value = (const char*)xmlGetProp (node, (xmlChar*)property); + const char *value = (const char*)xmlGetProp (node, (xmlChar*)property.c_str()); if (value) { // Active value @@ -1072,25 +1066,29 @@ bool CIXml::getPropertyString (std::string &result, xmlNodePtr node, const char // Found return true; } + return false; } // *************************************************************************** -int CIXml::getIntProperty(xmlNodePtr node, const char *property, int defaultValue) +int CIXml::getIntProperty(xmlNodePtr node, const std::string &property, int defaultValue) { - CSString s; - bool b; + std::string s; - b=getPropertyString(s,node,property); - if (b==false) + bool b = getPropertyString(s, node, property); + + if (!b) return defaultValue; - s=s.strip(); - sint val=s.atoi(); - if (val==0 && s!="0") + // remove leading and trailing spaces + s = trim(s); + + sint val; + + if (!fromString(s, val) || (val == 0 && s != "0")) { - nlwarning("bad integer value: %s",s.c_str()); + nlwarning("Bad integer value: %s",s.c_str()); return defaultValue; } @@ -1099,27 +1097,38 @@ int CIXml::getIntProperty(xmlNodePtr node, const char *property, int defaultValu // *************************************************************************** -double CIXml::getFloatProperty(xmlNodePtr node, const char *property, float defaultValue) +double CIXml::getFloatProperty(xmlNodePtr node, const std::string &property, float defaultValue) { - CSString s; - bool b; + std::string s; - b=getPropertyString(s,node,property); - if (b==false) + bool b = getPropertyString(s, node, property); + + if (!b) return defaultValue; - return s.strip().atof(); + // remove leading and trailing spaces + s = trim(s); + + float val; + + if (!fromString(s, val)) + { + nlwarning("Bad float value: %s", s.c_str()); + return defaultValue; + } + + return val; } // *************************************************************************** -std::string CIXml::getStringProperty(xmlNodePtr node, const char *property, const std::string& defaultValue) +std::string CIXml::getStringProperty(xmlNodePtr node, const std::string &property, const std::string& defaultValue) { std::string s; - bool b; - b=getPropertyString(s,node,property); - if (b==false) + bool b = getPropertyString(s, node, property); + + if (!b) return defaultValue; return s; @@ -1145,6 +1154,45 @@ bool CIXml::getContentString (std::string &result, xmlNodePtr node) // *************************************************************************** +void CIXml::initLibXml() +{ + if (_LibXmlIntialized) return; + + _ErrorString.clear(); + + // Set error handler + xmlSetGenericErrorFunc (NULL, xmlGenericErrorFuncRead); + + LIBXML_TEST_VERSION + + // an error occured during initialization + if (!_ErrorString.empty()) + { + throw EXmlParsingError (_ErrorString); + } + + // Ask to get debug info + xmlLineNumbersDefault(1); + + _LibXmlIntialized = true; +} + +// *************************************************************************** + +void CIXml::releaseLibXml() +{ + if (!_LibXmlIntialized) return; + + xmlCleanupParser(); + + _LibXmlIntialized = false; +} + +std::string CIXml::getErrorString() +{ + return _ErrorString; +} + } // NLMISC #endif // NL_DONT_USE_EXTERNAL_CODE diff --git a/code/nel/src/misc/inter_window_msg_queue.cpp b/code/nel/src/misc/inter_window_msg_queue.cpp index cca8f1a37..f27fa55da 100644 --- a/code/nel/src/misc/inter_window_msg_queue.cpp +++ b/code/nel/src/misc/inter_window_msg_queue.cpp @@ -268,7 +268,7 @@ namespace NLMISC typedef CSynchronized::CAccessor TAccessor; // NB : use a 'new' instead of an automatic object here, because I got an 'INTERNAL COMPILER ERROR' compiler file 'msc1.cpp', line 1794 // else, this is one of the way recommended by microsoft to solve the problem. - std::auto_ptr messageQueueMap(new TAccessor(&_MessageQueueMap)); + CUniquePtr messageQueueMap(new TAccessor(&_MessageQueueMap)); CMsgQueueIdent msgQueueIdent(ownerWindow, localId, foreignId); if (messageQueueMap->value().count(msgQueueIdent)) { @@ -368,7 +368,7 @@ namespace NLMISC typedef CSynchronized::CAccessor TAccessor; // NB : use a 'new' instead of an automatic object here, because I got an 'INTERNAL COMPILER ERROR' compiler file 'msc1.cpp', line 1794 // else, this is one of the way recommended by microsoft to solve the problem. - std::auto_ptr messageQueueMap(new TAccessor(&_MessageQueueMap)); + CUniquePtr messageQueueMap(new TAccessor(&_MessageQueueMap)); TMessageQueueMap::iterator it = messageQueueMap->value().find(CMsgQueueIdent(_LocalWindow.getWnd(), _LocalWindow.getId(), _ForeignWindow.getId())); nlassert(it != messageQueueMap->value().end()); messageQueueMap->value().erase(it); @@ -408,7 +408,7 @@ namespace NLMISC typedef CSynchronized::CAccessor TAccessor; // NB : use a 'new' instead of an automatic object here, because I got an 'INTERNAL COMPILER ERROR' compiler file 'msc1.cpp', line 1794 // else, this is one of the way recommended by microsoft to solve the problem. - std::auto_ptr messageQueueMap(new TAccessor(&_MessageQueueMap)); + CUniquePtr messageQueueMap(new TAccessor(&_MessageQueueMap)); TMessageQueueMap::iterator it = messageQueueMap->value().find(CMsgQueueIdent(hwnd, toId, fromId)); if (it != messageQueueMap->value().end()) { diff --git a/code/nel/src/misc/log.cpp b/code/nel/src/misc/log.cpp index 08f6b3107..277048c3b 100644 --- a/code/nel/src/misc/log.cpp +++ b/code/nel/src/misc/log.cpp @@ -377,11 +377,11 @@ void CLog::displayRawString (const char *str) { localargs.Date = 0; localargs.LogType = CLog::LOG_NO; - localargs.ProcessName = ""; + localargs.ProcessName.clear(); localargs.ThreadId = 0; localargs.FileName = NULL; localargs.Line = -1; - localargs.CallstackAndLog = ""; + localargs.CallstackAndLog.clear(); TempString = str; } @@ -397,11 +397,11 @@ void CLog::displayRawString (const char *str) { localargs.Date = 0; localargs.LogType = CLog::LOG_NO; - localargs.ProcessName = ""; + localargs.ProcessName.clear(); localargs.ThreadId = 0; localargs.FileName = NULL; localargs.Line = -1; - localargs.CallstackAndLog = ""; + localargs.CallstackAndLog.clear(); disp = str; args = &localargs; @@ -615,8 +615,12 @@ void CLog::releaseProcessName() { INelContext::getInstance().releaseSingletonPointer("NLMISC::CLog::_ProcessName", _ProcessName); } - delete _ProcessName; - _ProcessName = NULL; + + if (_ProcessName) + { + delete _ProcessName; + _ProcessName = NULL; + } } } // NLMISC diff --git a/code/nel/src/misc/md5.cpp b/code/nel/src/misc/md5.cpp index eaf9df6cc..052bfa0b2 100644 --- a/code/nel/src/misc/md5.cpp +++ b/code/nel/src/misc/md5.cpp @@ -118,31 +118,6 @@ CHashKeyMD5 getMD5(const uint8 *buffer, uint32 size) return Message_Digest; } -// **************************************************************************** -// Helper -// **************************************************************************** -static bool fromHex(char c, uint8 &x) -{ - if (c >= '0' && c <= '9') - { - x = c - '0'; - return true; - } - else if (c >= 'A' && c <= 'F') - { - x = c - 'A' + 10; - return true; - } - else if (c >= 'a' && c <= 'f') - { - x = c - 'a' + 10; - return true; - } - - nlwarning("cannot convert to hexa"); - return false; -} - // **************************************************************************** // **************************************************************************** // CHashKeyMD5 @@ -159,10 +134,7 @@ void CHashKeyMD5::clear() // **************************************************************************** string CHashKeyMD5::toString() const { - string sTmp; - for (uint32 i = 0; i < 16; ++i) - sTmp += NLMISC::toString("%02x", Data[i]); - return sTmp; + return toHexa(Data, 16); } // **************************************************************************** @@ -174,16 +146,7 @@ bool CHashKeyMD5::fromString(const std::string &in) return false; } - for (uint32 i = 0; i < 16; ++i) - { - char c1 = in[2*i]; - char c2 = in[2*i+1]; - uint8 x1, x2; - if (!fromHex(c1, x1)) return false; - if (!fromHex(c2, x2)) return false; - Data[i] = (x1 << 4) | x2; - } - return true; + return fromHexa(in, Data); } // **************************************************************************** diff --git a/code/nel/src/misc/mem_displayer.cpp b/code/nel/src/misc/mem_displayer.cpp index b8f4f2ea3..c2d7049de 100644 --- a/code/nel/src/misc/mem_displayer.cpp +++ b/code/nel/src/misc/mem_displayer.cpp @@ -85,7 +85,7 @@ static string getFuncInfo (DWORD_TYPE funcAddr, DWORD_TYPE stackAddr) // replace param with the value of the stack for this param string parse = str; - str = ""; + str.clear(); uint pos = 0; sint stop = 0; diff --git a/code/nel/src/misc/o_xml.cpp b/code/nel/src/misc/o_xml.cpp index 6df48ef80..5458ebf4c 100644 --- a/code/nel/src/misc/o_xml.cpp +++ b/code/nel/src/misc/o_xml.cpp @@ -17,6 +17,7 @@ #include "stdmisc.h" #include "nel/misc/o_xml.h" +#include "nel/misc/i_xml.h" #ifndef NL_DONT_USE_EXTERNAL_CODE @@ -134,7 +135,7 @@ COXml::COXml () : IStream (false /* Output mode */) _CurrentNode = NULL; // Content string - _ContentString = ""; + _ContentString.clear(); // Push begin _PushBegin = false; @@ -142,27 +143,15 @@ COXml::COXml () : IStream (false /* Output mode */) // *************************************************************************** -void xmlGenericErrorFuncWrite (void *ctx, const char *msg, ...) -{ - // Get the error string - string str; - NLMISC_CONVERT_VARGS (str, msg, NLMISC::MaxCStringSize); - ((COXml*)ctx)->_ErrorString += str; -} - -// *************************************************************************** - -bool COXml::init (IStream *stream, const char *version) +bool COXml::init (IStream *stream, const std::string &version) { resetPtrTable(); + CIXml::initLibXml(); + // Output stream ? if (!stream->isReading()) { - // Set error handler - _ErrorString = ""; - xmlSetGenericErrorFunc (this, xmlGenericErrorFuncWrite); - // Set XML mode setXMLMode (true); @@ -179,7 +168,7 @@ bool COXml::init (IStream *stream, const char *version) _CurrentNode = NULL; // Content string - _ContentString = ""; + _ContentString.clear(); // Push begin _PushBegin = false; @@ -201,7 +190,7 @@ COXml::~COXml () // *************************************************************************** -void COXml::serialSeparatedBufferOut( const char *value ) +void COXml::serialSeparatedBufferOut( const std::string &value ) { nlassert( ! isReading() ); @@ -218,7 +207,7 @@ void COXml::serialSeparatedBufferOut( const char *value ) if (_AttribPresent) { // Set the attribute - xmlSetProp (_CurrentNode, (const xmlChar*)_AttribName.c_str(), (const xmlChar*)value); + xmlSetProp (_CurrentNode, (const xmlChar*)_AttribName.c_str(), (const xmlChar*)value.c_str()); // The attribute has been used _AttribPresent = false; @@ -349,7 +338,8 @@ void COXml::serialBit(bool &bit) #ifndef NL_OS_CYGWIN void COXml::serial(char &b) { - char tmp[2] = {b , 0}; + std::string tmp; + tmp += b; serialSeparatedBufferOut( tmp ); } #endif // NL_OS_CYGWIN @@ -364,7 +354,7 @@ void COXml::serial(std::string &b) if (_PushBegin) { // Only serial the string - serialSeparatedBufferOut( b.c_str() ); + serialSeparatedBufferOut( b ); } else { @@ -372,7 +362,7 @@ void COXml::serial(std::string &b) xmlPush ("S"); // Serial the string - serialSeparatedBufferOut( b.c_str() ); + serialSeparatedBufferOut( b ); // Close the node xmlPop (); @@ -415,7 +405,7 @@ void COXml::serialBuffer(uint8 *buf, uint len) // *************************************************************************** -bool COXml::xmlPushBeginInternal (const char *nodeName) +bool COXml::xmlPushBeginInternal (const std::string &nodeName) { nlassert( ! isReading() ); @@ -439,7 +429,7 @@ bool COXml::xmlPushBeginInternal (const char *nodeName) } // Create the first node - _CurrentNode=xmlNewDocNode (_Document, NULL, (const xmlChar*)nodeName, NULL); + _CurrentNode=xmlNewDocNode (_Document, NULL, (const xmlChar*)nodeName.c_str(), NULL); xmlDocSetRootElement (_Document, _CurrentNode); // Return NULL if error @@ -451,7 +441,7 @@ bool COXml::xmlPushBeginInternal (const char *nodeName) flushContentString (); // Create a new node - _CurrentNode=xmlNewChild (_CurrentNode, NULL, (const xmlChar*)nodeName, NULL); + _CurrentNode=xmlNewChild (_CurrentNode, NULL, (const xmlChar*)nodeName.c_str(), NULL); // Return NULL if error nlassert (_CurrentNode); @@ -543,7 +533,7 @@ bool COXml::xmlPopInternal () // *************************************************************************** -bool COXml::xmlSetAttribInternal (const char *attribName) +bool COXml::xmlSetAttribInternal (const std::string &attribName) { nlassert( ! isReading() ); @@ -608,7 +598,7 @@ bool COXml::xmlBreakLineInternal () // *************************************************************************** -bool COXml::xmlCommentInternal (const char *comment) +bool COXml::xmlCommentInternal (const std::string &comment) { nlassert( ! isReading() ); @@ -619,7 +609,7 @@ bool COXml::xmlCommentInternal (const char *comment) if ( _CurrentNode != NULL) { // Add a comment node - xmlNodePtr commentPtr = xmlNewComment ((const xmlChar *)comment); + xmlNodePtr commentPtr = xmlNewComment ((const xmlChar *)comment.c_str()); // Add the node xmlAddChild (_CurrentNode, commentPtr); @@ -665,22 +655,17 @@ void COXml::flush () // *************************************************************************** -bool COXml::isStringValidForProperties (const char *str) +bool COXml::isStringValidForProperties (const std::string &str) { - while (*str) - { - if (*str == '\n') - return false; - str++; - } - return true; + return str.find('\n') == std::string::npos; } // *************************************************************************** -const char *COXml::getErrorString () const +std::string COXml::getErrorString() { - return _ErrorString.c_str (); + // error string is managed by CIXml + return CIXml::getErrorString(); } } // NLMISC diff --git a/code/nel/src/misc/object_arena_allocator.cpp b/code/nel/src/misc/object_arena_allocator.cpp index 5fba66005..e27a066ec 100644 --- a/code/nel/src/misc/object_arena_allocator.cpp +++ b/code/nel/src/misc/object_arena_allocator.cpp @@ -97,7 +97,7 @@ void *CObjectArenaAllocator::alloc(uint size) } // ***************************************************************************************************************** -void CObjectArenaAllocator::free(void *block) +void CObjectArenaAllocator::freeBlock(void *block) { if (!block) return; uint8 *realBlock = (uint8 *) block - NL_DEFAULT_MEMORY_ALIGNMENT; // sizeof(uint); // a uint is used at start of block to give its size @@ -114,7 +114,7 @@ void CObjectArenaAllocator::free(void *block) } uint entry = ((size + (_Granularity - 1)) / _Granularity); nlassert(entry < _ObjectSizeToAllocator.size()); - _ObjectSizeToAllocator[entry]->free(realBlock); + _ObjectSizeToAllocator[entry]->freeBlock(realBlock); #ifdef NL_DEBUG std::map::iterator it = _MemBlockToAllocID.find(realBlock); nlassert(it != _MemBlockToAllocID.end()); diff --git a/code/nel/src/misc/object_vector.cpp b/code/nel/src/misc/object_vector.cpp deleted file mode 100644 index 7a863342b..000000000 --- a/code/nel/src/misc/object_vector.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/object_vector.h" - -// leave not static else this workaround don't work -void dummyToAvoidStupidCompilerWarning_misc_object_vector_cpp() -{ -} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - -} // NLMISC diff --git a/code/nel/src/misc/p_thread.cpp b/code/nel/src/misc/p_thread.cpp index 778270d17..a38fb84b2 100644 --- a/code/nel/src/misc/p_thread.cpp +++ b/code/nel/src/misc/p_thread.cpp @@ -50,8 +50,11 @@ struct CPMainThread : public CPThread ~CPMainThread() { - if(pthread_key_delete(threadSpecificKey) != 0) - throw EThread("cannot delete thread specific storage key."); + if (pthread_key_delete(threadSpecificKey) != 0) + { + nlwarning("cannot delete thread specific storage key."); + // throw EThread("cannot delete thread specific storage key."); + } } }; diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index 9737589f7..c6f9786f4 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -2148,7 +2148,7 @@ bool CFile::setFileModificationDate(const std::string &filename, uint32 modTime) FILETIME accessFileTime; FILETIME modFileTime; - // read the current the files times + // read the current file time if (GetFileTime(h, &creationFileTime, &accessFileTime, &modFileTime) == 0) { nlwarning("Can't set modification date on file '%s' : %s", fn.c_str(), formatErrorMessage(getLastError()).c_str()); @@ -2523,7 +2523,7 @@ bool CFile::createDirectoryTree(const std::string &filename) return lastResult; } -bool CPath::makePathRelative (const char *basePath, std::string &relativePath) +bool CPath::makePathRelative (const std::string &basePath, std::string &relativePath) { // Standard path with final slash string tmp = standardizePath (basePath, true); diff --git a/code/nel/src/misc/polygon.cpp b/code/nel/src/misc/polygon.cpp index 9388dbd45..856255c34 100644 --- a/code/nel/src/misc/polygon.cpp +++ b/code/nel/src/misc/polygon.cpp @@ -113,7 +113,7 @@ void CPolygon::clip(const std::vector &planes) // *************************************************************************** -void CPolygon::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPolygon::serial(NLMISC::IStream &f) { f.serialVersion(0); f.serialCont(Vertices); @@ -1011,7 +1011,7 @@ void CPolygon2D::buildConvexHull(CPolygon2D &dest) const // *************************************************************************** -void CPolygon2D::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CPolygon2D::serial(NLMISC::IStream &f) { (void)f.serialVersion(0); f.serialCont(Vertices); @@ -1999,7 +1999,7 @@ float CPolygon2D::sumDPAgainstLine(float a, float b, float c) const // ******************************************************************************* bool CPolygon2D::getNonNullSeg(uint &index) const { - nlassert(Vertices.size() > 0); + nlassert(!Vertices.empty()); float bestLength = 0.f; sint bestIndex = -1; for (uint k = 0; k < Vertices.size() - 1; ++k) @@ -2046,7 +2046,7 @@ void CPolygon2D::getLineEquation(uint index, float &a, float &b, float &c) cons // ******************************************************************************* bool CPolygon2D::intersect(const CPolygon2D &other) const { - nlassert(other.Vertices.size() > 0); + nlassert(!other.Vertices.empty()); uint nonNullSegIndex; /// get the orientation of this poly if (getNonNullSeg(nonNullSegIndex)) diff --git a/code/nel/src/misc/quad.cpp b/code/nel/src/misc/quad.cpp deleted file mode 100644 index 8fced3318..000000000 --- a/code/nel/src/misc/quad.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/quad.h" - - -// leave not static else this workaround don't work -void dummyToAvoidStupidCompilerWarning_misc_quad_cpp() -{ -} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - - -} // NLMISC diff --git a/code/nel/src/misc/rgba.cpp b/code/nel/src/misc/rgba.cpp index 822ee1006..277793489 100644 --- a/code/nel/src/misc/rgba.cpp +++ b/code/nel/src/misc/rgba.cpp @@ -50,7 +50,7 @@ const CRGBA CRGBA::Cyan(0, 255, 255) ; const CRGBA CRGBA::White(255, 255, 255) ; // *************************************************************************** -void CRGBA::serial(class NLMISC::IStream &f) +void CRGBA::serial(NLMISC::IStream &f) { f.serial (R); f.serial (G); @@ -581,7 +581,7 @@ void CRGBA::subtractColors(CRGBA *dest, const CRGBA *src1, const CRGBA *src2, ui // *************************************************************************** -void CBGRA::serial(class NLMISC::IStream &f) +void CBGRA::serial(NLMISC::IStream &f) { f.serial (B); f.serial (G); @@ -748,6 +748,17 @@ CRGBA CRGBA::stringToRGBA( const char *ptr ) return CRGBA( r,g,b,a ); } + + // we need at least 3 hexadecimal values to consider string is valid + if (sscanf(ptr, "#%02x%02x%02x%02x", &r, &g, &b, &a) >= 3) + { + clamp(r, 0, 255); + clamp(g, 0, 255); + clamp(b, 0, 255); + clamp(a, 0, 255); + + return CRGBA(r, g, b, a); + } } return NLMISC::CRGBA::White; @@ -781,7 +792,7 @@ bool CRGBA::fromString( const std::string &s ) // *************************************************************************** -void CRGBAF::serial(class NLMISC::IStream &f) +void CRGBAF::serial(NLMISC::IStream &f) { f.serial (R); f.serial (G); diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index 1b3ca490f..2dd895153 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -561,7 +561,7 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const } // toString // -void CSheetId::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CSheetId::serial(NLMISC::IStream &f) { nlassert(!_DontHaveSheetKnowledge); @@ -576,7 +576,7 @@ void CSheetId::serial(NLMISC::IStream &f) throw(NLMISC::EStream) #endif } -void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType) throw(NLMISC::EStream) +void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType) { nlassert(_Initialised); diff --git a/code/nel/src/misc/smart_ptr.cpp b/code/nel/src/misc/smart_ptr.cpp index e5c31fcd7..73c3c0799 100644 --- a/code/nel/src/misc/smart_ptr.cpp +++ b/code/nel/src/misc/smart_ptr.cpp @@ -29,12 +29,5 @@ namespace NLMISC //CPtrInfo() {Ptr=NULL; RefCount=0x7FFFFFFF; IsNullPtrInfo=true;} CRefCount::CPtrInfoBase CRefCount::NullPtrInfo= {NULL, 0x7FFFFFFF, true}; - -// must not be static -void dummy_to_avoid_stupid_4768_smart_ptr_cpp() -{ -} - - } diff --git a/code/nel/src/misc/stdmisc.h b/code/nel/src/misc/stdmisc.h index 3ed96f900..d7a623465 100644 --- a/code/nel/src/misc/stdmisc.h +++ b/code/nel/src/misc/stdmisc.h @@ -17,6 +17,13 @@ #ifndef NL_STDMISC_H #define NL_STDMISC_H +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif + #include #include #include diff --git a/code/nel/src/misc/stl_block_allocator.cpp b/code/nel/src/misc/stl_block_allocator.cpp deleted file mode 100644 index f57d0c238..000000000 --- a/code/nel/src/misc/stl_block_allocator.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/stl_block_allocator.h" - -// remove stupid VC6 warnings -void foo_stl_block_allocator_cpp() {} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - - -} // NLMISC diff --git a/code/nel/src/misc/stl_block_list.cpp b/code/nel/src/misc/stl_block_list.cpp deleted file mode 100644 index 628b79371..000000000 --- a/code/nel/src/misc/stl_block_list.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/stl_block_list.h" - -// remove stupid VC6 warnings -void foo_stl_block_list_cpp() {} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - -} // NLMISC diff --git a/code/nel/src/misc/stop_watch.cpp b/code/nel/src/misc/stop_watch.cpp index 59b62150e..8da60d8ec 100644 --- a/code/nel/src/misc/stop_watch.cpp +++ b/code/nel/src/misc/stop_watch.cpp @@ -136,7 +136,7 @@ TMsDuration CStopWatch::getDuration() const */ TMsDuration CStopWatch::getPartialAverage() const { - if (_Queue.size() == 0) + if (_Queue.empty()) return (TMsDuration)0; else return (TMsDuration)(CTime::ticksToSecond( accumulate( _Queue.begin(), _Queue.end(), 0 ) / _Queue.size() ) * 1000.0); diff --git a/code/nel/src/misc/string_common.cpp b/code/nel/src/misc/string_common.cpp index dd8d1fe96..9c9085e4e 100644 --- a/code/nel/src/misc/string_common.cpp +++ b/code/nel/src/misc/string_common.cpp @@ -27,7 +27,7 @@ using namespace std; namespace NLMISC { -string addSlashR (string str) +string addSlashR (const string &str) { string formatedStr; // replace \n with \r\n @@ -42,10 +42,10 @@ string addSlashR (string str) return formatedStr; } -string removeSlashR (string str) +string removeSlashR (const string &str) { string formatedStr; - // replace \n with \r\n + // remove \r for (uint i = 0; i < str.size(); i++) { if (str[i] != '\r') diff --git a/code/nel/src/misc/string_id_array.cpp b/code/nel/src/misc/string_id_array.cpp deleted file mode 100644 index b9489e3f9..000000000 --- a/code/nel/src/misc/string_id_array.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/string_id_array.h" - - -// leave not static else this workaround don't work -void dummyToAvoidStupidCompilerWarning_misc_string_id_array_cpp() -{ -} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - -} // NLMISC diff --git a/code/nel/src/misc/string_mapper.cpp b/code/nel/src/misc/string_mapper.cpp index cf8a38e49..6e59f7bab 100644 --- a/code/nel/src/misc/string_mapper.cpp +++ b/code/nel/src/misc/string_mapper.cpp @@ -33,8 +33,7 @@ CStringMapper CStringMapper::_GlobalMapper; // **************************************************************************** CStringMapper::CStringMapper() { - _EmptyId = new string; - *_EmptyId = ""; + _EmptyId = new string(); } // **************************************************************************** @@ -46,7 +45,7 @@ CStringMapper *CStringMapper::createLocalMapper() // **************************************************************************** TStringId CStringMapper::localMap(const std::string &str) { - if (str.size() == 0) + if (str.empty()) return 0; CAutoFastMutex automutex(&_Mutex); diff --git a/code/nel/src/misc/system_info.cpp b/code/nel/src/misc/system_info.cpp index b78389064..2afa8da09 100644 --- a/code/nel/src/misc/system_info.cpp +++ b/code/nel/src/misc/system_info.cpp @@ -23,6 +23,156 @@ # include # include # define nlcpuid(regs, idx) __cpuid(regs, idx) + +// define them here to not rely on Windows 10 SDKs +# define NL_PRODUCT_UNDEFINED 0x00000000 +# define NL_PRODUCT_ULTIMATE 0x00000001 +# define NL_PRODUCT_HOME_BASIC 0x00000002 +# define NL_PRODUCT_HOME_PREMIUM 0x00000003 +# define NL_PRODUCT_ENTERPRISE 0x00000004 +# define NL_PRODUCT_HOME_BASIC_N 0x00000005 +# define NL_PRODUCT_BUSINESS 0x00000006 +# define NL_PRODUCT_STANDARD_SERVER 0x00000007 +# define NL_PRODUCT_DATACENTER_SERVER 0x00000008 +# define NL_PRODUCT_SMALLBUSINESS_SERVER 0x00000009 +# define NL_PRODUCT_ENTERPRISE_SERVER 0x0000000A +# define NL_PRODUCT_STARTER 0x0000000B +# define NL_PRODUCT_DATACENTER_SERVER_CORE 0x0000000C +# define NL_PRODUCT_STANDARD_SERVER_CORE 0x0000000D +# define NL_PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E +# define NL_PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F +# define NL_PRODUCT_BUSINESS_N 0x00000010 +# define NL_PRODUCT_WEB_SERVER 0x00000011 +# define NL_PRODUCT_CLUSTER_SERVER 0x00000012 +# define NL_PRODUCT_HOME_SERVER 0x00000013 +# define NL_PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014 +# define NL_PRODUCT_STORAGE_STANDARD_SERVER 0x00000015 +# define NL_PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016 +# define NL_PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017 +# define NL_PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018 +# define NL_PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019 +# define NL_PRODUCT_HOME_PREMIUM_N 0x0000001A +# define NL_PRODUCT_ENTERPRISE_N 0x0000001B +# define NL_PRODUCT_ULTIMATE_N 0x0000001C +# define NL_PRODUCT_WEB_SERVER_CORE 0x0000001D +# define NL_PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E +# define NL_PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F +# define NL_PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020 +# define NL_PRODUCT_SERVER_FOUNDATION 0x00000021 +# define NL_PRODUCT_HOME_PREMIUM_SERVER 0x00000022 +# define NL_PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023 +# define NL_PRODUCT_STANDARD_SERVER_V 0x00000024 +# define NL_PRODUCT_DATACENTER_SERVER_V 0x00000025 +# define NL_PRODUCT_ENTERPRISE_SERVER_V 0x00000026 +# define NL_PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027 +# define NL_PRODUCT_STANDARD_SERVER_CORE_V 0x00000028 +# define NL_PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029 +# define NL_PRODUCT_HYPERV 0x0000002A +# define NL_PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B +# define NL_PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C +# define NL_PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D +# define NL_PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E +# define NL_PRODUCT_STARTER_N 0x0000002F +# define NL_PRODUCT_PROFESSIONAL 0x00000030 +# define NL_PRODUCT_PROFESSIONAL_N 0x00000031 +# define NL_PRODUCT_SB_SOLUTION_SERVER 0x00000032 +# define NL_PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033 +# define NL_PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034 +# define NL_PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035 +# define NL_PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036 +# define NL_PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037 +# define NL_PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038 +# define NL_PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039 +# define NL_PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A +# define NL_PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B +# define NL_PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C +# define NL_PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D +# define NL_PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E +# define NL_PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F +# define NL_PRODUCT_CLUSTER_SERVER_V 0x00000040 +# define NL_PRODUCT_EMBEDDED 0x00000041 +# define NL_PRODUCT_STARTER_E 0x00000042 +# define NL_PRODUCT_HOME_BASIC_E 0x00000043 +# define NL_PRODUCT_HOME_PREMIUM_E 0x00000044 +# define NL_PRODUCT_PROFESSIONAL_E 0x00000045 +# define NL_PRODUCT_ENTERPRISE_E 0x00000046 +# define NL_PRODUCT_ULTIMATE_E 0x00000047 +# define NL_PRODUCT_ENTERPRISE_EVALUATION 0x00000048 +# define NL_PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C +# define NL_PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D +# define NL_PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F +# define NL_PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050 +# define NL_PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054 +# define NL_PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055 +# define NL_PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056 +# define NL_PRODUCT_THINPC 0x00000057 +# define NL_PRODUCT_EMBEDDED_A 0x00000058 +# define NL_PRODUCT_EMBEDDED_INDUSTRY 0x00000059 +# define NL_PRODUCT_EMBEDDED_E 0x0000005A +# define NL_PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B +# define NL_PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C +# define NL_PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F +# define NL_PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060 +# define NL_PRODUCT_CORE_ARM 0x00000061 +# define NL_PRODUCT_CORE_N 0x00000062 +# define NL_PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063 +# define NL_PRODUCT_CORE_SINGLELANGUAGE 0x00000064 +# define NL_PRODUCT_CORE 0x00000065 +# define NL_PRODUCT_PROFESSIONAL_WMC 0x00000067 +# define NL_PRODUCT_MOBILE_CORE 0x00000068 +# define NL_PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069 +# define NL_PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A +# define NL_PRODUCT_EMBEDDED_EVAL 0x0000006B +# define NL_PRODUCT_EMBEDDED_E_EVAL 0x0000006C +# define NL_PRODUCT_CORE_SERVER 0x0000006D +# define NL_PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E +# define NL_PRODUCT_CORE_CONNECTED 0x0000006F +# define NL_PRODUCT_PROFESSIONAL_STUDENT 0x00000070 +# define NL_PRODUCT_CORE_CONNECTED_N 0x00000071 +# define NL_PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072 +# define NL_PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073 +# define NL_PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074 +# define NL_PRODUCT_CONNECTED_CAR 0x00000075 +# define NL_PRODUCT_INDUSTRY_HANDHELD 0x00000076 +# define NL_PRODUCT_PPI_PRO 0x00000077 +# define NL_PRODUCT_ARM64_SERVER 0x00000078 +# define NL_PRODUCT_EDUCATION 0x00000079 +# define NL_PRODUCT_EDUCATION_N 0x0000007A +# define NL_PRODUCT_IOTUAP 0x0000007B +# define NL_PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C +# define NL_PRODUCT_ENTERPRISE_S 0x0000007D +# define NL_PRODUCT_ENTERPRISE_S_N 0x0000007E +# define NL_PRODUCT_PROFESSIONAL_S 0x0000007F +# define NL_PRODUCT_PROFESSIONAL_S_N 0x00000080 +# define NL_PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081 +# define NL_PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082 +# define NL_PRODUCT_HOLOGRAPHIC 0x00000087 +# define NL_PRODUCT_PRO_SINGLE_LANGUAGE 0x0000008A +# define NL_PRODUCT_PRO_CHINA 0x0000008B +# define NL_PRODUCT_ENTERPRISE_SUBSCRIPTION 0x0000008C +# define NL_PRODUCT_ENTERPRISE_SUBSCRIPTION_N 0x0000008D +# define NL_PRODUCT_DATACENTER_NANO_SERVER 0x0000008F +# define NL_PRODUCT_STANDARD_NANO_SERVER 0x00000090 +# define NL_PRODUCT_DATACENTER_A_SERVER_CORE 0x00000091 +# define NL_PRODUCT_STANDARD_A_SERVER_CORE 0x00000092 +# define NL_PRODUCT_DATACENTER_WS_SERVER_CORE 0x00000093 +# define NL_PRODUCT_STANDARD_WS_SERVER_CORE 0x00000094 +# define NL_PRODUCT_UTILITY_VM 0x00000095 +# define NL_PRODUCT_DATACENTER_EVALUATION_SERVER_CORE 0x0000009F +# define NL_PRODUCT_STANDARD_EVALUATION_SERVER_CORE 0x000000A0 +# define NL_PRODUCT_PRO_WORKSTATION 0x000000A1 +# define NL_PRODUCT_PRO_WORKSTATION_N 0x000000A2 +# define NL_PRODUCT_PRO_FOR_EDUCATION 0x000000A4 +# define NL_PRODUCT_PRO_FOR_EDUCATION_N 0x000000A5 +# define NL_PRODUCT_AZURE_SERVER_CORE 0x000000A8 +# define NL_PRODUCT_AZURE_NANO_SERVER 0x000000A9 +# define NL_PRODUCT_ENTERPRISEG 0x000000AB +# define NL_PRODUCT_ENTERPRISEGN 0x000000AC +# define NL_PRODUCT_SERVERRDSH 0x000000AF +# define NL_PRODUCT_CLOUD 0x000000B2 +# define NL_PRODUCT_CLOUDN 0x000000B3 +# define NL_PRODUCT_UNLICENSED 0xABCDABCD + #else # include # include @@ -443,544 +593,461 @@ string CSystemInfo::getOS() if (pGetProductInfo && pGetProductInfo(osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.wServicePackMajor, osvi.wServicePackMinor, &dwType)) { // Test for the specific product family. + // see https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms724358(v=vs.85).aspx switch (dwType) { -#ifdef PRODUCT_UNLICENSED - case PRODUCT_UNLICENSED: + case NL_PRODUCT_UNLICENSED: OSString += " Unlicensed"; break; -#endif -#ifdef PRODUCT_ULTIMATE - case PRODUCT_ULTIMATE: + case NL_PRODUCT_ULTIMATE: OSString += " Ultimate"; break; -#endif -#ifdef PRODUCT_HOME_BASIC - case PRODUCT_HOME_BASIC: + case NL_PRODUCT_HOME_BASIC: OSString += " Home Basic"; break; -#endif -#ifdef PRODUCT_HOME_PREMIUM - case PRODUCT_HOME_PREMIUM: + case NL_PRODUCT_HOME_PREMIUM: OSString += " Home Premium"; break; -#endif -#ifdef PRODUCT_ENTERPRISE - case PRODUCT_ENTERPRISE: + case NL_PRODUCT_ENTERPRISE: OSString += " Enterprise"; break; -#endif -#ifdef PRODUCT_HOME_BASIC_N - case PRODUCT_HOME_BASIC_N: + case NL_PRODUCT_HOME_BASIC_N: OSString += " Home Basic N"; break; -#endif -#ifdef PRODUCT_BUSINESS - case PRODUCT_BUSINESS: + case NL_PRODUCT_BUSINESS: OSString += " Business"; break; -#endif -#ifdef PRODUCT_STANDARD_SERVER - case PRODUCT_STANDARD_SERVER: + case NL_PRODUCT_STANDARD_SERVER: OSString += " Server Standard"; break; -#endif -#ifdef PRODUCT_DATACENTER_SERVER - case PRODUCT_DATACENTER_SERVER: + case NL_PRODUCT_DATACENTER_SERVER: OSString += " Server Datacenter (full installation)"; break; -#endif -#ifdef PRODUCT_SMALLBUSINESS_SERVER - case PRODUCT_SMALLBUSINESS_SERVER: + case NL_PRODUCT_SMALLBUSINESS_SERVER: OSString += " Small Business Server"; break; -#endif -#ifdef PRODUCT_ENTERPRISE_SERVER - case PRODUCT_ENTERPRISE_SERVER: + case NL_PRODUCT_ENTERPRISE_SERVER: OSString += " Server Enterprise (full installation)"; break; -#endif -#ifdef PRODUCT_STARTER - case PRODUCT_STARTER: + case NL_PRODUCT_STARTER: OSString += " Starter"; break; -#endif -#ifdef PRODUCT_DATACENTER_SERVER_CORE - case PRODUCT_DATACENTER_SERVER_CORE: + case NL_PRODUCT_DATACENTER_SERVER_CORE: OSString += " Server Datacenter (core installation)"; break; -#endif -#ifdef PRODUCT_STANDARD_SERVER_CORE - case PRODUCT_STANDARD_SERVER_CORE: + case NL_PRODUCT_STANDARD_SERVER_CORE: OSString += " Server Standard (core installation)"; break; -#endif -#ifdef PRODUCT_ENTERPRISE_SERVER_CORE - case PRODUCT_ENTERPRISE_SERVER_CORE: + case NL_PRODUCT_ENTERPRISE_SERVER_CORE: OSString += " Server Enterprise (core installation)"; break; -#endif -#ifdef PRODUCT_ENTERPRISE_SERVER_IA64 - case PRODUCT_ENTERPRISE_SERVER_IA64: + case NL_PRODUCT_ENTERPRISE_SERVER_IA64: OSString += " Server Enterprise for Itanium-based Systems"; break; -#endif -#ifdef PRODUCT_BUSINESS_N - case PRODUCT_BUSINESS_N: + case NL_PRODUCT_BUSINESS_N: OSString += " Business N"; break; -#endif -#ifdef PRODUCT_WEB_SERVER - case PRODUCT_WEB_SERVER: + case NL_PRODUCT_WEB_SERVER: OSString += " Web Server (full installation)"; break; -#endif -#ifdef PRODUCT_CLUSTER_SERVER - case PRODUCT_CLUSTER_SERVER: + case NL_PRODUCT_CLUSTER_SERVER: OSString += " Server Hyper Core"; break; -#endif -#ifdef PRODUCT_HOME_SERVER - case PRODUCT_HOME_SERVER: + case NL_PRODUCT_HOME_SERVER: OSString += " Home Server"; break; -#endif -#ifdef PRODUCT_STORAGE_EXPRESS_SERVER - case PRODUCT_STORAGE_EXPRESS_SERVER: + case NL_PRODUCT_STORAGE_EXPRESS_SERVER: OSString += " Storage Server Express"; break; -#endif -#ifdef PRODUCT_STORAGE_STANDARD_SERVER - case PRODUCT_STORAGE_STANDARD_SERVER: + case NL_PRODUCT_STORAGE_STANDARD_SERVER: OSString += " Storage Server Standard"; break; -#endif -#ifdef PRODUCT_STORAGE_WORKGROUP_SERVER - case PRODUCT_STORAGE_WORKGROUP_SERVER: + case NL_PRODUCT_STORAGE_WORKGROUP_SERVER: OSString += " Storage Server Workgroup"; break; -#endif -#ifdef PRODUCT_STORAGE_ENTERPRISE_SERVER - case PRODUCT_STORAGE_ENTERPRISE_SERVER: + case NL_PRODUCT_STORAGE_ENTERPRISE_SERVER: OSString += " Storage Server Enterprise"; break; -#endif -#ifdef PRODUCT_SERVER_FOR_SMALLBUSINESS - case PRODUCT_SERVER_FOR_SMALLBUSINESS: + case NL_PRODUCT_SERVER_FOR_SMALLBUSINESS: OSString += " Essential Server Solutions"; break; -#endif -#ifdef PRODUCT_SMALLBUSINESS_SERVER_PREMIUM - case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: + case NL_PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: OSString += " Small Business Server Premium"; break; -#endif -#ifdef PRODUCT_HOME_PREMIUM_N - case PRODUCT_HOME_PREMIUM_N: + case NL_PRODUCT_HOME_PREMIUM_N: OSString += " Home Premium N"; break; -#endif -#ifdef PRODUCT_ENTERPRISE_N - case PRODUCT_ENTERPRISE_N: + case NL_PRODUCT_ENTERPRISE_N: OSString += " Enterprise N"; break; -#endif -#ifdef PRODUCT_ULTIMATE_N - case PRODUCT_ULTIMATE_N: + case NL_PRODUCT_ULTIMATE_N: OSString += " Ultimate N"; break; -#endif -#ifdef PRODUCT_WEB_SERVER_CORE - case PRODUCT_WEB_SERVER_CORE: + case NL_PRODUCT_WEB_SERVER_CORE: OSString += " Web Server (core installation)"; break; -#endif -#ifdef PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT - case PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT: + case NL_PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT: OSString += " Essential Business Server Management Server"; break; -#endif -#ifdef PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY - case PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY: + case NL_PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY: OSString += " Essential Business Server Security Server"; break; -#endif -#ifdef PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING - case PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING: + case NL_PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING: OSString += " Essential Business Server Messaging Server"; break; -#endif -#ifdef PRODUCT_SERVER_FOUNDATION - case PRODUCT_SERVER_FOUNDATION: + case NL_PRODUCT_SERVER_FOUNDATION: OSString += " Server Foundation"; break; -#endif -#ifdef PRODUCT_HOME_PREMIUM_SERVER - case PRODUCT_HOME_PREMIUM_SERVER: + case NL_PRODUCT_HOME_PREMIUM_SERVER: OSString += " Home Server"; break; -#endif -#ifdef PRODUCT_SERVER_FOR_SMALLBUSINESS_V - case PRODUCT_SERVER_FOR_SMALLBUSINESS_V: + case NL_PRODUCT_SERVER_FOR_SMALLBUSINESS_V: OSString += " Server without Hyper-V for Windows Essential Server Solutions"; break; -#endif -#ifdef PRODUCT_STANDARD_SERVER_V - case PRODUCT_STANDARD_SERVER_V: + case NL_PRODUCT_STANDARD_SERVER_V: OSString += " Server Standard without Hyper-V"; break; -#endif -#ifdef PRODUCT_DATACENTER_SERVER_V - case PRODUCT_DATACENTER_SERVER_V: + case NL_PRODUCT_DATACENTER_SERVER_V: OSString += " Server Datacenter without Hyper-V (full installation)"; break; -#endif -#ifdef PRODUCT_ENTERPRISE_SERVER_V - case PRODUCT_ENTERPRISE_SERVER_V: + case NL_PRODUCT_ENTERPRISE_SERVER_V: OSString += " Enterprise without Hyper-V (full installation)"; break; -#endif -#ifdef PRODUCT_DATACENTER_SERVER_CORE_V - case PRODUCT_DATACENTER_SERVER_CORE_V: + case NL_PRODUCT_DATACENTER_SERVER_CORE_V: OSString += " Datacenter without Hyper-V (core installation)"; break; -#endif -#ifdef PRODUCT_STANDARD_SERVER_CORE_V - case PRODUCT_STANDARD_SERVER_CORE_V: + case NL_PRODUCT_STANDARD_SERVER_CORE_V: OSString += " Standard without Hyper-V (core installation)"; break; -#endif -#ifdef PRODUCT_ENTERPRISE_SERVER_CORE_V - case PRODUCT_ENTERPRISE_SERVER_CORE_V: + case NL_PRODUCT_ENTERPRISE_SERVER_CORE_V: OSString += " Enterprise without Hyper-V (core installation)"; break; -#endif -#ifdef PRODUCT_HYPERV - case PRODUCT_HYPERV: + case NL_PRODUCT_HYPERV: OSString += " Hyper-V Server"; break; -#endif -#ifdef PRODUCT_STORAGE_EXPRESS_SERVER_CORE - case PRODUCT_STORAGE_EXPRESS_SERVER_CORE: + case NL_PRODUCT_STORAGE_EXPRESS_SERVER_CORE: OSString += " Storage Server Express (core installation)"; break; -#endif -#ifdef PRODUCT_STORAGE_STANDARD_SERVER_CORE - case PRODUCT_STORAGE_STANDARD_SERVER_CORE: + case NL_PRODUCT_STORAGE_STANDARD_SERVER_CORE: OSString += " Storage Server Standard (core installation)"; break; -#endif -#ifdef PRODUCT_STORAGE_WORKGROUP_SERVER_CORE - case PRODUCT_STORAGE_WORKGROUP_SERVER_CORE: + case NL_PRODUCT_STORAGE_WORKGROUP_SERVER_CORE: OSString += " Storage Server Workgroup (core installation)"; break; -#endif -#ifdef PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE - case PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE: + case NL_PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE: OSString += " Storage Server Enterprise (core installation)"; break; -#endif -#ifdef PRODUCT_STARTER_N - case PRODUCT_STARTER_N: + case NL_PRODUCT_STARTER_N: OSString += " Starter N Edition"; break; -#endif -#ifdef PRODUCT_PROFESSIONAL - case PRODUCT_PROFESSIONAL: + case NL_PRODUCT_PROFESSIONAL: OSString += " Professional"; break; -#endif -#ifdef PRODUCT_PROFESSIONAL_N - case PRODUCT_PROFESSIONAL_N: + case NL_PRODUCT_PROFESSIONAL_N: OSString += " Professional N"; break; -#endif -#ifdef PRODUCT_SB_SOLUTION_SERVER - case PRODUCT_SB_SOLUTION_SERVER: + case NL_PRODUCT_SB_SOLUTION_SERVER: OSString += " Small Business Server"; break; -#endif -#ifdef PRODUCT_SERVER_FOR_SB_SOLUTIONS - case PRODUCT_SERVER_FOR_SB_SOLUTIONS: + case NL_PRODUCT_SERVER_FOR_SB_SOLUTIONS: OSString += " Server For Small Business Solutions"; break; -#endif -#ifdef PRODUCT_STANDARD_SERVER_SOLUTIONS - case PRODUCT_STANDARD_SERVER_SOLUTIONS: + case NL_PRODUCT_STANDARD_SERVER_SOLUTIONS: OSString += " Server Solutions Premium"; break; -#endif -#ifdef PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE - case PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE: + case NL_PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE: OSString += " Server Solutions Premium (core installation)"; break; -#endif -#ifdef PRODUCT_SB_SOLUTION_SERVER_EM - case PRODUCT_SB_SOLUTION_SERVER_EM: + case NL_PRODUCT_SB_SOLUTION_SERVER_EM: OSString += " Server For Small Business Solutions EM"; break; -#endif -#ifdef PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM - case PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM: + case NL_PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM: OSString += " Server For Small Business Solutions EM"; break; -#endif - -#ifdef PRODUCT_SOLUTION_EMBEDDEDSERVER - case PRODUCT_SOLUTION_EMBEDDEDSERVER: + case NL_PRODUCT_SOLUTION_EMBEDDEDSERVER: OSString += " Solution Embedded Server (full installation)"; break; -#endif -#ifdef PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE - case PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE: + case NL_PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE: OSString += " Solution Embedded Server (core installation)"; break; -#endif -#ifdef PRODUCT_PROFESSIONAL_EMBEDDED - case PRODUCT_PROFESSIONAL_EMBEDDED: + case NL_PRODUCT_PROFESSIONAL_EMBEDDED: OSString += " Professional Embedded"; break; -#endif -#ifdef PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT - case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT: + case NL_PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT: OSString += " Essential Server Solution Management"; break; -#endif -#ifdef PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL - case PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL: + case NL_PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL: OSString += " Essential Server Solution Additional"; break; -#endif -#ifdef PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC - case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC: + case NL_PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC: OSString += " Essential Server Solution Management SVC"; break; -#endif -#ifdef PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC - case PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC: + case NL_PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC: OSString += " Essential Server Solution Additional SVC"; break; -#endif -#ifdef PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE - case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE: + case NL_PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE: OSString += " Small Business Server Premium (core installation)"; break; -#endif -#ifdef PRODUCT_CLUSTER_SERVER_V - case PRODUCT_CLUSTER_SERVER_V: + case NL_PRODUCT_CLUSTER_SERVER_V: OSString += " Server Hyper Core V"; break; -#endif -#ifdef PRODUCT_EMBEDDED - case PRODUCT_EMBEDDED: + case NL_PRODUCT_EMBEDDED: OSString += " Embedded"; break; -#endif -#ifdef PRODUCT_STARTER_E - case PRODUCT_STARTER_E: + case NL_PRODUCT_STARTER_E: OSString += " Starter E"; break; -#endif -#ifdef PRODUCT_HOME_BASIC_E - case PRODUCT_HOME_BASIC_E: + case NL_PRODUCT_HOME_BASIC_E: OSString += " Home Basic E"; break; -#endif -#ifdef PRODUCT_HOME_PREMIUM_E - case PRODUCT_HOME_PREMIUM_E: + case NL_PRODUCT_HOME_PREMIUM_E: OSString += " Home Premium E"; break; -#endif -#ifdef PRODUCT_PROFESSIONAL_E - case PRODUCT_PROFESSIONAL_E: + case NL_PRODUCT_PROFESSIONAL_E: OSString += " Professional E"; break; -#endif -#ifdef PRODUCT_ENTERPRISE_E - case PRODUCT_ENTERPRISE_E: + case NL_PRODUCT_ENTERPRISE_E: OSString += " Enterprise E"; break; -#endif -#ifdef PRODUCT_ULTIMATE_E - case PRODUCT_ULTIMATE_E: + case NL_PRODUCT_ULTIMATE_E: OSString += " Ultimate E"; break; -#endif -#ifdef PRODUCT_ENTERPRISE_EVALUATION - case PRODUCT_ENTERPRISE_EVALUATION: + case NL_PRODUCT_ENTERPRISE_EVALUATION: OSString += " Enterprise Evaluation"; break; -#endif -#ifdef PRODUCT_MULTIPOINT_STANDARD_SERVER - case PRODUCT_MULTIPOINT_STANDARD_SERVER: + // nothing from 0x49 to 0x4b + case NL_PRODUCT_MULTIPOINT_STANDARD_SERVER: OSString += " MultiPoint Server Standard (full installation)"; break; -#endif -#ifdef PRODUCT_MULTIPOINT_PREMIUM_SERVER - case PRODUCT_MULTIPOINT_PREMIUM_SERVER: + case NL_PRODUCT_MULTIPOINT_PREMIUM_SERVER: OSString += " MultiPoint Server Premium (full installation)"; break; -#endif -#ifdef PRODUCT_STANDARD_EVALUATION_SERVER - case PRODUCT_STANDARD_EVALUATION_SERVER: + case NL_PRODUCT_STANDARD_EVALUATION_SERVER: OSString += " Server Standard (evaluation installation)"; break; -#endif -#ifdef PRODUCT_DATACENTER_EVALUATION_SERVER - case PRODUCT_DATACENTER_EVALUATION_SERVER: + case NL_PRODUCT_DATACENTER_EVALUATION_SERVER: OSString += " Server Datacenter (evaluation installation)"; break; -#endif -#ifdef PRODUCT_ENTERPRISE_N_EVALUATION - case PRODUCT_ENTERPRISE_N_EVALUATION: + // nothing from 0x51 to 0x53 + case NL_PRODUCT_ENTERPRISE_N_EVALUATION: OSString += " Enterprise N (evaluation installation)"; break; -#endif -#ifdef PRODUCT_EMBEDDED_AUTOMOTIVE - case PRODUCT_EMBEDDED_AUTOMOTIVE: + case NL_PRODUCT_EMBEDDED_AUTOMOTIVE: OSString += " Embedded Automotive"; break; -#endif -#ifdef PRODUCT_EMBEDDED_INDUSTRY_A - case PRODUCT_EMBEDDED_INDUSTRY_A: + case NL_PRODUCT_EMBEDDED_INDUSTRY_A: OSString += " Embedded Industry A"; break; -#endif -#ifdef PRODUCT_THINPC - case PRODUCT_THINPC: + case NL_PRODUCT_THINPC: OSString += " Thin PC"; break; -#endif -#ifdef PRODUCT_EMBEDDED_A - case PRODUCT_EMBEDDED_A: + case NL_PRODUCT_EMBEDDED_A: OSString += " Embedded A"; break; -#endif -#ifdef PRODUCT_EMBEDDED_INDUSTRY - case PRODUCT_EMBEDDED_INDUSTRY: + case NL_PRODUCT_EMBEDDED_INDUSTRY: OSString += " Embedded Industry"; break; -#endif -#ifdef PRODUCT_EMBEDDED_E - case PRODUCT_EMBEDDED_E: + case NL_PRODUCT_EMBEDDED_E: OSString += " Embedded E"; break; -#endif -#ifdef PRODUCT_EMBEDDED_INDUSTRY_E - case PRODUCT_EMBEDDED_INDUSTRY_E: + case NL_PRODUCT_EMBEDDED_INDUSTRY_E: OSString += " Embedded Industry E"; break; -#endif -#ifdef PRODUCT_EMBEDDED_INDUSTRY_A_E - case PRODUCT_EMBEDDED_INDUSTRY_A_E: + case NL_PRODUCT_EMBEDDED_INDUSTRY_A_E: OSString += " Embedded Industry A E"; break; -#endif -#ifdef PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER - case PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER: + // nothing from 0x5d to 0x5e + case NL_PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER: OSString += " Storage Server Workgroup (evaluation installation)"; break; -#endif -#ifdef PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER - case PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER: + case NL_PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER: OSString += " Storage Server Standard (evaluation installation)"; break; -#endif -#ifdef PRODUCT_CORE_ARM - case PRODUCT_CORE_ARM: + case NL_PRODUCT_CORE_ARM: OSString += " RT"; break; -#endif -#ifdef PRODUCT_CORE_N - case PRODUCT_CORE_N: + case NL_PRODUCT_CORE_N: OSString += " Home N"; break; -#endif -#ifdef PRODUCT_CORE_COUNTRYSPECIFIC - case PRODUCT_CORE_COUNTRYSPECIFIC: + case NL_PRODUCT_CORE_COUNTRYSPECIFIC: OSString += " Home China"; break; -#endif -#ifdef PRODUCT_CORE_SINGLELANGUAGE - case PRODUCT_CORE_SINGLELANGUAGE: + case NL_PRODUCT_CORE_SINGLELANGUAGE: OSString += " Home Single Language"; break; -#endif -#ifdef PRODUCT_CORE - case PRODUCT_CORE: + case NL_PRODUCT_CORE: OSString += " Home"; break; -#endif -#ifdef PRODUCT_PROFESSIONAL_WMC - case PRODUCT_PROFESSIONAL_WMC: + // nothing at 0x66 + case NL_PRODUCT_PROFESSIONAL_WMC: OSString += " Professional with Media Center"; break; -#endif -#ifdef PRODUCT_MOBILE_CORE - case PRODUCT_MOBILE_CORE: + case NL_PRODUCT_MOBILE_CORE: OSString += " Mobile"; break; -#endif -#ifdef PRODUCT_EMBEDDED_INDUSTRY_EVAL - case PRODUCT_EMBEDDED_INDUSTRY_EVAL: + case NL_PRODUCT_EMBEDDED_INDUSTRY_EVAL: OSString += " Embedded Industry (evaluation installation)"; break; -#endif -#ifdef PRODUCT_EMBEDDED_INDUSTRY_E_EVAL - case PRODUCT_EMBEDDED_INDUSTRY_E_EVAL: + case NL_PRODUCT_EMBEDDED_INDUSTRY_E_EVAL: OSString += " Embedded Industry E (evaluation installation)"; break; -#endif -#ifdef PRODUCT_EMBEDDED_EVAL - case PRODUCT_EMBEDDED_EVAL: + case NL_PRODUCT_EMBEDDED_EVAL: OSString += " Embedded (evaluation installation)"; break; -#endif -#ifdef PRODUCT_EMBEDDED_E_EVAL - case PRODUCT_EMBEDDED_E_EVAL: + case NL_PRODUCT_EMBEDDED_E_EVAL: OSString += " Embedded E (evaluation installation)"; break; -#endif -#ifdef PRODUCT_CORE_SERVER - case PRODUCT_CORE_SERVER: + case NL_PRODUCT_CORE_SERVER: OSString += " Server"; break; -#endif -#ifdef PRODUCT_CLOUD_STORAGE_SERVER - case PRODUCT_CLOUD_STORAGE_SERVER: + case NL_PRODUCT_CLOUD_STORAGE_SERVER: OSString += " Server Could Storage"; break; -#endif -#ifdef PRODUCT_CORE_CONNECTED - case PRODUCT_CORE_CONNECTED: + case NL_PRODUCT_CORE_CONNECTED: OSString += " Home Connected"; break; -#endif -#ifdef PRODUCT_PROFESSIONAL_STUDENT - case PRODUCT_PROFESSIONAL_STUDENT: + case NL_PRODUCT_PROFESSIONAL_STUDENT: OSString += " Professional Student"; break; -#endif -#ifdef PRODUCT_CORE_CONNECTED_N - case PRODUCT_CORE_CONNECTED_N: + case NL_PRODUCT_CORE_CONNECTED_N: OSString += " Home N Connected"; break; -#endif -#ifdef PRODUCT_PROFESSIONAL_STUDENT_N - case PRODUCT_PROFESSIONAL_STUDENT_N: + case NL_PRODUCT_PROFESSIONAL_STUDENT_N: OSString += " Professional Student N"; break; -#endif -#ifdef PRODUCT_CORE_CONNECTED_SINGLELANGUAGE - case PRODUCT_CORE_CONNECTED_SINGLELANGUAGE: + case NL_PRODUCT_CORE_CONNECTED_SINGLELANGUAGE: OSString += " Home Single Language Connected"; break; -#endif -#ifdef PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC - case PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC: + case NL_PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC: OSString += " Home China Connected"; break; -#endif + case NL_PRODUCT_CONNECTED_CAR: + OSString += " Connected Car"; + break; + case NL_PRODUCT_INDUSTRY_HANDHELD: + OSString += " Industry Handheld"; + break; + case NL_PRODUCT_PPI_PRO: + OSString += " PPI Pro"; + break; + case NL_PRODUCT_ARM64_SERVER: + OSString += " ARM64 Server"; + break; + case NL_PRODUCT_EDUCATION: + OSString += " Education"; + break; + case NL_PRODUCT_EDUCATION_N: + OSString += " Education N"; + break; + case NL_PRODUCT_IOTUAP: + OSString += " IoT Core"; + break; + case NL_PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER: + OSString += " Cloud Host Infrastructure Server"; + break; + case NL_PRODUCT_ENTERPRISE_S: + OSString += " Product Enterprise S"; + break; + case NL_PRODUCT_ENTERPRISE_S_N: + OSString += " Enterprise S N"; + break; + case NL_PRODUCT_PROFESSIONAL_S: + OSString += " Professional S"; + break; + case NL_PRODUCT_PROFESSIONAL_S_N: + OSString += " Professional S N"; + break; + case NL_PRODUCT_ENTERPRISE_S_EVALUATION: + OSString += " Enterprise S Evaluation"; + break; + case NL_PRODUCT_ENTERPRISE_S_N_EVALUATION: + OSString += " Enterprise S N Evaluation"; + break; + // nothing from x83 to 0x86 + case NL_PRODUCT_HOLOGRAPHIC: + OSString += " Holographic"; + break; + // nothing from x88 to 0x89 + case NL_PRODUCT_PRO_SINGLE_LANGUAGE: + OSString += " Pro Single Language"; + break; + case NL_PRODUCT_PRO_CHINA: + OSString += " Pro China"; + break; + case NL_PRODUCT_ENTERPRISE_SUBSCRIPTION: + OSString += " Enterprise Subscription"; + break; + case NL_PRODUCT_ENTERPRISE_SUBSCRIPTION_N: + OSString += " Enterprise Subscription N"; + break; + // nothing at 0x8e + case NL_PRODUCT_DATACENTER_NANO_SERVER: + OSString += " Datacenter Nano Server"; + break; + case NL_PRODUCT_STANDARD_NANO_SERVER: + OSString += " Standard Nano Server"; + break; + case NL_PRODUCT_DATACENTER_A_SERVER_CORE: + OSString += " Datacenter A Server Core"; + break; + case NL_PRODUCT_STANDARD_A_SERVER_CORE: + OSString += " Standard A Server Core"; + break; + case NL_PRODUCT_DATACENTER_WS_SERVER_CORE: + OSString += " Datacenter WS Server Core"; + break; + case NL_PRODUCT_STANDARD_WS_SERVER_CORE: + OSString += " Standard WS Server Core"; + break; + case NL_PRODUCT_UTILITY_VM: + OSString += " Utility VM"; + break; + // nothing from 0x96 to 0x9e + case NL_PRODUCT_DATACENTER_EVALUATION_SERVER_CORE: + OSString += " Datacenter_evaluation_server_core"; + break; + case NL_PRODUCT_STANDARD_EVALUATION_SERVER_CORE: + OSString += " Standard Evaluation Server Core"; + break; + case NL_PRODUCT_PRO_WORKSTATION: + OSString += " Pro Workstation"; + break; + case NL_PRODUCT_PRO_WORKSTATION_N: + OSString += " Pro Workstation N"; + break; + // nothing at 0xa3 + case NL_PRODUCT_PRO_FOR_EDUCATION: + OSString += " Pro for Education"; + break; + case NL_PRODUCT_PRO_FOR_EDUCATION_N: + OSString += " Pro for Education N"; + break; + // nothing from 0xa6 to 0xa7 + case NL_PRODUCT_AZURE_SERVER_CORE: + OSString += " Azure Server Core"; + break; + case NL_PRODUCT_AZURE_NANO_SERVER: + OSString += " Azure Nano Server"; + break; + // nothing at 0xaa + case NL_PRODUCT_ENTERPRISEG: + OSString += " Enterprise G"; + break; + case NL_PRODUCT_ENTERPRISEGN: + OSString += " Enterprise GN"; + break; + // nothing from 0xad to 0xae + case NL_PRODUCT_SERVERRDSH: + OSString += " Server RDSH"; + break; + // nothing from 0xb0 to 0xb1 + case NL_PRODUCT_CLOUD: + OSString += " Cloud"; + break; + case NL_PRODUCT_CLOUDN: + OSString += " Cloud N"; + break; + default: OSString += toString(" Unknown Edition (0x%04x)", dwType); } @@ -1387,13 +1454,10 @@ uint64 CSystemInfo::availableHDSpace (const string &filename) std::string path = CFile::getPath(filename); #ifdef NL_OS_UNIX - struct stat stst; struct statfs stfs; + if (::statfs(path.c_str(), &stfs) != 0) return 0; - if (::stat(path.c_str(), &stst) == -1) return 0; - if (::statfs(path.c_str(), &stfs) == -1) return 0; - - return (uint64)(stfs.f_bavail * stst.st_blksize); + return (uint64)stfs.f_bavail * (uint64)stfs.f_bsize; #else ULARGE_INTEGER freeSpace = {0}; BOOL bRes = ::GetDiskFreeSpaceExW(utf8ToWide(path), &freeSpace, NULL, NULL); @@ -1525,7 +1589,7 @@ NLMISC_CATEGORISED_DYNVARIABLE(nel, string, AvailableHDSpace, "Hard drive space if (get) { *pointer = (CSystemInfo::availableHDSpace(location)); - location = ""; + location.clear(); } else { diff --git a/code/nel/src/misc/system_utils.cpp b/code/nel/src/misc/system_utils.cpp index 81bb5246b..480e1c9a1 100644 --- a/code/nel/src/misc/system_utils.cpp +++ b/code/nel/src/misc/system_utils.cpp @@ -76,12 +76,21 @@ namespace NLMISC { nlWindow CSystemUtils::s_window = EmptyWindow; +#ifdef NL_OS_WINDOWS +static bool s_mustUninit = false; +#endif + bool CSystemUtils::init() { #ifdef NL_OS_WINDOWS // initialize COM - HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); - if (FAILED(hr)) return false; + if (!s_mustUninit) + { + HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); + if (FAILED(hr)) return false; + + s_mustUninit = true; + } #endif return true; @@ -91,7 +100,12 @@ bool CSystemUtils::uninit() { #ifdef NL_OS_WINDOWS // uninitialize COM - CoUninitialize(); + if (s_mustUninit) + { + CoUninitialize(); + + s_mustUninit = false; + } #endif return true; diff --git a/code/nel/src/misc/task_manager.cpp b/code/nel/src/misc/task_manager.cpp index 4cdb16bd0..c4ec29288 100644 --- a/code/nel/src/misc/task_manager.cpp +++ b/code/nel/src/misc/task_manager.cpp @@ -37,7 +37,7 @@ CTaskManager::CTaskManager() : _RunningTask (""), _TaskQueue (""), _DoneTaskQueu _IsTaskRunning = false; _ThreadRunning = true; CSynchronized::CAccessor currentTask(&_RunningTask); - currentTask.value () = ""; + currentTask.value ().clear(); _Thread = IThread::create(this); _Thread->start(); _ChangePriorityCallback = NULL; @@ -111,7 +111,7 @@ void CTaskManager::run(void) CSynchronized::CAccessor currentTask(&_RunningTask); CSynchronized >::CAccessor doneTask(&_DoneTaskQueue); doneTask.value().push_front (currentTask.value ()); - currentTask.value () = ""; + currentTask.value ().clear(); if (doneTask.value().size () > NLMISC_DONE_TASK_SIZE) doneTask.value().resize (NLMISC_DONE_TASK_SIZE); } diff --git a/code/nel/src/misc/uv.cpp b/code/nel/src/misc/uv.cpp deleted file mode 100644 index 9926efcc7..000000000 --- a/code/nel/src/misc/uv.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/uv.h" - - -// leave not static else this workaround don't work -void dummyToAvoidStupidCompilerWarning_misc_uv_cpp() -{ -} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC -{ - - - -} // NLMISC diff --git a/code/nel/src/misc/value_smoother.cpp b/code/nel/src/misc/value_smoother.cpp deleted file mode 100644 index 12de7842b..000000000 --- a/code/nel/src/misc/value_smoother.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/value_smoother.h" - -// remove stupid VC6 warnings -void foo_value_smoother_cpp() {} diff --git a/code/nel/src/misc/vector_2d.cpp b/code/nel/src/misc/vector_2d.cpp deleted file mode 100644 index 939e41239..000000000 --- a/code/nel/src/misc/vector_2d.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/vector_2d.h" - - -// leave not static else this workaround don't work -void dummyToAvoidStupidCompilerWarning_misc_vector_2d_cpp() -{ -} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC -{ - - - -} // NLMISC diff --git a/code/nel/src/misc/vector_h.cpp b/code/nel/src/misc/vector_h.cpp deleted file mode 100644 index 67eb41f6b..000000000 --- a/code/nel/src/misc/vector_h.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/vector_h.h" - - -// leave not static else this workaround don't work -void dummyToAvoidStupidCompilerWarning_misc_vector_h_cpp() -{ -} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - - -} // NLMISC diff --git a/code/nel/src/misc/win32_util.cpp b/code/nel/src/misc/win32_util.cpp index 7631ac7b2..a99ca57d7 100644 --- a/code/nel/src/misc/win32_util.cpp +++ b/code/nel/src/misc/win32_util.cpp @@ -40,7 +40,10 @@ void CWin32Util::localizeWindow(HWND wnd) std::string winText = wideToUtf8(str); if (CI18N::hasTranslation(winText)) { - SetWindowTextW(wnd, (const WCHAR *) CI18N::get(winText).c_str()); + if (!SetWindowTextW(wnd, (const WCHAR *) CI18N::get(winText).c_str())) + { + nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str()); + } } } HWND currSon = GetWindow(wnd, GW_CHILD); diff --git a/code/nel/src/misc/win_displayer.cpp b/code/nel/src/misc/win_displayer.cpp index c9e81bbb3..d350f25f3 100644 --- a/code/nel/src/misc/win_displayer.cpp +++ b/code/nel/src/misc/win_displayer.cpp @@ -156,7 +156,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) string str; while (*pos2 != '\0') { - str = ""; + str.clear(); // get the string while (*pos2 != '\0' && *pos2 != '\n') @@ -217,8 +217,13 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ucstring ucs; // convert the text from UTF-8 to unicode ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]); + // set the text as unicode string - SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str()); + if (!SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str())) + { + nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str()); + } + SendMessageA (cwd->_HInputEdit, EM_SETSEL, (WPARAM)ucs.size(), (LPARAM)ucs.size()); } } @@ -234,8 +239,13 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ucstring ucs; // convert the text from UTF-8 to unicode ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]); + // set the text as unicode string - SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str()); + if (!SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str())) + { + nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str()); + } + SendMessageA (cwd->_HInputEdit, EM_SETSEL, (WPARAM)ucs.size(), (LPARAM)ucs.size()); } } @@ -352,7 +362,10 @@ void CWinDisplayer::setTitleBar (const string &titleBar) nldebug("SERVICE: Set title bar to '%s'", wn.c_str()); - SetWindowTextW (_HWnd, (LPWSTR)ucstring::makeFromUtf8(wn).c_str()); + if (!SetWindowTextW(_HWnd, (LPWSTR)ucstring::makeFromUtf8(wn).c_str())) + { + nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str()); + } } void CWinDisplayer::open (string titleBar, bool iconified, sint x, sint y, sint w, sint h, sint hs, sint fs, const std::string &fn, bool ww, CLog *log) @@ -489,7 +502,7 @@ void CWinDisplayer::clear () SendMessageW (_HEdit, EM_SETSEL, 0, nIndex); // clear all the text - SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LPARAM) ""); + SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LPARAM) L""); SendMessageW(_HEdit,EM_SETMODIFY,(WPARAM)TRUE,(LPARAM)0); @@ -562,7 +575,7 @@ void CWinDisplayer::display_main () LRESULT oldIndex2 = SendMessageW (_HEdit, EM_LINEINDEX, nblineremove, 0); //nlassert (oldIndex2 != -1); SendMessageW (_HEdit, EM_SETSEL, oldIndex1, oldIndex2); - SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LPARAM) ""); + SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LPARAM) L""); // update the selection due to the erasing sint dt = (sint)(oldIndex2 - oldIndex1); diff --git a/code/nel/src/misc/win_tray.cpp b/code/nel/src/misc/win_tray.cpp deleted file mode 100644 index 73e837813..000000000 --- a/code/nel/src/misc/win_tray.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" diff --git a/code/nel/src/misc/words_dictionary.cpp b/code/nel/src/misc/words_dictionary.cpp index 4d5057dd7..f0e7751ea 100644 --- a/code/nel/src/misc/words_dictionary.cpp +++ b/code/nel/src/misc/words_dictionary.cpp @@ -23,12 +23,12 @@ using namespace std; -const string DefaultColTitle = "name"; - #ifdef DEBUG_NEW - #define new DEBUG_NEW +#define new DEBUG_NEW #endif +const string DefaultColTitle = "name"; + namespace NLMISC { NL_INSTANCE_COUNTER_IMPL(CWordsDictionary); diff --git a/code/nel/src/misc/xml_auto_ptr.cpp b/code/nel/src/misc/xml_auto_ptr.cpp index fbf681e1c..2315cd52b 100644 --- a/code/nel/src/misc/xml_auto_ptr.cpp +++ b/code/nel/src/misc/xml_auto_ptr.cpp @@ -21,6 +21,10 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + //======================================= void CXMLAutoPtr::destroy() { diff --git a/code/nel/src/net/CMakeLists.txt b/code/nel/src/net/CMakeLists.txt index d045d47e8..a3a909ea6 100644 --- a/code/nel/src/net/CMakeLists.txt +++ b/code/nel/src/net/CMakeLists.txt @@ -9,8 +9,8 @@ IF(WITH_GTK) IF(GTK2_FOUND) INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS}) ADD_DEFINITIONS(-DNL_USE_GTK) - ENDIF(GTK2_FOUND) -ENDIF(WITH_GTK) + ENDIF() +ENDIF() TARGET_LINK_LIBRARIES(nelnet nelmisc) NL_DEFAULT_PROPS(nelnet "NeL, Library: NeL Net") @@ -20,10 +20,10 @@ NL_ADD_LIB_SUFFIX(nelnet) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nelnet ${CMAKE_CURRENT_SOURCE_DIR}/stdnet.h ${CMAKE_CURRENT_SOURCE_DIR}/stdnet.cpp) -ENDIF(WITH_PCH) +ENDIF() NL_GEN_PC(nel-net.pc) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nelnet LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/src/net/admin.cpp b/code/nel/src/net/admin.cpp index 89981a697..4389e0f34 100644 --- a/code/nel/src/net/admin.cpp +++ b/code/nel/src/net/admin.cpp @@ -381,7 +381,7 @@ void serviceGetView (uint32 rid, const string &rawvarpath, TAdminViewResult &ans if (CCommandRegistry::getInstance().isNamedCommandHandler(varpath.Destination[0].first)) { varpath.Destination[0].first += "."+varpath.Destination[0].second; - varpath.Destination[0].second = ""; + varpath.Destination[0].second.clear(); } if (varpath.isFinal()) @@ -782,13 +782,13 @@ void setInformation (const vector &alarms, const vector &graphup for (i = 0; i < alarms.size(); i+=3) { CVarPath shardvarpath (alarms[i]); - if(shardvarpath.Destination.size() == 0 || shardvarpath.Destination[0].second.empty()) + if(shardvarpath.Destination.empty() || shardvarpath.Destination[0].second.empty()) continue; CVarPath servervarpath (shardvarpath.Destination[0].second); - if(servervarpath.Destination.size() == 0 || servervarpath.Destination[0].second.empty()) + if(servervarpath.Destination.empty() || servervarpath.Destination[0].second.empty()) continue; CVarPath servicevarpath (servervarpath.Destination[0].second); - if(servicevarpath.Destination.size() == 0 || servicevarpath.Destination[0].second.empty()) + if(servicevarpath.Destination.empty() || servicevarpath.Destination[0].second.empty()) continue; string name = servicevarpath.Destination[0].second; @@ -817,13 +817,13 @@ void setInformation (const vector &alarms, const vector &graphup for (i = 0; i < graphupdate.size(); i+=2) { CVarPath shardvarpath (graphupdate[i]); - if(shardvarpath.Destination.size() == 0 || shardvarpath.Destination[0].second.empty()) + if(shardvarpath.Destination.empty() || shardvarpath.Destination[0].second.empty()) continue; CVarPath servervarpath (shardvarpath.Destination[0].second); - if(servervarpath.Destination.size() == 0 || servervarpath.Destination[0].second.empty()) + if(servervarpath.Destination.empty() || servervarpath.Destination[0].second.empty()) continue; CVarPath servicevarpath (servervarpath.Destination[0].second); - if(servicevarpath.Destination.size() == 0 || servicevarpath.Destination[0].second.empty()) + if(servicevarpath.Destination.empty() || servicevarpath.Destination[0].second.empty()) continue; string VarName = servicevarpath.Destination[0].second; diff --git a/code/nel/src/net/buf_client.cpp b/code/nel/src/net/buf_client.cpp index 350b2d6db..18ce7babf 100644 --- a/code/nel/src/net/buf_client.cpp +++ b/code/nel/src/net/buf_client.cpp @@ -32,6 +32,10 @@ # include #endif +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; using namespace std; diff --git a/code/nel/src/net/buf_sock.cpp b/code/nel/src/net/buf_sock.cpp index c419e1aa2..b3d6d7acb 100644 --- a/code/nel/src/net/buf_sock.cpp +++ b/code/nel/src/net/buf_sock.cpp @@ -84,7 +84,7 @@ CBufSock::~CBufSock() delete Sock; // the socket disconnects automatically if needed // destroy the structur to be sure that other people will not access to this anymore - AuthorizedCallback = ""; + AuthorizedCallback.clear(); Sock = NULL; _KnowConnected = false; _LastFlushTime = 0; @@ -131,7 +131,7 @@ string stringFromVectorPart( const vector& v, uint32 pos, uint32 len ) * (see CNonBlockingBufSock), if all the data could not be sent immediately, * the returned nbBytesRemaining value is non-zero. * \param nbBytesRemaining If the pointer is not NULL, the method sets the number of bytes still pending after the flush attempt. - * \returns False if an error has occured (e.g. the remote host is disconnected). + * \returns False if an error has occurred (e.g. the remote host is disconnected). * To retrieve the reason of the error, call CSock::getLastError() and/or CSock::errorString() * * Note: this method works with both blocking and non-blocking sockets @@ -270,7 +270,7 @@ void CBufSock::setTimeFlushTrigger( sint32 ms ) /* - * Update the network sending (call this method evenly). Returns false if an error occured. + * Update the network sending (call this method evenly). Returns false if an error occurred. */ bool CBufSock::update() { diff --git a/code/nel/src/net/email.cpp b/code/nel/src/net/email.cpp index 9ac22c886..f402edd65 100644 --- a/code/nel/src/net/email.cpp +++ b/code/nel/src/net/email.cpp @@ -196,15 +196,8 @@ bool sendEmail (const string &smtpServer, const string &from, const string &to, // we must skip the first line formatedBody = "\r\n"; - // replace \n with \r\n - for (i = 0; i < body.size(); i++) - { - if (body[i] == '\n' && i > 0 && body[i-1] != '\r') - { - formatedBody += '\r'; - } - formatedBody += body[i]; - } + // replace \n by \r\n + formatedBody += addSlashR(body); // add attachment if any if (!attachedFile.empty()) diff --git a/code/nel/src/net/inet_address.cpp b/code/nel/src/net/inet_address.cpp index 093bf8dcb..13ae02c39 100644 --- a/code/nel/src/net/inet_address.cpp +++ b/code/nel/src/net/inet_address.cpp @@ -121,6 +121,10 @@ BOOLEAN IN6_IS_ADDR_UNSPECIFIED(CONST IN6_ADDR *a) using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + #ifndef NI_MAXHOST # define NI_MAXHOST 1025 #endif diff --git a/code/nel/src/net/login_client.cpp b/code/nel/src/net/login_client.cpp index 71ffc6825..0f4383e16 100644 --- a/code/nel/src/net/login_client.cpp +++ b/code/nel/src/net/login_client.cpp @@ -127,7 +127,7 @@ string CLoginClient::authenticate(const string &loginServiceAddr, const ucstring string CLoginClient::authenticateBegin(const string &loginServiceAddr, const ucstring &login, const string &cpassword, const string &application) { - VerifyLoginPasswordReason = ""; + VerifyLoginPasswordReason.clear(); VerifyLoginPassword = false; // S01: connect to the LS @@ -355,7 +355,7 @@ string CLoginClient::selectShardBegin(sint32 shardId) { nlassert(_LSCallbackClient != 0 && _LSCallbackClient->connected()); - ShardChooseShardReason = ""; + ShardChooseShardReason.clear(); ShardChooseShard = false; if (ShardList.empty()) diff --git a/code/nel/src/net/login_server.cpp b/code/nel/src/net/login_server.cpp index 5bd6dfd34..ff7d992c4 100644 --- a/code/nel/src/net/login_server.cpp +++ b/code/nel/src/net/login_server.cpp @@ -157,7 +157,7 @@ void cbWSChooseShard (CMessage &msgin, const std::string &/* serviceName */, TSe // add it to the awaiting client nlinfo ("LS: New cookie %s (name '%s' priv '%s' extended '%s' instance %u slot %u) inserted in the pending user list (awaiting new client)", cookie.toString().c_str(), userName.c_str(), userPriv.c_str(), userExtended.c_str(), instanceId, charSlot); PendingUsers.push_back (CPendingUser (cookie, userName, userPriv, userExtended, instanceId, charSlot)); - reason = ""; + reason.clear(); // callback if needed if (NewCookieCallback != NULL) @@ -233,7 +233,7 @@ void cbShardValidation (CMessage &msgin, TSockId from, CCallbackNetBase &netbase // if the cookie is not valid and we accept them, clear the error if(AcceptInvalidCookie && !reason.empty()) { - reason = ""; + reason.clear(); cookie.set (rand(), rand(), rand()); } @@ -425,7 +425,8 @@ void CLoginServer::addNewCookieCallback(TNewCookieCallback newCookieCb) string CLoginServer::isValidCookie (const CLoginCookie &lc, string &userName, string &userPriv, string &userExtended, uint32 &instanceId, uint32 &charSlot) { - userName = userPriv = ""; + userName.clear(); + userPriv.clear(); if (!AcceptInvalidCookie && !lc.isValid()) return "The cookie is invalid"; diff --git a/code/nel/src/net/message_recorder.cpp b/code/nel/src/net/message_recorder.cpp index 2f27be151..7b5412492 100644 --- a/code/nel/src/net/message_recorder.cpp +++ b/code/nel/src/net/message_recorder.cpp @@ -159,7 +159,7 @@ void CMessageRecorder::recordNext( sint64 updatecounter, TNetworkEvent event, TS void CMessageRecorder::stopRecord() { _File.close(); - _Filename = ""; + _Filename.clear(); } @@ -395,7 +395,7 @@ TNetworkEvent CMessageRecorder::replayConnectionAttempt( const CInetAddress& add void CMessageRecorder::stopReplay() { _File.close(); - _Filename = ""; + _Filename.clear(); } diff --git a/code/nel/src/net/module.cpp b/code/nel/src/net/module.cpp index b0e21308f..1b5e03bec 100644 --- a/code/nel/src/net/module.cpp +++ b/code/nel/src/net/module.cpp @@ -24,6 +24,10 @@ #include "nel/net/module_gateway.h" #include "nel/net/module_socket.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; using namespace NLNET; @@ -879,7 +883,7 @@ namespace NLNET throw EModuleNotReachable(); } - _Gateway->sendModuleMessage(senderProx, this, message); + _Gateway->sendModuleProxyMessage(senderProx, this, message); } const TSecurityData *CModuleProxy::findSecurityData(uint8 dataTag) const diff --git a/code/nel/src/net/module_common.cpp b/code/nel/src/net/module_common.cpp index 0133343dd..aacf80a93 100644 --- a/code/nel/src/net/module_common.cpp +++ b/code/nel/src/net/module_common.cpp @@ -195,7 +195,7 @@ namespace NLNET vector parts; NLMISC::explode(name, string("."), parts); - if (name.size() > 0) + if (!name.empty()) { // at least one part in the name // check if sub ojbcct exist @@ -208,12 +208,12 @@ namespace NLNET sub = SubParams.back(); } - if (name.size() > 0) + if (!name.empty()) { // name is more deep, need to resurse parts.erase(parts.begin()); - CSString subName; - subName.join(reinterpret_cast(parts), "."); + std::string subName; + join(parts, ".", subName); sub->setParam(subName, value); } else diff --git a/code/nel/src/net/module_gateway.cpp b/code/nel/src/net/module_gateway.cpp index 074dd78cd..81ba76859 100644 --- a/code/nel/src/net/module_gateway.cpp +++ b/code/nel/src/net/module_gateway.cpp @@ -627,7 +627,7 @@ namespace NLNET if (from->NextMessageType != CModuleMessageHeaderCodec::mt_invalid) { // this message must be dispatched to a module - onReceiveModuleMessage(from, msgin); + onReceiveModuleMessageFromGateway(from, msgin); } // Not a module message, dispatch the gateway message else if (msgin.getName() == "MOD_OP") @@ -813,7 +813,7 @@ namespace NLNET /***********************************/ /** A gateway receive module operation */ - void onReceiveModuleMessage(CGatewayRoute *from, const CMessage &msgin) + void onReceiveModuleMessageFromGateway(CGatewayRoute *from, const CMessage &msgin) { H_AUTO(CModuleGetaway_onReceiveModuleMessage); // clean the message type now, any return path will be safe @@ -843,7 +843,7 @@ namespace NLNET addresseeProxy = it->second; // give the message to the gateway (either for local dispatch or for forwarding) - sendModuleMessage(senderProxy, addresseeProxy, msgin); + sendModuleProxyMessage(senderProxy, addresseeProxy, msgin); } // A gateway receive a module message header @@ -1293,7 +1293,7 @@ namespace NLNET } - virtual void sendModuleMessage(IModuleProxy *senderProxy, IModuleProxy *addresseeProxy, const NLNET::CMessage &message) + virtual void sendModuleProxyMessage(IModuleProxy *senderProxy, IModuleProxy *addresseeProxy, const NLNET::CMessage &message) { H_AUTO(CModuleGetaway_sendModuleMessage); // manage firewall @@ -1581,7 +1581,7 @@ namespace NLNET IModuleProxy *destProx = it2->second; - sendModuleMessage(senderProx, destProx, message); + sendModuleProxyMessage(senderProx, destProx, message); } virtual void _broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) diff --git a/code/nel/src/net/module_gateway_transport.cpp b/code/nel/src/net/module_gateway_transport.cpp index cda4e8e81..d9029285f 100644 --- a/code/nel/src/net/module_gateway_transport.cpp +++ b/code/nel/src/net/module_gateway_transport.cpp @@ -27,6 +27,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLNET @@ -69,7 +72,7 @@ namespace NLNET friend class CL3ServerRoute; public: /// The callback server that receive connection and dispatch message - auto_ptr _CallbackServer; + CUniquePtr _CallbackServer; /// A static mapper to retrieve transport from the CCallbackServer pointer typedef map TDispatcherIndex; @@ -221,7 +224,7 @@ namespace NLNET throw ETransportError("openServer : The server is already open"); // create a new callback server - auto_ptr cbs = auto_ptr (new CCallbackServer()); + CUniquePtr cbs(new CCallbackServer()); // register the callbacks cbs->setConnectionCallback(cbConnection, static_cast(this)); @@ -231,7 +234,7 @@ namespace NLNET // open the server cbs->init(port); - _CallbackServer = cbs; + _CallbackServer = CUniquePtrMove(cbs); // register it in the dispatcher _DispatcherIndex.insert(make_pair(_CallbackServer.get(), this)); @@ -670,7 +673,7 @@ namespace NLNET _FreeRoutesIds.pop_back(); } - auto_ptr route = auto_ptr(new CL3ClientRoute(this, addr, connId)); + CUniquePtr route(new CL3ClientRoute(this, addr, connId)); // set the callbacks route->CallbackClient.setDisconnectionCallback(cbDisconnection, static_cast(this)); diff --git a/code/nel/src/net/module_local_gateway.cpp b/code/nel/src/net/module_local_gateway.cpp index 3c66c5dcc..3446c0663 100644 --- a/code/nel/src/net/module_local_gateway.cpp +++ b/code/nel/src/net/module_local_gateway.cpp @@ -287,7 +287,7 @@ namespace NLNET // virtual void onReceiveModuleMessage(TModuleGatewayProxyPtr &senderGateway, TModuleMessagePtr &message) // { // } - virtual void sendModuleMessage(IModuleProxy * /* senderProxy */, IModuleProxy * /* addresseeProxy */, const CMessage &/* message */) + virtual void sendModuleProxyMessage(IModuleProxy * /* senderProxy */, IModuleProxy * /* addresseeProxy */, const CMessage &/* message */) { } virtual void dispatchModuleMessage(IModuleProxy * /* senderProxy */, IModuleProxy * /* addresseeProxy */, const CMessage &/* message */) diff --git a/code/nel/src/net/module_manager.cpp b/code/nel/src/net/module_manager.cpp index 0b17738b1..20c947d03 100644 --- a/code/nel/src/net/module_manager.cpp +++ b/code/nel/src/net/module_manager.cpp @@ -250,7 +250,7 @@ namespace NLNET // now, load the library string fullName = NLMISC::CPath::standardizePath(path)+CLibrary::makeLibName(shortName); - std::auto_ptr mli = auto_ptr(new TModuleLibraryInfo); + CUniquePtr mli(new TModuleLibraryInfo); if (!mli->LibraryHandler.loadLibrary(fullName, false, true, true)) { nlwarning("CModuleManager : failed to load the library '%s' in '%s'", @@ -399,7 +399,7 @@ namespace NLNET IModuleFactory *mf = it->second; // sanity check nlassert(mf->getModuleClassName() == className); - std::auto_ptr module = auto_ptr(mf->createModule()); + CUniquePtr module(mf->createModule()); if (module.get() == NULL) { nlwarning("createModule : factory failed to create a module instance for class '%s'", className.c_str()); @@ -623,7 +623,7 @@ namespace NLNET const std::string &moduleManifest, TModuleId foreignModuleId) { - std::auto_ptr modProx = auto_ptr(new CModuleProxy(localModule, ++_LastGeneratedId, moduleClassName, moduleFullyQualifiedName, moduleManifest)); + CUniquePtr modProx(new CModuleProxy(localModule, ++_LastGeneratedId, moduleClassName, moduleFullyQualifiedName, moduleManifest)); modProx->_Gateway = gateway; modProx->_Route = route; modProx->_Distance = distance; diff --git a/code/nel/src/net/naming_client.cpp b/code/nel/src/net/naming_client.cpp index a54fddaa0..7e2fd5ec9 100644 --- a/code/nel/src/net/naming_client.cpp +++ b/code/nel/src/net/naming_client.cpp @@ -128,7 +128,7 @@ void cbRegisterBroadcast (CMessage &msgin, TSockId /* from */, CCallbackNetBase std::vector addrs; CNamingClient::find (sid, addrs); - if (addrs.size() == 0) + if (addrs.empty()) { CNamingClient::RegisteredServicesMutex.enter (); CNamingClient::RegisteredServices.push_back (CNamingClient::CServiceEntry (name, sid, addr)); diff --git a/code/nel/src/net/service.cpp b/code/nel/src/net/service.cpp index 989f94d81..24064db55 100644 --- a/code/nel/src/net/service.cpp +++ b/code/nel/src/net/service.cpp @@ -1453,7 +1453,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName, } if (dispName.empty()) - str = ""; + str.clear(); else str = dispName + ": "; diff --git a/code/nel/src/net/sock.cpp b/code/nel/src/net/sock.cpp index 0e2329733..4b736e541 100644 --- a/code/nel/src/net/sock.cpp +++ b/code/nel/src/net/sock.cpp @@ -63,6 +63,10 @@ typedef int SOCKET; using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLNET { @@ -149,7 +153,7 @@ void CSock::releaseNetwork() } -/* Returns the code of the last error that has occured. +/* Returns the code of the last error that has occurred. * Note: This code is platform-dependant. On Unix, it is errno; on Windows it is the Winsock error code. * See also errorString() */ @@ -497,9 +501,9 @@ CSock::TSockResult CSock::receive( uint8 *buffer, uint32& len, bool throw_except if ( _NonBlocking ) { // Receive incoming message (only the received part) - TTicks before = CTime::getPerformanceTime(); - len = ::recv( _Sock, (char*)buffer, len, 0 ); + + sint retLen = ::recv( _Sock, (char*)buffer, len, 0 ); //nlinfo ("CSock::receive(): NBM Received %d bytes to %d res: %d (%d)", realLen, _Sock, len, ERROR_NUM); @@ -509,7 +513,8 @@ CSock::TSockResult CSock::receive( uint8 *buffer, uint32& len, bool throw_except } _MaxReceiveTime = max( (uint32)(CTime::ticksToSecond(CTime::getPerformanceTime()-before)*1000.0f), _MaxReceiveTime ); - switch ( len ) + + switch (retLen) { // Graceful disconnection case 0 : @@ -546,12 +551,14 @@ CSock::TSockResult CSock::receive( uint8 *buffer, uint32& len, bool throw_except } } } + + len = (uint32)retLen; } else // Blocking Mode { // Receive incoming message, waiting until a complete message has arrived uint total = 0; - uint brecvd; + sint brecvd; while ( total < len ) { diff --git a/code/nel/src/net/stdnet.h b/code/nel/src/net/stdnet.h index 16e87c9f8..6ced991a5 100644 --- a/code/nel/src/net/stdnet.h +++ b/code/nel/src/net/stdnet.h @@ -17,20 +17,11 @@ #ifndef NL_STDNET_H #define NL_STDNET_H -#include "nel/misc/types_nl.h" - -#ifdef NL_OS_WINDOWS -# define WIN32_LEAN_AND_MEAN -# define _WIN32_WINDOWS 0x0500 -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0500 -# endif -# ifndef NL_COMP_MINGW -# define WINVER 0x0500 -# define NOMINMAX -# endif -# include -# include +#if defined(_MSC_VER) && defined(_DEBUG) +#define _CRTDBG_MAP_ALLOC +#include +#include +#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #endif #include @@ -55,6 +46,7 @@ #include +#include "nel/misc/types_nl.h" #include "nel/misc/debug.h" #include "nel/misc/common.h" #include "nel/misc/stream.h" @@ -64,4 +56,18 @@ #include "nel/misc/mem_stream.h" #include "nel/misc/hierarchical_timer.h" +#ifdef NL_OS_WINDOWS +# define WIN32_LEAN_AND_MEAN +# define _WIN32_WINDOWS 0x0500 +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0500 +# endif +# ifndef NL_COMP_MINGW +# define WINVER 0x0500 +# define NOMINMAX +# endif +# include +# include +#endif + #endif diff --git a/code/nel/src/net/transport_class.cpp b/code/nel/src/net/transport_class.cpp index 810ea6928..9dade0190 100644 --- a/code/nel/src/net/transport_class.cpp +++ b/code/nel/src/net/transport_class.cpp @@ -33,6 +33,9 @@ #include "nel/net/transport_class.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif // // Namespace diff --git a/code/nel/src/net/udp_sim_sock.cpp b/code/nel/src/net/udp_sim_sock.cpp index c9fb73e97..fabb037d3 100644 --- a/code/nel/src/net/udp_sim_sock.cpp +++ b/code/nel/src/net/udp_sim_sock.cpp @@ -116,7 +116,7 @@ void CUdpSimSock::sendUDP (const uint8 *buffer, uint32& len, const CInetAddress CBufferizedOutPacket *bp = new CBufferizedOutPacket (&UdpSock, buffer, len, lag, addr); // duplicate the packet - if ((float)rand()/(float)(RAND_MAX)*100.0f < _OutPacketDisordering && _BufferizedOutPackets.size() > 0) + if ((float)rand()/(float)(RAND_MAX)*100.0f < _OutPacketDisordering && !_BufferizedOutPackets.empty()) { CBufferizedOutPacket *bp2 = _BufferizedOutPackets.back(); diff --git a/code/nel/src/net/unified_network.cpp b/code/nel/src/net/unified_network.cpp index ee882f547..2589e1cbf 100644 --- a/code/nel/src/net/unified_network.cpp +++ b/code/nel/src/net/unified_network.cpp @@ -828,17 +828,17 @@ void CUnifiedNetwork::addService(const string &name, const vector for (uint i = 0; i < addr.size(); i++) { // first we have to look if we have a network that can established the connection - uint j = 0; + // it's loopback ip address, it's ok if (!addr[i].isLoopbackIPAddress()) { - // it's loopback ip address, it's ok for (j = 0; j < laddr.size (); j++) { if (laddr[j].internalNetAddress () == addr[i].internalNetAddress ()) { - break; // it's ok, we can try + // it's ok, we can try + break; } } @@ -1272,7 +1272,8 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid) uint8 connectionId = _IdCnx[sid.get()].DefaultNetwork; if (nid == 0xFF) - { // default network + { + // default network //nldebug ("HNETL5: nid %hu, will use the default connection %hu", (uint16)nid, (uint16)connectionId); } else if (nid >= _IdCnx[sid.get()].NetworkConnectionAssociations.size()) @@ -1293,7 +1294,6 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid) if (connectionId >= _IdCnx[sid.get()].Connections.size() || !_IdCnx[sid.get()].Connections[connectionId].valid() || !_IdCnx[sid.get()].Connections[connectionId].CbNetBase->connected()) { - if (nid != 0xFF) { // not a default network. There's a problem with the selected connectionID, so try to find a valid one diff --git a/code/nel/src/net/varpath.cpp b/code/nel/src/net/varpath.cpp index 729f52074..857af5c64 100644 --- a/code/nel/src/net/varpath.cpp +++ b/code/nel/src/net/varpath.cpp @@ -167,7 +167,7 @@ void CVarPath::decode () if (val == "=") { srv += val + RawVarPath.substr (TokenPos); - var = ""; + var.clear(); } else var = RawVarPath.substr (TokenPos); @@ -181,8 +181,8 @@ void CVarPath::decode () bool CVarPath::isFinal () { - if(Destination.size() == 0) return true; - if(Destination[0].second.size() == 0) return true; + if(Destination.empty()) return true; + if(Destination[0].second.empty()) return true; return false; } diff --git a/code/nel/src/pacs/CMakeLists.txt b/code/nel/src/pacs/CMakeLists.txt index b0e1a9281..70a80500a 100644 --- a/code/nel/src/pacs/CMakeLists.txt +++ b/code/nel/src/pacs/CMakeLists.txt @@ -15,10 +15,10 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nelpacs ${CMAKE_CURRENT_SOURCE_DIR}/stdpacs.h ${CMAKE_CURRENT_SOURCE_DIR}/stdpacs.cpp) -ENDIF(WITH_PCH) +ENDIF() NL_GEN_PC(nel-pacs.pc) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nelpacs LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/src/pacs/build_indoor.cpp b/code/nel/src/pacs/build_indoor.cpp index b4bad19a6..ca14eb7cf 100644 --- a/code/nel/src/pacs/build_indoor.cpp +++ b/code/nel/src/pacs/build_indoor.cpp @@ -631,7 +631,7 @@ bool computeRetriever(CCollisionMeshBuild &cmb, CLocalRetriever &lr, CVector &tr { nlwarning("Edge issues reported !!"); uint i; - error = ""; + error.clear(); for (i=0; i 0) + if (edges[i].Link != -1 && !cd.empty()) { nlwarning ("In NLPACS::CEdgeQuad::build()"); nlwarning ("ERROR: exterior edge %d with interior link crosses some surfaces", i); diff --git a/code/nel/src/pacs/global_retriever.cpp b/code/nel/src/pacs/global_retriever.cpp index 27b32fbf1..73691e19d 100644 --- a/code/nel/src/pacs/global_retriever.cpp +++ b/code/nel/src/pacs/global_retriever.cpp @@ -313,7 +313,7 @@ void NLPACS::CGlobalRetriever::getBorders(const CAABBox &sbox, std::vector 0) + if (!retriever.getFullOrderedChains().empty()) { const COrderedChain3f &ochain = retriever.getFullOrderedChain(entry.OChainId); @@ -1221,7 +1221,7 @@ void NLPACS::CGlobalRetriever::findCollisionChains(CCollisionSurfaceTemp &cst, c if (!localRetriever.isLoaded()) { - nlwarning("local retriever %d in %s not loaded, findCollisionChains in this retriever aborted", localRetrieverId, _RetrieverBank->getNamePrefix().c_str()); + nldebug("local retriever %d in %s not loaded, findCollisionChains in this retriever aborted", localRetrieverId, _RetrieverBank->getNamePrefix().c_str()); continue; } diff --git a/code/nel/src/pacs/move_container.cpp b/code/nel/src/pacs/move_container.cpp index 93e05794a..c302b53ab 100644 --- a/code/nel/src/pacs/move_container.cpp +++ b/code/nel/src/pacs/move_container.cpp @@ -43,7 +43,7 @@ Doc: // Collisionnable primitives Each primitive must be moved first with the move() method. Their moves are evaluate all at once. All the collisions found are time sorted in a time orderin table (_TimeOT). - While the table is not empty, the first collision occured in time is solved and + While the table is not empty, the first collision occurred in time is solved and If a collision is found, reaction() is called. @@ -1304,8 +1304,8 @@ void CMoveContainer::freeAllOTInfo () { H_AUTO (NLPACS_Free_All_OT_Info); - _AllocOTDynamicInfo.free (); - _AllocOTStaticInfo.free (); + _AllocOTDynamicInfo.freeBlock (); + _AllocOTStaticInfo.freeBlock (); } // *************************************************************************** diff --git a/code/nel/src/pacs/move_primitive.cpp b/code/nel/src/pacs/move_primitive.cpp index 08da7ac38..039fa0c7b 100644 --- a/code/nel/src/pacs/move_primitive.cpp +++ b/code/nel/src/pacs/move_primitive.cpp @@ -379,7 +379,7 @@ uint8 CMovePrimitive::getFirstWorldImageV () const uint8 CMovePrimitive::getNumWorldImageV () const { - return getNumWorldImageV (); + return getNumWorldImage (); } // *************************************************************************** diff --git a/code/nel/src/pacs/primitive_block_pacs.cpp b/code/nel/src/pacs/primitive_block_pacs.cpp index 1ee0615ea..c2f40c40c 100644 --- a/code/nel/src/pacs/primitive_block_pacs.cpp +++ b/code/nel/src/pacs/primitive_block_pacs.cpp @@ -103,7 +103,7 @@ UPrimitiveBlock *UPrimitiveBlock::createPrimitiveBlock(NLMISC::IStream &src) { nlassert(src.isReading()); - std::auto_ptr pb(new CPrimitiveBlock); + CUniquePtr pb(new CPrimitiveBlock); pb->serial(src); return pb.release(); } diff --git a/code/nel/src/pacs/primitive_world_image.cpp b/code/nel/src/pacs/primitive_world_image.cpp index e8d0378e6..22cf2cee2 100644 --- a/code/nel/src/pacs/primitive_world_image.cpp +++ b/code/nel/src/pacs/primitive_world_image.cpp @@ -1395,7 +1395,7 @@ void CPrimitiveWorldImage::reaction (const CCollisionSurfaceDesc& surfaceDesc, c void CPrimitiveWorldImage::setGlobalPosition (const UGlobalPosition& pos, CMoveContainer& container, CMovePrimitive &primitive, uint8 worldImage) { // Cast type - nlassert (dynamic_cast(&container)); + nlassert (dynamic_cast(&container) != NULL); const CMoveContainer *cont=(const CMoveContainer*)&container; if (!cont->getGlobalRetriever()) return; @@ -1421,7 +1421,7 @@ void CPrimitiveWorldImage::setGlobalPosition (const UGlobalPosition& pos, CMoveC void CPrimitiveWorldImage::setGlobalPosition (const NLMISC::CVectorD& pos, CMoveContainer& container, CMovePrimitive &primitive, uint8 worldImage, bool keepZ /*= false*/, UGlobalPosition::TType type /* =UGlobalPosition::Unspecified*/) { // Cast type - nlassert (dynamic_cast(&container)); + nlassert (dynamic_cast(&container) != NULL); const CMoveContainer *cont=(const CMoveContainer*)&container; // Get the retriever diff --git a/code/nel/src/pacs/surface_quad.cpp b/code/nel/src/pacs/surface_quad.cpp index dade8462c..308dc0054 100644 --- a/code/nel/src/pacs/surface_quad.cpp +++ b/code/nel/src/pacs/surface_quad.cpp @@ -19,6 +19,10 @@ #include "nel/misc/file.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; using namespace std; diff --git a/code/nel/src/pipeline/CMakeLists.txt b/code/nel/src/pipeline/CMakeLists.txt index 47ab9a376..d6e5705de 100644 --- a/code/nel/src/pipeline/CMakeLists.txt +++ b/code/nel/src/pipeline/CMakeLists.txt @@ -15,4 +15,4 @@ NL_ADD_LIB_SUFFIX(nelpipeline) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nelpipeline LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/src/pipeline/database_config.cpp b/code/nel/src/pipeline/database_config.cpp index b326a2888..56369c902 100644 --- a/code/nel/src/pipeline/database_config.cpp +++ b/code/nel/src/pipeline/database_config.cpp @@ -53,7 +53,7 @@ bool CDatabaseConfig::init(const std::string &asset) TPathString configPath = rootPath + "/database.cfg"; while (!CFile::fileExists(configPath)) { - int sep = CFile::getLastSeparator(rootPath); + std::string::size_type sep = CFile::getLastSeparator(rootPath); if (sep == string::npos) return false; diff --git a/code/nel/src/pipeline/project_config.cpp b/code/nel/src/pipeline/project_config.cpp index 995f92fd4..b292f033c 100644 --- a/code/nel/src/pipeline/project_config.cpp +++ b/code/nel/src/pipeline/project_config.cpp @@ -65,7 +65,7 @@ bool CProjectConfig::init(const std::string &asset, Flags flags, bool partial) TPathString configPath = rootPath + "/nel.cfg"; while (!CFile::fileExists(configPath)) { - int sep = CFile::getLastSeparator(rootPath); + std::string::size_type sep = CFile::getLastSeparator(rootPath); if (sep == string::npos) return false; @@ -82,7 +82,7 @@ bool CProjectConfig::init(const std::string &asset, Flags flags, bool partial) std::vector configRootPaths; TPathString projectConfigPath; - uint32 projectConfigModification; + uint32 projectConfigModification = 0; std::string projectName; if (partial) { diff --git a/code/nel/src/sound/CMakeLists.txt b/code/nel/src/sound/CMakeLists.txt index a78b455da..e4831c643 100644 --- a/code/nel/src/sound/CMakeLists.txt +++ b/code/nel/src/sound/CMakeLists.txt @@ -93,7 +93,7 @@ TARGET_LINK_LIBRARIES(nelsound ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY}) IF(WITH_STATIC) # Add libogg dependency only if target is static because to libvorbisfile TARGET_LINK_LIBRARIES(nelsound ${OGG_LIBRARY}) -ENDIF(WITH_STATIC) +ENDIF() INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) @@ -108,12 +108,12 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nelsound ${CMAKE_CURRENT_SOURCE_DIR}/stdsound.h ${CMAKE_CURRENT_SOURCE_DIR}/stdsound.cpp) -ENDIF(WITH_PCH) +ENDIF() NL_GEN_PC(nel-sound.pc) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nelsound LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() ADD_SUBDIRECTORY(driver) diff --git a/code/nel/src/sound/audio_decoder.cpp b/code/nel/src/sound/audio_decoder.cpp index f4884a427..6e9e42b61 100644 --- a/code/nel/src/sound/audio_decoder.cpp +++ b/code/nel/src/sound/audio_decoder.cpp @@ -94,7 +94,7 @@ IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &type, NLMISC } } -bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, std::string &title) +bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, std::string &title, float &length) { std::string lookup = CPath::lookup(filepath, false); if (lookup.empty()) @@ -111,7 +111,7 @@ bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, st ifile.setCacheFileOnOpen(false); ifile.allowBNPCacheFileOnOpen(false); if (ifile.open(lookup)) - return CAudioDecoderVorbis::getInfo(&ifile, artist, title); + return CAudioDecoderVorbis::getInfo(&ifile, artist, title, length); nlwarning("Unable to open: '%s'", filepath.c_str()); } diff --git a/code/nel/src/sound/audio_decoder_vorbis.cpp b/code/nel/src/sound/audio_decoder_vorbis.cpp index 1c11c32d7..fdda6e742 100644 --- a/code/nel/src/sound/audio_decoder_vorbis.cpp +++ b/code/nel/src/sound/audio_decoder_vorbis.cpp @@ -117,7 +117,7 @@ CAudioDecoderVorbis::~CAudioDecoderVorbis() } /// Get information on a music file (only artist and title at the moment). -bool CAudioDecoderVorbis::getInfo(NLMISC::IStream *stream, std::string &artist, std::string &title) +bool CAudioDecoderVorbis::getInfo(NLMISC::IStream *stream, std::string &artist, std::string &title, float &length) { CAudioDecoderVorbis mbv(stream, false); // just opens and closes the oggvorbisfile thing :) vorbis_comment *vc = ov_comment(&mbv._OggVorbisFile, -1); @@ -125,6 +125,7 @@ bool CAudioDecoderVorbis::getInfo(NLMISC::IStream *stream, std::string &artist, if (title_c) title = title_c; else title.clear(); char *artist_c = vorbis_comment_query(vc, "artist", 0); if (artist_c) artist = artist_c; else artist.clear(); + length = (float)ov_time_total(&mbv._OggVorbisFile, -1); return true; } diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 9ac90b3c7..854a2c1dc 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -56,6 +56,10 @@ #include "nel/sound/containers.h" #include "nel/sound/audio_decoder.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; @@ -1770,7 +1774,7 @@ void CAudioMixerUser::update() str += tmp; } nldebug((string("Status1: ")+str).c_str()); - str = ""; + str.clear(); for (i=_NbTracks/2; i<_NbTracks; ++i) { sprintf(tmp, "[%2u]%8p ", i, _Tracks[i]->getSource()); @@ -1797,7 +1801,7 @@ void CAudioMixerUser::addSource( CSourceCommon *source ) _Sources.insert( source ); // _profile(( "AM: ADDSOURCE, SOUND: %d, TRACK: %p, NAME=%s", source->getSound(), source->getTrack(), -// source->getSound() && (source->getSound()->getName()!="") ? source->getSound()->getName().c_str() : "" )); +// source->getSound() && (!source->getSound()->getName().empty()) ? source->getSound()->getName().c_str() : "" )); } @@ -2559,7 +2563,7 @@ void CAudioMixerUser::changeMaxTrack(uint maxTrack) else { vector non_erasable; - while (_Tracks.size() + non_erasable.size() > maxTrack && _Tracks.size() > 0) + while (_Tracks.size() + non_erasable.size() > maxTrack && !_Tracks.empty()) { CTrack *track = _Tracks.back(); _Tracks.pop_back(); @@ -2588,7 +2592,7 @@ void CAudioMixerUser::changeMaxTrack(uint maxTrack) non_erasable.push_back(track); } } - while (non_erasable.size() > 0) + while (!non_erasable.empty()) { // put non erasable back into track list _Tracks.push_back(non_erasable.back()); @@ -2684,17 +2688,17 @@ float CAudioMixerUser::getMusicLength() } // *************************************************************************** -bool CAudioMixerUser::getSongTitle(const std::string &filename, std::string &result) +bool CAudioMixerUser::getSongTitle(const std::string &filename, std::string &result, float &length) { if (_SoundDriver) { std::string artist; std::string title; - if (!_SoundDriver->getMusicInfo(filename, artist, title)) + if (!_SoundDriver->getMusicInfo(filename, artist, title, length)) { // use 3rd party libraries supported formats - IAudioDecoder::getInfo(filename, artist, title); + IAudioDecoder::getInfo(filename, artist, title, length); } if (!title.empty()) @@ -2715,6 +2719,7 @@ bool CAudioMixerUser::getSongTitle(const std::string &filename, std::string &res } result = "???"; + length = 0; return false; } diff --git a/code/nel/src/sound/context_sound.cpp b/code/nel/src/sound/context_sound.cpp index d1403c7c9..fe2512ac0 100644 --- a/code/nel/src/sound/context_sound.cpp +++ b/code/nel/src/sound/context_sound.cpp @@ -160,7 +160,7 @@ void CContextSound::init() uint contextArgIndex[SoundContextNbArgs]; bool useRandom = false; bool parseArg = false; - _BaseName = ""; + _BaseName.clear(); //nldebug("Init the context sound %s", _PatternName.c_str()); @@ -190,7 +190,7 @@ void CContextSound::init() nlassertex(nbJoker < SoundContextNbArgs, ("Error will trying to play ContextSound '%s'", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/)); fromString(index, contextArgIndex[nbJoker++]); parseArg = false; - index = ""; + index.clear(); } } else if (*first == 'r') diff --git a/code/nel/src/sound/driver/CMakeLists.txt b/code/nel/src/sound/driver/CMakeLists.txt index 09d65440a..320c4ee05 100644 --- a/code/nel/src/sound/driver/CMakeLists.txt +++ b/code/nel/src/sound/driver/CMakeLists.txt @@ -12,24 +12,24 @@ NL_ADD_LIB_SUFFIX(nelsnd_lowlevel) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nelsnd_lowlevel ${CMAKE_CURRENT_SOURCE_DIR}/stdsound_lowlevel.h ${CMAKE_CURRENT_SOURCE_DIR}/stdsound_lowlevel.cpp) -ENDIF(WITH_PCH) +ENDIF() IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS nelsnd_lowlevel LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() IF(WITH_DRIVER_OPENAL) ADD_SUBDIRECTORY(openal) -ENDIF(WITH_DRIVER_OPENAL) +ENDIF() IF(WITH_DRIVER_FMOD) ADD_SUBDIRECTORY(fmod) -ENDIF(WITH_DRIVER_FMOD) +ENDIF() IF(WITH_DRIVER_DSOUND) ADD_SUBDIRECTORY(dsound) -ENDIF(WITH_DRIVER_DSOUND) +ENDIF() IF(WITH_DRIVER_XAUDIO2) ADD_SUBDIRECTORY(xaudio2) -ENDIF(WITH_DRIVER_XAUDIO2) +ENDIF() diff --git a/code/nel/src/sound/driver/dsound/buffer_dsound.cpp b/code/nel/src/sound/driver/dsound/buffer_dsound.cpp index 53fa8dcec..72423bba7 100644 --- a/code/nel/src/sound/driver/dsound/buffer_dsound.cpp +++ b/code/nel/src/sound/driver/dsound/buffer_dsound.cpp @@ -23,6 +23,10 @@ #include #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; using namespace std; diff --git a/code/nel/src/sound/driver/dsound/listener_dsound.cpp b/code/nel/src/sound/driver/dsound/listener_dsound.cpp index 3bed4f821..d8c81b58b 100644 --- a/code/nel/src/sound/driver/dsound/listener_dsound.cpp +++ b/code/nel/src/sound/driver/dsound/listener_dsound.cpp @@ -18,6 +18,9 @@ #include "listener_dsound.h" #include "sound_driver_dsound.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif using namespace NLMISC; diff --git a/code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp b/code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp index ba212b990..d95b80ca0 100644 --- a/code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp +++ b/code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp @@ -31,6 +31,9 @@ #include "sound_driver_dsound.h" #include "listener_dsound.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif using namespace std; using namespace NLMISC; @@ -563,15 +566,15 @@ void CSoundDriverDSound::initDevice(const std::string &device, ISoundDriver::TSo switch (hr) { case DSERR_BUFFERLOST: - throw ESoundDriver("Failed to lock the DirectSound primary buffer : DSERR_BUFFERLOST"); + throw ESoundDriver("Failed to lock the DirectSound primary buffer: DSERR_BUFFERLOST"); case DSERR_INVALIDCALL: - throw ESoundDriver("Failed to lock the DirectSound primary buffer : DSERR_INVALIDCALL"); + throw ESoundDriver("Failed to lock the DirectSound primary buffer: DSERR_INVALIDCALL"); case DSERR_INVALIDPARAM: - throw ESoundDriver("Failed to lock the DirectSound primary buffer : DSERR_INVALIDPARAM"); + throw ESoundDriver("Failed to lock the DirectSound primary buffer: DSERR_INVALIDPARAM"); case DSERR_PRIOLEVELNEEDED: - throw ESoundDriver("Failed to lock the DirectSound primary buffer : DSERR_PRIOLEVELNEEDED"); + throw ESoundDriver("Failed to lock the DirectSound primary buffer: DSERR_PRIOLEVELNEEDED"); default: - throw ESoundDriver("Failed to lock the DirectSound primary buffer : unkown error"); + throw ESoundDriver("Failed to lock the DirectSound primary buffer: unknown error"); } } diff --git a/code/nel/src/sound/driver/dsound/sound_driver_dsound.h b/code/nel/src/sound/driver/dsound/sound_driver_dsound.h index 14872c1e1..e928cf137 100644 --- a/code/nel/src/sound/driver/dsound/sound_driver_dsound.h +++ b/code/nel/src/sound/driver/dsound/sound_driver_dsound.h @@ -115,7 +115,7 @@ public: * \param artist returns the song artist (empty if not available) * \param title returns the title (empty if not available) */ - virtual bool getMusicInfo(const std::string & /* filepath */, std::string &artist, std::string &title) { artist.clear(); title.clear(); return false; } + virtual bool getMusicInfo(const std::string & /* filepath */, std::string &artist, std::string &title, float &length) { artist.clear(); title.clear(); length = 0.f; return false; } private: diff --git a/code/nel/src/sound/driver/dsound/source_dsound.cpp b/code/nel/src/sound/driver/dsound/source_dsound.cpp index c3bff3289..b80d03590 100644 --- a/code/nel/src/sound/driver/dsound/source_dsound.cpp +++ b/code/nel/src/sound/driver/dsound/source_dsound.cpp @@ -21,6 +21,9 @@ #include "buffer_dsound.h" #include "listener_dsound.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif using namespace NLMISC; using namespace std; diff --git a/code/nel/src/sound/driver/dsound/stddsound.h b/code/nel/src/sound/driver/dsound/stddsound.h index f550e8150..cb953e630 100644 --- a/code/nel/src/sound/driver/dsound/stddsound.h +++ b/code/nel/src/sound/driver/dsound/stddsound.h @@ -14,6 +14,16 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#ifndef STDDSOUND_H +#define STDDSOUND_H + +#if defined(_MSC_VER) && defined(_DEBUG) +#define _CRTDBG_MAP_ALLOC +#include +#include +#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif + #include "nel/misc/types_nl.h" #define EAX_AVAILABLE 0 @@ -44,4 +54,5 @@ #include "nel/sound/driver/source.h" #include "nel/sound/driver/listener.h" +#endif /* end of file */ diff --git a/code/nel/src/sound/driver/fmod/buffer_fmod.cpp b/code/nel/src/sound/driver/fmod/buffer_fmod.cpp index 69081b013..edba0bec2 100644 --- a/code/nel/src/sound/driver/fmod/buffer_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/buffer_fmod.cpp @@ -25,6 +25,10 @@ # include #endif +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; using namespace std; diff --git a/code/nel/src/sound/driver/fmod/listener_fmod.cpp b/code/nel/src/sound/driver/fmod/listener_fmod.cpp index ad308c937..776a23d70 100644 --- a/code/nel/src/sound/driver/fmod/listener_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/listener_fmod.cpp @@ -18,6 +18,9 @@ #include "listener_fmod.h" #include "sound_driver_fmod.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif using namespace NLMISC; diff --git a/code/nel/src/sound/driver/fmod/music_channel_fmod.cpp b/code/nel/src/sound/driver/fmod/music_channel_fmod.cpp index 3640869b6..9abfd1006 100644 --- a/code/nel/src/sound/driver/fmod/music_channel_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/music_channel_fmod.cpp @@ -18,6 +18,10 @@ #include "music_channel_fmod.h" #include "sound_driver_fmod.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp b/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp index 6ca480ce7..d98aa600f 100644 --- a/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp @@ -26,6 +26,10 @@ #include #endif +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; @@ -496,7 +500,7 @@ bool getTag (std::string &result, const char *tag, FSOUND_STREAM *stream) * \param artist returns the song artist (empty if not available) * \param title returns the title (empty if not available) */ -bool CSoundDriverFMod::getMusicInfo(const std::string &filepath, std::string &artist, std::string &title) +bool CSoundDriverFMod::getMusicInfo(const std::string &filepath, std::string &artist, std::string &title, float &length) { /* Open a stream, get the tag if it exists, close the stream */ string pathName = CPath::lookup(filepath, false); @@ -526,6 +530,8 @@ bool CSoundDriverFMod::getMusicInfo(const std::string &filepath, std::string &ar { getTag(artist, "ARTIST", stream); getTag(title, "TITLE", stream); + // get length of the music in seconds + length = (float)FSOUND_Stream_GetLengthMs(stream) / 1000.f; FSOUND_Stream_Close(stream); return true; } diff --git a/code/nel/src/sound/driver/fmod/sound_driver_fmod.h b/code/nel/src/sound/driver/fmod/sound_driver_fmod.h index 8beabe562..db82cde6e 100644 --- a/code/nel/src/sound/driver/fmod/sound_driver_fmod.h +++ b/code/nel/src/sound/driver/fmod/sound_driver_fmod.h @@ -116,7 +116,7 @@ public: * \param artist returns the song artist (empty if not available) * \param title returns the title (empty if not available) */ - virtual bool getMusicInfo(const std::string &filepath, std::string &artist, std::string &title); + virtual bool getMusicInfo(const std::string &filepath, std::string &artist, std::string &title, float &length); // also check that the channel still exist (avoid any free problem) void markMusicChannelEnded(void *stream, CMusicChannelFMod *musicChannel); diff --git a/code/nel/src/sound/driver/fmod/source_fmod.cpp b/code/nel/src/sound/driver/fmod/source_fmod.cpp index 6026ce2f5..1224d647d 100644 --- a/code/nel/src/sound/driver/fmod/source_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/source_fmod.cpp @@ -21,6 +21,9 @@ #include "buffer_fmod.h" #include "listener_fmod.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif using namespace NLMISC; using namespace std; diff --git a/code/nel/src/sound/driver/fmod/stdfmod.h b/code/nel/src/sound/driver/fmod/stdfmod.h index afb1af3f1..4274adfe3 100644 --- a/code/nel/src/sound/driver/fmod/stdfmod.h +++ b/code/nel/src/sound/driver/fmod/stdfmod.h @@ -14,6 +14,16 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#ifndef STDFMOD_H +#define STDFMOD_H + +#if defined(_MSC_VER) && defined(_DEBUG) +#define _CRTDBG_MAP_ALLOC +#include +#include +#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif + #include #ifdef NL_OS_WINDOWS @@ -42,4 +52,6 @@ #include "nel/sound/driver/source.h" #include "nel/sound/driver/listener.h" +#endif + /* end of file */ diff --git a/code/nel/src/sound/driver/openal/buffer_al.cpp b/code/nel/src/sound/driver/openal/buffer_al.cpp index 352128c3e..ae0054096 100644 --- a/code/nel/src/sound/driver/openal/buffer_al.cpp +++ b/code/nel/src/sound/driver/openal/buffer_al.cpp @@ -18,6 +18,10 @@ #include "sound_driver_al.h" #include "buffer_al.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; namespace NLSOUND diff --git a/code/nel/src/sound/driver/openal/effect_al.cpp b/code/nel/src/sound/driver/openal/effect_al.cpp index 0eec97756..9a09ba7ac 100644 --- a/code/nel/src/sound/driver/openal/effect_al.cpp +++ b/code/nel/src/sound/driver/openal/effect_al.cpp @@ -19,6 +19,10 @@ #include "effect_al.h" #include "sound_driver_al.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; // using namespace NLMISC; diff --git a/code/nel/src/sound/driver/openal/listener_al.cpp b/code/nel/src/sound/driver/openal/listener_al.cpp index a79e551b6..f39f0f18f 100644 --- a/code/nel/src/sound/driver/openal/listener_al.cpp +++ b/code/nel/src/sound/driver/openal/listener_al.cpp @@ -18,6 +18,10 @@ #include "listener_al.h" #include "sound_driver_al.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace NLMISC; namespace NLSOUND { diff --git a/code/nel/src/sound/driver/openal/sound_driver_al.cpp b/code/nel/src/sound/driver/openal/sound_driver_al.cpp index ab9574483..d237f533a 100644 --- a/code/nel/src/sound/driver/openal/sound_driver_al.cpp +++ b/code/nel/src/sound/driver/openal/sound_driver_al.cpp @@ -22,6 +22,10 @@ #include "ext_al.h" #include "effect_al.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/sound/driver/openal/source_al.cpp b/code/nel/src/sound/driver/openal/source_al.cpp index c13db52af..825d9f1e9 100644 --- a/code/nel/src/sound/driver/openal/source_al.cpp +++ b/code/nel/src/sound/driver/openal/source_al.cpp @@ -22,6 +22,10 @@ #include "source_al.h" #include "ext_al.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // #define NLSOUND_DEBUG_GAIN using namespace std; diff --git a/code/nel/src/sound/driver/openal/stdopenal.h b/code/nel/src/sound/driver/openal/stdopenal.h index 37b7e5e2f..f689a1e53 100644 --- a/code/nel/src/sound/driver/openal/stdopenal.h +++ b/code/nel/src/sound/driver/openal/stdopenal.h @@ -14,7 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "nel/misc/types_nl.h" +#ifndef STDOPENAL_H +#define STDOPENAL_H + +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif #include #include @@ -35,6 +43,8 @@ #include #include +#include "nel/misc/types_nl.h" + #ifdef NL_OS_MAC # include # include @@ -59,4 +69,5 @@ #include "nel/sound/driver/listener.h" #include "nel/sound/driver/effect.h" +#endif /* end of file */ diff --git a/code/nel/src/sound/driver/sound_driver.cpp b/code/nel/src/sound/driver/sound_driver.cpp index 4a87df307..6e1ada902 100644 --- a/code/nel/src/sound/driver/sound_driver.cpp +++ b/code/nel/src/sound/driver/sound_driver.cpp @@ -225,10 +225,10 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD * MTR: Is there a way with NLMISC to replace SearchFile() ? Until then, no info for Linux. */ #ifdef NL_OS_WINDOWS - char buffer[1024], *ptr; - uint len = SearchPath (NULL, dllName.c_str(), NULL, 1023, buffer, &ptr); + wchar_t buffer[1024], *ptr; + uint len = SearchPathW (NULL, utf8ToWide(dllName), NULL, 1023, buffer, &ptr); if( len ) - nlinfo ("Using the library '%s' that is in the directory: '%s'", dllName.c_str(), buffer); + nlinfo ("Using the library '%s' that is in the directory: '%s'", dllName.c_str(), wideToUtf8(buffer).c_str()); #endif createSoundDriver = (ISDRV_CREATE_PROC) driverLib.getSymbolAddress(IDRV_CREATE_PROC_NAME); diff --git a/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.cpp index 2db913268..e70fec076 100644 --- a/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.cpp @@ -20,6 +20,10 @@ #include "buffer_xaudio2.h" #include "adpcm_xaudio2.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; // using namespace NLMISC; diff --git a/code/nel/src/sound/driver/xaudio2/buffer_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/buffer_xaudio2.cpp index 106d565f9..acdb95ab4 100644 --- a/code/nel/src/sound/driver/xaudio2/buffer_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/buffer_xaudio2.cpp @@ -20,6 +20,10 @@ #include "buffer_xaudio2.h" #include "sound_driver_xaudio2.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/sound/driver/xaudio2/effect_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/effect_xaudio2.cpp index 5c1f58722..ac3814226 100644 --- a/code/nel/src/sound/driver/xaudio2/effect_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/effect_xaudio2.cpp @@ -21,6 +21,10 @@ #include "listener_xaudio2.h" #include "effect_xaudio2.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/sound/driver/xaudio2/listener_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/listener_xaudio2.cpp index 10b7e7e48..c6b364046 100644 --- a/code/nel/src/sound/driver/xaudio2/listener_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/listener_xaudio2.cpp @@ -20,6 +20,10 @@ #include "sound_driver_xaudio2.h" #include "listener_xaudio2.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp index 529954006..992f6c66d 100644 --- a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp @@ -22,6 +22,10 @@ #include "effect_xaudio2.h" #include "sound_driver_xaudio2.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp index 021935e50..26566612c 100644 --- a/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp @@ -26,6 +26,10 @@ #include "effect_xaudio2.h" #include "source_xaudio2.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; diff --git a/code/nel/src/sound/driver/xaudio2/stdxaudio2.h b/code/nel/src/sound/driver/xaudio2/stdxaudio2.h index 76b2a13d8..f6e55d0aa 100644 --- a/code/nel/src/sound/driver/xaudio2/stdxaudio2.h +++ b/code/nel/src/sound/driver/xaudio2/stdxaudio2.h @@ -17,7 +17,12 @@ #ifndef NLSOUND_STDPCH_XAUDIO2_H #define NLSOUND_STDPCH_XAUDIO2_H -#include "nel/misc/types_nl.h" +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif // STL includes #include @@ -27,6 +32,8 @@ #include #include +#include "nel/misc/types_nl.h" + // 3rd Party Includes #include #define XAUDIO2_HELPER_FUNCTIONS diff --git a/code/nel/src/sound/group_controller.cpp b/code/nel/src/sound/group_controller.cpp index b82373c3e..f56eb34a4 100644 --- a/code/nel/src/sound/group_controller.cpp +++ b/code/nel/src/sound/group_controller.cpp @@ -62,7 +62,7 @@ CGroupController::~CGroupController() void CGroupController::addSource(CSourceCommon *source) { - nlassert(this); + nlassert(this != NULL); m_Sources.insert(source); increaseSources(); diff --git a/code/nel/src/sound/sample_bank_manager.cpp b/code/nel/src/sound/sample_bank_manager.cpp index 9a7b397e5..996c59f1e 100644 --- a/code/nel/src/sound/sample_bank_manager.cpp +++ b/code/nel/src/sound/sample_bank_manager.cpp @@ -81,7 +81,7 @@ void CSampleBankManager::init(NLGEORGES::UFormElm *mixerConfig) { TFilteredBank fb; std::string bankName; - NLGEORGES::UFormElm *realBank; + NLGEORGES::UFormElm *realBank = NULL; realBank->getArrayNode(&realBank, j); realBank->getValueByName(bankName, ".SampleBank"); diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index a1c9fd595..6c204be10 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -92,7 +92,7 @@ CSound *CSound::createSound(const std::string &filename, NLGEORGES::UFormElm& fo } else { - nlassertex(false, ("SoundType unsuported : %s", dfnName.c_str())); + nlassertex(false, ("SoundType unsupported: %s", dfnName.c_str())); } } diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index 59330f3f8..29621d337 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -33,6 +33,10 @@ #include "nel/georges/load_form.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + using namespace std; using namespace NLMISC; using namespace NLGEORGES; @@ -277,7 +281,7 @@ void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) maxShortId = first->second.Sound->getName().getShortId(); } ++maxShortId; // inc for size = last idx + 1 - if (container.size() == 0) + if (container.empty()) { nlwarning("NLSOUND: No sound sheets have been loaded, missing sound sheet directory or packed sound sheets file"); } diff --git a/code/nel/src/sound/stdsound.h b/code/nel/src/sound/stdsound.h index 071e2c70c..474e64441 100644 --- a/code/nel/src/sound/stdsound.h +++ b/code/nel/src/sound/stdsound.h @@ -14,9 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "nel/misc/types_nl.h" -#include "nel/misc/common.h" -#include "nel/misc/debug.h" +#ifndef SOUND_STDPCH_H +#define SOUND_STDPCH_H + +#if defined(_MSC_VER) && defined(_DEBUG) +#define _CRTDBG_MAP_ALLOC +#include +#include +#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif #include #include @@ -40,6 +46,11 @@ #include +#include "nel/misc/types_nl.h" +#include "nel/misc/common.h" +#include "nel/misc/debug.h" #include "nel/misc/vector.h" #include "nel/misc/path.h" #include "nel/misc/file.h" + +#endif diff --git a/code/nel/tools/3d/CMakeLists.txt b/code/nel/tools/3d/CMakeLists.txt index 034fc5f55..08fd9e776 100644 --- a/code/nel/tools/3d/CMakeLists.txt +++ b/code/nel/tools/3d/CMakeLists.txt @@ -36,6 +36,7 @@ IF(WITH_NEL_TOOLS) build_interface get_neighbors textures_optimizer + textures_tool tga_cut tga_resize) ENDIF() @@ -48,9 +49,9 @@ IF(WIN32 AND WITH_3D) IF(MAXSDK_FOUND) ADD_SUBDIRECTORY(plugin_max) ADD_SUBDIRECTORY(ligo) - ENDIF(MAXSDK_FOUND) - ENDIF(WITH_NEL_MAXPLUGIN) - ENDIF(MFC_FOUND) + ENDIF() + ENDIF() + ENDIF() ENDIF() IF(WITH_NEL_TOOLS AND WITH_3D) @@ -59,8 +60,8 @@ IF(WITH_NEL_TOOLS AND WITH_3D) IF(MFC_FOUND) ADD_SUBDIRECTORY(object_viewer_exe) ADD_SUBDIRECTORY(tile_edit) - ENDIF(MFC_FOUND) - ENDIF(WIN32) + ENDIF() + ENDIF() IF(WITH_QT OR WITH_QT5) ADD_SUBDIRECTORY(tile_edit_qt) diff --git a/code/nel/tools/3d/build_far_bank/build_far_bank.cpp b/code/nel/tools/3d/build_far_bank/build_far_bank.cpp index dfc3f7f65..e625b4e7f 100644 --- a/code/nel/tools/3d/build_far_bank/build_far_bank.cpp +++ b/code/nel/tools/3d/build_far_bank/build_far_bank.cpp @@ -271,7 +271,7 @@ int main (int argc, char **argv) bool _256=(type==CTileBank::_256x256); // Diffuse bitmap filled ? - if (pTile->getRelativeFileName (CTile::diffuse)!="") + if (!pTile->getRelativeFileName (CTile::diffuse).empty()) { // File exist ? string tileFilename = bank.getAbsPath()+CPath::standardizePath(pTile->getRelativeFileName (CTile::diffuse), false); @@ -302,7 +302,7 @@ int main (int argc, char **argv) } // Additive bitmap filled ? - if (pTile->getRelativeFileName (CTile::additive)!="") + if (!pTile->getRelativeFileName (CTile::additive).empty()) { // File exist ? string tileFilename = bank.getAbsPath()+CPath::standardizePath(pTile->getRelativeFileName (CTile::additive), false); @@ -333,7 +333,7 @@ int main (int argc, char **argv) } // Alpha bitmap filled ? - if (pTile->getRelativeFileName (CTile::alpha)!="") + if (!pTile->getRelativeFileName (CTile::alpha).empty()) { // File exist ? string tileFilename = bank.getAbsPath()+CPath::standardizePath(pTile->getRelativeFileName (CTile::alpha), false); diff --git a/code/nel/tools/3d/build_interface/main.cpp b/code/nel/tools/3d/build_interface/main.cpp index 1b13a0f71..a8f854721 100644 --- a/code/nel/tools/3d/build_interface/main.cpp +++ b/code/nel/tools/3d/build_interface/main.cpp @@ -24,8 +24,7 @@ #include "nel/misc/log.h" #include "nel/misc/path.h" #include "nel/misc/uv.h" - -//#include "windows.h" +#include "nel/misc/cmd_args.h" #include #include @@ -36,21 +35,9 @@ using namespace std; using namespace NLMISC; // *************************************************************************** -//char sExeDir[MAX_PATH]; -std::string sExeDir; -NLMISC::CApplicationContext _ApplicationContext; - -void outString (const string &sText) +void outString(const string &sText) { - std::string sCurDir = CPath::getCurrentPath(); - CPath::setCurrentPath(sExeDir.c_str()); - //char sCurDir[MAX_PATH]; - //GetCurrentDirectory (MAX_PATH, sCurDir); - //SetCurrentDirectory (sExeDir); - NLMISC::createDebug (); - NLMISC::InfoLog->displayRaw(sText.c_str()); - //SetCurrentDirectory (sCurDir); - CPath::setCurrentPath(sCurDir.c_str()); + printf("%s\n", sText.c_str()); } // *************************************************************************** @@ -59,7 +46,7 @@ const uint32 posStep= 4; // *************************************************************************** // Try all position to put pSrc in pDst -bool tryAllPos (NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 &x, sint32 &y) +bool tryAllPos(NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 &x, sint32 &y) { uint32 i, j; CObjectVector &rSrcPix = pSrc->getPixels(); @@ -99,7 +86,7 @@ bool tryAllPos (NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 &x, sint32 } // *************************************************************************** -void putPixel(uint8 *dst, uint8 *src, bool alphaTransfert) +void putPixel(uint8 *dst, uint8 *src, bool alphaTransfert) { dst[0] = src[0]; dst[1] = src[1]; @@ -111,7 +98,7 @@ void putPixel(uint8 *dst, uint8 *src, bool alphaTransfert) } // *************************************************************************** -bool putIn (NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 x, sint32 y, bool alphaTransfert=true) +bool putIn(NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 x, sint32 y, bool alphaTransfert=true) { uint8 *rSrcPix = &pSrc->getPixels()[0]; uint8 *rDstPix = &pDst->getPixels()[0]; @@ -158,18 +145,17 @@ bool putIn (NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 x, sint32 y, bo } // *************************************************************************** -string getBaseName (const string &fullname) +string getBaseName(const string &fullname) { - string sTmp2; + string basename; string::size_type pos = fullname.rfind('_'); - if (pos != string::npos) - sTmp2 = fullname.substr(0, pos+1); - return sTmp2; + if (pos != string::npos) basename = fullname.substr(0, pos+1); + return basename; } // *************************************************************************** // resize the bitmap to the next power of 2 and preserve content -void enlargeCanvas (NLMISC::CBitmap &b) +void enlargeCanvas(NLMISC::CBitmap &b) { sint32 nNewWidth = b.getWidth(), nNewHeight = b.getHeight(); if (nNewWidth > nNewHeight) @@ -188,65 +174,209 @@ void enlargeCanvas (NLMISC::CBitmap &b) b = b2; } +bool writeFileDependingOnFilename(const std::string &filename, CBitmap &bitmap) +{ + NLMISC::COFile out; + + if (out.open(filename)) + { + if (toLower(filename).find(".png") != string::npos) + { + bitmap.writePNG(out, 32); + } + else + { + bitmap.writeTGA(out, 32); + } + + out.close(); + + return true; + } + + return false; +} + + // *************************************************************************** // main // *************************************************************************** -int main(int nNbArg, char **ppArgs) +int main(int argc, char **argv) { - //GetCurrentDirectory (MAX_PATH, sExeDir); - sExeDir = CPath::getCurrentPath(); + CApplicationContext applicationContext; + + // Parse Command Line. + NLMISC::CCmdArgs args; + + args.setDescription("Build a huge interface texture from several small elements to optimize video memory usage."); + args.addArg("f", "format", "format", "Output format (png or tga)"); + args.addArg("s", "subset", "existing_uv_txt_name", "Build a subset of an existing interface definition while preserving the existing texture ids, to support freeing up VRAM by switching to the subset without rebuilding the entire interface."); + args.addArg("x", "extract", "", "Extract all interface elements from to ."); + args.addAdditionalArg("output_filename", "PNG or TGA file to generate", true); + args.addAdditionalArg("input_path", "Path that containts interfaces elements", false); + + if (!args.parse(argc, argv)) return 1; - if (nNbArg < 3) - { - outString ("ERROR : Wrong number of arguments\n"); - outString ("USAGE : build_interface [-s] [path_maps2] [path_maps3] ....\n"); - outString (" -s : build a subset of an existing interface definition while preserving the existing texture ids,"); - outString (" to support freeing up VRAM by switching to the subset without rebuilding the entire interface\n"); - return -1; - } - // build as a subset of existing interface bool buildSubset = false; string existingUVfilename; - list inputDirs; - for ( uint i=1; (sint)i inputDirs = args.getAdditionalArg("input_path"); + + string fmtName = args.getAdditionalArg("output_filename").front(); + + // append PNG extension if no one provided + if (fmtName.rfind('.') == string::npos) fmtName += "." + (outputFormat.empty() ? "png":outputFormat); + + if (extractElements) + { + if (inputDirs.empty()) + { + outString(toString("ERROR: No input directories specified")); + return -1; + } + + // name of UV file + existingUVfilename = fmtName.substr(0, fmtName.rfind('.')); + existingUVfilename += ".txt"; + + // Load existing UV file + CIFile iFile; + string filename = CPath::lookup(existingUVfilename, false); + + if (filename.empty() || !iFile.open(filename)) + { + outString(toString("ERROR: Unable to open %s", existingUVfilename.c_str())); + return -1; + } + + // Load existing bitmap file + CIFile bitmapFile; + + if (!bitmapFile.open(fmtName)) + { + outString(toString("ERROR: Unable to open %s", fmtName.c_str())); + return -1; + } + + // load bitmap + CBitmap textureBitmap; + uint8 colors = textureBitmap.load(bitmapFile); + + // file already loaded in memory, close it + bitmapFile.close(); + + if (colors != 32) + { + outString(toString("ERROR: %s is not a RGBA bitmap", existingUVfilename.c_str())); + return -1; + } + + // make sure transparent pixels are black + textureBitmap.makeTransparentPixelsBlack(); + + float textureWidth = (float)textureBitmap.getWidth(); + float textureHeight = (float)textureBitmap.getHeight(); + + char bufTmp[256], tgaName[256]; + string sTGAname; + float uvMinU, uvMinV, uvMaxU, uvMaxV; + while (!iFile.eof()) + { + iFile.getline(bufTmp, 256); + + if (sscanf(bufTmp, "%s %f %f %f %f", tgaName, &uvMinU, &uvMinV, &uvMaxU, &uvMaxV) != 5) + { + nlwarning("Can't parse %s", bufTmp); + continue; + } + + float xf = uvMinU * textureWidth; + float yf = uvMinV * textureHeight; + float widthf = (uvMaxU - uvMinU) * textureWidth; + float heightf = (uvMaxV - uvMinV) * textureHeight; + + uint x = (uint)xf; + uint y = (uint)yf; + uint width = (uint)widthf; + uint height = (uint)heightf; + + if ((float)x != xf || (float)y != yf || (float)width != widthf || (float)height != heightf) + { + nlwarning("Wrong round"); + } + + if (width && height) + { + // create bitmap + CBitmap bitmap; + bitmap.resize(width, height); + bitmap.blit(textureBitmap, x, y, width, height, 0, 0); + + sTGAname = inputDirs.front() + "/" + tgaName; + + // force specific format instead of using original one + if (!outputFormat.empty()) + { + sTGAname = sTGAname.substr(0, sTGAname.rfind('.')); + sTGAname += "." + outputFormat; + } + + // write the file + if (writeFileDependingOnFilename(sTGAname, bitmap)) + { + outString(toString("Writing file %s", sTGAname.c_str())); + } + else + { + outString(toString("Unable to writing file %s", sTGAname.c_str())); + } + } + else + { + outString(toString("Bitmap with wrong size")); + } + } + + return 0; + } + vector AllMapNames; - list::iterator it = inputDirs.begin(); - list::iterator itEnd = inputDirs.end(); + vector::iterator it = inputDirs.begin(), itEnd = inputDirs.end(); + while( it != itEnd ) { string sDir = *it++; + if( !CFile::isDirectory(sDir) ) { - outString (string("ERROR : directory ") + sDir + " does not exist\n"); + outString(toString("ERROR: directory %s does not exist", sDir.c_str())); return -1; } + CPath::getPathContent(sDir, false, false, true, AllMapNames); } @@ -264,13 +394,16 @@ int main(int nNbArg, char **ppArgs) { pBtmp = new NLMISC::CBitmap; NLMISC::CIFile inFile; - if (!inFile.open( AllMapNames[i] )) throw NLMISC::Exception("Unable to open " + AllMapNames[i]); + + if (!inFile.open(AllMapNames[i])) throw NLMISC::Exception(toString("Unable to open %s", AllMapNames[i].c_str())); uint8 colors = pBtmp->load(inFile); + if (!colors) throw NLMISC::Exception(toString("%s is not a bitmap", AllMapNames[i].c_str())); + if (pBtmp->getPixelFormat() != CBitmap::RGBA) { - nlwarning("Converting %s to RGBA (32 bits), originally using %u bits...", AllMapNames[i].c_str(), (uint)colors); + outString(toString("Converting %s to RGBA (32 bits), originally using %u bits...", AllMapNames[i].c_str(), (uint)colors)); pBtmp->convertToType(CBitmap::RGBA); } @@ -280,7 +413,7 @@ int main(int nNbArg, char **ppArgs) { if (pBtmp) delete pBtmp; - outString (string("ERROR :") + e.what()); + outString(toString("ERROR : %s", e.what())); return -1; } } @@ -314,6 +447,7 @@ int main(int nNbArg, char **ppArgs) vector UVMin, UVMax; UVMin.resize (mapSize, NLMISC::CUV(0.0f, 0.0f)); UVMax.resize (mapSize, NLMISC::CUV(0.0f, 0.0f)); + for (sint i = 0; i < mapSize; ++i) { sint32 x, y; @@ -323,40 +457,20 @@ int main(int nNbArg, char **ppArgs) enlargeCanvas (GlobalTexture); enlargeCanvas (GlobalMask); } + putIn (AllMaps[i], &GlobalTexture, x, y); putIn (AllMaps[i], &GlobalMask, x, y, false); + UVMin[i].U = (float)x; UVMin[i].V = (float)y; UVMax[i].U = (float)x+AllMaps[i]->getWidth(); UVMax[i].V = (float)y+AllMaps[i]->getHeight(); - /* // Do not remove this is useful for debugging - { - NLMISC::COFile outTga; - string fmtName = ppArgs[1]; - if (fmtName.rfind('.') == string::npos) - fmtName += ".tga"; - if (outTga.open(fmtName)) - { - GlobalTexture.writeTGA (outTga, 32); - outTga.close(); - } - } - { - NLMISC::COFile outTga; - string fmtName = ppArgs[1]; - if (fmtName.rfind('.') == string::npos) - fmtName += "_msk.tga"; - else - fmtName = fmtName.substr(0,fmtName.rfind('.')) + "_msk.tga"; - if (outTga.open(fmtName)) - { - GlobalMask.writeTGA (outTga, 32); - outTga.close(); - } - }*/ - - +#if 0 + // Do not remove this is useful for debugging + writeFileDependingOnFilename(fmtName.substr(0, fmtName.rfind('.')) + "_txt.png", GlobalTexture); + writeFileDependingOnFilename(fmtName.substr(0, fmtName.rfind('.')) + "_msk.png", GlobalMask); +#endif } // Convert UV from pixel to ratio @@ -368,33 +482,17 @@ int main(int nNbArg, char **ppArgs) UVMax[i].V = UVMax[i].V / (float)GlobalTexture.getHeight(); } + // make sure transparent pixels are black + GlobalTexture.makeTransparentPixelsBlack(); + // Write global texture file - //SetCurrentDirectory (sExeDir); - CPath::setCurrentPath(sExeDir.c_str()); - - NLMISC::COFile outTga; - if (fmtName.rfind('.') == string::npos) - fmtName += ".tga"; - if (outTga.open(fmtName)) + if (writeFileDependingOnFilename(fmtName, GlobalTexture)) { - std::string ext; - if (toLower(fmtName).find(".png") != string::npos) - { - ext = "png"; - GlobalTexture.writePNG (outTga, 32); - } - else - { - ext = "tga"; - GlobalTexture.writeTGA (outTga, 32); - } - - outTga.close(); - outString (toString("Writing %s file : %s\n", ext.c_str(), fmtName.c_str())); + outString(toString("Writing %s", fmtName.c_str())); } else { - outString (string("ERROR: Cannot write tga file : ") + fmtName + "\n"); + outString(toString("ERROR: Unable to write %s", fmtName.c_str())); } // Write UV text file @@ -402,22 +500,23 @@ int main(int nNbArg, char **ppArgs) { fmtName = fmtName.substr(0, fmtName.rfind('.')); fmtName += ".txt"; - FILE *f = fopen (fmtName.c_str(), "wt"); + FILE *f = nlfopen(fmtName, "wb"); if (f != NULL) { for (sint i = 0; i < mapSize; ++i) { // get the string whitout path - string fileName= CFile::getFilename(AllMapNames[i]); - fprintf (f, "%s %.12f %.12f %.12f %.12f\n", fileName.c_str(), UVMin[i].U, UVMin[i].V, - UVMax[i].U, UVMax[i].V); + string fileName = CFile::getFilename(AllMapNames[i]); + fprintf (f, "%s %.12f %.12f %.12f %.12f\n", fileName.c_str(), UVMin[i].U, UVMin[i].V, UVMax[i].U, UVMax[i].V); } + fclose (f); - outString (string("Writing UV file : ") + fmtName + "\n"); + + outString(toString("Writing UV file %s", fmtName.c_str())); } else { - outString (string("ERROR: Cannot write UV file : ") + fmtName + "\n"); + outString(toString("ERROR: Cannot write UV file %s", fmtName.c_str())); } } else // build as a subset @@ -425,20 +524,21 @@ int main(int nNbArg, char **ppArgs) // Load existing uv file CIFile iFile; string filename = CPath::lookup (existingUVfilename, false); - if( (filename == "") || (!iFile.open(filename)) ) + + if( filename.empty() || !iFile.open(filename) ) { - outString (string("ERROR : could not open file ") + existingUVfilename + "\n"); + outString(toString("ERROR: Unable to open %s", existingUVfilename.c_str())); return -1; } // Write subset UV text file fmtName = fmtName.substr(0, fmtName.rfind('.')); fmtName += ".txt"; - FILE *f = fopen (fmtName.c_str(), "wt"); + FILE *f = nlfopen(fmtName, "wb"); + if (f == NULL) { - outString (string("ERROR: Cannot write UV file : ") + fmtName + "\n"); -// fclose (iFile); + outString(toString("ERROR: Unable to write UV file %s", fmtName.c_str())); return -1; } @@ -454,17 +554,27 @@ int main(int nNbArg, char **ppArgs) continue; } + sTGAname = toLower(string(tgaName)); + + // search position of extension + std::string tgaExt = CFile::getExtension(sTGAname); + + // remove extension + sTGAname = CFile::getFilenameWithoutExtension(sTGAname); + sint i; - sTGAname = toLower(string(tgaName)); string findTGAName; for (i = 0; i < mapSize; ++i) { // get the string whitout path - findTGAName = toLower(CFile::getFilename(AllMapNames[i])); + findTGAName = toLower(CFile::getFilenameWithoutExtension(AllMapNames[i])); if( findTGAName == sTGAname ) break; } + + // append extension + sTGAname += "." + tgaExt; if( i == mapSize ) { @@ -474,13 +584,11 @@ int main(int nNbArg, char **ppArgs) else { // present in subset: use new uv's - fprintf (f, "%s %.12f %.12f %.12f %.12f\n", sTGAname.c_str(), UVMin[i].U, UVMin[i].V, - UVMax[i].U, UVMax[i].V); + fprintf (f, "%s %.12f %.12f %.12f %.12f\n", sTGAname.c_str(), UVMin[i].U, UVMin[i].V, UVMax[i].U, UVMax[i].V); } } -// fclose (iFile); fclose (f); - outString (string("Writing UV file : ") + fmtName + "\n"); + outString(toString("Writing UV file: %s", fmtName.c_str())); } return 0; diff --git a/code/nel/tools/3d/cluster_viewer/view_cs.cpp b/code/nel/tools/3d/cluster_viewer/view_cs.cpp index 5e31543ca..fa5485ca0 100644 --- a/code/nel/tools/3d/cluster_viewer/view_cs.cpp +++ b/code/nel/tools/3d/cluster_viewer/view_cs.cpp @@ -161,21 +161,20 @@ void LoadSceneScript (const char *ScriptName, CScene* pScene, vector &D { if (nLastNbPlus >= nNbPlus) for (int i = 0; i < ((nLastNbPlus-nNbPlus)+1); ++i) - if (pile.size() > 0) + if (!pile.empty()) pile.pop_back(); nLastNbPlus = nNbPlus; CInstanceGroup *father = pScene->getGlobalInstanceGroup(); - if (pile.size() > 0) + if (!pile.empty()) father = pile.back(); CInstanceGroup *ITemp = LoadInstanceGroup (nameIG); if (ITemp != NULL) { SDispCS dcsTemp; - dcsTemp.Name = ""; for (sint32 i = 0; i < (1+nNbPlus); ++i) dcsTemp.Name += " "; dcsTemp.Name += nameIG; @@ -339,7 +338,7 @@ int main(int argc, char **argv) } ++itAcc; } - if ((vCluster.size() == 0) && (DispCS[0].pIG == pCurIG)) + if (vCluster.empty() && (DispCS[0].pIG == pCurIG)) { vCluster.push_back (pClipTrav->RootCluster); } diff --git a/code/nel/tools/3d/ig_lighter/ig_lighter.cpp b/code/nel/tools/3d/ig_lighter/ig_lighter.cpp index a243ad7bc..10cbb076d 100644 --- a/code/nel/tools/3d/ig_lighter/ig_lighter.cpp +++ b/code/nel/tools/3d/ig_lighter/ig_lighter.cpp @@ -227,7 +227,7 @@ int main(int argc, char* argv[]) CGlobalRetriever *globalRetriever= NULL; uint32 grFileDate= 0; uint32 rbankFileDate= 0; - if( grFile!="" && rbankFile!="" ) + if( !grFile.empty() && !rbankFile.empty()) { CIFile fin; // serial the retrieverBank. Exception if not found. diff --git a/code/nel/tools/3d/lightmap_optimizer/main.cpp b/code/nel/tools/3d/lightmap_optimizer/main.cpp index 077cc83b5..a84e797ad 100644 --- a/code/nel/tools/3d/lightmap_optimizer/main.cpp +++ b/code/nel/tools/3d/lightmap_optimizer/main.cpp @@ -644,7 +644,7 @@ int main(int nNbArg, char **ppArgs) } } - if (AllLightmapNames.size() == 0) + if (AllLightmapNames.empty()) continue; // Load all the lightmaps diff --git a/code/nel/tools/3d/ligo/plugin_max/CMakeLists.txt b/code/nel/tools/3d/ligo/plugin_max/CMakeLists.txt index 761537791..cd2539ee4 100644 --- a/code/nel/tools/3d/ligo/plugin_max/CMakeLists.txt +++ b/code/nel/tools/3d/ligo/plugin_max/CMakeLists.txt @@ -4,22 +4,24 @@ ADD_LIBRARY(ligoscape_utility SHARED ligoscape_utility.rc ${SRC} ligoscape_utili INCLUDE_DIRECTORIES(${MAXSDK_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES(ligoscape_utility - nelmisc +TARGET_LINK_LIBRARIES(ligoscape_utility + nelmisc nelligo nel3d nelpacs - ${MAXSDK_LIBRARIES} - nel_patch_lib + ${MAXSDK_LIBRARIES} + nel_patch_lib nel_mesh_lib nel_3dsmax_shared comctl32) - + SET_TARGET_PROPERTIES(ligoscape_utility PROPERTIES SUFFIX ".dlx") NL_DEFAULT_PROPS(ligoscape_utility "MAX Plugin: Ligoscape Utility") NL_ADD_RUNTIME_FLAGS(ligoscape_utility) NL_ADD_LIB_SUFFIX(ligoscape_utility) - + +ADD_DEFINITIONS(${MAXSDK_DEFINITIONS}) + INSTALL(TARGETS ligoscape_utility RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) INSTALL(FILES ligoscript.txt DESTINATION maxplugin/docs) INSTALL(DIRECTORY scripts/ diff --git a/code/nel/tools/3d/ligo/plugin_max/ligoscript.txt b/code/nel/tools/3d/ligo/plugin_max/ligoscript.txt index 072e3b06f..71fcf6174 100644 --- a/code/nel/tools/3d/ligo/plugin_max/ligoscript.txt +++ b/code/nel/tools/3d/ligo/plugin_max/ligoscript.txt @@ -46,7 +46,7 @@ NeLLigoGetErrorZoneTemplate code_array vertex_id_array message_array error_index Get the export errors after a call to NeLLigoExportZoneTemplate. code_array is an integer array with the error code. (2 for OpenedEdge, 4 for InvalidVertexList, 5 for NotInserted) -vertex_id_array is an integer array with the id of the vertex where an error occured. +vertex_id_array is an integer array with the id of the vertex where an error occurred. message_array is a string array with the error message for the vertices error_index is the id of the error buffer (1 ~ 9) diff --git a/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp b/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp index 6eb8d1301..44b43beed 100644 --- a/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp +++ b/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp @@ -33,9 +33,10 @@ #include "nel/misc/stream.h" // From ligo library -#include "nel/../../src/ligo/zone_template.h" +#include "nel/ligo/zone_template.h" #include "nel/ligo/ligo_config.h" -#include "nel/../../src/ligo/ligo_error.h" +#include "nel/ligo/ligo_error.h" +#include "nel/misc/path.h" using namespace std; using namespace NLMISC; @@ -124,27 +125,24 @@ bool CMaxToLigo::loadLigoConfigFile (CLigoConfig& config, Interface& it, bool di if (hModule) { // Get the path - char sModulePath[256]; + TCHAR sModulePath[256]; int res=GetModuleFileName(hModule, sModulePath, 256); // Success ? if (res) { // Path - char sDrive[256]; - char sDir[256]; - _splitpath (sModulePath, sDrive, sDir, NULL, NULL); - _makepath (sModulePath, sDrive, sDir, "ligoscape", ".cfg"); + std::string path = NLMISC::CFile::getPath(tStrToUtf8(sModulePath) + "ligoscape.cfg"); try { // Load the config file - config.readConfigFile (sModulePath, false); + config.readConfigFile (path, false); // ok return true; } - catch (Exception& e) + catch (const Exception& e) { // Print an error message char msg[512]; @@ -160,22 +158,22 @@ bool CMaxToLigo::loadLigoConfigFile (CLigoConfig& config, Interface& it, bool di // *************************************************************************** -void CMaxToLigo::errorMessage (const char *msg, const char *title, Interface& it, bool dialog) +void CMaxToLigo::errorMessage(const std::string &msg, const std::string &title, Interface& it, bool dialog) { // Text or dialog ? if (dialog) { // Dialog message - MessageBox (it.GetMAXHWnd(), msg, title, MB_OK|MB_ICONEXCLAMATION); + MessageBox (it.GetMAXHWnd(), utf8ToTStr(msg), utf8ToTStr(title), MB_OK|MB_ICONEXCLAMATION); } else { // Text message - mprintf ((string(msg) + "\n").c_str()); + mprintf (utf8ToTStr(msg + "\n")); } // Output in log - nlwarning ("LIGO ERROR : %s", msg); + nlwarning ("LIGO ERROR : %s", msg.c_str()); } // *************************************************************************** diff --git a/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.h b/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.h index 23bcfd0f2..e8b19073f 100644 --- a/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.h +++ b/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.h @@ -70,7 +70,7 @@ public: * \param it if a max interface * \param dialog is true to see the message in a dilog, false to see it in the script window. */ - static void errorMessage (const char *msg, const char *title, Interface& it, bool dialog); + static void errorMessage (const std::string &msg, const std::string &title, Interface& it, bool dialog); }; } diff --git a/code/nel/tools/3d/ligo/plugin_max/script.cpp b/code/nel/tools/3d/ligo/plugin_max/script.cpp index 8a88136c5..7083a22a7 100644 --- a/code/nel/tools/3d/ligo/plugin_max/script.cpp +++ b/code/nel/tools/3d/ligo/plugin_max/script.cpp @@ -80,11 +80,11 @@ namespace std #include "nel/misc/config_file.h" // From ligo library -#include "nel/../../src/ligo/zone_template.h" +#include "nel/ligo/zone_template.h" #include "nel/ligo/ligo_config.h" -#include "nel/../../src/ligo/ligo_error.h" -#include "nel/../../src/ligo/ligo_material.h" -#include "nel/../../src/ligo/transition.h" +#include "nel/ligo/ligo_error.h" +#include "nel/ligo/ligo_material.h" +#include "nel/ligo/transition.h" #include "nel/ligo/zone_bank.h" #include "max_to_ligo.h" @@ -94,6 +94,10 @@ using namespace NLMISC; using namespace NLLIGO; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // APP DATA #define NEL3D_APPDATA_LIGO_USE_BOUNDINGBOX ((uint32)1342141818) @@ -137,7 +141,7 @@ Value* export_material_cf (Value** arg_list, int count) check_arg_count(export_material, 4, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoExportMaterial [Object] [Filename] [CheckOnly] [Error in dialog]"; + TCHAR *message = _T("NeLLigoExportMaterial [Object] [Filename] [CheckOnly] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], String, message); type_check(arg_list[2], Boolean, message); @@ -151,7 +155,7 @@ Value* export_material_cf (Value** arg_list, int count) nlassert (node); // The second arg - const char *fileName = arg_list[1]->to_string(); + const std::string fileName = tStrToUtf8(arg_list[1]->to_string()); // The third arg bool checkOnly = (arg_list[2]->to_bool() != FALSE); @@ -204,12 +208,7 @@ Value* export_material_cf (Value** arg_list, int count) { // Make a name for the zone - char drive[512]; - char dir[512]; - char name[512]; - char path[512]; - _splitpath (fileName, drive, dir, name, NULL); - _makepath (path, drive, dir, name, ".zone"); + std::string path = CFile::getPath(fileName) + CFile::getFilenameWithoutExtension(fileName) + ".zone"; // Ok ? bool ok = true; @@ -255,7 +254,7 @@ Value* export_material_cf (Value** arg_list, int count) ok = false; } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; @@ -267,8 +266,8 @@ Value* export_material_cf (Value** arg_list, int count) // Remove the files if (!ok) { - remove (fileName); - remove (path); + CFile::deleteFile(fileName); + CFile::deleteFile(path); } } } @@ -306,7 +305,7 @@ Value* export_transition_cf (Value** arg_list, int count) check_arg_count(export_transition, 6, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoExportTransition [Object array (count=9)] [Output filename] [First material filename] [Second material filename] [CheckOnly] [Error in dialog]"; + TCHAR *message = _T("NeLLigoExportTransition [Object array (count=9)] [Output filename] [First material filename] [Second material filename] [CheckOnly] [Error in dialog]"); type_check(arg_list[0], Array, message); type_check(arg_list[1], String, message); type_check(arg_list[2], String, message); @@ -322,12 +321,12 @@ Value* export_transition_cf (Value** arg_list, int count) nlassert (is_array(nodes)); // The second arg - const char *fileName = arg_list[1]->to_string(); + std::string fileName = tStrToUtf8(arg_list[1]->to_string()); // The second arg string matFilename[2]; - matFilename[0] = arg_list[2]->to_string(); - matFilename[1] = arg_list[3]->to_string(); + matFilename[0] = tStrToUtf8(arg_list[2]->to_string()); + matFilename[1] = tStrToUtf8(arg_list[3]->to_string()); // The third arg bool checkOnly = (arg_list[4]->to_bool() != FALSE); @@ -427,7 +426,7 @@ Value* export_transition_cf (Value** arg_list, int count) // Serial materials[mat].serial (inputXml); } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[2048]; @@ -505,10 +504,7 @@ Value* export_transition_cf (Value** arg_list, int count) for (zone=0; zoneappend (Integer::intern (id+1)); // Append messages - messages->append (new String("[LIGO DEBUG] Opened edge")); + messages->append (new String(_T("[LIGO DEBUG] Opened edge"))); } // Return the main error message @@ -687,7 +683,7 @@ Value* check_zone_with_material_cf (Value** arg_list, int count) check_arg_count(check_zone_with_template, 3, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoCheckZoneWithMaterial [Object] [Material filename] [Error in dialog]"; + TCHAR *message = _T("NeLLigoCheckZoneWithMaterial [Object] [Material filename] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], String, message); type_check(arg_list[2], Boolean, message); @@ -700,7 +696,7 @@ Value* check_zone_with_material_cf (Value** arg_list, int count) nlassert (node); // The second arg - string fileName = arg_list[1]->to_string(); + string fileName = tStrToUtf8(arg_list[1]->to_string()); // The fourth arg bool errorInDialog = (arg_list[2]->to_bool() != FALSE); @@ -778,7 +774,7 @@ Value* check_zone_with_material_cf (Value** arg_list, int count) CMaxToLigo::errorMessage (tmp, "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; @@ -820,7 +816,7 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count) check_arg_count(check_zone_with_template, 4, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoCheckZoneWithTransition [Object] [Transition filename] [Transition number: 0~8] [Error in dialog]"; + TCHAR *message = _T("NeLLigoCheckZoneWithTransition [Object] [Transition filename] [Transition number: 0~8] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], String, message); type_check(arg_list[2], Integer, message); @@ -834,7 +830,7 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count) nlassert (node); // The second arg - string fileName = arg_list[1]->to_string(); + string fileName = tStrToUtf8(arg_list[1]->to_string()); // The second arg int transitionNumber = arg_list[2]->to_int(); @@ -901,7 +897,7 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count) CMaxToLigo::errorMessage (tmp, "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; @@ -987,7 +983,7 @@ Value* export_zone_cf (Value** arg_list, int count) check_arg_count(check_zone_with_template, 5, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoExportZone [Object] [Ligozone filename] [Category Array] [Error in dialog] [Snapshot]"; + TCHAR *message = _T("NeLLigoExportZone [Object] [Ligozone filename] [Category Array] [Error in dialog] [Snapshot]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], String, message); type_check(arg_list[2], Array, message); @@ -1002,7 +998,7 @@ Value* export_zone_cf (Value** arg_list, int count) nlassert (node); // The second arg - string fileName = arg_list[1]->to_string(); + string fileName = tStrToUtf8(arg_list[1]->to_string()); // The thrid arg Array *array = (Array*)arg_list[2]; @@ -1047,8 +1043,8 @@ Value* export_zone_cf (Value** arg_list, int count) type_check (cell->get(2), String, message); // Get the strings - categories[i].first = cell->get(1)->to_string(); - categories[i].second = cell->get(2)->to_string(); + categories[i].first = tStrToUtf8(cell->get(1)->to_string()); + categories[i].second = tStrToUtf8(cell->get(2)->to_string()); } // Get a Object pointer @@ -1072,30 +1068,17 @@ Value* export_zone_cf (Value** arg_list, int count) else { // Build a filename - char drive[512]; - char path[512]; - char finalpath[512]; - char name[512]; - char ext[512]; - _splitpath (fileName.c_str(), drive, path, name, ext); + std::string path = NLMISC::CFile::getPath(fileName); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName); // Build the zone filename - char outputFilenameZone[512]; - strcpy (finalpath, path); - strcat (finalpath, "zones\\"); - _makepath (outputFilenameZone, drive, finalpath, name, ".zone"); + std::string outputFilenameZone = path + "zones/" + name + ".zone"; // Build the snap shot filename - char outputFilenameSnapShot[512]; - strcpy (finalpath, path); - strcat (finalpath, "zoneBitmaps\\"); - _makepath (outputFilenameSnapShot, drive, finalpath, name, ".tga"); + std::string outputFilenameSnapShot = path + "zonesBitmaps/" + name + ".tga"; // Build the ligozone filename - char outputFilenameLigozone[512]; - strcpy (finalpath, path); - strcat (finalpath, "zoneLigos\\"); - _makepath (outputFilenameLigozone, drive, finalpath, name, ".ligozone"); + std::string outputFilenameLigozone = path + "zoneLigos/" + name + ".ligozone"; // Build the zone CZone zone; @@ -1179,12 +1162,12 @@ Value* export_zone_cf (Value** arg_list, int count) if (weWantToMakeASnapshot) { CIFile fileFarBank; - char drive[512]; - char path[512]; - char name[512]; - char farBankPathName[512]; - _splitpath (GetBankPathName ().c_str (), drive, path, name, NULL); - _makepath (farBankPathName, drive, path, name, "farbank"); + + std::string path = NLMISC::CFile::getPath(GetBankPathName()); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(GetBankPathName()); + + std::string farBankPathName = path + name + ".farbank"; + if (fileFarBank.open (farBankPathName)) { // Create an xml stream @@ -1313,7 +1296,7 @@ Value* export_zone_cf (Value** arg_list, int count) CMaxToLigo::errorMessage (tmp, "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; @@ -1324,7 +1307,7 @@ Value* export_zone_cf (Value** arg_list, int count) } } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; @@ -1362,14 +1345,14 @@ Value* get_error_string_cf (Value** arg_list, int count) check_arg_count(get_error_string, 1, count); // Checks arg - char *message = "NeLLigoGetErrorString [error code]"; + TCHAR *message = _T("NeLLigoGetErrorString [error code]"); type_check(arg_list[0], Integer, message); // The first arg int errorCode = arg_list[0]->to_int()-1; // Error code - return new String ((char*)CLigoError::getStringError ((CLigoError::TError)errorCode)); + return new String (utf8ToTStr(CLigoError::getStringError ((CLigoError::TError)errorCode))); } // *************************************************************************** @@ -1380,14 +1363,14 @@ Value* set_directory_cf (Value** arg_list, int count) check_arg_count(set_directory, 1, count); // Checks arg - char *message = "NeLLigoDirectory [path]"; + TCHAR *message = _T("NeLLigoDirectory [path]"); type_check(arg_list[0], String, message); // The first arg - const char *dir = arg_list[0]->to_string(); + const std::string dir = tStrToUtf8(arg_list[0]->to_string()); // Set the directory - return (chdir (dir)==0)?&true_value:&false_value; + return (chdir (dir.c_str())==0)?&true_value:&false_value; } // *************************************************************************** @@ -1398,7 +1381,7 @@ Value* get_zone_mask_cf (Value** arg_list, int count) check_arg_count(check_zone_with_template, 5, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoGetZoneMask [Object] [Mask Array] [Width Array] [Height Array] [Error in dialog]"; + TCHAR *message = _T("NeLLigoGetZoneMask [Object] [Mask Array] [Width Array] [Height Array] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], Array, message); type_check(arg_list[2], Array, message); @@ -1558,7 +1541,7 @@ Value* get_zone_size_cf (Value** arg_list, int count) check_arg_count(check_zone_with_template, 6, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoGetZoneMask [Object] [minx Array] [maxy Array] [miny Array] [maxy Array] [Error in dialog]"; + TCHAR *message = _T("NeLLigoGetZoneMask [Object] [minx Array] [maxy Array] [miny Array] [maxy Array] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], Array, message); type_check(arg_list[2], Array, message); @@ -1835,7 +1818,7 @@ bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, c CMaxToLigo::errorMessage ("Can't initialise opengl offscreen renderer", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } } - catch (Exception &e) + catch (const Exception &e) { // Error char tmp[512]; @@ -1859,7 +1842,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) check_arg_count(NeLLigoMakeSnapShot, 7, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoMakeSnapShot [Object] [Snapshot filename] [xMin] [xMax] [yMin] [yMax] [Error in dialog]"; + TCHAR *message = _T("NeLLigoMakeSnapShot [Object] [Snapshot filename] [xMin] [xMax] [yMin] [yMax] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], String, message); type_check(arg_list[2], Integer, message); @@ -1876,7 +1859,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) nlassert (node); // The second arg - string fileName = arg_list[1]->to_string(); + string fileName = tStrToUtf8(arg_list[1]->to_string()); // The thrid arg int xMin = arg_list[2]->to_int(); @@ -1908,11 +1891,9 @@ Value* make_snapshot_cf (Value** arg_list, int count) else { // Build a filename - char drivetga[512]; - char pathtga[512]; - char nametga[512]; - char exttga[512]; - _splitpath (fileName.c_str(), drivetga, pathtga, nametga, exttga); + std::string nametga = CFile::getFilenameWithoutExtension(fileName); + std::string pathtga = CFile::getPath(fileName); + // Build the zone CZone zone; @@ -1956,12 +1937,9 @@ Value* make_snapshot_cf (Value** arg_list, int count) if (tileBank != NULL) { CIFile fileFarBank; - char drive[512]; - char path[512]; - char name[512]; - char farBankPathName[512]; - _splitpath (GetBankPathName ().c_str (), drive, path, name, NULL); - _makepath (farBankPathName, drive, path, name, "farbank"); + std::string name = CFile::getFilenameWithoutExtension(GetBankPathName()); + std::string farBankPathName = CFile::getPath(GetBankPathName()) + name + ".farbank"; + if (fileFarBank.open (farBankPathName)) { // Create an xml stream @@ -1974,8 +1952,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) if (MakeSnapShot (snapshot, *tileBank, *tileFarBank, xMin, xMax, yMin, yMax, config, errorInDialog)) { // Build the snap shot filename - char outputFilenameSnapShot[512]; - _makepath (outputFilenameSnapShot, drivetga, pathtga, nametga, ".tga"); + std::string outputFilenameSnapShot = pathtga + nametga + ".tga"; // Output the snap shot COFile outputSnapShot; @@ -2014,12 +1991,13 @@ Value* make_snapshot_cf (Value** arg_list, int count) bankElm.addCategory (strlwr (categories[j].first), strlwr (categories[j].second)); } + // Catch exception +#if 0 // Write the zone COFile outputLigoZone; - _makepath (outputFilenameSnapShot, drivetga, pathtga, nametga, ".ligozone"); + std::string outputFilenameSnapShot = pathtga + nametga + ".ligozone"; - // Catch exception - /*try + try { // Open the selected zone file if (outputLigoZone.open (outputFilenameSnapShot)) @@ -2042,13 +2020,14 @@ Value* make_snapshot_cf (Value** arg_list, int count) CMaxToLigo::errorMessage (tmp, "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; smprintf (tmp, 512, "Error while loading the file %s : %s", fileName, e.what()); CMaxToLigo::errorMessage (tmp, "NeL Ligo export zone", *MAXScript_interface, errorInDialog); - }*/ + } +#endif } else { @@ -2068,7 +2047,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) } } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; diff --git a/code/nel/tools/3d/mesh_utils/CMakeLists.txt b/code/nel/tools/3d/mesh_utils/CMakeLists.txt index c8390587c..d8a5b29d9 100644 --- a/code/nel/tools/3d/mesh_utils/CMakeLists.txt +++ b/code/nel/tools/3d/mesh_utils/CMakeLists.txt @@ -3,14 +3,14 @@ FILE(GLOB HDRS *.h) SOURCE_GROUP("" FILES ${SRCS} ${HDRS}) -INCLUDE_DIRECTORIES(${assimp_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${ASSIMP_INCLUDE_DIRS}) NL_TARGET_LIB(mesh_utils ${SRCS} ${HDRS}) -TARGET_LINK_LIBRARIES(mesh_utils ${assimp_LIBRARIES} nelmisc nelpipeline nel3d) +TARGET_LINK_LIBRARIES(mesh_utils ${ASSIMP_LIBRARIES} nelmisc nelpipeline nel3d) NL_DEFAULT_PROPS(mesh_utils "NeL, Tools, 3D: Mesh Utils") NL_ADD_RUNTIME_FLAGS(mesh_utils) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS mesh_utils LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT tools3d) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/tools/3d/object_viewer/CMakeLists.txt b/code/nel/tools/3d/object_viewer/CMakeLists.txt index e8def63ff..962f0b5bb 100644 --- a/code/nel/tools/3d/object_viewer/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer/CMakeLists.txt @@ -17,11 +17,11 @@ ADD_DEFINITIONS(${MFC_DEFINITIONS} -DOBJECT_VIEWER_LIB_EXPORTS) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(object_viewer_dll ${CMAKE_CURRENT_SOURCE_DIR}/std_afx.h ${CMAKE_CURRENT_SOURCE_DIR}/std_afx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS object_viewer_dll LIBRARY DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${NL_BIN_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT tools3d) INSTALL(FILES object_viewer.cfg DESTINATION ${NL_ETC_PREFIX} COMPONENT tools3d) IF(WITH_MAXPLUGIN) INSTALL(TARGETS object_viewer_dll RUNTIME DESTINATION maxplugin COMPONENT tools3d) INSTALL(FILES object_viewer.cfg DESTINATION maxplugin COMPONENT tools3d) -ENDIF(WITH_MAXPLUGIN) +ENDIF() diff --git a/code/nel/tools/3d/object_viewer/about_dialog.cpp b/code/nel/tools/3d/object_viewer/about_dialog.cpp index 7aa2c5227..4ebb0a676 100644 --- a/code/nel/tools/3d/object_viewer/about_dialog.cpp +++ b/code/nel/tools/3d/object_viewer/about_dialog.cpp @@ -48,10 +48,10 @@ END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CAboutDialog message handlers -BOOL CAboutDialog::OnInitDialog() +BOOL CAboutDialog::OnInitDialog() { CDialog::OnInitDialog(); - + // Get the module path HMODULE hModule = AfxGetInstanceHandle(); nlassert(hModule); // shouldn't be null now anymore in any case @@ -70,17 +70,17 @@ BOOL CAboutDialog::OnInitDialog() { uint *versionTab; uint versionSize; - if (VerQueryValue (pInfo, "\\", (void**)&versionTab, &versionSize)) + if (VerQueryValue (pInfo, _T("\\"), (void**)&versionTab, &versionSize)) { // Get the pointer on the structure - VS_FIXEDFILEINFO *info=(VS_FIXEDFILEINFO*)versionTab; + VS_FIXEDFILEINFO *info = (VS_FIXEDFILEINFO*)versionTab; // Setup version number - char version[512]; - sprintf (version, "Version %d.%d.%d.%d", - info->dwFileVersionMS>>16, - info->dwFileVersionMS&0xffff, - info->dwFileVersionLS>>16, + TCHAR version[512]; + _stprintf (version, _T("Version %d.%d.%d.%d"), + info->dwFileVersionMS>>16, + info->dwFileVersionMS&0xffff, + info->dwFileVersionLS>>16, info->dwFileVersionLS&0xffff); GetDlgItem (IDC_VERSION)->SetWindowText (version); } @@ -88,7 +88,7 @@ BOOL CAboutDialog::OnInitDialog() } } } - + return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } diff --git a/code/nel/tools/3d/object_viewer/animation_dlg.cpp b/code/nel/tools/3d/object_viewer/animation_dlg.cpp index 18952ef21..30b801256 100644 --- a/code/nel/tools/3d/object_viewer/animation_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/animation_dlg.cpp @@ -85,7 +85,7 @@ END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CAnimationDlg message handlers -void CAnimationDlg::OnEnd() +void CAnimationDlg::OnEnd() { UpdateData (); CurrentFrame=End; @@ -95,7 +95,7 @@ void CAnimationDlg::OnEnd() updateBar (); } -void CAnimationDlg::OnPlay() +void CAnimationDlg::OnPlay() { // play UpdateData (); @@ -111,7 +111,7 @@ void CAnimationDlg::OnPlay() Main->enableFXs(true); } -void CAnimationDlg::OnStop() +void CAnimationDlg::OnStop() { // Is checked ? UpdateData (); @@ -124,7 +124,7 @@ void CAnimationDlg::OnStop() Main->enableFXs(false); } -void CAnimationDlg::OnChangeCurrentFrame() +void CAnimationDlg::OnChangeCurrentFrame() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() @@ -133,7 +133,7 @@ void CAnimationDlg::OnChangeCurrentFrame() // Update values UpdateData (); - + // Clamp current frame clamp (UICurrentFrame, (int)Start, (int)End); CurrentFrame=(float)UICurrentFrame; @@ -141,21 +141,21 @@ void CAnimationDlg::OnChangeCurrentFrame() // Update updateBar (); - UpdateData (FALSE); + UpdateData (FALSE); } -void CAnimationDlg::OnChangeEndEdit() +void CAnimationDlg::OnChangeEndEdit() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. - + // TODO: Add your control notification handler code here // Update values UpdateData (); - + // Clamp current frame if (EndsetAnimTime (Start, End); } -void CAnimationDlg::OnChangeSpeed() +void CAnimationDlg::OnChangeSpeed() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. - + UpdateData(); if (Speed<=0.001f) Speed=0.001f; @@ -187,7 +187,7 @@ void CAnimationDlg::OnChangeSpeed() Main->setAnimTime (Start, End); } -void CAnimationDlg::OnStart() +void CAnimationDlg::OnStart() { UpdateData (); CurrentFrame=Start; @@ -197,16 +197,16 @@ void CAnimationDlg::OnStart() updateBar (); } -void CAnimationDlg::OnChangeStartEdit() +void CAnimationDlg::OnChangeStartEdit() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. - + // Update values UpdateData (); - + // Clamp current frame if (EndsetAnimTime (Start, End); } -void CAnimationDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +void CAnimationDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: Add your message handler code here and/or call default @@ -290,7 +290,7 @@ void CAnimationDlg::handle () float backup = CurrentFrame; CurrentFrame=(float)fmod ((CurrentFrame-Start), End-Start)+Start; if (backup!=CurrentFrame) - { + { LastFrame = CurrentFrame; Main->enableFXs(false); Main->enableFXs(true); @@ -306,7 +306,7 @@ void CAnimationDlg::handle () // Stop animation OnStop (); - + } if (CurrentFrameloadAnimation (name, instance); + _ObjView->loadAnimation (tStrToUtf8(name), instance); // Touch the channel mixer _ObjView->reinitChannels (); @@ -156,9 +156,9 @@ void CAnimationSetDlg::OnAddAnimation () refresh (TRUE); } } - catch (Exception& e) + catch (const Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -173,8 +173,8 @@ void CAnimationSetDlg::OnAddSkelWt() if (instance != CB_ERR) { // TODO: Add your control notification handler code here - static char BASED_CODE szFilter[] = "NeL Skeleton Weight Template Files (*.swt)|*.swt|All Files (*.*)|*.*||"; - CFileDialog fileDlg( TRUE, ".swt", "*.swt", OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("NeL Skeleton Weight Template Files (*.swt)|*.swt|All Files (*.*)|*.*||"); + CFileDialog fileDlg( TRUE, _T(".swt"), _T("*.swt"), OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal()==IDOK) { // Open the file @@ -188,7 +188,7 @@ void CAnimationSetDlg::OnAddSkelWt() CString filename=fileDlg.GetNextPathName(pos); // Load the animation - _ObjView->loadSWT (filename, instance); + _ObjView->loadSWT (tStrToUtf8(filename), instance); // Touch the channel mixer _ObjView->reinitChannels (); @@ -197,9 +197,9 @@ void CAnimationSetDlg::OnAddSkelWt() refresh (TRUE); } } - catch (Exception& e) + catch (const Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -233,9 +233,8 @@ void CAnimationSetDlg::refresh (BOOL update) uint i; for (i=0; i<_ObjView->getNumInstance (); i++) { - char name[512]; - _splitpath (_ObjView->getInstance (i)->Saved.ShapeFilename.c_str(), NULL, NULL, name, NULL); - EditedObject.InsertString (-1, name); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(_ObjView->getInstance(i)->Saved.ShapeFilename); + EditedObject.InsertString (-1, utf8ToTStr(name)); } // Get edited object @@ -263,14 +262,13 @@ void CAnimationSetDlg::refresh (BOOL update) for (i=0; iSaved.AnimationFileName.size(); i++) { // Get the animation name - char name[512]; - _splitpath (object->Saved.AnimationFileName[i].c_str(), NULL, NULL, name, NULL); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(object->Saved.AnimationFileName[i]); // Get the animation pointer CAnimation *anim = object->AnimationSet.getAnimation (object->AnimationSet.getAnimationIdByName (name)); // Insert an intem - HTREEITEM item=Tree.InsertItem (name); + HTREEITEM item=Tree.InsertItem(utf8ToTStr(name)); Tree.SetItemData (item, i); nlassert (item!=NULL); @@ -281,7 +279,7 @@ void CAnimationSetDlg::refresh (BOOL update) while (ite!=setString.end()) { // Add this string - HTREEITEM newItem = Tree.InsertItem (ite->c_str(), item); + HTREEITEM newItem = Tree.InsertItem (utf8ToTStr(*ite), item); Tree.SetItemData (newItem, 0xffffffff); // Get the track @@ -289,6 +287,7 @@ void CAnimationSetDlg::refresh (BOOL update) // Keyframer ? UTrackKeyframer *keyTrack=dynamic_cast(track); + if (keyTrack) { // Get number of keys @@ -296,20 +295,17 @@ void CAnimationSetDlg::refresh (BOOL update) keyTrack->getKeysInRange (track->getBeginTime ()-1, track->getEndTime ()+1, keys); // Print track info - char name[512]; - _snprintf (name, 512, "%s (%f - %f) %d keys", typeid(*track).name(), track->getBeginTime (), track->getEndTime (), keys.size()); - HTREEITEM keyItem = Tree.InsertItem (name, newItem); - Tree.SetItemData (keyItem, 0xffffffff); + name = toString("%s (%f - %f) %u keys", typeid(*track).name(), track->getBeginTime(), track->getEndTime(), (uint32)keys.size()); } else { // Print track info - char name[512]; - _snprintf (name, 512, "%s (%f - %f)", typeid(*track).name(), track->getBeginTime (), track->getEndTime ()); - HTREEITEM keyItem = Tree.InsertItem (name, newItem); - Tree.SetItemData (keyItem, 0xffffffff); + name = toString("%s (%f - %f)", typeid(*track).name(), track->getBeginTime(), track->getEndTime()); } + HTREEITEM keyItem = Tree.InsertItem(utf8ToTStr(name), newItem); + Tree.SetItemData(keyItem, 0xffffffff); + ite++; } } @@ -318,14 +314,13 @@ void CAnimationSetDlg::refresh (BOOL update) for (i=0; iSaved.SWTFileName.size(); i++) { // Get the animation name - char name[512]; - _splitpath (object->Saved.SWTFileName[i].c_str(), NULL, NULL, name, NULL); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(object->Saved.SWTFileName[i]); // Get the animation pointer - CSkeletonWeight *swt = object->AnimationSet.getSkeletonWeight (object->AnimationSet.getSkeletonWeightIdByName (name)); + CSkeletonWeight *swt = object->AnimationSet.getSkeletonWeight(object->AnimationSet.getSkeletonWeightIdByName(name)); // Insert an intem - HTREEITEM item=SkelTree.InsertItem (name); + HTREEITEM item=SkelTree.InsertItem(utf8ToTStr(name)); nlassert (item!=NULL); // Get number of node in this skeleton weight @@ -334,11 +329,10 @@ void CAnimationSetDlg::refresh (BOOL update) // Add the nodein the tree for (uint n=0; ngetNodeName (n).c_str(), swt->getNodeWeight(n)*100); + std::string percent = toString("%s (%f%%)", swt->getNodeName(n).c_str(), swt->getNodeWeight(n)*100); // Add this string - SkelTree.InsertItem (percent, item); + SkelTree.InsertItem (utf8ToTStr(percent), item); } } @@ -346,7 +340,7 @@ void CAnimationSetDlg::refresh (BOOL update) for (i=0; iSaved.PlayList.size(); i++) { // Insert an intem - int item=PlayList.InsertString (-1, object->Saved.PlayList[i].c_str()); + int item=PlayList.InsertString (-1, utf8ToTStr(object->Saved.PlayList[i])); nlassert (item!=LB_ERR); } } @@ -372,9 +366,9 @@ void CAnimationSetDlg::refresh (BOOL update) for (i=0; iSaved.PlayList.size(); i++) { // Insert an intem - char text[512]; + TCHAR text[512]; PlayList.GetText( i, text); - object->Saved.PlayList[i] = text; + object->Saved.PlayList[i] = tStrToUtf8(text); } CDialog::UpdateData (update); diff --git a/code/nel/tools/3d/object_viewer/attrib_dlg.cpp b/code/nel/tools/3d/object_viewer/attrib_dlg.cpp index a70216a43..674e7f307 100644 --- a/code/nel/tools/3d/object_viewer/attrib_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/attrib_dlg.cpp @@ -355,7 +355,7 @@ void CAttribDlg::init(HBITMAP bitmap, sint x, sint y, CWnd *pParent) for (uint k = 0; k < getNumScheme(); ++k) { - m_Scheme.InsertString(k, getSchemeName(k).c_str()); + m_Scheme.InsertString(k, utf8ToTStr(getSchemeName(k))); } @@ -683,7 +683,7 @@ END_MESSAGE_MAP() { CString out; - out.Format("%g", Scheme->getValue(index) ); + out.Format(_T("%g"), Scheme->getValue(index) ); dc->TextOut(x + 10, y + 4, out); } CEditAttribDlg *newDialog(const std::string &id, IPSWrapperFloat *wrapper) @@ -896,7 +896,7 @@ END_MESSAGE_MAP() { CString out; - out.Format("%d", Scheme->getValue(index) ); + out.Format(_T("%d"), Scheme->getValue(index) ); dc->TextOut(x + 10, y + 4, out); } CEditAttribDlg *newDialog(const std::string &id, IPSWrapperUInt *wrapper) @@ -1085,7 +1085,7 @@ END_MESSAGE_MAP() { CString out; - out.Format("%d", Scheme->getValue(index) ); + out.Format(_T("%d"), Scheme->getValue(index) ); dc->TextOut(x + 10, y + 4, out); } CEditAttribDlg *newDialog(const std::string &id, IPSWrapper *wrapper) diff --git a/code/nel/tools/3d/object_viewer/bin_op_dlg.h b/code/nel/tools/3d/object_viewer/bin_op_dlg.h index a35e8ee6a..1e54d7e98 100644 --- a/code/nel/tools/3d/object_viewer/bin_op_dlg.h +++ b/code/nel/tools/3d/object_viewer/bin_op_dlg.h @@ -98,14 +98,14 @@ public: } // init the operator list box - static const char *ops[] = { "selectArg1", "selectArg2", "modulate", "add", "subtract" } ; + static const TCHAR *ops[] = { _T("selectArg1"), _T("selectArg2"), _T("modulate"), _T("add"), _T("subtract") }; for (k = 0 ; k < (uint) NL3D::CPSBinOp::last ; ++k) { // SchemeWrapper[k].S reference the atriobute maker being edited if (_EditedScheme->supportOp( (NL3D::CPSBinOp::BinOp) k)) { - sint index = m_BinOp.AddString(ops[k]) ; - m_BinOp.SetItemData(index, k) ; + sint index = m_BinOp.AddString(ops[k]); + m_BinOp.SetItemData(index, k); if ((uint) _EditedScheme->getOp() == k) { m_BinOp.SetCurSel(k) ; diff --git a/code/nel/tools/3d/object_viewer/bound_checker.h b/code/nel/tools/3d/object_viewer/bound_checker.h index 6f797b556..1c1edec0c 100644 --- a/code/nel/tools/3d/object_viewer/bound_checker.h +++ b/code/nel/tools/3d/object_viewer/bound_checker.h @@ -77,24 +77,24 @@ public: /** validate a value against upper bound. (if an upper bound was set * \return NULL if ok or an error message */ - const char *validateUpperBound(T v) + const TCHAR *validateUpperBound(T v) { if (!_UpperBoundEnabled) return NULL; if (_UpperBoundExcluded && v < _UpperBound) return NULL; if (!_UpperBoundExcluded && v <= _UpperBound) return NULL; - return "value too high"; + return _T("value too high"); } /** validate a value against lower bound. (if an lower bound was set * \return NULL if ok or an error message */ - const char *validateLowerBound(T v) + const TCHAR *validateLowerBound(T v) { if (!_LowerBoundEnabled) return NULL; if (_LowerBoundExcluded && v > _LowerBound) return NULL; if (!_LowerBoundExcluded && v >= _LowerBound) return NULL; - return "value too low"; + return _T("value too low"); } /// copy this bound checker object to another one diff --git a/code/nel/tools/3d/object_viewer/choose_name.cpp b/code/nel/tools/3d/object_viewer/choose_name.cpp index ac15d50da..91dbf8d40 100644 --- a/code/nel/tools/3d/object_viewer/choose_name.cpp +++ b/code/nel/tools/3d/object_viewer/choose_name.cpp @@ -22,18 +22,18 @@ // CChooseName dialog -CChooseName::CChooseName(const char *initialName, CWnd* pParent /*=NULL*/) +CChooseName::CChooseName(const CString &initialName, CWnd* pParent /*=NULL*/) : CDialog(CChooseName::IDD, pParent) { //{{AFX_DATA_INIT(CChooseName) - m_Name = _T(initialName); + m_Name = initialName; //}}AFX_DATA_INIT } std::string CChooseName::getName() { - return std::string(m_Name); + return tStrToUtf8(m_Name); } void CChooseName::DoDataExchange(CDataExchange* pDX) diff --git a/code/nel/tools/3d/object_viewer/choose_name.h b/code/nel/tools/3d/object_viewer/choose_name.h index bcde16b76..a4a66e128 100644 --- a/code/nel/tools/3d/object_viewer/choose_name.h +++ b/code/nel/tools/3d/object_viewer/choose_name.h @@ -32,7 +32,7 @@ class CChooseName : public CDialog { // Construction public: - CChooseName(const char *initialName, CWnd* pParent = NULL); // standard constructor + CChooseName(const CString &initialName, CWnd* pParent = NULL); // standard constructor std::string getName(); diff --git a/code/nel/tools/3d/object_viewer/choose_pool_id.cpp b/code/nel/tools/3d/object_viewer/choose_pool_id.cpp index b15236cf0..3653e72d1 100644 --- a/code/nel/tools/3d/object_viewer/choose_pool_id.cpp +++ b/code/nel/tools/3d/object_viewer/choose_pool_id.cpp @@ -52,25 +52,28 @@ void CChoosePoolID::OnOK() { CString val; GetDlgItem(IDC_POOL_ID)->GetWindowText(val); - if (::sscanf((LPCTSTR) val, "%d", &PoolID) == 1) + + if (NLMISC::fromString(tStrToUtf8(val), PoolID)) { GetDlgItem(IDC_POOL_NAME)->GetWindowText(val); - Name = (LPCTSTR) val; + Name = tStrToUtf8(val); CDialog::OnOK(); } else { - MessageBox("Invalid value", "error", MB_OK); + MessageBox(_T("Invalid value"), _T("error"), MB_OK); } } BOOL CChoosePoolID::OnInitDialog() { CDialog::OnInitDialog(); - char val[128]; - sprintf(val, "%d", PoolID); - GetDlgItem(IDC_POOL_ID)->SetWindowText(val); - GetDlgItem(IDC_POOL_NAME)->SetWindowText(Name.c_str()); + + std::string val = NLMISC::toString(PoolID); + + GetDlgItem(IDC_POOL_ID)->SetWindowText(utf8ToTStr(val)); + GetDlgItem(IDC_POOL_NAME)->SetWindowText(utf8ToTStr(Name)); + if (_FreezeID) { GetDlgItem(IDC_POOL_ID)->EnableWindow(FALSE); diff --git a/code/nel/tools/3d/object_viewer/create_file_dlg.cpp b/code/nel/tools/3d/object_viewer/create_file_dlg.cpp index e42191f0b..64a404f88 100644 --- a/code/nel/tools/3d/object_viewer/create_file_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/create_file_dlg.cpp @@ -72,7 +72,7 @@ BOOL CCreateFileDlg::OnInitDialog() { CDialog::OnInitDialog(); SetWindowText((LPCTSTR) _Title); - GetDlgItem(IDC_LOCATION)->SetWindowText(_DefaultBasePath.c_str()); + GetDlgItem(IDC_LOCATION)->SetWindowText(utf8ToTStr(_DefaultBasePath)); if (!_DefaultBasePath.empty()) { GetDlgItem(IDC_FILENAME)->SetFocus(); @@ -90,10 +90,10 @@ void CCreateFileDlg::OnOK() { CString filename; GetDlgItem(IDC_FILENAME)->GetWindowText(filename); - _Filename = (LPCTSTR) filename; + _Filename = tStrToUtf8(filename); CString location; GetDlgItem(IDC_LOCATION)->GetWindowText(location); - _Path = (LPCTSTR) location; + _Path = tStrToUtf8(location); if (_Path.empty()) { localizedMessageBox(*this, IDS_EMPTY_PATH, IDS_ERROR, MB_ICONEXCLAMATION); @@ -139,9 +139,9 @@ void CCreateFileDlg::OnOK() void CCreateFileDlg::OnCancel() { - _Filename = ""; - _Path = ""; - _FullPath = ""; + _Filename.clear(); + _Path.clear(); + _FullPath.clear(); CDialog::OnCancel(); } diff --git a/code/nel/tools/3d/object_viewer/direction_attr.cpp b/code/nel/tools/3d/object_viewer/direction_attr.cpp index 666fd60e0..047457390 100644 --- a/code/nel/tools/3d/object_viewer/direction_attr.cpp +++ b/code/nel/tools/3d/object_viewer/direction_attr.cpp @@ -173,7 +173,7 @@ void CDirectionAttr::OnDestroy() void CDirectionAttr::OnGlobalDirection() { nlassert(_DirectionWrapper); - CChooseName chooseName(_DirectionWrapper->getGlobalVectorValueName().c_str()); + CChooseName chooseName(utf8ToTStr(_DirectionWrapper->getGlobalVectorValueName())); if (chooseName.DoModal() == IDOK) { diff --git a/code/nel/tools/3d/object_viewer/dup_ps.cpp b/code/nel/tools/3d/object_viewer/dup_ps.cpp index 6d21a7496..1d9f538c4 100644 --- a/code/nel/tools/3d/object_viewer/dup_ps.cpp +++ b/code/nel/tools/3d/object_viewer/dup_ps.cpp @@ -40,7 +40,7 @@ using namespace NL3D; * TODO maybe this could be used elsewhere ? */ template -static T *DupSerializable(const T *in) throw(NLMISC::EStream) +static T *DupSerializable(const T *in) { NLMISC::CMemStream ms; nlassert(!ms.isReading()); @@ -62,12 +62,12 @@ static T *DupSerializable(const T *in) throw(NLMISC::EStream) struct CDupObjPolicy { template - static void serial(T *&obj, NLMISC::IStream &dest) throw(NLMISC::EStream) + static void serial(T *&obj, NLMISC::IStream &dest) { dest.serialPtr(obj); /*if (dest.isReading()) { - std::auto_ptr newObj(new T); + CUniquePtr newObj(new T); newObj->serialPtr(dest); delete obj; obj = newObj.release(); @@ -84,7 +84,7 @@ struct CDupObjPolicy struct CDupPolymorphicObjPolicy { template - static void serial(T *&obj, NLMISC::IStream &dest) throw(NLMISC::EStream) + static void serial(T *&obj, NLMISC::IStream &dest) { dest.serialPolyPtr(obj); } @@ -112,13 +112,13 @@ NL3D::CParticleSystemProcess *DupPSLocated(const CParticleSystemProcess *in) /** Duplicate the system, and detach. * We can't duplicate the object direclty (it may be referencing other objects in the system, so these objects will be copied too...) */ - std::auto_ptr newPS(DupSerializable(in->getOwner())); + CUniquePtr newPS(DupSerializable(in->getOwner())); // scene pointer is not serialised, but 'detach' may need the scene to be specified newPS->setScene(in->getOwner()->getScene()); return newPS->detach(index); } } - catch (NLMISC::EStream &e) + catch (const NLMISC::EStream &e) { nlwarning (e.what()); return NULL; @@ -142,7 +142,7 @@ NL3D::CPSLocatedBindable *DupPSLocatedBindable(CPSLocatedBindable *in) else { CParticleSystem *srcPS = in->getOwner()->getOwner(); - std::auto_ptr newPS(DupSerializable(srcPS)); + CUniquePtr newPS(DupSerializable(srcPS)); // scene pointer is not serialised, but 'detach' may need the scene to be specified newPS->setScene(in->getOwner()->getOwner()->getScene()); // @@ -154,7 +154,7 @@ NL3D::CPSLocatedBindable *DupPSLocatedBindable(CPSLocatedBindable *in) return loc->unbind(subIndex); } } - catch (NLMISC::EStream &e) + catch (const NLMISC::EStream &e) { nlwarning (e.what()); return NULL; diff --git a/code/nel/tools/3d/object_viewer/edit_ex.cpp b/code/nel/tools/3d/object_viewer/edit_ex.cpp index 71d5b8907..97df943f2 100644 --- a/code/nel/tools/3d/object_viewer/edit_ex.cpp +++ b/code/nel/tools/3d/object_viewer/edit_ex.cpp @@ -74,36 +74,36 @@ float CEditEx::getFloat() const std::string CEditEx::getString() const { - char buf[128]; + TCHAR buf[128]; GetWindowText(buf, sizeof(buf)); - return std::string(buf); + return tStrToUtf8(buf); } void CEditEx::setSInt(sint value) { nlassert(_Type == SIntType); - char buf[16]; - sprintf(buf, "%d", (int) value); + TCHAR buf[16]; + _stprintf(buf, _T("%d"), (int) value); setString(buf); } void CEditEx::setUInt(uint value) { nlassert(_Type == UIntType); - char buf[16]; - sprintf(buf, "%d", (int) value); + TCHAR buf[16]; + _stprintf(buf, _T("%d"), (int) value); setString(buf); } void CEditEx::setFloat(float value) { nlassert(_Type == FloatType); - char buf[16]; - sprintf(buf, "%g", (double) value); + TCHAR buf[16]; + _stprintf(buf, _T("%g"), (double) value); setString(buf); } -void CEditEx::setString(const char *value) +void CEditEx::setString(const TCHAR *value) { SetWindowText(value); } @@ -121,7 +121,7 @@ void CEditEx::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) } else { - MessageBox("Invalid value", "Error", MB_OK | MB_ICONEXCLAMATION); + MessageBox(_T("Invalid value"), _T("Error"), MB_OK | MB_ICONEXCLAMATION); } } CEdit::OnKeyDown(nChar, nRepCnt, nFlags); @@ -130,21 +130,25 @@ void CEditEx::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) bool CEditEx::isValid() { - int iValue; - float fValue; switch(_Type) { case SIntType: - return sscanf(getString().c_str(), "%d", &iValue) == 1; - break; + { + sint value; + return NLMISC::fromString(getString(), value); + } case UIntType: - return sscanf(getString().c_str(), "%d", &iValue) == 1 && iValue >= 0; - break; + { + uint value; + return NLMISC::fromString(getString(), value); + } case FloatType: - return sscanf(getString().c_str(), "%f", &fValue) == 1; - break; - default: - return true; - break; + { + float value; + return NLMISC::fromString(getString(), value); + } + default: break; } + + return true; } diff --git a/code/nel/tools/3d/object_viewer/edit_ex.h b/code/nel/tools/3d/object_viewer/edit_ex.h index 759b51f51..957960fcc 100644 --- a/code/nel/tools/3d/object_viewer/edit_ex.h +++ b/code/nel/tools/3d/object_viewer/edit_ex.h @@ -57,7 +57,7 @@ public: void setSInt(sint value); void setUInt(uint value); void setFloat(float value); - void setString(const char *value); + void setString(const TCHAR *value); // Overrides diff --git a/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp b/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp index 091e6413c..0c7def7e9 100644 --- a/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp @@ -81,27 +81,15 @@ void CEditMorphMeshDlg::init(CWnd *pParent) //==================================================================== bool CEditMorphMeshDlg::getShapeNameFromDlg(std::string &name) { - CFileDialog fd(TRUE, ".shape", "*.shape", 0, NULL, this); + CFileDialog fd(TRUE, _T(".shape"), _T("*.shape"), 0, NULL, this); if (fd.DoModal() == IDOK) { - // Add to the path - /* - char drive[256]; - char dir[256]; - char path[256]; - char fname[256]; - char ext[256]; - */ - - // Add search path for the texture /* - _splitpath (fd.GetPathName(), drive, dir, fname, ext); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())); */ - name = fd.GetPathName(); + name = tStrToUtf8(fd.GetPathName()); return true; } @@ -135,7 +123,7 @@ void CEditMorphMeshDlg::OnAdd() _CM->setShapes(&shapeNames[0], (uint)shapeNames.size()); std::vector numVerts; _CM->getShapeNumVerts(numVerts); - m_MeshList.AddString(getShapeDescStr(index, numVerts[index]).c_str()); + m_MeshList.AddString(utf8ToTStr(getShapeDescStr(index, numVerts[index]))); GetDlgItem(IDC_REMOVE)->EnableWindow(TRUE); } touchPSState(); @@ -265,7 +253,7 @@ void CEditMorphMeshDlg::updateMeshList() m_MeshList.ResetContent(); for (uint k = 0; k < _CM->getNumShapes(); ++k) { - m_MeshList.AddString(getShapeDescStr(k, numVerts[k]).c_str()); + m_MeshList.AddString(utf8ToTStr(getShapeDescStr(k, numVerts[k]))); } m_MeshList.SetCurSel(0); updateValidFlag(); @@ -322,12 +310,12 @@ std::string CEditMorphMeshDlg::getShapeDescStr(uint shapeIndex, sint numVerts) c { CString verts; verts.LoadString(IDS_VERTICES); - std::string msg = _CM->getShape(shapeIndex) + " (" + NLMISC::toString(numVerts) + " " + (LPCTSTR) verts + ")"; + std::string msg = _CM->getShape(shapeIndex) + " (" + NLMISC::toString(numVerts) + " " + tStrToUtf8(verts) + ")"; return msg; } else { - std::string result = _CM->getShape(shapeIndex) + " (" + (LPCTSTR) CMeshDlg::getShapeErrorString(numVerts) + ")"; + std::string result = _CM->getShape(shapeIndex) + " (" + tStrToUtf8(CMeshDlg::getShapeErrorString(numVerts)) + ")"; return result; } } diff --git a/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp b/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp index 891818a43..40406c2fa 100644 --- a/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp +++ b/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp @@ -195,7 +195,7 @@ void CEditPSSound::OnChangeSoundName() { nlassert(_Sound); UpdateData(); - _Sound->setSoundName(NLMISC::CSheetId((LPCTSTR)m_SoundName, "sound")); + _Sound->setSoundName(NLMISC::CSheetId(tStrToUtf8(m_SoundName), "sound")); updateModifiedFlag(); } @@ -209,7 +209,7 @@ void CEditPSSound::OnSpawn() // play the currently selected sound void CEditPSSound::OnPlaySound() { - CSoundSystem::play(std::string((LPCTSTR)m_SoundName)); + CSoundSystem::play(tStrToUtf8(m_SoundName)); } void CEditPSSound::OnMute() diff --git a/code/nel/tools/3d/object_viewer/editable_range.cpp b/code/nel/tools/3d/object_viewer/editable_range.cpp index b86b35a72..28806fc31 100644 --- a/code/nel/tools/3d/object_viewer/editable_range.cpp +++ b/code/nel/tools/3d/object_viewer/editable_range.cpp @@ -159,7 +159,7 @@ void CEditableRange::OnUpdateValue() void CEditableRange::emptyDialog(void) { - m_Value = CString(""); + m_Value.Empty(); m_SliderPos = 0; UpdateData(FALSE); } @@ -185,12 +185,12 @@ static void concatEdit2Lines(CEdit &edit) const uint lineLen= 1000; uint n; // retrieve the 2 lines. - char tmp0[2*lineLen]; - char tmp1[lineLen]; + TCHAR tmp0[2*lineLen]; + TCHAR tmp1[lineLen]; n= edit.GetLine(0, tmp0, lineLen); tmp0[n]= 0; n= edit.GetLine(1, tmp1, lineLen); tmp1[n]= 0; // concat and update the CEdit. - edit.SetWindowText(strcat(tmp0, tmp1)); + edit.SetWindowText(_tcscat(tmp0, tmp1)); } diff --git a/code/nel/tools/3d/object_viewer/editable_range.h b/code/nel/tools/3d/object_viewer/editable_range.h index 485f57659..5a4b6263c 100644 --- a/code/nel/tools/3d/object_viewer/editable_range.h +++ b/code/nel/tools/3d/object_viewer/editable_range.h @@ -133,7 +133,7 @@ public: // SPECIALIZE THAT. write value into the given CString static void value2CString(T value, CString &dest); // SPECIALIZE THAT. convert a CString into a value, return NULL if ok, or a pointer to an error message - static const char *string2value(const CString &value, T &result); + static const TCHAR *string2value(const CString &value, T &result); @@ -162,14 +162,13 @@ protected: void updateValueFromText(void) { T value; - const char *message = string2value(m_Value, value); + const TCHAR *message = string2value(m_Value, value); if (!message) { - const char *mess = validateUpperBound(value) - ,*mess2 = validateLowerBound(value); + const TCHAR *mess = validateUpperBound(value), *mess2 = validateLowerBound(value); if (mess || mess2) { - MessageBox(mess ? mess : mess2, "error"); + MessageBox(mess ? mess : mess2, _T("error")); return; } @@ -179,7 +178,7 @@ protected: return; } - MessageBox(message, "error"); + MessageBox(message, _T("error")); } void selectRange(void) @@ -249,24 +248,23 @@ protected: { T upT, loT; - const char *message = string2value(lo, loT); + const TCHAR *message = string2value(lo, loT); if (message) { - ::MessageBox(NULL, message, "Range selection error", MB_OK); + ::MessageBox(NULL, message, _T("Range selection error"), MB_OK); return false; } - const char *mess = validateUpperBound(loT) - ,*mess2 = validateLowerBound(loT); + const TCHAR *mess = validateUpperBound(loT), *mess2 = validateLowerBound(loT); if (mess || mess2) { - MessageBox(mess ? mess : mess2, "error"); + MessageBox(mess ? mess : mess2, _T("error")); return false; } message = string2value(up, upT); if (message) { - ::MessageBox(NULL, message, "Range selection error", MB_OK); + ::MessageBox(NULL, message, _T("Range selection error"), MB_OK); return false; } @@ -274,14 +272,14 @@ protected: mess2 = validateLowerBound(upT); if (mess || mess2) { - MessageBox(mess ? mess : mess2, "error"); + MessageBox(mess ? mess : mess2, _T("error")); return false; } if (upT <= loT) { - ::MessageBox(NULL, "upper bound must be strictly greater than lower bound", "Range selection error", MB_OK); + ::MessageBox(NULL, _T("upper bound must be strictly greater than lower bound"), _T("Range selection error"), MB_OK); return false; } @@ -314,18 +312,18 @@ CEditableRangeT::CEditableRangeT(const std::string &id, CParticleWorkspac inline void CEditableRangeT::value2CString(float value, CString &dest) { - dest.Format("%g", (double) value); + dest.Format(_T("%g"), (double) value); } -inline const char *CEditableRangeT::string2value(const CString &value, float &result) +inline const TCHAR *CEditableRangeT::string2value(const CString &value, float &result) { - if (sscanf((LPCTSTR) value, "%f", &result) == 1) + if (NLMISC::fromString(tStrToUtf8(value), result)) { return NULL; } else { - return "invalid value"; + return _T("invalid value"); } } @@ -340,17 +338,17 @@ CEditableRangeT::CEditableRangeT(const std::string &id, CParticleWorkspa inline void CEditableRangeT::value2CString(uint32 value, CString &dest) { - dest.Format("%d", value); + dest.Format(_T("%d"), value); } -inline const char *CEditableRangeT::string2value(const CString &value, uint32 &result) +inline const TCHAR *CEditableRangeT::string2value(const CString &value, uint32 &result) { - uint32 tmp; - if (sscanf((LPCTSTR) value, "%d", &tmp) == 1) + sint32 tmp; + if (NLMISC::fromString(tStrToUtf8(value), tmp)) { - if (strchr((LPCTSTR) value, '-')) + if (value.Find(_T("-")) > -1) { - return "negative values not allowed"; + return _T("negative values not allowed"); } else { @@ -360,7 +358,7 @@ inline const char *CEditableRangeT::string2value(const CString &value, u } else { - return "invalid value"; + return _T("invalid value"); } } @@ -376,20 +374,20 @@ CEditableRangeT::CEditableRangeT(const std::string &id, CParticleWorkspa inline void CEditableRangeT::value2CString(sint32 value, CString &dest) { - dest.Format("%d", value); + dest.Format(_T("%d"), value); } -inline const char *CEditableRangeT::string2value(const CString &value, sint32 &result) +inline const TCHAR *CEditableRangeT::string2value(const CString &value, sint32 &result) { - uint32 tmp; - if (sscanf((LPCTSTR) value, "%d", &tmp) == 1) + sint32 tmp; + if (NLMISC::fromString(tStrToUtf8(value), tmp)) { result = tmp; return NULL; } else { - return "invalid value"; + return _T("invalid value"); } } diff --git a/code/nel/tools/3d/object_viewer/emitter_dlg.cpp b/code/nel/tools/3d/object_viewer/emitter_dlg.cpp index 175756c6d..e4864cfe6 100644 --- a/code/nel/tools/3d/object_viewer/emitter_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/emitter_dlg.cpp @@ -85,7 +85,7 @@ void CEmitterDlg::initEmittedType() NL3D::CPSLocated *loc = dynamic_cast(ps->getProcess(k)); if (loc) // is this a located { - m_EmittedTypeCtrl.AddString(loc->getName().c_str()); + m_EmittedTypeCtrl.AddString(utf8ToTStr(loc->getName())); _LocatedList.push_back(loc); if (loc == _Emitter->getEmittedType()) { @@ -129,11 +129,11 @@ void CEmitterDlg::OnSelchangeEmittedType() { if (_Emitter->getOwner()->getOwner()->getBehaviourType() == NL3D::CParticleSystem::SpellFX || _Emitter->getOwner()->getOwner()->getBypassMaxNumIntegrationSteps()) { - MessageBox("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', and thus, should have a finite duration. This operation create a loop in the system, and so is forbidden.", "Error", MB_ICONEXCLAMATION); + MessageBox(_T("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', and thus, should have a finite duration. This operation create a loop in the system, and so is forbidden."), _T("Error"), MB_ICONEXCLAMATION); } else { - MessageBox("Loops with emitters are forbidden.", "Error", MB_ICONEXCLAMATION); + MessageBox(_T("Loops with emitters are forbidden."), _T("Error"), MB_ICONEXCLAMATION); } initEmittedType(); } @@ -267,7 +267,7 @@ BOOL CEmitterDlg::OnInitDialog() CStatic *s = new CStatic; pushWnd(s); - s->Create("Radius :", SS_LEFT, CRect(posX, posY + 10 , posX + 70, posY + 32), this); + s->Create(_T("Radius :"), SS_LEFT, CRect(posX, posY + 10 , posX + 70, posY + 32), this); s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); diff --git a/code/nel/tools/3d/object_viewer/global_wind_dlg.cpp b/code/nel/tools/3d/object_viewer/global_wind_dlg.cpp index 505f6c7b8..ef55408e1 100644 --- a/code/nel/tools/3d/object_viewer/global_wind_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/global_wind_dlg.cpp @@ -61,11 +61,11 @@ END_MESSAGE_MAP() void CGlobalWindDlg::updateView() { float a; - char str[256]; + TCHAR str[256]; // update Power. a= _ObjViewer->getGlobalWindPower(); - sprintf(str, "%.2f", a); + _stprintf(str, _T("%.2f"), a); StaticPower.SetWindowText(str); NLMISC::clamp(a, 0.f, 1.f); SliderPower.SetPos((sint)(a*NL_GLOBAL_WIND_SLIDER_RANGE)); @@ -113,11 +113,11 @@ void CGlobalWindDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) if( sliderCtrl==&SliderPower && nSBCode==SB_THUMBPOSITION || nSBCode==SB_THUMBTRACK) { float a; - char str[256]; + TCHAR str[256]; a= (float)nPos / NL_GLOBAL_WIND_SLIDER_RANGE; _ObjViewer->setGlobalWindPower(a); - sprintf(str, "%.2f", a); + _stprintf(str, _T("%.2f"), a); StaticPower.SetWindowText(str); } else diff --git a/code/nel/tools/3d/object_viewer/lb_extern_id_dlg.cpp b/code/nel/tools/3d/object_viewer/lb_extern_id_dlg.cpp index edf9f2547..9ea2d51a9 100644 --- a/code/nel/tools/3d/object_viewer/lb_extern_id_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/lb_extern_id_dlg.cpp @@ -55,32 +55,32 @@ END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CLBExternIDDlg message handlers -BOOL CLBExternIDDlg::OnInitDialog() +BOOL CLBExternIDDlg::OnInitDialog() { CDialog::OnInitDialog(); - + GetDlgItem(IDC_ID_VALUE)->EnableWindow(_ID != 0); ((CButton *) GetDlgItem(IDC_ENABLE_EXTERN_ID))->SetCheck(_ID != 0 ? 1 : 0); if (_ID) { - char val[5]; + TCHAR val[5]; for (uint k = 0; k < 4; ++k) { #ifdef NL_LITTLE_ENDIAN val[k] = (unsigned char) (_ID >> ((3 - k) << 3)); #else - val[k] = (unsigned char) (_ID >> (k << 3)); + val[k] = (unsigned char) (_ID >> (k << 3)); #endif } - val[4] = '\0'; + val[4] = '\0'; GetDlgItem(IDC_ID_VALUE)->SetWindowText(val); } else { _ID = 0; - } + } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } @@ -90,41 +90,41 @@ static uint32 StringToID(const char *buf) { uint32 id; #ifdef NL_LITTLE_ENDIAN - id = ((uint32) buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3]); + id = ((uint32) buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3]); #else - id = *(uint32 *) buf; + id = *(uint32 *) buf; #endif return id; } -void CLBExternIDDlg::OnEnableExternId() +void CLBExternIDDlg::OnEnableExternId() { if (_ID == 0) { GetDlgItem(IDC_ID_VALUE)->EnableWindow(TRUE); - _ID = StringToID("NONE"); - GetDlgItem(IDC_ID_VALUE)->SetWindowText("NONE"); + _ID = StringToID("NONE"); + GetDlgItem(IDC_ID_VALUE)->SetWindowText(_T("NONE")); } else { GetDlgItem(IDC_ID_VALUE)->EnableWindow(FALSE); - GetDlgItem(IDC_ID_VALUE)->SetWindowText(""); + GetDlgItem(IDC_ID_VALUE)->SetWindowText(_T("")); _ID = 0; - } + } } -void CLBExternIDDlg::OnChangeIdValue() -{ +void CLBExternIDDlg::OnChangeIdValue() +{ if (!((CButton *) GetDlgItem(IDC_ENABLE_EXTERN_ID))->GetCheck()) return; - char buf[6]; + TCHAR buf[6]; ::memset(buf, 0, 6); GetDlgItem(IDC_ID_VALUE)->GetWindowText(buf, 6); - _ID = StringToID(buf); + _ID = StringToID(tStrToUtf8(buf).c_str()); if (_ID) { GetDlgItem(IDOK)->EnableWindow(TRUE); - GetDlgItem(IDC_ENABLE_EXTERN_ID)->EnableWindow(TRUE); - if (::strlen(buf) > 4) + GetDlgItem(IDC_ENABLE_EXTERN_ID)->EnableWindow(TRUE); + if (::_tcslen(buf) > 4) { buf[4] = '\0'; GetDlgItem(IDC_ID_VALUE)->SetWindowText(buf); @@ -133,7 +133,7 @@ void CLBExternIDDlg::OnChangeIdValue() else { GetDlgItem(IDOK)->EnableWindow(FALSE); - GetDlgItem(IDC_ENABLE_EXTERN_ID)->EnableWindow(FALSE); + GetDlgItem(IDC_ENABLE_EXTERN_ID)->EnableWindow(FALSE); } } diff --git a/code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp b/code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp index 6472eb7c5..2242c0684 100644 --- a/code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp +++ b/code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp @@ -42,7 +42,7 @@ #include "ribbon_dlg.h" -using NL3D::CPSLocatedBindable; +using NL3D::CPSLocatedBindable; ///////////////////////////////////////////////////////////////////////////// @@ -55,7 +55,7 @@ CLocatedBindableDialog::CLocatedBindableDialog(CParticleWorkspace::CNode *ownerN { //{{AFX_DATA_INIT(CLocatedBindableDialog) m_IndependantSizes = FALSE; - //}}AFX_DATA_INIT + //}}AFX_DATA_INIT } /// dtor @@ -78,7 +78,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) NL3D::CParticleSystem *ps = _Bindable->getOwner()->getOwner(); if (ps->isSharingEnabled()) - { + { GetDlgItem(IDC_NO_AUTO_LOD)->ShowWindow(TRUE); if (ps->isAutoLODEnabled() == false) { @@ -111,10 +111,10 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) NL3D::CPSMaterial *material = dynamic_cast(_Bindable); // blending mode m_BlendingMode.SetCurSel((uint) material->getBlendingMode() ); - // z-test + // z-test ((CButton *) GetDlgItem(IDC_ZTEST))->SetCheck(material->isZTestEnabled() ? BST_CHECKED : BST_UNCHECKED); // z-bias - GetDlgItem(IDC_ZBIAS)->SetWindowText(NLMISC::toString("%.2f", -material->getZBias()).c_str()); + GetDlgItem(IDC_ZBIAS)->SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", -material->getZBias()))); } else { @@ -126,7 +126,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) } GetDlgItem(IDC_ALIGN_ON_MOTION)->ShowWindow(SW_HIDE); GetDlgItem(IDC_ZALIGN)->ShowWindow(SW_HIDE); - // enable disable z-test + // enable disable z-test // if (dynamic_cast(_Bindable)) { @@ -147,12 +147,12 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) // check support for color if (dynamic_cast(_Bindable)) { - + CAttribDlgRGBA *ad = new CAttribDlgRGBA("PARTICLE_COLOR", _Node); pushWnd(ad); - _ColorWrapper.S = dynamic_cast(_Bindable); - ad->setWrapper(&_ColorWrapper); + _ColorWrapper.S = dynamic_cast(_Bindable); + ad->setWrapper(&_ColorWrapper); ad->setSchemeWrapper(&_ColorWrapper); HBITMAP bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_PARTICLE_COLOR)); @@ -169,13 +169,13 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) // check support for angle 2D if (dynamic_cast(_Bindable)) { - + CAttribDlgFloat *ad = new CAttribDlgFloat("PARTICLE_ANGLE2D", _Node, 0.f, 256.f); pushWnd(ad); _Angle2DWrapper.S = dynamic_cast(_Bindable); - ad->setWrapper(&_Angle2DWrapper); - ad->setSchemeWrapper(&_Angle2DWrapper); + ad->setWrapper(&_Angle2DWrapper); + ad->setSchemeWrapper(&_Angle2DWrapper); HBITMAP bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_PARTICLE_ANGLE)); ad->init(bmh, xPos, yPos, this); @@ -183,7 +183,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) yPos += rect.bottom + 3; } - + CAttribDlgPlaneBasis *pb = NULL; @@ -199,7 +199,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) pb->init(bmh, xPos, yPos, this); pb->GetClientRect(&rect); yPos += rect.bottom + 3; - + } // check support for precomputed rotations @@ -225,8 +225,8 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) CStatic *s = new CStatic; pushWnd(s); _MotionBlurWnd.push_back(s); - s->Create("Fake motion blur coeff.", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->Create(_T("Fake motion blur coeff."), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); mbc->GetClientRect(&rect); yPos += rect.bottom + 3; @@ -236,14 +236,14 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) _MotionBlurThresholdWrapper.P = fla; mbc->setWrapper(&_MotionBlurThresholdWrapper); mbc->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); _MotionBlurWnd.push_back(s); - s->Create("Fake motion blur threshold.", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Fake motion blur threshold."), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); mbc->GetClientRect(&rect); - yPos += rect.bottom + 3; + yPos += rect.bottom + 3; GetDlgItem(IDC_ALIGN_ON_MOTION)->ShowWindow(SW_SHOW); GetDlgItem(IDC_ZALIGN)->ShowWindow(SW_SHOW); ((CButton *) GetDlgItem(IDC_ALIGN_ON_MOTION))->SetCheck(fla->getAlignOnMotion()); @@ -256,14 +256,14 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) { NL3D::CPSShockWave *sw = static_cast(_Bindable); CEditableRangeFloat *rc = new CEditableRangeFloat(std::string("RADIUS CUT"), _Node, 0, 1); - pushWnd(rc); + pushWnd(rc); _RadiusCutWrapper.S = sw; rc->setWrapper(&_RadiusCutWrapper); rc->init(xPos + 140, yPos, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Radius cut.", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->Create(_T("Radius cut."), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); @@ -277,9 +277,9 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) snbs->setWrapper(&_ShockWaveNbSegWrapper); snbs->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Nb segs", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Nb segs"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->ShowWindow(SW_SHOW); snbs->GetClientRect(&rect); @@ -291,13 +291,13 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) _ShockWaveUFactorWrapper.S = sw; uvd->setWrapper(&_ShockWaveUFactorWrapper); uvd->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Texture U factor :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Texture U factor :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->ShowWindow(SW_SHOW); uvd->GetClientRect(&rect); - yPos += rect.bottom + 3; - + yPos += rect.bottom + 3; + } // fanlight @@ -312,8 +312,8 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) nbf->init(xPos + 140, yPos, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Nb fan lights :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->Create(_T("Nb fan lights :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); nbf->GetClientRect(&rect); @@ -325,35 +325,35 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) _FanLightSmoothnessWrapper.P = static_cast(_Bindable); nbf->setWrapper(&_FanLightSmoothnessWrapper); nbf->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Phase smoothnes:", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Phase smoothnes:"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->ShowWindow(SW_SHOW); nbf->GetClientRect(&rect); yPos += rect.bottom + 3; CEditableRangeFloat *nbfp = new CEditableRangeFloat(std::string("FAN_LIGHT_PHASE"), _Node, 0, 4.f); - pushWnd(nbfp); + pushWnd(nbfp); _FanLightPhaseWrapper.P = static_cast(_Bindable); nbfp->setWrapper(&_FanLightPhaseWrapper); nbfp->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Fan light speed :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Fan light speed :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->ShowWindow(SW_SHOW); nbf->GetClientRect(&rect); yPos += rect.bottom + 3; nbfp = new CEditableRangeFloat(std::string("FAN_LIGHT_INTENSITY"), _Node, 0, 4.f); - pushWnd(nbfp); + pushWnd(nbfp); _FanLightIntensityWrapper.P = static_cast(_Bindable); nbfp->setWrapper(&_FanLightIntensityWrapper); nbfp->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Fan light intensity:", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Fan light intensity:"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->ShowWindow(SW_SHOW); nbf->GetClientRect(&rect); @@ -383,24 +383,24 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) { nbs->enableUpperBound(256, true); } - - + + _TailParticleWrapper.P = dynamic_cast(_Bindable); nbs->setWrapper(&_TailParticleWrapper); nbs->init(xPos + 140, yPos, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Nb segs :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); - s->ShowWindow(SW_SHOW); - + s->Create(_T("Nb segs :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->ShowWindow(SW_SHOW); + nbs->GetClientRect(&rect); yPos += rect.bottom + 3; CTailParticleDlg *tpd = new CTailParticleDlg(_Node, dynamic_cast(_Bindable)); pushWnd(tpd); tpd->init(this, xPos, yPos); - + tpd->GetClientRect(&rect); yPos += rect.bottom + 3; } @@ -429,7 +429,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) cmtd->GetClientRect(&rect); yPos += rect.bottom + 3; pushWnd(cmd); - pushWnd(cmtd); + pushWnd(cmtd); } @@ -440,9 +440,9 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) CTextureAnimDlg *td = new CTextureAnimDlg(_Node, dynamic_cast(_Bindable), dynamic_cast(_Bindable) - ); + ); pushWnd(td); - + td->init(xPos, yPos, this); td->GetClientRect(&rect); yPos += rect.bottom + 3; @@ -453,7 +453,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) { NL3D::CPSTexturedParticleNoAnim *tp = dynamic_cast(_Bindable); _TextureNoAnimWrapper.TP = tp; - CTextureChooser *tc = new CTextureChooser(dynamic_cast(_Bindable), _Node); + CTextureChooser *tc = new CTextureChooser(dynamic_cast(_Bindable), _Node); tc->enableRemoveButton(); tc->setWrapper(&_TextureNoAnimWrapper); pushWnd(tc); @@ -465,8 +465,8 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) // ribbon texture (doesn't support texture animation for now) if (dynamic_cast(_Bindable)) - { - + { + // add dialog for uv tuning with ribbon CEditableRangeFloat *uvd = new CEditableRangeFloat(std::string("RIBBON UFACTOR"), _Node, 0, 5); pushWnd(uvd); @@ -475,8 +475,8 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) uvd->init(xPos + 140, yPos, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Texture U factor :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->Create(_T("Texture U factor :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); uvd->GetClientRect(&rect); yPos += rect.bottom + 3; @@ -486,19 +486,19 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) _RibbonVFactorWrapper.R = static_cast(_Bindable); uvd->setWrapper(&_RibbonVFactorWrapper); uvd->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Texture V factor :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Texture V factor :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); uvd->GetClientRect(&rect); yPos += rect.bottom + 3; - } + } if (dynamic_cast(_Bindable)) - { - + { + // add dialog for uv tuning with ribbon CEditableRangeFloat *sd = new CEditableRangeFloat(std::string("SEGMENT DURATION"), _Node, 0.05f, 0.5f); sd->enableLowerBound(0, true); @@ -508,19 +508,19 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) sd->init(xPos + 140, yPos, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Seg Duration :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->Create(_T("Seg Duration :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); sd->GetClientRect(&rect); yPos += rect.bottom + 3; } - + // 'look at' independant sizes - bool isLookAt = dynamic_cast(_Bindable) != NULL; + bool isLookAt = dynamic_cast(_Bindable) != NULL; GetDlgItem(IDC_INDE_SIZES)->ShowWindow(isLookAt ? SW_SHOW : SW_HIDE); GetDlgItem(IDC_SIZE_WIDTH)->ShowWindow(isLookAt ? SW_SHOW : SW_HIDE); GetDlgItem(IDC_SIZE_HEIGHT)->ShowWindow(isLookAt ? SW_SHOW : SW_HIDE); - GetDlgItem(IDC_WIDTH_HEIGHT_BOX)->ShowWindow(isLookAt ? SW_SHOW : SW_HIDE); + GetDlgItem(IDC_WIDTH_HEIGHT_BOX)->ShowWindow(isLookAt ? SW_SHOW : SW_HIDE); ((CButton *) GetDlgItem(IDC_SIZE_WIDTH))->SetCheck(1); if (isLookAt) { @@ -539,8 +539,8 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) pushWnd(rd); rd->GetClientRect(&rect); yPos += rect.bottom + 3; - } - } + } + } UpdateData(); } @@ -580,7 +580,7 @@ END_MESSAGE_MAP() void CLocatedBindableDialog::touchPSState() { if (_Node && _Node->getPSModel()) - { + { _Node->getPSModel()->touchTransparencyState(); _Node->getPSModel()->touchLightableState(); } @@ -588,19 +588,19 @@ void CLocatedBindableDialog::touchPSState() //*********************************************************************************** -void CLocatedBindableDialog::OnSelchangeBlendingMode() +void CLocatedBindableDialog::OnSelchangeBlendingMode() { UpdateData(); NL3D::CPSMaterial *m = dynamic_cast(_Bindable); nlassert(m); - m->setBlendingMode( (NL3D::CPSMaterial::TBlendingMode) m_BlendingMode.GetCurSel()); - touchPSState(); + m->setBlendingMode( (NL3D::CPSMaterial::TBlendingMode) m_BlendingMode.GetCurSel()); + touchPSState(); updateModifiedFlag(); } //*********************************************************************************** -void CLocatedBindableDialog::updateIndependantSizes() +void CLocatedBindableDialog::updateIndependantSizes() { UpdateData(); // make sure we are dealing with 'LookAt' for now @@ -613,7 +613,7 @@ void CLocatedBindableDialog::updateIndependantSizes() //*********************************************************************************** // user asked for independant sizes -void CLocatedBindableDialog::OnIndeSizes() +void CLocatedBindableDialog::OnIndeSizes() { UpdateData(); // make sure we are dealing with 'LookAt' for now @@ -621,13 +621,13 @@ void CLocatedBindableDialog::OnIndeSizes() NL3D::CPSFaceLookAt *la = static_cast(_Bindable); la->setIndependantSizes(m_IndependantSizes ? true : false /* VCC warning*/); updateIndependantSizes(); - updateSizeControl(); + updateSizeControl(); updateModifiedFlag(); } //*********************************************************************************** uint CLocatedBindableDialog::updateSizeControl() -{ +{ HBITMAP bmh; if (!dynamic_cast(_Bindable)) return 0; // if a previous control was there, remove it @@ -645,7 +645,7 @@ uint CLocatedBindableDialog::updateSizeControl() int editWidth = (((CButton *) GetDlgItem(IDC_SIZE_WIDTH))->GetCheck()); _SizeCtrl = new CAttribDlgFloat(editWidth ? "PARTICLE_WIDTH" : "PARTICLE_HEIGHT", _Node, 0.f, 1.f); - + if (editWidth) // wrap to the wanted size { _SizeWrapper.S = fla; @@ -656,8 +656,8 @@ uint CLocatedBindableDialog::updateSizeControl() } _SizeCtrl->setWrapper(&_SizeWrapper); _SizeCtrl->setSchemeWrapper(&_SizeWrapper); - - bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(editWidth ? IDB_PARTICLE_WIDTH : IDB_PARTICLE_HEIGHT)); + + bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(editWidth ? IDB_PARTICLE_WIDTH : IDB_PARTICLE_HEIGHT)); } else // general case. Wrap to the size interface and the appropriate dialog { @@ -666,29 +666,29 @@ uint CLocatedBindableDialog::updateSizeControl() _SizeWrapper.S = dynamic_cast(_Bindable); _SizeCtrl->setWrapper(&_SizeWrapper); _SizeCtrl->setSchemeWrapper(&_SizeWrapper); - - bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_PARTICLE_SIZE)); + + bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_PARTICLE_SIZE)); } RECT rect; _SizeCtrl->init(bmh, _SizeCtrlX, _SizeCtrlY, this); _SizeCtrl->GetClientRect(&rect); - return rect.bottom + 3; + return rect.bottom + 3; } //*********************************************************************************** -void CLocatedBindableDialog::OnSizeWidth() +void CLocatedBindableDialog::OnSizeWidth() { - updateSizeControl(); + updateSizeControl(); } //*********************************************************************************** -void CLocatedBindableDialog::OnSizeHeight() +void CLocatedBindableDialog::OnSizeHeight() { - updateSizeControl(); + updateSizeControl(); } //*********************************************************************************** -void CLocatedBindableDialog::OnNoAutoLod() +void CLocatedBindableDialog::OnNoAutoLod() { NL3D::CPSParticle *p = NLMISC::safe_cast(_Bindable); p->disableAutoLOD(((CButton *) GetDlgItem(IDC_NO_AUTO_LOD))->GetCheck() != 0); @@ -696,8 +696,8 @@ void CLocatedBindableDialog::OnNoAutoLod() } //*********************************************************************************** -void CLocatedBindableDialog::OnGlobalColorLighting() -{ +void CLocatedBindableDialog::OnGlobalColorLighting() +{ NL3D::CPSParticle *p = NLMISC::safe_cast(_Bindable); p->enableGlobalColorLighting(((CButton *) GetDlgItem(ID_GLOBAL_COLOR_LIGHTING))->GetCheck() == 1); touchPSState(); @@ -705,12 +705,12 @@ void CLocatedBindableDialog::OnGlobalColorLighting() } //*********************************************************************************** -void CLocatedBindableDialog::OnAlignOnMotion() +void CLocatedBindableDialog::OnAlignOnMotion() { bool align = ((CButton *) GetDlgItem(IDC_ALIGN_ON_MOTION))->GetCheck() != 0; NL3D::CPSFaceLookAt *fla = NLMISC::safe_cast(_Bindable); fla->setAlignOnMotion(align); - updateValidWndForAlignOnMotion(align); + updateValidWndForAlignOnMotion(align); updateModifiedFlag(); } @@ -723,10 +723,10 @@ void CLocatedBindableDialog::updateValidWndForAlignOnMotion(bool align) CEditAttribDlg *ead = dynamic_cast(_MotionBlurWnd[k]); if (ead) { - ead->EnableWindow(enable); // enable window not virtual in CWnd ... + ead->EnableWindow(enable); // enable window not virtual in CWnd ... } else - { + { _MotionBlurWnd[k]->EnableWindow(enable); } } @@ -734,7 +734,7 @@ void CLocatedBindableDialog::updateValidWndForAlignOnMotion(bool align) } //*********************************************************************************** -void CLocatedBindableDialog::OnZtest() +void CLocatedBindableDialog::OnZtest() { UpdateData(); NL3D::CPSMaterial *mat = dynamic_cast(_Bindable); @@ -749,12 +749,12 @@ static void concatEdit2Lines(CEdit &edit) const uint lineLen= 1000; uint n; // retrieve the 2 lines. - char tmp0[2*lineLen]; - char tmp1[lineLen]; + TCHAR tmp0[2*lineLen]; + TCHAR tmp1[lineLen]; n= edit.GetLine(0, tmp0, lineLen); tmp0[n]= 0; n= edit.GetLine(1, tmp1, lineLen); tmp1[n]= 0; // concat and update the CEdit. - edit.SetWindowText(strcat(tmp0, tmp1)); + edit.SetWindowText(_tcscat(tmp0, tmp1)); } //*************************************************************************************************************************** @@ -762,9 +762,9 @@ void CLocatedBindableDialog::updateZBias() { CString value; m_ZBias.GetWindowText(value); - float zbias = 0.f; + float zbias = 0.f; int dummy; // to test if end of string as no not wanted extra characters - if (sscanf((LPCTSTR) (value + "\n0"), "%f\n%d", &zbias, &dummy) == 2) + if (_stscanf((LPCTSTR)(value + _T("\n0")), _T("%f\n%d"), &zbias, &dummy) == 2) { NLMISC::safe_cast(_Bindable)->setZBias(-zbias); } @@ -773,8 +773,8 @@ void CLocatedBindableDialog::updateZBias() CString caption; CString mess; caption.LoadString(IDS_CAPTION_ERROR); - mess.LoadString(IDS_BAD_ZBIAS); - m_ZBias.SetWindowText("0.00"); + mess.LoadString(IDS_BAD_ZBIAS); + m_ZBias.SetWindowText(_T("0.00")); MessageBox((LPCTSTR) mess, (LPCTSTR) caption, MB_ICONERROR); NLMISC::safe_cast(_Bindable)->setZBias(0); updateModifiedFlag(); @@ -782,28 +782,28 @@ void CLocatedBindableDialog::updateZBias() } //*************************************************************************************************************************** -void CLocatedBindableDialog::OnChangeZbias() +void CLocatedBindableDialog::OnChangeZbias() { - UpdateData(); + UpdateData(); // Trick to track "Enter" keypress: CEdit are multiline. If GetLineCount()>1, then // user has press enter. if(m_ZBias.GetLineCount()>1) { // must ccat 2 lines of the CEdit. - concatEdit2Lines(m_ZBias); - updateZBias(); + concatEdit2Lines(m_ZBias); + updateZBias(); } } //*************************************************************************************************************************** -void CLocatedBindableDialog::OnKillfocusZbias() +void CLocatedBindableDialog::OnKillfocusZbias() { - updateZBias(); + updateZBias(); } //*************************************************************************************************************************** -void CLocatedBindableDialog::OnZalign() -{ +void CLocatedBindableDialog::OnZalign() +{ bool align = ((CButton *) GetDlgItem(IDC_ZALIGN))->GetCheck() != 0; NL3D::CPSFaceLookAt *fla = NLMISC::safe_cast(_Bindable); fla->setAlignOnZAxis(align); diff --git a/code/nel/tools/3d/object_viewer/located_properties.cpp b/code/nel/tools/3d/object_viewer/located_properties.cpp index 27ff466e1..b270e9d7f 100644 --- a/code/nel/tools/3d/object_viewer/located_properties.cpp +++ b/code/nel/tools/3d/object_viewer/located_properties.cpp @@ -322,7 +322,7 @@ void CLocatedProperties::goPostRender() _MaxNbParticles->update(); } // in all cases, show the current number of particles being used - GetDlgItem(IDC_CURR_NUM_PARTS)->SetWindowText(NLMISC::toString(_Located->getSize()).c_str()); + GetDlgItem(IDC_CURR_NUM_PARTS)->SetWindowText(utf8ToTStr(NLMISC::toString(_Located->getSize()))); } //**************************************************************************************************************** diff --git a/code/nel/tools/3d/object_viewer/located_target_dlg.cpp b/code/nel/tools/3d/object_viewer/located_target_dlg.cpp index 9cb9fced1..03fcb226c 100644 --- a/code/nel/tools/3d/object_viewer/located_target_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/located_target_dlg.cpp @@ -112,8 +112,8 @@ void CLocatedTargetDlg::OnAddTarget() nlassert(loc); _LBTarget->attachTarget(loc); m_AvailableTargets.DeleteString(indexs[k] - k); - int l = m_Targets.AddString(loc->getName().c_str()); - m_Targets.SetItemData(l, (DWORD) loc); + int l = m_Targets.AddString(utf8ToTStr(loc->getName())); + m_Targets.SetItemData(l, (DWORD_PTR) loc); } UpdateData(FALSE); // @@ -135,9 +135,9 @@ void CLocatedTargetDlg::OnRemoveTarget() nlassert(loc); _LBTarget->detachTarget(loc); m_Targets.DeleteString(indexs[k] - k); - int l = m_AvailableTargets.AddString(loc->getName().c_str()); + int l = m_AvailableTargets.AddString(utf8ToTStr(loc->getName())); - m_AvailableTargets.SetItemData(l, (DWORD) loc); + m_AvailableTargets.SetItemData(l, (DWORD_PTR) loc); } UpdateData(FALSE); updateModifiedFlag(); @@ -159,8 +159,8 @@ BOOL CLocatedTargetDlg::OnInitDialog() // fill the box thta tells us what the target are for(k = 0; k < nbTarg; ++k) { - m_Targets.AddString(_LBTarget->getTarget(k)->getName().c_str() ); - m_Targets.SetItemData(k, (DWORD) _LBTarget->getTarget(k) ); + m_Targets.AddString(utf8ToTStr(_LBTarget->getTarget(k)->getName())); + m_Targets.SetItemData(k, (DWORD_PTR) _LBTarget->getTarget(k)); targetSet.insert(_LBTarget->getTarget(k)); }; @@ -179,13 +179,12 @@ BOOL CLocatedTargetDlg::OnInitDialog() { if (targetSet.find(loc) == targetSet.end()) { - int l = m_AvailableTargets.AddString(loc->getName().c_str() ); - m_AvailableTargets.SetItemData(l, (DWORD) loc ); + int l = m_AvailableTargets.AddString(utf8ToTStr(loc->getName())); + m_AvailableTargets.SetItemData(l, (DWORD_PTR) loc); } } } - const sint posX = 5; sint posY = 180; @@ -227,7 +226,7 @@ BOOL CLocatedTargetDlg::OnInitDialog() rv->init(posX + 140, posY, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Radial viscosity : ", SS_LEFT, CRect(posX, posY, posX + 139, posY + 32), this); + s->Create(_T("Radial viscosity : "), SS_LEFT, CRect(posX, posY, posX + 139, posY + 32), this); s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); @@ -243,7 +242,7 @@ BOOL CLocatedTargetDlg::OnInitDialog() s = new CStatic; pushWnd(s); - s->Create("Tangential Viscosity : ", SS_LEFT, CRect(posX, posY, posX + 139, posY + 32), this); + s->Create(_T("Tangential Viscosity : "), SS_LEFT, CRect(posX, posY, posX + 139, posY + 32), this); s->ShowWindow(SW_SHOW); tv->GetClientRect(&r); @@ -273,7 +272,7 @@ BOOL CLocatedTargetDlg::OnInitDialog() rv->init(posX + 140, posY, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Parametric factor : ", SS_LEFT, CRect(posX, posY, posX + 139, posY + 40), this); + s->Create(_T("Parametric factor : "), SS_LEFT, CRect(posX, posY, posX + 139, posY + 40), this); s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); diff --git a/code/nel/tools/3d/object_viewer/main_frame.cpp b/code/nel/tools/3d/object_viewer/main_frame.cpp index d063e202d..aa24efa36 100644 --- a/code/nel/tools/3d/object_viewer/main_frame.cpp +++ b/code/nel/tools/3d/object_viewer/main_frame.cpp @@ -293,41 +293,41 @@ void CMainFrame::registerValue (bool read) DWORD len=sizeof (BOOL); DWORD type; NLMISC::CRGBA bgCol ; - RegQueryValueEx (hKey, "ViewAnimation", 0, &type, (LPBYTE)&AnimationWindow, &len); + RegQueryValueEx (hKey, _T("ViewAnimation"), 0, &type, (LPBYTE)&AnimationWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewAnimationSet", 0, &type, (LPBYTE)&AnimationSetWindow, &len); + RegQueryValueEx (hKey, _T("ViewAnimationSet"), 0, &type, (LPBYTE)&AnimationSetWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewSlots", 0, &type, (LPBYTE)&MixerSlotsWindow, &len); + RegQueryValueEx (hKey, _T("ViewSlots"), 0, &type, (LPBYTE)&MixerSlotsWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewParticles", 0, &type, (LPBYTE)&ParticlesWindow, &len); + RegQueryValueEx (hKey, _T("ViewParticles"), 0, &type, (LPBYTE)&ParticlesWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewDayNight", 0, &type, (LPBYTE)&DayNightWindow, &len); + RegQueryValueEx (hKey, _T("ViewDayNight"), 0, &type, (LPBYTE)&DayNightWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewWaterPool", 0, &type, (LPBYTE)&WaterPoolWindow, &len); + RegQueryValueEx (hKey, _T("ViewWaterPool"), 0, &type, (LPBYTE)&WaterPoolWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewVegetable", 0, &type, (LPBYTE)&VegetableWindow, &len); + RegQueryValueEx (hKey, _T("ViewVegetable"), 0, &type, (LPBYTE)&VegetableWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewGlobalWind", 0, &type, (LPBYTE)&GlobalWindWindow, &len); + RegQueryValueEx (hKey, _T("ViewGlobalWind"), 0, &type, (LPBYTE)&GlobalWindWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewSoundAnimWind", 0, &type, (LPBYTE)&GlobalWindWindow, &len); + RegQueryValueEx (hKey, _T("ViewSoundAnimWind"), 0, &type, (LPBYTE)&GlobalWindWindow, &len); len=sizeof (float); - RegQueryValueEx (hKey, "MoveSpeed", 0, &type, (LPBYTE)&MoveSpeed, &len); + RegQueryValueEx (hKey, _T("MoveSpeed"), 0, &type, (LPBYTE)&MoveSpeed, &len); len=sizeof (uint); - RegQueryValueEx (hKey, "ObjectMode", 0, &type, (LPBYTE)&MoveMode, &len); + RegQueryValueEx (hKey, _T("ObjectMode"), 0, &type, (LPBYTE)&MoveMode, &len); len=sizeof(NLMISC::CRGBA) ; - RegQueryValueEx (hKey, "BackGroundColor", 0, &type, (LPBYTE)&BgColor, &len); + RegQueryValueEx (hKey, _T("BackGroundColor"), 0, &type, (LPBYTE)&BgColor, &len); len=sizeof (float); - RegQueryValueEx (hKey, "GlobalWindPower", 0, &type, (LPBYTE)&GlobalWindPower, &len); + RegQueryValueEx (hKey, _T("GlobalWindPower"), 0, &type, (LPBYTE)&GlobalWindPower, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewChooseFrameDelay", 0, &type, (LPBYTE)&ChooseFrameDelayWindow, &len); + RegQueryValueEx (hKey, _T("ViewChooseFrameDelay"), 0, &type, (LPBYTE)&ChooseFrameDelayWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewChooseBGColor", 0, &type, (LPBYTE)&ChooseBGColorWindow, &len); + RegQueryValueEx (hKey, _T("ViewChooseBGColor"), 0, &type, (LPBYTE)&ChooseBGColorWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewChooseSunColor", 0, &type, (LPBYTE)&ChooseSunColorWindow, &len); + RegQueryValueEx (hKey, _T("ViewChooseSunColor"), 0, &type, (LPBYTE)&ChooseSunColorWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewSkeletonScaleWindow", 0, &type, (LPBYTE)&SkeletonScaleWindow, &len); + RegQueryValueEx (hKey, _T("ViewSkeletonScaleWindow"), 0, &type, (LPBYTE)&SkeletonScaleWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewTuneMRMWindow", 0, &type, (LPBYTE)&TuneMRMWindow, &len); + RegQueryValueEx (hKey, _T("ViewTuneMRMWindow"), 0, &type, (LPBYTE)&TuneMRMWindow, &len); } } else @@ -335,26 +335,26 @@ void CMainFrame::registerValue (bool read) HKEY hKey; if (RegCreateKey(HKEY_CURRENT_USER, REGKEY_OBJ_VIEW_SCENE_DLG, &hKey)==ERROR_SUCCESS) { - RegSetValueEx(hKey, "ViewAnimation", 0, REG_BINARY, (LPBYTE)&AnimationWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewAnimationSet", 0, REG_BINARY, (LPBYTE)&AnimationSetWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewSlots", 0, REG_BINARY, (LPBYTE)&MixerSlotsWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewParticles", 0, REG_BINARY, (LPBYTE)&ParticlesWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewDayNight", 0, REG_BINARY, (LPBYTE)&DayNightWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewWaterPool", 0, REG_BINARY, (LPBYTE)&WaterPoolWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewDayNight", 0, REG_BINARY, (LPBYTE)&DayNightWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewVegetable", 0, REG_BINARY, (LPBYTE)&VegetableWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewGlobalWind", 0, REG_BINARY, (LPBYTE)&GlobalWindWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewSoundAnimWind", 0, REG_BINARY, (LPBYTE)&SoundAnimWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewLightGroupWind", 0, REG_BINARY, (LPBYTE)&LightGroupWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewChooseFrameDelay", 0, REG_BINARY, (LPBYTE)&ChooseFrameDelayWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewChooseBGColor", 0, REG_BINARY, (LPBYTE)&ChooseBGColorWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewChooseSunColor", 0, REG_BINARY, (LPBYTE)&ChooseSunColorWindow, sizeof(bool)); - RegSetValueEx(hKey, "MoveSpeed", 0, REG_BINARY, (LPBYTE)&MoveSpeed, sizeof(float)); - RegSetValueEx(hKey, "ObjectMode", 0, REG_BINARY, (LPBYTE)&MoveMode, sizeof(uint)); - RegSetValueEx(hKey, "BackGroundColor", 0, REG_BINARY, (LPBYTE)&BgColor, sizeof(NLMISC::CRGBA)); - RegSetValueEx(hKey, "GlobalWindPower", 0, REG_BINARY, (LPBYTE)&GlobalWindPower, sizeof(float)); - RegSetValueEx(hKey, "ViewSkeletonScaleWindow", 0, REG_BINARY, (LPBYTE)&SkeletonScaleWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewTuneMRMWindow", 0, REG_BINARY, (LPBYTE)&TuneMRMWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewAnimation"), 0, REG_BINARY, (LPBYTE)&AnimationWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewAnimationSet"), 0, REG_BINARY, (LPBYTE)&AnimationSetWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewSlots"), 0, REG_BINARY, (LPBYTE)&MixerSlotsWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewParticles"), 0, REG_BINARY, (LPBYTE)&ParticlesWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewDayNight"), 0, REG_BINARY, (LPBYTE)&DayNightWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewWaterPool"), 0, REG_BINARY, (LPBYTE)&WaterPoolWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewDayNight"), 0, REG_BINARY, (LPBYTE)&DayNightWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewVegetable"), 0, REG_BINARY, (LPBYTE)&VegetableWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewGlobalWind"), 0, REG_BINARY, (LPBYTE)&GlobalWindWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewSoundAnimWind"), 0, REG_BINARY, (LPBYTE)&SoundAnimWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewLightGroupWind"), 0, REG_BINARY, (LPBYTE)&LightGroupWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewChooseFrameDelay"), 0, REG_BINARY, (LPBYTE)&ChooseFrameDelayWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewChooseBGColor"), 0, REG_BINARY, (LPBYTE)&ChooseBGColorWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewChooseSunColor"), 0, REG_BINARY, (LPBYTE)&ChooseSunColorWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("MoveSpeed"), 0, REG_BINARY, (LPBYTE)&MoveSpeed, sizeof(float)); + RegSetValueEx(hKey, _T("ObjectMode"), 0, REG_BINARY, (LPBYTE)&MoveMode, sizeof(uint)); + RegSetValueEx(hKey, _T("BackGroundColor"), 0, REG_BINARY, (LPBYTE)&BgColor, sizeof(NLMISC::CRGBA)); + RegSetValueEx(hKey, _T("GlobalWindPower"), 0, REG_BINARY, (LPBYTE)&GlobalWindPower, sizeof(float)); + RegSetValueEx(hKey, _T("ViewSkeletonScaleWindow"), 0, REG_BINARY, (LPBYTE)&SkeletonScaleWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewTuneMRMWindow"), 0, REG_BINARY, (LPBYTE)&TuneMRMWindow, sizeof(bool)); } } } @@ -568,13 +568,13 @@ void CMainFrame::OnFileLoadconfig() update (); // Create a dialog - static char BASED_CODE szFilter[] = "NeL Object viewer config (*.ovcgf)|*.ovcgf|All Files (*.*)|*.*||"; - CFileDialog fileDlg( TRUE, ".ovcgf", "*.ovcgf", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("NeL Object viewer config (*.ovcgf)|*.ovcgf|All Files (*.*)|*.*||"); + CFileDialog fileDlg( TRUE, _T(".ovcgf"), _T("*.ovcgf"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal()==IDOK) { // Open the file CIFile file; - if (file.open ((const char*)fileDlg.GetPathName())) + if (file.open(tStrToUtf8(fileDlg.GetPathName()))) { try { @@ -590,17 +590,17 @@ void CMainFrame::OnFileLoadconfig() } } } - catch (Exception& e) + catch (const Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", (const char*)fileDlg.GetPathName()); - MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + CString msg; + msg.Format(_T("Can't open the file %s for reading."), (LPCTSTR)fileDlg.GetPathName()); + MessageBox (msg, _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -613,15 +613,15 @@ void CMainFrame::OnFileOpen() update (); // Create a dialog - static char BASED_CODE szFilter[] = - "All NeL Files (*.shape;*.ps;*.ig)\0*.shape;*.ps;*.ig\0" - "NeL Shape Files (*.shape)\0*.shape\0" - "NeL Particule System Files (*.ps)\0*.ps\0" - "NeL Instance Group Files (*.ig)\0*.ig\0" - "All Files (*.*)\0*.*\0\0"; + static TCHAR BASED_CODE szFilter[] = + _T("All NeL Files (*.shape;*.ps;*.ig)\0*.shape;*.ps;*.ig\0") + _T("NeL Shape Files (*.shape)\0*.shape\0") + _T("NeL Particule System Files (*.ps)\0*.ps\0") + _T("NeL Instance Group Files (*.ig)\0*.ig\0") + _T("All Files (*.*)\0*.*\0\0"); // Filename buffer - char buffer[65535]; + TCHAR buffer[65535]; buffer[0]=0; OPENFILENAME openFile; @@ -633,7 +633,7 @@ void CMainFrame::OnFileOpen() openFile.lpstrFile = buffer; openFile.nMaxFile = 65535; openFile.Flags = OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT|OFN_ENABLESIZING|OFN_EXPLORER; - openFile.lpstrDefExt = "*.shape;*.ig;*.ps"; + openFile.lpstrDefExt = _T("*.shape;*.ig;*.ps"); if (GetOpenFileName(&openFile)) @@ -642,7 +642,7 @@ void CMainFrame::OnFileOpen() std::vector meshFilename; // Filename pointer - char *c=buffer; + TCHAR *c=buffer; // Read the path CString path = buffer; @@ -652,7 +652,7 @@ void CMainFrame::OnFileOpen() c[path.GetLength()+1]=0; // Path is empty - path = ""; + path.Empty(); } else { @@ -682,10 +682,10 @@ void CMainFrame::OnFileOpen() CString name = path + filename; // file is an ig ? - if (name.Find(".ig") != -1) + if (name.Find(_T(".ig")) != -1) { // Load the instance group - if (ObjView->loadInstanceGroup (name)) + if (ObjView->loadInstanceGroup (tStrToUtf8(name))) { // Reset the camera OnResetCamera(); @@ -697,7 +697,7 @@ void CMainFrame::OnFileOpen() else { // Add it in the array - meshFilename.push_back ((const char*)name); + meshFilename.push_back (tStrToUtf8(name)); } } @@ -705,12 +705,12 @@ void CMainFrame::OnFileOpen() if ( !meshFilename.empty() ) { // Create a dialog for the skel - static char BASED_CODE szFilter2[] = "NeL Skeleton Files (*.skel)|*.skel|All Files (*.*)|*.*||"; - CFileDialog fileDlg2 ( TRUE, ".skel", "*.skel", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter2); + static TCHAR BASED_CODE szFilter2[] = _T("NeL Skeleton Files (*.skel)|*.skel|All Files (*.*)|*.*||"); + CFileDialog fileDlg2 ( TRUE, _T(".skel"), _T("*.skel"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter2); if (fileDlg2.DoModal()==IDOK) { // Load the shape with a skeleton - if (ObjView->loadMesh (meshFilename, fileDlg2.GetPathName())) + if (ObjView->loadMesh (meshFilename, tStrToUtf8(fileDlg2.GetPathName()))) { // Reset the camera OnResetCamera(); @@ -741,11 +741,11 @@ void CMainFrame::OnFileSaveconfig() update (); // Create a dialog - static char BASED_CODE szFilter[] = "NeL Object viewer config (*.ovcgf)|*.ovcgf|All Files (*.*)|*.*||"; - CFileDialog fileDlg( FALSE, ".ovcgf", "*.ovcgf", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("NeL Object viewer config (*.ovcgf)|*.ovcgf|All Files (*.*)|*.*||"); + CFileDialog fileDlg( FALSE, _T(".ovcgf"), _T("*.ovcgf"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal()==IDOK) { - ObjView->ParticleWorkspaceFilename = ""; + ObjView->ParticleWorkspaceFilename.clear(); CParticleWorkspace *pw = ObjView->getParticleDialog()->getParticleWorkspace(); if (pw && pw->getNumNode() != 0) { @@ -756,23 +756,23 @@ void CMainFrame::OnFileSaveconfig() } // Open the file COFile file; - if (file.open ((const char*)fileDlg.GetPathName())) + if (file.open (tStrToUtf8(fileDlg.GetPathName()))) { try { ObjView->serial(file); } - catch (Exception& e) + catch (const Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for writing", (const char*)fileDlg.GetPathName()); - MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + CString msg; + msg.Format(_T("Can't open the file %s for writing"), (LPCTSTR)fileDlg.GetPathName()); + MessageBox (msg, _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -832,7 +832,7 @@ void CMainFrame::OnViewSetmovespeed() if (valueDlg.DoModal ()==IDOK) { // Get deflaut value - sscanf ((const char*)valueDlg.Value, "%f", &MoveSpeed); + NLMISC::fromString(tStrToUtf8(valueDlg.Value), MoveSpeed); } } @@ -1154,7 +1154,7 @@ void CMainFrame::OnHelpAboutobjectviewer() ///=========================================================================================== void CMainFrame::OnRemoveAllInstancesFromScene() { - if (MessageBox("Delete all instances from scene ?", "Object Viewer", MB_YESNO) == IDYES) + if (MessageBox(_T("Delete all instances from scene ?"), _T("Object Viewer"), MB_YESNO) == IDYES) { ObjView->removeAllInstancesFromScene(); @@ -1392,9 +1392,10 @@ void CMainFrame::OnViewSetSceneRotation() if (sceneRotDlg.DoModal() == IDOK) { // read value. - _LastSceneRotX= (float)atof(sceneRotDlg.RotX); - _LastSceneRotY= (float)atof(sceneRotDlg.RotY); - _LastSceneRotZ= (float)atof(sceneRotDlg.RotZ); + NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotX), _LastSceneRotX); + NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotY), _LastSceneRotY); + NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotZ), _LastSceneRotZ); + float rotx= degToRad(_LastSceneRotX); float roty= degToRad(_LastSceneRotY); float rotz= degToRad(_LastSceneRotZ); @@ -1441,11 +1442,12 @@ void CMainFrame::OnUpdateSceneCamera(CCmdUI* pCmdUI) { CInstanceInfo *instance = ObjView->getInstance (ObjView->getCameraInstance (pCmdUI->m_nID - ID_SCENE_CAMERA_FIRST)); nlassert (instance->Camera); - pCmdUI->SetText (("Camera "+instance->Saved.ShapeFilename).c_str ()); + std::string text = NLMISC::toString("Camera %s", instance->Saved.ShapeFilename.c_str()); + pCmdUI->SetText(utf8ToTStr(text)); } else { - pCmdUI->SetText ("No camera"); + pCmdUI->SetText (_T("No camera")); } } diff --git a/code/nel/tools/3d/object_viewer/mesh_dlg.cpp b/code/nel/tools/3d/object_viewer/mesh_dlg.cpp index f0d62bd41..a35b7fe71 100644 --- a/code/nel/tools/3d/object_viewer/mesh_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/mesh_dlg.cpp @@ -90,34 +90,31 @@ void CMeshDlg::touchPSState() void CMeshDlg::OnBrowseShape() { - CFileDialog fd(TRUE, ".shape", "*.shape", 0, NULL, this); + CFileDialog fd(TRUE, _T(".shape"), _T("*.shape"), 0, NULL, this); if (fd.DoModal() == IDOK) { // Add to the path - char drive[256]; - char dir[256]; - char path[256]; - char fname[256]; - char ext[256]; - + std::string fullPath = tStrToUtf8(fd.GetPathName()); + std::string fname = NLMISC::CFile::getFilenameWithoutExtension(fullPath); + std::string ext = NLMISC::CFile::getExtension(fullPath); // Add search path for the texture - _splitpath (fd.GetPathName(), drive, dir, fname, ext); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(fullPath)); try { - _ShapeParticle->setShape(std::string(fname) + ext); - m_ShapeName = (std::string(fname) + ext).c_str(); + _ShapeParticle->setShape(fname + "." + ext); + m_ShapeName = utf8ToTStr(fname + "." + ext); touchPSState(); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { - MessageBox(e.what(), "shape loading error"); + MessageBox(utf8ToTStr(e.what()), _T("shape loading error")); } + updateMeshErrorString(); } + UpdateData(FALSE); } @@ -162,11 +159,11 @@ void CMeshDlg::updateForMorph() GetDlgItem(IDC_SHAPE_NAME)->EnableWindow(!enable); if (!enable) { - m_ShapeName = cm->getShape().c_str(); + m_ShapeName = utf8ToTStr(cm->getShape()); } else { - m_ShapeName = ""; + m_ShapeName.Empty(); } } updateMeshErrorString(); @@ -238,7 +235,7 @@ BOOL CMeshDlg::EnableWindow( BOOL bEnable) ///================================================================== void CMeshDlg::updateMeshErrorString() { - GetDlgItem(IDC_MESH_ERROR)->SetWindowText(""); + GetDlgItem(IDC_MESH_ERROR)->SetWindowText(_T("")); NL3D::CPSConstraintMesh *cm = dynamic_cast(_ShapeParticle); if (!cm) return; std::vector numVerts; diff --git a/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp b/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp index d2d08e2cc..58d67bd0b 100644 --- a/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp @@ -165,30 +165,30 @@ void CMultiTexDlg::readValues(bool alternate) char buf[128]; if (!alternate) { - sprintf(buf, "%.3f", _MTP->getScrollSpeed(0).x); GetDlgItem(IDC_U_SPEED_1)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getScrollSpeed(0).y); GetDlgItem(IDC_V_SPEED_1)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getScrollSpeed(1).x); GetDlgItem(IDC_U_SPEED_2)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getScrollSpeed(1).y); GetDlgItem(IDC_V_SPEED_2)->SetWindowText(buf); + GetDlgItem(IDC_U_SPEED_1)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).x))); + GetDlgItem(IDC_V_SPEED_1)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).y))); + GetDlgItem(IDC_U_SPEED_2)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).x))); + GetDlgItem(IDC_V_SPEED_2)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).y))); } else { if (_MTP->isAlternateTexEnabled()) { - sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(0).x); GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(0).y); GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(1).x); GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(1).y); GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(buf); + GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).x))); + GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).y))); + GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).x))); + GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).y))); } else { - GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(""); - GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(""); - GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(""); - GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(""); + GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(_T("")); + GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(_T("")); + GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(_T("")); + GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(_T("")); } } - sprintf(buf, "%.3f", _MTP->getBumpFactor()); GetDlgItem(IDC_BUMP_FACTOR)->SetWindowText(buf); + GetDlgItem(IDC_BUMP_FACTOR)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getBumpFactor()))); } @@ -204,10 +204,9 @@ void CMultiTexDlg::updateBumpFactorEnabled() //====================================================== void CMultiTexDlg::writeValues(bool alternate) { - char u1[10], u2[10], v1[10], v2[10]; + TCHAR u1[10], u2[10], v1[10], v2[10]; NLMISC::CVector2f vs1, vs2; - if (!alternate) { GetDlgItem(IDC_U_SPEED_1)->GetWindowText(u1, 10); @@ -215,10 +214,10 @@ void CMultiTexDlg::writeValues(bool alternate) GetDlgItem(IDC_U_SPEED_2)->GetWindowText(u2, 10); GetDlgItem(IDC_V_SPEED_2)->GetWindowText(v2, 10); - if (sscanf(u1, "%f", &vs1.x) == 1 && - sscanf(v1, "%f", &vs1.y) == 1 && - sscanf(u2, "%f", &vs2.x) == 1 && - sscanf(v2, "%f", &vs2.y) == 1) + if (_stscanf(u1, _T("%f"), &vs1.x) == 1 && + _stscanf(v1, _T("%f"), &vs1.y) == 1 && + _stscanf(u2, _T("%f"), &vs2.x) == 1 && + _stscanf(v2, _T("%f"), &vs2.y) == 1) { _MTP->setScrollSpeed(0, vs1); _MTP->setScrollSpeed(1, vs2); @@ -226,7 +225,7 @@ void CMultiTexDlg::writeValues(bool alternate) } else { - MessageBox("Invalid value(s)", "Error", MB_OK | MB_ICONEXCLAMATION); + MessageBox(_T("Invalid value(s)"), _T("Error"), MB_OK | MB_ICONEXCLAMATION); } } else @@ -237,10 +236,10 @@ void CMultiTexDlg::writeValues(bool alternate) GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->GetWindowText(v1, 10); GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->GetWindowText(u2, 10); GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->GetWindowText(v2, 10); - if (sscanf(u1, "%f", &vs1.x) == 1 && - sscanf(v1, "%f", &vs1.y) == 1 && - sscanf(u2, "%f", &vs2.x) == 1 && - sscanf(v2, "%f", &vs2.y) == 1) + if (_stscanf(u1, _T("%f"), &vs1.x) == 1 && + _stscanf(v1, _T("%f"), &vs1.y) == 1 && + _stscanf(u2, _T("%f"), &vs2.x) == 1 && + _stscanf(v2, _T("%f"), &vs2.y) == 1) { _MTP->setAlternateScrollSpeed(0, vs1); _MTP->setAlternateScrollSpeed(1, vs2); @@ -249,10 +248,10 @@ void CMultiTexDlg::writeValues(bool alternate) } } - char bumpFactorTxt[10]; + TCHAR bumpFactorTxt[10]; float bumpFactor; GetDlgItem(IDC_BUMP_FACTOR)->GetWindowText(bumpFactorTxt, 10); - if (sscanf(bumpFactorTxt, "%f", &bumpFactor) == 1) + if (_stscanf(bumpFactorTxt, _T("%f"), &bumpFactor) == 1) { _MTP->setBumpFactor(bumpFactor); updateModifiedFlag(); diff --git a/code/nel/tools/3d/object_viewer/object_viewer.cpp b/code/nel/tools/3d/object_viewer/object_viewer.cpp index c6f163146..f1f663e38 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer/object_viewer.cpp @@ -93,8 +93,7 @@ using namespace NLPACS; -static char SDrive[256]; -static char SDir[256]; +static std::string SPath; uint SkeletonUsedForSound = 0xFFFFFFFF; CSoundContext SoundContext; @@ -281,12 +280,13 @@ std::string CObjectViewer::getModulePath() const HMODULE hModule = AfxGetInstanceHandle(); nlassert(hModule); // shouldn't be null now anymore in any case nlassert(hModule != GetModuleHandle(NULL)); // if this is dll, the module handle can't be same as exe - char sModulePath[256]; + TCHAR sModulePath[256]; int res = GetModuleFileName(hModule, sModulePath, 256); nlassert(res); nldebug("Object viewer module path is '%s'", sModulePath); - _splitpath (sModulePath, SDrive, SDir, NULL, NULL); - _makepath (sModulePath, SDrive, SDir, "object_viewer", ".cfg"); - return sModulePath; + + SPath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)); + + return SPath + "object_viewer.cfg"; } @@ -317,7 +317,7 @@ void CObjectViewer::loadConfigFile() for (uint i=0; i<(uint)search_pathes.size(); i++) CPath::addSearchPath (search_pathes.asString(i)); } - catch(EUnknownVar &) + catch(const EUnknownVar &) {} try @@ -327,7 +327,7 @@ void CObjectViewer::loadConfigFile() for (uint i=0; i<(uint)recursive_search_pathes.size(); i++) CPath::addSearchPath (recursive_search_pathes.asString(i), true, false); } - catch(EUnknownVar &) + catch(const EUnknownVar &) {} // Add extension remapping @@ -344,7 +344,7 @@ void CObjectViewer::loadConfigFile() CPath::remapExtension(extensions_remapping.asString(i), extensions_remapping.asString(i+1), true); } } - catch (EUnknownVar &) + catch (const EUnknownVar &) { } @@ -381,7 +381,7 @@ void CObjectViewer::loadConfigFile() for (uint i=0; i<(uint)var.size(); i++) CSoundSystem::addSampleBank(var.asString(i).c_str());*/ } - catch (EUnknownVar &) + catch (const EUnknownVar &) { //::MessageBox(NULL, "warning : 'sample_path' or 'packed_sheet_path' variable not defined.\nSound will not work properly.", "Objectviewer.cfg", MB_OK|MB_ICONEXCLAMATION); } @@ -392,7 +392,7 @@ void CObjectViewer::loadConfigFile() CConfigFile::CVar &camera_focal = cf.getVar("camera_focal"); _CameraFocal = camera_focal.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { } @@ -403,7 +403,7 @@ void CObjectViewer::loadConfigFile() CConfigFile::CVar &var = cf.getVar("scene_light_enabled"); _SceneLightEnabled = var.asInt() !=0 ; } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _SceneLightEnabled= false; } @@ -414,7 +414,7 @@ void CObjectViewer::loadConfigFile() _SceneLightSunAmbiant.G = var.asInt(1); _SceneLightSunAmbiant.B = var.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _SceneLightSunAmbiant= NLMISC::CRGBA::Black; } @@ -425,7 +425,7 @@ void CObjectViewer::loadConfigFile() _SceneLightSunDiffuse.G = var.asInt(1); _SceneLightSunDiffuse.B = var.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _SceneLightSunDiffuse= NLMISC::CRGBA::White; } @@ -436,7 +436,7 @@ void CObjectViewer::loadConfigFile() _SceneLightSunSpecular.G = var.asInt(1); _SceneLightSunSpecular.B = var.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _SceneLightSunSpecular= NLMISC::CRGBA::White; } @@ -448,7 +448,7 @@ void CObjectViewer::loadConfigFile() _SceneLightSunDir.z = var.asFloat(2); _SceneLightSunDir.normalize(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _SceneLightSunDir.set(0, 1, -1); _SceneLightSunDir.normalize(); @@ -458,7 +458,7 @@ void CObjectViewer::loadConfigFile() CConfigFile::CVar &var = cf.getVar("object_light_test"); _ObjectLightTestShape= var.asString(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { } @@ -469,7 +469,7 @@ void CObjectViewer::loadConfigFile() try { CConfigFile::CVar &var = cf.getVar("automatic_animation_path"); - std::auto_ptr as(new CAnimationSet); + CUniquePtr as(new CAnimationSet); // bool loadingOk = as->loadFromFiles(var.asString(),true ,"anim",true); // @@ -480,7 +480,7 @@ void CObjectViewer::loadConfigFile() } CNELU::Scene->setAutomaticAnimationSet(as.release()); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { //::MessageBox(NULL, "No automatic animation path specified, please set 'automatic_animation_path'", "warning", MB_OK); nlwarning("No automatic animation path specified"); @@ -492,7 +492,7 @@ void CObjectViewer::loadConfigFile() CConfigFile::CVar &var = cf.getVar("character_scale_pos"); _CharacterScalePos= var.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { } @@ -533,9 +533,9 @@ void CObjectViewer::loadConfigFile() if (var = cf.getVarPtr("cloud_wind_speed")) _CSS.WindSpeed = var->asFloat(); } - catch (Exception& e) + catch (const Exception& e) { - ::MessageBox (NULL, e.what(), "Objectviewer.cfg", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox (NULL, utf8ToTStr(e.what()), _T("Objectviewer.cfg"), MB_OK|MB_ICONEXCLAMATION); } } @@ -615,14 +615,14 @@ bool CObjectViewer::initUI (HWND parent) // The windows path uint dSize = ::GetWindowsDirectory(NULL, 0); nlverify(dSize); - char *wd = new char[dSize]; + + TCHAR *wd = new TCHAR[dSize]; nlverify(::GetWindowsDirectory(wd, dSize)); - _FontPath=wd; - _FontPath+="\\fonts\\arial.ttf"; + _FontPath = tStrToUtf8(wd) + "\\fonts\\arial.ttf"; + delete[] wd; // The font generator _FontGenerator = NL3D::newCFontGenerator ( _FontPath ); - delete[] wd; // The viewport CViewport viewport; @@ -654,7 +654,7 @@ bool CObjectViewer::initUI (HWND parent) // Create the window _MainFrame->CFrameWnd::Create (AfxRegisterWndClass(0, 0, NULL, hIcon), - "NeL object viewer", 0x00cfc000, /*WS_OVERLAPPEDWINDOW,*/ CFrameWnd::rectDefault, parentWndPtr, + _T("NeL object viewer"), 0x00cfc000, /*WS_OVERLAPPEDWINDOW,*/ CFrameWnd::rectDefault, parentWndPtr, MAKEINTRESOURCE(IDR_OBJECT_VIEWER_MENU), 0x00000300 /*WS_EX_ACCEPTFILES*/ /*|WS_EX_CLIENTEDGE*/); // Detach the hwnd @@ -811,34 +811,36 @@ bool CObjectViewer::initUI (HWND parent) // Enable sum of vram CNELU::Driver->enableUsedTextureMemorySum (); - char sModulePath[256]; // load the scheme bank if one is present CIFile iF; - ::_makepath (sModulePath, SDrive, SDir, "default", ".scb"); - if (iF.open(sModulePath)) + std::string path = SPath + "default.scb"; + if (iF.open(path)) { try { iF.serial(SchemeManager); } - catch (NLMISC::EStream &e) + catch (const NLMISC::EStream &e) { - ::MessageBox(NULL, ("Unable to load the default scheme bank file : " + std::string(e.what())).c_str(), "Object Viewer", MB_ICONEXCLAMATION); + std::string msg = toString("Unable to load the default scheme bank file : %s", e.what()); + ::MessageBox(NULL, utf8ToTStr(msg), _T("Object Viewer"), MB_ICONEXCLAMATION); } } iF.close(); // try to load a default config file for the viewer (for anitmation and particle edition setup) - ::_makepath (sModulePath, SDrive, SDir, "default", ".ovcgf"); - if (iF.open (sModulePath)) + path = SPath + "default.ovcgf"; + + if (iF.open (path)) { try { serial (iF); } - catch (Exception& e) + catch (const Exception& e) { - ::MessageBox (NULL, (std::string("error while loading default.ovcgf : ") + e.what()).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = toString("Error while loading default.ovcgf : %s", e.what()); + ::MessageBox (NULL, utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } @@ -1286,7 +1288,6 @@ void CObjectViewer::go () sint64 timeDiff = newTime - lastTime; float fps = timeDiff > 0 ? (float)(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime)) : 1000.0f; lastTime=newTime; - char msgBar[1024]; uint nbPlayingSources, nbSources; if (CSoundSystem::getAudioMixer()) { @@ -1299,30 +1300,32 @@ void CObjectViewer::go () } // Display std info. - sprintf (msgBar, "%s - Nb tri: %d -Texture used (Mo): %5.2f - Texture allocated (Mo): %5.2f - Distance: %5.0f - Sounds: %d/%d - Fps: %03.1f", - _Direct3d?"Direct3d":"OpenGL", - in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips, (float)CNELU::Driver->getUsedTextureMemory () / (float)(1024*1024), - (float)CNELU::Driver->profileAllocatedTextureMemory () / (float)(1024*1024), - (_SceneCenter-CNELU::Camera->getMatrix().getPos()).norm(), - nbPlayingSources, - nbSources, - fps - ); + std::string msgBar = toString("%s - Nb tri: %u - Texture used (MiB): %5.2f - Texture allocated (MiB): %5.2f - Distance: %5.0f - Sounds: %u/%u - Fps: %03.1f", + _Direct3d ? "Direct3d":"OpenGL", + in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips, + (float)CNELU::Driver->getUsedTextureMemory () / (float)(1024*1024), + (float)CNELU::Driver->profileAllocatedTextureMemory () / (float)(1024*1024), + (_SceneCenter-CNELU::Camera->getMatrix().getPos()).norm(), + nbPlayingSources, + nbSources, + fps + ); + // Display - _MainFrame->StatusBar.SetWindowText (msgBar); + _MainFrame->StatusBar.SetWindowText (utf8ToTStr(msgBar)); // Display Vegetable info. if(_VegetableDlg!=NULL) { if(_VegetableLandscape != NULL) { - char vegetMsgBar[1024]; - sprintf (vegetMsgBar, "%d", _VegetableLandscape->Landscape.getNumVegetableFaceRendered()); + CString vegetMsgBar; + vegetMsgBar.Format(_T("%u"), _VegetableLandscape->Landscape.getNumVegetableFaceRendered()); _VegetableDlg->StaticPolyCount.SetWindowText(vegetMsgBar); } else { - _VegetableDlg->StaticPolyCount.SetWindowText("0"); + _VegetableDlg->StaticPolyCount.SetWindowText(_T("0")); } } @@ -1564,23 +1567,23 @@ void CObjectViewer::releaseUI () // *************************************************************************** -void setRegisterWindowState (const CWnd *pWnd, const char* keyName) +void setRegisterWindowState (const CWnd *pWnd, const TCHAR* keyName) { HKEY hKey; if (RegCreateKey(HKEY_CURRENT_USER, keyName, &hKey)==ERROR_SUCCESS) { RECT rect; pWnd->GetWindowRect (&rect); - RegSetValueEx(hKey, "Left", 0, REG_DWORD, (LPBYTE)&rect.left, 4); - RegSetValueEx(hKey, "Right", 0, REG_DWORD, (LPBYTE)&rect.right, 4); - RegSetValueEx(hKey, "Top", 0, REG_DWORD, (LPBYTE)&rect.top, 4); - RegSetValueEx(hKey, "Bottom", 0, REG_DWORD, (LPBYTE)&rect.bottom, 4); + RegSetValueEx(hKey, _T("Left"), 0, REG_DWORD, (LPBYTE)&rect.left, 4); + RegSetValueEx(hKey, _T("Right"), 0, REG_DWORD, (LPBYTE)&rect.right, 4); + RegSetValueEx(hKey, _T("Top"), 0, REG_DWORD, (LPBYTE)&rect.top, 4); + RegSetValueEx(hKey, _T("Bottom"), 0, REG_DWORD, (LPBYTE)&rect.bottom, 4); } } // *************************************************************************** -void getRegisterWindowState (CWnd *pWnd, const char* keyName, bool resize) +void getRegisterWindowState (CWnd *pWnd, const TCHAR* keyName, bool resize) { HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER, keyName, 0, KEY_READ, &hKey)==ERROR_SUCCESS) @@ -1588,10 +1591,10 @@ void getRegisterWindowState (CWnd *pWnd, const char* keyName, bool resize) DWORD len=4; DWORD type; RECT rect; - RegQueryValueEx (hKey, "Left", 0, &type, (LPBYTE)&rect.left, &len); - RegQueryValueEx (hKey, "Right", 0, &type, (LPBYTE)&rect.right, &len); - RegQueryValueEx (hKey, "Top", 0, &type, (LPBYTE)&rect.top, &len); - RegQueryValueEx (hKey, "Bottom", 0, &type, (LPBYTE)&rect.bottom, &len); + RegQueryValueEx (hKey, _T("Left"), 0, &type, (LPBYTE)&rect.left, &len); + RegQueryValueEx (hKey, _T("Right"), 0, &type, (LPBYTE)&rect.right, &len); + RegQueryValueEx (hKey, _T("Top"), 0, &type, (LPBYTE)&rect.top, &len); + RegQueryValueEx (hKey, _T("Bottom"), 0, &type, (LPBYTE)&rect.bottom, &len); // Set window pos pWnd->SetWindowPos (NULL, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_NOOWNERZORDER|SWP_NOZORDER| @@ -1619,7 +1622,7 @@ void CObjectViewer::resetSlots (uint instance) // Set no animation in slot UI for (uint j=0; jSaved.SlotInfo[j].Animation = ""; + _ListInstance[instance]->Saved.SlotInfo[j].Animation.clear(); // Reset the animation list _ListInstance[instance]->Saved.AnimationFileName.clear (); @@ -1739,7 +1742,7 @@ void CObjectViewer::serial (NLMISC::IStream& f) { if (ver <=3) { - ParticleWorkspaceFilename = ""; + ParticleWorkspaceFilename.clear(); } // First instance uint firstInstance = (uint)_ListInstance.size(); @@ -1782,17 +1785,16 @@ void CObjectViewer::serial (NLMISC::IStream& f) { // Add the mesh if (readed[i].SkeletonId != 0xffffffff) - instance = addMesh (serialShape.getShapePointer(), readed[i].ShapeFilename.c_str(), readed[i].SkeletonId + firstInstance, (readed[i].BindBoneName=="")?NULL:readed[i].BindBoneName.c_str()); + instance = addMesh (serialShape.getShapePointer(), readed[i].ShapeFilename.c_str(), readed[i].SkeletonId + firstInstance, (readed[i].BindBoneName.empty())?NULL:readed[i].BindBoneName.c_str()); else - instance = addMesh (serialShape.getShapePointer(), readed[i].ShapeFilename.c_str(), 0xffffffff, (readed[i].BindBoneName=="")?NULL:readed[i].BindBoneName.c_str()); + instance = addMesh (serialShape.getShapePointer(), readed[i].ShapeFilename.c_str(), 0xffffffff, (readed[i].BindBoneName.empty())?NULL:readed[i].BindBoneName.c_str()); } } else { // Error message - char message[512]; - smprintf (message, 512, "File not found %s", readed[i].ShapeFilename.c_str()); - _MainFrame->MessageBox (message, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string message = toString("File not found %s", readed[i].ShapeFilename.c_str()); + _MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); // Stop loading break; @@ -1823,12 +1825,11 @@ void CObjectViewer::serial (NLMISC::IStream& f) for (uint slot=0; slotSaved.SlotInfo[slot] = readed[i].SlotInfo[slot]; } - catch (Exception &e) + catch (const Exception &e) { // Error message - char message[512]; - smprintf (message, 512, "Error loading shape %s: %s", readed[i].ShapeFilename.c_str(), e.what()); - _MainFrame->MessageBox (message, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string message = toString("Error loading shape %s: %s", readed[i].ShapeFilename.c_str(), e.what()); + _MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); // Stop loading break; @@ -1872,27 +1873,19 @@ void CObjectViewer::serial (NLMISC::IStream& f) // *************************************************************************** -bool CObjectViewer::loadInstanceGroup(const char *igFilename) +bool CObjectViewer::loadInstanceGroup(const std::string &igFilename) { //AFX_MANAGE_STATE(AfxGetStaticModuleState()); - // Add to the path - char drive[256]; - char dir[256]; - char path[256]; - // Add search path for the mesh - _splitpath (igFilename, drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); - CPath::addSearchPath (path); - + CPath::addSearchPath (NLMISC::CFile::getPath(igFilename)); // Open a file CIFile file; if (file.open (igFilename)) { // Shape pointer - NL3D::CInstanceGroup *ig= new NL3D::CInstanceGroup; + NL3D::CInstanceGroup *ig = new NL3D::CInstanceGroup; try { @@ -1902,20 +1895,19 @@ bool CObjectViewer::loadInstanceGroup(const char *igFilename) // Append the ig. addInstanceGroup(ig); } - catch (Exception& e) + catch (const Exception& e) { // clean delete ig; - _MainFrame->MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + _MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); return false; } } else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", igFilename); - _MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = toString("Can't open the file %s for reading.", igFilename.c_str()); + _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); return false; } @@ -1928,21 +1920,16 @@ bool CObjectViewer::loadInstanceGroup(const char *igFilename) // *************************************************************************** -bool CObjectViewer::loadMesh (std::vector &meshFilename, const char* skeleton) +bool CObjectViewer::loadMesh (std::vector &meshFilename, const std::string &skeleton) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Add to the path - char drive[256]; - char dir[256]; - char path[256]; // Add search path for the skeleton - if (skeleton) + if (skeleton.empty()) { - _splitpath (skeleton, drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); - CPath::addSearchPath (path); + CPath::addSearchPath (NLMISC::CFile::getPath(skeleton)); } // Open a file @@ -1957,7 +1944,7 @@ bool CObjectViewer::loadMesh (std::vector &meshFilename, const char bool skelError=false; // Continue ? - if (skeleton&&(strcmp (skeleton, "")!=0)) + if (!skeleton.empty()) { // Open a file @@ -1973,9 +1960,9 @@ bool CObjectViewer::loadMesh (std::vector &meshFilename, const char // Add the shape shapeSkel=streamShape.getShapePointer(); } - catch (Exception& e) + catch (const Exception& e) { - _MainFrame->MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + _MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); // error skelError=true; @@ -1984,9 +1971,8 @@ bool CObjectViewer::loadMesh (std::vector &meshFilename, const char else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", meshFilename); - _MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("Can't open the file %s for reading.", skeleton.c_str()); + _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); // error skelError=true; @@ -2007,12 +1993,10 @@ bool CObjectViewer::loadMesh (std::vector &meshFilename, const char for (uint i=0; i &meshFilename, const char // Add the shape shapeMesh=streamShape.getShapePointer(); } - catch (Exception& e) + catch (const Exception& e) { - _MainFrame->MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + _MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); continue; } } else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", fileName); - _MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str()); + _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); continue; } @@ -2097,7 +2080,7 @@ void CObjectViewer::resetCamera () // *************************************************************************** -uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const char* meshName, uint skelIndex, const char* bindSkelName, bool createInstance) +uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const std::string &meshName, uint skelIndex, const char* bindSkelName, bool createInstance) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); @@ -2167,7 +2150,7 @@ uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const char* meshName, uin { // Bind bone name uint bindBone = 0xffffffff; - std::string boneName = ""; + std::string boneName; // Name is passed, look for bone if (bindSkelName) @@ -2195,8 +2178,7 @@ uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const char* meshName, uin listBones.push_back (transformSkel->Bones[bone].getBoneName()); // Get name of the mesh - char nameMesh[512]; - _splitpath (meshName, NULL, NULL, nameMesh, NULL); + std::string nameMesh = NLMISC::CFile::getFilenameWithoutExtension(meshName); // Select a bones std::string message = "Select a bone to stick " + string (nameMesh); @@ -2280,7 +2262,7 @@ bool CObjectViewer::isSkeletonPresent() const // *************************************************************************** -uint CObjectViewer::addCamera (const NL3D::CCameraInfo &cameraInfo, const char* cameraName) +uint CObjectViewer::addCamera (const NL3D::CCameraInfo &cameraInfo, const std::string &cameraName) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); @@ -2315,7 +2297,7 @@ uint CObjectViewer::addCamera (const NL3D::CCameraInfo &cameraInfo, const char* // *************************************************************************** -uint CObjectViewer::addSkel (NL3D::IShape* pSkelShape, const char* skelName) +uint CObjectViewer::addSkel (NL3D::IShape* pSkelShape, const std::string &skelName) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); @@ -2380,7 +2362,7 @@ IObjectViewer* IObjectViewer::getInterface (int version) // Check version number if (version!=OBJECT_VIEWER_VERSION) { - MessageBox (NULL, "Bad version of object_viewer.dll.", "NeL object viewer", MB_ICONEXCLAMATION|MB_OK); + MessageBox (NULL, _T("Bad version of object_viewer.dll."), _T("NeL object viewer"), MB_ICONEXCLAMATION|MB_OK); return NULL; } else @@ -2398,7 +2380,7 @@ void IObjectViewer::releaseInterface (IObjectViewer* view) // *************************************************************************** -void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const char* name, uint instance) +void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const std::string &name, uint instance) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); @@ -2408,7 +2390,7 @@ void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const char* nam _SelectedObject = instance; // Add the animation - addAnimation (pAnim, (name+std::string(".anim")).c_str(), name, instance); + addAnimation (pAnim, name + ".anim", name, instance); // Add the animation to the animationSet _AnimationSetDlg->UpdateData (TRUE); @@ -2417,7 +2399,7 @@ void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const char* nam // Set the animation in the first slot _ListInstance[instance]->Saved.SlotInfo[0].Animation = name; - _ListInstance[instance]->Saved.SlotInfo[0].Skeleton = ""; + _ListInstance[instance]->Saved.SlotInfo[0].Skeleton.clear(); _ListInstance[instance]->Saved.SlotInfo[0].Offset = 0; _ListInstance[instance]->Saved.SlotInfo[0].StartTime = (int)(pAnim->getBeginTime()*_AnimationDlg->Speed); _ListInstance[instance]->Saved.SlotInfo[0].EndTime = (int)(pAnim->getEndTime()*_AnimationDlg->Speed); @@ -2601,7 +2583,7 @@ void CObjectViewer::evalSoundTrack (float lastTime, float currentTime) for (uint i = 0; i < _ListInstance.size(); i++) { // Some animation in the list ? - if (_ListInstance[i]->Saved.PlayList.size() > 0) + if (!_ListInstance[i]->Saved.PlayList.empty()) { // Accumul time float startTime = 0; @@ -2628,9 +2610,9 @@ void CObjectViewer::evalSoundTrack (float lastTime, float currentTime) { CEdit *edit = (CEdit*) _SoundAnimDlg->GetDlgItem(tab[i]); nlassert(edit); - char str[1024]; + TCHAR str[1024]; edit->GetLine(0, str, 1024); - SoundContext.Args[i] = atoi (str); + SoundContext.Args[i] = _ttoi (str); } // get the position of the skel if a skel is available @@ -2866,7 +2848,7 @@ void CObjectViewer::enableDynamicObjectLightingTest(NLPACS::CGlobalRetriever *gl if (!_ObjectLightTestShape.empty()) { string str= string("Path not found for Light Test Shape: ") + _ObjectLightTestShape; - ::MessageBox(NULL, str.c_str(), "Dynamic Object Light Test", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(NULL, utf8ToTStr(str.c_str()), _T("Dynamic Object Light Test"), MB_OK|MB_ICONEXCLAMATION); } // disable. _ObjectLightTest= NULL; @@ -2916,7 +2898,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) for (uint i=0; i<(uint)zones.size(); i++) _VegetableLandscapeZoneNames.push_back(zones.asString(i).c_str()); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLandscapeTileBank.clear(); _VegetableLandscapeTileFarBank.clear(); @@ -2934,7 +2916,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) // clamp to avoid divide/0. _VegetableLandscapeThreshold= max(_VegetableLandscapeThreshold, 0.001f); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLandscapeThreshold= 0.003f; } @@ -2944,7 +2926,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &tileNear= cf.getVar("veget_landscape_tile_near"); _VegetableLandscapeTileNear= tileNear.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLandscapeTileNear= 50; } @@ -2956,7 +2938,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) _VegetableLandscapeAmbient.G= color.asInt(1); _VegetableLandscapeAmbient.B= color.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLandscapeAmbient.set(80, 80, 80); } @@ -2968,7 +2950,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) _VegetableLandscapeDiffuse.G= color.asInt(1); _VegetableLandscapeDiffuse.B= color.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLandscapeDiffuse.set(255, 255, 255); } @@ -2978,7 +2960,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &var= cf.getVar("veget_landscape_snap_height"); _VegetableSnapHeight= var.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableSnapHeight= 1.70f; } @@ -2993,9 +2975,9 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &var= cf.getVar("veget_texture"); _VegetableTexture= var.asString(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { - _VegetableTexture= ""; + _VegetableTexture.clear(); } // vegetable ambient @@ -3006,7 +2988,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) _VegetableAmbient.G= color.asInt(1); _VegetableAmbient.B= color.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableAmbient.set(80, 80, 80); } @@ -3019,7 +3001,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) sint G= color.asInt(1) - _VegetableAmbient.G; clamp(G, 0, 255); _VegetableDiffuse.G= G; sint B= color.asInt(2) - _VegetableAmbient.B; clamp(B, 0, 255); _VegetableDiffuse.B= B; } - catch (EUnknownVar &) + catch (const EUnknownVar &) { sint R= 255 - _VegetableAmbient.R; clamp(R, 0, 255); _VegetableDiffuse.R= R; sint G= 255 - _VegetableAmbient.G; clamp(G, 0, 255); _VegetableDiffuse.G= G; @@ -3034,7 +3016,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) _VegetableLightDir.z= var.asFloat(2); _VegetableLightDir.normalize(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLightDir.set(0, 1, -1); _VegetableLightDir.normalize(); @@ -3048,7 +3030,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) _VegetableWindDir.y= var.asFloat(1); _VegetableWindDir.z= var.asFloat(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableWindDir.x= 0.5f; _VegetableWindDir.y= 0.5f; @@ -3060,7 +3042,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &var= cf.getVar("veget_wind_freq"); _VegetableWindFreq= var.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableWindFreq= 0.5; } @@ -3070,7 +3052,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &var= cf.getVar("veget_wind_power"); _VegetableWindPower= var.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableWindPower= 1; } @@ -3080,7 +3062,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &var= cf.getVar("veget_wind_bend_min"); _VegetableWindBendMin= var.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableWindBendMin= 0; } @@ -3105,7 +3087,7 @@ bool CObjectViewer::createVegetableLandscape() try { - if(_VegetableLandscapeTileBank=="") + if(_VegetableLandscapeTileBank.empty()) { throw Exception("Landscape CFG not fully defined"); } @@ -3113,7 +3095,7 @@ bool CObjectViewer::createVegetableLandscape() // Load The Bank files (copied from CLandscapeUser :) ). // ================ // progress - dlgProgress.ProgressText.SetWindowText("Loading TileBanks..."); + dlgProgress.ProgressText.SetWindowText(_T("Loading TileBanks...")); dlgProgress.ProgressBar.SetPos(0); // load CIFile bankFile(CPath::lookup(_VegetableLandscapeTileBank)); @@ -3140,7 +3122,7 @@ bool CObjectViewer::createVegetableLandscape() if(CNELU::Driver) { // progress - dlgProgress.ProgressText.SetWindowText("Loading Tiles..."); + dlgProgress.ProgressText.SetWindowText(_T("Loading Tiles...")); dlgProgress.ProgressBar.SetPos(0); // count nbText to load. @@ -3195,7 +3177,7 @@ bool CObjectViewer::createVegetableLandscape() bool zoneLoaded= false; CAABBox landscapeBBox; // progress - dlgProgress.ProgressText.SetWindowText("Loading Zones..."); + dlgProgress.ProgressText.SetWindowText(_T("Loading Zones...")); dlgProgress.ProgressBar.SetPos(0); uint nbZones= (uint)_VegetableLandscapeZoneNames.size(); for(uint i=0; isetLandscape(&_VegetableLandscape->Landscape); _VegetableCollisionEntity= _VegetableCollisionManager->createEntity(); } - catch (Exception &e) + catch (const Exception &e) { // close the progress dialog dlgProgress.DestroyWindow(); - MessageBox(_MainFrame->m_hWnd, e.what(), "Failed to Load landscape", MB_OK | MB_APPLMODAL); + MessageBox(_MainFrame->m_hWnd, utf8ToTStr(e.what()), _T("Failed to Load landscape"), MB_OK | MB_APPLMODAL); // remove first possibly created collisions objects. if(_VegetableCollisionEntity) @@ -3536,10 +3518,10 @@ void CObjectViewer::refreshAnimationListeners() } // *************************************************************************** -void CObjectViewer::addAnimation (NL3D::CAnimation* anim, const char* filename, const char* name, uint instance) +void CObjectViewer::addAnimation(NL3D::CAnimation* anim, const std::string &filename, const std::string &name, uint instance) { // Add an animation - uint id = _ListInstance[instance]->AnimationSet.addAnimation (name, anim); + uint id = _ListInstance[instance]->AnimationSet.addAnimation (name.c_str(), anim); _ListInstance[instance]->Saved.AnimationFileName.push_back (filename); // Rebuild the animationSet @@ -3553,15 +3535,14 @@ void CObjectViewer::addAnimation (NL3D::CAnimation* anim, const char* filename, } // *************************************************************************** -void CObjectViewer::loadAnimation (const char* fileName, uint instance) +void CObjectViewer::loadAnimation(const std::string &fileName, uint instance) { // Open the file CIFile file; if (file.open (fileName)) { // Get the animation name - char name[256]; - _splitpath (fileName, NULL, NULL, name, NULL); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName); // Make an animation CAnimation *anim=new CAnimation; @@ -3575,22 +3556,20 @@ void CObjectViewer::loadAnimation (const char* fileName, uint instance) else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", fileName); - _MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str()); + _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } // *************************************************************************** -void CObjectViewer::loadSWT (const char* fileName, uint instance) +void CObjectViewer::loadSWT (const std::string &fileName, uint instance) { // Open the file CIFile file; if (file.open (fileName)) { // Get the animation name - char name[256]; - _splitpath (fileName, NULL, NULL, name, NULL); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName); // Get the skeleton pointer CSkeletonWeight* skel=new CSkeletonWeight; @@ -3599,7 +3578,7 @@ void CObjectViewer::loadSWT (const char* fileName, uint instance) skel->serial (file); // Add an animation - _ListInstance[instance]->AnimationSet.addSkeletonWeight (name, skel); + _ListInstance[instance]->AnimationSet.addSkeletonWeight (name.c_str(), skel); // Add the filename in the list _ListInstance[instance]->Saved.SWTFileName.push_back (fileName); @@ -3607,9 +3586,8 @@ void CObjectViewer::loadSWT (const char* fileName, uint instance) else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", fileName); - _MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str()); + _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } @@ -3688,8 +3666,8 @@ float CObjectViewer::getGlobalWindPower() const void CObjectViewer::shootScene() { - static const char BASED_CODE szFilter[] = "Targa Files (*.tga)|*.tga|Jpeg Files (*.jpg)|*.jpg|All Files (*.*)|*.*||"; - CFileDialog fileDlg ( FALSE, ".tga", "*.tga", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static const TCHAR BASED_CODE szFilter[] = _T("PNG Files (*.png)|*.png|Targa Files (*.tga)|*.tga|Jpeg Files (*.jpg)|*.jpg|All Files (*.*)|*.*||"); + CFileDialog fileDlg ( FALSE, _T(".tga"), _T("*.tga"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal () == IDOK) { // Choose the size @@ -3712,8 +3690,8 @@ void CObjectViewer::shootScene() CNELU::Driver->setupViewport (CViewport ()); // The file name - string filename = NLMISC::CFile::getFilenameWithoutExtension ((const char*)fileDlg.GetPathName ()); - string extension = NLMISC::CFile::getExtension ((const char*)fileDlg.GetPathName ()); + string filename = NLMISC::CFile::getFilenameWithoutExtension(tStrToUtf8(fileDlg.GetPathName())); + string extension = NLMISC::CFile::getExtension (tStrToUtf8(fileDlg.GetPathName())); // The file name without extension bool jpeg = toLower (extension) == "jpg"; @@ -3792,13 +3770,15 @@ void CObjectViewer::shootScene() } else { - _MainFrame->MessageBox (("Can't open the file "+filenamefinal+" for writing.").c_str (), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string message = toString("Can't open the file %s for writing.", filenamefinal.c_str()); + _MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); break; } } - catch (Exception &e) + catch (const Exception &e) { - _MainFrame->MessageBox (("Error during writing of the file "+filenamefinal+" : "+(string)e.what ()).c_str (), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string message = toString("Error during writing of the file %s: %s", filenamefinal.c_str(), e.what()); + _MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); break; } } @@ -3815,7 +3795,7 @@ void CObjectViewer::drawFXUserMatrix() { CString fxUserMatrix; fxUserMatrix.LoadString(IDS_FX_USER_MATRIX); - fxUserMatrixStr = (LPCTSTR) fxUserMatrix; + fxUserMatrixStr = tStrToUtf8(fxUserMatrix); stringRetrieved = true; } nlassert(_ParticleDlg); @@ -3830,7 +3810,7 @@ void CObjectViewer::drawFXMatrix() { CString fx; fx.LoadString(IDS_FX_MATRIX); - fxStr = (LPCTSTR) fx; + fxStr = tStrToUtf8(fx); stringRetrieved = true; } drawNamedMatrix(_ParticleDlg->getPSWorldMatrix(), fxStr, NLMISC::CRGBA::Blue, -0.2f, 10.f); @@ -3844,7 +3824,7 @@ void CObjectViewer::drawSceneMatrix() { CString sceneMatrix; sceneMatrix.LoadString(IDS_SCENE_MATRIX); - sceneMatrixStr = (LPCTSTR) sceneMatrix; + sceneMatrixStr = tStrToUtf8(sceneMatrix); stringRetrieved = true; } drawNamedMatrix(_SceneRoot->getMatrix(), sceneMatrixStr, NLMISC::CRGBA::White, 0.f, 10.f); @@ -3882,7 +3862,6 @@ uint CObjectViewer::getNumCamera () const int localizedMessageBox(HWND parentWindow, int messageStringID, int captionStringID, UINT nType) { - CString caption; CString mess; caption.LoadString(captionStringID); @@ -3891,7 +3870,7 @@ int localizedMessageBox(HWND parentWindow, int messageStringID, int captionStrin // TODO : replace older call to ::MessageBox in the object viewer with that function } -int localizedMessageBox(HWND parentWindow, const char *message, int captionStringID, UINT nType) +int localizedMessageBox(HWND parentWindow, const TCHAR *message, int captionStringID, UINT nType) { CString caption; caption.LoadString(captionStringID); @@ -3907,7 +3886,7 @@ CString getStrRsc(uint stringID) bool browseFolder(const CString &caption, CString &destFolder, HWND parent) { - char chosenPath[MAX_PATH]; + TCHAR chosenPath[MAX_PATH]; // browse folder BROWSEINFO bi; bi.hwndOwner = parent; @@ -3918,7 +3897,7 @@ bool browseFolder(const CString &caption, CString &destFolder, HWND parent) bi.lpfn = NULL; bi.lParam = NULL; bi.iImage = 0; - LPITEMIDLIST result = SHBrowseForFolder(&bi); + PIDLIST_ABSOLUTE result = SHBrowseForFolder(&bi); if (result != NULL && SHGetPathFromIDList(result, chosenPath)) { destFolder = chosenPath; diff --git a/code/nel/tools/3d/object_viewer/object_viewer.h b/code/nel/tools/3d/object_viewer/object_viewer.h index bcf48d58f..c00c5490d 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.h +++ b/code/nel/tools/3d/object_viewer/object_viewer.h @@ -22,24 +22,24 @@ #endif // _MSC_VER > 1000 -#define REGKEY_OBJ_VIEW "Software\\Nevrax\\nel\\object_viewer" -#define REGKEY_OBJ_VIEW_OPENGL_WND "Software\\Nevrax\\nel\\object_viewer\\opengl_wnd" -#define REGKEY_OBJ_VIEW_SCENE_DLG "Software\\Nevrax\\nel\\object_viewer\\scene_dlg" -#define REGKEY_OBJ_VIEW_ANIMATION_DLG "Software\\Nevrax\\nel\\object_viewer\\animation_dlg" -#define REGKEY_OBJ_VIEW_ANIMATION_SET_DLG "Software\\Nevrax\\nel\\object_viewer\\animation_set_dlg" -#define REGKEY_OBJ_VIEW_SLOT_DLG "Software\\Nevrax\\nel\\object_viewer\\slot_dlg" -#define REGKEY_OBJ_PARTICLE_DLG "Software\\Nevrax\\nel\\object_viewer\\particle_dlg" -#define REGKEY_OBJ_DAYNIGHT_DLG "Software\\Nevrax\\nel\\object_viewer\\daynight_dlg" -#define REGKEY_OBJ_WATERPOOL_DLG "Software\\Nevrax\\nel\\object_viewer\\daynight_dlg" -#define REGKEY_OBJ_VIEW_VEGETABLE_DLG "Software\\Nevrax\\nel\\object_viewer\\vegetable_dlg" -#define REGKEY_OBJ_GLOBAL_WIND_DLG "Software\\Nevrax\\nel\\object_viewer\\global_wind_dlg" -#define REGKEY_OBJ_SOUND_ANIM_DLG "Software\\Nevrax\\nel\\object_viewer\\sound_anim_dlg" -#define REGKEY_OBJ_LIGHT_GROUP_DLG "Software\\Nevrax\\nel\\object_viewer\\light_group_dlg" -#define REGKEY_CHOOSE_FRAME_DELAY_DLG "Software\\Nevrax\\nel\\object_viewer\\choose_frame_delay_dlg" -#define REGKEY_CHOOSE_BG_COLOR_DLG "Software\\Nevrax\\nel\\object_viewer\\choose_bg_color_dlg" -#define REGKEY_CHOOSE_SUN_COLOR_DLG "Software\\Nevrax\\nel\\object_viewer\\choose_sun_color_dlg" -#define REGKEY_SKELETON_SCALE_DLG "Software\\Nevrax\\nel\\object_viewer\\skeleton_scale_dlg" -#define REGKEY_TUNE_MRM_DLG "Software\\Nevrax\\nel\\object_viewer\\tune_mrm_dlg" +#define REGKEY_OBJ_VIEW _T("Software\\Nevrax\\nel\\object_viewer") +#define REGKEY_OBJ_VIEW_OPENGL_WND _T("Software\\Nevrax\\nel\\object_viewer\\opengl_wnd") +#define REGKEY_OBJ_VIEW_SCENE_DLG _T("Software\\Nevrax\\nel\\object_viewer\\scene_dlg") +#define REGKEY_OBJ_VIEW_ANIMATION_DLG _T("Software\\Nevrax\\nel\\object_viewer\\animation_dlg") +#define REGKEY_OBJ_VIEW_ANIMATION_SET_DLG _T("Software\\Nevrax\\nel\\object_viewer\\animation_set_dlg") +#define REGKEY_OBJ_VIEW_SLOT_DLG _T("Software\\Nevrax\\nel\\object_viewer\\slot_dlg") +#define REGKEY_OBJ_PARTICLE_DLG _T("Software\\Nevrax\\nel\\object_viewer\\particle_dlg") +#define REGKEY_OBJ_DAYNIGHT_DLG _T("Software\\Nevrax\\nel\\object_viewer\\daynight_dlg") +#define REGKEY_OBJ_WATERPOOL_DLG _T("Software\\Nevrax\\nel\\object_viewer\\daynight_dlg") +#define REGKEY_OBJ_VIEW_VEGETABLE_DLG _T("Software\\Nevrax\\nel\\object_viewer\\vegetable_dlg") +#define REGKEY_OBJ_GLOBAL_WIND_DLG _T("Software\\Nevrax\\nel\\object_viewer\\global_wind_dlg") +#define REGKEY_OBJ_SOUND_ANIM_DLG _T("Software\\Nevrax\\nel\\object_viewer\\sound_anim_dlg") +#define REGKEY_OBJ_LIGHT_GROUP_DLG _T("Software\\Nevrax\\nel\\object_viewer\\light_group_dlg") +#define REGKEY_CHOOSE_FRAME_DELAY_DLG _T("Software\\Nevrax\\nel\\object_viewer\\choose_frame_delay_dlg") +#define REGKEY_CHOOSE_BG_COLOR_DLG _T("Software\\Nevrax\\nel\\object_viewer\\choose_bg_color_dlg") +#define REGKEY_CHOOSE_SUN_COLOR_DLG _T("Software\\Nevrax\\nel\\object_viewer\\choose_sun_color_dlg") +#define REGKEY_SKELETON_SCALE_DLG _T("Software\\Nevrax\\nel\\object_viewer\\skeleton_scale_dlg") +#define REGKEY_TUNE_MRM_DLG _T("Software\\Nevrax\\nel\\object_viewer\\tune_mrm_dlg") @@ -234,19 +234,19 @@ public: void releaseUI (); // Set single animtion. - void setSingleAnimation (NL3D::CAnimation* pAnim, const char* name, uint instance); + void setSingleAnimation (NL3D::CAnimation* pAnim, const std::string &name, uint instance); // Set automatic animation void setAutoAnimation (NL3D::CAnimationSet* pAnimSet); // Add a mesh - uint addMesh (NL3D::IShape* pMeshShape, const char* meshName, uint skelIndex, const char* bindSkelName = NULL, bool createInstance = true); + uint addMesh(NL3D::IShape* pMeshShape, const std::string &meshName, uint skelIndex, const char* bindSkelName = NULL, bool createInstance = true); // Add a camera - uint addCamera (const NL3D::CCameraInfo &cameraInfo, const char* cameraName); + uint addCamera (const NL3D::CCameraInfo &cameraInfo, const std::string &cameraName); // Add a skel - uint addSkel (NL3D::IShape* pSkelShape, const char* skelName); + uint addSkel (NL3D::IShape* pSkelShape, const std::string &skelName); // remove all instances from the scene void removeAllInstancesFromScene(); @@ -262,10 +262,10 @@ public: void shuffleTextureSet(); // Load a mesh - bool loadMesh (std::vector &meshFilename, const char* skeleton=""); + bool loadMesh (std::vector &meshFilename, const std::string &skeleton = ""); // Load an instance group - bool loadInstanceGroup(const char *igFilename); + bool loadInstanceGroup(const std::string &igFilename); // Set ambient color void setAmbientColor (const NLMISC::CRGBA& color); @@ -289,7 +289,7 @@ public: uint getNumInstance () const; // Add an animation - void addAnimation (NL3D::CAnimation* anim, const char* filename, const char* name, uint instance); + void addAnimation (NL3D::CAnimation* anim, const std::string &filename, const std::string &name, uint instance); // Update all objects that depend on the animation set void refreshAnimationListeners(); @@ -308,10 +308,10 @@ public: CChooseFrameDelay *getFrameDelayDlg() const { return _ChooseFrameDelayDlg; } // Load animation - void loadAnimation (const char* fileName, uint instance); + void loadAnimation(const std::string &fileName, uint instance); // Load a skeleton template - void loadSWT (const char* fileName, uint instance); + void loadSWT(const std::string &fileName, uint instance); /// Not exported @@ -387,7 +387,7 @@ public: /// inherited from CObjectViewerInterface void setWaterPoolManager(NL3D::CWaterPoolManager &wpm) { _Wpm = &wpm; } - NL3D::CWaterPoolManager &getWaterPoolManager() { return *_Wpm; } + NL3D::CWaterPoolManager &getWaterPoolManager() const { return *_Wpm; } // Reload textures void reloadTextures (); @@ -650,8 +650,8 @@ private: void drawNamedMatrix(const NLMISC::CMatrix &matrix, const std::string &name, NLMISC::CRGBA color, float textZOffset, float testSize); }; -void setRegisterWindowState (const CWnd *pWnd, const char* keyName); -void getRegisterWindowState (CWnd *pWnd, const char* keyName, bool resize); +void setRegisterWindowState (const CWnd *pWnd, const TCHAR* keyName); +void getRegisterWindowState (CWnd *pWnd, const TCHAR* keyName, bool resize); /** display a localized message box. Caption an message text are retrieved from the string table * \param parentWindow Pointer to initiator of the message box @@ -661,7 +661,7 @@ void getRegisterWindowState (CWnd *pWnd, const char* keyName, bool resize); * \return Same value than ::MessageBox */ int localizedMessageBox(HWND parentWindow, int messageStringID, int captionStringID, UINT nType); -int localizedMessageBox(HWND parentWindow, const char *message, int captionStringID, UINT nType); +int localizedMessageBox(HWND parentWindow, const TCHAR *message, int captionStringID, UINT nType); // Return a string from the string table CString getStrRsc(uint stringID); diff --git a/code/nel/tools/3d/object_viewer/object_viewer_interface.h b/code/nel/tools/3d/object_viewer/object_viewer_interface.h index a8eb696b3..e6df63394 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer_interface.h +++ b/code/nel/tools/3d/object_viewer/object_viewer_interface.h @@ -69,25 +69,25 @@ public: virtual void releaseUI () = 0; // Add a mesh - virtual uint addMesh (NL3D::IShape* pMeshShape, const char* meshName, uint skelIndex, const char* bindSkelName = NULL, bool createInstance = true) = 0; + virtual uint addMesh(NL3D::IShape* pMeshShape, const std::string &meshName, uint skelIndex, const char* bindSkelName = NULL, bool createInstance = true) = 0; // Add a skel - virtual uint addSkel (NL3D::IShape* pSkelShape, const char* skelName) = 0; + virtual uint addSkel (NL3D::IShape* pSkelShape, const std::string &skelName) = 0; // Add a camera - virtual uint addCamera (const NL3D::CCameraInfo &cameraInfo, const char* cameraName) = 0; + virtual uint addCamera (const NL3D::CCameraInfo &cameraInfo, const std::string &cameraName) = 0; // remove all the instance from the scene virtual void removeAllInstancesFromScene() = 0; // Load a mesh - virtual bool loadMesh (std::vector &meshFilename, const char* skeleton) = 0; + virtual bool loadMesh (std::vector &meshFilename, const std::string &skeleton) = 0; // Load a shape virtual void resetCamera () = 0; // Set single animation - virtual void setSingleAnimation (NL3D::CAnimation* pAnim, const char* name, uint instance) = 0; + virtual void setSingleAnimation (NL3D::CAnimation* pAnim, const std::string &name, uint instance) = 0; // Set automatic animation virtual void setAutoAnimation (NL3D::CAnimationSet* pAnimSet) = 0; diff --git a/code/nel/tools/3d/object_viewer/particle_dlg.cpp b/code/nel/tools/3d/object_viewer/particle_dlg.cpp index f56bfa1dd..f50fe53a2 100644 --- a/code/nel/tools/3d/object_viewer/particle_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/particle_dlg.cpp @@ -419,7 +419,7 @@ bool CParticleDlg::savePSAs(HWND parent, CParticleWorkspace::CNode &psNode ,cons psNode.setModified(false); setStatusBarText(CString(fullPath.c_str()) + " " + getStrRsc(IDS_SAVED)); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { if (askToContinueWhenError) { @@ -428,7 +428,7 @@ bool CParticleDlg::savePSAs(HWND parent, CParticleWorkspace::CNode &psNode ,cons } else { - ::MessageBox(parent, e.what(), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION); + ::MessageBox(parent, utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION); return false; } } @@ -468,13 +468,13 @@ bool CParticleDlg::loadPS(HWND parent, CParticleWorkspace::CNode &psNode, TLoadP setStatusBarText(CString(psNode.getFullPath().c_str()) + " " + getStrRsc(IDS_LOADED)); } } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { switch(behav) { case Silent: return false; // no op case ReportError: - ::MessageBox(parent, e.what(), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(parent, utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION); return true; break; case ReportErrorSkippable: @@ -547,9 +547,9 @@ void CParticleDlg::OnCreateNewPsWorkspace() { newPW->save(); } - catch(NLMISC::EStream &e) + catch(const NLMISC::EStream &e) { - MessageBox(e.what(), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION); + MessageBox(utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION); } closeWorkspace(); _PW = newPW; @@ -563,18 +563,18 @@ void CParticleDlg::OnCreateNewPsWorkspace() void CParticleDlg::OnLoadPSWorkspace() { checkModifiedWorkSpace(); - static const char BASED_CODE szFilter[] = "particle workspaces(*.pws)|*.pws||"; - CFileDialog fd( TRUE, ".pws", "*.pws", 0, szFilter); + static const TCHAR BASED_CODE szFilter[] = _T("particle workspaces(*.pws)|*.pws||"); + CFileDialog fd( TRUE, _T(".pws"), _T("*.pws"), 0, szFilter); INT_PTR result = fd.DoModal(); if (result != IDOK) return; - loadWorkspace((LPCTSTR) fd.GetPathName()); + loadWorkspace(tStrToUtf8(fd.GetPathName())); } //************************************************************************************************************************** void CParticleDlg::loadWorkspace(const std::string &fullPath) { // Add to the path - std::auto_ptr newPW(new CParticleWorkspace); + CUniquePtr newPW(new CParticleWorkspace); newPW->init(_ObjView, fullPath, _ObjView->getFontManager(), _ObjView->getFontGenerator()); newPW->setModificationCallback(ParticleTreeCtrl); // save empty workspace @@ -583,9 +583,9 @@ void CParticleDlg::loadWorkspace(const std::string &fullPath) newPW->load(); setStatusBarText(CString(newPW->getFilename().c_str()) + " " + getStrRsc(IDS_LOADED)); } - catch(NLMISC::EStream &e) + catch(const NLMISC::EStream &e) { - MessageBox(e.what(), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION); + MessageBox(utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION); setStatusBarText(CString(e.what())); return; } @@ -633,9 +633,9 @@ void CParticleDlg::saveWorkspaceStructure() _PW->save(); setStatusBarText(CString(_PW->getFilename().c_str()) + " " + getStrRsc(IDS_SAVED)); } - catch(NLMISC::EStream &e) + catch(const NLMISC::EStream &e) { - localizedMessageBox(*this, e.what(), IDS_ERROR, MB_ICONEXCLAMATION); + localizedMessageBox(*this, utf8ToTStr(e.what()), IDS_ERROR, MB_ICONEXCLAMATION); setStatusBarText(CString(e.what())); } } diff --git a/code/nel/tools/3d/object_viewer/particle_system_edit.cpp b/code/nel/tools/3d/object_viewer/particle_system_edit.cpp index 248a5cd1e..7aa989d8b 100644 --- a/code/nel/tools/3d/object_viewer/particle_system_edit.cpp +++ b/code/nel/tools/3d/object_viewer/particle_system_edit.cpp @@ -34,12 +34,12 @@ static void concatEdit2Lines(CEdit &edit) const uint lineLen= 1000; uint n; // retrieve the 2 lines. - char tmp0[2*lineLen]; - char tmp1[lineLen]; + TCHAR tmp0[2*lineLen]; + TCHAR tmp1[lineLen]; n= edit.GetLine(0, tmp0, lineLen); tmp0[n]= 0; n= edit.GetLine(1, tmp1, lineLen); tmp1[n]= 0; // concat and update the CEdit. - edit.SetWindowText(strcat(tmp0, tmp1)); + edit.SetWindowText(_tcscat(tmp0, tmp1)); } @@ -220,16 +220,20 @@ void CParticleSystemEdit::updateDieOnEventParams() { ew = FALSE; } + GetDlgItem(IDC_APPLY_AFTER_DELAY)->EnableWindow(ew); - char out[128]; + + CString out; + if (_Node->getPSPointer()->getDelayBeforeDeathConditionTest() >= 0) { - sprintf(out, "%.2g", _Node->getPSPointer()->getDelayBeforeDeathConditionTest()); + out.Format(_T("%.2g"), _Node->getPSPointer()->getDelayBeforeDeathConditionTest()); } else { - strcpy(out,"???"); + out = _T("???"); } + GetDlgItem(IDC_APPLY_AFTER_DELAY)->SetWindowText(out); ((CButton *) GetDlgItem(IDC_AUTO_DELAY))->SetCheck(autoDelay ? 1 : 0); } @@ -269,9 +273,9 @@ void CParticleSystemEdit::updatePrecomputedBBoxParams() if (!ew) { - m_BBoxX = ""; - m_BBoxY = ""; - m_BBoxZ = ""; + m_BBoxX.Empty(); + m_BBoxY.Empty(); + m_BBoxZ.Empty(); } else { @@ -394,13 +398,14 @@ void CParticleSystemEdit::OnEnableSlowDown() void CParticleSystemEdit::updateBBoxFromText() { NLMISC::CVector h; - char inX[128], inY[128], inZ[128]; + TCHAR inX[128], inY[128], inZ[128]; m_BBoxXCtrl.GetWindowText(inX, 128); m_BBoxYCtrl.GetWindowText(inY, 128); m_BBoxZCtrl.GetWindowText(inZ, 128); - if (sscanf(inX, "%f", &h.x) == 1 - && sscanf(inY, "%f", &h.y) == 1 - && sscanf(inZ, "%f", &h.z) == 1 + + if (_stscanf(inX, _T("%f"), &h.x) == 1 + && _stscanf(inY, _T("%f"), &h.y) == 1 + && _stscanf(inZ, _T("%f"), &h.z) == 1 ) { NLMISC::CAABBox b; @@ -409,7 +414,7 @@ void CParticleSystemEdit::updateBBoxFromText() } else { - MessageBox("Invalid entry","error", MB_OK); + MessageBox(_T("Invalid entry"), _T("error"), MB_OK); } } @@ -456,11 +461,12 @@ void CParticleSystemEdit::OnDieWhenOutOfFrustum() void CParticleSystemEdit::OnChangeApplyAfterDelay() { if (_Node->getPSPointer()->getAutoComputeDelayBeforeDeathConditionTest()) return; - // - char in[128]; - GetDlgItem(IDC_APPLY_AFTER_DELAY)->GetWindowText(in, 128); + + TCHAR in[128]; + GetDlgItem(IDC_APPLY_AFTER_DELAY)->GetWindowText(in, 128); + float value; - if (sscanf(in, "%f", &value) == 1) + if (_stscanf(in, _T("%f"), &value) == 1) { if (_Node->getPSPointer()->getDelayBeforeDeathConditionTest() != value) { @@ -728,7 +734,7 @@ void CParticleSystemEdit::OnEnableLoadBalancing() UpdateData(TRUE); if (m_EnableLoadBalancing == FALSE) { - int result = MessageBox("Are you sure ?", "Load balancing on/off", MB_OKCANCEL); + int result = MessageBox(_T("Are you sure ?"), _T("Load balancing on/off"), MB_OKCANCEL); if (result == IDOK) { _Node->getPSPointer()->enableLoadBalancing(false); @@ -791,7 +797,7 @@ void CParticleSystemEdit::OnBypassMaxNumSteps() UpdateData(TRUE); if (m_BypassMaxNumSteps && !_Node->getPSPointer()->canFinish()) { - MessageBox("The system must have a finite duration for this setting! Please check that.", "error", MB_ICONEXCLAMATION); + MessageBox(_T("The system must have a finite duration for this setting! Please check that."), _T("error"), MB_ICONEXCLAMATION); return; } _Node->getPSPointer()->setBypassMaxNumIntegrationSteps(m_BypassMaxNumSteps != FALSE); diff --git a/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp b/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp index 9c58cd875..daad7864a 100644 --- a/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp +++ b/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp @@ -165,7 +165,7 @@ void CParticleTreeCtrl::rebuildLocatedInstance(CParticleWorkspace::CNode &node) CNodeType *newNt = new CNodeType(loc, k); _NodeTypes.push_back(newNt); // bind located instance icon - InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, "instance", PSIconLocatedInstance, PSIconLocatedInstance, 0, 0, (LPARAM) newNt, currLocated, TVI_LAST); + InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, _T("instance"), PSIconLocatedInstance, PSIconLocatedInstance, 0, 0, (LPARAM) newNt, currLocated, TVI_LAST); } currLocated = GetNextItem(currLocated, TVGN_NEXT); } @@ -213,7 +213,7 @@ HTREEITEM CParticleTreeCtrl::buildTreeFromPS(CParticleWorkspace::CNode &node, H if (node.isLoaded()) { // bind particle system icon - HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, computeCaption(node).c_str(), PSIconParticleSystem, PSIconParticleSystem, 0, 0, NULL, rootHandle, prevSibling); + HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, utf8ToTStr(computeCaption(node)), PSIconParticleSystem, PSIconParticleSystem, 0, 0, NULL, rootHandle, prevSibling); // set the param (doesn't seems to work during first creation) SetItemData(psRoot, (LPARAM) nt); // now, create each located @@ -228,7 +228,7 @@ HTREEITEM CParticleTreeCtrl::buildTreeFromPS(CParticleWorkspace::CNode &node, H else { // bind a bitmap that say that the PS hasn't been loaded - HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, computeCaption(node).c_str(), PSIconParticleSystemNotLoaded, PSIconParticleSystemNotLoaded, 0, 0, NULL, rootHandle, prevSibling); + HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, utf8ToTStr(computeCaption(node)), PSIconParticleSystemNotLoaded, PSIconParticleSystemNotLoaded, 0, 0, NULL, rootHandle, prevSibling); SetItemData(psRoot, (LPARAM) nt); return psRoot; } @@ -242,7 +242,7 @@ void CParticleTreeCtrl::buildTreeFromWorkSpace(CParticleWorkspace &ws) CNodeType *nt = new CNodeType(&ws); _NodeTypes.push_back(nt); // bind particle system icon - HTREEITEM rootHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, computeCaption(ws).c_str(), PSIconWorkspace, PSIconWorkspace, 0, 0, NULL, NULL, TVI_LAST); + HTREEITEM rootHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, utf8ToTStr(computeCaption(ws)), PSIconWorkspace, PSIconWorkspace, 0, 0, NULL, NULL, TVI_LAST); // set the param (doesn't seems to work during first creation) SetItemData(rootHandle, (LPARAM) nt); // now, create each particle system @@ -259,7 +259,7 @@ void CParticleTreeCtrl::createNodeFromLocated(NL3D::CPSLocated *loc, HTREEITEM CNodeType *nt = new CNodeType(loc); _NodeTypes.push_back(nt); // bind located icon - HTREEITEM nodeHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM |TVIF_TEXT, loc->getName().c_str() , PSIconLocated, PSIconLocated, 0, 0, (LPARAM) nt, rootHandle, TVI_LAST); + HTREEITEM nodeHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM |TVIF_TEXT, utf8ToTStr(loc->getName()) , PSIconLocated, PSIconLocated, 0, 0, (LPARAM) nt, rootHandle, TVI_LAST); // now, insert each object that is bound to the located for (uint l = 0; l < loc->getNbBoundObjects(); ++l) { @@ -273,7 +273,7 @@ void CParticleTreeCtrl::createNodeFromLocatedBindable(NL3D::CPSLocatedBindable * // we ordered the image so that they match the type for a located bindable (force, particles, collision zones...) CNodeType *nt = new CNodeType(lb); _NodeTypes.push_back(nt); - InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT , lb->getName().c_str() , lb->getType(), lb->getType(), PSIconForce, PSIconForce, (LPARAM) nt, rootHandle, TVI_LAST); + InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT , utf8ToTStr(lb->getName()) , lb->getType(), lb->getType(), PSIconForce, PSIconForce, (LPARAM) nt, rootHandle, TVI_LAST); } @@ -852,8 +852,8 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA nt = new CNodeType(nt->Loc, objIndex); _NodeTypes.push_back(nt); // insert the element in the tree - HTREEITEM root = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, "instance", PSIconLocatedInstance, PSIconLocatedInstance, 0, 0, (LPARAM) nt, GetSelectedItem(), TVI_LAST); - SetItemData(root, (DWORD) nt); + HTREEITEM root = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, _T("instance"), PSIconLocatedInstance, PSIconLocatedInstance, 0, 0, (LPARAM) nt, GetSelectedItem(), TVI_LAST); + SetItemData(root, (DWORD_PTR) nt); Invalidate(); } break; @@ -995,30 +995,26 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA case IDM_MERGE_PS: { _ParticleDlg->StartStopDlg->stop(); - static char BASED_CODE szFilter[] = "ps & shapes files(*.ps;*.shape)|*.ps; *.shape||"; - CFileDialog fd( TRUE, ".ps", "*.ps;*.shape", 0, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("ps & shapes files(*.ps;*.shape)|*.ps; *.shape||"); + CFileDialog fd( TRUE, _T(".ps"), _T("*.ps;*.shape"), 0, szFilter); if (fd.DoModal() == IDOK) { CParticleWorkspace::CNode *ownerNode = getOwnerNode(nt); nlassert(ownerNode); - // Add to the path - char drive[256]; - char dir[256]; - char path[256]; + // Add search path for the texture - _splitpath (fd.GetPathName(), drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); - std::auto_ptr sb(new NL3D::CShapeBank); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()))); + + CUniquePtr sb(new NL3D::CShapeBank); CParticleSystemModel *psm = NULL; try { NL3D::CShapeStream ss; NLMISC::CIFile inputFile; - inputFile.open((LPCTSTR) fd.GetPathName()); + inputFile.open(tStrToUtf8(fd.GetPathName())); ss.serial(inputFile); - std::string shapeName = NLMISC::CFile::getFilename((LPCTSTR) fd.GetPathName()); + std::string shapeName = NLMISC::CFile::getFilename(tStrToUtf8(fd.GetPathName())); sb->add(shapeName, ss.getShapePointer()); NL3D::CShapeBank *oldSB = CNELU::Scene->getShapeBank(); CNELU::Scene->setShapeBank(sb.get()); @@ -1041,9 +1037,9 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA return false; } } - catch(NLMISC::EStream &e) + catch(const NLMISC::EStream &e) { - MessageBox(e.what(), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION); + MessageBox(utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION); return TRUE; } ownerNode->setResetAutoCountFlag(false); @@ -1099,11 +1095,11 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA { _ParticleDlg->StartStopDlg->stop(); std::string fileName = nt->PS->getFilename(); - static char BASED_CODE szFilter[] = "ps & shapes files(*.ps;*.shape)|*.ps; *.shape||"; - CFileDialog fd(FALSE, ".ps", fileName.c_str(), OFN_OVERWRITEPROMPT, szFilter, this); + static TCHAR BASED_CODE szFilter[] = _T("ps & shapes files(*.ps;*.shape)|*.ps; *.shape||"); + CFileDialog fd(FALSE, _T(".ps"), utf8ToTStr(fileName), OFN_OVERWRITEPROMPT, szFilter, this); if (fd.DoModal() == IDOK) { - _ParticleDlg->savePSAs(*this, *nt->PS, (LPCTSTR) fd.GetPathName(), false); + _ParticleDlg->savePSAs(*this, *nt->PS, tStrToUtf8(fd.GetPathName()), false); } } } @@ -1151,7 +1147,7 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA { float value; int dummy; // to avoid non numeric characters at the end - if (sscanf ((LPCTSTR)(valueDlg.Value + "\n0"), "%f\n%d", &value, &dummy) == 2) + if (_stscanf((LPCTSTR)(valueDlg.Value + _T("\n0")), _T("%f\n%d"), &value, &dummy) == 2) { nlassert(getOwnerNode(nt)->getPSPointer()); getOwnerNode(nt)->getPSPointer()->setZBias(-value); @@ -1198,7 +1194,7 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA } if (!nt->Loc->bind(toCreate)) { - MessageBox("The system is flagged with 'No max Nb steps', or uses the preset 'Spell FX'. System must have finite duration. Can't add object. To solve this, set a limited life time for the father.", "Error", MB_ICONEXCLAMATION); + MessageBox(_T("The system is flagged with 'No max Nb steps', or uses the preset 'Spell FX'. System must have finite duration. Can't add object. To solve this, set a limited life time for the father."), _T("Error"), MB_ICONEXCLAMATION); delete toCreate; if (createLocAndBindable) { @@ -1253,7 +1249,7 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA } getOwnerNode(nt)->setModified(true); // TODO : an enum for CPSLocatedBindable::getType would be better... - InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, toCreate->getName().c_str(), toCreate->getType(), toCreate->getType(), 0, 0, (LPARAM) newNt, father, lastSon); + InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, utf8ToTStr(toCreate->getName()), toCreate->getType(), toCreate->getType(), 0, 0, (LPARAM) newNt, father, lastSon); touchPSState(nt); Invalidate(); _ParticleDlg->StartStopDlg->resetAutoCount(getOwnerNode(nt)); @@ -1284,7 +1280,7 @@ std::pair CParticleTreeCtrl::createL CNodeType *newNt = new CNodeType(loc); _NodeTypes.push_back(newNt); // insert item in tree - HTREEITEM insertedItem = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, name.c_str(), PSIconLocated, PSIconLocated, 0, 0, (LPARAM) newNt, headItem, TVI_LAST); + HTREEITEM insertedItem = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, utf8ToTStr(name), PSIconLocated, PSIconLocated, 0, 0, (LPARAM) newNt, headItem, TVI_LAST); touchPSState(newNt); return std::make_pair(newNt, insertedItem); } @@ -1303,7 +1299,7 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) { case CNodeType::workspace: { - nt->WS->setName(std::string(info->item.pszText)); + nt->WS->setName(tStrToUtf8(info->item.pszText)); workspaceModifiedFlagChanged(*nt->WS); // change name (this may be called twice because of the modification callback, but this doesn't matter) } break; @@ -1315,10 +1311,10 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) } else { - nt->PS->getPSPointer()->setName(std::string(info->item.pszText)); + nt->PS->getPSPointer()->setName(tStrToUtf8(info->item.pszText)); nt->PS->setModified(true); } - this->SetItemText(info->item.hItem, computeCaption(*nt->PS).c_str()); + this->SetItemText(info->item.hItem, utf8ToTStr(computeCaption(*nt->PS))); } break; case CNodeType::located: @@ -1326,7 +1322,7 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) nlassert(getOwnerNode(nt)); getOwnerNode(nt)->setModified(true); this->SetItemText(info->item.hItem, info->item.pszText); - nt->Loc->setName(std::string(info->item.pszText)); + nt->Loc->setName(tStrToUtf8(info->item.pszText)); } break; case CNodeType::locatedBindable: @@ -1334,7 +1330,7 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) nlassert(getOwnerNode(nt)); getOwnerNode(nt)->setModified(true); this->SetItemText(info->item.hItem, info->item.pszText); - nt->Bind->setName(std::string(info->item.pszText)); + nt->Bind->setName(tStrToUtf8(info->item.pszText)); } break; } @@ -1470,7 +1466,7 @@ void CParticleTreeCtrl::updateCaption(CParticleWorkspace::CNode &node) HTREEITEM item = getTreeItem(&node); if (!item) return; // update name of ps to dipslay a star in front of it (this tells that the ps has been modified) - SetItemText(item, computeCaption(node).c_str()); + SetItemText(item, utf8ToTStr(computeCaption(node))); } //**************************************************************************************************************** @@ -1528,11 +1524,13 @@ std::string CParticleTreeCtrl::computeCaption(CParticleWorkspace &workspace) //**************************************************************************************************************** void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws) { - static const char BASED_CODE szFilter[] = "NeL Particle systems (*.ps)|*.ps||"; - CFileDialog fd(TRUE, ".ps", "*.ps", OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST, szFilter, this); + static const TCHAR BASED_CODE szFilter[] = _T("NeL Particle systems (*.ps)|*.ps||"); + CFileDialog fd(TRUE, _T(".ps"), _T("*.ps"), OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST, szFilter, this); + const uint MAX_NUM_CHAR = 65536; - char filenamesBuf[MAX_NUM_CHAR]; - strcpy(filenamesBuf, "*.ps"); + TCHAR filenamesBuf[MAX_NUM_CHAR]; + _tcscpy_s(filenamesBuf, MAX_NUM_CHAR, _T("*.ps")); + fd.m_ofn.lpstrFile = filenamesBuf; fd.m_ofn.nMaxFile = MAX_NUM_CHAR - 1; if (fd.DoModal() == IDOK) @@ -1547,7 +1545,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws) while (pos) { CString path = fd.GetNextPathName(pos); - CParticleWorkspace::CNode *node = pws.addNode((LPCTSTR) path); + CParticleWorkspace::CNode *node = pws.addNode(tStrToUtf8(path)); if (!node) { if (diplayNodeAlreadyInserted) @@ -1560,7 +1558,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws) } else { - MessageBox(NLMISC::CFile::getFilename((LPCTSTR)path).c_str() + getStrRsc(IDS_PS_ALREADY_INSERTED), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION); + MessageBox(CString(utf8ToTStr(NLMISC::CFile::getFilename(tStrToUtf8(path)))) + getStrRsc(IDS_PS_ALREADY_INSERTED), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION); } } continue; @@ -1595,7 +1593,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws) } } // update modified state - SetItemText(GetRootItem(), computeCaption(pws).c_str()); + SetItemText(GetRootItem(), utf8ToTStr(computeCaption(pws))); } } @@ -1738,29 +1736,29 @@ void CParticleTreeCtrl::OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult) switch (nt->Type) { case CNodeType::workspace: - pEdit->SetWindowText(nt->WS->getName().c_str()); + pEdit->SetWindowText(utf8ToTStr(nt->WS->getName())); break; case CNodeType::particleSystem: { if (!nt->PS->isLoaded()) { - pEdit->SetWindowText(""); + pEdit->SetWindowText(_T("")); //localizedMessageBox(*this, IDS_CANT_CHANGE_PS_NAME, IDS_ERROR, MB_OK|MB_ICONEXCLAMATION); } else { - pEdit->SetWindowText(nt->PS->getPSPointer()->getName().c_str()); + pEdit->SetWindowText(utf8ToTStr(nt->PS->getPSPointer()->getName())); } } break; case CNodeType::located: { - pEdit->SetWindowText(nt->Loc->getName().c_str()); + pEdit->SetWindowText(utf8ToTStr(nt->Loc->getName())); } break; case CNodeType::locatedBindable: { - pEdit->SetWindowText(nt->Bind->getName().c_str()); + pEdit->SetWindowText(utf8ToTStr(nt->Bind->getName())); } break; } @@ -1857,10 +1855,10 @@ void CParticleTreeCtrl::updateAllCaptions() switch(nt->Type) { case CNodeType::particleSystem: - SetItemText(curr, computeCaption(*nt->PS).c_str()); + SetItemText(curr, utf8ToTStr(computeCaption(*nt->PS))); break; case CNodeType::workspace: - SetItemText(curr, computeCaption(*nt->WS).c_str()); + SetItemText(curr, utf8ToTStr(computeCaption(*nt->WS))); break; case CNodeType::located: case CNodeType::locatedBindable: diff --git a/code/nel/tools/3d/object_viewer/particle_tree_ctrl.h b/code/nel/tools/3d/object_viewer/particle_tree_ctrl.h index fa3cafd1f..4f92adc34 100644 --- a/code/nel/tools/3d/object_viewer/particle_tree_ctrl.h +++ b/code/nel/tools/3d/object_viewer/particle_tree_ctrl.h @@ -182,8 +182,8 @@ private: // Matching infos for each nodes in the CTreeCtrl std::vector _NodeTypes; // - std::auto_ptr _LocatedCopy; - std::auto_ptr _LocatedBindableCopy; + CUniquePtr _LocatedCopy; + CUniquePtr _LocatedBindableCopy; // DECLARE_MESSAGE_MAP() // from CParticleWorkspace::IModificationCallback diff --git a/code/nel/tools/3d/object_viewer/particle_workspace.cpp b/code/nel/tools/3d/object_viewer/particle_workspace.cpp index e5823d178..43be30812 100644 --- a/code/nel/tools/3d/object_viewer/particle_workspace.cpp +++ b/code/nel/tools/3d/object_viewer/particle_workspace.cpp @@ -100,8 +100,8 @@ void CParticleWorkspace::CNode::stickPSToSkeleton(NL3D::CSkeletonModel *skel, void CParticleWorkspace::CNode::unstickPSFromSkeleton() { nlassert(_WS); - _ParentSkelName = ""; - _ParentBoneName = ""; + _ParentSkelName.clear(); + _ParentBoneName.clear(); if (!_PSM) return; if (_ParentSkel) { @@ -202,7 +202,7 @@ void CParticleWorkspace::CNode::createEmptyPS() NL3D::CParticleSystem emptyPS; NL3D::CParticleSystemShape *pss = new NL3D::CParticleSystemShape; pss->buildFromPS(emptyPS); - std::auto_ptr sb(new NL3D::CShapeBank); + CUniquePtr sb(new NL3D::CShapeBank); std::string shapeName = NLMISC::CFile::getFilename(_RelativePath); sb->add(shapeName, pss); NL3D::CShapeBank *oldSB = NL3D::CNELU::Scene->getShapeBank(); @@ -260,7 +260,7 @@ void CParticleWorkspace::CNode::savePS() //*********************************************************************************************** -void CParticleWorkspace::CNode::savePSAs(const std::string &fullPath) throw(NLMISC::EStream) +void CParticleWorkspace::CNode::savePSAs(const std::string &fullPath) { nlassert(_WS); if (!_PS) return; @@ -276,16 +276,7 @@ void CParticleWorkspace::CNode::savePSAs(const std::string &fullPath) throw(NLMI std::string CParticleWorkspace::CNode::getFullPath() const { nlassert(_WS); - char fullPath[MAX_PATH]; - std::string basePath = NLMISC::CPath::standardizeDosPath(_WS->getPath()); - if (PathCombine(fullPath, basePath.c_str(), _RelativePath.c_str())) - { - return fullPath; - } - else - { - return _RelativePath.c_str(); - } + return NLMISC::CPath::makePathAbsolute(_RelativePath, _WS->getPath(), true); } //*********************************************************************************************** @@ -298,7 +289,7 @@ bool CParticleWorkspace::CNode::loadPS() // collapse name inputFile.open(getFullPath()); ss.serial(inputFile); - std::auto_ptr sb(new NL3D::CShapeBank); + CUniquePtr sb(new NL3D::CShapeBank); std::string shapeName = NLMISC::CFile::getFilename(_RelativePath); sb->add(shapeName, ss.getShapePointer()); NL3D::CShapeBank *oldSB = NL3D::CNELU::Scene->getShapeBank(); @@ -374,18 +365,21 @@ CParticleWorkspace::CNode *CParticleWorkspace::addNode(const std::string &filena for(uint k = 0; k < _Nodes.size(); ++k) { if (NLMISC::nlstricmp(_Nodes[k]->getFilename(), fileName) == 0) return NULL; - } - char resultPath[MAX_PATH]; + } + + // TODO: replace with NeL methods + TCHAR resultPath[MAX_PATH]; std::string dosPath = NLMISC::CPath::standardizeDosPath(getPath()); std::string relativePath; - if (!PathRelativePathTo(resultPath, dosPath.c_str(), FILE_ATTRIBUTE_DIRECTORY, filenameWithFullPath.c_str(), 0)) + if (!PathRelativePathTo(resultPath, utf8ToTStr(dosPath), FILE_ATTRIBUTE_DIRECTORY, utf8ToTStr(filenameWithFullPath), 0)) { relativePath = filenameWithFullPath; } else { - relativePath = resultPath; + relativePath = tStrToUtf8(resultPath); } + if (relativePath.size() >= 2) { if (relativePath[0] == '\\' && relativePath[1] != '\\') @@ -393,6 +387,7 @@ CParticleWorkspace::CNode *CParticleWorkspace::addNode(const std::string &filena relativePath = relativePath.substr(1); } } + CNode *newNode = new CNode; newNode->init(this); newNode->setRelativePath(relativePath); @@ -420,7 +415,7 @@ void CParticleWorkspace::removeNode(CNode *ptr) } //*********************************************************************************************** -void CParticleWorkspace::save() throw(NLMISC::EStream) +void CParticleWorkspace::save() { NLMISC::COFile stream; stream.open(_Filename); @@ -442,7 +437,7 @@ void CParticleWorkspace::load() } //*********************************************************************************************** -void CParticleWorkspace::serial(NLMISC::IStream &f) throw(NLMISC::EStream) +void CParticleWorkspace::serial(NLMISC::IStream &f) { f.xmlPush("PARTICLE_WORKSPACE"); f.serialVersion(0); diff --git a/code/nel/tools/3d/object_viewer/particle_workspace.h b/code/nel/tools/3d/object_viewer/particle_workspace.h index fb94b2e15..694aab986 100644 --- a/code/nel/tools/3d/object_viewer/particle_workspace.h +++ b/code/nel/tools/3d/object_viewer/particle_workspace.h @@ -60,15 +60,15 @@ public: // Serial node information into workspace stream. This does not save the particle system shape, only a reference to its file void serial(NLMISC::IStream &f); // Save the particle system target file - void savePS() throw(NLMISC::EStream); + void savePS(); // Save particle system with an arbitrary filename - void savePSAs(const std::string &fullPath) throw(NLMISC::EStream); + void savePSAs(const std::string &fullPath); // put back in the unloaded state void unload(); /** Load the particle system target file * \return true if loading succeed (false means that loading was ok, but this is not a particle system). Other cases throw an exception. */ - bool loadPS() throw(NLMISC::EStream); + bool loadPS(); // create an empty particle system void createEmptyPS(); // helper flag to know if a ps has been modified @@ -196,11 +196,11 @@ public: /** Save the workspace structure. The target file is the one given when this object was created * NB : ps shape are not saved, only the structure is. To save the shapes, call CNode::save() */ - void save() throw(NLMISC::EStream); + void save(); /** Load the workspace structure. The target file is the one given when this object was created * All nodes are in the 'unloaded" state, so it is to the caller to load them by calling load() on their node */ - void load() throw(NLMISC::EStream); + void load(); // Test whether the structure of the workspace has been modified (does not test if ps inside the workspace have been modified) bool isModified() const { return _Modified; } // Test whether the content of the workspace has ben modified @@ -229,7 +229,7 @@ private: std::string _Name; // workspace user name private: // serial the object - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); // set the 'modified flag' and call the callback void setModifiedFlag(bool modified); public: diff --git a/code/nel/tools/3d/object_viewer/pick_sound.cpp b/code/nel/tools/3d/object_viewer/pick_sound.cpp index 280a65326..0e6c175d0 100644 --- a/code/nel/tools/3d/object_viewer/pick_sound.cpp +++ b/code/nel/tools/3d/object_viewer/pick_sound.cpp @@ -74,7 +74,7 @@ BOOL CPickSound::OnInitDialog() for (TNameVect::iterator it = _Names.begin(); it != _Names.end(); ++it) { - m_NameList.AddString((*it).toString().c_str()); + m_NameList.AddString(utf8ToTStr((*it).toString())); } _Timer = SetTimer (1, 100, NULL); @@ -107,11 +107,11 @@ BOOL CPickSound::OnInitDialog() void CPickSound::OnSelchange() { UpdateData(); - char str[1024]; + TCHAR str[1024]; nlassert(m_NameList.GetTextLen(m_NameList.GetCurSel()) < 1024); m_NameList.GetText(m_NameList.GetCurSel(), str); - _CurrName = NLMISC::CSheetId(str, "sound"); + _CurrName = NLMISC::CSheetId(tStrToUtf8(str), "sound"); } @@ -123,7 +123,7 @@ void CPickSound::OnPlaySound() stopCurrSource(); CString sName; m_NameList.GetText(curSel, sName); - CSoundSystem::create(std::string( (LPCTSTR) sName)); + CSoundSystem::create(tStrToUtf8(sName)); } //======================================================================================== @@ -159,7 +159,7 @@ void CPickSound::OnDblclkList() stopCurrSource(); CString sName; m_NameList.GetText(curSel, sName); - _CurrSource = CSoundSystem::create(std::string( (LPCTSTR) sName)); + _CurrSource = CSoundSystem::create(tStrToUtf8(sName)); } //======================================================================================== diff --git a/code/nel/tools/3d/object_viewer/precomputed_rotations_dlg.cpp b/code/nel/tools/3d/object_viewer/precomputed_rotations_dlg.cpp index 21a1a2fac..4f1374eb2 100644 --- a/code/nel/tools/3d/object_viewer/precomputed_rotations_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/precomputed_rotations_dlg.cpp @@ -85,7 +85,9 @@ void CPrecomputedRotationsDlg::updateFromReader(void) } else { - m_NbModels = m_RotSpeedMin = m_RotSpeedMax = ""; + m_NbModels.Empty(); + m_RotSpeedMin.Empty(); + m_RotSpeedMax.Empty(); } UpdateData(FALSE); @@ -124,7 +126,7 @@ void CPrecomputedRotationsDlg::OnUpdateMinRotSpeed() nlassert(_RotatedParticle); UpdateData(); float newValue, valueMin, valueMax; - if (sscanf(m_RotSpeedMin, "%f", &newValue) == 1) + if (NLMISC::fromString(tStrToUtf8(m_RotSpeedMin), newValue)) { uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax); valueMin = newValue; @@ -133,7 +135,7 @@ void CPrecomputedRotationsDlg::OnUpdateMinRotSpeed() } else { - MessageBox("invalid value !!"); + MessageBox(_T("invalid value !!")); } UpdateData(FALSE); updateModifiedFlag(); @@ -144,7 +146,7 @@ void CPrecomputedRotationsDlg::OnUpdateMaxRotSpeed() nlassert(_RotatedParticle); UpdateData(); float newValue, valueMin, valueMax; - if (sscanf(m_RotSpeedMax, "%f", &newValue) == 1) + if (NLMISC::fromString(tStrToUtf8(m_RotSpeedMax), newValue)) { uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax); valueMax = newValue; @@ -153,7 +155,7 @@ void CPrecomputedRotationsDlg::OnUpdateMaxRotSpeed() } else { - MessageBox("invalid value !!"); + MessageBox(_T("invalid value !!")); } UpdateData(FALSE); updateModifiedFlag(); @@ -165,7 +167,7 @@ void CPrecomputedRotationsDlg::OnUpdateNbModels() UpdateData(); float valueMin, valueMax; sint32 newNbModels; - bool valid = (sscanf(m_NbModels, "%d", &newNbModels) == 1 && newNbModels > 0); + bool valid = (NLMISC::fromString(tStrToUtf8(m_NbModels), newNbModels) && newNbModels > 0); if (dynamic_cast(_RotatedParticle)) { valid &= (newNbModels < NL3D::ConstraintMeshMaxNumPrerotatedModels); @@ -178,7 +180,7 @@ void CPrecomputedRotationsDlg::OnUpdateNbModels() } else { - MessageBox("invalid value !!"); + MessageBox(_T("invalid value !!")); } UpdateData(FALSE); updateModifiedFlag(); diff --git a/code/nel/tools/3d/object_viewer/ps_mover_dlg.cpp b/code/nel/tools/3d/object_viewer/ps_mover_dlg.cpp index dce09b3dc..cdd88ea70 100644 --- a/code/nel/tools/3d/object_viewer/ps_mover_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/ps_mover_dlg.cpp @@ -46,9 +46,9 @@ CPSMoverDlg::CPSMoverDlg(CParticleWorkspace::CNode *ownerNode, CWnd *parent, NL3 const NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex]; - m_X.Format("%.3g", pos.x); - m_Y.Format("%.3g", pos.y); - m_Z.Format("%.3g", pos.z); + m_X.Format(_T("%.3g"), pos.x); + m_Y.Format(_T("%.3g"), pos.y); + m_Z.Format(_T("%.3g"), pos.z); //{{AFX_DATA_INIT(CPSMoverDlg) //}}AFX_DATA_INIT @@ -84,9 +84,9 @@ void CPSMoverDlg::updatePosition(void) UpdateData(); const NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex]; - m_X.Format("%.3g", pos.x); - m_Y.Format("%.3g", pos.y); - m_Z.Format("%.3g", pos.z); + m_X.Format(_T("%.3g"), pos.x); + m_Y.Format(_T("%.3g"), pos.y); + m_Z.Format(_T("%.3g"), pos.z); UpdateData(FALSE); } @@ -120,14 +120,14 @@ void CPSMoverDlg::OnUpdateXpos() UpdateData(); NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex]; float x; - if (::sscanf(m_X, "%f", &x) == 1) + if (NLMISC::fromString(tStrToUtf8(m_X), x)) { pos.x = x; updateListener(); } else { - MessageBox("invalid entry", "error"); + MessageBox(_T("invalid entry"), _T("error")); } UpdateData(FALSE); } @@ -137,14 +137,14 @@ void CPSMoverDlg::OnUpdateYpos() UpdateData(); NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex]; float y; - if (::sscanf(m_Y, "%f", &y) == 1) + if (NLMISC::fromString(tStrToUtf8(m_Y), y)) { pos.y = y; updateListener(); } else { - MessageBox("invalid entry", "error"); + MessageBox(_T("invalid entry"), _T("error")); } UpdateData(FALSE); } @@ -154,14 +154,14 @@ void CPSMoverDlg::OnUpdateZpos() UpdateData(); NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex]; float z; - if (::sscanf(m_Z, "%f", &z) == 1) + if (NLMISC::fromString(tStrToUtf8(m_Z), z)) { pos.z = z; updateListener(); } else { - MessageBox("invalid entry", "error"); + MessageBox(_T("invalid entry"), _T("error")); } UpdateData(FALSE); } @@ -178,8 +178,8 @@ BOOL CPSMoverDlg::OnInitDialog() { if (dynamic_cast(_EditedLocated->getBoundObject(k))) { - uint insertedLine = m_SubComponentCtrl.AddString(_EditedLocated->getBoundObject(k)->getName().c_str()); - m_SubComponentCtrl.SetItemData(insertedLine, (DWORD) _EditedLocated->getBoundObject(k)); + uint insertedLine = m_SubComponentCtrl.AddString(utf8ToTStr(_EditedLocated->getBoundObject(k)->getName())); + m_SubComponentCtrl.SetItemData(insertedLine, (DWORD_PTR) _EditedLocated->getBoundObject(k)); ++nbCandidates; } } @@ -235,7 +235,7 @@ void CPSMoverDlg::createScaleControls(void) _Scale->init(100 + xPos, yPos, this); _ScaleText = new CStatic; - _ScaleText ->Create("Scale : ", SS_LEFT, CRect(xPos, yPos + 10, xPos + 60, yPos + 32), this); + _ScaleText ->Create(_T("Scale : "), SS_LEFT, CRect(xPos, yPos + 10, xPos + 60, yPos + 32), this); _ScaleText ->ShowWindow(SW_SHOW); _Scale->GetClientRect(&r); @@ -254,7 +254,7 @@ void CPSMoverDlg::createScaleControls(void) _XScale->GetClientRect(&r); _XScaleText = new CStatic; - _XScaleText ->Create("x Scale : ", SS_LEFT, CRect(xPos, yPos + 10, xPos + 60, yPos + 32), this); + _XScaleText ->Create(_T("x Scale : "), SS_LEFT, CRect(xPos, yPos + 10, xPos + 60, yPos + 32), this); _XScaleText ->ShowWindow(SW_SHOW); yPos += r.bottom; @@ -269,7 +269,7 @@ void CPSMoverDlg::createScaleControls(void) _YScaleText = new CStatic; - _YScaleText ->Create("y Scale : ", SS_LEFT, CRect(xPos, yPos + 10, xPos + 60, yPos + 32), this); + _YScaleText ->Create(_T("y Scale : "), SS_LEFT, CRect(xPos, yPos + 10, xPos + 60, yPos + 32), this); _YScaleText ->ShowWindow(SW_SHOW); yPos += r.bottom; @@ -283,7 +283,7 @@ void CPSMoverDlg::createScaleControls(void) _ZScale->GetClientRect(&r); _ZScaleText = new CStatic; - _ZScaleText ->Create("z Scale : ", SS_LEFT, CRect(xPos, yPos + 10, xPos + 60, yPos + 32), this); + _ZScaleText ->Create(_T("z Scale : "), SS_LEFT, CRect(xPos, yPos + 10, xPos + 60, yPos + 32), this); _ZScaleText ->ShowWindow(SW_SHOW); } diff --git a/code/nel/tools/3d/object_viewer/range_manager.h b/code/nel/tools/3d/object_viewer/range_manager.h index 2bdac5189..338578ce4 100644 --- a/code/nel/tools/3d/object_viewer/range_manager.h +++ b/code/nel/tools/3d/object_viewer/range_manager.h @@ -62,7 +62,7 @@ public: } /// serialization - static void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + static void serial(NLMISC::IStream &f) { uint32 size; if (!f.isReading()) diff --git a/code/nel/tools/3d/object_viewer/range_selector.cpp b/code/nel/tools/3d/object_viewer/range_selector.cpp index dca002b13..d809c7d11 100644 --- a/code/nel/tools/3d/object_viewer/range_selector.cpp +++ b/code/nel/tools/3d/object_viewer/range_selector.cpp @@ -32,8 +32,8 @@ CRangeSelector::CRangeSelector(const CString &lowerBound, const CString &upperBo : CDialog(CRangeSelector::IDD, pParent), _EditableRange(er) { //{{AFX_DATA_INIT(CRangeSelector) - m_LowerBound = _T(lowerBound); - m_UpperBound = _T(upperBound); + m_LowerBound = lowerBound; + m_UpperBound = upperBound; //}}AFX_DATA_INIT } diff --git a/code/nel/tools/3d/object_viewer/scheme_bank_dlg.cpp b/code/nel/tools/3d/object_viewer/scheme_bank_dlg.cpp index 65d1b8205..2db27bc35 100644 --- a/code/nel/tools/3d/object_viewer/scheme_bank_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/scheme_bank_dlg.cpp @@ -84,8 +84,8 @@ void CSchemeBankDlg::buildList() SchemeManager.getSchemes(_Type, schemes); for (TSchemeVect::const_iterator it = schemes.begin(); it != schemes.end(); ++it) { - int index = m_SchemeList.AddString(it->first.c_str()); - m_SchemeList.SetItemData(index, (unsigned long) it->second); + int index = m_SchemeList.AddString(utf8ToTStr(it->first)); + m_SchemeList.SetItemData(index, (DWORD_PTR) it->second); } UpdateData(FALSE); @@ -93,30 +93,24 @@ void CSchemeBankDlg::buildList() void CSchemeBankDlg::OnSaveBank() { - static char BASED_CODE szFilter[] = "scheme bank files(*.scb)|*.scb||"; - CFileDialog fd( FALSE, NULL, "default.scb", 0, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("scheme bank files(*.scb)|*.scb||"); + CFileDialog fd( FALSE, NULL, _T("default.scb"), 0, szFilter); if (fd.DoModal() == IDOK) { - // Add to the path - char drive[256]; - char dir[256]; - char path[256]; - // Add search path for the texture - _splitpath (fd.GetPathName(), drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()))); try { NLMISC::COFile iF; - iF.open(std::string( (LPCTSTR) fd.GetFileName())); + iF.open(tStrToUtf8(fd.GetFileName())); iF.serial(SchemeManager); } - catch (std::exception &e) + catch (const std::exception &e) { - MessageBox(("Error saving scheme bank :" + std::string(e.what())).c_str(), "Object viewer", MB_ICONEXCLAMATION | MB_OK); + std::string message = NLMISC::toString("Error saving scheme bank : %s", e.what()); + MessageBox(utf8ToTStr(message), _T("Object viewer"), MB_ICONEXCLAMATION | MB_OK); return; } } @@ -124,32 +118,26 @@ void CSchemeBankDlg::OnSaveBank() void CSchemeBankDlg::OnLoadBank() { - static char BASED_CODE szFilter[] = "scheme bank files(*.scb)|*.scb||"; - CFileDialog fd( TRUE, NULL, "*.scb", 0, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("scheme bank files(*.scb)|*.scb||"); + CFileDialog fd( TRUE, NULL, _T("*.scb"), 0, szFilter); if (fd.DoModal() == IDOK) { - // Add to the path - char drive[256]; - char dir[256]; - char path[256]; - // Add search path for the texture - _splitpath (fd.GetPathName(), drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath(NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()))); CSchemeManager sm; try { NLMISC::CIFile iF; - iF.open(NLMISC::CPath::lookup(std::string((LPCTSTR) fd.GetFileName()))); + iF.open(NLMISC::CPath::lookup(tStrToUtf8(fd.GetFileName()))); iF.serial(sm); SchemeManager.swap(sm); } - catch (std::exception &e) + catch (const std::exception &e) { - MessageBox(("Error loading scheme bank :" + std::string(e.what())).c_str(), "Object viewer", MB_ICONEXCLAMATION | MB_OK); + std::string message = NLMISC::toString("Error loading scheme bank : %s", e.what()); + MessageBox(utf8ToTStr(message), _T("Object viewer"), MB_ICONEXCLAMATION | MB_OK); return; } buildList(); @@ -179,7 +167,7 @@ void CSchemeBankDlg::OnRename() SchemeManager.rename(scheme, cn.getName()); int curSel = m_SchemeList.GetCurSel(); m_SchemeList.DeleteString(curSel); - int insertedPos = m_SchemeList.InsertString(curSel, cn.getName().c_str()); + int insertedPos = m_SchemeList.InsertString(curSel, utf8ToTStr(cn.getName())); m_SchemeList.SetCurSel(insertedPos); m_SchemeList.Invalidate(); } diff --git a/code/nel/tools/3d/object_viewer/scheme_manager.cpp b/code/nel/tools/3d/object_viewer/scheme_manager.cpp index e7f93b589..7c3d7a3ec 100644 --- a/code/nel/tools/3d/object_viewer/scheme_manager.cpp +++ b/code/nel/tools/3d/object_viewer/scheme_manager.cpp @@ -47,7 +47,7 @@ void CSchemeManager::getSchemes(const std::string &type, std::vector &dest); // serial this collection - void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serial(NLMISC::IStream &f); // swap this collection with another one void swap(CSchemeManager &other); // remove a scheme from the bank, given a pointer on it diff --git a/code/nel/tools/3d/object_viewer/select_string.cpp b/code/nel/tools/3d/object_viewer/select_string.cpp index 4ff61c23b..f506d905b 100644 --- a/code/nel/tools/3d/object_viewer/select_string.cpp +++ b/code/nel/tools/3d/object_viewer/select_string.cpp @@ -23,7 +23,7 @@ // CSelectString dialog -CSelectString::CSelectString(const std::vector& vectString, const char* title, CWnd* pParent, bool empty) +CSelectString::CSelectString(const std::vector& vectString, const std::string &title, CWnd* pParent, bool empty) : CDialog(CSelectString::IDD, pParent) { //{{AFX_DATA_INIT(CSelectString) @@ -77,14 +77,14 @@ BOOL CSelectString::OnInitDialog() CDialog::OnInitDialog(); // Change title - SetWindowText (Title.c_str()); + SetWindowText (utf8ToTStr(Title)); // Empty button ? EmptyCtrl.ShowWindow (Empty?SW_SHOW:SW_HIDE); // Add string for (uint s=0; s& vectString, const char* title, CWnd* pParent, bool empty); // standard constructor + CSelectString(const std::vector& vectString, const std::string &title, CWnd* pParent, bool empty); // standard constructor // Dialog Data //{{AFX_DATA(CSelectString) diff --git a/code/nel/tools/3d/object_viewer/skeleton_scale_dlg.cpp b/code/nel/tools/3d/object_viewer/skeleton_scale_dlg.cpp index 75e20064f..f54c723df 100644 --- a/code/nel/tools/3d/object_viewer/skeleton_scale_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/skeleton_scale_dlg.cpp @@ -199,14 +199,17 @@ void CSkeletonScaleDlg::setSkeletonToEdit(NL3D::CSkeletonModel *skel, const std { for(uint i=0;i<_SkeletonModel->Bones.size();i++) { - const std::string tabStr= " "; - std::string name= _SkeletonModel->Bones[i].getBoneName(); + const std::string tabStr = " "; + std::string name = _SkeletonModel->Bones[i].getBoneName(); + // append a tab for easy hierarchy - uint boneId= i; + uint boneId = i; + while((boneId=_SkeletonModel->Bones[boneId].getFatherId())!=-1) - name= tabStr + name; + name = tabStr + name; + // append to the list - _BoneList.AddString(name.c_str()); + _BoneList.AddString(utf8ToTStr(name)); } } @@ -216,8 +219,8 @@ void CSkeletonScaleDlg::setSkeletonToEdit(NL3D::CSkeletonModel *skel, const std { _ScaleSliders[i]->SetRange(0, NL_SSD_SLIDER_SIZE); _ScaleSliders[i]->SetPos(NL_SSD_SLIDER_SIZE/2); - *_ScaleEdits[i]= ""; - _StaticScaleMarkers[i]->SetWindowText("100%"); + _ScaleEdits[i]->Empty(); + _StaticScaleMarkers[i]->SetWindowText(_T("100%")); } // ensure no problem with scale and ALT-TAB _SliderEdited= SidNone; @@ -338,7 +341,7 @@ void CSkeletonScaleDlg::onSliderReleased(TScaleId sid) // And reset the slider _ScaleSliders[_SliderEdited]->SetPos(NL_SSD_SLIDER_SIZE/2); - _StaticScaleMarkers[_SliderEdited]->SetWindowText("100%"); + _StaticScaleMarkers[_SliderEdited]->SetWindowText(_T("100%")); _SliderEdited= SidNone; // push an undo/redo only at release of slide. push the value of scale before slide @@ -400,9 +403,8 @@ void CSkeletonScaleDlg::applyScaleSlider(sint scrollValue) refreshTextViews(); // update marker text - char str[256]; - sprintf(str, "%d%%", (sint)(factor*100)); - _StaticScaleMarkers[_SliderEdited]->SetWindowText(str); + std::string str = NLMISC::toString("%d%%", (sint)(factor*100)); + _StaticScaleMarkers[_SliderEdited]->SetWindowText(utf8ToTStr(str)); } // *************************************************************************** @@ -503,7 +505,7 @@ void CSkeletonScaleDlg::refreshTextViewWithScale(TScaleId sid, float scale, flo // if different values selected, diff if(diff) { - *_ScaleEdits[sid]= ""; + _ScaleEdits[sid]->Empty(); } // else display text else @@ -592,12 +594,12 @@ static void concatEdit2Lines(CEdit &edit) const uint lineLen= 1000; uint n; // retrieve the 2 lines. - char tmp0[2*lineLen]; - char tmp1[lineLen]; + TCHAR tmp0[2*lineLen]; + TCHAR tmp1[lineLen]; n= edit.GetLine(0, tmp0, lineLen); tmp0[n]= 0; n= edit.GetLine(1, tmp1, lineLen); tmp1[n]= 0; // concat and update the CEdit. - edit.SetWindowText(strcat(tmp0, tmp1)); + edit.SetWindowText(_tcscat(tmp0, tmp1)); } @@ -715,7 +717,7 @@ void CSkeletonScaleDlg::updateScalesFromText(UINT ctrlId) return; // get the scale info - std::string str= (const char*)(*_ScaleEdits[sid]); + std::string str = tStrToUtf8(*_ScaleEdits[sid]); if(str.empty()) return; float f; @@ -833,7 +835,7 @@ void CSkeletonScaleDlg::OnSsdButtonSave() } else { - MessageBox("Failed to open file for write!"); + MessageBox(_T("Failed to open file for write!")); } } @@ -844,13 +846,13 @@ void CSkeletonScaleDlg::OnSsdButtonSaveas() return; // choose the file - CFileDialog fd(FALSE, "skel", _SkeletonFileName.c_str(), OFN_OVERWRITEPROMPT, "SkelFiles (*.skel)|*.skel|All Files (*.*)|*.*||", this) ; - fd.m_ofn.lpstrTitle= "Save As Skeleton"; + CFileDialog fd(FALSE, _T("skel"), utf8ToTStr(_SkeletonFileName), OFN_OVERWRITEPROMPT, _T("SkelFiles (*.skel)|*.skel|All Files (*.*)|*.*||"), this) ; + fd.m_ofn.lpstrTitle = _T("Save As Skeleton"); if (fd.DoModal() == IDOK) { NLMISC::COFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { if(saveCurrentInStream(f)) { @@ -860,13 +862,13 @@ void CSkeletonScaleDlg::OnSsdButtonSaveas() } // bkup the valid fileName (new file edited) - _SkeletonFileName= (const char*)fd.GetPathName(); + _SkeletonFileName= tStrToUtf8(fd.GetPathName()); _StaticFileName= _SkeletonFileName.c_str(); UpdateData(FALSE); } else { - MessageBox("Failed to open file for write!"); + MessageBox(_T("Failed to open file for write!")); } } } @@ -905,9 +907,9 @@ bool CSkeletonScaleDlg::saveCurrentInStream(NLMISC::IStream &f) ss.serial(f); delete skelShape; } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { - MessageBox("Failed to save file!"); + MessageBox(_T("Failed to save file!")); return false; } @@ -1223,20 +1225,22 @@ void CSkeletonScaleDlg::OnSsdButtonSaveScale() return; // choose the file - std::string defaultFileName= _SkeletonFileName; + std::string defaultFileName = _SkeletonFileName; NLMISC::strFindReplace(defaultFileName, ".skel", ".scale"); - CFileDialog fd(FALSE, "scale", defaultFileName.c_str(), OFN_OVERWRITEPROMPT, "SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||", this) ; - fd.m_ofn.lpstrTitle= "Save As Skeleton Scale File"; + + CFileDialog fd(FALSE, _T("scale"), utf8ToTStr(defaultFileName), OFN_OVERWRITEPROMPT, _T("SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||"), this) ; + fd.m_ofn.lpstrTitle = _T("Save As Skeleton Scale File"); + if (fd.DoModal() == IDOK) { NLMISC::COFile f; - if( f.open((const char*)fd.GetPathName()) ) + if (f.open(tStrToUtf8(fd.GetPathName()))) { saveSkelScaleInStream(f); } else { - MessageBox("Failed to open file for write!"); + MessageBox(_T("Failed to open file for write!")); } } } @@ -1251,18 +1255,20 @@ void CSkeletonScaleDlg::OnSsdButtonLoadScale() // choose the file std::string defaultFileName= _SkeletonFileName; NLMISC::strFindReplace(defaultFileName, ".skel", ".scale"); - CFileDialog fd(TRUE, "scale", defaultFileName.c_str(), 0, "SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||", this) ; - fd.m_ofn.lpstrTitle= "Load a Skeleton Scale File"; + + CFileDialog fd(TRUE, _T("scale"), utf8ToTStr(defaultFileName), 0, _T("SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||"), this) ; + fd.m_ofn.lpstrTitle= _T("Load a Skeleton Scale File"); + if (fd.DoModal() == IDOK) { NLMISC::CIFile f; - if( f.open((const char*)fd.GetPathName()) ) + if (f.open(tStrToUtf8(fd.GetPathName()))) { loadSkelScaleFromStream(f); } else { - MessageBox("Failed to open file for read!"); + MessageBox(_T("Failed to open file for read!")); } } } @@ -1307,9 +1313,9 @@ bool CSkeletonScaleDlg::saveSkelScaleInStream(NLMISC::IStream &f) sint32 ver= f.serialVersion(0); f.serialCont(boneScales); } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { - MessageBox("Failed to save file!"); + MessageBox(_T("Failed to save file!")); return false; } @@ -1353,9 +1359,9 @@ bool CSkeletonScaleDlg::loadSkelScaleFromStream(NLMISC::IStream &f) // and update display refreshTextViews(); } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { - MessageBox("Failed to save file!"); + MessageBox(_T("Failed to save file!")); return false; } diff --git a/code/nel/tools/3d/object_viewer/slot_dlg.cpp b/code/nel/tools/3d/object_viewer/slot_dlg.cpp index d6c707125..507c9b4e8 100644 --- a/code/nel/tools/3d/object_viewer/slot_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/slot_dlg.cpp @@ -420,7 +420,7 @@ void CSlotDlg::OnSetAnimation() updateScrollBar (); } else - getSlotInformation ()->Animation = ""; + getSlotInformation ()->Animation.clear(); } refresh (TRUE); } @@ -444,7 +444,7 @@ void CSlotDlg::OnSetSkeleton() if (select.Selection!=-1) getSlotInformation ()->Skeleton = vectString[select.Selection].c_str(); else - getSlotInformation ()->Skeleton = ""; + getSlotInformation ()->Skeleton.clear(); setWindowName (); Invalidate (); @@ -455,26 +455,24 @@ void CSlotDlg::OnSetSkeleton() void CSlotDlg::setWindowName () { - char tmp[512]; - _snprintf (tmp, 512, "Slot %d : ", Id); + std::string tmp = NLMISC::toString("Slot %d : ", Id); + if (isEmpty()) - strcat (tmp, "empty"); + tmp += "empty"; else - strcat (tmp, getSlotInformation ()->Animation .c_str()); + tmp += getSlotInformation ()->Animation; CSlotInfo *information = getSlotInformation (); if (information) { std::string SkeletonName = information->Skeleton; - if (SkeletonName != "") + if (!SkeletonName.empty()) { - strcat (tmp, " ("); - strcat (tmp, SkeletonName.c_str()); - strcat (tmp, ")"); + tmp += " (" + SkeletonName + ")"; } } - GetDlgItem (IDC_SLOT_NAME)->SetWindowText (tmp); + GetDlgItem (IDC_SLOT_NAME)->SetWindowText (utf8ToTStr(tmp)); } // *************************************************************************** diff --git a/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp b/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp index 0d256573c..a85b8ae9f 100644 --- a/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp @@ -42,7 +42,7 @@ -#define NEL_OV_SNAPSHOT_TOOL_REGKEY "Software\\Nevrax\\nel\\object_viewer\\snapshot_dlg" +#define NEL_OV_SNAPSHOT_TOOL_REGKEY _T("Software\\Nevrax\\nel\\object_viewer\\snapshot_dlg") using namespace NLMISC; @@ -109,30 +109,33 @@ void CSnapshotToolDlg::DoDataExchange(CDataExchange* pDX) } //**************************************************************************************** -void CSnapshotToolDlg::stringFromRegistry(HKEY hKey, const char *name, CString &dest, const CString &defaultStr) +void CSnapshotToolDlg::stringFromRegistry(HKEY hKey, const TCHAR *name, CString &dest, const CString &defaultStr) { DWORD type; DWORD size; LONG result = RegQueryValueEx(hKey, name, NULL, &type, NULL, &size); + if (type != REG_SZ || result != ERROR_SUCCESS || size == 0) { dest = defaultStr; return; } - std::string tmpDest; - tmpDest.resize(size); - result = RegQueryValueEx(hKey, name, NULL, &type, (unsigned char *) &tmpDest[0], &size); + + std::vector tmpDest(size); + result = RegQueryValueEx(hKey, name, NULL, &type, (BYTE*)&tmpDest[0], &size); + if (result != ERROR_SUCCESS) { dest = defaultStr; return; } - dest = tmpDest.c_str(); + + dest = &tmpDest[0]; } //**************************************************************************************** -template void integralTypeFromRegistry(HKEY hKey, const char *name, T &dest, const U &defaultValue) +template void integralTypeFromRegistry(HKEY hKey, const TCHAR *name, T &dest, const U &defaultValue) { if (hKey == 0) { @@ -142,18 +145,22 @@ template void integralTypeFromRegistry(HKEY hKey, const char DWORD type; DWORD size; LONG result = RegQueryValueEx(hKey, name, NULL, &type, NULL, &size); + if (type != REG_DWORD || result != ERROR_SUCCESS || size == 0) { dest = (T) defaultValue; return; } + DWORD value; result = RegQueryValueEx(hKey, name, NULL, &type, LPBYTE(&value), &size); + if (result != ERROR_SUCCESS) { dest = defaultValue; return; } + dest = (T) value; } @@ -163,32 +170,35 @@ void CSnapshotToolDlg::fromRegistry() { HKEY hKey = 0; RegOpenKeyEx(HKEY_CURRENT_USER, NEL_OV_SNAPSHOT_TOOL_REGKEY, 0, KEY_READ, &hKey); - stringFromRegistry(hKey, "InputPath", m_InputPath, ""); - stringFromRegistry(hKey, "OutputPath", m_OutputPath, ""); + stringFromRegistry(hKey, _T("InputPath"), m_InputPath, ""); + stringFromRegistry(hKey, _T("OutputPath"), m_OutputPath, ""); + CString filters; - stringFromRegistry(hKey, "Filters", filters, "*.shape"); - std::string stdFilters((LPCTSTR) filters); + stringFromRegistry(hKey, _T("Filters"), filters, "*.shape"); + std::vector filterList; - NLMISC::splitString(stdFilters, ",", filterList); + NLMISC::splitString(tStrToUtf8(filters), ",", filterList); + m_Filters.ResetContent(); + for (uint k = 0; k < filterList.size(); ++k) { - m_Filters.AddString(filterList[k].c_str()); + m_Filters.AddString(utf8ToTStr(filterList[k])); } - integralTypeFromRegistry(hKey, "RecurseSubFolder", (int &) m_RecurseSubFolder, FALSE); - integralTypeFromRegistry(hKey, "DumpTextureSets", (int &) m_DumpTextureSets, TRUE); - integralTypeFromRegistry(hKey, "PostFixViewName", (int &) m_PostFixViewName, TRUE); - integralTypeFromRegistry(hKey, "ViewBack", (int &) m_ViewBack, FALSE); - integralTypeFromRegistry(hKey, "ViewBottom", (int &) m_ViewBottom, FALSE); - integralTypeFromRegistry(hKey, "ViewFront", (int &) m_ViewFront, TRUE); - integralTypeFromRegistry(hKey, "ViewLeft", (int &) m_ViewLeft, FALSE); - integralTypeFromRegistry(hKey, "ViewRight", (int &) m_ViewRight, FALSE); - integralTypeFromRegistry(hKey, "ViewTop", (int &) m_ViewTop, FALSE); - integralTypeFromRegistry(hKey, "OutputWidth", m_OutputWidth, 128); - integralTypeFromRegistry(hKey, "OutputHeight", m_OutputHeight, 128); - integralTypeFromRegistry(hKey, "Format", m_Format, 0); - integralTypeFromRegistry(hKey, "OutputPathOption", m_OutputPathOption, 1); + integralTypeFromRegistry(hKey, _T("RecurseSubFolder"), (int &) m_RecurseSubFolder, FALSE); + integralTypeFromRegistry(hKey, _T("DumpTextureSets"), (int &) m_DumpTextureSets, TRUE); + integralTypeFromRegistry(hKey, _T("PostFixViewName"), (int &) m_PostFixViewName, TRUE); + integralTypeFromRegistry(hKey, _T("ViewBack"), (int &) m_ViewBack, FALSE); + integralTypeFromRegistry(hKey, _T("ViewBottom"), (int &) m_ViewBottom, FALSE); + integralTypeFromRegistry(hKey, _T("ViewFront"), (int &) m_ViewFront, TRUE); + integralTypeFromRegistry(hKey, _T("ViewLeft"), (int &) m_ViewLeft, FALSE); + integralTypeFromRegistry(hKey, _T("ViewRight"), (int &) m_ViewRight, FALSE); + integralTypeFromRegistry(hKey, _T("ViewTop"), (int &) m_ViewTop, FALSE); + integralTypeFromRegistry(hKey, _T("OutputWidth"), m_OutputWidth, 128); + integralTypeFromRegistry(hKey, _T("OutputHeight"), m_OutputHeight, 128); + integralTypeFromRegistry(hKey, _T("Format"), m_Format, 0); + integralTypeFromRegistry(hKey, _T("OutputPathOption"), m_OutputPathOption, 1); UpdateData(FALSE); updateUIEnabledState(); } @@ -200,8 +210,8 @@ void CSnapshotToolDlg::toRegistry() HKEY hKey; if (RegCreateKey(HKEY_CURRENT_USER, NEL_OV_SNAPSHOT_TOOL_REGKEY, &hKey)==ERROR_SUCCESS) { - RegSetValueEx(hKey, "InputPath", 0, REG_SZ, (unsigned char *) (LPCTSTR) m_InputPath, m_InputPath.GetLength() + 1); - RegSetValueEx(hKey, "OutputPath", 0, REG_SZ, (unsigned char *) (LPCTSTR) m_OutputPath, m_OutputPath.GetLength() + 1); + RegSetValueEx(hKey, _T("InputPath"), 0, REG_SZ, (BYTE*) (LPCTSTR) m_InputPath, (m_InputPath.GetLength() + 1) * sizeof(TCHAR)); + RegSetValueEx(hKey, _T("OutputPath"), 0, REG_SZ, (BYTE*) (LPCTSTR) m_OutputPath, (m_OutputPath.GetLength() + 1) * sizeof(TCHAR)); CString filters; for (uint k = 0; k < (uint) m_Filters.GetCount(); ++k) { @@ -210,36 +220,28 @@ void CSnapshotToolDlg::toRegistry() m_Filters.GetText(k, filter); filters += filter; } - RegSetValueEx(hKey, "Filters", 0, REG_SZ, (unsigned char *) (LPCTSTR) filters, filters.GetLength() + 1); + + RegSetValueEx(hKey, _T("Filters"), 0, REG_SZ, (BYTE*) (LPCTSTR) filters, (filters.GetLength() + 1) * sizeof(TCHAR)); DWORD recurseSubFolder = m_RecurseSubFolder; DWORD dumpTextureSets = m_DumpTextureSets; - DWORD views [] = - { - m_ViewBack, - m_ViewBottom, - m_ViewFront, - m_ViewLeft, - m_ViewRight, - m_ViewTop - }; DWORD width = (DWORD) m_OutputWidth; DWORD height = (DWORD) m_OutputHeight; DWORD format = m_Format; DWORD outputPathOption = m_OutputPathOption; DWORD postFixViewName = m_PostFixViewName; - integralTypeFromRegistry(hKey, "PostFixViewName", (int &) m_PostFixViewName, TRUE); - RegSetValueEx(hKey, "ViewBack", 0, REG_DWORD, (const BYTE *) &m_ViewBack, sizeof(DWORD)); - RegSetValueEx(hKey, "ViewBottom", 0, REG_DWORD, (const BYTE *) &m_ViewBottom, sizeof(DWORD)); - RegSetValueEx(hKey, "ViewFront", 0, REG_DWORD, (const BYTE *) &m_ViewFront, sizeof(DWORD)); - RegSetValueEx(hKey, "ViewLeft", 0, REG_DWORD, (const BYTE *) &m_ViewLeft, sizeof(DWORD)); - RegSetValueEx(hKey, "ViewRight", 0, REG_DWORD, (const BYTE *) &m_ViewRight, sizeof(DWORD)); - RegSetValueEx(hKey, "ViewTop", 0, REG_DWORD, (const BYTE *) &m_ViewTop, sizeof(DWORD)); - RegSetValueEx(hKey, "RecurseSubFolder", 0, REG_DWORD, (const BYTE *) &recurseSubFolder, sizeof(DWORD)); - RegSetValueEx(hKey, "DumpTextureSets", 0, REG_DWORD, (const BYTE *) &dumpTextureSets, sizeof(DWORD)); - RegSetValueEx(hKey, "OutputWidth", 0, REG_DWORD, (const BYTE *) &width, sizeof(DWORD)); - RegSetValueEx(hKey, "OutputHeight", 0, REG_DWORD, (const BYTE *) &height, sizeof(DWORD)); - RegSetValueEx(hKey, "Format", 0, REG_DWORD, (const BYTE *) &format, sizeof(DWORD)); - RegSetValueEx(hKey, "OutputPathOption", 0, REG_DWORD, (const BYTE *) &outputPathOption, sizeof(DWORD)); + integralTypeFromRegistry(hKey, _T("PostFixViewName"), (int &) m_PostFixViewName, TRUE); + RegSetValueEx(hKey, _T("ViewBack"), 0, REG_DWORD, (const BYTE *) &m_ViewBack, sizeof(DWORD)); + RegSetValueEx(hKey, _T("ViewBottom"), 0, REG_DWORD, (const BYTE *) &m_ViewBottom, sizeof(DWORD)); + RegSetValueEx(hKey, _T("ViewFront"), 0, REG_DWORD, (const BYTE *) &m_ViewFront, sizeof(DWORD)); + RegSetValueEx(hKey, _T("ViewLeft"), 0, REG_DWORD, (const BYTE *) &m_ViewLeft, sizeof(DWORD)); + RegSetValueEx(hKey, _T("ViewRight"), 0, REG_DWORD, (const BYTE *) &m_ViewRight, sizeof(DWORD)); + RegSetValueEx(hKey, _T("ViewTop"), 0, REG_DWORD, (const BYTE *) &m_ViewTop, sizeof(DWORD)); + RegSetValueEx(hKey, _T("RecurseSubFolder"), 0, REG_DWORD, (const BYTE *) &recurseSubFolder, sizeof(DWORD)); + RegSetValueEx(hKey, _T("DumpTextureSets"), 0, REG_DWORD, (const BYTE *) &dumpTextureSets, sizeof(DWORD)); + RegSetValueEx(hKey, _T("OutputWidth"), 0, REG_DWORD, (const BYTE *) &width, sizeof(DWORD)); + RegSetValueEx(hKey, _T("OutputHeight"), 0, REG_DWORD, (const BYTE *) &height, sizeof(DWORD)); + RegSetValueEx(hKey, _T("Format"), 0, REG_DWORD, (const BYTE *) &format, sizeof(DWORD)); + RegSetValueEx(hKey, _T("OutputPathOption"), 0, REG_DWORD, (const BYTE *) &outputPathOption, sizeof(DWORD)); } } @@ -403,7 +405,7 @@ void CSnapshotToolDlg::OnGo() MessageBox(getStrRsc(IDS_SNAPSHOT_EMPTY_INPUT_PATH), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION); return; } - if (!NLMISC::CFile::isDirectory(LPCTSTR(m_InputPath))) + if (!NLMISC::CFile::isDirectory(tStrToUtf8(m_InputPath))) { MessageBox(getStrRsc(IDS_SNAPSHOT_EMPTY_INPUT_PATH_NOT_FOUND), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION); return; @@ -413,20 +415,19 @@ void CSnapshotToolDlg::OnGo() MessageBox(getStrRsc(IDS_SNAPSHOT_EMPTY_OUTPUT_PATH), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION); return; } - if (m_OutputPathOption == OutputPath_Custom && !NLMISC::CFile::isDirectory(LPCTSTR(m_OutputPath))) + if (m_OutputPathOption == OutputPath_Custom && !NLMISC::CFile::isDirectory(tStrToUtf8(m_OutputPath))) { if (MessageBox(getStrRsc(IDS_SNAPSHOT_CREATE_OUTPUT_DIRECTORY), getStrRsc(IDS_OBJECT_VIEWER), MB_OKCANCEL) != IDOK) { return; } - if(!NLMISC::CFile::createDirectoryTree(LPCTSTR(m_OutputPath))) + if(!NLMISC::CFile::createDirectoryTree(tStrToUtf8(m_OutputPath))) { MessageBox(getStrRsc(IDS_SNAPSHOT_OUTPUT_PATH_CREATION_FAILED), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION); return; } } - // make sure that the screen can contains the window client area RECT desktopSize; ::GetClientRect(::GetDesktopWindow(), &desktopSize); @@ -440,7 +441,7 @@ void CSnapshotToolDlg::OnGo() m_Log.ResetContent(); m_Log.AddString(getStrRsc(IDS_GETTING_PATH_CONTENT)); std::vector files; - CPath::getPathContent((LPCTSTR) m_InputPath, m_RecurseSubFolder == TRUE, false, true, files); + CPath::getPathContent(tStrToUtf8(m_InputPath), m_RecurseSubFolder == TRUE, false, true, files); if (files.empty()) { m_Log.AddString(getStrRsc(IDS_SNAPSHOT_NO_FILES_FOUND)); @@ -454,7 +455,7 @@ void CSnapshotToolDlg::OnGo() CString wildCard; m_Filters.GetText(l, wildCard); wildCard.MakeLower(); - if (testWildCard(toLower(NLMISC::CFile::getFilename(files[k])).c_str(), (LPCTSTR) wildCard)) + if (testWildCard(toLower(NLMISC::CFile::getFilename(files[k])).c_str(), tStrToUtf8(wildCard).c_str())) { _FilteredFiles.push_back(files[k]); break; @@ -596,7 +597,7 @@ void CSnapshotToolDlg::OnTimer(UINT_PTR nIDEvent) try { CShapeStream ss; - m_Log.AddString(_FilteredFiles[0].c_str()); + m_Log.AddString(utf8ToTStr(_FilteredFiles[0])); CIFile stream(_FilteredFiles[0]); ss.serial(stream); nlassert(ss.getShapePointer()); @@ -700,24 +701,47 @@ void CSnapshotToolDlg::OnTimer(UINT_PTR nIDEvent) { outputFilename += "_" + viewToString(viewIndex); } - outputFilename += (m_Format == OutputFormat_Tga ? ".tga" : ".jpg"); + + std::string ext; + switch (m_Format) + { + case OutputFormat_Tga: + ext = "tga"; + break; + case OutputFormat_Png: + ext = "png"; + break; + case OutputFormat_Jpg: + ext = "jpg"; + break; + default: + nlerror("Unsupported format %d", m_Format); + break; + } + outputFilename += "." + ext; + switch(m_OutputPathOption) { case OutputPath_Custom: // custom output path - outputFilename = LPCTSTR(m_OutputPath) + std::string("\\") + NLMISC::CFile::getFilename(outputFilename); + outputFilename = tStrToUtf8(m_OutputPath) + "\\" + NLMISC::CFile::getFilename(outputFilename); break; case OutputPath_SameAsInput: // Input path - outputFilename = LPCTSTR(m_InputPath) + std::string("\\") + NLMISC::CFile::getFilename(outputFilename); + outputFilename = tStrToUtf8(m_InputPath) + "\\" + NLMISC::CFile::getFilename(outputFilename); break; case OutputPath_CurrShapeDirectory: // current path // no op break; } COFile output(outputFilename); + if (m_Format == OutputFormat_Tga) { snapshot.writeTGA(output); } + else if (m_Format == OutputFormat_Png) + { + snapshot.writePNG(output); + } else { snapshot.writeJPG(output); @@ -730,7 +754,7 @@ void CSnapshotToolDlg::OnTimer(UINT_PTR nIDEvent) } sb.reset(); } - catch(std::exception &e) + catch(const std::exception &e) { nlwarning(e.what()); diff --git a/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.h b/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.h index c696163d5..a9b1d476a 100644 --- a/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.h +++ b/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.h @@ -42,20 +42,21 @@ public: enum { - OutputFormat_Tga = 0, + OutputFormat_Tga, + OutputFormat_Png, OutputFormat_Jpg }; enum { - OutputPath_Custom = 0, + OutputPath_Custom, OutputPath_SameAsInput, OutputPath_CurrShapeDirectory, }; enum { - SnapshotAngle_Front = 0, + SnapshotAngle_Front, SnapshotAngle_Right, SnapshotAngle_Left, SnapshotAngle_Top, @@ -137,7 +138,7 @@ private: void fromRegistry(); // Save the options chosen in the snapshot tool ui into the registry. void toRegistry(); - void stringFromRegistry(HKEY hKey, const char *name, CString &dest, const CString &defaultStr); + void stringFromRegistry(HKEY hKey, const TCHAR *name, CString &dest, const CString &defaultStr); void updateUIEnabledState(); static void setCamFromView(uint view, NL3D::CCamera *cam, const NLMISC::CAABBox &bbox); diff --git a/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp b/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp index 965ad3d90..893a6a011 100644 --- a/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp @@ -76,10 +76,9 @@ BOOL CSoundAnimDlg::OnInitDialog() void CSoundAnimDlg::handle() { - char text[256]; float sec = _AnimationDlg->getTime(); - _snprintf(text, 256, "time: %.3f", sec); - GetDlgItem(IDC_SOUNDANIMINFO)->SetWindowText(text); + std::string text = toString("time: %.3f", sec); + GetDlgItem(IDC_SOUNDANIMINFO)->SetWindowText(utf8ToTStr(text)); _AnimView.updateCursor(); } @@ -137,7 +136,7 @@ void CSoundAnimDlg::updateSounds() for (iter = sounds.begin(); iter != sounds.end(); iter++) { - list->AddString((*iter).toString().c_str()); + list->AddString(utf8ToTStr((*iter).toString())); } list->UpdateData(); @@ -177,14 +176,13 @@ void CSoundAnimDlg::OnRemoveSound() { if (_SelectedMarker != 0) { - char s[256]; - CListBox* list = (CListBox*) GetDlgItem(IDC_SOUND_ANIM_LIST); + TCHAR s[256]; + CListBox* list = (CListBox*) GetDlgItem(IDC_SOUND_ANIM_LIST); if (list->GetText(list->GetCurSel(), s) != LB_ERR) { - string name(s); - _SelectedMarker->removeSound(NLMISC::CSheetId(name, "sound")); - updateSounds(); + _SelectedMarker->removeSound(NLMISC::CSheetId(tStrToUtf8(s), "sound")); + updateSounds(); } } } diff --git a/code/nel/tools/3d/object_viewer/sound_anim_view.cpp b/code/nel/tools/3d/object_viewer/sound_anim_view.cpp index 84998ad81..72591a4b4 100644 --- a/code/nel/tools/3d/object_viewer/sound_anim_view.cpp +++ b/code/nel/tools/3d/object_viewer/sound_anim_view.cpp @@ -67,7 +67,7 @@ bool CSoundAnimView::registerClass() _WndClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(WHITE_BRUSH)); // Do some additional initialization of static veriables - _Font.CreateFont(14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial"); + _Font.CreateFont(14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Arial")); _FillBrush.CreateSolidBrush(RGB(230, 245, 245)); _MarkerBrush.CreateSolidBrush(RGB(0, 0, 0)); _SelectBrush.CreateSolidBrush(RGB(0, 210, 210)); @@ -113,7 +113,7 @@ void CSoundAnimView::Create(CObjectViewer* objView, CAnimationDlg* animDlg, CSou } - CWnd::Create((LPCTSTR) _WndClass, "Sound Animation", WS_CHILD | WS_VISIBLE, rect, (CWnd*) sndDlg, ++_WndId); + CWnd::Create((LPCTSTR) _WndClass, _T("Sound Animation"), WS_CHILD | WS_VISIBLE, rect, (CWnd*) sndDlg, ++_WndId); } // ******************************************************** @@ -216,12 +216,12 @@ void CSoundAnimView::save() filename.append(anim->getName()).append(".sound_anim"); // Create a dialog - char BASED_CODE szFilter[] = "NeL Sound Animations (*.sound_anim)|*.sound_anim|All Files (*.*)|*.*||"; - CFileDialog fileDlg( FALSE, ".sound_anim", filename.c_str(), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + TCHAR BASED_CODE szFilter[] = _T("NeL Sound Animations (*.sound_anim)|*.sound_anim|All Files (*.*)|*.*||"); + CFileDialog fileDlg( FALSE, _T(".sound_anim"), utf8ToTStr(filename), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal() == IDOK) { - filename = (const char*) fileDlg.GetPathName(); + filename = tStrToUtf8(fileDlg.GetPathName()); } else { @@ -234,9 +234,9 @@ void CSoundAnimView::save() { CSoundAnimManager::instance()->saveAnimation(anim, filename); } - catch (Exception& e) + catch (const Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -298,7 +298,7 @@ void CSoundAnimView::refresh(BOOL update) CInstanceInfo *instanceInfo = _ObjView->getInstance(selected); // Some animation in the list ? - if (instanceInfo->Saved.PlayList.size() > 0) + if (!instanceInfo->Saved.PlayList.empty()) { // Accumul time float startTime = 0; @@ -328,7 +328,7 @@ void CSoundAnimView::refresh(BOOL update) else soundAnim = animManager->findAnimation(name); } - catch (exception& e) + catch (const exception& e) { nlwarning("Couldn't find sound animation <%s>: %s", name.c_str(), e.what()); needCreate = true; diff --git a/code/nel/tools/3d/object_viewer/sound_system.cpp b/code/nel/tools/3d/object_viewer/sound_system.cpp index 69e10ea18..5a79c3af3 100644 --- a/code/nel/tools/3d/object_viewer/sound_system.cpp +++ b/code/nel/tools/3d/object_viewer/sound_system.cpp @@ -67,7 +67,7 @@ void CSoundSystem::initSoundSystem () _AudioMixer->setPackedSheetOption(_PackedSheetPath, true); _AudioMixer->init(32, true, false, NULL, true); } - catch(NLMISC::Exception &e) + catch(const NLMISC::Exception &e) { // in case of exeption during mixer init, the mixer is destroyed ! string mess = string("Unable to init sound :") + e.what(); @@ -82,7 +82,7 @@ void CSoundSystem::initSoundSystem () // TODO : boris : Hum, as far as I know, throwing exeption in constructor is a very BAD idea... _AnimManager = new CSoundAnimManager(_AudioMixer); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { string mess = string("Unable to init sound :") + e.what(); nlwarning ("Init sound: %s", mess.c_str()); @@ -109,7 +109,7 @@ void CSoundSystem::initSoundSystem () //_AudioMixer->loadSampleBank(NLMISC::CPath::lookup(*it).c_str()); _AudioMixer->loadSampleBank(false, (*it1)); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { string mess = "Unable to load sound file :" + *it1 + "\n" + e.what(); @@ -126,7 +126,7 @@ void CSoundSystem::initSoundSystem () //_AudioMixer->loadSoundBank(NLMISC::CPath::lookup(*it).c_str()); _AudioMixer->loadSoundBank((*it2).c_str()); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { string mess = "Unable to load sound file :" + *it2 + "\n" + e.what(); @@ -178,7 +178,7 @@ void CSoundSystem::play(const string &soundName) } else { - MessageBox(NULL, "Can't play the sound (perhaps it's contextual sound)", "warning", MB_OK|MB_ICONWARNING ); + MessageBox(NULL, _T("Can't play the sound (perhaps it's contextual sound)"), _T("warning"), MB_OK|MB_ICONWARNING ); } } } @@ -198,7 +198,7 @@ USource *CSoundSystem::create(const std::string &soundName) } else { - MessageBox(NULL, "Can't play the sound (perhaps it's contextual sound)", "warning", MB_OK|MB_ICONWARNING ); + MessageBox(NULL, _T("Can't play the sound (perhaps it's contextual sound)"), _T("warning"), MB_OK|MB_ICONWARNING ); } return NULL; } return NULL; diff --git a/code/nel/tools/3d/object_viewer/start_stop_particle_system.cpp b/code/nel/tools/3d/object_viewer/start_stop_particle_system.cpp index 450b8b714..923c35ed1 100644 --- a/code/nel/tools/3d/object_viewer/start_stop_particle_system.cpp +++ b/code/nel/tools/3d/object_viewer/start_stop_particle_system.cpp @@ -210,7 +210,7 @@ void CStartStopParticleSystem::updateUIFromState() if (!getCurrPS()) { GetDlgItem(IDC_ACTIVE_PS)->SetWindowText(getStrRsc(IDS_NO_ACTIVE_PS)); - GetDlgItem(IDC_STICK_BONE)->SetWindowText(""); + GetDlgItem(IDC_STICK_BONE)->SetWindowText(_T("")); GetDlgItem(IDC_ENABLE_AUTO_COUNT)->EnableWindow(FALSE); GetDlgItem(IDC_RESET_COUNT)->EnableWindow(FALSE); ((CButton *) GetDlgItem(IDC_ENABLE_AUTO_COUNT))->SetCheck(0); @@ -225,19 +225,19 @@ void CStartStopParticleSystem::updateUIFromState() GetDlgItem(IDC_BROWSE_ANIM)->EnableWindow(FALSE); GetDlgItem(IDC_DISPLAY_HELPERS)->EnableWindow(FALSE); GetDlgItem(IDC_CLEAR_ANIM)->EnableWindow(FALSE); - m_TriggerAnim = ""; + m_TriggerAnim.Empty(); } else { if (!_ActiveNode->getParentSkelName().empty()) { - GetDlgItem(IDC_STICK_BONE)->SetWindowText((_ActiveNode->getParentBoneName() + "." + _ActiveNode->getParentBoneName()).c_str()); + GetDlgItem(IDC_STICK_BONE)->SetWindowText(utf8ToTStr(_ActiveNode->getParentBoneName() + "." + _ActiveNode->getParentBoneName())); } else { - GetDlgItem(IDC_STICK_BONE)->SetWindowText(""); + GetDlgItem(IDC_STICK_BONE)->SetWindowText(_T("")); } - GetDlgItem(IDC_ACTIVE_PS)->SetWindowText(_ActiveNode->getFilename().c_str()); + GetDlgItem(IDC_ACTIVE_PS)->SetWindowText(utf8ToTStr(_ActiveNode->getFilename())); GetDlgItem(IDC_ENABLE_AUTO_COUNT)->EnableWindow(TRUE); ((CButton *) GetDlgItem(IDC_ENABLE_AUTO_COUNT))->SetCheck(getCurrPS()->getAutoCountFlag() ? 1 : 0); GetDlgItem(IDC_RESET_COUNT)->EnableWindow((_ActiveNode->getPSPointer()->getAutoCountFlag() && !_ActiveNode->getResetAutoCountFlag()) ? TRUE : FALSE); @@ -844,7 +844,7 @@ void CStartStopParticleSystem::OnLinkToSkeleton() uint boneIndex; std::string parentSkelName; std::string parentBoneName; - if (ov->chooseBone((LPCTSTR) chooseBoneForPS, skel, boneIndex, &parentSkelName, &parentBoneName)) + if (ov->chooseBone(tStrToUtf8(chooseBoneForPS), skel, boneIndex, &parentSkelName, &parentBoneName)) { _ParticleDlg->stickPSToSkeleton(_ActiveNode, skel, boneIndex, parentSkelName, parentBoneName); } @@ -1017,11 +1017,11 @@ void CStartStopParticleSystem::OnBrowseAnim() } } std::vector animList(animSet.begin(), animSet.end()); - CSelectString st(animList, (LPCTSTR) getStrRsc(IDS_SELECT_ANIMATION), this, false); + CSelectString st(animList, tStrToUtf8(getStrRsc(IDS_SELECT_ANIMATION)), this, false); if (st.DoModal() == IDOK && st.Selection != -1) { m_TriggerAnim = animList[st.Selection].c_str(); - _ActiveNode->setTriggerAnim((LPCTSTR) m_TriggerAnim); + _ActiveNode->setTriggerAnim(tStrToUtf8(m_TriggerAnim)); GetDlgItem(IDC_CLEAR_ANIM)->EnableWindow(!_ActiveNode->getTriggerAnim().empty()); } _ParticleDlg->ParticleTreeCtrl->updateCaption(*_ActiveNode); @@ -1033,7 +1033,7 @@ void CStartStopParticleSystem::OnBrowseAnim() void CStartStopParticleSystem::OnClearAnim() { // TODO: Add your control notification handler code here - m_TriggerAnim = ""; + m_TriggerAnim.Empty(); _ActiveNode->setTriggerAnim(""); _ParticleDlg->ParticleTreeCtrl->updateCaption(*_ActiveNode); UpdateData(FALSE); diff --git a/code/nel/tools/3d/object_viewer/texture_anim_dlg.cpp b/code/nel/tools/3d/object_viewer/texture_anim_dlg.cpp index 31babe7b3..79a05ad8f 100644 --- a/code/nel/tools/3d/object_viewer/texture_anim_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/texture_anim_dlg.cpp @@ -332,13 +332,13 @@ void CTextureAnimDlg::CGradientInterface::CTextureWrapper::set(NL3D::ITexture *t if (t->getWidth() != tex->getWidth() || t->getHeight() != tex->getHeight()) { - ::MessageBox(NULL, "All textures must have the same size !", "error", MB_OK); + ::MessageBox(NULL, _T("All textures must have the same size !"), _T("error"), MB_OK); return; } if (t->PixelFormat != tex->PixelFormat) { - ::MessageBox(NULL, "All textures must have the same pixel format !", "error", MB_OK); + ::MessageBox(NULL, _T("All textures must have the same pixel format !"), _T("error"), MB_OK); return; } } diff --git a/code/nel/tools/3d/object_viewer/texture_chooser.cpp b/code/nel/tools/3d/object_viewer/texture_chooser.cpp index 65407aca1..70cc151b0 100644 --- a/code/nel/tools/3d/object_viewer/texture_chooser.cpp +++ b/code/nel/tools/3d/object_viewer/texture_chooser.cpp @@ -179,29 +179,22 @@ void CTextureChooser::OnBrowseTexture() { texName = (static_cast(_Wrapper->get()))->getFileName(); } - CFileDialog fd(TRUE, ".tga", texName.c_str(), 0, NULL, this); + CFileDialog fd(TRUE, _T(".tga"), utf8ToTStr(texName), 0, NULL, this); if (fd.DoModal() == IDOK) { - // Add to the path - char drive[256]; - char dir[256]; - char path[256]; - // Add search path for the texture - _splitpath (fd.GetPathName(), drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()))); try { - NL3D::CTextureFile *tf = new NL3D::CTextureFile(std::string(fd.GetFileName())); + NL3D::CTextureFile *tf = new NL3D::CTextureFile(tStrToUtf8(fd.GetFileName())); _Wrapper->setAndUpdateModifiedFlag(tf); _Texture = tf; textureToBitmap(); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { - MessageBox(e.what(), "error loading texture"); + MessageBox(utf8ToTStr(e.what()), _T("error loading texture")); } } diff --git a/code/nel/tools/3d/object_viewer/value_gradient_dlg.cpp b/code/nel/tools/3d/object_viewer/value_gradient_dlg.cpp index ccddc5833..5eff39642 100644 --- a/code/nel/tools/3d/object_viewer/value_gradient_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/value_gradient_dlg.cpp @@ -100,7 +100,7 @@ void CValueGradientDlg::OnAddValue() UpdateData(); ++_Size; _ClientInterface->modifyGradient(IValueGradientDlgClient::Add, 0); - m_GradientList.AddString("value"); + m_GradientList.AddString(_T("value")); m_RemoveCtrl.EnableWindow(TRUE); m_GradientList.SetCurSel(_Size - 1); @@ -116,7 +116,7 @@ void CValueGradientDlg::OnInsertValue() uint oldIndex = m_GradientList.GetCurSel(); ++_Size; _ClientInterface->modifyGradient(IValueGradientDlgClient::Insert, m_GradientList.GetCurSel()); - m_GradientList.InsertString(m_GradientList.GetCurSel(), "value"); + m_GradientList.InsertString(m_GradientList.GetCurSel(), _T("value")); m_GradientList.Invalidate(); m_GradientList.SetCurSel(oldIndex); OnSelchangeGradientList(); @@ -185,7 +185,7 @@ BOOL CValueGradientDlg::OnInitDialog() m_GradientList.InitStorage(_Size, 16); for (uint k = 0; k < _Size; ++k) { - m_GradientList.AddString("value"); + m_GradientList.AddString(_T("value")); } m_RemoveCtrl.EnableWindow(_Size > _MinSize ? TRUE : FALSE); m_GradientList.SetCurSel(0); diff --git a/code/nel/tools/3d/object_viewer/vegetable_copy_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_copy_dlg.cpp index 4e3162559..05e0ab1fd 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_copy_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_copy_dlg.cpp @@ -249,7 +249,7 @@ BOOL CVegetableCopyDlg::OnInitDialog() uint num= _VegetableDlg->getNumVegetables(); for(uint i=0; igetVegetableName(i).c_str()); + VegetableList.AddString(utf8ToTStr(_VegetableDlg->getVegetableName(i))); } @@ -289,7 +289,7 @@ void CVegetableCopyDlg::OnOK() } else { - MessageBox("Select a vegetable to copy first", "Error", MB_OK | MB_ICONWARNING); + MessageBox(_T("Select a vegetable to copy first"), _T("Error"), MB_OK | MB_ICONWARNING); } } diff --git a/code/nel/tools/3d/object_viewer/vegetable_density_page.cpp b/code/nel/tools/3d/object_viewer/vegetable_density_page.cpp index 2db682bcd..d8f9c2d75 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_density_page.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_density_page.cpp @@ -100,7 +100,7 @@ void CVegetableDensityPage::setVegetableToEdit(NL3D::CVegetable *vegetable) { // Init ShapeName // ---------- - StaticVegetableShape.SetWindowText(_Vegetable->ShapeName.c_str()); + StaticVegetableShape.SetWindowText(utf8ToTStr(_Vegetable->ShapeName)); // init Creation Distance. // ---------- @@ -198,8 +198,9 @@ void CVegetableDensityPage::updateViewAngleMin() sint pos= (sint)(angle/(NLMISC::Pi/2) * NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE); NLMISC::clamp(pos, -NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE, NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE); AngleMinSlider.SetPos(pos); - char stmp[256]; - sprintf(stmp, "%.2f", (double)(angle*180/NLMISC::Pi)); + + CString stmp; + stmp.Format(_T("%.2f"), (double)(angle*180/NLMISC::Pi)); AngleMinEdit.SetWindowText(stmp); } @@ -213,8 +214,9 @@ void CVegetableDensityPage::updateViewAngleMax() sint pos= (sint)(angle/(NLMISC::Pi/2) * NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE); NLMISC::clamp(pos, -NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE, NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE); AngleMaxSlider.SetPos(pos); - char stmp[256]; - sprintf(stmp, "%.2f", (double)(angle*180/NLMISC::Pi)); + + CString stmp; + stmp.Format(_T("%.2f"), (double)(angle * 180 / NLMISC::Pi)); AngleMaxEdit.SetWindowText(stmp); } @@ -223,10 +225,10 @@ void CVegetableDensityPage::updateViewAngleMax() void CVegetableDensityPage::updateAngleMinFromEditText() { // get angles edited. - char stmp[256]; + TCHAR stmp[256]; AngleMinEdit.GetWindowText(stmp, 256); float angleMin; - NLMISC::fromString(stmp, angleMin); + NLMISC::fromString(tStrToUtf8(stmp), angleMin); NLMISC::clamp(angleMin, -90, 90); // make a sinus, because 90 => 1, and -90 =>-1 float cosAngleMin= (float)sin(angleMin*NLMISC::Pi/180.f); @@ -247,10 +249,10 @@ void CVegetableDensityPage::updateAngleMinFromEditText() void CVegetableDensityPage::updateAngleMaxFromEditText() { // get angles edited. - char stmp[256]; + TCHAR stmp[256]; AngleMaxEdit.GetWindowText(stmp, 256); float angleMax; - NLMISC::fromString(stmp, angleMax); + NLMISC::fromString(tStrToUtf8(stmp), angleMax); NLMISC::clamp(angleMax, -90, 90); // make a sinus, because 90 => 1, and -90 =>-1 float cosAngleMax= (float)sin(angleMax*NLMISC::Pi/180.f); @@ -320,7 +322,7 @@ BOOL CVegetableDensityPage::OnInitDialog() // Init ShapeName - StaticVegetableShape.SetWindowText(""); + StaticVegetableShape.SetWindowText(_T("")); return TRUE; // return TRUE unless you set the focus to a control @@ -477,12 +479,12 @@ static void concatEdit2Lines(CEdit &edit) const uint lineLen= 1000; uint n; // retrieve the 2 lines. - char tmp0[2*lineLen]; - char tmp1[lineLen]; + TCHAR tmp0[2*lineLen]; + TCHAR tmp1[lineLen]; n= edit.GetLine(0, tmp0, lineLen); tmp0[n]= 0; n= edit.GetLine(1, tmp1, lineLen); tmp1[n]= 0; // concat and update the CEdit. - edit.SetWindowText(strcat(tmp0, tmp1)); + edit.SetWindowText(_tcscat(tmp0, tmp1)); } void CVegetableDensityPage::OnChangeEditAngleMin() @@ -515,27 +517,25 @@ void CVegetableDensityPage::OnChangeEditAngleMax() // *************************************************************************** void CVegetableDensityPage::OnButtonVegetableBrowse() { - CFileDialog fd(TRUE, "veget", "*.veget", 0, NULL, this) ; - fd.m_ofn.lpstrTitle= "Open Vegetable Shape"; + CFileDialog fd(TRUE, _T("veget"), _T("*.veget"), 0, NULL, this) ; + fd.m_ofn.lpstrTitle = _T("Open Vegetable Shape"); + if (fd.DoModal() == IDOK) { // Add to the path - char drive[256]; - char dir[256]; - char path[256]; + std::string fileName = tStrToUtf8(fd.GetFileName()); // Add search path for the .veget - _splitpath (fd.GetPathName(), drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); + std::string path = NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())); NLMISC::CPath::addSearchPath (path); try { // verify the file can be opened. - NLMISC::CPath::lookup((const char*)fd.GetFileName()); + NLMISC::CPath::lookup(fileName); // update shapeName and view - _Vegetable->ShapeName= std::string(fd.GetFileName()); + _Vegetable->ShapeName = fileName; StaticVegetableShape.SetWindowText(fd.GetFileName()); // update the name in the list-box @@ -544,9 +544,9 @@ void CVegetableDensityPage::OnButtonVegetableBrowse() // update 3D view _VegetableDlg->refreshVegetableDisplay(); } - catch (NLMISC::EPathNotFound &ep) + catch (const NLMISC::EPathNotFound &ep) { - MessageBox(ep.what(), "Can't open file"); + MessageBox(utf8ToTStr(ep.what()), _T("Can't open file")); } } } diff --git a/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp index 09aa67ea4..09a2079e5 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp @@ -196,7 +196,7 @@ void CVegetableDlg::updateCurSelVegetableName() _Vegetables[id].updateVegetableName(); // replace name in the listBox: must delete, and re-insert VegetableList.DeleteString(id); - VegetableList.InsertString(id, _Vegetables[id].VegetableName.c_str()); + VegetableList.InsertString(id, utf8ToTStr(_Vegetables[id].VegetableName)); VegetableList.SetCurSel(id); } } @@ -293,7 +293,7 @@ void CVegetableDlg::CVegetableDesc::initVegetable(const NL3D::CVegetable &veget void CVegetableDlg::CVegetableDesc::updateVegetableName() { // Build the vegetable Name according to the ShapeName - if(Vegetable->ShapeName=="") + if(Vegetable->ShapeName.empty()) { VegetableName= NL_DefaultVegetName; } @@ -336,38 +336,38 @@ void CVegetableDlg::clearVegetables() // *************************************************************************** -bool CVegetableDlg::loadVegetableSet(NL3D::CTileVegetableDesc &vegetSet, const char *title) +bool CVegetableDlg::loadVegetableSet(NL3D::CTileVegetableDesc &vegetSet, const TCHAR *title) { vegetSet.clear(); bool ok= false; - CFileDialog fd(TRUE, ".vegetset", "*.vegetset", 0, NULL, this) ; - fd.m_ofn.lpstrTitle= title; + CFileDialog fd(TRUE, _T(".vegetset"), _T("*.vegetset"), 0, NULL, this) ; + fd.m_ofn.lpstrTitle = title; if (fd.DoModal() == IDOK) { NLMISC::CIFile f; ok= true; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName()))) { try { // read the vegetable f.serial(vegetSet); // bkup fileName. - _LastVegetSetName= (const char*)fd.GetFileName(); + _LastVegetSetName = tStrToUtf8(fd.GetFileName()); } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { ok= false; - MessageBox("Failed to load file!"); + MessageBox(_T("Failed to load file!")); } } else { ok= false; - MessageBox("Failed to open file!"); + MessageBox(_T("Failed to open file!")); } } @@ -385,7 +385,7 @@ void CVegetableDlg::buildVegetableSet(NL3D::CTileVegetableDesc &vegetSet, bool for(uint i=0;i<_Vegetables.size();i++) { // if don't want to keep ShapeNames, skip them. - if(!keepDefaultShapeName && _Vegetables[i].Vegetable->ShapeName=="") + if(!keepDefaultShapeName && _Vegetables[i].Vegetable->ShapeName.empty()) continue; // if don't want to keep hiden vegetables, skip them. if(!keepHiden && !_Vegetables[i].Visible) @@ -439,7 +439,7 @@ void CVegetableDlg::appendVegetableSet(NL3D::CTileVegetableDesc &vegetSet) _Vegetables[id].initVegetable(veget); // update view - VegetableList.AddString(_Vegetables[id].VegetableName.c_str()); + VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName)); } } } @@ -529,7 +529,7 @@ void CVegetableDlg::OnButtonVegetableAdd() _Vegetables[id].initDefaultVegetable(); // update view - VegetableList.AddString(_Vegetables[id].VegetableName.c_str()); + VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName)); // update 3D view refreshVegetableDisplay(); @@ -540,7 +540,7 @@ void CVegetableDlg::OnButtonVegetableClear() if(_Vegetables.size()==0) return; - if( MessageBox("Clear all the list?", "Clear List", MB_OKCANCEL | MB_ICONWARNING | MB_APPLMODAL)==IDOK ) + if( MessageBox(_T("Clear all the list?"), _T("Clear List"), MB_OKCANCEL | MB_ICONWARNING | MB_APPLMODAL)==IDOK ) { clearVegetables(); @@ -559,7 +559,7 @@ void CVegetableDlg::OnButtonVegetableInsert() _Vegetables[id].initDefaultVegetable(); // update view - VegetableList.InsertString(id, _Vegetables[id].VegetableName.c_str()); + VegetableList.InsertString(id, utf8ToTStr(_Vegetables[id].VegetableName)); // update 3D view refreshVegetableDisplay(); @@ -605,13 +605,13 @@ void CVegetableDlg::OnButtonVegetableRemove() // *************************************************************************** void CVegetableDlg::OnButtonVegetableLoadDesc() { - CFileDialog fd(TRUE, ".vegetdesc", "*.vegetdesc", 0, NULL, this) ; - fd.m_ofn.lpstrTitle= "Open Vegetable Descriptor"; + CFileDialog fd(TRUE, _T(".vegetdesc"), _T("*.vegetdesc"), 0, NULL, this) ; + fd.m_ofn.lpstrTitle = _T("Open Vegetable Descriptor"); if (fd.DoModal() == IDOK) { NLMISC::CIFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { NL3D::CVegetable veget; try @@ -624,19 +624,19 @@ void CVegetableDlg::OnButtonVegetableLoadDesc() _Vegetables[id].initVegetable(veget); // update view - VegetableList.AddString(_Vegetables[id].VegetableName.c_str()); + VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName)); // update 3D view refreshVegetableDisplay(); } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { - MessageBox("Failed to load file!"); + MessageBox(_T("Failed to load file!")); } } else { - MessageBox("Failed to open file!"); + MessageBox(_T("Failed to open file!")); } } @@ -651,27 +651,27 @@ void CVegetableDlg::OnButtonVegetableSaveDesc() std::string fileName= _Vegetables[id].VegetableName + ".vegetdesc"; - CFileDialog fd(FALSE, "vegetdesc", fileName.c_str(), OFN_OVERWRITEPROMPT, "VegetDescFiles (*.vegetdesc)|*.vegetdesc|All Files (*.*)|*.*||", this) ; - fd.m_ofn.lpstrTitle= "Save Vegetable Descriptor"; + CFileDialog fd(FALSE, _T("vegetdesc"), utf8ToTStr(fileName), OFN_OVERWRITEPROMPT, _T("VegetDescFiles (*.vegetdesc)|*.vegetdesc|All Files (*.*)|*.*||"), this) ; + fd.m_ofn.lpstrTitle = _T("Save Vegetable Descriptor"); if (fd.DoModal() == IDOK) { NLMISC::COFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { try { // save the vegetable f.serial(veget); } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { - MessageBox("Failed to save file!"); + MessageBox(_T("Failed to save file!")); } } else { - MessageBox("Failed to open file for write!"); + MessageBox(_T("Failed to open file for write!")); } } } @@ -684,7 +684,7 @@ void CVegetableDlg::OnButtonVegetableLoadSet() { NL3D::CTileVegetableDesc vegetSet; // if succes to load the vegetSet - if(loadVegetableSet(vegetSet, "Load Vegetable Set")) + if(loadVegetableSet(vegetSet, _T("Load Vegetable Set"))) { // Delete all vegetables. clearVegetables(); @@ -702,7 +702,7 @@ void CVegetableDlg::OnButtonVegetableAppendSet() { NL3D::CTileVegetableDesc vegetSet; // if succes to load the vegetSet - if(loadVegetableSet(vegetSet, "Append Vegetable Set")) + if(loadVegetableSet(vegetSet, _T("Append Vegetable Set"))) { // Do not Delete any vegetables. // build them from list. @@ -722,27 +722,27 @@ void CVegetableDlg::OnButtonVegetableSaveSet() buildVegetableSet(vegetSet); // Then try to save it. - CFileDialog fd(FALSE, "vegetset", _LastVegetSetName.c_str(), OFN_OVERWRITEPROMPT, "VegetSetFiles (*.vegetset)|*.vegetset|All Files (*.*)|*.*||", this) ; - fd.m_ofn.lpstrTitle= "Save Vegetable Set"; + CFileDialog fd(FALSE, _T("vegetset"), utf8ToTStr(_LastVegetSetName), OFN_OVERWRITEPROMPT, _T("VegetSetFiles (*.vegetset)|*.vegetset|All Files (*.*)|*.*||"), this) ; + fd.m_ofn.lpstrTitle = _T("Save Vegetable Set"); if (fd.DoModal() == IDOK) { NLMISC::COFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { try { // save the vegetable set f.serial(vegetSet); } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { - MessageBox("Failed to save file!"); + MessageBox(_T("Failed to save file!")); } } else { - MessageBox("Failed to open file for write!"); + MessageBox(_T("Failed to open file for write!")); } } diff --git a/code/nel/tools/3d/object_viewer/vegetable_dlg.h b/code/nel/tools/3d/object_viewer/vegetable_dlg.h index 37a263630..72d588259 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_dlg.h +++ b/code/nel/tools/3d/object_viewer/vegetable_dlg.h @@ -144,10 +144,10 @@ protected: // clear all vegetables. void clearVegetables(); // load a vegetSet with a FileDialog - bool loadVegetableSet(NL3D::CTileVegetableDesc &vegetSet, const char *title); + bool loadVegetableSet(NL3D::CTileVegetableDesc &vegetSet, const TCHAR *title); /** build the vegetSet from the current _Vegetables * NB: transform Rotate Angle in Radians. - * \param keepDefaultShapeName if true, then vegetables with a ShapeName=="" are kept. + * \param keepDefaultShapeName if true, then vegetables with a ShapeName.empty() are kept. * \param keepHiden if true, then vegetables maked as hiden in ObjectViewer are kept. */ void buildVegetableSet(NL3D::CTileVegetableDesc &vegetSet, bool keepDefaultShapeName= true, bool keepHiden= true ); diff --git a/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp b/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp index 8d791a0fe..b0508cca9 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp @@ -33,7 +33,7 @@ void CDirectEditableRangeFloat::init(uint32 x, uint32 y, CWnd *pParent) CRect rect; rect.SetRect(x, y+10, x+dx, y+25); - _StaticText.Create(_Title.c_str(), WS_CHILD | WS_VISIBLE, rect, pParent); + _StaticText.Create(utf8ToTStr(_Title), WS_CHILD | WS_VISIBLE, rect, pParent); _StaticText.SetFont(pParent->GetFont()); } diff --git a/code/nel/tools/3d/object_viewer/vegetable_list_box.cpp b/code/nel/tools/3d/object_viewer/vegetable_list_box.cpp index f5c7a2372..41305b38c 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_list_box.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_list_box.cpp @@ -216,8 +216,7 @@ void CVegetableListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) dc.SetTextColor(::GetSysColor(COLOR_GRAYTEXT) ); } - dc.DrawText( - (const char*)str, + dc.DrawText(str, str.GetLength(), &lpDrawItemStruct->rcItem, DT_LEFT|DT_SINGLELINE|DT_VCENTER); diff --git a/code/nel/tools/3d/object_viewer/vegetable_list_color.cpp b/code/nel/tools/3d/object_viewer/vegetable_list_color.cpp index 4e272e7d3..ec27c7352 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_list_color.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_list_color.cpp @@ -134,7 +134,7 @@ void CVegetableListColor::clear() void CVegetableListColor::addValue(CRGBA color) { // Append a dummy string to the list box. - AddString(" "); + AddString(_T(" ")); // append a color to the array. _Colors.push_back(color); @@ -149,7 +149,7 @@ void CVegetableListColor::insertValueBeforeCurSel(CRGBA color) else { // insert a dummy string to the list box. - InsertString(id, " "); + InsertString(id, _T(" ")); // insert a color to the array. _Colors.insert(_Colors.begin()+id, color); diff --git a/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp index 0c04d33c8..12bfe4050 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp @@ -154,7 +154,7 @@ BOOL CVegetableNoiseValueDlg::OnInitDialog() // Set the name. - NoiseValueName.SetWindowText(_TitleName.c_str()); + NoiseValueName.SetWindowText(utf8ToTStr(_TitleName)); // if previously setuped, setup now the noiseValue. @@ -203,7 +203,7 @@ void CVegetableNoiseValueDlg::OnReleasedcaptureSliderVegetableScaleNoise(NMHDR* // And reset SliderNoiseValue.SetPos(NL_VEGETABLE_EDIT_SLIDER_NVS_SIZE/2); _EnteringScalerSlider= false; - StaticScaleMarker.SetWindowText("100%"); + StaticScaleMarker.SetWindowText(_T("100%")); // Must update display. _VegetableRefresh->refreshVegetableDisplay(); @@ -264,7 +264,5 @@ void CVegetableNoiseValueDlg::applyScaleSlider(sint scrollValue) _RandValue->updateValueFromReader(); // update marker text - char str[256]; - sprintf(str, "%d%%", (sint)(factor*100)); - StaticScaleMarker.SetWindowText(str); + StaticScaleMarker.SetWindowText(utf8ToTStr(NLMISC::toString("%d%%", (sint)(factor * 100)))); } diff --git a/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp index 51b4cdc5e..d7be7bcb3 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp @@ -63,7 +63,7 @@ BOOL CVegetableSelectDlg::OnInitDialog() uint num= _VegetableDlg->getNumVegetables(); for(uint i=0; igetVegetableName(i).c_str()); + VegetableList.AddString(utf8ToTStr(_VegetableDlg->getVegetableName(i))); } return TRUE; // return TRUE unless you set the focus to a control diff --git a/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp index 5c6657167..0b2084863 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp @@ -70,26 +70,22 @@ END_MESSAGE_MAP() void CVegetableWindDlg::updateView() { float a; - char str[256]; // update Power. a= _ObjViewer->getVegetableWindPower(); - sprintf(str, "%.2f", a); - StaticPower.SetWindowText(str); + StaticPower.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_POWER); SliderPower.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_POWER)); // update BendStart. a= _ObjViewer->getVegetableWindBendStart(); - sprintf(str, "%.2f", a); - StaticBendStart.SetWindowText(str); + StaticBendStart.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART); SliderBendStart.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART)); // update Frequency. a= _ObjViewer->getVegetableWindFrequency(); - sprintf(str, "%.2f", a); - StaticFrequency.SetWindowText(str); + StaticFrequency.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY); SliderFrequency.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY)); @@ -129,28 +125,24 @@ void CVegetableWindDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBa && nSBCode==SB_THUMBPOSITION || nSBCode==SB_THUMBTRACK) { float a; - char str[256]; if(sliderCtrl == &SliderPower) { a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_POWER / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE; _ObjViewer->setVegetableWindPower(a); - sprintf(str, "%.2f", a); - StaticPower.SetWindowText(str); + StaticPower.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); } else if(sliderCtrl == &SliderBendStart) { a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE; _ObjViewer->setVegetableWindBendStart(a); - sprintf(str, "%.2f", a); - StaticBendStart.SetWindowText(str); + StaticBendStart.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); } else if(sliderCtrl == &SliderFrequency) { a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE; _ObjViewer->setVegetableWindFrequency(a); - sprintf(str, "%.2f", a); - StaticFrequency.SetWindowText(str); + StaticFrequency.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); } } else diff --git a/code/nel/tools/3d/object_viewer/water_pool_editor.cpp b/code/nel/tools/3d/object_viewer/water_pool_editor.cpp index 601c5c907..bf6f461bf 100644 --- a/code/nel/tools/3d/object_viewer/water_pool_editor.cpp +++ b/code/nel/tools/3d/object_viewer/water_pool_editor.cpp @@ -165,9 +165,8 @@ BOOL CWaterPoolEditor::OnInitDialog() int CWaterPoolEditor::addPool(uint32 ID) { - char poolId[128]; - sprintf(poolId, "%d (%s)", ID, _Wpm->getPoolByID(ID).getName().c_str()); - int index = m_PoolList.AddString(poolId); + std::string poolId = NLMISC::toString("%d (%s)", ID, _Wpm->getPoolByID(ID).getName().c_str()); + int index = m_PoolList.AddString(utf8ToTStr(poolId)); nlassert(index != LB_ERR); m_PoolList.SetItemData(index, ID); return index; @@ -304,7 +303,7 @@ void CWaterPoolEditor::OnAddPool() { if (_Wpm->hasPool(cpi.PoolID) ) { - MessageBox("Pool already exists", "error"); + MessageBox(_T("Pool already exists"), _T("error")); } else { @@ -324,7 +323,7 @@ void CWaterPoolEditor::OnDeletePool() UpdateData(); if (m_PoolList.GetCount() == 1) { - MessageBox("Must have at least one water pool", "error"); + MessageBox(_T("Must have at least one water pool"), _T("error")); } else { @@ -350,15 +349,15 @@ void CWaterPoolEditor::OnSelchangeMapSize() void CWaterPoolEditor::OnLoadPool() { - static char BASED_CODE szFilter[] = "NeL Water Pool Files (*.wpf)|*.wpf||"; - CFileDialog fileDlg( TRUE, ".wpf", "*.wpf", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("NeL Water Pool Files (*.wpf)|*.wpf||"); + CFileDialog fileDlg( TRUE, _T(".wpf"), _T("*.wpf"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal()==IDOK) { try { NLMISC::CIXml iXml; NLMISC::CIFile iF; - if (iF.open((LPCTSTR) fileDlg.GetPathName())) + if (iF.open(tStrToUtf8(fileDlg.GetPathName()))) { if (iXml.init (iF)) { @@ -370,17 +369,17 @@ void CWaterPoolEditor::OnLoadPool() else { iF.close(); - MessageBox (("Unable to init xml stream from file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to init xml stream from file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } else { - MessageBox (("Unable to open file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to open file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } - catch (NLMISC::Exception& e) + catch (const NLMISC::Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -388,15 +387,15 @@ void CWaterPoolEditor::OnLoadPool() void CWaterPoolEditor::OnSavePool() { - static char BASED_CODE szFilter[] = "NeL Water Pool Files (*.wpf)|*.wpf||"; - CFileDialog fileDlg( TRUE, ".wpf", "*.wpf", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("NeL Water Pool Files (*.wpf)|*.wpf||"); + CFileDialog fileDlg( TRUE, _T(".wpf"), _T("*.wpf"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal()==IDOK) { try { NLMISC::COXml oXml; NLMISC::COFile oF; - if (oF.open((LPCTSTR) fileDlg.GetPathName())) + if (oF.open(tStrToUtf8(fileDlg.GetPathName()))) { if (oXml.init (&oF)) { @@ -407,17 +406,17 @@ void CWaterPoolEditor::OnSavePool() else { oF.close(); - MessageBox (("Unable to init xml stream from file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to init xml stream from file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } else { - MessageBox (("Unable to open file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to open file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } - catch (NLMISC::Exception& e) + catch (const NLMISC::Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } diff --git a/code/nel/tools/3d/object_viewer_exe/CMakeLists.txt b/code/nel/tools/3d/object_viewer_exe/CMakeLists.txt index d6adb9694..a57a3788a 100644 --- a/code/nel/tools/3d/object_viewer_exe/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_exe/CMakeLists.txt @@ -17,9 +17,9 @@ NL_ADD_RUNTIME_FLAGS(object_viewer) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(object_viewer ${CMAKE_CURRENT_SOURCE_DIR}/std_afx.h ${CMAKE_CURRENT_SOURCE_DIR}/std_afx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS object_viewer RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d) IF(WITH_MAXPLUGIN) INSTALL(TARGETS object_viewer RUNTIME DESTINATION maxplugin COMPONENT tools3d) -ENDIF(WITH_MAXPLUGIN) +ENDIF() diff --git a/code/nel/tools/3d/object_viewer_exe/object_viewer_exe.cpp b/code/nel/tools/3d/object_viewer_exe/object_viewer_exe.cpp index d10a6a7ad..c57c8e8ff 100644 --- a/code/nel/tools/3d/object_viewer_exe/object_viewer_exe.cpp +++ b/code/nel/tools/3d/object_viewer_exe/object_viewer_exe.cpp @@ -18,7 +18,7 @@ // #include "std_afx.h" - +#include //#include "nel/3d/register_3d.h" //#include "nel/3d/scene.h" @@ -29,9 +29,9 @@ using namespace NLMISC; using namespace std; -int APIENTRY WinMain(HINSTANCE hInstance, +int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpCmdLine, + LPTSTR lpCmdLine, int nCmdShow) { // Register 3d @@ -41,13 +41,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, // init3d (); // Remove command line "" - char commandLine[512]; - char *commandLinePtr=commandLine; - strcpy (commandLine, lpCmdLine); - if (commandLine[0]=='"') + TCHAR commandLine[512]; + TCHAR *commandLinePtr=commandLine; + _tcscpy (commandLine, lpCmdLine); + if (commandLine[0]==_T('"')) commandLinePtr++; - if (commandLinePtr[strlen (commandLinePtr)-1]=='"') - commandLinePtr[strlen (commandLinePtr)-1]=0; + if (commandLinePtr[_tcslen (commandLinePtr)-1]==_T('"')) + commandLinePtr[_tcslen (commandLinePtr)-1]=0; // Create a object viewer IObjectViewer *objectViewer=IObjectViewer::getInterface(); @@ -58,11 +58,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, if (objectViewer->initUI ()) { // Argument ? - if (strcmp (commandLinePtr, "")!=0) + if (_tcscmp (commandLinePtr, _T(""))!=0) { // Make a string vector vector strVector; - strVector.push_back (commandLinePtr); + strVector.push_back (tStrToUtf8(commandLinePtr)); // Try to load a shape if (objectViewer->loadMesh (strVector, "")) diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp index 54bc1cc19..fbc379d95 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp +++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp @@ -502,7 +502,7 @@ namespace NLQT // load and set search paths from config //Modules::config().configSearchPaths(); - _CurrentInstance = ""; + _CurrentInstance.clear(); nlinfo("Scene cleared"); } diff --git a/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/CMakeLists.txt b/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/CMakeLists.txt index 3a596badc..9a14d59a6 100644 --- a/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/CMakeLists.txt +++ b/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/CMakeLists.txt @@ -16,10 +16,10 @@ NL_ADD_RUNTIME_FLAGS(nel_3dsmax_shared) NL_ADD_LIB_SUFFIX(nel_3dsmax_shared) #SET_TARGET_PROPERTIES(nel_export PROPERTIES SUFFIX ".dlx") -ADD_DEFINITIONS(-DNEL_3DSMAX_SHARED_EXPORTS) +ADD_DEFINITIONS(-DNEL_3DSMAX_SHARED_EXPORTS ${MAXSDK_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nel_3dsmax_shared ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.h ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS nel_3dsmax_shared RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) diff --git a/code/nel/tools/3d/plugin_max/nel_export/CMakeLists.txt b/code/nel/tools/3d/plugin_max/nel_export/CMakeLists.txt index dd91a3101..2787a7645 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/CMakeLists.txt +++ b/code/nel/tools/3d/plugin_max/nel_export/CMakeLists.txt @@ -25,8 +25,10 @@ NL_ADD_RUNTIME_FLAGS(nel_export) NL_ADD_LIB_SUFFIX(nel_export) SET_TARGET_PROPERTIES(nel_export PROPERTIES SUFFIX ".dlu") +ADD_DEFINITIONS(${MAXSDK_DEFINITIONS}) + IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nel_export ${CMAKE_CURRENT_SOURCE_DIR}/std_afx.h ${CMAKE_CURRENT_SOURCE_DIR}/std_afx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS nel_export RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export.cpp index 3a3e40810..4482ab51f 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export.cpp @@ -26,7 +26,7 @@ #include "nel_export_scene.h" - + using namespace NL3D; using namespace NLMISC; @@ -42,15 +42,15 @@ CExportNelOptions theExportSceneStruct; CNelExportClassDesc CNelExportDesc; ClassDesc2* GetCNelExportDesc() {return &CNelExportDesc;} -static const char *zoneFilter="NeL zone file (*.zone)\0*.zone\0All files (*.*)\0*.*\0"; -static const char *meshFilter="NeL shape file (*.shape)\0*.shape\0All files (*.*)\0*.*\0"; -static const char *collisionFilter="NeL collision file (*.cmb)\0*.cmb\0All files (*.*)\0*.*\0"; -static const char *animModelFilter="NeL model animation file (*.anim)\0*.anim\0All files (*.*)\0*.*\0"; -static const char *SWTFilter="NeL Skeleton Weight Template file (*.swt)\0*.swt\0All files (*.*)\0*.*\0"; -static const char *InstanceGroupFilter="NeL Instance Group file (*.ig)\0*.ig\0All files (*.*)\0*.*\0"; -static const char *skeletonFilter="NeL Skeleton file (*.skel)\0*.skel\0All files (*.*)\0*.*\0"; -static const char *vegetableFilter="NeL Vegetable file (*.veget)\0*.veget\0All files (*.*)\0*.*\0"; -static const char *lodCharacterFilter="NeL LodCharacter file (*.clod)\0*.clod\0All files (*.*)\0*.*\0"; +static const TCHAR *zoneFilter = _T("NeL zone file (*.zone)\0*.zone\0All files (*.*)\0*.*\0"); +static const TCHAR *meshFilter = _T("NeL shape file (*.shape)\0*.shape\0All files (*.*)\0*.*\0"); +static const TCHAR *collisionFilter = _T("NeL collision file (*.cmb)\0*.cmb\0All files (*.*)\0*.*\0"); +static const TCHAR *animModelFilter = _T("NeL model animation file (*.anim)\0*.anim\0All files (*.*)\0*.*\0"); +static const TCHAR *SWTFilter = _T("NeL Skeleton Weight Template file (*.swt)\0*.swt\0All files (*.*)\0*.*\0"); +static const TCHAR *InstanceGroupFilter = _T("NeL Instance Group file (*.ig)\0*.ig\0All files (*.*)\0*.*\0"); +static const TCHAR *skeletonFilter = _T("NeL Skeleton file (*.skel)\0*.skel\0All files (*.*)\0*.*\0"); +static const TCHAR *vegetableFilter = _T("NeL Vegetable file (*.veget)\0*.veget\0All files (*.*)\0*.*\0"); +static const TCHAR *lodCharacterFilter = _T("NeL LodCharacter file (*.clod)\0*.clod\0All files (*.*)\0*.*\0"); void *CNelExportClassDesc::Create(BOOL loading) @@ -66,50 +66,61 @@ INT_PTR CALLBACK OptionsDialogCallback ( LPARAM lParam // second message parameter ) { - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: { - char tmp[1024]; CenterWindow( hwndDlg, theCNelExport._Ip->GetMAXHWnd() ); ShowWindow( hwndDlg, TRUE ); + // Initialize from theExportSceneStruct if( theExportSceneStruct.bExcludeNonSelected ) SendMessage( GetDlgItem(hwndDlg,IDC_EXCLUDE), BM_SETCHECK, BST_CHECKED, 0 ); else SendMessage( GetDlgItem(hwndDlg,IDC_EXCLUDE), BM_SETCHECK, BST_UNCHECKED, 0 ); + if( theExportSceneStruct.bExportLighting ) SendMessage( GetDlgItem(hwndDlg,IDC_CHECKEXPORTLIGHTING), BM_SETCHECK, BST_CHECKED, 0 ); else SendMessage( GetDlgItem(hwndDlg,IDC_CHECKEXPORTLIGHTING), BM_SETCHECK, BST_UNCHECKED, 0 ); + if( theExportSceneStruct.OutputLightmapLog ) SendMessage( GetDlgItem(hwndDlg,IDC_CHECKOUTPUTLIGHTMAPLOG), BM_SETCHECK, BST_CHECKED, 0 ); else SendMessage( GetDlgItem(hwndDlg,IDC_CHECKOUTPUTLIGHTMAPLOG), BM_SETCHECK, BST_UNCHECKED, 0 ); + if( theExportSceneStruct.bShadow) SendMessage( GetDlgItem(hwndDlg,IDC_SHADOW), BM_SETCHECK, BST_CHECKED, 0 ); else SendMessage( GetDlgItem(hwndDlg,IDC_SHADOW), BM_SETCHECK, BST_UNCHECKED, 0 ); - SendMessage( GetDlgItem(hwndDlg,IDC_EDITEXPORTLIGHTING), WM_SETTEXT, 0, (long)theExportSceneStruct.sExportLighting.c_str() ); + + SendMessage( GetDlgItem(hwndDlg,IDC_EDITEXPORTLIGHTING), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(theExportSceneStruct.sExportLighting)); + if( theExportSceneStruct.nExportLighting == 0 ) SendMessage( GetDlgItem(hwndDlg,IDC_RADIONORMALEXPORTLIGHTING), BM_SETCHECK, BST_CHECKED, 0 ); + if( theExportSceneStruct.nExportLighting == 1 ) SendMessage( GetDlgItem(hwndDlg,IDC_RADIORADIOSITYEXPORTLIGHTING), BM_SETCHECK, BST_CHECKED, 0 ); - sprintf( tmp, "%f", theExportSceneStruct.rLumelSize ); - SendMessage( GetDlgItem(hwndDlg,IDC_EDITLUMELSIZE), WM_SETTEXT, 0, (long)tmp ); + + SendMessage( GetDlgItem(hwndDlg,IDC_EDITLUMELSIZE), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(toString(theExportSceneStruct.rLumelSize))); + if( theExportSceneStruct.nOverSampling == 1 ) SendMessage( GetDlgItem(hwndDlg,IDC_RADIOSS1), BM_SETCHECK, BST_CHECKED, 0 ); + if( theExportSceneStruct.nOverSampling == 2 ) SendMessage( GetDlgItem(hwndDlg,IDC_RADIOSS2), BM_SETCHECK, BST_CHECKED, 0 ); + if( theExportSceneStruct.nOverSampling == 4 ) SendMessage( GetDlgItem(hwndDlg,IDC_RADIOSS3), BM_SETCHECK, BST_CHECKED, 0 ); + if( theExportSceneStruct.nOverSampling == 8 ) SendMessage( GetDlgItem(hwndDlg,IDC_RADIOSS4), BM_SETCHECK, BST_CHECKED, 0 ); + if( theExportSceneStruct.bShowLumel ) SendMessage( GetDlgItem(hwndDlg,IDC_SHOWLUMEL), BM_SETCHECK, BST_CHECKED, 0 ); else SendMessage( GetDlgItem(hwndDlg,IDC_SHOWLUMEL), BM_SETCHECK, BST_UNCHECKED, 0 ); - + if( theExportSceneStruct.bExportBgColor ) SendMessage( GetDlgItem(hwndDlg,IDC_EXPORT_BG_COLOR), BM_SETCHECK, BST_CHECKED, 0 ); else @@ -120,26 +131,24 @@ INT_PTR CALLBACK OptionsDialogCallback ( SendMessage( GetDlgItem(hwndDlg,IDC_TEST_SURFACE_LIGHT), BM_SETCHECK, BST_CHECKED, 0 ); else SendMessage( GetDlgItem(hwndDlg,IDC_TEST_SURFACE_LIGHT), BM_SETCHECK, BST_UNCHECKED, 0 ); - sprintf( tmp, "%f", theExportSceneStruct.SurfaceLightingCellSize ); - SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLSIZE), WM_SETTEXT, 0, (long)tmp ); - sprintf( tmp, "%f", theExportSceneStruct.SurfaceLightingDeltaZ ); - SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLDELTAZ), WM_SETTEXT, 0, (long)tmp ); + + SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLSIZE), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(toString(theExportSceneStruct.SurfaceLightingCellSize))); + SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLDELTAZ), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(toString(theExportSceneStruct.SurfaceLightingDeltaZ))); } break; case WM_COMMAND: if( HIWORD(wParam) == BN_CLICKED ) - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDC_BUTTONEXPORTLIGHTING: { - char sTemp[1024]; - strcpy(sTemp,theExportSceneStruct.sExportLighting.c_str()); - if( theCNelExport.SelectDir(hwndDlg, "LightMaps Directory", sTemp ) ) + std::string sTemp = theExportSceneStruct.sExportLighting; + if( theCNelExport.SelectDir(hwndDlg, _T("LightMaps Directory"), sTemp ) ) { theExportSceneStruct.sExportLighting = sTemp; - SendMessage( GetDlgItem(hwndDlg,IDC_EDITEXPORTLIGHTING), WM_SETTEXT, 0, (long)theExportSceneStruct.sExportLighting.c_str() ); + SendMessage( GetDlgItem(hwndDlg, IDC_EDITEXPORTLIGHTING), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(theExportSceneStruct.sExportLighting) ); } } break; @@ -148,53 +157,67 @@ INT_PTR CALLBACK OptionsDialogCallback ( break; case IDOK: { - char tmp[1024]; // The result goes in theExportSceneStruct if( SendMessage( GetDlgItem(hwndDlg,IDC_EXCLUDE), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.bExcludeNonSelected = true; else theExportSceneStruct.bExcludeNonSelected = false; + if( SendMessage( GetDlgItem(hwndDlg,IDC_SHADOW), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.bShadow = true; else theExportSceneStruct.bShadow = false; + if( SendMessage( GetDlgItem(hwndDlg,IDC_CHECKEXPORTLIGHTING), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.bExportLighting = true; else theExportSceneStruct.bExportLighting = false; + if( SendMessage( GetDlgItem(hwndDlg,IDC_CHECKOUTPUTLIGHTMAPLOG), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.OutputLightmapLog = true; else theExportSceneStruct.OutputLightmapLog = false; - SendMessage( GetDlgItem(hwndDlg,IDC_EDITEXPORTLIGHTING), WM_GETTEXT, 1024, (long)tmp ); - theExportSceneStruct.sExportLighting = tmp; + + TCHAR tmp[1024]; + SendMessage( GetDlgItem(hwndDlg,IDC_EDITEXPORTLIGHTING), WM_GETTEXT, 1024, (LPARAM)tmp ); + theExportSceneStruct.sExportLighting = tStrToUtf8(tmp); + if( SendMessage( GetDlgItem(hwndDlg,IDC_RADIONORMALEXPORTLIGHTING), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.nExportLighting = 0; + if( SendMessage( GetDlgItem(hwndDlg,IDC_RADIORADIOSITYEXPORTLIGHTING), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.nExportLighting = 1; - SendMessage( GetDlgItem(hwndDlg,IDC_EDITLUMELSIZE), WM_GETTEXT, 1024, (long)tmp ); - NLMISC::fromString(tmp, theExportSceneStruct.rLumelSize); + + SendMessage( GetDlgItem(hwndDlg,IDC_EDITLUMELSIZE), WM_GETTEXT, 1024, (LPARAM)tmp ); + NLMISC::fromString(tStrToUtf8(tmp), theExportSceneStruct.rLumelSize); if( SendMessage( GetDlgItem(hwndDlg,IDC_RADIOSS1), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.nOverSampling = 1; + if( SendMessage( GetDlgItem(hwndDlg,IDC_RADIOSS2), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.nOverSampling = 2; + if( SendMessage( GetDlgItem(hwndDlg,IDC_RADIOSS3), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.nOverSampling = 4; + if( SendMessage( GetDlgItem(hwndDlg,IDC_RADIOSS4), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.nOverSampling = 8; + if( SendMessage( GetDlgItem(hwndDlg,IDC_SHOWLUMEL), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) theExportSceneStruct.bShowLumel = true; else theExportSceneStruct.bShowLumel = false; + theExportSceneStruct.bExportBgColor = ( SendMessage( GetDlgItem(hwndDlg,IDC_EXPORT_BG_COLOR), BM_GETCHECK, 0, 0 ) == BST_CHECKED ); // SurfaceLighting theExportSceneStruct.bTestSurfaceLighting= (SendMessage( GetDlgItem(hwndDlg,IDC_TEST_SURFACE_LIGHT), BM_GETCHECK, 0, 0 ) == BST_CHECKED); - SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLSIZE), WM_GETTEXT, 1024, (long)tmp ); - NLMISC::fromString(tmp, theExportSceneStruct.SurfaceLightingCellSize); - SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLDELTAZ), WM_GETTEXT, 1024, (long)tmp ); - NLMISC::fromString(tmp, theExportSceneStruct.SurfaceLightingDeltaZ); + + SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLSIZE), WM_GETTEXT, 1024, (LPARAM)tmp ); + NLMISC::fromString(tStrToUtf8(tmp), theExportSceneStruct.SurfaceLightingCellSize); + + SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLDELTAZ), WM_GETTEXT, 1024, (LPARAM)tmp ); + NLMISC::fromString(tStrToUtf8(tmp), theExportSceneStruct.SurfaceLightingDeltaZ); // End the dialog EndDialog(hwndDlg, TRUE); @@ -207,9 +230,9 @@ INT_PTR CALLBACK OptionsDialogCallback ( EndDialog(hwndDlg,1); break; - case WM_DESTROY: + case WM_DESTROY: break; - + default: return FALSE; } @@ -220,10 +243,10 @@ extern HINSTANCE hInstance; static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { // Set locale to english - setlocale (LC_NUMERIC, "English"); + setlocale (LC_NUMERIC, "C"); BOOL ret = TRUE; - switch (msg) + switch (msg) { case WM_INITDIALOG: { @@ -234,7 +257,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP if (hModule) { // Get module file name - char moduldeFileName[512]; + TCHAR moduldeFileName[512]; if (GetModuleFileName (hModule, moduldeFileName, 512)) { // Get version info size @@ -250,41 +273,41 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP { uint *versionTab; uint versionSize; - if (VerQueryValue (buffer, "\\", (void**)&versionTab, &versionSize)) + if (VerQueryValue (buffer, _T("\\"), (void**)&versionTab, &versionSize)) { // Get the pointer on the structure VS_FIXEDFILEINFO *info=(VS_FIXEDFILEINFO*)versionTab; if (info) { // Setup version number - char version[512]; - sprintf (version, "Version %d.%d.%d.%d", - info->dwFileVersionMS>>16, - info->dwFileVersionMS&0xffff, - info->dwFileVersionLS>>16, + TCHAR version[512]; + _stprintf(version, _T("Version %d.%d.%d.%d"), + info->dwFileVersionMS>>16, + info->dwFileVersionMS&0xffff, + info->dwFileVersionLS>>16, info->dwFileVersionLS&0xffff); SetWindowText (GetDlgItem (hWnd, IDC_VERSION), version); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "VS_FIXEDFILEINFO * is NULL"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("VS_FIXEDFILEINFO * is NULL")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "VerQueryValue failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("VerQueryValue failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetFileVersionInfo failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetFileVersionInfo failed")); // Free the buffer delete [] buffer; } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetFileVersionInfoSize failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetFileVersionInfoSize failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetModuleFileName failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetModuleFileName failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "hInstance NULL"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("hInstance NULL")); } break; @@ -307,7 +330,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Get time TimeValue time=theCNelExport._Ip->GetTime(); - + // Get node count int nNumSelNode=theCNelExport._Ip->GetSelNodeCount(); @@ -324,15 +347,14 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP nlwarning("pNode->GetName()"); // Name of the node - char sNodeMsg[256]; - nlwarning (sNodeMsg, "Save %s model...", pNode->GetName()); + TCHAR sNodeMsg[256]; + _stprintf(sNodeMsg, _T("Save %s model..."), pNode->GetName()); // It is a zone ? if (RPO::isZone (*pNode, time)) { // Save path - char sSavePath[256]; - strcpy (sSavePath, pNode->GetName()); + std::string sSavePath = tStrToUtf8(pNode->GetName()); // Choose a file to export if (!CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_DONTEXPORT, 0)) @@ -342,29 +364,26 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP if (!theCNelExport.exportZone (sSavePath, *pNode, time)) { // Error message - char sErrorMsg[512]; - sprintf (sErrorMsg, "Error exporting the zone %s in the file\n%s", pNode->GetName(), sSavePath); - MessageBox (hWnd, sErrorMsg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string sErrorMsg = toString("Error exporting the zone %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str()); + MessageBox (hWnd, utf8ToTStr(sErrorMsg), L"NeL export", MB_OK|MB_ICONEXCLAMATION); } } } else if (CExportNel::isVegetable (*pNode, time)) { // Save path - char sSavePath[256]; - strcpy (sSavePath, pNode->GetName()); + std::string sSavePath = tStrToUtf8(pNode->GetName()); // Choose a file to export if (!CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_DONTEXPORT, 0)) if (theCNelExport.SelectFileForSave(hWnd, sNodeMsg, vegetableFilter, sSavePath)) { // Export the mesh - if (!theCNelExport.exportVegetable (sSavePath, *pNode, time)) + if (!theCNelExport.exportVegetable (sSavePath.c_str(), *pNode, time)) { // Error message - char sErrorMsg[512]; - sprintf (sErrorMsg, "Error exporting the vegetable %s in the file\n%s", pNode->GetName(), sSavePath); - MessageBox (hWnd, sErrorMsg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string sErrorMsg = toString("Error exporting the vegetable %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str()); + MessageBox (hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -372,8 +391,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP else if (CExportNel::isLodCharacter (*pNode, time)) { // Save path - char sSavePath[256]; - strcpy (sSavePath, pNode->GetName()); + std::string sSavePath = tStrToUtf8(pNode->GetName()); // Choose a file to export if (!CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_DONTEXPORT, 0)) @@ -383,9 +401,8 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP if (!theCNelExport.exportLodCharacter (sSavePath, *pNode, time)) { // Error message - char sErrorMsg[512]; - sprintf (sErrorMsg, "Error exporting the lod character %s in the file\n%s", pNode->GetName(), sSavePath); - MessageBox (hWnd, sErrorMsg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string sErrorMsg = toString("Error exporting the lod character %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str()); + MessageBox (hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -393,8 +410,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP else if (CExportNel::isMesh (*pNode, time)) { // Save path - char sSavePath[256]; - strcpy (sSavePath, pNode->GetName()); + std::string sSavePath = tStrToUtf8(pNode->GetName()); // Choose a file to export if (!CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_DONTEXPORT, 0)) @@ -408,9 +424,8 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP if (!theCNelExport.exportMesh (sSavePath, *pNode, time)) { // Error message - char sErrorMsg[512]; - sprintf (sErrorMsg, "Error exporting the mesh %s in the file\n%s", pNode->GetName(), sSavePath); - MessageBox (hWnd, sErrorMsg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string sErrorMsg = toString("Error exporting the mesh %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str()); + MessageBox (hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION); } // Delete the skeleton pointer if (pSkinShape) @@ -433,7 +448,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Get time TimeValue time=theCNelExport._Ip->GetTime(); - + // Get node count uint nNumSelNode=theCNelExport._Ip->GetSelNodeCount(); @@ -446,24 +461,20 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP nlassert (vectNode.size()!=0); // Name of the node - char sNodeMsg[256]; - sprintf (sNodeMsg, "Save animations..."); // Save path - char sSavePath[256]; - strcpy (sSavePath, (*vectNode.begin())->GetName()); + std::string sSavePath = tStrToUtf8((*vectNode.begin())->GetName()); // Choose a file to export - if (theCNelExport.SelectFileForSave (hWnd, sNodeMsg, (LOWORD(wParam)==ID_SAVE_MODEL_ANIM)?animModelFilter:animModelFilter, + if (theCNelExport.SelectFileForSave (hWnd, _T("Save animations..."), (LOWORD(wParam)==ID_SAVE_MODEL_ANIM)?animModelFilter:animModelFilter, sSavePath)) { // Export the zone if (!theCNelExport.exportAnim (sSavePath, vectNode, time, LOWORD(wParam)==ID_SAVE_SCENE_ANIM)) { // Error message - char sErrorMsg[512]; - sprintf (sErrorMsg, "Error exporting animation %s in the file\n%s", (*vectNode.begin())->GetName(), sSavePath); - MessageBox (hWnd, sErrorMsg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string sErrorMsg = toString("Error exporting animation %s in the file\n%s", tStrToUtf8((*vectNode.begin())->GetName()).c_str(), sSavePath.c_str()); + MessageBox(hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION); } } } @@ -472,7 +483,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // --- case ID_SAVECOLLISION: { - + // Init the exporter nlassert (theIP); @@ -480,7 +491,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Get time TimeValue time=theCNelExport._Ip->GetTime(); - + // Get node count int nNumSelNode=theCNelExport._Ip->GetSelNodeCount(); @@ -505,23 +516,20 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP } // Name of the node - char sNodeMsg[256]; - sprintf (sNodeMsg, "Save collision mesh build..."); // Save path - char sSavePath[256]; - strcpy (sSavePath, ""); + std::string sSavePath; // Choose a file to export // ULONG SelectDir(HWND Parent, char* Title, char* Path); // if (theCNelExport.SelectFileForSave(hWnd, sNodeMsg, collisionFilter, sSavePath)) - if (theCNelExport.SelectDir(hWnd, sNodeMsg, sSavePath)) + if (theCNelExport.SelectDir(hWnd, _T("Save collision mesh build..."), sSavePath)) { // Export the mesh if (!theCNelExport.exportCollision (sSavePath, nodes, time)) { // Error message - MessageBox (hWnd, "Error during export collision", "NeL export", MB_OK|MB_ICONEXCLAMATION); + MessageBox (hWnd, _T("Error during export collision"), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION); } } @@ -547,32 +555,27 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Init the exporter nlassert (theIP); theCNelExport.init (false, true, theIP, true); - + uint nNumSelNode = theCNelExport._Ip->GetSelNodeCount(); // Save all selected objects if (nNumSelNode) - { + { std::vector vectNode; theCNelExport.getSelectedNode (vectNode); nlassert (vectNode.size()!=0); - char sDialogMsg[256]; - sprintf (sDialogMsg, "Save SWT..."); - // Save path - char sSavePath[256]; - strcpy (sSavePath, (*vectNode.begin())->GetName()); + std::string sSavePath = tStrToUtf8((*vectNode.begin())->GetName()); - if (theCNelExport.SelectFileForSave (hWnd, sDialogMsg, SWTFilter, sSavePath)) + if (theCNelExport.SelectFileForSave (hWnd, _T("Save SWT..."), SWTFilter, sSavePath)) { // Export the swt if (!theCNelExport.exportSWT (sSavePath, vectNode)) { // Error message - char sErrorMsg[512]; - sprintf (sErrorMsg, "Error exporting SWT %s in the file\n%s", (*vectNode.begin())->GetName(), sSavePath); - MessageBox (hWnd, sErrorMsg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string sErrorMsg = toString("Error exporting SWT %s in the file\n%s", tStrToUtf8((*vectNode.begin())->GetName()).c_str(), sSavePath.c_str()); + MessageBox(hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION); } } } @@ -584,10 +587,8 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Init the exporter nlassert (theIP); theCNelExport.init (false, true, theIP, true); - - char sConfigFileName[512]; - strcpy( sConfigFileName, theCNelExport._Ip->GetDir(APP_PLUGCFG_DIR) ); - strcat( sConfigFileName, "\\NelExportScene.cfg" ); + + std::string sConfigFileName = tStrToUtf8(theCNelExport._Ip->GetDir(APP_PLUGCFG_DIR)) + "\\NelExportScene.cfg"; // Do a modal dialog box to choose the scene export options if( DialogBox( hInstance, @@ -600,7 +601,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP COFile outputFile; if( outputFile.open(sConfigFileName) ) theExportSceneStruct.serial( outputFile ); - } + } // EXPORT THE SCENE // theCNelExport.exportScene( vectNode ); } @@ -612,7 +613,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Init the exporter nlassert (theIP); theCNelExport.init (false, true, theIP, true); - + // Build a seleted set std::set listNode; @@ -635,29 +636,27 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Init the exporter nlassert (theIP); theCNelExport.init (false, true, theIP, true); - + uint nNumSelNode = theCNelExport._Ip->GetSelNodeCount(); // done in dllentry registerSerial3d(); - // All the selected nodes are considered as a scene + // All the selected nodes are considered as a scene if( nNumSelNode > 0 ) - { + { std::vector vectNode; theCNelExport.getSelectedNode (vectNode); nlassert (vectNode.size()!=0); - char sSavePath[256]; - strcpy (sSavePath, (*vectNode.begin())->GetName()); + std::string sSavePath = tStrToUtf8((*vectNode.begin())->GetName()); - if (theCNelExport.SelectFileForSave (hWnd, "Save Instance group", InstanceGroupFilter, sSavePath)) + if (theCNelExport.SelectFileForSave (hWnd, _T("Save Instance group"), InstanceGroupFilter, sSavePath)) { // Export the instance group if (!theCNelExport.exportInstanceGroup( sSavePath, vectNode)) { // Error message - char sErrorMsg[512]; - sprintf (sErrorMsg, "Error exporting instance group %s", sSavePath); - MessageBox (hWnd, sErrorMsg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string sErrorMsg = toString("Error exporting instance group %s", sSavePath.c_str()); + MessageBox(hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION); } } } @@ -669,12 +668,12 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Init the exporter nlassert (theIP); theCNelExport.init (false, true, theIP, true); - + uint nNumSelNode = theCNelExport._Ip->GetSelNodeCount(); if (nNumSelNode!=1) { // Select only the root of the skeleton - MessageBox (hWnd, "Select the root node of the skeleton.", "NeL export", MB_OK|MB_ICONEXCLAMATION); + MessageBox (hWnd, _T("Select the root node of the skeleton."), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION); } else { @@ -682,31 +681,29 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP INode* pNode=theCNelExport._Ip->GetSelNode (0); // Save path - char sSavePath[256]; - strcpy (sSavePath, "*.skel"); + std::string sSavePath = "*.skel"; // Select the file - if (theCNelExport.SelectFileForSave (hWnd, "Save skeleton...", skeletonFilter, sSavePath)) + if (theCNelExport.SelectFileForSave (hWnd, _T("Save skeleton..."), skeletonFilter, sSavePath)) { // Export the zone if (!theCNelExport.exportSkeleton (sSavePath, pNode, theCNelExport._Ip->GetTime())) { // Error message - char sErrorMsg[512]; - sprintf (sErrorMsg, "Error exporting skeleton %s in the file\n%s", pNode->GetName(), sSavePath); - MessageBox (hWnd, sErrorMsg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string sErrorMsg = toString("Error exporting skeleton %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str()); + MessageBox(hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION); } } } } break; - case ID_TEST_INTERFACE_MESH: - { - nlassert (theIP); + case ID_TEST_INTERFACE_MESH: + { + nlassert (theIP); theCNelExport.init (false, true, theIP, true); // Get time TimeValue time = theCNelExport._Ip->GetTime(); - + // Get node count uint nNumSelNode=theCNelExport._Ip->GetSelNodeCount(); @@ -716,41 +713,36 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Get the nodes std::vector vectNode; theCNelExport.getSelectedNode (vectNode); - if (vectNode.size() == 0) + if (vectNode.empty()) { - ::MessageBox(hWnd, "No nodes selected", "Error", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(hWnd, _T("No nodes selected"), _T("Error"), MB_OK|MB_ICONEXCLAMATION); return ret; } - // create a mem displayer, that will receive errors + // create a mem displayer, that will receive errors try - { + { // test all nodes for(std::vector::iterator it = vectNode.begin(); it != vectNode.end(); ++it) { nlassert(theCNelExport._ExportNel); if (!theCNelExport._ExportNel->selectInterfaceVertices(**it, time)) { - ::MessageBox(NULL, "Unable to bind interface of mesh %s", (*it)->GetName(), MB_OK | MB_ICONEXCLAMATION); + ::MessageBox(NULL, _T("Unable to bind interface of mesh %s"), (*it)->GetName(), MB_OK | MB_ICONEXCLAMATION); break; - } - } + } + } theIP->RedrawViews(time); } - catch(std::exception &e) - { - ::MessageBox(hWnd, e.what(), "Error", MB_OK | MB_ICONEXCLAMATION); - } + catch(const std::exception &e) + { + ::MessageBox(hWnd, utf8ToTStr(e.what()), _T("Error"), MB_OK | MB_ICONEXCLAMATION); + } } } - break; + break; } - - break; - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - theCNelExport._Ip->RollupMouseMessage(hWnd,msg,wParam,lParam); + break; default: @@ -768,7 +760,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP //--- CNelExport ------------------------------------------------------- CNelExport::CNelExport() : _ErrorInDialog(true), _TerminateOnFileOpenIssues(false) { - _Ip = NULL; + _Ip = NULL; theHPanel = NULL; } @@ -777,7 +769,7 @@ CNelExport::~CNelExport() } -void CNelExport::BeginEditParams(Interface *_Ip,IUtil *iu) +void CNelExport::BeginEditParams(Interface *_Ip,IUtil *iu) { theIP = _Ip; if (_ExportNel) @@ -789,8 +781,8 @@ void CNelExport::BeginEditParams(Interface *_Ip,IUtil *iu) theHBar = GetDlgItem(theHPanel,ID_BAR); SendMessage(theHBar,PBM_SETPOS,0,0); } - -void CNelExport::EndEditParams(Interface *_Ip,IUtil *iu) + +void CNelExport::EndEditParams(Interface *_Ip,IUtil *iu) { this->_Ip = NULL; if (_ExportNel) @@ -828,14 +820,14 @@ void CNelExport::getSelectedNode (std::vector& vectNode) void CNelExport::initOptions() { // Initialization of theExportSceneStruct - char sConfigFileName[512]; - strcpy( sConfigFileName, theCNelExport._Ip->GetDir(APP_PLUGCFG_DIR) ); - strcat( sConfigFileName, "\\NelExportScene.cfg" ); + std::string sConfigFileName = tStrToUtf8(theCNelExport._Ip->GetDir(APP_PLUGCFG_DIR)) + "\\NelExportScene.cfg"; + // MessageBox (hWnd, sConfigFileName, "sConfigFileName", MB_OK|MB_ICONEXCLAMATION); - if( theCNelExport.FileExists(sConfigFileName) ) + if( CFile::fileExists(sConfigFileName) ) { // Serial the configuration - try { + try + { CIFile inputFile; if( inputFile.open(sConfigFileName) ) { @@ -845,8 +837,7 @@ void CNelExport::initOptions() } catch(...) { - MessageBox( theCNelExport._Ip->GetMAXHWnd(), "NelExportScene.cfg corrupted or old version", - "Error", MB_OK|MB_ICONEXCLAMATION ); + MessageBox( theCNelExport._Ip->GetMAXHWnd(), _T("NelExportScene.cfg corrupted or old version"), _T("Error"), MB_OK|MB_ICONEXCLAMATION ); } } } @@ -861,7 +852,7 @@ void CNelExport::init (bool view, bool errorInDialog, Interface *ip, bool loadSt // Create a new nelexport _Ip = ip; - + // Load the options if (loadStruct) theCNelExport.initOptions(); diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export.def b/code/nel/tools/3d/plugin_max/nel_export/nel_export.def index cd87c4dc0..8e50aaeed 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export.def +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export.def @@ -1,4 +1,4 @@ -LIBRARY nelexport.dlu +;LIBRARY nelexport.dlu EXPORTS LibDescription @1 LibNumberClasses @2 diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export.h b/code/nel/tools/3d/plugin_max/nel_export/nel_export.h index f6f0b145a..3cf20cf47 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export.h +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export.h @@ -49,7 +49,7 @@ public: CNelExport (); - ~CNelExport(); + virtual ~CNelExport(); void init (bool view, bool errorInDialog, Interface *ip, bool loadStruct); @@ -59,21 +59,21 @@ public: bool freeExported(void); void getSelectedNode (std::vector& vectNode); - bool exportZone (const char *sName, INode& node, TimeValue time); - bool exportMesh (const char *sPath, INode& node, TimeValue time); - bool exportAnim (const char *sPath, std::vector& vectNode, TimeValue time, bool scene); - bool exportSWT (const char *sPath, std::vector& vectNode); + bool exportZone (const std::string &sName, INode& node, TimeValue time); + bool exportMesh (const std::string &sPath, INode& node, TimeValue time); + bool exportAnim (const std::string &sPath, std::vector& vectNode, TimeValue time, bool scene); + bool exportSWT (const std::string &sPath, std::vector& vectNode); bool exportInstanceGroup (std::string filename, std::vector& vectNode); - bool exportSkeleton (const char *sPath, INode* pNode, TimeValue time); + bool exportSkeleton (const std::string &sPath, INode* pNode, TimeValue time); - bool exportCollision (const char *sPath, std::vector &nodes, TimeValue time); + bool exportCollision (const std::string &sPath, std::vector &nodes, TimeValue time); - bool exportPACSPrimitives (const char *sPath, std::vector &nodes, TimeValue time); + bool exportPACSPrimitives (const std::string &sPath, std::vector &nodes, TimeValue time); - bool exportVegetable (const char *sPath, INode& node, TimeValue time); + bool exportVegetable (const std::string &sPath, INode& node, TimeValue time); - bool exportLodCharacter (const char *sPath, INode& node, TimeValue time); + bool exportLodCharacter (const std::string &sPath, INode& node, TimeValue time); void viewMesh (TimeValue time); @@ -81,16 +81,8 @@ public: static void deleteLM(INode& ZeNode); // the export scene struct MUST be initialized before calling this fn void OnNodeProperties (const std::set &listNode); - ULONG ExtractFileName(char* Path, char* Name); - ULONG ExtractPath(char* FullPath, char* Path); - ULONG SelectFileForLoad(HWND Parent, char* Title, const char* Mask, char* FileName); - ULONG SelectFileForSave(HWND Parent, char* Title, const char* Mask, char* FileName); - ULONG SelectDir(HWND Parent, char* Title, char* Path); - static ULONG FileExists(const char* FileName); - ULONG GetFileSize(char* FileName); - ULONG ProcessDir(char* Dir, const char* Mask, unsigned long flag, ULONG Fnct(char* FileName) ); - ULONG CleanFileName(char* FileName); - ULONG CreateBAKFile(char* FileName); + ULONG SelectFileForSave(HWND Parent, const TCHAR* Title, const TCHAR* Mask, std::string &FileName); + ULONG SelectDir(HWND Parent, const TCHAR* Title, std::string &Path); // The nel export objtect CExportNel *_ExportNel; @@ -113,11 +105,11 @@ class CNelExportClassDesc:public ClassDesc2 public: int IsPublic() {return 1;} void * Create(BOOL loading = FALSE); - const TCHAR * ClassName() {return _T("NeL Export");} + const MCHAR * ClassName() {return _M("NeL Export");} SClass_ID SuperClassID() {return UTILITY_CLASS_ID;} Class_ID ClassID() {return CNELEXPORT_CLASS_ID;} - const TCHAR* Category() {return _T("NeL Tools");} - const TCHAR* InternalName() { return _T("NeL export and view"); } // returns fixed parsable name (scripter-visible name) + const MCHAR* Category() {return _M("NeL Tools");} + const MCHAR* InternalName() { return _M("NeL export and view"); } // returns fixed parsable name (scripter-visible name) HINSTANCE HInstance() { return hInstance; } // returns owning module handle }; diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_collision.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_collision.cpp index 8ff853031..8bfcf3e5d 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_collision.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_collision.cpp @@ -30,7 +30,7 @@ using namespace NLPACS; // -------------------------------------------------- -bool CNelExport::exportCollision (const char *sPath, std::vector &nodes, TimeValue time) +bool CNelExport::exportCollision (const std::string &sPath, std::vector &nodes, TimeValue time) { // get list of CMB froms nodes. std::vector > meshBuildList; @@ -43,7 +43,7 @@ bool CNelExport::exportCollision (const char *sPath, std::vector &nodes // ULONG SelectDir(HWND Parent, char* Title, char* Path); std::string path = std::string(sPath); - if (path.size() == 0 || path[path.size()-1] != '\\' && path[path.size()-1] != '/') + if (path.empty() || path[path.size()-1] != '\\' && path[path.size()-1] != '/') path.insert(path.end(), '/'); if (meshBuildList.empty()) return true; @@ -148,7 +148,7 @@ bool CNelExport::exportCollision (const char *sPath, INode& node, Interface& _Ip */ // -------------------------------------------------- -bool CNelExport::exportPACSPrimitives (const char *sPath, std::vector &nodes, TimeValue time) +bool CNelExport::exportPACSPrimitives (const std::string &sPath, std::vector &nodes, TimeValue time) { // Build the primitive block NLPACS::CPrimitiveBlock primitiveBlock; @@ -172,12 +172,12 @@ bool CNelExport::exportPACSPrimitives (const char *sPath, std::vector & } else { - nlwarning ("Can't init XML stream with file %s", sPath); + nlwarning ("Can't init XML stream with file %s", sPath.c_str()); } } else { - nlwarning ("Can't open the file %s for writing", sPath); + nlwarning ("Can't open the file %s for writing", sPath.c_str()); } } return false; diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp index 46d88757b..3be72a9bb 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp @@ -32,21 +32,17 @@ using namespace NLMISC; // -------------------------------------------------- -bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) +bool CNelExport::exportMesh (const std::string &sPath, INode& node, TimeValue time) { // Result to return bool bRet = false; - char tempFileName[MAX_PATH] = { 0 }; - char tempPathBuffer[MAX_PATH] = { 0 }; - + std::string tempFileName; + std::string tempPathBuffer; + try - { - DWORD dwRetVal = GetTempPathA(MAX_PATH, tempPathBuffer); - if (dwRetVal > MAX_PATH || (dwRetVal == 0)) - nlerror("GetTempPath failed"); - UINT uRetVal = GetTempFileNameA(tempPathBuffer, TEXT("_nel_export_mesh_"), 0, tempFileName); - if (uRetVal == 0) - nlerror("GetTempFileName failed"); + { + tempPathBuffer = NLMISC::CPath::getTemporaryDirectory(); + NLMISC::CFile::getTemporaryOutputFilename(tempPathBuffer + "_nel_export_mesh_", tempFileName); // Eval the object a time ObjectState os = node.EvalWorldState(time); @@ -85,7 +81,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) skeletonShape = NULL; } } - + DWORD t = timeGetTime(); if (InfoLog) InfoLog->display("Beg buildShape %s \n", node.GetName()); @@ -93,7 +89,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) IShape *pShape = _ExportNel->buildShape(node, time, mapIdPtr, true); if (InfoLog) InfoLog->display("End buildShape in %d ms \n", timeGetTime()-t); - + // Conversion success ? if (pShape) { @@ -105,7 +101,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) { // Create a streamable shape CShapeStream shapeStream(pShape); - + // Serial the shape shapeStream.serial(file); @@ -126,12 +122,13 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) { } - remove(tempFileName); + + CFile::deleteFile(tempFileName); } } else { - nlwarning("Failed to create file %s", tempFileName); + nlwarning("Failed to create file %s", tempFileName.c_str()); if (_TerminateOnFileOpenIssues) nelExportTerminateProcess(); } @@ -148,7 +145,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) catch (...) { nlwarning("Failed to delete pShape pointer! Something might be wrong."); - remove(tempFileName); + CFile::deleteFile(tempFileName); bRet = false; } @@ -173,7 +170,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) } else { - nlwarning("Failed to open file: %s", tempFileName); + nlwarning("Failed to open file: %s", tempFileName.c_str()); if (_TerminateOnFileOpenIssues) nelExportTerminateProcess(); } @@ -181,7 +178,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) catch (...) { nlwarning("Failed to verify shape. Must crash now."); - remove(tempFileName); + CFile::deleteFile(tempFileName); bRet = false; } @@ -196,16 +193,9 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) if (bRet) { - try - { - remove(sPath); - } - catch (...) - { - - } + CFile::deleteFile(sPath); CFile::moveFile(sPath, tempFileName); - nlinfo("MOVE %s -> %s", tempFileName, sPath); + nlinfo("MOVE %s -> %s", tempFileName.c_str(), sPath.c_str()); } return bRet; @@ -213,7 +203,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) // -------------------------------------------------- -bool CNelExport::exportVegetable (const char *sPath, INode& node, TimeValue time) +bool CNelExport::exportVegetable (const std::string &sPath, INode& node, TimeValue time) { bool bRet=false; @@ -233,7 +223,7 @@ bool CNelExport::exportVegetable (const char *sPath, INode& node, TimeValue time // All is good bRet=true; } - catch (Exception &e) + catch (const Exception &e) { // Message box const char *message = e.what(); @@ -246,40 +236,36 @@ bool CNelExport::exportVegetable (const char *sPath, INode& node, TimeValue time // -------------------------------------------------- -bool CNelExport::exportAnim (const char *sPath, std::vector& vectNode, TimeValue time, bool scene) +bool CNelExport::exportAnim (const std::string &sPath, std::vector& vectNode, TimeValue time, bool scene) { // Result to return bool bRet=false; - char tempFileName[MAX_PATH] = { 0 }; - char tempPathBuffer[MAX_PATH] = { 0 }; - + std::string tempFileName; + std::string tempPathBuffer; + try { - DWORD dwRetVal = GetTempPathA(MAX_PATH, tempPathBuffer); - if (dwRetVal > MAX_PATH || (dwRetVal == 0)) - nlerror("GetTempPath failed"); - UINT uRetVal = GetTempFileNameA(tempPathBuffer, TEXT("_nel_export_mesh_"), 0, tempFileName); - if (uRetVal == 0) - nlerror("GetTempFileName failed"); - + tempPathBuffer = NLMISC::CPath::getTemporaryDirectory(); + NLMISC::CFile::getTemporaryOutputFilename(tempPathBuffer + "_nel_export_mesh_", tempFileName); + // Create an animation file CAnimation animFile; // For each node to export for (uint n=0; n& vectNode, T bool root = vectNode[n]->GetParentNode () == _Ip->GetRootNode(); // Add animation - _ExportNel->addAnimation (animFile, *vectNode[n], nodeName.c_str(), root); + _ExportNel->addAnimation (animFile, *vectNode[n], nodeName.c_str(), root); } if (vectNode.size()) @@ -327,7 +313,7 @@ bool CNelExport::exportAnim (const char *sPath, std::vector& vectNode, T } else { - nlwarning("Failed to open file: %s", tempFileName); + nlwarning("Failed to open file: %s", tempFileName.c_str()); bRet = false; if (_TerminateOnFileOpenIssues) nelExportTerminateProcess(); @@ -336,14 +322,14 @@ bool CNelExport::exportAnim (const char *sPath, std::vector& vectNode, T catch (...) { nlwarning("Failed to verify shape. Must crash now."); - remove(tempFileName); + CFile::deleteFile(tempFileName); bRet = false; } } - catch (Exception& e) + catch (const Exception& e) { if (_ErrorInDialog) - MessageBox (NULL, e.what(), "NeL export", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(e.what()), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION); else nlwarning ("ERROR : %s", e.what ()); } @@ -351,9 +337,9 @@ bool CNelExport::exportAnim (const char *sPath, std::vector& vectNode, T else { if (_ErrorInDialog) - MessageBox (NULL, "Can't open the file for writing.", "NeL export", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, _T("Can't open the file for writing."), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION); else - nlwarning ("ERROR : Can't open the file (%s) for writing", tempFileName); + nlwarning ("ERROR : Can't open the file (%s) for writing", tempFileName.c_str()); if (_TerminateOnFileOpenIssues) nelExportTerminateProcess(); } @@ -367,23 +353,16 @@ bool CNelExport::exportAnim (const char *sPath, std::vector& vectNode, T if (bRet) { - try - { - remove(sPath); - } - catch (...) - { - - } + CFile::deleteFile(sPath); CFile::moveFile(sPath, tempFileName); - nlinfo("MOVE %s -> %s", tempFileName, sPath); + nlinfo("MOVE %s -> %s", tempFileName.c_str(), sPath.c_str()); } return bRet; } // -------------------------------------------------- -bool CNelExport::exportSkeleton (const char *sPath, INode* pNode, TimeValue time) +bool CNelExport::exportSkeleton (const std::string &sPath, INode* pNode, TimeValue time) { // Result to return bool bRet=false; @@ -401,14 +380,14 @@ bool CNelExport::exportSkeleton (const char *sPath, INode* pNode, TimeValue time { // Create a streamable shape CShapeStream shapeStream (skeletonShape); - + // Serial the shape shapeStream.serial (file); // All is good bRet=true; } - catch (Exception &e) + catch (const Exception &e) { nlwarning (e.what()); } @@ -422,7 +401,7 @@ bool CNelExport::exportSkeleton (const char *sPath, INode* pNode, TimeValue time // -------------------------------------------------- -bool CNelExport::exportLodCharacter (const char *sPath, INode& node, TimeValue time) +bool CNelExport::exportLodCharacter (const std::string &sPath, INode& node, TimeValue time) { // Result to return bool bRet=false; diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_filetools.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_filetools.cpp index 5bafa24c5..11020e4fc 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_filetools.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_filetools.cpp @@ -18,103 +18,42 @@ #include "nel_export.h" -//-------------------------------------------------------------------------------------------------------------- +#include "nel/misc/path.h" -ULONG CNelExport::ExtractFileName(char* Path, char* Name) -{ - long i,j; - char temp[MAX_PATH]; - - for(j=0,i=strlen(Path)-1 ; i>=0 && Path[i]!='\\' && Path[i]!='//' ; i--,j++) - temp[j]=Path[i]; - temp[j]=0; - - for(i=strlen(temp)-1,j=0 ; i>=0 ; i--,j++) - Name[j]=temp[i]; - Name[j]=0; - - return(1); -} +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif //-------------------------------------------------------------------------------------------------------------- -ULONG CNelExport::ExtractPath(char* FullPath, char* Path) +ULONG CNelExport::SelectFileForSave(HWND Parent, const TCHAR* Title, const TCHAR* Mask, std::string &FileName) { - long i; + TCHAR curdir[MAX_PATH]; + TCHAR fname[MAX_PATH]; - for(i=strlen(FullPath)-1 ; i>=0 && FullPath[i]!='\\' && FullPath[i]!='//' ; i--); - strncpy(Path,FullPath,i+1); - Path[i+1]=0; + std::string path, filename; - return(1); -} - -//-------------------------------------------------------------------------------------------------------------- - -ULONG CNelExport::SelectFileForLoad(HWND Parent, char* Title, const char* Mask, char* FileName) -{ - OPENFILENAME ofn; - char r; - char curdir[MAX_PATH]; - char fname[MAX_PATH]; - - fname[0]=0; if (!FileName[0]) { - GetCurrentDirectory(MAX_PATH,curdir); + path = NLMISC::CPath::getCurrentPath(); } else { - ExtractPath(FileName,curdir); - if (!curdir[0]) + path = NLMISC::CFile::getPath(FileName); + + if (path.empty()) { - GetCurrentDirectory(MAX_PATH,curdir); + path = NLMISC::CPath::getCurrentPath(); } - ExtractFileName(FileName,fname); + + filename = NLMISC::CFile::getFilename(FileName); } - memset(&ofn,0,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof ( OPENFILENAME ); - ofn.hwndOwner = Parent; - ofn.hInstance = GetModuleHandle(NULL); - ofn.lpstrFilter = Mask; - ofn.lpstrCustomFilter = NULL; - ofn.nFilterIndex = 0; - ofn.lpstrFile = fname; - ofn.nMaxFile = 500; - ofn.lpstrTitle = Title; - ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_OVERWRITEPROMPT; - ofn.lpstrDefExt = "*"; - ofn.lpstrInitialDir = curdir; - r=GetOpenFileName ( &ofn ); - strcpy(FileName,fname); - return(r); -} - -//-------------------------------------------------------------------------------------------------------------- - -ULONG CNelExport::SelectFileForSave(HWND Parent, char* Title, const char* Mask, char* FileName) -{ - OPENFILENAME ofn; - char r; - char curdir[MAX_PATH]; - char fname[MAX_PATH]; - - fname[0]=0; - if (!FileName[0]) - { - GetCurrentDirectory(MAX_PATH,curdir); - } - else - { - ExtractPath(FileName,curdir); - if (!curdir[0]) - { - GetCurrentDirectory(MAX_PATH,curdir); - } - ExtractFileName(FileName,fname); - } + // copy path and filename to temporary buffers + _tcscpy_s(curdir, MAX_PATH, utf8ToTStr(path)); + _tcscpy_s(fname, MAX_PATH, utf8ToTStr(filename)); + OPENFILENAME ofn; memset(&ofn,0,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof ( OPENFILENAME ); ofn.hwndOwner = Parent; @@ -126,201 +65,40 @@ ULONG CNelExport::SelectFileForSave(HWND Parent, char* Title, const char* Mask, ofn.nMaxFile = 500; ofn.lpstrTitle = Title; ofn.Flags = OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_OVERWRITEPROMPT; - ofn.lpstrDefExt = "*"; + ofn.lpstrDefExt = _T("*"); ofn.lpstrInitialDir = curdir; - r=GetSaveFileName ( &ofn ); - strcpy(FileName,fname); - return(r); + BOOL r = GetSaveFileName ( &ofn ); + + FileName = tStrToUtf8(fname); + + return r; } //-------------------------------------------------------------------------------------------------------------- -ULONG CNelExport::SelectDir(HWND Parent, char* Title, char* Path) +ULONG CNelExport::SelectDir(HWND Parent, const TCHAR* Title, std::string &Path) { - BROWSEINFO bi; - char str[MAX_PATH]; - ITEMIDLIST* pidl; + TCHAR str[MAX_PATH]; + _tcscpy_s(str, MAX_PATH, utf8ToTStr(Path)); + BROWSEINFO bi; bi.hwndOwner=Parent; bi.pidlRoot=NULL; - bi.pszDisplayName=Path; + bi.pszDisplayName=str; bi.lpszTitle=Title; bi.ulFlags=0; bi.lpfn=0; bi.lParam=0; bi.iImage=0; - pidl=SHBrowseForFolder(&bi); + + PIDLIST_ABSOLUTE pidl = SHBrowseForFolder(&bi); + if (!SHGetPathFromIDList(pidl,str) ) { - return(0); + return 0; } - strcpy(Path,str); - return(1); + + Path = tStrToUtf8(str); + + return 1; } - -//-------------------------------------------------------------------------------------------------------------- - -ULONG CNelExport::FileExists(const char* FileName) -{ - FILE *file; - if ( !strcmp(FileName,"") ) return(0); - file=fopen(FileName,"rb"); - if (!file) return(0); - fclose(file); - return(1); -} - -//-------------------------------------------------------------------------------------------------------------- - -ULONG CNelExport::GetFileSize(char* FileName) -{ - FILE *file; - unsigned long fsize; - - file=fopen(FileName,"rb"); - if (!file) return(0); - fseek(file,0,SEEK_END); - fsize=ftell(file); - fclose(file); - return(fsize); -} - -//-------------------------------------------------------------------------------------------------------------- - -ULONG CNelExport::ProcessDir(char* Dir, const char* Mask, unsigned long flag, ULONG Fnct(char* FileName) ) -{ - char ToFound[MAX_PATH]; - char FullDir[MAX_PATH]; - char str[MAX_PATH]; - HANDLE h; - WIN32_FIND_DATA fi; - BOOL r; - - GetFullPathName(Dir,MAX_PATH,FullDir,NULL); - // --- Directory - if (flag) - { - strcpy(ToFound,Dir); - if ( ToFound[strlen(ToFound)-1]!='\\') - strcat(ToFound,"\\"); - strcat(ToFound,"*.*"); - h=FindFirstFile(ToFound,&fi); - if (h!=INVALID_HANDLE_VALUE) - { - r=1; - while(r) - { - if ( strcmp(fi.cFileName,".") && strcmp(fi.cFileName,"..") ) - { - if ( - fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && - !(fi.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) - ) - { - strcpy(str,Dir); - if ( str[strlen(str)-1]!='\\' ) strcat(str,"\\"); - strcat(str,fi.cFileName); - if ( !ProcessDir(str,Mask,flag,Fnct) ) return(0); - } - } - r=FindNextFile(h,&fi); - } - FindClose(h); - } - } - // --- Files - strcpy(ToFound,Dir); - if ( ToFound[strlen(ToFound)-1]!='\\') strcat(ToFound,"\\"); - strcat(ToFound,Mask); - h=FindFirstFile(ToFound,&fi); - if (h!=INVALID_HANDLE_VALUE) - { - r=1; - while(r) - { - if ( strcmp(fi.cFileName,".") && strcmp(fi.cFileName,"..") ) - { - if ( !(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) - { - strcpy(str,FullDir); - if ( str[strlen(str)-1]!='\\' ) strcat(str,"\\"); - strcat(str,fi.cFileName); - ::strupr(str); - if ( !Fnct(str) ) return(0); - } - } - r=FindNextFile(h,&fi); - } - FindClose(h); - } - return(1); -} - -//-------------------------------------------------------------------------------------------------------------- - -ULONG CNelExport::CleanFileName(char* FileName) -{ - char str[MAX_PATH]; - unsigned long i,j,found; - - j=0; - for(i=0 ; i *listNodeCallBack; // *************************************************************************** -class addSubLodNodeHitCallBack : public HitByNameDlgCallback +class addSubLodNodeHitCallBack : public HitByNameDlgCallback { public: INodeTab NodeTab; private: - virtual TCHAR *dialogTitle() + virtual const MCHAR *dialogTitle() { - return "Select sub lod objects to add"; + return _M("Select sub lod objects to add"); } - virtual TCHAR *buttonText() + virtual const MCHAR *buttonText() { - return "Add"; + return _M("Add"); } virtual BOOL singleSelect() { @@ -154,7 +154,7 @@ public: ((CRGBA*)this)->operator= (col); return *this; } - + void setDifferentValuesMode() { DifferentValues= true; @@ -174,7 +174,7 @@ public: SubDlg[i] = NULL; for (i=0; iVertexProgramBypassed ? FALSE : TRUE); // Enable AmbientAddSun for realTime Ambient only - EnableWindow(GetDlgItem (hwndDlg, IDC_REALTIME_LIGHT_AMBIENT_ADD_SUN), + EnableWindow(GetDlgItem (hwndDlg, IDC_REALTIME_LIGHT_AMBIENT_ADD_SUN), SendMessage (GetDlgItem (hwndDlg, IDC_EXPORT_REALTIME_LIGHT), BM_GETCHECK, 0, 0)!=BST_UNCHECKED); } @@ -382,14 +382,14 @@ void VegetableStateChanged (HWND hwndDlg) { // Vegetable ? bool enable = ( SendMessage (GetDlgItem (hwndDlg, IDC_VEGETABLE), BM_GETCHECK, 0, 0)!=BST_UNCHECKED ); - + // Enable alpha blend button EnableWindow (GetDlgItem (hwndDlg, IDC_VEGETABLE_ALPHA_BLEND_ON), enable); EnableWindow (GetDlgItem (hwndDlg, IDC_VEGETABLE_ALPHA_BLEND_OFF), enable); EnableWindow (GetDlgItem (hwndDlg, IDC_CENTER_Z), enable); EnableWindow (GetDlgItem (hwndDlg, IDC_CENTER_NULL), enable); EnableWindow (GetDlgItem (hwndDlg, IDC_VEGETABLE_BEND_FACTOR), enable); - + // Alpha blend ? bool alphaBlend = IsDlgButtonChecked (hwndDlg, IDC_VEGETABLE_ALPHA_BLEND_ON)!=BST_UNCHECKED; @@ -407,7 +407,7 @@ void VegetableStateChanged (HWND hwndDlg) precomputed= IsDlgButtonChecked (hwndDlg, IDC_VEGETABLE_AB_ON_LIGHTED_PRECOMPUTED)!=BST_UNCHECKED; else precomputed= IsDlgButtonChecked (hwndDlg, IDC_VEGETABLE_AB_OFF_LIGHTED_PRECOMPUTED)!=BST_UNCHECKED; - + // Force Best Sided Lighting only if precomputed EnableWindow (GetDlgItem (hwndDlg, IDC_VEGETABLE_FORCE_BEST_SIDED_LIGHTING), enable && precomputed); @@ -456,7 +456,7 @@ void exploreNode(INode *node) if (soundGroup != "no sound") _KnownSoundGroups.insert(soundGroup); - + for (int i= 0; iNumChildren(); ++i) { exploreNode(node->GetChildNode(i)); @@ -473,7 +473,7 @@ INT_PTR CALLBACK AccelDialogCallback ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: { @@ -508,42 +508,42 @@ INT_PTR CALLBACK AccelDialogCallback ( { for (uint i=0; _MaterialNames[i] != 0; ++i) { - SendMessage (GetDlgItem (hwndDlg, IDC_OCC_MODEL), CB_ADDSTRING, 0, (LONG)(_MaterialNames[i])); - SendMessage (GetDlgItem (hwndDlg, IDC_OPEN_OCC_MODEL), CB_ADDSTRING, 0, (LONG)(_MaterialNames[i])); + SendMessage (GetDlgItem (hwndDlg, IDC_OCC_MODEL), CB_ADDSTRING, 0, (LPARAM)_MaterialNames[i]); + SendMessage (GetDlgItem (hwndDlg, IDC_OPEN_OCC_MODEL), CB_ADDSTRING, 0, (LPARAM)_MaterialNames[i]); } } { for (uint i =0; _EnvironmentNames[i] != 0; ++i) { - SendMessage (GetDlgItem (hwndDlg, IDC_ENV_FX), CB_ADDSTRING, 0, (LONG)(_EnvironmentNames[i])); + SendMessage (GetDlgItem (hwndDlg, IDC_ENV_FX), CB_ADDSTRING, 0, (LPARAM)_EnvironmentNames[i]); } } { std::set::iterator first(_KnownSoundGroups.begin()), last(_KnownSoundGroups.end()); for (; first != last; ++first) { - SendMessage (GetDlgItem (hwndDlg, IDC_SOUND_GROUP), CB_ADDSTRING, 0, (LONG)(first->c_str())); + SendMessage (GetDlgItem (hwndDlg, IDC_SOUND_GROUP), CB_ADDSTRING, 0, (LPARAM)utf8ToTStr(*first)); } } // set the combo and edit box - if (SendMessage (GetDlgItem (hwndDlg, IDC_OCC_MODEL), CB_SELECTSTRING, -1, (LONG)(currentParam->OcclusionModel.c_str())) == CB_ERR) + if (SendMessage (GetDlgItem (hwndDlg, IDC_OCC_MODEL), CB_SELECTSTRING, -1, (LPARAM)utf8ToTStr(currentParam->OcclusionModel)) == CB_ERR) { // nlassert(false); } - if (SendMessage (GetDlgItem (hwndDlg, IDC_OPEN_OCC_MODEL), CB_SELECTSTRING, -1, (LONG)(currentParam->OpenOcclusionModel.c_str())) == CB_ERR) + if (SendMessage (GetDlgItem (hwndDlg, IDC_OPEN_OCC_MODEL), CB_SELECTSTRING, -1, (LPARAM)utf8ToTStr(currentParam->OpenOcclusionModel)) == CB_ERR) { // nlassert(false); } - if (SendMessage (GetDlgItem (hwndDlg, IDC_ENV_FX), CB_SELECTSTRING, -1, (LONG)(currentParam->EnvironmentFX.c_str())) == CB_ERR) + if (SendMessage (GetDlgItem (hwndDlg, IDC_ENV_FX), CB_SELECTSTRING, -1, (LPARAM)utf8ToTStr(currentParam->EnvironmentFX)) == CB_ERR) { // nlassert(false); } - if (SendMessage (GetDlgItem (hwndDlg, IDC_SOUND_GROUP), CB_SELECTSTRING, -1, (LONG)(currentParam->SoundGroup.c_str())) == CB_ERR) + if (SendMessage (GetDlgItem (hwndDlg, IDC_SOUND_GROUP), CB_SELECTSTRING, -1, (LPARAM)utf8ToTStr(currentParam->SoundGroup)) == CB_ERR) { // nlassert(false); } -// SendMessage(GetDlgItem(hwndDlg, IDC_SOUND_GROUP), WM_SETTEXT, 0, (LONG)(currentParam->SoundGroup.c_str())); - +// SendMessage(GetDlgItem(hwndDlg, IDC_SOUND_GROUP), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(currentParam->SoundGroup)); + bool accelerator = (currentParam->AcceleratorType != -1); CheckRadioButton (hwndDlg, IDC_RADIOACCELNO, IDC_RADIOACCELCLUSTER, accelerator?(IDC_RADIOACCELNO+(currentParam->AcceleratorType&NEL3D_APPDATA_ACCEL_TYPE)):0); AccelStateChanged (hwndDlg); @@ -554,7 +554,7 @@ INT_PTR CALLBACK AccelDialogCallback ( if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); @@ -581,16 +581,16 @@ INT_PTR CALLBACK AccelDialogCallback ( currentParam->AudibleFromFather=SendMessage (GetDlgItem (hwndDlg, IDC_AUDIBLE_FROM_FATHER), BM_GETCHECK, 0, 0); // get the strings params - char tmp[256]; - SendMessage (GetDlgItem(hwndDlg, IDC_OCC_MODEL), WM_GETTEXT, 256, (LONG)tmp); - currentParam->OcclusionModel = tmp; - SendMessage (GetDlgItem(hwndDlg, IDC_OPEN_OCC_MODEL), WM_GETTEXT, 256, (LONG)tmp); - currentParam->OpenOcclusionModel = tmp; - SendMessage (GetDlgItem(hwndDlg, IDC_SOUND_GROUP), WM_GETTEXT, 256, (LONG)tmp); - currentParam->SoundGroup = tmp; - _KnownSoundGroups.insert(tmp); - SendMessage (GetDlgItem(hwndDlg, IDC_ENV_FX), WM_GETTEXT, 256, (LONG)tmp); - currentParam->EnvironmentFX = tmp; + TCHAR tmp[256]; + SendMessage (GetDlgItem(hwndDlg, IDC_OCC_MODEL), WM_GETTEXT, 256, (LPARAM)tmp); + currentParam->OcclusionModel = tStrToUtf8(tmp); + SendMessage (GetDlgItem(hwndDlg, IDC_OPEN_OCC_MODEL), WM_GETTEXT, 256, (LPARAM)tmp); + currentParam->OpenOcclusionModel = tStrToUtf8(tmp); + SendMessage (GetDlgItem(hwndDlg, IDC_SOUND_GROUP), WM_GETTEXT, 256, (LPARAM)tmp); + currentParam->SoundGroup = tStrToUtf8(tmp); + _KnownSoundGroups.insert(currentParam->SoundGroup); + SendMessage (GetDlgItem(hwndDlg, IDC_ENV_FX), WM_GETTEXT, 256, (LPARAM)tmp); + currentParam->EnvironmentFX = tStrToUtf8(tmp); // Quit EndDialog(hwndDlg, IDOK); @@ -644,7 +644,7 @@ INT_PTR CALLBACK MRMDialogCallback ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: { @@ -653,9 +653,9 @@ INT_PTR CALLBACK MRMDialogCallback ( currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); // Window text - std::string winName=(*(currentParam->ListNode->begin()))->GetName(); + std::string winName= tStrToUtf8((*(currentParam->ListNode->begin()))->GetName()); winName="Node properties ("+winName+((currentParam->ListNode->size()>1)?" ...)":")"); - SetWindowText (hwndDlg, winName.c_str()); + SetWindowText (hwndDlg, utf8ToTStr(winName)); // Set default state SendMessage (GetDlgItem (hwndDlg, IDC_BLEND_IN), BM_SETCHECK, currentParam->BlendIn, 0); @@ -668,9 +668,9 @@ INT_PTR CALLBACK MRMDialogCallback ( EnableWindow (GetDlgItem (hwndDlg, IDC_REMOVE), currentParam->ListActived); EnableWindow (GetDlgItem (hwndDlg, IDC_UP), currentParam->ListActived); EnableWindow (GetDlgItem (hwndDlg, IDC_DOWN), currentParam->ListActived); - - SetWindowText (GetDlgItem (hwndDlg, IDC_DIST_MAX), currentParam->DistMax.c_str()); - SetWindowText (GetDlgItem (hwndDlg, IDC_BLEND_LENGTH), currentParam->BlendLength.c_str()); + + SetWindowText (GetDlgItem (hwndDlg, IDC_DIST_MAX), utf8ToTStr(currentParam->DistMax)); + SetWindowText (GetDlgItem (hwndDlg, IDC_BLEND_LENGTH), utf8ToTStr(currentParam->BlendLength)); SendMessage (GetDlgItem (hwndDlg, IDC_ACTIVE_MRM), BM_SETCHECK, currentParam->MRM, 0); CoarseStateChanged (hwndDlg); @@ -678,12 +678,12 @@ INT_PTR CALLBACK MRMDialogCallback ( if (currentParam->SkinReduction!=-1) CheckRadioButton (hwndDlg, IDC_SKIN_REDUCTION_MIN, IDC_SKIN_REDUCTION_BEST, IDC_SKIN_REDUCTION_MIN+currentParam->SkinReduction); - SetWindowText (GetDlgItem (hwndDlg, IDC_NB_LOD), currentParam->NbLod.c_str()); - SetWindowText (GetDlgItem (hwndDlg, IDC_DIVISOR), currentParam->Divisor.c_str()); - SetWindowText (GetDlgItem (hwndDlg, IDC_DIST_FINEST), currentParam->DistanceFinest.c_str()); - SetWindowText (GetDlgItem (hwndDlg, IDC_DIST_MIDDLE), currentParam->DistanceMiddle.c_str()); - SetWindowText (GetDlgItem (hwndDlg, IDC_DIST_COARSEST), currentParam->DistanceCoarsest.c_str()); - SetWindowText (GetDlgItem (hwndDlg, IDC_BONE_LOD_DISTANCE), currentParam->BoneLodDistance.c_str()); + SetWindowText (GetDlgItem (hwndDlg, IDC_NB_LOD), utf8ToTStr(currentParam->NbLod)); + SetWindowText (GetDlgItem (hwndDlg, IDC_DIVISOR), utf8ToTStr(currentParam->Divisor)); + SetWindowText (GetDlgItem (hwndDlg, IDC_DIST_FINEST), utf8ToTStr(currentParam->DistanceFinest)); + SetWindowText (GetDlgItem (hwndDlg, IDC_DIST_MIDDLE), utf8ToTStr(currentParam->DistanceMiddle)); + SetWindowText (GetDlgItem (hwndDlg, IDC_DIST_COARSEST), utf8ToTStr(currentParam->DistanceCoarsest)); + SetWindowText (GetDlgItem (hwndDlg, IDC_BONE_LOD_DISTANCE), utf8ToTStr(currentParam->BoneLodDistance)); // Iterate list HWND hwndList=GetDlgItem (hwndDlg, IDC_LIST1); @@ -704,7 +704,7 @@ INT_PTR CALLBACK MRMDialogCallback ( if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); @@ -716,12 +716,12 @@ INT_PTR CALLBACK MRMDialogCallback ( currentParam->BlendOut=SendMessage (GetDlgItem (hwndDlg, IDC_BLEND_OUT), BM_GETCHECK, 0, 0); currentParam->CoarseMesh=SendMessage (GetDlgItem (hwndDlg, IDC_COARSE_MESH), BM_GETCHECK, 0, 0); currentParam->DynamicMesh=SendMessage (GetDlgItem (hwndDlg, IDC_DYNAMIC_MESH), BM_GETCHECK, 0, 0); - - char tmp[512]; + + TCHAR tmp[512]; GetWindowText (GetDlgItem (hwndDlg, IDC_DIST_MAX), tmp, 512); - currentParam->DistMax=tmp; + currentParam->DistMax = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_BLEND_LENGTH), tmp, 512); - currentParam->BlendLength=tmp; + currentParam->BlendLength = tStrToUtf8(tmp); currentParam->MRM=SendMessage (GetDlgItem (hwndDlg, IDC_ACTIVE_MRM), BM_GETCHECK, 0, 0); @@ -734,17 +734,17 @@ INT_PTR CALLBACK MRMDialogCallback ( currentParam->SkinReduction=2; GetWindowText (GetDlgItem (hwndDlg, IDC_NB_LOD), tmp, 512); - currentParam->NbLod=tmp; + currentParam->NbLod = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_DIVISOR), tmp, 512); - currentParam->Divisor=tmp; + currentParam->Divisor = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_DIST_FINEST), tmp, 512); - currentParam->DistanceFinest=tmp; + currentParam->DistanceFinest = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_DIST_MIDDLE), tmp, 512); - currentParam->DistanceMiddle=tmp; + currentParam->DistanceMiddle = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_DIST_COARSEST), tmp, 512); - currentParam->DistanceCoarsest=tmp; + currentParam->DistanceCoarsest = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_BONE_LOD_DISTANCE), tmp, 512); - currentParam->BoneLodDistance=tmp; + currentParam->BoneLodDistance = tStrToUtf8(tmp); // Iterate list HWND hwndList=GetDlgItem (hwndDlg, IDC_LIST1); @@ -758,7 +758,7 @@ INT_PTR CALLBACK MRMDialogCallback ( SendMessage (hwndList, LB_GETTEXT, item, (LPARAM) tmp); // Push it back - currentParam->ListLodName.push_back (tmp); + currentParam->ListLodName.push_back (tStrToUtf8(tmp)); } // default LodCharacter @@ -875,7 +875,7 @@ INT_PTR CALLBACK MRMDialogCallback ( if (wID!=LB_ERR) { // Get the node name - char name[512]; + TCHAR name[512]; SendMessage (GetDlgItem (hwndDlg, IDC_LIST1), LB_GETTEXT, wID, (LPARAM) (LPCTSTR) name); // Find the node @@ -912,7 +912,7 @@ INT_PTR CALLBACK InstanceDialogCallback ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: { @@ -920,8 +920,8 @@ INT_PTR CALLBACK InstanceDialogCallback ( LONG_PTR res = SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INSTANCE_GROUP_SHAPE), currentParam->InstanceShape.c_str()); - SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INSTANCE_NAME), currentParam->InstanceName.c_str()); + SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INSTANCE_GROUP_SHAPE), utf8ToTStr(currentParam->InstanceShape)); + SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INSTANCE_NAME), utf8ToTStr(currentParam->InstanceName)); SendMessage (GetDlgItem (hwndDlg, IDC_DONT_ADD_TO_SCENE), BM_SETCHECK, currentParam->DontAddToScene, 0); @@ -930,11 +930,11 @@ INT_PTR CALLBACK InstanceDialogCallback ( SendMessage (GetDlgItem (hwndDlg, IDC_CHECK_COLLISION), BM_SETCHECK, currentParam->Collision, 0); SendMessage (GetDlgItem (hwndDlg, IDC_CHECK_COLLISION_EXTERIOR), BM_SETCHECK, currentParam->CollisionExterior, 0); - SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INSTANCE_GROUP_NAME), currentParam->InstanceGroupName.c_str()); + SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INSTANCE_GROUP_NAME), utf8ToTStr(currentParam->InstanceGroupName)); bool colOk = currentParam->CollisionMeshGeneration>=0 && currentParam->CollisionMeshGeneration<4; CheckRadioButton (hwndDlg, IDC_CAMERA_COL_RADIO1, IDC_CAMERA_COL_RADIO4, colOk?(IDC_CAMERA_COL_RADIO1+(currentParam->CollisionMeshGeneration)):0); - + InstanceStateChanged(hwndDlg); } break; @@ -943,23 +943,23 @@ INT_PTR CALLBACK InstanceDialogCallback ( if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); break; case IDOK: { - char tmp[512]; + TCHAR tmp[512]; GetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INSTANCE_GROUP_SHAPE), tmp, 512); - currentParam->InstanceShape=tmp; + currentParam->InstanceShape = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INSTANCE_NAME), tmp, 512); - currentParam->InstanceName=tmp; - + currentParam->InstanceName = tStrToUtf8(tmp); + currentParam->DontAddToScene=SendMessage (GetDlgItem (hwndDlg, IDC_DONT_ADD_TO_SCENE), BM_GETCHECK, 0, 0); GetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INSTANCE_GROUP_NAME), tmp, 512); - currentParam->InstanceGroupName=tmp; + currentParam->InstanceGroupName = tStrToUtf8(tmp); currentParam->DontExport=SendMessage (GetDlgItem (hwndDlg, IDC_DONT_EXPORT), BM_GETCHECK, 0, 0); @@ -1028,7 +1028,7 @@ INT_PTR CALLBACK LightmapDialogCallback ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: { @@ -1036,9 +1036,9 @@ INT_PTR CALLBACK LightmapDialogCallback ( LONG_PTR res = SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_LUMELSIZEMUL), currentParam->LumelSizeMul.c_str()); - SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_SOFTSHADOW_RADIUS), currentParam->SoftShadowRadius.c_str()); - SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_SOFTSHADOW_CONELENGTH), currentParam->SoftShadowConeLength.c_str()); + SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_LUMELSIZEMUL), utf8ToTStr(currentParam->LumelSizeMul)); + SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_SOFTSHADOW_RADIUS), utf8ToTStr(currentParam->SoftShadowRadius)); + SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_SOFTSHADOW_CONELENGTH), utf8ToTStr(currentParam->SoftShadowConeLength)); // Lighting SendMessage (GetDlgItem (hwndDlg, IDC_EXPORT_REALTIME_LIGHT), BM_SETCHECK, currentParam->ExportRealTimeLight, 0); @@ -1048,9 +1048,9 @@ INT_PTR CALLBACK LightmapDialogCallback ( SendMessage (GetDlgItem (hwndDlg, IDC_USE_LIGHT_LOCAL_ATTENUATION), BM_SETCHECK, currentParam->UseLightingLocalAttenuation, 0); SendMessage (GetDlgItem (hwndDlg, IDC_LIGHT_DONT_CAST_SHADOW_INTERIOR), BM_SETCHECK, currentParam->LightDontCastShadowInterior, 0); SendMessage (GetDlgItem (hwndDlg, IDC_LIGHT_DONT_CAST_SHADOW_EXTERIOR), BM_SETCHECK, currentParam->LightDontCastShadowExterior, 0); - SetWindowText (GetDlgItem (hwndDlg, IDC_EXPORT_LIGHTMAP_NAME), currentParam->ExportLightMapName.c_str()); + SetWindowText (GetDlgItem (hwndDlg, IDC_EXPORT_LIGHTMAP_NAME), utf8ToTStr(currentParam->ExportLightMapName)); SendMessage (GetDlgItem (hwndDlg, IDC_REALTIME_LIGHT_AMBIENT_ADD_SUN), BM_SETCHECK, currentParam->RealTimeAmbientLightAddSun, 0); - + // Set enable disable LightingStateChanged (hwndDlg, currentParam); @@ -1062,10 +1062,10 @@ INT_PTR CALLBACK LightmapDialogCallback ( if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDC_RESET_NAME: - SetWindowText (GetDlgItem (hwndDlg, IDC_EXPORT_LIGHTMAP_NAME), "GlobalLight"); + SetWindowText (GetDlgItem (hwndDlg, IDC_EXPORT_LIGHTMAP_NAME), _T("GlobalLight")); break; case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); @@ -1073,13 +1073,13 @@ INT_PTR CALLBACK LightmapDialogCallback ( case IDOK: { // Set default state - char tmp[512]; + TCHAR tmp[512]; GetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_LUMELSIZEMUL), tmp, 512); - currentParam->LumelSizeMul = tmp; + currentParam->LumelSizeMul = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_SOFTSHADOW_RADIUS), tmp, 512); - currentParam->SoftShadowRadius = tmp; + currentParam->SoftShadowRadius = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_SOFTSHADOW_CONELENGTH), tmp, 512); - currentParam->SoftShadowConeLength = tmp; + currentParam->SoftShadowConeLength = tStrToUtf8(tmp); // RealTime light currentParam->ExportRealTimeLight = SendMessage (GetDlgItem (hwndDlg, IDC_EXPORT_REALTIME_LIGHT), BM_GETCHECK, 0, 0); @@ -1090,9 +1090,9 @@ INT_PTR CALLBACK LightmapDialogCallback ( currentParam->LightDontCastShadowExterior = SendMessage (GetDlgItem (hwndDlg, IDC_LIGHT_DONT_CAST_SHADOW_EXTERIOR), BM_GETCHECK, 0, 0); currentParam->ExportLightMapAnimated = SendMessage (GetDlgItem (hwndDlg, IDC_EXPORT_LIGHTMAP_ANIMATED), BM_GETCHECK, 0, 0); GetWindowText (GetDlgItem (hwndDlg, IDC_EXPORT_LIGHTMAP_NAME), tmp, 512); - currentParam->ExportLightMapName = tmp; + currentParam->ExportLightMapName = tStrToUtf8(tmp); currentParam->RealTimeAmbientLightAddSun= SendMessage (GetDlgItem (hwndDlg, IDC_REALTIME_LIGHT_AMBIENT_ADD_SUN), BM_GETCHECK, 0, 0); - + // Get the acceleration type if (IsDlgButtonChecked (hwndDlg, IDC_LIGHT_GROUP_ALWAYS) == BST_CHECKED) currentParam->LightGroup = 0; @@ -1132,7 +1132,7 @@ INT_PTR CALLBACK LightmapDialogCallback ( if (wID!=LB_ERR) { // Get the node name - char name[512]; + TCHAR name[512]; SendMessage (GetDlgItem (hwndDlg, IDC_LIST1), LB_GETTEXT, wID, (LPARAM) (LPCTSTR) name); // Find the node @@ -1154,7 +1154,7 @@ INT_PTR CALLBACK LightmapDialogCallback ( EndDialog(hwndDlg,1); break; - case WM_DESTROY: + case WM_DESTROY: break; @@ -1180,7 +1180,7 @@ void Lightmap2StateChanged (HWND hwndDlg, CLodDialogBoxParam *currentParam) EnableWindow (GetDlgItem(hwndDlg, IDC_LMC_AUTO_SETUP), enabled); EnableWindow (GetDlgItem(hwndDlg, IDC_LMC_AUTO_SETUP_VISIBLEONLY), enabled); EnableWindow (GetDlgItem(hwndDlg, IDC_LMC_COPY_FROM), enabled); - + // MAX enable/disable uint i; for(i=0;i lights; getLightmapLightBuilds(lights, theCNelExport._Ip->GetTime(), *theCNelExport._Ip, visibleOnly); - + // mean all light, by lightgroup CRGBAF sumAmbient[CLodDialogBoxParam::NumLightGroup]; CRGBAF sumDiffuse[CLodDialogBoxParam::NumLightGroup]; @@ -1258,7 +1258,7 @@ void lmcAutoSetup(CLodDialogBoxParam *currentParam, bool visibleOnly) sumDiffuse[i]/= float(countDiffuse[i]); diff= sumDiffuse[i]; } - + // change the control and value currentParam->LMCAmbient[i]= amb; currentParam->LMCAmbient[i].Ctrl->SetColor(RGB(amb.R, amb.G, amb.B)); @@ -1269,7 +1269,7 @@ void lmcAutoSetup(CLodDialogBoxParam *currentParam, bool visibleOnly) // *************************************************************************** -struct CLMCParamFrom +struct CLMCParamFrom { bool AmbFilter[CLodDialogBoxParam::NumLightGroup]; bool DiffFilter[CLodDialogBoxParam::NumLightGroup]; @@ -1278,7 +1278,7 @@ struct CLMCParamFrom std::vector Nodes; // true if the user has clicked at least one item bool SelectionDone; - + CLMCParamFrom() { SelectionDone= false; @@ -1311,8 +1311,8 @@ INT_PTR CALLBACK LMCCopyFromDialogCallback( { CLMCParamFrom *lmcParam=(CLMCParamFrom *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); uint i; - - switch (uMsg) + + switch (uMsg) { case WM_INITDIALOG: { @@ -1336,7 +1336,7 @@ INT_PTR CALLBACK LMCCopyFromDialogCallback( lmcParam->AmbValue[i].Ctrl->SetColor(RGB(a.R, a.G, a.B)); lmcParam->DiffValue[i].Ctrl->SetColor(RGB(d.R, d.G, d.B)); } - + // init the filters. nlctassert(CLodDialogBoxParam::NumLightGroup==3); SendMessage (GetDlgItem (hwndDlg, IDC_LMC_COPY_ALWAYS_AMBIENT_FILTER), BM_SETCHECK, lmcParam->AmbFilter[0]?BST_CHECKED:BST_UNCHECKED, 0); @@ -1345,7 +1345,7 @@ INT_PTR CALLBACK LMCCopyFromDialogCallback( SendMessage (GetDlgItem (hwndDlg, IDC_LMC_COPY_ALWAYS_DIFFUSE_FILTER), BM_SETCHECK, lmcParam->DiffFilter[0]?BST_CHECKED:BST_UNCHECKED, 0); SendMessage (GetDlgItem (hwndDlg, IDC_LMC_COPY_SUN_DIFFUSE_FILTER), BM_SETCHECK, lmcParam->DiffFilter[1]?BST_CHECKED:BST_UNCHECKED, 0); SendMessage (GetDlgItem (hwndDlg, IDC_LMC_COPY_NIGHT_DIFFUSE_FILTER), BM_SETCHECK, lmcParam->DiffFilter[2]?BST_CHECKED:BST_UNCHECKED, 0); - + // init the list HWND hwndList=GetDlgItem (hwndDlg, IDC_LMC_COPY_LIST); for(i=0;iNodes.size();i++) @@ -1355,7 +1355,7 @@ INT_PTR CALLBACK LMCCopyFromDialogCallback( // Insert string SendMessage (hwndList, LB_ADDSTRING, 0, (LPARAM) str.c_str()); } - + // gray the OK button EnableWindow( GetDlgItem(hwndDlg, IDOK), FALSE); } @@ -1365,7 +1365,7 @@ INT_PTR CALLBACK LMCCopyFromDialogCallback( if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); @@ -1380,7 +1380,7 @@ INT_PTR CALLBACK LMCCopyFromDialogCallback( lmcParam->DiffFilter[0]= SendMessage (GetDlgItem (hwndDlg, IDC_LMC_COPY_ALWAYS_DIFFUSE_FILTER), BM_GETCHECK, 0, 0) == BST_CHECKED; lmcParam->DiffFilter[1]= SendMessage (GetDlgItem (hwndDlg, IDC_LMC_COPY_SUN_DIFFUSE_FILTER), BM_GETCHECK, 0, 0) == BST_CHECKED; lmcParam->DiffFilter[2]= SendMessage (GetDlgItem (hwndDlg, IDC_LMC_COPY_NIGHT_DIFFUSE_FILTER), BM_GETCHECK, 0, 0) == BST_CHECKED; - + // get colors for(i=0;iSelectionDone= true; // Get the node name - char name[512]; + TCHAR name[512]; SendMessage (GetDlgItem (hwndDlg, IDC_LMC_COPY_LIST), LB_GETTEXT, wID, (LPARAM) (LPCTSTR) name); - + // Find the node INode *nodeClk=theCNelExport._Ip->GetINodeByName(name); if (nodeClk) @@ -1454,17 +1454,17 @@ INT_PTR CALLBACK LMCCopyFromDialogCallback( // ungray the OK button EnableWindow( GetDlgItem(hwndDlg, IDOK), TRUE); } - + } break; - + case WM_CLOSE: EndDialog(hwndDlg,IDCANCEL); break; - - case WM_DESTROY: + + case WM_DESTROY: break; - + default: return FALSE; } @@ -1479,7 +1479,7 @@ void lmcCopyFrom(CLodDialogBoxParam *currentParam, HWND parentDlg) // static to save filter between calls static CLMCParamFrom paramLMCFrom; - + // **** get all nodes // get all nodes std::vector nodes; @@ -1497,7 +1497,7 @@ void lmcCopyFrom(CLodDialogBoxParam *currentParam, HWND parentDlg) // **** launch the choosing dialog paramLMCFrom.reset(); - if (DialogBoxParam (hInstance, MAKEINTRESOURCE(IDD_LMC_CHOOSE_FROM), parentDlg, LMCCopyFromDialogCallback, (long)¶mLMCFrom)==IDOK + if (DialogBoxParam (hInstance, MAKEINTRESOURCE(IDD_LMC_CHOOSE_FROM), parentDlg, LMCCopyFromDialogCallback, (LPARAM)¶mLMCFrom)==IDOK && paramLMCFrom.SelectionDone) { // **** Apply to the current setup @@ -1532,7 +1532,7 @@ INT_PTR CALLBACK Lightmap2DialogCallback ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: { @@ -1540,7 +1540,7 @@ INT_PTR CALLBACK Lightmap2DialogCallback ( LONG_PTR res = SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - // retrieve the color choosing Ctrl + // retrieve the color choosing Ctrl nlctassert(CLodDialogBoxParam::NumLightGroup==3); nlverify(currentParam->LMCAmbient[0].Ctrl= GetIColorSwatch(GetDlgItem(hwndDlg, IDC_LM_ALWAYS_AMBIENT))); nlverify(currentParam->LMCAmbient[1].Ctrl= GetIColorSwatch(GetDlgItem(hwndDlg, IDC_LM_DAY_AMBIENT))); @@ -1548,7 +1548,7 @@ INT_PTR CALLBACK Lightmap2DialogCallback ( nlverify(currentParam->LMCDiffuse[0].Ctrl= GetIColorSwatch(GetDlgItem(hwndDlg, IDC_LM_ALWAYS_DIFFUSE))); nlverify(currentParam->LMCDiffuse[1].Ctrl= GetIColorSwatch(GetDlgItem(hwndDlg, IDC_LM_DAY_DIFFUSE))); nlverify(currentParam->LMCDiffuse[2].Ctrl= GetIColorSwatch(GetDlgItem(hwndDlg, IDC_LM_NIGHT_DIFFUSE))); - + // set color, and color state for(uint i=0;iLMCEnabled, 0); - + // Set enable disable Lightmap2StateChanged (hwndDlg, currentParam); } @@ -1570,7 +1570,7 @@ INT_PTR CALLBACK Lightmap2DialogCallback ( if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); @@ -1616,7 +1616,7 @@ INT_PTR CALLBACK Lightmap2DialogCallback ( { nlctassert(CLodDialogBoxParam::NumLightGroup==3); CRGBAProp *propEdited; - switch(LOWORD(wParam)) + switch(LOWORD(wParam)) { case IDC_LM_ALWAYS_AMBIENT: propEdited= ¤tParam->LMCAmbient[0]; break; case IDC_LM_DAY_AMBIENT: propEdited= ¤tParam->LMCAmbient[1]; break; @@ -1635,7 +1635,7 @@ INT_PTR CALLBACK Lightmap2DialogCallback ( EndDialog(hwndDlg,1); break; - case WM_DESTROY: + case WM_DESTROY: break; default: @@ -1655,7 +1655,7 @@ INT_PTR CALLBACK VegetableDialogCallback ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: { @@ -1664,22 +1664,22 @@ INT_PTR CALLBACK VegetableDialogCallback ( currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); SendMessage (GetDlgItem (hwndDlg, IDC_VEGETABLE), BM_SETCHECK, currentParam->Vegetable, 0); - + // Yoyo: enable like this. Crappy CheckRadioButton method... SendMessage (GetDlgItem (hwndDlg, IDC_VEGETABLE_ALPHA_BLEND_ON), BM_SETCHECK, currentParam->VegetableAlphaBlend==0, 0 ); SendMessage (GetDlgItem (hwndDlg, IDC_VEGETABLE_ALPHA_BLEND_OFF), BM_SETCHECK, currentParam->VegetableAlphaBlend==1, 0 ); - + CheckRadioButton(hwndDlg, IDC_VEGETABLE_AB_ON_LIGHTED_PRECOMPUTED, IDC_VEGETABLE_AB_ON_UNLIGHTED, IDC_VEGETABLE_AB_ON_LIGHTED_PRECOMPUTED+currentParam->VegetableAlphaBlendOnLighted); - + CheckRadioButton(hwndDlg, IDC_VEGETABLE_AB_OFF_LIGHTED_PRECOMPUTED, IDC_VEGETABLE_AB_OFF_UNLIGHTED, IDC_VEGETABLE_AB_OFF_LIGHTED_PRECOMPUTED+currentParam->VegetableAlphaBlendOffLighted); - + SendMessage (GetDlgItem (hwndDlg, IDC_VEGETABLE_AB_OFF_DOUBLE_SIDED), BM_SETCHECK, currentParam->VegetableAlphaBlendOffDoubleSided, 0); SendMessage (GetDlgItem (hwndDlg, IDC_VEGETABLE_FORCE_BEST_SIDED_LIGHTING), BM_SETCHECK, currentParam->VegetableForceBestSidedLighting, 0); - + CheckRadioButton(hwndDlg, IDC_CENTER_NULL, IDC_CENTER_Z, IDC_CENTER_NULL+currentParam->VegetableBendCenter); - SetWindowText (GetDlgItem (hwndDlg, IDC_VEGETABLE_BEND_FACTOR), currentParam->VegetableBendFactor.c_str()); + SetWindowText (GetDlgItem (hwndDlg, IDC_VEGETABLE_BEND_FACTOR), utf8ToTStr(currentParam->VegetableBendFactor)); VegetableStateChanged (hwndDlg); } @@ -1689,7 +1689,7 @@ INT_PTR CALLBACK VegetableDialogCallback ( if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); @@ -1702,25 +1702,25 @@ INT_PTR CALLBACK VegetableDialogCallback ( currentParam->VegetableAlphaBlend = 0; else if (IsDlgButtonChecked (hwndDlg, IDC_VEGETABLE_ALPHA_BLEND_OFF) == BST_CHECKED) currentParam->VegetableAlphaBlend = 1; - else + else currentParam->VegetableAlphaBlend = -1; - + if (IsDlgButtonChecked (hwndDlg, IDC_VEGETABLE_AB_ON_LIGHTED_PRECOMPUTED) == BST_CHECKED) currentParam->VegetableAlphaBlendOnLighted = 0; else if (IsDlgButtonChecked (hwndDlg, IDC_VEGETABLE_AB_ON_UNLIGHTED) == BST_CHECKED) currentParam->VegetableAlphaBlendOnLighted = 1; - else + else currentParam->VegetableAlphaBlendOnLighted = -1; - + if (IsDlgButtonChecked (hwndDlg, IDC_VEGETABLE_AB_OFF_LIGHTED_PRECOMPUTED) == BST_CHECKED) currentParam->VegetableAlphaBlendOffLighted = 0; else if (IsDlgButtonChecked (hwndDlg, IDC_VEGETABLE_AB_OFF_LIGHTED_DYNAMIC) == BST_CHECKED) currentParam->VegetableAlphaBlendOffLighted = 1; else if (IsDlgButtonChecked (hwndDlg, IDC_VEGETABLE_AB_OFF_UNLIGHTED) == BST_CHECKED) currentParam->VegetableAlphaBlendOffLighted = 2; - else + else currentParam->VegetableAlphaBlendOffLighted = -1; - + currentParam->VegetableAlphaBlendOffDoubleSided = SendMessage (GetDlgItem (hwndDlg, IDC_VEGETABLE_AB_OFF_DOUBLE_SIDED), BM_GETCHECK, 0, 0); currentParam->VegetableForceBestSidedLighting= SendMessage (GetDlgItem (hwndDlg, IDC_VEGETABLE_FORCE_BEST_SIDED_LIGHTING), BM_GETCHECK, 0, 0); @@ -1729,12 +1729,12 @@ INT_PTR CALLBACK VegetableDialogCallback ( currentParam->VegetableBendCenter = 0; else if (IsDlgButtonChecked (hwndDlg, IDC_CENTER_Z) == BST_CHECKED) currentParam->VegetableBendCenter = 1; - else + else currentParam->VegetableBendCenter = -1; - - char tmp[512]; + + TCHAR tmp[512]; GetWindowText (GetDlgItem (hwndDlg, IDC_VEGETABLE_BEND_FACTOR), tmp, 512); - currentParam->VegetableBendFactor = tmp; + currentParam->VegetableBendFactor = tStrToUtf8(tmp); } break; case IDC_VEGETABLE: @@ -1775,7 +1775,7 @@ INT_PTR CALLBACK VertexProgramDialogCallBack ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: { @@ -1789,8 +1789,8 @@ INT_PTR CALLBACK VertexProgramDialogCallBack ( if(currentParam->VertexProgramId>=0) { // Init DropList. - SendDlgItemMessage(hwndDlg, IDC_COMBO_VP, CB_ADDSTRING, 0, (LPARAM)"Disable"); - SendDlgItemMessage(hwndDlg, IDC_COMBO_VP, CB_ADDSTRING, 0, (LPARAM)"Wind Tree"); + SendDlgItemMessage(hwndDlg, IDC_COMBO_VP, CB_ADDSTRING, 0, (LPARAM)_T("Disable")); + SendDlgItemMessage(hwndDlg, IDC_COMBO_VP, CB_ADDSTRING, 0, (LPARAM)_T("Wind Tree")); SendDlgItemMessage(hwndDlg, IDC_COMBO_VP, CB_SETCURSEL, currentParam->VertexProgramId, 0); EnableWindow( GetDlgItem(hwndDlg, IDC_COMBO_VP), TRUE); } @@ -1823,7 +1823,7 @@ INT_PTR CALLBACK VertexProgramDialogCallBack ( for (uint vpId=0; vpIdSubVPDlg[vpId] = CreateDialogParam (hInstance, MAKEINTRESOURCE(SubVPTab[vpId]), hwndDlg, SubVPProc[vpId], (LONG)lParam); + currentParam->SubVPDlg[vpId] = CreateDialogParam (hInstance, MAKEINTRESOURCE(SubVPTab[vpId]), hwndDlg, SubVPProc[vpId], lParam); // To client coord RECT client = tabRect; @@ -1847,7 +1847,7 @@ INT_PTR CALLBACK VertexProgramDialogCallBack ( if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); @@ -1930,10 +1930,10 @@ static int VPWTBiasStaticId[CVPWindTreeAppData::HrcDepth]= void updateVPWTStatic(HWND hwndDlg, uint type, uint depth, const CVPWindTreeAppData &vpwt) { int sliderValue; - char stmp[256]; + TCHAR stmp[256]; float nticks= CVPWindTreeAppData::NumTicks; float scale; - + // which scale?? switch(type) { @@ -1951,31 +1951,31 @@ void updateVPWTStatic(HWND hwndDlg, uint type, uint depth, const CVPWindTreeAppD // update static according to type. switch(type) { - case 0: + case 0: sliderValue= SendDlgItemMessage(hwndDlg, VPWTFreqSliderId[depth], TBM_GETPOS, 0, 0); - _stprintf(stmp, "%.2f", scale * float(sliderValue)/nticks); + _stprintf(stmp, _T("%.2f"), scale * float(sliderValue)/nticks); SetWindowText( GetDlgItem(hwndDlg, VPWTFreqStaticId[depth]), stmp ); break; - case 1: + case 1: sliderValue= SendDlgItemMessage(hwndDlg, VPWTFreqWDSliderId[depth], TBM_GETPOS, 0, 0); - _stprintf(stmp, "%.2f", scale * float(sliderValue)/nticks); + _stprintf(stmp, _T("%.2f"), scale * float(sliderValue)/nticks); SetWindowText( GetDlgItem(hwndDlg, VPWTFreqWDStaticId[depth]), stmp ); break; - case 2: + case 2: sliderValue= SendDlgItemMessage(hwndDlg, VPWTDistXYSliderId[depth], TBM_GETPOS, 0, 0); - _stprintf(stmp, "%.2f", scale * float(sliderValue)/nticks); + _stprintf(stmp, _T("%.2f"), scale * float(sliderValue)/nticks); SetWindowText( GetDlgItem(hwndDlg, VPWTDistXYStaticId[depth]), stmp ); break; - case 3: + case 3: sliderValue= SendDlgItemMessage(hwndDlg, VPWTDistZSliderId[depth], TBM_GETPOS, 0, 0); - _stprintf(stmp, "%.2f", scale * float(sliderValue)/nticks); + _stprintf(stmp, _T("%.2f"), scale * float(sliderValue)/nticks); SetWindowText( GetDlgItem(hwndDlg, VPWTDistZStaticId[depth]), stmp ); break; - case 4: + case 4: sliderValue= SendDlgItemMessage(hwndDlg, VPWTBiasSliderId[depth], TBM_GETPOS, 0, 0); // expand to -2 to 2. float biasVal= 4 * float(sliderValue)/nticks - 2; - _stprintf(stmp, "%.2f", biasVal); + _stprintf(stmp, _T("%.2f"), biasVal); SetWindowText( GetDlgItem(hwndDlg, VPWTBiasStaticId[depth]), stmp ); break; } @@ -1987,14 +1987,14 @@ static void concatEdit2Lines(HWND edit) const uint lineLen= 1000; uint n; // retrieve the 2 lines. - char tmp0[2*lineLen]; - char tmp1[lineLen]; + TCHAR tmp0[2*lineLen]; + TCHAR tmp1[lineLen]; *(WORD*)tmp0= lineLen; *(WORD*)tmp1= lineLen; - n= SendMessage(edit, EM_GETLINE, 0, (LONG)tmp0); tmp0[n]= 0; - n= SendMessage(edit, EM_GETLINE, 1, (LONG)tmp1); tmp1[n]= 0; + n= SendMessage(edit, EM_GETLINE, 0, (LPARAM)tmp0); tmp0[n]= 0; + n= SendMessage(edit, EM_GETLINE, 1, (LPARAM)tmp1); tmp1[n]= 0; // concat and update the CEdit. - SetWindowText(edit, strcat(tmp0, tmp1)); + SetWindowText(edit, _tcscat(tmp0, tmp1)); } @@ -2041,10 +2041,10 @@ INT_PTR CALLBACK VPWindTreeCallback ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: - { + { // Param pointers LONG_PTR res = SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); @@ -2055,10 +2055,10 @@ INT_PTR CALLBACK VPWindTreeCallback ( // Init Global. editBox - char stmp[256]; - _stprintf(stmp, "%.2f", vpwt.FreqScale); + TCHAR stmp[256]; + _stprintf(stmp, _T("%.2f"), vpwt.FreqScale); SetWindowText( GetDlgItem(hwndDlg, IDC_EDIT_VPWT_FREQ_SCALE), stmp ); - _stprintf(stmp, "%.2f", vpwt.DistScale); + _stprintf(stmp, _T("%.2f"), vpwt.DistScale); SetWindowText( GetDlgItem(hwndDlg, IDC_EDIT_VPWT_DIST_SCALE), stmp ); SendDlgItemMessage(hwndDlg, IDC_CHECK_VP_SPECLIGHT, BM_SETCHECK, vpwt.SpecularLighting, 0); @@ -2102,13 +2102,13 @@ INT_PTR CALLBACK VPWindTreeCallback ( { CVPWindTreeAppData &vpwt= currentParam->VertexProgramWindTree; int nticks= CVPWindTreeAppData::NumTicks; - char stmp[256]; + TCHAR stmp[256]; float val; if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); @@ -2175,9 +2175,9 @@ INT_PTR CALLBACK VPWindTreeCallback ( // EditBox change: ... if( HIWORD(wParam) == EN_KILLFOCUS || EnChangeReturn) - { - switch (LOWORD(wParam)) - { + { + switch (LOWORD(wParam)) + { case IDC_EDIT_VPWT_FREQ_SCALE: { // Read FreqScale @@ -2195,7 +2195,7 @@ INT_PTR CALLBACK VPWindTreeCallback ( } } // Update Scale Edit text. - _stprintf(stmp, "%.2f", vpwt.FreqScale); + _stprintf(stmp, _T("%.2f"), vpwt.FreqScale); SetWindowText( GetDlgItem(hwndDlg, IDC_EDIT_VPWT_FREQ_SCALE), stmp ); } break; @@ -2216,11 +2216,11 @@ INT_PTR CALLBACK VPWindTreeCallback ( } } // Update Scale Edit text. - _stprintf(stmp, "%.2f", vpwt.DistScale); + _stprintf(stmp, _T("%.2f"), vpwt.DistScale); SetWindowText( GetDlgItem(hwndDlg, IDC_EDIT_VPWT_DIST_SCALE), stmp ); } break; - } + } } } break; @@ -2279,10 +2279,10 @@ INT_PTR CALLBACK MiscDialogCallback ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: - { + { // Param pointers LONG_PTR res = SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); @@ -2290,34 +2290,34 @@ INT_PTR CALLBACK MiscDialogCallback ( // Ligoscape SendMessage (GetDlgItem (hwndDlg, IDC_LIGO_SYMMETRY), BM_SETCHECK, currentParam->LigoSymmetry, 0); - SetWindowText (GetDlgItem (hwndDlg, IDC_LIGO_ROTATE), currentParam->LigoRotate.c_str()); + SetWindowText (GetDlgItem (hwndDlg, IDC_LIGO_ROTATE), utf8ToTStr(currentParam->LigoRotate)); // SWT SendMessage (GetDlgItem (hwndDlg, IDC_SWT), BM_SETCHECK, currentParam->SWT, 0); - SetWindowText (GetDlgItem (hwndDlg, IDC_SWT_WEIGHT), currentParam->SWTWeight.c_str()); + SetWindowText (GetDlgItem (hwndDlg, IDC_SWT_WEIGHT), utf8ToTStr(currentParam->SWTWeight)); // Radial normals for (uint smoothGroup=0; smoothGroupRadialNormals[smoothGroup].c_str()); + SetWindowText (GetDlgItem (hwndDlg, IDC_RADIAL_NORMAL_29+smoothGroup), utf8ToTStr(currentParam->RadialNormals[smoothGroup])); // Mesh interfaces - SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INTERFACE_FILE), currentParam->InterfaceFileName.c_str()); - SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INTERFACE_THRESHOLD), - currentParam->InterfaceThreshold != -1.f ? toStringMax(currentParam->InterfaceThreshold).c_str() - : "" + SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INTERFACE_FILE), utf8ToTStr(currentParam->InterfaceFileName)); + SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INTERFACE_THRESHOLD), + currentParam->InterfaceThreshold != -1.f ? utf8ToTStr(toStringMax(currentParam->InterfaceThreshold)) + : _T("") ); SendMessage(GetDlgItem(hwndDlg, IDC_GET_INTERFACE_NORMAL_FROM_SCENE_OBJECTS), BM_SETCHECK, currentParam->GetInterfaceNormalsFromSceneObjects, 0); - + // Skeleton Scale SendMessage( GetDlgItem(hwndDlg, IDC_EXPORT_BONE_SCALE), BM_SETCHECK, currentParam->ExportBoneScale, 0); - SetWindowText (GetDlgItem (hwndDlg, IDC_EXPORT_BONE_SCALE_NAME_EXT), currentParam->ExportBoneScaleNameExt.c_str()); + SetWindowText (GetDlgItem (hwndDlg, IDC_EXPORT_BONE_SCALE_NAME_EXT), utf8ToTStr(currentParam->ExportBoneScaleNameExt)); // Remanence SendMessage (GetDlgItem (hwndDlg, IDC_USE_REMANENCE), BM_SETCHECK, currentParam->UseRemanence, 0); SendMessage (GetDlgItem (hwndDlg, IDC_REMANENCE_SHIFTING_TEXTURE), BM_SETCHECK, currentParam->RemanenceShiftingTexture, 0); - SetWindowText (GetDlgItem (hwndDlg, IDC_REMANENCE_SLICE_NUMBER), currentParam->RemanenceSliceNumber != - 1 ? toStringMax(currentParam->RemanenceSliceNumber).c_str() : ""); - SetWindowText (GetDlgItem (hwndDlg, IDC_REMANENCE_SAMPLING_PERIOD), currentParam->RemanenceSamplingPeriod != -1 ? toStringMax(currentParam->RemanenceSamplingPeriod).c_str() : ""); - SetWindowText (GetDlgItem (hwndDlg, IDC_REMANENCE_ROLLUP_RATIO), currentParam->RemanenceRollupRatio != -1 ? toStringMax(currentParam->RemanenceRollupRatio).c_str() : ""); + SetWindowText (GetDlgItem (hwndDlg, IDC_REMANENCE_SLICE_NUMBER), currentParam->RemanenceSliceNumber != - 1 ? utf8ToTStr(toStringMax(currentParam->RemanenceSliceNumber)) : _T("")); + SetWindowText (GetDlgItem (hwndDlg, IDC_REMANENCE_SAMPLING_PERIOD), currentParam->RemanenceSamplingPeriod != -1 ? utf8ToTStr(toStringMax(currentParam->RemanenceSamplingPeriod)) : _T("")); + SetWindowText (GetDlgItem (hwndDlg, IDC_REMANENCE_ROLLUP_RATIO), currentParam->RemanenceRollupRatio != -1 ? utf8ToTStr(toStringMax(currentParam->RemanenceRollupRatio)) : _T("")); } break; @@ -2325,58 +2325,60 @@ INT_PTR CALLBACK MiscDialogCallback ( if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); break; case IDOK: { - currentParam->FloatingObject=SendMessage (GetDlgItem (hwndDlg, IDC_FLOATING_OBJECT), BM_GETCHECK, 0, 0); + currentParam->FloatingObject = SendMessage (GetDlgItem (hwndDlg, IDC_FLOATING_OBJECT), BM_GETCHECK, 0, 0); // Ligoscape currentParam->LigoSymmetry = SendMessage (GetDlgItem (hwndDlg, IDC_LIGO_SYMMETRY), BM_GETCHECK, 0, 0); - char tmp[512]; + TCHAR tmp[512]; GetWindowText (GetDlgItem (hwndDlg, IDC_LIGO_ROTATE), tmp, 512); - currentParam->LigoRotate = tmp; + currentParam->LigoRotate = tStrToUtf8(tmp); // SWT currentParam->SWT = SendMessage (GetDlgItem (hwndDlg, IDC_SWT), BM_GETCHECK, 0, 0); GetWindowText (GetDlgItem (hwndDlg, IDC_SWT_WEIGHT), tmp, 512); - currentParam->SWTWeight = tmp; + currentParam->SWTWeight = tStrToUtf8(tmp); // Radial normals for (uint smoothGroup=0; smoothGroupRadialNormals[smoothGroup]=tmp; + currentParam->RadialNormals[smoothGroup] = tStrToUtf8(tmp); } // mesh interfaces GetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INTERFACE_FILE), tmp, 512); - currentParam->InterfaceFileName=tmp; + currentParam->InterfaceFileName = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INTERFACE_THRESHOLD), tmp, 512); - if (strlen(tmp) != 0) - currentParam->InterfaceThreshold = toFloatMax(tmp); + if (_tcslen(tmp) != 0) + currentParam->InterfaceThreshold = toFloatMax(tmp); currentParam->GetInterfaceNormalsFromSceneObjects = SendMessage (GetDlgItem (hwndDlg, IDC_GET_INTERFACE_NORMAL_FROM_SCENE_OBJECTS), BM_GETCHECK, 0, 0); - - + + // Skeleton Scale currentParam->ExportBoneScale= SendMessage( GetDlgItem(hwndDlg, IDC_EXPORT_BONE_SCALE), BM_GETCHECK, 0, 0); GetWindowText (GetDlgItem (hwndDlg, IDC_EXPORT_BONE_SCALE_NAME_EXT), tmp, 512); - currentParam->ExportBoneScaleNameExt= tmp; + currentParam->ExportBoneScaleNameExt = tStrToUtf8(tmp); // remanence currentParam->UseRemanence = SendMessage (GetDlgItem (hwndDlg, IDC_USE_REMANENCE), BM_GETCHECK, 0, 0); currentParam->RemanenceShiftingTexture = SendMessage (GetDlgItem (hwndDlg, IDC_REMANENCE_SHIFTING_TEXTURE), BM_GETCHECK, 0, 0); GetWindowText (GetDlgItem (hwndDlg, IDC_REMANENCE_SLICE_NUMBER), tmp, 512); + uint rsn; - if (sscanf(tmp, "%d", &rsn) == 1) + if (NLMISC::fromString(tStrToUtf8(tmp), rsn)) { currentParam->RemanenceSliceNumber = rsn; } + GetWindowText (GetDlgItem (hwndDlg, IDC_REMANENCE_SAMPLING_PERIOD), tmp, 512); toFloatMax(tmp, currentParam->RemanenceSamplingPeriod); GetWindowText (GetDlgItem (hwndDlg, IDC_REMANENCE_ROLLUP_RATIO), tmp, 512); @@ -2412,10 +2414,10 @@ INT_PTR CALLBACK AnimationDialogCallback ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: - { + { // Param pointers LONG_PTR res = SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); @@ -2432,7 +2434,7 @@ INT_PTR CALLBACK AnimationDialogCallback ( if( HIWORD(wParam) == BN_CLICKED ) { HWND hwndButton = (HWND) lParam; - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); @@ -2481,7 +2483,7 @@ INT_PTR CALLBACK LodDialogCallback ( { CLodDialogBoxParam *currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: { @@ -2490,9 +2492,9 @@ INT_PTR CALLBACK LodDialogCallback ( currentParam=(CLodDialogBoxParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); // Window text - std::string winName=(*(currentParam->ListNode->begin()))->GetName(); + std::string winName = tStrToUtf8((*(currentParam->ListNode->begin()))->GetName()); winName="Node properties ("+winName+((currentParam->ListNode->size()>1)?" ...)":")"); - SetWindowText (hwndDlg, winName.c_str()); + SetWindowText (hwndDlg, utf8ToTStr(winName)); // Move dialog RECT windowRect, desktopRect; @@ -2520,11 +2522,11 @@ INT_PTR CALLBACK LodDialogCallback ( // Insert a tab TCITEM tabItem; tabItem.mask = TCIF_TEXT; - tabItem.pszText = (char*)SubText[tab]; + tabItem.pszText = (LPTSTR)SubText[tab]; SendMessage (GetDlgItem (hwndDlg, IDC_TAB), TCM_INSERTITEM, SendMessage (GetDlgItem (hwndDlg, IDC_TAB), TCM_GETITEMCOUNT, 0, 0), (LPARAM)&tabItem); // Create the dialog - currentParam->SubDlg[tab] = CreateDialogParam (hInstance, MAKEINTRESOURCE(SubTab[tab]), GetDlgItem (hwndDlg, IDC_TAB), SubProc[tab], (LONG)lParam); + currentParam->SubDlg[tab] = CreateDialogParam (hInstance, MAKEINTRESOURCE(SubTab[tab]), GetDlgItem (hwndDlg, IDC_TAB), SubProc[tab], lParam); // To client coord RECT client = tabRect; @@ -2549,7 +2551,7 @@ INT_PTR CALLBACK LodDialogCallback ( { case TCN_SELCHANGE: { - + uint curSel=SendMessage (pnmh->hwndFrom, TCM_GETCURSEL, 0, 0); for (uint tab=0; tab &listNode) { - // Get + // Get uint nNumSelNode=(uint)listNode.size(); if (nNumSelNode) @@ -2650,7 +2652,7 @@ void CNelExport::OnNodeProperties (const std::set &listNode) { // Get a string std::string nameLod=CExportNel::getScriptAppData (node, NEL3D_APPDATA_LOD_NAME+name, ""); - if (nameLod!="") + if (!nameLod.empty()) { param.ListLodName.push_back (nameLod); } @@ -2778,13 +2780,13 @@ void CNelExport::OnNodeProperties (const std::set &listNode) param.LMCAmbient[i]= CExportNel::getScriptAppData (node, NEL3D_APPDATA_EXPORT_LMC_AMBIENT_START+i, CRGBA::Black); param.LMCDiffuse[i]= CExportNel::getScriptAppData (node, NEL3D_APPDATA_EXPORT_LMC_DIFFUSE_START+i, CRGBA::White); } - + // CollisionMeshGeneration param.CollisionMeshGeneration=CExportNel::getScriptAppData (node, NEL3D_APPDATA_CAMERA_COLLISION_MESH_GENERATION, 0); - + // RealTimeAmbientLightAddSun param.RealTimeAmbientLightAddSun= CExportNel::getScriptAppData (node, NEL3D_APPDATA_REALTIME_AMBIENT_ADD_SUN, BST_UNCHECKED); - + // Something selected ? std::set::const_iterator ite=listNode.begin(); ite++; @@ -2854,7 +2856,7 @@ void CNelExport::OnNodeProperties (const std::set &listNode) param.SoundGroup = DIFFERENT_VALUE_STRING; if (CExportNel::getScriptAppData(node, NEL3D_APPDATA_ENV_FX, "no fx") != param.EnvironmentFX) { - param.EnvironmentFX = ""; + param.EnvironmentFX.clear(); } if ( param.LightGroup != CExportNel::getScriptAppData (node, NEL3D_APPDATA_LM_LIGHT_GROUP, 0) ) @@ -2871,7 +2873,7 @@ void CNelExport::OnNodeProperties (const std::set &listNode) if (CExportNel::getScriptAppData (node, NEL3D_APPDATA_IGNAME, "")!=param.InstanceGroupName) param.InstanceGroupName = DIFFERENT_VALUE_STRING; if (CExportNel::getScriptAppData (node, NEL3D_APPDATA_INTERFACE_FILE, "")!=param.InterfaceFileName) - param.InterfaceFileName = ""; + param.InterfaceFileName.clear(); if (CExportNel::getScriptAppData (node, NEL3D_APPDATA_INTERFACE_THRESHOLD, 0.1f)!=param.InterfaceThreshold) param.InterfaceThreshold = -1; if (CExportNel::getScriptAppData (node, NEL3D_APPDATA_GET_INTERFACE_NORMAL_FROM_SCENE_OBJECTS, 0)!=param.GetInterfaceNormalsFromSceneObjects) @@ -2900,7 +2902,7 @@ void CNelExport::OnNodeProperties (const std::set &listNode) param.RemanenceRollupRatio = -1.f; if (CExportNel::getScriptAppData (node, NEL3D_APPDATA_REMANENCE_SLICE_NUMBER, 64)!=param.RemanenceSliceNumber) param.RemanenceSliceNumber = -1; - + // Radial normals for (uint smoothGroup=0; smoothGroup &listNode) { // Get a string std::string nameLod=CExportNel::getScriptAppData (node, NEL3D_APPDATA_LOD_NAME+name, ""); - if (nameLod!="") + if (!nameLod.empty()) { tmplist.push_back (nameLod); } @@ -3002,9 +3004,9 @@ void CNelExport::OnNodeProperties (const std::set &listNode) if (CExportNel::getScriptAppData (node, NEL3D_APPDATA_LIGHT_DONT_CAST_SHADOW_EXTERIOR, BST_UNCHECKED) != param.LightDontCastShadowExterior) param.LightDontCastShadowExterior= BST_INDETERMINATE; - + // VertexProgram - // simply disable VertexProgram edition of multiple selection... + // simply disable VertexProgram edition of multiple selection... param.VertexProgramId= -1; // Collision @@ -3035,20 +3037,20 @@ void CNelExport::OnNodeProperties (const std::set &listNode) if(CExportNel::getScriptAppData (node, NEL3D_APPDATA_EXPORT_LMC_DIFFUSE_START+i, CRGBA::White) != param.LMCDiffuse[i]) param.LMCDiffuse[i].setDifferentValuesMode(); } - + // CollisionMeshGeneration if (CExportNel::getScriptAppData (node, NEL3D_APPDATA_CAMERA_COLLISION_MESH_GENERATION, 0)!=param.CollisionMeshGeneration) param.CollisionMeshGeneration = -1; - + // RealTimeAmbientLightAddSun if (CExportNel::getScriptAppData (node, NEL3D_APPDATA_REALTIME_AMBIENT_ADD_SUN, BST_UNCHECKED) != param.RealTimeAmbientLightAddSun) param.RealTimeAmbientLightAddSun= BST_INDETERMINATE; - + // Next sel ite++; } - if (DialogBoxParam (hInstance, MAKEINTRESOURCE(IDD_NODE_PROPERTIES), _Ip->GetMAXHWnd(), LodDialogCallback, (long)¶m)==IDOK) + if (DialogBoxParam (hInstance, MAKEINTRESOURCE(IDD_NODE_PROPERTIES), _Ip->GetMAXHWnd(), LodDialogCallback, (LPARAM)¶m)==IDOK) { // Next node ite=listNode.begin(); @@ -3152,22 +3154,22 @@ void CNelExport::OnNodeProperties (const std::set &listNode) } if ( (param.InstanceShape != DIFFERENT_VALUE_STRING) || (listNode.size()==1)) - CExportNel::setScriptAppData (node, NEL3D_APPDATA_INSTANCE_SHAPE, param.InstanceShape); + CExportNel::setScriptAppData (node, NEL3D_APPDATA_INSTANCE_SHAPE, param.InstanceShape); if (param.InstanceName != DIFFERENT_VALUE_STRING) - CExportNel::setScriptAppData (node, NEL3D_APPDATA_INSTANCE_NAME, param.InstanceName); + CExportNel::setScriptAppData (node, NEL3D_APPDATA_INSTANCE_NAME, param.InstanceName); if (param.DontAddToScene != BST_INDETERMINATE) CExportNel::setScriptAppData (node, NEL3D_APPDATA_DONT_ADD_TO_SCENE, param.DontAddToScene); if (param.AutomaticAnimation != BST_INDETERMINATE) CExportNel::setScriptAppData (node, NEL3D_APPDATA_AUTOMATIC_ANIMATION, param.AutomaticAnimation); if (param.InstanceGroupName != DIFFERENT_VALUE_STRING) - CExportNel::setScriptAppData (node, NEL3D_APPDATA_IGNAME, param.InstanceGroupName); + CExportNel::setScriptAppData (node, NEL3D_APPDATA_IGNAME, param.InstanceGroupName); if (param.InterfaceFileName != "") CExportNel::setScriptAppData (node, NEL3D_APPDATA_INTERFACE_FILE, param.InterfaceFileName); if (param.InterfaceThreshold != -1) CExportNel::setScriptAppData (node, NEL3D_APPDATA_INTERFACE_THRESHOLD, param.InterfaceThreshold); if (param.GetInterfaceNormalsFromSceneObjects != BST_INDETERMINATE) CExportNel::setScriptAppData (node, NEL3D_APPDATA_GET_INTERFACE_NORMAL_FROM_SCENE_OBJECTS, param.GetInterfaceNormalsFromSceneObjects); - + if (param.LightGroup != -1) CExportNel::setScriptAppData (node, NEL3D_APPDATA_LM_LIGHT_GROUP, param.LightGroup); @@ -3193,7 +3195,7 @@ void CNelExport::OnNodeProperties (const std::set &listNode) CExportNel::setScriptAppData (node, NEL3D_APPDATA_RADIAL_NORMAL_SM+smoothGroup, param.RadialNormals[smoothGroup]); } - + if (param.LumelSizeMul != DIFFERENT_VALUE_STRING) CExportNel::setScriptAppData (node, NEL3D_APPDATA_LUMELSIZEMUL, param.LumelSizeMul); if (param.SoftShadowRadius != DIFFERENT_VALUE_STRING) @@ -3226,7 +3228,7 @@ void CNelExport::OnNodeProperties (const std::set &listNode) // Write size of the list uint sizeList=std::min ((uint)param.ListLodName.size(), (uint)NEL3D_APPDATA_LOD_NAME_COUNT_MAX); CExportNel::setScriptAppData (node, NEL3D_APPDATA_LOD_NAME_COUNT, (int)sizeList); - + // Write the strings uint stringIndex=0; std::list::iterator ite=param.ListLodName.begin(); @@ -3287,7 +3289,7 @@ void CNelExport::OnNodeProperties (const std::set &listNode) if (param.VertexProgramId!=-1) { CExportNel::setScriptAppData (node, NEL3D_APPDATA_VERTEXPROGRAM_ID, param.VertexProgramId); - // according to VertexProgram, change setup + // according to VertexProgram, change setup if(param.VertexProgramId==1) { CExportNel::setScriptAppDataVPWT(node, param.VertexProgramWindTree); @@ -3344,15 +3346,15 @@ void CNelExport::OnNodeProperties (const std::set &listNode) CExportNel::setScriptAppData (node, NEL3D_APPDATA_EXPORT_LMC_DIFFUSE_START+i, col); } } - + // CollisionMeshGeneration if (param.CollisionMeshGeneration != -1) CExportNel::setScriptAppData (node, NEL3D_APPDATA_CAMERA_COLLISION_MESH_GENERATION, param.CollisionMeshGeneration); - + // RealTimeAmbientLightAddSun. if (param.RealTimeAmbientLightAddSun != BST_INDETERMINATE) CExportNel::setScriptAppData (node, NEL3D_APPDATA_REALTIME_AMBIENT_ADD_SUN, param.RealTimeAmbientLightAddSun); - + // Next node ite++; } diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_scene.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_scene.cpp index 1a007cb8b..b50903324 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_scene.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_scene.cpp @@ -56,10 +56,10 @@ bool CNelExport::exportInstanceGroup(string filename, vector& vectNode) pIG->serial (file); // All is good } - catch (Exception &c) + catch (const Exception &c) { // Cannot save the file - MessageBox (NULL, c.what(), "NeL export", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(c.what()), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION); return false; } } diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_script.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_script.cpp index c5457786e..dfdbdec08 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_script.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_script.cpp @@ -63,11 +63,11 @@ def_visible_primitive ( set_file_modification_date, "NeLSetFileModificationDate def_visible_primitive ( force_quit_on_msg_displayer, "NelForceQuitOnMsgDisplayer"); def_visible_primitive ( force_quit_right_now, "NelForceQuitRightNow"); -char *sExportShapeErrorMsg = "NeLExportShape [Object] [Filename.shape]"; -char *sExportShapeExErrorMsg = "NeLExportShapeEx [Object] [Filename.shape] [bShadow] [bExportLighting] [sLightmapPath] [nLightingLimit] [fLumelSize] [nOverSampling] [bExcludeNonSelected] [bShowLumel]"; -char *sExportAnimationErrorMsg = "NelExportAnimation [node array] [Filename.anim] [bool_scene_animation]"; -char *sExportCollisionErrorMsg = "NelExportCollision [node array] [output directory]"; -char *sExportPACSPrimitivesErrorMsg = "NelExportPACSPrimitves [node array] [output filename]"; +MCHAR *sExportShapeErrorMsg = _M("NeLExportShape [Object] [Filename.shape]"); +MCHAR *sExportShapeExErrorMsg = _M("NeLExportShapeEx [Object] [Filename.shape] [bShadow] [bExportLighting] [sLightmapPath] [nLightingLimit] [fLumelSize] [nOverSampling] [bExcludeNonSelected] [bShowLumel]"); +MCHAR *sExportAnimationErrorMsg = _M("NelExportAnimation [node array] [Filename.anim] [bool_scene_animation]"); +MCHAR *sExportCollisionErrorMsg = _M("NelExportCollision [node array] [output directory]"); +MCHAR *sExportPACSPrimitivesErrorMsg = _M("NelExportPACSPrimitves [node array] [output filename]"); extern CExportNelOptions theExportSceneStruct; @@ -91,7 +91,7 @@ Value* export_shape_cf (Value** arg_list, int count) theCNelExport.init (false, false, ip, true); // Export path - const char* sPath=arg_list[1]->to_string(); + std::string sPath = tStrToUtf8(arg_list[1]->to_string()); // Ok ? Boolean *ret=&false_value; @@ -112,7 +112,7 @@ Value* export_shape_cf (Value** arg_list, int count) if (theCNelExport.exportMesh (sPath, *node, ip->GetTime())) ret = &true_value; } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR (NelExportShape) %s", e.what()); } @@ -154,12 +154,12 @@ Value* export_shape_ex_cf (Value** arg_list, int count) nlassert(node->GetName()); // Export path - std::string sPath=arg_list[1]->to_string(); + std::string sPath = tStrToUtf8(arg_list[1]->to_string()); // Ex argu theExportSceneStruct.bShadow = arg_list[2]->to_bool()!=FALSE; theExportSceneStruct.bExportLighting = arg_list[3]->to_bool()!=FALSE; - theExportSceneStruct.sExportLighting = arg_list[4]->to_string(); + theExportSceneStruct.sExportLighting = tStrToUtf8(arg_list[4]->to_string()); theExportSceneStruct.nExportLighting = arg_list[5]->to_int(); theExportSceneStruct.rLumelSize = arg_list[6]->to_float(); theExportSceneStruct.nOverSampling = arg_list[7]->to_int(); @@ -187,7 +187,7 @@ Value* export_shape_ex_cf (Value** arg_list, int count) if (theCNelExport.exportMesh (sPath.c_str(), *node, ip->GetTime())) ret = &true_value; } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR (NelExportShapeEx) %s", e.what()); } @@ -207,8 +207,8 @@ Value* export_skeleton_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check (arg_list[0], MAXNode, "NelExportSkeleton [root node] [Filename]"); - type_check (arg_list[1], String, "NelExportSkeleton [root node] [Filename]"); + type_check (arg_list[0], MAXNode, _M("NelExportSkeleton [root node] [Filename]")); + type_check (arg_list[1], String, _M("NelExportSkeleton [root node] [Filename]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -220,7 +220,7 @@ Value* export_skeleton_cf (Value** arg_list, int count) nlassert (node); // Export path - const char* sPath=arg_list[1]->to_string(); + std::string sPath = tStrToUtf8(arg_list[1]->to_string()); // Ok ? Boolean *ret=&false_value; @@ -231,7 +231,7 @@ Value* export_skeleton_cf (Value** arg_list, int count) if (theCNelExport.exportSkeleton (sPath, node, ip->GetTime())) ret = &true_value; } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR (NelExportSkeleton) %s", e.what()); } @@ -260,7 +260,7 @@ Value* export_animation_cf (Value** arg_list, int count) theCNelExport.init (false, false, ip, true); // Export path - const char* sPath=arg_list[1]->to_string(); + std::string sPath = tStrToUtf8(arg_list[1]->to_string()); // Get time TimeValue time=MAXScript_interface->GetTime(); @@ -298,11 +298,11 @@ Value* export_animation_cf (Value** arg_list, int count) else { // Error message - mprintf ("Error exporting animation %s in the file\n%s\n", (*vectNode.begin())->GetName(), sPath); + mprintf (_M("Error exporting animation %s in the file\n%s\n"), (*vectNode.begin())->GetName(), utf8ToTStr(sPath)); } } } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR (NelExportAnimation) %s", e.what()); } @@ -321,8 +321,8 @@ Value* export_ig_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check (arg_list[0], Array, "NelExportInstanceGroup [Object array] [Filename]"); - type_check (arg_list[1], String, "NelExportInstanceGroup [Object array] [Filename]"); + type_check (arg_list[0], Array, _M("NelExportInstanceGroup [Object array] [Filename]")); + type_check (arg_list[1], String, _M("NelExportInstanceGroup [Object array] [Filename]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -342,7 +342,7 @@ Value* export_ig_cf (Value** arg_list, int count) // Check each value in the array uint i; for (i=0; i<(uint)array->size; i++) - type_check (array->get (i+1), MAXNode, "NelExportInstanceGroup [Object array] [Filename]"); + type_check (array->get (i+1), MAXNode, _M("NelExportInstanceGroup [Object array] [Filename]")); // Create a STL array if (array->size) @@ -352,7 +352,7 @@ Value* export_ig_cf (Value** arg_list, int count) vect.push_back (array->get (i+1)->to_node()); // Export path - const char* sPath=arg_list[1]->to_string(); + std::string sPath = tStrToUtf8(arg_list[1]->to_string()); // Export if (theCNelExport.exportInstanceGroup (sPath, vect)) @@ -360,7 +360,7 @@ Value* export_ig_cf (Value** arg_list, int count) } } } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR (NelExportInstanceGroup) %s", e.what()); } @@ -380,8 +380,8 @@ Value* export_skeleton_weight_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check (arg_list[0], Array, "NelExportSkeletonWeight [Object array] [Filename]"); - type_check (arg_list[1], String, "NelExportSkeletonWeight [Object array] [Filename]"); + type_check (arg_list[0], Array, _M("NelExportSkeletonWeight [Object array] [Filename]")); + type_check (arg_list[1], String, _M("NelExportSkeletonWeight [Object array] [Filename]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -401,7 +401,7 @@ Value* export_skeleton_weight_cf (Value** arg_list, int count) // Check each value in the array uint i; for (i=0; i<(uint)array->size; i++) - type_check (array->get (i+1), MAXNode, "NelExportSkeletonWeight [Object array] [Filename]"); + type_check (array->get (i+1), MAXNode, _M("NelExportSkeletonWeight [Object array] [Filename]")); // Create a STL array if (array->size) @@ -411,7 +411,7 @@ Value* export_skeleton_weight_cf (Value** arg_list, int count) vect.push_back (array->get (i+1)->to_node()); // Export path - const char* sPath=arg_list[1]->to_string(); + std::string sPath = tStrToUtf8(arg_list[1]->to_string()); // Export if (theCNelExport.exportSWT (sPath, vect)) @@ -419,7 +419,7 @@ Value* export_skeleton_weight_cf (Value** arg_list, int count) } } } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR (NelExportSkeletonWeight) %s", e.what()); } @@ -445,7 +445,7 @@ Value* view_shape_cf (Value** arg_list, int count) theCNelExport.viewMesh (ip->GetTime()); } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR %s", e.what()); } @@ -462,8 +462,8 @@ Value* test_file_date_cf (Value** arg_list, int count) // Make sure we have the correct number of arguments (2) check_arg_count(view_shape, 2, count); - type_check (arg_list[0], String, "NeLTestFileDate [DestFilename] [SrcFilename]"); - type_check (arg_list[1], String, "NeLTestFileDate [DestFilename] [SrcFilename]"); + type_check (arg_list[0], String, _M("NeLTestFileDate [DestFilename] [SrcFilename]")); + type_check (arg_list[1], String, _M("NeLTestFileDate [DestFilename] [SrcFilename]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -471,11 +471,11 @@ Value* test_file_date_cf (Value** arg_list, int count) theCNelExport.init (false, false, ip, true); // The 2 filenames - string file0 = arg_list[0]->to_string(); - string file1 = arg_list[1]->to_string(); + string file0 = tStrToUtf8(arg_list[0]->to_string()); + string file1 = tStrToUtf8(arg_list[1]->to_string()); // Open it - FILE *file=fopen (file0.c_str(), "r"); + FILE *file=nlfopen (file0.c_str(), "r"); if (file == NULL) return &true_value; @@ -486,10 +486,10 @@ Value* test_file_date_cf (Value** arg_list, int count) Value *ret = &undefined; // Create first file - HANDLE h0 = CreateFile (file0.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE h0 = CreateFile (utf8ToTStr(file0), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (h0!=INVALID_HANDLE_VALUE) { - HANDLE h1 = CreateFile (file1.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE h1 = CreateFile (utf8ToTStr(file1), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (h1!=INVALID_HANDLE_VALUE) { // Get file time @@ -526,7 +526,7 @@ Value* export_vegetable_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - char *message = "NelExportVegetable [node] [filename] [dialog error]"; + MCHAR *message = _M("NelExportVegetable [node] [filename] [dialog error]"); type_check (arg_list[0], MAXNode, message); type_check (arg_list[1], String, message); type_check (arg_list[2], Boolean, message); @@ -536,7 +536,7 @@ Value* export_vegetable_cf (Value** arg_list, int count) nlassert (node); // Export path - const char* sPath=arg_list[1]->to_string(); + std::string sPath = tStrToUtf8(arg_list[1]->to_string()); // Message in dialog bool dialogMessage = arg_list[2]->to_bool() != FALSE; @@ -555,7 +555,7 @@ Value* export_vegetable_cf (Value** arg_list, int count) if (theCNelExport.exportVegetable (sPath, *node, ip->GetTime())) ret = &true_value; } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR (NelExportVegetable) %s", e.what()); } @@ -615,7 +615,7 @@ Value* export_collision_cf (Value** arg_list, int count) theCNelExport.init (false, false, ip, true); // Export path - string sPath = arg_list[1]->to_string(); + string sPath = tStrToUtf8(arg_list[1]->to_string()); // Get time TimeValue time = MAXScript_interface->GetTime(); @@ -648,7 +648,7 @@ Value* export_collision_cf (Value** arg_list, int count) if (theCNelExport.exportCollision (sPath.c_str(), nodes, time)) ret = &true_value; } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR (NelExportCollision) %s", e.what()); } @@ -674,7 +674,7 @@ Value* export_pacs_primitives_cf (Value** arg_list, int count) theCNelExport.init (false, false, ip, true); // Export path - string sPath = arg_list[1]->to_string(); + string sPath = tStrToUtf8(arg_list[1]->to_string()); // Get time TimeValue time = MAXScript_interface->GetTime(); @@ -705,7 +705,7 @@ Value* export_pacs_primitives_cf (Value** arg_list, int count) if (theCNelExport.exportPACSPrimitives (sPath.c_str(), nodes, time)) ret = &true_value; } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR (NelExportPACSPrimitives) %s", e.what()); } @@ -723,7 +723,7 @@ Value* export_lod_character_cf (Value** arg_list, int count) check_arg_count(export_lod_character, 3, count); // Check to see if the arguments match up to what we expect - char *message = "NelExportLodCharacter [node] [filename] [dialog error]"; + MCHAR *message = _M("NelExportLodCharacter [node] [filename] [dialog error]"); type_check (arg_list[0], MAXNode, message); type_check (arg_list[1], String, message); type_check (arg_list[2], Boolean, message); @@ -733,7 +733,7 @@ Value* export_lod_character_cf (Value** arg_list, int count) nlassert (node); // Export path - const char* sPath=arg_list[1]->to_string(); + std::string sPath = tStrToUtf8(arg_list[1]->to_string()); // Message in dialog bool dialogMessage = arg_list[2]->to_bool() != FALSE; @@ -752,7 +752,7 @@ Value* export_lod_character_cf (Value** arg_list, int count) if (theCNelExport.exportLodCharacter (sPath, *node, ip->GetTime())) ret = &true_value; } - catch (Exception &e) + catch (const Exception &e) { nlwarning ("ERROR (NelExportLodCharacter) %s", e.what()); } @@ -771,7 +771,7 @@ Value* node_properties_cf (Value** arg_list, int count) check_arg_count(export_lod_character, 2, count); // Check to see if the arguments match up to what we expect - char *message = "NelNodeProperties [node_array] [dialog error]"; + MCHAR *message = _M("NelNodeProperties [node_array] [dialog error]"); //type_check (arg_list[0], MAXNode, message); type_check (arg_list[0], Array, message); @@ -787,7 +787,7 @@ Value* node_properties_cf (Value** arg_list, int count) uint i; for (i=0; i<(uint)array->size; i++) { - type_check (array->get (i+1), MAXNode, "NelNodeProperties [node_array] [dialog error]"); + type_check (array->get (i+1), MAXNode, _M("NelNodeProperties [node_array] [dialog error]")); // Add to the array of nodes nodes.insert (array->get (i+1)->to_node()); @@ -830,7 +830,7 @@ Value* mirror_physique_cf (Value** arg_list, int count) check_arg_count(NelMirrorPhysique , 3, count); // Check to see if the arguments match up to what we expect - char *message = "NelMirrorPhysique [node] [vert_list_in] [threshold]"; + MCHAR *message = _M("NelMirrorPhysique [node] [vert_list_in] [threshold]"); //type_check type_check (arg_list[0], MAXNode, message); @@ -873,17 +873,17 @@ Value* get_file_modification_date_cf (Value** arg_list, int count) check_arg_count(NeLGetFileModificationDate , 1, count); // Check to see if the arguments match up to what we expect - char *message = "date NeLGetFileModificationDate [filename] - If an error occured, returns undefined."; + MCHAR *message = _M("date NeLGetFileModificationDate [filename] - If an error occurred, returns undefined."); //type_check type_check (arg_list[0], String, message); // get the node - string sPath = arg_list[0]->to_string(); + string sPath = tStrToUtf8(arg_list[0]->to_string()); // get vertices indices string result; - HANDLE file = CreateFile (sPath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile (utf8ToTStr(sPath), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (file) { FILETIME lastWriteTime; @@ -899,7 +899,7 @@ Value* get_file_modification_date_cf (Value** arg_list, int count) if (result.empty()) return &undefined; else - return new String((char*)result.c_str()); + return new String(utf8ToTStr(result)); } // *************************************************************************** @@ -911,19 +911,19 @@ Value* set_file_modification_date_cf (Value** arg_list, int count) check_arg_count(NeLSetFileModificationDate , 2, count); // Check to see if the arguments match up to what we expect - char *message = "bool NeLSetFileModificationDate [filename] [date] - If an error occured, returns false."; + MCHAR *message = _M("bool NeLSetFileModificationDate [filename] [date] - If an error occurred, returns false."); //type_check type_check (arg_list[0], String, message); type_check (arg_list[1], String, message); // get the node - string sPath = arg_list[0]->to_string(); - string sDate = arg_list[1]->to_string(); + string sPath = tStrToUtf8(arg_list[0]->to_string()); + string sDate = tStrToUtf8(arg_list[1]->to_string()); // get vertices indices string result; - HANDLE file = CreateFile (sPath.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile (utf8ToTStr(sPath), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (file) { FILETIME lastWriteTime; diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_swt.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_swt.cpp index 496db99ec..c466b7055 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_swt.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_swt.cpp @@ -27,7 +27,7 @@ using namespace NL3D; using namespace NLMISC; -bool CNelExport::exportSWT(const char *sPath, std::vector& vectNode) +bool CNelExport::exportSWT(const std::string &sPath, std::vector& vectNode) { float rPosValue; float rRotValue; @@ -55,22 +55,22 @@ bool CNelExport::exportSWT(const char *sPath, std::vector& vectNode) // Store them in the temporary list aSWNodes.resize(nNumNode+3); - aSWNodes[nNumNode].Name = pNode->GetName(); + aSWNodes[nNumNode].Name = tStrToUtf8(pNode->GetName()); aSWNodes[nNumNode].Name += std::string (".")+ITransformable::getRotQuatValueName(); aSWNodes[nNumNode].Weight = rRotValue; ++nNumNode; - aSWNodes[nNumNode].Name = pNode->GetName(); + aSWNodes[nNumNode].Name = tStrToUtf8(pNode->GetName()); aSWNodes[nNumNode].Name += std::string (".")+ITransformable::getPosValueName (); aSWNodes[nNumNode].Weight = rPosValue; ++nNumNode; - aSWNodes[nNumNode].Name = pNode->GetName(); + aSWNodes[nNumNode].Name = tStrToUtf8(pNode->GetName()); aSWNodes[nNumNode].Name += std::string (".")+ITransformable::getScaleValueName(); aSWNodes[nNumNode].Weight = rScaleValue; ++nNumNode; } } - if (aSWNodes.size()) + if (!aSWNodes.empty()) { CSkeletonWeight sw; COFile file; @@ -86,7 +86,7 @@ bool CNelExport::exportSWT(const char *sPath, std::vector& vectNode) // All is good return true; } - catch (Exception &e) + catch (const Exception &e) { nlwarning (e.what()); } diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp index f4d5fdaf2..adfba5a98 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp @@ -102,24 +102,22 @@ void regsiterOVPath () //#ifdef NL_DEBUG_FAST // HMODULE hModule = GetModuleHandle("object_viewer_dll_df.dll"); #if defined (NL_DEBUG) - HMODULE hModule = GetModuleHandle("object_viewer_dll_d.dll"); + HMODULE hModule = GetModuleHandle(_T("object_viewer_dll_d.dll")); //#elif defined (NL_RELEASE_DEBUG) // HMODULE hModule = GetModuleHandle("object_viewer_dll_rd.dll"); #else - HMODULE hModule = GetModuleHandle("object_viewer_dll_r.dll"); + HMODULE hModule = GetModuleHandle(_T("object_viewer_dll_r.dll")); #endif - if (!hModule) { ::MessageBox(NULL, "'hModule' failed at '" __FUNCTION__ "' in file '" __FILE__ " on line " NL_MACRO_TO_STR(__LINE__), "NeL Export", MB_OK | MB_ICONERROR); return; } - char sModulePath[256]; + if (!hModule) { ::MessageBox(NULL, _T("'hModule' failed at '") __FUNCTION__ _T("' in file '") __FILE__ _T(" on line ") NL_MACRO_TO_STR(__LINE__), _T("NeL Export"), MB_OK | MB_ICONERROR); return; } + TCHAR sModulePath[256]; int res = GetModuleFileName(hModule, sModulePath, 256); - if (!res) { ::MessageBox(NULL, "'res' failed at '" __FUNCTION__ "' in file '" __FILE__ " on line " NL_MACRO_TO_STR(__LINE__), "NeL Export", MB_OK | MB_ICONERROR); return; } - char SDrive[512]; - char SDir[512]; - _splitpath (sModulePath, SDrive, SDir, NULL, NULL); - _makepath (sModulePath, SDrive, SDir, "object_viewer", ".cfg"); + if (!res) { ::MessageBox(NULL, _T("'res' failed at '") __FUNCTION__ _T("' in file '") __FILE__ _T(" on line ") NL_MACRO_TO_STR(__LINE__), _T("NeL Export"), MB_OK | MB_ICONERROR); return; } + + std::string modulePath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)) + "object_viewer.cfg"; // Load the config file CConfigFile cf; - cf.load (sModulePath); + cf.load (modulePath); try { @@ -128,7 +126,7 @@ void regsiterOVPath () for (uint i=0; i<(uint)search_pathes.size(); i++) CPath::addSearchPath (search_pathes.asString(i)); } - catch(EUnknownVar &) + catch(const EUnknownVar &) {} try @@ -138,7 +136,7 @@ void regsiterOVPath () for (uint i=0; i<(uint)recursive_search_pathes.size(); i++) CPath::addSearchPath (recursive_search_pathes.asString(i), true, false); } - catch(EUnknownVar &) + catch(const EUnknownVar &) {} // Add extension remapping @@ -155,7 +153,7 @@ void regsiterOVPath () CPath::remapExtension(extensions_remapping.asString(i), extensions_remapping.asString(i+1), true); } } - catch (EUnknownVar &) + catch (const EUnknownVar &) { } } @@ -176,7 +174,7 @@ void CNelExport::viewMesh (TimeValue time) // Check wether there's not an instance currently running if (view->isInstanceRunning()) { - ::MessageBox(NULL, "An instance of the viewer is currently running, please close it :)", "NeL Export", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(NULL, _T("An instance of the viewer is currently running, please close it :)"), _T("NeL Export"), MB_OK|MB_ICONEXCLAMATION); return; } @@ -193,7 +191,7 @@ void CNelExport::viewMesh (TimeValue time) // Init it if (!view->initUI()) { - ::MessageBox(NULL, "Failed to initialize object viewer ui, this may be a driver init issue, check your log.log files", "NeL Export", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(NULL, _T("Failed to initialize object viewer ui, this may be a driver init issue, check your log.log files"), _T("NeL Export"), MB_OK|MB_ICONEXCLAMATION); IObjectViewer::releaseInterface(view); return; } @@ -302,7 +300,7 @@ void CNelExport::viewMesh (TimeValue time) _ExportNel->buildSkeletonShape (*skelShape, *skeletonRoot, &(iteSkeleton->second), mapId, time); // Add the shape in the view - uint instance = view->addSkel (skelShape, skeletonRoot->GetName()); + uint instance = view->addSkel (skelShape, tStrToUtf8(skeletonRoot->GetName())); // Add tracks CAnimation *anim=new CAnimation; @@ -367,9 +365,9 @@ void CNelExport::viewMesh (TimeValue time) INode* pNode=_Ip->GetSelNode (nNode); string sTmp = "Object Name: "; - sTmp += pNode->GetName(); + sTmp += tStrToUtf8(pNode->GetName()); ProgBar.setLine (0, sTmp); - sTmp = ""; + sTmp.clear(); for (uint32 i = 1; i < 10; ++i) ProgBar.setLine (i, sTmp); sTmp = "Last Error"; @@ -412,7 +410,7 @@ void CNelExport::viewMesh (TimeValue time) if (pShape) { // Add the shape in the view - uint instance = view->addMesh (pShape, pNode->GetName(), iteSkelShape->second.SkeletonInstance); + uint instance = view->addMesh (pShape, tStrToUtf8(pNode->GetName()).c_str(), iteSkelShape->second.SkeletonInstance); // Add tracks CAnimation *anim=new CAnimation; @@ -582,8 +580,8 @@ void CNelExport::viewMesh (TimeValue time) NLMISC::clamp(slInfo.CellSurfaceLightSize, 0.001f, 1000000.f); slInfo.CellRaytraceDeltaZ= theExportSceneStruct.SurfaceLightingDeltaZ; // no more add any prefix to the colision identifier. - slInfo.ColIdentifierPrefix= ""; - slInfo.ColIdentifierSuffix= ""; + slInfo.ColIdentifierPrefix.clear(); + slInfo.ColIdentifierSuffix.clear(); // Build RetrieverBank and GlobalRetriever from collisions in scene _ExportNel->computeCollisionRetrieverFromScene(time, slInfo.RetrieverBank, slInfo.GlobalRetriever, slInfo.ColIdentifierPrefix.c_str(), slInfo.ColIdentifierSuffix.c_str(), slInfo.IgFileName); diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_zone.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_zone.cpp index e74e39dd0..334b56aff 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_zone.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_zone.cpp @@ -25,7 +25,7 @@ using namespace NLMISC; // -------------------------------------------------- -bool CNelExport::exportZone (const char *sPath, INode& node, TimeValue time) +bool CNelExport::exportZone (const std::string &sPath, INode& node, TimeValue time) { // Result to return bool bRet=false; diff --git a/code/nel/tools/3d/plugin_max/nel_export/progress.cpp b/code/nel/tools/3d/plugin_max/nel_export/progress.cpp index 167a4fc14..17b3fab2a 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/progress.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/progress.cpp @@ -52,24 +52,25 @@ INT_PTR CALLBACK CalculatingDialogCallback ( case WM_PAINT: { - char temp[256]; + TCHAR temp[256]; SendMessage( GetDlgItem( hwndDlg, IDC_PROGRESS1 ), PBM_SETPOS, (int)(pClass->rRatioCalculated*100), 0 ); if( pClass->rRatioCalculated > 0.0 ) { double TimeLeft = (TimeCurrent - pClass->rTimeBegin) * (1.0-pClass->rRatioCalculated); - sprintf( temp, "Time remaining : %02d h %02d m %02d s", ((uint32)TimeLeft)/3600, + _stprintf( temp, _T("Time remaining : %02d h %02d m %02d s"), ((uint32)TimeLeft)/3600, (((uint32)TimeLeft)/60)%60, (((uint32)TimeLeft))%60 ); if (pClass->bCancelCalculation) - strcpy (temp, "INTERRUPTED - Finishing current object..."); - SendMessage (GetDlgItem (hwndDlg, IDC_STATICTIMELEFT), WM_SETTEXT, 0, (long)temp); + _tcscpy_s (temp, 256, _T("INTERRUPTED - Finishing current object...")); + + SendMessage (GetDlgItem (hwndDlg, IDC_STATICTIMELEFT), WM_SETTEXT, 0, (LPARAM)temp); SendMessage (GetDlgItem (hwndDlg, IDC_BUTTONCANCEL), WM_PAINT, 0, 0); } - string all = ""; + string all; for (uint32 i = 0; i < 14; ++i) all += pClass->sInfoProgress[i] + "\n"; - SendMessage (GetDlgItem (hwndDlg, IDC_STATICINFO), WM_SETTEXT, 0, (long)all.c_str()); + SendMessage (GetDlgItem (hwndDlg, IDC_STATICINFO), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(all)); } break; @@ -119,7 +120,7 @@ void CProgressBar::initProgressBar( sint32 nNbMesh, Interface &ip) MAKEINTRESOURCE(IDD_CALCULATING), NULL,//ip.GetMAXHWnd(), CalculatingDialogCallback, - (long)this ); + (LPARAM)this ); } // ----------------------------------------------------------------------------------------------- diff --git a/code/nel/tools/3d/plugin_max/nel_export/std_afx.h b/code/nel/tools/3d/plugin_max/nel_export/std_afx.h index 9b4b18357..ba7b4b4c0 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/std_afx.h +++ b/code/nel/tools/3d/plugin_max/nel_export/std_afx.h @@ -71,5 +71,6 @@ namespace std #endif #include "nel/misc/bsphere.h" +#include "nel/misc/path.h" #endif diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/CMakeLists.txt b/code/nel/tools/3d/plugin_max/nel_mesh_lib/CMakeLists.txt index a6161338d..e8222ad54 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/CMakeLists.txt +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/CMakeLists.txt @@ -8,8 +8,10 @@ NL_DEFAULT_PROPS(nel_mesh_lib "MAX Plugin: NeL Mesh Library") NL_ADD_RUNTIME_FLAGS(nel_mesh_lib) NL_ADD_LIB_SUFFIX(nel_mesh_lib) +ADD_DEFINITIONS(${MAXSDK_DEFINITIONS}) + IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nel_mesh_lib ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.h ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS nel_mesh_lib RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp index d82e2a394..5ccc223f9 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp @@ -128,7 +128,7 @@ void SLightBuild::convertFromMaxLight (INode *node,TimeValue tvTime) if (maxLight->EvalLightState(tvTime, valid, &ls)!=REF_SUCCEED) return; - this->Name = node->GetName(); + this->Name = tStrToUtf8(node->GetName()); // Retrieve the correct light Group Name this->AnimatedLight = CExportNel::getAnimatedLight (node); @@ -295,7 +295,7 @@ void SLightBuild::convertFromMaxLight (INode *node,TimeValue tvTime) INode *exclNode = exclusionList[i]; if (exclNode) // Crashfix // FIXME: Why is this NULL? { - string tmp = exclNode->GetName(); + string tmp = tStrToUtf8(exclNode->GetName()); this->setExclusion.insert(tmp); } } @@ -1930,7 +1930,7 @@ void supprLightNoInteractOne( vector &vLights, CMesh::CMeshBuild* p { bool bInteract = false; - if( vLights[i].setExclusion.find( node.GetName() ) != vLights[i].setExclusion.end() ) + if( vLights[i].setExclusion.find(tStrToUtf8(node.GetName()) ) != vLights[i].setExclusion.end() ) { bInteract = false; } @@ -2005,7 +2005,7 @@ void CExportNel::deleteLM(INode& ZeNode) string sSaveName; sSaveName = _Options.sExportLighting; if( sSaveName[sSaveName.size()-1] != '\\' ) sSaveName += "\\"; - sSaveName += ZeNode.GetName(); + sSaveName += tStrToUtf8(ZeNode.GetName()); char tmp[32]; sprintf( tmp, "%d", i ); sSaveName += tmp; @@ -2063,7 +2063,7 @@ void sans_majuscule_au_debut_LinkToObjectAround (CMesh::CMeshBuild *pMB, CMeshBa } } - if (ivert.size() > 0) + if (!ivert.empty()) { // Get all faces that contains at least one shared vertex for (k = 0; k < wrt.vMB[i]->Faces.size(); ++k) @@ -2128,7 +2128,7 @@ void appendLightmapLog (COFile &outputLog, const char *lightmapName, const vecto outputLog.serialBuffer ((uint8*)text.c_str(), text.size()); } - catch (exception &e) + catch (const exception &e) { nlwarning ("Error writing the file : %s", e.what()); } @@ -2258,7 +2258,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB // Bubble sort pointer to the faces (Material sorting) ClearFaceWithNoLM( pMB, pMBB, AllFaces ); - if( AllFaces.size() == 0 ) + if( AllFaces.empty() ) { if (InfoLog) InfoLog->display("CalculateLM : %d ms\n", timeGetTime()-t); @@ -2276,7 +2276,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { string thetext; thetext = "Warning "; - thetext += ZeNode.GetName(); + thetext += tStrToUtf8(ZeNode.GetName()); thetext = "have all faces NOT mapped (UV2)"; if (gOptions.FeedBack != NULL) { @@ -2325,11 +2325,11 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { // Make an error message string sTmp = "Warning : "; - sTmp += ZeNode.GetName(); + sTmp += tStrToUtf8(ZeNode.GetName()); sTmp += " has mapping problem"; // Script trace - mprintf ((sTmp+"\n").c_str()); + mprintf (utf8ToTStr((sTmp+"\n"))); // Feedback is here ? if (gOptions.FeedBack != NULL) @@ -2436,7 +2436,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { string sTmp = "Placement"; gOptions.FeedBack->setLine (3, sTmp); - sTmp = ""; + sTmp.clear(); for(i=4;i<10;++i) gOptions.FeedBack->setLine (i, sTmp); gOptions.FeedBack->update (); @@ -2525,12 +2525,12 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB // Get the name of the max project char projectName[512]; - _splitpath (_Ip->GetCurFileName(), NULL, NULL, projectName, NULL); + _wsplitpath (_Ip->GetCurFileName(), NULL, NULL, utf8ToTStr(projectName), NULL); // Add lightmap information in the lightmap log COFile outputLog; if (outputLightmapLog) - createLightmapLog (outputLog, gOptions.sExportLighting.c_str(), projectName, ZeNode.GetName()); + createLightmapLog (outputLog, gOptions.sExportLighting.c_str(), projectName, tStrToUtf8(ZeNode.GetName()).c_str()); // Update UV coords to Texture space PutFaceUV1InTextureCoord( LightMap.w, LightMap.h, AllFaces.begin(), AllFaces.size() ); @@ -2559,7 +2559,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { CTextureFile *pLightMap = new CTextureFile(); //string sSaveName = AllMeshBuilds[nNode].second->GetName(); - string sSaveName = ZeNode.GetName(); + string sSaveName = tStrToUtf8(ZeNode.GetName()); char tmp[32]; sSaveName += "_"; sprintf( tmp, "%d", nLightMapNb ); @@ -2628,13 +2628,12 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB pLightMap->writeTGA (f, 32); } } - catch(Exception &e) + catch(const Exception &e) { if (gOptions.FeedBack != NULL) { - char message[512]; - sprintf (message, "Can't write the file %s : %s", sSaveName, e.what()); - mprintf (message); + std::string message = toString("Can't write the file %s : %s", sSaveName.c_str(), e.what()); + mprintf (utf8ToTStr(message)); } } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp index a0e6139b2..1a89c8d31 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp @@ -113,7 +113,7 @@ void CRTWorld::build (vector &AllLights, CVector &trans, bool bExcl pLAP->create( 64 ); // width of each grid in number of square for( j = 0; j < vMB.size(); ++j ) { - if (rLight.setExclusion.find (vINode[j]->GetName()) != rLight.setExclusion.end()) + if (rLight.setExclusion.find (tStrToUtf8(vINode[j]->GetName())) != rLight.setExclusion.end()) continue; for (k = 0; k < vMB[j]->Faces.size(); ++k) @@ -142,7 +142,7 @@ void CRTWorld::build (vector &AllLights, CVector &trans, bool bExcl pLAD->create (64, rLight.rDirRadius/64.0f, rLight.Direction); for( j = 0; j < vMB.size(); ++j ) { - if (rLight.setExclusion.find (vINode[j]->GetName()) != rLight.setExclusion.end()) + if (rLight.setExclusion.find (tStrToUtf8(vINode[j]->GetName())) != rLight.setExclusion.end()) continue; for (k = 0; k < vMB[j]->Faces.size(); ++k) @@ -246,7 +246,7 @@ CRGBAF CRTWorld::raytrace (NLMISC::CVector &vVertex, sint32 nLightNb, uint8& rtV RayOfLight.clip (t); - if (RayOfLight.Shapes.size() == 0) + if (RayOfLight.Shapes.empty()) return CRGBAF(0.0f, 0.0f, 0.0f, 0.0f); // Next selected element diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_anim.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_anim.cpp index 06e3c051d..d55312af6 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_anim.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_anim.cpp @@ -34,6 +34,10 @@ using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + static Class_ID DefNoteTrackClassID(NOTETRACK_CLASS_ID, 0); #define BOOL_CONTROL_CLASS_ID 0x984b8d27 @@ -185,7 +189,7 @@ void CExportNel::addSSSTrack(CSSSBuild &ssBuilder, INode& node) if(note) { CSSSBuild::CKey ks; - ks.Value = std::string(note->note); + ks.Value = note->note.ToUTF8(); ks.Time= CExportNel::convertTime (note->time); bs.Track.push_back(ks); } @@ -224,7 +228,7 @@ NL3D::CTrackKeyFramerConstString* CExportNel::buildFromNoteTrack(INode& node) { firstDate = CExportNel::convertTime (note->time); } - ks.Value = std::string(note->note); + ks.Value = note->note.ToUTF8(); lastDate = CExportNel::convertTime (note->time); st->addKey(ks , lastDate ); @@ -605,7 +609,7 @@ void CExportNel::addMorphTracks (NL3D::CAnimation& animation, INode& node, const if (pNode == NULL) continue; std::string name = parentName; - name += pNode->GetName(); + name += tStrToUtf8(pNode->GetName()); name += "MorphFactor"; IParamBlock *pb = (IParamBlock*)(pMorphMod->SubAnim (i+1)); @@ -1761,7 +1765,7 @@ ITrack* CExportNel::buildATrack (CAnimation& animation, Control& c, TNelValueTyp } else { - MessageBox (NULL, "Warning: no pos track exported!", "Tmp NEL", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, _T("Warning: no pos track exported!"), _T("Tmp NEL"), MB_OK|MB_ICONEXCLAMATION); } } } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp index 0a01a9fb8..d9657cd68 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp @@ -73,7 +73,7 @@ CCollisionMeshBuild* CExportNel::createCollisionMeshBuild(std::vector & { // get the mesh name uint meshId = rootMeshNames.size(); - rootMeshNames.push_back(nodes[node]->GetName()); + rootMeshNames.push_back(tStrToUtf8(nodes[node]->GetName())); bool collision = getScriptAppData (nodes[node], NEL3D_APPDATA_COLLISION, 0) != 0; bool exterior = getScriptAppData (nodes[node], NEL3D_APPDATA_COLLISION_EXTERIOR, 0) != 0; @@ -263,7 +263,7 @@ CCollisionMeshBuild* CExportNel::createCollisionMeshBuild(std::vector & // report warnings if (!warnings.empty()) { - string message = "Warning(s) occured during collision export\n(defective links may result) error"; + string message = "Warning(s) occurred during collision export\n(defective links may result) error"; for (i=0; i & // report warnings if (!errors.empty()) { - string message = "Error(s) occured during collision export\n(edge issues)"; + string message = "Error(s) occurred during collision export\n(edge issues)"; for (i=0; i & pCollisionMeshBuild = NULL; } - // Return the shape pointer or NULL if an error occured. + // Return the shape pointer or NULL if an error occurred. return pCollisionMeshBuild; } @@ -391,7 +391,7 @@ void CExportNel::computeCollisionRetrieverFromScene(TimeValue time, // Default: empty retrieverBank/globalRetriever retrieverBank= NULL; globalRetriever= NULL; - retIgName= ""; + retIgName.clear(); // get list of nodes from scene std::vector nodes; diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp index afe64907b..f7c8135ad 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp @@ -768,7 +768,7 @@ void CExportNel::buildAMaterial (NL3D::CMaterial& material, CMaxMaterialInfo& ma // Set material name TSTR name=mtl.GetName(); - materialInfo.MaterialName = (const char*)name; + materialInfo.MaterialName = name.ToUTF8(); } else { @@ -1120,7 +1120,7 @@ void CExportNel::buildAMaterial (NL3D::CMaterial& material, CMaxMaterialInfo& ma // Set material name TSTR name=mtl.GetName(); - materialInfo.MaterialName = (const char*)name; + materialInfo.MaterialName = name.ToUTF8(); } } @@ -1142,22 +1142,6 @@ int CExportNel::getVertMapChannel (Texmap& texmap, Matrix3& channelMatrix, TimeV // get the absolute or relative path from a texture filename static std::string ConvertTexFileName(const std::string &path, bool _AbsolutePath) { - /*// File name, maxlen 256 under windows - char sFileName[512]; - strcpy (sFileName, src); - - // Let absolute path ? - if (!_AbsolutePath) - { - // Decompose bitmap file name - char sName[256]; - char sExt[256]; - _splitpath (sFileName, NULL, NULL, sName, sExt); - - // Make the final path - _makepath (sFileName, NULL, NULL, sName, sExt); - } - return std::string(sFileName);*/ if (_AbsolutePath) { return path; @@ -1271,7 +1255,7 @@ ITexture* CExportNel::buildATexture (Texmap& texmap, CMaterialDesc &remap3dsTexC else // standard texture { srcTex = new CTextureFile; - std::string mapName = pBitmap->GetMapName(); + std::string mapName = tStrToUtf8(pBitmap->GetMapName()); static_cast(srcTex)->setFileName (ConvertTexFileName(mapName, _AbsolutePath)); } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh.cpp index bd48be1ea..d39020a64 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh.cpp @@ -116,7 +116,7 @@ CMesh::CMeshBuild* CExportNel::createMeshBuild(INode& node, TimeValue tvTime, CM } } - // Return the shape pointer or NULL if an error occured. + // Return the shape pointer or NULL if an error occurred. return pMeshBuild; } @@ -266,7 +266,7 @@ NL3D::IShape *CExportNel::buildShape (INode& node, TimeValue time, const TInodeP std::string nodeName=getScriptAppData (&node, NEL3D_APPDATA_LOD_NAME+lod, ""); // Get the node - INode *lodNode=_Ip->GetINodeByName(nodeName.c_str()); + INode *lodNode=_Ip->GetINodeByName(utf8ToTStr(nodeName)); if (lodNode) { // Index of the lod in the build structure @@ -467,7 +467,7 @@ NL3D::IShape *CExportNel::buildShape (INode& node, TimeValue time, const TInodeP retShape->setDistMax (distmax); } - // Return the shape pointer or NULL if an error occured. + // Return the shape pointer or NULL if an error occurred. return retShape; } @@ -611,7 +611,7 @@ void CExportNel::buildBaseMeshInterface (NL3D::CMeshBase::CMeshBaseBuild& buildM continue; // get factor here ! buildMesh.DefaultBSFactors.push_back(0.0f); - std::string sTemp = pNode->GetName(); + std::string sTemp = tStrToUtf8(pNode->GetName()); buildMesh.BSNames.push_back (sTemp); } @@ -1063,9 +1063,8 @@ void CExportNel::buildMeshInterface (TriObject &tri, CMesh::CMeshBuild& buildMes // Error code ? if (error!=NoError) { - char msg[512]; - sprintf (msg, "%s skin: %s", getName (node).c_str(), ErrorMessage[error]); - MessageBox (NULL, msg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string msg = toString("%s skin: %s", getName (node).c_str(), ErrorMessage[error]); + MessageBoxW (NULL, utf8ToTStr(msg), L"NeL export", MB_OK|MB_ICONEXCLAMATION); } else { @@ -1181,7 +1180,7 @@ void CExportNel::getBSMeshBuild (std::vector &bsList, INode convertMatrix(finalSpace, node.GetNodeTM(time)); CMeshBase::CMeshBaseBuild *dummyMBB = NULL; - std::auto_ptr baseMB(createMeshBuild (node, time, dummyMBB, finalSpace)); + CUniquePtr baseMB(createMeshBuild (node, time, dummyMBB, finalSpace)); delete dummyMBB; dummyMBB = NULL; if (baseMB.get() == NULL) return; @@ -1421,7 +1420,7 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP if (InfoLog) InfoLog->display("End of %s \n", node.GetName()); - // Return the shape pointer or NULL if an error occured. + // Return the shape pointer or NULL if an error occurred. return meshGeom; } @@ -1493,7 +1492,7 @@ void CExportNel::buildMeshMorph (CMesh::CMeshBuild& buildMesh, INode &node, Time continue; } - bs.Name = pNode->GetName(); + bs.Name = tStrToUtf8(pNode->GetName()); bool bIsDeltaPos = false; bs.deltaPos.resize (nNbVertVB, CVector::Null); diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp index 899c28a28..0cbd8fbe1 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp @@ -20,7 +20,7 @@ #include #include - +#include #include "nel/misc/line.h" #include "nel/misc/polygon.h" @@ -316,7 +316,7 @@ static void AddNodeToQuadGrid(const NLMISC::CAABBox &delimiter, TNodeFaceQG &des { if (delimiter.intersect(nodeBBox)) { - nldebug((std::string("Adding ") + node.GetName() + std::string(" to mesh interface quad grid")).c_str()); + nldebug("Adding %s to mesh interface quad grid", tStrToUtf8(node.GetName()).c_str()); // add this node tris ObjectState os = node.EvalWorldState(time); Object *obj = os.obj; @@ -579,9 +579,9 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetName (); + string originalName = (*lib)[i]->GetName ().ToUTF8(); renameMap.insert (map::value_type (newName, originalName)); - (*lib)[i]->SetName (newName.c_str ()); + (*lib)[i]->SetName (utf8ToTStr(newName)); } // Merge the interface project @@ -604,7 +604,7 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetName (); + string key = (*lib)[i]->GetName ().ToUTF8(); map::iterator ite = renameMap.find (key); // Not found ? This is a merged material @@ -612,9 +612,9 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetName (); + string originalName = (*lib)[i]->GetName ().ToUTF8(); renameMap.insert (map::value_type (newName, originalName)); - (*lib)[i]->SetName (newName.c_str ()); + (*lib)[i]->SetName (utf8ToTStr(newName)); } } @@ -622,12 +622,12 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetName (); + string key = (*lib)[i]->GetName ().ToUTF8(); map::iterator ite = renameMap.find (key); if (ite != renameMap.end ()) { // Rename the material with its original name - (*lib)[i]->SetName (ite->second.c_str ()); + (*lib)[i]->SetName (utf8ToTStr(ite->second)); } } @@ -648,7 +648,7 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetParamDef(id); // Good name? - if (strcmp (paramDef.int_name, sName)==0) + if (strcmp (tStrToUtf8(paramDef.int_name).c_str(), sName)==0) { // ok, return this subanim #if MAX_VERSION_MAJOR >= 14 @@ -288,7 +288,7 @@ Control* CExportNel::getControlerByName (Animatable& node, const char* sName) { // Sub anim name TSTR name=node.SubAnimName (s); - if (strcmp (name, sName)==0) + if (strcmp (name.ToUTF8(), sName)==0) { // Get the controller pointer of this sub anim Control* c=GetControlInterface (node.SubAnim(s)); @@ -332,7 +332,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName ParamDef& paramDef=param->GetParamDef(id); // Good name? - if (strcmp (paramDef.int_name, sName)==0) + if (strcmp (tStrToUtf8(paramDef.int_name).c_str(), sName)==0) { // Check this value is good type ParamType2 paramType = param->GetParameterType(id); @@ -372,7 +372,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName break; case TYPE_FILENAME: case TYPE_STRING: - *(std::string*)pValue = param->GetStr (id, tvTime); + *(std::string*)pValue = tStrToUtf8(param->GetStr (id, tvTime)); bRes = TRUE; break; case TYPE_FILENAME_TAB: @@ -382,7 +382,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName uint total = param->Count (id); rTab.resize(total); for( uint i = 0; i < total; ++i ) - rTab[i] = param->GetStr (id, tvTime, i); + rTab[i] = tStrToUtf8(param->GetStr (id, tvTime, i)); bRes = TRUE; } break; @@ -409,7 +409,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName } else { - nlwarning("Invalid type specified for pblock2 value with name '%s', given type '%u', found '%u'", + nlwarning("Invalid type specified for pblock2 value with name '%s', given type '%u', found '%u'", sName, (uint32)type, (uint32)paramType); } } @@ -476,12 +476,12 @@ Modifier* CExportNel::getModifier (INode* pNode, Class_ID modCID) int m; int nNumMods = pDObj->NumModifiers(); // Step through all modififers and verify the class id - for (m=0; mGetModifier(m); - if (pMod) + if (pMod) { - if (pMod->ClassID() == modCID) + if (pMod->ClassID() == modCID) { // Match! Return it return pMod; @@ -502,7 +502,7 @@ std::string CExportNel::getName (MtlBase& mtl) // Return its name TSTR name; name=mtl.GetName(); - return std::string (name); + return std::string((const char*)name.ToUTF8()); } // -------------------------------------------------- @@ -511,8 +511,8 @@ std::string CExportNel::getName (MtlBase& mtl) std::string CExportNel::getName(INode& node) { // Return its name - MCHAR* name = node.GetName(); - return std::string(name); + const MCHAR* name = node.GetName(); + return tStrToUtf8(name); } // -------------------------------------------------- @@ -528,28 +528,28 @@ std::string CExportNel::getNelObjectName (INode& node) if (obj) { Class_ID clid = obj->ClassID(); - // is the object a particle system ? (we do this defore meshs, because for now there is a mesh in max scenes to say where a particle system is...) + // is the object a particle system ? (we do this defore meshs, because for now there is a mesh in max scenes to say where a particle system is...) if (clid.PartA() == NEL_PARTICLE_SYSTEM_CLASS_ID) { std::string shapeName; if (CExportNel::getValueByNameUsingParamBlock2(node, "ps_file_name", (ParamType2) TYPE_STRING, &shapeName, 0)) { return NLMISC::CFile::getFilename(shapeName); - } + } } } - // Try to get an APPDATA for the name of the object + // Try to get an APPDATA for the name of the object AppDataChunk *ad = node.GetAppDataChunk (MAXSCRIPT_UTILITY_CLASS_ID, UTILITY_CLASS_ID, NEL3D_APPDATA_INSTANCE_SHAPE); if (ad&&ad->data) { if (::strlen((const char *) ad->data) != 0) - { + { // Get the name of the object in the APP data return (const char*)ad->data; } else { - return node.GetName(); + return tStrToUtf8(node.GetName()); } } else @@ -561,36 +561,33 @@ std::string CExportNel::getNelObjectName (INode& node) ad = obj->GetAppDataChunk (MAXSCRIPT_UTILITY_CLASS_ID, UTILITY_CLASS_ID, NEL3D_APPDATA_INSTANCE_SHAPE); if (ad&&ad->data) { - if (::strlen((const char *) ad->data) != 0) - { + if (_tcslen((const TCHAR *) ad->data) != 0) + { // get file name only - char fName[_MAX_FNAME]; - char ext[_MAX_FNAME]; - ::_splitpath((const char*)ad->data, NULL, NULL, fName, ext) ; - return std::string(fName + std::string(ext)); + return NLMISC::CFile::getFilename(tStrToUtf8((const TCHAR*)ad->data)); } else { - return node.GetName(); + return tStrToUtf8(node.GetName()); } } else { // Extract the node name - return node.GetName(); + return tStrToUtf8(node.GetName()); } } else - { + { // Extract the node name - return node.GetName(); + return tStrToUtf8(node.GetName()); } } } // -------------------------------------------------- -void CExportNel::decompMatrix (NLMISC::CVector& nelScale, NLMISC::CQuat& nelRot, NLMISC::CVector& nelPos, +void CExportNel::decompMatrix (NLMISC::CVector& nelScale, NLMISC::CQuat& nelRot, NLMISC::CVector& nelPos, const Matrix3& maxMatrix) { // Use decomp part of the max SDK @@ -604,7 +601,7 @@ void CExportNel::decompMatrix (NLMISC::CVector& nelScale, NLMISC::CQuat& nelRot, parts.q.MakeMatrix(rtm); parts.u.MakeMatrix(srtm); stm = ScaleMatrix(parts.k); - ftm = ScaleMatrix(Point3(parts.f,parts.f,parts.f)); + ftm = ScaleMatrix(Point3(parts.f,parts.f,parts.f)); Matrix3 mat = Inverse(srtm) * stm * srtm * rtm * ftm * ptm; // Set the translation @@ -763,32 +760,32 @@ bool CExportNel::hasLightMap (INode& node, TimeValue time) // -------------------------------------------------- -void CExportNel::outputErrorMessage (const char *message) +void CExportNel::outputErrorMessage(const std::string &message) { if (_ErrorInDialog) { - MessageBox (_Ip->GetMAXHWnd(), message, _ErrorTitle.c_str(), MB_OK|MB_ICONEXCLAMATION); + MessageBoxW (_Ip->GetMAXHWnd(), utf8ToTStr(message), utf8ToTStr(_ErrorTitle), MB_OK|MB_ICONEXCLAMATION); } - mprintf (message); - mprintf ("\n"); + mprintf (utf8ToTStr(message)); + mprintf (_T("\n")); nlwarning ("Error in max file %s : ", _Ip->GetCurFilePath()); - nlwarning (message); + nlwarning (message.c_str()); } // -------------------------------------------------- -void CExportNel::outputWarningMessage (const char *message) +void CExportNel::outputWarningMessage (const std::string &message) { if (_ErrorInDialog) { - MessageBox (_Ip->GetMAXHWnd(), message, _ErrorTitle.c_str(), MB_OK|MB_ICONEXCLAMATION); + MessageBox (_Ip->GetMAXHWnd(), utf8ToTStr(message), utf8ToTStr(_ErrorTitle), MB_OK|MB_ICONEXCLAMATION); } - mprintf (message); - mprintf ("\n"); + mprintf (utf8ToTStr(message)); + mprintf (_M("\n")); nlwarning ("Warning in max file %s : ", _Ip->GetCurFilePath()); - nlwarning (message); + nlwarning (message.c_str()); } // -------------------------------------------------- @@ -822,7 +819,7 @@ void CExportNel::addChildLodNode (std::set &lodListToExclude, INode *cur if (lodName != "") { // Get the lod by name - INode *lodNode = _Ip->GetINodeByName (lodName.c_str()); + INode *lodNode = _Ip->GetINodeByName (utf8ToTStr(lodName)); if (lodNode) { // Insert it in the set @@ -844,7 +841,7 @@ void CExportNel::addParentLodNode (INode &child, std::set &lodListToExcl if (parent == NULL) parent = _Ip->GetRootNode(); - // Get its child lod + // Get its child lod uint lodCount = getScriptAppData (parent, NEL3D_APPDATA_LOD_NAME_COUNT, 0); for (uint lod=0; lod &lodListToExcl if (lodName != "") { // Get the lod by name - INode *lodNode = _Ip->GetINodeByName (lodName.c_str()); + INode *lodNode = _Ip->GetINodeByName (utf8ToTStr(lodName)); if (lodNode == &child) { // Insert it in the set @@ -897,13 +894,13 @@ void CExportNel::uvMatrix2NelUVMatrix (const Matrix3& maxMatrix, NLMISC::CMatrix dest.identity(); // Set the rotation part - dest.setRot(I, J, K); + dest.setRot(I, J, K); // Set the position part - dest.setPos(P); + dest.setPos(P); // transfo matrix - + CMatrix convert; convert.setRot(CVector::I, -CVector::J, CVector::K); convert.setPos(CVector::J); @@ -946,11 +943,11 @@ std::string CExportNel::getAnimatedLight (INode *node) { std::string ret = CExportNel::getScriptAppData (node, NEL3D_APPDATA_LM_ANIMATED_LIGHT, NEL3D_APPDATA_LM_ANIMATED_LIGHT_DEFAULT); if (ret == "Sun") - ret = ""; + ret.clear(); if (ret == "GlobalLight") - ret = ""; + ret.clear(); if (ret == "(Use NelLight Modifier)") - ret = ""; + ret.clear(); return ret; } @@ -970,7 +967,7 @@ struct CMaxMeshSeg uint V0, V1; // for map insertion bool operator<(const CMaxMeshSeg &other) const - { + { uint lv0 = std::min(V0, V1); uint lv1 = std::max(V0, V1); @@ -986,8 +983,8 @@ struct CMaxMeshSeg return !(*this < other) && !(other < *this); } CMaxMeshSeg(uint v0, uint v1) : V0(v0), - V1(v1) - { + V1(v1) + { } }; @@ -996,7 +993,7 @@ struct CPredNextSegOf { uint Prev; CPredNextSegOf(uint prev) : Prev(prev) {} - bool operator()(const CMaxMeshSeg &value) const { return value.V0 == Prev || value.V1 == Prev; } + bool operator()(const CMaxMeshSeg &value) const { return value.V0 == Prev || value.V1 == Prev; } }; /// Get normal of a max triangle in nel format @@ -1012,7 +1009,7 @@ static NLMISC::CVector getMaxFaceNormal(const Mesh &m, const NLMISC::CMatrix &ba normal.normalize(); return normal; } - + @@ -1020,11 +1017,11 @@ static NLMISC::CVector getMaxFaceNormal(const Mesh &m, const NLMISC::CMatrix &ba // This convert a polygon expressed as a max mesh into a list of ordered vectors void CExportNel::maxPolygonMeshToOrderedPoly(Mesh &mesh, std::vector &dest, const NLMISC::CMatrix &basis, NLMISC::CVector &avgNormal) { - /// We use a very simple (but slow) algo : examine for each segment how many tris share it. If it is one then it is a border seg + /// We use a very simple (but slow) algo : examine for each segment how many tris share it. If it is one then it is a border seg /// Then, just order segments - - typedef std::map TSegMap; - + + typedef std::map TSegMap; + avgNormal.set(0, 0, 0); ///////////////////////////////////////////////////////////// @@ -1059,15 +1056,15 @@ void CExportNel::maxPolygonMeshToOrderedPoly(Mesh &mesh, std::vector TSegList; - TSegList borderSegs; + typedef std::list TSegList; + TSegList borderSegs; for(TSegMap::const_iterator it = segs.begin(); it != segs.end(); ++it) { if (it->second == 1) borderSegs.push_back(it->first); } - + dest.clear(); if (borderSegs.empty()) return; @@ -1084,9 +1081,9 @@ void CExportNel::maxPolygonMeshToOrderedPoly(Mesh &mesh, std::vectorV0 == nextToFind ? nextSeg->V0 : nextSeg->V1]); - dest.push_back(basis * pos); + dest.push_back(basis * pos); nextToFind = (nextSeg->V0 == nextToFind) ? nextSeg->V1 : nextSeg->V0; borderSegs.erase(nextSeg); } @@ -1099,28 +1096,39 @@ void CExportNel::maxPolygonMeshToOrderedPoly(Mesh &mesh, std::vector(ss.getShapePointer())) { - mprintf("Error : Object shape %s isn't a particle system", shapeName.c_str()); + mprintf(_T("Error : Object shape %s isn't a particle system"), utf8ToTStr(shapeName)); return NULL; } @@ -78,7 +78,7 @@ IShape* CExportNel::buildParticleSystem(INode& node, TimeValue time) } else { - mprintf("Error : Can't find %s while exporting a particle system \n", shapeName.c_str()); + mprintf(_T("Error : Can't find %s while exporting a particle system \n"), utf8ToTStr(shapeName)); return NULL; } } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_radial_normal.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_radial_normal.cpp index 541c0c152..80f57bfb4 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_radial_normal.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_radial_normal.cpp @@ -56,13 +56,13 @@ void CRadialVertices::init (INode *node, Mesh *mesh, TimeValue time, Interface & string pivotName = CExportNel::getScriptAppData (_NodePtr, NEL3D_APPDATA_RADIAL_NORMAL_SM+app-NEL3D_RADIAL_FIRST_SM, ""); // Active ? - if (pivotName != "") + if (!pivotName.empty()) { // Add the mask _SmoothingGroupMask |= (1< srs(new CSegRemanenceShape); + CUniquePtr srs(new CSegRemanenceShape); uint numSlices = getScriptAppData (&node, NEL3D_APPDATA_REMANENCE_SLICE_NUMBER, 2); float samplingPeriod = getScriptAppData (&node, NEL3D_APPDATA_REMANENCE_SAMPLING_PERIOD, 0.02f); float rollupRatio = getScriptAppData (&node, NEL3D_APPDATA_REMANENCE_ROLLUP_RATIO, 1.f); diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_scene.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_scene.cpp index 820f03b06..cd8fcb5b7 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_scene.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_scene.cpp @@ -93,7 +93,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v resultInstanceNode[nNumIG] = pNode; if (aIGArray[nNumIG].InstanceName == "") // no instance name was set, takes the node name instead { - aIGArray[nNumIG].InstanceName = pNode->GetName(); + aIGArray[nNumIG].InstanceName = tStrToUtf8(pNode->GetName()); } // Visible? always true, but if special flag for camera collision @@ -236,10 +236,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v pMB->Vertices[pMB->Faces[j].Corner[2].Vertex]) ) { // ERROR : The volume is not convex !!! - char tam[256]; - sprintf(tam,"ERROR: The cluster %s is not convex.",vectNode[i]->GetName()); - //MessageBox(NULL,tam,"Error",MB_OK|MB_ICONERROR); - nlwarning(tam); + nlwarning("ERROR: The cluster %s is not convex.", tStrToUtf8(vectNode[i]->GetName()).c_str()); } } @@ -247,7 +244,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v clusterTemp.VisibleFromFather = bVisibleFromFather; clusterTemp.FatherAudible = bFatherAudible; clusterTemp.AudibleFromFather = bAudibleFromFather; - clusterTemp.Name = pNode->GetName(); + clusterTemp.Name = tStrToUtf8(pNode->GetName()); vClusters.push_back (clusterTemp); delete pMB; pMB = NULL; @@ -336,10 +333,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (!portalTemp.setPoly (polyv)) { // ERROR : Poly not convex, or set of vertices not plane - char tam[256]; - sprintf(tam,"ERROR: The portal %s is not convex.",vectNode[i]->GetName()); - //MessageBox(NULL,tam,"Error",MB_OK|MB_ICONERROR); - nlwarning(tam); + nlwarning("ERROR: The portal %s is not convex.", tStrToUtf8(vectNode[i]->GetName()).c_str()); } if (nAccelType&16) // is dynamic portal ? @@ -348,7 +342,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (!InstanceName.empty()) portalTemp.setName (InstanceName); else - portalTemp.setName (string(pNode->GetName())); + portalTemp.setName (tStrToUtf8(pNode->GetName())); } // Check if portal has 2 cluster @@ -368,10 +362,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (nNbCluster != 2) { // ERROR - char tam[256]; - sprintf(tam,"ERROR: The portal %s has not 2 clusters but %d",vectNode[i]->GetName(), nNbCluster); - //MessageBox(NULL,tam,"Error",MB_OK|MB_ICONERROR); - nlwarning(tam); + nlwarning("ERROR: The portal %s has not 2 clusters but %d", tStrToUtf8(vectNode[i]->GetName()).c_str(), nNbCluster); } @@ -467,7 +458,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v delete ss.getShapePointer(); ss.setShapePointer(NULL); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { nlwarning(e.what()); } @@ -510,13 +501,10 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v } // debug purpose : to remove - if (vClusters.size() > 0) - if (aIGArray[nNumIG].Clusters.size() == 0) + if (!vClusters.empty()) + if (aIGArray[nNumIG].Clusters.empty()) { - char tam[256]; - sprintf(tam,"ERROR: Object %s is not attached to any cluster\nbut his flag clusterize is set", pNode->GetName()); - //MessageBox(NULL, tam, "Warning", MB_OK); - nlwarning(tam); + nlwarning("ERROR: Object %s is not attached to any cluster\nbut his flag clusterize is set", tStrToUtf8(pNode->GetName()).c_str()); } // debug purpose : to remove @@ -712,10 +700,10 @@ void CExportNel::buildScene (NL3D::CScene &scene, NL3D::CShapeBank &shapeBank, I if ( (!pNode->IsHidden () || buildHidden) && (pNode->Selected () || !onlySelected) ) { string sTmp = "Object Name: "; - sTmp += pNode->GetName(); + sTmp += tStrToUtf8(pNode->GetName()); if (progress) progress->setLine (0, sTmp); - sTmp = ""; + sTmp.clear(); for (uint32 i = 1; i < 10; ++i) { if (progress) diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp index a0971d587..cf99e2c0c 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp @@ -36,11 +36,19 @@ bool CExportNel::scriptEvaluate (const char *script, void *out, TNelScriptValueT four_typed_value_locals(Parser* parser,Value* code,Value* result,StringStream* source); vl.parser = new Parser; - vl.source = new StringStream (const_cast(script)); + vl.source = new StringStream (utf8ToTStr(script)); vl.source->log_to(NULL); + +#if MAX_VERSION_MAJOR < 19 save_current_frames(); +#endif + try { +#if MAX_VERSION_MAJOR >= 19 + ScopedSaveCurrentFrames currentFrames; +#endif + vl.source->flush_whitespace(); vl.code = vl.parser->compile_all(vl.source); vl.result = vl.code->eval(); @@ -66,11 +74,16 @@ bool CExportNel::scriptEvaluate (const char *script, void *out, TNelScriptValueT } catch (...) { +#if MAX_VERSION_MAJOR < 19 restore_current_frames(); +#endif result=FALSE; vl.source->close(); } + +#if MAX_VERSION_MAJOR < 19 pop_value_locals(); +#endif return (result!=FALSE); } @@ -125,7 +138,7 @@ float CExportNel::getScriptAppData (Animatable *node, uint32 id, float def) // String to int float value = 0.f; - if (toFloatMax((const char*)ap->data, value)) + if (toFloatMax((const TCHAR*)ap->data, value)) return value; else return def; diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp index 3708a0906..d5030ee9d 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp @@ -114,7 +114,7 @@ INode *CExportNel::getNELScaleReferenceNode(INode &node) { std::string boneScaleName= getName(node) + boneScaleNameExt; // Get the reference node - referenceNode= _Ip->GetINodeByName(boneScaleName.c_str()); + referenceNode= _Ip->GetINodeByName(utf8ToTStr(boneScaleName)); } } @@ -455,7 +455,7 @@ uint CExportNel::buildSkinning (CMesh::CMeshBuild& buildMesh, const TInodePtrInt nlassert ((uint)ite->secondsecond] = ite->first->GetName(); + buildMesh.BonesNames[ite->second] = tStrToUtf8(ite->first->GetName()); // Next ite++; @@ -724,7 +724,7 @@ uint CExportNel::buildSkinning (CMesh::CMeshBuild& buildMesh, const TInodePtrInt nlassert (node); // Insert in the map - weightMap.insert (std::map::value_type (1, node)); + weightMap.insert (std::map::value_type (1.f, node)); } } @@ -1171,8 +1171,8 @@ void CExportNel::addSkeletonBindPos (INode& skinedNode, mapBoneBindPos& boneBind if (res != MATRIX_RETURNED) { - nlwarning("res != MATRIX_RETURNED; res = %i; boneIndex = %i / %i", res, boneIndex, count); - nlwarning("bone = %i", (uint32)(void *)bone); + nlwarning("res != MATRIX_RETURNED; res = %d; boneIndex = %u / %u", res, boneIndex, count); + nlwarning("bone = %p", bone); std::string boneName = getName (*bone); nlwarning("boneName = %s", boneName.c_str()); nlassert(false); @@ -1306,7 +1306,7 @@ static sint getBoneSide(INode *bone, std::string &mirrorName) { sint side= 0; sint pos; - mirrorName= bone->GetName(); + mirrorName = tStrToUtf8(bone->GetName()); if((pos= mirrorName.find(" R "))!=std::string::npos) { @@ -1335,7 +1335,7 @@ static INode *getMirrorBone(const std::vector &skeletonNodes, INode *bon // find for(uint i=0;iGetName()) + if(mirrorName == tStrToUtf8(skeletonNodes[i]->GetName())) return skeletonNodes[i]; } } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/CMakeLists.txt b/code/nel/tools/3d/plugin_max/nel_patch_converter/CMakeLists.txt index c173232b3..178e70f5d 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/CMakeLists.txt +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/CMakeLists.txt @@ -18,4 +18,6 @@ NL_DEFAULT_PROPS(nel_patch_converter "MAX Plugin: NeL Patch Converter") NL_ADD_RUNTIME_FLAGS(nel_patch_converter) NL_ADD_LIB_SUFFIX(nel_patch_converter) +ADD_DEFINITIONS(${MAXSDK_DEFINITIONS}) + INSTALL(TARGETS nel_patch_converter RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/PO2RPO.h b/code/nel/tools/3d/plugin_max/nel_patch_converter/PO2RPO.h index d91777070..77c2c03ca 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/PO2RPO.h +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/PO2RPO.h @@ -50,7 +50,7 @@ class PO2RPO : public Modifier { HWND hRollup; // From Animatable - TCHAR *GetObjectName() { return GetString(IDS_CLASS_NAME); } + const MCHAR *GetObjectName() { return GetString(IDS_CLASS_NAME); } //From Modifier //TODO: Add the channels that the modifier needs to perform its modification @@ -87,8 +87,7 @@ class PO2RPO : public Modifier { void GetClassName(TSTR& s) {s = GetString(IDS_CLASS_NAME);} RefTargetHandle Clone( RemapDir &remap ); - RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, - PartID& partID, RefMessage message); + RefResult NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate); int NumSubs() { return 0; } TSTR SubAnimName(int i) { return GetString(IDS_PARAMS); } @@ -115,11 +114,11 @@ class PO2RPOClassDesc:public ClassDesc2 { return new PO2RPO(); } - const TCHAR * ClassName() {return "NeL Convert";} + const MCHAR * ClassName() {return _M("NeL Convert");} SClass_ID SuperClassID() {return OSM_CLASS_ID;} Class_ID ClassID() {return PO2RPO_CLASS_ID;} - const TCHAR* Category() {return "NeL Tools";} - const TCHAR* InternalName() { return _T("PatchObjectToNelPatchObject"); } // returns fixed parsable name (scripter-visible name) + const MCHAR* Category() {return _M("NeL Tools");} + const MCHAR* InternalName() { return _M("PatchObjectToNelPatchObject"); } // returns fixed parsable name (scripter-visible name) HINSTANCE HInstance() { return hInstance; } // returns owning module handle }; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/nel_patch_converter.cpp b/code/nel/tools/3d/plugin_max/nel_patch_converter/nel_patch_converter.cpp index 3bf145d6f..ee75bc152 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/nel_patch_converter.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/nel_patch_converter.cpp @@ -35,17 +35,17 @@ enum { po2rpo_params }; //TODO: Add enums for various parameters enum { pb_spin,}; -static ParamBlockDesc2 po2rpo_param_blk ( po2rpo_params, _T("params"), 0, &PO2RPODesc, - P_AUTO_CONSTRUCT + P_AUTO_UI, PBLOCK_REF, +static ParamBlockDesc2 po2rpo_param_blk ( po2rpo_params, _T("params"), 0, &PO2RPODesc, + P_AUTO_CONSTRUCT + P_AUTO_UI, PBLOCK_REF, //rollout IDD_PANEL, IDS_PARAMS, 0, 0, NULL, // params - pb_spin, _T("spin"), TYPE_FLOAT, P_ANIMATABLE, IDS_SPIN, - p_default, 0.1f, - p_range, 0.0f,1000.0f, - p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_EDIT, IDC_SPIN, 0.01f, - end, - end + pb_spin, _T("spin"), TYPE_FLOAT, P_ANIMATABLE, IDS_SPIN, + p_default, 0.1f, + p_range, 0.0f,1000.0f, + p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_EDIT, IDC_SPIN, 0.01f, + p_end, + p_end ); IObjParam *PO2RPO::ip = NULL; @@ -67,11 +67,11 @@ PO2RPO::~PO2RPO() Interval PO2RPO::LocalValidity(TimeValue t) { - // if being edited, return NEVER forces a cache to be built + // if being edited, return NEVER forces a cache to be built // after previous modifier. if (TestAFlag(A_MOD_BEING_EDITED)) { - return NEVER; + return NEVER; } //TODO: Return the validity interval of the modifier return NEVER; @@ -81,7 +81,7 @@ Interval PO2RPO::LocalValidity(TimeValue t) RefTargetHandle PO2RPO::Clone(RemapDir& remap) { - PO2RPO* newmod = new PO2RPO(); + PO2RPO* newmod = new PO2RPO(); //TODO: Add the cloning code here newmod->ReplaceReference(0,pblock->Clone(remap)); return(newmod); @@ -90,7 +90,7 @@ RefTargetHandle PO2RPO::Clone(RemapDir& remap) // ----------------------------------------------------------------------------------------------------------------------------------------------------------- static int done=0; -void PO2RPO::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *node) +void PO2RPO::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *node) { /* if (!done) @@ -121,19 +121,19 @@ void PO2RPO::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode * // ----------------------------------------------------------------------------------------------------------------------------------------------------------- extern HINSTANCE hInstance; -INT_PTR CALLBACK DlgProc_Panel(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DlgProc_Panel(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) + switch (message) { // ----- - case WM_INITDIALOG: + case WM_INITDIALOG: { // Get the module path HMODULE hModule = hInstance; if (hModule) { // Get module file name - char moduldeFileName[512]; + TCHAR moduldeFileName[512]; if (GetModuleFileName (hModule, moduldeFileName, 512)) { // Get version info size @@ -141,49 +141,49 @@ INT_PTR CALLBACK DlgProc_Panel(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP uint versionInfoSize=GetFileVersionInfoSize (moduldeFileName, &doomy); if (versionInfoSize) { - // Alloc the buffer - char *buffer=new char[versionInfoSize]; + // Alloc the buffer (size in bytes) + uint8_t *buffer = new uint8_t[versionInfoSize]; // Find the verion resource if (GetFileVersionInfo(moduldeFileName, 0, versionInfoSize, buffer)) { uint *versionTab; uint versionSize; - if (VerQueryValue (buffer, "\\", (void**)&versionTab, &versionSize)) + if (VerQueryValue (buffer, _T("\\"), (void**)&versionTab, &versionSize)) { // Get the pointer on the structure VS_FIXEDFILEINFO *info=(VS_FIXEDFILEINFO*)versionTab; if (info) { // Setup version number - char version[512]; - sprintf (version, "Version %d.%d.%d.%d", - info->dwFileVersionMS>>16, - info->dwFileVersionMS&0xffff, - info->dwFileVersionLS>>16, + TCHAR version[512]; + _stprintf (version, _T("Version %d.%d.%d.%d"), + info->dwFileVersionMS>>16, + info->dwFileVersionMS&0xffff, + info->dwFileVersionLS>>16, info->dwFileVersionLS&0xffff); SetWindowText (GetDlgItem (hWnd, IDC_VERSION), version); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "VS_FIXEDFILEINFO * is NULL"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("VS_FIXEDFILEINFO * is NULL")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "VerQueryValue failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("VerQueryValue failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetFileVersionInfo failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetFileVersionInfo failed")); // Free the buffer delete [] buffer; } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetFileVersionInfoSize failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetFileVersionInfoSize failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetModuleFileName failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetModuleFileName failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "hInstance NULL"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("hInstance NULL")); } // ----- @@ -214,14 +214,14 @@ void PO2RPO::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev ) void PO2RPO::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next) { //PO2RPODesc.EndEditParams(ip, this, flags, next); - ip->DeleteRollupPage(hRollup); + ip->DeleteRollupPage(hRollup); this->ip = NULL; } // ----------------------------------------------------------------------------------------------------------------------------------------------------------- -//From ReferenceMaker -RefResult PO2RPO::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget,PartID& partID, RefMessage message) +//From ReferenceMaker +RefResult PO2RPO::NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate) { //TODO: Add code to handle the various reference changed messages return REF_SUCCEED; @@ -230,21 +230,21 @@ RefResult PO2RPO::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget,P // ----------------------------------------------------------------------------------------------------------------------------------------------------------- //From Object -BOOL PO2RPO::HasUVW() -{ +BOOL PO2RPO::HasUVW() +{ //TODO: Return whether the object has UVW coordinates or not - return TRUE; + return TRUE; } // ----------------------------------------------------------------------------------------------------------------------------------------------------------- -void PO2RPO::SetGenUVW(BOOL sw) -{ - if (sw==HasUVW()) +void PO2RPO::SetGenUVW(BOOL sw) +{ + if (sw==HasUVW()) { return; } - //TODO: Set the plugin internal value to sw + //TODO: Set the plugin internal value to sw } // ----------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/rykolscript.txt b/code/nel/tools/3d/plugin_max/nel_patch_converter/rykolscript.txt index 1a73ba02f..526870762 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/rykolscript.txt +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/rykolscript.txt @@ -261,6 +261,6 @@ If file0 doesn't exist the function return true If date (file0) <= date (file1) the function return true If date (file0) > date (file1) the function return false If file1 doesn't exist the function return undefined -If an error occured, the function return undefined +If an error occurred, the function return undefined ********************************************** diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp b/code/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp index 80e715f21..7ce6c3068 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp @@ -157,7 +157,7 @@ def_visible_primitive( set_vertex_pos, "SetRykolVertexPos"); def_visible_primitive( get_vector_pos, "GetRykolVectorPos"); def_visible_primitive( set_vector_pos, "SetRykolVectorPos");*/ -void errorMessage (const char *msg, const char *title, Interface& it, bool dialog) +void errorMessage (const MCHAR *msg, const TCHAR *title, Interface& it, bool dialog) { // Text or dialog ? if (dialog) @@ -168,7 +168,8 @@ void errorMessage (const char *msg, const char *title, Interface& it, bool dialo else { // Text message - mprintf ((string(msg) + "\n").c_str()); + mprintf(msg); + mprintf(_M("\n")); } } @@ -180,7 +181,7 @@ export_zone_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "ExportRykolZone [Object]"); + type_check(arg_list[0], MAXNode, _M("ExportRykolZone [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -215,7 +216,7 @@ export_zone_cf (Value** arg_list, int count) if (tri->rpatch->exportZone (node, &tri->patch, zone, zoneSymmetry, nZone, 160, 1, false)) { // Export path - const char* sPath=arg_list[1]->to_string(); + const std::string sPath = tStrToUtf8(arg_list[1]->to_string()); COFile file; if (file.open (sPath)) @@ -237,7 +238,7 @@ Value* import_zone_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - char *help = "NeLImportZone filename dialogError"; + MCHAR *help = _M("NeLImportZone filename dialogError"); type_check (arg_list[0], String, help); type_check (arg_list[1], Boolean, help); @@ -245,7 +246,7 @@ Value* import_zone_cf (Value** arg_list, int count) Interface *ip = MAXScript_interface; // Get the filename - string filename = arg_list[0]->to_string(); + string filename = tStrToUtf8(arg_list[0]->to_string()); // Get the flip bool dialog = arg_list[1]->to_bool ()!=FALSE; @@ -284,16 +285,18 @@ Value* import_zone_cf (Value** arg_list, int count) // Redraw the viewports ip->RedrawViews(ip->GetTime()); } - catch (Exception& e) + catch (const Exception& e) { // Error message - errorMessage (("Error when loading file "+filename+": "+e.what()).c_str(), "NeL import zone", *ip, dialog); + std::string msg = toString("Error when loading file %s: %s", filename.c_str(), e.what()); + errorMessage (utf8ToTStr(msg), _T("NeL import zone"), *ip, dialog); } } else { // Error message - errorMessage (("Can't open the file "+filename+" for reading.").c_str(), "NeL import zone", *ip, dialog); + std::string msg = toString("Can't open the file %s for reading.", filename.c_str()); + errorMessage (utf8ToTStr(msg), _T("NeL import zone"), *ip, dialog); } return ret; @@ -307,7 +310,7 @@ get_selected_tile_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolSeltile [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolSeltile [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -354,7 +357,7 @@ get_selected_patch_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolSelPatch [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolSelPatch [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -401,7 +404,7 @@ get_selected_vertex_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolSelVertex [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolSelVertex [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -448,7 +451,7 @@ set_tile_mode_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolTileMode [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolTileMode [Object]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -498,7 +501,7 @@ set_compute_interior_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "RykolComputeInterior [Object]"); + type_check(arg_list[0], MAXNode, _M("RykolComputeInterior [Object]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -546,7 +549,7 @@ set_interior_mode_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolInteriorMode [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolInteriorMode [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -598,7 +601,7 @@ set_vertex_count_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolVertexCount [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolVertexCount [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -638,7 +641,7 @@ set_vector_count_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolVectorCount [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolVectorCount [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -678,7 +681,7 @@ set_vertex_pos_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolVertexPos [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolVertexPos [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -728,7 +731,7 @@ set_vector_pos_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolVectorPos [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolVectorPos [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -778,7 +781,7 @@ get_vertex_pos_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolVertexPos [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolVertexPos [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -822,7 +825,7 @@ get_vector_pos_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolVectorPos [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolVectorPos [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -867,7 +870,7 @@ get_edge_vect1_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolEdgesVect1 [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolEdgesVect1 [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -911,7 +914,7 @@ get_edge_vect2_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolEdgesVect2 [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolEdgesVect2 [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -955,7 +958,7 @@ get_edge_vert1_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolEdgesVert1 [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolEdgesVert1 [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1000,7 +1003,7 @@ get_edge_vert2_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolEdgesVert2 [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolEdgesVert2 [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1044,7 +1047,7 @@ get_sel_edge_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolSelEdges [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolSelEdges [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1092,7 +1095,7 @@ set_steps_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolPatchSteps [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolPatchSteps [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1155,7 +1158,7 @@ set_tile_steps_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykoltileSteps [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykoltileSteps [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1208,7 +1211,7 @@ get_tile_count_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolTileCount [Zone] [PatchNumber]"); + type_check(arg_list[0], MAXNode, _M("GetRykolTileCount [Zone] [PatchNumber]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1265,7 +1268,7 @@ Value* get_patch_vertex_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - char *message="NeLGetPatchVertex [NeLPatchMesh] [PatchId] [VertexId]"; + const MCHAR *message= _M("NeLGetPatchVertex [NeLPatchMesh] [PatchId] [VertexId]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], Integer, message); type_check(arg_list[2], Integer, message); @@ -1336,7 +1339,7 @@ get_patch_count_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolPatchCount [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolPatchCount [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1389,10 +1392,10 @@ get_tile_tile_number_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]"); - type_check(arg_list[1], Integer, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]"); - type_check(arg_list[2], Integer, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]"); - type_check(arg_list[3], Integer, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]"); + type_check(arg_list[0], MAXNode, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]")); + type_check(arg_list[1], Integer, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]")); + type_check(arg_list[2], Integer, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]")); + type_check(arg_list[3], Integer, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -1411,7 +1414,7 @@ get_tile_tile_number_cf(Value** arg_list, int count) uint layer=arg_list[3]->to_int()-1; if (layer>=3) { - mprintf ("Error: layer must be 1, 2, or 3\n"); + mprintf (_M("Error: layer must be 1, 2, or 3\n")); } else { @@ -1427,7 +1430,7 @@ get_tile_tile_number_cf(Value** arg_list, int count) uint nPatch=arg_list[1]->to_int()-1; if (nPatch>=tri->rpatch->getUIPatchSize()) { - mprintf ("Error: patch index is invalid.\n"); + mprintf (_M("Error: patch index is invalid.\n")); } else { @@ -1439,7 +1442,7 @@ get_tile_tile_number_cf(Value** arg_list, int count) uint tile=arg_list[2]->to_int()-1; if (tile>=nPatchCount) { - mprintf ("Error: tile index is invalid.\n"); + mprintf (_M("Error: tile index is invalid.\n")); } else { @@ -1475,9 +1478,9 @@ get_tile_noise_number_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]"); - type_check(arg_list[1], Integer, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]"); - type_check(arg_list[2], Integer, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]"); + type_check(arg_list[0], MAXNode, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]")); + type_check(arg_list[1], Integer, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]")); + type_check(arg_list[2], Integer, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -1504,7 +1507,7 @@ get_tile_noise_number_cf(Value** arg_list, int count) uint nPatch=arg_list[1]->to_int()-1; if (nPatch>=tri->rpatch->getUIPatchSize()) { - mprintf ("Error: patch index is invalid.\n"); + mprintf (_M("Error: patch index is invalid.\n")); } else { @@ -1516,7 +1519,7 @@ get_tile_noise_number_cf(Value** arg_list, int count) uint tile=arg_list[2]->to_int()-1; if (tile>=nPatchCount) { - mprintf ("Error: patch index is invalid.\n"); + mprintf (_M("Error: patch index is invalid.\n")); } else { @@ -1544,10 +1547,10 @@ set_tile_noise_number_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]"); - type_check(arg_list[1], Integer, "NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]"); - type_check(arg_list[2], Integer, "NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]"); - type_check(arg_list[3], Integer, "NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]"); + type_check(arg_list[0], MAXNode, _M("NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]")); + type_check(arg_list[1], Integer, _M("NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]")); + type_check(arg_list[2], Integer, _M("NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]")); + type_check(arg_list[3], Integer, _M("NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -1566,7 +1569,7 @@ set_tile_noise_number_cf(Value** arg_list, int count) uint noise=arg_list[3]->to_int()-1; if (noise>=16) { - mprintf ("Error: noise value must be 1~16\n"); + mprintf (_M("Error: noise value must be 1~16\n")); } else { @@ -1582,7 +1585,7 @@ set_tile_noise_number_cf(Value** arg_list, int count) uint nPatch=arg_list[1]->to_int()-1; if (nPatch>=tri->rpatch->getUIPatchSize()) { - mprintf ("Error: patch index is invalid.\n"); + mprintf (_M("Error: patch index is invalid.\n")); } else { @@ -1594,7 +1597,7 @@ set_tile_noise_number_cf(Value** arg_list, int count) uint tile=arg_list[2]->to_int()-1; if (tile>=nPatchCount) { - mprintf ("Error: patch index is invalid.\n"); + mprintf (_M("Error: patch index is invalid.\n")); } else { @@ -1627,7 +1630,7 @@ load_bank_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' std::string bankName = GetBankPathName (); - if (bankName!="") + if (!bankName.empty()) { try { @@ -1646,13 +1649,13 @@ load_bank_cf(Value** arg_list, int count) } else { - mprintf ("Error: can't open bank file %s\n", bankName.c_str()); + mprintf (_M("Error: can't open bank file %s\n"), bankName.c_str()); } } - catch (Exception& e) + catch (const Exception& e) { // Error message - mprintf ("Error: %s\n", e.what()); + mprintf (_M("Error: %s\n"), e.what()); } } @@ -1668,7 +1671,7 @@ get_tile_set_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], Integer, "NelGetTileSet [tileId]"); + type_check(arg_list[0], Integer, _M("NelGetTileSet [tileId]")); // ok ? int nRet=-1; @@ -1677,7 +1680,7 @@ get_tile_set_cf(Value** arg_list, int count) uint tile=arg_list[0]->to_int()-1; if (tile>=(uint)scriptedBank.getTileCount()) { - mprintf ("Error: tile number is wrong. (1 ~ %d)\n", scriptedBank.getTileCount()); + mprintf (_M("Error: tile number is wrong. (1 ~ %d)\n"), scriptedBank.getTileCount()); } else { @@ -1702,10 +1705,10 @@ Value* set_tile_bank_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], String, "NelSetTileBank [tile bank pathname]"); + type_check(arg_list[0], String, _M("NelSetTileBank [tile bank pathname]")); // ok ? - const char *pathname = arg_list[0]->to_string(); + const std::string pathname = tStrToUtf8(arg_list[0]->to_string()); // Get tile number SetBankPathName (pathname); @@ -1947,8 +1950,8 @@ attach_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "NeLAttachPatchMesh [RykolPatchMeshSrc] [RykolPatchMeshDest]"); - type_check(arg_list[1], MAXNode, "NeLAttachPatchMesh [RykolPatchMeshSrc] [RykolPatchMeshDest]"); + type_check(arg_list[0], MAXNode, _M("NeLAttachPatchMesh [RykolPatchMeshSrc] [RykolPatchMeshDest]")); + type_check(arg_list[1], MAXNode, _M("NeLAttachPatchMesh [RykolPatchMeshSrc] [RykolPatchMeshDest]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -2005,8 +2008,8 @@ weld_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "NeLWeldPatchMesh [RykolPatchMeshSrc] [threshold]"); - type_check(arg_list[1], Float, "NeLWeldPatchMesh [RykolPatchMeshSrc] [threshold]"); + type_check(arg_list[0], MAXNode, _M("NeLWeldPatchMesh [RykolPatchMeshSrc] [threshold]")); + type_check(arg_list[1], Float, _M("NeLWeldPatchMesh [RykolPatchMeshSrc] [threshold]")); // Get a good interface pointer Interface *ip = MAXScript_interface; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/CMakeLists.txt b/code/nel/tools/3d/plugin_max/nel_patch_edit/CMakeLists.txt index 82cc06611..bc2f81f33 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/CMakeLists.txt +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/CMakeLists.txt @@ -18,8 +18,10 @@ NL_DEFAULT_PROPS(nel_patch_edit "MAX Plugin: NeL Patch Editor") NL_ADD_RUNTIME_FLAGS(nel_patch_edit) NL_ADD_LIB_SUFFIX(nel_patch_edit) +ADD_DEFINITIONS(${MAXSDK_DEFINITIONS}) + IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nel_patch_edit ${CMAKE_CURRENT_SOURCE_DIR}/stdafx.h ${CMAKE_CURRENT_SOURCE_DIR}/stdafx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS nel_patch_edit RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/editpat.h b/code/nel/tools/3d/plugin_max/nel_patch_edit/editpat.h index ec8947571..b6fe7adb1 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/editpat.h +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/editpat.h @@ -574,9 +574,8 @@ class EditPatchMod : public Modifier, IPatchOps, IPatchSelect, ISubMtlAPI, Attac static bool additiveTile; static bool automaticLighting; - RefResult NotifyRefChanged( Interval changeInt,RefTargetHandle hTarget, - PartID& partID, RefMessage message ) { return REF_SUCCEED; } - + RefResult NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate) { return REF_SUCCEED; } + int selLevel; // RB:named sel sets @@ -752,7 +751,7 @@ class EditPatchMod : public Modifier, IPatchOps, IPatchSelect, ISubMtlAPI, Attac void BeginEditParams( IObjParam *ip, ULONG flags, Animatable *prev ); void EndEditParams( IObjParam *ip, ULONG flags, Animatable *next ); RefTargetHandle Clone(RemapDir& remap = DefaultRemapDir()); - TCHAR *GetObjectName() { return GetString(IDS_TH_EDITPATCH); } + const MCHAR *GetObjectName() { return GetString(IDS_TH_EDITPATCH); } void ActivateSubobjSel(int level, XFormModes& modes ); int NeedUseSubselButton() { return 0; } void SelectSubPatch(int index); @@ -929,10 +928,10 @@ class EditPatchClassDesc:public ClassDesc { { return new EditPatchMod; } - const TCHAR * ClassName() { return "NeL Edit"; } + const MCHAR * ClassName() { return _M("NeL Edit"); } SClass_ID SuperClassID() { return OSM_CLASS_ID; } Class_ID ClassID() { return Class_ID(0x4dd14a3c, 0x4ac23c0c); } - const TCHAR* Category() { return "NeL Tools";} + const MCHAR* Category() { return _M("NeL Tools");} void ResetClassParams(BOOL fileReset); }; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np.cpp index 133d0b4d6..2d1fbd707 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np.cpp @@ -589,10 +589,10 @@ void EditPatchMod::UpdateSelectDisplay() for (j = 0; j < thePatch->tileSel.GetSize(); j++) if (thePatch->tileSel[j]) break; - buf.printf("Tile %d Selected", j + 1); + buf.printf(_T("Tile %d Selected"), j + 1); } else - buf.printf("%d Tiles Selected", num); + buf.printf(_T("%d Tiles Selected"), num); } break; } @@ -642,7 +642,7 @@ void EditPatchMod::DoVertWeld() { hadSel = TRUE; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoVertWeld")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoVertWeld"))); // Call the patch weld function if (patch->Weld(weldThreshold)) { @@ -716,7 +716,7 @@ void EditPatchMod::DoVertReset () { hadSel = TRUE; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoVertReset")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoVertReset"))); // Call the patch weld function ResetVert (patch); patchData->UpdateChanges(patch, rpatch); @@ -733,7 +733,7 @@ void EditPatchMod::DoVertReset () } ResolveTopoChanges(); - theHold.Accept("Reset Vertex"); + theHold.Accept(_M("Reset Vertex")); /*if (holdNeeded) { ResolveTopoChanges(); @@ -890,9 +890,9 @@ Value *turn_patch_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "RykolTurnPatch [Node] [Modifier] [Patch]"); - type_check(arg_list[1], MAXModifier, "RykolTurnPatch [Node] [Modifier] [Patch]"); - type_check(arg_list[2], Integer, "RykolTurnPatch [Node] [Modifier] [Patch]"); + type_check(arg_list[0], MAXNode, _M("RykolTurnPatch [Node] [Modifier] [Patch]")); + type_check(arg_list[1], MAXModifier, _M("RykolTurnPatch [Node] [Modifier] [Patch]")); + type_check(arg_list[2], Integer, _M("RykolTurnPatch [Node] [Modifier] [Patch]")); // Get a good interface pointer Interface *ip = MAXScript_interface; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_edit_patch_mod.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_edit_patch_mod.cpp index 55825158b..4306cfd0b 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_edit_patch_mod.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_edit_patch_mod.cpp @@ -338,8 +338,7 @@ static INT_PTR CALLBACK PickSetDlgProc( Tab &names = *((Tab < TSTR*>*)lParam); for (int i = 0; i < names.Count(); i++) { - int pos = SendDlgItemMessage(hWnd, IDC_NS_LIST, LB_ADDSTRING, 0, - (LPARAM)(TCHAR*)*names[i]); + int pos = SendDlgItemMessage(hWnd, IDC_NS_LIST, LB_ADDSTRING, 0, (LPARAM)(TCHAR*)*names[i]->ToMCHAR()); SendDlgItemMessage(hWnd, IDC_NS_LIST, LB_SETITEMDATA, pos, i); } break; @@ -688,7 +687,7 @@ if (!TestAFlag(A_HELD)) patchData->vdelta.SetSize(*patch, FALSE); if (theHold.Holding()) { - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "XFormHandles")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("XFormHandles"))); } patchData->vdelta.Zero(); // Reset all deltas patchData->ClearHandleFlag(); @@ -946,7 +945,7 @@ for (int i = 0; i < mcList.Count(); i++) if (theHold.Holding()) { // Hulud: here, i pass a NULL pointer because rpatch are not modified by xform - theHold.Put(new PatchRestore(patchData, this, patch, NULL, "XFormVerts")); + theHold.Put(new PatchRestore(patchData, this, patch, NULL, _T("XFormVerts"))); } patchData->vdelta.Zero(); // Reset all deltas patchData->ClearHandleFlag(); diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_add_patches.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_add_patches.cpp index 49e2cb005..8ef6fde75 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_add_patches.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_add_patches.cpp @@ -24,7 +24,7 @@ static void AddPatches(int type, PatchMesh *patch, RPatchMesh *rpatch, BOOL post int edges = patch->getNumEdges(); if (type==PATCH_TRI) - MessageBox (NULL, "Rykol tools", "C'est pas cool les tripatches...", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, _T("Rykol tools"), _T("C'est pas cool les tripatches..."), MB_OK|MB_ICONEXCLAMATION); // Add a patch of the desired type to each selected edge that doesn't have two patches atatched! for (int i = 0; i < edges; ++i) @@ -393,7 +393,7 @@ void EditPatchMod::DoPatchAdd(int type) { altered = holdNeeded = 1; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoPatchAdd")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoPatchAdd"))); // Call the patch add function AddPatches(type, patch, rpatch, TRUE); patchData->UpdateChanges(patch, rpatch); diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_attach.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_attach.cpp index d2843df1c..0067a7175 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_attach.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_attach.cpp @@ -284,7 +284,7 @@ int EditPatchMod::DoAttach(INode *node, PatchMesh *attPatch, RPatchMesh *rattPat // Start a restore object... if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoAttach")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoAttach"))); // Do the attach patch->Attach(attPatch, mat2Offset); diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_bevel.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_bevel.cpp index 0021d62f1..c2e81e460 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_bevel.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_bevel.cpp @@ -12,8 +12,12 @@ // ------------------------------------------------------------------------------------------------------------------------------------------------------ int EPM_BevelMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 m) -{ +{ +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hwnd); +#else ViewExp *vpt = ip->GetViewport(hwnd); +#endif Point3 p0, p1; ISpinnerControl *spin; int ln, ln2; @@ -48,11 +52,13 @@ int EPM_BevelMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 m case MOUSE_MOVE: if (point == 1) { - p0 = vpt->MapScreenToView(om, float(-200)); + p0 = vpt->MapScreenToView(om, -200.f); + // sca 1999.02.24: find worldspace point with om's x value and m's y value m2.x = om.x; m2.y = m.y; - p1 = vpt->MapScreenToView(m2, float(-200)); + p1 = vpt->MapScreenToView(m2, -200.f); + amount = Length(p1 - p0); ln = IsDlgButtonChecked(po->hOpsPanel, IDC_EM_EXTYPE_B); if (om.y < m.y) @@ -66,14 +72,16 @@ int EPM_BevelMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 m ReleaseISpinner(spin); } ip->RedrawViews(ip->GetTime(), REDRAW_INTERACTIVE); - } + } else if (point == 2) - { - p0 = vpt->MapScreenToView(om, float(-200)); + { + p0 = vpt->MapScreenToView(om, -200.f); + // sca 1999.02.24: find worldspace point with om's x value and m's y value m2.x = om.x; m2.y = m.y; - p1 = vpt->MapScreenToView(m2, float(-200)); + p1 = vpt->MapScreenToView(m2, -200.f); + if (IsDlgButtonChecked(po->hOpsPanel, IDC_EP_SM_SMOOTH)) ln = 0; else if (IsDlgButtonChecked(po->hOpsPanel, IDC_EP_SM_SMOOTH2)) @@ -114,8 +122,11 @@ int EPM_BevelMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 m break; } +#if MAX_VERSION_MAJOR < 19 if (vpt) ip->ReleaseViewport(vpt); +#endif + return TRUE; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_del.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_del.cpp index f196105ed..f2597fc58 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_del.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_del.cpp @@ -110,7 +110,7 @@ void EditPatchMod::DoPatchDelete() { altered = holdNeeded = 1; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoPatchDelete")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoPatchDelete"))); // Call the patch delete function DeleteSelPatches(patch, rpatch); patchData->UpdateChanges(patch, rpatch); @@ -211,7 +211,7 @@ void EditPatchMod::DoVertDelete() { altered = holdNeeded = 1; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoVertDelete")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoVertDelete"))); // Call the vertex delete function DeleteSelVerts(patch, rpatch); patchData->UpdateChanges(patch, rpatch); @@ -279,7 +279,7 @@ void EditPatchMod::DoEdgeDelete() { altered = holdNeeded = 1; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoEdgeDelete")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoEdgeDelete"))); int edges = patch->getNumEdges(); int patches = patch->getNumPatches(); int verts = patch->getNumVerts(); diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_detach.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_detach.cpp index eaf0c7369..370027a46 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_detach.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_detach.cpp @@ -133,7 +133,7 @@ void EditPatchMod::DoPatchDetach(int copy, int reorient) // Save the unmodified info. if (theHold.Holding()) { - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoPatchDetach")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoPatchDetach"))); } PatchMesh wpatch = *patch; RPatchMesh wrpatch = *rpatch; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_extrude.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_extrude.cpp index c4c502de9..35d9986de 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_extrude.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_extrude.cpp @@ -13,7 +13,11 @@ int EPM_ExtrudeMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 m) { +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hwnd); +#else ViewExp *vpt = ip->GetViewport(hwnd); +#endif Point3 p0, p1; ISpinnerControl *spin; BOOL ln; @@ -39,11 +43,13 @@ int EPM_ExtrudeMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 break; case MOUSE_MOVE: - p0 = vpt->MapScreenToView(om, float(-200)); + p0 = vpt->MapScreenToView(om, -200.f); + // sca 1999.02.24: Find m's projection in om's vertical axis: m2.x = om.x; m2.y = m.y; - p1 = vpt->MapScreenToView(m2, float(-200)); + p1 = vpt->MapScreenToView(m2, -200.f); + amount = Length(p1 - p0); if (m.y > om.y) amount *= -1.0f; @@ -66,8 +72,11 @@ int EPM_ExtrudeMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 break; } +#if MAX_VERSION_MAJOR < 19 if (vpt) ip->ReleaseViewport(vpt); +#endif + return TRUE; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_material.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_material.cpp index 6adcde3cd..bc36eae43 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_material.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_material.cpp @@ -89,7 +89,7 @@ void EditPatchMod::SetSelMatIndex(int index) // Start a restore object... if (theHold.Holding()) { - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "SetSelMatIndex")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("SetSelMatIndex"))); } for (int j = 0; j < patch->getNumPatches(); j++) @@ -254,7 +254,7 @@ void EditPatchMod::SetSelTess(int nU, int nV) // Start a restore object... if (theHold.Holding()) { - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "SetSelTess")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("SetSelTess"))); } for (int j = 0; j < patch->getNumPatches(); j++) @@ -276,7 +276,7 @@ void EditPatchMod::SetSelTess(int nU, int nV) } if (holdNeeded) - theHold.Accept("Tile count in U and V change"); + theHold.Accept(_M("Tile count in U and V change")); else { ip->DisplayTempPrompt(GetString(IDS_TH_NOPATCHESSEL), PROMPT_TIME); @@ -391,7 +391,7 @@ void EditPatchMod::setSmoothFlags (bool smooth) // Start a restore object... if (theHold.Holding()) { - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "SetSmoothFlags")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("SetSmoothFlags"))); } // For each edges @@ -453,7 +453,7 @@ void EditPatchMod::setSmoothFlags (bool smooth) } if (holdNeeded) - theHold.Accept("Tile count in U and V change"); + theHold.Accept(_M("Tile count in U and V change")); else { ip->DisplayTempPrompt(GetString(IDS_TH_NOPATCHESSEL), PROMPT_TIME); @@ -539,7 +539,7 @@ void EditPatchMod::BalanceSelPatch () // Start a restore object... if (theHold.Holding()) { - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "SetSelTess")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("SetSelTess"))); } std::set visitedU; @@ -589,7 +589,7 @@ void EditPatchMod::BalanceSelPatch () } if (holdNeeded) - theHold.Accept("Balance tile"); + theHold.Accept(_M("Balance tile")); else { ip->DisplayTempPrompt(GetString(IDS_TH_NOPATCHESSEL), PROMPT_TIME); diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_remember.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_remember.cpp index 3ab9a629b..161187e35 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_remember.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_remember.cpp @@ -35,8 +35,13 @@ int EditPatchMod::RememberPatchThere(HWND hWnd, IPoint2 m) ClearPatchDataFlag(mcList, EPD_BEENDONE); // See if we're over a patch +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hWnd); +#else ViewExp *vpt = ip->GetViewport(hWnd); +#endif GraphicsWindow *gw = vpt->getGW(); + HitRegion hr; MakeHitRegion(hr, HITTYPE_POINT, 1, 4, &m); gw->setHitRegion(&hr); @@ -110,8 +115,12 @@ int EditPatchMod::RememberPatchThere(HWND hWnd, IPoint2 m) finish: nodes.DisposeTemporary(); ClearPatchDataFlag(mcList, EPD_BEENDONE); + +#if MAX_VERSION_MAJOR < 19 if (vpt) ip->ReleaseViewport(vpt); +#endif + return result; } @@ -149,7 +158,7 @@ void EditPatchMod::ChangeRememberedPatch(int type) theHold.Begin(); if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "ChangeRememberedPatch")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("ChangeRememberedPatch"))); // Call the patch type change function ChangePatchType(patch, rememberedIndex, type); patchData->UpdateChanges(patch, rpatch, FALSE); @@ -185,8 +194,13 @@ int EditPatchMod::RememberVertThere(HWND hWnd, IPoint2 m) ClearPatchDataFlag(mcList, EPD_BEENDONE); // See if we're over a vertex +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hWnd); +#else ViewExp *vpt = ip->GetViewport(hWnd); +#endif GraphicsWindow *gw = vpt->getGW(); + HitRegion hr; MakeHitRegion(hr, HITTYPE_POINT, 1, 4, &m); gw->setHitRegion(&hr); @@ -260,8 +274,11 @@ int EditPatchMod::RememberVertThere(HWND hWnd, IPoint2 m) finish: nodes.DisposeTemporary(); ClearPatchDataFlag(mcList, EPD_BEENDONE); + +#if MAX_VERSION_MAJOR < 19 if (vpt) ip->ReleaseViewport(vpt); +#endif return result; } @@ -299,7 +316,7 @@ void EditPatchMod::ChangeRememberedVert(int type) theHold.Begin(); if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "ChangeRememberedVert")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("ChangeRememberedVert"))); // Call the vertex type change function patch->ChangeVertType(rememberedIndex, type); patchData->UpdateChanges(patch, rpatch, FALSE); diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_selection.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_selection.cpp index 0b15b63e7..03409c374 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_selection.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_selection.cpp @@ -71,18 +71,15 @@ void EditPatchMod::RefreshSelType() */ if (selLevel == EP_PATCH) { - hSurfPanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_SURF), - PatchSurfDlgProc, GetString(IDS_TH_SURFACEPROPERTIES), (LPARAM) this, rsSurf ? 0 : APPENDROLL_CLOSED); + hSurfPanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_SURF), PatchSurfDlgProc, GetString(IDS_TH_SURFACEPROPERTIES), (LPARAM) this, rsSurf ? 0 : APPENDROLL_CLOSED); } if (selLevel == EP_TILE) { - hTilePanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_TILE), - PatchTileDlgProc, "Tile Properties", (LPARAM) this, rsTile ? 0 : APPENDROLL_CLOSED); + hTilePanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_TILE), PatchTileDlgProc, _M("Tile Properties"), (LPARAM) this, rsTile ? 0 : APPENDROLL_CLOSED); } if (selLevel == EP_EDGE) { - hEdgePanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_EDGE), - PatchEdgeDlgProc, "Edge Properties", (LPARAM) this, rsEdge ? 0 : APPENDROLL_CLOSED); + hEdgePanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_EDGE), PatchEdgeDlgProc, _M("Edge Properties"), (LPARAM) this, rsEdge ? 0 : APPENDROLL_CLOSED); } SetSurfDlgEnables(); SetTileDlgEnables(); @@ -262,7 +259,7 @@ void EditPatchMod::SelectSubPatch(int index) patchData->BeginEdit(t); if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "SelectSubComponent")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("SelectSubComponent"))); patch->patchSel.Set(index); @@ -311,7 +308,7 @@ void EditPatchMod::SelectSubPatch(int index) patchData->BeginEdit(t); if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "SelectSubComponent")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("SelectSubComponent"))); switch (selLevel) { @@ -636,7 +633,7 @@ void EditPatchMod::ClearSelection(int selLevel) patchData->BeginEdit(ip->GetTime()); if (theHold.Holding()) { - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "ClearSelection")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("ClearSelection"))); } switch (selLevel) @@ -744,7 +741,7 @@ void EditPatchMod::SelectAll(int selLevel) patchData->BeginEdit(ip->GetTime()); if (theHold.Holding()) { - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "SelectAll")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("SelectAll"))); } switch (selLevel) @@ -813,7 +810,7 @@ void EditPatchMod::InvertSelection(int selLevel) patchData->BeginEdit(ip->GetTime()); if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "InvertSelection")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("InvertSelection"))); switch (selLevel) { @@ -1004,7 +1001,7 @@ void EditPatchMod::ChangeSelPatches(int type) { altered = holdNeeded = TRUE; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "ChangeSelPatches")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("ChangeSelPatches"))); // Call the vertex type change function ChangePatchType(patch, -1, type); patchData->UpdateChanges(patch, rpatch, FALSE); @@ -1077,7 +1074,7 @@ void EditPatchMod::ChangeSelVerts(int type) { altered = holdNeeded = TRUE; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "ChangeSelVerts")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("ChangeSelVerts"))); // Call the vertex type change function patch->ChangeVertType(-1, type); patchData->UpdateChanges(patch, rpatch, FALSE); diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_subdivide.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_subdivide.cpp index b67153e07..644b508a8 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_subdivide.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_subdivide.cpp @@ -1237,7 +1237,7 @@ void EditPatchMod::DoEdgeSubdivide() { altered = holdNeeded = 1; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoEdgeSubdivide")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoEdgeSubdivide"))); // Call the patch add function SubdividePatch(SUBDIV_EDGES, propagate, patch, rpatch); patchData->UpdateChanges(patch, rpatch); @@ -1304,7 +1304,7 @@ void EditPatchMod::DoPatchSubdivide() { altered = holdNeeded = 1; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoPatchSubdivide")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoPatchSubdivide"))); // Call the patch add function SubdividePatch(SUBDIV_PATCHES, propagate, patch, rpatch); patchData->UpdateChanges(patch, rpatch); @@ -1441,7 +1441,7 @@ void EditPatchMod::DoPatchTurn(bool ccw) { altered = holdNeeded = 1; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoTurnPatch")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoTurnPatch"))); // Call the patch add function TurnPatch (patch, rpatch, ccw); diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_surface.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_surface.cpp index 4f72420b1..e5f2220ba 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_surface.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_surface.cpp @@ -33,13 +33,13 @@ INT_PTR CALLBACK SelectByMatDlgProc( case WM_COMMAND: switch (LOWORD(wParam)) { - case IDOK: + case IDOK: { ISpinnerControl *spin = GetISpinner(GetDlgItem(hWnd, IDC_MAT_IDSPIN)); param[0] = spin->GetIVal(); param[1] = IsDlgButtonChecked(hWnd, IDC_CLEARSELECTION); ReleaseISpinner(spin); - EndDialog(hWnd, 1); + EndDialog(hWnd, 1); break; } @@ -57,7 +57,7 @@ INT_PTR CALLBACK SelectByMatDlgProc( // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void SetSmoothButtonState(HWND hWnd, DWORD bits, DWORD invalid, DWORD unused = 0) +void SetSmoothButtonState(HWND hWnd, DWORD bits, DWORD invalid, DWORD unused = 0) { for (int i = IDC_SMOOTH_GRP1; i < IDC_SMOOTH_GRP1 + 32; i++) { @@ -71,7 +71,7 @@ void SetSmoothButtonState(HWND hWnd, DWORD bits, DWORD invalid, DWORD unused = 0 { SetWindowText(GetDlgItem(hWnd, i), NULL); SendMessage(GetDlgItem(hWnd, i), CC_COMMAND, CC_CMD_SET_STATE, FALSE); - } else + } else { TSTR buf; buf.printf(_T("%d"), i - IDC_SMOOTH_GRP1 + 1); @@ -84,7 +84,7 @@ void SetSmoothButtonState(HWND hWnd, DWORD bits, DWORD invalid, DWORD unused = 0 // ------------------------------------------------------------------------------------------------------------------------------------------------------ -INT_PTR CALLBACK SelectBySmoothDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK SelectBySmoothDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static DWORD *param; switch (msg) @@ -99,19 +99,19 @@ INT_PTR CALLBACK SelectBySmoothDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARA CenterWindow(hWnd, GetParent(hWnd)); break; - case WM_COMMAND: + case WM_COMMAND: if (LOWORD(wParam) >= IDC_SMOOTH_GRP1 && LOWORD(wParam) <= IDC_SMOOTH_GRP32) { - ICustButton *iBut = GetICustButton(GetDlgItem(hWnd, LOWORD(wParam))); - int shift = LOWORD(wParam) - IDC_SMOOTH_GRP1; + ICustButton *iBut = GetICustButton(GetDlgItem(hWnd, LOWORD(wParam))); + int shift = LOWORD(wParam) - IDC_SMOOTH_GRP1; if (iBut->IsChecked()) { param[0] |= 1 << shift; - } else + } else { param[0] &= ~(1 << shift); - } + } ReleaseICustButton(iBut); break; } @@ -119,15 +119,15 @@ INT_PTR CALLBACK SelectBySmoothDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARA switch (LOWORD(wParam)) { case IDOK: - param[1] = IsDlgButtonChecked(hWnd, IDC_CLEARSELECTION); - EndDialog(hWnd, 1); - break; + param[1] = IsDlgButtonChecked(hWnd, IDC_CLEARSELECTION); + EndDialog(hWnd, 1); + break; case IDCANCEL: EndDialog(hWnd, 0); break; } - break; + break; default: return FALSE; @@ -142,10 +142,10 @@ INT_PTR CALLBACK PatchTileDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM EditPatchMod *ep =(EditPatchMod *)GetWindowLongPtr(hDlg, GWLP_USERDATA); if (!ep && message != WM_INITDIALOG) return FALSE; - + switch (message) { - case WM_INITDIALOG: + case WM_INITDIALOG: { ep =(EditPatchMod *)lParam; @@ -169,16 +169,16 @@ INT_PTR CALLBACK PatchTileDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM ep->tileRot = NULL; } return FALSE; - + case CC_SPINNER_CHANGE: /*switch (LOWORD(wParam)) { - case IDC_TILE_MAT_SPIN: + case IDC_TILE_MAT_SPIN: if (HIWORD(wParam)) break; // No interactive action ep->SetTileNum (ep->tileNum->GetIVal()); break; - case IDC_TILE_ROT_SPIN: + case IDC_TILE_ROT_SPIN: if (HIWORD(wParam)) break; // No interactive action ep->SetTileRot (ep->tileRot->GetIVal()); @@ -208,8 +208,8 @@ INT_PTR CALLBACK PatchTileDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (u == 0xffffffff) { ep->tileNum->SetIndeterminate(TRUE); - } - else + } + else { ep->tileNum->SetIndeterminate(FALSE); ep->tileNum->SetValue((int)u, FALSE); @@ -220,30 +220,24 @@ INT_PTR CALLBACK PatchTileDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (v == -1) { ep->tileRot->SetIndeterminate(TRUE); - } - else + } + else { ep->tileRot->SetIndeterminate(FALSE); ep->tileRot->SetValue(v, FALSE); }*/ - + ep->patchUIValid = TRUE; } return FALSE; - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - ep->ip->RollupMouseMessage(hDlg, message, wParam, lParam); - return FALSE; - - case WM_COMMAND: + case WM_COMMAND: /*switch (LOWORD(wParam)) { }*/ break; } - + return FALSE; } @@ -254,10 +248,10 @@ INT_PTR CALLBACK PatchEdgeDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM EditPatchMod *ep =(EditPatchMod *)GetWindowLongPtr(hDlg, GWLP_USERDATA); if (!ep && message != WM_INITDIALOG) return FALSE; - + switch (message) { - case WM_INITDIALOG: + case WM_INITDIALOG: { ep =(EditPatchMod *)lParam; @@ -269,7 +263,7 @@ INT_PTR CALLBACK PatchEdgeDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM case WM_DESTROY: return FALSE; - + case WM_PAINT: if (!ep->edgeUIValid) { @@ -298,15 +292,9 @@ INT_PTR CALLBACK PatchEdgeDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } return FALSE; - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - ep->ip->RollupMouseMessage(hDlg, message, wParam, lParam); - return FALSE; - - case WM_COMMAND: + case WM_COMMAND: switch (LOWORD(wParam)) - { + { case IDC_NO_SMOOTH: // 3 states management if (IsDlgButtonChecked(hDlg, IDC_NO_SMOOTH)==BST_INDETERMINATE) @@ -318,7 +306,7 @@ INT_PTR CALLBACK PatchEdgeDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } break; } - + return FALSE; } @@ -329,21 +317,21 @@ INT_PTR CALLBACK PatchSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM EditPatchMod *ep =(EditPatchMod *)GetWindowLongPtr(hDlg, GWLP_USERDATA); if (!ep && message != WM_INITDIALOG) return FALSE; - + switch (message) { - case WM_INITDIALOG: + case WM_INITDIALOG: { ep = (EditPatchMod *)lParam; ep->hSurfPanel = hDlg; for (int i = IDC_SMOOTH_GRP1; i < IDC_SMOOTH_GRP1 + 32; i++) SendMessage(GetDlgItem(hDlg, i), CC_COMMAND, CC_CMD_SET_TYPE, CBT_CHECK); - SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)ep); + SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)ep); ep->matSpin = SetupIntSpinner(hDlg, IDC_MAT_IDSPIN, IDC_MAT_ID, 1, MAX_MATID, 0); ep->tessUSpin = SetupIntSpinner(hDlg, IDC_TESS_U_SPIN, IDC_TESS_U2, 1, 4, RPO_DEFAULT_TESSEL); ep->tessVSpin = SetupIntSpinner(hDlg, IDC_TESS_V_SPIN, IDC_TESS_V2, 1, 4, RPO_DEFAULT_TESSEL); - + ep->SetSurfDlgEnables(); return TRUE; @@ -366,17 +354,17 @@ INT_PTR CALLBACK PatchSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM ep->tessVSpin = NULL; } return FALSE; - + case CC_SPINNER_CHANGE: switch (LOWORD(wParam)) { - case IDC_MAT_IDSPIN: + case IDC_MAT_IDSPIN: if (HIWORD(wParam)) break; // No interactive action ep->SetSelMatIndex(ep->matSpin->GetIVal() - 1); break; - case IDC_TESS_U_SPIN: - case IDC_TESS_V_SPIN: + case IDC_TESS_U_SPIN: + case IDC_TESS_V_SPIN: if (HIWORD(wParam)) break; // No interactive action ep->SetSelTess(ep->tessUSpin->GetIVal(), ep->tessVSpin->GetIVal()); @@ -391,8 +379,8 @@ INT_PTR CALLBACK PatchSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM ep->SetSelMatIndex(ep->matSpin->GetIVal() - 1); ep->ip->RedrawViews(ep->ip->GetTime(), REDRAW_END); break; - case IDC_TESS_U_SPIN: - case IDC_TESS_V_SPIN: + case IDC_TESS_U_SPIN: + case IDC_TESS_V_SPIN: ep->SetSelTess(ep->tessUSpin->GetIVal(), ep->tessVSpin->GetIVal()); ep->ip->RedrawViews(ep->ip->GetTime(), REDRAW_END); break; @@ -407,8 +395,8 @@ INT_PTR CALLBACK PatchSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (mat == -1) { ep->matSpin->SetIndeterminate(TRUE); - } - else + } + else { ep->matSpin->SetIndeterminate(FALSE); ep->matSpin->SetValue(mat + 1, FALSE); @@ -423,8 +411,8 @@ INT_PTR CALLBACK PatchSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (u == -1) { ep->tessUSpin->SetIndeterminate(TRUE); - } - else + } + else { ep->tessUSpin->SetIndeterminate(FALSE); ep->tessUSpin->SetValue(u, FALSE); @@ -435,8 +423,8 @@ INT_PTR CALLBACK PatchSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (v == -1) { ep->tessVSpin->SetIndeterminate(TRUE); - } - else + } + else { ep->tessVSpin->SetIndeterminate(FALSE); ep->tessVSpin->SetValue(v, FALSE); @@ -446,13 +434,7 @@ INT_PTR CALLBACK PatchSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } return FALSE; - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - ep->ip->RollupMouseMessage(hDlg, message, wParam, lParam); - return FALSE; - - case WM_COMMAND: + case WM_COMMAND: if (LOWORD(wParam) >= IDC_SMOOTH_GRP1 && LOWORD(wParam) <= IDC_SMOOTH_GRP32) { @@ -464,25 +446,25 @@ INT_PTR CALLBACK PatchSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM break; } switch (LOWORD(wParam)) - { + { // Material - case IDC_SELECT_BYID: - { + case IDC_SELECT_BYID: + { if (DialogBoxParam( - hInstance, + hInstance, MAKEINTRESOURCE(IDD_SELECTBYMAT), - ep->ip->GetMAXHWnd(), + ep->ip->GetMAXHWnd(), SelectByMatDlgProc, (LPARAM)sbmParams)) { - + ep->SelectByMat(sbmParams[0] - 1/*index*/, sbmParams[1]/*clear*/); } break; } // Smoothing groups - case IDC_SELECTBYSMOOTH: - { + case IDC_SELECTBYSMOOTH: + { sbsParams[2] = ~ep->GetUsedSmoothBits(); if (DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_EM_SELECTBYSMOOTH), ep->ip->GetMAXHWnd(), SelectBySmoothDlgProc, (LPARAM)sbsParams)) @@ -504,19 +486,19 @@ INT_PTR CALLBACK PatchSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } break; } - + return FALSE; } // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetSurfDlgEnables() +void EditPatchMod::SetSurfDlgEnables() { if (!hSurfPanel) return; - + nlassert(ip); - + BOOL oType =(GetSubobjectLevel() == EP_OBJECT) ? TRUE : FALSE; BOOL pType =(GetSubobjectLevel() == EP_PATCH) ? TRUE : FALSE; @@ -550,13 +532,13 @@ void EditPatchMod::SetSurfDlgEnables() // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetTileDlgEnables() +void EditPatchMod::SetTileDlgEnables() { if (!hTilePanel) return; - + nlassert(ip); - + BOOL oType =(GetSubobjectLevel() == EP_OBJECT) ? TRUE : FALSE; BOOL pType =(GetSubobjectLevel() == EP_TILE) ? TRUE : FALSE; @@ -568,13 +550,13 @@ void EditPatchMod::SetTileDlgEnables() // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetEdgeDlgEnables() +void EditPatchMod::SetEdgeDlgEnables() { if (!hEdgePanel) return; - + nlassert(ip); - + BOOL oType =(GetSubobjectLevel() == EP_OBJECT) ? TRUE : FALSE; BOOL pType =(GetSubobjectLevel() == EP_TILE) ? TRUE : FALSE; @@ -591,14 +573,14 @@ DWORD EditPatchMod::GetSelSmoothBits(DWORD &invalid) BOOL first = 1; DWORD bits = 0; invalid = 0; - ModContextList mcList; + ModContextList mcList; INodeTab nodes; if (!ip) return 0; ip->GetModContexts(mcList, nodes); ClearPatchDataFlag(mcList, EPD_BEENDONE); - + for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; @@ -619,8 +601,8 @@ DWORD EditPatchMod::GetSelSmoothBits(DWORD &invalid) if (first) { first = FALSE; - bits = patch->patches[j].smGroup; - } else + bits = patch->patches[j].smGroup; + } else { if (patch->patches[j].smGroup != bits) { @@ -632,7 +614,7 @@ DWORD EditPatchMod::GetSelSmoothBits(DWORD &invalid) patchData->SetFlag(EPD_BEENDONE, TRUE); } - + nodes.DisposeTemporary(); return bits; } @@ -640,16 +622,16 @@ DWORD EditPatchMod::GetSelSmoothBits(DWORD &invalid) // ------------------------------------------------------------------------------------------------------------------------------------------------------ DWORD EditPatchMod::GetUsedSmoothBits() - { + { DWORD bits = 0; - ModContextList mcList; + ModContextList mcList; INodeTab nodes; if (!ip) return 0; ip->GetModContexts(mcList, nodes); ClearPatchDataFlag(mcList, EPD_BEENDONE); - + for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; @@ -666,11 +648,11 @@ DWORD EditPatchMod::GetUsedSmoothBits() for (int j = 0; j < patch->getNumPatches(); j++) { bits |= patch->patches[j].smGroup; - } + } patchData->SetFlag(EPD_BEENDONE, TRUE); } - + nodes.DisposeTemporary(); return bits; } @@ -679,14 +661,14 @@ DWORD EditPatchMod::GetUsedSmoothBits() void EditPatchMod::SelectBySmoothGroup(DWORD bits, BOOL clear) { - ModContextList mcList; + ModContextList mcList; INodeTab nodes; if (!ip) return; ip->GetModContexts(mcList, nodes); ClearPatchDataFlag(mcList, EPD_BEENDONE); - + theHold.Begin(); for (int i = 0; i < mcList.Count(); i++) @@ -707,25 +689,25 @@ void EditPatchMod::SelectBySmoothGroup(DWORD bits, BOOL clear) { theHold.Put(new PatchSelRestore(patchData, this, patch)); } - + if (clear) - patch->patchSel.ClearAll(); + patch->patchSel.ClearAll(); for (int j = 0; j < patch->getNumPatches(); j++) - { + { if (patch->patches[j].smGroup & bits) { - patch->patchSel.Set(j); + patch->patchSel.Set(j); } } - + patchData->UpdateChanges(patch, rpatch, FALSE); patchData->SetFlag(EPD_BEENDONE, TRUE); patchData->TempData(this)->Invalidate(PART_SELECT); } - + PatchSelChanged(); theHold.Accept(GetString(IDS_RB_SELECTBYSMOOTH)); - + nodes.DisposeTemporary(); NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); ip->RedrawViews(ip->GetTime()); @@ -735,14 +717,14 @@ void EditPatchMod::SelectBySmoothGroup(DWORD bits, BOOL clear) void EditPatchMod::SetSelSmoothBits(DWORD bits, DWORD which) { - ModContextList mcList; + ModContextList mcList; INodeTab nodes; if (!ip) return; ip->GetModContexts(mcList, nodes); ClearPatchDataFlag(mcList, EPD_BEENDONE); - + theHold.Begin(); for (int i = 0; i < mcList.Count(); i++) @@ -763,24 +745,24 @@ void EditPatchMod::SetSelSmoothBits(DWORD bits, DWORD which) { theHold.Put(new PatchSelRestore(patchData, this, patch)); } - + for (int j = 0; j < patch->getNumPatches(); j++) - { + { if (patch->patchSel[j]) { patch->patches[j].smGroup &= ~which; - patch->patches[j].smGroup |= bits&which; + patch->patches[j].smGroup |= bits&which; } } - + patchData->UpdateChanges(patch, rpatch, FALSE); patchData->SetFlag(EPD_BEENDONE, TRUE); patchData->TempData(this)->Invalidate(PART_SELECT); } - + PatchSelChanged(); theHold.Accept(GetString(IDS_RB_SETSMOOTHGROUP)); - + nodes.DisposeTemporary(); NotifyDependents(FOREVER, PART_TOPO, REFMSG_CHANGE); InvalidateSurfaceUI(); diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_tess.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_tess.cpp index 0823afbd4..de534123d 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_tess.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_tess.cpp @@ -1,6 +1,10 @@ #include "stdafx.h" #include "editpat.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // ------------------------------------------------------------------------------------------------------------------------------------------------------ #define DBGWELD_DUMPx @@ -10,7 +14,7 @@ #define PROMPT_TIME 2000 extern AdvParams sParams; -INT_PTR CALLBACK AdvParametersDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK AdvParametersDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); // ------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -52,7 +56,7 @@ void EditPatchMod::SetTessUI(HWND hDlg, TessApprox *tess) { CheckDlgButton(hDlg, IDC_TILE_MODE, TRUE); } - else + else { CheckDlgButton(hDlg, IDC_TILE_MODE, FALSE); } @@ -62,7 +66,7 @@ void EditPatchMod::SetTessUI(HWND hDlg, TessApprox *tess) EnableWindow (GetDlgItem (hDlg, IDC_STEPSSPINNER), !bCheck); EnableWindow (GetDlgItem (hDlg, IDC_STEPS_RENDER), !bCheck); EnableWindow (GetDlgItem (hDlg, IDC_STEPSRENDERSPINNER), !bCheck); - + // New EnableWindow (GetDlgItem (hDlg, IDC_TILESTEPS), bCheck); EnableWindow (GetDlgItem (hDlg, IDC_TILESTEPSSPINNER), bCheck); @@ -72,7 +76,7 @@ void EditPatchMod::SetTessUI(HWND hDlg, TessApprox *tess) if (keepMapping) CheckDlgButton(hDlg, IDC_KEEP_MAPPING, TRUE); - else + else CheckDlgButton(hDlg, IDC_KEEP_MAPPING, FALSE); switch (tess->type) @@ -162,13 +166,13 @@ void EditPatchMod::SetTessUI(HWND hDlg, TessApprox *tess) EnableWindow(GetDlgItem(hDlg, IDC_TESS_NORMALS), !GetViewTessWeld()); EnableWindow(GetDlgItem(hDlg, IDC_WELDTESS), tess->merge > 0.0f); } - } else + } else { if (settingDisp) { ShowWindow(GetDlgItem(hDlg, IDC_MESH), SW_SHOW); ShowWindow(GetDlgItem(hDlg, IDC_DISP), SW_SHOW); - } else + } else { if (tess->type != TESS_SET) { @@ -198,7 +202,7 @@ void EditPatchMod::SetTessUI(HWND hDlg, TessApprox *tess) CheckDlgButton(hDlg, IDC_TESS_RENDERER, FALSE); CheckDlgButton(hDlg, IDC_TESS_NORMALS, GetViewTessNormals()); CheckDlgButton(hDlg, IDC_WELDTESS, GetViewTessWeld()); - } else + } else { CheckDlgButton(hDlg, IDC_TESS_VIEW, FALSE); CheckDlgButton(hDlg, IDC_TESS_RENDERER, TRUE); @@ -209,28 +213,28 @@ void EditPatchMod::SetTessUI(HWND hDlg, TessApprox *tess) } // ------------------------------------------------------------------------------------------------------------------------------------------------------ - + BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { EditPatchMod *ep =(EditPatchMod *)GetWindowLongPtr(hDlg, GWLP_USERDATA); if (!ep && message != WM_INITDIALOG) return FALSE; - + switch (message) { - case WM_INITDIALOG: + case WM_INITDIALOG: { ep =(EditPatchMod *)lParam; ep->hSurfPanel = hDlg; - SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG)ep); + SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)ep); if (!ep->settingViewportTess && ep->settingDisp && ep->GetProdTess().type == TESS_SET) ep->settingDisp = FALSE; TessApprox t; if (ep->settingViewportTess) { t = ep->GetViewTess(); - } else + } else { if (ep->settingDisp) t = ep->GetDispTess(); @@ -282,14 +286,14 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM ep->mergeSpin = NULL; } return FALSE; - - case CC_SPINNER_BUTTONUP: + + case CC_SPINNER_BUTTONUP: { TessApprox tess; if (ep->settingViewportTess) { tess = ep->GetViewTess(); - } else + } else { if (ep->settingDisp) tess = ep->GetDispTess(); @@ -300,7 +304,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } break; - case CC_SPINNER_CHANGE: + case CC_SPINNER_CHANGE: switch (LOWORD(wParam)) { case IDC_TESS_U_SPINNER: @@ -314,7 +318,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (ep->settingViewportTess) { tess = ep->GetViewTess(); - } else + } else { if (ep->settingDisp) tess = ep->GetDispTess(); @@ -345,7 +349,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (ep->settingViewportTess) { ep->SetViewTess(tess); - } else + } else { if (ep->settingDisp) ep->SetDispTess(tess); @@ -359,17 +363,11 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } break; - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - ep->ip->RollupMouseMessage(hDlg, message, wParam, lParam); - return FALSE; - - case WM_COMMAND: + case WM_COMMAND: switch (LOWORD(wParam)) - { + { // Tessellation - case IDC_TESS_VIEW: + case IDC_TESS_VIEW: { ep->settingViewportTess = TRUE; TessApprox t = ep->GetViewTess(); @@ -377,14 +375,14 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM EnableWindow(GetDlgItem(hDlg, IDC_TESS_VIEW_DEP), FALSE); // always off here break; } - case IDC_TESS_RENDERER: + case IDC_TESS_RENDERER: { ep->settingViewportTess = FALSE; if (ep->settingDisp) { TessApprox t = ep->GetDispTess(); ep->SetTessUI(hDlg, &t); - } else + } else { TessApprox t = ep->GetProdTess(); ep->SetTessUI(hDlg, &t); @@ -403,13 +401,13 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM { BOOL bCheck=(IsDlgButtonChecked(hDlg, IDC_TILE_MODE)==BST_CHECKED); ep->SetTileMode (bCheck!=0); - + // Old EnableWindow (GetDlgItem (hDlg, IDC_STEPS), !bCheck); EnableWindow (GetDlgItem (hDlg, IDC_STEPSSPINNER), !bCheck); EnableWindow (GetDlgItem (hDlg, IDC_STEPS_RENDER), !bCheck); EnableWindow (GetDlgItem (hDlg, IDC_STEPSRENDERSPINNER), !bCheck); - + // New EnableWindow (GetDlgItem (hDlg, IDC_TILESTEPS), bCheck); EnableWindow (GetDlgItem (hDlg, IDC_TILESTEPSSPINNER), bCheck); @@ -437,7 +435,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (ep->settingViewportTess) { tess = ep->GetViewTess(); - } else + } else { if (ep->settingDisp) tess = ep->GetDispTess(); @@ -478,7 +476,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (ep->settingViewportTess) { ep->SetViewTess(tess); - } else + } else { if (ep->settingDisp) ep->SetDispTess(tess); @@ -488,7 +486,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM ep->SetTessUI(hDlg, &tess); } break; - case IDC_TESS_VIEW_DEP: + case IDC_TESS_VIEW_DEP: { TessApprox tess; tess = ep->GetProdTess(); @@ -504,7 +502,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM { ep->SetViewTessNormals(IsDlgButtonChecked(hDlg, IDC_TESS_NORMALS)); ep->SetTessUI(hDlg, &ep->GetViewTess()); - } else + } else { ep->SetProdTessNormals(IsDlgButtonChecked(hDlg, IDC_TESS_NORMALS)); if (ep->settingDisp) @@ -518,7 +516,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM { ep->SetViewTessWeld(IsDlgButtonChecked(hDlg, IDC_WELDTESS)); ep->SetTessUI(hDlg, &ep->GetViewTess()); - } else + } else { ep->SetProdTessWeld(IsDlgButtonChecked(hDlg, IDC_WELDTESS)); if (ep->settingDisp) @@ -527,13 +525,13 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM ep->SetTessUI(hDlg, &ep->GetProdTess()); } break; - case IDC_ADVANCED_PARAMETERS: + case IDC_ADVANCED_PARAMETERS: { TessApprox tess; if (ep->settingViewportTess) { tess = ep->GetViewTess(); - } else + } else { if (ep->settingDisp) tess = ep->GetDispTess(); @@ -559,7 +557,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (MessageBox(hDlg, warning, title, MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) == IDYES) confirm = TRUE; - + } else confirm = TRUE; if (confirm) @@ -572,7 +570,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (ep->settingViewportTess) { ep->SetViewTess(tess); - } else + } else { if (ep->settingDisp) ep->SetDispTess(tess); @@ -586,8 +584,8 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } break; } - - return FALSE; + + return FALSE; } // ------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -604,7 +602,7 @@ AdvParametersDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { - case WM_INITDIALOG: + case WM_INITDIALOG: { initing = TRUE; CenterWindow(hDlg, GetCOREInterface()->GetMAXHWnd()); @@ -630,7 +628,7 @@ AdvParametersDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) CheckDlgButton(hDlg, IDC_DELAUNAY, TRUE); break; } - break; + break; } case WM_COMMAND: @@ -708,27 +706,27 @@ AdvParametersDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetViewTess(TessApprox &tess) +void EditPatchMod::SetViewTess(TessApprox &tess) { viewTess = tess; ModContextList mcList; INodeTab nodes; - + if (!ip) - return; - + return; + ip->GetModContexts(mcList, nodes); - + for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) - continue; + continue; RPatchMesh *rpatch; PatchMesh *patch = patchData->TempData(this)->GetPatch(ip->GetTime(),rpatch); if (!patch) continue; - + patch->SetViewTess(tess); patchData->viewTess = tess; //rpatch->rTess = rTess; @@ -744,27 +742,27 @@ void EditPatchMod::SetViewTess(TessApprox &tess) // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetProdTess(TessApprox &tess) +void EditPatchMod::SetProdTess(TessApprox &tess) { prodTess = tess; ModContextList mcList; INodeTab nodes; - + if (!ip) - return; - + return; + ip->GetModContexts(mcList, nodes); - + for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) - continue; + continue; RPatchMesh *rpatch; PatchMesh *patch = patchData->TempData(this)->GetPatch(ip->GetTime(),rpatch); if (!patch) continue; - + patch->SetProdTess(tess); patchData->prodTess = tess; if (patchData->tempData) @@ -779,27 +777,27 @@ void EditPatchMod::SetProdTess(TessApprox &tess) // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetDispTess(TessApprox &tess) +void EditPatchMod::SetDispTess(TessApprox &tess) { dispTess = tess; ModContextList mcList; INodeTab nodes; - + if (!ip) - return; - + return; + ip->GetModContexts(mcList, nodes); - + for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) - continue; + continue; RPatchMesh *rpatch; PatchMesh *patch = patchData->TempData(this)->GetPatch(ip->GetTime(),rpatch); if (!patch) continue; - + patch->SetDispTess(tess); patchData->dispTess = tess; if (patchData->tempData) @@ -814,27 +812,27 @@ void EditPatchMod::SetDispTess(TessApprox &tess) // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetViewTessNormals(BOOL use) +void EditPatchMod::SetViewTessNormals(BOOL use) { mViewTessNormals = use; ModContextList mcList; INodeTab nodes; - + if (!ip) - return; - + return; + ip->GetModContexts(mcList, nodes); - + for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) - continue; + continue; RPatchMesh *rpatch; PatchMesh *patch = patchData->TempData(this)->GetPatch(ip->GetTime(),rpatch); if (!patch) continue; - + patch->SetViewTessNormals(use); patchData->mViewTessNormals = use; if (patchData->tempData) @@ -849,27 +847,27 @@ void EditPatchMod::SetViewTessNormals(BOOL use) // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetProdTessNormals(BOOL use) +void EditPatchMod::SetProdTessNormals(BOOL use) { mProdTessNormals = use; ModContextList mcList; INodeTab nodes; - + if (!ip) - return; - + return; + ip->GetModContexts(mcList, nodes); - + for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) - continue; + continue; RPatchMesh *rpatch; PatchMesh *patch = patchData->TempData(this)->GetPatch(ip->GetTime(),rpatch); if (!patch) continue; - + patch->SetProdTessNormals(use); patchData->mProdTessNormals = use; if (patchData->tempData) @@ -884,27 +882,27 @@ void EditPatchMod::SetProdTessNormals(BOOL use) // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetViewTessWeld(BOOL weld) +void EditPatchMod::SetViewTessWeld(BOOL weld) { mViewTessWeld = weld; ModContextList mcList; INodeTab nodes; - + if (!ip) - return; - + return; + ip->GetModContexts(mcList, nodes); - + for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) - continue; + continue; RPatchMesh *rpatch; PatchMesh *patch = patchData->TempData(this)->GetPatch(ip->GetTime(),rpatch); if (!patch) continue; - + patch->SetViewTessWeld(weld); patchData->mViewTessWeld = weld; if (patchData->tempData) @@ -919,27 +917,27 @@ void EditPatchMod::SetViewTessWeld(BOOL weld) // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetProdTessWeld(BOOL weld) +void EditPatchMod::SetProdTessWeld(BOOL weld) { mProdTessWeld = weld; ModContextList mcList; INodeTab nodes; - + if (!ip) - return; - + return; + ip->GetModContexts(mcList, nodes); - + for (int i = 0; i < mcList.Count(); i++) { EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; if (!patchData) - continue; + continue; RPatchMesh *rpatch; PatchMesh *patch = patchData->TempData(this)->GetPatch(ip->GetTime(),rpatch); if (!patch) continue; - + patch->SetProdTessWeld(weld); patchData->mProdTessWeld = weld; if (patchData->tempData) diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_gui_bind.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_gui_bind.cpp index 4b3d4b6b4..af533c4c8 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_gui_bind.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_gui_bind.cpp @@ -165,7 +165,11 @@ int EPM_BindMouseProc::proc( int flags, IPoint2 m) { - ViewExp *vpt = ip->GetViewport(hwnd); +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hwnd); +#else + ViewExp *vpt = ip->GetViewport(hwnd); +#endif int res = TRUE; static PatchMesh *shape1 = NULL; static int poly1, vert1, seg1; @@ -302,8 +306,11 @@ int EPM_BindMouseProc::proc( break; } - if (vpt) +#if MAX_VERSION_MAJOR < 19 + if (vpt) ip->ReleaseViewport(vpt); +#endif + return res; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_main.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_main.cpp index 2a36cf070..bbe8e95a9 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_main.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_main.cpp @@ -160,24 +160,21 @@ void EditPatchMod::BeginEditParams(IObjParam *ip, ULONG flags, Animatable *prev) */ if (selLevel == EP_PATCH) { - hSurfPanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_SURF), - PatchSurfDlgProc, GetString(IDS_TH_SURFACEPROPERTIES), (LPARAM) this, rsSurf ? 0 : APPENDROLL_CLOSED); + hSurfPanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_SURF), PatchSurfDlgProc, GetString(IDS_TH_SURFACEPROPERTIES), (LPARAM) this, rsSurf ? 0 : APPENDROLL_CLOSED); } else hSurfPanel = NULL; if (selLevel == EP_TILE) { - hTilePanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_TILE), - PatchTileDlgProc, "Tile Properties", (LPARAM) this, rsTile ? 0 : APPENDROLL_CLOSED); + hTilePanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_TILE), PatchTileDlgProc, _M("Tile Properties"), (LPARAM) this, rsTile ? 0 : APPENDROLL_CLOSED); } else hTilePanel = NULL; if (selLevel == EP_EDGE) { - hEdgePanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_EDGE), - PatchEdgeDlgProc, "Edge Properties", (LPARAM) this, rsEdge ? 0 : APPENDROLL_CLOSED); + hEdgePanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_EDGE), PatchEdgeDlgProc, _M("Edge Properties"), (LPARAM) this, rsEdge ? 0 : APPENDROLL_CLOSED); } else hEdgePanel = NULL; @@ -329,7 +326,7 @@ ISubObjType *EditPatchMod::GetSubObjType(int i) SOT_Vertex.SetName(GetString(IDS_TH_VERTEX)); SOT_Edge.SetName(GetString(IDS_TH_EDGE)); SOT_Patch.SetName(GetString(IDS_TH_PATCH)); - SOT_Tile.SetName("Tile"); + SOT_Tile.SetName(_M("Tile")); // SOT_Element.SetName(GetString(IDS_TH_ELEMENT)); // SOT_Handle.SetName(GetString(IDS_TH_HANDLE)); } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp index 0d16dd149..ec109d320 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp @@ -26,7 +26,7 @@ int controlsInit = FALSE; using namespace NLMISC; /** public functions **/ -BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) +BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { // initialize nel context if (!NLMISC::INelContext::isContextInitialised()) @@ -40,11 +40,11 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { hInstance = hinstDLL; DisableThreadLibraryCalls(hInstance); - - if (!controlsInit) + + if (!controlsInit) { controlsInit = TRUE; - + // jaguar controls #if MAX_VERSION_MAJOR < 14 InitCustomControls(hInstance); @@ -55,12 +55,12 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) Ctl3dRegister(hinstDLL); Ctl3dAutoSubclass(hinstDLL); #endif - + // initialize Chicago controls InitCommonControls(); } } - + return TRUE; } @@ -68,20 +68,20 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) //------------------------------------------------------ // This is the interface to Jaguar: //------------------------------------------------------ -__declspec( dllexport ) const TCHAR *LibDescription() -{ - return "NeL Patch Edit"; +__declspec( dllexport ) const TCHAR *LibDescription() +{ + return _T("NeL Patch Edit"); } /// MUST CHANGE THIS NUMBER WHEN ADD NEW CLASS __declspec( dllexport ) int LibNumberClasses() -{ +{ return 1; } -__declspec( dllexport ) ClassDesc *LibClassDesc(int i) +__declspec( dllexport ) ClassDesc *LibClassDesc(int i) { - switch(i) + switch(i) { case 0: return GetEditPatchModDesc(); default: return NULL; @@ -90,7 +90,7 @@ __declspec( dllexport ) ClassDesc *LibClassDesc(int i) // Return version so can detect obsolete DLLs __declspec( dllexport ) ULONG LibVersion() -{ +{ return VERSION_3DSMAX; } @@ -110,12 +110,6 @@ BOOL CALLBACK DefaultSOTProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam); break; - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - if (ip) ip->RollupMouseMessage(hWnd,msg,wParam,lParam); - return FALSE; - default: return FALSE; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_rollup.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_rollup.cpp index 649b3b051..baf340ae2 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_rollup.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_rollup.cpp @@ -22,7 +22,7 @@ BOOL filterVerts = TRUE; static BOOL filterVecs = TRUE; -static void SetVertFilter() +static void SetVertFilter() { patchHitLevel[EP_VERTEX] =(filterVerts ? SUBHIT_PATCH_VERTS : 0) |(filterVecs ? SUBHIT_PATCH_VECS : 0); } @@ -35,22 +35,22 @@ extern void LoadImages(); INT_PTR CALLBACK PatchSelectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - static char string[64]; + static TCHAR string[64]; EditPatchMod *ep =(EditPatchMod *)GetWindowLongPtr(hDlg, GWLP_USERDATA); ICustToolbar *iToolbar; if (!ep && message != WM_INITDIALOG) return FALSE; - + switch (message) { - case WM_INITDIALOG: + case WM_INITDIALOG: { // Get the module path HMODULE hModule = hInstance; if (hModule) { // Get module file name - char moduldeFileName[512]; + TCHAR moduldeFileName[512]; if (GetModuleFileName (hModule, moduldeFileName, 512)) { // Get version info size @@ -59,52 +59,52 @@ INT_PTR CALLBACK PatchSelectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPAR if (versionInfoSize) { // Alloc the buffer - char *buffer=new char[versionInfoSize]; + TCHAR *buffer = new TCHAR[versionInfoSize]; // Find the verion resource if (GetFileVersionInfo(moduldeFileName, 0, versionInfoSize, buffer)) { uint *versionTab; uint versionSize; - if (VerQueryValue (buffer, "\\", (void**)&versionTab, &versionSize)) + if (VerQueryValue (buffer, _T("\\"), (void**)&versionTab, &versionSize)) { // Get the pointer on the structure VS_FIXEDFILEINFO *info=(VS_FIXEDFILEINFO*)versionTab; if (info) { // Setup version number - char version[512]; - sprintf (version, "Version %d.%d.%d.%d", - info->dwFileVersionMS>>16, - info->dwFileVersionMS&0xffff, - info->dwFileVersionLS>>16, + TCHAR version[512]; + _stprintf(version, _T("Version %d.%d.%d.%d"), + info->dwFileVersionMS>>16, + info->dwFileVersionMS&0xffff, + info->dwFileVersionLS>>16, info->dwFileVersionLS&0xffff); SetWindowText (GetDlgItem (hDlg, IDC_VERSION), version); } else - SetWindowText (GetDlgItem (hDlg, IDC_VERSION), "VS_FIXEDFILEINFO * is NULL"); + SetWindowText (GetDlgItem (hDlg, IDC_VERSION), _T("VS_FIXEDFILEINFO * is NULL")); } else - SetWindowText (GetDlgItem (hDlg, IDC_VERSION), "VerQueryValue failed"); + SetWindowText (GetDlgItem (hDlg, IDC_VERSION), _T("VerQueryValue failed")); } else - SetWindowText (GetDlgItem (hDlg, IDC_VERSION), "GetFileVersionInfo failed"); + SetWindowText (GetDlgItem (hDlg, IDC_VERSION), _T("GetFileVersionInfo failed")); // Free the buffer delete [] buffer; } else - SetWindowText (GetDlgItem (hDlg, IDC_VERSION), "GetFileVersionInfoSize failed"); + SetWindowText (GetDlgItem (hDlg, IDC_VERSION), _T("GetFileVersionInfoSize failed")); } else - SetWindowText (GetDlgItem (hDlg, IDC_VERSION), "GetModuleFileName failed"); + SetWindowText (GetDlgItem (hDlg, IDC_VERSION), _T("GetModuleFileName failed")); } else - SetWindowText (GetDlgItem (hDlg, IDC_VERSION), "GetModuleHandle failed"); + SetWindowText (GetDlgItem (hDlg, IDC_VERSION), _T("GetModuleHandle failed")); ep =(EditPatchMod *)lParam; ep->hSelectPanel = hDlg; - SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)ep); + SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)ep); // Set up the editing level selector LoadImages(); iToolbar = GetICustToolbar(GetDlgItem(hDlg, IDC_SELTYPE)); @@ -122,7 +122,7 @@ INT_PTR CALLBACK PatchSelectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPAR CheckDlgButton(hDlg, IDC_LOCK_HANDLES, lockedHandles); ep->SetSelDlgEnables(); - sprintf(string,"%s - %s",__DATE__,__TIME__); + _stprintf(string, _T("%s - %s"), _T(__DATE__), _T(__TIME__)); SetDlgItemText(hDlg,ID_VERSION,string); return TRUE; } @@ -132,18 +132,12 @@ INT_PTR CALLBACK PatchSelectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPAR ep->ip->ClearPickMode(); CancelEditPatchModes(ep->ip); return FALSE; - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - ep->ip->RollupMouseMessage(hDlg, message, wParam, lParam); - return FALSE; - - case WM_COMMAND: + + case WM_COMMAND: { BOOL needRedraw = FALSE; switch (LOWORD(wParam)) - { + { case EP_VERTEX: if (ep->GetSubobjectLevel() == EP_VERTEX) ep->ip->SetSubObjectLevel(PO_OBJECT); @@ -211,7 +205,7 @@ INT_PTR CALLBACK PatchSelectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPAR if (((LPNMHDR)lParam)->code == TTN_NEEDTEXT) { LPTOOLTIPTEXT lpttt; - lpttt =(LPTOOLTIPTEXT)lParam; + lpttt =(LPTOOLTIPTEXT)lParam; switch (lpttt->hdr.idFrom) { case EP_VERTEX: @@ -224,26 +218,26 @@ INT_PTR CALLBACK PatchSelectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPAR lpttt->lpszText = GetString(IDS_TH_PATCH); break; case EP_TILE: - lpttt->lpszText = "Tile"; + lpttt->lpszText = _T("Tile"); break; } } break; } - + return FALSE; } // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void EditPatchMod::SetOpsDlgEnables() +void EditPatchMod::SetOpsDlgEnables() { if (!hOpsPanel) return; - + nlassert(ip); - + // Disconnect right-click and delete mechanisms ip->GetRightClickMenuManager()->Unregister(&pMenu); ip->UnRegisterDeleteUser(&pDel); @@ -339,7 +333,7 @@ void EditPatchMod::SetOpsDlgEnables() // Enable/disable right-click and delete mechanisms if (!oType) - { + { pMenu.SetMod(this); ip->GetRightClickMenuManager()->Register(&pMenu); pDel.SetMod(this); @@ -355,19 +349,19 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (!ep && message != WM_INITDIALOG) return FALSE; - + ISpinnerControl *spin; ICustButton *ebut; switch (message) { - case WM_INITDIALOG: + case WM_INITDIALOG: { ep =(EditPatchMod *)lParam; ep->hOpsPanel = hDlg; for (int i = IDC_SMOOTH_GRP1; i < IDC_SMOOTH_GRP1 + 32; i++) SendMessage(GetDlgItem(hDlg, i), CC_COMMAND, CC_CMD_SET_TYPE, CBT_CHECK); - SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)ep); + SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)ep); ICustButton *but = GetICustButton(GetDlgItem(hDlg, IDC_ATTACH)); but->SetHighlightColor(GREEN_WASH); but->SetType(CBT_CHECK); @@ -407,12 +401,12 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM EnableWindow (GetDlgItem (hDlg, IDC_STEPSSPINNER), !IsDlgButtonChecked(hDlg, IDC_TILE_MODE)); EnableWindow (GetDlgItem (hDlg, IDC_STEPS_RENDER), !IsDlgButtonChecked(hDlg, IDC_TILE_MODE)); EnableWindow (GetDlgItem (hDlg, IDC_STEPSRENDERSPINNER), !IsDlgButtonChecked(hDlg, IDC_TILE_MODE)); - + // New EnableWindow (GetDlgItem (hDlg, IDC_TILESTEPS), IsDlgButtonChecked(hDlg, IDC_TILE_MODE)); EnableWindow (GetDlgItem (hDlg, IDC_TILESTEPSSPINNER), IsDlgButtonChecked(hDlg, IDC_TILE_MODE)); EnableWindow (GetDlgItem (hDlg, IDC_KEEP_MAPPING), IsDlgButtonChecked(hDlg, IDC_TILE_MODE)); - + // New EnableWindow (GetDlgItem (hDlg, IDC_TRANSITION), IsDlgButtonChecked(hDlg, IDC_TILE_MODE)); EnableWindow (GetDlgItem (hDlg, IDC_TRANSITIONSPINNER), IsDlgButtonChecked(hDlg, IDC_TILE_MODE)); @@ -500,7 +494,7 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM ep->ip->UnRegisterDeleteUser(&pDel); ep->ip->GetRightClickMenuManager()->Unregister(&pMenu); return FALSE; - + case CC_SPINNER_CHANGE: switch (LOWORD(wParam)) { @@ -550,7 +544,7 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } ep->ip->RedrawViews(ep->ip->GetTime(), REDRAW_END); - } else + } else { ep->ip->RedrawViews(ep->ip->GetTime(), REDRAW_INTERACTIVE); } @@ -568,18 +562,18 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM int sm =0; int sm2 = 0; if (IsDlgButtonChecked(hDlg, IDC_EP_SM_SMOOTH)) - sm = 0; + sm = 0; else if (IsDlgButtonChecked(hDlg, IDC_EP_SM_SMOOTH2)) - sm = 1; + sm = 1; else if (IsDlgButtonChecked(hDlg, IDC_EP_SM_SMOOTH3)) - sm = 2; + sm = 2; if (IsDlgButtonChecked(hDlg, IDC_EP_SM_SMOOTH4)) - sm2 = 0; + sm2 = 0; else if (IsDlgButtonChecked(hDlg, IDC_EP_SM_SMOOTH5)) - sm2 = 1; + sm2 = 1; else if (IsDlgButtonChecked(hDlg, IDC_EP_SM_SMOOTH6)) - sm2 = 2; + sm2 = 2; spin = GetISpinner(GetDlgItem(hDlg, IDC_EP_OUTLINESPINNER)); ep->Bevel(ep->ip->GetTime(), spin->GetFVal(), sm, sm2); @@ -594,7 +588,7 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } ep->ip->RedrawViews(ep->ip->GetTime(), REDRAW_END); - } else + } else { ep->ip->RedrawViews(ep->ip->GetTime(), REDRAW_INTERACTIVE); } @@ -645,15 +639,9 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } break; - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - ep->ip->RollupMouseMessage(hDlg, message, wParam, lParam); - return FALSE; - - case WM_COMMAND: + case WM_COMMAND: switch (LOWORD(wParam)) - { + { // Subdivision // watje 3-18-99 case IDC_SHOW_INTERIOR_FACES: @@ -666,18 +654,18 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM { BOOL bCheck=(IsDlgButtonChecked(hDlg, IDC_TILE_MODE)==BST_CHECKED); ep->SetTileMode (bCheck!=0); - + // Old EnableWindow (GetDlgItem (hDlg, IDC_STEPS), !bCheck); EnableWindow (GetDlgItem (hDlg, IDC_STEPSSPINNER), !bCheck); EnableWindow (GetDlgItem (hDlg, IDC_STEPS_RENDER), !bCheck); EnableWindow (GetDlgItem (hDlg, IDC_STEPSRENDERSPINNER), !bCheck); - + // New EnableWindow (GetDlgItem (hDlg, IDC_TILESTEPS), bCheck); EnableWindow (GetDlgItem (hDlg, IDC_TILESTEPSSPINNER), bCheck); EnableWindow (GetDlgItem (hDlg, IDC_KEEP_MAPPING), bCheck); - + // New EnableWindow (GetDlgItem (hDlg, IDC_TRANSITION), bCheck); EnableWindow (GetDlgItem (hDlg, IDC_TRANSITIONSPINNER), bCheck); @@ -743,7 +731,7 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM ep->ip->SetStdCommandMode(CID_OBJMOVE); else ep->ip->SetCommandMode(ep->bevelMode); break; - + case IDC_TURN: nlassert (ep->GetSubobjectLevel()==PO_PATCH); ep->DoPatchTurn(true); @@ -784,7 +772,7 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM case IDC_DETACHREORIENT: patchDetachReorient = IsDlgButtonChecked(hDlg, IDC_DETACHREORIENT); break; - case IDC_ATTACH: + case IDC_ATTACH: { ModContextList mcList; INodeTab nodes; @@ -810,7 +798,7 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } break; } - + return FALSE; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_lib/CMakeLists.txt b/code/nel/tools/3d/plugin_max/nel_patch_lib/CMakeLists.txt index 63f0a5bcc..127b7fba2 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_lib/CMakeLists.txt +++ b/code/nel/tools/3d/plugin_max/nel_patch_lib/CMakeLists.txt @@ -8,4 +8,6 @@ NL_DEFAULT_PROPS(nel_patch_lib "MAX Plugin: NeL Patch Library") NL_ADD_RUNTIME_FLAGS(nel_patch_lib) NL_ADD_LIB_SUFFIX(nel_patch_lib) +ADD_DEFINITIONS(${MAXSDK_DEFINITIONS}) + INSTALL(TARGETS nel_patch_lib RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) diff --git a/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.cpp b/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.cpp index a0697ac79..90803fad1 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.cpp @@ -53,7 +53,7 @@ float bindWhere[BIND_COUNT]= #define RK_APPDATA_TILEFILE 0 #define RK_APPDATA_LAND 1 -#define REGKEY_TILEDIT "Software\\Nevrax\\Ryzom\\Tile_Edit" +#define REGKEY_TILEDIT _T("Software\\Nevrax\\Ryzom\\Tile_Edit") //#define CHECK_VALIDITY // check validity @@ -103,11 +103,11 @@ std::string GetBankPathName () HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER, REGKEY_TILEDIT, 0, KEY_READ, &hKey)==ERROR_SUCCESS) { - char path[256]; - DWORD len=256; + TCHAR path[256]; + DWORD len=256 * sizeof(TCHAR); DWORD type; - if (RegQueryValueEx(hKey, "Bank Path", 0, &type, (LPBYTE)path, &len)==ERROR_SUCCESS) - return std::string (path); + if (RegQueryValueEx(hKey, _T("Bank Path"), 0, &type, (LPBYTE)path, &len)==ERROR_SUCCESS) + return tStrToUtf8(path); RegCloseKey (hKey); } return ""; @@ -121,7 +121,7 @@ int GetBankTileSetSet () int tileSetSet; DWORD len=256; DWORD type; - if (RegQueryValueEx(hKey, "Tileset Set", 0, &type, (LPBYTE)&tileSetSet, &len)==ERROR_SUCCESS) + if (RegQueryValueEx(hKey, _T("Tileset Set"), 0, &type, (LPBYTE)&tileSetSet, &len)==ERROR_SUCCESS) return tileSetSet; RegCloseKey (hKey); } @@ -133,7 +133,10 @@ void SetBankPathName (const std::string& path) HKEY hKey; if (RegCreateKey(HKEY_CURRENT_USER, REGKEY_TILEDIT, &hKey)==ERROR_SUCCESS) { - RegSetValueEx(hKey, "Bank Path", 0, REG_SZ, (LPBYTE)path.c_str(), path.length()+1); + TCHAR buffer[MAX_PATH]; + _tcscpy_s(buffer, MAX_PATH, utf8ToTStr(path)); + + RegSetValueEx(hKey, _T("Bank Path"), 0, REG_SZ, (LPBYTE)buffer, (_tcslen(buffer)+1)*sizeof(TCHAR)); RegCloseKey (hKey); } } @@ -143,7 +146,7 @@ void SetBankTileSetSet (int tileSetSet) HKEY hKey; if (RegCreateKey(HKEY_CURRENT_USER, REGKEY_TILEDIT, &hKey)==ERROR_SUCCESS) { - RegSetValueEx(hKey, "Tileset Set", 0, REG_DWORD, (LPBYTE)&tileSetSet, 4); + RegSetValueEx(hKey, _T("Tileset Set"), 0, REG_DWORD, (LPBYTE)&tileSetSet, 4); RegCloseKey (hKey); } } @@ -1972,7 +1975,7 @@ IOResult RPatchMesh::Load(ILoad *iload) for (i=0; iWrite(&bBinded, sizeof (bool), &nb); @@ -2261,9 +2264,18 @@ BOOL RPatchMesh::SubObjectHitTest (GraphicsWindow *gw, Material *ma, HitRegion * gw->setRndLimits(gw->getRndLimits() & ~GW_BACKCULL); bRet=mesh.SubObjectHitTest (gw, ma, hr, nFlags, list); +#if MAX_VERSION_MAJOR < 19 MeshSubHitRec *rec=list.First(); + while (rec) { +#else + MeshSubHitRec::Iterator it = list.begin(), iend = list.end(); + + while(it != iend) + { + MeshSubHitRec *rec = &*it; +#endif if (flags&SUBHIT_PATCH_SELONLY) { int otot=0; @@ -2284,7 +2296,11 @@ BOOL RPatchMesh::SubObjectHitTest (GraphicsWindow *gw, Material *ma, HitRegion * hitList.AddHit (rec->dist, &patch, nRemapedIndex, PATCH_HIT_TILE); // Next hit - rec=rec->Next(); +#if MAX_VERSION_MAJOR < 19 + rec = rec->Next(); +#else + ++it; +#endif } } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.h b/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.h index 42d514eb3..f0ed9601c 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.h +++ b/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.h @@ -434,8 +434,8 @@ class CBankManager public: CBankManager () { - _lastPath=""; } + const NL3D::CTileBank& getBank (std::string& path=GetBankPathName ()) { if (path!=_lastPath) @@ -449,9 +449,9 @@ public: _bank.serial (file); } } - catch (NLMISC::EStream& excp) + catch (const NLMISC::EStream& excp) { - MessageBox (NULL, excp.what(), "Load error", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(excp.what()), _T("Load error"), MB_OK|MB_ICONEXCLAMATION); } } return _bank; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo.cpp b/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo.cpp index c2fd487dc..9216d4155 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo.cpp @@ -43,9 +43,9 @@ class RPOClassDesc:public ClassDesc { return new RPO; } - const TCHAR * ClassName() + const MCHAR * ClassName() { - return "RklPatch"; + return _M("RklPatch"); } SClass_ID SuperClassID() { @@ -55,9 +55,9 @@ class RPOClassDesc:public ClassDesc { return RYKOLPATCHOBJ_CLASS_ID; } - const TCHAR* Category() + const MCHAR* Category() { - return "Rykol Tools"; + return _M("Rykol Tools"); } }; @@ -117,7 +117,7 @@ RPO::RPO(PatchObject& pPO) : PatchObject(pPO) RPO::~RPO() { - if (((~GetChannelLocks()))&PART_TOPO) + if ( (~((PartID)GetChannelLocks())) & PART_TOPO ) { delete rpatch; rpatch=NULL; @@ -304,10 +304,10 @@ void RPO::GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel ) // ------------------------------------------------------------------------------------------------------------------------------------------------ //From ReferenceMaker -RefResult RPO::NotifyRefChanged( Interval changeInt, RefTargetHandle hTarget,PartID& partID, RefMessage message ) +RefResult RPO::NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget,PartID& partID, RefMessage message, BOOL propagate ) { //TODO: Implement, if the object makes references to other things - //return PatchObject::NotifyRefChanged( changeInt, hTarget, partID, message); + //return PatchObject::NotifyRefChanged( changeInt, hTarget, partID, message, propagate); return(REF_SUCCEED); } @@ -381,7 +381,7 @@ void RPO::GetCollapseTypes(Tab &clist,Tab &nlist) //TODO: Append any any other collapse type the plugin supports Class_ID id = RYKOLPATCHOBJ_CLASS_ID; - TSTR *name = new TSTR("Rykol Patch Mesh"); + TSTR *name = new TSTR(_T("Rykol Patch Mesh")); clist.Append(1,&id); nlist.Append(1,&name); } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo.h b/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo.h index 0dfde7454..0faa95aa6 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo.h +++ b/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo.h @@ -83,14 +83,14 @@ class RPO : public PatchObject int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt); void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt); //TODO: Return the name that will appear in the history browser (modifier stack) - TCHAR *GetObjectName() { return "Rykol Patch Object";} + const MCHAR *GetObjectName() { return _M("Rykol Patch Object");} void GetWorldBoundBox(TimeValue t, INode *mat, ViewExp *vpt, Box3& box ); void GetLocalBoundBox(TimeValue t, INode *mat, ViewExp *vpt, Box3& box ); void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel ); //TODO: Return the default name of the node when it is created. - void InitNodeName(TSTR& s) { s = "Rykol Patch Object"; } + void InitNodeName(TSTR& s) { s = _M("Rykol Patch Object"); } // From Object BOOL HasUVW(); @@ -206,10 +206,10 @@ class RPO : public PatchObject ? true : PatchObject::IsSubClassOf(classID); } SClass_ID SuperClassID() { return GEOMOBJECT_CLASS_ID; } - void GetClassName(TSTR& s) {s = "Rykol Patch Object";} + void GetClassName(TSTR& s) {s.FromUTF8("Rykol Patch Object");} RefTargetHandle Clone ( RemapDir &remap ); - RefResult NotifyRefChanged (Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message); + RefResult NotifyRefChanged (const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate); int NumSubs() { diff --git a/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo2nel.cpp b/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo2nel.cpp index a80b2d0e9..ea21e8fbe 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo2nel.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo2nel.cpp @@ -175,7 +175,7 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo // Get the bank name std::string sName=GetBankPathName (); - if (sName!="") + if (!sName.empty()) { // Open the bank CIFile file; @@ -191,9 +191,9 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo // Ok loaded = true; } - catch (EStream& stream) + catch (const EStream& e) { - MessageBox (NULL, stream.what(), "Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(e.what()), _T("Error"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -202,7 +202,7 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo if (loaded == false) { nlwarning ("Can't load any tile bank. Select on with the tile_utility plug-in"); - mprintf ("Can't load any tile bank. Select on with the tile_utility plug-in"); + mprintf (_T("Can't load any tile bank. Select on with the tile_utility plug-in")); return false; } } @@ -253,25 +253,22 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo if (!patchError.empty()) { // Make an error message - char error[2098]; - smprintf (error, 2098, "Error: triple edge detected in "); + std::string error = "Error: triple edge detected in "; // For each error set::iterator ite=patchError.begin(); while (ite!=patchError.end()) { // Sub error message - char subError[512]; - smprintf (subError, 512, "patch %d ", (*ite)+1); - strcat (error, subError); + error += toString("patch %d ", (*ite)+1); // Next error ite++; } // Show the message - mprintf (error); - nlwarning (error); + mprintf (utf8ToTStr(error)); + nlwarning (error.c_str()); // Error return false; @@ -398,7 +395,7 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo icv=getCommonVertex(pPM,idstpatch,isrcpatch,&orderdstvtx); if (icv==-1) { - mprintf ("Invalid bind"); + mprintf (_T("Invalid bind")); nlwarning ("Invalid bind"); return false; } @@ -422,7 +419,7 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo icv=getCommonVertex(pPM,idstpatch,isrcpatch); if (icv==-1) { - mprintf ("Invalid bind"); + mprintf (_T("Invalid bind")); nlwarning ("Invalid bind"); return false; } @@ -439,7 +436,7 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo icv=getCommonVertex(pPM,idstpatch,isrcpatch); if (icv==-1) { - mprintf ("Invalid bind"); + mprintf (_T("Invalid bind")); nlwarning ("Invalid bind"); return false; } @@ -451,7 +448,7 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo isrcedge=getEdge(pPM,srcpatch,srcpatch->v[nv],icv); if (isrcedge==-1) { - mprintf ("Invalid edge"); + mprintf (_T("Invalid edge")); nlwarning ("Invalid bind"); return false; } @@ -595,7 +592,7 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo sym.invert (); if (!CPatchInfo::transform (patchinfo, zoneSymmetry, bank, symmetry, rotate, snapCell, weldThreshold, sym)) { - mprintf ("Can't transform the zone"); + mprintf (_T("Can't transform the zone")); nlwarning ("Invalid bind"); return false; } @@ -612,7 +609,7 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo uint i; for (i=0; iRollupMouseMessage(hWnd,msg,wParam,lParam); - return FALSE; - default: return FALSE; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/nel_patch_paint.h b/code/nel/tools/3d/plugin_max/nel_patch_paint/nel_patch_paint.h index 20009d0c7..d0e16bd11 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/nel_patch_paint.h +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/nel_patch_paint.h @@ -422,8 +422,7 @@ class PaintPatchMod : public Modifier static bool automaticLighting; static bool lockBorders; - RefResult NotifyRefChanged( Interval changeInt,RefTargetHandle hTarget, - PartID& partID, RefMessage message ) { return REF_SUCCEED; } + RefResult NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate) { return REF_SUCCEED; } bool includeMeshes; bool preloadTiles; @@ -482,7 +481,7 @@ class PaintPatchMod : public Modifier void BeginEditParams( IObjParam *ip, ULONG flags, Animatable *prev ); void EndEditParams( IObjParam *ip, ULONG flags, Animatable *next ); RefTargetHandle Clone(RemapDir& remap = DefaultRemapDir()); - TCHAR *GetObjectName() { return "NeL Patch Painter"; } + const MCHAR *GetObjectName() { return _M("NeL Patch Painter"); } void RescaleWorldUnits(float f); @@ -500,10 +499,10 @@ class EditPatchClassDesc:public ClassDesc { { return new PaintPatchMod; } - const TCHAR * ClassName() { return "NeL Painter"; } + const MCHAR * ClassName() { return _M("NeL Painter"); } SClass_ID SuperClassID() { return OSM_CLASS_ID; } Class_ID ClassID() { return Class_ID(0xc49560f, 0x3c3d68e7); } - const TCHAR* Category() { return "NeL Tools";} + const MCHAR* Category() { return _M("NeL Tools");} void ResetClassParams(BOOL fileReset); }; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp index 73bb142b1..98bc67305 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp @@ -47,7 +47,7 @@ using namespace NLLIGO; #define DEPTH_SEARCH_MAX 8 -#define REGKEY_EDIT_PATCH "Software\\Nevrax\\Ryzom\\edit_patch" +#define REGKEY_EDIT_PATCH _T("Software\\Nevrax\\Ryzom\\edit_patch") // Bank bitmaps CBankCont* bankCont; @@ -77,8 +77,7 @@ void WarningInvalidTileSet () if (!bWarningInvalidTileSet) { bWarningInvalidTileSet=true; - MessageBox (NULL, "The tile bank is not compatible with your zone.\nPlease use the good bank or erase and repaint the zone.", - "Tile paint", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, _T("The tile bank is not compatible with your zone.\nPlease use the good bank or erase and repaint the zone."), _T("Tile paint"), MB_OK|MB_ICONEXCLAMATION); } } @@ -105,13 +104,13 @@ void enterPainter (CTileBank& banktoLoad) { DWORD len=4; DWORD type; - RegQueryValueEx (hKey, "Background", 0, &type, (LPBYTE)&backGround, &len); - RegQueryValueEx (hKey, "Color1", 0, &type, (LPBYTE)&color1, &len); - RegQueryValueEx (hKey, "Color2", 0, &type, (LPBYTE)&color2, &len); - RegQueryValueEx (hKey, "Opa1", 0, &type, (LPBYTE)&opa1, &len); - RegQueryValueEx (hKey, "Opa2", 0, &type, (LPBYTE)&opa2, &len); - RegQueryValueEx (hKey, "Hard1", 0, &type, (LPBYTE)&hard1, &len); - RegQueryValueEx (hKey, "Hard2", 0, &type, (LPBYTE)&hard2, &len); + RegQueryValueEx (hKey, _T("Background"), 0, &type, (LPBYTE)&backGround, &len); + RegQueryValueEx (hKey, _T("Color1"), 0, &type, (LPBYTE)&color1, &len); + RegQueryValueEx (hKey, _T("Color2"), 0, &type, (LPBYTE)&color2, &len); + RegQueryValueEx (hKey, _T("Opa1"), 0, &type, (LPBYTE)&opa1, &len); + RegQueryValueEx (hKey, _T("Opa2"), 0, &type, (LPBYTE)&opa2, &len); + RegQueryValueEx (hKey, _T("Hard1"), 0, &type, (LPBYTE)&hard1, &len); + RegQueryValueEx (hKey, _T("Hard2"), 0, &type, (LPBYTE)&hard2, &len); RegCloseKey (hKey); } } @@ -126,13 +125,13 @@ void exitPainter () HKEY hKey; if (RegCreateKey(HKEY_CURRENT_USER, REGKEY_EDIT_PATCH, &hKey)==ERROR_SUCCESS) { - RegSetValueEx(hKey, "Background", 0, REG_DWORD, (LPBYTE)&backGround, 4); - RegSetValueEx(hKey, "Color1", 0, REG_DWORD, (LPBYTE)&color1, 4); - RegSetValueEx(hKey, "Color2", 0, REG_DWORD, (LPBYTE)&color2, 4); - RegSetValueEx(hKey, "Opa1", 0, REG_DWORD, (LPBYTE)&opa1, 4); - RegSetValueEx(hKey, "Opa2", 0, REG_DWORD, (LPBYTE)&opa2, 4); - RegSetValueEx(hKey, "Hard1", 0, REG_DWORD, (LPBYTE)&hard1, 4); - RegSetValueEx(hKey, "Hard2", 0, REG_DWORD, (LPBYTE)&hard2, 4); + RegSetValueEx(hKey, _T("Background"), 0, REG_DWORD, (LPBYTE)&backGround, 4); + RegSetValueEx(hKey, _T("Color1"), 0, REG_DWORD, (LPBYTE)&color1, 4); + RegSetValueEx(hKey, _T("Color2"), 0, REG_DWORD, (LPBYTE)&color2, 4); + RegSetValueEx(hKey, _T("Opa1"), 0, REG_DWORD, (LPBYTE)&opa1, 4); + RegSetValueEx(hKey, _T("Opa2"), 0, REG_DWORD, (LPBYTE)&opa2, 4); + RegSetValueEx(hKey, _T("Hard1"), 0, REG_DWORD, (LPBYTE)&hard1, 4); + RegSetValueEx(hKey, _T("Hard2"), 0, REG_DWORD, (LPBYTE)&hard2, 4); RegCloseKey (hKey); } } @@ -154,7 +153,7 @@ void drawVertexColorBox (float x0, float y0, float x1, float y1, CRGBA color, fl { // Draw a white frame behind CDRU::drawQuad (x0, y0, x1, y1, driver, CRGBA (0x40, 0x40, 0x40), CViewport()); - + // Compute the colors with alpha to show the hardness CRGBA fullFull=color; CRGBA full=color; @@ -223,9 +222,9 @@ void drawInterface (TModeMouse select, TModePaint mode, PaintPatchMod *pobj, IDr CDRU::drawBitmap ( (float)(t%MOD_WIDTH)/(float)MOD_WIDTH, (float)(t/MOD_WIDTH)/(float)MOD_HEIGHT, 1.f/(float)MOD_WIDTH, 1.f/(float)MOD_HEIGHT, *texture, driver, CViewport(), false); else - CDRU::drawQuad ( (float)(t%MOD_WIDTH)/(float)MOD_WIDTH, (float)(t/MOD_WIDTH)/(float)MOD_HEIGHT, + CDRU::drawQuad ( (float)(t%MOD_WIDTH)/(float)MOD_WIDTH, (float)(t/MOD_WIDTH)/(float)MOD_HEIGHT, (float)(t%MOD_WIDTH)/(float)MOD_WIDTH+1.f/(float)MOD_WIDTH, - (float)(t/MOD_WIDTH)/(float)MOD_HEIGHT+1.f/(float)MOD_HEIGHT, driver, + (float)(t/MOD_WIDTH)/(float)MOD_HEIGHT+1.f/(float)MOD_HEIGHT, driver, CRGBA (128, 128, 128), CViewport()); } } @@ -395,7 +394,7 @@ void drawInterface (TModeMouse select, TModePaint mode, PaintPatchMod *pobj, IDr if ((pobj->CurrentTileSet!=-1)&&(mode==ModeTile)) { // *** Draw the current group - ITexture* group[NL3D_CTILE_NUM_GROUP+1]={bankCont->allBitmap, bankCont->_0Bitmap, bankCont->_1Bitmap, bankCont->_2Bitmap, bankCont->_3Bitmap, + ITexture* group[NL3D_CTILE_NUM_GROUP+1]={bankCont->allBitmap, bankCont->_0Bitmap, bankCont->_1Bitmap, bankCont->_2Bitmap, bankCont->_3Bitmap, bankCont->_4Bitmap, bankCont->_5Bitmap, bankCont->_6Bitmap, bankCont->_7Bitmap, bankCont->_8Bitmap, bankCont->_9Bitmap, bankCont->_10Bitmap, bankCont->_11Bitmap}; @@ -451,7 +450,7 @@ void makeVectMesh (std::vector& vectMesh, INodeTab& nodes, ModContextL for (int i = 0; i < mcList.Count (); i++) { - // + // PaintPatchData *patchData = (PaintPatchData*)mcList[i]->localData; if (!patchData) continue; @@ -497,7 +496,7 @@ void transformDesc (tileDesc &desc, bool symmetry, uint rotate, uint mesh, uint CTileBank::TTileType type; bank.getTileXRef (tile, tileSet, number, type); - // Transform the transfo + // Transform the transfo CPatchInfo::getTileSymmetryRotate (bank, desc.getLayer(0).Tile, tileSymmetry, tileRotate); // Get the state of the layer 0 @@ -580,7 +579,7 @@ void transformInvDesc (tileDesc &desc, bool symmetry, uint rotate, uint mesh, ui transformDesc (desc, symmetry, 0, mesh, tile, vectMesh); } -void EPM_PaintMouseProc::SetTile (int mesh, int tile, const tileDesc& desc, std::vector& vectMesh, CLandscape* land, +void EPM_PaintMouseProc::SetTile (int mesh, int tile, const tileDesc& desc, std::vector& vectMesh, CLandscape* land, CNelPatchChanger& nelPatchChg, std::vector* backupStack, bool undo, bool updateDisplace) { // Undo: get old value @@ -601,7 +600,7 @@ void EPM_PaintMouseProc::SetTile (int mesh, int tile, const tileDesc& desc, std: maxDesc.setDisplace (oldDesc.getDisplace()); } - // Transform tile + // Transform tile tileDesc copyDesc=maxDesc; transformInvDesc (maxDesc, vectMesh[mesh].Symmetry, 4-vectMesh[mesh].Rotate, mesh, tile, vectMesh); transformInvDesc (copyDesc, vectMesh[mesh].Symmetry, 0, mesh, tile, vectMesh); @@ -806,7 +805,7 @@ bool EPM_PaintMouseProc::isLocked256 (PaintPatchMod *pobj, EPM_PaintTile* pTile) return false; } -bool EPM_PaintMouseProc::ClearATile ( EPM_PaintTile* pTile, std::vector& vectMesh, +bool EPM_PaintMouseProc::ClearATile ( EPM_PaintTile* pTile, std::vector& vectMesh, CLandscape* land, CNelPatchChanger& nelPatchChg, bool _256, bool _force128) { // ** 1) Backup of the tile @@ -865,7 +864,7 @@ bool EPM_PaintMouseProc::ClearATile ( EPM_PaintTile* pTile, std::vector& visited, std::vector& vectMesh, +bool EPM_PaintMouseProc::PutATile ( EPM_PaintTile* pTile, int tileSet, int curRotation, const CTileBank& bank, + bool selectCycle, std::set& visited, std::vector& vectMesh, CLandscape* land, CNelPatchChanger& nelPatchChg, bool _256) { // If tile 256, must have delta pos aligned on 2x2 @@ -913,7 +912,7 @@ bool EPM_PaintMouseProc::PutATile ( EPM_PaintTile* pTile, int tileSet, int curRo int patch=pTile->tile/NUM_TILE_SEL; // Check if we are in patch subobject and if this patch is selected - + if ((vectMesh[pTile->Mesh].PMesh->selLevel==EP_PATCH)&&(!vectMesh[pTile->Mesh].PMesh->patchSel[patch])) return false; @@ -987,7 +986,7 @@ bool EPM_PaintMouseProc::PutATile ( EPM_PaintTile* pTile, int tileSet, int curRo desc.setTile (1, 1+((-curRotation-1)&3), 0, tileIndex (nTile, (curRotation-nRot)&3), tileIndex (0,0), tileIndex (0,0)); nlassert (other); SetTile (other->Mesh, other->tile, desc, vectMesh, land, nelPatchChg, &backupStack); - + // Add to visited tile set visited.insert (other); @@ -996,7 +995,7 @@ bool EPM_PaintMouseProc::PutATile ( EPM_PaintTile* pTile, int tileSet, int curRo desc.setTile (1, 1+((-curRotation+1)&3), 0, tileIndex (nTile, (curRotation-nRot)&3), tileIndex (0,0), tileIndex (0,0)); nlassert (other); SetTile (other->Mesh, other->tile, desc, vectMesh, land, nelPatchChg, &backupStack); - + // Add to visited tile set visited.insert (other); @@ -1006,7 +1005,7 @@ bool EPM_PaintMouseProc::PutATile ( EPM_PaintTile* pTile, int tileSet, int curRo nlassert (other); nlassert (other==pTile->getBottomRight256 (0, nRot)); SetTile (other->Mesh, other->tile, desc, vectMesh, land, nelPatchChg, &backupStack); - + // Add to visited tile set visited.insert (other); } @@ -1038,14 +1037,14 @@ bool EPM_PaintMouseProc::PutATile ( EPM_PaintTile* pTile, int tileSet, int curRo case 0: // Main if (pTile->voisins[3]) - if (!PropagateBorder (pTile->voisins[3], (pTile->rotate[3]+curRotation)&3, tileSet, visited, bank, + if (!PropagateBorder (pTile->voisins[3], (pTile->rotate[3]+curRotation)&3, tileSet, visited, bank, vectMesh, land, nelPatchChg, backupStack)) { bContinue=false; goto zap; } if (pTile->voisins[0]) - if (!PropagateBorder (pTile->voisins[0], (pTile->rotate[0]+curRotation)&3, tileSet, visited, bank, + if (!PropagateBorder (pTile->voisins[0], (pTile->rotate[0]+curRotation)&3, tileSet, visited, bank, vectMesh, land, nelPatchChg, backupStack)) { bContinue=false; @@ -1213,13 +1212,13 @@ zap:; for (uint corner=0; corner<4; corner++) { finalCorner[corner].TileSet = -1; - + // All the same or empty ? for (uint layer=0; layer<4; layer++) { // Compatible ? - if ( ( finalCorner[corner].TileSet == -1 ) - || ( tileSetCases[layer][corner].TileSet == -1 ) + if ( ( finalCorner[corner].TileSet == -1 ) + || ( tileSetCases[layer][corner].TileSet == -1 ) || ( tileSetCases[layer][corner] == finalCorner[corner] ) ) { // Copy the tile @@ -1266,7 +1265,7 @@ zap:; bFind=true; } } - + // no, ok push it back. if (!bFind) setIndex.push_back (finalCorner[v]); @@ -1370,7 +1369,7 @@ zap:; finalIndex[l].Tile=tileTrans->getTile(); } } - + // Set the border desc tileDesc desc; GetTile (pTile->Mesh, pTile->tile, desc, vectMesh, land); @@ -1404,8 +1403,8 @@ zap:; /*-------------------------------------------------------------------*/ -void EPM_PaintMouseProc::PutADisplacetile ( EPM_PaintTile* pTile, const CTileBank& bank, - std::vector& vectMesh, +void EPM_PaintMouseProc::PutADisplacetile ( EPM_PaintTile* pTile, const CTileBank& bank, + std::vector& vectMesh, CLandscape* land, CNelPatchChanger& nelPatchChg) { // Get tile description @@ -1432,8 +1431,8 @@ void EPM_PaintMouseProc::PutADisplacetile ( EPM_PaintTile* pTile, const CTileBan /*-------------------------------------------------------------------*/ -bool EPM_PaintMouseProc::GetBorderDesc (EPM_PaintTile* tile, tileSetIndex *pVoisinCorner, CTileSet::TFlagBorder pBorder[4][3], - tileDesc *pVoisinIndex, const CTileBank& bank, std::vector& vectMesh, +bool EPM_PaintMouseProc::GetBorderDesc (EPM_PaintTile* tile, tileSetIndex *pVoisinCorner, CTileSet::TFlagBorder pBorder[4][3], + tileDesc *pVoisinIndex, const CTileBank& bank, std::vector& vectMesh, CNelPatchChanger& nelPatchChg, CLandscape *land) { // Tile info @@ -1446,7 +1445,7 @@ bool EPM_PaintMouseProc::GetBorderDesc (EPM_PaintTile* tile, tileSetIndex *pVois tileIndex pIndexx[3]; for (int nL=0; nLrotate[border]; index.Rotate&=3; - + CTileBank::TTileType type; int TileSet, number; @@ -1555,8 +1554,8 @@ int EPM_PaintMouseProc::getLayer (EPM_PaintTile* tile, int border, int tileSet, /*-------------------------------------------------------------------*/ -bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, int curTileSet, std::set& visited, - const CTileBank& bank, std::vector& vectMesh, +bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, int curTileSet, std::set& visited, + const CTileBank& bank, std::vector& vectMesh, CLandscape* land, CNelPatchChanger& nelPatchChg, std::vector& backupStack, bool recurseNoDiff) { // 1) Already visited @@ -1699,7 +1698,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, } extraOrdinary[v]++; bDiff=true; - } + } } else { @@ -1800,7 +1799,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, (desc1.isEmpty())|| (desc1.getCase()!=(1+((nCase+3)&3)))|| (desc1.getLayer(0).Tile!=backup.getLayer(0).Tile)|| - (desc1.getLayer(0).Rotate!=((backup.getLayer(0).Rotate-rot)&3)) + (desc1.getLayer(0).Rotate!=((backup.getLayer(0).Rotate-rot)&3)) ) bDiff=true; } @@ -1869,7 +1868,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, bFind=true; } } - + // no, ok push it back. if (!bFind) setIndex.push_back (nCorner[v]); @@ -1878,7 +1877,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, std::sort (setIndex.begin(), setIndex.end()); // Check validity - + // A) Check for more than 3 materials if (setIndex.size()>3) return false; @@ -1982,18 +1981,18 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, // Last on the stack ? if (*itevoisins[c]) { @@ -2035,7 +2034,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, return false; // Set the tile.. - SetTile (tile->voisins[c]->Mesh, tile->voisins[c]->tile, pVoisinIndex, vectMesh, + SetTile (tile->voisins[c]->Mesh, tile->voisins[c]->tile, pVoisinIndex, vectMesh, land, nelPatchChg, &backupStack); } /*if (pBorder[edge][nLayer]==CTileSet::_0001) @@ -2046,11 +2045,11 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, } } } - // Normal, + // Normal, else { // Voisin visited or frozen ? - if (tile->voisins[c]&&((visited.find (tile->voisins[c])!=visited.end()) /*|| + if (tile->voisins[c]&&((visited.find (tile->voisins[c])!=visited.end()) /*|| (vectMesh[tile->voisins[c]->Mesh].Node->IsFrozen())*/ )) { // Yes, visited. Copy the border @@ -2058,7 +2057,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, CTileSet::TFlagBorder pBorder[4][3]; tileDesc pVoisinIndex; bool bOk=GetBorderDesc (tile->voisins[c], pVoisinCorner, pBorder, &pVoisinIndex, bank, vectMesh, nelPatchChg, land); - + // Should not be empty nlassert (bOk); int edge=(2+c+tile->rotate[c])&3; @@ -2076,7 +2075,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, else { // No, not yet visited - + // Choose transition by random bool bComputed=false; if ((bVisited[c]||!recurseNoDiff)&&bSameEdge[c]) @@ -2087,7 +2086,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, CTileSet::TFlagBorder pBorder[4][3]; tileDesc pVoisinIndex; bool bOk=GetBorderDesc (tile->voisins[c], pVoisinCorner, pBorder, &pVoisinIndex, bank, vectMesh, nelPatchChg, land); - + // ok voisin is here ? if (bOk) { @@ -2141,18 +2140,18 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, // Last on the stack ? if (*itevoisins[c])//&&visited.find (tile->voisins[c])!=visited.end()) { @@ -2194,7 +2193,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, return false; // Set the tile.. - SetTile (tile->voisins[c]->Mesh, tile->voisins[c]->tile, pVoisinIndex, vectMesh, + SetTile (tile->voisins[c]->Mesh, tile->voisins[c]->tile, pVoisinIndex, vectMesh, land, nelPatchChg, &backupStack); } /*if (pBorder[edge][nLayer]==CTileSet::_1000) @@ -2206,7 +2205,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, } } - // Normal, + // Normal, else { // Voisin visited ? @@ -2217,7 +2216,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, CTileSet::TFlagBorder pBorder[4][3]; tileDesc pVoisinIndex; bool bOk=GetBorderDesc (tile->voisins[c], pVoisinCorner, pBorder, &pVoisinIndex, bank, vectMesh, nelPatchChg, land); - + // Should not be empty nlassert (bOk); int edge=(2+c+tile->rotate[c])&3; @@ -2236,7 +2235,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, else { // No, not yet visited - + // Choose transition by random bool bComputed=false; if ((bVisited[c]||!recurseNoDiff)&&bSameEdge[c]) @@ -2247,7 +2246,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, CTileSet::TFlagBorder pBorder[4][3]; tileDesc pVoisinIndex; bool bOk=GetBorderDesc (tile->voisins[c], pVoisinCorner, pBorder, &pVoisinIndex, bank, vectMesh, nelPatchChg, land); - + // ok voisin is here ? if (bOk) { @@ -2294,7 +2293,7 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, } ite++; } - + // Set the border desc tileDesc desc; GetTile (tile->Mesh, tile->tile, desc, vectMesh, land); @@ -2342,22 +2341,22 @@ bool EPM_PaintMouseProc::PropagateBorder (EPM_PaintTile* tile, int curRotation, { // Voisin not already visited and not frozen ? if ((tile->voisins[v]) && (visited.find (tile->voisins[v])==visited.end()) /* && (vectMesh[tile->voisins[v]->Mesh].Node->IsFrozen()==0)*/) - { + { // ok.. not visited, border with modified corner ? if (bModified[v]||bModified[(v+1)&3]||(!bSameEdge[v])) - if (!PropagateBorder (tile->voisins[v], (tile->rotate[v]+curRotation)&3, curTileSet, visited, bank, vectMesh, land, nelPatchChg, + if (!PropagateBorder (tile->voisins[v], (tile->rotate[v]+curRotation)&3, curTileSet, visited, bank, vectMesh, land, nelPatchChg, backupStack, false)) { bContinue=false; break; - } + } } } if (!bContinue) - { + { return false; } - + return true; } @@ -2414,8 +2413,8 @@ uint8 EPM_PaintMouseProc::CalcRotPath (EPM_PaintTile* from, EPM_PaintTile* to, i static TModePaint nModeTexture=ModeTile; static TModeMouse modeSelect=ModePaint; -void EPM_PaintMouseProc::RecursTile (EPM_PaintTile* pTile, const CTileBank& bank, int tileSet, std::vector& vectMesh, CLandscape* land, - int recurs, std::set& alreadyRecursed, bool first, int rotation, +void EPM_PaintMouseProc::RecursTile (EPM_PaintTile* pTile, const CTileBank& bank, int tileSet, std::vector& vectMesh, CLandscape* land, + int recurs, std::set& alreadyRecursed, bool first, int rotation, CNelPatchChanger& nelPatchChg, bool _256) { if (alreadyRecursed.find (pTile)==alreadyRecursed.end()) @@ -2438,20 +2437,20 @@ void EPM_PaintMouseProc::RecursTile (EPM_PaintTile* pTile, const CTileBank& bank if (_256) { if (pTile->get2Voisin(i)) - RecursTile (pTile->get2Voisin(i), bank, tileSet, vectMesh, land, recurs-2, alreadyRecursed, false, + RecursTile (pTile->get2Voisin(i), bank, tileSet, vectMesh, land, recurs-2, alreadyRecursed, false, (rotation+pTile->get2VoisinRotate(i))&3, nelPatchChg, true); } else { if (pTile->voisins[i]) - RecursTile (pTile->voisins[i], bank, tileSet, vectMesh, land, recurs-1, alreadyRecursed, false, (rotation+pTile->rotate[i])&3, + RecursTile (pTile->voisins[i], bank, tileSet, vectMesh, land, recurs-1, alreadyRecursed, false, (rotation+pTile->rotate[i])&3, nelPatchChg, false); } } } } -BOOL EPM_PaintMouseProc::PutDisplace (int tile, int mesh, const CTileBank& bank, std::vector& vectMesh, CLandscape* land, +BOOL EPM_PaintMouseProc::PutDisplace (int tile, int mesh, const CTileBank& bank, std::vector& vectMesh, CLandscape* land, int recurs, std::set& alreadyRecursed, CNelPatchChanger& nelPatchChg) { static sint32 MeshOld=-1; @@ -2461,7 +2460,7 @@ BOOL EPM_PaintMouseProc::PutDisplace (int tile, int mesh, const CTileBank& bank, EPM_PaintTile* pTile=&metaTile[mesh][tile]; // Ok recurse tiles - RecursTile (pTile, bank, 0, vectMesh, land, brushValue[PaintPatchMod::brushSize], alreadyRecursed, true, + RecursTile (pTile, bank, 0, vectMesh, land, brushValue[PaintPatchMod::brushSize], alreadyRecursed, true, EPM_PaintMouseProc::Rotation, nelPatchChg, false); MeshOld=mesh; @@ -2470,7 +2469,7 @@ BOOL EPM_PaintMouseProc::PutDisplace (int tile, int mesh, const CTileBank& bank, return TRUE; } -BOOL EPM_PaintMouseProc::PutTile (int tile, int mesh, bool first, const CTileBank& bank, int tileSet, std::vector& vectMesh, CLandscape* land, +BOOL EPM_PaintMouseProc::PutTile (int tile, int mesh, bool first, const CTileBank& bank, int tileSet, std::vector& vectMesh, CLandscape* land, int recurs, std::set& alreadyRecursed, CNelPatchChanger& nelPatchChg, bool _256) { static sint32 MeshOld=-1; @@ -2524,7 +2523,7 @@ BOOL EPM_PaintMouseProc::PutTile (int tile, int mesh, bool first, const CTileBan std::set alreadyRecursed; // Ok recurse tiles - RecursTile (pTile, bank, tileSet, vectMesh, land, brushValue[PaintPatchMod::brushSize], alreadyRecursed, first, + RecursTile (pTile, bank, tileSet, vectMesh, land, brushValue[PaintPatchMod::brushSize], alreadyRecursed, first, EPM_PaintMouseProc::Rotation, nelPatchChg, _256); } MeshOld=mesh; @@ -2816,12 +2815,12 @@ void mainproc(CScene& scene, CEventListenerAsync& AsyncListener, CEvent3dMouseLi if (AsyncListener.isKeyPushed ((TKey)PainterKeys[SelectColorBrush])) { // Create a dialog filter - static char szFilter[] = - "Targa Files (*.tga)\0*.tga\0" - "All Files (*.*)\0*.*\0\0"; + static TCHAR szFilter[] = + _T("Targa Files (*.tga)\0*.tga\0") + _T("All Files (*.*)\0*.*\0\0"); // Filename buffer - char buffer[65535]; + TCHAR buffer[65535]; buffer[0]=0; // Fill the (big) struct @@ -2834,13 +2833,13 @@ void mainproc(CScene& scene, CEventListenerAsync& AsyncListener, CEvent3dMouseLi openFile.lpstrFile = buffer; openFile.nMaxFile = 65535; openFile.Flags = OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ENABLESIZING|OFN_EXPLORER; - openFile.lpstrDefExt = "*.tga"; + openFile.lpstrDefExt = _T("*.tga"); // Open the dialog if (GetOpenFileName(&openFile)) - { + { // Load the file - paintColor.loadBrush (buffer); + paintColor.loadBrush (tStrToUtf8(buffer)); paintColor.setBrushMode (true); } } @@ -2992,7 +2991,7 @@ void mainproc(CScene& scene, CEventListenerAsync& AsyncListener, CEvent3dMouseLi t0= t1; } - + // Draw interface drawInterface (modeSelect, nModeTexture, pData->pobj, driver, landscape, paintColor); @@ -3017,7 +3016,7 @@ public: bool WindowActive; CPaintColor PaintColor; public: - MouseListener (IObjParam *ip, CCamera *camera, CViewport *viewport, PaintPatchMod *pobj, EPM_PaintMouseProc *eproc, CLandscape* land, + MouseListener (IObjParam *ip, CCamera *camera, CViewport *viewport, PaintPatchMod *pobj, EPM_PaintMouseProc *eproc, CLandscape* land, CEventListenerAsync* async, CEvent3dMouseListener* mouseList, std::vector& vectMesh, TimeValue t) : PaintColor (pobj, land, &bankCont->Undo, eproc), _FillTile (pobj, land, &bankCont->Undo, eproc), _VectMesh(vectMesh) { @@ -3064,7 +3063,7 @@ private: if (pressed&&((mouse->Button&rightButton)&&((mouse->Button&(ctrlButton|shiftButton|altButton))==0))) { pressed=false; - + // Undo step bankCont->Undo.pushUndo (); @@ -3100,13 +3099,13 @@ private: if (nModeTexture==ModeTile) { // Put the tile - _Eproc->PutTile (tile1, mesh1, true, bank, _Pobj->CurrentTileSet, _VectMesh, _Land, brushValue[PaintPatchMod::brushSize], + _Eproc->PutTile (tile1, mesh1, true, bank, _Pobj->CurrentTileSet, _VectMesh, _Land, brushValue[PaintPatchMod::brushSize], alreadyRecursed, nelPatchChg, _Pobj->tileSize!=0); } else // (nModeTexture==ModeDisplace) - { + { // Put the tile - _Eproc->PutDisplace (tile1, mesh1, bank, _VectMesh, _Land, brushValue[PaintPatchMod::brushSize], + _Eproc->PutDisplace (tile1, mesh1, bank, _VectMesh, _Land, brushValue[PaintPatchMod::brushSize], alreadyRecursed, nelPatchChg); } @@ -3142,7 +3141,7 @@ private: // Paint mode if (nModeTexture==ModeTile) // Fill this patch with the current tile - _FillTile.fillTile (mesh1, patch, _VectMesh, _Pobj->CurrentTileSet, _Pobj->TileFillRotation, _Pobj->TileGroup, _Pobj->tileSize!=0, + _FillTile.fillTile (mesh1, patch, _VectMesh, _Pobj->CurrentTileSet, _Pobj->TileFillRotation, _Pobj->TileGroup, _Pobj->tileSize!=0, bank); else if (nModeTexture==ModeColor) // Fill this patch with the current color @@ -3189,7 +3188,7 @@ private: { pressed = false; _Pobj->ShowCurrentState = false; - + // Undo step bankCont->Undo.pushUndo (); } @@ -3223,13 +3222,13 @@ private: if (nModeTexture==ModeTile) { // Put the tile - _Eproc->PutTile (tile2, mesh2, false, bank, _Pobj->CurrentTileSet, _VectMesh, _Land, + _Eproc->PutTile (tile2, mesh2, false, bank, _Pobj->CurrentTileSet, _VectMesh, _Land, brushValue[PaintPatchMod::brushSize], alreadyRecursed, nelPatchChg, _Pobj->tileSize!=0); } else // (nModeTexture==ModeDisplace) - { + { // Put the tile - _Eproc->PutDisplace (tile2, mesh2, bank, _VectMesh, _Land, brushValue[PaintPatchMod::brushSize], + _Eproc->PutDisplace (tile2, mesh2, bank, _VectMesh, _Land, brushValue[PaintPatchMod::brushSize], alreadyRecursed, nelPatchChg); } @@ -3300,7 +3299,7 @@ private: _Pobj->CurrentTileSet=tileSetSelector.getTileSet (tile-1); _Pobj->DisplaceTileSet=_Pobj->CurrentTileSet; } - } + } } // Mode displace ? @@ -3309,7 +3308,7 @@ private: if ((tile>=0)&&(tileDisplaceTile=tile; - } + } } } } @@ -3346,7 +3345,7 @@ void MouseListener::pick (int mesh, int tile, const CVector& hit, TModePaint mod // Pickup a displace ? else { - // Get the displace tile index + // Get the displace tile index _Pobj->DisplaceTile=desc.getDisplace (); _Pobj->DisplaceTileSet=tileSet; } @@ -3523,7 +3522,7 @@ void EPM_PaintCMode::DoPaint () static float best = 10000.f; // Set local to english - setlocale (LC_NUMERIC, "English"); + setlocale (LC_NUMERIC, "C"); if (pobj->hOpsPanel) { @@ -3578,7 +3577,7 @@ void EPM_PaintCMode::DoPaint () int nV=1<getUIPatch (p).NbTilesV; for (int u=0; u<=nU; u++) for (int v=0; v<=nV; v++) - { + { Point3 pos=patch->patches[p].interp (patch, (float)u/(float)(nU), (float)v/(float)(nV)); pos=pos*(vectMesh[i].Node->GetObjectTM (t)); if (fMaxXrotate[2]=0; pTile->u=u; pTile->v=v; - + // Compute bouding box of the tile fMinX=FLT_MAX; fMinY=FLT_MAX; @@ -3666,7 +3665,7 @@ void EPM_PaintCMode::DoPaint () pTile->Center=(maxToNel (pos[0])+maxToNel (pos[1])+maxToNel (pos[2])+maxToNel (pos[3]))/4.f; // Store its radius - pTile->Radius=std::max + pTile->Radius=std::max ( std::max ( (maxToNel (pos[0])-pTile->Center).norm(), (maxToNel (pos[1])-pTile->Center).norm() ), std::max ( (maxToNel (pos[2])-pTile->Center).norm(), (maxToNel (pos[3])-pTile->Center).norm() ) @@ -3721,7 +3720,7 @@ void EPM_PaintCMode::DoPaint () { std::string error = NLMISC::toString("Invalid edge '%i' with value '%i' in patch '%i' in PatchMesh", p, mYedge, e); nlwarning(error.c_str()); - MessageBox(NULL, error.c_str(), "NeL Patch Painter", MB_OK | MB_ICONSTOP); + MessageBox(NULL, utf8ToTStr(error), _T("NeL Patch Painter"), MB_OK | MB_ICONSTOP); return; } #if (MAX_RELEASE < 4000) @@ -3884,8 +3883,8 @@ void EPM_PaintCMode::DoPaint () } if (patchVoisin.patch!=-1) { - std::string first = vectMesh[i].Node->GetName(); - std::string second = vectMesh[patchVoisin.Mesh].Node->GetName(); + std::string first = tStrToUtf8(vectMesh[i].Node->GetName()); + std::string second = tStrToUtf8(vectMesh[patchVoisin.Mesh].Node->GetName()); int rot = (2-((vectMesh[i].Symmetry)?(2-e):e)+((vectMesh[patchVoisin.Mesh].Symmetry)?(2-edgeVoisin):edgeVoisin))&3; int nU = 1 << rpatch->getUIPatch (p).NbTilesU; int nV = 1 << rpatch->getUIPatch (p).NbTilesV; @@ -3959,7 +3958,7 @@ void EPM_PaintCMode::DoPaint () pTile->locked = 0; // Check that neighbor tiles are not frozen - uint neighbor; + uint neighbor; for (neighbor=0; neighbor<4; neighbor++) { // Neighbor exist ? @@ -3979,7 +3978,7 @@ void EPM_PaintCMode::DoPaint () std::string sName=GetBankPathName (); - if (sName!="") + if (!sName.empty()) { CIFile file; if (file.open (sName)) @@ -3990,9 +3989,9 @@ void EPM_PaintCMode::DoPaint () bank.serial (file); bank.computeXRef (); } - catch (EStream& stream) + catch (const EStream& stream) { - MessageBox (NULL, stream.what(), "Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(stream.what()), _T("Error"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -4010,7 +4009,7 @@ void EPM_PaintCMode::DoPaint () pData->pobj=pobj; pData->center=center; pData->T=t; - + myThread (pData); // Do it without thread // Invalidate all objects @@ -4035,7 +4034,7 @@ void EPM_PaintCMode::DoPaint () patchData->SetFlag(EPD_BEENDONE, TRUE); } - theHold.Accept("Patch change"); + theHold.Accept(_M("Patch change")); nodes.DisposeTemporary(); pobj->ClearPatchDataFlag(mcList, EPD_BEENDONE); @@ -4058,38 +4057,34 @@ bool loadLigoConfigFile (CLigoConfig& config, Interface& it) if (hModule) { // Get the path - char sModulePath[256]; + TCHAR sModulePath[256]; int res=GetModuleFileName(hModule, sModulePath, 256); // Success ? if (res) { // Path - char sDrive[256]; - char sDir[256]; - _splitpath (sModulePath, sDrive, sDir, NULL, NULL); - _makepath (sModulePath, sDrive, sDir, "ligoscape", ".cfg"); + std::string modulePath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)); + try { // Load the config file - config.readConfigFile (sModulePath, false); + config.readConfigFile (modulePath, false); // ok return true; } - catch (Exception& e) + catch (const Exception& e) { // Print an error message - char msg[512]; - smprintf (msg, 512, "Error loading the config file ligoscape.cfg: %s", e.what()); - nlwarning (msg); + nlwarning("Error loading the config file ligoscape.cfg: %s", e.what()); } } } // Can't found the module return false; } - + DWORD WINAPI myThread (LPVOID vData) -{ +{ // Mega try try { @@ -4100,10 +4095,13 @@ DWORD WINAPI myThread (LPVOID vData) nlassert (pData->eproc->ip); // Viewport parameters - ViewExp* vp; Matrix3 affineTM; float minx,maxx,miny,maxy; - vp=pData->eproc->ip->GetActiveViewport(); +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vp = &pData->eproc->ip->GetActiveViewExp(); +#else + ViewExp *vp = pData->eproc->ip->GetActiveViewport(); +#endif vp->GetAffineTM(affineTM); if ( vp->IsPerspView() ) { @@ -4111,7 +4109,7 @@ DWORD WINAPI myThread (LPVOID vData) } // The scene - + // Loaf cfg files LoadKeyCfg (); LoadVarCfg (); @@ -4157,7 +4155,7 @@ DWORD WINAPI myThread (LPVOID vData) { // Build skined ? bool skined=false; - + // Export the shape IShape *pShape; pShape=export_.buildShape (*pNode, pData->T, NULL, true); @@ -4195,7 +4193,7 @@ DWORD WINAPI myThread (LPVOID vData) CMatrix mat; mat.identity(); CVector I,J,K,P; - + Matrix3 matInvert; matInvert.SetRow (0, Point3(1.f, 0.f, 0.f)); matInvert.SetRow (1, Point3(0.f, 0.f, 1.f)); @@ -4261,9 +4259,8 @@ DWORD WINAPI myThread (LPVOID vData) } else { - char message[512]; - smprintf (message, 512, "Can't build the zone named %s", pData->VectMesh[i].Node->GetName()); - MessageBox (pData->eproc->ip->GetMAXHWnd(), message, "NeL Painter", MB_OK|MB_ICONEXCLAMATION); + std::string message = toString("Can't build the zone named %s", tStrToUtf8(pData->VectMesh[i].Node->GetName()).c_str()); + MessageBox (pData->eproc->ip->GetMAXHWnd(), utf8ToTStr(message), _T("NeL Painter"), MB_OK|MB_ICONEXCLAMATION); } } @@ -4278,7 +4275,7 @@ DWORD WINAPI myThread (LPVOID vData) // Go. //======== CEvent3dMouseListener mouseListener; - MouseListener listener (pData->eproc->ip, CNELU::Camera, &viewport, pData->pobj, pData->eproc, &TheLand->Landscape, + MouseListener listener (pData->eproc->ip, CNELU::Camera, &viewport, pData->pobj, pData->eproc, &TheLand->Landscape, &CNELU::AsyncListener, &mouseListener, pData->VectMesh, pData->T); // Mouse listener @@ -4306,7 +4303,7 @@ DWORD WINAPI myThread (LPVOID vData) { // For all the tileset selected for (sint tss=0; tss<(sint)tileSetSelector.getTileCount (); tss++) - { + { // Get the tileset index sint ts=tileSetSelector.getTileSet (tss); @@ -4363,16 +4360,16 @@ DWORD WINAPI myThread (LPVOID vData) //======== CNELU::release(); } - catch (EDru& druExcept) + catch (const EDru& druExcept) { - MessageBox (NULL, druExcept.what(), "NeL driver utility", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(druExcept.what()), _T("NeL driver utility"), MB_OK|MB_ICONEXCLAMATION); } delete pData; } - catch (Exception& e) + catch (const Exception& e) { - MessageBox (NULL, e.what(), "NeL Painter", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(e.what()), _T("NeL Painter"), MB_OK|MB_ICONEXCLAMATION); } return 0; @@ -4437,7 +4434,7 @@ BOOL EPM_PaintMouseProc::HitATile(ViewExp *vpt, IPoint2 *p, int *tile, int *mesh return FALSE; } -BOOL EPM_PaintMouseProc::HitATile(const CViewport& viewport, const CCamera& camera, float x, float y, int *tile, int *mesh, TimeValue t, +BOOL EPM_PaintMouseProc::HitATile(const CViewport& viewport, const CCamera& camera, float x, float y, int *tile, int *mesh, TimeValue t, std::vector& vectMesh, NLMISC::CVector& hit, NLMISC::CVector &topVector) { // Get a world ray with the mouse 2d point @@ -4584,13 +4581,17 @@ bool EPM_PaintTile::intersect (const Ray& ray, std::vector& vectMesh, /*-------------------------------------------------------------------*/ int EPM_PaintMouseProc::proc( - HWND hwnd, - int msg, - int point, - int flags, + HWND hwnd, + int msg, + int point, + int flags, IPoint2 m) { - ViewExp *vpt = ip->GetViewport(hwnd); +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hwnd); +#else + ViewExp *vpt = ip->GetViewport(hwnd); +#endif int res = TRUE; static PatchMesh *shape1 = NULL; static int poly1, tile1, tile2, mesh1, mesh2, seg1; @@ -4610,17 +4611,19 @@ int EPM_PaintMouseProc::proc( case MOUSE_MOVE: break; - + case MOUSE_FREEMOVE: break; - + case MOUSE_ABORT: ip->SetStdCommandMode(CID_OBJMOVE); break; } +#if MAX_VERSION_MAJOR < 19 if (vpt) ip->ReleaseViewport(vpt); +#endif return res; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_main.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_main.cpp index a4c22cbaf..a05fc67b7 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_main.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_main.cpp @@ -47,8 +47,7 @@ void PaintPatchMod::BeginEditParams(IObjParam *ip, ULONG flags, Animatable *prev CreatePatchDataTempData(); - hOpsPanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_OPS), - PatchOpsDlgProc, "Geometry", (LPARAM) this, rsOps ? 0 : APPENDROLL_CLOSED); + hOpsPanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_OPS), PatchOpsDlgProc, _M("Geometry"), (LPARAM) this, rsOps ? 0 : APPENDROLL_CLOSED); // Create sub object editing modes. paintMode = new EPM_PaintCMode(this, ip); diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_rollup.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_rollup.cpp index 0b4714090..e225adaa4 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_rollup.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_rollup.cpp @@ -28,13 +28,13 @@ extern void LoadImages(); // ------------------------------------------------------------------------------------------------------------------------------------------------------ -void PaintPatchMod::SetOpsDlgEnables() +void PaintPatchMod::SetOpsDlgEnables() { if (!hOpsPanel) return; - + nlassert(ip); - + ICustButton *but; but = GetICustButton(GetDlgItem(hOpsPanel, IDC_PAINT)); @@ -52,12 +52,12 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM switch (message) { - case WM_INITDIALOG: + case WM_INITDIALOG: { ep =(PaintPatchMod *)lParam; ep->hOpsPanel = hDlg; - SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)ep); + SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)ep); CheckDlgButton(hDlg, IDC_INCLUDE_MESHES, ep->includeMeshes); CheckDlgButton(hDlg, IDC_PRELOAD_TILES, ep->preloadTiles); @@ -65,15 +65,9 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM return TRUE; } - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - ep->ip->RollupMouseMessage(hDlg, message, wParam, lParam); - return FALSE; - - case WM_COMMAND: + case WM_COMMAND: switch (LOWORD(wParam)) - { + { case IDC_INCLUDE_MESHES: { BOOL bCheck=(IsDlgButtonChecked(hDlg, IDC_INCLUDE_MESHES)==BST_CHECKED); @@ -92,7 +86,7 @@ INT_PTR CALLBACK PatchOpsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM } break; } - + return FALSE; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp index b8503c137..59b7897db 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp @@ -7,7 +7,7 @@ #include "nel/3d/texture_mem.h" #include "nel/misc/config_file.h" -#define REGKEY_EDIT_PATCH "Software\\Nevrax\\Ryzom\\edit_patch" +#define REGKEY_EDIT_PATCH _T("Software\\Nevrax\\Ryzom\\edit_patch") /*-------------------------------------------------------------------*/ @@ -168,7 +168,7 @@ void CTileSetCont::build (CTileBank& bank, uint tileSet) std::string fileName=bank.getAbsPath()+bank.getTile (set->getTile128(0))->getRelativeFileName (CTile::diffuse); // Valid name? - if (fileName!="") + if (!fileName.empty()) { // Create it MainBitmap=new CTextureFile (fileName); @@ -193,7 +193,7 @@ void CTileSetCont::build (CTileBank& bank, uint tileSet) std::string fileName=bank.getAbsPath()+pTile->getRelativeFileName (CTile::diffuse); // Valid name? - if (fileName!="") + if (!fileName.empty()) { // Create it if (GroupBitmap[group]==NULL) @@ -218,7 +218,7 @@ void CTileSetCont::build (CTileBank& bank, uint tileSet) std::string fileName=bank.getAbsPath()+pTile->getRelativeFileName (CTile::diffuse); // Valid name? - if (fileName!="") + if (!fileName.empty()) { // Create it if (GroupBitmap[group]==NULL) @@ -242,7 +242,7 @@ void CTileSetCont::build (CTileBank& bank, uint tileSet) if (!dmwarn) { dmwarn = true; - MessageBox(NULL, "Tile bank not loaded, or bad tile bank. Missing a displacement tile. Use the tile bank utility to load the correct tilebank.", "NeL Patch Paint", MB_OK | MB_ICONWARNING); + MessageBox(NULL, _T("Tile bank not loaded, or bad tile bank. Missing a displacement tile. Use the tile bank utility to load the correct tilebank."), _T("NeL Patch Paint"), MB_OK | MB_ICONWARNING); } continue; // with next displace } @@ -250,10 +250,10 @@ void CTileSetCont::build (CTileBank& bank, uint tileSet) // Get the name std::string fileName = bank.getDisplacementMap(dispTile); if (fileName=="EmptyDisplacementMap") - fileName=""; + fileName.clear(); // Valid name? - if (fileName!="") + if (!fileName.empty()) { // Create it DisplaceBitmap[displace]=new CTextureFile (bank.getAbsPath()+fileName); @@ -318,9 +318,8 @@ void getColors (COLORREF *array) { DWORD len=4; DWORD type; - char regName[100]; - smprintf (regName, 100, "Color%d", i); - RegQueryValueEx (hKey, regName, 0, &type, (LPBYTE)(array+i), &len); + std::string regName = toString("Color%u", i); + RegQueryValueEx (hKey, utf8ToTStr(regName), 0, &type, (LPBYTE)(array+i), &len); } RegCloseKey (hKey); } @@ -337,9 +336,8 @@ void setColors (const COLORREF *array) for (uint i=0; i<16; i++) { DWORD len=4; - char regName[100]; - smprintf (regName, 100, "Color%d", i); - RegSetValueEx (hKey, regName, 0, REG_DWORD, (LPBYTE)(array+i), 4); + std::string regName = toString("Color%u", i); + RegSetValueEx (hKey, utf8ToTStr(regName), 0, REG_DWORD, (LPBYTE)(array+i), 4); } RegCloseKey (hKey); } @@ -409,24 +407,17 @@ void LoadKeyCfg () HMODULE hModule = hInstance; if (hModule) { - char sModulePath[256]; + TCHAR sModulePath[256]; int res=GetModuleFileName(hModule, sModulePath, 256); if (res) { - // split path - char drive[256]; - char dir[256]; - _splitpath (sModulePath, drive, dir, NULL, NULL); - // Make a new path - char cgfPath[256]; - _makepath (cgfPath, drive, dir, "keys", ".cfg"); - + std::string cfgPath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)) + "keys.cfg"; CConfigFile cf; // Load and parse "test.txt" file - cf.load (cgfPath); + cf.load (cfgPath); // For each keys for (uint key=0; keygetDisplay(), msg, "NeL Painter", MB_OK|MB_ICONEXCLAMATION); + std::string msg = toString("Can't open the file %s.", brushFileName.c_str()); + MessageBox ((HWND)CNELU::Driver->getDisplay(), utf8ToTStr(msg), _T("NeL Painter"), MB_OK|MB_ICONEXCLAMATION); // Return false return false; } } - catch (Exception &e) + catch (const Exception &e) { // Error message - MessageBox ((HWND)CNELU::Driver->getDisplay(), e.what(), "NeL Painter", MB_OK|MB_ICONEXCLAMATION); + MessageBox ((HWND)CNELU::Driver->getDisplay(), utf8ToTStr(e.what()), _T("NeL Painter"), MB_OK|MB_ICONEXCLAMATION); // Return false return false; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_vcolor.h b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_vcolor.h index 594d0f5bb..204b36d47 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_vcolor.h +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_vcolor.h @@ -81,7 +81,7 @@ public: } // Load a brush - bool loadBrush (const char *brushFileName); + bool loadBrush (const std::string &brushFileName); private: diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/CMakeLists.txt b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/CMakeLists.txt index 9c4f6deb2..dc5b6a284 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/CMakeLists.txt +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/CMakeLists.txt @@ -19,4 +19,6 @@ NL_DEFAULT_PROPS(nel_vertex_tree_paint "MAX Plugin: NeL Vertex Tree Painter") NL_ADD_RUNTIME_FLAGS(nel_vertex_tree_paint) NL_ADD_LIB_SUFFIX(nel_vertex_tree_paint) +ADD_DEFINITIONS(${MAXSDK_DEFINITIONS}) + INSTALL(TARGETS nel_vertex_tree_paint RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/Paint.cpp b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/Paint.cpp index 37b1b891b..241037218 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/Paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/Paint.cpp @@ -103,7 +103,11 @@ void PaintMouseProc::DoPainting(HWND hWnd, IPoint2 m) } VertexPaintData* d = (VertexPaintData*)mc->localData; +#if MAX_VERSION_MAJOR >= 19 + ViewExp* pView = &GetCOREInterface()->GetViewExp(hWnd); +#else ViewExp* pView = GetCOREInterface()->GetViewport(hWnd); +#endif Mesh* mesh = d->GetMesh(); if (mesh) { @@ -158,7 +162,9 @@ void PaintMouseProc::DoPainting(HWND hWnd, IPoint2 m) } } +#if MAX_VERSION_MAJOR < 19 GetCOREInterface()->ReleaseViewport(pView); +#endif } else { SetCursor(hNoPaintCursor); @@ -186,7 +192,11 @@ void PaintMouseProc::DoPickColor(HWND hWnd, IPoint2 m) SetCursor(hDropperCursor); TriObject *pTri = (TriObject *) os.obj; +#if MAX_VERSION_MAJOR >= 19 + ViewExp* pView = &GetCOREInterface()->GetViewExp(hWnd); +#else ViewExp* pView = GetCOREInterface()->GetViewport(hWnd); +#endif Mesh* mesh = &pTri->mesh; if (mesh) { @@ -234,7 +244,9 @@ void PaintMouseProc::DoPickColor(HWND hWnd, IPoint2 m) } } +#if MAX_VERSION_MAJOR < 19 GetCOREInterface()->ReleaseViewport(pView); +#endif } } else { diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp index a2465ba4c..664ec0868 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp @@ -2,11 +2,11 @@ *< FILE: vertex_tree_paint.cpp - DESCRIPTION: Modifier implementation + DESCRIPTION: Modifier implementation CREATED BY: Christer Janson, Nikolai Sander - HISTORY: + HISTORY: *> Copyright (c) 1997, All Rights Reserved. **********************************************************************/ @@ -14,19 +14,20 @@ #include "vertex_tree_paint.h" #include "meshdelta.h" -// flags: + // flags: #define VP_DISP_END_RESULT 0x01 static WNDPROC colorSwatchOriginalWndProc; static HIMAGELIST hButtonImages = NULL; -static void LoadImages() { +static void LoadImages() +{ if (hButtonImages) return; HBITMAP hBitmap, hMask; hButtonImages = ImageList_Create(15, 14, ILC_MASK, 2, 0); // 17 is kluge to center square. -SA - hBitmap = LoadBitmap (hInstance,MAKEINTRESOURCE(IDB_BUTTONS)); - hMask = LoadBitmap (hInstance,MAKEINTRESOURCE(IDB_BUTTON_MASK)); + hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTTONS)); + hMask = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTTON_MASK)); ImageList_Add(hButtonImages, hBitmap, hMask); DeleteObject(hBitmap); DeleteObject(hMask); @@ -35,282 +36,284 @@ static void LoadImages() { ClassDesc* GetVertexPaintDesc(); -class VertexPaintClassDesc:public ClassDesc { - public: - int IsPublic() {return 1;} - void * Create(BOOL loading = FALSE){return new VertexPaint();} - const TCHAR * ClassName() {return GetString(IDS_CLASS_NAME);} - SClass_ID SuperClassID() {return OSM_CLASS_ID;} - Class_ID ClassID() {return VERTEX_TREE_PAINT_CLASS_ID;} - const TCHAR* Category() {return GetString(IDS_CATEGORY);} +class VertexPaintClassDesc :public ClassDesc +{ +public: + int IsPublic() { return 1; } + void * Create(BOOL loading = FALSE) { return new VertexPaint(); } + const MCHAR * ClassName() { return GetString(IDS_CLASS_NAME); } + SClass_ID SuperClassID() { return OSM_CLASS_ID; } + Class_ID ClassID() { return VERTEX_TREE_PAINT_CLASS_ID; } + const MCHAR* Category() { return GetString(IDS_CATEGORY); } void ResetClassParams(BOOL fileReset) {} - }; +}; static VertexPaintClassDesc VertexPaintDesc; -ClassDesc* GetVertexPaintDesc() {return &VertexPaintDesc;} +ClassDesc* GetVertexPaintDesc() { return &VertexPaintDesc; } -static INT_PTR CALLBACK VertexPaintDlgProc( - HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) - { +static INT_PTR CALLBACK VertexPaintDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ int numPoints; - VertexPaint *mod = (VertexPaint*)GetWindowLongPtr(hWnd,GWLP_USERDATA); - if (!mod && msg!=WM_INITDIALOG) return FALSE; + VertexPaint *mod = (VertexPaint*)GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (!mod && msg != WM_INITDIALOG) return FALSE; int comboResult; - + // Manages Spinners. - if (((msg==CC_SPINNER_BUTTONUP) && HIWORD(wParam)) || - ((msg==CC_SPINNER_CHANGE) )) + if (((msg == CC_SPINNER_BUTTONUP) && HIWORD(wParam)) || + ((msg == CC_SPINNER_CHANGE))) { ISpinnerControl *spin; - spin = (ISpinnerControl *) lParam; - - switch (LOWORD(wParam)) + spin = (ISpinnerControl *)lParam; + + switch (LOWORD(wParam)) { case IDC_TINT_SPIN: if ((msg == CC_SPINNER_CHANGE)) { - mod->fTint = spin->GetFVal()/100; + mod->fTint = spin->GetFVal() / 100; } break; case IDC_BEND_SPIN: if ((msg == CC_SPINNER_CHANGE)) { - mod->fGradientBend = spin->GetFVal()/100; + mod->fGradientBend = spin->GetFVal() / 100; } break; } } - switch (msg) { - case WM_INITDIALOG: - LoadImages(); - mod = (VertexPaint*)lParam; - SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam); - mod->hParams = hWnd; - mod->iPaintButton = GetICustButton(GetDlgItem(hWnd, IDC_PAINT)); - mod->iPaintButton->SetType(CBT_CHECK); - mod->iPaintButton->SetHighlightColor(GREEN_WASH); - mod->iPaintButton->SetCheck(mod->ip->GetCommandMode()->ID() == CID_PAINT && - !((PaintMouseProc *)mod->ip->GetCommandMode()->MouseProc(&numPoints))->GetPickMode()); - mod->iPaintButton->SetImage(hButtonImages,0,0,0,0,15,14); - mod->iPaintButton->SetTooltip (TRUE, GetString (IDS_PAINT)); + switch (msg) + { + case WM_INITDIALOG: + LoadImages(); + mod = (VertexPaint*)lParam; + SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam); + mod->hParams = hWnd; + mod->iPaintButton = GetICustButton(GetDlgItem(hWnd, IDC_PAINT)); + mod->iPaintButton->SetType(CBT_CHECK); + mod->iPaintButton->SetHighlightColor(GREEN_WASH); + mod->iPaintButton->SetCheck(mod->ip->GetCommandMode()->ID() == CID_PAINT && + !((PaintMouseProc *)mod->ip->GetCommandMode()->MouseProc(&numPoints))->GetPickMode()); + mod->iPaintButton->SetImage(hButtonImages, 0, 0, 0, 0, 15, 14); + mod->iPaintButton->SetTooltip(TRUE, GetString(IDS_PAINT)); - mod->iPickButton = GetICustButton(GetDlgItem(hWnd, IDC_PICK)); - mod->iPickButton->SetType(CBT_CHECK); - mod->iPickButton->SetHighlightColor(GREEN_WASH); - mod->iPickButton->SetCheck(mod->ip->GetCommandMode()->ID() == CID_PAINT && - ((PaintMouseProc *)mod->ip->GetCommandMode()->MouseProc(&numPoints))->GetPickMode()); - mod->iPickButton->SetImage(hButtonImages,1,1,1,1,15,14); - mod->iPickButton->SetTooltip (TRUE, GetString (IDS_PICK)); + mod->iPickButton = GetICustButton(GetDlgItem(hWnd, IDC_PICK)); + mod->iPickButton->SetType(CBT_CHECK); + mod->iPickButton->SetHighlightColor(GREEN_WASH); + mod->iPickButton->SetCheck(mod->ip->GetCommandMode()->ID() == CID_PAINT && + ((PaintMouseProc *)mod->ip->GetCommandMode()->MouseProc(&numPoints))->GetPickMode()); + mod->iPickButton->SetImage(hButtonImages, 1, 1, 1, 1, 15, 14); + mod->iPickButton->SetTooltip(TRUE, GetString(IDS_PICK)); - mod->iColor = GetIColorSwatch(GetDlgItem(hWnd, IDC_COLOR)); - // change current Color according to editMode - mod->reloadBkupColor(); + mod->iColor = GetIColorSwatch(GetDlgItem(hWnd, IDC_COLOR)); + // change current Color according to editMode + mod->reloadBkupColor(); - // Get interface For ZGradient, reload bkuped colors - mod->iColorGradient[0] = GetIColorSwatch(GetDlgItem(hWnd, IDC_PALETTE_GRAD0)); - mod->iColorGradient[1] = GetIColorSwatch(GetDlgItem(hWnd, IDC_PALETTE_GRAD1)); - mod->iColorGradient[0]->SetColor(mod->lastGradientColor[0]); - mod->iColorGradient[1]->SetColor(mod->lastGradientColor[1]); + // Get interface For ZGradient, reload bkuped colors + mod->iColorGradient[0] = GetIColorSwatch(GetDlgItem(hWnd, IDC_PALETTE_GRAD0)); + mod->iColorGradient[1] = GetIColorSwatch(GetDlgItem(hWnd, IDC_PALETTE_GRAD1)); + mod->iColorGradient[0]->SetColor(mod->lastGradientColor[0]); + mod->iColorGradient[1]->SetColor(mod->lastGradientColor[1]); - - // Init comboBox - SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Tree Weight"); - SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Phase Level 1"); - SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Phase Level 2"); - SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_SETCURSEL, mod->getEditionType(), 0); - // If paint mode at last edit. - if(mod->_LastPaintMode) - { - // ActivatePaint / check button. - mod->ActivatePaint(TRUE); - mod->iPaintButton->SetCheck(TRUE); - } + // Init comboBox + SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("Tree Weight")); + SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("Phase Level 1")); + SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("Phase Level 2")); + SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_SETCURSEL, mod->getEditionType(), 0); - break; - - case WM_POSTINIT: - mod->InitPalettes(); - break; - - case CC_COLOR_CHANGE: - if (LOWORD(wParam) == IDC_COLOR) - { - IColorSwatch* iCol = (IColorSwatch*)lParam; - switch(mod->getEditionType()) - { - case 0: mod->lastWeightColor = iCol->GetColor(); break; - case 1: - case 2: - mod->lastPhaseColor = iCol->GetColor(); break; - } - } - break; - case WM_DESTROY: - mod->SavePalettes(); - mod->iPaintButton = NULL; - mod->iPickButton = NULL; - mod->iColor = NULL; - mod->iColorGradient[0] = NULL; - mod->iColorGradient[1] = NULL; - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDC_PAINT: - mod->ActivatePaint(mod->iPaintButton->IsChecked()); - break; - case IDC_PICK: - mod->ActivatePaint(mod->iPickButton->IsChecked(),TRUE); - break; - - case IDC_VC_ON: - mod->TurnVCOn(FALSE); - break; - case IDC_SHADED: - mod->TurnVCOn(TRUE); - break; - case IDC_COMBO_TYPE: - // Init default type. - comboResult= SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0); - mod->setEditionType(comboResult); - break; - case IDC_BUTTON_FILL: - mod->fillSelectionColor(); - break; - case IDC_BUTTON_GRADIENT: - mod->fillSelectionGradientColor(); - break; - case IDC_BUTTON_GRAD0: - mod->iColorGradient[0]->SetColor(RGB(0,0,0)); - mod->iColorGradient[1]->SetColor(RGB(85,85,85)); - break; - case IDC_BUTTON_GRAD1: - mod->iColorGradient[0]->SetColor(RGB(85,85,85)); - mod->iColorGradient[1]->SetColor(RGB(170,170,170)); - break; - case IDC_BUTTON_GRAD2: - mod->iColorGradient[0]->SetColor(RGB(170,170,170)); - mod->iColorGradient[1]->SetColor(RGB(255,255,255)); - break; - } - break; - - default: - return FALSE; + // If paint mode at last edit. + if (mod->_LastPaintMode) + { + // ActivatePaint / check button. + mod->ActivatePaint(TRUE); + mod->iPaintButton->SetCheck(TRUE); } + + break; + + case WM_POSTINIT: + mod->InitPalettes(); + break; + + case CC_COLOR_CHANGE: + if (LOWORD(wParam) == IDC_COLOR) + { + IColorSwatch* iCol = (IColorSwatch*)lParam; + switch (mod->getEditionType()) + { + case 0: mod->lastWeightColor = iCol->GetColor(); break; + case 1: + case 2: + mod->lastPhaseColor = iCol->GetColor(); break; + } + } + break; + case WM_DESTROY: + mod->SavePalettes(); + mod->iPaintButton = NULL; + mod->iPickButton = NULL; + mod->iColor = NULL; + mod->iColorGradient[0] = NULL; + mod->iColorGradient[1] = NULL; + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_PAINT: + mod->ActivatePaint(mod->iPaintButton->IsChecked()); + break; + case IDC_PICK: + mod->ActivatePaint(mod->iPickButton->IsChecked(), TRUE); + break; + + case IDC_VC_ON: + mod->TurnVCOn(FALSE); + break; + case IDC_SHADED: + mod->TurnVCOn(TRUE); + break; + case IDC_COMBO_TYPE: + // Init default type. + comboResult = SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0); + mod->setEditionType(comboResult); + break; + case IDC_BUTTON_FILL: + mod->fillSelectionColor(); + break; + case IDC_BUTTON_GRADIENT: + mod->fillSelectionGradientColor(); + break; + case IDC_BUTTON_GRAD0: + mod->iColorGradient[0]->SetColor(RGB(0, 0, 0)); + mod->iColorGradient[1]->SetColor(RGB(85, 85, 85)); + break; + case IDC_BUTTON_GRAD1: + mod->iColorGradient[0]->SetColor(RGB(85, 85, 85)); + mod->iColorGradient[1]->SetColor(RGB(170, 170, 170)); + break; + case IDC_BUTTON_GRAD2: + mod->iColorGradient[0]->SetColor(RGB(170, 170, 170)); + mod->iColorGradient[1]->SetColor(RGB(255, 255, 255)); + break; + } + break; + + default: + return FALSE; + } return TRUE; - } +} // Subclass procedure -LRESULT APIENTRY colorSwatchSubclassWndProc( - HWND hwnd, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) +LRESULT APIENTRY colorSwatchSubclassWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_LBUTTONDBLCLK: { - HWND hPanel = GetParent(hwnd); - LONG_PTR mod = GetWindowLongPtr(hPanel,GWLP_USERDATA); - if (mod) { - ((VertexPaint*)mod)->PaletteButton(hwnd); - } - } - break; - case WM_DESTROY: - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) colorSwatchOriginalWndProc); - // Fallthrough... - default: - return CallWindowProc(colorSwatchOriginalWndProc, hwnd, uMsg, wParam, lParam); - break; + switch (uMsg) + { + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + case WM_LBUTTONDBLCLK: + { + HWND hPanel = GetParent(hwnd); + LONG_PTR mod = GetWindowLongPtr(hPanel, GWLP_USERDATA); + if (mod) + { + ((VertexPaint*)mod)->PaletteButton(hwnd); } - return 0; } - + break; + case WM_DESTROY: + SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)colorSwatchOriginalWndProc); + // Fallthrough... + default: + return CallWindowProc(colorSwatchOriginalWndProc, hwnd, uMsg, wParam, lParam); + break; + } + return 0; +} -IObjParam *VertexPaint::ip = NULL; -HWND VertexPaint::hParams = NULL; -VertexPaint* VertexPaint::editMod = NULL; -ICustButton* VertexPaint::iPaintButton = NULL; -ICustButton* VertexPaint::iPickButton = NULL; -IColorSwatch* VertexPaint::iColor = NULL; -COLORREF VertexPaint::lastWeightColor = RGB(85,85,85); -COLORREF VertexPaint::lastPhaseColor = RGB(0,0,0); -COLORREF VertexPaint::palColors[] = { + +IObjParam *VertexPaint::ip = NULL; +HWND VertexPaint::hParams = NULL; +VertexPaint* VertexPaint::editMod = NULL; +ICustButton* VertexPaint::iPaintButton = NULL; +ICustButton* VertexPaint::iPickButton = NULL; +IColorSwatch* VertexPaint::iColor = NULL; +COLORREF VertexPaint::lastWeightColor = RGB(85, 85, 85); +COLORREF VertexPaint::lastPhaseColor = RGB(0, 0, 0); +COLORREF VertexPaint::palColors[] = +{ //RGB(32, 32, 32), RGB( 96,96,96), RGB( 160,160,160), RGB(224,224,224) }; - RGB(0, 0, 0), RGB( 85,85,85), RGB( 170,170,170), RGB(255,255,255), - RGB(42, 42, 42), RGB( 127, 127, 127), RGB( 212, 212, 212)}; + RGB(0, 0, 0), RGB(85,85,85), RGB(170,170,170), RGB(255,255,255), + RGB(42, 42, 42), RGB(127, 127, 127), RGB(212, 212, 212) }; -IColorSwatch* VertexPaint::iColorGradient[]= {NULL, NULL}; -COLORREF VertexPaint::lastGradientColor[] = {RGB(0, 0, 0), RGB(85, 85, 85)}; +IColorSwatch* VertexPaint::iColorGradient[] = { NULL, NULL }; +COLORREF VertexPaint::lastGradientColor[] = { RGB(0, 0, 0), RGB(85, 85, 85) }; //--- VertexPaint ------------------------------------------------------- VertexPaint::VertexPaint() : iTint(NULL), fTint(1.0f), iGradientBend(NULL), fGradientBend(0.0f) - { +{ flags = 0x0; - _EditType= 0; - _LastPaintMode= false; - } + _EditType = 0; + _LastPaintMode = false; +} VertexPaint::~VertexPaint() - { - } +{ +} Interval VertexPaint::LocalValidity(TimeValue t) - { +{ return FOREVER; - } +} BOOL VertexPaint::DependOnTopology(ModContext &mc) - { +{ return TRUE; - } +} RefTargetHandle VertexPaint::Clone(RemapDir& remap) - { - VertexPaint* newmod = new VertexPaint(); +{ + VertexPaint* newmod = new VertexPaint(); return(newmod); - } +} void VertexPaint::NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc) - { +{ if (!mc->localData) return; ((VertexPaintData*)mc->localData)->FreeCache(); - } +} -void VertexPaint::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *node) - { +void VertexPaint::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *node) +{ if (!os->obj->IsSubClassOf(triObjectClassID)) return; - - os->obj->ReadyChannelsForMod(GEOM_CHANNEL|TOPO_CHANNEL|VERTCOLOR_CHANNEL|TEXMAP_CHANNEL); - + + os->obj->ReadyChannelsForMod(GEOM_CHANNEL | TOPO_CHANNEL | VERTCOLOR_CHANNEL | TEXMAP_CHANNEL); + TriObject *tobj = (TriObject*)os->obj; - VertexPaintData *d = (VertexPaintData*)mc.localData; - + VertexPaintData *d = (VertexPaintData*)mc.localData; + Mesh* mesh = &tobj->GetMesh(); - - if (mesh) + + if (mesh) { // We don't have any VColors yet, so we allocate the vcfaces // and set all vcolors to black (index 0) - if (!mesh->vcFace) + if (!mesh->vcFace) { mesh->setNumVCFaces(mesh->getNumFaces()); mesh->setNumVertCol(1); - - mesh->vertCol[0] = Color(0,0,0); - for (int f=0; fgetNumFaces(); f++) + mesh->vertCol[0] = Color(0, 0, 0); + + for (int f = 0; f < mesh->getNumFaces(); f++) { mesh->vcFace[f].t[0] = 0; mesh->vcFace[f].t[1] = 0; @@ -318,10 +321,10 @@ void VertexPaint::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, IN } } - if (!d) mc.localData = d = new VertexPaintData(tobj->GetMesh()); - if (!d->GetMesh()) d->SetCache(*mesh); + if (!d) mc.localData = d = new VertexPaintData(tobj->GetMesh()); + if (!d->GetMesh()) d->SetCache(*mesh); + - { MeshDelta md(*mesh); //MeshDelta mdc; @@ -330,141 +333,139 @@ void VertexPaint::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, IN // If the incoming Mesh had no vertex colors, this will add a default map to start with. // The default map has the same topology as the Mesh (so one color per vertex), // with all colors set to white. - if (!mesh->mapSupport(0)) md.AddVertexColors (); + if (!mesh->mapSupport(0)) md.AddVertexColors(); //if (cache && !cache->mapSupport(0)) mdc.AddVertexColors (); - + // We used two routines -- VCreate to add new map vertices, and FRemap to make the // existing map faces use the new verts. frFlags tell FRemap which vertices on a face // should be "remapped", and the ww array contains the new locations. VertColor nvc; int j; - for (int v=0; v < d->GetNumColors(); v++) + for (int v = 0; v < d->GetNumColors(); v++) { ColorData cd = d->GetColorData(v); - + // Edition Mode ?? - if(editMod == this) + if (editMod == this) { - nvc= Color(cd.color); + nvc = Color(cd.color); // change color to view only monochromatic info for this channel; - switch(_EditType) + switch (_EditType) { - case 0: nvc.y= nvc.z= nvc.x; - nvc.y*= 0.7f; - nvc.z*= 0.7f; + case 0: nvc.y = nvc.z = nvc.x; + nvc.y *= 0.7f; + nvc.z *= 0.7f; break; - case 1: nvc.x= nvc.z= nvc.y; - nvc.x*= 0.7f; - nvc.z*= 0.7f; + case 1: nvc.x = nvc.z = nvc.y; + nvc.x *= 0.7f; + nvc.z *= 0.7f; break; - case 2: nvc.x= nvc.y= nvc.z; - nvc.x*= 0.7f; - nvc.y*= 0.7f; + case 2: nvc.x = nvc.y = nvc.z; + nvc.x *= 0.7f; + nvc.y *= 0.7f; break; } } else { // replace the VertexColor of the outgoing mesh - nvc= Color(cd.color); + nvc = Color(cd.color); } DWORD ww[3], frFlags; - - md.map->VCreate (&nvc); - + + md.map->VCreate(&nvc); + // increase the number of vcol's and set the vcfaces as well - for(int i = 0 ; i < d->GetNVert(v).faces.Count() ; i++) - { + for (int i = 0; i < d->GetNVert(v).faces.Count(); i++) + { j = d->GetNVert(v).whichVertex[i]; - frFlags = (1<outVNum()-1; + frFlags = (1 << j); + ww[j] = md.map->outVNum() - 1; md.map->FRemap(d->GetNVert(v).faces[i], frFlags, ww); - + } - } + } md.Apply(*mesh); } - + NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); - os->obj->UpdateValidity(VERT_COLOR_CHAN_NUM, Interval(t,t)); + os->obj->UpdateValidity(VERT_COLOR_CHAN_NUM, Interval(t, t)); } } static bool oldShowEnd; -void VertexPaint::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev ) - { - +void VertexPaint::BeginEditParams(IObjParam *ip, ULONG flags, Animatable *prev) +{ + this->ip = ip; editMod = this; - if (!hParams) { - hParams = ip->AddRollupPage( - hInstance, - MAKEINTRESOURCE(IDD_PANEL), - VertexPaintDlgProc, - GetString(IDS_PARAMS), - (LPARAM)this); + if (!hParams) + { + hParams = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_PANEL), VertexPaintDlgProc, GetString(IDS_PARAMS), (LPARAM)this); // Subclass the palette controls - hPaletteWnd[ 0] = GetDlgItem(hParams, IDC_PALETTE_1); - hPaletteWnd[ 1] = GetDlgItem(hParams, IDC_PALETTE_2); - hPaletteWnd[ 2] = GetDlgItem(hParams, IDC_PALETTE_3); - hPaletteWnd[ 3] = GetDlgItem(hParams, IDC_PALETTE_4); - hPaletteWnd[ 4] = GetDlgItem(hParams, IDC_PALETTE_5); - hPaletteWnd[ 5] = GetDlgItem(hParams, IDC_PALETTE_6); - hPaletteWnd[ 6] = GetDlgItem(hParams, IDC_PALETTE_7); + hPaletteWnd[0] = GetDlgItem(hParams, IDC_PALETTE_1); + hPaletteWnd[1] = GetDlgItem(hParams, IDC_PALETTE_2); + hPaletteWnd[2] = GetDlgItem(hParams, IDC_PALETTE_3); + hPaletteWnd[3] = GetDlgItem(hParams, IDC_PALETTE_4); + hPaletteWnd[4] = GetDlgItem(hParams, IDC_PALETTE_5); + hPaletteWnd[5] = GetDlgItem(hParams, IDC_PALETTE_6); + hPaletteWnd[6] = GetDlgItem(hParams, IDC_PALETTE_7); int i; - for (i=0; iGetShowEndResult() ? TRUE : FALSE; - ip->SetShowEndResult (GetFlag (VP_DISP_END_RESULT)); + ip->SetShowEndResult(GetFlag(VP_DISP_END_RESULT)); // Force an eval to update caches. NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); } -void VertexPaint::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next) - { +void VertexPaint::EndEditParams(IObjParam *ip, ULONG flags, Animatable *next) +{ // Dsiable Painting. - bool lpm= _LastPaintMode; + bool lpm = _LastPaintMode; ActivatePaint(FALSE); // bkup lastPainMode - _LastPaintMode= lpm; - - ReleaseISpinner (iTint); - ReleaseISpinner (iGradientBend); - + _LastPaintMode = lpm; + + ReleaseISpinner(iTint); + ReleaseISpinner(iGradientBend); + ModContextList list; INodeTab nodes; - ip->GetModContexts(list,nodes); - for (int i=0; iGetModContexts(list, nodes); + for (int i = 0; i < list.Count(); i++) + { VertexPaintData *vd = (VertexPaintData*)list[i]->localData; if (vd) vd->FreeCache(); } nodes.DisposeTemporary(); // Reset show end result - SetFlag (VP_DISP_END_RESULT, ip->GetShowEndResult() ? TRUE : FALSE); + SetFlag(VP_DISP_END_RESULT, ip->GetShowEndResult() ? TRUE : FALSE); ip->SetShowEndResult(oldShowEnd); @@ -476,47 +477,45 @@ void VertexPaint::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next) ip->DeleteRollupPage(hParams); hParams = NULL; iTint = NULL; - iGradientBend= NULL; + iGradientBend = NULL; this->ip = NULL; - } +} //From ReferenceMaker -RefResult VertexPaint::NotifyRefChanged( - Interval changeInt, RefTargetHandle hTarget, - PartID& partID, RefMessage message) - { +RefResult VertexPaint::NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate) +{ return REF_SUCCEED; - } +} -int VertexPaint::NumRefs() - { +int VertexPaint::NumRefs() +{ return 0; - } +} -RefTargetHandle VertexPaint::GetReference(int i) - { +RefTargetHandle VertexPaint::GetReference(int i) +{ return NULL; - } +} void VertexPaint::SetReference(int i, RefTargetHandle rtarg) - { - } +{ +} -int VertexPaint::NumSubs() - { +int VertexPaint::NumSubs() +{ return 0; - } +} -Animatable* VertexPaint::SubAnim(int i) - { - return NULL; - } +Animatable* VertexPaint::SubAnim(int i) +{ + return NULL; +} -TSTR VertexPaint::SubAnimName(int i) - { +TSTR VertexPaint::SubAnimName(int i) +{ return _T(""); - } +} #define VERSION_CHUNKID 0x100 @@ -525,66 +524,70 @@ TSTR VertexPaint::SubAnimName(int i) static int currentVersion = 1; IOResult VertexPaint::Load(ILoad *iload) - { +{ IOResult res; ULONG nb; int version = 1; Modifier::Load(iload); - while (IO_OK==(res=iload->OpenChunk())) { - switch(iload->CurChunkID()) { - case VERSION_CHUNKID: - iload->Read (&version, sizeof(version), &nb); - break; - } - iload->CloseChunk(); - if (res!=IO_OK) return res; + while (IO_OK == (res = iload->OpenChunk())) + { + switch (iload->CurChunkID()) + { + case VERSION_CHUNKID: + iload->Read(&version, sizeof(version), &nb); + break; } - - return IO_OK; + iload->CloseChunk(); + if (res != IO_OK) return res; } + return IO_OK; +} + IOResult VertexPaint::Save(ISave *isave) - { +{ IOResult res; ULONG nb; Modifier::Save(isave); isave->BeginChunk(VERSION_CHUNKID); - res = isave->Write (¤tVersion, sizeof(int), &nb); + res = isave->Write(¤tVersion, sizeof(int), &nb); isave->EndChunk(); return IO_OK; - } +} IOResult VertexPaint::SaveLocalData(ISave *isave, LocalModData *ld) - { +{ VertexPaintData* d = (VertexPaintData*)ld; IOResult res; ULONG nb; int numColors; ColorData col; - + isave->BeginChunk(VERSION_CHUNKID); - res = isave->Write (¤tVersion, sizeof(int), &nb); + res = isave->Write(¤tVersion, sizeof(int), &nb); isave->EndChunk(); - + isave->BeginChunk(COLORLIST_CHUNKID); numColors = d->GetNumColors(); res = isave->Write(&numColors, sizeof(int), &nb); - for (int i=0; iGetColorData(i); - isave->Write(&col.color,sizeof(col.color),&nb); - } + isave->Write(&col.color, sizeof(col.color), &nb); + } isave->EndChunk(); return IO_OK; - } +} -IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld) { +IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld) +{ VertexPaintData *d = new VertexPaintData; - IOResult res; + IOResult res; ULONG nb; int version = 1; int numColors; @@ -592,74 +595,80 @@ IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld) { *pld = d; - while (IO_OK==(res=iload->OpenChunk())) { - switch(iload->CurChunkID()) { + while (IO_OK == (res = iload->OpenChunk())) + { + switch (iload->CurChunkID()) + { case VERSION_CHUNKID: - iload->Read (&version, sizeof(version), &nb); - break; + iload->Read(&version, sizeof(version), &nb); + break; case COLORLIST_CHUNKID: - { - iload->Read(&numColors,sizeof(int), &nb); - d->AllocColorData(numColors); - for (int i=0; iRead(&col.color,sizeof(col.color), &nb); - d->SetColor(i, col); - } - } - break; + { + iload->Read(&numColors, sizeof(int), &nb); + d->AllocColorData(numColors); + for (int i = 0; i < numColors; i++) + { + iload->Read(&col.color, sizeof(col.color), &nb); + d->SetColor(i, col); } - iload->CloseChunk(); - if (res!=IO_OK) return res; } - return IO_OK; + break; + } + iload->CloseChunk(); + if (res != IO_OK) return res; } + return IO_OK; +} void VertexPaint::PaletteButton(HWND hWnd) - { +{ IColorSwatch* iPal = GetIColorSwatch(hWnd); - if (iPal && iColor) { + if (iPal && iColor) + { iColor->SetColor(iPal->GetColor(), TRUE); - } } +} void VertexPaint::InitPalettes() - { +{ IColorSwatch* c; - for (int i=0; iSetColor(palColors[i]); ReleaseIColorSwatch(c); - } } +} void VertexPaint::SavePalettes() - { +{ IColorSwatch* c; - for (int i=0; iGetColor(); ReleaseIColorSwatch(c); - } - // Save Gradient Palettes. - lastGradientColor[0]= iColorGradient[0]->GetColor(); - lastGradientColor[1]= iColorGradient[1]->GetColor(); } + // Save Gradient Palettes. + lastGradientColor[0] = iColorGradient[0]->GetColor(); + lastGradientColor[1] = iColorGradient[1]->GetColor(); +} void VertexPaint::TurnVCOn(BOOL shaded) { ModContextList list; INodeTab NodeTab; - - // Only the selected nodes will be affected - ip->GetModContexts(list,NodeTab); - for( int i = 0 ; i < NodeTab.Count() ; i++) + // Only the selected nodes will be affected + ip->GetModContexts(list, NodeTab); + + for (int i = 0; i < NodeTab.Count(); i++) { - if(shaded) + if (shaded) NodeTab[i]->SetShadeCVerts(!NodeTab[i]->GetShadeCVerts()); else - NodeTab[i]->SetCVertMode(!NodeTab[i]->GetCVertMode()); - + NodeTab[i]->SetCVertMode(!NodeTab[i]->GetCVertMode()); + } NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); ip->RedrawViews(ip->GetTime()); @@ -669,37 +678,37 @@ void VertexPaint::TurnVCOn(BOOL shaded) // ***************************************************************** void VertexPaint::setEditionType(int editMode) { - if(editMode<0) editMode= 0; - if(editMode>2) editMode= 2; + if (editMode < 0) editMode = 0; + if (editMode > 2) editMode = 2; // backup current Color according to editMode backupCurrentColor(); - _EditType= editMode; + _EditType = editMode; NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); ip->RedrawViews(ip->GetTime()); // Change Color Swatch according to editMode. IColorSwatch* c; - for (int i=0; i=4) + if (i >= 4) { - if(editMode==0) - val= 42 + (i-4)*255 / (4-1); // 42, 127, 212 + if (editMode == 0) + val = 42 + (i - 4) * 255 / (4 - 1); // 42, 127, 212 else - val= 0; // Phase not used + val = 0; // Phase not used } // Setup Color - palColors[i]= RGB(val, val, val); + palColors[i] = RGB(val, val, val); c = GetIColorSwatch(hPaletteWnd[i]); @@ -714,7 +723,7 @@ void VertexPaint::setEditionType(int editMode) // ***************************************************************** void VertexPaint::backupCurrentColor() { - switch(getEditionType()) + switch (getEditionType()) { case 0: lastWeightColor = iColor->GetColor(); break; case 1: @@ -724,10 +733,10 @@ void VertexPaint::backupCurrentColor() void VertexPaint::reloadBkupColor() { // Change current color according to editMode. - switch(getEditionType()) + switch (getEditionType()) { case 0: iColor->SetColor(lastWeightColor); break; - case 1: + case 1: case 2: iColor->SetColor(lastPhaseColor); break; } } @@ -739,18 +748,18 @@ void VertexPaint::fillSelectionColor() int mci; // Put Data in Undo/Redo List. - if(!theHold.Holding()) + if (!theHold.Holding()) theHold.Begin(); - + ModContextList modContexts; INodeTab nodeTab; - + GetCOREInterface()->GetModContexts(modContexts, nodeTab); - - for (mci=0; mcilocalData) + if (mc && mc->localData) theHold.Put(new VertexPaintRestore((VertexPaintData*)mc->localData, this)); } @@ -759,42 +768,42 @@ void VertexPaint::fillSelectionColor() // Which Component to change?? VertexPaintData::TComponent whichComponent; - switch(getEditionType()) + switch (getEditionType()) { - case 0: whichComponent= VertexPaintData::Red; break; - case 1: whichComponent= VertexPaintData::Green; break; - case 2: whichComponent= VertexPaintData::Blue; break; + case 0: whichComponent = VertexPaintData::Red; break; + case 1: whichComponent = VertexPaintData::Green; break; + case 2: whichComponent = VertexPaintData::Blue; break; } // Modify all meshes. - for (mci=0; mcilocalData) + if (mc && mc->localData) { VertexPaintData* d = (VertexPaintData*)mc->localData; - Mesh* mesh = d->GetMesh(); - if (mesh && mesh->vertCol) + Mesh* mesh = d->GetMesh(); + if (mesh && mesh->vertCol) { // For all faces of the mesh - for(int fi=0; figetNumFaces(); fi++) + for (int fi = 0; fi < mesh->getNumFaces(); fi++) { Face* f = &mesh->faces[fi]; - for (int i=0; i<3; i++) + for (int i = 0; i < 3; i++) { // Skip painting because not selected?? - if(mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]] ) + if (mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]]) continue; - if(mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) + if (mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) continue; // Also skip if face is hidden. - if(f->Hidden()) + if (f->Hidden()) continue; // Apply painting - d->SetColor(f->v[i], 1, GetActiveColor(), whichComponent); + d->SetColor(f->v[i], 1, GetActiveColor(), whichComponent); } } } @@ -812,18 +821,18 @@ void VertexPaint::fillSelectionGradientColor() int mci; // Put Data in Undo/Redo List. - if(!theHold.Holding()) + if (!theHold.Holding()) theHold.Begin(); - + ModContextList modContexts; INodeTab nodeTab; - + GetCOREInterface()->GetModContexts(modContexts, nodeTab); - - for (mci=0; mcilocalData) + if (mc && mc->localData) theHold.Put(new VertexPaintRestore((VertexPaintData*)mc->localData, this)); } @@ -832,93 +841,100 @@ void VertexPaint::fillSelectionGradientColor() // Which Component to change?? VertexPaintData::TComponent whichComponent; - switch(getEditionType()) + switch (getEditionType()) { - case 0: whichComponent= VertexPaintData::Red; break; - case 1: whichComponent= VertexPaintData::Green; break; - case 2: whichComponent= VertexPaintData::Blue; break; + case 0: whichComponent = VertexPaintData::Red; break; + case 1: whichComponent = VertexPaintData::Green; break; + case 2: whichComponent = VertexPaintData::Blue; break; } - COLORREF grad0= iColorGradient[0]->GetColor(); - COLORREF grad1= iColorGradient[1]->GetColor(); + COLORREF grad0 = iColorGradient[0]->GetColor(); + COLORREF grad1 = iColorGradient[1]->GetColor(); // Get Matrix to viewport. Matrix3 viewMat; { +#if MAX_VERSION_MAJOR >= 19 + ViewExp *ve = &GetCOREInterface()->GetActiveViewExp(); +#else ViewExp *ve = GetCOREInterface()->GetActiveViewport(); +#endif // The affine TM transforms from world coords to view coords ve->GetAffineTM(viewMat); + +#if MAX_VERSION_MAJOR < 19 GetCOREInterface()->ReleaseViewport(ve); +#endif } // Modify all meshes. - for (mci=0; mcilocalData) + if (mc && mc->localData) { VertexPaintData* d = (VertexPaintData*)mc->localData; - Mesh* mesh = d->GetMesh(); - if (mesh && mesh->vertCol) + Mesh* mesh = d->GetMesh(); + if (mesh && mesh->vertCol) { - float yMini= FLT_MAX; - float yMaxi= -FLT_MAX; + float yMini = FLT_MAX; + float yMaxi = -FLT_MAX; // 1st, For all faces of the mesh, comute BBox of selection. int fi; - for(fi=0; figetNumFaces(); fi++) + for (fi = 0; fi < mesh->getNumFaces(); fi++) { Face* f = &mesh->faces[fi]; - for (int i=0; i<3; i++) + for (int i = 0; i < 3; i++) { // Skip painting because not selected?? - if(mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]] ) + if (mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]]) continue; - if(mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) + if (mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) continue; // Also skip if face is hidden. - if(f->Hidden()) + if (f->Hidden()) continue; // Transform to viewSpace. - Point3 p= viewMat*mesh->getVert(f->v[i]); + Point3 p = viewMat*mesh->getVert(f->v[i]); // extend bbox. - yMini= p.yyMaxi?p.y:yMaxi; + yMini = p.y < yMini ? p.y : yMini; + yMaxi = p.y > yMaxi ? p.y : yMaxi; } } // 2nd, For all faces of the mesh, fill with gradient - for(fi=0; figetNumFaces(); fi++) + for (fi = 0; fi < mesh->getNumFaces(); fi++) { Face* f = &mesh->faces[fi]; - for (int i=0; i<3; i++) + for (int i = 0; i < 3; i++) { // Skip painting because not selected?? - if(mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]] ) + if (mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]]) continue; - if(mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) + if (mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) continue; // Also skip if face is hidden. - if(f->Hidden()) + if (f->Hidden()) continue; // Compute gradientValue. float gradValue; - Point3 p= viewMat*mesh->getVert(f->v[i]); - gradValue= (p.y-yMini)/(yMaxi-yMini); + Point3 p = viewMat*mesh->getVert(f->v[i]); + gradValue = (p.y - yMini) / (yMaxi - yMini); // Modifie with bendPower. 1->6. - float pow= 1 + fGradientBend * 5; - gradValue= powf(gradValue, pow); + float pow = 1 + fGradientBend * 5; + gradValue = powf(gradValue, pow); // Apply painting // Reset To 0. - d->SetColor(f->v[i], 1, grad0, whichComponent); + d->SetColor(f->v[i], 1, grad0, whichComponent); // Blend with gradientValue. - d->SetColor(f->v[i], gradValue, grad1, whichComponent); + d->SetColor(f->v[i], gradValue, grad1, whichComponent); } } @@ -933,34 +949,34 @@ void VertexPaint::fillSelectionGradientColor() // ***************************************************************** -VertexPaintData::VertexPaintData(Mesh& m) : mesh(NULL), colordata(NULL), nverts(NULL), +VertexPaintData::VertexPaintData(Mesh& m) : mesh(NULL), colordata(NULL), nverts(NULL), nvcverts(NULL), numColors(0), numnverts(0), numnvcverts(0) { SetCache(m); } -VertexPaintData::VertexPaintData() : mesh(NULL), colordata(NULL), nverts(NULL), +VertexPaintData::VertexPaintData() : mesh(NULL), colordata(NULL), nverts(NULL), nvcverts(NULL), numColors(0), numnverts(0), numnvcverts(0) { } VertexPaintData::~VertexPaintData() - { +{ FreeCache(); - if (colordata) delete [] colordata; - if(nverts) delete [] nverts; - if(nvcverts) delete [] nvcverts; + if (colordata) delete[] colordata; + if (nverts) delete[] nverts; + if (nvcverts) delete[] nvcverts; nverts = NULL; nvcverts = NULL; colordata = NULL; - + numColors = 0; numnverts = 0; numnvcverts = 0; - } +} void VertexPaintData::SetCache(Mesh& m) { @@ -968,31 +984,31 @@ void VertexPaintData::SetCache(Mesh& m) mesh = new Mesh(m); SynchVerts(m); AllocColorData(mesh->getNumVerts()); - + } void VertexPaintData::FreeCache() - { +{ if (mesh) delete mesh; - if(nverts) delete [] nverts; - if(nvcverts) delete [] nvcverts; + if (nverts) delete[] nverts; + if (nvcverts) delete[] nvcverts; mesh = NULL; nverts = NULL; nvcverts = NULL; numnverts = 0; numnvcverts = 0; - } +} Mesh* VertexPaintData::GetMesh() - { +{ return mesh; - } +} NVert& VertexPaintData::GetNVert(int i) { static NVert nv; - + if (numnverts > i) return nverts[i]; else @@ -1002,7 +1018,7 @@ NVert& VertexPaintData::GetNVert(int i) NVert& VertexPaintData::GetNVCVert(int i) { static NVert nv; - + if (numnvcverts > i) return nvcverts[i]; else @@ -1010,70 +1026,70 @@ NVert& VertexPaintData::GetNVCVert(int i) } COLORREF& VertexPaintData::GetColor(int i) - { - static COLORREF c = RGB(0,0,0); +{ + static COLORREF c = RGB(0, 0, 0); if (numColors > i) return colordata[i].color; else return c; - } +} ColorData& VertexPaintData::GetColorData(int i) - { +{ static ColorData c; if (numColors > i) return colordata[i]; else return c; - } +} void VertexPaintData::SetColor(int i, float bary, COLORREF c, TComponent whichComp) { - - if (colordata && numColors > i) + + if (colordata && numColors > i) { // change color. - COLORREF oldColor= colordata[i].color; + COLORREF oldColor = colordata[i].color; int oldVal; int editVal; int newVal; - + // Mask good component. - switch(whichComp) + switch (whichComp) { case Red: - oldVal= GetRValue(colordata[i].color); - editVal= GetRValue(c); + oldVal = GetRValue(colordata[i].color); + editVal = GetRValue(c); break; case Green: - oldVal= GetGValue(colordata[i].color); - editVal= GetGValue(c); + oldVal = GetGValue(colordata[i].color); + editVal = GetGValue(c); break; case Blue: - oldVal= GetBValue(colordata[i].color); - editVal= GetBValue(c); + oldVal = GetBValue(colordata[i].color); + editVal = GetBValue(c); break; } // Blend Color component // This color was set before ! - float alpha = (1.0f-bary); - + float alpha = (1.0f - bary); + // Compute new value - newVal= (int)(alpha*oldVal + bary*editVal); + newVal = (int)(alpha*oldVal + bary*editVal); // Mask good component. - switch(whichComp) + switch (whichComp) { case Red: - colordata[i].color= (RGB(newVal, 0, 0)) | (oldColor & RGB(0,255,255)); + colordata[i].color = (RGB(newVal, 0, 0)) | (oldColor & RGB(0, 255, 255)); break; case Green: - colordata[i].color= (RGB(0, newVal, 0)) | (oldColor & RGB(255,0,255)); + colordata[i].color = (RGB(0, newVal, 0)) | (oldColor & RGB(255, 0, 255)); break; case Blue: - colordata[i].color= (RGB(0, 0, newVal)) | (oldColor & RGB(255,255,0)); + colordata[i].color = (RGB(0, 0, newVal)) | (oldColor & RGB(255, 255, 0)); break; } @@ -1082,47 +1098,47 @@ void VertexPaintData::SetColor(int i, float bary, COLORREF c, TComponent whichCo void VertexPaintData::SetColor(int i, const ColorData &c) { - if (colordata && numColors > i) + if (colordata && numColors > i) { - colordata[i]= c; + colordata[i] = c; } } int VertexPaintData::GetNumColors() - { +{ return numColors; - } +} void VertexPaintData::AllocColorData(int numcols) - { +{ ColorData* newColorData; // Colors already exist. if (numColors == numcols) return; - - if (numColors > 0 ) + + if (numColors > 0) { // If the new number of colors is bigger than what we have in the colordata array - if(numcols > numColors) + if (numcols > numColors) { // Allocate a new color list and fill in as many as // we have from the previous set newColorData = new ColorData[numcols]; - - for (int i=0; icolordata = new ColorData[numColors]; d->numColors = numColors; - for (int i=0; icolordata[i] = colordata[i]; - } } - if(nverts) + } + if (nverts) { d->nverts = new NVert[numnverts]; - for(int i = 0 ; i < numnverts ; i++ ) { + for (int i = 0; i < numnverts; i++) + { d->nverts[i] = nverts[i]; } } - if(nvcverts) + if (nvcverts) { d->nvcverts = new NVert[numnvcverts]; - for(int i = 0 ; i < numnvcverts ; i++ ) { + for (int i = 0; i < numnvcverts; i++) + { d->nvcverts[i] = nvcverts[i]; } } return d; - } - +} void VertexPaintData::SynchVerts(Mesh &m) { @@ -1177,47 +1196,47 @@ void VertexPaintData::SynchVerts(Mesh &m) return; } - if(nverts) - delete [] nverts; - + if (nverts) + delete[] nverts; + numnverts = m.getNumVerts(); - + nverts = new NVert[numnverts]; - if(nvcverts) - delete [] nvcverts; - + if (nvcverts) + delete[] nvcverts; + numnvcverts = m.getNumVertCol(); nvcverts = new NVert[numnvcverts]; - - for(int i = 0 ; i < mesh->getNumFaces() ; i++) - { + + for (int i = 0; i < mesh->getNumFaces(); i++) + { // for each vertex of each face - for(int j = 0 ; j < 3 ; j++) - { + for (int j = 0; j < 3; j++) + { int iCur = nverts[mesh->faces[i].v[j]].faces.Count(); - + // Tell the vertex, which to which face it belongs and which // of the three face v-indices corresponds to the vertex - - nverts[mesh->faces[i].v[j]].faces.SetCount(iCur+1); - nverts[mesh->faces[i].v[j]].whichVertex.SetCount(iCur+1); + + nverts[mesh->faces[i].v[j]].faces.SetCount(iCur + 1); + nverts[mesh->faces[i].v[j]].whichVertex.SetCount(iCur + 1); nverts[mesh->faces[i].v[j]].faces[iCur] = i; nverts[mesh->faces[i].v[j]].whichVertex[iCur] = j; - - - if(mesh->vcFace) + + + if (mesh->vcFace) { // Do the same for texture vertices - iCur = nvcverts[mesh->vcFace[i].t[j]].faces.Count(); - - nvcverts[mesh->vcFace[i].t[j]].faces.SetCount(iCur+1); - nvcverts[mesh->vcFace[i].t[j]].whichVertex.SetCount(iCur+1); - - nvcverts[mesh->vcFace[i].t[j]].faces[iCur] = i; - nvcverts[mesh->vcFace[i].t[j]].whichVertex[iCur] = j; + iCur = nvcverts[mesh->vcFace[i].t[j]].faces.Count(); + + nvcverts[mesh->vcFace[i].t[j]].faces.SetCount(iCur + 1); + nvcverts[mesh->vcFace[i].t[j]].whichVertex.SetCount(iCur + 1); + + nvcverts[mesh->vcFace[i].t[j]].faces[iCur] = i; + nvcverts[mesh->vcFace[i].t[j]].whichVertex[iCur] = j; } else @@ -1269,11 +1288,11 @@ ColorData::ColorData() : color(0) //** //*************************************************************************** -VertexPaintRestore::VertexPaintRestore(VertexPaintData *pLocalData, VertexPaint *pVPaint) -: pMod(pVPaint), pPaintData(pLocalData), redoColordata(NULL) +VertexPaintRestore::VertexPaintRestore(VertexPaintData *pLocalData, VertexPaint *pVPaint) + : pMod(pVPaint), pPaintData(pLocalData), redoColordata(NULL) { colordata = new ColorData[pPaintData->numColors]; - for(int i = 0; i < pPaintData->numColors ; i++) + for (int i = 0; i < pPaintData->numColors; i++) { colordata[i] = pPaintData->colordata[i]; } @@ -1283,16 +1302,16 @@ VertexPaintRestore::VertexPaintRestore(VertexPaintData *pLocalData, VertexPaint VertexPaintRestore::~VertexPaintRestore() { - if(colordata) - delete [] colordata; - - if(redoColordata) - delete [] redoColordata; + if (colordata) + delete[] colordata; + + if (redoColordata) + delete[] redoColordata; } void VertexPaintRestore::Restore(int isUndo) { - if(isUndo) + if (isUndo) { nlassert(pPaintData->colordata); @@ -1303,7 +1322,7 @@ void VertexPaintRestore::Restore(int isUndo) pPaintData->numColors = numcolors; colordata = NULL; - + pMod->NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); GetCOREInterface()->RedrawViews(GetCOREInterface()->GetTime()); } @@ -1312,28 +1331,28 @@ void VertexPaintRestore::Restore(int isUndo) void VertexPaintRestore::Redo() { nlassert(pPaintData->colordata); - + colordata = pPaintData->colordata; numcolors = pPaintData->numColors; - + pPaintData->colordata = redoColordata; pPaintData->numColors = redonumcolors; - + redoColordata = NULL; pMod->NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); GetCOREInterface()->RedrawViews(GetCOREInterface()->GetTime()); - + } int VertexPaintRestore::Size() { int iSize = 0; - - if(colordata) + + if (colordata) iSize += sizeof(ColorData) * numcolors; - - if(redoColordata) + + if (redoColordata) iSize += sizeof(ColorData) * redonumcolors; return iSize; diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.h b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.h index 510828754..7c751899e 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.h +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.h @@ -131,7 +131,7 @@ public: void GetClassName(TSTR& s) { s= TSTR(GetString(IDS_CLASS_NAME)); } virtual Class_ID ClassID() { return VERTEX_TREE_PAINT_CLASS_ID;} RefTargetHandle Clone(RemapDir& remap = DefaultRemapDir()); - TCHAR *GetObjectName() { return GetString(IDS_CLASS_NAME); } + const MCHAR *GetObjectName() { return GetString(IDS_CLASS_NAME); } IOResult Load(ILoad *iload); IOResult Save(ISave *isave); IOResult LoadLocalData(ILoad *iload, LocalModData **pld); @@ -161,9 +161,7 @@ public: Animatable* SubAnim(int i); TSTR SubAnimName(int i); - RefResult NotifyRefChanged( Interval changeInt,RefTargetHandle hTarget, - PartID& partID, RefMessage message); - + RefResult NotifyRefChanged(const Interval& changeInt,RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate); CreateMouseCallBack* GetCreateMouseCallBack() {return NULL;} void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev); diff --git a/code/nel/tools/3d/plugin_max/scripts/nel_assets_png_batched.ms b/code/nel/tools/3d/plugin_max/scripts/nel_assets_png_batched.ms index 7a4783027..cb6c339c8 100644 --- a/code/nel/tools/3d/plugin_max/scripts/nel_assets_png_batched.ms +++ b/code/nel/tools/3d/plugin_max/scripts/nel_assets_png_batched.ms @@ -322,7 +322,7 @@ rollout assets_png_rollout "Properties" -- To use this script -- Include it in your script into the rollout at the beginning. -- Implement a do_it function to do the job in your rollout. - -- The function should retun -1 if an arror occured, else the count of modification done + -- The function should retun -1 if an arror occurred, else the count of modification done -- It the function returns <1, the project will not be overwritten Group "Running properties" diff --git a/code/nel/tools/3d/plugin_max/scripts/nel_assets_ps_batched.ms b/code/nel/tools/3d/plugin_max/scripts/nel_assets_ps_batched.ms index f8165e25e..c4bc56800 100644 --- a/code/nel/tools/3d/plugin_max/scripts/nel_assets_ps_batched.ms +++ b/code/nel/tools/3d/plugin_max/scripts/nel_assets_ps_batched.ms @@ -105,7 +105,7 @@ rollout assets_ps_rollout "Properties" -- To use this script -- Include it in your script into the rollout at the beginning. -- Implement a do_it function to do the job in your rollout. - -- The function should retun -1 if an arror occured, else the count of modification done + -- The function should retun -1 if an arror occurred, else the count of modification done -- It the function returns <1, the project will not be overwritten Group "Running properties" diff --git a/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave.ms b/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave.ms index ab9e45325..dcd8fde63 100644 --- a/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave.ms +++ b/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave.ms @@ -46,7 +46,7 @@ rollout assets_resave_rollout "Properties" -- To use this script -- Include it in your script into the rollout at the beginning. -- Implement a do_it function to do the job in your rollout. - -- The function should retun -1 if an arror occured, else the count of modification done + -- The function should retun -1 if an arror occurred, else the count of modification done -- It the function returns <1, the project will not be overwritten Group "Running properties" diff --git a/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave_hard.ms b/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave_hard.ms index 05220c7a5..50bd4efe9 100644 --- a/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave_hard.ms +++ b/code/nel/tools/3d/plugin_max/scripts/nel_assets_resave_hard.ms @@ -46,7 +46,7 @@ rollout assets_resave_rollout "Properties" -- To use this script -- Include it in your script into the rollout at the beginning. -- Implement a do_it function to do the job in your rollout. - -- The function should retun -1 if an arror occured, else the count of modification done + -- The function should retun -1 if an arror occurred, else the count of modification done -- It the function returns <1, the project will not be overwritten Group "Running properties" diff --git a/code/nel/tools/3d/plugin_max/scripts/nel_batched_mergesave.ms b/code/nel/tools/3d/plugin_max/scripts/nel_batched_mergesave.ms index cbf17a097..511056bff 100644 --- a/code/nel/tools/3d/plugin_max/scripts/nel_batched_mergesave.ms +++ b/code/nel/tools/3d/plugin_max/scripts/nel_batched_mergesave.ms @@ -3,7 +3,7 @@ -- To use this script -- Include it in your script into the rollout at the beginning. -- Implement a do_it function to do the job in your rollout. --- The function should retun -1 if an arror occured, else the count of modification done +-- The function should retun -1 if an arror occurred, else the count of modification done -- It the function returns <1, the project will not be overwritten Group "Running properties" diff --git a/code/nel/tools/3d/plugin_max/scripts/nel_batched_script.ms b/code/nel/tools/3d/plugin_max/scripts/nel_batched_script.ms index 628aa916b..be53ce06f 100644 --- a/code/nel/tools/3d/plugin_max/scripts/nel_batched_script.ms +++ b/code/nel/tools/3d/plugin_max/scripts/nel_batched_script.ms @@ -3,7 +3,7 @@ -- To use this script -- Include it in your script into the rollout at the beginning. -- Implement a do_it function to do the job in your rollout. --- The function should retun -1 if an arror occured, else the count of modification done +-- The function should retun -1 if an arror occurred, else the count of modification done -- It the function returns <1, the project will not be overwritten Group "Running properties" diff --git a/code/nel/tools/3d/plugin_max/tile_utility/CMakeLists.txt b/code/nel/tools/3d/plugin_max/tile_utility/CMakeLists.txt index 7f0122cda..1ea546e38 100644 --- a/code/nel/tools/3d/plugin_max/tile_utility/CMakeLists.txt +++ b/code/nel/tools/3d/plugin_max/tile_utility/CMakeLists.txt @@ -18,4 +18,6 @@ NL_DEFAULT_PROPS(tile_utility "MAX Plugin: Tile Utility") NL_ADD_RUNTIME_FLAGS(tile_utility) NL_ADD_LIB_SUFFIX(tile_utility) +ADD_DEFINITIONS(${MAXSDK_DEFINITIONS}) + INSTALL(TARGETS tile_utility RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) diff --git a/code/nel/tools/3d/plugin_max/tile_utility/rgbadd.cpp b/code/nel/tools/3d/plugin_max/tile_utility/rgbadd.cpp index c798f83e2..5f512b88e 100644 --- a/code/nel/tools/3d/plugin_max/tile_utility/rgbadd.cpp +++ b/code/nel/tools/3d/plugin_max/tile_utility/rgbadd.cpp @@ -70,8 +70,8 @@ class RGBAdd: public Texmap { Class_ID ClassID() { return RGBAddClassID; } SClass_ID SuperClassID() { return TEXMAP_CLASS_ID; } - void GetClassName(TSTR& s) { s= "RGB Additive"; } - void DeleteThis() { delete this; } + void GetClassName(TSTR& s) { s= _T("RGB Additive"); } + void DeleteThis() { delete this; } int NumSubs() { return NSUBTEX+1; } Animatable* SubAnim(int i); @@ -85,8 +85,7 @@ class RGBAdd: public Texmap { int RemapRefOnLoad(int iref); RefTargetHandle Clone(RemapDir &remap = DefaultRemapDir()); - RefResult NotifyRefChanged( Interval changeInt, RefTargetHandle hTarget, - PartID& partID, RefMessage message ); + RefResult NotifyRefChanged(const Interval &changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate); // IO IOResult Save(ISave *isave); @@ -107,10 +106,10 @@ class RGBAddClassDesc:public ClassDesc2 { const TCHAR * ClassName() { return GetString(IDS_DS_RGBMULT_CDESC); } // mjm - 2.3.99 SClass_ID SuperClassID() { return TEXMAP_CLASS_ID; } Class_ID ClassID() { return RGBAddClassID; } - const TCHAR* Category() { return TEXMAP_CAT_COMP; } + const MCHAR* Category() { return TEXMAP_CAT_COMP; } // JBW: new descriptor data accessors added. Note that the // internal name is hardwired since it must not be localized. - const TCHAR* InternalName() { return _T("RGBAdd"); } // returns fixed parsable name (scripter-visible name) + const MCHAR* InternalName() { return _M("RGBAdd"); } // returns fixed parsable name (scripter-visible name) HINSTANCE HInstance() { return hInstance; } // returns owning module handle }; @@ -136,36 +135,36 @@ static ParamBlockDesc2 RGBAdd_param_blk ( RGBAdd_params, _T("parameters"), 0, & RGBAdd_color1, _T("color1"), TYPE_RGBA, P_ANIMATABLE, IDS_DS_COLOR1, p_default, Color(0,0,0), p_ui, TYPE_COLORSWATCH, IDC_MULT_COL1, - end, + p_end, RGBAdd_color2, _T("color2"), TYPE_RGBA, P_ANIMATABLE, IDS_DS_COLOR2, p_default, Color(0.5,0.5,0.5), p_ui, TYPE_COLORSWATCH, IDC_MULT_COL2, - end, + p_end, RGBAdd_map1, _T("map1"), TYPE_TEXMAP, P_OWNERS_REF, IDS_JW_MAP1, p_refno, 1, p_subtexno, 0, p_ui, TYPE_TEXMAPBUTTON, IDC_MULT_TEX1, - end, + p_end, RGBAdd_map2, _T("map2"), TYPE_TEXMAP, P_OWNERS_REF, IDS_JW_MAP2, p_refno, 2, p_subtexno, 1, p_ui, TYPE_TEXMAPBUTTON, IDC_MULT_TEX2, - end, + p_end, RGBAdd_map1_on, _T("map1Enabled"), TYPE_BOOL, 0, IDS_JW_MAP1ENABLE, p_default, TRUE, p_ui, TYPE_SINGLECHEKBOX, IDC_MAPON1, - end, + p_end, RGBAdd_map2_on, _T("map2Enabled"), TYPE_BOOL, 0, IDS_JW_MAP2ENABLE, p_default, TRUE, p_ui, TYPE_SINGLECHEKBOX, IDC_MAPON2, - end, + p_end, RGBAdd_type, _T("alphaFrom"), TYPE_INT, 0, IDS_PW_ALPHAFROM, p_default, 2, p_range, 0, 2, p_ui, TYPE_RADIO, 3, IDC_MULT_ALPHA1, IDC_MULT_ALPHA2, IDC_MULT_ALPHA3, - end, + p_end, - end + p_end ); @@ -365,25 +364,26 @@ TSTR RGBAdd::SubAnimName(int i) { } } -RefResult RGBAdd::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, - PartID& partID, RefMessage message ) { - switch (message) { +RefResult RGBAdd::NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate) +{ + switch (message) + { case REFMSG_CHANGE: ivalid.SetEmpty(); if (hTarget == pblock) - { - // see if this message came from a changing parameter in the pblock, - // if so, limit rollout update to the changing item and update any active viewport texture + { + // see if this message came from a changing parameter in the pblock, + // if so, limit rollout update to the changing item and update any active viewport texture ParamID changing_param = pblock->LastNotifyParamID(); RGBAdd_param_blk.InvalidateUI(changing_param); - // notify our dependents that we've changed + // notify our dependents that we've changed // NotifyChanged(); //DS this is redundant - } + } break; - } - return(REF_SUCCEED); } + return(REF_SUCCEED); +} #define MTL_HDR_CHUNK 0x4000 diff --git a/code/nel/tools/3d/plugin_max/tile_utility/tile_utility.cpp b/code/nel/tools/3d/plugin_max/tile_utility/tile_utility.cpp index b1e0583e8..893f44eea 100644 --- a/code/nel/tools/3d/plugin_max/tile_utility/tile_utility.cpp +++ b/code/nel/tools/3d/plugin_max/tile_utility/tile_utility.cpp @@ -29,7 +29,7 @@ extern HINSTANCE hInstance; using namespace NLMISC; using namespace NL3D; -class Tile_utility : public UtilityObj +class Tile_utility : public UtilityObj { public: HWND hPanel; @@ -44,8 +44,8 @@ public: void Init(HWND hWnd); void Destroy(HWND hWnd); - - void DeleteThis() { } + + void DeleteThis() { } void Load (const std::string& path); void SetLand (sint land); @@ -55,7 +55,7 @@ public: //Constructor/Destructor Tile_utility(); - ~Tile_utility(); + ~Tile_utility(); }; CTileBank Tile_utility::Bank; @@ -64,19 +64,19 @@ std::string Tile_utility::Path; static Tile_utility theTile_utility; -class Tile_utilityClassDesc:public ClassDesc2 +class Tile_utilityClassDesc:public ClassDesc2 { public: int IsPublic() {return 1;} - void * Create(BOOL loading = FALSE) + void * Create(BOOL loading = FALSE) { return &theTile_utility; } - const TCHAR * ClassName() {return "NeL Tile Bank";} + const TCHAR * ClassName() {return _T("NeL Tile Bank");} SClass_ID SuperClassID() {return UTILITY_CLASS_ID;} Class_ID ClassID() {return TILE_UTILITY_CLASS_ID;} - const TCHAR* Category() {return _T("NeL Tools");} - const TCHAR* InternalName() { return _T("NeL tile bank utility"); } // returns fixed parsable name (scripter-visible name) + const MCHAR* Category() {return _M("NeL Tools");} + const MCHAR* InternalName() { return _M("NeL tile bank utility"); } // returns fixed parsable name (scripter-visible name) HINSTANCE HInstance() { return hInstance; } // returns owning module handle }; @@ -85,7 +85,7 @@ ClassDesc2* GetTile_utilityDesc() {return &Tile_utilityDesc;} static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) + switch (msg) { case WM_INITDIALOG: { @@ -96,7 +96,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, if (hModule) { // Get module file name - char moduldeFileName[512]; + TCHAR moduldeFileName[512]; if (GetModuleFileName (hModule, moduldeFileName, 512)) { // Get version info size @@ -112,41 +112,41 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, { uint *versionTab; uint versionSize; - if (VerQueryValue (buffer, "\\", (void**)&versionTab, &versionSize)) + if (VerQueryValue (buffer, _T("\\"), (void**)&versionTab, &versionSize)) { // Get the pointer on the structure VS_FIXEDFILEINFO *info=(VS_FIXEDFILEINFO*)versionTab; if (info) { // Setup version number - char version[512]; - sprintf (version, "Version %d.%d.%d.%d", - info->dwFileVersionMS>>16, - info->dwFileVersionMS&0xffff, - info->dwFileVersionLS>>16, + TCHAR version[512]; + _stprintf (version, _T("Version %d.%d.%d.%d"), + info->dwFileVersionMS>>16, + info->dwFileVersionMS&0xffff, + info->dwFileVersionLS>>16, info->dwFileVersionLS&0xffff); SetWindowText (GetDlgItem (hWnd, IDC_VERSION), version); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "VS_FIXEDFILEINFO * is NULL"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("VS_FIXEDFILEINFO * is NULL")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "VerQueryValue failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("VerQueryValue failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetFileVersionInfo failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetFileVersionInfo failed")); // Free the buffer delete [] buffer; } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetFileVersionInfoSize failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetFileVersionInfoSize failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetModuleFileName failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetModuleFileName failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "hInstance NULL"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("hInstance NULL")); theTile_utility.Init(hWnd); @@ -156,19 +156,14 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, // load the sampler dropdown theTile_utility.Destroy(hWnd); break; - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - theTile_utility.ip->RollupMouseMessage(hWnd,msg,wParam,lParam); - break; case WM_COMMAND: { int id = LOWORD(wParam); - switch (id) + switch (id) { case IDC_BANK_PATH: { - static char sPath[256]; + static TCHAR sPath[256]; static bool bFirst=false; if (!bFirst) { @@ -178,7 +173,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, OPENFILENAME ofn; ofn.lStructSize=sizeof (ofn); ofn.hwndOwner=NULL; - ofn.lpstrFilter="Rykol bank files (*.bank)\0*.bank\0All Files (*.*)\0*.*\0"; + ofn.lpstrFilter = _T("Rykol bank files (*.bank)\0*.bank\0All Files (*.*)\0*.*\0"); ofn.lpstrCustomFilter=NULL; ofn.nMaxCustFilter=0; ofn.nFilterIndex=0; @@ -187,7 +182,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, ofn.lpstrFileTitle=NULL; ofn.nMaxFileTitle=NULL; ofn.lpstrInitialDir=NULL; - ofn.lpstrTitle="Choose a bank file"; + ofn.lpstrTitle = _T("Choose a bank file"); ofn.Flags=OFN_ENABLESIZING|OFN_FILEMUSTEXIST; ofn.nFileOffset=0; ofn.nFileExtension=0; @@ -197,7 +192,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, ofn.lpTemplateName=0; if (GetOpenFileName(&ofn)) { - theTile_utility.Load (sPath); + theTile_utility.Load (tStrToUtf8(sPath)); theTile_utility.SetLand (theTile_utility.Land); theTile_utility.SetupUI (); } @@ -223,7 +218,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, case IDC_SETUP: { if (!theTile_utility.SetupMaterial ()) - MessageBox (NULL, "Select some nel patch object..", "Rykol tile", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, _T("Select some nel patch object.."), _T("Rykol tile"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -240,7 +235,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, Tile_utility::Tile_utility() { iu = NULL; - ip = NULL; + ip = NULL; hPanel = NULL; Bank.clear(); Land=0; @@ -252,7 +247,7 @@ Tile_utility::~Tile_utility() } -void Tile_utility::BeginEditParams(Interface *ip,IUtil *iu) +void Tile_utility::BeginEditParams(Interface *ip,IUtil *iu) { this->iu = iu; this->ip = ip; @@ -264,8 +259,8 @@ void Tile_utility::BeginEditParams(Interface *ip,IUtil *iu) 0); SetupUI (); } - -void Tile_utility::EndEditParams(Interface *ip,IUtil *iu) + +void Tile_utility::EndEditParams(Interface *ip,IUtil *iu) { this->iu = NULL; this->ip = NULL; @@ -291,9 +286,8 @@ void Tile_utility::Load (const std::string& path) CIFile file; if (!file.open (path)) { - char tmp[1024]; - sprintf (tmp, "File not found: %s", path); - MessageBox (NULL, tmp, "Error..", MB_OK|MB_ICONEXCLAMATION); + std::string tmp = toString("File not found: %s", path.c_str()); + MessageBox (NULL, utf8ToTStr(tmp), _T("Error.."), MB_OK|MB_ICONEXCLAMATION); } else { @@ -302,11 +296,10 @@ void Tile_utility::Load (const std::string& path) SetBankPathName (path); } } - catch (EStream stream) + catch (const EStream &stream) { - char tmp[1024]; - sprintf (tmp, "Error while loading %s:\n\n%s", path, stream.what()); - MessageBox (NULL, tmp, "Error..", MB_OK|MB_ICONEXCLAMATION); + std::string tmp = toString("Error while loading %s:\n\n%s", path.c_str(), stream.what()); + MessageBox (NULL, utf8ToTStr(tmp), _T("Error.."), MB_OK|MB_ICONEXCLAMATION); } } @@ -321,7 +314,7 @@ void Tile_utility::SetLand (sint land) Land=0; SetBankTileSetSet (Land); } - + void Tile_utility::SetupUI () { // Clear combo box @@ -335,7 +328,7 @@ void Tile_utility::SetupUI () // Enable combo box if (Bank.getLandCount()) EnableWindow (hCombo, TRUE); - else + else EnableWindow (hCombo, FALSE); } @@ -344,7 +337,7 @@ void Tile_utility::SetupUI () std::string name=Bank.getLand(nLand)->getName(); if (hCombo) { - SendMessage (hCombo, CB_INSERTSTRING, -1, (LPARAM) name.c_str()); + SendMessage (hCombo, CB_INSERTSTRING, -1, (LPARAM)utf8ToTStr(name)); } } @@ -368,32 +361,29 @@ void Tile_utility::SetupUI () if (Bank.getLandCount()) { // Button text - char sName[256]; - _splitpath (Path.c_str(), NULL, NULL, sName, NULL); - char *sName2=sName; - if (*sName2) - *sName2=toupper (*sName2); - sName2++; - while (*sName2) + std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(Path)); + + if (!name.empty()) { - *sName2=tolower (*sName2); - sName2++; + std::string upName = toUpper(name); + name[0] = upName[0]; } - SetWindowText (hwnd, sName); + + SetWindowText (hwnd, utf8ToTStr(name)); // Static text - char sTmp[256]; - sprintf (sTmp, "%d diffuse tiles.", Bank.getNumBitmap (CTile::diffuse)); + TCHAR sTmp[256]; + _stprintf (sTmp, _T("%d diffuse tiles."), Bank.getNumBitmap (CTile::diffuse)); SetWindowText (hwndStatic1, sTmp); - sprintf (sTmp, "%d additive tiles.", Bank.getNumBitmap (CTile::additive)); + _stprintf (sTmp, _T("%d additive tiles."), Bank.getNumBitmap (CTile::additive)); SetWindowText (hwndStatic2, sTmp); } else { - SetWindowText (hwnd, "Click to choose a bank.."); - SetWindowText (hwndStatic1, ""); - SetWindowText (hwndStatic2, ""); - SetWindowText (hwndStatic3, ""); + SetWindowText (hwnd, _T("Click to choose a bank..")); + SetWindowText (hwndStatic1, _T("")); + SetWindowText (hwndStatic2, _T("")); + SetWindowText (hwndStatic3, _T("")); } } } @@ -412,7 +402,7 @@ bool Tile_utility::SetupMaterial () const // Multi MultiMtl* multi=NewDefaultMultiMtl(); multi->SetNumSubMtls (Bank.getTileCount()+1); - multi->SetName ("Rykol Bank"); + multi->SetName (_T("Rykol Bank")); // Default mtl Mtl* firstMtl=multi->GetSubMtl (0); @@ -420,7 +410,7 @@ bool Tile_utility::SetupMaterial () const // Mtl param firstMtl->SetDiffuse (Color (0.5f,0.5f,0.5f), t); firstMtl->SetAmbient (Color (0,0,0), t); - firstMtl->SetName ("Rykol Tile Default"); + firstMtl->SetName (_T("Rykol Tile Default")); firstMtl->SetShininess (0.0, t); firstMtl->SetSpecular (Color (0,0,0), t); @@ -439,11 +429,11 @@ bool Tile_utility::SetupMaterial () const // Mtl param mtl->SetDiffuse (Color (1.f,1.f,1.f), t); mtl->SetAmbient (Color (0,0,0), t); - mtl->SetName ("Rykol Tile"); + mtl->SetName (_T("Rykol Tile")); mtl->SetShininess (0.0, t); mtl->SetSpecular (Color (0,0,0), t); - if ((tile->getRelativeFileName(CTile::diffuse)!="")||(tile->getRelativeFileName(CTile::additive)!="")) + if (!tile->getRelativeFileName(CTile::diffuse).empty() || !tile->getRelativeFileName(CTile::additive).empty()) { bActive=true; Texmap* rgb=(Texmap*)GetRGBAddDesc()->Create (FALSE); @@ -452,7 +442,7 @@ bool Tile_utility::SetupMaterial () const mtl->SetSubTexmap (ID_DI, rgb); mtl->SubTexmapOn (ID_DI); - if (tile->getRelativeFileName(CTile::diffuse)!="") + if (!tile->getRelativeFileName(CTile::diffuse).empty()) { // New BitmapTex BitmapTex* tex=NewDefaultBitmapTex(); @@ -461,7 +451,7 @@ bool Tile_utility::SetupMaterial () const tex->SetAlphaSource (ALPHA_NONE); tex->SetAlphaAsMono (FALSE); tex->SetAlphaAsRGB (FALSE); - tex->SetMapName (const_cast((Bank.getAbsPath()+tile->getRelativeFileName(CTile::diffuse)).c_str())); + tex->SetMapName (utf8ToTStr(Bank.getAbsPath() + tile->getRelativeFileName(CTile::diffuse))); // Assign BitmapTex rgb->SetSubTexmap (0, tex); @@ -472,7 +462,7 @@ bool Tile_utility::SetupMaterial () const mtl->NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE); } - if (tile->getRelativeFileName(CTile::additive)!="") + if (!tile->getRelativeFileName(CTile::additive).empty()) { // New BitmapTex BitmapTex* tex=NewDefaultBitmapTex(); @@ -481,7 +471,7 @@ bool Tile_utility::SetupMaterial () const tex->SetAlphaSource (ALPHA_NONE); tex->SetAlphaAsMono (FALSE); tex->SetAlphaAsRGB (FALSE); - tex->SetMapName (const_cast((Bank.getAbsPath()+tile->getRelativeFileName(CTile::additive)).c_str())); + tex->SetMapName (utf8ToTStr(Bank.getAbsPath() + tile->getRelativeFileName(CTile::additive))); // Assign BitmapTex rgb->SetSubTexmap (1, tex); diff --git a/code/nel/tools/3d/s3tc_compressor_lib/CMakeLists.txt b/code/nel/tools/3d/s3tc_compressor_lib/CMakeLists.txt index 4062f6905..48c14fb3b 100644 --- a/code/nel/tools/3d/s3tc_compressor_lib/CMakeLists.txt +++ b/code/nel/tools/3d/s3tc_compressor_lib/CMakeLists.txt @@ -13,4 +13,4 @@ ADD_DEFINITIONS(${SQUISH_DEFINITIONS}) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS s3tc_compressor LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT tools3d) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/tools/3d/shape2obj/main.cpp b/code/nel/tools/3d/shape2obj/main.cpp index 66d9dd6c4..7d106a887 100644 --- a/code/nel/tools/3d/shape2obj/main.cpp +++ b/code/nel/tools/3d/shape2obj/main.cpp @@ -101,7 +101,7 @@ int main(int argc, char* argv[]) // Add the shape shapeMesh = streamShape.getShapePointer(); } - catch (Exception& e) + catch (const Exception& e) { cout << "Error : " << e.what() << endl; diff --git a/code/nel/tools/3d/shapes_exporter/main.cpp b/code/nel/tools/3d/shapes_exporter/main.cpp index 56249e357..a77161849 100644 --- a/code/nel/tools/3d/shapes_exporter/main.cpp +++ b/code/nel/tools/3d/shapes_exporter/main.cpp @@ -292,7 +292,7 @@ sint main(int argc, char **argv) } else { - // an error occured, try to delete directory + // an error occurred, try to delete directory nlwarning("can't export shape"); CFile::deleteDirectory(output_path); } diff --git a/code/nel/tools/3d/shared_widgets/CMakeLists.txt b/code/nel/tools/3d/shared_widgets/CMakeLists.txt index 2ac70dfe6..ff0794d8b 100644 --- a/code/nel/tools/3d/shared_widgets/CMakeLists.txt +++ b/code/nel/tools/3d/shared_widgets/CMakeLists.txt @@ -25,4 +25,4 @@ NL_ADD_RUNTIME_FLAGS(shared_widgets) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) INSTALL(TARGETS shared_widgets LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT tools3d) -ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) +ENDIF() diff --git a/code/nel/tools/3d/textures_tool/CMakeLists.txt b/code/nel/tools/3d/textures_tool/CMakeLists.txt new file mode 100644 index 000000000..203167162 --- /dev/null +++ b/code/nel/tools/3d/textures_tool/CMakeLists.txt @@ -0,0 +1,9 @@ +FILE(GLOB SRC *.cpp *.h) + +ADD_EXECUTABLE(textures_tool ${SRC}) + +TARGET_LINK_LIBRARIES(textures_tool nelmisc) +NL_DEFAULT_PROPS(textures_tool "NeL, Tools, 3D: Textures Tool") +NL_ADD_RUNTIME_FLAGS(textures_tool) + +INSTALL(TARGETS textures_tool RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d) diff --git a/code/nel/tools/3d/textures_tool/main.cpp b/code/nel/tools/3d/textures_tool/main.cpp new file mode 100644 index 000000000..cccb62bee --- /dev/null +++ b/code/nel/tools/3d/textures_tool/main.cpp @@ -0,0 +1,445 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "nel/misc/file.h" +#include "nel/misc/common.h" +#include "nel/misc/bitmap.h" +#include "nel/misc/path.h" +#include "nel/misc/cmd_args.h" +#include "nel/misc/vector_2d.h" +#include "nel/misc/uv.h" +#include "nel/misc/algo.h" + +struct CPoint +{ + CPoint(sint _x, sint _y) :x(_x), y(_y) + { + } + + CPoint operator + (const CPoint &p) const + { + return CPoint(x + p.x, y + p.y); + } + + sint x; + sint y; +}; + +const CPoint Up(0, -1); +const CPoint Down(0, 1); +const CPoint Left(-1, 0); +const CPoint Right(1, 0); + +uint TextureSize = 4096; + +const NLMISC::CRGBA DiscardColor = NLMISC::CRGBA::Red; +const NLMISC::CRGBA KeepColor = NLMISC::CRGBA::Blue; + +typedef std::vector CPoints; + +struct CFace +{ + std::vector indices; +}; + +struct CObject +{ + std::string name; + std::vector textureCoords; + std::vector faces; + + void display() + { + nlinfo("Object %s processed with %u vertices and %u faces", name.c_str(), (uint)textureCoords.size(), (uint)faces.size()); + } +}; + +bool fillPoint(NLMISC::CBitmap &bitmap, sint width, CPoints &points) +{ + if (points.empty()) return false; + + // take last point in queue + CPoint p(points.back()); + points.pop_back(); + + NLMISC::CRGBA c = bitmap.getPixelColor(p.x, p.y); + + if (c == NLMISC::CRGBA::White) + { + // white is used for background + + // replace with color we want to discard + bitmap.setPixelColor(p.x, p.y, DiscardColor); + + uint w = bitmap.getWidth(); + uint h = bitmap.getHeight(); + + // put adjacent pixels in queue to process later + if (p.y > 0) points.push_back(p + Up); + if (p.y < h-1) points.push_back(p + Down); + if (p.x > 0) points.push_back(p + Left); + if (p.x < w-1) points.push_back(p + Right); + } + else if (c == NLMISC::CRGBA::Black) + { + // black is used for vertices + + // increase them by border width + for (sint y = -width; y <= width; ++y) + { + for (sint x = -width; x <= width; ++x) + { + bitmap.setPixelColor(p.x + x, p.y + y, KeepColor); + } + } + } + + return true; +} + +void drawEdge(NLMISC::CBitmap &bitmap, const CObject &object, const CFace &face, uint index0, uint index1) +{ + NLMISC::CUV uv0 = object.textureCoords[face.indices[index0]]; + NLMISC::CUV uv1 = object.textureCoords[face.indices[index1]]; + + std::vector > pixels; + + // draw the triangle with vertices UV coordinates + NLMISC::drawFullLine(uv0.U, uv0.V, uv1.U, uv1.V, pixels); + + // for each pixels, set them to black + for (uint j = 0, jlen = pixels.size(); j < jlen; ++j) + { + bitmap.setPixelColor(pixels[j].first, pixels[j].second, NLMISC::CRGBA::Black); + } +} + +int main(int argc, char **argv) +{ + NLMISC::CApplicationContext applicationContext; + + // Parse Command Line. + //==================== + NLMISC::CCmdArgs args; + + args.setDescription("Textures tool"); + args.addArg("c", "colorize", "color", "Colorize textures using a color (in HTML hexdecimal format like #rrggbb)"); + args.addArg("f", "fill", "color or image", "Fill background part with color or image"); + args.addArg("u", "uvmap", "", "Generate a UV Map texture from OBJ file"); + args.addArg("w", "width", "width of border", "Width of the border to fill (default 0)"); + args.addArg("s", "size", "size of output bitmap", "Width and height of generated bitmap (default 4096)"); + args.addArg("b", "background", "background color", "Color to use to fill background"); + args.addArg("o", "output", "filename", "Output filename"); + args.addAdditionalArg("filename", "File to process", true, true); + + if (!args.parse(argc, argv)) return 1; + + std::string filename = args.getAdditionalArg("filename").front(); + + std::string output = args.haveArg("o") ? args.getArg("o").front() : ""; + + if (args.haveArg("s")) + { + // size of generated bitmap + NLMISC::fromString(args.getArg("s").front(), TextureSize); + } + + if (args.haveArg("c")) + { + // colorize + NLMISC::CIFile file; + + NLMISC::CRGBA color; + color.fromString(args.getArg("c").front()); + + if (file.open(filename)) + { + NLMISC::CBitmap bitmap; + + if (bitmap.load(file)) + { + NLMISC::CObjectVector &pixels = bitmap.getPixels(); + + NLMISC::CRGBA *pRGBA = (NLMISC::CRGBA*)&pixels[0]; + + uint32 size = bitmap.getSize(); + + for (uint j = 0; j < size; ++j) + { + pRGBA->modulateFromColorRGBOnly(*pRGBA, color); + ++pRGBA; + } + + NLMISC::COFile out; + + if (out.open(output)) + { + bitmap.writePNG(out, 24); + } + } + } + } + + if (args.haveArg("f")) + { + // fill areas in a bitmap with another texture or color + + // for example : + // textures_tool -f normal.png -w 2 -b #000000 uvmap.png -o test_normal.png + // will use a copy 1024x1024 texture map on a 4096x4096 UV Map preserving the different areas + + std::string foregroundColorOrFilename = args.getArg("f").front(); + + NLMISC::CRGBA foregroundColor = NLMISC::CRGBA::Black, backgroundColor = NLMISC::CRGBA::Black; + + NLMISC::CBitmap textureBitmap; + + bool useTexture = false; + + // f parameter is required + if (NLMISC::CFile::fileExists(foregroundColorOrFilename)) + { + // load texture + NLMISC::CIFile textureFile; + + if (!textureFile.open(foregroundColorOrFilename)) + { + nlwarning("Unable to open %s", foregroundColorOrFilename.c_str()); + return 1; + } + + // decode texture + if (!textureBitmap.load(textureFile)) + { + nlwarning("Unable to decode %s", foregroundColorOrFilename.c_str()); + return 1; + } + + useTexture = true; + } + else + { + // parse color from argument + foregroundColor.fromString(foregroundColorOrFilename); + } + + if (args.haveArg("b")) + { + // parse HTML color from argument + backgroundColor.fromString(args.getArg("b").front()); + } + + sint width = 0; + + if (args.haveArg("w")) + { + // parse width of borders + NLMISC::fromString(args.getArg("w").front(), width); + } + + // load bitmap + NLMISC::CIFile file; + + if (!file.open(filename)) + { + nlwarning("Unable to open %s", filename.c_str()); + return 1; + } + + // decode bitmap + NLMISC::CBitmap inBitmap; + + if (!inBitmap.load(file)) + { + nlwarning("Unable to decode %s", filename.c_str()); + return 1; + } + + CPoints Points; + + // we can't have more than width * height points, so allocate memory for all of them + Points.reserve(inBitmap.getWidth() * inBitmap.getHeight()); + + // first point to process + Points.push_back(CPoint(0, 0)); + + // process all points from 0, 0 + while(fillPoint(inBitmap, width, Points)) { } + + // create a new bitmap for output + NLMISC::CBitmap outBitmap; + outBitmap.resize(inBitmap.getWidth(), inBitmap.getHeight()); + + // copy points colors to new bitmap + for (sint y = 0, h = inBitmap.getHeight(); y < h; ++y) + { + for (sint x = 0, w = inBitmap.getWidth(); x < w; ++x) + { + if (inBitmap.getPixelColor(x, y) != DiscardColor) + { + // we copy this point, repeat texture image if using it + outBitmap.setPixelColor(x, y, useTexture ? textureBitmap.getPixelColor(x % textureBitmap.getWidth(), y % textureBitmap.getHeight()) : foregroundColor); + } + else + { + // put a background color + outBitmap.setPixelColor(x, y, backgroundColor); + } + } + } + + // save output bitmap + NLMISC::COFile outFile; + + if (outFile.open(output)) + { + outBitmap.writePNG(outFile, 24); + } + } + + if (args.haveArg("u")) + { + NLMISC::CIFile objFile; + + if (!objFile.open(filename)) + { + nlwarning("Unable to open %s", filename.c_str()); + return 1; + } + + CObject object; + + char buffer[1024]; + + while (!objFile.eof()) + { + objFile.getline(buffer, 1024); + buffer[1023] = '\0'; + + std::string line(buffer); + + if (line.size() > 1022) + { + nlwarning("More than 1022 bytes on a line!"); + return 1; + } + + if (line.size() < 3) continue; + + // texture coordinate + if (line.substr(0, 3) == "vt ") + { + // vertex texture + std::vector tokens; + NLMISC::explode(line, std::string(" "), tokens); + + if (tokens.size() == 3) + { + float u, v; + NLMISC::fromString(tokens[1], u); + NLMISC::fromString(tokens[2], v); + + // V coordinates are inverted + object.textureCoords.push_back(NLMISC::CUV(u * (float)TextureSize, (1.f - v) * (float)TextureSize)); + } + else + { + nlwarning("Not 3 arguments for VT"); + } + } + else if (line.substr(0, 2) == "f ") + { + // face + std::vector tokens; + NLMISC::explode(line, std::string(" "), tokens); + + CFace face; + face.indices.resize(tokens.size()-1); + + bool faceValid = true; + + for (uint i = 1, ilen = tokens.size(); i < ilen; ++i) + { + std::vector tokens2; + NLMISC::explode(tokens[i], std::string("/"), tokens2); + + if (tokens2.size() == 3) + { + if (NLMISC::fromString(tokens2[1], face.indices[i - 1])) + { + // we want indices start from 0 instead of 1 + --face.indices[i - 1]; + } + else + { + faceValid = false; + } + } + else + { + nlwarning("Not 3 arguments for indices"); + } + } + + if (faceValid) object.faces.push_back(face); + } + else if (line.substr(0, 2) == "o ") + { + // object + object.name = line.substr(2); + object.display(); + } + } + + object.display(); + + objFile.close(); + + // draw UV Map + // create a new bitmap for output + NLMISC::CBitmap outBitmap; + outBitmap.resize(TextureSize, TextureSize); + + // white background + memset(&outBitmap.getPixels()[0], 255, TextureSize * TextureSize * 4); + + // process all faces + for (uint i = 0, ilen = object.faces.size(); i < ilen; ++i) + { + const CFace &face = object.faces[i]; + + // pixels of a face + for (uint k = 1, klen = face.indices.size(); k < klen; ++k) + { + drawEdge(outBitmap, object, face, k - 1, k); + } + + // link last and fist pixels + drawEdge(outBitmap, object, face, face.indices.size()-1, 0); + } + + // save output bitmap + NLMISC::COFile outFile; + + if (outFile.open(output)) + { + outBitmap.writePNG(outFile, 24); + } + } + + return 0; +} diff --git a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp index 5e40a4cca..d7158c045 100644 --- a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp +++ b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp @@ -32,6 +32,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif #define TGA8 8 #define TGA16 16 @@ -297,6 +300,7 @@ int main(int argc, char **argv) "\n" " default : DXTC1 if 24 bits, DXTC5 if 32 bits." ); + args.addArg("g", "grayscale", "", "Don't load grayscape images as alpha but as grayscale"); args.addArg("m", "mipmap", "", "Create MipMap"); args.addArg("r", "reduce", "FACTOR", "Reduce the bitmap size before compressing\n FACTOR is 0, 1, 2, 3, 4, 5, 6, 7 or 8"); args.addAdditionalArg("input", "PNG or TGA files to convert", false); @@ -306,11 +310,18 @@ int main(int argc, char **argv) string OptOutputFileName; uint8 OptAlgo = NOT_DEFINED; bool OptMipMap = false; + bool OptGrayscale = false; uint Reduce = 0; if (args.haveArg("o")) OptOutputFileName = args.getArg("o").front(); + if (args.haveArg("m")) + OptMipMap = true; + + if (args.haveArg("g")) + OptGrayscale = true; + if (args.haveArg("a")) { std::string strAlgo = args.getArg("a").front(); @@ -359,12 +370,17 @@ int main(int argc, char **argv) { return 0; } + NLMISC::CIFile input; if(!input.open(inputFileName)) { cerr<<"Can't open input file " << inputFileName << endl; return 1; } + + // allow to load an image as grayscale instead of alpha + if (OptGrayscale) picTga.loadGrayscaleAsAlpha(false); + uint8 imageDepth = picTga.load(input); if(imageDepth==0) { diff --git a/code/nel/tools/3d/tile_edit/Browse.cpp b/code/nel/tools/3d/tile_edit/Browse.cpp index 7c4f6d745..89e45c62d 100644 --- a/code/nel/tools/3d/tile_edit/Browse.cpp +++ b/code/nel/tools/3d/tile_edit/Browse.cpp @@ -546,7 +546,7 @@ unsigned long Browse::MyControllingFunction( void* pParam ) rot = tileBank2.getTile (index)->getRotAlpha (); } else - path = ""; + path.clear(); } break; case 3: @@ -576,7 +576,7 @@ unsigned long Browse::MyControllingFunction( void* pParam ) break; } - if ((path!="") && _LoadBitmap(tileBank2.getAbsPath() + path, pBmp, *bits, pAlpha, rot)) + if (!path.empty() && _LoadBitmap(tileBank2.getAbsPath() + path, pBmp, *bits, pAlpha, rot)) { *ld=1; int iFV,iLV; br->m_ctrl.GetVisibility(iFV, iLV, br->m_128x128); @@ -633,7 +633,7 @@ void Browse::Init() value=256; type=REG_SZ; if (RegQueryValueEx(regkey,REGKEY_LASTPATH,0,&type,(unsigned char *)&sWindowpl,&value)!=ERROR_SUCCESS) - m_ctrl.LastPath=""; + m_ctrl.LastPath.clear(); else m_ctrl.LastPath=(const char*)sWindowpl; value=4; @@ -778,7 +778,7 @@ void Browse::OnCancel() // TODO: Add your control notification handler code here if (thread_actif) return; - if (::MessageBox (NULL, "Are you sure you want to cancel?", "Cancel", MB_OK|MB_ICONQUESTION|MB_YESNO)==IDYES) + if (::MessageBox (NULL, _T("Are you sure you want to cancel?"), _T("Cancel"), MB_OK|MB_ICONQUESTION|MB_YESNO)==IDYES) { this->SendMessage(WM_CLOSE); CDialog::OnCancel(); @@ -884,27 +884,27 @@ void Browse::OnChangeVariety() void Browse::OnBatchLoad () { - CFileDialog sFile (true, NULL, NULL, OFN_ENABLESIZING, - "PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL); + CFileDialog sFile (true, NULL, NULL, OFN_ENABLESIZING, _T("PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||"), NULL); if (sFile.DoModal()==IDOK) { - char sDrive[256]; - char sPath[256]; - char sName[256]; - char sExt[256]; - _splitpath (sFile.GetPathName(), sDrive, sPath, sName, sExt); + std::string fullPath = tStrToUtf8(sFile.GetPathName()); + + std::string path = NLMISC::CFile::getPath(fullPath); + std::string filename = NLMISC::CFile::getFilenameWithoutExtension(fullPath); + std::string ext = NLMISC::CFile::getExtension(fullPath); // look for some numbers.. - char *sNumber=sName+strlen(sName)-1; - while ((sNumber>sName)&&(*sNumber>='0')&&(*sNumber<='9')) + std::string::size_type pos = filename.find_last_not_of("0123456789"); + + if (pos != std::string::npos) { - sNumber--; + filename = filename.substr(0, pos + 1); } - sNumber[1]=0; bool rotate=false; - if (::MessageBox (NULL, "Do you want to use rotation to reuse alpha tiles ?", "Import rotated tiles", MB_OK|MB_ICONQUESTION|MB_YESNO)==IDYES) + + if (::MessageBox (NULL, _T("Do you want to use rotation to reuse alpha tiles ?"), _T("Import rotated tiles"), MB_OK|MB_ICONQUESTION|MB_YESNO)==IDYES) rotate=true; for (int i=0; igetTransition (transition); - if (tileBank2.getTile (trans->getTile())->getRelativeFileName (CTile::alpha)=="") + if (tileBank2.getTile (trans->getTile())->getRelativeFileName (CTile::alpha).empty()) { // Continue ? int ok; @@ -925,11 +925,9 @@ void Browse::OnBatchLoad () for (int rot=0; rot<4; rot++) { // Try to load a tile with a file name like /tiletransition0.tga - char sName2[256]; - char sFinal[256]; - sprintf (sName2, "%s%02d", sName, (int)transition); - _makepath (sFinal, sDrive, sPath, sName2, sExt); - FILE *pFile=fopen (sFinal, "rb"); + std::string sFinal = path + toString("%s%02d.%s", filename.c_str(), (int)transition, ext.c_str()); + + FILE *pFile = nlfopen (sFinal, "rb"); // Close the file and add the tile if opened if (pFile) @@ -958,14 +956,12 @@ void Browse::OnBatchLoad () // Transition to patch CTileSetTransition* trans=tileBank2.getTileSet (land)->getTransition (transition); - if (tileBank2.getTile (trans->getTile())->getRelativeFileName (m_ctrl.Texture==1?CTile::diffuse:CTile::additive)=="") + if (tileBank2.getTile (trans->getTile())->getRelativeFileName (m_ctrl.Texture==1?CTile::diffuse:CTile::additive).empty()) { // Try to load a tile with a file name like /tiletransition0.tga - char sName2[256]; - char sFinal[256]; - sprintf (sName2, "%s%02d", sName, (int)transition); - _makepath (sFinal, sDrive, sPath, sName2, sExt); - FILE *pFile=fopen (sFinal, "rb"); + std::string sFinal = path + toString("%s%02d.%s", filename.c_str(), (int)transition, ext.c_str()); + + FILE *pFile = nlfopen (sFinal, "rb"); // Close the file and add the tile if opened if (pFile) @@ -1364,8 +1360,7 @@ void Browse::OnSubgroup11() void Browse::OnExportBorder() { // Select a file - CFileDialog sFile (false, NULL, NULL, OFN_ENABLESIZING, - "PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL); + CFileDialog sFile (false, NULL, NULL, OFN_ENABLESIZING, _T("PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||"), NULL); if (sFile.DoModal()==IDOK) { // Get the border of the bank @@ -1401,7 +1396,7 @@ void Browse::OnExportBorder() try { COFile file; - if (file.open ((const char*)pathName)) + if (file.open (tStrToUtf8(pathName))) { // Export bitmap.writeTGA (file, 32); @@ -1409,7 +1404,7 @@ void Browse::OnExportBorder() else error=true; } - catch (Exception& e) + catch (const Exception& e) { const char *toto=e.what (); error=true; @@ -1419,9 +1414,8 @@ void Browse::OnExportBorder() if (error) { // Error message - char tmp[512]; - sprintf (tmp, "Can't write bitmap %s", (const char*)pathName); - MessageBox (tmp, "Export border", MB_OK|MB_ICONEXCLAMATION); + std::string tmp = toString("Can't write bitmap %s", tStrToUtf8(pathName).c_str()); + MessageBox (utf8ToTStr(tmp), _T("Export border"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -1430,8 +1424,7 @@ void Browse::OnExportBorder() void Browse::OnImportBorder() { // Select a file - CFileDialog sFile (true, NULL, NULL, OFN_ENABLESIZING, - "PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL); + CFileDialog sFile (true, NULL, NULL, OFN_ENABLESIZING,_T("PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||"), NULL); if (sFile.DoModal()==IDOK) { // Get the border of the bank @@ -1446,7 +1439,7 @@ void Browse::OnImportBorder() try { CIFile file; - if (file.open ((const char*)pathName)) + if (file.open (tStrToUtf8(pathName))) { // Export bitmap.load (file); @@ -1454,7 +1447,7 @@ void Browse::OnImportBorder() else error=true; } - catch (Exception& e) + catch (const Exception& e) { const char *toto=e.what (); error=true; @@ -1464,9 +1457,8 @@ void Browse::OnImportBorder() if (error) { // Error message - char tmp[512]; - sprintf (tmp, "Can't read bitmap %s", (const char*)pathName); - MessageBox (tmp, "Import border", MB_OK|MB_ICONEXCLAMATION); + std::string tmp = toString("Can't read bitmap %s", tStrToUtf8(pathName).c_str()); + MessageBox (utf8ToTStr(tmp), _T("Import border"), MB_OK|MB_ICONEXCLAMATION); } // Get pixel @@ -1489,9 +1481,8 @@ void Browse::OnImportBorder() else { // Error message - char tmp[512]; - sprintf (tmp, "The bitmap must have a size of 128x128 (%s)", (const char*)pathName); - MessageBox (tmp, "Import border", MB_OK|MB_ICONEXCLAMATION); + std::string tmp = toString("The bitmap must have a size of 128x128 (%s)", tStrToUtf8(pathName).c_str()); + MessageBox (utf8ToTStr(tmp), _T("Import border"), MB_OK|MB_ICONEXCLAMATION); } // 256 or 128 ? @@ -1500,6 +1491,6 @@ void Browse::OnImportBorder() tileBank2.getTileSet (land)->setBorder (m_ctrl.Texture==1?CTile::diffuse:CTile::additive, border); // Message - MessageBox ("The border has been changed.", "Import border", MB_OK|MB_ICONINFORMATION); + MessageBox (_T("The border has been changed."), _T("Import border"), MB_OK|MB_ICONINFORMATION); } } diff --git a/code/nel/tools/3d/tile_edit/Browse.h b/code/nel/tools/3d/tile_edit/Browse.h index 3c1ce166c..70fd1c6ac 100644 --- a/code/nel/tools/3d/tile_edit/Browse.h +++ b/code/nel/tools/3d/tile_edit/Browse.h @@ -25,15 +25,15 @@ #include "SelectionTerritoire.h" #include "View.h" -#define REGKEY_TILEDIT "Software\\Nevrax\\Nel\\Tile_Edit" -#define REGKEY_BUTTONZOOM "Zoom button" -#define REGKEY_BUTTONVARIETY "Zoom variety" -#define REGKEY_BUTTONTEXTURE "Texture button" -#define REGKEY_BUTTONSORT "Sort button" -#define REGKEY_BUTTONTEXTINFO "Info button" -#define REGKEY_LISTCOMBOBOX "List type combo box" -#define REGKEY_WNDPL "Window placement" -#define REGKEY_LASTPATH "Last path" +#define REGKEY_TILEDIT _T("Software\\Nevrax\\Nel\\Tile_Edit") +#define REGKEY_BUTTONZOOM _T("Zoom button") +#define REGKEY_BUTTONVARIETY _T("Zoom variety") +#define REGKEY_BUTTONTEXTURE _T("Texture button") +#define REGKEY_BUTTONSORT _T("Sort button") +#define REGKEY_BUTTONTEXTINFO _T("Info button") +#define REGKEY_LISTCOMBOBOX _T("List type combo box") +#define REGKEY_WNDPL _T("Window placement") +#define REGKEY_LASTPATH _T("Last path") #define SCROLL_MAX 50000 diff --git a/code/nel/tools/3d/tile_edit/CMakeLists.txt b/code/nel/tools/3d/tile_edit/CMakeLists.txt index 394359cd0..bd29fea37 100644 --- a/code/nel/tools/3d/tile_edit/CMakeLists.txt +++ b/code/nel/tools/3d/tile_edit/CMakeLists.txt @@ -15,6 +15,6 @@ ADD_DEFINITIONS(${MFC_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(tile_edit ${CMAKE_CURRENT_SOURCE_DIR}/stdafx.h ${CMAKE_CURRENT_SOURCE_DIR}/stdafx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS tile_edit RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d) diff --git a/code/nel/tools/3d/tile_edit/GetVal.cpp b/code/nel/tools/3d/tile_edit/GetVal.cpp index 13128feb5..ff9bcf660 100644 --- a/code/nel/tools/3d/tile_edit/GetVal.cpp +++ b/code/nel/tools/3d/tile_edit/GetVal.cpp @@ -64,8 +64,8 @@ void GetVal::OnOK() CString rString; EditStr->GetWindowText( rString ); int size = rString.GetLength(); - name = new char[size+1]; - strcpy (name, rString); + name = new TCHAR[size+1]; + _tcscpy(name, rString); /**((short*)name)=size; EditStr->GetLine(0,name,size); for (int i=0;iFindStringExact(0,GetStr.name)!=LB_ERR) { - MessageBox("Ce nom existe deja","Error",MB_ICONERROR); + MessageBox(_T("Ce nom existe deja"), _T("Error"), MB_ICONERROR); } else { list->InsertString(-1, GetStr.name); - tileBank.addLand (GetStr.name); + tileBank.addLand (tStrToUtf8(GetStr.name)); } } } @@ -119,14 +119,14 @@ private: virtual void OnInit () { UpdateData (); - char sTitle[512]; - sprintf (sTitle, "Tile sets use by %s", tileBank.getLand(_land)->getName().c_str()); + TCHAR sTitle[512]; + _stprintf(sTitle, _T("Tile sets use by %s"), utf8ToTStr(tileBank.getLand(_land)->getName())); SetWindowText (sTitle); for (int i=0; igetName().c_str()); + m_ctrlCombo.InsertString (-1, utf8ToTStr(tileBank.getTileSet(i)->getName())); if (tileBank.getLand(_land)->isTileSet (tileBank.getTileSet(i)->getName())) - m_ctrlList.InsertString (-1, tileBank.getTileSet(i)->getName().c_str()); + m_ctrlList.InsertString (-1, utf8ToTStr(tileBank.getTileSet(i)->getName())); } UpdateData (FALSE); } @@ -143,7 +143,7 @@ private: { CString rString; m_ctrlList.GetText(i, rString); - tileBank.getLand(_land)->addTileSet ((const char*)rString); + tileBank.getLand(_land)->addTileSet (tStrToUtf8(rString)); } UpdateData (FALSE); } @@ -163,7 +163,7 @@ void SelectionTerritoire::OnEditTerritoire() } else { - MessageBox("No tilesset selected","Error",MB_ICONERROR); + MessageBox(_T("No tilesset selected"), _T("Error"), MB_ICONERROR); } } @@ -179,7 +179,7 @@ void SelectionTerritoire::OnRemoveTerritoire() } else { - MessageBox("No tilesset selected","Chcrois kca va pas etreuu possibleuuu",MB_ICONERROR); + MessageBox(_T("No tilesset selected"), _T("Chcrois kca va pas etreuu possibleuuu"), MB_ICONERROR); } } @@ -197,12 +197,12 @@ void SelectionTerritoire::OnAddTileSet() CListBox *list=(CListBox*)GetDlgItem(IDC_TILE_SET); if (list->FindStringExact(0,GetStr.name)!=LB_ERR) { - MessageBox("Ce nom existe deja","Error",MB_ICONERROR); + MessageBox(_T("Ce nom existe deja") , _T("Error"), MB_ICONERROR); } else { list->InsertString(-1, GetStr.name); - tileBank.addTileSet (GetStr.name); + tileBank.addTileSet (tStrToUtf8(GetStr.name)); } } } @@ -218,16 +218,18 @@ private: virtual void OnInit () { UpdateData (); - char sTitle[512]; - sprintf (sTitle, "Children of the tile set %s", tileBank.getTileSet(_tileSet)->getName().c_str()); + TCHAR sTitle[512]; + _stprintf(sTitle, _T("Children of the tile set %s"), utf8ToTStr(tileBank.getTileSet(_tileSet)->getName())); SetWindowText (sTitle); for (int i=0; igetName().c_str()); + m_ctrlCombo.InsertString (-1, utf8ToTStr(tileBank.getTileSet(i)->getName())); + if (tileBank.getTileSet(_tileSet)->isChild (tileBank.getTileSet(i)->getName())) - m_ctrlList.InsertString (-1, tileBank.getTileSet(i)->getName().c_str()); + m_ctrlList.InsertString (-1, utf8ToTStr(tileBank.getTileSet(i)->getName())); } + UpdateData (FALSE); } virtual void OnOk () @@ -243,7 +245,7 @@ private: { CString rString; m_ctrlList.GetText(i, rString); - tileBank.getTileSet(_tileSet)->addChild ((const char*)rString); + tileBank.getTileSet(_tileSet)->addChild (tStrToUtf8(rString)); } UpdateData (FALSE); } @@ -268,7 +270,7 @@ void SelectionTerritoire::OnEditTileSet() } else { - MessageBox("No tilesset selected","Error",MB_ICONERROR); + MessageBox(_T("No tilesset selected"), _T("Error"), MB_ICONERROR); } } @@ -284,7 +286,7 @@ void SelectionTerritoire::OnRemoveTileSet() } else { - MessageBox("No tilesset selected","Chcrois kca va pas etreuu possibleuuu",MB_ICONERROR); + MessageBox(_T("No tilesset selected"), _T("Chcrois kca va pas etreuu possibleuuu"), MB_ICONERROR); } } @@ -315,7 +317,7 @@ void SelectionTerritoire::OnMonter() } else { - MessageBox("No tilesset selected","Chcrois kca va pas etreuu possibleuuu",MB_ICONERROR); + MessageBox(_T("No tilesset selected"), _T("Chcrois kca va pas etreuu possibleuuu"), MB_ICONERROR); } } @@ -346,7 +348,7 @@ void SelectionTerritoire::OnDescendre() } else { - MessageBox("No tilesset selected","Chcrois kca va pas etreuu possibleuuu",MB_ICONERROR); + MessageBox(_T("No tilesset selected"), _T("Chcrois kca va pas etreuu possibleuuu"), MB_ICONERROR); } } @@ -355,18 +357,17 @@ void SelectionTerritoire::OnSelect() // TODO: Add your control notification handler code here CListBox *list=(CListBox*)GetDlgItem(IDC_LIST_TERRITOIRE); CListBox *list2=(CListBox*)GetDlgItem(IDC_TILE_SET); - static char BASED_CODE szFilter[] = - "NeL tile bank files (*.bank)|*.bank|All Files (*.*)|*.*||"; - CFileDialog sFile(true, "bank", "main.bank",0, szFilter, this); + static TCHAR BASED_CODE szFilter[] = _T("NeL tile bank files (*.bank)|*.bank|All Files (*.*)|*.*||"); + CFileDialog sFile(true, _T("bank"), _T("main.bank"), 0, szFilter, this); if (sFile.DoModal()==IDOK) { POSITION p = sFile.GetStartPosition(); CString str = sFile.GetNextPathName(p); - char *temp = str.GetBuffer(256); - if (temp) + std::string temp = tStrToUtf8(str); + if (!temp.empty()) { CIFile stream; - if (stream.open ((const char*)str)) + if (stream.open (temp)) { list->ResetContent (); list2->ResetContent (); @@ -378,21 +379,17 @@ void SelectionTerritoire::OnSelect() for (i=0; iAddString(tileBank.getLand(i)->getName().c_str()); + list->AddString(utf8ToTStr(tileBank.getLand(i)->getName())); } for (i=0; iAddString(tileBank.getTileSet(i)->getName().c_str()); + list2->AddString(utf8ToTStr(tileBank.getTileSet(i)->getName())); } - char drive[256],name[256],path[256],ext[256]; - _splitpath(temp,drive,path,name,ext); - MainFileName = name; - MainFileName += ext; - DefautPath = drive; - DefautPath += path; + MainFileName = CString(utf8ToTStr(NLMISC::CFile::getFilename(temp))); + DefautPath = CString(utf8ToTStr(NLMISC::CFile::getPath(temp))); MainFileOk = 1; CButton *button = (CButton*)GetDlgItem(IDC_ADD_TERRITOIRE); @@ -405,7 +402,7 @@ void SelectionTerritoire::OnSelect() button->EnableWindow(true); // Change the bouton text path - GetDlgItem (IDC_PATH)->SetWindowText (tileBank.getAbsPath().c_str()); + GetDlgItem (IDC_PATH)->SetWindowText (utf8ToTStr(tileBank.getAbsPath())); } } @@ -425,7 +422,7 @@ LRESULT SelectionTerritoire::WindowProc(UINT message, WPARAM wParam, LPARAM lPar void SelectionTerritoire::OnOK() { // TODO: Add extra validation here - if (::MessageBox (NULL, "Are you sure you want to quit?", "Quit", MB_OK|MB_ICONQUESTION|MB_YESNO)==IDYES) + if (::MessageBox (NULL, _T("Are you sure you want to quit?"), _T("Quit"), MB_OK|MB_ICONQUESTION|MB_YESNO)==IDYES) { CDialog::OnOK(); } @@ -438,12 +435,12 @@ void SelectionTerritoire::OnSave() Save (str, tileBank); } -void SelectionTerritoire::Save(const char* path, CTileBank &toSave) +void SelectionTerritoire::Save(const TCHAR* path, CTileBank &toSave) { // TODO: Add extra validation here { COFile stream; - if (stream.open ((const char*)path)) + if (stream.open (tStrToUtf8(path))) { toSave.serial (stream); } @@ -453,9 +450,8 @@ void SelectionTerritoire::Save(const char* path, CTileBank &toSave) void SelectionTerritoire::OnSaveAs() { // TODO: Add your control notification handler code here - static char BASED_CODE szFilter[] = - "NeL tile bank files (*.bank)|*.bank|All Files (*.*)|*.*||"; - CFileDialog sFile(false, "bank", DefautPath+MainFileName, 0, szFilter, this); + static TCHAR BASED_CODE szFilter[] = _T("NeL tile bank files (*.bank)|*.bank|All Files (*.*)|*.*||"); + CFileDialog sFile(false, _T("bank"), DefautPath+MainFileName, 0, szFilter, this); if (sFile.DoModal()==IDOK) { Save (sFile.GetPathName(), tileBank); @@ -470,45 +466,42 @@ void SelectionTerritoire::OnSaveAs() button->EnableWindow(true); // Create a file name - char drive[256],name[256],path[256],ext[256]; - _splitpath(sFile.GetPathName(), drive, path, name, ext); - MainFileName = name; - MainFileName += ext; - DefautPath = drive; - DefautPath += path; + std::string temp = tStrToUtf8(sFile.GetPathName()); + + MainFileName = CString(utf8ToTStr(NLMISC::CFile::getFilename(temp))); + DefautPath = CString(utf8ToTStr(NLMISC::CFile::getPath(temp))); } } void SelectionTerritoire::OnCancel() { // TODO: Add extra cleanup here - if (::MessageBox (NULL, "Are you sure you want to quit?", "Quit", MB_OK|MB_ICONQUESTION|MB_YESNO)==IDYES) + if (::MessageBox (NULL, _T("Are you sure you want to quit?"), _T("Quit"), MB_OK|MB_ICONQUESTION|MB_YESNO)==IDYES) { CDialog::OnCancel(); } } -bool CheckPath (const std::string& path, const char* absolutePathToRemplace) +bool CheckPath (const std::string& path, const std::string &absolutePathToRemplace) { // Look for absolute path in path - if (strnicmp (path.c_str(), absolutePathToRemplace, strlen (absolutePathToRemplace))==0) + if (strnicmp(path.c_str(), absolutePathToRemplace.c_str(), absolutePathToRemplace.length()) == 0) return true; - else - return false; + + return false; } -bool RemovePath (std::string& path, const char* absolutePathToRemplace) +bool RemovePath (std::string& path, const std::string &absolutePathToRemplace) { // Look for absolute path in path - if (strnicmp (path.c_str(), absolutePathToRemplace, strlen (absolutePathToRemplace))==0) + if (strnicmp(path.c_str(), absolutePathToRemplace.c_str(), absolutePathToRemplace.length())==0) { // New path - std::string toto=path; - path=toto.c_str()+strlen (absolutePathToRemplace); + path = path.substr(absolutePathToRemplace.length()); return true; } - else - return false; + + return false; } void SelectionTerritoire::OnPath() @@ -516,34 +509,35 @@ void SelectionTerritoire::OnPath() // TODO: Add your control notification handler code here // Select a directory. - char path[MAX_PATH]; + TCHAR path[MAX_PATH]; // Build the struct BROWSEINFO info; memset (&info, 0, sizeof (BROWSEINFO)); - info.lpszTitle="Select the absolute base path of the bank"; + info.lpszTitle = _T("Select the absolute base path of the bank"); info.ulFlags=BIF_RETURNONLYFSDIRS; // Select the path - LPITEMIDLIST list; - if (list=SHBrowseForFolder (&info)) + PIDLIST_ABSOLUTE list = SHBrowseForFolder(&info); + if (list) { // Convert item into path string BOOL bRet=SHGetPathFromIDList(list, path); nlassert (bRet); // Add a final back slash - if (strcmp (path, "")!=0) + if (_tcscmp(path, _T("")) != 0) { // Add a '\' at the end - if (path[strlen (path)-1]!='\\') - strcat (path, "\\"); + if (path[_tcslen(path)-1] != _T('\\')) + _tcscat(path, _T("\\")); } // Last check - char msg[512]; - sprintf (msg, "Do you really want to set %s as base path of the bank ?", path); - if (MessageBox (msg, "TileEdit", MB_YESNO|MB_ICONQUESTION)==IDYES) + TCHAR msg[512]; + _stprintf(msg, _T("Do you really want to set %s as base path of the bank ?"), path); + + if (MessageBox (msg, _T("TileEdit"), MB_YESNO|MB_ICONQUESTION)==IDYES) { // Set as default path.. @@ -579,19 +573,19 @@ void SelectionTerritoire::OnPath() const std::string& bitmapPath=tileBank.getTile(tiles)->getRelativeFileName ((CTile::TBitmap)type); // not empty ? - if (bitmapPath!="") + if (!bitmapPath.empty()) { // Check the path - if (CheckPath (bitmapPath, path)==false) + if (CheckPath (bitmapPath, tStrToUtf8(path))==false) { // Bad path goodPath=false; // Make a message - sprintf (msg, "Path '%s' can't be found in bitmap '%s'. Continue ?", path, bitmapPath.c_str()); + _stprintf(msg, _T("Path '%s' can't be found in bitmap '%s'. Continue ?"), path, utf8ToTStr(bitmapPath)); // Message - if (MessageBox (msg, "TileEdit", MB_YESNO|MB_ICONQUESTION)==IDNO) + if (MessageBox (msg, _T("TileEdit"), MB_YESNO|MB_ICONQUESTION)==IDNO) break; } } @@ -611,16 +605,16 @@ void SelectionTerritoire::OnPath() if (strcmp (bitmapPath, "")!=0) { // Check the path - if (CheckPath (bitmapPath, path)==false) + if (CheckPath (bitmapPath, tStrToUtf8(path))==false) { // Bad path goodPath=false; // Make a message - sprintf (msg, "Path '%s' can't be found in bitmap '%s'. Continue ?", path, bitmapPath); + _stprintf(msg, _T("Path '%s' can't be found in bitmap '%s'. Continue ?"), path, utf8ToTStr(bitmapPath)); // Message - if (MessageBox (msg, "TileEdit", MB_YESNO|MB_ICONQUESTION)==IDNO) + if (MessageBox (msg, _T("TileEdit"), MB_YESNO|MB_ICONQUESTION)==IDNO) break; } } @@ -650,10 +644,10 @@ void SelectionTerritoire::OnPath() std::string bitmapPath=tileBank.getTile(tiles)->getRelativeFileName ((CTile::TBitmap)type); // not empty ? - if (bitmapPath!="") + if (!bitmapPath.empty()) { // Remove the absolute path - bool res=RemovePath (bitmapPath, path); + bool res=RemovePath (bitmapPath, tStrToUtf8(path)); nlassert (res); // Set the bitmap @@ -670,10 +664,10 @@ void SelectionTerritoire::OnPath() std::string bitmapPath=tileBank.getDisplacementMap (noise); // not empty ? - if (bitmapPath!="") + if (!bitmapPath.empty()) { // Remove the absolute path - bool res=RemovePath (bitmapPath, path); + bool res=RemovePath (bitmapPath, tStrToUtf8(path)); nlassert (res); // Set the bitmap @@ -683,7 +677,7 @@ void SelectionTerritoire::OnPath() } else // Info message - MessageBox ("Can't set the path.", "TileEdit", MB_OK|MB_ICONINFORMATION); + MessageBox (_T("Can't set the path."), _T("TileEdit"), MB_OK|MB_ICONINFORMATION); } @@ -691,7 +685,7 @@ void SelectionTerritoire::OnPath() if (goodPath) { // Change the abs path of the bank - tileBank.setAbsPath (path); + tileBank.setAbsPath (tStrToUtf8(path)); // Change the bouton text GetDlgItem (IDC_PATH)->SetWindowText (path); @@ -706,9 +700,10 @@ void SelectionTerritoire::OnPath() void SelectionTerritoire::OnExport() { // TODO: Add your control notification handler code here - static char BASED_CODE szFilter[] = - "NeL tile bank files (*.smallbank)|*.smallbank|All Files (*.*)|*.*||"; - CFileDialog sFile(false, "*.smallbank", DefautPath+"*.smallbank", 0, szFilter, this); + static TCHAR BASED_CODE szFilter[] = _T("NeL tile bank files (*.smallbank)|*.smallbank|All Files (*.*)|*.*||"); + + CFileDialog sFile(false, _T("*.smallbank"), DefautPath+ _T("*.smallbank"), 0, szFilter, this); + if (sFile.DoModal()==IDOK) { // Copy the bank @@ -737,7 +732,7 @@ void SelectionTerritoire::OnChooseVeget() } else { - MessageBox("No tilesset selected","Error",MB_ICONERROR); + MessageBox(_T("No tilesset selected"), _T("Error"), MB_ICONERROR); } } diff --git a/code/nel/tools/3d/tile_edit/SelectionTerritoire.h b/code/nel/tools/3d/tile_edit/SelectionTerritoire.h index 600fd9cdb..f38f264d4 100644 --- a/code/nel/tools/3d/tile_edit/SelectionTerritoire.h +++ b/code/nel/tools/3d/tile_edit/SelectionTerritoire.h @@ -86,7 +86,7 @@ protected: afx_msg void OnSelchangeTileSet(); virtual BOOL OnInitDialog(); //}}AFX_MSG - void Save(const char* path, NL3D::CTileBank &toSave); + void Save(const TCHAR* path, NL3D::CTileBank &toSave); DECLARE_MESSAGE_MAP() }; diff --git a/code/nel/tools/3d/tile_edit/View.cpp b/code/nel/tools/3d/tile_edit/View.cpp index 81f5fe784..cf65a527d 100644 --- a/code/nel/tools/3d/tile_edit/View.cpp +++ b/code/nel/tools/3d/tile_edit/View.cpp @@ -101,7 +101,7 @@ static bool loadPic(const string &path, std::vector &tampon, uint return true; } } - catch (NLMISC::Exception& ) { } + catch (const NLMISC::Exception& ) { } return false; } @@ -227,7 +227,7 @@ int TileList::addTile256 () return index; } -bool RemovePath (std::string& path, const char* absolutePathToRemplace); +bool RemovePath (std::string& path, const std::string &absolutePathToRemplace); int TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitmap type) { @@ -240,7 +240,9 @@ int TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitma uint Height; if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height)) { - return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + std::string msg = tileBank2.getAbsPath() + troncated + "\nContinue ?"; + + return (int)(MessageBox (NULL, utf8ToTStr(msg), _T("Can't load bitmap."), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } else { @@ -256,10 +258,10 @@ int TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitma error=tileBank2.getTileSet(_tileSet)->checkTile128 (type, border, pixel, composante); if ((error!=CTileSet::ok)&&(error!=CTileSet::addFirstA128128)&&!zouille ()) { - char sTmp[512]; static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; - sprintf (sTmp, "%s\nPixel: %d (%s)", CTileSet::getErrorMessage (error), pixel, comp[composante]); - return (int)(MessageBox (NULL, (std::string(sTmp)+"\nContinue ?").c_str(), "Can't add tile", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + std::string msg = NLMISC::toString("%s\nPixel: %d (%s)\nContinue ?", CTileSet::getErrorMessage (error), pixel, comp[composante]); + + return (int)(MessageBox (NULL, utf8ToTStr(msg), _T("Can't add tile"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } else { @@ -286,9 +288,8 @@ int TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitma else { // Error: bitmap not in the absolute path.. - char msg[512]; - sprintf (msg, "The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); - return (int)(MessageBox (NULL, (std::string (msg)+"\nContinue ?").c_str(), "Load error", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + std::string msg = NLMISC::toString("The bitmap %s is not in the absolute path %s.\nContinue ?", name.c_str(), tileBank2.getAbsPath ().c_str()); + return (int)(MessageBox (NULL, utf8ToTStr(msg), _T("Load error"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } return 1; @@ -305,7 +306,8 @@ int TileList::setTile256 (int tile, const std::string& name, NL3D::CTile::TBitma uint Height; if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height)) { - return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + std::string msg = tileBank2.getAbsPath() + troncated + "\nContinue ?"; + return (int)(MessageBox (NULL, utf8ToTStr(msg), _T("Can't load bitmap."), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } else { @@ -322,10 +324,9 @@ int TileList::setTile256 (int tile, const std::string& name, NL3D::CTile::TBitma error=tileBank2.getTileSet(_tileSet)->checkTile256 (type, border, pixel, composante); if ((error!=CTileSet::ok)&&!zouille()) { - char sTmp[512]; - static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; - sprintf (sTmp, "%s\nPixel: %d (%s)", CTileSet::getErrorMessage (error), pixel, comp[composante]); - return (int)(MessageBox (NULL, (std::string(sTmp)+"\nContinue ?").c_str(), "Can't add tile", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + static const char* comp[] = { "Red", "Green", "Blue", "Alpha", "" }; + std::string msg = NLMISC::toString("%s\nPixel: %d (%s)\nContinue ?", CTileSet::getErrorMessage (error), pixel, comp[composante]); + return (int)(MessageBox (NULL, utf8ToTStr(msg), _T("Can't add tile"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } else { @@ -349,9 +350,8 @@ int TileList::setTile256 (int tile, const std::string& name, NL3D::CTile::TBitma else { // Error: bitmap not in the absolute path.. - char msg[512]; - sprintf (msg, "The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); - return (int)(MessageBox (NULL, (std::string (msg)+"\nContinue ?").c_str(), "Load error", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + std::string msg = NLMISC::toString("The bitmap %s is not in the absolute path %s.\nContinue ?", name.c_str(), tileBank2.getAbsPath ().c_str()); + return (int)(MessageBox (NULL, utf8ToTStr(msg), _T("Load error"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } return 1; @@ -371,7 +371,8 @@ int TileList::setTileTransition (int tile, const std::string& name, NL3D::CTile: uint Height; if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height)) { - return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + std::string msg = tileBank2.getAbsPath() + troncated + "\nContinue ?"; + return (int)(MessageBox (NULL, utf8ToTStr(msg), _T("Can't load bitmap."), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } else { @@ -387,10 +388,9 @@ int TileList::setTileTransition (int tile, const std::string& name, NL3D::CTile: error=tileBank2.getTileSet(_tileSet)->checkTile128 (type, border, pixel, composante); if ((error!=CTileSet::ok)&&(error!=CTileSet::addFirstA128128)&&!zouille ()) { - char sTmp[512]; static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; - sprintf (sTmp, "%s\nPixel: %d (%s)", CTileSet::getErrorMessage (error), pixel, comp[composante]); - return MessageBox (NULL, (std::string(sTmp)+"\nContinue ?").c_str(), "Can't add tile", MB_YESNO|MB_ICONEXCLAMATION)==IDYES; + std::string msg = NLMISC::toString("%s\nPixel: %d (%s)\nContinue ?", CTileSet::getErrorMessage(error), pixel, comp[composante]); + return MessageBox (NULL, utf8ToTStr(msg), _T("Can't add tile"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES; } else { @@ -417,9 +417,8 @@ int TileList::setTileTransition (int tile, const std::string& name, NL3D::CTile: else { // Error: bitmap not in the absolute path.. - char msg[512]; - sprintf (msg, "The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); - MessageBox (NULL, msg, "Load error", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); + MessageBox (NULL, utf8ToTStr(msg), _T("Load error"), MB_OK|MB_ICONEXCLAMATION); } return 1; @@ -432,20 +431,23 @@ int TileList::setDisplacement (int tile, const std::string& name) if (RemovePath (troncated, tileBank2.getAbsPath ().c_str())) { // load it - if (troncated!="") + if (!troncated.empty()) { // not loaded theListDisplacement[tile].loaded=0; if (!_LoadBitmap(tileBank2.getAbsPath() + troncated, &theListDisplacement[tile].BmpInfo, theListDisplacement[tile].Bits, NULL, 0)) - MessageBox (NULL, (tileBank2.getAbsPath() + troncated).c_str(), "Can't load file", MB_OK|MB_ICONEXCLAMATION); + { + std::string msg = tileBank2.getAbsPath() + troncated; + MessageBox(NULL, utf8ToTStr(msg), _T("Can't load file"), MB_OK | MB_ICONEXCLAMATION); + } else { // Check the size if ((theListDisplacement[tile].BmpInfo.bmiHeader.biWidth!=32)||(-theListDisplacement[tile].BmpInfo.bmiHeader.biHeight!=32)) { // Error message - MessageBox (NULL, "Invalid size: displacement map must be 32x32 8 bits.", troncated.c_str(), + MessageBox (NULL, _T("Invalid size: displacement map must be 32x32 8 bits."), utf8ToTStr(troncated), MB_OK|MB_ICONEXCLAMATION); // Free the bitmap @@ -465,9 +467,8 @@ int TileList::setDisplacement (int tile, const std::string& name) else { // Error: bitmap not in the absolute path.. - char msg[512]; - sprintf (msg, "The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); - MessageBox (NULL, msg, "Load error", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); + MessageBox (NULL, utf8ToTStr(msg), _T("Load error"), MB_OK|MB_ICONEXCLAMATION); } return 1; @@ -484,7 +485,8 @@ int TileList::setTileTransitionAlpha (int tile, const std::string& name, int rot uint Height; if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height)) { - return MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES; + std::string msg = tileBank2.getAbsPath() + troncated + "\nContinue ?"; + return MessageBox (NULL, utf8ToTStr(msg), _T("Can't load bitmap."), MB_YESNO|MB_ICONEXCLAMATION)==IDYES; } else { @@ -506,23 +508,27 @@ int TileList::setTileTransitionAlpha (int tile, const std::string& name, int rot if (((error=tileBank2.getTileSet(_tileSet)->checkTileTransition ((CTileSet::TTransition)tile, CTile::alpha, border, indexError, pixel, composante))!=CTileSet::ok)&&!zouille ()) { - char sMsg[512]; + std::string msg; if ((error==CTileSet::topInterfaceProblem)||(error==CTileSet::bottomInterfaceProblem)||(error==CTileSet::leftInterfaceProblem) ||(error==CTileSet::rightInterfaceProblem)||(error==CTileSet::topBottomNotTheSame)||(error==CTileSet::rightLeftNotTheSame) ||(error==CTileSet::topInterfaceProblem)) { static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; if (indexError!=-1) - sprintf (sMsg, "%s\nIncompatible with tile nb %d\nPixel: %d (%s)", CTileSet::getErrorMessage (error), indexError, + msg = NLMISC::toString("%s\nIncompatible with tile nb %d\nPixel: %d (%s)", CTileSet::getErrorMessage (error), indexError, pixel, comp[composante]); else - sprintf (sMsg, "%s\nIncompatible with the 128x128 tile\nPixel: %d (%s)", CTileSet::getErrorMessage (error), + msg = NLMISC::toString("%s\nIncompatible with the 128x128 tile\nPixel: %d (%s)", CTileSet::getErrorMessage (error), pixel, comp[composante]); } else - sprintf (sMsg, "%s\nIncompatible filled tile", CTileSet::getErrorMessage (error)); + { + msg = NLMISC::toString("%s\nIncompatible filled tile", CTileSet::getErrorMessage(error)); + } + + msg += "\nContinue ?"; - return MessageBox (NULL, (std::string(sMsg)+"\nContinue ?").c_str(), "Can't add tile", MB_YESNO|MB_ICONEXCLAMATION)==IDYES; + return MessageBox (NULL, utf8ToTStr(msg), _T("Can't add tile"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES; } else { @@ -535,9 +541,9 @@ int TileList::setTileTransitionAlpha (int tile, const std::string& name, int rot else { // Error: bitmap not in the absolute path.. - char msg[512]; - sprintf (msg, "The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); - MessageBox (NULL, msg, "Load error", MB_OK|MB_ICONEXCLAMATION); + TCHAR msg[512]; + _stprintf(msg, _T("The bitmap %s is not in the absolute path %s."), utf8ToTStr(name), utf8ToTStr(tileBank2.getAbsPath ())); + MessageBox (NULL, msg, _T("Load error"), MB_OK|MB_ICONEXCLAMATION); } return 1; @@ -670,33 +676,33 @@ const std::string& TileInfo::getRelativeFileName (CTile::TBitmap type, int index bool TileInfo::Load (int index, std::vector* Alpha) { bool bRes=true; - if (!loaded && getRelativeFileName (CTile::diffuse, index)!="") + if (!loaded && !getRelativeFileName (CTile::diffuse, index).empty()) { if (!_LoadBitmap(tileBank2.getAbsPath() + getRelativeFileName (CTile::diffuse, index), &BmpInfo, Bits, Alpha, 0)) { bRes=false; - MessageBox (NULL, (tileBank2.getAbsPath() + getRelativeFileName (CTile::diffuse, index)).c_str(), "Can't load file", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(tileBank2.getAbsPath() + getRelativeFileName (CTile::diffuse, index)), _T("Can't load file"), MB_OK|MB_ICONEXCLAMATION); } else loaded=1; } - if (!nightLoaded && getRelativeFileName (CTile::additive, index)!="") + if (!nightLoaded && !getRelativeFileName (CTile::additive, index).empty()) { if (!_LoadBitmap(tileBank2.getAbsPath() + getRelativeFileName (CTile::additive, index), &nightBmpInfo, nightBits, Alpha, 0)) { bRes=false; - MessageBox (NULL, (tileBank2.getAbsPath() + getRelativeFileName (CTile::additive, index)).c_str(), "Can't load file", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(tileBank2.getAbsPath() + getRelativeFileName (CTile::additive, index)), _T("Can't load file"), MB_OK|MB_ICONEXCLAMATION); } else nightLoaded=1; } - if (!alphaLoaded && getRelativeFileName (CTile::alpha, index)!="") + if (!alphaLoaded && !getRelativeFileName (CTile::alpha, index).empty()) { if (!_LoadBitmap(tileBank2.getAbsPath() + getRelativeFileName (CTile::alpha, index), &alphaBmpInfo, alphaBits, NULL, tileBank2.getTile (index)->getRotAlpha ())) { bRes=false; - MessageBox (NULL, (tileBank2.getAbsPath() + getRelativeFileName (CTile::alpha, index)).c_str(), "Can't load file", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(tileBank2.getAbsPath() + getRelativeFileName (CTile::alpha, index)), _T("Can't load file"), MB_OK|MB_ICONEXCLAMATION); } else alphaLoaded=1; @@ -754,7 +760,7 @@ void CTView::Init(int _land, int n) pImList = new CImageList; pImList->Create(sizetile_x,sizetile_y,ILC_COLOR24,0,1); pImList->Add(bmp,(CBitmap*)NULL); - char *defautpath = ((SelectionTerritoire*)GetParent()->GetParent())->DefautPath.GetBuffer(256); + TCHAR *defautpath = ((SelectionTerritoire*)GetParent()->GetParent())->DefautPath.GetBuffer(256); count_=1; } @@ -1124,8 +1130,8 @@ void CTView::OnDropFiles(HDROP hDropInfo) if (!lockInsertion) { Browse *parent = (Browse*)this->GetParent(); - char FileName[256]; - int count=DragQueryFile(hDropInfo,0xffffffff,FileName,256); //count = files number in drop queue + TCHAR FileName[256]; + int count=DragQueryFile(hDropInfo, 0xffffffff, FileName, 256); //count = files number in drop queue POINT pos; @@ -1139,7 +1145,7 @@ void CTView::OnDropFiles(HDROP hDropInfo) case 0: { int index=InfoList.addTile128 (); - if (InfoList.setTile128 (index, FileName, Texture==1?CTile::diffuse:(Texture==2?CTile::additive:CTile::alpha))) + if (InfoList.setTile128 (index, tStrToUtf8(FileName), Texture==1?CTile::diffuse:(Texture==2?CTile::additive:CTile::alpha))) { tilelist::iterator it = InfoList.GetLast(parent->m_128x128); it--; @@ -1153,7 +1159,7 @@ void CTView::OnDropFiles(HDROP hDropInfo) case 1: { int index=InfoList.addTile256 (); - if (InfoList.setTile256 (index, FileName, Texture==1?CTile::diffuse:(Texture==2?CTile::additive:CTile::alpha))) + if (InfoList.setTile256 (index, tStrToUtf8(FileName), Texture==1?CTile::diffuse:(Texture==2?CTile::additive:CTile::alpha))) { tilelist::iterator it = InfoList.GetLast(parent->m_128x128); it--; @@ -1205,7 +1211,7 @@ void CTView::DrawTile(tilelist::iterator i,CDC *pDC,int clear, int n) if (index!=-1) pth = i->getRelativeFileName ((CTile::TBitmap)(Texture-1), index); else - pth = ""; + pth.clear(); } break; case 3: @@ -1284,11 +1290,10 @@ void CTView::DrawTile(tilelist::iterator i,CDC *pDC,int clear, int n) &*bits->begin(),bmpinf,DIB_RGB_COLORS,SRCCOPY); } - char temp[100]; - char Name[256]; Name[0] = 0; + std::string Name; if (InfoTexte==2) { - _splitpath(pth.c_str(),temp,temp,Name,temp); + Name = NLMISC::CFile::getFilenameWithoutExtension(pth); } else if (InfoTexte==3) { @@ -1296,12 +1301,21 @@ void CTView::DrawTile(tilelist::iterator i,CDC *pDC,int clear, int n) } else if (InfoTexte==1) { - sprintf(Name,"%d",i->id); + Name = NLMISC::toString("%d", i->id); } + rect_txt.top = pt.y + sizetile_y + spacing_tile_text; rect_txt.bottom += rect_txt.top + sizetext_y; rect_txt.left -= spacing_x; - pDC->DrawText(Name,(int)strlen(Name),&rect_txt,DT_CENTER | DT_SINGLELINE); + +#ifdef _UNICODE + ucstring tmp; + tmp.fromUtf8(Name); +#else + std::string tmp = Name; +#endif + + pDC->DrawText((LPCTSTR)tmp.c_str(), (int)tmp.length(), &rect_txt,DT_CENTER | DT_SINGLELINE); // Restore the device context pDC->SetBkColor( clrBk ); @@ -1520,9 +1534,8 @@ LRESULT CTView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) else if ((id==ID_MENU_ADD)||(id==ID_MENU_REPLACE)) { _chdir (LastPath.c_str()); - CFileDialog load(true, NULL, LastPath.c_str(), OFN_ENABLESIZING | OFN_ALLOWMULTISELECT, - "PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL); - load.m_ofn.lpstrFile = new char[10000]; // buffer contains filenames list + CFileDialog load(true, NULL, utf8ToTStr(LastPath), OFN_ENABLESIZING | OFN_ALLOWMULTISELECT, _T("PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||"), NULL); + load.m_ofn.lpstrFile = new TCHAR[10000]; // buffer contains filenames list load.m_ofn.lpstrFile[0] = 0; // with 10 KB we should be large enough... // if all files are exceeding 10000 characters, insert would be skipped @@ -1538,15 +1551,12 @@ LRESULT CTView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { CString str = load.GetNextPathName(p); - char sDrive[256]; - char sPath[256]; - _splitpath (str, sDrive, sPath, NULL, NULL); - LastPath=string (sDrive)+string (sPath); + LastPath = NLMISC::CFile::getPath(tStrToUtf8(str)); - if (str!=CString("")) + if (!str.IsEmpty()) { int index=0; - const char *pathname = (LPCTSTR)str; + std::string pathname = tStrToUtf8(str); // Add mode, to the end of the list if (id==ID_MENU_ADD) @@ -1680,10 +1690,10 @@ void CTView::OnRButtonDown(UINT nFlags, CPoint point) if (!ViewTileMode) { - popup.AppendMenu(parent->m_128x128<2 ? MF_STRING : MF_STRING | MF_GRAYED, ID_MENU_ADD,"Add..."); - popup.AppendMenu(c>0 ? MF_STRING : MF_STRING | MF_GRAYED, ID_MENU_REPLACE, "Replace..."); - popup.AppendMenu(c>0 ? MF_STRING : MF_STRING | MF_GRAYED, ID_MENU_SUPR_BITMAP, "Del bitmap"); - popup.AppendMenu((c>0 && parent->m_128x128<2) ? MF_STRING : MF_STRING | MF_GRAYED, ID_MENU_SUPR_TILE, "Del tile"); + popup.AppendMenu(parent->m_128x128<2 ? MF_STRING : MF_STRING | MF_GRAYED, ID_MENU_ADD, _T("Add...")); + popup.AppendMenu(c>0 ? MF_STRING : MF_STRING | MF_GRAYED, ID_MENU_REPLACE, _T("Replace...")); + popup.AppendMenu(c>0 ? MF_STRING : MF_STRING | MF_GRAYED, ID_MENU_SUPR_BITMAP, _T("Del bitmap")); + popup.AppendMenu((c>0 && parent->m_128x128<2) ? MF_STRING : MF_STRING | MF_GRAYED, ID_MENU_SUPR_TILE, _T("Del tile")); } else { diff --git a/code/nel/tools/3d/tile_edit/ViewColumn.cpp b/code/nel/tools/3d/tile_edit/ViewColumn.cpp index d060b6788..db69b11dc 100644 --- a/code/nel/tools/3d/tile_edit/ViewColumn.cpp +++ b/code/nel/tools/3d/tile_edit/ViewColumn.cpp @@ -19,10 +19,36 @@ #include "ViewColumn.h" #include "Browse.h" -char *WndRegKeys[4][5] = {{"POPUP BOTTOM RX","POPUP BOTTOM RY","POPUP BOTTOM CX","POPUP BOTTOM CY","POPUP BOTTOM N"}, - {"POPUP TOP RX","POPUP TOP RY","POPUP TOP CX","POPUP TOP CY","POPUP TOP N"}, - {"POPUP LEFT RX","POPUP LEFT RY","POPUP LEFT CX","POPUP LEFT CY","POPUP LEFT N"}, - {"POPUP RIGHT RX","POPUP RIGHT RY","POPUP RIGHT CX","POPUP RIGHT CY","POPUP RIGHT N"}}; +TCHAR *WndRegKeys[4][5] = { + { + _T("POPUP BOTTOM RX"), + _T("POPUP BOTTOM RY"), + _T("POPUP BOTTOM CX"), + _T("POPUP BOTTOM CY"), + _T("POPUP BOTTOM N") + }, + { + _T("POPUP TOP RX"), + _T("POPUP TOP RY"), + _T("POPUP TOP CX"), + _T("POPUP TOP CY"), + _T("POPUP TOP N") + }, + { + _T("POPUP LEFT RX"), + _T("POPUP LEFT RY"), + _T("POPUP LEFT CX"), + _T("POPUP LEFT CY"), + _T("POPUP LEFT N") + }, + { + _T("POPUP RIGHT RX"), + _T("POPUP RIGHT RY"), + _T("POPUP RIGHT CX"), + _T("POPUP RIGHT CY"), + _T("POPUP RIGHT N") + } +}; ///////////////////////////////////////////////////////////////////////////// // ViewColumn dialog @@ -164,11 +190,11 @@ BOOL ViewColumn::OnInitDialog() if (RegOpenKey(HKEY_CURRENT_USER,REGKEY_TILEDIT,®key)==ERROR_SUCCESS) { unsigned long value; - RegQueryValueEx(regkey,WndRegKeys[pos&3][0],0,&value,(unsigned char *)&rx,&value); - RegQueryValueEx(regkey,WndRegKeys[pos&3][1],0,&value,(unsigned char *)&ry,&value); - RegQueryValueEx(regkey,WndRegKeys[pos&3][2],0,&value,(unsigned char *)&cx,&value); - RegQueryValueEx(regkey,WndRegKeys[pos&3][3],0,&value,(unsigned char *)&cy,&value); - RegQueryValueEx(regkey,WndRegKeys[pos&3][4],0,&value,(unsigned char *)&nTileInWnd,&value); + RegQueryValueEx(regkey, WndRegKeys[pos&3][0], 0, &value, (LPBYTE)&rx, &value); + RegQueryValueEx(regkey, WndRegKeys[pos&3][1], 0, &value, (LPBYTE)&ry, &value); + RegQueryValueEx(regkey, WndRegKeys[pos&3][2], 0, &value, (LPBYTE)&cx, &value); + RegQueryValueEx(regkey, WndRegKeys[pos&3][3], 0, &value, (LPBYTE)&cy, &value); + RegQueryValueEx(regkey, WndRegKeys[pos&3][4], 0, &value, (LPBYTE)&nTileInWnd, &value); RegCloseKey(regkey); } EnableScrollBar(SB_VERT); @@ -378,9 +404,9 @@ void ViewColumn::OnRButtonDown(UINT nFlags, CPoint point) // TODO: Add your message handler code here and/or call default CMenu popup; popup.CreatePopupMenu(); - popup.AppendMenu(MF_STRING | (nTileInWnd==1?MF_CHECKED:0),10,"*1"); - popup.AppendMenu(MF_STRING | (nTileInWnd==4?MF_CHECKED:0),12,"*4"); - popup.AppendMenu(MF_STRING,13,"Replace window"); + popup.AppendMenu(MF_STRING | (nTileInWnd == 1 ? MF_CHECKED:0), 10, _T("*1")); + popup.AppendMenu(MF_STRING | (nTileInWnd == 4 ? MF_CHECKED:0), 12, _T("*4")); + popup.AppendMenu(MF_STRING, 13, _T("Replace window")); RECT rect; GetWindowRect(&rect); popup.TrackPopupMenu(TPM_LEFTALIGN,MousePos.x+rect.left,MousePos.y+rect.top,this,NULL); diff --git a/code/nel/tools/3d/tile_edit/ViewColumn.h b/code/nel/tools/3d/tile_edit/ViewColumn.h index 78455fce2..e079c8fc0 100644 --- a/code/nel/tools/3d/tile_edit/ViewColumn.h +++ b/code/nel/tools/3d/tile_edit/ViewColumn.h @@ -23,7 +23,7 @@ // ViewColumn.h : header file // -extern char *WndRegKeys[4][5]; +extern TCHAR *WndRegKeys[4][5]; #include "View.h" diff --git a/code/nel/tools/3d/tile_edit/choose_veget_set.cpp b/code/nel/tools/3d/tile_edit/choose_veget_set.cpp index e1a652675..e1ccf4f4f 100644 --- a/code/nel/tools/3d/tile_edit/choose_veget_set.cpp +++ b/code/nel/tools/3d/tile_edit/choose_veget_set.cpp @@ -61,15 +61,15 @@ END_MESSAGE_MAP() void CChooseVegetSet::OnBrowse() { // Select a veget set - static char BASED_CODE szFilter[] = "NeL VegetSet Files (*.vegetset)|*.vegetset|All Files (*.*)|*.*||"; + static TCHAR BASED_CODE szFilter[] = _T("NeL VegetSet Files (*.vegetset)|*.vegetset|All Files (*.*)|*.*||"); // Create a file dialog - CFileDialog dialog ( TRUE, "*.vegetset", "*.vegetset", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, (CWnd*)Parent); + CFileDialog dialog ( TRUE, _T("*.vegetset"), _T("*.vegetset"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, (CWnd*)Parent); if (dialog.DoModal() == IDOK) { // Get the file name - FileName = dialog.GetFileName (); - Name.SetWindowText (FileName.c_str()); + FileName = tStrToUtf8(dialog.GetFileName ()); + Name.SetWindowText (utf8ToTStr(FileName)); } } @@ -77,10 +77,10 @@ BOOL CChooseVegetSet::OnInitDialog() { CDialog::OnInitDialog(); - if (FileName != "") - Name.SetWindowText (FileName.c_str()); + if (!FileName.empty()) + Name.SetWindowText (utf8ToTStr(FileName)); else - Name.SetWindowText ("Browse..."); + Name.SetWindowText (_T("Browse...")); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE @@ -88,6 +88,6 @@ BOOL CChooseVegetSet::OnInitDialog() void CChooseVegetSet::OnReset() { - FileName = ""; - Name.SetWindowText ("Browse..."); + FileName.clear(); + Name.SetWindowText (_T("Browse...")); } diff --git a/code/nel/tools/3d/tile_edit/custom.cpp b/code/nel/tools/3d/tile_edit/custom.cpp index e33ac3b0f..d7b4f8173 100644 --- a/code/nel/tools/3d/tile_edit/custom.cpp +++ b/code/nel/tools/3d/tile_edit/custom.cpp @@ -97,7 +97,7 @@ LRESULT Custom::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { CString str; clist->GetLBText(i+2,str); - buttonList[i].Create((LPCSTR)str,BS_CHECKBOX,button,this,i+10); + buttonList[i].Create(str,BS_CHECKBOX,button,this,i+10); buttonList[i].SetFont(&font,1); buttonList[i].ModifyStyle(0,WS_VISIBLE); /* RECT st = button; st.left+=20; st.right = client.right - 90; st.top -= 3; diff --git a/code/nel/tools/3d/tile_edit_qt/browser_model.cpp b/code/nel/tools/3d/tile_edit_qt/browser_model.cpp index 68c28dbb8..eab1b193e 100644 --- a/code/nel/tools/3d/tile_edit_qt/browser_model.cpp +++ b/code/nel/tools/3d/tile_edit_qt/browser_model.cpp @@ -51,7 +51,7 @@ static bool loadPic(const string &path, std::vector &tampon, uint return true; } } - catch (NLMISC::Exception& ) { } + catch (const NLMISC::Exception& ) { } return false; } @@ -149,7 +149,7 @@ void TileInfo::Init(int id, TileType tileType) bool TileInfo::Load (int index, std::vector* Alpha) { bool bRes=true; - if (!loaded && getRelativeFileName (Diffuse, index)!="") + if (!loaded && !getRelativeFileName (Diffuse, index).empty()) { path = fixPath(tileBankBrowser.getAbsPath() + getRelativeFileName (Diffuse, index)); @@ -164,7 +164,7 @@ bool TileInfo::Load (int index, std::vector* Alpha) else loaded=1; } - if (!nightLoaded && getRelativeFileName (Additive, index)!="") + if (!nightLoaded && !getRelativeFileName (Additive, index).empty()) { nightPath = fixPath(tileBankBrowser.getAbsPath() + getRelativeFileName (Additive, index)); if (!loadPixmapBuffer( nightPath, nightBits, Alpha, 0)) @@ -175,7 +175,7 @@ bool TileInfo::Load (int index, std::vector* Alpha) else nightLoaded=1; } - if (!alphaLoaded && getRelativeFileName (::Alpha, index)!="") + if (!alphaLoaded && !getRelativeFileName (::Alpha, index).empty()) { alphaPath = fixPath(tileBankBrowser.getAbsPath() + getRelativeFileName (::Alpha, index)); if (!loadPixmapBuffer( alphaPath, alphaBits, NULL, tileBankBrowser.getTile (index)->getRotAlpha ())) @@ -234,7 +234,7 @@ const std::string TileInfo::getRelativeFileName (TileTexture texture, int index) //TODO titegus: remove MAGIC STRING "EmptyDisplacementMap" in Nel \tile_bank.cpp\void CTileNoise::setEmpty () or add an IsEmpty() method !!!! if (currentPath == "EmptyDisplacementMap") - currentPath = ""; + currentPath.clear(); } } diff --git a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp index 063b4cf47..a6ca57fd3 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp @@ -421,7 +421,7 @@ void CTile_browser_dlg::on_batchLoadPushButton_clicked() // Transition to patch CTileSetTransition* trans=tileBankBrowser.getTileSet (tileSetIndex)->getTransition (transition); - if (tileBankBrowser.getTile (trans->getTile())->getRelativeFileName (CTile::alpha)=="") + if (tileBankBrowser.getTile (trans->getTile())->getRelativeFileName (CTile::alpha).empty()) { // Continue ? int ok; @@ -434,7 +434,7 @@ void CTile_browser_dlg::on_batchLoadPushButton_clicked() QString batchNumber = transitionNumber.rightJustified(2, '0'); QString nextBaseName = baseName + batchNumber; QString nextFileName = QDir::toNativeSeparators(fi.absolutePath()) + QDir::separator() + nextBaseName + QString(".") + fi.suffix(); - FILE *pFile=fopen (nextFileName.toUtf8().constData(), "rb"); + FILE *pFile = nlfopen (nextFileName.toUtf8().constData(), "rb"); // Close the file and add the tile if opened if (pFile) @@ -465,14 +465,13 @@ void CTile_browser_dlg::on_batchLoadPushButton_clicked() // Transition to patch //CTileSetTransition* trans=tileBankBrowser.getTileSet (tileSetIndex)->getTransition (transition); - //if (tileBankBrowser.getTile (trans->getTile())->getRelativeFileName ((CTile::TBitmap)tileTextureButtonGroup->checkedId())=="") + //if (tileBankBrowser.getTile (trans->getTile())->getRelativeFileName ((CTile::TBitmap)tileTextureButtonGroup->checkedId()).empty()) //{ // // Try to load a tile with a file name like /tiletransition0.tga // char sName2[256]; // char sFinal[256]; // sprintf (sName2, "%s%02d", sName, (int)transition); - // _makepath (sFinal, sDrive, sPath, sName2, sExt); - // FILE *pFile=fopen (sFinal, "rb"); + // FILE *pFile = nlfopen (sFinal, "rb"); // // Close the file and add the tile if opened // if (pFile) @@ -543,7 +542,7 @@ void CTile_browser_dlg::on_exportBorderPushButton_clicked() else error=true; } - catch (Exception& e) + catch (const Exception& e) { const char *toto=e.what (); error=true; @@ -592,7 +591,7 @@ void CTile_browser_dlg::on_importBorderPushButton_clicked() else error=true; } - catch (Exception& e) + catch (const Exception& e) { const char *toto=e.what (); error=true; diff --git a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp index 2b6612e9c..bd5bb625a 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp @@ -514,7 +514,7 @@ void CTile_edit_dlg::on_absolutePathPushButton_clicked() const std::string& bitmapPath=tileBank.getTile(tiles)->getRelativeFileName ((CTile::TBitmap)type); // not empty ? - if (bitmapPath!="") + if (!bitmapPath.empty()) { // Check the path if ( CheckPath( bitmapPath, path.toUtf8() ) == false ) @@ -583,7 +583,7 @@ void CTile_edit_dlg::on_absolutePathPushButton_clicked() std::string bitmapPath=tileBank.getTile(tiles)->getRelativeFileName ((CTile::TBitmap)type); // not empty ? - if (bitmapPath!="") + if (!bitmapPath.empty()) { // Remove the absolute path bool res=RemovePath (bitmapPath, path.toUtf8()); @@ -603,7 +603,7 @@ void CTile_edit_dlg::on_absolutePathPushButton_clicked() std::string bitmapPath=tileBank.getDisplacementMap (noise); // not empty ? - if (bitmapPath!="") + if (!bitmapPath.empty()) { // Remove the absolute path bool res=RemovePath (bitmapPath, path.toUtf8()); diff --git a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h index 88c32bd05..993420ffa 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h +++ b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h @@ -19,6 +19,8 @@ #include "ui_tile_edit_qt.h" +#include + class QCheckBox; class QPushButton; class QLineEdit; diff --git a/code/nel/tools/3d/tile_edit_qt/tiles_model.h b/code/nel/tools/3d/tile_edit_qt/tiles_model.h index 57aee8687..de093fe09 100644 --- a/code/nel/tools/3d/tile_edit_qt/tiles_model.h +++ b/code/nel/tools/3d/tile_edit_qt/tiles_model.h @@ -1,6 +1,9 @@ #ifndef TILESMODEL_H #define TILESMODEL_H +#include +#include + class TileModel { diff --git a/code/nel/tools/3d/zone_check_bind/zone_check_bind.cpp b/code/nel/tools/3d/zone_check_bind/zone_check_bind.cpp index 465fcddb1..45808e479 100644 --- a/code/nel/tools/3d/zone_check_bind/zone_check_bind.cpp +++ b/code/nel/tools/3d/zone_check_bind/zone_check_bind.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . #include "zone_utility.h" -// +// #include "nel/misc/types_nl.h" #include "nel/misc/path.h" #include "nel/misc/file.h" @@ -54,7 +54,7 @@ struct CPatchVertexInfo uint patchIndex, uint patchVertex, const CVector &pos - ) + ) : ZoneIndex(zoneIndex), PatchIndex(patchIndex), PatchVertex(patchVertex), @@ -89,13 +89,13 @@ typedef CQuadGrid TPVQuadGrid; /** Load the given zone (name without extension) * return a pointer to the zone, or NULL if not found - * Throw an exception if a read error occured + * Throw an exception if a read error occurred */ static CZone *LoadZone(uint16 xPos, uint16 yPos, std::string zoneExt) { std::string zoneName; ::getZoneNameByCoord(xPos, yPos, zoneName); - std::auto_ptr zone(new CZone); + CUniquePtr zone(new CZone); std::string lookedUpZoneName = CPath::lookup(zoneName + zoneExt, false, false, false); if (lookedUpZoneName.empty()) return NULL; CIFile iF; @@ -128,7 +128,7 @@ static void GetCandidateVertices(const CVector &pos, float weldThreshold ) { - dest.clear(); + dest.clear(); CVector half(weldThreshold, weldThreshold, weldThreshold); qg.select(pos - half, pos + half); for (TPVQuadGrid::CIterator it = qg.begin(); it != qg.end(); ++it) @@ -146,8 +146,8 @@ static void GetCandidateVertices(const CVector &pos, //=========================================================================================================================== /** Search a vertex of a patch that can be welded with the given vertex * return -1 if none - */ -static sint GetWeldableVertex(const CBezierPatch &bp, const CVector &pos, float weldThreshold) + */ +static sint GetWeldableVertex(const CBezierPatch &bp, const CVector &pos, float weldThreshold) { for (uint k = 0; k < 4; ++k) { @@ -166,7 +166,7 @@ static sint GetWeldableVertex(const CBezierPatch &bp, const CVector &pos, float static uint CheckZone(std::string middleZoneFile, float weldThreshold, float middleEdgeWeldThreshold) { uint numErrors = 0; - uint k, l, m, n, p, q; // some loop counters + uint k, l, m, n, p, q; // some loop counters // This avoid reporting errors twice (for readability) std::set errorPairs; @@ -174,9 +174,9 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid // Load the zones around // //////////////////////////// - std::auto_ptr zones[9]; + CUniquePtr zones[9]; std::string zoneNames[9]; - CZoneInfo zoneInfos[9]; + CZoneInfo zoneInfos[9]; uint16 xPos, yPos; const sint16 posOffs[][2] = { {0, 0}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1} }; @@ -201,16 +201,16 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid nlinfo("Zones loading failed : %d", e.what()); return 0; } - + /////////////////////////////// // retrieve datas from zones // /////////////////////////////// for (k = 0; k < 9; ++k) { - ::getZoneNameByCoord(xPos + posOffs[k][0], yPos + posOffs[k][1], zoneNames[k]); + ::getZoneNameByCoord(xPos + posOffs[k][0], yPos + posOffs[k][1], zoneNames[k]); if (zones[k].get() != NULL) zones[k]->retrieve(zoneInfos[k]); - } + } // fill the quad grid CAABBox zoneBBox = zones[0]->getZoneBB().getAABBox(); @@ -222,7 +222,7 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid // insert vertices in quadgrid for (k = 0; k < 9; ++k) - { + { for (l = 0; l < zoneInfos[k].Patchs.size(); ++l) { CPatchInfo &patch = zoneInfos[k].Patchs[l]; @@ -236,7 +236,7 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid CVector half(weldThreshold, weldThreshold, weldThreshold); // yes, insert it in the tree qg.insert(pos - half, pos + half, CPatchVertexInfo(k, l, m, pos)); - } + } } } } @@ -246,11 +246,11 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid ///////////////////////////////////////////////// for (l = 0; l < zoneInfos[0].Patchs.size(); ++l) - { + { CPatchInfo &patch = zoneInfos[0].Patchs[l]; // deals with each border for (m = 0; m < 4; ++m) - { + { // if this border is said to be bound, no need to test.. if (patch.BindEdges[m].NPatchs == 0) { @@ -271,10 +271,10 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid ::GetCandidateVertices(patch.Patch.Vertices[vIndex[q]], qg, verts[q], l, 0, weldThreshold); } - + /////////////////////////// // 1 - 1 connectivity ? // - /////////////////////////// + /////////////////////////// // If there is a patch that is present in the 2 lists, then this is a 1-1 error for (n = 0; n < verts[0].size() && !errorFound; ++n) { @@ -288,9 +288,9 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid CPatchIdentPair errPair = std::make_pair(pi1, pi2); // if (std::find(errorPairs.begin(), errorPairs.end(), errPair) == errorPairs.end()) // error already displayed ? - { + { nlinfo("**** Patch %d of zone %s has 1 - 1 connectivity error, try binding it with patch %d of zone %s", - l + 1, middleZoneName.c_str(), verts[0][n]->PatchIndex + 1, zoneNames[verts[0][n]->ZoneIndex].c_str()); + l + 1, middleZoneName.c_str(), verts[0][n]->PatchIndex + 1, zoneNames[verts[0][n]->ZoneIndex].c_str()); errorPairs.insert(std::make_pair(pi2, pi1)); ++numErrors; } @@ -303,10 +303,10 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid ////////////////////////// // 1 - 2 connectivity ? // ////////////////////////// - + // get the position at the middle of that border CVector middlePos = patch.Patch.eval( 0.5f * (indexToST[vIndex[0]][0] + indexToST[vIndex[1]][0]), - 0.5f * (indexToST[vIndex[0]][1] + indexToST[vIndex[1]][1]) ); + 0.5f * (indexToST[vIndex[0]][1] + indexToST[vIndex[1]][1]) ); // for each vertex of this border for (q = 0; q < 2 && !errorFound; ++q) @@ -330,24 +330,24 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid CPatchIdentPair errPair = std::make_pair(pi1, pi2); // if (std::find(errorPairs.begin(), errorPairs.end(), errPair) == errorPairs.end()) // error already displayed ? - { + { nlinfo("**** Patch %d of zone %s has 1 - 2 connectivity error, try binding it with patch %d of zone %s", - l + 1, middleZoneName.c_str(), pv.PatchIndex + 1, zoneNames[pv.ZoneIndex].c_str()); + l + 1, middleZoneName.c_str(), pv.PatchIndex + 1, zoneNames[pv.ZoneIndex].c_str()); errorPairs.insert(std::make_pair(pi2, pi1)); - ++numErrors; + ++numErrors; } errorFound = true; break; - } + } } } - if (errorFound) continue; - + if (errorFound) continue; + ////////////////////////// // 1 - 4 connectivity ? // ////////////////////////// - + // compute points along the border. CVector borderPos[5]; float lambda = 0.f; @@ -356,12 +356,12 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid borderPos[n] = patch.Patch.eval((1.f - lambda) * indexToST[vIndex[0]][0] + lambda * indexToST[vIndex[1]][0], (1.f - lambda) * indexToST[vIndex[0]][1] + lambda * indexToST[vIndex[1]][1]); lambda += 0.25f; - } - + } + // Try to find a patch that shares 2 consecutives vertices for (k = 0; k < 4 && !errorFound; ++k) { - ::GetCandidateVertices(borderPos[k], qg, verts[0], l, 0, middleEdgeWeldThreshold); + ::GetCandidateVertices(borderPos[k], qg, verts[0], l, 0, middleEdgeWeldThreshold); for (p = 0; p < verts[0].size() && !errorFound; ++p) { const CPatchVertexInfo &pv = *(verts[0][p]); @@ -382,16 +382,16 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid CPatchIdentPair errPair = std::make_pair(pi1, pi2); // if (std::find(errorPairs.begin(), errorPairs.end(), errPair) == errorPairs.end()) // error already displayed ? - { + { nlinfo("**** Patch %d of zone %s has 1 - 4 connectivity error, try binding it with patch %d of zone %s", - l + 1, middleZoneName.c_str(), pv.PatchIndex + 1, zoneNames[pv.ZoneIndex].c_str()); + l + 1, middleZoneName.c_str(), pv.PatchIndex + 1, zoneNames[pv.ZoneIndex].c_str()); ++numErrors; errorPairs.insert(std::make_pair(pi2, pi1)); } errorFound = true; } } - } + } } } } @@ -406,26 +406,26 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid //========================================================================================================================= int main(int argc, char* argv[]) -{ +{ NLMISC::createDebug(); InfoLog->addNegativeFilter("adding the path"); if (argc < 4) { std::string appName = CFile::getFilename(std::string(argv[0])); - nlinfo("usage : %s \n", appName.empty() ? "zone_check_bind" : appName.c_str()); + nlinfo("usage : %s \n", appName.empty() ? "zone_check_bind" : appName.c_str()); return -1; } float weldThreshold, middleEdgeWeldThreshold; - if (::sscanf(argv[2], "%f", &weldThreshold) != 1) + if (!fromString(argv[2], weldThreshold)) { nlinfo("invalid weldThreshold"); return -1; } - if (::sscanf(argv[3], "%f", &middleEdgeWeldThreshold) != 1) + if (!fromString(argv[3], middleEdgeWeldThreshold)) { nlinfo("invalid middleEdgeWeldThreshold"); return -1; @@ -442,10 +442,10 @@ int main(int argc, char* argv[]) // Filter addSearchPath CPath::addSearchPath(zonePaths); - + // Contains all the zone in the directory std::vector zoneNames; - + CPath::getPathContent(zonePaths, true, false, true, zoneNames); uint numErrors = 0; @@ -461,4 +461,4 @@ int main(int argc, char* argv[]) nlinfo("%d errors were found", numErrors); } - + diff --git a/code/nel/tools/3d/zone_dependencies/zone_dependencies.cpp b/code/nel/tools/3d/zone_dependencies/zone_dependencies.cpp index b109c2db2..846902cde 100644 --- a/code/nel/tools/3d/zone_dependencies/zone_dependencies.cpp +++ b/code/nel/tools/3d/zone_dependencies/zone_dependencies.cpp @@ -522,7 +522,7 @@ int main (int argc, char* argv[]) // Write the dependencies file FILE *outputFile; - if ((outputFile=fopen (toLower (outputFileName).c_str(), "w"))) + if ((outputFile = nlfopen (toLower (outputFileName), "w"))) { // Add a dependency entry fprintf (outputFile, "dependencies =\n{\n"); diff --git a/code/nel/tools/3d/zone_lighter/zone_lighter.cpp b/code/nel/tools/3d/zone_lighter/zone_lighter.cpp index b3c6807c1..04c165a01 100644 --- a/code/nel/tools/3d/zone_lighter/zone_lighter.cpp +++ b/code/nel/tools/3d/zone_lighter/zone_lighter.cpp @@ -153,14 +153,14 @@ static void loadIGFromVillage(const NLGEORGES::UFormElm *villageItem, const std: if (inputFile.open (nameLookup)) { // New ig - std::auto_ptr group(new CInstanceGroup); + CUniquePtr group(new CInstanceGroup); try { group->serial (inputFile); } catch(const NLMISC::Exception &) { - nlwarning ("Error while loading instance group %s\n", igName.c_str()); + nlwarning ("Error while loading instance group %s", igName.c_str()); continue; } inputFile.close(); diff --git a/code/nel/tools/3d/zviewer/CMakeLists.txt b/code/nel/tools/3d/zviewer/CMakeLists.txt index 35472f39c..c4222c992 100644 --- a/code/nel/tools/3d/zviewer/CMakeLists.txt +++ b/code/nel/tools/3d/zviewer/CMakeLists.txt @@ -2,9 +2,9 @@ FILE(GLOB SRC *.cpp *.h) IF(WIN32) ADD_EXECUTABLE(zviewer WIN32 ${SRC} zviewer.rc) -ELSE(WIN32) +ELSE() ADD_EXECUTABLE(zviewer ${SRC}) -ENDIF(WIN32) +ENDIF() ADD_DEFINITIONS(-DNL_ZVIEWER_CFG="\\"${NL_ETC_PREFIX}/\\"") diff --git a/code/nel/tools/3d/zviewer/zviewer.cpp b/code/nel/tools/3d/zviewer/zviewer.cpp index c5f4419a4..fc8e00a4c 100644 --- a/code/nel/tools/3d/zviewer/zviewer.cpp +++ b/code/nel/tools/3d/zviewer/zviewer.cpp @@ -135,7 +135,6 @@ struct CViewerConfig LandscapeThreshold = 0.001f; LandscapeNoise = true; - HeightFieldName= ""; HeightFieldMaxZ= 100; HeightFieldOriginX= 16000; HeightFieldOriginY= -24000; @@ -344,7 +343,7 @@ void displayZones() CBitmap heightBitmap; CIFile file(ViewerCfg.HeightFieldName); - if( ViewerCfg.HeightFieldName!="" && heightBitmap.load(file) ) + if( !ViewerCfg.HeightFieldName.empty() && heightBitmap.load(file) ) { CHeightMap heightMap; heightMap.buildFromBitmap(heightBitmap); @@ -373,7 +372,7 @@ void displayZones() nlerror (tmp.c_str()); } - if ((Landscape->Landscape.TileBank.getAbsPath ()=="")&&(ViewerCfg.TilesPath!="")) + if ((Landscape->Landscape.TileBank.getAbsPath ().empty())&&(!ViewerCfg.TilesPath.empty())) Landscape->Landscape.TileBank.setAbsPath (ViewerCfg.TilesPath + "/"); if (ViewerCfg.UseDDS) diff --git a/code/nel/tools/build_gamedata/generators/max_exporter_scripts/shape.ms b/code/nel/tools/build_gamedata/generators/max_exporter_scripts/shape.ms index cfb51d0e0..a3b28bc02 100755 --- a/code/nel/tools/build_gamedata/generators/max_exporter_scripts/shape.ms +++ b/code/nel/tools/build_gamedata/generators/max_exporter_scripts/shape.ms @@ -375,7 +375,7 @@ fn runNelMaxExportSub inputMaxFile retryCount = ( -- Error nlerror("ERROR exporting '%PreGenFileExtension%': can't open the file " + inputMaxFile) - nlerror("FAIL Mysterious error occured") + nlerror("FAIL Mysterious error occurred") NelForceQuitRightNow() ) ) diff --git a/code/nel/tools/build_gamedata/generators/tagged_max_exporter_template/export_footer.ms b/code/nel/tools/build_gamedata/generators/tagged_max_exporter_template/export_footer.ms index 2db696b7f..289e9e8b6 100755 --- a/code/nel/tools/build_gamedata/generators/tagged_max_exporter_template/export_footer.ms +++ b/code/nel/tools/build_gamedata/generators/tagged_max_exporter_template/export_footer.ms @@ -91,7 +91,7 @@ catch ( -- Error nlerror("ERROR Fatal error exporting '%PreGenFileExtension%' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") + nlerror("FAIL Fatal error occurred") NelForceQuitRightNow() removeRunningTag = false ) @@ -116,7 +116,7 @@ if (removeRunningTag) then ) else ( - nlerror("FAIL One or more issues occured") + nlerror("FAIL One or more issues occurred") NelForceQuitRightNow() ) diff --git a/code/nel/tools/build_gamedata/processes/anim/maxscript/anim_export.ms b/code/nel/tools/build_gamedata/processes/anim/maxscript/anim_export.ms index fc1eda5f9..8ebded952 100755 --- a/code/nel/tools/build_gamedata/processes/anim/maxscript/anim_export.ms +++ b/code/nel/tools/build_gamedata/processes/anim/maxscript/anim_export.ms @@ -235,7 +235,7 @@ catch ( -- Error nlerror("ERROR Fatal error exporting 'anim' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") + nlerror("FAIL Fatal error occurred") NelForceQuitRightNow() removeRunningTag = false ) @@ -260,7 +260,7 @@ if (removeRunningTag) then ) else ( - nlerror("FAIL One or more issues occured") + nlerror("FAIL One or more issues occurred") NelForceQuitRightNow() ) diff --git a/code/nel/tools/build_gamedata/processes/clodbank/maxscript/clod_export.ms b/code/nel/tools/build_gamedata/processes/clodbank/maxscript/clod_export.ms index 02856d2c7..f2dad66ce 100755 --- a/code/nel/tools/build_gamedata/processes/clodbank/maxscript/clod_export.ms +++ b/code/nel/tools/build_gamedata/processes/clodbank/maxscript/clod_export.ms @@ -292,7 +292,7 @@ catch ( -- Error nlerror("ERROR Fatal error exporting 'clod' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") + nlerror("FAIL Fatal error occurred") NelForceQuitRightNow() removeRunningTag = false ) @@ -317,7 +317,7 @@ if (removeRunningTag) then ) else ( - nlerror("FAIL One or more issues occured") + nlerror("FAIL One or more issues occurred") NelForceQuitRightNow() ) diff --git a/code/nel/tools/build_gamedata/processes/ig/maxscript/ig_export.ms b/code/nel/tools/build_gamedata/processes/ig/maxscript/ig_export.ms index e91732391..5bcdfd42b 100755 --- a/code/nel/tools/build_gamedata/processes/ig/maxscript/ig_export.ms +++ b/code/nel/tools/build_gamedata/processes/ig/maxscript/ig_export.ms @@ -342,7 +342,7 @@ catch ( -- Error nlerror("ERROR Fatal error exporting 'ig' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") + nlerror("FAIL Fatal error occurred") NelForceQuitRightNow() removeRunningTag = false ) @@ -367,7 +367,7 @@ if (removeRunningTag) then ) else ( - nlerror("FAIL One or more issues occured") + nlerror("FAIL One or more issues occurred") NelForceQuitRightNow() ) diff --git a/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms b/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms index d0d7c7ce4..66b1a9df5 100755 --- a/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms +++ b/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms @@ -215,7 +215,7 @@ catch ( -- Error nlerror("ERROR Fatal error exporting 'pacs_prim' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") + nlerror("FAIL Fatal error occurred") NelForceQuitRightNow() removeRunningTag = false ) @@ -240,7 +240,7 @@ if (removeRunningTag) then ) else ( - nlerror("FAIL One or more issues occured") + nlerror("FAIL One or more issues occurred") NelForceQuitRightNow() ) diff --git a/code/nel/tools/build_gamedata/processes/rbank/maxscript/cmb_export.ms b/code/nel/tools/build_gamedata/processes/rbank/maxscript/cmb_export.ms index 4949f7c60..969691b9e 100755 --- a/code/nel/tools/build_gamedata/processes/rbank/maxscript/cmb_export.ms +++ b/code/nel/tools/build_gamedata/processes/rbank/maxscript/cmb_export.ms @@ -227,7 +227,7 @@ catch ( -- Error nlerror("ERROR Fatal error exporting 'cmb' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") + nlerror("FAIL Fatal error occurred") NelForceQuitRightNow() removeRunningTag = false ) @@ -252,7 +252,7 @@ if (removeRunningTag) then ) else ( - nlerror("FAIL One or more issues occured") + nlerror("FAIL One or more issues occurred") NelForceQuitRightNow() ) diff --git a/code/nel/tools/build_gamedata/processes/shape/maxscript/shape_export.ms b/code/nel/tools/build_gamedata/processes/shape/maxscript/shape_export.ms index f97419aa7..375fe8eea 100755 --- a/code/nel/tools/build_gamedata/processes/shape/maxscript/shape_export.ms +++ b/code/nel/tools/build_gamedata/processes/shape/maxscript/shape_export.ms @@ -451,7 +451,7 @@ fn runNelMaxExportSub inputMaxFile retryCount = ( -- Error nlerror("ERROR exporting 'shape': can't open the file " + inputMaxFile) - nlerror("FAIL Mysterious error occured") + nlerror("FAIL Mysterious error occurred") NelForceQuitRightNow() ) ) @@ -559,7 +559,7 @@ catch ( -- Error nlerror("ERROR Fatal error exporting 'shape' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") + nlerror("FAIL Fatal error occurred") NelForceQuitRightNow() removeRunningTag = false ) @@ -584,7 +584,7 @@ if (removeRunningTag) then ) else ( - nlerror("FAIL One or more issues occured") + nlerror("FAIL One or more issues occurred") NelForceQuitRightNow() ) diff --git a/code/nel/tools/build_gamedata/processes/veget/maxscript/veget_export.ms b/code/nel/tools/build_gamedata/processes/veget/maxscript/veget_export.ms index 1b8154530..acc81e21e 100755 --- a/code/nel/tools/build_gamedata/processes/veget/maxscript/veget_export.ms +++ b/code/nel/tools/build_gamedata/processes/veget/maxscript/veget_export.ms @@ -282,7 +282,7 @@ catch ( -- Error nlerror("ERROR Fatal error exporting 'veget' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") + nlerror("FAIL Fatal error occurred") NelForceQuitRightNow() removeRunningTag = false ) @@ -307,7 +307,7 @@ if (removeRunningTag) then ) else ( - nlerror("FAIL One or more issues occured") + nlerror("FAIL One or more issues occurred") NelForceQuitRightNow() ) diff --git a/code/nel/tools/georges/georges2csv/georges2csv.cpp b/code/nel/tools/georges/georges2csv/georges2csv.cpp index 339479bfe..3e1207308 100644 --- a/code/nel/tools/georges/georges2csv/georges2csv.cpp +++ b/code/nel/tools/georges/georges2csv/georges2csv.cpp @@ -179,7 +179,7 @@ void setOutputFile(const CSString &filename) { if (Outf!=NULL) fclose(Outf); - Outf=fopen(filename.c_str(), "wt"); + Outf = nlfopen(filename.c_str(), "wt"); if (Outf == NULL) { fprintf(stderr, "Can't open output file '%s' ! aborting.", filename.c_str()); @@ -382,7 +382,7 @@ void scanFiles(const CSString &filespec) UFormElm *fieldForm=NULL; std::string valueString; - form->getRootNode ().getNodeByName(&fieldForm, fields[i]._name.c_str()); + form->getRootNode ().getNodeByName(&fieldForm, fields[i]._name); if (fieldForm) { @@ -405,7 +405,7 @@ void scanFiles(const CSString &filespec) } else { - if (form->getRootNode ().getValueByName(valueString,fields[i]._name.c_str(),fields[i]._evaluated,&where)) //fieldForm->getValue(valueString,fields[i]._evaluated)) + if (form->getRootNode ().getValueByName(valueString,fields[i]._name, fields[i]._evaluated, &where)) //fieldForm->getValue(valueString,fields[i]._evaluated)) ;//addQuotesRoundString (valueString); else setErrorString (valueString, fields[i]._evaluated, where); @@ -422,7 +422,7 @@ void scanFiles(const CSString &filespec) // UFormElm::TWhereIsValue where; // -// bool result=form->getRootNode ().getValueByName(s,fields[i]._name.c_str(),fields[i]._evaluated,&where); +// bool result=form->getRootNode ().getValueByName(s,fields[i]._name, fields[i]._evaluated,&where); // if (!result) // { // if (fields[i]._evaluated) @@ -550,7 +550,7 @@ void executeScriptBuf(const string &text) void executeScriptFile(const string &filename) { ucstring temp; - CI18N::readTextFile(filename, temp, false, false, false); + CI18N::readTextFile(filename, temp, false, false); if (temp.empty()) { @@ -933,7 +933,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType if ( idm==dirmapDirs.end() ) { nlinfo( "Directory mapping not found for %s (index %u)", filebase.c_str(), letterIndex ); - dirbase = ""; // put into root + dirbase.clear(); // put into root } } else @@ -953,7 +953,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType { // Load sheet (skip if failed) - dirbase = ""; + dirbase.clear(); filename = (*it).second; // whole path form = (CForm*)formLoader->loadForm( filename.c_str() ); if (form == NULL) @@ -1026,7 +1026,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType const UFormElm *fieldForm=NULL; - if (rootForm.getNodeByName(&fieldForm, var.c_str())) + if (rootForm.getNodeByName(&fieldForm, var)) { UFormDfn *dfnForm=const_cast(rootForm).getStructDfn(); nlassert(dfnForm); @@ -1122,8 +1122,8 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType } //nldebug( "%s: %s '%s'", args[0].c_str(), var.c_str(), memberVal.c_str() ); // need to put the value at the correct index. - const std::string fieldName=NLMISC::toString("%s[%d]", var.c_str(), currentMemberIndex).c_str(); - const_cast(rootForm).setValueByName(memberVal.c_str(), fieldName.c_str()); + const std::string fieldName=NLMISC::toString("%s[%u]", var.c_str(), currentMemberIndex).c_str(); + const_cast(rootForm).setValueByName(memberVal, fieldName); isModified=true; displayed = true; } @@ -1132,7 +1132,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType if (!isNewSheet) { string test; - if ( rootForm.getValueByName(test,var.c_str()) + if ( rootForm.getValueByName(test, var) && test==memberVal ) { continue; @@ -1140,7 +1140,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType } //nldebug( "%s: %s '%s'", args[0].c_str(), var.c_str(), memberVal.c_str() ); - const_cast(rootForm).setValueByName(memberVal.c_str(), var.c_str()); + const_cast(rootForm).setValueByName(memberVal, var); isModified=true; displayed = true; } diff --git a/code/nel/tools/logic/CMakeLists.txt b/code/nel/tools/logic/CMakeLists.txt index 496f7f31b..0f65ab8f6 100644 --- a/code/nel/tools/logic/CMakeLists.txt +++ b/code/nel/tools/logic/CMakeLists.txt @@ -1,3 +1,3 @@ IF(MFC_FOUND) SUBDIRS(logic_editor_dll logic_editor_exe) -ENDIF(MFC_FOUND) +ENDIF() diff --git a/code/nel/tools/logic/logic_editor_dll/CMakeLists.txt b/code/nel/tools/logic/logic_editor_dll/CMakeLists.txt index e538799a0..8bf325694 100644 --- a/code/nel/tools/logic/logic_editor_dll/CMakeLists.txt +++ b/code/nel/tools/logic/logic_editor_dll/CMakeLists.txt @@ -13,6 +13,6 @@ NL_ADD_LIB_SUFFIX(logic_editor_dll) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(logic_editor_dll ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.h ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS logic_editor_dll LIBRARY DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${NL_BIN_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT toolsmisc) diff --git a/code/nel/tools/logic/logic_editor_dll/Condition.cpp b/code/nel/tools/logic/logic_editor_dll/Condition.cpp index cc395562e..ba248a80d 100644 --- a/code/nel/tools/logic/logic_editor_dll/Condition.cpp +++ b/code/nel/tools/logic/logic_editor_dll/Condition.cpp @@ -80,7 +80,7 @@ const CString & CConditionNode::getNodeAsString() const m_sNodeString = m_sConditionName; else // comparison { - m_sNodeString.Format("%s %s %g",LPCTSTR(m_sVariableName),LPCTSTR(m_sOperator), m_dComparand ); + m_sNodeString.Format(_T("%s %s %g"),LPCTSTR(m_sVariableName),LPCTSTR(m_sOperator), m_dComparand ); } return m_sNodeString; @@ -260,8 +260,8 @@ void cConditionNodeToCLogicConditionNode(CConditionNode * conditionNode, CLogicC { logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::COMPARISON; - logicConditionNode->LogicBlock.ComparisonBlock.VariableName = string( (LPCSTR)conditionNode->m_sVariableName ); - logicConditionNode->LogicBlock.ComparisonBlock.Operator = string( (LPCSTR)conditionNode->m_sOperator ); + logicConditionNode->LogicBlock.ComparisonBlock.VariableName = tStrToUtf8(conditionNode->m_sVariableName); + logicConditionNode->LogicBlock.ComparisonBlock.Operator = tStrToUtf8(conditionNode->m_sOperator); logicConditionNode->LogicBlock.ComparisonBlock.Comparand = (sint64)conditionNode->m_dComparand; } break; @@ -270,7 +270,7 @@ void cConditionNodeToCLogicConditionNode(CConditionNode * conditionNode, CLogicC { logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::SUB_CONDITION; - logicConditionNode->LogicBlock.SubCondition = string( (LPCSTR)conditionNode->m_sConditionName ); + logicConditionNode->LogicBlock.SubCondition = tStrToUtf8(conditionNode->m_sConditionName); } break; } @@ -298,7 +298,7 @@ void cConditionNodeToCLogicConditionNode(CConditionNode * conditionNode, CLogicC void cConditionToCLogicCondition( CCondition& condition, CLogicCondition& logicCondition ) { // condition name - logicCondition.setName( string( (LPCSTR)condition.m_sName ) ); + logicCondition.setName(tStrToUtf8(condition.m_sName)); // nodes POSITION pos; diff --git a/code/nel/tools/logic/logic_editor_dll/ConditionPage.cpp b/code/nel/tools/logic/logic_editor_dll/ConditionPage.cpp index 60beeec25..e7a4b1567 100644 --- a/code/nel/tools/logic/logic_editor_dll/ConditionPage.cpp +++ b/code/nel/tools/logic/logic_editor_dll/ConditionPage.cpp @@ -272,7 +272,7 @@ void CConditionPage::addCondition( CLogic_editorDoc *pDoc, CCondition * conditio CCondition *pCondition; if (pDoc->m_conditions.Lookup( condition->m_sName, (void*&)pCondition)) { - AfxMessageBox("A condition with this name already exist..."); + AfxMessageBox(_T("A condition with this name already exist...")); return; } @@ -296,7 +296,7 @@ void CConditionPage::OnButtonAddCondition() if (m_sConditionName.IsEmpty()) { - AfxMessageBox("Condition Name cannot be empty, please choose a name"); + AfxMessageBox(_T("Condition Name cannot be empty, please choose a name")); return; } @@ -326,7 +326,7 @@ void CConditionPage::OnButtonAddNode() // check that data are valid if ( checkNodeValidity() == FALSE) { - AfxMessageBox("Invalid node datas - cannot add node"); + AfxMessageBox(_T("Invalid node datas - cannot add node")); return; } @@ -426,7 +426,7 @@ void CConditionPage::OnButtonCondApply() if (m_sConditionName.IsEmpty()) { - AfxMessageBox("Condition Name cannot be empty, please choose a name"); + AfxMessageBox(_T("Condition Name cannot be empty, please choose a name")); return; } @@ -442,7 +442,7 @@ void CConditionPage::OnButtonCondApply() } else { - AfxMessageBox( "No condition selected ! Choose a condition first" ); + AfxMessageBox(_T("No condition selected ! Choose a condition first")); } } @@ -466,7 +466,7 @@ void CConditionPage::OnButtonDeleteCondition() } else { - AfxMessageBox( "No condition selected ! Choose a condition first" ); + AfxMessageBox(_T("No condition selected ! Choose a condition first")); } } @@ -477,7 +477,7 @@ void CConditionPage::OnButtonNodeApply() // check that data are valid if ( checkNodeValidity() == FALSE) { - AfxMessageBox("Invalid node datas - cancel node modification"); + AfxMessageBox(_T("Invalid node datas - cancel node modification")); return; } @@ -517,7 +517,7 @@ void CConditionPage::OnButtonNodeApply() } else { - AfxMessageBox( "No condition node selected ! Choose a node first" ); + AfxMessageBox(_T("No condition node selected ! Choose a node first")); } } @@ -553,6 +553,6 @@ void CConditionPage::OnButtonDeleteNode() } else { - AfxMessageBox( "No condition node selected ! Choose a node first" ); + AfxMessageBox(_T("No condition node selected ! Choose a node first")); } } diff --git a/code/nel/tools/logic/logic_editor_dll/ConditionsView.cpp b/code/nel/tools/logic/logic_editor_dll/ConditionsView.cpp index 5cab8c7ff..a9750d456 100644 --- a/code/nel/tools/logic/logic_editor_dll/ConditionsView.cpp +++ b/code/nel/tools/logic/logic_editor_dll/ConditionsView.cpp @@ -246,7 +246,7 @@ void CConditionsView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) TPositionList heap; - HTREEITEM hItem = m_tree.InsertItem( "Conditions",0,0); + HTREEITEM hItem = m_tree.InsertItem(_T("Conditions"), 0, 0); // get the states map CCondition *pCondition; @@ -645,7 +645,7 @@ void CConditionsView::OnMoveAsChild() } else { - AfxMessageBox("Error : root condition not found"); + AfxMessageBox(_T("Error : root condition not found")); delete pDragNode; } } @@ -722,7 +722,7 @@ void CConditionsView::OnCopyAsChild() } else { - AfxMessageBox("Error : root condition not found"); + AfxMessageBox(_T("Error : root condition not found")); delete pNewNode; } } diff --git a/code/nel/tools/logic/logic_editor_dll/Counter.cpp b/code/nel/tools/logic/logic_editor_dll/Counter.cpp index a7f62823f..52537ea08 100644 --- a/code/nel/tools/logic/logic_editor_dll/Counter.cpp +++ b/code/nel/tools/logic/logic_editor_dll/Counter.cpp @@ -45,7 +45,7 @@ CCounter::~CCounter() void cCounterToCLogicCounter( CCounter& counter, CLogicCounter& logicCounter ) { // counter name - logicCounter.setName( string((LPCSTR)counter.m_sName) ); + logicCounter.setName(tStrToUtf8(counter.m_sName)); // running mode if( counter.m_sMode == "Shuttle" ) diff --git a/code/nel/tools/logic/logic_editor_dll/CounterPage.cpp b/code/nel/tools/logic/logic_editor_dll/CounterPage.cpp index c706114b5..8ca41516d 100644 --- a/code/nel/tools/logic/logic_editor_dll/CounterPage.cpp +++ b/code/nel/tools/logic/logic_editor_dll/CounterPage.cpp @@ -194,7 +194,7 @@ void CCounterPage::OnButtonCounterRemove() } else { - AfxMessageBox( "No counter selected ! Choose a counter first"); + AfxMessageBox(_T("No counter selected ! Choose a counter first")); } } @@ -237,7 +237,7 @@ void CCounterPage::OnButtonCounterApply() } else { - AfxMessageBox( "No counter selected ! Choose a counter first"); + AfxMessageBox(_T("No counter selected ! Choose a counter first")); } } diff --git a/code/nel/tools/logic/logic_editor_dll/EditorFormView.cpp b/code/nel/tools/logic/logic_editor_dll/EditorFormView.cpp index 1fea05476..8380ad163 100644 --- a/code/nel/tools/logic/logic_editor_dll/EditorFormView.cpp +++ b/code/nel/tools/logic/logic_editor_dll/EditorFormView.cpp @@ -76,7 +76,7 @@ void CEditorFormView::OnInitialUpdate() CRect rectPlaceholder; GetWindowRect(rectPlaceholder); - m_pPropertySheet = new CEditorPropertySheet("",this); + m_pPropertySheet = new CEditorPropertySheet(_T(""),this); if (!m_pPropertySheet->Create(this,WS_CHILD | WS_VISIBLE, 0) ) { diff --git a/code/nel/tools/logic/logic_editor_dll/MainFrm.cpp b/code/nel/tools/logic/logic_editor_dll/MainFrm.cpp index 3c4b57729..1f3751265 100644 --- a/code/nel/tools/logic/logic_editor_dll/MainFrm.cpp +++ b/code/nel/tools/logic/logic_editor_dll/MainFrm.cpp @@ -114,7 +114,7 @@ void CMainFrame::OnClose() // load // //----------------------------------------------- -void CMainFrame::load( const char * fileName ) +void CMainFrame::load( const TCHAR * fileName ) { // child frame CChildFrame *pChild = (CChildFrame *) GetActiveFrame(); diff --git a/code/nel/tools/logic/logic_editor_dll/MainFrm.h b/code/nel/tools/logic/logic_editor_dll/MainFrm.h index bafe828c7..966bda122 100644 --- a/code/nel/tools/logic/logic_editor_dll/MainFrm.h +++ b/code/nel/tools/logic/logic_editor_dll/MainFrm.h @@ -36,7 +36,7 @@ public: /** * load a logic state machine */ - void load( const char * fileName ); + void load( const TCHAR *fileName ); #ifdef _DEBUG virtual void AssertValid() const; diff --git a/code/nel/tools/logic/logic_editor_dll/State.cpp b/code/nel/tools/logic/logic_editor_dll/State.cpp index 1cf6065cf..fbfdebb2d 100644 --- a/code/nel/tools/logic/logic_editor_dll/State.cpp +++ b/code/nel/tools/logic/logic_editor_dll/State.cpp @@ -70,7 +70,7 @@ bool operator==( const CEvent &ev1, const CEvent &ev2) void cEventToCLogicEvent( CEvent& event, CLogicEvent& logicEvent ) { /// condition name - logicEvent.ConditionName = string( (LPCSTR)event.m_sConditionName ); + logicEvent.ConditionName = tStrToUtf8(event.m_sConditionName); /// event action logicEvent.EventAction.IsStateChange = !event.m_bActionIsMessage; @@ -78,18 +78,18 @@ void cEventToCLogicEvent( CEvent& event, CLogicEvent& logicEvent ) if( logicEvent.EventAction.IsStateChange ) { /// state name for state change - logicEvent.EventAction.StateChange = string( (LPCSTR)event.m_sStateChange ); + logicEvent.EventAction.StateChange = tStrToUtf8(event.m_sStateChange); } else { /// message destination - logicEvent.EventAction.EventMessage.Destination = string( (LPCSTR)event.m_sMessageDestination ); + logicEvent.EventAction.EventMessage.Destination = tStrToUtf8(event.m_sMessageDestination); /// message id logicEvent.EventAction.EventMessage.MessageId = "LOGIC"; //string( (LPCSTR)event.m_sMessageID ); //TEMP!!! /// message arguments - logicEvent.EventAction.EventMessage.Arguments = string( (LPCSTR)event.m_sArguments ); + logicEvent.EventAction.EventMessage.Arguments = tStrToUtf8(event.m_sArguments); } } // cEventToCLogicEvent // @@ -176,7 +176,7 @@ BOOL CState::removeEvent( CEvent *event) void cStateToCLogicState( CState& state, CLogicState& logicState ) { /// state name - logicState.setName( string( (LPCSTR)state.m_sName ) ); + logicState.setName(tStrToUtf8(state.m_sName)); POSITION pos; for( pos = state.m_evEvents.GetHeadPosition(); pos != NULL; ) diff --git a/code/nel/tools/logic/logic_editor_dll/StatePage.cpp b/code/nel/tools/logic/logic_editor_dll/StatePage.cpp index f3a414b0a..9135f274f 100644 --- a/code/nel/tools/logic/logic_editor_dll/StatePage.cpp +++ b/code/nel/tools/logic/logic_editor_dll/StatePage.cpp @@ -251,7 +251,7 @@ void CStatePage::OnButtonAddState() if (m_sStateName.IsEmpty()) { - AfxMessageBox("State name cannot be empty, please enter a valid name"); + AfxMessageBox(_T("State name cannot be empty, please enter a valid name")); return; } @@ -366,7 +366,7 @@ void CStatePage::OnButtonStateRemove() // get selected state if (m_pSelectedState != NULL) { - if (AfxMessageBox("Your are about to permanently delete this state.\nDoing so will invalidate all references to this state.\nDo you want to continue anyway ?" ,MB_OKCANCEL|MB_DEFBUTTON2) == IDOK) + if (AfxMessageBox(_T("Your are about to permanently delete this state.\nDoing so will invalidate all references to this state.\nDo you want to continue anyway ?") ,MB_OKCANCEL|MB_DEFBUTTON2) == IDOK) { CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; CChildFrame *pChild = (CChildFrame *) pFrame->GetActiveFrame(); @@ -384,7 +384,7 @@ void CStatePage::OnButtonStateRemove() } else { - AfxMessageBox( "No state selected ! Choose a state first" ); + AfxMessageBox(_T("No state selected ! Choose a state first")); } } @@ -399,11 +399,11 @@ void CStatePage::OnButtonStateApply() { if (m_sStateName.IsEmpty()) { - AfxMessageBox("State name cannot be empty, please enter a valid name"); + AfxMessageBox(_T("State name cannot be empty, please enter a valid name")); return; } - if (AfxMessageBox("Your are about to change this state name.\nDoing so will change all occurence of the old name to the new one.\nDo you want to continue anyway ?" ,MB_OKCANCEL|MB_DEFBUTTON2) == IDOK) + if (AfxMessageBox(_T("Your are about to change this state name.\nDoing so will change all occurence of the old name to the new one.\nDo you want to continue anyway ?") ,MB_OKCANCEL|MB_DEFBUTTON2) == IDOK) { CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; CChildFrame *pChild = (CChildFrame *) pFrame->GetActiveFrame(); @@ -418,14 +418,14 @@ void CStatePage::OnButtonStateApply() } else { - AfxMessageBox( "No state selected ! Choose a state first" ); + AfxMessageBox(_T("No state selected ! Choose a state first")); } } void CStatePage::OnButtonEventApply() { // TODO: Add your control notification handler code here - AfxMessageBox( "Features not implemented" ); + AfxMessageBox(_T("Features not implemented")); } void CStatePage::OnButtonEventRemove() @@ -447,6 +447,6 @@ void CStatePage::OnButtonEventRemove() } else { - AfxMessageBox( "No event selected ! Choose a event first" ); + AfxMessageBox(_T("No event selected ! Choose a event first")); } } diff --git a/code/nel/tools/logic/logic_editor_dll/StatesView.cpp b/code/nel/tools/logic/logic_editor_dll/StatesView.cpp index 4aa74c48d..e466b99d8 100644 --- a/code/nel/tools/logic/logic_editor_dll/StatesView.cpp +++ b/code/nel/tools/logic/logic_editor_dll/StatesView.cpp @@ -131,7 +131,7 @@ void CStatesView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) m_tree.DeleteAllItems(); m_mapItemToEvent.RemoveAll(); - m_tree.InsertItem( "States"); + m_tree.InsertItem(_T("States")); // get the states map CState *pState; diff --git a/code/nel/tools/logic/logic_editor_dll/VariablePage.cpp b/code/nel/tools/logic/logic_editor_dll/VariablePage.cpp index da9ad6991..ef87443b6 100644 --- a/code/nel/tools/logic/logic_editor_dll/VariablePage.cpp +++ b/code/nel/tools/logic/logic_editor_dll/VariablePage.cpp @@ -145,7 +145,7 @@ void CVariablePage::OnButtonVarDelete() } else { - AfxMessageBox( "No variable selected ! Choose a variable first" ); + AfxMessageBox(_T("No variable selected ! Choose a variable first")); } } @@ -178,7 +178,7 @@ void CVariablePage::OnButtonVarApply() } else { - AfxMessageBox( "No variable selected ! Choose a variable first" ); + AfxMessageBox(_T("No variable selected ! Choose a variable first")); } } diff --git a/code/nel/tools/logic/logic_editor_dll/logic_editor.cpp b/code/nel/tools/logic/logic_editor_dll/logic_editor.cpp index cd0c591b2..52e25fd7a 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editor.cpp +++ b/code/nel/tools/logic/logic_editor_dll/logic_editor.cpp @@ -321,7 +321,7 @@ void CLogicEditor::go() // loadFile // //--------------------------------------------- -void CLogicEditor::loadFile( const char * fileName ) +void CLogicEditor::loadFile( const TCHAR * fileName ) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); @@ -337,7 +337,7 @@ void CLogicEditor::loadFile( const char * fileName ) // create a default file // //--------------------------------------------- -void CLogicEditor::createDefaultFile( const char * fileName ) +void CLogicEditor::createDefaultFile( const TCHAR * fileName ) { // create an empty doc CLogic_editorDoc * pDoc = CLogic_editorDoc::getNewDoc(); @@ -402,7 +402,7 @@ ILogicEditor * ILogicEditor::getInterface( int version ) // Check version number if( version != LOGIC_EDITOR_VERSION ) { - MessageBox( NULL, "Bad version of logic_editor.dll.", "Logic Editor", MB_ICONEXCLAMATION|MB_OK); + MessageBox( NULL, _T("Bad version of logic_editor.dll."), _T("Logic Editor"), MB_ICONEXCLAMATION|MB_OK); return NULL; } else diff --git a/code/nel/tools/logic/logic_editor_dll/logic_editor.h b/code/nel/tools/logic/logic_editor_dll/logic_editor.h index 42dc19ee0..80b6e981b 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editor.h +++ b/code/nel/tools/logic/logic_editor_dll/logic_editor.h @@ -88,12 +88,12 @@ public: /** * load file */ - virtual void loadFile( const char * fileName ); + virtual void loadFile( const TCHAR * fileName ); /** * create a default file */ - virtual void createDefaultFile( const char * filename = "logic.logic "); + virtual void createDefaultFile( const TCHAR * filename = _T("logic.logic ")); /** diff --git a/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp b/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp index 0b91c41f4..de2e75e23 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp +++ b/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp @@ -488,7 +488,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) { variable = m_variables.GetNext( pos ); CLogicVariable logicVariable; - logicVariable.setName( string((LPCSTR)variable) ); + logicVariable.setName(tStrToUtf8(variable)); logicStateMachine.addVariable( logicVariable ); } @@ -502,7 +502,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) CLogicCounter logicCounter; cCounterToCLogicCounter( *pCounter, logicCounter ); // set the logic counter name - logicCounter.setName( (LPCSTR)eltName ); + logicCounter.setName(tStrToUtf8(eltName)); // add the logic counter logicStateMachine.addCounter( logicCounter ); } @@ -517,7 +517,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) CLogicCondition logicCondition; cConditionToCLogicCondition( *pCondition, logicCondition ); // set the logic condition name - logicCondition.setName( (LPCSTR)eltName ); + logicCondition.setName(tStrToUtf8(eltName)); // add the logic condition logicStateMachine.addCondition( logicCondition ); } @@ -532,7 +532,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) CLogicState logicState; cStateToCLogicState( *pState, logicState ); // set the logic state's name - logicState.setName( (LPCSTR)eltName ); + logicState.setName(tStrToUtf8(eltName)); // add the logic state logicStateMachine.addState( logicState ); } @@ -542,14 +542,14 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) if(pos != NULL) { m_states.GetNextAssoc( pos, eltName, (void*&)pState ); - logicStateMachine.setCurrentState( string((LPCSTR)eltName) ); + logicStateMachine.setCurrentState(tStrToUtf8(eltName)); } else { - logicStateMachine.setCurrentState( string("") ); + logicStateMachine.setCurrentState(""); } // set the name of the state machine - logicStateMachine.setName( string(fileName) ); + logicStateMachine.setName(tStrToUtf8(fileName)); // Check exceptions @@ -559,7 +559,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) COFile file; // Open the file - file.open (fileName); + file.open (tStrToUtf8(fileName)); // Create the XML stream COXml output; @@ -578,7 +578,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) // Close the file file.close (); } - catch (Exception &) + catch (const Exception &) { } @@ -625,7 +625,7 @@ BOOL CLogic_editorDoc::load( LPCTSTR fileName ) CIFile file; // Open the file - file.open (fileName); + file.open (tStrToUtf8(fileName)); // Create the XML stream CIXml xmlfileIn; @@ -646,7 +646,7 @@ BOOL CLogic_editorDoc::load( LPCTSTR fileName ) // Close the file file.close (); } - catch (Exception &) + catch (const Exception &) { } diff --git a/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.h b/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.h index 39fd90d7e..1fa9156a0 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.h +++ b/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.h @@ -53,7 +53,7 @@ public: * change a variable name (all it's occurence) * \param CString old the old name of the var (not a reference because we may delete the string when deleting the variable !!) * \param CString &newName the new name of the var - * \return BOOL TRUE if the change has been made, FALSE if an error occured + * \return BOOL TRUE if the change has been made, FALSE if an error occurred */ BOOL changeVarName( CString old, const CString &newName); @@ -67,7 +67,7 @@ public: * change a counter name (all it's occurence) * \param CString old the old name of the counter * \param CString &newName the new name of the counter - * \return BOOL TRUE if the change has been made, FALSE if an error occured + * \return BOOL TRUE if the change has been made, FALSE if an error occurred */ BOOL changeCounterName( CString old, const CString &newName); @@ -82,7 +82,7 @@ public: * change a condition name (all it's occurence) * \param CString old the old name of the condition * \param CString &newName the new name of the condition - * \return BOOL TRUE if the change has been made, FALSE if an error occured + * \return BOOL TRUE if the change has been made, FALSE if an error occurred */ BOOL changeConditionName( CString old, const CString &newName); @@ -97,7 +97,7 @@ public: * change a state name (all it's occurence) * \param CString old the old name of the state * \param CString &newName the new name of the state - * \return BOOL TRUE if the change has been made, FALSE if an error occured + * \return BOOL TRUE if the change has been made, FALSE if an error occurred */ BOOL changeStateName( CString old, const CString &newName); diff --git a/code/nel/tools/logic/logic_editor_dll/logic_editor_interface.h b/code/nel/tools/logic/logic_editor_dll/logic_editor_interface.h index 4e48ceb6f..d0059571c 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editor_interface.h +++ b/code/nel/tools/logic/logic_editor_dll/logic_editor_interface.h @@ -17,6 +17,8 @@ #ifndef LOGIC_EDITOR_INTERFACE #define LOGIC_EDITOR_INTERFACE +#include + #ifndef LOGIC_EDITOR_EXPORT #define LOGIC_EDITOR_EXPORT __declspec( dllimport ) #endif // LOGIC_EDITOR_EXPORT @@ -54,10 +56,10 @@ public: virtual void*getMainFrame ()=0; // load a logic file - virtual void loadFile( const char * fileName ) = 0; + virtual void loadFile( const TCHAR * fileName ) = 0; // create a default file - virtual void createDefaultFile( const char * filename = "logic.logic ") = 0; + virtual void createDefaultFile( const TCHAR * filename = _T("logic.logic ")) = 0; // Get instance static LOGIC_EDITOR_EXPORT ILogicEditor * getInterface( int version = LOGIC_EDITOR_VERSION ); diff --git a/code/nel/tools/logic/logic_editor_exe/CMakeLists.txt b/code/nel/tools/logic/logic_editor_exe/CMakeLists.txt index 7a210a71a..455cb2d8f 100644 --- a/code/nel/tools/logic/logic_editor_exe/CMakeLists.txt +++ b/code/nel/tools/logic/logic_editor_exe/CMakeLists.txt @@ -8,6 +8,6 @@ NL_ADD_RUNTIME_FLAGS(logic_editor) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(logic_editor ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.h ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS logic_editor RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT toolsmisc) diff --git a/code/nel/tools/misc/bnp_make/main.cpp b/code/nel/tools/misc/bnp_make/main.cpp index 868f36f62..d6842b8fe 100644 --- a/code/nel/tools/misc/bnp_make/main.cpp +++ b/code/nel/tools/misc/bnp_make/main.cpp @@ -85,14 +85,14 @@ bool i_comp(const string &s0, const string &s1) return nlstricmp (CFile::getFilename(s0).c_str(), CFile::getFilename(s1).c_str()) < 0; } -void packSubRecurse(const std::string &srcDirectory) +bool packSubRecurse(const std::string &srcDirectory) { vector pathContent; printf ("Treating directory: %s\n", srcDirectory.c_str()); CPath::getPathContent(srcDirectory, true, false, true, pathContent); - if (pathContent.empty()) return; + if (pathContent.empty()) return true; // Sort filename sort (pathContent.begin(), pathContent.end(), i_comp); @@ -102,8 +102,8 @@ void packSubRecurse(const std::string &srcDirectory) { if (toLower(CFile::getFilename(pathContent[i-1])) == toLower(CFile::getFilename(pathContent[i]))) { - nlerror("File %s is not unique in BNP!", CFile::getFilename(pathContent[i]).c_str()); - return; + nlwarning("File %s is not unique in BNP!", CFile::getFilename(pathContent[i]).c_str()); + return false; } } @@ -121,6 +121,8 @@ void packSubRecurse(const std::string &srcDirectory) } } } + + return true; } // --------------------------------------------------------------------------- @@ -194,7 +196,8 @@ int main(int argc, char **argv) CFile::deleteFile(gBNPHeader.BigFileName); - packSubRecurse(srcDirectory); + if (!packSubRecurse(srcDirectory)) return 1; + return gBNPHeader.appendHeader() ? 0:-1; } diff --git a/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp b/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp index cfcd82c9f..134eddebf 100644 --- a/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp +++ b/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp @@ -92,14 +92,14 @@ BOOL CBranch_patcherDlg::OnInitDialog() SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon - + // Extra initialization here RECT cltRect; - GetClientRect( &cltRect ), - m_Display = new CRichEditCtrl(); - m_Display->Create( WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|ES_AUTOHSCROLL|ES_AUTOVSCROLL|ES_MULTILINE, - CRect( 20, 180, cltRect.right-20, cltRect.bottom-20 ), this, 1 ); + GetClientRect(&cltRect), + m_Display = new CRichEditCtrl(); + m_Display->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, + CRect(20, 180, cltRect.right - 20, cltRect.bottom - 20), this, 1); // Initialize directories loadConfiguration(); @@ -109,8 +109,8 @@ BOOL CBranch_patcherDlg::OnInitDialog() EnteringTokens = false; m_SrcDirLabel = "Source Dir"; m_TargetDirLabel = "Target Dir"; - UpdateData( false ); - ((CButton*)GetDlgItem( IDC_DoPatch ))->EnableWindow( FALSE ); + UpdateData(false); + ((CButton*)GetDlgItem(IDC_DoPatch))->EnableWindow(FALSE); return TRUE; // return TRUE unless you set the focus to a control } @@ -119,13 +119,13 @@ BOOL CBranch_patcherDlg::OnInitDialog() // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. -void CBranch_patcherDlg::OnPaint() +void CBranch_patcherDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); + SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); @@ -146,38 +146,38 @@ void CBranch_patcherDlg::OnPaint() HCURSOR CBranch_patcherDlg::OnQueryDragIcon() { - return (HCURSOR) m_hIcon; + return (HCURSOR)m_hIcon; } -void CBranch_patcherDlg::setSrcDirectory( const CString& s ) +void CBranch_patcherDlg::setSrcDirectory(const CString& s) { m_SrcDir = s; - UpdateData( false ); + UpdateData(false); } -void CBranch_patcherDlg::setDestDirectory( const CString& s ) +void CBranch_patcherDlg::setDestDirectory(const CString& s) { m_DestDir = s; - UpdateData( false ); + UpdateData(false); } -void CBranch_patcherDlg::OnButtonSetSrcDir() +void CBranch_patcherDlg::OnButtonSetSrcDir() { DirDialog.m_strTitle = "Please choose the SOURCE directory"; - if ( DirDialog.DoBrowse() == TRUE ) + if (DirDialog.DoBrowse() == TRUE) { - setSrcDirectory( DirDialog.m_strPath ); + setSrcDirectory(DirDialog.m_strPath); guessDestDirectory(); } } -void CBranch_patcherDlg::OnButtonSetDestDir() +void CBranch_patcherDlg::OnButtonSetDestDir() { DirDialog.m_strTitle = "Please choose the TARGET directory"; - if ( DirDialog.DoBrowse() == TRUE ) + if (DirDialog.DoBrowse() == TRUE) { - setDestDirectory( DirDialog.m_strPath ); + setDestDirectory(DirDialog.m_strPath); } } @@ -198,80 +198,83 @@ CDirDialog::~CDirDialog() } -int CDirDialog::DoBrowse () +int CDirDialog::DoBrowse() {///////////////////////////////////////// - LPMALLOC pMalloc; - if (SHGetMalloc (&pMalloc)!= NOERROR) - { - return 0; - } + LPMALLOC pMalloc; + if (SHGetMalloc(&pMalloc) != NOERROR) + { + return 0; + } - BROWSEINFO bInfo; - LPITEMIDLIST pidl; - ZeroMemory ( (PVOID) &bInfo,sizeof (BROWSEINFO)); + BROWSEINFO bInfo; + ZeroMemory((PVOID)&bInfo, sizeof(BROWSEINFO)); - if (!m_strInitDir.IsEmpty ()) - { - OLECHAR olePath[MAX_PATH]; - ULONG chEaten; - ULONG dwAttributes; - HRESULT hr; - LPSHELLFOLDER pDesktopFolder; - // // Get a pointer to the Desktop's IShellFolder interface. // - if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder))) - { + if (!m_strInitDir.IsEmpty()) + { + OLECHAR olePath[MAX_PATH]; + ULONG chEaten; + ULONG dwAttributes; + HRESULT hr; + LPSHELLFOLDER pDesktopFolder; + // // Get a pointer to the Desktop's IShellFolder interface. // + if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder))) + { +#ifndef _UNICODE + // + // IShellFolder::ParseDisplayName requires the file name be in Unicode. + // + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, m_strInitDir.GetBuffer(MAX_PATH), -1, olePath, MAX_PATH); - // - // IShellFolder::ParseDisplayName requires the file name be in Unicode. - // - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, m_strInitDir.GetBuffer (MAX_PATH), -1, - olePath, MAX_PATH); + m_strInitDir.ReleaseBuffer(-1); +#else + wcscpy(olePath, (LPCTSTR)m_strInitDir); +#endif + // + // Convert the path to an ITEMIDLIST. + // + hr = pDesktopFolder->ParseDisplayName(NULL, + NULL, + olePath, + &chEaten, + &pidl, + &dwAttributes); - m_strInitDir.ReleaseBuffer (-1); - // - // Convert the path to an ITEMIDLIST. - // - hr = pDesktopFolder->ParseDisplayName(NULL, - NULL, - olePath, - &chEaten, - &pidl, - &dwAttributes); - if (FAILED(hr)) - { - pMalloc ->Free (pidl); - pMalloc ->Release (); - return 0; - } - bInfo.pidlRoot = pidl; - } - } - bInfo.hwndOwner = NULL; - bInfo.pszDisplayName = m_strPath.GetBuffer (MAX_PATH); - bInfo.lpszTitle = (m_strTitle.IsEmpty()) ? "Open":m_strTitle; - bInfo.ulFlags = BIF_RETURNFSANCESTORS|BIF_RETURNONLYFSDIRS; + if (FAILED(hr)) + { + pMalloc->Free(pidl); + pMalloc->Release(); + return 0; + } + bInfo.pidlRoot = pidl; - if ((pidl = ::SHBrowseForFolder (&bInfo)) == NULL) - { - return 0; - } - m_strPath.ReleaseBuffer (); - m_iImageIndex = bInfo.iImage; + } + } - if (::SHGetPathFromIDList(pidl,m_strPath.GetBuffer (MAX_PATH)) == FALSE) - { - pMalloc ->Free (pidl); - pMalloc ->Release (); - return 0; - } + bInfo.hwndOwner = NULL; + bInfo.pszDisplayName = m_strPath.GetBuffer(MAX_PATH); + bInfo.lpszTitle = (m_strTitle.IsEmpty()) ? "Open" : m_strTitle; + bInfo.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; - m_strPath.ReleaseBuffer (); + PIDLIST_ABSOLUTE pidl = ::SHBrowseForFolder(&bInfo); + if (!pidl) return 0; - pMalloc ->Free (pidl); - pMalloc ->Release (); - return 1; + m_strPath.ReleaseBuffer(); + m_iImageIndex = bInfo.iImage; + + if (::SHGetPathFromIDList(pidl, m_strPath.GetBuffer(MAX_PATH)) == FALSE) + { + pMalloc->Free(pidl); + pMalloc->Release(); + return 0; + } + + m_strPath.ReleaseBuffer(); + + pMalloc->Free(pidl); + pMalloc->Release(); + return 1; } @@ -280,87 +283,87 @@ int CDirDialog::DoBrowse () */ BOOL SendTextToClipboard(CString source) { - // Return value is TRUE if the text was sent - // Return value is FALSE if something went wrong - if(OpenClipboard(NULL)) - { - HGLOBAL clipbuffer; - char* buffer; + // Return value is TRUE if the text was sent + // Return value is FALSE if something went wrong + if (OpenClipboard(NULL)) + { + HGLOBAL clipbuffer; + char* buffer; - EmptyClipboard(); // Empty whatever's already there + EmptyClipboard(); // Empty whatever's already there - clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1); - buffer = (char*)GlobalLock(clipbuffer); - strcpy(buffer, LPCSTR(source)); - GlobalUnlock(clipbuffer); + clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength() + 1); + buffer = (char*)GlobalLock(clipbuffer); + strcpy(buffer, LPCSTR(source)); + GlobalUnlock(clipbuffer); - SetClipboardData(CF_TEXT, clipbuffer); // Send the data + SetClipboardData(CF_TEXT, clipbuffer); // Send the data - CloseClipboard(); // VERY IMPORTANT - return TRUE; - } - return FALSE; + CloseClipboard(); // VERY IMPORTANT + return TRUE; + } + return FALSE; } -void CBranch_patcherDlg::displayMessage( const CString& msg, bool insertAtTop ) +void CBranch_patcherDlg::displayMessage(const CString& msg, bool insertAtTop) { - if ( insertAtTop ) - m_Display->SetSel( 0, 0 ); + if (insertAtTop) + m_Display->SetSel(0, 0); else - m_Display->SetSel( 0, -1 ); - m_Display->ReplaceSel( msg ); + m_Display->SetSel(0, -1); + m_Display->ReplaceSel(msg); SaveDiff = false; } -void CBranch_patcherDlg::OnButtonPatch() +void CBranch_patcherDlg::OnButtonPatch() { - UpdateData( true ); + UpdateData(true); CString diffCmdLine; - diffCmdLine.Format( "cvs.exe diff -c > %s 2> %s", TEMP_DIFF_FILE, DIFF_ERRORS ); // needs a valid cvs login before! and cvs.exe in the path + diffCmdLine.Format(_T("cvs.exe diff -c > %s 2> %s"), TEMP_DIFF_FILE, DIFF_ERRORS); // needs a valid cvs login before! and cvs.exe in the path CString text; - text.Format( "Get diff from directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s", m_SrcDir, diffCmdLine ); + text.Format(_T("Get diff from directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s"), m_SrcDir, diffCmdLine); int result; - if ( (result = ::MessageBox( m_hWnd, text, "Confirmation", MB_YESNOCANCEL | MB_ICONQUESTION )) == IDYES ) + if ((result = ::MessageBox(m_hWnd, text, "Confirmation", MB_YESNOCANCEL | MB_ICONQUESTION)) == IDYES) { - if ( _chdir( m_SrcDir ) == 0 ) + if (_chdir(m_SrcDir) == 0) { - system( diffCmdLine ); - displayFile( TEMP_DIFF_FILE ); + system(diffCmdLine); + displayFile(TEMP_DIFF_FILE); SaveDiff = true; colorizeDiff(); - m_Display->LineScroll( 0 ); - ((CButton*)GetDlgItem( IDC_DoPatch ))->EnableWindow( TRUE ); + m_Display->LineScroll(0); + ((CButton*)GetDlgItem(IDC_DoPatch))->EnableWindow(TRUE); - if ( (m_Display->GetLineCount() == 0) || - (m_Display->GetLineCount() == 1 && m_Display->LineLength(0)<2) ) + if ((m_Display->GetLineCount() == 0) || + (m_Display->GetLineCount() == 1 && m_Display->LineLength(0) < 2)) { - displayFile( DIFF_ERRORS ); - displayMessage( "Diff is empty.\r\nIf this is not the expected result:\r\n- check if the source directory is part of a CVS tree\r\n- check if cvs.exe is in your PATH\r\n- check if you are logged to the cvs server with 'cvs login' (set your home cvs directory in the HOME environment variable if needed)\r\n- check if C:\\ has enough free space and access rights to write a file.\n\nHere is the log:\n\n", true ); + displayFile(DIFF_ERRORS); + displayMessage("Diff is empty.\r\nIf this is not the expected result:\r\n- check if the source directory is part of a CVS tree\r\n- check if cvs.exe is in your PATH\r\n- check if you are logged to the cvs server with 'cvs login' (set your home cvs directory in the HOME environment variable if needed)\r\n- check if C:\\ has enough free space and access rights to write a file.\n\nHere is the log:\n\n", true); } else { m_Filename = TEMP_DIFF_FILE + ":"; - UpdateData( false ); + UpdateData(false); } } else { - displayMessage( "Source directory not found" ); + displayMessage("Source directory not found"); } } - else if ( result == IDNO ) + else if (result == IDNO) { - SendTextToClipboard( diffCmdLine ); + SendTextToClipboard(diffCmdLine); } } static unsigned long CALLBACK MyStreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { - CFile* pFile = (CFile*) dwCookie; + CFile* pFile = (CFile*)dwCookie; *pcb = pFile->Read(pbBuff, cb); return 0; } @@ -368,144 +371,144 @@ static unsigned long CALLBACK MyStreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBu static unsigned long CALLBACK MyStreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { - CFile* pFile = (CFile*) dwCookie; + CFile* pFile = (CFile*)dwCookie; pFile->Write(pbBuff, cb); *pcb = cb; return 0; } -void CBranch_patcherDlg::displayFile( const CString& filename ) +void CBranch_patcherDlg::displayFile(const CString& filename) { - CFile cFile( filename, CFile::modeRead ); + CFile cFile(filename, CFile::modeRead); EDITSTREAM es; - es.dwCookie = (DWORD_PTR) &cFile; + es.dwCookie = (DWORD_PTR)&cFile; es.pfnCallback = MyStreamInCallback; - m_Display->StreamIn( SF_TEXT, es ); + m_Display->StreamIn(SF_TEXT, es); } -void CBranch_patcherDlg::saveFile( const CString& filename ) +void CBranch_patcherDlg::saveFile(const CString& filename) { - CFile cFile( filename, CFile::modeCreate | CFile::modeWrite ); + CFile cFile(filename, CFile::modeCreate | CFile::modeWrite); EDITSTREAM es; - es.dwCookie = (DWORD_PTR) &cFile; - es.pfnCallback = MyStreamOutCallback; - m_Display->StreamOut( SF_TEXT, es ); + es.dwCookie = (DWORD_PTR)&cFile; + es.pfnCallback = MyStreamOutCallback; + m_Display->StreamOut(SF_TEXT, es); } void CBranch_patcherDlg::colorizeDiff() { CHARFORMAT blue; - ZeroMemory( &blue, sizeof(blue) ); + ZeroMemory(&blue, sizeof(blue)); blue.cbSize = sizeof(blue); blue.dwMask = CFM_COLOR; - blue.crTextColor = RGB(0,0,0xFF); + blue.crTextColor = RGB(0, 0, 0xFF); CHARFORMAT red; - ZeroMemory( &red, sizeof(red) ); + ZeroMemory(&red, sizeof(red)); red.cbSize = sizeof(red); red.dwMask = CFM_COLOR; - red.crTextColor = RGB(0xFF,0,0); + red.crTextColor = RGB(0xFF, 0, 0); CHARFORMAT green; - ZeroMemory( &green, sizeof(green) ); + ZeroMemory(&green, sizeof(green)); green.cbSize = sizeof(green); green.dwMask = CFM_COLOR; - green.crTextColor = RGB(0,0x7F,0); - for ( int i=0; i!=m_Display->GetLineCount(); ++i ) + green.crTextColor = RGB(0, 0x7F, 0); + for (int i = 0; i != m_Display->GetLineCount(); ++i) { - int c = m_Display->LineIndex( i ); - int l = m_Display->LineLength( c ); - m_Display->SetSel( c, c+l ); + int c = m_Display->LineIndex(i); + int l = m_Display->LineLength(c); + m_Display->SetSel(c, c + l); CString s = m_Display->GetSelText(); - if ( ! s.IsEmpty() ) + if (!s.IsEmpty()) { - if ( s.Left(2) == "+ " ) + if (s.Left(2) == "+ ") { - m_Display->SetSelectionCharFormat( blue ); + m_Display->SetSelectionCharFormat(blue); } - else if ( s.Left(2) == "- " ) + else if (s.Left(2) == "- ") { - m_Display->SetSelectionCharFormat( red ); + m_Display->SetSelectionCharFormat(red); } - else if ( s.Left(2) == "! " ) + else if (s.Left(2) == "! ") { - m_Display->SetSelectionCharFormat( green ); + m_Display->SetSelectionCharFormat(green); } } } } -void CBranch_patcherDlg::OnDoPatch() +void CBranch_patcherDlg::OnDoPatch() { - UpdateData( true ); - - if ( SaveDiff ) + UpdateData(true); + + if (SaveDiff) { // Save the diff from the richedit - saveFile( TEMP_DIFF_FILE ); + saveFile(TEMP_DIFF_FILE); } // Apply the patch CString patchCmdLine, concatOutput, delPatchErrors; - patchCmdLine.Format( "%spatch.exe -c -p%u --verbose < %s > %s 2> %s", PatchExeDir, CvsDiffDirLevel, TEMP_DIFF_FILE, PATCH_RESULT, PATCH_ERRORS ); // needs patch.exe in the path - concatOutput.Format( "copy %s+%s %s", PATCH_RESULT, PATCH_ERRORS, PATCH_RESULT ); - delPatchErrors.Format( "del %s", PATCH_ERRORS ); + patchCmdLine.Format(_T("%spatch.exe -c -p%u --verbose < %s > %s 2> %s"), PatchExeDir, CvsDiffDirLevel, TEMP_DIFF_FILE, PATCH_RESULT, PATCH_ERRORS); // needs patch.exe in the path + concatOutput.Format(_T("copy %s+%s %s"), PATCH_RESULT, PATCH_ERRORS, PATCH_RESULT); + delPatchErrors.Format(_T("del %s"), PATCH_ERRORS); CString text; - text.Format( "Patch diff to directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s", m_DestDir, patchCmdLine ); + text.Format(_T("Patch diff to directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s"), (LPCTSTR)m_DestDir, (LPCTSTR)patchCmdLine); int result; - if ( (result = ::MessageBox( m_hWnd, text, "Confirmation", MB_YESNOCANCEL | MB_ICONQUESTION )) == IDYES ) + if ((result = ::MessageBox(m_hWnd, text, _T("Confirmation"), MB_YESNOCANCEL | MB_ICONQUESTION)) == IDYES) { - if ( _chdir( m_DestDir ) == 0 ) + if (_chdir(m_DestDir) == 0) { - system( patchCmdLine ); - system( concatOutput ); - system( delPatchErrors ); - displayFile( PATCH_RESULT ); + system(patchCmdLine); + system(concatOutput); + system(delPatchErrors); + displayFile(PATCH_RESULT); SaveDiff = false; - m_Display->LineScroll( 0 ); + m_Display->LineScroll(0); - if ( (m_Display->GetLineCount() == 0) || - (m_Display->GetLineCount() == 1 && m_Display->LineLength(0)<2) ) + if ((m_Display->GetLineCount() == 0) || + (m_Display->GetLineCount() == 1 && m_Display->LineLength(0) < 2)) { CString s; - s.Format( "Nothing was patched.\r\nIf this is not the expected result:\r\n- check if the good patch.exe is in %s\r\n- check if %s exists (generated by previous diff)\r\n- check if C:\\ has enough free space and access rights to write a file.", TEMP_DIFF_FILE ); - displayMessage( s ); + s.Format(_T("Nothing was patched.\r\nIf this is not the expected result:\r\n- check if the good patch.exe is in %s\r\n- check if %s exists (generated by previous diff)\r\n- check if C:\\ has enough free space and access rights to write a file."), TEMP_DIFF_FILE); + displayMessage(s); } else { m_Filename = PATCH_RESULT + ":"; - UpdateData( false ); + UpdateData(false); } } else { - displayMessage( "Target directory not found" ); + displayMessage("Target directory not found"); } } - else if ( result == IDNO ) + else if (result == IDNO) { - SendTextToClipboard( patchCmdLine ); + SendTextToClipboard(patchCmdLine); } } -void CBranch_patcherDlg::OnSize(UINT nType, int cx, int cy) +void CBranch_patcherDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); - - if ( m_Display ) + + if (m_Display) { RECT cltRect; - GetClientRect( &cltRect ); + GetClientRect(&cltRect); CRect dispRect; - m_Display->MoveWindow( 20, 180, cltRect.right-40, cltRect.bottom-200, true ); + m_Display->MoveWindow(20, 180, cltRect.right - 40, cltRect.bottom - 200, true); } } -void CBranch_patcherDlg::OnClose() +void CBranch_patcherDlg::OnClose() { saveConfiguration(); @@ -516,10 +519,10 @@ void CBranch_patcherDlg::OnClose() void CBranch_patcherDlg::processCommandLine() { CString cmdLine = theApp.m_lpCmdLine; - - if ( ! cmdLine.IsEmpty() ) + + if (!cmdLine.IsEmpty()) { - setSrcDirectory( cmdLine ); + setSrcDirectory(cmdLine); guessDestDirectory(); } } @@ -527,18 +530,18 @@ void CBranch_patcherDlg::processCommandLine() void CBranch_patcherDlg::guessDestDirectory() { - if ( hasTokens() ) + if (hasTokens()) { CString dir = m_SrcDir; - if ( dir.Find( "\\"+Token1+"\\", 0 ) != -1 ) + if (dir.Find("\\" + Token1 + "\\", 0) != -1) { - dir.Replace( "\\"+Token1+"\\", "\\"+Token2+"\\" ); - setDestDirectory( dir ); + dir.Replace("\\" + Token1 + "\\", "\\" + Token2 + "\\"); + setDestDirectory(dir); } - else if ( dir.Find( "\\"+Token2+"\\", 0 ) != -1 ) + else if (dir.Find("\\" + Token2 + "\\", 0) != -1) { - dir.Replace( "\\"+Token2+"\\", "\\"+Token1+"\\" ); - setDestDirectory( dir ); + dir.Replace("\\" + Token2 + "\\", "\\" + Token1 + "\\"); + setDestDirectory(dir); } } } @@ -548,51 +551,51 @@ void CBranch_patcherDlg::extractDirTokens() { int beginOfToken1, beginOfToken2, endOfToken1, endOfToken2; CString text; - UpdateData( true ); + UpdateData(true); // Search backward from the end until a different substring is found - int c1 = m_SrcDir.GetLength()-1; - int c2 = m_DestDir.GetLength()-1; - while ( (c1 >= 0) && (c2 >= 0) && (m_SrcDir[c1] == m_DestDir[c2]) ) + int c1 = m_SrcDir.GetLength() - 1; + int c2 = m_DestDir.GetLength() - 1; + while ((c1 >= 0) && (c2 >= 0) && (m_SrcDir[c1] == m_DestDir[c2])) { --c1; --c2; } - + // Test if both strings are identical - if ( (c1 < 0) || (c2 < 0) ) + if ((c1 < 0) || (c2 < 0)) { Token1 = m_SrcDir; Token2 = m_DestDir; return; } - endOfToken1 = c1+1; - endOfToken2 = c2+1; + endOfToken1 = c1 + 1; + endOfToken2 = c2 + 1; // Search forward from the beginning until a different substring is found c1 = 0; c2 = 0; - while ( (c1 < m_SrcDir.GetLength()) && (c2 < m_DestDir.GetLength()) && (m_SrcDir[c1] == m_DestDir[c2]) ) + while ((c1 < m_SrcDir.GetLength()) && (c2 < m_DestDir.GetLength()) && (m_SrcDir[c1] == m_DestDir[c2])) { ++c1; ++c2; } - if ( (c1 == m_SrcDir.GetLength()) || (c2 == m_DestDir.GetLength()) ) + if ((c1 == m_SrcDir.GetLength()) || (c2 == m_DestDir.GetLength())) { return; // both strings are identical (should not occur again) } // If one of the token is empty, expand both downto the closest backslash - if ( (c1 == endOfToken1) || (c2 == endOfToken2) ) + if ((c1 == endOfToken1) || (c2 == endOfToken2)) { --c1; - while ( (c1 >= 0) && (m_SrcDir[c1] != '\\') ) + while ((c1 >= 0) && (m_SrcDir[c1] != '\\')) { --c1; } ++c1; --c2; - while ( (c2 >= 0) && (m_DestDir[c2] != '\\') ) + while ((c2 >= 0) && (m_DestDir[c2] != '\\')) { --c2; } @@ -601,67 +604,67 @@ void CBranch_patcherDlg::extractDirTokens() beginOfToken1 = c1; beginOfToken2 = c2; - Token1 = m_SrcDir.Mid( beginOfToken1, endOfToken1-beginOfToken1 ); - Token2 = m_DestDir.Mid( beginOfToken2, endOfToken2-beginOfToken2 ); + Token1 = m_SrcDir.Mid(beginOfToken1, endOfToken1 - beginOfToken1); + Token2 = m_DestDir.Mid(beginOfToken2, endOfToken2 - beginOfToken2); -//endExtract: - /*if ( hasTokens() ) - { - text.Format( "The two branch tokens '%s' and '%s' are now stored", Token1, Token2 ); - ::MessageBox( m_hWnd, text, "Tokens found", MB_OK | MB_ICONINFORMATION ); - return; - }*/ -//notfound: - //::MessageBox( m_hWnd, "Tokens not found in the directories", "Extracting tokens", MB_OK | MB_ICONEXCLAMATION ); + //endExtract: + /*if ( hasTokens() ) + { + text.Format( "The two branch tokens '%s' and '%s' are now stored", Token1, Token2 ); + ::MessageBox( m_hWnd, text, "Tokens found", MB_OK | MB_ICONINFORMATION ); + return; + }*/ + //notfound: + //::MessageBox( m_hWnd, "Tokens not found in the directories", "Extracting tokens", MB_OK | MB_ICONEXCLAMATION ); } void CBranch_patcherDlg::loadConfiguration() { // Read the dest directory from the registry - free( (void*)theApp.m_pszRegistryKey ); - theApp.m_pszRegistryKey = _tcsdup( _T("Nevrax") ); + free((void*)theApp.m_pszRegistryKey); + theApp.m_pszRegistryKey = _tcsdup(_T("Nevrax")); CString savedSrcDir, savedTargetDir, token1, token2; - if ( m_SrcDir.IsEmpty() ) + if (m_SrcDir.IsEmpty()) { - savedSrcDir = theApp.GetProfileString( _T(""), _T("SourceDir") ); - if ( ! savedSrcDir.IsEmpty() ) + savedSrcDir = theApp.GetProfileString(_T(""), _T("SourceDir")); + if (!savedSrcDir.IsEmpty()) { - setSrcDirectory( savedSrcDir ); + setSrcDirectory(savedSrcDir); } } - savedTargetDir = theApp.GetProfileString( _T(""), _T("TargetDir") ); - if ( ! savedTargetDir.IsEmpty() ) + savedTargetDir = theApp.GetProfileString(_T(""), _T("TargetDir")); + if (!savedTargetDir.IsEmpty()) { - setDestDirectory( savedTargetDir ); + setDestDirectory(savedTargetDir); } - Token1 = theApp.GetProfileString( _T(""), _T("Token1") ); - Token2 = theApp.GetProfileString( _T(""), _T("Token2") ); - PatchExeDir = theApp.GetProfileString( _T(""), _T("PatchExeDir") ); - CvsDiffDirLevel = theApp.GetProfileInt( _T(""), _T("CvsDiffDirLevel"), 1 ); // 0 for old version of CVS, 1 for new version of CVS + Token1 = theApp.GetProfileString(_T(""), _T("Token1")); + Token2 = theApp.GetProfileString(_T(""), _T("Token2")); + PatchExeDir = theApp.GetProfileString(_T(""), _T("PatchExeDir")); + CvsDiffDirLevel = theApp.GetProfileInt(_T(""), _T("CvsDiffDirLevel"), 1); // 0 for old version of CVS, 1 for new version of CVS } void CBranch_patcherDlg::saveConfiguration() { - UpdateData( true ); - if ( ! EnteringTokens ) + UpdateData(true); + if (!EnteringTokens) { - theApp.WriteProfileString( _T(""), _T("SourceDir"), m_SrcDir ); - theApp.WriteProfileString( _T(""), _T("TargetDir"), m_DestDir ); + theApp.WriteProfileString(_T(""), _T("SourceDir"), m_SrcDir); + theApp.WriteProfileString(_T(""), _T("TargetDir"), m_DestDir); } - theApp.WriteProfileString( _T(""), _T("Token1"), Token1 ); - theApp.WriteProfileString( _T(""), _T("Token2"), Token2 ); + theApp.WriteProfileString(_T(""), _T("Token1"), Token1); + theApp.WriteProfileString(_T(""), _T("Token2"), Token2); } -void CBranch_patcherDlg::OnButtonExtractTokens() +void CBranch_patcherDlg::OnButtonExtractTokens() { - if ( ! EnteringTokens ) + if (!EnteringTokens) { EnteringTokens = true; - extractDirTokens(); + extractDirTokens(); SrcDirBackup = m_SrcDir; TargetDirBackup = m_DestDir; m_SrcDir = Token1; @@ -669,18 +672,18 @@ void CBranch_patcherDlg::OnButtonExtractTokens() m_SrcDirLabel = "Enter Token 1"; m_TargetDirLabel = "Enter Token 2"; m_Filename = "The tokens above were extracted from the directories."; - ((CButton*)GetDlgItem( IDC_ButtonExtractTokens ))->SetWindowText( "Store Tokens" ); - GetDlgItem( IDC_TopText )->ShowWindow( SW_HIDE ); - GetDlgItem( IDC_ButtonClearTokens )->EnableWindow( FALSE ); - GetDlgItem( IDC_ButtonPatch )->ShowWindow( SW_HIDE ); - GetDlgItem( IDC_ButtonPatch )->EnableWindow( FALSE ); - GetDlgItem( IDC_DoPatch )->ShowWindow( SW_HIDE ); - GetDlgItem( IDC_Group )->ShowWindow( SW_HIDE ); - UpdateData( false ); + ((CButton*)GetDlgItem(IDC_ButtonExtractTokens))->SetWindowText(_T("Store Tokens")); + GetDlgItem(IDC_TopText)->ShowWindow(SW_HIDE); + GetDlgItem(IDC_ButtonClearTokens)->EnableWindow(FALSE); + GetDlgItem(IDC_ButtonPatch)->ShowWindow(SW_HIDE); + GetDlgItem(IDC_ButtonPatch)->EnableWindow(FALSE); + GetDlgItem(IDC_DoPatch)->ShowWindow(SW_HIDE); + GetDlgItem(IDC_Group)->ShowWindow(SW_HIDE); + UpdateData(false); } else { - UpdateData( true ); + UpdateData(true); EnteringTokens = false; Token1 = m_SrcDir; Token2 = m_DestDir; @@ -688,37 +691,37 @@ void CBranch_patcherDlg::OnButtonExtractTokens() m_TargetDirLabel = "Target Dir"; m_SrcDir = SrcDirBackup; m_DestDir = TargetDirBackup; - m_Filename = ""; - ((CButton*)GetDlgItem( IDC_ButtonExtractTokens ))->SetWindowText( "Enter Tokens" ); - GetDlgItem( IDC_TopText )->ShowWindow( SW_SHOW ); - GetDlgItem( IDC_ButtonClearTokens )->EnableWindow( TRUE ); - GetDlgItem( IDC_ButtonPatch )->ShowWindow( SW_SHOW ); - GetDlgItem( IDC_ButtonPatch )->EnableWindow( TRUE ); - GetDlgItem( IDC_DoPatch )->ShowWindow( SW_SHOW ); - GetDlgItem( IDC_Group )->ShowWindow( SW_SHOW ); + m_Filename.Empty(); + ((CButton*)GetDlgItem(IDC_ButtonExtractTokens))->SetWindowText(_T("Enter Tokens")); + GetDlgItem(IDC_TopText)->ShowWindow(SW_SHOW); + GetDlgItem(IDC_ButtonClearTokens)->EnableWindow(TRUE); + GetDlgItem(IDC_ButtonPatch)->ShowWindow(SW_SHOW); + GetDlgItem(IDC_ButtonPatch)->EnableWindow(TRUE); + GetDlgItem(IDC_DoPatch)->ShowWindow(SW_SHOW); + GetDlgItem(IDC_Group)->ShowWindow(SW_SHOW); displayTokens(); } } -void CBranch_patcherDlg::OnButtonClearTokens() +void CBranch_patcherDlg::OnButtonClearTokens() { - Token1 = ""; - Token2 = ""; + Token1.Empty(); + Token2.Empty(); displayTokens(); } bool CBranch_patcherDlg::hasTokens() const { - return ! (Token1.IsEmpty() || Token2.IsEmpty()); + return !(Token1.IsEmpty() || Token2.IsEmpty()); } void CBranch_patcherDlg::displayTokens() { - ((CButton*)GetDlgItem( IDC_ButtonClearTokens ))->EnableWindow( hasTokens()?TRUE:FALSE ); - if ( hasTokens() ) + ((CButton*)GetDlgItem(IDC_ButtonClearTokens))->EnableWindow(hasTokens() ? TRUE : FALSE); + if (hasTokens()) { m_Tokens = "Tokens: '" + Token1 + "' and '" + Token2 + "'"; } @@ -726,5 +729,5 @@ void CBranch_patcherDlg::displayTokens() { m_Tokens = "No token"; } - UpdateData( false ); + UpdateData(false); } diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.ui b/code/nel/tools/misc/crash_report/crash_report_widget.ui index da1e38618..2dbc1e044 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.ui +++ b/code/nel/tools/misc/crash_report/crash_report_widget.ui @@ -20,7 +20,7 @@ - What were you doing when the crash occured? + What were you doing when the crash occurred? diff --git a/code/nel/tools/misc/data_mirror/data_mirror.cpp b/code/nel/tools/misc/data_mirror/data_mirror.cpp index 930e23873..99a87f547 100644 --- a/code/nel/tools/misc/data_mirror/data_mirror.cpp +++ b/code/nel/tools/misc/data_mirror/data_mirror.cpp @@ -198,7 +198,7 @@ BOOL CData_mirrorApp::InitInstance() } } } - catch (Exception &e) + catch (const Exception &e) { MessageBox (NULL, e.what (), "NeL Data Mirror", MB_OK|MB_ICONEXCLAMATION); } diff --git a/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp b/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp index 340655e36..4fb771d86 100644 --- a/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp +++ b/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp @@ -280,7 +280,7 @@ void CData_mirrorDlg::updateList () { // Add the items const CEntryFile &entry = *ite; - uint nItem = List.InsertItem (0, entry.Strings[CEntryFile::Path].c_str (), entry.Image); + uint nItem = List.InsertItem (0, utf8ToTStr(entry.Strings[CEntryFile::Path]), entry.Image); List.SetItemData (nItem, DWORD(new std::list::iterator (ite))); // Sub string @@ -289,25 +289,25 @@ void CData_mirrorDlg::updateList () // Add the sizes if (ModifiedFilter != Removed) { - List.SetItemText (nItem, subString++, entry.Strings[CEntryFile::NewSize].c_str ()); + List.SetItemText (nItem, subString++, utf8ToTStr(entry.Strings[CEntryFile::NewSize])); } if (ModifiedFilter != Added) { - List.SetItemText (nItem, subString++, entry.Strings[CEntryFile::OldSize].c_str ()); + List.SetItemText (nItem, subString++, utf8ToTStr(entry.Strings[CEntryFile::OldSize])); } // Add the dates if (ModifiedFilter != Removed) { - List.SetItemText (nItem, subString++, entry.Strings[CEntryFile::NewDate].c_str ()); + List.SetItemText (nItem, subString++, utf8ToTStr(entry.Strings[CEntryFile::NewDate])); } if (ModifiedFilter != Added) { - List.SetItemText (nItem, subString++, entry.Strings[CEntryFile::OldDate].c_str ()); + List.SetItemText (nItem, subString++, utf8ToTStr(entry.Strings[CEntryFile::OldDate])); } // Add the type - List.SetItemText (nItem, subString++, entry.Strings[CEntryFile::Type].c_str ()); + List.SetItemText (nItem, subString++, utf8ToTStr(entry.Strings[CEntryFile::Type])); // Next item ite++; @@ -382,7 +382,7 @@ void CData_mirrorDlg::OnIgnore() CString itemText = List.GetItemText (i, 0); // Add to ignore list - IgnoreFiles.insert ((const char*)itemText); + IgnoreFiles.insert (tStrToUtf8(itemText)); // Remove from the file list std::list::iterator *ite = (std::list::iterator *)List.GetItemData (i); @@ -408,9 +408,9 @@ void createDirectory (const string &dir) NLMISC::CFile::createDirectory (dir); } -bool setFileTime (const char *filename, const FILETIME &result) +bool setFileTime(const std::string &filename, const FILETIME &result) { - HANDLE handle = CreateFile (filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE handle = CreateFile (utf8ToTStr(filename), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (handle) { SetFileTime (handle, NULL, NULL, &result); @@ -460,7 +460,7 @@ void CData_mirrorDlg::OnOK() createDirectory (directory.c_str ()); if (!CopyFile (source.c_str (), dest.c_str (), FALSE)) { - MessageBox (("Can't copy file "+source+" in file "+dest).c_str (), "NeL Data Mirror", + MessageBox (("Can't copy file "+source+" in file "+dest).c_str (), _T("NeL Data Mirror"), MB_OK|MB_ICONEXCLAMATION); success = false; } @@ -499,7 +499,7 @@ void CData_mirrorDlg::OnOK() createDirectory (directory.c_str ()); if (!CopyFile (source.c_str (), dest.c_str (), FALSE)) { - MessageBox (("Can't copy file "+source+" in file "+dest).c_str (), "NeL Data Mirror", + MessageBox (("Can't copy file "+source+" in file "+dest).c_str (), _T("NeL Data Mirror"), MB_OK|MB_ICONEXCLAMATION); success = false; } @@ -534,7 +534,7 @@ void CData_mirrorDlg::OnOK() if (!DeleteFile (dest.c_str ())) { - MessageBox (("Can't delete the file "+dest).c_str (), "NeL Data Mirror", + MessageBox (("Can't delete the file "+dest).c_str (), _T("NeL Data Mirror"), MB_OK|MB_ICONEXCLAMATION); success = false; } @@ -594,9 +594,9 @@ void CData_mirrorDlg::OnSize(UINT nType, int cx, int cy) resize (); } -bool getFileTime (const char *filename, FILETIME &result) +bool getFileTime (const std::string &filename, FILETIME &result) { - HANDLE handle = CreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE handle = CreateFile (utf8ToTStr(filename), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (handle) { FILETIME res0; @@ -637,8 +637,8 @@ void CData_mirrorDlg::buildSourceFiles () { FILETIME time0; FILETIME time1; - getFileTime (mirrorFile.c_str (), time0); - getFileTime (mainFile.c_str (), time1); + getFileTime (mirrorFile, time0); + getFileTime (mainFile, time1); sint64 deltaInt = (((uint64)time1.dwHighDateTime)<<32|((uint64)time1.dwLowDateTime)) - (((uint64)time0.dwHighDateTime)<<32|((uint64)time0.dwLowDateTime)); double deltaInSec = (double)deltaInt; deltaInSec /= 10000000.0; @@ -688,8 +688,8 @@ void CData_mirrorDlg::buildSourceFiles () { // Update time stamp FILETIME fileTime; - getFileTime (mainFile.c_str (), fileTime); - setFileTime (mirrorFile.c_str(), fileTime); + getFileTime (mainFile, fileTime); + setFileTime (mirrorFile, fileTime); } } else @@ -699,8 +699,8 @@ void CData_mirrorDlg::buildSourceFiles () else { FILETIME time; - getFileTime (mainFile.c_str (), time); - addEntry (Added, str.c_str (), time, time); + getFileTime (mainFile, time); + addEntry (Added, str, time, time); } } } @@ -777,7 +777,7 @@ void CData_mirrorDlg::addEntry (uint where, const char *filename, FILETIME &newD file.Strings[CEntryFile::Path] = filename; file.NewDateST = newDate; file.OldDateST = oldDate; - const char *aFilename; + std::string aFilename; string mirrorFile = MirrorDirectory+filename; string mainFile = MainDirectory+filename; @@ -790,7 +790,7 @@ void CData_mirrorDlg::addEntry (uint where, const char *filename, FILETIME &newD // Date timeToString (file.Strings[CEntryFile::OldDate], oldDate); - aFilename = mirrorFile.c_str (); + aFilename = mirrorFile; } if (where != Removed) @@ -801,7 +801,7 @@ void CData_mirrorDlg::addEntry (uint where, const char *filename, FILETIME &newD // Date timeToString (file.Strings[CEntryFile::NewDate], newDate); - aFilename = mainFile.c_str (); + aFilename = mainFile; } // Get the extension @@ -811,19 +811,19 @@ void CData_mirrorDlg::addEntry (uint where, const char *filename, FILETIME &newD { // Get the image SHFILEINFO sfi; - char winName[512]; - strcpy (winName, aFilename); - char *ptr = winName; + TCHAR winName[512]; + _tcscpy (winName, utf8ToTStr(aFilename)); + TCHAR *ptr = winName; while (*ptr) { - if (*ptr=='/') - *ptr = '\\'; + if (*ptr==_T('/')) + *ptr = _T('\\'); ptr++; } SHGetFileInfo (winName, 0, &sfi, sizeof (SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_LINKOVERLAY | SHGFI_TYPENAME ); CExtension extension; - extension.Description = sfi.szTypeName; + extension.Description = tStrToUtf8(sfi.szTypeName); extension.Icon = sfi.iIcon; ite = MapExtensions.insert (std::map::value_type (ext, extension)).first; } @@ -883,7 +883,7 @@ void CData_mirrorDlg::OnUpdate() CString itemText = List.GetItemText (i, 0); // Add to ignore good list - entriesToUpdate.push_back ((const char*)itemText); + entriesToUpdate.push_back (tStrToUtf8(itemText)); // Remove from the file list std::list::iterator *ite = (std::list::iterator *)List.GetItemData (i); diff --git a/code/nel/tools/misc/log_analyser/FilterDialog.cpp b/code/nel/tools/misc/log_analyser/FilterDialog.cpp index 1e65b1e09..6eec719d7 100644 --- a/code/nel/tools/misc/log_analyser/FilterDialog.cpp +++ b/code/nel/tools/misc/log_analyser/FilterDialog.cpp @@ -71,7 +71,7 @@ BOOL CFilterDialog::OnInitDialog() if ( Trace ) { - GetDlgItem( IDC_PosFilterCap )->SetWindowText( "Service code" ); + GetDlgItem( IDC_PosFilterCap )->SetWindowText(_T("Service code")); GetDlgItem( IDC_NegFilterCap )->ShowWindow( SW_HIDE ); GetDlgItem( IDC_SepCap )->ShowWindow( SW_HIDE ); GetDlgItem( IDC_NegFilter )->ShowWindow( SW_HIDE ); @@ -79,11 +79,11 @@ BOOL CFilterDialog::OnInitDialog() } else { - GetDlgItem( IDC_PosFilterCap )->SetWindowText( "Positive filters (all lines must contain one of these substrings)" ); + GetDlgItem( IDC_PosFilterCap )->SetWindowText(_T("Positive filters (all lines must contain one of these substrings)")); GetDlgItem( IDC_NegFilterCap )->ShowWindow( SW_SHOW ); GetDlgItem( IDC_SepCap )->ShowWindow( SW_SHOW ); GetDlgItem( IDC_NegFilter )->ShowWindow( SW_SHOW ); - GetDlgItem( IDC_Sep )->SetWindowText( ";" ); + GetDlgItem( IDC_Sep )->SetWindowText(_T(";")); GetDlgItem( IDC_Sep )->ShowWindow( SW_SHOW ); } @@ -98,12 +98,12 @@ std::vector buildVectorFromString( const CString& str, const CString& s { std::vector vec; CString str2 = str; - char *token; - token = strtok( str2.GetBuffer( str2.GetLength() ), sep ); + TCHAR *token; + token = _tcstok( str2.GetBuffer( str2.GetLength() ), sep ); while ( token != NULL ) { vec.push_back( CString(token) ); - token = strtok( NULL, sep ); + token = _tcstok( NULL, sep ); } str2.ReleaseBuffer(); return vec; diff --git a/code/nel/tools/misc/log_analyser/PlugInSelector.cpp b/code/nel/tools/misc/log_analyser/PlugInSelector.cpp index 9a21a8df6..120ceacaf 100644 --- a/code/nel/tools/misc/log_analyser/PlugInSelector.cpp +++ b/code/nel/tools/misc/log_analyser/PlugInSelector.cpp @@ -87,7 +87,7 @@ BOOL CPlugInSelector::OnInitDialog() } -int getLastSeparator (const string &filename) +std::string::size_type getLastSeparator (const string &filename) { string::size_type pos = filename.find_last_of ('/'); if (pos == string::npos) @@ -131,10 +131,10 @@ void CPlugInSelector::OnSelchangeList1() if ( ! LibInst ) { CString s; - char msg [300]; + TCHAR msg [300]; FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), msg, 299, NULL ); - s.Format( "Can't load %s: %s", dllName, msg ); + s.Format(_T("Can't load %s: %s"), dllName, msg ); AfxMessageBox( s ); AnalyseFunc = NULL; return; @@ -144,17 +144,17 @@ void CPlugInSelector::OnSelchangeList1() TInfoFunc infoFunc = (TInfoFunc)GetProcAddress( LibInst, "getInfoString" ); if ( ! infoFunc ) { - AfxMessageBox( "Can't find function getInfoString in dll" ); + AfxMessageBox( _T("Can't find function getInfoString in dll") ); return; } - GetDlgItem( IDC_GROUP_INFO )->SetWindowText( getFilename( string(dllName)).c_str() ); - GetDlgItem( IDC_PLUGIN_INFO )->SetWindowText( infoFunc().c_str() ); + GetDlgItem( IDC_GROUP_INFO )->SetWindowText( utf8ToTStr(getFilename(tStrToUtf8(dllName))) ); + GetDlgItem( IDC_PLUGIN_INFO )->SetWindowText(utf8ToTStr(infoFunc()) ); // Prepare analyse func AnalyseFunc = (TAnalyseFunc)GetProcAddress( LibInst, "doAnalyse" ); if ( ! AnalyseFunc ) { - AfxMessageBox( "Can't find function doAnalyse in dll" ); + AfxMessageBox( _T("Can't find function doAnalyse in dll") ); return; } diff --git a/code/nel/tools/misc/log_analyser/StdAfx.h b/code/nel/tools/misc/log_analyser/StdAfx.h index 7fdcd1587..bd3d88df1 100644 --- a/code/nel/tools/misc/log_analyser/StdAfx.h +++ b/code/nel/tools/misc/log_analyser/StdAfx.h @@ -37,6 +37,9 @@ #include // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT +#include +#include +#include //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/code/nel/tools/misc/log_analyser/ViewDialog.cpp b/code/nel/tools/misc/log_analyser/ViewDialog.cpp index c750cbd83..cdc38ed08 100644 --- a/code/nel/tools/misc/log_analyser/ViewDialog.cpp +++ b/code/nel/tools/misc/log_analyser/ViewDialog.cpp @@ -301,14 +301,14 @@ void CViewDialog::reload() { SessionDatePassed = false; CWaitCursor wc; - if ( LogSessionStartDate.IsEmpty() || (LogSessionStartDate == "Beginning") ) + if ( LogSessionStartDate.IsEmpty() || (LogSessionStartDate == _T("Beginning")) ) { SessionDatePassed = true; } ((CButton*)GetDlgItem( IDC_BUTTON1 ))->ShowWindow( SW_SHOW ); ((CButton*)GetDlgItem( IDC_BUTTON2 ))->ShowWindow( SW_SHOW ); - m_Caption.Format( "%s (%u file%s) %u+ %u- (%s)", Seriesname, Filenames.size(), Filenames.size()>1?"s":"", PosFilter.size(), NegFilter.size(), LogSessionStartDate.IsEmpty()?"all":CString("session ")+LogSessionStartDate ); + m_Caption.Format( _T("%s (%u file%s) %u+ %u- (%s)"), Seriesname, Filenames.size(), Filenames.size()>1?"s":"", PosFilter.size(), NegFilter.size(), LogSessionStartDate.IsEmpty()?"all":CString("session ")+LogSessionStartDate ); UpdateData( false ); clear(); setRedraw( false ); @@ -356,17 +356,21 @@ void CViewDialog::getBookmarksAbsoluteLines( vector& bookmarksAbsoluteLine for ( unsigned int i=0; i!=Filenames.size(); ++i ) { CString& filename = Filenames[i]; - ifstream ifs( filename ); - if ( ! ifs.fail() ) + + NLMISC::CIFile ifs; + + if (ifs.open(tStrToUtf8(filename))) { char line [1024]; - while ( ! ifs.eof() ) + + while (!ifs.eof()) { - ifs.getline( line, 1024 ); + ifs.getline(line, 1024); + if ( SessionDatePassed ) { // Stop if the session is finished - if ( (! LogSessionStartDate.IsEmpty()) && (strstr( line, LogDateString )) ) + if ( (! LogSessionStartDate.IsEmpty()) && (strstr( line, tStrToUtf8(LogDateString).c_str())) ) { return; } @@ -390,7 +394,7 @@ void CViewDialog::getBookmarksAbsoluteLines( vector& bookmarksAbsoluteLine else { // Look for the session beginning - if ( strstr( line, LogSessionStartDate ) != NULL ) + if ( strstr( line, tStrToUtf8(LogSessionStartDate).c_str()) != NULL ) { SessionDatePassed = true; } @@ -457,15 +461,12 @@ std::string CViewDialog::corruptedLinesString( const std::vector& string res; if ( ! corruptedLines.empty() ) { - CString s; - s.Format( "%u", corruptedLines.size() ); - res = " -> " + string(s) + " corrupted lines:"; + res = NLMISC::toString(" -> %u corrupted lines:", (uint)corruptedLines.size()); vector::const_iterator ivc; for ( ivc=corruptedLines.begin(); ivc!=corruptedLines.end(); ++ivc ) { - s.Format( "%u", *ivc ); - res += "\r\n line " + string(s) + " : " + string(Buffer[*ivc].Left(20)) + "..."; + res += NLMISC::toString("\r\n line %u : %s...", *ivc, tStrToUtf8(Buffer[*ivc].Left(20)).c_str()); } HasCorruptedLines = true; } @@ -483,7 +484,7 @@ void CViewDialog::loadFileOrSeries( const vector& bookmarksAbsoluteLines ) if ( LogSessionStartDate.IsEmpty() ) actualFilenames += ":\r\n"; else - actualFilenames += " for Session of " + LogSessionStartDate + ":\r\n"; + actualFilenames += " for Session of " + tStrToUtf8(LogSessionStartDate) + ":\r\n"; bool corruptionDetectionEnabled = (((CButton*)(((CLog_analyserDlg*)GetParent())->GetDlgItem( IDC_DetectCorruptedLines )))->GetCheck() == 1); HasCorruptedLines = false; vector corruptedLines; diff --git a/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp b/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp index ae7c6ce00..e23fd2bd9 100644 --- a/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp +++ b/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp @@ -188,7 +188,7 @@ BOOL CLog_analyserDlg::OnInitDialog() cf.load( "log_analyser.cfg" ); LogDateString = cf.getVar( "LogDateString" ).asString().c_str(); } - catch ( EConfigFile& ) + catch (const EConfigFile& ) {*/ LogDateString = "Log Starting ["; AnalyseFunc = NULL; @@ -517,7 +517,7 @@ CViewDialog *CLog_analyserDlg::onAddCommon( const vector& filenames ) view->Filenames = filenames; } - view->LogSessionStartDate = ""; + view->LogSessionStartDate.Empty(); LogSessionsDialog.clear(); if ( ((CButton*)GetDlgItem( IDC_CheckSessions ))->GetCheck() == 1 ) @@ -620,7 +620,7 @@ void CLog_analyserDlg::getLogSeries( const CString& filenameStr, std::vector pl; - pl.push_back( "Analyse log" ); + pl.push_back(_T("Analyse log")); onAddCommon( pl ); Views.back()->addText( logstr.c_str() ); Views.back()->commitAddedLines(); @@ -1041,7 +1041,7 @@ void CLog_analyserDlg::OnAnalyse() if ( nEndChar != (int)resstr.size() ) { CString s; - s.Format( "Error: plug-in returned %u characters, only %d displayed", resstr.size(), nEndChar+1 ); + s.Format(_T("Error: plug-in returned %u characters, only %d displayed"), (uint)resstr.size(), nEndChar+1 ); AfxMessageBox( s ); } } diff --git a/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp b/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp index 5aefbcf4c..c6accc1cb 100644 --- a/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp +++ b/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp @@ -164,7 +164,9 @@ void readFormId( string& outputFileName ) map::iterator itFT = FileTypeToId.find(fileType); if( itFT == FileTypeToId.end() ) { - FileTypeToId.insert( std::pair(fileType,fid.FormIDInfos.Type) ); + uint8 type = (uint8)fid.FormIDInfos.Type; + + FileTypeToId.insert( std::pair(fileType, type) ); } } else @@ -529,9 +531,9 @@ int main( int argc, char ** argv ) readFormId( outputFileName ); // output path - sint lastSeparator = CFile::getLastSeparator(outputFileName); + std::string::size_type lastSeparator = CFile::getLastSeparator(outputFileName); string outputPath; - if( lastSeparator != -1 ) + if( lastSeparator != std::string::npos ) { outputPath = outputFileName.substr(0,lastSeparator+1); } diff --git a/code/nel/tools/misc/words_dic/CMakeLists.txt b/code/nel/tools/misc/words_dic/CMakeLists.txt index c3f3975f2..a2d0293ad 100644 --- a/code/nel/tools/misc/words_dic/CMakeLists.txt +++ b/code/nel/tools/misc/words_dic/CMakeLists.txt @@ -10,6 +10,6 @@ ADD_DEFINITIONS(${MFC_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(words_dic ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.h ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS words_dic RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT toolsmisc) diff --git a/code/nel/tools/misc/words_dic/words_dicDlg.cpp b/code/nel/tools/misc/words_dic/words_dicDlg.cpp index 8c28c2124..f161e22e5 100644 --- a/code/nel/tools/misc/words_dic/words_dicDlg.cpp +++ b/code/nel/tools/misc/words_dic/words_dicDlg.cpp @@ -87,12 +87,12 @@ BOOL CWords_dicDlg::OnInitDialog() SplashScreen->Create( IDD_SplashScreen, NULL ); SplashScreen->ShowWindow( SW_SHOW ); SplashScreen->SetWindowPos( &wndTop, 400, 300, 0,0, SWP_NOSIZE ); - SplashScreen->GetDlgItem( IDC_SplashText )->SetWindowText( "Please wait while loading dictionary..." ); + SplashScreen->GetDlgItem( IDC_SplashText )->SetWindowText( _T("Please wait while loading dictionary...") ); if ( ! Dico.init() ) - AfxMessageBox( "Can't init dictionary, see reason in log.log" ); + AfxMessageBox( _T("Can't init dictionary, see reason in log.log") ); SplashScreen->DestroyWindow(); delete SplashScreen; - GetDlgItem( IDC_Status )->SetWindowText( "Tip: ^ and $ can be used to represent the start and the end of string" ); + GetDlgItem( IDC_Status )->SetWindowText( _T("Tip: ^ and $ can be used to represent the start and the end of string") ); return TRUE; // return TRUE unless you set the focus to a control } @@ -157,13 +157,13 @@ void CWords_dicDlg::lookUp( const CString& inputStr ) { // Look up CVectorSString resultVec; - Dico.lookup( CSString(inputStr), resultVec ); + Dico.lookup( tStrToUtf8(inputStr), resultVec ); // Display results clear(); if ( resultVec.empty() ) { - m_Results.AddString( "" ); + m_Results.AddString(_T("")); return; } else @@ -176,14 +176,14 @@ void CWords_dicDlg::lookUp( const CString& inputStr ) const CSString& res = (*ivs); if ( showAll || (res.find( "lvl" ) == string::npos) ) { - m_Results.AddString( res.c_str() ); + m_Results.AddString( utf8ToTStr(res) ); } else lvlRemoved = true; } m_Results.SetRedraw( true ); CString s; - s.Format( "%u results found for \"%s\".%s", resultVec.size(), inputStr, lvlRemoved?" Results containing \"lvl\" not shown":"" ); + s.Format(_T("%u results found for \"%s\".%s"), resultVec.size(), inputStr, lvlRemoved? _T(" Results containing \"lvl\" not shown"): _T("") ); GetDlgItem( IDC_Status )->SetWindowText( s ); } } @@ -204,7 +204,7 @@ void CWords_dicDlg::OnBtnFind() */ void CWords_dicDlg::clear() { - GetDlgItem( IDC_Status )->SetWindowText( "" ); + GetDlgItem( IDC_Status )->SetWindowText(_T("")); m_Results.ResetContent(); } @@ -213,7 +213,7 @@ void CWords_dicDlg::clear() */ void CWords_dicDlg::OnBtnClear() { - m_LookUp.SetWindowText( "" ); + m_LookUp.SetWindowText(_T("")); clear(); } @@ -234,7 +234,7 @@ void CWords_dicDlg::OnFileList() const vector& fileList = Dico.getFileList(); for ( vector::const_iterator ifl=fileList.begin(); ifl!=fileList.end(); ++ifl ) { - m_Results.AddString( (*ifl).c_str() ); + m_Results.AddString( utf8ToTStr(*ifl) ); } } @@ -253,7 +253,7 @@ void CWords_dicDlg::OnSelchangeResultList() // Get selection CString resStr; m_Results.GetText( m_Results.GetCurSel(), resStr ); - CSString key = Dico.getWordsKey( CSString(resStr) ); + CSString key = Dico.getWordsKey( tStrToUtf8(resStr) ); // Copy the selection into the clipboard if ( OpenClipboard() ) @@ -271,13 +271,13 @@ void CWords_dicDlg::OnSelchangeResultList() if ( mem ) { CString s; - s.Format( "\"%s\" copied into the clipboard", key.c_str() ); + s.Format(_T("\"%s\" copied into the clipboard"), utf8ToTStr(key) ); GetDlgItem( IDC_Status )->SetWindowText( s ); } } else { - GetDlgItem( IDC_Status )->SetWindowText( "Cannot access the clipboard" ); + GetDlgItem( IDC_Status )->SetWindowText(_T("Cannot access the clipboard")); } } diff --git a/code/nel/tools/nel_unit_test/CMakeLists.txt b/code/nel/tools/nel_unit_test/CMakeLists.txt index 7e26a2498..6abc06a49 100644 --- a/code/nel/tools/nel_unit_test/CMakeLists.txt +++ b/code/nel/tools/nel_unit_test/CMakeLists.txt @@ -8,6 +8,6 @@ TARGET_LINK_LIBRARIES(nel_unit_test ${CPPTEST_LIBRARIES} nelmisc nelnet nelligo) NL_DEFAULT_PROPS(nel_unit_test "Unit Tests") NL_ADD_RUNTIME_FLAGS(nel_unit_test) -ADD_DEFINITIONS(-DNEL_UNIT_BASE="${PROJECT_SOURCE_DIR}/tools/nel_unit_test/") +ADD_DEFINITIONS(-DNEL_UNIT_BASE="${PROJECT_SOURCE_DIR}/nel/tools/nel_unit_test/") INSTALL(TARGETS nel_unit_test RUNTIME DESTINATION ${NL_BIN_PREFIX}) diff --git a/code/nel/tools/nel_unit_test/__copy_file_dst.foo b/code/nel/tools/nel_unit_test/__copy_file_dst.foo deleted file mode 100644 index ab13f948a..000000000 Binary files a/code/nel/tools/nel_unit_test/__copy_file_dst.foo and /dev/null differ diff --git a/code/nel/tools/nel_unit_test/__ligo_class.xml b/code/nel/tools/nel_unit_test/__ligo_class.xml deleted file mode 100644 index ff2ff2ee0..000000000 --- a/code/nel/tools/nel_unit_test/__ligo_class.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/code/nel/tools/nel_unit_test/__test_prim.primitive b/code/nel/tools/nel_unit_test/__test_prim.primitive deleted file mode 100644 index 479734bcb..000000000 --- a/code/nel/tools/nel_unit_test/__test_prim.primitive +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - class - test - - - name - test_root - - - - - class - alias - - - name - alias - - - - - diff --git a/code/nel/tools/nel_unit_test/debug_cfg_with_error_main.cfg b/code/nel/tools/nel_unit_test/debug_cfg_with_error_main.cfg deleted file mode 100644 index 72c6bdf68..000000000 --- a/code/nel/tools/nel_unit_test/debug_cfg_with_error_main.cfg +++ /dev/null @@ -1,41 +0,0 @@ -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error_main.cfg" 1 -// This config file include the config file with error then generate an error -// WARNING : is you add lines, update the code in the test - - -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error.cfg" 1 -// In this cfg, we introduce an error in a line after define and if clause - - -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error.cfg" 5 - -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error.cfg" 7 - -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error.cfg" 9 - // nothing - -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error.cfg" 13 -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error.cfg" 15 - - -// Here is the offending line, at line 18 -ABadVar iable = "foo"; - -// Some additionnal garbase lines - -AGoodVar = "bar"; -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error_main.cfg" 6 - -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error_main.cfg" 8 -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error_main.cfg" 9 - -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error_main.cfg" 11 - // nothing - -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error_main.cfg" 15 -#fileline "r:/code/nel/tools/nel_unit_test/ut_misc_files/cfg_with_error_main.cfg" 17 - - -// Some additionnal garbase lines - -AGoodVar = "bar"; diff --git a/code/nel/tools/nel_unit_test/nel_unit_test.cpp b/code/nel/tools/nel_unit_test/nel_unit_test.cpp index 753dfd46a..d716fef98 100644 --- a/code/nel/tools/nel_unit_test/nel_unit_test.cpp +++ b/code/nel/tools/nel_unit_test/nel_unit_test.cpp @@ -67,7 +67,7 @@ static void usage() exit(0); } -static auto_ptr cmdline(int argc, char* argv[]) +static CUniquePtr cmdline(int argc, char* argv[]) { if (argc > 2) usage(); // will not return @@ -102,7 +102,7 @@ static auto_ptr cmdline(int argc, char* argv[]) } } - return auto_ptr(output); + return CUniquePtr(output); } // Main test program @@ -134,12 +134,12 @@ int main(int argc, char *argv[]) { Test::Suite ts; - ts.add(auto_ptr(new CUTMisc)); - ts.add(auto_ptr(new CUTNet)); - ts.add(auto_ptr(new CUTLigo)); + ts.add(std::auto_ptr(new CUTMisc)); + ts.add(std::auto_ptr(new CUTNet)); + ts.add(std::auto_ptr(new CUTLigo)); // Add a line here when adding a new test MODULE - auto_ptr output(cmdline(argc, argv)); + CUniquePtr output(cmdline(argc, argv)); noerrors = ts.run(*output); Test::HtmlOutput* const html = dynamic_cast(output.get()); diff --git a/code/nel/tools/nel_unit_test/result.html b/code/nel/tools/nel_unit_test/result.html deleted file mode 100644 index 057425b9f..000000000 --- a/code/nel/tools/nel_unit_test/result.html +++ /dev/null @@ -1,820 +0,0 @@ - - - - - - - NeLTest Unit Tests Results - - - - - - -

NeLTest Unit Tests Results

- -
-Designed by CppTest -
-
- -

Summary

- - - - - - - - - - - - - -
TestsErrorsSuccessTime (s)
66198%35.265000
-
- -

Test suites

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTestsErrorsSuccessTime (s)
CUTMiscCoTask20100%0.000000
CUTMiscCommand50100%0.015000
CUTMiscConfigFile60100%0.032000
CUTMiscDebug20100%0.000000
CUTMiscDynLibLoad 10100%0.000000
CUTMiscFile40100%0.859000
CUTMiscPackFile110100%0.016000
CUTMiscSingleton20100%0.000000
CUTMiscSString10100%0.000000
CUTMiscStream40100%0.000000
CUTMiscVariable 10100%0.000000
CUTMiscTypes110%0.000000
CUTNetLayer310100%2.312000
CUTNetMessage30100%0.000000
CUTNetModule210100%32.031000
CUTLigoPrimitive10100%0.000000
-
- -

Suite: CUTMiscCoTask

- - - - - - - - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
runTasks0true0.000000
tasksAndThreads0true0.000000
-

Back to top -

-

Suite: CUTMiscCommand

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
createOneInstance0true0.015000
createAnotherInstance0true0.000000
deleteOneInstance0true0.000000
derivedClass0true0.000000
derivedClassAndBaseCall0true0.000000
-

Back to top -

-

Suite: CUTMiscConfigFile

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
configWithInclude0true0.016000
configWithOptional0true0.000000
configWithDefine0true0.000000
configWithBadTest0true0.000000
configIncludeAndOptional0true0.000000
reportErrorInSubFiles0true0.016000
-

Back to top -

-

Suite: CUTMiscDebug

- - - - - - - - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
testInstanceCounter0true0.000000
testInstanceCounterOutput0true0.000000
-

Back to top -

-

Suite: CUTMiscDynLibLoad

- - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
libraryNameDecoration0true0.000000
-

Back to top -

-

Suite: CUTMiscFile

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
copyOneBigFile0true0.187000
copyDifferentFileSize0true0.203000
moveOneBigFile0true0.203000
moveDifferentFileSize0true0.266000
-

Back to top -

-

Suite: CUTMiscPackFile

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
addBnp0true0.000000
loadFromBnp0true0.000000
addXmlpack0true0.016000
loadFromXmlpack0true0.000000
compressMemory0true0.000000
loadFromBnpCompressed0true0.000000
loadFromXmlpackCompressed0true0.000000
decompressMemory0true0.000000
loadFromBnpUncompressed0true0.000000
loadFromXmlpackUncompressed0true0.000000
loadXmlpackWithSameName0true0.000000
-

Back to top -

-

Suite: CUTMiscSingleton

- - - - - - - - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
createSingleton0true0.000000
accessSingleton0true0.000000
-

Back to top -

-

Suite: CUTMiscSString

- - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
testStrtok0true0.000000
-

Back to top -

-

Suite: CUTMiscStream

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
constAndStream0true0.000000
memStreamSwap0true0.000000
copyOnWrite0true0.000000
preallocatedBitStream0true0.000000
-

Back to top -

-

Suite: CUTMiscVariable

- - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
declareVar0true0.000000
-

Back to top -

-

Suite: CUTMiscTypes

- - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
basicTypes1false0.000000
-

Back to top -

-

Suite: CUTNetLayer3

- - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
sendReceiveUpdate0true2.312000
-

Back to top -

-

Suite: CUTNetMessage

- - - - - - - - - - - - - - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
messageSwap0true0.000000
lockSubMEssage0true0.000000
lockSubMEssageWithLongName0true0.000000
-

Back to top -

-

Suite: CUTNetModule

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
testModuleInitInfoParsing0true0.000000
testModuleInitInfoQuering0true0.000000
testModuleInitInfoBadParsing0true0.000000
localModuleFactory0true0.016000
failedInit0true0.000000
createLocalGateway0true0.000000
plugLocalGateway0true0.000000
gatewayTransportManagement0true1.219000
connectGateways0true0.828000
moduleDisclosure0true1.328000
moduleMessaging0true1.625000
localMessageQueing0true0.609000
uniqueNameGenerator0true0.000000
gwPlugUnplug0true0.000000
peerInvisible0true3.453000
firewalling0true3.438000
distanceAndConnectionLoop0true6.109000
securityPlugin0true5.094000
synchronousMessaging0true1.031000
layer3Autoconnect0true6.672000
interceptorTest0true0.609000
-

Back to top -

-

Suite: CUTLigoPrimitive

- - - - - - - - - - - - - -
NameErrorsSuccessTime (s)
testAliasGenerator0true0.000000
-

Back to top -

-
- -

Test results

-

CUTMiscTypes::basicTypes

- - - - - - - - - - - - - -
TestCUTMiscTypes::basicTypes
Filed:\ryzom\nel\tools\nel_unit_test\ut_misc_types.h:31
Messagesizeof(time_t) == sizeof(uint32)
-

Back to CUTMiscTypes -

-
- - -

- - Valid XHTML 1.0 Strict - -

- - diff --git a/code/nel/tools/nel_unit_test/ut_ligo.h b/code/nel/tools/nel_unit_test/ut_ligo.h index 6dba782d8..c41bc1463 100644 --- a/code/nel/tools/nel_unit_test/ut_ligo.h +++ b/code/nel/tools/nel_unit_test/ut_ligo.h @@ -26,7 +26,7 @@ struct CUTLigo : public Test::Suite { CUTLigo() { - add(auto_ptr(new CUTLigoPrimitive)); + add(std::auto_ptr(new CUTLigoPrimitive)); // Add a line here when adding a new test CLASS } }; diff --git a/code/nel/tools/nel_unit_test/ut_misc.h b/code/nel/tools/nel_unit_test/ut_misc.h index e7a3cc8c6..7f125f2f3 100644 --- a/code/nel/tools/nel_unit_test/ut_misc.h +++ b/code/nel/tools/nel_unit_test/ut_misc.h @@ -37,20 +37,20 @@ struct CUTMisc : public Test::Suite { CUTMisc() { - add(auto_ptr(new CUTMiscCoTask)); - add(auto_ptr(new CUTMiscCommand)); - add(auto_ptr(new CUTMiscCommon)); - add(auto_ptr(new CUTMiscConfigFile)); - add(auto_ptr(new CUTMiscDebug)); - add(auto_ptr(new CUTMiscDynLibLoad)); - add(auto_ptr(new CUTMiscFile)); - add(auto_ptr(new CUTMiscPackFile)); - add(auto_ptr(new CUTMiscSingleton)); - add(auto_ptr(new CUTMiscSString)); - add(auto_ptr(new CUTMiscStream)); - add(auto_ptr(new CUTMiscVariable)); - add(auto_ptr(new CUTMiscTypes)); - add(auto_ptr(new CUTMiscStringCommon)); + add(std::auto_ptr(new CUTMiscCoTask)); + add(std::auto_ptr(new CUTMiscCommand)); + add(std::auto_ptr(new CUTMiscCommon)); + add(std::auto_ptr(new CUTMiscConfigFile)); + add(std::auto_ptr(new CUTMiscDebug)); + add(std::auto_ptr(new CUTMiscDynLibLoad)); + add(std::auto_ptr(new CUTMiscFile)); + add(std::auto_ptr(new CUTMiscPackFile)); + add(std::auto_ptr(new CUTMiscSingleton)); + add(std::auto_ptr(new CUTMiscSString)); + add(std::auto_ptr(new CUTMiscStream)); + add(std::auto_ptr(new CUTMiscVariable)); + add(std::auto_ptr(new CUTMiscTypes)); + add(std::auto_ptr(new CUTMiscStringCommon)); // Add a line here when adding a new test CLASS } }; diff --git a/code/nel/tools/nel_unit_test/ut_net.h b/code/nel/tools/nel_unit_test/ut_net.h index bd43a0eee..cee3b01cb 100644 --- a/code/nel/tools/nel_unit_test/ut_net.h +++ b/code/nel/tools/nel_unit_test/ut_net.h @@ -28,9 +28,9 @@ struct CUTNet : public Test::Suite { CUTNet() { - add(auto_ptr(new CUTNetLayer3)); - add(auto_ptr(new CUTNetMessage)); - add(auto_ptr(new CUTNetModule)); + add(std::auto_ptr(new CUTNetLayer3)); + add(std::auto_ptr(new CUTNetMessage)); + add(std::auto_ptr(new CUTNetModule)); // Add a line here when adding a new test CLASS } }; diff --git a/code/nel/tools/pacs/build_rbank/build_surf.cpp b/code/nel/tools/pacs/build_rbank/build_surf.cpp index 10d4c6a19..7e873f15f 100644 --- a/code/nel/tools/pacs/build_rbank/build_surf.cpp +++ b/code/nel/tools/pacs/build_rbank/build_surf.cpp @@ -1420,7 +1420,7 @@ void NLPACS::CZoneTessellation::compile() bool force = false; - if (surf.Area < 30.0f && surf.Elements.size() > 0) + if (surf.Area < 30.0f && !surf.Elements.empty()) { uint i; CAABBox aabbox; @@ -1688,7 +1688,7 @@ CAABBox NLPACS::CZoneTessellation::computeBBox() const bool set = false; uint i; - if (_Vertices.size() == 0) + if (_Vertices.empty()) return zbox; zbox.setCenter(_Vertices[0]); diff --git a/code/nelns/CMakeLists.txt b/code/nelns/CMakeLists.txt index fe72e20b3..d45111118 100644 --- a/code/nelns/CMakeLists.txt +++ b/code/nelns/CMakeLists.txt @@ -6,8 +6,8 @@ IF(WITH_NELNS_SERVER) ADD_SUBDIRECTORY(naming_service) ADD_SUBDIRECTORY(login_service) ADD_SUBDIRECTORY(welcome_service) -ENDIF(WITH_NELNS_SERVER) +ENDIF() IF(WITH_NELNS_LOGIN_SYSTEM) ADD_SUBDIRECTORY(login_system) -ENDIF(WITH_NELNS_LOGIN_SYSTEM) +ENDIF() diff --git a/code/nelns/CMakePackaging.txt b/code/nelns/CMakePackaging.txt index 8a509272e..34a766ebc 100644 --- a/code/nelns/CMakePackaging.txt +++ b/code/nelns/CMakePackaging.txt @@ -34,10 +34,10 @@ SET(CPACK_SOURCE_PACKAGE_FILE_NAME "nelns-${NL_VERSION}") IF(WIN32) SET(CPACK_GENERATOR "NSIS") SET(CPACK_SOURCE_GENERATOR "ZIP") -ELSE(WIN32) +ELSE() SET(CPACK_GENERATOR "TGZ") SET(CPACK_SOURCE_GENERATOR "TGZ") -ENDIF(WIN32) +ENDIF() set(CPACK_SOURCE_IGNORE_FILES "~$" "\\\\.cvsignore$" @@ -49,7 +49,7 @@ set(CPACK_SOURCE_IGNORE_FILES IF(WIN32) IF(NOT CMAKE_BUILD_TYPE STREQUAL "Release") SET(CMAKE_INSTALL_DEBUG_LIBRARIES TRUE) - ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "Release") + ENDIF() IF(WITH_QT) INCLUDE(${QT_USE_FILE}) @@ -58,15 +58,15 @@ IF(WIN32) "${QT_LIBRARY_DIR}/QtXml4.dll" "${QT_LIBRARY_DIR}/QtCore4.dll" DESTINATION bin) - ENDIF(WITH_QT) + ENDIF() # Only the tools require MFC. IF(BUILD_RYZOM_LAUNCHER) SET(CMAKE_INSTALL_MFC_LIBRARIES TRUE) - ENDIF(BUILD_RYZOM_LAUNCHER) + ENDIF() INCLUDE(InstallRequiredSystemLibraries) -ENDIF(WIN32) +ENDIF() INCLUDE(CPack) diff --git a/code/nelns/login_system/CMakeLists.txt b/code/nelns/login_system/CMakeLists.txt index 1e80f4d05..ac79f857c 100644 --- a/code/nelns/login_system/CMakeLists.txt +++ b/code/nelns/login_system/CMakeLists.txt @@ -1,9 +1,9 @@ IF(WIN32) IF(BUILD_RYZOM_LAUNCHER) ADD_SUBDIRECTORY(nel_launcher_windows_ext2) - ENDIF(BUILD_RYZOM_LAUNCHER) -ENDIF(WIN32) + ENDIF() +ENDIF() IF(WITH_QT) ADD_SUBDIRECTORY(nel_launcher_qt) -ENDIF(WITH_QT) +ENDIF() diff --git a/code/nelns/login_system/nel_launcher_qt/CMakeLists.txt b/code/nelns/login_system/nel_launcher_qt/CMakeLists.txt index 92dac70f1..02cd438b7 100644 --- a/code/nelns/login_system/nel_launcher_qt/CMakeLists.txt +++ b/code/nelns/login_system/nel_launcher_qt/CMakeLists.txt @@ -34,6 +34,6 @@ ADD_DEFINITIONS(${QT_DEFINITIONS}) INSTALL(TARGETS nel_launcher_qt RUNTIME DESTINATION bin COMPONENT launcher) IF(WIN32) INSTALL(FILES nel_launcher.cfg DESTINATION bin COMPONENT launcher) -ELSE(WIN32) +ELSE() INSTALL(FILES nel_launcher.cfg DESTINATION ${NL_ETC_PREFIX}/nelns COMPONENT launcher) -ENDIF(WIN32) +ENDIF() diff --git a/code/nelns/login_system/nel_launcher_windows_ext2/CMakeLists.txt b/code/nelns/login_system/nel_launcher_windows_ext2/CMakeLists.txt index 2851d5f1d..b283624d1 100644 --- a/code/nelns/login_system/nel_launcher_windows_ext2/CMakeLists.txt +++ b/code/nelns/login_system/nel_launcher_windows_ext2/CMakeLists.txt @@ -3,7 +3,7 @@ FILE(GLOB SRC *.cpp *.h) ADD_EXECUTABLE(nel_launcher_ext2 WIN32 ${SRC} nel_launcher.rc) IF(CURL_FOUND) ADD_DEFINITIONS(-DUSE_CURL) -ENDIF(CURL_FOUND) +ENDIF() ADD_DEFINITIONS(-DNL_LAUNCHER_CFG="\\"${NL_ETC_PREFIX}/\\"") TARGET_LINK_LIBRARIES(nel_launcher_ext2 @@ -17,7 +17,7 @@ NL_ADD_RUNTIME_FLAGS(nel_launcher_ext2) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nel_launcher_ext2 ${CMAKE_CURRENT_SOURCE_DIR}/std_afx.h ${CMAKE_CURRENT_SOURCE_DIR}/std_afx.cpp) -ENDIF(WITH_PCH) +ENDIF() INSTALL(TARGETS nel_launcher_ext2 RUNTIME DESTINATION bin COMPONENT launcher) INSTALL(FILES nel_launcher.cfg DESTINATION ${NL_ETC_PREFIX} COMPONENT launcher) diff --git a/code/ryzom/CMakeLists.txt b/code/ryzom/CMakeLists.txt index 46c8bcb68..5ce811872 100644 --- a/code/ryzom/CMakeLists.txt +++ b/code/ryzom/CMakeLists.txt @@ -13,6 +13,8 @@ ADD_SUBDIRECTORY(client) IF(WITH_RYZOM_SERVER OR WITH_RYZOM_TOOLS) # Need servershare for build packed collision tool # Need aishare for build wmap tool - FIND_PACKAGE(MySQL REQUIRED) - ADD_SUBDIRECTORY(server) + FIND_PACKAGE(MySQL) + IF(MYSQL_FOUND) + ADD_SUBDIRECTORY(server) + ENDIF() ENDIF() diff --git a/code/ryzom/client/CMakeLists.txt b/code/ryzom/client/CMakeLists.txt index 919f9fe22..43897c905 100644 --- a/code/ryzom/client/CMakeLists.txt +++ b/code/ryzom/client/CMakeLists.txt @@ -10,4 +10,18 @@ IF(WITH_RYZOM_CLIENT) ENDIF() INSTALL(FILES client_default.cfg DESTINATION ${RYZOM_ETC_PREFIX}) + + IF(WITH_RYZOM_PATCH) + IF(APPLE) + INSTALL(FILES macosx/upgd_nl.sh DESTINATION ${RYZOM_GAMES_PREFIX}) + ELSEIF(WIN32) + IF(MSVC10) + INSTALL(FILES windows/upgd_nl_msvc10.bat DESTINATION ${RYZOM_GAMES_PREFIX} RENAME upgd_nl.bat) + ELSEIF(MSVC12) + INSTALL(FILES windows/upgd_nl_msvc12.bat DESTINATION ${RYZOM_GAMES_PREFIX} RENAME upgd_nl.bat) + ENDIF() + ELSE() + INSTALL(FILES unix/upgd_nl.sh DESTINATION ${RYZOM_GAMES_PREFIX}) + ENDIF() + ENDIF() ENDIF() diff --git a/code/ryzom/client/client_default.cfg b/code/ryzom/client/client_default.cfg index 80c2875dd..c128ac28a 100644 --- a/code/ryzom/client/client_default.cfg +++ b/code/ryzom/client/client_default.cfg @@ -16,11 +16,11 @@ SaveConfig = 1; Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" // "Auto" will choose the best suited driver depending on hardware FullScreen = 1; -Width = 1024; -Height = 768; +Width = 0; +Height = 0; PositionX = 0; PositionY = 0; -Frequency = 60; +Frequency = 0; Depth = 32; Sleep = -1; ProcessPriority = 0; // -2 = idle, -1 = below normal, 0 = normal, 1 = above normal, 2 = high, 3 = real time @@ -113,6 +113,7 @@ FreeLookAcceleration_min = 20; FreeLookAcceleration_max = 80; FreeLookInverted = 0; +FreeLookTablet = 0; AutomaticCamera = 0; DblClickMode = 1; AutoEquipTool = 1; @@ -280,7 +281,7 @@ DivideTextureSizeBy2= 0; // Divide texture size DisableVtxProgram = 0; // Disable Hardware Vertex Program. DisableVtxAGP = 0; // Disable Hardware Vertex AGP. DisableTextureShdr = 0; // Disable Hardware Texture Shader. -HDEntityTexture = 0; +HDEntityTexture = 1; HDTextureInstalled = 1; WaitVBL = 0; // 0 or 1 to wait Vertical Sync. @@ -480,7 +481,8 @@ XMLInterfaceFiles = { "commands2.xml", "ring_access_point_filter.xml", "ring_window.xml", - "bg_downloader.xml" + "bg_downloader.xml", + "ryzhome_toolbar.xml" }; XMLR2EDInterfaceFiles = @@ -568,7 +570,9 @@ HelpPages = "fr=http://forums.ryzom.com/forum/showthread.php?t=29130", "en=http://forums.ryzom.com/forum/showthread.php?t=29129", "wk=http://forums.ryzom.com/forum/showthread.php?t=29129", - "de=http://forums.ryzom.com/forum/showthread.php?t=29131" + "de=http://forums.ryzom.com/forum/showthread.php?t=29131", + "es=http://forums.ryzom.com/forum/showthread.php?t=29129", + "ru=http://forums.ryzom.com/forum/showthread.php?t=29129" }; WebIgMainDomain = "app.ryzom.com"; diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml b/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml index 8696de32a..42c931e29 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml @@ -220,6 +220,22 @@ + + + + + + + + + + + + + + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml b/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml index 6fdb5d32a..31a1a7099 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml @@ -50,6 +50,24 @@ + + + + + + + + + + + + + + + + + + @@ -63,9 +81,15 @@ + + + + + + @@ -96,6 +120,8 @@ + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/compass.xml b/code/ryzom/client/data/gamedev/interfaces_v3/compass.xml index 35a259ea4..a88f49f44 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/compass.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/compass.xml @@ -8,7 +8,7 @@ - @@ -25,23 +25,38 @@ + + + + + + + + + + + - + + + params="volume=@UI:SAVE:MP3_VOLUME" /> + onclick_l="enter_modal" + params_l="group=ui:interface:playlist" + tooltip="uiMP3Playlist" /> + posref="TM TL" + x="0" + y="-35" /> + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua b/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua index 12210fadf..64858c69c 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua @@ -1431,6 +1431,8 @@ function game:onInGameDbInitialized() end game:setInfoPlayerCharacterRace() + + runAH(nil, "sort_tribefame", "") end function game:onWebIgReady() diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua index e10ad2f6f..bdf838f88 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua @@ -10,7 +10,7 @@ end ------------------------------------------------------------------------------------------------------------ -- called when server send an invitaion we receive a text id containing the string to display (invitor name) function game:onTeamInvation(textID) - + local ui = getUI('ui:interface:join_team_proposal'); ui.content.inside.invitor_name.textid = textID; ui.active = true; @@ -20,7 +20,7 @@ function game:onTeamInvation(textID) end ------------------------------------------------------------------------------------------------------------ --- +-- function game:teamInvitationAccept() local ui = getUI('ui:interface:join_team_proposal'); @@ -29,7 +29,7 @@ function game:teamInvitationAccept() end ------------------------------------------------------------------------------------------------------------ --- +-- function game:teamInvitationRefuse() local ui = getUI('ui:interface:join_team_proposal'); @@ -38,7 +38,7 @@ function game:teamInvitationRefuse() end ------------------------------------------------------------------------------------------------------------ --- +-- function game:switchChatTab(dbEntry) local db= 'UI:SAVE:ISENABLED:' .. dbEntry; local val= getDbProp(db); @@ -51,13 +51,13 @@ function game:switchChatTab(dbEntry) end ------------------------------------------------------------------------------------------------------------ --- +-- function game:updateEmoteMenu(prop, tooltip, tooltip_pushed, name, param) for i=0,9 do -- Get key shortcut local text = i18n.get('uiTalkMemMsg0' .. i); local key = runExpr( "getKey('talk_message','0" .. i .. "',1)" ); - + if (key ~= nil and key ~= '') then key = ' @{T25}@{2F2F}(' .. key .. ')'; text = concatUCString(text, key); @@ -67,11 +67,11 @@ function game:updateEmoteMenu(prop, tooltip, tooltip_pushed, name, param) local uiQC= getUI("ui:interface:user_chat_emote_menu:quick_chat:" .. "qc" .. i); uiQC.uc_hardtext_format= text; end - + end ------------------------------------------------------------------------------------------------------------ --- +-- if (ui_free_chat_h == nil) then ui_free_chat_h = {} end @@ -81,14 +81,14 @@ if (ui_free_chat_w == nil) then end ------------------------------------------------------------------------------------------------------------ --- +-- function game:closeTellHeader(uiID) local ui = getUI('ui:interface:' .. uiID); - + -- save size ui_free_chat_h[uiID] = ui.h; ui_free_chat_w[uiID] = ui.w; - + -- reduce window size ui.pop_min_h = 32; ui.h = 0; @@ -96,7 +96,7 @@ function game:closeTellHeader(uiID) end ------------------------------------------------------------------------------------------------------------ --- +-- function game:openTellHeader(uiID) local ui = getUI('ui:interface:' .. uiID); ui.pop_min_h = 96; @@ -105,7 +105,7 @@ function game:openTellHeader(uiID) if (ui_free_chat_h[uiID] ~= nil) then ui.h = ui_free_chat_h[uiID]; end - + if (ui_free_chat_w[uiID] ~= nil) then ui.w = ui_free_chat_w[uiID]; end @@ -127,12 +127,12 @@ local function levelToForceRegion(level) return 6 else return math.floor(level / 50) + 2 - end -end + end +end local function levelToLevelForce(level) - return math.floor(math.fmod(level, 50) * 5 / 50) + 1 -end + return math.floor(math.fmod(level, 50) * 5 / 50) + 1 +end @@ -186,7 +186,7 @@ end local function twIsTargetPlayer() if config.Local == 1 then return twTargetPlayer - else + else return isTargetPlayer() end end @@ -195,7 +195,7 @@ end local function twIsPlayerInPVPMode() if config.Local == 1 then return twPlayerInPVPMode - else + else return isPlayerInPVPMode() end end @@ -204,7 +204,7 @@ end local function twIsTargetInPVPMode() if config.Local == 1 then return twTargetInPVPMode - else + else return isTargetInPVPMode() end end @@ -217,27 +217,29 @@ end -- Is its level known (not too high ...) -- Boss/Mini-bosses/Names colored ring function game:updateTargetConsiderUI() - --debugInfo("Updating consider widget") + -- debugInfo("Updating consider widget") - local targetWindow = getUI("ui:interface:target") - -- + local targetWindow = getUI("ui:interface:target") + -- local wgTargetSlotForce = targetWindow:find("slot_force") local wgTargetLevel = targetWindow:find("target_level") local wgImpossible = targetWindow:find("impossible") local wgSlotRing = targetWindow:find("slot_ring") local wgToolTip = targetWindow:find("target_tooltip") - local wgPvPTag = targetWindow:find("pvp_tags") - local wgHeader = targetWindow:find("header_opened") + local wgPvPTag = targetWindow:find("pvp_tags") + local wgHeader = targetWindow:find("header_opened") + local wgLock = targetWindow:find("lock") wgTargetSlotForce.active = true wgImpossible.active = true -- no selection ? if twGetTargetLevel() == -1 then + wgLock.active = false wgTargetSlotForce.active = false wgTargetLevel.active = false wgImpossible.active = false - wgSlotRing.active = false + wgSlotRing.active = false if (isTargetUser() and twIsPlayerInPVPMode()) then wgToolTip.tooltip = "" wgPvPTag.active = true @@ -254,20 +256,36 @@ function game:updateTargetConsiderUI() wgPvPTag.active = false wgHeader.h = 34; + +-- /luaScript getUI("ui:interface:target:header_opened:lock").active=true + -- if the selection is a player, then both the local & targeted player must be in PVP mode for the level to be displayed if (twIsTargetPlayer()) then -- don't display anything ... + wgLock.active = false wgTargetSlotForce.active = false wgTargetLevel.active = false wgImpossible.active = false wgSlotRing.active = false wgToolTip.tooltip = "" if twIsTargetInPVPMode() then - debugInfo("target in pvp") wgPvPTag.active = true wgHeader.h = 56; end return + else + wgLock.active = false + local level = getDbProp(getDefine("target_player_level")) + + if level == 2 then -- Locked by team of player + wgLock.active = true + wgLock.color = "50 250 250 255" + else + if level == 1 then -- Locked by another team + wgLock.active = true + wgLock.color = "250 50 50 255" + end + end end -- depending on the number of people in the group, set the max diff for visibility between player level @@ -288,14 +306,14 @@ function game:updateTargetConsiderUI() local impossible = (twGetTargetLevel() - twGetPlayerLevel() > maxDiffLevel) wgSlotRing.active = false - + if impossible then -- targeted object is too hard too beat, display a skull wgTargetLevel.active = false wgImpossible.y = -5 wgImpossible.color = "255 50 50 255" else - -- player can see the level of the targeted creature + -- player can see the level of the targeted creature wgTargetLevel.active = true wgImpossible.y = 6 wgTargetLevel.hardtext = tostring(twGetTargetLevel()) @@ -309,7 +327,7 @@ function game:updateTargetConsiderUI() wgImpossible.texture = getDefine("force_level_" .. tostring(levelForce)) wgImpossible.active = true - if levelForce < 6 then + if levelForce < 6 then wgToolTip.tooltip = i18n.get("uittConsiderTargetLevel") elseif levelForce == 6 then -- Named creature @@ -342,7 +360,6 @@ function game:updateTargetConsiderUI() if impossible then wgToolTip.tooltip = concatUCString(wgToolTip.tooltip, ucstring("\n"), i18n.get("uittConsiderUnknownLevel")) end - end ---------------------- @@ -505,18 +522,18 @@ function twGroup(groupSize) else setDbProp("SERVER:GROUP:" .. tostring(gm) .. ":PRESENT", 0) end - end + end end ------------------------------------------------------------------------------------------------------------ --- +-- function game:closeWebIGBrowserHeader() local ui = getUI('ui:interface:webig'); - + -- save size ui_webig_browser_h = ui.h; ui_webig_browser_w = ui.w; - + -- reduce window size ui.pop_min_h = 32; ui.h = 0; @@ -524,7 +541,7 @@ function game:closeWebIGBrowserHeader() end ------------------------------------------------------------------------------------------------------------ --- +-- function game:openWebIGBrowserHeader() local ui = getUI('ui:interface:webig'); ui.pop_min_h = 96; @@ -533,8 +550,22 @@ function game:openWebIGBrowserHeader() if (ui_webig_browser_h ~= nil) then ui.h = ui_webig_browser_h; end - + if (ui_webig_browser_w ~= nil) then ui.w = ui_webig_browser_w; end end + +------------------------------------------------------------------------------------------------------------ +local SavedUrl = ""; +function game:chatUrl(url) + SavedUrl = url + runAH(nil, "active_menu", "menu=ui:interface:chat_uri_action_menu"); +end +function game:chatUrlCopy() + runAH(nil, "copy_to_clipboard", SavedUrl) +end +function game:chatUrlBrowse() + runAH(nil, "browse", "name=ui:interface:webig:content:html|url=" .. SavedUrl) +end + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml index d6d4a4cba..f4ab98453 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml @@ -269,14 +269,27 @@ posparent="slot_force" x="-1" y="6" - scale="true" - h="16" - w="32" + scale="true" + h="16" + w="32" color="255 255 255 255" texture="consider_impossible.tga" global_color="false" render_layer="1" active="true" /> + + + + + + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/inventory.xml b/code/ryzom/client/data/gamedev/interfaces_v3/inventory.xml index e9ff0719b..2864894ab 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/inventory.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/inventory.xml @@ -549,7 +549,7 @@ pop_min_h="240" pop_max_w="920" pop_max_h="1600" - w="300" + w="400" h="400" movable="true" active="false" diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/json.lua b/code/ryzom/client/data/gamedev/interfaces_v3/json.lua new file mode 100644 index 000000000..70d8c4413 --- /dev/null +++ b/code/ryzom/client/data/gamedev/interfaces_v3/json.lua @@ -0,0 +1,376 @@ +-- +-- json.lua +-- +-- Copyright (c) 2015 rxi +-- +-- This library is free software; you can redistribute it and/or modify it +-- under the terms of the MIT license. See LICENSE for details. +-- + +Json = { _version = "0.1.0" } + +------------------------------------------------------------------------------- +-- Encode +------------------------------------------------------------------------------- + +local encode + +local escape_char_map = { + [ "\\" ] = "\\\\", + [ "\"" ] = "\\\"", + [ "\b" ] = "\\b", + [ "\f" ] = "\\f", + [ "\n" ] = "\\n", + [ "\r" ] = "\\r", + [ "\t" ] = "\\t", +} + +local escape_char_map_inv = { [ "\\/" ] = "/" } +for k, v in pairs(escape_char_map) do + escape_char_map_inv[v] = k +end + + +local function escape_char(c) + return escape_char_map[c] or string.format("\\u%04x", c:byte()) +end + + +local function encode_nil(val) + return "null" +end + + +local function encode_table(val, stack) + local res = {} + stack = stack or {} + + -- Circular reference? + if stack[val] then error("circular reference") end + + stack[val] = true + + if val[1] ~= nil or next(val) == nil then + -- Treat as array -- check keys are valid and it is not sparse + local n = 0 + for k in pairs(val) do + if type(k) ~= "number" then + error("invalid table: mixed or invalid key types") + end + n = n + 1 + end + if n ~= #val then + error("invalid table: sparse array") + end + -- Encode + for i, v in ipairs(val) do + table.insert(res, encode(v, stack)) + end + stack[val] = nil + return "[" .. table.concat(res, ",") .. "]" + + else + -- Treat as an object + for k, v in pairs(val) do + if type(k) ~= "string" then + error("invalid table: mixed or invalid key types") + end + table.insert(res, encode(k, stack) .. ":" .. encode(v, stack)) + end + stack[val] = nil + return "{" .. table.concat(res, ",") .. "}" + end +end + + +local function encode_string(val) + return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"' +end + + +local function encode_number(val) + -- Check for NaN, -inf and inf + if val ~= val or val <= -math.huge or val >= math.huge then + error("unexpected number value '" .. tostring(val) .. "'") + end + return string.format("%.3f", val) +end + +local type_func_map = { + [ "nil" ] = encode_nil, + [ "table" ] = encode_table, + [ "string" ] = encode_string, + [ "number" ] = encode_number, + [ "boolean" ] = tostring, +} + + +encode = function(val, stack) + local t = type(val) + local f = type_func_map[t] + if f then + return f(val, stack) + end + error("unexpected type '" .. t .. "'") +end + + +function Json.encode(val) + return ( encode(val) ) +end + + +------------------------------------------------------------------------------- +-- Decode +------------------------------------------------------------------------------- + +local parse + +local function create_set(...) + local res = {} + for i = 1, select("#", ...) do + res[ select(i, ...) ] = true + end + return res +end + +local space_chars = create_set(" ", "\t", "\r", "\n") +local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",") +local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u") +local literals = create_set("true", "false", "null") + +local literal_map = { + [ "true" ] = true, + [ "false" ] = false, + [ "null" ] = nil, +} + + +local function next_char(str, idx, set, negate) + for i = idx, #str do + if set[str:sub(i, i)] ~= negate then + return i + end + end + return #str + 1 +end + + +local function decode_error(str, idx, msg) + local line_count = 1 + local col_count = 1 + for i = 1, idx - 1 do + col_count = col_count + 1 + if str:sub(i, i) == "\n" then + line_count = line_count + 1 + col_count = 1 + end + end + error( string.format("%s at line %d col %d", msg, line_count, col_count) ) +end + + +local function codepoint_to_utf8(n) + -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa + local f = math.floor + if n <= 0x7f then + return string.char(n) + elseif n <= 0x7ff then + return string.char(f(n / 64) + 192, n % 64 + 128) + elseif n <= 0xffff then + return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128) + elseif n <= 0x10ffff then + return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128, + f(n % 4096 / 64) + 128, n % 64 + 128) + end + error( string.format("invalid unicode codepoint '%x'", n) ) +end + + +local function parse_unicode_escape(s) + local n1 = tonumber( s:sub(3, 6), 16 ) + local n2 = tonumber( s:sub(9, 12), 16 ) + -- Surrogate pair? + if n2 then + return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000) + else + return codepoint_to_utf8(n1) + end +end + + +local function parse_string(str, i) + local has_unicode_escape = false + local has_surrogate_escape = false + local has_escape = false + local last + for j = i + 1, #str do + local x = str:byte(j) + + if x < 32 then + decode_error(str, j, "control character in string") + end + + if last == 92 then -- "\\" (escape char) + if x == 117 then -- "u" (unicode escape sequence) + local hex = str:sub(j + 1, j + 5) + if not hex:find("%x%x%x%x") then + decode_error(str, j, "invalid unicode escape in string") + end + if hex:find("^[dD][89aAbB]") then + has_surrogate_escape = true + else + has_unicode_escape = true + end + else + local c = string.char(x) + if not escape_chars[c] then + decode_error(str, j, "invalid escape char '" .. c .. "' in string") + end + has_escape = true + end + last = nil + + elseif x == 34 then -- '"' (end of string) + local s = str:sub(i + 1, j - 1) + if has_surrogate_escape then + s = s:gsub("\\u[dD][89aAbB]..\\u....", parse_unicode_escape) + end + if has_unicode_escape then + s = s:gsub("\\u....", parse_unicode_escape) + end + if has_escape then + s = s:gsub("\\.", escape_char_map_inv) + end + return s, j + 1 + + else + last = x + end + end + decode_error(str, i, "expected closing quote for string") +end + + +local function parse_number(str, i) + local x = next_char(str, i, delim_chars) + local s = str:sub(i, x - 1) + local n = tonumber(s) + if not n then + decode_error(str, i, "invalid number '" .. s .. "'") + end + return n, x +end + + +local function parse_literal(str, i) + local x = next_char(str, i, delim_chars) + local word = str:sub(i, x - 1) + if not literals[word] then + decode_error(str, i, "invalid literal '" .. word .. "'") + end + return literal_map[word], x +end + + +local function parse_array(str, i) + local res = {} + local n = 1 + i = i + 1 + while 1 do + local x + i = next_char(str, i, space_chars, true) + -- Empty / end of array? + if str:sub(i, i) == "]" then + i = i + 1 + break + end + -- Read token + x, i = parse(str, i) + res[n] = x + n = n + 1 + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "]" then break end + if chr ~= "," then decode_error(str, i, "expected ']' or ','") end + end + return res, i +end + + +local function parse_object(str, i) + local res = {} + i = i + 1 + while 1 do + local key, val + i = next_char(str, i, space_chars, true) + -- Empty / end of object? + if str:sub(i, i) == "}" then + i = i + 1 + break + end + -- Read key + if str:sub(i, i) ~= '"' then + decode_error(str, i, "expected string for key") + end + key, i = parse(str, i) + -- Read ':' delimiter + i = next_char(str, i, space_chars, true) + if str:sub(i, i) ~= ":" then + decode_error(str, i, "expected ':' after key") + end + i = next_char(str, i + 1, space_chars, true) + -- Read value + val, i = parse(str, i) + -- Set + res[key] = val + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "}" then break end + if chr ~= "," then decode_error(str, i, "expected '}' or ','") end + end + return res, i +end + + +local char_func_map = { + [ '"' ] = parse_string, + [ "0" ] = parse_number, + [ "1" ] = parse_number, + [ "2" ] = parse_number, + [ "3" ] = parse_number, + [ "4" ] = parse_number, + [ "5" ] = parse_number, + [ "6" ] = parse_number, + [ "7" ] = parse_number, + [ "8" ] = parse_number, + [ "9" ] = parse_number, + [ "-" ] = parse_number, + [ "t" ] = parse_literal, + [ "f" ] = parse_literal, + [ "n" ] = parse_literal, + [ "[" ] = parse_array, + [ "{" ] = parse_object, +} + + +parse = function(str, idx) + local chr = str:sub(idx, idx) + local f = char_func_map[chr] + if f then + return f(str, idx) + end + decode_error(str, idx, "unexpected character '" .. chr .. "'") +end + + +function Json.decode(str) + if type(str) ~= "string" then + error("expected argument of type string, got " .. type(str)) + end + return ( parse(str, next_char(str, 1, space_chars, true)) ) +end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/keys.xml b/code/ryzom/client/data/gamedev/interfaces_v3/keys.xml index ae212a589..40ecd1c75 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/keys.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/keys.xml @@ -278,6 +278,7 @@ + @@ -168,6 +180,10 @@ type="I10" /> + + + + + + @@ -309,6 +333,10 @@ type="I10" /> + + @@ -352,6 +380,10 @@ type="I10" /> + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/macros.xml b/code/ryzom/client/data/gamedev/interfaces_v3/macros.xml index 5dc1142bf..8c2eb9f82 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/macros.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/macros.xml @@ -200,7 +200,7 @@ - + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/map.xml b/code/ryzom/client/data/gamedev/interfaces_v3/map.xml index 4370e5593..dcc2515ea 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/map.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/map.xml @@ -194,6 +194,7 @@ + @@ -447,4 +448,4 @@ - \ No newline at end of file + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/phrase.xml b/code/ryzom/client/data/gamedev/interfaces_v3/phrase.xml index c551f66e6..3640099ac 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/phrase.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/phrase.xml @@ -9,8 +9,8 @@ - @@ -44,13 +44,13 @@