diff --git a/.hgtags b/.hgtags index f13a14cd9..c8ad3e352 100644 --- a/.hgtags +++ b/.hgtags @@ -8,3 +8,6 @@ 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 +9d41f2994d44b9aad92b83f945f114e4b6bed44a ryzom-patch-3.0.2 diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index c85030049..4e5d4bfb5 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -36,7 +36,7 @@ IF(COMMAND cmake_policy) IF(POLICY CMP0020) CMAKE_POLICY(SET CMP0020 NEW) ENDIF() -ENDIF(COMMAND cmake_policy) +ENDIF() INCLUDE(nel) INCLUDE(ConfigureChecks) @@ -64,7 +64,7 @@ SET(YEAR "2004-${CURRENT_YEAR}") SET(AUTHOR "Winch Gate and The Ryzom Core Community") SET(RYZOM_VERSION_MAJOR 3) -SET(RYZOM_VERSION_MINOR 0) +SET(RYZOM_VERSION_MINOR 1) SET(RYZOM_VERSION_PATCH 0) #----------------------------------------------------------------------------- @@ -75,15 +75,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 @@ -97,8 +97,6 @@ NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS() NL_SETUP_PREFIX_PATHS() RYZOM_SETUP_PREFIX_PATHS() -NL_CONFIGURE_CHECKS() - NL_SETUP_BUILD() NL_SETUP_BUILD_FLAGS() @@ -112,8 +110,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) @@ -122,15 +120,25 @@ FIND_PACKAGE(OpenSSL REQUIRED) FIND_PACKAGE(GIF) FIND_PACKAGE(Jpeg) +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 @@ -145,20 +153,20 @@ 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) + ENDIF() +ENDIF() IF(APPLE_CERTIFICATE) # Find codesign_allocate @@ -304,7 +312,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() @@ -399,16 +407,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) @@ -446,19 +454,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) @@ -466,22 +474,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() @@ -491,8 +499,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") @@ -524,10 +532,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$" @@ -545,8 +553,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 @@ -554,8 +562,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) @@ -565,14 +573,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) @@ -582,4 +590,4 @@ INCLUDE(CMakePackaging.txt) #INCLUDE(UseDebian) #IF(DEBIAN_FOUND) # ADD_DEBIAN_TARGETS(nel) -#ENDIF(DEBIAN_FOUND) +#ENDIF() 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/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..d7918816f 100644 --- a/code/CMakeModules/FindWindowsSDK.cmake +++ b/code/CMakeModules/FindWindowsSDK.cmake @@ -255,8 +255,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() @@ -441,8 +452,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 and 2015 + 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/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index 20539e87f..36d031f10 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,71 @@ 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}") + LIST(APPEND _FLAGS ${oldProps}) ENDIF() GET_TARGET_PROPERTY(oldPropsBuild ${_target} COMPILE_FLAGS_${_UPPER_BUILD}) IF(oldPropsBuild) - LIST(APPEND _FLAGS " ${oldPropsBuild}") + LIST(APPEND _FLAGS ${oldPropsBuild}) 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 +152,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 +161,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 +172,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 +181,39 @@ 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() # 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 +270,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 +282,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 +305,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") diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 941351315..ed0847015 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) @@ -334,6 +353,7 @@ MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) 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) @@ -347,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) @@ -360,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) @@ -413,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}") @@ -454,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) @@ -470,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) @@ -508,23 +548,19 @@ 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") @@ -535,50 +571,53 @@ MACRO(NL_SETUP_BUILD) # without inlining it's unusable, use custom optimizations again SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") 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") @@ -586,9 +625,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}") @@ -597,25 +636,25 @@ 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) IF(NOT XCODE) @@ -650,97 +689,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) @@ -750,75 +789,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") @@ -826,11 +878,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}") @@ -839,68 +903,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) @@ -934,7 +1010,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) @@ -1011,7 +1087,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. @@ -1051,7 +1127,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. @@ -1069,7 +1145,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) @@ -1078,8 +1154,8 @@ 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) @@ -1088,28 +1164,28 @@ MACRO(SETUP_EXTERNAL) 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) SET(CMAKE_USE_PTHREADS_INIT 1) SET(Threads_FOUND TRUE) - ELSE(ANDROID OR IOS) + ELSE() FIND_PACKAGE(Threads REQUIRED) # 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 @@ -1117,10 +1193,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..0f1d11579 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -2,23 +2,23 @@ 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() -ENDIF(WITH_3D) +ENDIF() IF(WITH_SOUND) FIND_PACKAGE(Ogg) @@ -26,24 +26,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 +53,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/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/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/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/meshvp_wind_tree.h b/code/nel/include/nel/3d/meshvp_wind_tree.h index e2c790d6d..d8e7598b7 100644 --- a/code/nel/include/nel/3d/meshvp_wind_tree.h +++ b/code/nel/include/nel/3d/meshvp_wind_tree.h @@ -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/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/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_maker_bin_op_inline.h b/code/nel/include/nel/3d/ps_attrib_maker_bin_op_inline.h index 2a9cbff45..339a52e7f 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; 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..73ab32a31 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker_helper.h +++ b/code/nel/include/nel/3d/ps_attrib_maker_helper.h @@ -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(); 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..c41931ab3 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 { /* @@ -480,7 +482,11 @@ 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 } diff --git a/code/nel/include/nel/3d/ps_emitter.h b/code/nel/include/nel/3d/ps_emitter.h index 00163c48e..3d62dd7f0 100644 --- a/code/nel/include/nel/3d/ps_emitter.h +++ b/code/nel/include/nel/3d/ps_emitter.h @@ -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(); diff --git a/code/nel/include/nel/3d/ps_located.h b/code/nel/include/nel/3d/ps_located.h index 30fa7defa..08d1c72d8 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() { @@ -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 diff --git a/code/nel/include/nel/3d/ps_mesh.h b/code/nel/include/nel/3d/ps_mesh.h index 72ba76f4d..6863903f9 100644 --- a/code/nel/include/nel/3d/ps_mesh.h +++ b/code/nel/include/nel/3d/ps_mesh.h @@ -590,7 +590,7 @@ protected: void serial(NLMISC::IStream &f) throw(NLMISC::EStream); }; - typedef std::auto_ptr PGlobalTexAnims; + typedef CUniquePtr PGlobalTexAnims; PGlobalTexAnims _GlobalTexAnims; float _GlobalAnimDate; diff --git a/code/nel/include/nel/3d/ps_zone.h b/code/nel/include/nel/3d/ps_zone.h index 7289e64e0..0e0ff7274 100644 --- a/code/nel/include/nel/3d/ps_zone.h +++ b/code/nel/include/nel/3d/ps_zone.h @@ -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 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..80d54b6ca 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" 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/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_emboss.h b/code/nel/include/nel/3d/texture_emboss.h index a4c469a5c..cdab6d648 100644 --- a/code/nel/include/nel/3d/texture_emboss.h +++ b/code/nel/include/nel/3d/texture_emboss.h @@ -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_font.h b/code/nel/include/nel/3d/texture_font.h index 3aeb77b65..20353f236 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: diff --git a/code/nel/include/nel/3d/tile_bank.h b/code/nel/include/nel/3d/tile_bank.h index 32a205e6d..1205c5940 100644 --- a/code/nel/include/nel/3d/tile_bank.h +++ b/code/nel/include/nel/3d/tile_bank.h @@ -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; @@ -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(); 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..dcd38d90d 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); 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/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/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/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 2f9220cda..4d96be1b5 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -502,7 +502,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 ); @@ -536,7 +536,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/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/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..f96cd39b9 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 */ 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..c7c1369c5 100644 --- a/code/nel/include/nel/misc/common.h +++ b/code/nel/include/nel/misc/common.h @@ -286,6 +286,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); @@ -469,6 +478,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 +690,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) 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/fixed_size_allocator.h b/code/nel/include/nel/misc/fixed_size_allocator.h index 079c54bc0..ffc975250 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; } 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..f750c3265 100644 --- a/code/nel/include/nel/misc/i_xml.h +++ b/code/nel/include/nel/misc/i_xml.h @@ -120,11 +120,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 +136,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 +147,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 +171,11 @@ public: */ static bool getContentString (std::string &result, xmlNodePtr node); + /** + * Release meory used by libxml2, to only call before exit. + */ + static void releaseLibXml(); + private: /// From IStream @@ -193,12 +198,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 ); diff --git a/code/nel/include/nel/misc/mouse_smoother.h b/code/nel/include/nel/misc/mouse_smoother.h index 86a75b7f1..f909cde96 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 trueif 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..179534bb9 100644 --- a/code/nel/include/nel/misc/o_xml.h +++ b/code/nel/include/nel/misc/o_xml.h @@ -95,7 +95,7 @@ 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 @@ -120,7 +120,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 +144,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 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/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/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/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..a532a47fb 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -162,7 +162,7 @@ # 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 @@ -386,17 +386,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_ */ @@ -430,30 +430,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/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/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/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_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/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/cluster.cpp b/code/nel/src/3d/cluster.cpp index 76ed153e1..d78468e61 100644 --- a/code/nel/src/3d/cluster.cpp +++ b/code/nel/src/3d/cluster.cpp @@ -319,7 +319,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..fec5f0b3f 100644 --- a/code/nel/src/3d/coarse_mesh_build.cpp +++ b/code/nel/src/3d/coarse_mesh_build.cpp @@ -19,6 +19,7 @@ #include "nel/3d/coarse_mesh_build.h" #include "nel/3d/mesh.h" +#include "nel/3d/debug_vb.h" using namespace NLMISC; diff --git a/code/nel/src/3d/coarse_mesh_manager.cpp b/code/nel/src/3d/coarse_mesh_manager.cpp index f45ca7675..6ba8b3ec6 100644 --- a/code/nel/src/3d/coarse_mesh_manager.cpp +++ b/code/nel/src/3d/coarse_mesh_manager.cpp @@ -21,6 +21,8 @@ #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" diff --git a/code/nel/src/3d/computed_string.cpp b/code/nel/src/3d/computed_string.cpp index 1a9fefba5..6bc1be856 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" 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..6e319b59e 100644 --- a/code/nel/src/3d/cube_map_builder.cpp +++ b/code/nel/src/3d/cube_map_builder.cpp @@ -89,8 +89,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/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..5bd0e2cbf 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -1265,7 +1265,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 +2267,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_material.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp index 1e8878fb9..cc54d6305 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp @@ -568,7 +568,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_shader.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp index 5cc6c283c..6f48cc2a4 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp @@ -62,7 +62,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..d9ba5a526 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp @@ -270,7 +270,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_vertex_program.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex_program.cpp index d4af02592..69ae49c4f 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 @@ -109,7 +109,7 @@ void dumpWriteMask(uint mask, std::string &out) H_AUTO_D3D(dumpWriteMask) if (mask == 0xf) { - out = ""; + out.clear(); return; } out = "."; @@ -126,7 +126,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/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 6ab0e3336..80b424cba 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) 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 9d9143515..91a2fcab3 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 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..bf9845103 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 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..95eaf8465 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 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..ecadaaac2 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 @@ -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 c826238ea..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; @@ -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..898c9f001 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); @@ -626,7 +629,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..b236223b7 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -33,6 +33,8 @@ #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" diff --git a/code/nel/src/3d/flare_model.cpp b/code/nel/src/3d/flare_model.cpp index f964a9102..c48e754cf 100644 --- a/code/nel/src/3d/flare_model.cpp +++ b/code/nel/src/3d/flare_model.cpp @@ -26,8 +26,9 @@ #include "nel/3d/occlusion_query.h" #include "nel/3d/mesh.h" #include "nel/3d/viewport.h" -#include "nel/misc/common.h" +#include "nel/3d/debug_vb.h" +#include "nel/misc/common.h" namespace NL3D { diff --git a/code/nel/src/3d/font_generator.cpp b/code/nel/src/3d/font_generator.cpp index cdbaf8834..ce8048f15 100644 --- a/code/nel/src/3d/font_generator.cpp +++ b/code/nel/src/3d/font_generator.cpp @@ -457,7 +457,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/gpu_program_params.cpp b/code/nel/src/3d/gpu_program_params.cpp index 9e84865be..f46ba8713 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 @@ -44,14 +43,14 @@ using namespace std; 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/landscape.cpp b/code/nel/src/3d/landscape.cpp index d588fa424..b54bffa28 100644 --- a/code/nel/src/3d/landscape.cpp +++ b/code/nel/src/3d/landscape.cpp @@ -1831,9 +1831,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 +1844,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 +1866,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 +1880,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 +3216,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_user.cpp b/code/nel/src/3d/landscape_user.cpp index d6de7df9e..fd1bc3747 100644 --- a/code/nel/src/3d/landscape_user.cpp +++ b/code/nel/src/3d/landscape_user.cpp @@ -213,9 +213,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 +262,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/landscapeig_manager.cpp b/code/nel/src/3d/landscapeig_manager.cpp index f4388f9fa..500373360 100644 --- a/code/nel/src/3d/landscapeig_manager.cpp +++ b/code/nel/src/3d/landscapeig_manager.cpp @@ -174,7 +174,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 +232,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 +255,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 +272,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/material.cpp b/code/nel/src/3d/material.cpp index 886f45308..3204a620d 100644 --- a/code/nel/src/3d/material.cpp +++ b/code/nel/src/3d/material.cpp @@ -105,9 +105,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 +265,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..3595c962d 100644 --- a/code/nel/src/3d/mesh.cpp +++ b/code/nel/src/3d/mesh.cpp @@ -1101,7 +1101,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; 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/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/patch_render.cpp b/code/nel/src/3d/patch_render.cpp index ee916a3fe..59978a94d 100644 --- a/code/nel/src/3d/patch_render.cpp +++ b/code/nel/src/3d/patch_render.cpp @@ -24,8 +24,11 @@ #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; diff --git a/code/nel/src/3d/play_list_user.cpp b/code/nel/src/3d/play_list_user.cpp index 0a80a1076..9f9d0c688 100644 --- a/code/nel/src/3d/play_list_user.cpp +++ b/code/nel/src/3d/play_list_user.cpp @@ -19,8 +19,9 @@ #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; diff --git a/code/nel/src/3d/portal.cpp b/code/nel/src/3d/portal.cpp index deb80c5c5..62df832db 100644 --- a/code/nel/src/3d/portal.cpp +++ b/code/nel/src/3d/portal.cpp @@ -242,11 +242,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/ps_dot.cpp b/code/nel/src/3d/ps_dot.cpp index 516cac8f1..3711ff50e 100644 --- a/code/nel/src/3d/ps_dot.cpp +++ b/code/nel/src/3d/ps_dot.cpp @@ -21,6 +21,8 @@ #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" namespace NL3D diff --git a/code/nel/src/3d/ps_emitter.cpp b/code/nel/src/3d/ps_emitter.cpp index c9806722f..a976ea5c4 100644 --- a/code/nel/src/3d/ps_emitter.cpp +++ b/code/nel/src/3d/ps_emitter.cpp @@ -1901,9 +1901,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) { @@ -2797,7 +2797,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 +2830,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..818522897 100644 --- a/code/nel/src/3d/ps_face.cpp +++ b/code/nel/src/3d/ps_face.cpp @@ -21,8 +21,9 @@ #include "nel/3d/driver.h" #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" -#include "nel/misc/quat.h" +#include "nel/3d/debug_vb.h" +#include "nel/misc/quat.h" namespace NL3D diff --git a/code/nel/src/3d/ps_face_look_at.cpp b/code/nel/src/3d/ps_face_look_at.cpp index 5b06f6eb5..32cd7c248 100644 --- a/code/nel/src/3d/ps_face_look_at.cpp +++ b/code/nel/src/3d/ps_face_look_at.cpp @@ -21,6 +21,8 @@ #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" diff --git a/code/nel/src/3d/ps_fan_light.cpp b/code/nel/src/3d/ps_fan_light.cpp index 055826749..7f4f789a0 100644 --- a/code/nel/src/3d/ps_fan_light.cpp +++ b/code/nel/src/3d/ps_fan_light.cpp @@ -22,6 +22,7 @@ #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" #include "nel/3d/driver.h" +#include "nel/3d/debug_vb.h" diff --git a/code/nel/src/3d/ps_located.cpp b/code/nel/src/3d/ps_located.cpp index 5409f3480..6572a5b23 100644 --- a/code/nel/src/3d/ps_located.cpp +++ b/code/nel/src/3d/ps_located.cpp @@ -1004,7 +1004,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 } } @@ -1839,10 +1839,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 +1878,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 +2190,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 +2213,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 } diff --git a/code/nel/src/3d/ps_mesh.cpp b/code/nel/src/3d/ps_mesh.cpp index 5002f0054..655534c6c 100644 --- a/code/nel/src/3d/ps_mesh.cpp +++ b/code/nel/src/3d/ps_mesh.cpp @@ -29,12 +29,11 @@ #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" - - - namespace NL3D { @@ -1113,11 +1112,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 +1129,6 @@ void CPSConstraintMesh::setShape(uint index, const std::string &shapeName) _ValidBuild = 0; } - //==================================================================================== const std::string &CPSConstraintMesh::getShape(uint index) const { @@ -1533,7 +1533,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); } @@ -2352,7 +2352,7 @@ void CPSConstraintMesh::setTexAnimType(TTexAnimType type) { PGlobalTexAnims newPtr(new CGlobalTexAnims); //std::swap(_GlobalTexAnims, newPtr); - _GlobalTexAnims = newPtr; + _GlobalTexAnims = CUniquePtrMove(newPtr); _GlobalAnimationEnabled = 1; } break; 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_ribbon.cpp b/code/nel/src/3d/ps_ribbon.cpp index af907313f..00a3d1310 100644 --- a/code/nel/src/3d/ps_ribbon.cpp +++ b/code/nel/src/3d/ps_ribbon.cpp @@ -36,7 +36,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 */ @@ -1463,8 +1463,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..8f602b931 100644 --- a/code/nel/src/3d/ps_ribbon_base.cpp +++ b/code/nel/src/3d/ps_ribbon_base.cpp @@ -20,6 +20,8 @@ #include "nel/3d/ps_ribbon_base.h" #include "nel/3d/particle_system.h" +using namespace NLMISC; + namespace NL3D { diff --git a/code/nel/src/3d/ps_ribbon_look_at.cpp b/code/nel/src/3d/ps_ribbon_look_at.cpp index 966e5a5b1..7fece0e3d 100644 --- a/code/nel/src/3d/ps_ribbon_look_at.cpp +++ b/code/nel/src/3d/ps_ribbon_look_at.cpp @@ -20,6 +20,7 @@ #include "nel/3d/particle_system.h" #include "nel/3d/ps_macro.h" #include "nel/3d/driver.h" +#include "nel/3d/debug_vb.h" namespace NL3D { diff --git a/code/nel/src/3d/ps_shockwave.cpp b/code/nel/src/3d/ps_shockwave.cpp index 20069e175..44f91d208 100644 --- a/code/nel/src/3d/ps_shockwave.cpp +++ b/code/nel/src/3d/ps_shockwave.cpp @@ -22,6 +22,7 @@ #include "nel/3d/texture_grouped.h" #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" +#include "nel/3d/debug_vb.h" namespace NL3D diff --git a/code/nel/src/3d/ps_sound.cpp b/code/nel/src/3d/ps_sound.cpp index a5ae6ad26..a1705d907 100644 --- a/code/nel/src/3d/ps_sound.cpp +++ b/code/nel/src/3d/ps_sound.cpp @@ -21,6 +21,8 @@ #include "nel/3d/u_ps_sound_interface.h" #include "nel/3d/ps_attrib_maker.h" +using namespace NLMISC; + namespace NL3D { diff --git a/code/nel/src/3d/ps_tail_dot.cpp b/code/nel/src/3d/ps_tail_dot.cpp index 075c9a598..cf9baa016 100644 --- a/code/nel/src/3d/ps_tail_dot.cpp +++ b/code/nel/src/3d/ps_tail_dot.cpp @@ -33,7 +33,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 */ 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_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/ray_mesh.cpp b/code/nel/src/3d/ray_mesh.cpp index b315979b1..ca6b9b09d 100644 --- a/code/nel/src/3d/ray_mesh.cpp +++ b/code/nel/src/3d/ray_mesh.cpp @@ -19,6 +19,8 @@ #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; diff --git a/code/nel/src/3d/scene_group.cpp b/code/nel/src/3d/scene_group.cpp index fa67230d4..c5f6f24dc 100644 --- a/code/nel/src/3d/scene_group.cpp +++ b/code/nel/src/3d/scene_group.cpp @@ -451,7 +451,6 @@ void CInstanceGroup::serial (NLMISC::IStream& f) _PointLightArray.clear(); } - if (version >= 2) f.serial(_GlobalPos); @@ -574,10 +573,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()); + } } } } @@ -1121,7 +1121,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/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/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/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_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..b683725a3 100644 --- a/code/nel/src/3d/tessellation.cpp +++ b/code/nel/src/3d/tessellation.cpp @@ -2530,7 +2530,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/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_cube.cpp b/code/nel/src/3d/texture_cube.cpp index fbcd425f9..809bff5fa 100644 --- a/code/nel/src/3d/texture_cube.cpp +++ b/code/nel/src/3d/texture_cube.cpp @@ -193,7 +193,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_emboss.cpp b/code/nel/src/3d/texture_emboss.cpp index 414f93093..55d5d85a9 100644 --- a/code/nel/src/3d/texture_emboss.cpp +++ b/code/nel/src/3d/texture_emboss.cpp @@ -17,6 +17,8 @@ #include "std3d.h" #include "nel/3d/texture_emboss.h" +using namespace NLMISC; + 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..23075448e 100644 --- a/code/nel/src/3d/tile_bank.cpp +++ b/code/nel/src/3d/tile_bank.cpp @@ -134,7 +134,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 +243,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 +264,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); @@ -583,7 +583,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 +608,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()) @@ -782,7 +782,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 +804,7 @@ void CTile::serial(NLMISC::IStream &f) throw(NLMISC::EStream) // *************************************************************************** void CTile::clearTile (CTile::TBitmap type) { - _BitmapName[type]=""; + _BitmapName[type].clear(); } @@ -1433,7 +1433,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 +1450,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 +1474,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 +1521,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 +1564,7 @@ const CTileVegetableDesc &CTileSet::getTileVegetableDesc() const // *************************************************************************** void CTileSet::loadTileVegetableDesc() { - if(_TileVegetableDescFileName!="") + if(!_TileVegetableDescFileName.empty()) { try { @@ -1853,14 +1853,12 @@ CTileNoise::CTileNoise () { // Not loaded _TileNoiseMap=NULL; - _FileName=""; } // *************************************************************************** CTileNoise::CTileNoise (const CTileNoise &src) { // Default ctor _TileNoiseMap=NULL; - _FileName=""; // Copy *this=src; @@ -1932,7 +1930,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/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/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/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_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_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..fa5aea364 100644 --- a/code/nel/src/3d/vegetablevb_allocator.cpp +++ b/code/nel/src/3d/vegetablevb_allocator.cpp @@ -19,6 +19,7 @@ #include "nel/3d/vegetablevb_allocator.h" #include "nel/3d/vegetable_def.h" +#include "nel/3d/debug_vb.h" using namespace std; diff --git a/code/nel/src/3d/vertex_buffer.cpp b/code/nel/src/3d/vertex_buffer.cpp index fc09dc956..8315b46da 100644 --- a/code/nel/src/3d/vertex_buffer.cpp +++ b/code/nel/src/3d/vertex_buffer.cpp @@ -885,7 +885,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_parse.cpp b/code/nel/src/3d/vertex_program_parse.cpp index 0e144d54f..259e72b41 100644 --- a/code/nel/src/3d/vertex_program_parse.cpp +++ b/code/nel/src/3d/vertex_program_parse.cpp @@ -1110,7 +1110,7 @@ static void dumpWriteMask(uint mask, std::string &out) { if (mask == 0xf) { - out = ""; + out.clear(); return; } out = "."; @@ -1125,7 +1125,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/visual_collision_manager.cpp b/code/nel/src/3d/visual_collision_manager.cpp index cafc9948e..c5c45578f 100644 --- a/code/nel/src/3d/visual_collision_manager.cpp +++ b/code/nel/src/3d/visual_collision_manager.cpp @@ -98,7 +98,7 @@ CVisualTileDescNode *CVisualCollisionManager::newVisualTileDescNode() // *************************************************************************** void CVisualCollisionManager::deleteVisualTileDescNode(CVisualTileDescNode *ptr) { - _TileDescNodeAllocator.free(ptr); + _TileDescNodeAllocator.freeBlock(ptr); } // *************************************************************************** @@ -110,7 +110,7 @@ CPatchQuadBlock *CVisualCollisionManager::newPatchQuadBlock() // *************************************************************************** void CVisualCollisionManager::deletePatchQuadBlock(CPatchQuadBlock *ptr) { - _PatchQuadBlockAllocator.free(ptr); + _PatchQuadBlockAllocator.freeBlock(ptr); } 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_height_map.cpp b/code/nel/src/3d/water_height_map.cpp index 9ab5a31f3..38ca1cacf 100644 --- a/code/nel/src/3d/water_height_map.cpp +++ b/code/nel/src/3d/water_height_map.cpp @@ -305,7 +305,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 { diff --git a/code/nel/src/3d/water_pool_manager.cpp b/code/nel/src/3d/water_pool_manager.cpp index c377ff1f3..8ca8e2bfc 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 { diff --git a/code/nel/src/3d/zone_manager.cpp b/code/nel/src/3d/zone_manager.cpp index efa36fa66..34a670b5e 100644 --- a/code/nel/src/3d/zone_manager.cpp +++ b/code/nel/src/3d/zone_manager.cpp @@ -170,7 +170,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 +187,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); 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_dfn.cpp b/code/nel/src/georges/form_dfn.cpp index 16ee74d5b..114a3aaf1 100644 --- a/code/nel/src/georges/form_dfn.cpp +++ b/code/nel/src/georges/form_dfn.cpp @@ -498,7 +498,7 @@ void CFormDfn::CEntry::setDfn (CFormLoader &loader, const char *filename) void CFormDfn::CEntry::setDfnPointer () { TypeElement = EntryVirtualDfn; - Filename = ""; + Filename.clear(); Type = NULL; Dfn = NULL; } diff --git a/code/nel/src/georges/form_elm.cpp b/code/nel/src/georges/form_elm.cpp index 01e4010e2..1c752b0bc 100644 --- a/code/nel/src/georges/form_elm.cpp +++ b/code/nel/src/georges/form_elm.cpp @@ -1512,7 +1512,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 @@ -2066,7 +2066,7 @@ void CFormElmStruct::getFormName (std::string &result, const CFormElm *child) co // Reset the result if (child == NULL) { - result = ""; + result.clear(); result.reserve (50); } @@ -2723,7 +2723,7 @@ void CFormElmArray::getFormName (std::string &result, const CFormElm *child) con // Reset the result if (child == NULL) { - result = ""; + result.clear(); result.reserve (50); } @@ -3067,7 +3067,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 diff --git a/code/nel/src/georges/header.cpp b/code/nel/src/georges/header.cpp index ff92d60ea..a2df85cd3 100644 --- a/code/nel/src/georges/header.cpp +++ b/code/nel/src/georges/header.cpp @@ -159,7 +159,7 @@ void CFileHeader::read (xmlNodePtr root) } // Look for the comment node - Comments = ""; + Comments.clear(); xmlNodePtr node = CIXml::getFirstChildNode (root, "COMMENTS"); if (node) { @@ -181,7 +181,7 @@ void CFileHeader::read (xmlNodePtr root) } // Look for the log node - Log = ""; + Log.clear(); node = CIXml::getFirstChildNode (root, "LOG"); if (node) { 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/type.cpp b/code/nel/src/georges/type.cpp index f401c7ee8..5867f1282 100644 --- a/code/nel/src/georges/type.cpp +++ b/code/nel/src/georges/type.cpp @@ -185,7 +185,7 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); } else - Default = ""; + Default.clear(); // Read Min value = (const char*)xmlGetProp (root, (xmlChar*)"Min"); @@ -197,7 +197,7 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); } else - Min = ""; + Min.clear(); // Read Max value = (const char*)xmlGetProp (root, (xmlChar*)"Max"); @@ -209,7 +209,7 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); } else - Max = ""; + Max.clear(); // Read Increment value = (const char*)xmlGetProp (root, (xmlChar*)"Increment"); @@ -221,7 +221,7 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); } else - Increment = ""; + Increment.clear(); // Read the definitions uint childrenCount = CIXml::countChildren (root, "DEFINITION"); @@ -465,7 +465,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] == '\\') 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..bbe7948cd 100644 --- a/code/nel/src/gui/action_handler.cpp +++ b/code/nel/src/gui/action_handler.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { 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..02fd4b7d4 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 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/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..f0a41c8a0 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 { @@ -1768,7 +1771,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..54412f229 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 { 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 57b55b5cc..916b6a9e2 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -49,6 +49,9 @@ 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) @@ -572,7 +575,7 @@ namespace NLGUI curl_easy_cleanup(it->curl); 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()); } @@ -2088,10 +2091,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]; @@ -2111,7 +2114,7 @@ namespace NLGUI if(!_TitlePrefix.empty()) _TitleString = _TitlePrefix + " - "; else - _TitleString = ""; + _TitleString.clear(); _Title = true; } break; @@ -2143,10 +2146,10 @@ namespace NLGUI 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]) @@ -2368,7 +2371,7 @@ namespace NLGUI { endParagraph(); } - _DivName = ""; + _DivName.clear(); popIfNotEmpty (_Divs); popIfNotEmpty (_BlockLevelElement); break; @@ -2443,6 +2446,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; @@ -2612,7 +2616,7 @@ namespace NLGUI { CLuaManager::getInstance().executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true); } - _ObjectScript = ""; + _ObjectScript.clear(); } } _Object = false; @@ -2630,7 +2634,7 @@ namespace NLGUI { // we receive an embeded lua script _ParsingLua = _TrustedDomain; // Only parse lua if TrustedDomain - _LuaScript = ""; + _LuaScript.clear(); } } @@ -2685,8 +2689,6 @@ namespace NLGUI _LI = false; _SelectOption = false; _GroupListAdaptor = NULL; - _DocumentUrl = ""; - _DocumentDomain = ""; _UrlFragment.clear(); _RefreshUrl.clear(); _NextRefreshTime = 0.0; @@ -2739,7 +2741,6 @@ namespace NLGUI DefaultCheckBoxBitmapOver = "checkbox_over.tga"; DefaultRadioButtonBitmapNormal = "w_radiobutton.png"; DefaultRadioButtonBitmapPushed = "w_radiobutton_pushed.png"; - DefaultRadioButtonBitmapOver = ""; DefaultBackgroundBitmapView = "bg"; clearContext(); @@ -4623,34 +4624,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()) @@ -5823,7 +5811,7 @@ namespace NLGUI if (it->second == "monospace") style.FontFamily = "monospace"; else - style.FontFamily = ""; + style.FontFamily.clear(); } else if (it->first == "font-weight") 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..c0502577b 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; } diff --git a/code/nel/src/gui/group_menu.cpp b/code/nel/src/gui/group_menu.cpp index 48a9ee8b5..409921faf 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 { @@ -266,7 +269,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; @@ -1093,7 +1096,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 { 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..7eaf11841 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 @@ -337,7 +341,7 @@ namespace NLGUI if( fromString( value, i ) ) { _TextId = i; - _HardText = ""; + _HardText.clear(); } onTextChanged(); return; 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..e194a70a4 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 { diff --git a/code/nel/src/gui/group_tree.cpp b/code/nel/src/gui/group_tree.cpp index 1b80ee84b..c65ceba17 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 { @@ -765,7 +769,7 @@ namespace NLGUI rVR.getTextureSizeFromId(id, _XExtend, dummy); else // if not found, reset, to avoid errors - _ArboXExtend= ""; + _ArboXExtend.clear(); } // ---------------------------------------------------------------------------- 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/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..e33d1dbd8 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; 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..07e329feb 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 { 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..c0e7f6f17 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 @@ -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; } diff --git a/code/nel/src/gui/interface_link.cpp b/code/nel/src/gui/interface_link.cpp index 282199ee7..612fa908e 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 { 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..e038cb73e 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,7 +670,7 @@ namespace NLGUI if (strchr(ptr, '#') != NULL) { string LastProp = ptr.str(); - string NewProp =""; + string NewProp; string RepProp; while (LastProp.size() > 0) @@ -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..ab375ae5e 100644 --- a/code/nel/src/gui/interface_property.cpp +++ b/code/nel/src/gui/interface_property.cpp @@ -24,8 +24,18 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { + // helper to convert double <> sint64 + union C64BitsParts + { + sint64 i64; + double d; + }; bool CInterfaceProperty::link( CCDBNodeLeaf *dbNode ) { @@ -66,6 +76,20 @@ namespace NLGUI } + void CInterfaceProperty::setDouble(double value) + { + C64BitsParts parts; + parts.d = value; + setSInt64(parts.i64); + } + + double CInterfaceProperty::getDouble() const + { + C64BitsParts parts; + parts.i64 = getSInt64(); + return parts.d; + } + // ***************** // sint64 operations // ***************** @@ -104,10 +128,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); + _VolatileValue->setValue64(buf.i64); } else { diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index 53cc9e403..919d50562 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 { 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..0951d973c 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 } @@ -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" 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..e0be5837e 100644 --- a/code/nel/src/gui/stdpch.h +++ b/code/nel/src/gui/stdpch.h @@ -17,6 +17,13 @@ #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 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..75a84dc77 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) diff --git a/code/nel/src/gui/view_bitmap_combo.cpp b/code/nel/src/gui/view_bitmap_combo.cpp index 3fc54c89a..7ffe644b6 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 { 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 5b0127e1e..85b7a3baf 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 { 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 4c5d7c501..58aceb185 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 { diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index c88dd8173..06f46bf0c 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) @@ -1430,7 +1434,7 @@ namespace NLGUI // Append to the last line _Lines.back()->addWord(ucCurrentWord, 0, wordFormat, _FontWidth, *TextContext); // reset the word - ucCurrentWord = ucstring(""); + ucCurrentWord.clear(); } 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 bd8dfb5fe..73c7098fe 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 ) ); } // ------------------------------------------------------------------------------------------------ @@ -2109,8 +2113,6 @@ namespace NLGUI bool handled = false; - CViewPointer *_Pointer = static_cast< CViewPointer* >( getPointer() ); - if( evnt.getType() == CEventDescriptor::system ) { handleSystemEvent( evnt ); @@ -3272,7 +3274,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ void CWidgetManager::startAnim( const std::string &animId ) { - CInterfaceAnim *pIT = parser->getAnim( animId ); + CInterfaceAnim *pIT = _Parser->getAnim( animId ); if( pIT == NULL ) return; @@ -3298,7 +3300,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 ) @@ -3321,7 +3323,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; @@ -3357,7 +3359,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; @@ -3697,7 +3699,7 @@ namespace NLGUI CReflectableRegister::registerClasses(); - parser = IParser::createParser(); + _Parser = IParser::createParser(); _Pointer = NULL; curContextHelp = NULL; @@ -3739,6 +3741,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..0025d4290 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 (%p) :\n%s", filename.c_str(), xmlNode->name, xmlNode->content, 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/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..98b471e44 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,34 @@ 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) TARGET_LINK_LIBRARIES(nelmisc -lrt) - ENDIF(NOT APPLE) -ENDIF(UNIX) + ENDIF() +ENDIF() INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${PNG_INCLUDE_DIR} config_file) @@ -220,10 +219,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..100bc4d07 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); diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index 5574a8597..a996c8546 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -369,6 +369,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 +1837,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 +1877,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 +2245,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, diff --git a/code/nel/src/misc/bitmap_gif.cpp b/code/nel/src/misc/bitmap_gif.cpp index 4ae9dd0cf..9904d8312 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 { diff --git a/code/nel/src/misc/bitmap_png.cpp b/code/nel/src/misc/bitmap_png.cpp index 459437f5c..251fd5495 100644 --- a/code/nel/src/misc/bitmap_png.cpp +++ b/code/nel/src/misc/bitmap_png.cpp @@ -91,7 +91,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 +241,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 +289,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..92631280c 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{ 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/common.cpp b/code/nel/src/misc/common.cpp index 5954ac9c9..2194a89db 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -761,10 +761,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) { @@ -1011,20 +1013,32 @@ sint launchProgramAndWaitForResult(const std::string &programName, const std::st if (!createProcess(programName, arguments, log, pi)) return -1; // Successfully created the process. Wait for it to finish. - WaitForSingleObject(pi.hProcess, INFINITE); + DWORD ret = WaitForSingleObject(pi.hProcess, INFINITE); - // Get the exit code. - DWORD exitCode = 0; - BOOL ok = GetExitCodeProcess(pi.hProcess, &exitCode); + if (ret == WAIT_OBJECT_0) + { + // Get the exit code. + DWORD exitCode = 0; + BOOL ok = GetExitCodeProcess(pi.hProcess, &exitCode); - //nldebug("LAUNCH: Successful launch '%s' with arg '%s'", programName.c_str(), arguments.c_str()); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); + //nldebug("LAUNCH: Successful launch '%s' with arg '%s'", programName.c_str(), arguments.c_str()); + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); - if (ok) return (sint)exitCode; + if (ok) return (sint)exitCode; + } if (log) - nlwarning("LAUNCH: Failed launched '%s' with arg '%s'", programName.c_str(), arguments.c_str()); + { + std::string error = toString((uint)ret); + + if (ret == WAIT_FAILED) + { + error += "(" + formatErrorMessage(getLastError()) +")"; + } + + nlwarning("LAUNCH: Failed launched '%s' with arg '%s' and error: %s", programName.c_str(), arguments.c_str(), error.c_str()); + } return -1; #else @@ -1416,17 +1430,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 +1506,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 +1515,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 +1523,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 +1531,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 +1548,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 +1569,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..020416b01 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 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/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..70fb98d9f 100644 --- a/code/nel/src/misc/hierarchical_timer.cpp +++ b/code/nel/src/misc/hierarchical_timer.cpp @@ -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 a170f6d20..3d617bef4 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..e3d6f19a6 100644 --- a/code/nel/src/misc/i_xml.cpp +++ b/code/nel/src/misc/i_xml.cpp @@ -67,7 +67,6 @@ CIXml::CIXml () : IStream (true /* Input mode */) _CurrentNode = NULL; _PushBegin = false; _AttribPresent = false; - _ErrorString = ""; _TryBinaryMode = false; _BinaryStream = NULL; } @@ -82,7 +81,6 @@ CIXml::CIXml (bool tryBinaryMode) : IStream (true /* Input mode */) _CurrentNode = NULL; _PushBegin = false; _AttribPresent = false; - _ErrorString = ""; _TryBinaryMode = tryBinaryMode; _BinaryStream = NULL; } @@ -105,18 +103,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(); } @@ -195,7 +191,7 @@ bool CIXml::init (IStream &stream) } // Set error handler - _ErrorString = ""; + _ErrorString.clear(); xmlSetGenericErrorFunc (this, xmlGenericErrorFuncRead); // Ask to get debug info @@ -319,7 +315,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 +715,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 +744,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 +769,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 +789,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 +902,7 @@ bool CIXml::xmlPopInternal () // *************************************************************************** -bool CIXml::xmlSetAttribInternal (const char *attribName) +bool CIXml::xmlSetAttribInternal (const std::string &attribName) { nlassert( isReading() ); @@ -955,7 +951,7 @@ bool CIXml::xmlBreakLineInternal () // *************************************************************************** -bool CIXml::xmlCommentInternal (const char * /* comment */) +bool CIXml::xmlCommentInternal (const std::string &/* comment */) { // Ok return true; @@ -963,12 +959,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 +973,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 +1015,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 +1053,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 @@ -1077,7 +1073,7 @@ bool CIXml::getPropertyString (std::string &result, xmlNodePtr node, const char // *************************************************************************** -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; @@ -1099,7 +1095,7 @@ 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; @@ -1113,7 +1109,7 @@ double CIXml::getFloatProperty(xmlNodePtr node, const char *property, float defa // *************************************************************************** -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; @@ -1145,6 +1141,11 @@ bool CIXml::getContentString (std::string &result, xmlNodePtr node) // *************************************************************************** +void CIXml::releaseLibXml() +{ + xmlCleanupParser(); +} + } // 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/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..2228b24dc 100644 --- a/code/nel/src/misc/o_xml.cpp +++ b/code/nel/src/misc/o_xml.cpp @@ -134,7 +134,7 @@ COXml::COXml () : IStream (false /* Output mode */) _CurrentNode = NULL; // Content string - _ContentString = ""; + _ContentString.clear(); // Push begin _PushBegin = false; @@ -152,7 +152,7 @@ void xmlGenericErrorFuncWrite (void *ctx, const char *msg, ...) // *************************************************************************** -bool COXml::init (IStream *stream, const char *version) +bool COXml::init (IStream *stream, const std::string &version) { resetPtrTable(); @@ -160,7 +160,7 @@ bool COXml::init (IStream *stream, const char *version) if (!stream->isReading()) { // Set error handler - _ErrorString = ""; + _ErrorString.clear(); xmlSetGenericErrorFunc (this, xmlGenericErrorFuncWrite); // Set XML mode @@ -179,7 +179,7 @@ bool COXml::init (IStream *stream, const char *version) _CurrentNode = NULL; // Content string - _ContentString = ""; + _ContentString.clear(); // Push begin _PushBegin = false; @@ -201,7 +201,7 @@ COXml::~COXml () // *************************************************************************** -void COXml::serialSeparatedBufferOut( const char *value ) +void COXml::serialSeparatedBufferOut( const std::string &value ) { nlassert( ! isReading() ); @@ -218,7 +218,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 +349,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 +365,7 @@ void COXml::serial(std::string &b) if (_PushBegin) { // Only serial the string - serialSeparatedBufferOut( b.c_str() ); + serialSeparatedBufferOut( b ); } else { @@ -372,7 +373,7 @@ void COXml::serial(std::string &b) xmlPush ("S"); // Serial the string - serialSeparatedBufferOut( b.c_str() ); + serialSeparatedBufferOut( b ); // Close the node xmlPop (); @@ -415,7 +416,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 +440,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 +452,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 +544,7 @@ bool COXml::xmlPopInternal () // *************************************************************************** -bool COXml::xmlSetAttribInternal (const char *attribName) +bool COXml::xmlSetAttribInternal (const std::string &attribName) { nlassert( ! isReading() ); @@ -608,7 +609,7 @@ bool COXml::xmlBreakLineInternal () // *************************************************************************** -bool COXml::xmlCommentInternal (const char *comment) +bool COXml::xmlCommentInternal (const std::string &comment) { nlassert( ! isReading() ); @@ -619,7 +620,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,15 +666,9 @@ 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; } // *************************************************************************** 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/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/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/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..7177b062b 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(); } // **************************************************************************** diff --git a/code/nel/src/misc/system_info.cpp b/code/nel/src/misc/system_info.cpp index b78389064..680329dcf 100644 --- a/code/nel/src/misc/system_info.cpp +++ b/code/nel/src/misc/system_info.cpp @@ -1387,13 +1387,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 * stfs.f_bsize); #else ULARGE_INTEGER freeSpace = {0}; BOOL bRes = ::GetDiskFreeSpaceExW(utf8ToWide(path), &freeSpace, NULL, NULL); @@ -1525,7 +1522,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/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..b157448ec 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) 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..625523ea5 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()) 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/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_common.cpp b/code/nel/src/net/module_common.cpp index 0133343dd..f16e1bfa9 100644 --- a/code/nel/src/net/module_common.cpp +++ b/code/nel/src/net/module_common.cpp @@ -212,8 +212,8 @@ namespace NLNET { // 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_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_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/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/varpath.cpp b/code/nel/src/net/varpath.cpp index 729f52074..4fc52c341 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); 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; igetNamePrefix().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/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/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_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 6f2c2b449..58e171e0a 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -1770,7 +1770,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 +1797,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() : "" )); } 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/sound_driver_dsound.cpp b/code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp index ba212b990..986993c49 100644 --- a/code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp +++ b/code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp @@ -563,15 +563,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/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..4c83d5a0d 100644 --- a/code/nel/src/sound/driver/sound_driver.cpp +++ b/code/nel/src/sound/driver/sound_driver.cpp @@ -200,7 +200,7 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD #if defined (NL_COMP_MINGW) dllName = "libnel_drv_xaudio2_win"; #elif defined (NL_OS_WINDOWS) - dllName = "nel_drv_xaudio2_win"; + dllName = "nel_drv_fmod_win"; #elif defined (NL_OS_UNIX) dllName = "nel_drv_openal"; #else @@ -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/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/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/tools/3d/CMakeLists.txt b/code/nel/tools/3d/CMakeLists.txt index 034fc5f55..ff5c37db0 100644 --- a/code/nel/tools/3d/CMakeLists.txt +++ b/code/nel/tools/3d/CMakeLists.txt @@ -48,9 +48,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 +59,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 04213d34b..a8f854721 100644 --- a/code/nel/tools/3d/build_interface/main.cpp +++ b/code/nel/tools/3d/build_interface/main.cpp @@ -209,12 +209,14 @@ int main(int argc, char **argv) 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; - + // build as a subset of existing interface bool buildSubset = false; string existingUVfilename; @@ -225,12 +227,142 @@ int main(int argc, char **argv) existingUVfilename = args.getArg("s").front(); } + // extract all interface elements + bool extractElements = args.haveArg("x"); + + // output format + std::string outputFormat; + + if (args.haveArg("f")) + { + outputFormat = args.getArg("f").front(); + + if (outputFormat != "png" && outputFormat != "tga") + { + outString(toString("ERROR: Format %s not supported, only png and tga formats are", outputFormat.c_str())); + return -1; + } + } + std::vector 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 += ".png"; + 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; vector::iterator it = inputDirs.begin(), itEnd = inputDirs.end(); @@ -263,10 +395,12 @@ int main(int argc, char **argv) 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) { outString(toString("Converting %s to RGBA (32 bits), originally using %u bits...", AllMapNames[i].c_str(), (uint)colors)); @@ -348,6 +482,9 @@ int main(int argc, char **argv) UVMax[i].V = UVMax[i].V / (float)GlobalTexture.getHeight(); } + // make sure transparent pixels are black + GlobalTexture.makeTransparentPixelsBlack(); + // Write global texture file if (writeFileDependingOnFilename(fmtName, GlobalTexture)) { @@ -363,7 +500,7 @@ int main(int argc, char **argv) { fmtName = fmtName.substr(0, fmtName.rfind('.')); fmtName += ".txt"; - FILE *f = nlfopen(fmtName, "wt"); + FILE *f = nlfopen(fmtName, "wb"); if (f != NULL) { for (sint i = 0; i < mapSize; ++i) @@ -397,7 +534,7 @@ int main(int argc, char **argv) // Write subset UV text file fmtName = fmtName.substr(0, fmtName.rfind('.')); fmtName += ".txt"; - FILE *f = nlfopen(fmtName, "wt"); + FILE *f = nlfopen(fmtName, "wb"); if (f == NULL) { @@ -417,17 +554,27 @@ int main(int argc, char **argv) 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 ) { @@ -437,8 +584,7 @@ int main(int argc, char **argv) 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 (f); diff --git a/code/nel/tools/3d/cluster_viewer/view_cs.cpp b/code/nel/tools/3d/cluster_viewer/view_cs.cpp index 5e31543ca..9e4dc4f80 100644 --- a/code/nel/tools/3d/cluster_viewer/view_cs.cpp +++ b/code/nel/tools/3d/cluster_viewer/view_cs.cpp @@ -175,7 +175,6 @@ void LoadSceneScript (const char *ScriptName, CScene* pScene, vector &D if (ITemp != NULL) { SDispCS dcsTemp; - dcsTemp.Name = ""; for (sint32 i = 0; i < (1+nNbPlus); ++i) dcsTemp.Name += " "; dcsTemp.Name += nameIG; 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/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..0d9f6deb3 100644 --- a/code/nel/tools/3d/mesh_utils/CMakeLists.txt +++ b/code/nel/tools/3d/mesh_utils/CMakeLists.txt @@ -13,4 +13,4 @@ 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..d942a3d6e 100644 --- a/code/nel/tools/3d/object_viewer/dup_ps.cpp +++ b/code/nel/tools/3d/object_viewer/dup_ps.cpp @@ -67,7 +67,7 @@ struct CDupObjPolicy dest.serialPtr(obj); /*if (dest.isReading()) { - std::auto_ptr newObj(new T); + CUniquePtr newObj(new T); newObj->serialPtr(dest); delete obj; obj = newObj.release(); @@ -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..525d15ab7 100644 --- a/code/nel/tools/3d/object_viewer/editable_range.cpp +++ b/code/nel/tools/3d/object_viewer/editable_range.cpp @@ -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..207404635 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); @@ -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; 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..54df32400 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(); @@ -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); 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_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/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..af4326cd7 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); } } } @@ -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..ee0b05c21 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; } @@ -223,7 +246,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP setlocale (LC_NUMERIC, "English"); 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(); @@ -718,39 +715,39 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP theCNelExport.getSelectedNode (vectNode); if (vectNode.size() == 0) { - ::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); + theCNelExport._Ip->RollupMouseMessage(hWnd,msg,wParam,lParam); break; default: @@ -768,7 +765,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 +774,7 @@ CNelExport::~CNelExport() } -void CNelExport::BeginEditParams(Interface *_Ip,IUtil *iu) +void CNelExport::BeginEditParams(Interface *_Ip,IUtil *iu) { theIP = _Ip; if (_ExportNel) @@ -789,8 +786,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 +825,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 +842,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 +857,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.h b/code/nel/tools/3d/plugin_max/nel_export/nel_export.h index f6f0b145a..eabc05a09 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 @@ -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, TCHAR* Title, const TCHAR* Mask, std::string &FileName); + ULONG SelectDir(HWND Parent, 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..dd48e4487 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; @@ -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..a41c3134c 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,34 +236,30 @@ 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..7ecb61efe 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, 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, 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); + + ITEMIDLIST* 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::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)(first->c_str())); } } // 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)(currentParam->OcclusionModel.c_str())) == 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)(currentParam->OpenOcclusionModel.c_str())) == 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)(currentParam->EnvironmentFX.c_str())) == 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)(currentParam->SoundGroup.c_str())) == CB_ERR) { // nlassert(false); } @@ -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); @@ -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); @@ -669,8 +669,8 @@ INT_PTR CALLBACK MRMDialogCallback ( 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); @@ -717,11 +717,11 @@ INT_PTR CALLBACK MRMDialogCallback ( 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 @@ -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,7 +930,7 @@ 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); @@ -950,16 +950,16 @@ INT_PTR CALLBACK InstanceDialogCallback ( 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); @@ -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,7 +1048,7 @@ 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 @@ -1065,7 +1065,7 @@ INT_PTR CALLBACK LightmapDialogCallback ( 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,7 +1090,7 @@ 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 @@ -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 @@ -1432,7 +1432,7 @@ INT_PTR CALLBACK LMCCopyFromDialogCallback( lmcParam->SelectionDone= 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 @@ -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 @@ -1679,7 +1679,7 @@ INT_PTR CALLBACK VegetableDialogCallback ( 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); } @@ -1732,9 +1732,9 @@ INT_PTR CALLBACK VegetableDialogCallback ( 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: @@ -1930,7 +1930,7 @@ 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; @@ -1953,29 +1953,29 @@ void updateVPWTStatic(HWND hwndDlg, uint type, uint depth, const CVPWindTreeAppD { 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: 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: 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: 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: 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)); } @@ -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,7 +2102,7 @@ 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 ) @@ -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,7 +2216,7 @@ 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; @@ -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_FILE), utf8ToTStr(currentParam->InterfaceFileName)); SetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INTERFACE_THRESHOLD), - currentParam->InterfaceThreshold != -1.f ? toStringMax(currentParam->InterfaceThreshold).c_str() - : "" + 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; @@ -2332,32 +2332,32 @@ INT_PTR CALLBACK MiscDialogCallback ( 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) + if (_tcslen(tmp) != 0) currentParam->InterfaceThreshold = toFloatMax(tmp); currentParam->GetInterfaceNormalsFromSceneObjects = SendMessage (GetDlgItem (hwndDlg, IDC_GET_INTERFACE_NORMAL_FROM_SCENE_OBJECTS), BM_GETCHECK, 0, 0); @@ -2365,18 +2365,20 @@ INT_PTR CALLBACK MiscDialogCallback ( // 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); @@ -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,7 +2522,7 @@ 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 @@ -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); } @@ -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) @@ -2942,7 +2944,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()) { tmplist.push_back (nameLod); } @@ -3048,7 +3050,7 @@ void CNelExport::OnNodeProperties (const std::set &listNode) 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(); 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..ba4fe5769 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"); #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..863b1b89b 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; @@ -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()); } @@ -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..789c37b23 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) 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..82eb42484 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)); } } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp index 5997006d5..908d87c6d 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp @@ -223,7 +223,7 @@ Animatable* CExportNel::getSubAnimByName (Animatable& node, const char* sName) TSTR sSubName=node.SubAnimName(nSub); // Good name? - if (strcmp (sSubName, sName)==0) + if (strcmp (sSubName.ToUTF8(), sName)==0) { // ok, return this subanim return node.SubAnim(nSub); @@ -265,7 +265,7 @@ Control* CExportNel::getControlerByName (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) { // 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; @@ -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); } // -------------------------------------------------- @@ -549,7 +549,7 @@ std::string CExportNel::getNelObjectName (INode& node) } else { - return node.GetName(); + return tStrToUtf8(node.GetName()); } } else @@ -561,29 +561,26 @@ 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()); } } } @@ -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 @@ -853,7 +850,7 @@ void CExportNel::addParentLodNode (INode &child, std::set &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 @@ -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; } @@ -1111,15 +1108,26 @@ static void restoreDecimalSeparator() ///======================================================================= -float toFloatMax(const char *src) +float toFloatMax(const TCHAR *src) +{ + float result = 0.f; + if (toFloatMax(tStrToUtf8(src), result)) return result; + return 0.f; +} + +float toFloatMax(const std::string &src) { float result = 0.f; if (toFloatMax(src, result)) return result; return 0.f; } +bool toFloatMax(const TCHAR *src, float &dest) +{ + return toFloatMax(tStrToUtf8(src), dest); +} -bool toFloatMax(const char *src, float &dest) +bool toFloatMax(const std::string &src, float &dest) { setDecimalSeparatorAsPoint(); std::string str(src); diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_nel.h b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_nel.h index 11e762099..178190f13 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_nel.h +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_nel.h @@ -667,8 +667,8 @@ public: static void setScriptAppData (Animatable *node, uint32 id, NLMISC::CRGBA val); // Output error message - void outputErrorMessage (const char *message); - void outputWarningMessage (const char *message); + void outputErrorMessage (const std::string &message); + void outputWarningMessage(const std::string &message); // Get an appData VertexProgram WindTree (ensure same default values for all retrieve). @@ -1092,9 +1092,11 @@ private: /** replacment for sprintf scanf (because of localisation in max) */ -float toFloatMax(const char *src); +float toFloatMax(const std::string &src); +float toFloatMax(const TCHAR *src); // Same as to float max, but returns true if succeed -bool toFloatMax(const char *src, float &dest); +bool toFloatMax(const std::string &src, float &dest); +bool toFloatMax(const TCHAR *src, float &dest); std::string toStringMax(float value); std::string toStringMax(int value); diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp index b84eb738e..4b17b17d3 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp @@ -51,7 +51,7 @@ IShape* CExportNel::buildParticleSystem(INode& node, TimeValue time) iF.serial(ss); if (!dynamic_cast(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..d623b7269 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 @@ -62,7 +62,7 @@ void CRadialVertices::init (INode *node, Mesh *mesh, TimeValue time, Interface & _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..2fb18cd9f 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()); } @@ -513,10 +504,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (vClusters.size() > 0) if (aIGArray[nNumIG].Clusters.size() == 0) { - 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_tess.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_tess.cpp index 0823afbd4..34d6b8397 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 @@ -223,7 +227,7 @@ BOOL CALLBACK PatchObjSurfDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM 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; 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..bb134c871 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 @@ -70,7 +70,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) //------------------------------------------------------ __declspec( dllexport ) const TCHAR *LibDescription() { - return "NeL Patch Edit"; + return _T("NeL Patch Edit"); } /// MUST CHANGE THIS NUMBER WHEN ADD NEW CLASS 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..ede7215f9 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 @@ -35,7 +35,7 @@ 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) @@ -50,7 +50,7 @@ INT_PTR CALLBACK PatchSelectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPAR if (hModule) { // Get module file name - char moduldeFileName[512]; + TCHAR moduldeFileName[512]; if (GetModuleFileName (hModule, moduldeFileName, 512)) { // Get version info size @@ -59,22 +59,22 @@ 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", + TCHAR version[512]; + _stprintf(version, _T("Version %d.%d.%d.%d"), info->dwFileVersionMS>>16, info->dwFileVersionMS&0xffff, info->dwFileVersionLS>>16, @@ -82,25 +82,25 @@ INT_PTR CALLBACK PatchSelectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPAR 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; @@ -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; } @@ -224,7 +224,7 @@ 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; } } 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; iGetName(); - 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; @@ -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); } } } @@ -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,29 +4057,25 @@ 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()); } } } @@ -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() ) { @@ -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); } } @@ -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; @@ -4590,7 +4587,11 @@ int EPM_PaintMouseProc::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, tile1, tile2, mesh1, mesh2, seg1; @@ -4619,8 +4620,10 @@ int EPM_PaintMouseProc::proc( 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_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..3a513683a 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)"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); - 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..c77a027a9 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); @@ -159,16 +159,16 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MOUSEMOVE: - theTile_utility.ip->RollupMouseMessage(hWnd,msg,wParam,lParam); + 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 +178,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 +187,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 +197,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 +223,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 +240,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 +252,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 +264,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 +291,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 +301,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 +319,7 @@ void Tile_utility::SetLand (sint land) Land=0; SetBankTileSetSet (Land); } - + void Tile_utility::SetupUI () { // Clear combo box @@ -335,7 +333,7 @@ void Tile_utility::SetupUI () // Enable combo box if (Bank.getLandCount()) EnableWindow (hCombo, TRUE); - else + else EnableWindow (hCombo, FALSE); } @@ -368,32 +366,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 +407,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 +415,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 +434,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 +447,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 +456,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 +467,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 +476,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/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/SelectionTerritoire.cpp b/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp index f82eef8c2..15b9a5b7d 100644 --- a/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp +++ b/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp @@ -98,7 +98,7 @@ void SelectionTerritoire::OnAddTerritoire() CListBox *list=(CListBox*)GetDlgItem(IDC_LIST_TERRITOIRE); if (list->FindStringExact(0,GetStr.name)!=LB_ERR) { - MessageBox("Ce nom existe deja","Error",MB_ICONERROR); + MessageBox(_T("Ce nom existe deja","Error"), MB_ICONERROR); } else { @@ -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,7 +197,7 @@ 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 { @@ -268,7 +268,7 @@ void SelectionTerritoire::OnEditTileSet() } else { - MessageBox("No tilesset selected","Error",MB_ICONERROR); + MessageBox(_T("No tilesset selected"), _T("Error"), MB_ICONERROR); } } @@ -284,7 +284,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 +315,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 +346,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 +355,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 +377,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 +400,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 +420,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(); } @@ -453,9 +448,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,19 +464,17 @@ 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(); } @@ -543,7 +535,7 @@ void SelectionTerritoire::OnPath() // 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) + if (MessageBox (msg, _T("TileEdit"), MB_YESNO|MB_ICONQUESTION)==IDYES) { // Set as default path.. @@ -579,7 +571,7 @@ 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) @@ -591,7 +583,7 @@ void SelectionTerritoire::OnPath() sprintf (msg, "Path '%s' can't be found in bitmap '%s'. Continue ?", path, bitmapPath.c_str()); // Message - if (MessageBox (msg, "TileEdit", MB_YESNO|MB_ICONQUESTION)==IDNO) + if (MessageBox (msg, _T("TileEdit"), MB_YESNO|MB_ICONQUESTION)==IDNO) break; } } @@ -620,7 +612,7 @@ void SelectionTerritoire::OnPath() sprintf (msg, "Path '%s' can't be found in bitmap '%s'. Continue ?", path, bitmapPath); // Message - if (MessageBox (msg, "TileEdit", MB_YESNO|MB_ICONQUESTION)==IDNO) + if (MessageBox (msg, _T("TileEdit"), MB_YESNO|MB_ICONQUESTION)==IDNO) break; } } @@ -650,7 +642,7 @@ 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); @@ -670,7 +662,7 @@ 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); @@ -683,7 +675,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); } @@ -706,9 +698,9 @@ 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 +729,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/View.cpp b/code/nel/tools/3d/tile_edit/View.cpp index 81f5fe784..9a0907aa3 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; } @@ -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,20 @@ 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); + MessageBox (NULL, (tileBank2.getAbsPath() + troncated).c_str(), _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."), troncated.c_str(), MB_OK|MB_ICONEXCLAMATION); // Free the bitmap @@ -467,7 +466,7 @@ int TileList::setDisplacement (int tile, const std::string& name) // 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); + MessageBox (NULL, msg, _T("Load error"), MB_OK|MB_ICONEXCLAMATION); } return 1; @@ -537,7 +536,7 @@ int TileList::setTileTransitionAlpha (int tile, const std::string& name, int rot // 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); + MessageBox (NULL, msg, _T("Load error"), MB_OK|MB_ICONEXCLAMATION); } return 1; @@ -670,7 +669,7 @@ 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)) { @@ -680,7 +679,7 @@ bool TileInfo::Load (int index, std::vector* Alpha) 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)) { @@ -690,7 +689,7 @@ bool TileInfo::Load (int index, std::vector* Alpha) 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 ())) @@ -754,7 +753,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 +1123,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 +1138,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 +1152,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 +1204,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 +1283,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 +1294,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 +1527,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 +1544,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 +1683,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/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_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/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..131e5961c 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()); @@ -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) 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/logic_editorDoc.cpp b/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp index 0b91c41f4..baf34938c 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp +++ b/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp @@ -578,7 +578,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) // Close the file file.close (); } - catch (Exception &) + catch (const Exception &) { } @@ -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_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..c20a90d53 100644 --- a/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp +++ b/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp @@ -669,7 +669,7 @@ 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" ); + ((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 ); @@ -688,8 +688,8 @@ void CBranch_patcherDlg::OnButtonExtractTokens() m_TargetDirLabel = "Target Dir"; m_SrcDir = SrcDirBackup; m_DestDir = TargetDirBackup; - m_Filename = ""; - ((CButton*)GetDlgItem( IDC_ButtonExtractTokens ))->SetWindowText( "Enter Tokens" ); + 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 ); @@ -703,8 +703,8 @@ void CBranch_patcherDlg::OnButtonExtractTokens() void CBranch_patcherDlg::OnButtonClearTokens() { - Token1 = ""; - Token2 = ""; + Token1.Empty(); + Token2.Empty(); displayTokens(); } 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/log_analyser/PlugInSelector.cpp b/code/nel/tools/misc/log_analyser/PlugInSelector.cpp index 9a21a8df6..f62c0b5b1 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,7 +144,7 @@ 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() ); @@ -154,7 +154,7 @@ void CPlugInSelector::OnSelchangeList1() 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/ViewDialog.cpp b/code/nel/tools/misc/log_analyser/ViewDialog.cpp index c750cbd83..0e524ff31 100644 --- a/code/nel/tools/misc/log_analyser/ViewDialog.cpp +++ b/code/nel/tools/misc/log_analyser/ViewDialog.cpp @@ -483,7 +483,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..34e7459cb 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 ) 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/nel_unit_test/nel_unit_test.cpp b/code/nel/tools/nel_unit_test/nel_unit_test.cpp index 753dfd46a..ede52b006 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(CUniquePtr(new CUTMisc)); + ts.add(CUniquePtr(new CUTNet)); + ts.add(CUniquePtr(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/ut_ligo.h b/code/nel/tools/nel_unit_test/ut_ligo.h index 6dba782d8..338ffada0 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(CUniquePtr(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..900273260 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(CUniquePtr(new CUTMiscCoTask)); + add(CUniquePtr(new CUTMiscCommand)); + add(CUniquePtr(new CUTMiscCommon)); + add(CUniquePtr(new CUTMiscConfigFile)); + add(CUniquePtr(new CUTMiscDebug)); + add(CUniquePtr(new CUTMiscDynLibLoad)); + add(CUniquePtr(new CUTMiscFile)); + add(CUniquePtr(new CUTMiscPackFile)); + add(CUniquePtr(new CUTMiscSingleton)); + add(CUniquePtr(new CUTMiscSString)); + add(CUniquePtr(new CUTMiscStream)); + add(CUniquePtr(new CUTMiscVariable)); + add(CUniquePtr(new CUTMiscTypes)); + add(CUniquePtr(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..64678f828 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(CUniquePtr(new CUTNetLayer3)); + add(CUniquePtr(new CUTNetMessage)); + add(CUniquePtr(new CUTNetModule)); // Add a line here when adding a new test CLASS } }; 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/client_default.cfg b/code/ryzom/client/client_default.cfg index eece51360..b127ae3a6 100644 --- a/code/ryzom/client/client_default.cfg +++ b/code/ryzom/client/client_default.cfg @@ -41,7 +41,6 @@ Gamma_max = 1.0; Application = { "ryzom_live", "./client_ryzom_r.exe", "./" }; BackgroundDownloader = 0; -PatchUrl = "http://dl.ryzom.com/patch_live"; StartupHost = "shard.ryzom.com:40916"; StartupPage = "/login/r2_login.php"; @@ -106,6 +105,7 @@ FreeLookAcceleration_min = 20; FreeLookAcceleration_max = 80; FreeLookInverted = 0; +FreeLookTablet = 0; AutomaticCamera = 0; DblClickMode = 1; AutoEquipTool = 1; @@ -473,7 +473,8 @@ XMLInterfaceFiles = { "commands2.xml", "ring_access_point_filter.xml", "ring_window.xml", - "bg_downloader.xml" + "bg_downloader.xml", + "ryzhome_toolbar.xml" }; XMLR2EDInterfaceFiles = diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml b/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml index 6fdb5d32a..58f41d919 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml @@ -63,9 +63,15 @@ + + + + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml index 38e63cb24..bcd2bb808 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml @@ -2672,9 +2672,9 @@ + posref="TM TL" + x="0" + y="-35" /> + + - @@ -44,13 +44,13 @@