diff --git a/.gitignore b/.gitignore index eda61148c..6d75a91f5 100644 --- a/.gitignore +++ b/.gitignore @@ -162,13 +162,6 @@ build/* install/* build_vc* code/nel/tools/build_gamedata/configuration/buildsite.py -code/build_mac -code/build_linux32 -code/build_linux64 -code/build_windows32 -code/build_windows64 -code/build_server -code/build_nel_tools # Linux nel compile code/nel/build/nel-config @@ -245,7 +238,6 @@ code/ryzom/tools/server/ryzom_ams/old #tools and external dir's external -external_vc14 external_stlport nel_tools* ryzom_tools* diff --git a/.hgeol b/.hgeol new file mode 100644 index 000000000..a9766f577 --- /dev/null +++ b/.hgeol @@ -0,0 +1,28 @@ +[patterns] +**.h = native +**.cpp = native + +**/database.xml = BIN +**/msg.xml = BIN + +**.txt = native +**.xml = native + +**.layout = native +**.looknfeel = native +**.imageset = native +**.font = native +**.scheme = native + +**.tpl = native + +**.xsd = native +**.dox = native + +**.py = native +**.lua = native + +**.pkg = native + +[repository] +native = LF diff --git a/.hgignore b/.hgignore new file mode 100644 index 000000000..41a0e58cf --- /dev/null +++ b/.hgignore @@ -0,0 +1,265 @@ +syntax: glob + +# Various build directories +bin +obj +Debug +Release +ReleaseDebug +DebugFast +ReleaseDebugStatic +DebugFastStatic + +# Test and application directories +screenshots +release +test +Temp + +# NeL cache +*.packed_sheets + +# Ryzom save +save_shard +last_loaded_char.bin +*.binprim +*.string_cache +graphs_output +default_c + +# Windows compile +*.exe +*.dll +*.lib +*.obj + +# Linux compile +*.a +*.la +*.lo +*.Po +*.Plo +*.o +*.so +*.so.* +*_debug +*.pc +*.gch + +# Mac OS X compile +*.dylib + +# Log dump files +report_refused +report_failed +exception_catched +*.stat +*.log +log.txt + +# Max plugin extensions +*.dlx +*.dlm +*.dlu + +# makeall build +.mode_static + +# cmake build files & directories +CMakeFiles +CMakeCache.txt +cmake_install.cmake +CTestTestfile.cmake +CPackConfig.cmake +CPackSourceConfig.cmake +.libs + +# Linux garbage +Makefile* +aclocal.m4 +config.guess +config.sub +configure +depcomp +config.h.in +nelconfig.h.in +install-sh +ltmain.sh +missing +ylwrap +*.mk + +# Visual Studio garbage +*.opensdf +UpgradeLog*.XML +_UpgradeReport_Files +BuildLog.htm +mt.dep +ipch +*.suo +*.ncb +*.user +*.ilk +*.pdb +*.aps +*.exp +*.idb +*.sdf + +# Mac OS X garbage +.DS_Store + +# Ryzom server garbage +aes_alias_name.cfg +aes_nagios_report.txt +aes_state.txt +*.launch_ctrl +*.state +*.start_count + +# Vim and kwrite cache +*~ + +# Kdevelop4 garbage +*.kdev4 +.kdev4 + +# intellij project folder +.idea/ + +# Python cache +*.pyd +*.pyc + +# Qt compiler +moc_*.cpp +*.moc + +# Misc garbage +*.rej +*.orig +*.cachefile +*.cache +*.patch +*.7z +3rdParty +.svn +thumbs.db +Thumbs.db +*.tpl.php +.SyncID +.SyncIgnore +.SyncArchive + +# build +code/nel/build/* +code/nelns/build/* +code/snowballs/build/* +code/ryzom/build/* +code/build/* +code/build-2010/* +build/* +install/* +build_vc* +code/nel/tools/build_gamedata/configuration/buildsite.py + +# Linux nel compile +code/nel/build/nel-config +code/nel/config.status +code/nel/include/nelconfig.h +code/nel/include/stamp-h1 +code/nel/libtool +code/nel/nel-config +code/nel/samples/3d/cluster_viewer/cluster_viewer +code/nel/samples/3d/font/font +code/nel/samples/georges/georges +code/nel/samples/misc/command/command +code/nel/samples/misc/configfile/configfile +code/nel/samples/misc/debug/debug +code/nel/samples/misc/i18n/i18n +code/nel/samples/misc/log/log +code/nel/samples/misc/strings/strings +code/nel/samples/net/chat/chatclient +code/nel/samples/net/chat/chatserver +code/nel/samples/net/login_system/nls_frontend_service +code/nel/samples/net/login_system/nls_login_client +code/nel/samples/net/udp/udp_bench_client +code/nel/samples/net/udp/udp_bench_service +code/nel/samples/pacs/pacs_sample +code/nel/tools/3d/build_coarse_mesh/build_coarse_mesh +code/nel/tools/3d/build_far_bank/build_far_bank +code/nel/tools/3d/build_smallbank/build_smallbank +code/nel/tools/3d/ig_lighter/ig_lighter +code/nel/tools/3d/zone_dependencies/zone_dependencies +code/nel/tools/3d/zone_ig_lighter/zone_ig_lighter +code/nel/tools/3d/zone_lighter/zone_lighter +code/nel/tools/3d/zone_welder/zone_welder +code/nel/tools/misc/bnp_make/bnp_make +code/nel/tools/misc/disp_sheet_id/disp_sheet_id +code/nel/tools/misc/make_sheet_id/make_sheet_id +code/nel/tools/misc/xml_packer/xml_packer +code/nel/tools/pacs/build_ig_boxes/build_ig_boxes +code/nel/tools/pacs/build_indoor_rbank/build_indoor_rbank +code/nel/tools/pacs/build_rbank/build_rbank +code/ryzom/common/data_leveldesign/leveldesign/game_element/xp_table/skills.skill_tree +code/ryzom/common/data_leveldesign/leveldesign/game_element/xp_table/xptable.xp_table +code/ryzom/tools/server/sql/ryzom_admin_default_data.sql + + +# Linux server compile +code/ryzom/server/src/entities_game_service/entities_game_service +code/ryzom/server/src/frontend_service/frontend_service +code/ryzom/server/src/gpm_service/gpm_service +code/ryzom/server/src/input_output_service/input_output_service +code/ryzom/server/src/mirror_service/mirror_service +code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service +code/ryzom/server/src/ryzom_naming_service/ryzom_naming_service +code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service +code/ryzom/server/src/tick_service/tick_service +# WebTT temp dir +code/ryzom/tools/server/www/webtt/app/tmp + +# AMS ignore +code/web/public_php/ams/is_installed +code/web/docs/ams/html +code/web/public_php/ams/templates_c +code/ryzom/tools/server/ryzom_ams/drupal +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/autoload +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/configs +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/cron +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/img +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/plugins +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/smarty +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/translations +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/libinclude.php +code/ryzom/tools/server/ryzom_ams/old + + + +#tools and external dir's +external +external_stlport +nel_tools* +ryzom_tools* + +#Dumps +*.dmp + +code/nel/tools/build_gamedata/processes/ai_wmap/ai_build_wmap.cfg +code/nel/tools/build_gamedata/processes/sheets/sheets_packer.cfg +code/nel/tools/build_gamedata/processes/rbank/build_rbank.cfg +code/nel/tools/build_gamedata/processes/zone/debug_zone_dependencies.cfg +code/web/public_php/config.php +code/web/public_php/is_installed +code/web/public_php/ams/files +code/web/public_php/db_version_lib +code/web/public_php/db_version_shard +code/web/public_php/db_version_tool +code/web/public_php/db_version_web +code/web/public_php/role_service +code/web/public_php/role_support +code/web/public_php/role_domain +code/web/public_php/db_version_ring +code/web/public_php/config_user.php +code/nel/tools/build_gamedata/processes/pz/build_world_packed_col.cfg +code/nel/tools/build_gamedata/processes/cartographer/island_screenshots.cfg diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..c59df07eb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,48 @@ +sudo: false +language: cpp + +compiler: + - gcc + +os: + - linux +matrix: + fast_finish: true +env: + - CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS=OFF -DWITH_LUA51=ON" + - CMAKE_CONFIGURE_OPTIONS="-DCPPTEST_LIBRARY_DEBUG:STRING=/usr/lib/libcpptest.so" + CMAKE_BUILD_OPTIONS="--target nel_unit_test -- -j 2" + RUN="build/bin/nel_unit_test" + +addons: + apt: + packages: + - liblua5.1-dev + - libluabind-dev + - libcpptest-dev + - libogg-dev + - libvorbis-dev + - libopenal-dev + - libgif-dev + - libfreetype6-dev + - libxml2-dev + +before_script: + - mkdir build + - cmake --version + - cmake -Hcode -Bbuild $CMAKE_CONFIGURE_OPTIONS + - cat build/CMakeCache.txt + +script: + - cmake --build build $CMAKE_BUILD_OPTIONS + - $RUN + +notifications: + irc: + channels: + - $NOTIFICATION_IRC_CHANNEL + template: + - "%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}" + - "Description : %{commit_message}" + - "Change view : %{compare_url}" + - "Build details : %{build_url}" diff --git a/README.md b/README.md index 12659827f..1fa4cc8ef 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Ryzom Core [![Build Status](https://travis-ci.org/ryzom/ryzomcore.svg)](https://travis-ci.org/ryzom/ryzomcore) - -Ryzom Core is the open-source project related to Ryzom Game. Written in C++, Ryzom Core contains the whole code (client, server, tools) used to make the commercial MMORPG Ryzom. Ryzom Core is a toolkit for the development of massively multiplayer online universes. It provides the base technologies and a set of development methodologies for the development of both client and server code. - - - -Ryzom Core is open source and released under the terms of the GNU Affero General Public License 3.0 (GNU/AGPLv3) for the source code and the Creative Commons Attributions-ShareAlike 3.0 (CC-BY-SA) for the art assets. Which means you can create your own game using Ryzom Core, for more information on doing so check out Creating Your Own Game Using Ryzom Core. - -Modification par la Team Khaganat +# Ryzom Core [![Build Status](https://travis-ci.org/ryzom/ryzomcore.svg)](https://travis-ci.org/ryzom/ryzomcore) + +Ryzom Core is the open-source project related to Ryzom Game. Written in C++, Ryzom Core contains the whole code (client, server, tools) used to make the commercial MMORPG Ryzom. Ryzom Core is a toolkit for the development of massively multiplayer online universes. It provides the base technologies and a set of development methodologies for the development of both client and server code. + + + +Ryzom Core is open source and released under the terms of the GNU Affero General Public License 3.0 (GNU/AGPLv3) for the source code and the Creative Commons Attributions-ShareAlike 3.0 (CC-BY-SA) for the art assets. Which means you can create your own game using Ryzom Core, for more information on doing so check out Creating Your Own Game Using Ryzom Core. + +Modification par la Team Khaganat diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 09a071436..4e5d4bfb5 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -63,10 +63,9 @@ SET(NL_VERSION_PATCH 0) SET(YEAR "2004-${CURRENT_YEAR}") SET(AUTHOR "Winch Gate and The Ryzom Core Community") -SET(RYZOM_VERSION_MAJOR 2) -SET(RYZOM_VERSION_MINOR 9) +SET(RYZOM_VERSION_MAJOR 3) +SET(RYZOM_VERSION_MINOR 1) SET(RYZOM_VERSION_PATCH 0) -SET(REVISION 0) #----------------------------------------------------------------------------- # Redirect output files diff --git a/code/CMakeModules/Find3dsMaxSDK.cmake b/code/CMakeModules/Find3dsMaxSDK.cmake index 9cd4bd67b..2319e0ed5 100644 --- a/code/CMakeModules/Find3dsMaxSDK.cmake +++ b/code/CMakeModules/Find3dsMaxSDK.cmake @@ -1,82 +1,101 @@ -# - Find DirectInput -# Find the DirectSound includes and libraries -# -# MAXSDK_DIR - 3DSMAX SDK root directory -# MAXSDK_INCLUDE_DIR - where to find baseinterface.h -# MAXSDK_LIBRARIES - List of libraries when using 3DSMAX. -# MAXSDK_FOUND - True if MAX SDK found. - -if(MAXSDK_INCLUDE_DIR) - # Already in cache, be silent - SET(MAXSDK_FIND_QUIETLY TRUE) -endif() - -FIND_PATH(MAXSDK_DIR - "include/maxversion.h" - HINTS - "$ENV{MAXSDK_DIR}" - PATHS - "$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk" - "$ENV{3DSMAX_2011_SDK_PATH}/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" - "$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk" -) - -FIND_PATH(MAXSDK_INCLUDE_DIR - max.h - HINTS - ${MAXSDK_DIR}/include -) - -FIND_PATH(MAXSDK_CS_INCLUDE_DIR bipexp.h - HINTS - ${MAXSDK_DIR}/include/CS -) - -IF(TARGET_X64) - SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/x64/lib) -ELSE() - SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/lib) -ENDIF() - -MACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME) - FIND_LIBRARY(${MYLIBRARY} - NAMES ${MYLIBRARYNAME} - HINTS - ${MAXSDK_LIBRARY_DIRS} - ) -ENDMACRO() - -FIND_3DS_LIBRARY(MAXSDK_CORE_LIBRARY core) -FIND_3DS_LIBRARY(MAXSDK_GEOM_LIBRARY geom) -FIND_3DS_LIBRARY(MAXSDK_GFX_LIBRARY gfx) -FIND_3DS_LIBRARY(MAXSDK_MESH_LIBRARY mesh) -FIND_3DS_LIBRARY(MAXSDK_MAXUTIL_LIBRARY maxutil) -FIND_3DS_LIBRARY(MAXSDK_MAXSCRIPT_LIBRARY maxscrpt) -FIND_3DS_LIBRARY(MAXSDK_PARAMBLK2_LIBRARY paramblk2) -FIND_3DS_LIBRARY(MAXSDK_BMM_LIBRARY bmm) - -# Handle the QUIETLY and REQUIRED arguments and set MAXSDK_FOUND to TRUE if -# all listed variables are TRUE. -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(MAXSDK DEFAULT_MSG - MAXSDK_INCLUDE_DIR MAXSDK_CORE_LIBRARY) - -if(MAXSDK_FOUND) - SET(MAXSDK_LIBRARIES - ${MAXSDK_CORE_LIBRARY} - ${MAXSDK_GEOM_LIBRARY} - ${MAXSDK_GFX_LIBRARY} - ${MAXSDK_MESH_LIBRARY} - ${MAXSDK_MAXUTIL_LIBRARY} - ${MAXSDK_MAXSCRIPT_LIBRARY} - ${MAXSDK_PARAMBLK2_LIBRARY} - ${MAXSDK_BMM_LIBRARY} ) - -ELSE() - set(MAXSDK_LIBRARIES) -ENDIF() - -mark_as_advanced(MAXSDK_INCLUDE_DIR MAXSDK_LIBRARY) +# - Find DirectInput +# Find the DirectSound includes and libraries +# +# MAXSDK_DIR - 3DSMAX SDK root directory +# MAXSDK_INCLUDE_DIR - where to find baseinterface.h +# MAXSDK_LIBRARIES - List of libraries when using 3DSMAX. +# MAXSDK_FOUND - True if MAX SDK found. + +if(MAXSDK_INCLUDE_DIR) + # Already in cache, be silent + SET(MAXSDK_FIND_QUIETLY TRUE) +endif() + +FIND_PATH(MAXSDK_DIR + "include/maxversion.h" + HINTS + "$ENV{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" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk" +) + +FIND_PATH(MAXSDK_INCLUDE_DIR + max.h + HINTS + ${MAXSDK_DIR}/include +) + +FIND_PATH(MAXSDK_CS_INCLUDE_DIR bipexp.h + HINTS + ${MAXSDK_DIR}/include/CS +) + +IF(TARGET_X64) + 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) + FIND_LIBRARY(${MYLIBRARY} + NAMES ${MYLIBRARYNAME} + HINTS + ${MAXSDK_LIBRARY_DIRS} + ) +ENDMACRO() + +FIND_3DS_LIBRARY(MAXSDK_CORE_LIBRARY core) +FIND_3DS_LIBRARY(MAXSDK_GEOM_LIBRARY geom) +FIND_3DS_LIBRARY(MAXSDK_GFX_LIBRARY gfx) +FIND_3DS_LIBRARY(MAXSDK_MESH_LIBRARY mesh) +FIND_3DS_LIBRARY(MAXSDK_MAXUTIL_LIBRARY maxutil) +FIND_3DS_LIBRARY(MAXSDK_MAXSCRIPT_LIBRARY maxscrpt) +FIND_3DS_LIBRARY(MAXSDK_PARAMBLK2_LIBRARY paramblk2) +FIND_3DS_LIBRARY(MAXSDK_BMM_LIBRARY bmm) + +# Handle the QUIETLY and REQUIRED arguments and set MAXSDK_FOUND to TRUE if +# all listed variables are TRUE. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MAXSDK DEFAULT_MSG + MAXSDK_INCLUDE_DIR MAXSDK_CORE_LIBRARY) + +if(MAXSDK_FOUND) + SET(MAXSDK_LIBRARIES + ${MAXSDK_CORE_LIBRARY} + ${MAXSDK_GEOM_LIBRARY} + ${MAXSDK_GFX_LIBRARY} + ${MAXSDK_MESH_LIBRARY} + ${MAXSDK_MAXUTIL_LIBRARY} + ${MAXSDK_MAXSCRIPT_LIBRARY} + ${MAXSDK_PARAMBLK2_LIBRARY} + ${MAXSDK_BMM_LIBRARY}) + + # 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() + +mark_as_advanced(MAXSDK_INCLUDE_DIR MAXSDK_LIBRARY) diff --git a/code/CMakeModules/FindCustomMFC.cmake b/code/CMakeModules/FindCustomMFC.cmake index 7865d0828..b71e4a8d8 100644 --- a/code/CMakeModules/FindCustomMFC.cmake +++ b/code/CMakeModules/FindCustomMFC.cmake @@ -41,7 +41,7 @@ IF(MFC_FOUND) 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/FindCustomMFC.cmake.BACKUP.4342.cmake b/code/CMakeModules/FindCustomMFC.cmake.BACKUP.4342.cmake new file mode 100644 index 000000000..94a293333 --- /dev/null +++ b/code/CMakeModules/FindCustomMFC.cmake.BACKUP.4342.cmake @@ -0,0 +1,54 @@ +# - Locate MFC libraries +# This module defines +# MFC_FOUND, if false, do not try to link to MFC +# MFC_LIBRARY_DIR, where to find libraries +# MFC_INCLUDE_DIR, where to find headers + +IF(CustomMFC_FIND_REQUIRED) + SET(MFC_FIND_REQUIRED TRUE) +ENDIF() + +IF(NOT MFC_DIR) + # If MFC have been found, remember their directory + IF(VC_DIR) + SET(MFC_STANDARD_DIR "${VC_DIR}/atlmfc") + ENDIF() + + FIND_PATH(MFC_DIR + include/afxwin.h + HINTS + ${MFC_STANDARD_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 +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(MFC DEFAULT_MSG MFC_DIR) + +IF(MFC_FOUND) + SET(MFC_INCLUDE_DIR "${MFC_DIR}/include") + INCLUDE_DIRECTORIES(${MFC_INCLUDE_DIR}) + + # Using 32 or 64 bits libraries + IF(TARGET_X64) + SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64") + ELSE() + SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib") + ENDIF() + + # Add MFC libraries directory to default library path + LINK_DIRECTORIES(${MFC_LIBRARY_DIR}) + + # Set definitions for using MFC in DLL +<<<<<<< HEAD + SET(MFC_DEFINITIONS -D_AFXDLL) +======= + SET(MFC_DEFINITIONS -D_AFXDLL -DUNICODE -D_UNICODE) +>>>>>>> ryzomcore + + # Set CMake flag to use MFC DLL + SET(CMAKE_MFC_FLAG 2) +ENDIF() + +# TODO: create a macro which set MFC_DEFINITIONS, MFC_LIBRARY_DIR and MFC_INCLUDE_DIR for a project diff --git a/code/CMakeModules/FindCustomMFC.cmake.BASE.4342.cmake b/code/CMakeModules/FindCustomMFC.cmake.BASE.4342.cmake new file mode 100644 index 000000000..e69de29bb diff --git a/code/CMakeModules/FindCustomMFC.cmake.LOCAL.4342.cmake b/code/CMakeModules/FindCustomMFC.cmake.LOCAL.4342.cmake new file mode 100644 index 000000000..7865d0828 --- /dev/null +++ b/code/CMakeModules/FindCustomMFC.cmake.LOCAL.4342.cmake @@ -0,0 +1,50 @@ +# - Locate MFC libraries +# This module defines +# MFC_FOUND, if false, do not try to link to MFC +# MFC_LIBRARY_DIR, where to find libraries +# MFC_INCLUDE_DIR, where to find headers + +IF(CustomMFC_FIND_REQUIRED) + SET(MFC_FIND_REQUIRED TRUE) +ENDIF() + +IF(NOT MFC_DIR) + # If MFC have been found, remember their directory + IF(VC_DIR) + SET(MFC_STANDARD_DIR "${VC_DIR}/atlmfc") + ENDIF() + + FIND_PATH(MFC_DIR + include/afxwin.h + HINTS + ${MFC_STANDARD_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 +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(MFC DEFAULT_MSG MFC_DIR) + +IF(MFC_FOUND) + SET(MFC_INCLUDE_DIR "${MFC_DIR}/include") + INCLUDE_DIRECTORIES(${MFC_INCLUDE_DIR}) + + # Using 32 or 64 bits libraries + IF(TARGET_X64) + SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64") + ELSE() + SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib") + 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 CMake flag to use MFC DLL + SET(CMAKE_MFC_FLAG 2) +ENDIF() + +# TODO: create a macro which set MFC_DEFINITIONS, MFC_LIBRARY_DIR and MFC_INCLUDE_DIR for a project diff --git a/code/CMakeModules/FindCustomMFC.cmake.REMOTE.4342.cmake b/code/CMakeModules/FindCustomMFC.cmake.REMOTE.4342.cmake new file mode 100644 index 000000000..b71e4a8d8 --- /dev/null +++ b/code/CMakeModules/FindCustomMFC.cmake.REMOTE.4342.cmake @@ -0,0 +1,50 @@ +# - Locate MFC libraries +# This module defines +# MFC_FOUND, if false, do not try to link to MFC +# MFC_LIBRARY_DIR, where to find libraries +# MFC_INCLUDE_DIR, where to find headers + +IF(CustomMFC_FIND_REQUIRED) + SET(MFC_FIND_REQUIRED TRUE) +ENDIF() + +IF(NOT MFC_DIR) + # If MFC have been found, remember their directory + IF(VC_DIR) + SET(MFC_STANDARD_DIR "${VC_DIR}/atlmfc") + ENDIF() + + FIND_PATH(MFC_DIR + include/afxwin.h + HINTS + ${MFC_STANDARD_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 +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(MFC DEFAULT_MSG MFC_DIR) + +IF(MFC_FOUND) + SET(MFC_INCLUDE_DIR "${MFC_DIR}/include") + INCLUDE_DIRECTORIES(${MFC_INCLUDE_DIR}) + + # Using 32 or 64 bits libraries + IF(TARGET_X64) + SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64") + ELSE() + SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib") + 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 -DUNICODE -D_UNICODE) + + # Set CMake flag to use MFC DLL + SET(CMAKE_MFC_FLAG 2) +ENDIF() + +# TODO: create a macro which set MFC_DEFINITIONS, MFC_LIBRARY_DIR and MFC_INCLUDE_DIR for a project diff --git a/code/CMakeModules/FindMSVC.cmake b/code/CMakeModules/FindMSVC.cmake index 6a8bdd33a..dceb6f054 100644 --- a/code/CMakeModules/FindMSVC.cmake +++ b/code/CMakeModules/FindMSVC.cmake @@ -55,7 +55,15 @@ MACRO(DETECT_EXPRESS_VERSION _VERSION) ENDIF() ENDMACRO() -IF(MSVC12) +IF(MSVC14) + DETECT_VC_VERSION("14.0") + SET(MSVC_TOOLSET "140") + + IF(NOT MSVC14_REDIST_DIR) + # If you have VC++ 2015 Express, put x64/Microsoft.VC140.CRT/*.dll in ${EXTERNAL_PATH}/redist + SET(MSVC14_REDIST_DIR "${EXTERNAL_PATH}/redist") + ENDIF() +ELSEIF(MSVC12) DETECT_VC_VERSION("12.0") SET(MSVC_TOOLSET "120") @@ -98,7 +106,7 @@ IF(NOT VC_DIR) ELSE() SET(_COMPILER ${CMAKE_C_COMPILER}) ENDIF() - STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${_COMPILER}) + STRING(REGEX REPLACE "/(bin|BIN|Bin)/.+" "" VC_DIR ${_COMPILER}) ENDIF() SET(VC_INCLUDE_DIR "${VC_DIR}/include") diff --git a/code/CMakeModules/FindMercurial.cmake b/code/CMakeModules/FindMercurial.cmake index f85952557..4e6429357 100644 --- a/code/CMakeModules/FindMercurial.cmake +++ b/code/CMakeModules/FindMercurial.cmake @@ -60,12 +60,12 @@ IF(Mercurial_HG_EXECUTABLE) EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} --version OUTPUT_VARIABLE Mercurial_VERSION_HG OUTPUT_STRIP_TRAILING_WHITESPACE) - + STRING(REGEX REPLACE ".*version ([\\.0-9]+).*" "\\1" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}") MACRO(Mercurial_WC_INFO dir prefix) - EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} tip --template "{rev};{node};{tags};{author}" + EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} log -r . --template "{rev};{node};{tags};{author}" WORKING_DIRECTORY ${dir} OUTPUT_VARIABLE ${prefix}_WC_INFO ERROR_VARIABLE Mercurial_hg_info_error @@ -73,7 +73,7 @@ IF(Mercurial_HG_EXECUTABLE) OUTPUT_STRIP_TRAILING_WHITESPACE) IF(NOT ${Mercurial_hg_info_result} EQUAL 0) - MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} tip\" failed with output:\n${Mercurial_hg_info_error}") + MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} log\" failed with output:\n${Mercurial_hg_info_error}") ELSE() LIST(LENGTH ${prefix}_WC_INFO _COUNT) IF(_COUNT EQUAL 4) diff --git a/code/CMakeModules/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/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index 01118650e..36d031f10 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -27,6 +27,16 @@ 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) @@ -77,28 +87,28 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") + 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$>") + 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$>") + 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$>") + APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() @@ -122,14 +132,14 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") + 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$>") + APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() @@ -151,7 +161,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) IF(_DEFINITIONS) FOREACH(item ${_DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") + APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() ENDIF() @@ -176,10 +186,23 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDIF() 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 @@ -282,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 d311a7747..ed0847015 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -367,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) @@ -390,9 +394,13 @@ MACRO(NL_SETUP_BUILD) 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") @@ -402,10 +410,10 @@ MACRO(NL_SETUP_BUILD) # If not specified, use the same CPU as host IF(NOT TARGET_CPU) - SET(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) + 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") @@ -413,7 +421,7 @@ MACRO(NL_SETUP_BUILD) IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") SET(CLANG ON) - MESSAGE(STATUS "Using Clang compiler") + MESSAGE(STATUS "Using Clang ${CMAKE_CXX_COMPILER_VERSION} compiler") ENDIF() IF(CMAKE_GENERATOR MATCHES "Xcode") @@ -426,6 +434,11 @@ MACRO(NL_SETUP_BUILD) MESSAGE(STATUS "Generating NMake project") 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) # x86-compatible CPU @@ -474,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) @@ -493,6 +509,10 @@ MACRO(NL_SETUP_BUILD) ENDIF() IF(TARGET_ARM) + IF(TARGET_ARM64) + ADD_PLATFORM_FLAGS("-DHAVE_ARM64") + ENDIF() + IF(TARGET_ARMV7S) ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S") ENDIF() @@ -541,10 +561,6 @@ MACRO(NL_SETUP_BUILD) ENDIF() IF(MSVC) - IF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11) - SET(MSVC11 ON) - ENDIF() - # Ignore default include paths ADD_PLATFORM_FLAGS("/X") @@ -555,31 +571,31 @@ 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 @@ -588,16 +604,19 @@ MACRO(NL_SETUP_BUILD) MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") 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") + ADD_PLATFORM_FLAGS("/bigobj") ELSE() # Allows 32 bits applications to use 3 GB of RAM - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /LARGEADDRESSAWARE") + ADD_PLATFORM_LINKFLAGS("/LARGEADDRESSAWARE") ENDIF() # Exceptions are only set for C++ @@ -780,7 +799,7 @@ MACRO(NL_SETUP_BUILD) 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}") + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") ENDIF() IF(TARGET_ARMV7) @@ -790,7 +809,7 @@ MACRO(NL_SETUP_BUILD) 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}") + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") ENDIF() IF(TARGET_ARMV6) @@ -800,7 +819,7 @@ MACRO(NL_SETUP_BUILD) 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}") + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") ENDIF() ENDIF() @@ -812,20 +831,27 @@ MACRO(NL_SETUP_BUILD) 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}") + 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}") + 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") + ADD_PLATFORM_LINKFLAGS("-Wl,-search_paths_first") ENDIF() ENDIF() ELSE() @@ -838,7 +864,13 @@ MACRO(NL_SETUP_BUILD) 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") @@ -849,7 +881,19 @@ MACRO(NL_SETUP_BUILD) ENDIF() IF(WITH_WARNINGS) - ADD_PLATFORM_FLAGS("-Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused") + 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) @@ -859,37 +903,33 @@ 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() 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() ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300") - SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -fno-strict-aliasing") - SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -fstrict-aliasing") 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() - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -L${PLATFORM_ROOT}/usr/lib") + ADD_PLATFORM_LINKFLAGS("-Wl,-z,noexecstack") + ADD_PLATFORM_LINKFLAGS("-L${PLATFORM_ROOT}/usr/lib") ENDIF() IF(APPLE) @@ -897,14 +937,30 @@ MACRO(NL_SETUP_BUILD) 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() 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") + 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) @@ -920,7 +976,7 @@ MACRO(NL_SETUP_BUILD) SET(NL_DEBUG_CFLAGS "-g -DNL_DEBUG -D_DEBUG ${NL_DEBUG_CFLAGS}") SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O3 ${NL_RELEASE_CFLAGS}") ENDIF() -ENDMACRO(NL_SETUP_BUILD) +ENDMACRO() MACRO(NL_SETUP_BUILD_FLAGS) SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE) diff --git a/code/CMakeModules/nel.cmake.BACKUP.4553.cmake b/code/CMakeModules/nel.cmake.BACKUP.4553.cmake new file mode 100644 index 000000000..8893e5c4c --- /dev/null +++ b/code/CMakeModules/nel.cmake.BACKUP.4553.cmake @@ -0,0 +1,1347 @@ +# Force Release configuration for compiler checks +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() + +# Declare CMAKE_CONFIGURATION_TYPES before PROJECT +SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) + +### +# Helper macro that generates .pc and installs it. +# Argument: name - the name of the .pc package, e.g. "nel-pacs.pc" +### +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() +ENDMACRO(NL_GEN_PC) + +### +# +### +MACRO(NL_TARGET_LIB name) + IF(WITH_STATIC) + ADD_LIBRARY(${name} STATIC ${ARGN}) + ELSE() + ADD_LIBRARY(${name} SHARED ${ARGN}) + ENDIF() +ENDMACRO(NL_TARGET_LIB) + +### +# +### +MACRO(NL_TARGET_DRIVER name) + IF(WITH_STATIC_DRIVERS) + ADD_LIBRARY(${name} STATIC ${ARGN}) + ELSE() + ADD_LIBRARY(${name} MODULE ${ARGN}) + ENDIF() +ENDMACRO(NL_TARGET_DRIVER) + +### +# Helper macro that sets the default library properties. +# Argument: name - the target name whose properties are being set +# Argument: +### +MACRO(NL_DEFAULT_PROPS name label) + IF(TARGET revision) + # explicitly say that the target depends on revision.h + ADD_DEPENDENCIES(${name} revision) + ENDIF() + + # Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name. + # CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819 + STRING(REGEX REPLACE "\\:" " -" proj_label ${label}) + SET_TARGET_PROPERTIES(${name} PROPERTIES PROJECT_LABEL ${proj_label}) + GET_TARGET_PROPERTY(type ${name} TYPE) + IF(${type} STREQUAL SHARED_LIBRARY) + # Set versions only if target is a shared library + SET_TARGET_PROPERTIES(${name} PROPERTIES + VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR}) + IF(NL_LIB_PREFIX) + SET_TARGET_PROPERTIES(${name} PROPERTIES INSTALL_NAME_DIR ${NL_LIB_PREFIX}) + 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} /SUBSYSTEM:${_SUBSYSTEM},${_SUBSYSTEM_VERSION}") + ENDIF() +ENDMACRO(NL_DEFAULT_PROPS) + +### +# Adds the target suffix on Windows. +# Argument: name - the library's target name. +### +MACRO(NL_ADD_LIB_SUFFIX name) + IF(WIN32) + SET_TARGET_PROPERTIES(${name} PROPERTIES DEBUG_POSTFIX "_d" RELEASE_POSTFIX "_r") + ENDIF() +ENDMACRO(NL_ADD_LIB_SUFFIX) + +### +# Adds the runtime link flags for Win32 binaries and links STLport. +# Argument: name - the target to add the link flags to. +### +MACRO(NL_ADD_RUNTIME_FLAGS name) + IF(WIN32) +# SET_TARGET_PROPERTIES(${name} PROPERTIES +# LINK_FLAGS_DEBUG "${CMAKE_LINK_FLAGS_DEBUG}" +# LINK_FLAGS_RELEASE "${CMAKE_LINK_FLAGS_RELEASE}") + ENDIF() + IF(WITH_STLPORT) + TARGET_LINK_LIBRARIES(${name} ${STLPORT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF() +ENDMACRO(NL_ADD_RUNTIME_FLAGS) + +MACRO(NL_ADD_STATIC_VID_DRIVERS name) + IF(WITH_STATIC_DRIVERS) + IF(WIN32) + IF(WITH_DRIVER_DIRECT3D) + TARGET_LINK_LIBRARIES(${name} nel_drv_direct3d_win) + ENDIF() + ENDIF() + + IF(WITH_DRIVER_OPENGL) + IF(WIN32) + TARGET_LINK_LIBRARIES(${name} nel_drv_opengl_win) + ELSE() + TARGET_LINK_LIBRARIES(${name} nel_drv_opengl) + ENDIF() + ENDIF() + + IF(WITH_DRIVER_OPENGLES) + IF(WIN32) + TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win) + ELSE() + TARGET_LINK_LIBRARIES(${name} nel_drv_opengles) + ENDIF() + ENDIF() + ENDIF() +ENDMACRO(NL_ADD_STATIC_VID_DRIVERS) + +MACRO(NL_ADD_STATIC_SND_DRIVERS name) + IF(WITH_STATIC_DRIVERS) + IF(WIN32) + IF(WITH_DRIVER_DSOUND) + TARGET_LINK_LIBRARIES(${name} nel_drv_dsound_win) + ENDIF() + + IF(WITH_DRIVER_XAUDIO2) + TARGET_LINK_LIBRARIES(${name} nel_drv_xaudio2_win) + ENDIF() + + IF(WITH_DRIVER_OPENAL) + TARGET_LINK_LIBRARIES(${name} nel_drv_openal_win) + ENDIF() + + IF(WITH_DRIVER_FMOD) + TARGET_LINK_LIBRARIES(${name} nel_drv_fmod_win) + ENDIF() + ELSE() + IF(WITH_DRIVER_OPENAL) + TARGET_LINK_LIBRARIES(${name} nel_drv_openal) + ENDIF() + + IF(WITH_DRIVER_FMOD) + TARGET_LINK_LIBRARIES(${name} nel_drv_fmod) + ENDIF() + ENDIF() + + ENDIF() +ENDMACRO(NL_ADD_STATIC_SND_DRIVERS) + +### +# Checks build vs. source location. Prevents In-Source builds. +### +MACRO(CHECK_OUT_OF_SOURCE) + IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + MESSAGE(FATAL_ERROR " + +CMake generation for this project is not allowed within the source directory! +Remove the CMakeCache.txt file and try again from another folder, e.g.: + + rm CMakeCache.txt + mkdir cmake + cd cmake + cmake .. + ") + ENDIF() + +ENDMACRO(CHECK_OUT_OF_SOURCE) + +MACRO(NL_SETUP_DEFAULT_OPTIONS) + IF(WITH_QT) + OPTION(WITH_STUDIO "Build Core Studio" OFF ) + ENDIF() + + ### + # Features + ### + OPTION(WITH_LOGGING "With Logging" ON ) + OPTION(WITH_COVERAGE "With Code Coverage Support" OFF) + OPTION(WITH_PCH "With Precompiled Headers" ON ) + OPTION(WITH_LOW_MEMORY "With low memory (use the least of RAM)" OFF) + OPTION(FINAL_VERSION "Build in Final Version mode" ON ) + + # Default to static building on Windows. + IF(WIN32) + OPTION(WITH_STATIC "With static libraries." ON ) + ELSE() + OPTION(WITH_STATIC "With static libraries." OFF) + ENDIF() + IF (WITH_STATIC) + OPTION(WITH_STATIC_LIBXML2 "With static libxml2" ON ) + ELSE() + OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF) + ENDIF() + IF (WITH_STATIC) + OPTION(WITH_STATIC_CURL "With static curl" ON ) + ELSE() + OPTION(WITH_STATIC_CURL "With static curl" OFF) + ENDIF() + IF(APPLE) + OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" ON ) + ELSE() + OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" OFF) + ENDIF() + OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF) + IF(WIN32) + OPTION(WITH_EXTERNAL "With provided external." ON ) + ELSE() + OPTION(WITH_EXTERNAL "With provided external." OFF) + 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 ) + ELSE() + OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" OFF) + ENDIF() + OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON ) + + OPTION(WITH_ASSIMP "Use assimp exporter" OFF) + + ### + # GUI toolkits + ### + OPTION(WITH_GTK "With GTK Support" OFF) + OPTION(WITH_QT "With Qt 4 Support" OFF) + OPTION(WITH_QT5 "With Qt 5 Support" OFF) + + IF(WIN32 AND MFC_FOUND) + OPTION(WITH_MFC "With MFC Support" ON ) + ELSE() + OPTION(WITH_MFC "With MFC Support" OFF) + ENDIF() + + ### + # Optional support + ### + OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" OFF) + + # only enable STLport for VC++ 2010 and less + IF(WIN32 AND MSVC_VERSION LESS 1600) + OPTION(WITH_STLPORT "With STLport support." ON ) + ELSE() + OPTION(WITH_STLPORT "With STLport support." OFF) + ENDIF() + + OPTION(BUILD_DASHBOARD "Build to the CDash dashboard" OFF) + + OPTION(WITH_NEL "Build NeL (nearly always required)." ON ) + OPTION(WITH_NELNS "Build NeL Network Services." OFF) + OPTION(WITH_RYZOM "Build Ryzom Core." ON ) + OPTION(WITH_SNOWBALLS "Build Snowballs." OFF) + OPTION(WITH_TOOLS "Build Tools" OFF) +ENDMACRO(NL_SETUP_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_NET "Build NLNET" ON ) + OPTION(WITH_3D "Build NL3D" ON ) + OPTION(WITH_GUI "Build GUI" ON ) + OPTION(WITH_PACS "Build NLPACS" ON ) + OPTION(WITH_GEORGES "Build NLGEORGES" ON ) + OPTION(WITH_LIGO "Build NLLIGO" ON ) + OPTION(WITH_LOGIC "Build NLLOGIC" ON ) + OPTION(WITH_SOUND "Build NLSOUND" ON ) + + ### + # Drivers Support + ### + OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON ) + OPTION(WITH_DRIVER_OPENGLES "Build OpenGL ES Driver (3D)" OFF) + OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF) + OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON ) + OPTION(WITH_DRIVER_FMOD "Build FMOD Driver (Sound)" OFF) + OPTION(WITH_DRIVER_DSOUND "Build DirectSound Driver (Sound)" OFF) + OPTION(WITH_DRIVER_XAUDIO2 "Build XAudio2 Driver (Sound)" OFF) + + ### + # Optional support + ### + OPTION(WITH_NEL_CEGUI "Build CEGUI Renderer" OFF) + OPTION(WITH_NEL_TOOLS "Build NeL Tools" ON ) + OPTION(WITH_NEL_MAXPLUGIN "Build NeL 3dsMax Plugin" OFF) + OPTION(WITH_NEL_SAMPLES "Build NeL Samples" ON ) + OPTION(WITH_NEL_TESTS "Build NeL Unit Tests" ON ) + + OPTION(WITH_LIBOVR "With LibOVR support" OFF) + OPTION(WITH_LIBVR "With LibVR support" OFF) + OPTION(WITH_PERFHUD "With NVIDIA PerfHUD support" OFF) + + OPTION(WITH_SSE2 "With SSE2" ON ) + OPTION(WITH_SSE3 "With SSE3" ON ) + + IF(NOT MSVC) + OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF) + ENDIF() +ENDMACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_NELNS_SERVER "Build NeLNS Services" ON ) + OPTION(WITH_NELNS_LOGIN_SYSTEM "Build NeLNS Login System Tools" ON ) +ENDMACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_RYZOM_CLIENT "Build Ryzom Core Client" ON ) + OPTION(WITH_RYZOM_TOOLS "Build Ryzom Core Tools" ON ) + OPTION(WITH_RYZOM_SERVER "Build Ryzom Core Services" ON ) + OPTION(WITH_RYZOM_INSTALLER "Build Ryzom Installer" OFF) + + ### + # Optional support + ### + OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON ) + OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF) + OPTION(WITH_LUA53 "Build Ryzom Core using Lua 5.3" OFF) + OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF) + OPTION(WITH_RYZOM_PATCH "Enable Ryzom in-game patch support" OFF) + OPTION(WITH_RYZOM_CUSTOM_PATCH_SERVER "Only use patch server from CFG file" OFF) + OPTION(WITH_RYZOM_STEAM "Enable Steam features" OFF) + OPTION(WITH_RYZOM_SANDBOX "Enable Sandbox under OS X" OFF) +ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_SNOWBALLS_CLIENT "Build Snowballs Client" ON ) + OPTION(WITH_SNOWBALLS_SERVER "Build Snowballs Services" ON ) +ENDMACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS) + +MACRO(ADD_PLATFORM_FLAGS _FLAGS) + SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${_FLAGS}") + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${_FLAGS}") +<<<<<<< HEAD +ENDMACRO(ADD_PLATFORM_FLAGS) +======= +ENDMACRO() + +MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS) + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}") +ENDMACRO() +>>>>>>> ryzomcore + +MACRO(NL_SETUP_BUILD) + + #----------------------------------------------------------------------------- + # Setup the buildmode variables. + # + # None = NL_RELEASE + # Debug = NL_DEBUG + # Release = NL_RELEASE + + IF(CMAKE_BUILD_TYPE MATCHES "Debug") + SET(NL_BUILD_MODE "NL_DEBUG") + ELSE() + IF(CMAKE_BUILD_TYPE MATCHES "Release") + SET(NL_BUILD_MODE "NL_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() + ENDIF() + +<<<<<<< HEAD + SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR}) + + IF(HOST_CPU MATCHES "(amd|AMD)64") +======= + 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|x86_)64") +>>>>>>> ryzomcore + SET(HOST_CPU "x86_64") + ELSEIF(HOST_CPU MATCHES "i.86") + SET(HOST_CPU "x86") + ENDIF() + + # Determine target CPU + + # If not specified, use the same CPU as host + IF(NOT TARGET_CPU) +<<<<<<< HEAD + SET(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) + ENDIF() + + IF(TARGET_CPU MATCHES "(amd|AMD)64") +======= + SET(TARGET_CPU ${HOST_CPU}) + ENDIF() + + IF(TARGET_CPU MATCHES "(amd|AMD|x86_)64") +>>>>>>> ryzomcore + SET(TARGET_CPU "x86_64") + ELSEIF(TARGET_CPU MATCHES "i.86") + SET(TARGET_CPU "x86") + ENDIF() + + IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + SET(CLANG ON) +<<<<<<< HEAD + MESSAGE(STATUS "Using Clang compiler") +======= + MESSAGE(STATUS "Using Clang ${CMAKE_CXX_COMPILER_VERSION} compiler") +>>>>>>> ryzomcore + ENDIF() + + IF(CMAKE_GENERATOR MATCHES "Xcode") + SET(XCODE ON) + MESSAGE(STATUS "Generating Xcode project") + ENDIF() + + IF(CMAKE_GENERATOR MATCHES "NMake") + SET(NMAKE ON) + MESSAGE(STATUS "Generating NMake project") + ENDIF() + +<<<<<<< HEAD +======= + IF(CMAKE_GENERATOR MATCHES "Ninja") + SET(NINJA ON) + MESSAGE(STATUS "Generating Ninja project") + ENDIF() + +>>>>>>> ryzomcore + # If target and host CPU are the same + IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING) + # x86-compatible CPU + IF(HOST_CPU MATCHES "x86") + IF(NOT CMAKE_SIZEOF_VOID_P) + INCLUDE (CheckTypeSize) + CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P) + ENDIF() + + # Using 32 or 64 bits libraries + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(TARGET_CPU "x86_64") + ELSE() + SET(TARGET_CPU "x86") + ENDIF() + ELSEIF(HOST_CPU MATCHES "arm") + SET(TARGET_CPU "arm") + ELSE() + SET(TARGET_CPU "unknown") + MESSAGE(STATUS "Unknown architecture: ${HOST_CPU}") + ENDIF() + # TODO: add checks for PPC + ELSE() + MESSAGE(STATUS "Compiling on ${HOST_CPU} for ${TARGET_CPU}") + ENDIF() + + # Use values from environment variables + SET(PLATFORM_CFLAGS "$ENV{CFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CFLAGS}") + SET(PLATFORM_CXXFLAGS "$ENV{CXXFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CXXFLAGS}") + SET(PLATFORM_LINKFLAGS "$ENV{LDFLAGS} ${PLATFORM_LINKFLAGS}") + + # Remove -g and -O flag because we are managing them ourself + STRING(REPLACE "-g" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS}) + STRING(REPLACE "-g" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS}) + STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS}) + STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS}) + + # Strip spaces + STRING(STRIP ${PLATFORM_CFLAGS} PLATFORM_CFLAGS) + STRING(STRIP ${PLATFORM_CXXFLAGS} PLATFORM_CXXFLAGS) + STRING(STRIP ${PLATFORM_LINKFLAGS} PLATFORM_LINKFLAGS) + + IF(NOT CMAKE_OSX_ARCHITECTURES) + IF(TARGET_CPU STREQUAL "x86_64") + SET(TARGET_X64 1) + SET(TARGET_X86 1) + ELSEIF(TARGET_CPU STREQUAL "x86") + SET(TARGET_X86 1) +<<<<<<< HEAD +======= + ELSEIF(TARGET_CPU STREQUAL "arm64") + SET(TARGET_ARM 1) + SET(TARGET_ARM64 1) +>>>>>>> ryzomcore + ELSEIF(TARGET_CPU STREQUAL "armv7s") + SET(TARGET_ARM 1) + SET(TARGET_ARMV7S 1) + ELSEIF(TARGET_CPU STREQUAL "armv7") + SET(TARGET_ARM 1) + SET(TARGET_ARMV7 1) + ELSEIF(TARGET_CPU STREQUAL "armv6") + SET(TARGET_ARM 1) + SET(TARGET_ARMV6 1) + ELSEIF(TARGET_CPU STREQUAL "armv5") + SET(TARGET_ARM 1) + SET(TARGET_ARMV5 1) + ELSEIF(TARGET_CPU STREQUAL "arm") + SET(TARGET_ARM 1) + ELSEIF(TARGET_CPU STREQUAL "mips") + SET(TARGET_MIPS 1) + ENDIF() + + IF(TARGET_ARM) +<<<<<<< HEAD +======= + IF(TARGET_ARM64) + ADD_PLATFORM_FLAGS("-DHAVE_ARM64") + ENDIF() + +>>>>>>> ryzomcore + IF(TARGET_ARMV7S) + ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S") + ENDIF() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-DHAVE_ARMV7") + ENDIF() + + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-HAVE_ARMV6") + ENDIF() + + ADD_PLATFORM_FLAGS("-DHAVE_ARM") + ENDIF() + + IF(TARGET_X86) + ADD_PLATFORM_FLAGS("-DHAVE_X86") + ENDIF() + + IF(TARGET_X64) + ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64") + ENDIF() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-DHAVE_MIPS") + ENDIF() + ENDIF() + + # Fix library paths suffixes for Debian MultiArch + IF(LIBRARY_ARCHITECTURE) + SET(CMAKE_LIBRARY_PATH /lib/${LIBRARY_ARCHITECTURE} /usr/lib/${LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH}) + IF(TARGET_X64) + SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64) + ELSEIF(TARGET_X86) + SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32) + 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() + + IF(WITH_LOGGING) + ADD_PLATFORM_FLAGS("-DENABLE_LOGS") + ENDIF() + + IF(MSVC) +<<<<<<< HEAD + IF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11) + SET(MSVC11 ON) + ENDIF() + +======= +>>>>>>> ryzomcore + # Ignore default include paths + ADD_PLATFORM_FLAGS("/X") + + IF(MSVC14) + ADD_PLATFORM_FLAGS("/Gy- /MP") + # /Ox is working with VC++ 2015, but custom optimizations don't exist + 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(MSVC12) +<<<<<<< HEAD + ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") +======= + ADD_PLATFORM_FLAGS("/Gy-") +>>>>>>> ryzomcore + # /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) +<<<<<<< HEAD + ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") +======= + ADD_PLATFORM_FLAGS("/Gy-") +>>>>>>> ryzomcore + # /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) +<<<<<<< HEAD + ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") +======= + ADD_PLATFORM_FLAGS("/Gy-") +>>>>>>> ryzomcore + # /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) +<<<<<<< HEAD + ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") +======= + ADD_PLATFORM_FLAGS("/Gy-") +>>>>>>> ryzomcore + # 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) +<<<<<<< HEAD + ADD_PLATFORM_FLAGS("/Gy- /Wp64 /Zm1000") +======= + ADD_PLATFORM_FLAGS("/Gy- /Wp64") +>>>>>>> ryzomcore + # 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() + MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") + ENDIF() + +<<<<<<< HEAD + 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") +>>>>>>> ryzomcore + + IF(TARGET_X64) + # Fix a bug with Intellisense + ADD_PLATFORM_FLAGS("/D_WIN64") + # Fix a compilation error for some big C++ files +<<<<<<< HEAD + SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} /bigobj") + ELSE() + # Allows 32 bits applications to use 3 GB of RAM + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /LARGEADDRESSAWARE") +======= + ADD_PLATFORM_FLAGS("/bigobj") + ELSE() + # Allows 32 bits applications to use 3 GB of RAM + ADD_PLATFORM_LINKFLAGS("/LARGEADDRESSAWARE") +>>>>>>> ryzomcore + ENDIF() + + # Exceptions are only set for C++ + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} /EHa") + + IF(WITH_SYMBOLS) + SET(NL_RELEASE_CFLAGS "/Zi ${NL_RELEASE_CFLAGS}") + SET(NL_RELEASE_LINKFLAGS "/DEBUG ${NL_RELEASE_LINKFLAGS}") + ELSE() + SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}") + ENDIF() + + SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}") + SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}") + SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt ${MSVC_INCREMENTAL_YES_FLAG} ${NL_DEBUG_LINKFLAGS}") + SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}") + + IF(WITH_WARNINGS) + SET(DEBUG_CFLAGS "/W4 ${DEBUG_CFLAGS}") + ELSE() + SET(DEBUG_CFLAGS "/W3 ${DEBUG_CFLAGS}") + ENDIF() + ELSE() + IF(WIN32) + ADD_PLATFORM_FLAGS("-DWIN32 -D_WIN32") + + IF(CLANG) + ADD_PLATFORM_FLAGS("-nobuiltininc") + ENDIF() + ENDIF() + + IF(WITH_SSE3) + ADD_PLATFORM_FLAGS("-msse3") + ENDIF() + + IF(WITH_GCC_FPMATH_BOTH) + ADD_PLATFORM_FLAGS("-mfpmath=both") + ENDIF() + + IF(APPLE) + IF(NOT XCODE) + IF(CMAKE_OSX_ARCHITECTURES) + SET(TARGETS_COUNT 0) + SET(_ARCHS) + FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES}) + IF(_ARCH STREQUAL "i386") + SET(_ARCHS "${_ARCHS} i386") + SET(TARGET_X86 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "x86_64") + SET(_ARCHS "${_ARCHS} x86_64") + SET(TARGET_X64 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "armv7s") + SET(_ARCHS "${_ARCHS} armv7s") + SET(TARGET_ARMV7S 1) + SET(TARGET_ARM 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "armv7") + SET(_ARCHS "${_ARCHS} armv7") + SET(TARGET_ARMV7 1) + SET(TARGET_ARM 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "armv6") + SET(_ARCHS "${_ARCHS} armv6") + SET(TARGET_ARMV6 1) + SET(TARGET_ARM 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "mips") + SET(_ARCHS "${_ARCHS} mips") + SET(TARGET_MIPS 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSE() + SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})") + ENDIF() + ENDFOREACH(_ARCH) + MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}") + ELSE() + SET(TARGETS_COUNT 0) + ENDIF() + + IF(TARGETS_COUNT EQUAL 1) + IF(TARGET_ARM) + IF(TARGET_ARMV7S) + ADD_PLATFORM_FLAGS("-arch armv7s -DHAVE_ARMV7S") + ENDIF() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-arch armv7 -DHAVE_ARMV7") + ENDIF() + + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-arch armv6 -DHAVE_ARMV6") + ENDIF() + + IF(TARGET_ARMV5) + ADD_PLATFORM_FLAGS("-arch armv5 -DHAVE_ARMV5") + ENDIF() + + ADD_PLATFORM_FLAGS("-mthumb -DHAVE_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() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-arch mips -DHAVE_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() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-arch armv7") + ENDIF() + + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-arch armv6") + ENDIF() + + IF(TARGET_ARMV5) + ADD_PLATFORM_FLAGS("-arch armv5") + ENDIF() + + ADD_PLATFORM_FLAGS("-mthumb") + ENDIF() + + IF(TARGET_X64) + ADD_PLATFORM_FLAGS("-arch x86_64") + ELSEIF(TARGET_X86) + ADD_PLATFORM_FLAGS("-arch i386") + ENDIF() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-arch mips") + ENDIF() + ELSE() + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6") + ENDIF() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-Xarch_armv7 -mthumb -Xarch_armv7 -DHAVE_ARM -Xarch_armv7 -DHAVE_ARMV7") + ENDIF() + + IF(TARGET_X86) + ADD_PLATFORM_FLAGS("-Xarch_i386 -DHAVE_X86") + ENDIF() + + IF(TARGET_X64) + ADD_PLATFORM_FLAGS("-Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64") + ENDIF() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-Xarch_mips -DHAVE_MIPS") + ENDIF() + ENDIF() + + IF(IOS) + SET(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE) + + IF(IOS_VERSION) + PARSE_VERSION_STRING(${IOS_VERSION} IOS_VERSION_MAJOR IOS_VERSION_MINOR IOS_VERSION_PATCH) + 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() + + IF(CMAKE_IOS_SYSROOT) + IF(TARGET_ARMV7S) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_armv7s ") + ENDIF() + + ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") + ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") +<<<<<<< HEAD + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") +======= + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") +>>>>>>> ryzomcore + ENDIF() + + IF(TARGET_ARMV7) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_armv7 ") + ENDIF() + + ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") + ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") +<<<<<<< HEAD + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") +======= + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") +>>>>>>> ryzomcore + ENDIF() + + IF(TARGET_ARMV6) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_armv6 ") + ENDIF() + + ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") + ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") +<<<<<<< HEAD + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") +======= + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") +>>>>>>> ryzomcore + ENDIF() + ENDIF() + + IF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_i386 ") + 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) +<<<<<<< HEAD + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") +======= + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") +>>>>>>> ryzomcore + ENDIF() + ENDIF() + ELSE() + # Always force -mmacosx-version-min to override environement variable + IF(CMAKE_OSX_DEPLOYMENT_TARGET) +<<<<<<< HEAD + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") + ENDIF() + ENDIF() + + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-headerpad_max_install_names") + + IF(HAVE_FLAG_SEARCH_PATHS_FIRST) + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-search_paths_first") +======= + 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() + + # 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) + ADD_PLATFORM_LINKFLAGS("-Wl,-search_paths_first") +>>>>>>> ryzomcore + ENDIF() + ENDIF() + ELSE() + IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86") + ADD_PLATFORM_FLAGS("-m32 -march=i686") + ENDIF() + + IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") + ADD_PLATFORM_FLAGS("-m64") + ENDIF() + ENDIF() + +<<<<<<< HEAD + 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") +>>>>>>> ryzomcore + + IF(NOT WITH_LOW_MEMORY) + ADD_PLATFORM_FLAGS("-pipe") + ENDIF() + + IF(WITH_COVERAGE) + ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage") + ENDIF() + + IF(WITH_WARNINGS) +<<<<<<< HEAD + ADD_PLATFORM_FLAGS("-Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused") +======= + 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") +>>>>>>> ryzomcore + ENDIF() + + IF(ANDROID) + ADD_PLATFORM_FLAGS("--sysroot=${PLATFORM_ROOT}") + ADD_PLATFORM_FLAGS("-ffunction-sections -funwind-tables") + ADD_PLATFORM_FLAGS("-DANDROID") + ADD_PLATFORM_FLAGS("-Wa,--noexecstack") + + IF(TARGET_ARM) +<<<<<<< HEAD + ADD_PLATFORM_FLAGS("-fpic -fstack-protector") +======= + ADD_PLATFORM_FLAGS("-fpic") +>>>>>>> ryzomcore + 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") +<<<<<<< HEAD + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -march=armv7-a -Wl,--fix-cortex-a8") +======= + ADD_PLATFORM_LINKFLAGS("-march=armv7-a -Wl,--fix-cortex-a8") +>>>>>>> ryzomcore + ELSEIF(TARGET_ARMV5) + ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float") + ENDIF() + + SET(TARGET_THUMB ON) + IF(TARGET_THUMB) +<<<<<<< HEAD + ADD_PLATFORM_FLAGS("-mthumb -fno-strict-aliasing -finline-limit=64") + SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm") + ELSE() + ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300") + SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -fno-strict-aliasing") + SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -fstrict-aliasing") +======= + ADD_PLATFORM_FLAGS("-mthumb -finline-limit=64") + SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm") + ELSE() + ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300") +>>>>>>> ryzomcore + 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") +<<<<<<< HEAD + 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") + 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") + SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300") + ENDIF() + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -L${PLATFORM_ROOT}/usr/lib") +======= + 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") + SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300") + ENDIF() + ADD_PLATFORM_LINKFLAGS("-Wl,-z,noexecstack") + ADD_PLATFORM_LINKFLAGS("-L${PLATFORM_ROOT}/usr/lib") +>>>>>>> ryzomcore + ENDIF() + + IF(APPLE) + ADD_PLATFORM_FLAGS("-gdwarf-2 -D_DARWIN_UNLIMITED_STREAMS") + ENDIF() + + # Fix "relocation R_X86_64_32 against.." error on x64 platforms +<<<<<<< HEAD + IF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS AND NOT MINGW) +======= + IF(NOT MINGW) +>>>>>>> ryzomcore + ADD_PLATFORM_FLAGS("-fPIC") + ENDIF() + + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48") + +<<<<<<< HEAD + IF(NOT APPLE) + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--no-undefined -Wl,--as-needed") +======= + # 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) + 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") +>>>>>>> ryzomcore + ENDIF() + + IF(WITH_SYMBOLS) + SET(NL_RELEASE_CFLAGS "${NL_RELEASE_CFLAGS} -g") + ELSE() + IF(APPLE) + SET(NL_RELEASE_LINKFLAGS "-Wl,-dead_strip ${NL_RELEASE_LINKFLAGS}") + ELSE() + SET(NL_RELEASE_LINKFLAGS "-Wl,-s ${NL_RELEASE_LINKFLAGS}") + 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() +<<<<<<< HEAD +ENDMACRO(NL_SETUP_BUILD) +======= +ENDMACRO() +>>>>>>> ryzomcore + +MACRO(NL_SETUP_BUILD_FLAGS) + SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + + ## Debug + SET(CMAKE_C_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_CXX_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + + ## Release + SET(CMAKE_C_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_CXX_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) +ENDMACRO(NL_SETUP_BUILD_FLAGS) + +# Macro to create x_ABSOLUTE_PREFIX from x_PREFIX +MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE) + IF(IS_ABSOLUTE "${${NAME_RELATIVE}}") + SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}}) + ELSE() + IF(WITH_UNIX_STRUCTURE) + SET(${NAME_ABSOLUTE} ${CMAKE_INSTALL_PREFIX}/${${NAME_RELATIVE}}) + ELSE() + SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}}) + ENDIF() + ENDIF() +ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX) + +MACRO(NL_SETUP_PREFIX_PATHS) + ## Allow override of install_prefix/etc path. + IF(NOT NL_ETC_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_ETC_PREFIX "etc/nel" CACHE PATH "Installation path for configurations") + ELSE() + SET(NL_ETC_PREFIX "." CACHE PATH "Installation path for configurations") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_ETC_PREFIX NL_ETC_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/share path. + IF(NOT NL_SHARE_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_SHARE_PREFIX "share/nel" CACHE PATH "Installation path for data.") + ELSE() + SET(NL_SHARE_PREFIX "." CACHE PATH "Installation path for data.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_SHARE_PREFIX NL_SHARE_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/sbin path. + IF(NOT NL_SBIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + ELSE() + SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_SBIN_PREFIX NL_SBIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/bin path. + IF(NOT NL_BIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_BIN_PREFIX "bin" CACHE PATH "Installation path for tools and applications.") + ELSE() + SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_BIN_PREFIX NL_BIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/lib path. + IF(NOT NL_LIB_PREFIX) + IF(LIBRARY_ARCHITECTURE) + SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") + ELSE() + SET(NL_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/lib path. + IF(NOT NL_DRIVER_PREFIX) + IF(WITH_UNIX_STRUCTURE) + IF(LIBRARY_ARCHITECTURE) + SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.") + ELSE() + SET(NL_DRIVER_PREFIX "lib/nel" CACHE PATH "Installation path for drivers.") + ENDIF() + ELSE() + SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_DRIVER_PREFIX NL_DRIVER_ABSOLUTE_PREFIX) +ENDMACRO(NL_SETUP_PREFIX_PATHS) + +MACRO(RYZOM_SETUP_PREFIX_PATHS) + ## Allow override of install_prefix/etc path. + IF(NOT RYZOM_ETC_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_ETC_PREFIX "etc/ryzom" CACHE PATH "Installation path for configurations") + ELSE() + SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_ETC_PREFIX RYZOM_ETC_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/share path. + IF(NOT RYZOM_SHARE_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_SHARE_PREFIX "share/ryzom" CACHE PATH "Installation path for data.") + ELSE() + SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SHARE_PREFIX RYZOM_SHARE_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/sbin path. + IF(NOT RYZOM_SBIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + ELSE() + SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SBIN_PREFIX RYZOM_SBIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/bin path. + IF(NOT RYZOM_BIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_BIN_PREFIX "bin" CACHE PATH "Installation path for tools.") + ELSE() + SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_BIN_PREFIX RYZOM_BIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/lib path. + IF(NOT RYZOM_LIB_PREFIX) + IF(LIBRARY_ARCHITECTURE) + SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") + ELSE() + SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/games path. + IF(NOT RYZOM_GAMES_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_GAMES_PREFIX "games" CACHE PATH "Installation path for client.") + ELSE() + SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_GAMES_PREFIX RYZOM_GAMES_ABSOLUTE_PREFIX) + +ENDMACRO(RYZOM_SETUP_PREFIX_PATHS) + +MACRO(SETUP_EXTERNAL) + IF(WITH_EXTERNAL) + FIND_PACKAGE(External REQUIRED) + ENDIF() + + IF(WIN32) + FIND_PACKAGE(External REQUIRED) + + # If using custom boost, we need to define the right variables used by official boost CMake module + IF(DEFINED BOOST_DIR) + SET(BOOST_INCLUDEDIR ${BOOST_DIR}/include) + SET(BOOST_LIBRARYDIR ${BOOST_DIR}/lib) + ENDIF() + ELSE() + FIND_PACKAGE(External QUIET) + + IF(APPLE) + IF(WITH_STATIC_EXTERNAL) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) + ELSE() + SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so .a) + ENDIF() + ELSE() + IF(WITH_STATIC_EXTERNAL) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so) + ELSE() + SET(CMAKE_FIND_LIBRARY_SUFFIXES .so .a) + ENDIF() + ENDIF() + ENDIF() + + # Android and iOS have pthread + IF(ANDROID OR IOS) + SET(CMAKE_USE_PTHREADS_INIT 1) + SET(Threads_FOUND TRUE) + ELSE() + FIND_PACKAGE(Threads REQUIRED) + # TODO: replace all -l by absolute path to in CMAKE_THREAD_LIBS_INIT + ENDIF() + + IF(WITH_STLPORT) + FIND_PACKAGE(STLport REQUIRED) + INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR}) + ENDIF() + + IF(WIN32) + # Must include DXSDK before WINSDK + FIND_PACKAGE(DirectXSDK REQUIRED) + # IF(DXSDK_INCLUDE_DIR) + # INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) + # ENDIF() + ENDIF() + + IF(MSVC) + FIND_PACKAGE(MSVC REQUIRED) + FIND_PACKAGE(WindowsSDK REQUIRED) + ENDIF() +ENDMACRO(SETUP_EXTERNAL) diff --git a/code/CMakeModules/nel.cmake.BASE.4553.cmake b/code/CMakeModules/nel.cmake.BASE.4553.cmake new file mode 100644 index 000000000..e69de29bb diff --git a/code/CMakeModules/nel.cmake.LOCAL.4553.cmake b/code/CMakeModules/nel.cmake.LOCAL.4553.cmake new file mode 100644 index 000000000..d311a7747 --- /dev/null +++ b/code/CMakeModules/nel.cmake.LOCAL.4553.cmake @@ -0,0 +1,1146 @@ +# Force Release configuration for compiler checks +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() + +# Declare CMAKE_CONFIGURATION_TYPES before PROJECT +SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) + +### +# Helper macro that generates .pc and installs it. +# Argument: name - the name of the .pc package, e.g. "nel-pacs.pc" +### +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() +ENDMACRO(NL_GEN_PC) + +### +# +### +MACRO(NL_TARGET_LIB name) + IF(WITH_STATIC) + ADD_LIBRARY(${name} STATIC ${ARGN}) + ELSE() + ADD_LIBRARY(${name} SHARED ${ARGN}) + ENDIF() +ENDMACRO(NL_TARGET_LIB) + +### +# +### +MACRO(NL_TARGET_DRIVER name) + IF(WITH_STATIC_DRIVERS) + ADD_LIBRARY(${name} STATIC ${ARGN}) + ELSE() + ADD_LIBRARY(${name} MODULE ${ARGN}) + ENDIF() +ENDMACRO(NL_TARGET_DRIVER) + +### +# Helper macro that sets the default library properties. +# Argument: name - the target name whose properties are being set +# Argument: +### +MACRO(NL_DEFAULT_PROPS name label) + IF(TARGET revision) + # explicitly say that the target depends on revision.h + ADD_DEPENDENCIES(${name} revision) + ENDIF() + + # Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name. + # CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819 + STRING(REGEX REPLACE "\\:" " -" proj_label ${label}) + SET_TARGET_PROPERTIES(${name} PROPERTIES PROJECT_LABEL ${proj_label}) + GET_TARGET_PROPERTY(type ${name} TYPE) + IF(${type} STREQUAL SHARED_LIBRARY) + # Set versions only if target is a shared library + SET_TARGET_PROPERTIES(${name} PROPERTIES + VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR}) + IF(NL_LIB_PREFIX) + SET_TARGET_PROPERTIES(${name} PROPERTIES INSTALL_NAME_DIR ${NL_LIB_PREFIX}) + 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} /SUBSYSTEM:${_SUBSYSTEM},${_SUBSYSTEM_VERSION}") + ENDIF() +ENDMACRO(NL_DEFAULT_PROPS) + +### +# Adds the target suffix on Windows. +# Argument: name - the library's target name. +### +MACRO(NL_ADD_LIB_SUFFIX name) + IF(WIN32) + SET_TARGET_PROPERTIES(${name} PROPERTIES DEBUG_POSTFIX "_d" RELEASE_POSTFIX "_r") + ENDIF() +ENDMACRO(NL_ADD_LIB_SUFFIX) + +### +# Adds the runtime link flags for Win32 binaries and links STLport. +# Argument: name - the target to add the link flags to. +### +MACRO(NL_ADD_RUNTIME_FLAGS name) + IF(WIN32) +# SET_TARGET_PROPERTIES(${name} PROPERTIES +# LINK_FLAGS_DEBUG "${CMAKE_LINK_FLAGS_DEBUG}" +# LINK_FLAGS_RELEASE "${CMAKE_LINK_FLAGS_RELEASE}") + ENDIF() + IF(WITH_STLPORT) + TARGET_LINK_LIBRARIES(${name} ${STLPORT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF() +ENDMACRO(NL_ADD_RUNTIME_FLAGS) + +MACRO(NL_ADD_STATIC_VID_DRIVERS name) + IF(WITH_STATIC_DRIVERS) + IF(WIN32) + IF(WITH_DRIVER_DIRECT3D) + TARGET_LINK_LIBRARIES(${name} nel_drv_direct3d_win) + ENDIF() + ENDIF() + + IF(WITH_DRIVER_OPENGL) + IF(WIN32) + TARGET_LINK_LIBRARIES(${name} nel_drv_opengl_win) + ELSE() + TARGET_LINK_LIBRARIES(${name} nel_drv_opengl) + ENDIF() + ENDIF() + + IF(WITH_DRIVER_OPENGLES) + IF(WIN32) + TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win) + ELSE() + TARGET_LINK_LIBRARIES(${name} nel_drv_opengles) + ENDIF() + ENDIF() + ENDIF() +ENDMACRO(NL_ADD_STATIC_VID_DRIVERS) + +MACRO(NL_ADD_STATIC_SND_DRIVERS name) + IF(WITH_STATIC_DRIVERS) + IF(WIN32) + IF(WITH_DRIVER_DSOUND) + TARGET_LINK_LIBRARIES(${name} nel_drv_dsound_win) + ENDIF() + + IF(WITH_DRIVER_XAUDIO2) + TARGET_LINK_LIBRARIES(${name} nel_drv_xaudio2_win) + ENDIF() + + IF(WITH_DRIVER_OPENAL) + TARGET_LINK_LIBRARIES(${name} nel_drv_openal_win) + ENDIF() + + IF(WITH_DRIVER_FMOD) + TARGET_LINK_LIBRARIES(${name} nel_drv_fmod_win) + ENDIF() + ELSE() + IF(WITH_DRIVER_OPENAL) + TARGET_LINK_LIBRARIES(${name} nel_drv_openal) + ENDIF() + + IF(WITH_DRIVER_FMOD) + TARGET_LINK_LIBRARIES(${name} nel_drv_fmod) + ENDIF() + ENDIF() + + ENDIF() +ENDMACRO(NL_ADD_STATIC_SND_DRIVERS) + +### +# Checks build vs. source location. Prevents In-Source builds. +### +MACRO(CHECK_OUT_OF_SOURCE) + IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + MESSAGE(FATAL_ERROR " + +CMake generation for this project is not allowed within the source directory! +Remove the CMakeCache.txt file and try again from another folder, e.g.: + + rm CMakeCache.txt + mkdir cmake + cd cmake + cmake .. + ") + ENDIF() + +ENDMACRO(CHECK_OUT_OF_SOURCE) + +MACRO(NL_SETUP_DEFAULT_OPTIONS) + IF(WITH_QT) + OPTION(WITH_STUDIO "Build Core Studio" OFF ) + ENDIF() + + ### + # Features + ### + OPTION(WITH_LOGGING "With Logging" ON ) + OPTION(WITH_COVERAGE "With Code Coverage Support" OFF) + OPTION(WITH_PCH "With Precompiled Headers" ON ) + OPTION(WITH_LOW_MEMORY "With low memory (use the least of RAM)" OFF) + OPTION(FINAL_VERSION "Build in Final Version mode" ON ) + + # Default to static building on Windows. + IF(WIN32) + OPTION(WITH_STATIC "With static libraries." ON ) + ELSE() + OPTION(WITH_STATIC "With static libraries." OFF) + ENDIF() + IF (WITH_STATIC) + OPTION(WITH_STATIC_LIBXML2 "With static libxml2" ON ) + ELSE() + OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF) + ENDIF() + IF (WITH_STATIC) + OPTION(WITH_STATIC_CURL "With static curl" ON ) + ELSE() + OPTION(WITH_STATIC_CURL "With static curl" OFF) + ENDIF() + IF(APPLE) + OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" ON ) + ELSE() + OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" OFF) + ENDIF() + OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF) + IF(WIN32) + OPTION(WITH_EXTERNAL "With provided external." ON ) + ELSE() + OPTION(WITH_EXTERNAL "With provided external." OFF) + 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 ) + ELSE() + OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" OFF) + ENDIF() + OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON ) + + OPTION(WITH_ASSIMP "Use assimp exporter" OFF) + + ### + # GUI toolkits + ### + OPTION(WITH_GTK "With GTK Support" OFF) + OPTION(WITH_QT "With Qt 4 Support" OFF) + OPTION(WITH_QT5 "With Qt 5 Support" OFF) + + IF(WIN32 AND MFC_FOUND) + OPTION(WITH_MFC "With MFC Support" ON ) + ELSE() + OPTION(WITH_MFC "With MFC Support" OFF) + ENDIF() + + ### + # Optional support + ### + OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" OFF) + + # only enable STLport for VC++ 2010 and less + IF(WIN32 AND MSVC_VERSION LESS 1600) + OPTION(WITH_STLPORT "With STLport support." ON ) + ELSE() + OPTION(WITH_STLPORT "With STLport support." OFF) + ENDIF() + + OPTION(BUILD_DASHBOARD "Build to the CDash dashboard" OFF) + + OPTION(WITH_NEL "Build NeL (nearly always required)." ON ) + OPTION(WITH_NELNS "Build NeL Network Services." OFF) + OPTION(WITH_RYZOM "Build Ryzom Core." ON ) + OPTION(WITH_SNOWBALLS "Build Snowballs." OFF) + OPTION(WITH_TOOLS "Build Tools" OFF) +ENDMACRO(NL_SETUP_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_NET "Build NLNET" ON ) + OPTION(WITH_3D "Build NL3D" ON ) + OPTION(WITH_GUI "Build GUI" ON ) + OPTION(WITH_PACS "Build NLPACS" ON ) + OPTION(WITH_GEORGES "Build NLGEORGES" ON ) + OPTION(WITH_LIGO "Build NLLIGO" ON ) + OPTION(WITH_LOGIC "Build NLLOGIC" ON ) + OPTION(WITH_SOUND "Build NLSOUND" ON ) + + ### + # Drivers Support + ### + OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON ) + OPTION(WITH_DRIVER_OPENGLES "Build OpenGL ES Driver (3D)" OFF) + OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF) + OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON ) + OPTION(WITH_DRIVER_FMOD "Build FMOD Driver (Sound)" OFF) + OPTION(WITH_DRIVER_DSOUND "Build DirectSound Driver (Sound)" OFF) + OPTION(WITH_DRIVER_XAUDIO2 "Build XAudio2 Driver (Sound)" OFF) + + ### + # Optional support + ### + OPTION(WITH_NEL_CEGUI "Build CEGUI Renderer" OFF) + OPTION(WITH_NEL_TOOLS "Build NeL Tools" ON ) + OPTION(WITH_NEL_MAXPLUGIN "Build NeL 3dsMax Plugin" OFF) + OPTION(WITH_NEL_SAMPLES "Build NeL Samples" ON ) + OPTION(WITH_NEL_TESTS "Build NeL Unit Tests" ON ) + + OPTION(WITH_LIBOVR "With LibOVR support" OFF) + OPTION(WITH_LIBVR "With LibVR support" OFF) + OPTION(WITH_PERFHUD "With NVIDIA PerfHUD support" OFF) + + OPTION(WITH_SSE2 "With SSE2" ON ) + OPTION(WITH_SSE3 "With SSE3" ON ) + + IF(NOT MSVC) + OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF) + ENDIF() +ENDMACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_NELNS_SERVER "Build NeLNS Services" ON ) + OPTION(WITH_NELNS_LOGIN_SYSTEM "Build NeLNS Login System Tools" ON ) +ENDMACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_RYZOM_CLIENT "Build Ryzom Core Client" ON ) + OPTION(WITH_RYZOM_TOOLS "Build Ryzom Core Tools" ON ) + OPTION(WITH_RYZOM_SERVER "Build Ryzom Core Services" ON ) + OPTION(WITH_RYZOM_INSTALLER "Build Ryzom Installer" OFF) + + ### + # Optional support + ### + OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON ) + OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF) + OPTION(WITH_LUA53 "Build Ryzom Core using Lua 5.3" OFF) + OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF) + OPTION(WITH_RYZOM_PATCH "Enable Ryzom in-game patch support" OFF) + OPTION(WITH_RYZOM_CUSTOM_PATCH_SERVER "Only use patch server from CFG file" OFF) + OPTION(WITH_RYZOM_STEAM "Enable Steam features" OFF) + OPTION(WITH_RYZOM_SANDBOX "Enable Sandbox under OS X" OFF) +ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_SNOWBALLS_CLIENT "Build Snowballs Client" ON ) + OPTION(WITH_SNOWBALLS_SERVER "Build Snowballs Services" ON ) +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) + +MACRO(NL_SETUP_BUILD) + + #----------------------------------------------------------------------------- + # Setup the buildmode variables. + # + # None = NL_RELEASE + # Debug = NL_DEBUG + # Release = NL_RELEASE + + IF(CMAKE_BUILD_TYPE MATCHES "Debug") + SET(NL_BUILD_MODE "NL_DEBUG") + ELSE() + IF(CMAKE_BUILD_TYPE MATCHES "Release") + SET(NL_BUILD_MODE "NL_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() + ENDIF() + + SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR}) + + IF(HOST_CPU MATCHES "(amd|AMD)64") + SET(HOST_CPU "x86_64") + ELSEIF(HOST_CPU MATCHES "i.86") + SET(HOST_CPU "x86") + ENDIF() + + # Determine target CPU + + # If not specified, use the same CPU as host + IF(NOT TARGET_CPU) + SET(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) + ENDIF() + + IF(TARGET_CPU MATCHES "(amd|AMD)64") + SET(TARGET_CPU "x86_64") + ELSEIF(TARGET_CPU MATCHES "i.86") + SET(TARGET_CPU "x86") + ENDIF() + + IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + SET(CLANG ON) + MESSAGE(STATUS "Using Clang compiler") + ENDIF() + + IF(CMAKE_GENERATOR MATCHES "Xcode") + SET(XCODE ON) + MESSAGE(STATUS "Generating Xcode project") + ENDIF() + + IF(CMAKE_GENERATOR MATCHES "NMake") + SET(NMAKE ON) + MESSAGE(STATUS "Generating NMake project") + ENDIF() + + # If target and host CPU are the same + IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING) + # x86-compatible CPU + IF(HOST_CPU MATCHES "x86") + IF(NOT CMAKE_SIZEOF_VOID_P) + INCLUDE (CheckTypeSize) + CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P) + ENDIF() + + # Using 32 or 64 bits libraries + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(TARGET_CPU "x86_64") + ELSE() + SET(TARGET_CPU "x86") + ENDIF() + ELSEIF(HOST_CPU MATCHES "arm") + SET(TARGET_CPU "arm") + ELSE() + SET(TARGET_CPU "unknown") + MESSAGE(STATUS "Unknown architecture: ${HOST_CPU}") + ENDIF() + # TODO: add checks for PPC + ELSE() + MESSAGE(STATUS "Compiling on ${HOST_CPU} for ${TARGET_CPU}") + ENDIF() + + # Use values from environment variables + SET(PLATFORM_CFLAGS "$ENV{CFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CFLAGS}") + SET(PLATFORM_CXXFLAGS "$ENV{CXXFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CXXFLAGS}") + SET(PLATFORM_LINKFLAGS "$ENV{LDFLAGS} ${PLATFORM_LINKFLAGS}") + + # Remove -g and -O flag because we are managing them ourself + STRING(REPLACE "-g" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS}) + STRING(REPLACE "-g" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS}) + STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS}) + STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS}) + + # Strip spaces + STRING(STRIP ${PLATFORM_CFLAGS} PLATFORM_CFLAGS) + STRING(STRIP ${PLATFORM_CXXFLAGS} PLATFORM_CXXFLAGS) + STRING(STRIP ${PLATFORM_LINKFLAGS} PLATFORM_LINKFLAGS) + + IF(NOT CMAKE_OSX_ARCHITECTURES) + IF(TARGET_CPU STREQUAL "x86_64") + SET(TARGET_X64 1) + SET(TARGET_X86 1) + ELSEIF(TARGET_CPU STREQUAL "x86") + SET(TARGET_X86 1) + ELSEIF(TARGET_CPU STREQUAL "armv7s") + SET(TARGET_ARM 1) + SET(TARGET_ARMV7S 1) + ELSEIF(TARGET_CPU STREQUAL "armv7") + SET(TARGET_ARM 1) + SET(TARGET_ARMV7 1) + ELSEIF(TARGET_CPU STREQUAL "armv6") + SET(TARGET_ARM 1) + SET(TARGET_ARMV6 1) + ELSEIF(TARGET_CPU STREQUAL "armv5") + SET(TARGET_ARM 1) + SET(TARGET_ARMV5 1) + ELSEIF(TARGET_CPU STREQUAL "arm") + SET(TARGET_ARM 1) + ELSEIF(TARGET_CPU STREQUAL "mips") + SET(TARGET_MIPS 1) + ENDIF() + + IF(TARGET_ARM) + IF(TARGET_ARMV7S) + ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S") + ENDIF() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-DHAVE_ARMV7") + ENDIF() + + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-HAVE_ARMV6") + ENDIF() + + ADD_PLATFORM_FLAGS("-DHAVE_ARM") + ENDIF() + + IF(TARGET_X86) + ADD_PLATFORM_FLAGS("-DHAVE_X86") + ENDIF() + + IF(TARGET_X64) + ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64") + ENDIF() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-DHAVE_MIPS") + ENDIF() + ENDIF() + + # Fix library paths suffixes for Debian MultiArch + IF(LIBRARY_ARCHITECTURE) + SET(CMAKE_LIBRARY_PATH /lib/${LIBRARY_ARCHITECTURE} /usr/lib/${LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH}) + IF(TARGET_X64) + SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64) + ELSEIF(TARGET_X86) + SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32) + 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() + + IF(WITH_LOGGING) + ADD_PLATFORM_FLAGS("-DENABLE_LOGS") + ENDIF() + + IF(MSVC) + IF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11) + SET(MSVC11 ON) + ENDIF() + + # Ignore default include paths + ADD_PLATFORM_FLAGS("/X") + + IF(MSVC14) + ADD_PLATFORM_FLAGS("/Gy- /MP") + # /Ox is working with VC++ 2015, but custom optimizations don't exist + 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(MSVC12) + ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") + # /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") + # /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") + # /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") + # 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") + # 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() + MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") + ENDIF() + + ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /wd4250") + + 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() + # Allows 32 bits applications to use 3 GB of RAM + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /LARGEADDRESSAWARE") + ENDIF() + + # Exceptions are only set for C++ + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} /EHa") + + IF(WITH_SYMBOLS) + SET(NL_RELEASE_CFLAGS "/Zi ${NL_RELEASE_CFLAGS}") + SET(NL_RELEASE_LINKFLAGS "/DEBUG ${NL_RELEASE_LINKFLAGS}") + ELSE() + SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}") + ENDIF() + + SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}") + SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}") + SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt ${MSVC_INCREMENTAL_YES_FLAG} ${NL_DEBUG_LINKFLAGS}") + SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}") + + IF(WITH_WARNINGS) + SET(DEBUG_CFLAGS "/W4 ${DEBUG_CFLAGS}") + ELSE() + SET(DEBUG_CFLAGS "/W3 ${DEBUG_CFLAGS}") + ENDIF() + ELSE() + IF(WIN32) + ADD_PLATFORM_FLAGS("-DWIN32 -D_WIN32") + + IF(CLANG) + ADD_PLATFORM_FLAGS("-nobuiltininc") + ENDIF() + ENDIF() + + IF(WITH_SSE3) + ADD_PLATFORM_FLAGS("-msse3") + ENDIF() + + IF(WITH_GCC_FPMATH_BOTH) + ADD_PLATFORM_FLAGS("-mfpmath=both") + ENDIF() + + IF(APPLE) + IF(NOT XCODE) + IF(CMAKE_OSX_ARCHITECTURES) + SET(TARGETS_COUNT 0) + SET(_ARCHS) + FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES}) + IF(_ARCH STREQUAL "i386") + SET(_ARCHS "${_ARCHS} i386") + SET(TARGET_X86 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "x86_64") + SET(_ARCHS "${_ARCHS} x86_64") + SET(TARGET_X64 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "armv7s") + SET(_ARCHS "${_ARCHS} armv7s") + SET(TARGET_ARMV7S 1) + SET(TARGET_ARM 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "armv7") + SET(_ARCHS "${_ARCHS} armv7") + SET(TARGET_ARMV7 1) + SET(TARGET_ARM 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "armv6") + SET(_ARCHS "${_ARCHS} armv6") + SET(TARGET_ARMV6 1) + SET(TARGET_ARM 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "mips") + SET(_ARCHS "${_ARCHS} mips") + SET(TARGET_MIPS 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSE() + SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})") + ENDIF() + ENDFOREACH(_ARCH) + MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}") + ELSE() + SET(TARGETS_COUNT 0) + ENDIF() + + IF(TARGETS_COUNT EQUAL 1) + IF(TARGET_ARM) + IF(TARGET_ARMV7S) + ADD_PLATFORM_FLAGS("-arch armv7s -DHAVE_ARMV7S") + ENDIF() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-arch armv7 -DHAVE_ARMV7") + ENDIF() + + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-arch armv6 -DHAVE_ARMV6") + ENDIF() + + IF(TARGET_ARMV5) + ADD_PLATFORM_FLAGS("-arch armv5 -DHAVE_ARMV5") + ENDIF() + + ADD_PLATFORM_FLAGS("-mthumb -DHAVE_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() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-arch mips -DHAVE_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() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-arch armv7") + ENDIF() + + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-arch armv6") + ENDIF() + + IF(TARGET_ARMV5) + ADD_PLATFORM_FLAGS("-arch armv5") + ENDIF() + + ADD_PLATFORM_FLAGS("-mthumb") + ENDIF() + + IF(TARGET_X64) + ADD_PLATFORM_FLAGS("-arch x86_64") + ELSEIF(TARGET_X86) + ADD_PLATFORM_FLAGS("-arch i386") + ENDIF() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-arch mips") + ENDIF() + ELSE() + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6") + ENDIF() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-Xarch_armv7 -mthumb -Xarch_armv7 -DHAVE_ARM -Xarch_armv7 -DHAVE_ARMV7") + ENDIF() + + IF(TARGET_X86) + ADD_PLATFORM_FLAGS("-Xarch_i386 -DHAVE_X86") + ENDIF() + + IF(TARGET_X64) + ADD_PLATFORM_FLAGS("-Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64") + ENDIF() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-Xarch_mips -DHAVE_MIPS") + ENDIF() + ENDIF() + + IF(IOS) + SET(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE) + + IF(IOS_VERSION) + PARSE_VERSION_STRING(${IOS_VERSION} IOS_VERSION_MAJOR IOS_VERSION_MINOR IOS_VERSION_PATCH) + 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() + + IF(CMAKE_IOS_SYSROOT) + IF(TARGET_ARMV7S) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_armv7s ") + 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() + + IF(TARGET_ARMV7) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_armv7 ") + 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() + + IF(TARGET_ARMV6) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_armv6 ") + 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() + ENDIF() + + IF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_i386 ") + 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() + 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() + ENDIF() + + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-headerpad_max_install_names") + + IF(HAVE_FLAG_SEARCH_PATHS_FIRST) + SET(PLATFORM_LINKFLAGS "${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() + + IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") + ADD_PLATFORM_FLAGS("-m64") + ENDIF() + ENDIF() + + ADD_PLATFORM_FLAGS("-D_REENTRANT -fno-strict-aliasing") + + IF(NOT WITH_LOW_MEMORY) + ADD_PLATFORM_FLAGS("-pipe") + ENDIF() + + IF(WITH_COVERAGE) + ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage") + ENDIF() + + IF(WITH_WARNINGS) + ADD_PLATFORM_FLAGS("-Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused") + ENDIF() + + IF(ANDROID) + ADD_PLATFORM_FLAGS("--sysroot=${PLATFORM_ROOT}") + ADD_PLATFORM_FLAGS("-ffunction-sections -funwind-tables") + ADD_PLATFORM_FLAGS("-DANDROID") + ADD_PLATFORM_FLAGS("-Wa,--noexecstack") + + IF(TARGET_ARM) + ADD_PLATFORM_FLAGS("-fpic -fstack-protector") + 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") + ELSEIF(TARGET_ARMV5) + ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float") + ENDIF() + + SET(TARGET_THUMB ON) + IF(TARGET_THUMB) + ADD_PLATFORM_FLAGS("-mthumb -fno-strict-aliasing -finline-limit=64") + SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm") + 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() + 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") + 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") + SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300") + ENDIF() + 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() + + IF(APPLE) + ADD_PLATFORM_FLAGS("-gdwarf-2 -D_DARWIN_UNLIMITED_STREAMS") + 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) + ADD_PLATFORM_FLAGS("-fPIC") + ENDIF() + + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48") + + IF(NOT APPLE) + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--no-undefined -Wl,--as-needed") + ENDIF() + + IF(WITH_SYMBOLS) + SET(NL_RELEASE_CFLAGS "${NL_RELEASE_CFLAGS} -g") + ELSE() + IF(APPLE) + SET(NL_RELEASE_LINKFLAGS "-Wl,-dead_strip ${NL_RELEASE_LINKFLAGS}") + ELSE() + SET(NL_RELEASE_LINKFLAGS "-Wl,-s ${NL_RELEASE_LINKFLAGS}") + 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() +ENDMACRO(NL_SETUP_BUILD) + +MACRO(NL_SETUP_BUILD_FLAGS) + SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + + ## Debug + SET(CMAKE_C_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_CXX_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + + ## Release + SET(CMAKE_C_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_CXX_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) +ENDMACRO(NL_SETUP_BUILD_FLAGS) + +# Macro to create x_ABSOLUTE_PREFIX from x_PREFIX +MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE) + IF(IS_ABSOLUTE "${${NAME_RELATIVE}}") + SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}}) + ELSE() + IF(WITH_UNIX_STRUCTURE) + SET(${NAME_ABSOLUTE} ${CMAKE_INSTALL_PREFIX}/${${NAME_RELATIVE}}) + ELSE() + SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}}) + ENDIF() + ENDIF() +ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX) + +MACRO(NL_SETUP_PREFIX_PATHS) + ## Allow override of install_prefix/etc path. + IF(NOT NL_ETC_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_ETC_PREFIX "etc/nel" CACHE PATH "Installation path for configurations") + ELSE() + SET(NL_ETC_PREFIX "." CACHE PATH "Installation path for configurations") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_ETC_PREFIX NL_ETC_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/share path. + IF(NOT NL_SHARE_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_SHARE_PREFIX "share/nel" CACHE PATH "Installation path for data.") + ELSE() + SET(NL_SHARE_PREFIX "." CACHE PATH "Installation path for data.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_SHARE_PREFIX NL_SHARE_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/sbin path. + IF(NOT NL_SBIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + ELSE() + SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_SBIN_PREFIX NL_SBIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/bin path. + IF(NOT NL_BIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_BIN_PREFIX "bin" CACHE PATH "Installation path for tools and applications.") + ELSE() + SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_BIN_PREFIX NL_BIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/lib path. + IF(NOT NL_LIB_PREFIX) + IF(LIBRARY_ARCHITECTURE) + SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") + ELSE() + SET(NL_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/lib path. + IF(NOT NL_DRIVER_PREFIX) + IF(WITH_UNIX_STRUCTURE) + IF(LIBRARY_ARCHITECTURE) + SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.") + ELSE() + SET(NL_DRIVER_PREFIX "lib/nel" CACHE PATH "Installation path for drivers.") + ENDIF() + ELSE() + SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_DRIVER_PREFIX NL_DRIVER_ABSOLUTE_PREFIX) +ENDMACRO(NL_SETUP_PREFIX_PATHS) + +MACRO(RYZOM_SETUP_PREFIX_PATHS) + ## Allow override of install_prefix/etc path. + IF(NOT RYZOM_ETC_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_ETC_PREFIX "etc/ryzom" CACHE PATH "Installation path for configurations") + ELSE() + SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_ETC_PREFIX RYZOM_ETC_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/share path. + IF(NOT RYZOM_SHARE_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_SHARE_PREFIX "share/ryzom" CACHE PATH "Installation path for data.") + ELSE() + SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SHARE_PREFIX RYZOM_SHARE_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/sbin path. + IF(NOT RYZOM_SBIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + ELSE() + SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SBIN_PREFIX RYZOM_SBIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/bin path. + IF(NOT RYZOM_BIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_BIN_PREFIX "bin" CACHE PATH "Installation path for tools.") + ELSE() + SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_BIN_PREFIX RYZOM_BIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/lib path. + IF(NOT RYZOM_LIB_PREFIX) + IF(LIBRARY_ARCHITECTURE) + SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") + ELSE() + SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/games path. + IF(NOT RYZOM_GAMES_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_GAMES_PREFIX "games" CACHE PATH "Installation path for client.") + ELSE() + SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_GAMES_PREFIX RYZOM_GAMES_ABSOLUTE_PREFIX) + +ENDMACRO(RYZOM_SETUP_PREFIX_PATHS) + +MACRO(SETUP_EXTERNAL) + IF(WITH_EXTERNAL) + FIND_PACKAGE(External REQUIRED) + ENDIF() + + IF(WIN32) + FIND_PACKAGE(External REQUIRED) + + # If using custom boost, we need to define the right variables used by official boost CMake module + IF(DEFINED BOOST_DIR) + SET(BOOST_INCLUDEDIR ${BOOST_DIR}/include) + SET(BOOST_LIBRARYDIR ${BOOST_DIR}/lib) + ENDIF() + ELSE() + FIND_PACKAGE(External QUIET) + + IF(APPLE) + IF(WITH_STATIC_EXTERNAL) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) + ELSE() + SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so .a) + ENDIF() + ELSE() + IF(WITH_STATIC_EXTERNAL) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so) + ELSE() + SET(CMAKE_FIND_LIBRARY_SUFFIXES .so .a) + ENDIF() + ENDIF() + ENDIF() + + # Android and iOS have pthread + IF(ANDROID OR IOS) + SET(CMAKE_USE_PTHREADS_INIT 1) + SET(Threads_FOUND TRUE) + ELSE() + FIND_PACKAGE(Threads REQUIRED) + # TODO: replace all -l by absolute path to in CMAKE_THREAD_LIBS_INIT + ENDIF() + + IF(WITH_STLPORT) + FIND_PACKAGE(STLport REQUIRED) + INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR}) + ENDIF() + + IF(WIN32) + # Must include DXSDK before WINSDK + FIND_PACKAGE(DirectXSDK REQUIRED) + # IF(DXSDK_INCLUDE_DIR) + # INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) + # ENDIF() + ENDIF() + + IF(MSVC) + FIND_PACKAGE(MSVC REQUIRED) + FIND_PACKAGE(WindowsSDK REQUIRED) + ENDIF() +ENDMACRO(SETUP_EXTERNAL) diff --git a/code/CMakeModules/nel.cmake.REMOTE.4553.cmake b/code/CMakeModules/nel.cmake.REMOTE.4553.cmake new file mode 100644 index 000000000..ed0847015 --- /dev/null +++ b/code/CMakeModules/nel.cmake.REMOTE.4553.cmake @@ -0,0 +1,1202 @@ +# Force Release configuration for compiler checks +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() + +# Declare CMAKE_CONFIGURATION_TYPES before PROJECT +SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) + +### +# Helper macro that generates .pc and installs it. +# Argument: name - the name of the .pc package, e.g. "nel-pacs.pc" +### +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() +ENDMACRO(NL_GEN_PC) + +### +# +### +MACRO(NL_TARGET_LIB name) + IF(WITH_STATIC) + ADD_LIBRARY(${name} STATIC ${ARGN}) + ELSE() + ADD_LIBRARY(${name} SHARED ${ARGN}) + ENDIF() +ENDMACRO(NL_TARGET_LIB) + +### +# +### +MACRO(NL_TARGET_DRIVER name) + IF(WITH_STATIC_DRIVERS) + ADD_LIBRARY(${name} STATIC ${ARGN}) + ELSE() + ADD_LIBRARY(${name} MODULE ${ARGN}) + ENDIF() +ENDMACRO(NL_TARGET_DRIVER) + +### +# Helper macro that sets the default library properties. +# Argument: name - the target name whose properties are being set +# Argument: +### +MACRO(NL_DEFAULT_PROPS name label) + IF(TARGET revision) + # explicitly say that the target depends on revision.h + ADD_DEPENDENCIES(${name} revision) + ENDIF() + + # Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name. + # CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819 + STRING(REGEX REPLACE "\\:" " -" proj_label ${label}) + SET_TARGET_PROPERTIES(${name} PROPERTIES PROJECT_LABEL ${proj_label}) + GET_TARGET_PROPERTY(type ${name} TYPE) + IF(${type} STREQUAL SHARED_LIBRARY) + # Set versions only if target is a shared library + SET_TARGET_PROPERTIES(${name} PROPERTIES + VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR}) + IF(NL_LIB_PREFIX) + SET_TARGET_PROPERTIES(${name} PROPERTIES INSTALL_NAME_DIR ${NL_LIB_PREFIX}) + 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} /SUBSYSTEM:${_SUBSYSTEM},${_SUBSYSTEM_VERSION}") + ENDIF() +ENDMACRO(NL_DEFAULT_PROPS) + +### +# Adds the target suffix on Windows. +# Argument: name - the library's target name. +### +MACRO(NL_ADD_LIB_SUFFIX name) + IF(WIN32) + SET_TARGET_PROPERTIES(${name} PROPERTIES DEBUG_POSTFIX "_d" RELEASE_POSTFIX "_r") + ENDIF() +ENDMACRO(NL_ADD_LIB_SUFFIX) + +### +# Adds the runtime link flags for Win32 binaries and links STLport. +# Argument: name - the target to add the link flags to. +### +MACRO(NL_ADD_RUNTIME_FLAGS name) + IF(WIN32) +# SET_TARGET_PROPERTIES(${name} PROPERTIES +# LINK_FLAGS_DEBUG "${CMAKE_LINK_FLAGS_DEBUG}" +# LINK_FLAGS_RELEASE "${CMAKE_LINK_FLAGS_RELEASE}") + ENDIF() + IF(WITH_STLPORT) + TARGET_LINK_LIBRARIES(${name} ${STLPORT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF() +ENDMACRO(NL_ADD_RUNTIME_FLAGS) + +MACRO(NL_ADD_STATIC_VID_DRIVERS name) + IF(WITH_STATIC_DRIVERS) + IF(WIN32) + IF(WITH_DRIVER_DIRECT3D) + TARGET_LINK_LIBRARIES(${name} nel_drv_direct3d_win) + ENDIF() + ENDIF() + + IF(WITH_DRIVER_OPENGL) + IF(WIN32) + TARGET_LINK_LIBRARIES(${name} nel_drv_opengl_win) + ELSE() + TARGET_LINK_LIBRARIES(${name} nel_drv_opengl) + ENDIF() + ENDIF() + + IF(WITH_DRIVER_OPENGLES) + IF(WIN32) + TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win) + ELSE() + TARGET_LINK_LIBRARIES(${name} nel_drv_opengles) + ENDIF() + ENDIF() + ENDIF() +ENDMACRO(NL_ADD_STATIC_VID_DRIVERS) + +MACRO(NL_ADD_STATIC_SND_DRIVERS name) + IF(WITH_STATIC_DRIVERS) + IF(WIN32) + IF(WITH_DRIVER_DSOUND) + TARGET_LINK_LIBRARIES(${name} nel_drv_dsound_win) + ENDIF() + + IF(WITH_DRIVER_XAUDIO2) + TARGET_LINK_LIBRARIES(${name} nel_drv_xaudio2_win) + ENDIF() + + IF(WITH_DRIVER_OPENAL) + TARGET_LINK_LIBRARIES(${name} nel_drv_openal_win) + ENDIF() + + IF(WITH_DRIVER_FMOD) + TARGET_LINK_LIBRARIES(${name} nel_drv_fmod_win) + ENDIF() + ELSE() + IF(WITH_DRIVER_OPENAL) + TARGET_LINK_LIBRARIES(${name} nel_drv_openal) + ENDIF() + + IF(WITH_DRIVER_FMOD) + TARGET_LINK_LIBRARIES(${name} nel_drv_fmod) + ENDIF() + ENDIF() + + ENDIF() +ENDMACRO(NL_ADD_STATIC_SND_DRIVERS) + +### +# Checks build vs. source location. Prevents In-Source builds. +### +MACRO(CHECK_OUT_OF_SOURCE) + IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + MESSAGE(FATAL_ERROR " + +CMake generation for this project is not allowed within the source directory! +Remove the CMakeCache.txt file and try again from another folder, e.g.: + + rm CMakeCache.txt + mkdir cmake + cd cmake + cmake .. + ") + ENDIF() + +ENDMACRO(CHECK_OUT_OF_SOURCE) + +MACRO(NL_SETUP_DEFAULT_OPTIONS) + IF(WITH_QT) + OPTION(WITH_STUDIO "Build Core Studio" OFF ) + ENDIF() + + ### + # Features + ### + OPTION(WITH_LOGGING "With Logging" ON ) + OPTION(WITH_COVERAGE "With Code Coverage Support" OFF) + OPTION(WITH_PCH "With Precompiled Headers" ON ) + OPTION(WITH_LOW_MEMORY "With low memory (use the least of RAM)" OFF) + OPTION(FINAL_VERSION "Build in Final Version mode" ON ) + + # Default to static building on Windows. + IF(WIN32) + OPTION(WITH_STATIC "With static libraries." ON ) + ELSE() + OPTION(WITH_STATIC "With static libraries." OFF) + ENDIF() + IF (WITH_STATIC) + OPTION(WITH_STATIC_LIBXML2 "With static libxml2" ON ) + ELSE() + OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF) + ENDIF() + IF (WITH_STATIC) + OPTION(WITH_STATIC_CURL "With static curl" ON ) + ELSE() + OPTION(WITH_STATIC_CURL "With static curl" OFF) + ENDIF() + IF(APPLE) + OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" ON ) + ELSE() + OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" OFF) + ENDIF() + OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF) + IF(WIN32) + OPTION(WITH_EXTERNAL "With provided external." ON ) + ELSE() + OPTION(WITH_EXTERNAL "With provided external." OFF) + 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 ) + ELSE() + OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" OFF) + ENDIF() + OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON ) + + OPTION(WITH_ASSIMP "Use assimp exporter" OFF) + + ### + # GUI toolkits + ### + OPTION(WITH_GTK "With GTK Support" OFF) + OPTION(WITH_QT "With Qt 4 Support" OFF) + OPTION(WITH_QT5 "With Qt 5 Support" OFF) + + IF(WIN32 AND MFC_FOUND) + OPTION(WITH_MFC "With MFC Support" ON ) + ELSE() + OPTION(WITH_MFC "With MFC Support" OFF) + ENDIF() + + ### + # Optional support + ### + OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" OFF) + + # only enable STLport for VC++ 2010 and less + IF(WIN32 AND MSVC_VERSION LESS 1600) + OPTION(WITH_STLPORT "With STLport support." ON ) + ELSE() + OPTION(WITH_STLPORT "With STLport support." OFF) + ENDIF() + + OPTION(BUILD_DASHBOARD "Build to the CDash dashboard" OFF) + + OPTION(WITH_NEL "Build NeL (nearly always required)." ON ) + OPTION(WITH_NELNS "Build NeL Network Services." OFF) + OPTION(WITH_RYZOM "Build Ryzom Core." ON ) + OPTION(WITH_SNOWBALLS "Build Snowballs." OFF) + OPTION(WITH_TOOLS "Build Tools" OFF) +ENDMACRO(NL_SETUP_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_NET "Build NLNET" ON ) + OPTION(WITH_3D "Build NL3D" ON ) + OPTION(WITH_GUI "Build GUI" ON ) + OPTION(WITH_PACS "Build NLPACS" ON ) + OPTION(WITH_GEORGES "Build NLGEORGES" ON ) + OPTION(WITH_LIGO "Build NLLIGO" ON ) + OPTION(WITH_LOGIC "Build NLLOGIC" ON ) + OPTION(WITH_SOUND "Build NLSOUND" ON ) + + ### + # Drivers Support + ### + OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON ) + OPTION(WITH_DRIVER_OPENGLES "Build OpenGL ES Driver (3D)" OFF) + OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF) + OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON ) + OPTION(WITH_DRIVER_FMOD "Build FMOD Driver (Sound)" OFF) + OPTION(WITH_DRIVER_DSOUND "Build DirectSound Driver (Sound)" OFF) + OPTION(WITH_DRIVER_XAUDIO2 "Build XAudio2 Driver (Sound)" OFF) + + ### + # Optional support + ### + OPTION(WITH_NEL_CEGUI "Build CEGUI Renderer" OFF) + OPTION(WITH_NEL_TOOLS "Build NeL Tools" ON ) + OPTION(WITH_NEL_MAXPLUGIN "Build NeL 3dsMax Plugin" OFF) + OPTION(WITH_NEL_SAMPLES "Build NeL Samples" ON ) + OPTION(WITH_NEL_TESTS "Build NeL Unit Tests" ON ) + + OPTION(WITH_LIBOVR "With LibOVR support" OFF) + OPTION(WITH_LIBVR "With LibVR support" OFF) + OPTION(WITH_PERFHUD "With NVIDIA PerfHUD support" OFF) + + OPTION(WITH_SSE2 "With SSE2" ON ) + OPTION(WITH_SSE3 "With SSE3" ON ) + + IF(NOT MSVC) + OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF) + ENDIF() +ENDMACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_NELNS_SERVER "Build NeLNS Services" ON ) + OPTION(WITH_NELNS_LOGIN_SYSTEM "Build NeLNS Login System Tools" ON ) +ENDMACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_RYZOM_CLIENT "Build Ryzom Core Client" ON ) + OPTION(WITH_RYZOM_TOOLS "Build Ryzom Core Tools" ON ) + OPTION(WITH_RYZOM_SERVER "Build Ryzom Core Services" ON ) + OPTION(WITH_RYZOM_INSTALLER "Build Ryzom Installer" OFF) + + ### + # Optional support + ### + OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON ) + OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF) + OPTION(WITH_LUA53 "Build Ryzom Core using Lua 5.3" OFF) + OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF) + OPTION(WITH_RYZOM_PATCH "Enable Ryzom in-game patch support" OFF) + OPTION(WITH_RYZOM_CUSTOM_PATCH_SERVER "Only use patch server from CFG file" OFF) + OPTION(WITH_RYZOM_STEAM "Enable Steam features" OFF) + OPTION(WITH_RYZOM_SANDBOX "Enable Sandbox under OS X" OFF) +ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) + +MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS) + ### + # Core libraries + ### + OPTION(WITH_SNOWBALLS_CLIENT "Build Snowballs Client" ON ) + OPTION(WITH_SNOWBALLS_SERVER "Build Snowballs Services" ON ) +ENDMACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS) + +MACRO(ADD_PLATFORM_FLAGS _FLAGS) + SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${_FLAGS}") + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${_FLAGS}") +ENDMACRO() + +MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS) + SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}") +ENDMACRO() + +MACRO(NL_SETUP_BUILD) + + #----------------------------------------------------------------------------- + # Setup the buildmode variables. + # + # None = NL_RELEASE + # Debug = NL_DEBUG + # Release = NL_RELEASE + + IF(CMAKE_BUILD_TYPE MATCHES "Debug") + SET(NL_BUILD_MODE "NL_DEBUG") + ELSE() + IF(CMAKE_BUILD_TYPE MATCHES "Release") + SET(NL_BUILD_MODE "NL_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() + ENDIF() + + 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|x86_)64") + SET(HOST_CPU "x86_64") + ELSEIF(HOST_CPU MATCHES "i.86") + SET(HOST_CPU "x86") + ENDIF() + + # Determine target CPU + + # If not specified, use the same CPU as host + IF(NOT TARGET_CPU) + SET(TARGET_CPU ${HOST_CPU}) + ENDIF() + + IF(TARGET_CPU MATCHES "(amd|AMD|x86_)64") + SET(TARGET_CPU "x86_64") + ELSEIF(TARGET_CPU MATCHES "i.86") + SET(TARGET_CPU "x86") + ENDIF() + + IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + SET(CLANG ON) + MESSAGE(STATUS "Using Clang ${CMAKE_CXX_COMPILER_VERSION} compiler") + ENDIF() + + IF(CMAKE_GENERATOR MATCHES "Xcode") + SET(XCODE ON) + MESSAGE(STATUS "Generating Xcode project") + ENDIF() + + IF(CMAKE_GENERATOR MATCHES "NMake") + SET(NMAKE ON) + MESSAGE(STATUS "Generating NMake project") + 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) + # x86-compatible CPU + IF(HOST_CPU MATCHES "x86") + IF(NOT CMAKE_SIZEOF_VOID_P) + INCLUDE (CheckTypeSize) + CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P) + ENDIF() + + # Using 32 or 64 bits libraries + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(TARGET_CPU "x86_64") + ELSE() + SET(TARGET_CPU "x86") + ENDIF() + ELSEIF(HOST_CPU MATCHES "arm") + SET(TARGET_CPU "arm") + ELSE() + SET(TARGET_CPU "unknown") + MESSAGE(STATUS "Unknown architecture: ${HOST_CPU}") + ENDIF() + # TODO: add checks for PPC + ELSE() + MESSAGE(STATUS "Compiling on ${HOST_CPU} for ${TARGET_CPU}") + ENDIF() + + # Use values from environment variables + SET(PLATFORM_CFLAGS "$ENV{CFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CFLAGS}") + SET(PLATFORM_CXXFLAGS "$ENV{CXXFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CXXFLAGS}") + SET(PLATFORM_LINKFLAGS "$ENV{LDFLAGS} ${PLATFORM_LINKFLAGS}") + + # Remove -g and -O flag because we are managing them ourself + STRING(REPLACE "-g" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS}) + STRING(REPLACE "-g" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS}) + STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS}) + STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS}) + + # Strip spaces + STRING(STRIP ${PLATFORM_CFLAGS} PLATFORM_CFLAGS) + STRING(STRIP ${PLATFORM_CXXFLAGS} PLATFORM_CXXFLAGS) + STRING(STRIP ${PLATFORM_LINKFLAGS} PLATFORM_LINKFLAGS) + + IF(NOT CMAKE_OSX_ARCHITECTURES) + IF(TARGET_CPU STREQUAL "x86_64") + SET(TARGET_X64 1) + 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) + ELSEIF(TARGET_CPU STREQUAL "armv7") + SET(TARGET_ARM 1) + SET(TARGET_ARMV7 1) + ELSEIF(TARGET_CPU STREQUAL "armv6") + SET(TARGET_ARM 1) + SET(TARGET_ARMV6 1) + ELSEIF(TARGET_CPU STREQUAL "armv5") + SET(TARGET_ARM 1) + SET(TARGET_ARMV5 1) + ELSEIF(TARGET_CPU STREQUAL "arm") + SET(TARGET_ARM 1) + ELSEIF(TARGET_CPU STREQUAL "mips") + SET(TARGET_MIPS 1) + ENDIF() + + IF(TARGET_ARM) + IF(TARGET_ARM64) + ADD_PLATFORM_FLAGS("-DHAVE_ARM64") + ENDIF() + + IF(TARGET_ARMV7S) + ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S") + ENDIF() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-DHAVE_ARMV7") + ENDIF() + + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-HAVE_ARMV6") + ENDIF() + + ADD_PLATFORM_FLAGS("-DHAVE_ARM") + ENDIF() + + IF(TARGET_X86) + ADD_PLATFORM_FLAGS("-DHAVE_X86") + ENDIF() + + IF(TARGET_X64) + ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64") + ENDIF() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-DHAVE_MIPS") + ENDIF() + ENDIF() + + # Fix library paths suffixes for Debian MultiArch + IF(LIBRARY_ARCHITECTURE) + SET(CMAKE_LIBRARY_PATH /lib/${LIBRARY_ARCHITECTURE} /usr/lib/${LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH}) + IF(TARGET_X64) + SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64) + ELSEIF(TARGET_X86) + SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32) + 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() + + IF(WITH_LOGGING) + ADD_PLATFORM_FLAGS("-DENABLE_LOGS") + ENDIF() + + IF(MSVC) + # Ignore default include paths + ADD_PLATFORM_FLAGS("/X") + + IF(MSVC14) + ADD_PLATFORM_FLAGS("/Gy- /MP") + # /Ox is working with VC++ 2015, but custom optimizations don't exist + 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(MSVC12) + 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-") + # /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-") + # /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-") + # 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") + # 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() + MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") + ENDIF() + + 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 + ADD_PLATFORM_FLAGS("/bigobj") + ELSE() + # Allows 32 bits applications to use 3 GB of RAM + ADD_PLATFORM_LINKFLAGS("/LARGEADDRESSAWARE") + ENDIF() + + # Exceptions are only set for C++ + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} /EHa") + + IF(WITH_SYMBOLS) + SET(NL_RELEASE_CFLAGS "/Zi ${NL_RELEASE_CFLAGS}") + SET(NL_RELEASE_LINKFLAGS "/DEBUG ${NL_RELEASE_LINKFLAGS}") + ELSE() + SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}") + ENDIF() + + SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}") + SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}") + SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt ${MSVC_INCREMENTAL_YES_FLAG} ${NL_DEBUG_LINKFLAGS}") + SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}") + + IF(WITH_WARNINGS) + SET(DEBUG_CFLAGS "/W4 ${DEBUG_CFLAGS}") + ELSE() + SET(DEBUG_CFLAGS "/W3 ${DEBUG_CFLAGS}") + ENDIF() + ELSE() + IF(WIN32) + ADD_PLATFORM_FLAGS("-DWIN32 -D_WIN32") + + IF(CLANG) + ADD_PLATFORM_FLAGS("-nobuiltininc") + ENDIF() + ENDIF() + + IF(WITH_SSE3) + ADD_PLATFORM_FLAGS("-msse3") + ENDIF() + + IF(WITH_GCC_FPMATH_BOTH) + ADD_PLATFORM_FLAGS("-mfpmath=both") + ENDIF() + + IF(APPLE) + IF(NOT XCODE) + IF(CMAKE_OSX_ARCHITECTURES) + SET(TARGETS_COUNT 0) + SET(_ARCHS) + FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES}) + IF(_ARCH STREQUAL "i386") + SET(_ARCHS "${_ARCHS} i386") + SET(TARGET_X86 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "x86_64") + SET(_ARCHS "${_ARCHS} x86_64") + SET(TARGET_X64 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "armv7s") + SET(_ARCHS "${_ARCHS} armv7s") + SET(TARGET_ARMV7S 1) + SET(TARGET_ARM 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "armv7") + SET(_ARCHS "${_ARCHS} armv7") + SET(TARGET_ARMV7 1) + SET(TARGET_ARM 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "armv6") + SET(_ARCHS "${_ARCHS} armv6") + SET(TARGET_ARMV6 1) + SET(TARGET_ARM 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSEIF(_ARCH STREQUAL "mips") + SET(_ARCHS "${_ARCHS} mips") + SET(TARGET_MIPS 1) + MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") + ELSE() + SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})") + ENDIF() + ENDFOREACH(_ARCH) + MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}") + ELSE() + SET(TARGETS_COUNT 0) + ENDIF() + + IF(TARGETS_COUNT EQUAL 1) + IF(TARGET_ARM) + IF(TARGET_ARMV7S) + ADD_PLATFORM_FLAGS("-arch armv7s -DHAVE_ARMV7S") + ENDIF() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-arch armv7 -DHAVE_ARMV7") + ENDIF() + + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-arch armv6 -DHAVE_ARMV6") + ENDIF() + + IF(TARGET_ARMV5) + ADD_PLATFORM_FLAGS("-arch armv5 -DHAVE_ARMV5") + ENDIF() + + ADD_PLATFORM_FLAGS("-mthumb -DHAVE_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() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-arch mips -DHAVE_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() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-arch armv7") + ENDIF() + + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-arch armv6") + ENDIF() + + IF(TARGET_ARMV5) + ADD_PLATFORM_FLAGS("-arch armv5") + ENDIF() + + ADD_PLATFORM_FLAGS("-mthumb") + ENDIF() + + IF(TARGET_X64) + ADD_PLATFORM_FLAGS("-arch x86_64") + ELSEIF(TARGET_X86) + ADD_PLATFORM_FLAGS("-arch i386") + ENDIF() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-arch mips") + ENDIF() + ELSE() + IF(TARGET_ARMV6) + ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6") + ENDIF() + + IF(TARGET_ARMV7) + ADD_PLATFORM_FLAGS("-Xarch_armv7 -mthumb -Xarch_armv7 -DHAVE_ARM -Xarch_armv7 -DHAVE_ARMV7") + ENDIF() + + IF(TARGET_X86) + ADD_PLATFORM_FLAGS("-Xarch_i386 -DHAVE_X86") + ENDIF() + + IF(TARGET_X64) + ADD_PLATFORM_FLAGS("-Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64") + ENDIF() + + IF(TARGET_MIPS) + ADD_PLATFORM_FLAGS("-Xarch_mips -DHAVE_MIPS") + ENDIF() + ENDIF() + + IF(IOS) + SET(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE) + + IF(IOS_VERSION) + PARSE_VERSION_STRING(${IOS_VERSION} IOS_VERSION_MAJOR IOS_VERSION_MINOR IOS_VERSION_PATCH) + 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() + + IF(CMAKE_IOS_SYSROOT) + IF(TARGET_ARMV7S) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_armv7s ") + ENDIF() + + ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") + ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") + ENDIF() + + IF(TARGET_ARMV7) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_armv7 ") + ENDIF() + + ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") + ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") + ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") + ENDIF() + + IF(TARGET_ARMV6) + IF(TARGETS_COUNT GREATER 1) + SET(XARCH "-Xarch_armv6 ") + ENDIF() + + ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") + ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") + 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() + + ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SIMULATOR_SYSROOT}") + ADD_PLATFORM_FLAGS("${XARCH}-mios-simulator-version-min=${IOS_VERSION}") + IF(CMAKE_OSX_DEPLOYMENT_TARGET) + 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) + 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() + + # 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) + 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() + + IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") + ADD_PLATFORM_FLAGS("-m64") + ENDIF() + ENDIF() + + # 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") + ENDIF() + + IF(WITH_COVERAGE) + ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage") + ENDIF() + + IF(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}") + ADD_PLATFORM_FLAGS("-ffunction-sections -funwind-tables") + ADD_PLATFORM_FLAGS("-DANDROID") + ADD_PLATFORM_FLAGS("-Wa,--noexecstack") + + IF(TARGET_ARM) + 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") + ADD_PLATFORM_LINKFLAGS("-march=armv7-a -Wl,--fix-cortex-a8") + ELSEIF(TARGET_ARMV5) + ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float") + ENDIF() + + SET(TARGET_THUMB ON) + IF(TARGET_THUMB) + ADD_PLATFORM_FLAGS("-mthumb -finline-limit=64") + SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm") + ELSE() + ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300") + 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("-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") + SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300") + 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() + + # Fix "relocation R_X86_64_32 against.." error on x64 platforms + IF(NOT MINGW) + ADD_PLATFORM_FLAGS("-fPIC") + 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) + 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() + IF(APPLE) + SET(NL_RELEASE_LINKFLAGS "-Wl,-dead_strip ${NL_RELEASE_LINKFLAGS}") + ELSE() + SET(NL_RELEASE_LINKFLAGS "-Wl,-s ${NL_RELEASE_LINKFLAGS}") + 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() +ENDMACRO() + +MACRO(NL_SETUP_BUILD_FLAGS) + SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + + ## Debug + SET(CMAKE_C_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_CXX_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + + ## Release + SET(CMAKE_C_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_CXX_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) +ENDMACRO(NL_SETUP_BUILD_FLAGS) + +# Macro to create x_ABSOLUTE_PREFIX from x_PREFIX +MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE) + IF(IS_ABSOLUTE "${${NAME_RELATIVE}}") + SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}}) + ELSE() + IF(WITH_UNIX_STRUCTURE) + SET(${NAME_ABSOLUTE} ${CMAKE_INSTALL_PREFIX}/${${NAME_RELATIVE}}) + ELSE() + SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}}) + ENDIF() + ENDIF() +ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX) + +MACRO(NL_SETUP_PREFIX_PATHS) + ## Allow override of install_prefix/etc path. + IF(NOT NL_ETC_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_ETC_PREFIX "etc/nel" CACHE PATH "Installation path for configurations") + ELSE() + SET(NL_ETC_PREFIX "." CACHE PATH "Installation path for configurations") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_ETC_PREFIX NL_ETC_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/share path. + IF(NOT NL_SHARE_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_SHARE_PREFIX "share/nel" CACHE PATH "Installation path for data.") + ELSE() + SET(NL_SHARE_PREFIX "." CACHE PATH "Installation path for data.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_SHARE_PREFIX NL_SHARE_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/sbin path. + IF(NOT NL_SBIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + ELSE() + SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_SBIN_PREFIX NL_SBIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/bin path. + IF(NOT NL_BIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(NL_BIN_PREFIX "bin" CACHE PATH "Installation path for tools and applications.") + ELSE() + SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_BIN_PREFIX NL_BIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/lib path. + IF(NOT NL_LIB_PREFIX) + IF(LIBRARY_ARCHITECTURE) + SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") + ELSE() + SET(NL_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/lib path. + IF(NOT NL_DRIVER_PREFIX) + IF(WITH_UNIX_STRUCTURE) + IF(LIBRARY_ARCHITECTURE) + SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.") + ELSE() + SET(NL_DRIVER_PREFIX "lib/nel" CACHE PATH "Installation path for drivers.") + ENDIF() + ELSE() + SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(NL_DRIVER_PREFIX NL_DRIVER_ABSOLUTE_PREFIX) +ENDMACRO(NL_SETUP_PREFIX_PATHS) + +MACRO(RYZOM_SETUP_PREFIX_PATHS) + ## Allow override of install_prefix/etc path. + IF(NOT RYZOM_ETC_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_ETC_PREFIX "etc/ryzom" CACHE PATH "Installation path for configurations") + ELSE() + SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_ETC_PREFIX RYZOM_ETC_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/share path. + IF(NOT RYZOM_SHARE_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_SHARE_PREFIX "share/ryzom" CACHE PATH "Installation path for data.") + ELSE() + SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SHARE_PREFIX RYZOM_SHARE_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/sbin path. + IF(NOT RYZOM_SBIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + ELSE() + SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SBIN_PREFIX RYZOM_SBIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/bin path. + IF(NOT RYZOM_BIN_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_BIN_PREFIX "bin" CACHE PATH "Installation path for tools.") + ELSE() + SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_BIN_PREFIX RYZOM_BIN_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/lib path. + IF(NOT RYZOM_LIB_PREFIX) + IF(LIBRARY_ARCHITECTURE) + SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") + ELSE() + SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX) + + ## Allow override of install_prefix/games path. + IF(NOT RYZOM_GAMES_PREFIX) + IF(WITH_UNIX_STRUCTURE) + SET(RYZOM_GAMES_PREFIX "games" CACHE PATH "Installation path for client.") + ELSE() + SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.") + ENDIF() + ENDIF() + NL_MAKE_ABSOLUTE_PREFIX(RYZOM_GAMES_PREFIX RYZOM_GAMES_ABSOLUTE_PREFIX) + +ENDMACRO(RYZOM_SETUP_PREFIX_PATHS) + +MACRO(SETUP_EXTERNAL) + IF(WITH_EXTERNAL) + FIND_PACKAGE(External REQUIRED) + ENDIF() + + IF(WIN32) + FIND_PACKAGE(External REQUIRED) + + # If using custom boost, we need to define the right variables used by official boost CMake module + IF(DEFINED BOOST_DIR) + SET(BOOST_INCLUDEDIR ${BOOST_DIR}/include) + SET(BOOST_LIBRARYDIR ${BOOST_DIR}/lib) + ENDIF() + ELSE() + FIND_PACKAGE(External QUIET) + + IF(APPLE) + IF(WITH_STATIC_EXTERNAL) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) + ELSE() + SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so .a) + ENDIF() + ELSE() + IF(WITH_STATIC_EXTERNAL) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so) + ELSE() + SET(CMAKE_FIND_LIBRARY_SUFFIXES .so .a) + ENDIF() + ENDIF() + ENDIF() + + # Android and iOS have pthread + IF(ANDROID OR IOS) + SET(CMAKE_USE_PTHREADS_INIT 1) + SET(Threads_FOUND TRUE) + ELSE() + FIND_PACKAGE(Threads REQUIRED) + # TODO: replace all -l by absolute path to in CMAKE_THREAD_LIBS_INIT + ENDIF() + + IF(WITH_STLPORT) + FIND_PACKAGE(STLport REQUIRED) + INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR}) + ENDIF() + + IF(WIN32) + # Must include DXSDK before WINSDK + FIND_PACKAGE(DirectXSDK REQUIRED) + # IF(DXSDK_INCLUDE_DIR) + # INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) + # ENDIF() + ENDIF() + + IF(MSVC) + FIND_PACKAGE(MSVC REQUIRED) + FIND_PACKAGE(WindowsSDK REQUIRED) + ENDIF() +ENDMACRO(SETUP_EXTERNAL) diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 0f1d11579..84b820d33 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -1,5 +1,3 @@ -PROJECT(NeL CXX C) - IF(WITH_STATIC_DRIVERS) ADD_DEFINITIONS(-DNL_STATIC) ENDIF() @@ -17,7 +15,6 @@ IF(WITH_3D) IF(WITH_NEL_CEGUI) FIND_PACKAGE(CEGUI) ENDIF() - ENDIF() IF(WITH_SOUND) diff --git a/code/nel/include/nel/3d/animatable.h b/code/nel/include/nel/3d/animatable.h index 09297ab2b..6e4a7b39f 100644 --- a/code/nel/include/nel/3d/animatable.h +++ b/code/nel/include/nel/3d/animatable.h @@ -19,6 +19,8 @@ #include "nel/misc/types_nl.h" #include "nel/misc/bit_set.h" +#include "nel/misc/smart_ptr.h" + #include #include #include diff --git a/code/nel/include/nel/3d/animated_lightmap.h b/code/nel/include/nel/3d/animated_lightmap.h index 51f1c909e..b8b887d7a 100644 --- a/code/nel/include/nel/3d/animated_lightmap.h +++ b/code/nel/include/nel/3d/animated_lightmap.h @@ -21,13 +21,17 @@ #include "nel/misc/types_nl.h" #include "nel/misc/smart_ptr.h" #include "nel/3d/animatable.h" + #include "nel/3d/track.h" + #include namespace NL3D { +class CScene; + // *************************************************************************** /** * An animated lightmap diff --git a/code/nel/include/nel/3d/animation_set_user.h b/code/nel/include/nel/3d/animation_set_user.h index b0e863297..39477891e 100644 --- a/code/nel/include/nel/3d/animation_set_user.h +++ b/code/nel/include/nel/3d/animation_set_user.h @@ -93,7 +93,7 @@ public: uint addAnimation (const char* fileName, const char* animName, bool displayMissingFileWarning = true) { // Allocate an animation - std::auto_ptr anim (new CAnimation); + CUniquePtr anim (new CAnimation); // Read it NLMISC::CIFile file; @@ -130,7 +130,7 @@ public: virtual uint addSkeletonWeight (const char* fileName, const char* skelName) { // Allocate an animation - std::auto_ptr skeletonWeight (new CSkeletonWeight); + CUniquePtr skeletonWeight (new CSkeletonWeight); // Read it NLMISC::CIFile file; diff --git a/code/nel/include/nel/3d/async_file_manager_3d.h b/code/nel/include/nel/3d/async_file_manager_3d.h index dede1b419..4e86f10b1 100644 --- a/code/nel/include/nel/3d/async_file_manager_3d.h +++ b/code/nel/include/nel/3d/async_file_manager_3d.h @@ -88,7 +88,7 @@ private: public: std::string MeshName; public: - CMeshLoad (const std::string &meshName, IShape **ppShp, IDriver *pDriver, const CVector &position, uint selectedTexture); + CMeshLoad (const std::string &meshName, IShape **ppShp, IDriver *pDriver, const NLMISC::CVector &position, uint selectedTexture); void run (void); void getName (std::string &result) const; }; @@ -122,7 +122,7 @@ private: CTextureFile *TextureFile; bool *Signal; public: - CTextureLoad(CTextureFile *textureFile, bool *psgn, const CVector &position) + CTextureLoad(CTextureFile *textureFile, bool *psgn, const NLMISC::CVector &position) : TextureFile(textureFile), Signal(psgn) { Position = position; diff --git a/code/nel/include/nel/3d/async_texture_manager.h b/code/nel/include/nel/3d/async_texture_manager.h index 8a848cb52..af27c3fde 100644 --- a/code/nel/include/nel/3d/async_texture_manager.h +++ b/code/nel/include/nel/3d/async_texture_manager.h @@ -152,7 +152,7 @@ private: struct CTextureLodToSort { CTextureLod *Lod; - CVector Position; + NLMISC::CVector Position; bool operator<(const CTextureLodToSort &other) const { return Lod->WeightWeight; diff --git a/code/nel/include/nel/3d/camera_col.h b/code/nel/include/nel/3d/camera_col.h index 9151b0a22..6b5a30517 100644 --- a/code/nel/include/nel/3d/camera_col.h +++ b/code/nel/include/nel/3d/camera_col.h @@ -20,6 +20,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/vector.h" #include "nel/misc/plane.h" +#include "nel/misc/aabbox.h" namespace NL3D { @@ -39,16 +40,16 @@ public: /** build the camera collision as a cone or a cylinder */ - void build(const CVector &start, const CVector &end, float radius, bool cone); + void build(const NLMISC::CVector &start, const NLMISC::CVector &end, float radius, bool cone); /** build the camera collision as a simple ray */ - void buildRay(const CVector &start, const CVector &end); + void buildRay(const NLMISC::CVector &start, const NLMISC::CVector &end); /** compute the intersection of the Camera Volume against the triangle, and minimize * minDist (actual square of distance) with min sqr distance of the poly. */ - void minimizeDistanceAgainstTri(const CVector &p0, const CVector &p1, const CVector &p2, float &sqrMinDist); + void minimizeDistanceAgainstTri(const NLMISC::CVector &p0, const NLMISC::CVector &p1, const NLMISC::CVector &p2, float &sqrMinDist); /** Compute into this the camera collision 'other' mul by 'matrix' * NB: for cone Radius, suppose uniform scale, else will have strange result (a uniform scale is deduced) @@ -69,9 +70,9 @@ private: enum {MaxNPlanes=6}; // The start of the camera raycast - CVector _Start; + NLMISC::CVector _Start; // The end of the camera raycast - CVector _End; + NLMISC::CVector _End; // The radius (at end only if cone) float _Radius; // cone or cylinder? @@ -83,8 +84,8 @@ private: NLMISC::CAABBox _BBox; // Temp Data for minimizeDistanceAgainstTri - CVector _ArrayIn[3+MaxNPlanes]; - CVector _ArrayOut[3+MaxNPlanes]; + NLMISC::CVector _ArrayIn[3+MaxNPlanes]; + NLMISC::CVector _ArrayOut[3+MaxNPlanes]; // The pyramid representing the camera collision volume. Nb: local to start for precision problems NLMISC::CPlane _Pyramid[MaxNPlanes]; @@ -97,10 +98,10 @@ private: float _MaxRadiusProj; float _OODeltaRadiusProj; float _RayLen; - CVector _RayNorm; + NLMISC::CVector _RayNorm; // simpler method for simple ray - void intersectRay(const CVector &p0, const CVector &p1, const CVector &p2, float &sqrMinDist); + void intersectRay(const NLMISC::CVector &p0, const NLMISC::CVector &p1, const NLMISC::CVector &p2, float &sqrMinDist); }; diff --git a/code/nel/include/nel/3d/cloud_scape_user.h b/code/nel/include/nel/3d/cloud_scape_user.h index 15c926927..9e2a88376 100644 --- a/code/nel/include/nel/3d/cloud_scape_user.h +++ b/code/nel/include/nel/3d/cloud_scape_user.h @@ -22,6 +22,7 @@ namespace NL3D class UDriver; class UCamera; class CCloudScape; +class CScene; /// implementation of UWaterInstance methods class CCloudScapeUser : public UCloudScape diff --git a/code/nel/include/nel/3d/cluster.h b/code/nel/include/nel/3d/cluster.h index 552d7474a..b038a34c4 100644 --- a/code/nel/include/nel/3d/cluster.h +++ b/code/nel/include/nel/3d/cluster.h @@ -120,7 +120,7 @@ public: void setWorldMatrix (const NLMISC::CMatrix &WM); - bool isRoot() { return _LocalVolume.size() == 0; } + bool isRoot() { return _LocalVolume.empty(); } //\name Sound related. //@{ diff --git a/code/nel/include/nel/3d/coarse_mesh_manager.h b/code/nel/include/nel/3d/coarse_mesh_manager.h index ce571cbd1..feaad9e05 100644 --- a/code/nel/include/nel/3d/coarse_mesh_manager.h +++ b/code/nel/include/nel/3d/coarse_mesh_manager.h @@ -84,7 +84,7 @@ public: void setTextureFile (const char* file); /** - * Add a coarse mesh in the manager. If an error occured, it returns CantAddCoarseMesh. + * Add a coarse mesh in the manager. If an error occurred, it returns CantAddCoarseMesh. * \param vBuffer the VertexBuffer pre-transformed / Colored. Size MUST be numVertices*NL3D_COARSEMESH_VERTEX_FORMAT_MGR * \param indexBuffer containing triangles that will be inserted. * \return false if the mesh can't be added to this pass BECAUSE OF TOO MANY VERTICES or TOO MANY PRIMITIVES reason diff --git a/code/nel/include/nel/3d/fasthls_modifier.h b/code/nel/include/nel/3d/fasthls_modifier.h index b5ec7ad82..de8f22a3d 100644 --- a/code/nel/include/nel/3d/fasthls_modifier.h +++ b/code/nel/include/nel/3d/fasthls_modifier.h @@ -48,7 +48,7 @@ public: static void releaseInstance(); /// convert a HLS (0..255) to a RGBA. - CRGBA convert(uint H, uint L, uint S); + NLMISC::CRGBA convert(uint H, uint L, uint S); /// convert a RGBA bitmap into another RGBA, with HLS decal (0..255, -255..+255, -255..+255). void convertRGBABitmap(NLMISC::CBitmap &dst, const NLMISC::CBitmap &src, uint8 dh, sint dl, sint ds); @@ -75,7 +75,7 @@ private: uint8 H,L,S,A; }; - CRGBA _HueTable[HueTableSize]; + NLMISC::CRGBA _HueTable[HueTableSize]; CHLSA _Color16ToHLS[65536]; /// Constructor diff --git a/code/nel/include/nel/3d/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.h b/code/nel/include/nel/3d/particle_system.h index 7255cfec9..50a8d8269 100644 --- a/code/nel/include/nel/3d/particle_system.h +++ b/code/nel/include/nel/3d/particle_system.h @@ -841,7 +841,7 @@ public: /// return true when there are still emitters in the system - bool hasEmitters(void) const; + bool hasEmitters() const; /// return true when there are still particles bool hasParticles() const; diff --git a/code/nel/include/nel/3d/particle_system_manager.h b/code/nel/include/nel/3d/particle_system_manager.h index f48b17f1b..1e02963bb 100644 --- a/code/nel/include/nel/3d/particle_system_manager.h +++ b/code/nel/include/nel/3d/particle_system_manager.h @@ -87,7 +87,7 @@ private: { public: CParticleSystemModel *Model; - CMatrix OldAncestorMatOrRelPos; // last matrix of ancestor skeleton or relative matrix of ps to its ancestor (see flag below) + NLMISC::CMatrix OldAncestorMatOrRelPos; // last matrix of ancestor skeleton or relative matrix of ps to its ancestor (see flag below) bool IsRelMatrix; // gives usage of the field OldAncestorMatOrRelPos bool HasAncestorSkeleton; // has the system an ancestor skeleton ? public: diff --git a/code/nel/include/nel/3d/particle_system_process.h b/code/nel/include/nel/3d/particle_system_process.h index 1ff031a5a..75aa6e0f1 100644 --- a/code/nel/include/nel/3d/particle_system_process.h +++ b/code/nel/include/nel/3d/particle_system_process.h @@ -163,10 +163,10 @@ class CParticleSystemProcess : public NLMISC::IStreamable virtual void setMatrixMode(TPSMatrixMode matrixMode); /// tells whether there are alive entities / particles in the system - virtual bool hasParticles(void) const { return false ; } + virtual bool hasParticles() const { return false ; } /// tells whether there are alive emitters / particles in the system - virtual bool hasEmitters(void) const { return false ; } + virtual bool hasEmitters() const { return false ; } /// max number of faces wanted by this process (for load balancing) diff --git a/code/nel/include/nel/3d/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..7170be75a 100644 --- a/code/nel/include/nel/3d/ps_emitter.h +++ b/code/nel/include/nel/3d/ps_emitter.h @@ -51,14 +51,14 @@ public: //@} /// Return this bindable type - uint32 getType(void) const { return PSEmitter; } + uint32 getType() const { return PSEmitter; } /// Return priority for emitters - virtual uint32 getPriority(void) const { return 500; } + virtual uint32 getPriority() const { return 500; } /// Return true if this located bindable derived class holds alive emitters - virtual bool hasEmitters(void) { nlassert(_Owner); return _Owner->getSize() != 0; } + virtual bool hasEmitters() const { nlassert(_Owner); return _Owner->getSize() != 0; } virtual void step(TPSProcessPass pass); @@ -76,7 +76,7 @@ public: /// Display the emitter in edition mode - virtual void showTool(void); + virtual void showTool(); /** Set the type of located to be emitted. The default is NULL which mean that no emission will occur * \return true if the operation could be performed. It can fail when this cause the system the system to last forever, @@ -90,9 +90,9 @@ public: virtual void notifyTargetRemoved(CPSLocated *ptr); /// Get emitted type. - CPSLocated *getEmittedType(void) { return _EmittedType; } + CPSLocated *getEmittedType() { return _EmittedType; } /// Get const ptr on emitted type - const CPSLocated *getEmittedType(void) const { return _EmittedType; } + const CPSLocated *getEmittedType() const { return _EmittedType; } /** The type of emission. @@ -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..4245c5c81 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() { @@ -449,14 +449,14 @@ public: void setName(const std::string &name) { _Name = name; } /// get the located bindable name (edition purpose) - std::string getName(void) const { return _Name; } + std::string getName() const { return _Name; } /// tells whether there are alive entities / particles in the system - virtual bool hasParticles(void) const; + virtual bool hasParticles() const; /// tells whether there are alive emitters / particles in the system - virtual bool hasEmitters(void) const; + virtual bool hasEmitters() const; /** Enable the to force LOD degradation. This will suppress instances immediately, (during the motion pass) so that * there won't be more than maxNbInstance * dist / maxDist instances. This may not be desirable @@ -468,7 +468,7 @@ public: /** Test whether LOD degradation was activated * \see forceLODDegradation() */ - bool hasLODDegradation(void) const { return _LODDegradation; } + bool hasLODDegradation() const { return _LODDegradation; } /// for the CPSLocated to reevaluate the max number of faces it may need @@ -853,11 +853,11 @@ public: */ void setLOD(TPSLod lod) { _LOD = lod; } /// get the valid lods for that object - TPSLod getLOD(void) const { return _LOD; } + TPSLod getLOD() const { return _LOD; } /// tells whether there are alive entities / particles - virtual bool hasParticles(void) const { return false; } + virtual bool hasParticles() const { return false; } /// tells whether there are alive emitters - virtual bool hasEmitters(void) const { return false; } + virtual bool hasEmitters() const { return false; } /** set the extern ID of this located bindable. 0 means no extern access. The map of ID-locatedBindable. Is in th * particle system, so this located bindable must have been attached to a particle system, otherwise an assertion is raised */ @@ -906,10 +906,10 @@ protected: */ virtual void resize(uint32 size) = 0; - /** a bounce occured, so some action could be done. The default behaviour does nothing + /** a bounce occurred, so some action could be done. The default behaviour does nothing * \param index the index of the element that bounced */ - virtual void bounceOccured(uint32 /* index */, TAnimationTime /* timeToNextsimStep */) {} + virtual void bounceOccurred(uint32 /* index */, TAnimationTime /* timeToNextsimStep */) {} /** show an drawing to represent the object, and in red if it is selected * \param tab : a table of 2 * nbSeg vector. only the x and y coordinates are used 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/tile_bank.h b/code/nel/include/nel/3d/tile_bank.h index ec96afb64..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; 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/georges/form.h b/code/nel/include/nel/georges/form.h index d2b6a2f2d..da5c0ea88 100644 --- a/code/nel/include/nel/georges/form.h +++ b/code/nel/include/nel/georges/form.h @@ -22,7 +22,7 @@ #include "form_elm.h" #include "header.h" -extern bool convertFormFile (const char *oldFileName, const char *newFileName); +extern bool convertFormFile (const std::string &oldFileName, const std::string &newFileName); namespace NLGEORGES { @@ -35,7 +35,7 @@ class UFormElm; class CForm : public UForm { friend class CFormLoader; - friend bool convertFormFile (const char *oldFileName, const char *newFileName); + friend bool convertFormFile (const std::string &oldFileName, const std::string &newFileName); public: enum { HeldElementCount = 4 }; @@ -73,12 +73,12 @@ public: // ** IO functions // Set the filename before saving the form - void write (xmlDocPtr doc, const char *filename); + void write (xmlDocPtr doc, const std::string &filename); // ** Parent access // Insert parent before parent indexed "before". - bool insertParent (uint before, const char *filename, CForm *parent); + bool insertParent (uint before, const std::string &filename, CForm *parent); // Remove a parent from parent list void removeParent (uint parent); @@ -97,7 +97,7 @@ public: const std::string &getFilename () const; // Error handling - void warning (bool exception, const char *function, const char *format, ... ) const; + void warning (bool exception, const std::string &function, const char *format, ... ) const; private: @@ -114,7 +114,7 @@ private: // CFormLoader call it // Set the filename before reading the form - void read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const char *filename); + void read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const std::string &filename); // Called by read void readParent (const char *parent, CFormLoader &loader); diff --git a/code/nel/include/nel/georges/form_dfn.h b/code/nel/include/nel/georges/form_dfn.h index a93dcbe48..4e9870043 100644 --- a/code/nel/include/nel/georges/form_dfn.h +++ b/code/nel/include/nel/georges/form_dfn.h @@ -24,7 +24,7 @@ #include "header.h" #include "type.h" -bool convertDfnFile (const char *oldFileName, const char *newFileName); +bool convertDfnFile (const std::string &oldFileName, const std::string &newFileName); namespace NLGEORGES { @@ -41,7 +41,7 @@ class CFormDfn : public UFormDfn friend class CFormElm; friend class CFormLoader; friend class CFormElmStruct; - friend bool convertDfnFile (const char *oldFileName, const char *newFileName); + friend bool convertDfnFile (const std::string &oldFileName, const std::string &newFileName); public: // Default cstr @@ -60,7 +60,7 @@ public: friend class CFormElm; friend class CFormDfn; friend class CFormElmStruct; - friend bool convertDfnFile (const char *oldFileName, const char *newFileName); + friend bool convertDfnFile (const std::string &oldFileName, const std::string &newFileName); public: CEntry () @@ -85,12 +85,12 @@ public: TEntryType getType () const; // Set as a type - void setType (CFormLoader &loader, const char *filename); + void setType (CFormLoader &loader, const std::string &filename); void setType (TEntryType type); // Set as a dfn - void setDfn (CFormLoader &loader, const char *filename); + void setDfn (CFormLoader &loader, const std::string &filename); // Set as a dfn pointer void setDfnPointer (); @@ -99,7 +99,7 @@ public: const std::string &getName () const; // Set element Name - void setName (const char *name); + void setName (const std::string &name); // Get the filename const std::string &getFilename() const; @@ -108,16 +108,16 @@ public: const std::string &getFilenameExt() const; // Set the filename - void setFilename (const char *def); + void setFilename (const std::string &def); // Set the filename extension - void setFilenameExt (const char *ext); + void setFilenameExt (const std::string &ext); // Get default value const std::string &getDefault () const; // Set default value - void setDefault (const char *def); + void setDefault (const std::string &def); // Set array flag void setArrayFlag (bool flag); @@ -167,7 +167,7 @@ public: void removeEntry( uint idx ); // ** IO functions - void write (xmlDocPtr root, const char *filename); + void write (xmlDocPtr root, const std::string &filename); // Count parent DFN uint countParentDfn (uint32 round=0) const; @@ -185,7 +185,7 @@ public: void setNumParent (uint size); // Set a parent - void setParent (uint parent, CFormLoader &loader, const char *filename); + void setParent (uint parent, CFormLoader &loader, const std::string &filename); // Get a parent CFormDfn *getParent (uint parent) const; @@ -232,7 +232,7 @@ public: CFileHeader Header; // Error handling - void warning (bool exception, const char *function, const char *format, ... ) const; + void warning (bool exception, const std::string &function, const char *format, ... ) const; private: // The parents array @@ -249,7 +249,7 @@ private: private: // Read method called by the form loader - void read (xmlNodePtr doc, CFormLoader &loader, bool forceLoad, const char *filename); + void read (xmlNodePtr doc, CFormLoader &loader, bool forceLoad, const std::string &filename); }; } // NLGEORGES diff --git a/code/nel/include/nel/georges/form_elm.h b/code/nel/include/nel/georges/form_elm.h index 2d9e76630..738e6a55a 100644 --- a/code/nel/include/nel/georges/form_elm.h +++ b/code/nel/include/nel/georges/form_elm.h @@ -62,30 +62,30 @@ public: virtual void getFormName (std::string &result, const CFormElm *child=NULL) const = 0; // From UFormElm - virtual bool getNodeByName (const UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round=0) const; - virtual bool getNodeByName (UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round=0); - virtual bool getValueByName (std::string &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (sint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (uint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (sint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (uint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (sint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (uint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (float &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (double &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (bool &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool getValueByName (NLMISC::CRGBA &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; - virtual bool setValueByName (const char *value, const char *name, bool *created); - virtual bool setValueByName (sint8 value, const char *name, bool *created); - virtual bool setValueByName (uint8 value, const char *name, bool *created); - virtual bool setValueByName (sint16 value, const char *name, bool *created); - virtual bool setValueByName (uint16 value, const char *name, bool *created); - virtual bool setValueByName (sint32 value, const char *name, bool *created); - virtual bool setValueByName (uint32 value, const char *name, bool *created); - virtual bool setValueByName (float value, const char *name, bool *created); - virtual bool setValueByName (double value, const char *name, bool *created); - virtual bool setValueByName (bool value, const char *name, bool *created); - virtual bool setValueByName (NLMISC::CRGBA value, const char *name, bool *created); + virtual bool getNodeByName (const UFormElm **result, const std::string &name, TWhereIsNode *where, bool verbose, uint32 round=0) const; + virtual bool getNodeByName (UFormElm **result, const std::string &name, TWhereIsNode *where, bool verbose, uint32 round=0); + virtual bool getValueByName (std::string &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (sint8 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (uint8 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (sint16 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (uint16 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (sint32 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (uint32 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (float &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (double &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (bool &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool getValueByName (NLMISC::CRGBA &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; + virtual bool setValueByName (const std::string &value, const std::string &name, bool *created); + virtual bool setValueByName (sint8 value, const std::string &name, bool *created); + virtual bool setValueByName (uint8 value, const std::string &name, bool *created); + virtual bool setValueByName (sint16 value, const std::string &name, bool *created); + virtual bool setValueByName (uint16 value, const std::string &name, bool *created); + virtual bool setValueByName (sint32 value, const std::string &name, bool *created); + virtual bool setValueByName (uint32 value, const std::string &name, bool *created); + virtual bool setValueByName (float value, const std::string &name, bool *created); + virtual bool setValueByName (double value, const std::string &name, bool *created); + virtual bool setValueByName (bool value, const std::string &name, bool *created); + virtual bool setValueByName (NLMISC::CRGBA value, const std::string &name, bool *created); virtual UFormElm *getParent () const; virtual const CType *getType (); virtual bool isArray () const; @@ -127,16 +127,16 @@ public: // ** Convert functions - inline bool convertValue (sint8 &result, const char *value) const; - inline bool convertValue (uint8 &result, const char *value) const; - inline bool convertValue (sint16 &result, const char *value) const; - inline bool convertValue (uint16 &result, const char *value) const; - inline bool convertValue (sint32 &result, const char *value) const; - inline bool convertValue (uint32 &result, const char *value) const; - inline bool convertValue (float &result, const char *value) const; - inline bool convertValue (double &result, const char *value) const; - inline bool convertValue (bool &result, const char *value) const; - inline bool convertValue (NLMISC::CRGBA &result, const char *value) const; + inline bool convertValue (sint8 &result, const std::string &value) const; + inline bool convertValue (uint8 &result, const std::string &value) const; + inline bool convertValue (sint16 &result, const std::string &value) const; + inline bool convertValue (uint16 &result, const std::string &value) const; + inline bool convertValue (sint32 &result, const std::string &value) const; + inline bool convertValue (uint32 &result, const std::string &value) const; + inline bool convertValue (float &result, const std::string &value) const; + inline bool convertValue (double &result, const std::string &value) const; + inline bool convertValue (bool &result, const std::string &value) const; + inline bool convertValue (NLMISC::CRGBA &result, const std::string &value) const; // ** Get dependencies virtual void getDependencies (std::set &dependencies) const = 0; @@ -144,7 +144,7 @@ public: // ** Internal node access // Create a node by name. If the node already exists, return it - bool createNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, + bool createNodeByName (const std::string &, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool &created); @@ -153,13 +153,13 @@ public: * Delete a node by name. If the node already exists, return it *Delete its parent if not used */ - bool deleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, + bool deleteNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array); // Search for a node by name - bool getNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, + bool getNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool &parentVDfnArray, bool verbose, uint32 round) const; @@ -168,7 +168,7 @@ public: * Insert an array node by name * The index asked must be < the size of the array. */ - bool arrayInsertNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, + bool arrayInsertNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool verbose, uint arrayIndex) const; @@ -177,7 +177,7 @@ public: * Delete an array node by name * The index asked must be < the size of the array. */ - bool arrayDeleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, + bool arrayDeleteNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool verbose, uint arrayIndex) const; @@ -199,7 +199,7 @@ protected: * Then, else (*parentDfn / indexDfn ) or *node must be defined. * Other values are for result only. */ - static bool getInternalNodeByName (CForm *form, const char *name, const CFormDfn **parentDfn, uint &indexDfn, + static bool getInternalNodeByName (CForm *form, const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, TNodeAction action, bool &created, bool &parentVDfnArray, bool verbose, uint32 round); @@ -215,7 +215,7 @@ public: static const char* tokenize (const char *name, std::string &str, uint &errorIndex, uint &code); // ** IO functions - virtual xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName = NULL, bool forceWrite = false) const = 0; + virtual xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName = "", bool forceWrite = false) const = 0; protected: @@ -235,8 +235,8 @@ protected: uint32 Round; // Error handling - static void warning (bool exception, const char *formName, const char *formFileName, const char *function, const char *format, ... ); - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + static void warning (bool exception, const std::string &formName, const std::string &formFileName, const std::string &function, const char *format, ... ); + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; private: // Tokens @@ -298,7 +298,7 @@ public: // From CFormElm bool isUsed (const CForm *form) const; - xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; + xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const; void unlink (CFormElm *child); void getFormName (std::string &result, const CFormElm *child) const; void getDependencies (std::set &dependencies) const; @@ -310,7 +310,7 @@ public: std::vector Elements; // Error handling - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; }; /** @@ -332,13 +332,13 @@ public: // From CFormElm bool isUsed (const CForm *form) const; - xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; + xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const; // Call by CFormLoader void read (xmlNodePtr node, CFormLoader &loader, CForm *form); // Error handling - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; }; /** @@ -377,7 +377,7 @@ public: bool getArrayValue (NLMISC::CRGBA &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const; // From CFormElm - xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; + xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const; bool setParent (CFormElm *parent); void unlink (CFormElm *child); bool isUsed (const CForm *form) const; @@ -406,7 +406,7 @@ public: std::vector Elements; // Error handling - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; }; /** @@ -429,7 +429,7 @@ public: const CType *Type; // From CFormElm - xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; + xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const; bool setParent (CFormElm *parent); void getFormName (std::string &result, const CFormElm *child) const; void getDependencies (std::set &dependencies) const; @@ -453,7 +453,7 @@ public: bool getValue (NLMISC::CRGBA &result, TEval evaluate) const; // Set the value, the elt been used - void setValue (const char *value); + void setValue (const std::string &value); // Get the raw value. Does not care about any parent or default values void getValue (std::string &result) const; @@ -463,14 +463,14 @@ private: std::string Value; // Error handling - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; }; // *************************************************************************** // CFormElm inlines // *************************************************************************** -inline bool CFormElm::convertValue (sint8 &result, const char *value) const +inline bool CFormElm::convertValue (sint8 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -482,14 +482,14 @@ inline bool CFormElm::convertValue (sint8 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in sint8.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in sint8.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (uint8 &result, const char *value) const +inline bool CFormElm::convertValue (uint8 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -501,14 +501,14 @@ inline bool CFormElm::convertValue (uint8 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in uint8.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in uint8.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (sint16 &result, const char *value) const +inline bool CFormElm::convertValue (sint16 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -520,14 +520,14 @@ inline bool CFormElm::convertValue (sint16 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in sint16.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in sint16.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (uint16 &result, const char *value) const +inline bool CFormElm::convertValue (uint16 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -539,14 +539,14 @@ inline bool CFormElm::convertValue (uint16 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in uint16.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in uint16.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (sint32 &result, const char *value) const +inline bool CFormElm::convertValue (sint32 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -558,14 +558,14 @@ inline bool CFormElm::convertValue (sint32 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in sint32.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in sint32.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (uint32 &result, const char *value) const +inline bool CFormElm::convertValue (uint32 &result, const std::string &value) const { float tmp; if (NLMISC::fromString(value, tmp)) @@ -577,14 +577,14 @@ inline bool CFormElm::convertValue (uint32 &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in uint32.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in uint32.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (float &result, const char *value) const +inline bool CFormElm::convertValue (float &result, const std::string &value) const { if (NLMISC::fromString(value, result)) { @@ -593,16 +593,16 @@ inline bool CFormElm::convertValue (float &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in float.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in float.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (double &result, const char *value) const +inline bool CFormElm::convertValue (double &result, const std::string &value) const { - float tmp; + double tmp; if (NLMISC::fromString(value, tmp)) { result = tmp; @@ -611,14 +611,14 @@ inline bool CFormElm::convertValue (double &result, const char *value) const else { // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in double.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in double.", value.c_str()); } return false; } // *************************************************************************** -inline bool CFormElm::convertValue (bool &result, const char *value) const +inline bool CFormElm::convertValue (bool &result, const std::string &value) const { int tmp; if (NLMISC::fromString(value, tmp)) @@ -628,7 +628,7 @@ inline bool CFormElm::convertValue (bool &result, const char *value) const } else { - std::string temp = NLMISC::toLower(std::string(value)); + std::string temp = NLMISC::toLower(value); if (strcmp (temp.c_str (), "true") == 0) { result = true; @@ -642,17 +642,17 @@ inline bool CFormElm::convertValue (bool &result, const char *value) const } // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in boolean.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in boolean.", value.c_str()); return false; } // *************************************************************************** -inline bool CFormElm::convertValue (NLMISC::CRGBA &result, const char *value) const +inline bool CFormElm::convertValue (NLMISC::CRGBA &result, const std::string &value) const { float r, g, b; - if (sscanf (value, "%f,%f,%f", &r, &g, &b) == 3) + if (sscanf (value.c_str(), "%f,%f,%f", &r, &g, &b) == 3) { NLMISC::clamp (r, 0.f, 255.f); NLMISC::clamp (g, 0.f, 255.f); @@ -664,7 +664,7 @@ inline bool CFormElm::convertValue (NLMISC::CRGBA &result, const char *value) co } // Error message - warning (false, "convertValue", "Can't convert the string \"%s\" in RGB color.", value); + warning (false, "convertValue", "Can't convert the string \"%s\" in RGB color.", value.c_str()); return false; } diff --git a/code/nel/include/nel/georges/form_loader.h b/code/nel/include/nel/georges/form_loader.h index 75d7152ec..c46d79f22 100644 --- a/code/nel/include/nel/georges/form_loader.h +++ b/code/nel/include/nel/georges/form_loader.h @@ -42,18 +42,18 @@ class CFormLoader : public UFormLoader public: virtual ~CFormLoader(); // From UFormLoader - UForm *loadForm (const char *filename); - UFormDfn *loadFormDfn (const char *filename); - UType *loadFormType (const char *filename); + UForm *loadForm (const std::string &filename); + UFormDfn *loadFormDfn (const std::string &filename); + UType *loadFormType (const std::string &filename); // Load type and formDfn - CType *loadType (const char *filename); - CFormDfn *loadFormDfn (const char *filename, bool forceLoad); + CType *loadType (const std::string &filename); + CFormDfn *loadFormDfn (const std::string &filename, bool forceLoad); private: // Error handling - virtual void warning (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &function, const char *format, ... ) const; typedef std::map > TTypeMap; typedef std::map > TFormDfnMap; diff --git a/code/nel/include/nel/georges/header.h b/code/nel/include/nel/georges/header.h index 343b2baa1..82a094b3d 100644 --- a/code/nel/include/nel/georges/header.h +++ b/code/nel/include/nel/georges/header.h @@ -44,10 +44,10 @@ public: }; /// Add a log - void addLog (const char *log); + void addLog(const std::string &log); /// Set the comment - void setComments (const char *comments); + void setComments (const std::string &comments); /// Major version number uint32 MajorVersion; @@ -72,7 +72,7 @@ public: static const char *getStateString (TState state); // Error handling - void warning (bool exception, const char *function, const char *format, ... ) const; + void warning (bool exception, const std::string &function, const char *format, ... ) const; }; } // NLGEORGES diff --git a/code/nel/include/nel/georges/load_form.h b/code/nel/include/nel/georges/load_form.h index 34e5c99c4..5a133e61e 100644 --- a/code/nel/include/nel/georges/load_form.h +++ b/code/nel/include/nel/georges/load_form.h @@ -385,7 +385,7 @@ void loadForm (const std::vector &sheetFilters, const std::string & } } - if(NeededToRecompute.size() > 0) + if(!NeededToRecompute.empty()) nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); // free the georges loader if necessary @@ -748,7 +748,7 @@ void loadForm2(const std::vector &sheetFilters, const std::string & } } - if(NeededToRecompute.size() > 0) + if(!NeededToRecompute.empty()) nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); // free the georges loader if necessary @@ -1304,7 +1304,7 @@ void loadFormNoPackedSheet (const std::vector &sheetFilters, std::m } } - if(NeededToRecompute.size() > 0) + if(!NeededToRecompute.empty()) nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); // free the georges loader if necessary @@ -1393,7 +1393,7 @@ void loadFormNoPackedSheet2 (const std::vector &sheetFilters, std:: } } - if(NeededToRecompute.size() > 0) + if(!NeededToRecompute.empty()) nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); // free the georges loader if necessary diff --git a/code/nel/include/nel/georges/type.h b/code/nel/include/nel/georges/type.h index 936506c7c..e1bad7934 100644 --- a/code/nel/include/nel/georges/type.h +++ b/code/nel/include/nel/georges/type.h @@ -80,7 +80,7 @@ public: // Evaluate a node bool getValue (std::string &result, const class CForm *form, const class CFormElmAtom *node, const class CFormDfn &parentDfn, - uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const char *formName) const; + uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const std::string &formName) const; // Definitions class CDefinition @@ -114,8 +114,8 @@ public: private: // Error handling - virtual void warning (bool exception, const char *formName, const char *formFilename, const char *function, const char *format, ... ) const; - virtual void warning2 (bool exception, const char *function, const char *format, ... ) const; + virtual void warning (bool exception, const std::string &formName, const std::string &formFilename, const std::string &function, const char *format, ... ) const; + virtual void warning2 (bool exception, const std::string &function, const char *format, ... ) const; // Type names static const char *TypeNames[]; diff --git a/code/nel/include/nel/georges/u_form_elm.h b/code/nel/include/nel/georges/u_form_elm.h index 6ec80938f..d6b5f075a 100644 --- a/code/nel/include/nel/georges/u_form_elm.h +++ b/code/nel/include/nel/georges/u_form_elm.h @@ -78,8 +78,8 @@ public: * "position.x" : get the element named x in the struct named position * "entities[2].color" : get the node named color in the second element of the entities array */ - virtual bool getNodeByName (const UFormElm **result, const char *name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) const = 0; - virtual bool getNodeByName (UFormElm **result, const char *name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) = 0; + virtual bool getNodeByName (const UFormElm **result, const std::string &name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) const = 0; + virtual bool getNodeByName (UFormElm **result, const std::string &name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) = 0; /// Where a value has been found @@ -104,19 +104,19 @@ public: * \return true if the result has been filled, false if the value has not been found or the cast has failed or the evaluation has failed. * \see getNodeByName () */ - virtual bool getValueByName (std::string &result, const char *namename, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (sint8 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (uint8 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (sint16 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (uint16 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (sint32 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (uint32 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (float &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (double &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; - virtual bool getValueByName (bool &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (std::string &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (sint8 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (uint8 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (sint16 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (uint16 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (sint32 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (uint32 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (float &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (double &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (bool &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; /// Warning, only R, G and B members are filled, not A. - virtual bool getValueByName (NLMISC::CRGBA &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; + virtual bool getValueByName (NLMISC::CRGBA &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; /** * Set a form value with its name. If the node doesn't exist, it is created. @@ -129,17 +129,17 @@ public: * true if the value has been created, false it the value has been filled. * \return true if the value has been set, false if the value has not been found or hasn't been created. */ - virtual bool setValueByName (const char *value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (sint8 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (uint8 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (sint16 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (uint16 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (sint32 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (uint32 value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (float value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (double value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (bool value, const char *name, bool *created = NULL) = 0; - virtual bool setValueByName (NLMISC::CRGBA value, const char *name, bool *created = NULL) = 0; + virtual bool setValueByName (const std::string &value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (sint8 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (uint8 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (sint16 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (uint16 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (sint32 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (uint32 value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (float value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (double value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (bool value, const std::string &name, bool *created = NULL) = 0; + virtual bool setValueByName (NLMISC::CRGBA value, const std::string &name, bool *created = NULL) = 0; // ** Array element methods @@ -224,6 +224,9 @@ public: // ** Atom element methods + /// Returns the type of the atom. NULL otherwise. + virtual const class UType *getType () = 0; + /// Returns the type of the atom. NULL otherwise. virtual const class UType *getType () = 0; diff --git a/code/nel/include/nel/georges/u_form_loader.h b/code/nel/include/nel/georges/u_form_loader.h index b32f358e0..c1cb30cfb 100644 --- a/code/nel/include/nel/georges/u_form_loader.h +++ b/code/nel/include/nel/georges/u_form_loader.h @@ -43,19 +43,19 @@ public: * * The pointer on the form must be held in a CSmartPtr. Returns NULL if the form can't be loaded. */ - virtual UForm *loadForm (const char *filename) = 0; + virtual UForm *loadForm (const std::string &filename) = 0; /** Load a DFN, use NMISC::CPath to find the file. * * The pointer on the form must be held in a CSmartPtr. Returns NULL if the DFN can't be loaded. */ - virtual UFormDfn *loadFormDfn (const char *filename) = 0; + virtual UFormDfn *loadFormDfn (const std::string &filename) = 0; /** Load a type, use NMISC::CPath to find the file. * * The pointer on the form must be held in a CSmartPtr. Returns NULL if the type can't be loaded. */ - virtual UType *loadFormType (const char *filename) = 0; + virtual UType *loadFormType (const std::string &filename) = 0; /// Create a form loader static UFormLoader *createLoader (); diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index a794f349b..479fc7384 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -321,7 +321,7 @@ namespace NLGUI // \name internal methods // Add a group in the current parent group - void addGroup (CInterfaceGroup *group, uint beginSpace); + void addHtmlGroup (CInterfaceGroup *group, uint beginSpace); // Get the current parent group CInterfaceGroup *getCurrentGroup(); diff --git a/code/nel/include/nel/gui/group_menu.h b/code/nel/include/nel/gui/group_menu.h index e55bed751..d4f940088 100644 --- a/code/nel/include/nel/gui/group_menu.h +++ b/code/nel/include/nel/gui/group_menu.h @@ -191,6 +191,7 @@ namespace NLGUI int luaGetLineFromId(CLuaState &ls); int luaIsSeparator(CLuaState &ls); int luaAddLine(CLuaState &ls); + int luaAddIconLine(CLuaState &ls); int luaAddLineAtIndex(CLuaState &ls); int luaAddSeparator(CLuaState &ls); int luaAddSeparatorAtIndex(CLuaState &ls); @@ -210,6 +211,7 @@ namespace NLGUI REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu); REFLECT_LUA_METHOD("isSeparator", luaIsSeparator); REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id + REFLECT_LUA_METHOD("addIconLine", luaAddIconLine); // name, ah, ah_params, id, texture REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id REFLECT_LUA_METHOD("addSeparator", luaAddSeparator); REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex); @@ -278,6 +280,7 @@ namespace NLGUI */ CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const; void initOptions(CInterfaceGroup *parent); + CViewBitmap *createIcon(CInterfaceElement *parentPos, const std::string &texture); CViewBitmap *createCheckBox(bool checked); CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center); }; diff --git a/code/nel/include/nel/gui/group_paragraph.h b/code/nel/include/nel/gui/group_paragraph.h index b8792ece1..0004850fa 100644 --- a/code/nel/include/nel/gui/group_paragraph.h +++ b/code/nel/include/nel/gui/group_paragraph.h @@ -206,12 +206,6 @@ namespace NLGUI invalidateContent(); } - // Set the HTML group used for links - void setBrowseGroup (CInterfaceElement *group) - { - _BrowseGroup = group; - } - /// \from CInterfaceElement void onInvalidateContent(); sint32 getMaxUsedW() const; @@ -293,9 +287,6 @@ namespace NLGUI // The links std::vector _Links; - // The HTML group used - CInterfaceElement *_BrowseGroup; - private: std::string _HardText; uint32 _TextId; diff --git a/code/nel/include/nel/gui/group_table.h b/code/nel/include/nel/gui/group_table.h index 746078908..2be9ef98c 100644 --- a/code/nel/include/nel/gui/group_table.h +++ b/code/nel/include/nel/gui/group_table.h @@ -64,7 +64,7 @@ namespace NLGUI xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; // to be called by CGroupTable - bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex); + bool parseCell (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex); // If the cell is a new line. This is the first after a bool NewLine; diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 0a2d107fb..bfc951ce2 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -208,7 +208,7 @@ namespace NLGUI CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, const std::pair *templateParams, uint numParams, bool updateLinks = true); CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, std::vector > &templateParams, bool updateLinks = true) { - if (templateParams.size() > 0) + if (!templateParams.empty()) return createGroupInstance(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks); else return createGroupInstance(templateName, parentID, NULL, 0, updateLinks); @@ -222,7 +222,7 @@ namespace NLGUI CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, const std::pair *templateParams, uint numParams, bool updateLinks /* = true */); CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, std::vector > &templateParams, bool updateLinks = true) { - if (templateParams.size() > 0) + if (!templateParams.empty()) return createUIElement(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks); else return createUIElement(templateName, parentID, NULL, 0, updateLinks); diff --git a/code/nel/include/nel/gui/interface_property.h b/code/nel/include/nel/gui/interface_property.h index 4ed6e701e..b506ec7a9 100644 --- a/code/nel/include/nel/gui/interface_property.h +++ b/code/nel/include/nel/gui/interface_property.h @@ -72,8 +72,8 @@ namespace NLGUI bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL ); /// float operations - void setDouble (double value) {setSInt64((sint64&) value);} - double getDouble () const {sint64 i = getSInt64(); return (double &) i; } + void setDouble(double value); + double getDouble() const; void readDouble (const char* value, const std::string& id); /// sint32 operations diff --git a/code/nel/include/nel/gui/lua_helper.h b/code/nel/include/nel/gui/lua_helper.h index 50896b30c..7388c729d 100644 --- a/code/nel/include/nel/gui/lua_helper.h +++ b/code/nel/include/nel/gui/lua_helper.h @@ -90,7 +90,7 @@ namespace NLGUI virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());} }; - // A parse error occured + // A parse error occurred class ELuaParseError : public ELuaError { public: @@ -117,7 +117,7 @@ namespace NLGUI std::string _Reason; }; - // A execution error occured + // A execution error occurred class ELuaExecuteError : public ELuaError { public: @@ -128,7 +128,7 @@ namespace NLGUI virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());} }; - // A bad cast occured when using lua_checkcast + // A bad cast occurred when using lua_checkcast class ELuaBadCast : public ELuaError { public: diff --git a/code/nel/include/nel/gui/view_link.h b/code/nel/include/nel/gui/view_link.h index 1cc40a883..0fbca1065 100644 --- a/code/nel/include/nel/gui/view_link.h +++ b/code/nel/include/nel/gui/view_link.h @@ -50,10 +50,21 @@ namespace NLGUI void setHTMLView( CGroupHTML *html); bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col); + void setActionOnLeftClick(const std::string &actionHandler) { _AHOnLeftClick = actionHandler; }; + void setParamsOnLeftClick(const std::string &actionParams) { _AHOnLeftClickParams = actionParams; }; + + const std::string &getActionOnLeftClick() const { return _AHOnLeftClick; } + const std::string &getParamsOnLeftClick() const { return _AHOnLeftClickParams; } protected: // The main HTML group CGroupHTML *HTML; + + // Left mouse click action + // Don't use CStringShared as URLs change past values would be permanently remembered. + std::string _AHOnLeftClick; + std::string _AHOnLeftClickParams; + }; } diff --git a/code/nel/include/nel/gui/view_pointer_base.h b/code/nel/include/nel/gui/view_pointer_base.h index e772d934f..5468ba6d5 100644 --- a/code/nel/include/nel/gui/view_pointer_base.h +++ b/code/nel/include/nel/gui/view_pointer_base.h @@ -38,14 +38,17 @@ namespace NLGUI void resetPointerPos (); void setPointerDown (bool pd); + void setPointerMiddleDown (bool pd); + void setPointerRightDown (bool pd); void setPointerDownString (const std::string &s); void getPointerPos (sint32 &x, sint32 &y); void getPointerDispPos (sint32 &x, sint32 &y); void getPointerOldPos (sint32 &x, sint32 &y); - void getPointerDownPos (sint32 &x, sint32 &y); - bool getPointerDown (); + bool getPointerDown (sint32 &x, sint32 &y); + bool getPointerMiddleDown (sint32 &x, sint32 &y); + bool getPointerRightDown (sint32 &x, sint32 &y); std::string getPointerDownString (); bool getPointerDrag (); @@ -70,6 +73,12 @@ namespace NLGUI bool _PointerDown; // Is the pointer down ? sint32 _PointerDownX; // Pointer down position sint32 _PointerDownY; + bool _PointerMiddleDown; // Is the middle pointer down ? + sint32 _PointerMiddleDownX; // Pointer middle down position + sint32 _PointerMiddleDownY; + bool _PointerRightDown; // Is the right pointer down ? + sint32 _PointerRightDownX; // Pointer right down position + sint32 _PointerRightDownY; std::string _PointerDownString; // What is under the pointer at the down position bool _PointerDrag; // Is the pointer down and we have moved ? bool _PointerVisible; // Is the pointer visible or hidden ? diff --git a/code/nel/include/nel/gui/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/include/nel/ligo/primitive.h.BACKUP.4924.h b/code/nel/include/nel/ligo/primitive.h.BACKUP.4924.h new file mode 100644 index 000000000..619ddb6bd --- /dev/null +++ b/code/nel/include/nel/ligo/primitive.h.BACKUP.4924.h @@ -0,0 +1,875 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef __PRIMITIVE_H__ +#define __PRIMITIVE_H__ + +#include "nel/misc/vector.h" +#include "nel/misc/rgba.h" + +// Forward declarations for libxml2 +typedef struct _xmlNode xmlNode; +typedef xmlNode *xmlNodePtr; + +typedef struct _xmlDoc xmlDoc; +typedef xmlDoc *xmlDocPtr; + + +#include + +namespace NLLIGO +{ + +#ifdef NL_DEBUG +# define NLLIGO_DEBUG +#endif + + +/** + * Ligo primitives are used to add logical geometrical gameplay information. + * Ligo primitives are NODES, POINTS, PATHES or ZONES. + * Ligo primitives have a CLASS. + * + * The primitive class defines the properties attached to the primitive + * The primitive class are defined in the XML file specified in the LigoClass field of the CLigoConfig class. + */ + +class CPrimitives; +class CLigoConfig; + +// *************************************************************************** + +void Register (); + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + */ +class IProperty : public NLMISC::IStreamable +{ +public: + IProperty () + { + Default = false; + } + + // This property is set to default + bool Default; + // Force class to be polymorphic + virtual void foo () const = 0; +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a simple string + */ +class CPropertyString : public IProperty +{ +public: + CPropertyString () {} +<<<<<<< HEAD + CPropertyString (const char *str); + CPropertyString (const std::string &str); + CPropertyString (const char *str, bool _default); +======= + CPropertyString (const std::string &str); + CPropertyString (const std::string &str, bool _default); +>>>>>>> ryzomcore + virtual ~CPropertyString () {} + std::string String; + + NLMISC_DECLARE_CLASS (CPropertyString) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serial(String); + } + + // Force class to be polymorphic + virtual void foo () const {} +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a string array + */ +class CPropertyStringArray : public IProperty +{ +public: + CPropertyStringArray () {} + virtual ~CPropertyStringArray () {} + CPropertyStringArray (const std::vector &stringArray); + CPropertyStringArray (const std::vector &stringArray, bool _default); + std::vector StringArray; + + NLMISC_DECLARE_CLASS (CPropertyStringArray) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serialCont(StringArray); + } + // Force class to be polymorphic + virtual void foo () const {} +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a string array + */ +class CPropertyColor : public IProperty +{ +public: + NLMISC::CRGBA Color; + + NLMISC_DECLARE_CLASS (CPropertyColor) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serial(Color); + } + // Force class to be polymorphic + virtual void foo () const {} + + // ctors + CPropertyColor() {} + CPropertyColor(NLMISC::CRGBA col) : Color(col) {} +}; + +// *************************************************************************** + +class CPrimVector : public NLMISC::CVector +{ +public: + CPrimVector () + { + Selected = false; + } + CPrimVector (const NLMISC::CVector &v) + { + CVector::operator= (v); + Selected = false; + } + + void serial(NLMISC::IStream &f) + { + CVector::serial(f); + f.serial(Selected); + } + + bool Selected; +}; + +// *************************************************************************** + +/* + * This class is the base class for ligo primitive. + * + * Provide access to common properties. + * Provide access to the primitive hierachy + */ +class IPrimitive : public NLMISC::IStreamable +{ + friend class CPrimitives; +public: + + // Deprecated +// std::string Layer; + // Deprecated +// std::string Name; + + // Expended in the tree view +// bool Expanded; + + enum + { + NotAnArray, + AtTheEnd = 0xffffffff, + }; + + /// \name Hierarchy + IPrimitive (); + + virtual ~IPrimitive (); + + IPrimitive (const IPrimitive &node); + + virtual void operator= (const IPrimitive &node); + + /** Get the children primitive count */ + uint getNumChildren () const + { + return (uint)_Children.size (); + } + + /** Get a child primitive */ + bool getChild (const IPrimitive *&result, uint childId) const; + + /** Get a child primitive */ + bool getChild (IPrimitive *&result, uint childId); + + /** Get the parent primitive */ + IPrimitive *getParent () + { + return _Parent; + } + const IPrimitive *getParent () const + { + return _Parent; + } + + /** Get the primitive relative to this and the given path */ + const IPrimitive *getPrimitive (const std::string &absoluteOrRelativePath) const; + + /** Get the id of the child, return 0xffffffff if not found */ + bool getChildId (uint &childId, const IPrimitive *child) const; + + /** Remove and delete a child primitive */ + bool removeChild (IPrimitive *child); + + /** Remove and delete a child primitive */ + bool removeChild (uint childId); + + /// Remove the child primitive from the children list, don't delete it + bool unlinkChild(IPrimitive *child); + + /** Remove and delete all children primitives */ + void removeChildren (); + + /** + * Insert a child primitive before the index. + * The pointer will be deleted by the parent primitive using the ::delete operator. + * return false if the index is invalid + */ + bool insertChild (IPrimitive *primitive, uint index = AtTheEnd); + + /// \name Properties + + /** + * Get a num properties + **/ + uint getNumProperty () const; + + /** + * Get a properties by its index + * This method (iterate a list) is slower than getPropertyByName (look up in a map). + **/ + bool getProperty (uint index, std::string &property_name, const IProperty *&result) const; + + /** + * Get a properties by its index + * This method (iterate a list) is slower than getPropertyByName (look up in a map). + **/ + bool getProperty (uint index, std::string &property_name, IProperty *&result); + + /** Check the existence of a named property */ + bool checkProperty(const std::string &property_name) const; + + /** + * Add a property + * If the property already exist, the method does nothing and returns false. + * The pointer will be deleted by the primitive using the ::delete operator. + **/ +<<<<<<< HEAD + bool addPropertyByName (const char *property_name, IProperty *result); +======= + bool addPropertyByName (const std::string &property_name, IProperty *result); +>>>>>>> ryzomcore + + /** + * Get a property with its name + **/ +<<<<<<< HEAD + bool getPropertyByName (const char *property_name, const IProperty *&result) const; +======= + bool getPropertyByName (const std::string &property_name, const IProperty *&result) const; +>>>>>>> ryzomcore + + /** + * Get a property with its name + **/ +<<<<<<< HEAD + bool getPropertyByName (const char *property_name, IProperty *&result) const; +======= + bool getPropertyByName (const std::string &property_name, IProperty *&result) const; +>>>>>>> ryzomcore + + /** + * Get a string property with its name. Return false if the property is not found or is not a string property. + **/ +<<<<<<< HEAD + bool getPropertyByName (const char *property_name, std::string *&result) const; +======= + bool getPropertyByName (const std::string &property_name, std::string *&result) const; +>>>>>>> ryzomcore + + /** + * Get a string array property with its name. Return false if the property is not found or is not a string array property. + **/ +<<<<<<< HEAD + bool getPropertyByName (const char *property_name, std::vector *&result) const; +======= + bool getPropertyByName (const std::string &property_name, std::vector *&result) const; +>>>>>>> ryzomcore + + /** + * Get a string property with its name. Return false if the property is not found or is not a string property. + **/ +<<<<<<< HEAD + bool getPropertyByName (const char *property_name, std::string &result) const; +======= + bool getPropertyByName (const std::string &property_name, std::string &result) const; +>>>>>>> ryzomcore + + /** + * Get a string array property with its name. Return false if the property is not found or is not a string array property. + **/ +<<<<<<< HEAD + bool getPropertyByName (const char *property_name, const std::vector *&result) const; +======= + bool getPropertyByName (const std::string &property_name, const std::vector *&result) const; +>>>>>>> ryzomcore + + /** + * Get a color property with its name. Return false if the property is not found or is not a string array property. + **/ +<<<<<<< HEAD + bool getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const; +======= + bool getPropertyByName (const std::string &property_name, NLMISC::CRGBA &result) const; +>>>>>>> ryzomcore + + /** + * Remove a property + * This is method (iterate a list) is slower than removePropertyByName (look up in a map). + **/ + bool removeProperty (uint index); + + /** + * Remove a property by its name + **/ +<<<<<<< HEAD + bool removePropertyByName (const char *property_name); +======= + bool removePropertyByName (const std::string &property_name); +>>>>>>> ryzomcore + + /** + * Remove all the properties + **/ + void removeProperties (); + + /* Init default primitive's parameters + * + * This method will add all the properties declared in the primitive class and create default properties. + */ + void initDefaultValues (CLigoConfig &config); + + // Read the primitive, calls initDefaultValue (CLigoConfig &config) +<<<<<<< HEAD + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; +======= + virtual bool read (xmlNodePtr xmlNode, const std::string &property_name, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const std::string &property_name) const; +>>>>>>> ryzomcore + + // Get the vertices + virtual uint getNumVector () const = 0; + virtual const CPrimVector *getPrimVector () const = 0; + virtual CPrimVector *getPrimVector () = 0; + + // Make a copy + virtual IPrimitive *copy () const = 0; + + // used for fast binary save/load (exploitation mode) + void serial(NLMISC::IStream &f); + + // shortcut to getPropertyByName("name", ret); return ret; + std::string getName() const; + + const std::string &getUnparsedProperties() const; + void setUnparsedProperties(const std::string &unparsedProperties) const; + +private: + + // callback called just after the node is attach under a parent + virtual void onLinkToParent() {} + // callback called just before the node is removed from it's parent + virtual void onUnlinkFromParent() {} + + /// Callback called just after an ancestor is linked + virtual void onBranchLink() {} + /// Callback called just before an ancestor is unlinked + virtual void onBranchUnlink() {} + + /// Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading + virtual void onModifyPrimitive(CPrimitives &/* primitives */) const {} + + // internal recusive call + void branchLink(); + void branchUnlink(); + + // Update child Id + void updateChildId (uint index); + + // Child id + uint32 _ChildId; + + // Parent + IPrimitive *_Parent; + + // Children + std::vector _Children; + + // Single properties + std::map _Properties; + + // Editor specific properties (unparsed) + mutable std::string _UnparsedProperties; + + +#ifdef NLLIGO_DEBUG + std::string _DebugClassName; + std::string _DebugPrimitiveName; +#endif + + +}; + +// *************************************************************************** + +// Simple primitive node +class CPrimNode : public IPrimitive +{ +public: + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimNode) + +protected: + + // void operator= (const CPrimNode &node); + + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive +<<<<<<< HEAD + 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); +>>>>>>> ryzomcore + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + +// *************************************************************************** + +class CPrimPoint : public IPrimitive +{ + +public: + + CPrimPoint () + { + Angle = 0; + } + + + CPrimVector Point; + float Angle; // Angle on OZ, CCW + +public: + + void serial (NLMISC::IStream &f); + + // void operator= (const CPrimPoint &node); + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimPoint); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive +<<<<<<< HEAD + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; +======= + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; +>>>>>>> ryzomcore + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** +class CPrimPath : public IPrimitive +{ + +public: + + std::vector VPoints; + +public: + + void serial (NLMISC::IStream &f); + + // void operator= (const CPrimPath &node); + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimPath); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive +<<<<<<< HEAD + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; +======= + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; +>>>>>>> ryzomcore + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** + +class CPrimZone : public IPrimitive +{ + +public: + + std::vector VPoints; + + static float getSegmentDist(const NLMISC::CVector v, const NLMISC::CVector &p1, const NLMISC::CVector &p2, NLMISC::CVector &nearPos); + +public: + + bool contains (const NLMISC::CVector &v) const { return CPrimZone::contains(v, VPoints); } + bool contains(const NLMISC::CVector &v, float &distance, NLMISC::CVector &nearPos, bool isPath) const { return CPrimZone::contains(v, VPoints, distance, nearPos, isPath); } + + // void operator= (const CPrimZone &node); + + void serial (NLMISC::IStream &f); + + // Returns true if the vector v is inside of the patatoid + static bool contains (const NLMISC::CVector &v, const std::vector &points); + // Returns true if the vector v is inside of the patatoid and set the distance of the nearest segment and the position of the nearest point. + static bool contains (const NLMISC::CVector &v, const std::vector &points, float &distance, NLMISC::CVector &nearPos, bool isPath); + // Returns true if the vector v is inside of the patatoid + static bool contains (const NLMISC::CVector &v, const std::vector &points); + // Returns true if the vector v is inside of the patatoid and set the distance of the nearest segment and the position of the nearest point. + static bool contains (const NLMISC::CVector &v, const std::vector &points, float &distance, NLMISC::CVector &nearPos, bool isPath); + + /// Returns the barycenter of the zone (warning, it may be outside of the zone if it is not convex). Returns CVector::Null if there is no vertex. + NLMISC::CVector getBarycentre() const; + + /// Returns the smallest axis-aligned box containing the zone (z is always set to 0) + void getAABox( NLMISC::CVector& cornerMin, NLMISC::CVector& cornerMax ) const; + + /// Return the area of the axis-aligned box containing the zone + float getAreaOfAABox() const; + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimZone); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive +<<<<<<< HEAD + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; +======= + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; +>>>>>>> ryzomcore + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** + +/** This primitive type is used to handle unique alias across a primitive file. + * Usage of this primitive imply the setting of the appropriate 'ligo context' + * before reading or copy/pasting alias. +*/ +class CPrimAlias : public IPrimitive +{ + friend class CPrimitives; + + /// The 'dynamic' part of the alias + uint32 _Alias; + /// The primitive container + class CPrimitives *_Container; + + // Needed overloads (not used) + virtual uint getNumVector () const + { + return 0; + }; + virtual const CPrimVector *getPrimVector () const + { + return NULL; + } + virtual CPrimVector *getPrimVector () + { + return NULL; + } + + + virtual void onBranchLink(); + // callback called just before the node is removed from it's parent + virtual void onBranchUnlink(); + + void regenAlias(); + +public: + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimAlias); + + // private default constructor + CPrimAlias(); + // copy constructor needed + CPrimAlias(const CPrimAlias &other); + + ~CPrimAlias(); + + // return the dynamic part of the alias + uint32 getAlias() const; + + // Return the full alias, merge of the static and dynamic part + uint32 getFullAlias() const; + + // Read the primitive +<<<<<<< HEAD + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; +======= + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; +>>>>>>> ryzomcore + // Create a copy of this primitive + virtual IPrimitive *copy () const; + // serial for binary save + virtual void serial (NLMISC::IStream &f); + +}; + +// *************************************************************************** + +/* +This class is deprecated. +*/ +class CPrimRegion +{ + +public: + + std::string Name; + std::vector VPoints; + std::vector VZones; + std::vector VPaths; + + std::vector VHidePoints; + std::vector VHideZones; + std::vector VHidePaths; + +public: + + void serial (NLMISC::IStream &f); +}; + +// *************************************************************************** + +/** + * This class is a ligo primitives set + */ +class CPrimitives +{ +public: + + CPrimitives (); + CPrimitives (const CPrimitives &other); + ~CPrimitives (); + + // Operator copy + CPrimitives& operator= (const CPrimitives &other); + + // Convert from old format to the new one + void convert (const CPrimRegion ®ion); + + // Read the primitive +<<<<<<< HEAD + bool read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &config); + + // Write the primitive + void write (xmlDocPtr xmlNode, const char *filename) const; + + // Write the primitive + void write (xmlNodePtr root, const char *filename) const; +======= + bool read (xmlNodePtr xmlNode, const std::string &filename, CLigoConfig &config); + + // Write the primitive + void write (xmlDocPtr xmlNode, const std::string &filename) const; + + // Write the primitive + void write (xmlNodePtr root, const std::string &filename) const; +>>>>>>> ryzomcore + + // serial the primitive. Used for binary files. + void serial(NLMISC::IStream &f); + + // Root primitive hierarchy + CPrimNode *RootNode; + + // get the static alias part for this primitive + uint32 getAliasStaticPart(); + + // set the static alias part for this primitive + void setAliasStaticPart(uint32 staticPart); + + // Build an alias by combining the static and dynamic part + uint32 buildFullAlias(uint32 dynamicPart); + + // Generate a new unique alias (dynamic part only) + uint32 genAlias(IPrimitive *prim, uint32 preferedAlias = 0); + // Reserve an alias and store it in the used alias list (dynamic part only) +// void reserveAlias(uint32 dynamicAlias); + // Remove an alias from the list of alias in use (dynamic part only) + void releaseAlias(IPrimitive *prim, uint32 dynamicAlias); + + // Force the assignation of the specified alias to the primitive. If another primitive + // already hold the alias, this other primitive is assigned a new alias. + void forceAlias(CPrimAlias *prim, uint32 alias); + + // get the last generated alias value (for debug only) + uint32 getLastGeneratedAlias(); + + // Return the primitive indexed by the given alias (ie, it doesn't return the alias primitive, but its first parent) + IPrimitive *getPrimitiveByAlias(uint32 primAlias); + + // Build the complete list of indexed primitive (ie all primitive that have a primalias child) + void buildPrimitiveWithAliasList(std::map &result); + + +private: + // Conversion internal methods + void convertAddPrimitive (IPrimitive *child, const IPrimitive *prim, bool hidden); + void convertPrimitive (const IPrimitive *prim, bool hidden); + + /// Optional context information + CLigoConfig *_LigoConfig; + /// Static part alias mapping (can be 0 if no mapping is defined) + uint32 _AliasStaticPart; + /// Last generated Alias, used to compute the next alias + uint32 _LastGeneratedAlias; + /// List of alias in use in the primitive (dynamic part only) + std::map _AliasInUse; + // Store the filename + // This allows to retrieve the static alias when reloading from binary file + std::string _Filename; +}; + +// *************************************************************************** + +/** Singleton to manage special loading feature related to + * unique alias assignment + */ +class CPrimitiveContext +{ + static CPrimitiveContext *_Instance; + + // private ctor + CPrimitiveContext(); +public: + + // get the singleton reference + static CPrimitiveContext &instance() + { + if (!_Instance) + { + _Instance = new CPrimitiveContext; + } + + return *_Instance; + } + + /// The current ligo configuration file. + CLigoConfig *CurrentLigoConfig; + /// The current primitives container. + CPrimitives *CurrentPrimitive; + +}; + + +} // namespace NLLIGO + +#endif // __PRIMITIVE_H__ + diff --git a/code/nel/include/nel/ligo/primitive.h.BASE.4924.h b/code/nel/include/nel/ligo/primitive.h.BASE.4924.h new file mode 100644 index 000000000..e131a89e5 --- /dev/null +++ b/code/nel/include/nel/ligo/primitive.h.BASE.4924.h @@ -0,0 +1,781 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef __PRIMITIVE_H__ +#define __PRIMITIVE_H__ + +#include "nel/misc/vector.h" +#include "nel/misc/rgba.h" + +// Include from libxml2 +#include + +#include + +namespace NLLIGO +{ + +#ifdef NL_DEBUG +# define NLLIGO_DEBUG +#endif + + +/** + * Ligo primitives are used to add logical geometrical gameplay informations. + * Ligo primitives are NODES, POINTS, PATHES or ZONES. + * Ligo primitives have a CLASS. + * + * The primitive class defines the properties attached to the primitive + * The primitive class are defined in the XML file specified in the LigoClass field of the CLigoConfig class. + */ + +class CPrimitives; +class CLigoConfig; + +// *************************************************************************** + +void Register (); + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + */ +class IProperty : public NLMISC::IStreamable +{ +public: + IProperty () + { + Default = false; + } + + // This property is set to default + bool Default; + // Force class to be polymorphic + virtual void foo () const = 0; +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a simple string + */ +class CPropertyString : public IProperty +{ +public: + CPropertyString () {} + CPropertyString (const char *str); + CPropertyString (const std::string &str); + CPropertyString (const char *str, bool _default); + virtual ~CPropertyString () {} + std::string String; + + NLMISC_DECLARE_CLASS (CPropertyString) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serial(String); + } + + // Force class to be polymorphic + virtual void foo () const {} +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a string array + */ +class CPropertyStringArray : public IProperty +{ +public: + CPropertyStringArray () {} + virtual ~CPropertyStringArray () {} + CPropertyStringArray (const std::vector &stringArray); + CPropertyStringArray (const std::vector &stringArray, bool _default); + std::vector StringArray; + + NLMISC_DECLARE_CLASS (CPropertyStringArray) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serialCont(StringArray); + } + // Force class to be polymorphic + virtual void foo () const {} +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a string array + */ +class CPropertyColor : public IProperty +{ +public: + NLMISC::CRGBA Color; + + NLMISC_DECLARE_CLASS (CPropertyColor) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serial(Color); + } + // Force class to be polymorphic + virtual void foo () const {} + + // ctors + CPropertyColor() {} + CPropertyColor(NLMISC::CRGBA col) : Color(col) {} +}; + +// *************************************************************************** + +class CPrimVector : public NLMISC::CVector +{ +public: + CPrimVector () + { + Selected = false; + } + CPrimVector (const NLMISC::CVector &v) + { + CVector::operator= (v); + Selected = false; + } + + void serial(NLMISC::IStream &f) + { + CVector::serial(f); + f.serial(Selected); + } + + bool Selected; +}; + +// *************************************************************************** + +/* + * This class is the base class for ligo primitive. + * + * Provide access to common properties. + * Provide access to the primitive hierachy + */ +class IPrimitive : public NLMISC::IStreamable +{ + friend class CPrimitives; +public: + + // Deprecated +// std::string Layer; + // Deprecated +// std::string Name; + + // Expended in the tree view +// bool Expanded; + + enum + { + NotAnArray, + AtTheEnd = 0xffffffff, + }; + + /// \name Hierarchy + IPrimitive (); + + virtual ~IPrimitive (); + + IPrimitive (const IPrimitive &node); + + virtual void operator= (const IPrimitive &node); + + /** Get the children primitive count */ + uint getNumChildren () const + { + return _Children.size (); + } + + /** Get a child primitive */ + bool getChild (const IPrimitive *&result, uint childId) const; + + /** Get a child primitive */ + bool getChild (IPrimitive *&result, uint childId); + + /** Get the parent primitive */ + IPrimitive *getParent () + { + return _Parent; + } + const IPrimitive *getParent () const + { + return _Parent; + } + + /** Get the primitive relative to this and the given path */ + const IPrimitive *getPrimitive (const std::string &absoluteOrRelativePath) const; + + /** Get the id of the child, return 0xffffffff if not found */ + bool getChildId (uint &childId, const IPrimitive *child) const; + + /** Remove and delete a child primitive */ + bool removeChild (IPrimitive *child); + + /** Remove and delete a child primitive */ + bool removeChild (uint childId); + + /// Remove the child primitive from the children list, don't delete it + bool unlinkChild(IPrimitive *child); + + /** Remove and delete all children primitives */ + void removeChildren (); + + /** + * Insert a child primitive before the index. + * The pointer will be deleted by the parent primitive using the ::delete operator. + * return false if the index is invalid + */ + bool insertChild (IPrimitive *primitive, uint index = AtTheEnd); + + /// \name Properties + + /** + * Get a num properties + **/ + uint getNumProperty () const; + + /** + * Get a properties by its index + * This method (iterate a list) is slower than getPropertyByName (look up in a map). + **/ + bool getProperty (uint index, std::string &property_name, const IProperty *&result) const; + + /** + * Get a properties by its index + * This method (iterate a list) is slower than getPropertyByName (look up in a map). + **/ + bool getProperty (uint index, std::string &property_name, IProperty *&result); + + /** Check the existence of a named property */ + bool checkProperty(const std::string &property_name) const; + + /** + * Add a property + * 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); + + /** + * Get a property with its name + **/ + bool getPropertyByName (const char *property_name, const IProperty *&result) const; + + /** + * Get a property with its name + **/ + bool getPropertyByName (const char *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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * Remove a property + * This is method (iterate a list) is slower than removePropertyByName (look up in a map). + **/ + bool removeProperty (uint index); + + /** + * Remove a property by its name + **/ + bool removePropertyByName (const char *property_name); + + /** + * Remove all the properties + **/ + void removeProperties (); + + /* Init default primitive's parameters + * + * This method will add all the properties declared in the primitive class and create default properties. + */ + void initDefaultValues (CLigoConfig &config); + + // Read the primitive, calls initDefaultValue (CLigoConfig &config) + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; + + // Get the vertices + virtual uint getNumVector () const = 0; + virtual const CPrimVector *getPrimVector () const = 0; + virtual CPrimVector *getPrimVector () = 0; + + // Make a copy + virtual IPrimitive *copy () const = 0; + + // used for fast binary save/load (exploitation mode) + void serial(NLMISC::IStream &f); + + // shortcut to getPropertyByName("name", ret); return ret; + std::string getName() const; + + const std::string &getUnparsedProperties() const; + void setUnparsedProperties(const std::string &unparsedProperties) const; + +private: + + // callback called just after the node is attach under a parent + virtual void onLinkToParent() {} + // callback called just before the node is removed from it's parent + virtual void onUnlinkFromParent() {} + + /// Callback called just after an ancestor is linked + virtual void onBranchLink() {} + /// Callback called just before an ancestor is unlinked + virtual void onBranchUnlink() {} + + /// Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading + virtual void onModifyPrimitive(CPrimitives &/* primitives */) const {} + + // internal recusive call + void branchLink(); + void branchUnlink(); + + // Update child Id + void updateChildId (uint index); + + // Child id + uint32 _ChildId; + + // Parent + IPrimitive *_Parent; + + // Children + std::vector _Children; + + // Single properties + std::map _Properties; + + // Editor specific properties (unparsed) + mutable std::string _UnparsedProperties; + + +#ifdef NLLIGO_DEBUG + std::string _DebugClassName; + std::string _DebugPrimitiveName; +#endif + + +}; + +// *************************************************************************** + +// Simple primitive node +class CPrimNode : public IPrimitive +{ +public: + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimNode) + +protected: + + // void operator= (const CPrimNode &node); + + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + +// *************************************************************************** + +class CPrimPoint : public IPrimitive +{ + +public: + + CPrimPoint () + { + Angle = 0; + } + + + CPrimVector Point; + float Angle; // Angle on OZ, CCW + +public: + + void serial (NLMISC::IStream &f); + + // void operator= (const CPrimPoint &node); + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimPoint); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** +class CPrimPath : public IPrimitive +{ + +public: + + std::vector VPoints; + +public: + + void serial (NLMISC::IStream &f); + + // void operator= (const CPrimPath &node); + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimPath); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** + +class CPrimZone : public IPrimitive +{ + +public: + + std::vector VPoints; + + static float getSegmentDist(const NLMISC::CVector v, const NLMISC::CVector &p1, const NLMISC::CVector &p2, NLMISC::CVector &nearPos); + +public: + + bool contains (const NLMISC::CVector &v) const { return CPrimZone::contains(v, VPoints); } + bool contains(const NLMISC::CVector &v, float &distance, NLMISC::CVector &nearPos, bool isPath) const { return CPrimZone::contains(v, VPoints, distance, nearPos, isPath); } + + // void operator= (const CPrimZone &node); + + void serial (NLMISC::IStream &f); + + // Returns true if the vector v is inside of the patatoid + static bool contains (const NLMISC::CVector &v, const std::vector &points); + // Returns true if the vector v is inside of the patatoid and set the distance of the nearest segment and the position of the nearest point. + static bool contains (const NLMISC::CVector &v, const std::vector &points, float &distance, NLMISC::CVector &nearPos, bool isPath); + // Returns true if the vector v is inside of the patatoid + static bool contains (const NLMISC::CVector &v, const std::vector &points); + // Returns true if the vector v is inside of the patatoid and set the distance of the nearest segment and the position of the nearest point. + static bool contains (const NLMISC::CVector &v, const std::vector &points, float &distance, NLMISC::CVector &nearPos, bool isPath); + + /// Returns the barycenter of the zone (warning, it may be outside of the zone if it is not convex). Returns CVector::Null if there is no vertex. + NLMISC::CVector getBarycentre() const; + + /// Returns the smallest axis-aligned box containing the zone (z is always set to 0) + void getAABox( NLMISC::CVector& cornerMin, NLMISC::CVector& cornerMax ) const; + + /// Return the area of the axis-aligned box containing the zone + float getAreaOfAABox() const; + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimZone); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** + +/** This primitive type is used to handle unique alias across a primitive file. + * Usage of this primitive imply the setting of the appropriate 'ligo context' + * before reading or copy/pasting alias. +*/ +class CPrimAlias : public IPrimitive +{ + friend class CPrimitives; + + /// The 'dynamic' part of the alias + uint32 _Alias; + /// The primitive container + class CPrimitives *_Container; + + // Needed overloads (not used) + virtual uint getNumVector () const + { + return 0; + }; + virtual const CPrimVector *getPrimVector () const + { + return NULL; + } + virtual CPrimVector *getPrimVector () + { + return NULL; + } + + + virtual void onBranchLink(); + // callback called just before the node is removed from it's parent + virtual void onBranchUnlink(); + + void regenAlias(); + +public: + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimAlias); + + // private default constructor + CPrimAlias(); + // copy constructor needed + CPrimAlias(const CPrimAlias &other); + + ~CPrimAlias(); + + // return the dynamic part of the alias + uint32 getAlias() const; + + // Return the full alias, merge of the static and dynamic part + uint32 getFullAlias() const; + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; + // Create a copy of this primitive + virtual IPrimitive *copy () const; + // serial for binary save + virtual void serial (NLMISC::IStream &f); + +}; + +// *************************************************************************** + +/* +This class is deprecated. +*/ +class CPrimRegion +{ + +public: + + std::string Name; + std::vector VPoints; + std::vector VZones; + std::vector VPaths; + + std::vector VHidePoints; + std::vector VHideZones; + std::vector VHidePaths; + +public: + + void serial (NLMISC::IStream &f); +}; + +// *************************************************************************** + +/** + * This class is a ligo primitives set + */ +class CPrimitives +{ +public: + + CPrimitives (); + CPrimitives (const CPrimitives &other); + ~CPrimitives (); + + // Operator copy + CPrimitives& operator= (const CPrimitives &other); + + // Convert from old format to the new one + void convert (const CPrimRegion ®ion); + + // Read the primitive + bool read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &config); + + // Write the primitive + void write (xmlDocPtr xmlNode, const char *filename) const; + + // Write the primitive + void write (xmlNodePtr root, const char *filename) const; + + // serial the primitive. Used for binary files. + void serial(NLMISC::IStream &f); + + // Root primitive hierarchy + CPrimNode *RootNode; + + // get the static alias part for this primitive + uint32 getAliasStaticPart(); + + // set the static alias part for this primitive + void setAliasStaticPart(uint32 staticPart); + + // Build an alias by combining the static and dynamic part + uint32 buildFullAlias(uint32 dynamicPart); + + // Generate a new unique alias (dynamic part only) + uint32 genAlias(IPrimitive *prim, uint32 preferedAlias = 0); + // Reserve an alias and store it in the used alias list (dynamic part only) +// void reserveAlias(uint32 dynamicAlias); + // Remove an alias from the list of alias in use (dynamic part only) + void releaseAlias(IPrimitive *prim, uint32 dynamicAlias); + + // Force the assignation of the specified alias the the primitive. If another primitive + // already hold the alias, this other primitive is assigned a new alias. + void forceAlias(CPrimAlias *prim, uint32 alias); + + // get the last generated alias value (for debug only) + uint32 getLastGeneratedAlias(); + + // Return the primitive indexed by the given alias (ie, it doesn't return the alias primitive, but its first parent) + IPrimitive *getPrimitiveByAlias(uint32 primAlias); + + // Build the complete list of indexed primitive (ie all primitive that have a primalias child) + void buildPrimitiveWithAliasList(std::map &result); + + +private: + // Conversion internal methods + void convertAddPrimitive (IPrimitive *child, const IPrimitive *prim, bool hidden); + void convertPrimitive (const IPrimitive *prim, bool hidden); + + /// Optional context information + CLigoConfig *_LigoConfig; + /// Static part alias mapping (can be 0 if no mapping is defined) + uint32 _AliasStaticPart; + /// Last generated Alias, used to compute the next alias + uint32 _LastGeneratedAlias; + /// List of alias in use in the primitive (dynamic part only) + std::map _AliasInUse; + // Store the filename + // This allows to retrieve the static alias when reloading from binary file + std::string _Filename; +}; + +// *************************************************************************** + +/** Singleton to manage special loading feature related to + * unique alias assignment + */ +class CPrimitiveContext +{ + static CPrimitiveContext *_Instance; + + // private ctor + CPrimitiveContext(); +public: + + // get the singleton reference + static CPrimitiveContext &instance() + { + if (!_Instance) + { + _Instance = new CPrimitiveContext; + } + + return *_Instance; + } + + /// The current ligo configuration file. + CLigoConfig *CurrentLigoConfig; + /// The current primitives container. + CPrimitives *CurrentPrimitive; + +}; + + +} // namespace NLLIGO + +#endif // __PRIMITIVE_H__ + diff --git a/code/nel/include/nel/ligo/primitive.h.LOCAL.4924.h b/code/nel/include/nel/ligo/primitive.h.LOCAL.4924.h new file mode 100644 index 000000000..c5aa26b02 --- /dev/null +++ b/code/nel/include/nel/ligo/primitive.h.LOCAL.4924.h @@ -0,0 +1,786 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef __PRIMITIVE_H__ +#define __PRIMITIVE_H__ + +#include "nel/misc/vector.h" +#include "nel/misc/rgba.h" + +// Forward declarations for libxml2 +typedef struct _xmlNode xmlNode; +typedef xmlNode *xmlNodePtr; + +typedef struct _xmlDoc xmlDoc; +typedef xmlDoc *xmlDocPtr; + + +#include + +namespace NLLIGO +{ + +#ifdef NL_DEBUG +# define NLLIGO_DEBUG +#endif + + +/** + * Ligo primitives are used to add logical geometrical gameplay information. + * Ligo primitives are NODES, POINTS, PATHES or ZONES. + * Ligo primitives have a CLASS. + * + * The primitive class defines the properties attached to the primitive + * The primitive class are defined in the XML file specified in the LigoClass field of the CLigoConfig class. + */ + +class CPrimitives; +class CLigoConfig; + +// *************************************************************************** + +void Register (); + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + */ +class IProperty : public NLMISC::IStreamable +{ +public: + IProperty () + { + Default = false; + } + + // This property is set to default + bool Default; + // Force class to be polymorphic + virtual void foo () const = 0; +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a simple string + */ +class CPropertyString : public IProperty +{ +public: + CPropertyString () {} + CPropertyString (const char *str); + CPropertyString (const std::string &str); + CPropertyString (const char *str, bool _default); + virtual ~CPropertyString () {} + std::string String; + + NLMISC_DECLARE_CLASS (CPropertyString) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serial(String); + } + + // Force class to be polymorphic + virtual void foo () const {} +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a string array + */ +class CPropertyStringArray : public IProperty +{ +public: + CPropertyStringArray () {} + virtual ~CPropertyStringArray () {} + CPropertyStringArray (const std::vector &stringArray); + CPropertyStringArray (const std::vector &stringArray, bool _default); + std::vector StringArray; + + NLMISC_DECLARE_CLASS (CPropertyStringArray) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serialCont(StringArray); + } + // Force class to be polymorphic + virtual void foo () const {} +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a string array + */ +class CPropertyColor : public IProperty +{ +public: + NLMISC::CRGBA Color; + + NLMISC_DECLARE_CLASS (CPropertyColor) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serial(Color); + } + // Force class to be polymorphic + virtual void foo () const {} + + // ctors + CPropertyColor() {} + CPropertyColor(NLMISC::CRGBA col) : Color(col) {} +}; + +// *************************************************************************** + +class CPrimVector : public NLMISC::CVector +{ +public: + CPrimVector () + { + Selected = false; + } + CPrimVector (const NLMISC::CVector &v) + { + CVector::operator= (v); + Selected = false; + } + + void serial(NLMISC::IStream &f) + { + CVector::serial(f); + f.serial(Selected); + } + + bool Selected; +}; + +// *************************************************************************** + +/* + * This class is the base class for ligo primitive. + * + * Provide access to common properties. + * Provide access to the primitive hierachy + */ +class IPrimitive : public NLMISC::IStreamable +{ + friend class CPrimitives; +public: + + // Deprecated +// std::string Layer; + // Deprecated +// std::string Name; + + // Expended in the tree view +// bool Expanded; + + enum + { + NotAnArray, + AtTheEnd = 0xffffffff, + }; + + /// \name Hierarchy + IPrimitive (); + + virtual ~IPrimitive (); + + IPrimitive (const IPrimitive &node); + + virtual void operator= (const IPrimitive &node); + + /** Get the children primitive count */ + uint getNumChildren () const + { + return (uint)_Children.size (); + } + + /** Get a child primitive */ + bool getChild (const IPrimitive *&result, uint childId) const; + + /** Get a child primitive */ + bool getChild (IPrimitive *&result, uint childId); + + /** Get the parent primitive */ + IPrimitive *getParent () + { + return _Parent; + } + const IPrimitive *getParent () const + { + return _Parent; + } + + /** Get the primitive relative to this and the given path */ + const IPrimitive *getPrimitive (const std::string &absoluteOrRelativePath) const; + + /** Get the id of the child, return 0xffffffff if not found */ + bool getChildId (uint &childId, const IPrimitive *child) const; + + /** Remove and delete a child primitive */ + bool removeChild (IPrimitive *child); + + /** Remove and delete a child primitive */ + bool removeChild (uint childId); + + /// Remove the child primitive from the children list, don't delete it + bool unlinkChild(IPrimitive *child); + + /** Remove and delete all children primitives */ + void removeChildren (); + + /** + * Insert a child primitive before the index. + * The pointer will be deleted by the parent primitive using the ::delete operator. + * return false if the index is invalid + */ + bool insertChild (IPrimitive *primitive, uint index = AtTheEnd); + + /// \name Properties + + /** + * Get a num properties + **/ + uint getNumProperty () const; + + /** + * Get a properties by its index + * This method (iterate a list) is slower than getPropertyByName (look up in a map). + **/ + bool getProperty (uint index, std::string &property_name, const IProperty *&result) const; + + /** + * Get a properties by its index + * This method (iterate a list) is slower than getPropertyByName (look up in a map). + **/ + bool getProperty (uint index, std::string &property_name, IProperty *&result); + + /** Check the existence of a named property */ + bool checkProperty(const std::string &property_name) const; + + /** + * Add a property + * 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); + + /** + * Get a property with its name + **/ + bool getPropertyByName (const char *property_name, const IProperty *&result) const; + + /** + * Get a property with its name + **/ + bool getPropertyByName (const char *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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * Remove a property + * This is method (iterate a list) is slower than removePropertyByName (look up in a map). + **/ + bool removeProperty (uint index); + + /** + * Remove a property by its name + **/ + bool removePropertyByName (const char *property_name); + + /** + * Remove all the properties + **/ + void removeProperties (); + + /* Init default primitive's parameters + * + * This method will add all the properties declared in the primitive class and create default properties. + */ + void initDefaultValues (CLigoConfig &config); + + // Read the primitive, calls initDefaultValue (CLigoConfig &config) + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; + + // Get the vertices + virtual uint getNumVector () const = 0; + virtual const CPrimVector *getPrimVector () const = 0; + virtual CPrimVector *getPrimVector () = 0; + + // Make a copy + virtual IPrimitive *copy () const = 0; + + // used for fast binary save/load (exploitation mode) + void serial(NLMISC::IStream &f); + + // shortcut to getPropertyByName("name", ret); return ret; + std::string getName() const; + + const std::string &getUnparsedProperties() const; + void setUnparsedProperties(const std::string &unparsedProperties) const; + +private: + + // callback called just after the node is attach under a parent + virtual void onLinkToParent() {} + // callback called just before the node is removed from it's parent + virtual void onUnlinkFromParent() {} + + /// Callback called just after an ancestor is linked + virtual void onBranchLink() {} + /// Callback called just before an ancestor is unlinked + virtual void onBranchUnlink() {} + + /// Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading + virtual void onModifyPrimitive(CPrimitives &/* primitives */) const {} + + // internal recusive call + void branchLink(); + void branchUnlink(); + + // Update child Id + void updateChildId (uint index); + + // Child id + uint32 _ChildId; + + // Parent + IPrimitive *_Parent; + + // Children + std::vector _Children; + + // Single properties + std::map _Properties; + + // Editor specific properties (unparsed) + mutable std::string _UnparsedProperties; + + +#ifdef NLLIGO_DEBUG + std::string _DebugClassName; + std::string _DebugPrimitiveName; +#endif + + +}; + +// *************************************************************************** + +// Simple primitive node +class CPrimNode : public IPrimitive +{ +public: + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimNode) + +protected: + + // void operator= (const CPrimNode &node); + + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + +// *************************************************************************** + +class CPrimPoint : public IPrimitive +{ + +public: + + CPrimPoint () + { + Angle = 0; + } + + + CPrimVector Point; + float Angle; // Angle on OZ, CCW + +public: + + void serial (NLMISC::IStream &f); + + // void operator= (const CPrimPoint &node); + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimPoint); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** +class CPrimPath : public IPrimitive +{ + +public: + + std::vector VPoints; + +public: + + void serial (NLMISC::IStream &f); + + // void operator= (const CPrimPath &node); + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimPath); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** + +class CPrimZone : public IPrimitive +{ + +public: + + std::vector VPoints; + + static float getSegmentDist(const NLMISC::CVector v, const NLMISC::CVector &p1, const NLMISC::CVector &p2, NLMISC::CVector &nearPos); + +public: + + bool contains (const NLMISC::CVector &v) const { return CPrimZone::contains(v, VPoints); } + bool contains(const NLMISC::CVector &v, float &distance, NLMISC::CVector &nearPos, bool isPath) const { return CPrimZone::contains(v, VPoints, distance, nearPos, isPath); } + + // void operator= (const CPrimZone &node); + + void serial (NLMISC::IStream &f); + + // Returns true if the vector v is inside of the patatoid + static bool contains (const NLMISC::CVector &v, const std::vector &points); + // Returns true if the vector v is inside of the patatoid and set the distance of the nearest segment and the position of the nearest point. + static bool contains (const NLMISC::CVector &v, const std::vector &points, float &distance, NLMISC::CVector &nearPos, bool isPath); + // Returns true if the vector v is inside of the patatoid + static bool contains (const NLMISC::CVector &v, const std::vector &points); + // Returns true if the vector v is inside of the patatoid and set the distance of the nearest segment and the position of the nearest point. + static bool contains (const NLMISC::CVector &v, const std::vector &points, float &distance, NLMISC::CVector &nearPos, bool isPath); + + /// Returns the barycenter of the zone (warning, it may be outside of the zone if it is not convex). Returns CVector::Null if there is no vertex. + NLMISC::CVector getBarycentre() const; + + /// Returns the smallest axis-aligned box containing the zone (z is always set to 0) + void getAABox( NLMISC::CVector& cornerMin, NLMISC::CVector& cornerMax ) const; + + /// Return the area of the axis-aligned box containing the zone + float getAreaOfAABox() const; + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimZone); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** + +/** This primitive type is used to handle unique alias across a primitive file. + * Usage of this primitive imply the setting of the appropriate 'ligo context' + * before reading or copy/pasting alias. +*/ +class CPrimAlias : public IPrimitive +{ + friend class CPrimitives; + + /// The 'dynamic' part of the alias + uint32 _Alias; + /// The primitive container + class CPrimitives *_Container; + + // Needed overloads (not used) + virtual uint getNumVector () const + { + return 0; + }; + virtual const CPrimVector *getPrimVector () const + { + return NULL; + } + virtual CPrimVector *getPrimVector () + { + return NULL; + } + + + virtual void onBranchLink(); + // callback called just before the node is removed from it's parent + virtual void onBranchUnlink(); + + void regenAlias(); + +public: + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimAlias); + + // private default constructor + CPrimAlias(); + // copy constructor needed + CPrimAlias(const CPrimAlias &other); + + ~CPrimAlias(); + + // return the dynamic part of the alias + uint32 getAlias() const; + + // Return the full alias, merge of the static and dynamic part + uint32 getFullAlias() const; + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const char *filename) const; + // Create a copy of this primitive + virtual IPrimitive *copy () const; + // serial for binary save + virtual void serial (NLMISC::IStream &f); + +}; + +// *************************************************************************** + +/* +This class is deprecated. +*/ +class CPrimRegion +{ + +public: + + std::string Name; + std::vector VPoints; + std::vector VZones; + std::vector VPaths; + + std::vector VHidePoints; + std::vector VHideZones; + std::vector VHidePaths; + +public: + + void serial (NLMISC::IStream &f); +}; + +// *************************************************************************** + +/** + * This class is a ligo primitives set + */ +class CPrimitives +{ +public: + + CPrimitives (); + CPrimitives (const CPrimitives &other); + ~CPrimitives (); + + // Operator copy + CPrimitives& operator= (const CPrimitives &other); + + // Convert from old format to the new one + void convert (const CPrimRegion ®ion); + + // Read the primitive + bool read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &config); + + // Write the primitive + void write (xmlDocPtr xmlNode, const char *filename) const; + + // Write the primitive + void write (xmlNodePtr root, const char *filename) const; + + // serial the primitive. Used for binary files. + void serial(NLMISC::IStream &f); + + // Root primitive hierarchy + CPrimNode *RootNode; + + // get the static alias part for this primitive + uint32 getAliasStaticPart(); + + // set the static alias part for this primitive + void setAliasStaticPart(uint32 staticPart); + + // Build an alias by combining the static and dynamic part + uint32 buildFullAlias(uint32 dynamicPart); + + // Generate a new unique alias (dynamic part only) + uint32 genAlias(IPrimitive *prim, uint32 preferedAlias = 0); + // Reserve an alias and store it in the used alias list (dynamic part only) +// void reserveAlias(uint32 dynamicAlias); + // Remove an alias from the list of alias in use (dynamic part only) + void releaseAlias(IPrimitive *prim, uint32 dynamicAlias); + + // Force the assignation of the specified alias to the primitive. If another primitive + // already hold the alias, this other primitive is assigned a new alias. + void forceAlias(CPrimAlias *prim, uint32 alias); + + // get the last generated alias value (for debug only) + uint32 getLastGeneratedAlias(); + + // Return the primitive indexed by the given alias (ie, it doesn't return the alias primitive, but its first parent) + IPrimitive *getPrimitiveByAlias(uint32 primAlias); + + // Build the complete list of indexed primitive (ie all primitive that have a primalias child) + void buildPrimitiveWithAliasList(std::map &result); + + +private: + // Conversion internal methods + void convertAddPrimitive (IPrimitive *child, const IPrimitive *prim, bool hidden); + void convertPrimitive (const IPrimitive *prim, bool hidden); + + /// Optional context information + CLigoConfig *_LigoConfig; + /// Static part alias mapping (can be 0 if no mapping is defined) + uint32 _AliasStaticPart; + /// Last generated Alias, used to compute the next alias + uint32 _LastGeneratedAlias; + /// List of alias in use in the primitive (dynamic part only) + std::map _AliasInUse; + // Store the filename + // This allows to retrieve the static alias when reloading from binary file + std::string _Filename; +}; + +// *************************************************************************** + +/** Singleton to manage special loading feature related to + * unique alias assignment + */ +class CPrimitiveContext +{ + static CPrimitiveContext *_Instance; + + // private ctor + CPrimitiveContext(); +public: + + // get the singleton reference + static CPrimitiveContext &instance() + { + if (!_Instance) + { + _Instance = new CPrimitiveContext; + } + + return *_Instance; + } + + /// The current ligo configuration file. + CLigoConfig *CurrentLigoConfig; + /// The current primitives container. + CPrimitives *CurrentPrimitive; + +}; + + +} // namespace NLLIGO + +#endif // __PRIMITIVE_H__ + diff --git a/code/nel/include/nel/ligo/primitive.h.REMOTE.4924.h b/code/nel/include/nel/ligo/primitive.h.REMOTE.4924.h new file mode 100644 index 000000000..d964ac125 --- /dev/null +++ b/code/nel/include/nel/ligo/primitive.h.REMOTE.4924.h @@ -0,0 +1,785 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef __PRIMITIVE_H__ +#define __PRIMITIVE_H__ + +#include "nel/misc/vector.h" +#include "nel/misc/rgba.h" + +// Forward declarations for libxml2 +typedef struct _xmlNode xmlNode; +typedef xmlNode *xmlNodePtr; + +typedef struct _xmlDoc xmlDoc; +typedef xmlDoc *xmlDocPtr; + + +#include + +namespace NLLIGO +{ + +#ifdef NL_DEBUG +# define NLLIGO_DEBUG +#endif + + +/** + * Ligo primitives are used to add logical geometrical gameplay information. + * Ligo primitives are NODES, POINTS, PATHES or ZONES. + * Ligo primitives have a CLASS. + * + * The primitive class defines the properties attached to the primitive + * The primitive class are defined in the XML file specified in the LigoClass field of the CLigoConfig class. + */ + +class CPrimitives; +class CLigoConfig; + +// *************************************************************************** + +void Register (); + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + */ +class IProperty : public NLMISC::IStreamable +{ +public: + IProperty () + { + Default = false; + } + + // This property is set to default + bool Default; + // Force class to be polymorphic + virtual void foo () const = 0; +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a simple string + */ +class CPropertyString : public IProperty +{ +public: + CPropertyString () {} + CPropertyString (const std::string &str); + CPropertyString (const std::string &str, bool _default); + virtual ~CPropertyString () {} + std::string String; + + NLMISC_DECLARE_CLASS (CPropertyString) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serial(String); + } + + // Force class to be polymorphic + virtual void foo () const {} +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a string array + */ +class CPropertyStringArray : public IProperty +{ +public: + CPropertyStringArray () {} + virtual ~CPropertyStringArray () {} + CPropertyStringArray (const std::vector &stringArray); + CPropertyStringArray (const std::vector &stringArray, bool _default); + std::vector StringArray; + + NLMISC_DECLARE_CLASS (CPropertyStringArray) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serialCont(StringArray); + } + // Force class to be polymorphic + virtual void foo () const {} +}; + +// *************************************************************************** + +/* + * This class is a property class for ligo primitive. + * This is a string array + */ +class CPropertyColor : public IProperty +{ +public: + NLMISC::CRGBA Color; + + NLMISC_DECLARE_CLASS (CPropertyColor) + + virtual void serial(NLMISC::IStream &f) + { + f.serial(Default); + f.serial(Color); + } + // Force class to be polymorphic + virtual void foo () const {} + + // ctors + CPropertyColor() {} + CPropertyColor(NLMISC::CRGBA col) : Color(col) {} +}; + +// *************************************************************************** + +class CPrimVector : public NLMISC::CVector +{ +public: + CPrimVector () + { + Selected = false; + } + CPrimVector (const NLMISC::CVector &v) + { + CVector::operator= (v); + Selected = false; + } + + void serial(NLMISC::IStream &f) + { + CVector::serial(f); + f.serial(Selected); + } + + bool Selected; +}; + +// *************************************************************************** + +/* + * This class is the base class for ligo primitive. + * + * Provide access to common properties. + * Provide access to the primitive hierachy + */ +class IPrimitive : public NLMISC::IStreamable +{ + friend class CPrimitives; +public: + + // Deprecated +// std::string Layer; + // Deprecated +// std::string Name; + + // Expended in the tree view +// bool Expanded; + + enum + { + NotAnArray, + AtTheEnd = 0xffffffff, + }; + + /// \name Hierarchy + IPrimitive (); + + virtual ~IPrimitive (); + + IPrimitive (const IPrimitive &node); + + virtual void operator= (const IPrimitive &node); + + /** Get the children primitive count */ + uint getNumChildren () const + { + return (uint)_Children.size (); + } + + /** Get a child primitive */ + bool getChild (const IPrimitive *&result, uint childId) const; + + /** Get a child primitive */ + bool getChild (IPrimitive *&result, uint childId); + + /** Get the parent primitive */ + IPrimitive *getParent () + { + return _Parent; + } + const IPrimitive *getParent () const + { + return _Parent; + } + + /** Get the primitive relative to this and the given path */ + const IPrimitive *getPrimitive (const std::string &absoluteOrRelativePath) const; + + /** Get the id of the child, return 0xffffffff if not found */ + bool getChildId (uint &childId, const IPrimitive *child) const; + + /** Remove and delete a child primitive */ + bool removeChild (IPrimitive *child); + + /** Remove and delete a child primitive */ + bool removeChild (uint childId); + + /// Remove the child primitive from the children list, don't delete it + bool unlinkChild(IPrimitive *child); + + /** Remove and delete all children primitives */ + void removeChildren (); + + /** + * Insert a child primitive before the index. + * The pointer will be deleted by the parent primitive using the ::delete operator. + * return false if the index is invalid + */ + bool insertChild (IPrimitive *primitive, uint index = AtTheEnd); + + /// \name Properties + + /** + * Get a num properties + **/ + uint getNumProperty () const; + + /** + * Get a properties by its index + * This method (iterate a list) is slower than getPropertyByName (look up in a map). + **/ + bool getProperty (uint index, std::string &property_name, const IProperty *&result) const; + + /** + * Get a properties by its index + * This method (iterate a list) is slower than getPropertyByName (look up in a map). + **/ + bool getProperty (uint index, std::string &property_name, IProperty *&result); + + /** Check the existence of a named property */ + bool checkProperty(const std::string &property_name) const; + + /** + * Add a property + * 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 std::string &property_name, IProperty *result); + + /** + * Get a property with its name + **/ + bool getPropertyByName (const std::string &property_name, const IProperty *&result) const; + + /** + * Get a property with its name + **/ + 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 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 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 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 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 std::string &property_name, NLMISC::CRGBA &result) const; + + /** + * Remove a property + * This is method (iterate a list) is slower than removePropertyByName (look up in a map). + **/ + bool removeProperty (uint index); + + /** + * Remove a property by its name + **/ + bool removePropertyByName (const std::string &property_name); + + /** + * Remove all the properties + **/ + void removeProperties (); + + /* Init default primitive's parameters + * + * This method will add all the properties declared in the primitive class and create default properties. + */ + void initDefaultValues (CLigoConfig &config); + + // Read the primitive, calls initDefaultValue (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 std::string &property_name) const; + + // Get the vertices + virtual uint getNumVector () const = 0; + virtual const CPrimVector *getPrimVector () const = 0; + virtual CPrimVector *getPrimVector () = 0; + + // Make a copy + virtual IPrimitive *copy () const = 0; + + // used for fast binary save/load (exploitation mode) + void serial(NLMISC::IStream &f); + + // shortcut to getPropertyByName("name", ret); return ret; + std::string getName() const; + + const std::string &getUnparsedProperties() const; + void setUnparsedProperties(const std::string &unparsedProperties) const; + +private: + + // callback called just after the node is attach under a parent + virtual void onLinkToParent() {} + // callback called just before the node is removed from it's parent + virtual void onUnlinkFromParent() {} + + /// Callback called just after an ancestor is linked + virtual void onBranchLink() {} + /// Callback called just before an ancestor is unlinked + virtual void onBranchUnlink() {} + + /// Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading + virtual void onModifyPrimitive(CPrimitives &/* primitives */) const {} + + // internal recusive call + void branchLink(); + void branchUnlink(); + + // Update child Id + void updateChildId (uint index); + + // Child id + uint32 _ChildId; + + // Parent + IPrimitive *_Parent; + + // Children + std::vector _Children; + + // Single properties + std::map _Properties; + + // Editor specific properties (unparsed) + mutable std::string _UnparsedProperties; + + +#ifdef NLLIGO_DEBUG + std::string _DebugClassName; + std::string _DebugPrimitiveName; +#endif + + +}; + +// *************************************************************************** + +// Simple primitive node +class CPrimNode : public IPrimitive +{ +public: + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimNode) + +protected: + + // void operator= (const CPrimNode &node); + + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + +// *************************************************************************** + +class CPrimPoint : public IPrimitive +{ + +public: + + CPrimPoint () + { + Angle = 0; + } + + + CPrimVector Point; + float Angle; // Angle on OZ, CCW + +public: + + void serial (NLMISC::IStream &f); + + // void operator= (const CPrimPoint &node); + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimPoint); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** +class CPrimPath : public IPrimitive +{ + +public: + + std::vector VPoints; + +public: + + void serial (NLMISC::IStream &f); + + // void operator= (const CPrimPath &node); + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimPath); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** + +class CPrimZone : public IPrimitive +{ + +public: + + std::vector VPoints; + + static float getSegmentDist(const NLMISC::CVector v, const NLMISC::CVector &p1, const NLMISC::CVector &p2, NLMISC::CVector &nearPos); + +public: + + bool contains (const NLMISC::CVector &v) const { return CPrimZone::contains(v, VPoints); } + bool contains(const NLMISC::CVector &v, float &distance, NLMISC::CVector &nearPos, bool isPath) const { return CPrimZone::contains(v, VPoints, distance, nearPos, isPath); } + + // void operator= (const CPrimZone &node); + + void serial (NLMISC::IStream &f); + + // Returns true if the vector v is inside of the patatoid + static bool contains (const NLMISC::CVector &v, const std::vector &points); + // Returns true if the vector v is inside of the patatoid and set the distance of the nearest segment and the position of the nearest point. + static bool contains (const NLMISC::CVector &v, const std::vector &points, float &distance, NLMISC::CVector &nearPos, bool isPath); + // Returns true if the vector v is inside of the patatoid + static bool contains (const NLMISC::CVector &v, const std::vector &points); + // Returns true if the vector v is inside of the patatoid and set the distance of the nearest segment and the position of the nearest point. + static bool contains (const NLMISC::CVector &v, const std::vector &points, float &distance, NLMISC::CVector &nearPos, bool isPath); + + /// Returns the barycenter of the zone (warning, it may be outside of the zone if it is not convex). Returns CVector::Null if there is no vertex. + NLMISC::CVector getBarycentre() const; + + /// Returns the smallest axis-aligned box containing the zone (z is always set to 0) + void getAABox( NLMISC::CVector& cornerMin, NLMISC::CVector& cornerMax ) const; + + /// Return the area of the axis-aligned box containing the zone + float getAreaOfAABox() const; + + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimZone); + +protected: + + // Get the vertices + virtual uint getNumVector () const; + virtual const CPrimVector *getPrimVector () const; + virtual CPrimVector *getPrimVector (); + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); + + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; + + // \name From IPrimitive + virtual IPrimitive *copy () const; +}; + + +// *************************************************************************** + +/** This primitive type is used to handle unique alias across a primitive file. + * Usage of this primitive imply the setting of the appropriate 'ligo context' + * before reading or copy/pasting alias. +*/ +class CPrimAlias : public IPrimitive +{ + friend class CPrimitives; + + /// The 'dynamic' part of the alias + uint32 _Alias; + /// The primitive container + class CPrimitives *_Container; + + // Needed overloads (not used) + virtual uint getNumVector () const + { + return 0; + }; + virtual const CPrimVector *getPrimVector () const + { + return NULL; + } + virtual CPrimVector *getPrimVector () + { + return NULL; + } + + + virtual void onBranchLink(); + // callback called just before the node is removed from it's parent + virtual void onBranchUnlink(); + + void regenAlias(); + +public: + // \name From IClassable + NLMISC_DECLARE_CLASS (CPrimAlias); + + // private default constructor + CPrimAlias(); + // copy constructor needed + CPrimAlias(const CPrimAlias &other); + + ~CPrimAlias(); + + // return the dynamic part of the alias + uint32 getAlias() const; + + // Return the full alias, merge of the static and dynamic part + uint32 getFullAlias() const; + + // Read the primitive + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config); + // Write the primitive + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; + // Create a copy of this primitive + virtual IPrimitive *copy () const; + // serial for binary save + virtual void serial (NLMISC::IStream &f); + +}; + +// *************************************************************************** + +/* +This class is deprecated. +*/ +class CPrimRegion +{ + +public: + + std::string Name; + std::vector VPoints; + std::vector VZones; + std::vector VPaths; + + std::vector VHidePoints; + std::vector VHideZones; + std::vector VHidePaths; + +public: + + void serial (NLMISC::IStream &f); +}; + +// *************************************************************************** + +/** + * This class is a ligo primitives set + */ +class CPrimitives +{ +public: + + CPrimitives (); + CPrimitives (const CPrimitives &other); + ~CPrimitives (); + + // Operator copy + CPrimitives& operator= (const CPrimitives &other); + + // Convert from old format to the new one + void convert (const CPrimRegion ®ion); + + // Read the primitive + bool read (xmlNodePtr xmlNode, const std::string &filename, CLigoConfig &config); + + // Write the primitive + void write (xmlDocPtr xmlNode, const std::string &filename) const; + + // Write the primitive + void write (xmlNodePtr root, const std::string &filename) const; + + // serial the primitive. Used for binary files. + void serial(NLMISC::IStream &f); + + // Root primitive hierarchy + CPrimNode *RootNode; + + // get the static alias part for this primitive + uint32 getAliasStaticPart(); + + // set the static alias part for this primitive + void setAliasStaticPart(uint32 staticPart); + + // Build an alias by combining the static and dynamic part + uint32 buildFullAlias(uint32 dynamicPart); + + // Generate a new unique alias (dynamic part only) + uint32 genAlias(IPrimitive *prim, uint32 preferedAlias = 0); + // Reserve an alias and store it in the used alias list (dynamic part only) +// void reserveAlias(uint32 dynamicAlias); + // Remove an alias from the list of alias in use (dynamic part only) + void releaseAlias(IPrimitive *prim, uint32 dynamicAlias); + + // Force the assignation of the specified alias to the primitive. If another primitive + // already hold the alias, this other primitive is assigned a new alias. + void forceAlias(CPrimAlias *prim, uint32 alias); + + // get the last generated alias value (for debug only) + uint32 getLastGeneratedAlias(); + + // Return the primitive indexed by the given alias (ie, it doesn't return the alias primitive, but its first parent) + IPrimitive *getPrimitiveByAlias(uint32 primAlias); + + // Build the complete list of indexed primitive (ie all primitive that have a primalias child) + void buildPrimitiveWithAliasList(std::map &result); + + +private: + // Conversion internal methods + void convertAddPrimitive (IPrimitive *child, const IPrimitive *prim, bool hidden); + void convertPrimitive (const IPrimitive *prim, bool hidden); + + /// Optional context information + CLigoConfig *_LigoConfig; + /// Static part alias mapping (can be 0 if no mapping is defined) + uint32 _AliasStaticPart; + /// Last generated Alias, used to compute the next alias + uint32 _LastGeneratedAlias; + /// List of alias in use in the primitive (dynamic part only) + std::map _AliasInUse; + // Store the filename + // This allows to retrieve the static alias when reloading from binary file + std::string _Filename; +}; + +// *************************************************************************** + +/** Singleton to manage special loading feature related to + * unique alias assignment + */ +class CPrimitiveContext +{ + static CPrimitiveContext *_Instance; + + // private ctor + CPrimitiveContext(); +public: + + // get the singleton reference + static CPrimitiveContext &instance() + { + if (!_Instance) + { + _Instance = new CPrimitiveContext; + } + + return *_Instance; + } + + /// The current ligo configuration file. + CLigoConfig *CurrentLigoConfig; + /// The current primitives container. + CPrimitives *CurrentPrimitive; + +}; + + +} // namespace NLLIGO + +#endif // __PRIMITIVE_H__ + 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 f96cd39b9..7e5994152 100644 --- a/code/nel/include/nel/misc/bitmap.h +++ b/code/nel/include/nel/misc/bitmap.h @@ -636,11 +636,17 @@ public: - /** Get the pixel at the given coorrdinate. + /** Get the pixel at the given coordinate. * Works in RGBA and DXTC modes. * Outside of the bitmap it returns Black (or if mipmap is not found) */ CRGBA getPixelColor(sint x, sint y, uint32 numMipMap = 0) const; + + /** Set the pixel at the given coordinate. + * Works in RGBA mode only. + */ + void setPixelColor(sint x, sint y, CRGBA c, uint32 numMipMap = 0); + /** * Horizontal flip (all the columns are flipped) * Works only with RGBA, and DXTC formats (only if w/h is a power of 2) diff --git a/code/nel/include/nel/misc/block_memory.h b/code/nel/include/nel/misc/block_memory.h index 65fb36c46..912f92d1c 100644 --- a/code/nel/include/nel/misc/block_memory.h +++ b/code/nel/include/nel/misc/block_memory.h @@ -132,7 +132,7 @@ public: } /// delete an element allocated with this manager. dtor is called. NULL is tested. - void free(T* ptr) + void freeBlock(T* ptr) { if(!ptr) return; diff --git a/code/nel/include/nel/misc/cdb_leaf.h b/code/nel/include/nel/misc/cdb_leaf.h index e3df6f8b3..c80ec903a 100644 --- a/code/nel/include/nel/misc/cdb_leaf.h +++ b/code/nel/include/nel/misc/cdb_leaf.h @@ -40,20 +40,20 @@ public: /// Return the value of the property. - inline sint64 getValue64() { return _Property; } + inline sint64 getValue64() const { return _Property; } /// Set the value of the property (set '_Changed' flag with 'true'). void setValue64 (sint64 prop); - inline sint32 getValue32() { return *((sint32*)&_Property); } + inline sint32 getValue32() const { return (sint32)(_Property & 0xffffffff); } void setValue32 (sint32 prop); - inline sint16 getValue16() { return *((sint16*)&_Property); } + inline sint16 getValue16() const { return (sint16)(_Property & 0xffff); } void setValue16 (sint16 prop); - inline sint8 getValue8() { return *((sint8*)&_Property); } + inline sint8 getValue8() const { return (sint8)(_Property & 0xff); } void setValue8 (sint8 prop); - inline bool getValueBool() { return (_Property!=(sint64)0 ); } + inline bool getValueBool() const { return (_Property!=(sint64)0 ); } void setValueBool (bool prop); - inline CRGBA getValueRGBA() + inline CRGBA getValueRGBA() const { CRGBA col; col.R = (uint8)(_Property&0xff); @@ -65,11 +65,11 @@ public: void setValueRGBA (const CRGBA &color); /// Return the value of the property before the database change - inline sint64 getOldValue64() { return _oldProperty; } - inline sint32 getOldValue32() { return *((sint32*)&_oldProperty); } - inline sint16 getOldValue16() { return *((sint16*)&_oldProperty); } - inline sint8 getOldValue8() { return *((sint8*)&_oldProperty); } - inline bool getOldValueBool() { return (_oldProperty!=(sint64)0 ); } + inline sint64 getOldValue64() const { return _oldProperty; } + inline sint32 getOldValue32() const { return (sint32)(_oldProperty & 0xffffffff); } + inline sint16 getOldValue16() const { return (sint16)(_oldProperty & 0xffff); } + inline sint8 getOldValue8() const { return (sint8)(_oldProperty & 0xff); } + inline bool getOldValueBool() const { return (_oldProperty!=(sint64)0 ); } /// Return the type of the property. diff --git a/code/nel/include/nel/misc/co_task.h b/code/nel/include/nel/misc/co_task.h index bfd8f9ef0..80542834e 100644 --- a/code/nel/include/nel/misc/co_task.h +++ b/code/nel/include/nel/misc/co_task.h @@ -201,7 +201,9 @@ namespace NLMISC */ void sleep(uint milliseconds); - + /** Release internal instance. + */ + static void releaseInstance(); }; diff --git a/code/nel/include/nel/misc/common.h b/code/nel/include/nel/misc/common.h index 4ddc88076..4c2b38cca 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) @@ -689,6 +714,25 @@ inline T iavoid0(T x) return x; } +// Helper to convert in memory between types of different sizes +union C64BitsParts +{ + // unsigned + uint64 u64[1]; + uint32 u32[2]; + uint16 u16[4]; + uint8 u8[8]; + + // signed + sint64 i64[1]; + sint32 i32[2]; + sint16 i16[4]; + sint8 i8[8]; + + // floats + double d[1]; + float f[2]; +}; } // NLMISC diff --git a/code/nel/include/nel/misc/contiguous_block_allocator.h b/code/nel/include/nel/misc/contiguous_block_allocator.h index 7a15d296d..43d6fac09 100644 --- a/code/nel/include/nel/misc/contiguous_block_allocator.h +++ b/code/nel/include/nel/misc/contiguous_block_allocator.h @@ -55,7 +55,7 @@ public: // allocated a block of n bytes void *alloc(uint numBytes); // deallocate a block - void free(void *block, uint numBytes); + void freeBlock(void *block, uint numBytes); // compute the total number of bytes allocated since init // NB : freed block are not subtracted from that total !! uint getNumAllocatedBytes() const { return _NumAllocatedBytes; } diff --git a/code/nel/include/nel/misc/debug.h b/code/nel/include/nel/misc/debug.h index 54e22880d..d01c85f1c 100644 --- a/code/nel/include/nel/misc/debug.h +++ b/code/nel/include/nel/misc/debug.h @@ -151,8 +151,8 @@ void setCrashAlreadyReported(bool state); * Note 2 : To show a warning under GCC, use #warning "Your warning here", * see nel/net/net_manager.h for an example on how to use these correctly. */ -#define NL_LOC_MSG __FILE__"("NL_MACRO_TO_STR(__LINE__)") : Message: " -#define NL_LOC_WRN __FILE__"("NL_MACRO_TO_STR(__LINE__)") : Warning Msg: " +#define NL_LOC_MSG __FILE__ "(" NL_MACRO_TO_STR(__LINE__) ") : Message: " +#define NL_LOC_WRN __FILE__ "(" NL_MACRO_TO_STR(__LINE__) ") : Warning Msg: " /** diff --git a/code/nel/include/nel/misc/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/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..6e528964f 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,21 @@ 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 + * \param directory - the directory to which the path is relative to + * \param simplify - if we should simplify or not the path (convert . and .. in path) + * returns the absolute path, or empty if something went wrong. + */ + static std::string makePathAbsolute (const std::string &relativePath, const std::string &directory, bool simplify = false ); + + /** Return if a path is absolute or not. + * \param path - The path + * returns true if path is absolute or false if relative. + */ + static bool isAbsolutePath (const std::string &path); /** 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/module_gateway.h b/code/nel/include/nel/net/module_gateway.h index 27fb2784d..a097f8de0 100644 --- a/code/nel/include/nel/net/module_gateway.h +++ b/code/nel/include/nel/net/module_gateway.h @@ -264,7 +264,7 @@ namespace NLNET /** Send a message to a module. */ - virtual void sendModuleMessage(IModuleProxy *senderProxy, IModuleProxy *addresseeProxy, const NLNET::CMessage &message) =0; + virtual void sendModuleProxyMessage(IModuleProxy *senderProxy, IModuleProxy *addresseeProxy, const NLNET::CMessage &message) =0; /** Send a message to the module plugged in this gateway. * You can override this method to change the dispatching, add filtering, diff --git a/code/nel/include/nel/net/pacs_client.h b/code/nel/include/nel/net/pacs_client.h index f3c6d0426..7cc61deba 100644 --- a/code/nel/include/nel/net/pacs_client.h +++ b/code/nel/include/nel/net/pacs_client.h @@ -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); 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/src/3d/anim_ctrl.cpp b/code/nel/src/3d/anim_ctrl.cpp deleted file mode 100644 index 507d1dc6e..000000000 --- a/code/nel/src/3d/anim_ctrl.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" -#include "nel/3d/anim_ctrl.h" - - -namespace NL3D -{ - - - - -} // NL3D diff --git a/code/nel/src/3d/anim_detail_trav.cpp b/code/nel/src/3d/anim_detail_trav.cpp index dc825b849..563e95da8 100644 --- a/code/nel/src/3d/anim_detail_trav.cpp +++ b/code/nel/src/3d/anim_detail_trav.cpp @@ -26,6 +26,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/animatable.cpp b/code/nel/src/3d/animatable.cpp index c36df64d6..a40a2a0c8 100644 --- a/code/nel/src/3d/animatable.cpp +++ b/code/nel/src/3d/animatable.cpp @@ -19,6 +19,9 @@ #include "nel/3d/animatable.h" #include "nel/3d/channel_mixer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/animated_lightmap.cpp b/code/nel/src/3d/animated_lightmap.cpp index 4493168ed..0c3564969 100644 --- a/code/nel/src/3d/animated_lightmap.cpp +++ b/code/nel/src/3d/animated_lightmap.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/animated_material.cpp b/code/nel/src/3d/animated_material.cpp index dff998863..8e33a3a9f 100644 --- a/code/nel/src/3d/animated_material.cpp +++ b/code/nel/src/3d/animated_material.cpp @@ -21,6 +21,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/animated_morph.cpp b/code/nel/src/3d/animated_morph.cpp index 040fe1484..fcad597f4 100644 --- a/code/nel/src/3d/animated_morph.cpp +++ b/code/nel/src/3d/animated_morph.cpp @@ -21,6 +21,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/animated_value.cpp b/code/nel/src/3d/animated_value.cpp deleted file mode 100644 index e5175b922..000000000 --- a/code/nel/src/3d/animated_value.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/animated_value.h" - - -namespace NL3D -{ - -/* -// Some compilation check: force Visual to compile to template -CAnimatedValueBool atoto1; -CAnimatedValueInt atoto2; -CAnimatedValueFloat atoto3; -CAnimatedValueVector atoto4; -CAnimatedValueString atoto5; -CAnimatedValueQuat atoto6; -CAnimatedValueRGBA atoto7; -*/ - -} // NL3D diff --git a/code/nel/src/3d/animation.cpp b/code/nel/src/3d/animation.cpp index a604d2bde..157ca5427 100644 --- a/code/nel/src/3d/animation.cpp +++ b/code/nel/src/3d/animation.cpp @@ -30,6 +30,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -315,7 +318,7 @@ UAnimation* UAnimation::createAnimation (const char* sPath) NL3D_HAUTO_UI_ANIMATION; // Allocate an animation - std::auto_ptr anim (new CAnimation); + CUniquePtr anim (new CAnimation); // Read it NLMISC::CIFile file; diff --git a/code/nel/src/3d/animation_optimizer.cpp b/code/nel/src/3d/animation_optimizer.cpp index 726086f8b..9205fde39 100644 --- a/code/nel/src/3d/animation_optimizer.cpp +++ b/code/nel/src/3d/animation_optimizer.cpp @@ -29,6 +29,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/animation_playlist.cpp b/code/nel/src/3d/animation_playlist.cpp index 26e84e1e4..336d8d44b 100644 --- a/code/nel/src/3d/animation_playlist.cpp +++ b/code/nel/src/3d/animation_playlist.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/animation_set.cpp b/code/nel/src/3d/animation_set.cpp index 05db8a7be..0b4c096c0 100644 --- a/code/nel/src/3d/animation_set.cpp +++ b/code/nel/src/3d/animation_set.cpp @@ -29,6 +29,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -221,7 +225,7 @@ bool CAnimationSet::loadFromFiles(const std::string &path, bool recurse /* = tru { NLMISC::CIFile iFile; iFile.open(anims[k]); - std::auto_ptr anim(new CAnimation); + CUniquePtr anim(new CAnimation); anim->serial(iFile); addAnimation(NLMISC::CFile::getFilenameWithoutExtension(anims[k]).c_str(), anim.release()); iFile.close(); diff --git a/code/nel/src/3d/animation_set_user.cpp b/code/nel/src/3d/animation_set_user.cpp index 9ad16c46a..c1e83f7f3 100644 --- a/code/nel/src/3d/animation_set_user.cpp +++ b/code/nel/src/3d/animation_set_user.cpp @@ -19,6 +19,9 @@ #include "nel/3d/animation_set_user.h" #include "nel/3d/driver_user.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/animation_time.cpp b/code/nel/src/3d/animation_time.cpp deleted file mode 100644 index 0cda680a6..000000000 --- a/code/nel/src/3d/animation_time.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/animation_time.h" - - -namespace NL3D { - - - -} // NL3D diff --git a/code/nel/src/3d/async_file_manager_3d.cpp b/code/nel/src/3d/async_file_manager_3d.cpp index 9f94b5260..cbb3f5e5d 100644 --- a/code/nel/src/3d/async_file_manager_3d.cpp +++ b/code/nel/src/3d/async_file_manager_3d.cpp @@ -31,6 +31,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/async_texture_block.cpp b/code/nel/src/3d/async_texture_block.cpp deleted file mode 100644 index c0abc4704..000000000 --- a/code/nel/src/3d/async_texture_block.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "std3d.h" -#include "nel/3d/async_texture_block.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/async_texture_manager.cpp b/code/nel/src/3d/async_texture_manager.cpp index a30bd6eb6..a962c9991 100644 --- a/code/nel/src/3d/async_texture_manager.cpp +++ b/code/nel/src/3d/async_texture_manager.cpp @@ -25,6 +25,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/bezier_patch.cpp b/code/nel/src/3d/bezier_patch.cpp index 7181630f6..099a532d2 100644 --- a/code/nel/src/3d/bezier_patch.cpp +++ b/code/nel/src/3d/bezier_patch.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // *************************************************************************** diff --git a/code/nel/src/3d/bloom_effect.cpp b/code/nel/src/3d/bloom_effect.cpp index c468349ac..f515ad50c 100644 --- a/code/nel/src/3d/bloom_effect.cpp +++ b/code/nel/src/3d/bloom_effect.cpp @@ -33,6 +33,10 @@ using namespace NLMISC; using namespace NL3D; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -98,10 +102,6 @@ CBloomEffect::~CBloomEffect() if (_Driver) _Driver->deleteMaterial(_BlurMat); } } -} - -//----------------------------------------------------------------------------------------------------------- - void CBloomEffect::init() { if (!((CDriverUser *)_Driver)->getDriver()->supportBloomEffect()) diff --git a/code/nel/src/3d/bone.cpp b/code/nel/src/3d/bone.cpp index 9adf64fcd..98d26c6ce 100644 --- a/code/nel/src/3d/bone.cpp +++ b/code/nel/src/3d/bone.cpp @@ -20,6 +20,9 @@ #include "nel/3d/anim_ctrl.h" #include "nel/misc/hierarchical_timer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/camera.cpp b/code/nel/src/3d/camera.cpp index b2c02fe2f..012402b74 100644 --- a/code/nel/src/3d/camera.cpp +++ b/code/nel/src/3d/camera.cpp @@ -19,6 +19,9 @@ #include "nel/3d/camera.h" #include "nel/3d/scene.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/camera_col.cpp b/code/nel/src/3d/camera_col.cpp index 538cb1695..7f7e349d3 100644 --- a/code/nel/src/3d/camera_col.cpp +++ b/code/nel/src/3d/camera_col.cpp @@ -22,6 +22,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/channel_mixer.cpp b/code/nel/src/3d/channel_mixer.cpp index 6e7ab7ba7..bd8a4dff5 100644 --- a/code/nel/src/3d/channel_mixer.cpp +++ b/code/nel/src/3d/channel_mixer.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/clip_trav.cpp b/code/nel/src/3d/clip_trav.cpp index b75abe61e..f26c84273 100644 --- a/code/nel/src/3d/clip_trav.cpp +++ b/code/nel/src/3d/clip_trav.cpp @@ -37,6 +37,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -130,7 +133,7 @@ bool CClipTrav::fullSearch (vector& vCluster, const CVector& pos) if (pIG->_ClusterInstances[i]->isIn(pos)) vCluster.push_back (pIG->_ClusterInstances[i]); } - if (vCluster.size() > 0) + if (!vCluster.empty()) return true;*/ return true; diff --git a/code/nel/src/3d/cloud.cpp b/code/nel/src/3d/cloud.cpp index eb53589ce..bfd83ba80 100644 --- a/code/nel/src/3d/cloud.cpp +++ b/code/nel/src/3d/cloud.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/cloud_scape.cpp b/code/nel/src/3d/cloud_scape.cpp index 77d046eec..5c40d89ec 100644 --- a/code/nel/src/3d/cloud_scape.cpp +++ b/code/nel/src/3d/cloud_scape.cpp @@ -23,6 +23,10 @@ // ------------------------------------------------------------------------------------------------ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/cloud_scape_user.cpp b/code/nel/src/3d/cloud_scape_user.cpp index 5570ed7eb..1a18a26fa 100644 --- a/code/nel/src/3d/cloud_scape_user.cpp +++ b/code/nel/src/3d/cloud_scape_user.cpp @@ -22,6 +22,9 @@ #include "nel/3d/cloud_scape.h" #include "nel/3d/scene.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/cluster.cpp b/code/nel/src/3d/cluster.cpp index 76ed153e1..312042364 100644 --- a/code/nel/src/3d/cluster.cpp +++ b/code/nel/src/3d/cluster.cpp @@ -28,6 +28,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -319,7 +323,7 @@ void CCluster::serial (NLMISC::IStream&f) // write the env fx name std::string envFxName = CStringMapper::unmap(_EnvironmentFxId); if (envFxName == "no fx") - envFxName = ""; + envFxName.clear(); f.serial(envFxName); } diff --git a/code/nel/src/3d/coarse_mesh_build.cpp b/code/nel/src/3d/coarse_mesh_build.cpp index 8a712a57f..966f389b4 100644 --- a/code/nel/src/3d/coarse_mesh_build.cpp +++ b/code/nel/src/3d/coarse_mesh_build.cpp @@ -19,9 +19,14 @@ #include "nel/3d/coarse_mesh_build.h" #include "nel/3d/mesh.h" +#include "nel/3d/debug_vb.h" using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/coarse_mesh_manager.cpp b/code/nel/src/3d/coarse_mesh_manager.cpp index f45ca7675..2d4792263 100644 --- a/code/nel/src/3d/coarse_mesh_manager.cpp +++ b/code/nel/src/3d/coarse_mesh_manager.cpp @@ -21,11 +21,17 @@ #include "nel/3d/texture_file.h" #include "nel/misc/hierarchical_timer.h" #include "nel/3d/clip_trav.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/fast_mem.h" using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/computed_string.cpp b/code/nel/src/3d/computed_string.cpp index 1a9fefba5..a8f7743b3 100644 --- a/code/nel/src/3d/computed_string.cpp +++ b/code/nel/src/3d/computed_string.cpp @@ -22,6 +22,7 @@ #include "nel/3d/material.h" #include "nel/3d/frustum.h" #include "nel/3d/viewport.h" +#include "nel/3d/debug_vb.h" #include "nel/misc/smart_ptr.h" #include "nel/misc/debug.h" @@ -31,6 +32,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/cube_grid.cpp b/code/nel/src/3d/cube_grid.cpp deleted file mode 100644 index 2826a087f..000000000 --- a/code/nel/src/3d/cube_grid.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/cube_grid.h" - - -namespace NL3D -{ - -} // NL3D diff --git a/code/nel/src/3d/cube_map_builder.cpp b/code/nel/src/3d/cube_map_builder.cpp index 8d8e016b7..60aec6cdd 100644 --- a/code/nel/src/3d/cube_map_builder.cpp +++ b/code/nel/src/3d/cube_map_builder.cpp @@ -26,6 +26,9 @@ +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -89,8 +92,8 @@ static uint8 *BuildCubeMapTexLuminance(const NLMISC::CVector &start, CTextureCube *BuildCubeMap(sint mapSize, ICubeMapFunctor &f, bool luminanceOnly /* = false*/, const std::string &shareName /* = "" */) { - std::auto_ptr cubeMap(new CTextureCube); - std::auto_ptr faces[6]; + CUniquePtr cubeMap(new CTextureCube); + CUniquePtr faces[6]; /// this gives the start (unormalized normal for each face for u,v = 0, 0) static const NLMISC::CVector start[] = diff --git a/code/nel/src/3d/debug_vb.cpp b/code/nel/src/3d/debug_vb.cpp index 39e01b646..b1aebe6e0 100644 --- a/code/nel/src/3d/debug_vb.cpp +++ b/code/nel/src/3d/debug_vb.cpp @@ -19,6 +19,10 @@ #include "nel/3d/vertex_buffer.h" #include "nel/3d/index_buffer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/deform_2d.cpp b/code/nel/src/3d/deform_2d.cpp index 7a4ffb507..f36f61820 100644 --- a/code/nel/src/3d/deform_2d.cpp +++ b/code/nel/src/3d/deform_2d.cpp @@ -27,6 +27,10 @@ #include "nel/3d/dru.h" #include "nel/3d/material.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/driver.cpp b/code/nel/src/3d/driver.cpp index 3ba0178f2..1b738abb7 100644 --- a/code/nel/src/3d/driver.cpp +++ b/code/nel/src/3d/driver.cpp @@ -28,6 +28,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 887034a9d..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; } } 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 3f2dca9b6..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 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..edd3943ef 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp @@ -28,6 +28,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif //#define NEL_DUMP_UPLOAD_TIME @@ -97,7 +100,7 @@ CTextureDrvInfosGL::~CTextureDrvInfosGL() CDepthStencilFBO::CDepthStencilFBO(CDriverGL *driver, uint width, uint height) { - nldebug("3D: Init shared FBO"); + //nldebug("3D: Init shared FBO"); m_Driver = driver; Width = width; @@ -139,7 +142,7 @@ CDepthStencilFBO::~CDepthStencilFBO() if (DepthFBOId) { - nldebug("3D: Release shared FBO"); + //nldebug("3D: Release shared FBO"); nglDeleteRenderbuffersEXT(1, &DepthFBOId); if (StencilFBOId == DepthFBOId) StencilFBOId = 0; @@ -188,10 +191,10 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex) } nglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, DepthStencilFBO->DepthFBOId); - nldebug("3D: glFramebufferRenderbufferExt(depth:24) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); + //nldebug("3D: glFramebufferRenderbufferExt(depth:24) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); nglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, DepthStencilFBO->StencilFBOId); - nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); + //nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); } // check status diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp index f981ae3ba..bd945c1a1 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp @@ -21,6 +21,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef NL_STATIC diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_vertex.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_vertex.cpp index 39f71d77a..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 4469550b3..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 @@ -473,18 +477,18 @@ 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"); } } @@ -497,8 +501,11 @@ bool CDriverGL::unInit() // restore default X errors handler XSetErrorHandler(NULL); - XCloseDisplay(_dpy); - _dpy = NULL; + if (_dpy) + { + XCloseDisplay(_dpy); + _dpy = NULL; + } #endif // NL_OS_UNIX @@ -2747,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_opengl_view.mm b/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.mm new file mode 100644 index 000000000..e989f94d5 --- /dev/null +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.mm @@ -0,0 +1,152 @@ +// 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 "../stdopengl.h" +#include "../driver_opengl.h" + +#import "cocoa_opengl_view.h" + +static void viewDidResize(NSView* view, CDriverGL* driver) +{ + NSRect rect = [[view superview] frame]; + driver->_CurrentMode.Height = rect.size.height; + driver->_CurrentMode.Width = rect.size.width; +} + +@implementation CocoaOpenGLView + +-(id)initWithFrame:(NSRect)frame +{ + if((self = [super initWithFrame:frame])) + { + _characterStorage = [[NSMutableAttributedString alloc] initWithString:@""]; + _driver = nil; + return self; + } + return nil; +} + +-(void)dealloc +{ + [_characterStorage release]; + [super dealloc]; +} + +-(void)keyDown:(NSEvent*)event +{ +#ifdef NL_MAC_VERSION_10_6_UP + [[self inputContext] handleEvent:event]; +#endif +} + +-(void)setDriver:(CDriverGL*)driver +{ + _driver = driver; +} + +-(void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize +{ + [super resizeWithOldSuperviewSize:oldBoundsSize]; + + if(!_driver) + return; + + viewDidResize(self, _driver); +} + +/******************************************************************************/ +/* NSTextInputClient Protocol */ + +-(BOOL)hasMarkedText +{ + return (_markedRange.location == NSNotFound ? NO : YES); +} + +-(NSRange)markedRange +{ + return _markedRange; +} + +-(NSRange)selectedRange +{ + return NSMakeRange(NSNotFound, 0); +} + +-(void)setMarkedText:(id)aString + selectedRange:(NSRange)newSelection + replacementRange:(NSRange)replacementRange +{ + if(replacementRange.location == NSNotFound) + replacementRange = _markedRange; + + if([aString length] == 0) + { + [_characterStorage deleteCharactersInRange:replacementRange]; + [self unmarkText]; + } + else + { + _markedRange = NSMakeRange(replacementRange.location, [aString length]); + [_characterStorage replaceCharactersInRange:replacementRange + withString:aString]; + } +} + +-(void)unmarkText +{ + _markedRange = NSMakeRange(NSNotFound, 0); + [[self inputContext] discardMarkedText]; +} + +-(NSArray*)validAttributesForMarkedText +{ + return [NSArray arrayWithObjects: + NSMarkedClauseSegmentAttributeName, NSGlyphInfoAttributeName, nil]; +} + +-(NSAttributedString*)attributedSubstringForProposedRange:(NSRange)aRange + actualRange:(NSRangePointer)actualRange +{ + return [_characterStorage attributedSubstringFromRange:aRange]; +} + +-(void)insertText:(id)aString + replacementRange:(NSRange)replacementRange +{ + if(replacementRange.location == NSNotFound) + replacementRange = _markedRange; + + [_characterStorage replaceCharactersInRange:replacementRange + withString:aString]; +} + +-(NSUInteger)characterIndexForPoint:(NSPoint)aPoint +{ + return 0; +} + +-(NSRect)firstRectForCharacterRange:(NSRange)aRange + actualRange:(NSRangePointer)actualRange +{ + return NSMakeRect(0, 0, 0, 0); +} + +-(void)doCommandBySelector:(SEL)aSelector +{ + [super doCommandBySelector:aSelector]; +} + +@end 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..c970e971b 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -33,11 +33,17 @@ #include "nel/3d/water_env_map_user.h" #include "nel/3d/water_pool_manager.h" #include "nel/3d/u_camera.h" +#include "nel/3d/debug_vb.h" +#include "nel/misc/event_emitter.h" #include "nel/misc/hierarchical_timer.h" #include "nel/misc/event_emitter.h" using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/driver_user2.cpp b/code/nel/src/3d/driver_user2.cpp index 1b46ab607..e24391a1c 100644 --- a/code/nel/src/3d/driver_user2.cpp +++ b/code/nel/src/3d/driver_user2.cpp @@ -37,6 +37,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/dru.cpp b/code/nel/src/3d/dru.cpp index fd3e77404..15ccbfe01 100644 --- a/code/nel/src/3d/dru.cpp +++ b/code/nel/src/3d/dru.cpp @@ -46,6 +46,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/event_mouse_listener.cpp b/code/nel/src/3d/event_mouse_listener.cpp index cb9fb142e..d81b2bfd4 100644 --- a/code/nel/src/3d/event_mouse_listener.cpp +++ b/code/nel/src/3d/event_mouse_listener.cpp @@ -24,6 +24,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/fast_ptr_list.cpp b/code/nel/src/3d/fast_ptr_list.cpp index 753824dae..c9cab1069 100644 --- a/code/nel/src/3d/fast_ptr_list.cpp +++ b/code/nel/src/3d/fast_ptr_list.cpp @@ -20,6 +20,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/fasthls_modifier.cpp b/code/nel/src/3d/fasthls_modifier.cpp index 2790e1442..cae414f2c 100644 --- a/code/nel/src/3d/fasthls_modifier.cpp +++ b/code/nel/src/3d/fasthls_modifier.cpp @@ -26,6 +26,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/flare_model.cpp b/code/nel/src/3d/flare_model.cpp index f964a9102..f070bdcec 100644 --- a/code/nel/src/3d/flare_model.cpp +++ b/code/nel/src/3d/flare_model.cpp @@ -26,9 +26,13 @@ #include "nel/3d/occlusion_query.h" #include "nel/3d/mesh.h" #include "nel/3d/viewport.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/common.h" - +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/flare_shape.cpp b/code/nel/src/3d/flare_shape.cpp index a3a1d135f..e8f74dc4e 100644 --- a/code/nel/src/3d/flare_shape.cpp +++ b/code/nel/src/3d/flare_shape.cpp @@ -24,6 +24,9 @@ #include "nel/3d/shape_bank.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/font_generator.cpp b/code/nel/src/3d/font_generator.cpp index ce8048f15..0adf29418 100644 --- a/code/nel/src/3d/font_generator.cpp +++ b/code/nel/src/3d/font_generator.cpp @@ -58,6 +58,10 @@ const char* err_msg; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { FT_Library CFontGenerator::_Library = NULL; diff --git a/code/nel/src/3d/font_manager.cpp b/code/nel/src/3d/font_manager.cpp index 7b503099b..3b77a2100 100644 --- a/code/nel/src/3d/font_manager.cpp +++ b/code/nel/src/3d/font_manager.cpp @@ -32,6 +32,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/frustum.cpp b/code/nel/src/3d/frustum.cpp index 356673a92..36d28ebb0 100644 --- a/code/nel/src/3d/frustum.cpp +++ b/code/nel/src/3d/frustum.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/fxaa.cpp b/code/nel/src/3d/fxaa.cpp index 1eff22501..d37a159ef 100644 --- a/code/nel/src/3d/fxaa.cpp +++ b/code/nel/src/3d/fxaa.cpp @@ -49,11 +49,17 @@ using namespace std; namespace NL3D { namespace { - #include "fxaa_program.h" - } /* anonymous namespace */ +} + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + +namespace NL3D { + CFXAA::CFXAA(NL3D::UDriver *driver) : m_Driver(driver), m_VP(NULL), m_PP(NULL), m_Width(~0), m_Height(~0) { nldebug("3D: Create FXAA"); diff --git a/code/nel/src/3d/geometry_program.cpp b/code/nel/src/3d/geometry_program.cpp index 8f785b6c6..985309a55 100644 --- a/code/nel/src/3d/geometry_program.cpp +++ b/code/nel/src/3d/geometry_program.cpp @@ -27,6 +27,10 @@ #include "nel/3d/driver.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/gpu_program_params.cpp b/code/nel/src/3d/gpu_program_params.cpp index 9e84865be..f7cc6654d 100644 --- a/code/nel/src/3d/gpu_program_params.cpp +++ b/code/nel/src/3d/gpu_program_params.cpp @@ -26,7 +26,6 @@ */ #include "std3d.h" -#include "nel/misc/types_nl.h" #include "nel/3d/gpu_program_params.h" // STL includes @@ -42,16 +41,20 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { +const size_t CGPUProgramParams::s_End = -1; + CGPUProgramParams::CGPUProgramParams() : m_First(s_End), m_Last(s_End) { - } CGPUProgramParams::~CGPUProgramParams() { - } void CGPUProgramParams::copy(CGPUProgramParams *params) diff --git a/code/nel/src/3d/heat_haze.cpp b/code/nel/src/3d/heat_haze.cpp index c42942fe7..03ea4dc06 100644 --- a/code/nel/src/3d/heat_haze.cpp +++ b/code/nel/src/3d/heat_haze.cpp @@ -22,6 +22,10 @@ #include "nel/3d/deform_2d.h" #include "nel/misc/vector_2f.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/height_map.cpp b/code/nel/src/3d/height_map.cpp index 505145376..4236cd15e 100644 --- a/code/nel/src/3d/height_map.cpp +++ b/code/nel/src/3d/height_map.cpp @@ -21,6 +21,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/hls_color_texture.cpp b/code/nel/src/3d/hls_color_texture.cpp index 4afd1c5ea..16766b202 100644 --- a/code/nel/src/3d/hls_color_texture.cpp +++ b/code/nel/src/3d/hls_color_texture.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/hls_texture_bank.cpp b/code/nel/src/3d/hls_texture_bank.cpp index bc7cc7c1f..d7e213cf4 100644 --- a/code/nel/src/3d/hls_texture_bank.cpp +++ b/code/nel/src/3d/hls_texture_bank.cpp @@ -21,6 +21,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/hls_texture_manager.cpp b/code/nel/src/3d/hls_texture_manager.cpp index 147238ae7..586ec53ce 100644 --- a/code/nel/src/3d/hls_texture_manager.cpp +++ b/code/nel/src/3d/hls_texture_manager.cpp @@ -22,6 +22,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/hrc_trav.cpp b/code/nel/src/3d/hrc_trav.cpp index 9d79ac55d..a4cbc525a 100644 --- a/code/nel/src/3d/hrc_trav.cpp +++ b/code/nel/src/3d/hrc_trav.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ig_surface_light.cpp b/code/nel/src/3d/ig_surface_light.cpp index efd5e89a4..ef4a59a46 100644 --- a/code/nel/src/3d/ig_surface_light.cpp +++ b/code/nel/src/3d/ig_surface_light.cpp @@ -18,6 +18,9 @@ #include "nel/3d/ig_surface_light.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ig_surface_light_build.cpp b/code/nel/src/3d/ig_surface_light_build.cpp index 33a5a33b0..70d66c388 100644 --- a/code/nel/src/3d/ig_surface_light_build.cpp +++ b/code/nel/src/3d/ig_surface_light_build.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/index_buffer.cpp b/code/nel/src/3d/index_buffer.cpp index 7bb2e1cd5..e99b1e1e3 100644 --- a/code/nel/src/3d/index_buffer.cpp +++ b/code/nel/src/3d/index_buffer.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // *************************************************************************** diff --git a/code/nel/src/3d/init_3d.cpp b/code/nel/src/3d/init_3d.cpp index b2bf2c05e..e34702b74 100644 --- a/code/nel/src/3d/init_3d.cpp +++ b/code/nel/src/3d/init_3d.cpp @@ -22,6 +22,10 @@ #include "nel/3d/scene.h" #include "nel/3d/register_3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace { static bool _Initialized = false; diff --git a/code/nel/src/3d/instance_group_user.cpp b/code/nel/src/3d/instance_group_user.cpp index 651e54094..536e14e94 100644 --- a/code/nel/src/3d/instance_group_user.cpp +++ b/code/nel/src/3d/instance_group_user.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/instance_lighter.cpp b/code/nel/src/3d/instance_lighter.cpp index d21f80e4e..8e7c16294 100644 --- a/code/nel/src/3d/instance_lighter.cpp +++ b/code/nel/src/3d/instance_lighter.cpp @@ -28,6 +28,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/key.cpp b/code/nel/src/3d/key.cpp index e1722bf23..561041175 100644 --- a/code/nel/src/3d/key.cpp +++ b/code/nel/src/3d/key.cpp @@ -18,6 +18,9 @@ #include "nel/3d/key.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/landscape.cpp b/code/nel/src/3d/landscape.cpp index e3658dd88..8112053d7 100644 --- a/code/nel/src/3d/landscape.cpp +++ b/code/nel/src/3d/landscape.cpp @@ -41,6 +41,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D @@ -3216,37 +3219,37 @@ void CLandscape::deleteTessFace(CTessFace *f) // for refine() mgt, must remove from refine priority list, or from the temp rootTessFaceToUpdate list. f->unlinkInPList(); - TessFaceAllocator.free(f); + TessFaceAllocator.freeBlock(f); } // *************************************************************************** void CLandscape::deleteTessVertex(CTessVertex *v) { - TessVertexAllocator.free(v); + TessVertexAllocator.freeBlock(v); } // *************************************************************************** void CLandscape::deleteTessNearVertex(CTessNearVertex *v) { - TessNearVertexAllocator.free(v); + TessNearVertexAllocator.freeBlock(v); } // *************************************************************************** void CLandscape::deleteTessFarVertex(CTessFarVertex *v) { - TessFarVertexAllocator.free(v); + TessFarVertexAllocator.freeBlock(v); } // *************************************************************************** void CLandscape::deleteTileMaterial(CTileMaterial *tm) { - TileMaterialAllocator.free(tm); + TileMaterialAllocator.freeBlock(tm); } // *************************************************************************** void CLandscape::deleteTileFace(CTileFace *tf) { - TileFaceAllocator.free(tf); + TileFaceAllocator.freeBlock(tf); } diff --git a/code/nel/src/3d/landscape_collision_grid.cpp b/code/nel/src/3d/landscape_collision_grid.cpp index 07b509a68..1636fc6bd 100644 --- a/code/nel/src/3d/landscape_collision_grid.cpp +++ b/code/nel/src/3d/landscape_collision_grid.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/landscape_def.cpp b/code/nel/src/3d/landscape_def.cpp index ac545d04b..0c463e167 100644 --- a/code/nel/src/3d/landscape_def.cpp +++ b/code/nel/src/3d/landscape_def.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/landscape_face_vector_manager.cpp b/code/nel/src/3d/landscape_face_vector_manager.cpp index 955ac3587..0ba4b07cf 100644 --- a/code/nel/src/3d/landscape_face_vector_manager.cpp +++ b/code/nel/src/3d/landscape_face_vector_manager.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/landscape_model.cpp b/code/nel/src/3d/landscape_model.cpp index ca90bae2e..017b82e51 100644 --- a/code/nel/src/3d/landscape_model.cpp +++ b/code/nel/src/3d/landscape_model.cpp @@ -23,9 +23,14 @@ #include "nel/3d/cluster.h" #include "nel/3d/scene.h" #include "nel/3d/light_trav.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/landscape_profile.cpp b/code/nel/src/3d/landscape_profile.cpp index 97ccba0b5..3f20ac4d8 100644 --- a/code/nel/src/3d/landscape_profile.cpp +++ b/code/nel/src/3d/landscape_profile.cpp @@ -18,6 +18,9 @@ #include "nel/3d/landscape_profile.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/landscape_user.cpp b/code/nel/src/3d/landscape_user.cpp index c2c3a4b27..76d73583f 100644 --- a/code/nel/src/3d/landscape_user.cpp +++ b/code/nel/src/3d/landscape_user.cpp @@ -24,6 +24,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -262,8 +266,8 @@ void CLandscapeUser::refreshZonesAround(const CVector &pos, float radius, std::s { NL3D_HAUTO_LOAD_LANDSCAPE; - zoneRemoved= ""; - zoneAdded= ""; + zoneRemoved.clear(); + zoneAdded.clear(); CZoneManager::SZoneManagerWork Work; // Check if new zone must be added to landscape if (_ZoneManager.isWorkComplete(Work)) diff --git a/code/nel/src/3d/landscape_vegetable_block.cpp b/code/nel/src/3d/landscape_vegetable_block.cpp index 593725828..ec015916b 100644 --- a/code/nel/src/3d/landscape_vegetable_block.cpp +++ b/code/nel/src/3d/landscape_vegetable_block.cpp @@ -27,6 +27,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/landscapeig_manager.cpp b/code/nel/src/3d/landscapeig_manager.cpp index 500373360..10eab0f60 100644 --- a/code/nel/src/3d/landscapeig_manager.cpp +++ b/code/nel/src/3d/landscapeig_manager.cpp @@ -36,6 +36,10 @@ H_AUTO_DECL ( NL3D_Unload_Zone_IG ) #define NL3D_HAUTO_LAND_MNGR_LOAD_ZONEIG H_AUTO_USE( NL3D_Load_Zone_IG ) #define NL3D_HAUTO_LAND_MNGR_UNLOAD_ZONEIG H_AUTO_USE( NL3D_Unload_Zone_IG ) +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/landscapevb_allocator.cpp b/code/nel/src/3d/landscapevb_allocator.cpp index c6815ea05..81a91fb12 100644 --- a/code/nel/src/3d/landscapevb_allocator.cpp +++ b/code/nel/src/3d/landscapevb_allocator.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/landscapevb_info.cpp b/code/nel/src/3d/landscapevb_info.cpp index 46d666ea7..f5955e622 100644 --- a/code/nel/src/3d/landscapevb_info.cpp +++ b/code/nel/src/3d/landscapevb_info.cpp @@ -20,6 +20,9 @@ #include "nel/3d/vertex_buffer.h" #include "nel/3d/landscapevb_allocator.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/light.cpp b/code/nel/src/3d/light.cpp index bd190dc00..ba887a447 100644 --- a/code/nel/src/3d/light.cpp +++ b/code/nel/src/3d/light.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/light_contribution.cpp b/code/nel/src/3d/light_contribution.cpp index 9e7e3d1ce..240b540b9 100644 --- a/code/nel/src/3d/light_contribution.cpp +++ b/code/nel/src/3d/light_contribution.cpp @@ -18,6 +18,9 @@ #include "nel/3d/light_contribution.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/light_influence_interpolator.cpp b/code/nel/src/3d/light_influence_interpolator.cpp index 2875abaac..d6e90bd18 100644 --- a/code/nel/src/3d/light_influence_interpolator.cpp +++ b/code/nel/src/3d/light_influence_interpolator.cpp @@ -20,6 +20,9 @@ #include "nel/misc/debug.h" #include "nel/3d/point_light_named.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/light_trav.cpp b/code/nel/src/3d/light_trav.cpp index 0e31d1558..42c2e2aa5 100644 --- a/code/nel/src/3d/light_trav.cpp +++ b/code/nel/src/3d/light_trav.cpp @@ -27,12 +27,13 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { -using namespace NLMISC; - // *************************************************************************** CLightTrav::CLightTrav(bool bSmallScene) : LightingManager(bSmallScene) { diff --git a/code/nel/src/3d/light_user.cpp b/code/nel/src/3d/light_user.cpp index 14f5b463a..a74e2bd02 100644 --- a/code/nel/src/3d/light_user.cpp +++ b/code/nel/src/3d/light_user.cpp @@ -18,6 +18,9 @@ #include "nel/3d/light_user.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/lighting_manager.cpp b/code/nel/src/3d/lighting_manager.cpp index 0f528d5fb..dcf6eff80 100644 --- a/code/nel/src/3d/lighting_manager.cpp +++ b/code/nel/src/3d/lighting_manager.cpp @@ -28,6 +28,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/load_balancing_trav.cpp b/code/nel/src/3d/load_balancing_trav.cpp index a9f289d11..1e983a2a5 100644 --- a/code/nel/src/3d/load_balancing_trav.cpp +++ b/code/nel/src/3d/load_balancing_trav.cpp @@ -32,6 +32,10 @@ using namespace NLMISC; #define NL3D_DEFAULT_LOADBALANCING_VALUE_SMOOTHER 50 #define NL3D_LOADBALANCING_SMOOTHER_MAX_RATIO 1.1f +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/lod_character_builder.cpp b/code/nel/src/3d/lod_character_builder.cpp index 6b0b6e51b..05eef0b30 100644 --- a/code/nel/src/3d/lod_character_builder.cpp +++ b/code/nel/src/3d/lod_character_builder.cpp @@ -27,6 +27,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/lod_character_instance.cpp b/code/nel/src/3d/lod_character_instance.cpp index 7c0d7a0b9..09940184b 100644 --- a/code/nel/src/3d/lod_character_instance.cpp +++ b/code/nel/src/3d/lod_character_instance.cpp @@ -18,6 +18,9 @@ #include "nel/3d/lod_character_instance.h" #include "nel/3d/lod_character_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/lod_character_manager.cpp b/code/nel/src/3d/lod_character_manager.cpp index 48c2a500f..92dee846a 100644 --- a/code/nel/src/3d/lod_character_manager.cpp +++ b/code/nel/src/3d/lod_character_manager.cpp @@ -34,6 +34,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/lod_character_shape.cpp b/code/nel/src/3d/lod_character_shape.cpp index 02d15ce03..21e1cce7f 100644 --- a/code/nel/src/3d/lod_character_shape.cpp +++ b/code/nel/src/3d/lod_character_shape.cpp @@ -28,6 +28,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/lod_character_shape_bank.cpp b/code/nel/src/3d/lod_character_shape_bank.cpp index 018b336f3..f8fdd1a22 100644 --- a/code/nel/src/3d/lod_character_shape_bank.cpp +++ b/code/nel/src/3d/lod_character_shape_bank.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/lod_character_texture.cpp b/code/nel/src/3d/lod_character_texture.cpp index 5876da48f..2f91861d2 100644 --- a/code/nel/src/3d/lod_character_texture.cpp +++ b/code/nel/src/3d/lod_character_texture.cpp @@ -18,6 +18,9 @@ #include "std3d.h" #include "nel/3d/lod_character_texture.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/logic_info.cpp b/code/nel/src/3d/logic_info.cpp index 4202eb863..7599b0917 100644 --- a/code/nel/src/3d/logic_info.cpp +++ b/code/nel/src/3d/logic_info.cpp @@ -18,6 +18,9 @@ #include "nel/3d/logic_info.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/material.cpp b/code/nel/src/3d/material.cpp index 886f45308..3cae5dd30 100644 --- a/code/nel/src/3d/material.cpp +++ b/code/nel/src/3d/material.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -105,9 +109,9 @@ CMaterial &CMaterial::operator=(const CMaterial &mat) // copy texture matrix if there. if (mat._TexUserMat.get()) { - std::auto_ptr texMatClone( new CUserTexMat(*(mat._TexUserMat))); // make cpy + CUniquePtr texMatClone(new CUserTexMat(*(mat._TexUserMat))); // make cpy //std::swap(texMatClone, _TexUserMat); // swap with old - _TexUserMat = texMatClone; + _TexUserMat = CUniquePtrMove(texMatClone); } else { @@ -265,9 +269,9 @@ void CMaterial::serial(NLMISC::IStream &f) if ((_Flags & IDRV_MAT_USER_TEX_MAT_ALL)) // are there user textrue coordinates matrix ? { - std::auto_ptr newPtr(new CUserTexMat); // create new + CUniquePtr newPtr(new CUserTexMat); // create new //std::swap(_TexUserMat, newPtr); // replace old - _TexUserMat = newPtr; + _TexUserMat = CUniquePtrMove(newPtr); } } diff --git a/code/nel/src/3d/matrix_3x4.cpp b/code/nel/src/3d/matrix_3x4.cpp deleted file mode 100644 index a8384c332..000000000 --- a/code/nel/src/3d/matrix_3x4.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/matrix_3x4.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/mesh.cpp b/code/nel/src/3d/mesh.cpp index 0d3095182..cd3109733 100644 --- a/code/nel/src/3d/mesh.cpp +++ b/code/nel/src/3d/mesh.cpp @@ -36,6 +36,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -538,7 +541,7 @@ void CMeshGeom::render(IDriver *drv, CTransformShape *trans, float polygonCount, skeleton= mi->getSkeletonModel(); // The mesh must not be skinned for render() nlassert(!(_Skinned && mi->isSkinned() && skeleton)); - bool bMorphApplied = _MeshMorpher->BlendShapes.size() > 0; + bool bMorphApplied = !_MeshMorpher->BlendShapes.empty(); bool useTangentSpace = _MeshVertexProgram && _MeshVertexProgram->needTangentSpace(); @@ -730,7 +733,7 @@ void CMeshGeom::renderSkin(CTransformShape *trans, float alphaMRM) skeleton= mi->getSkeletonModel(); // must be skinned for renderSkin() nlassert(_Skinned && mi->isSkinned() && skeleton); - bool bMorphApplied = _MeshMorpher->BlendShapes.size() > 0; + bool bMorphApplied = !_MeshMorpher->BlendShapes.empty(); bool useTangentSpace = _MeshVertexProgram && _MeshVertexProgram->needTangentSpace(); @@ -1101,7 +1104,11 @@ bool CMeshGeom::retrieveTriangles(std::vector &indices) const else { // std::copy will convert from 16 bits index to 32 bit index - std::copy((uint16 *) iba.getPtr(), ((uint16 *) iba.getPtr()) + pb.getNumIndexes(), &indices[triIdx*3]); +#ifdef NL_COMP_VC14 + std::copy((uint16 *)iba.getPtr(), ((uint16 *)iba.getPtr()) + pb.getNumIndexes(), stdext::make_checked_array_iterator(&indices[triIdx * 3], indices.size() - triIdx * 3)); +#else + std::copy((uint16 *)iba.getPtr(), ((uint16 *)iba.getPtr()) + pb.getNumIndexes(), &indices[triIdx * 3]); +#endif } // next triIdx+= pb.getNumIndexes()/3; diff --git a/code/nel/src/3d/mesh_base.cpp b/code/nel/src/3d/mesh_base.cpp index f355b7271..3e11e7bfe 100644 --- a/code/nel/src/3d/mesh_base.cpp +++ b/code/nel/src/3d/mesh_base.cpp @@ -25,6 +25,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mesh_base_instance.cpp b/code/nel/src/3d/mesh_base_instance.cpp index 566bebbb1..33037393e 100644 --- a/code/nel/src/3d/mesh_base_instance.cpp +++ b/code/nel/src/3d/mesh_base_instance.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/mesh_blender.cpp b/code/nel/src/3d/mesh_blender.cpp index 866ba5048..ec4b74015 100644 --- a/code/nel/src/3d/mesh_blender.cpp +++ b/code/nel/src/3d/mesh_blender.cpp @@ -20,6 +20,9 @@ #include "nel/3d/driver.h" #include "nel/misc/fast_floor.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mesh_block_manager.cpp b/code/nel/src/3d/mesh_block_manager.cpp index c672e6436..64a24cbfb 100644 --- a/code/nel/src/3d/mesh_block_manager.cpp +++ b/code/nel/src/3d/mesh_block_manager.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/mesh_geom.cpp b/code/nel/src/3d/mesh_geom.cpp index 53eac4967..e8a34f4c5 100644 --- a/code/nel/src/3d/mesh_geom.cpp +++ b/code/nel/src/3d/mesh_geom.cpp @@ -19,6 +19,9 @@ #include "nel/3d/mesh_geom.h" #include "nel/3d/mesh_block_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mesh_instance.cpp b/code/nel/src/3d/mesh_instance.cpp index 5ce134675..eef6e92a5 100644 --- a/code/nel/src/3d/mesh_instance.cpp +++ b/code/nel/src/3d/mesh_instance.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/mesh_morpher.cpp b/code/nel/src/3d/mesh_morpher.cpp index 39f44a130..6d5d2dc73 100644 --- a/code/nel/src/3d/mesh_morpher.cpp +++ b/code/nel/src/3d/mesh_morpher.cpp @@ -24,6 +24,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -102,7 +105,7 @@ void CMeshMorpher::update (std::vector *pBSFactor) if (_VBOri == NULL) return; - if (BlendShapes.size() == 0) + if (BlendShapes.empty()) return; if (_VBOri->getNumVertices() != _VBDst->getNumVertices()) @@ -161,21 +164,21 @@ void CMeshMorpher::update (std::vector *pBSFactor) // Modify Pos/Norm/TgSpace. //------------ if (_VBDst->getVertexFormat() & CVertexBuffer::PositionFlag) - if (rBS.deltaPos.size() > 0) + if (!rBS.deltaPos.empty()) { CVector *pV = dstvba.getVertexCoordPointer (vp); *pV += rBS.deltaPos[j] * rFactor; } if (_VBDst->getVertexFormat() & CVertexBuffer::NormalFlag) - if (rBS.deltaNorm.size() > 0) + if (!rBS.deltaNorm.empty()) { CVector *pV = dstvba.getNormalCoordPointer (vp); *pV += rBS.deltaNorm[j] * rFactor; } if (_UseTgSpace) - if (rBS.deltaTgSpace.size() > 0) + if (!rBS.deltaTgSpace.empty()) { CVector *pV = (CVector*)dstvba.getTexCoordPointer (vp, tgSpaceStage); *pV += rBS.deltaTgSpace[j] * rFactor; @@ -184,14 +187,14 @@ void CMeshMorpher::update (std::vector *pBSFactor) // Modify UV0 / Color //------------ if (_VBDst->getVertexFormat() & CVertexBuffer::TexCoord0Flag) - if (rBS.deltaUV.size() > 0) + if (!rBS.deltaUV.empty()) { CUV *pUV = dstvba.getTexCoordPointer (vp); *pUV += rBS.deltaUV[j] * rFactor; } if (_VBDst->getVertexFormat() & CVertexBuffer::PrimaryColorFlag) - if (rBS.deltaCol.size() > 0) + if (!rBS.deltaCol.empty()) { // todo hulud d3d vertex color RGBA / BGRA CRGBA *pRGBA = (CRGBA*)dstvba.getColorPointer (vp); @@ -221,7 +224,7 @@ void CMeshMorpher::updateSkinned (std::vector *pBSFactor) if (_VBOri == NULL) return; - if (BlendShapes.size() == 0) + if (BlendShapes.empty()) return; if (_VBOri->getNumVertices() != _VBDst->getNumVertices()) @@ -289,21 +292,21 @@ void CMeshMorpher::updateSkinned (std::vector *pBSFactor) // Modify Pos/Norm/TgSpace. //------------ if (_Vertices != NULL) - if (rBS.deltaPos.size() > 0) + if (!rBS.deltaPos.empty()) { CVector *pV = &(_Vertices->operator[](vp)); *pV += rBS.deltaPos[j] * rFactor; } if (_Normals != NULL) - if (rBS.deltaNorm.size() > 0) + if (!rBS.deltaNorm.empty()) { CVector *pV = &(_Normals->operator[](vp)); *pV += rBS.deltaNorm[j] * rFactor; } if (_UseTgSpace && _TgSpace != NULL) - if (rBS.deltaTgSpace.size() > 0) + if (!rBS.deltaTgSpace.empty()) { CVector *pV = &((*_TgSpace)[vp]); *pV += rBS.deltaTgSpace[j] * rFactor; @@ -312,14 +315,14 @@ void CMeshMorpher::updateSkinned (std::vector *pBSFactor) // Modify UV0 / Color //------------ if (_VBDst->getVertexFormat() & CVertexBuffer::TexCoord0Flag) - if (rBS.deltaUV.size() > 0) + if (!rBS.deltaUV.empty()) { CUV *pUV = dstvba.getTexCoordPointer (vp); *pUV += rBS.deltaUV[j] * rFactor; } if (_VBDst->getVertexFormat() & CVertexBuffer::PrimaryColorFlag) - if (rBS.deltaCol.size() > 0) + if (!rBS.deltaCol.empty()) { // todo hulud d3d vertex color RGBA / BGRA CRGBA *pRGBA = (CRGBA*)dstvba.getColorPointer (vp); @@ -368,7 +371,7 @@ void CMeshMorpher::updateRawSkin (CVertexBuffer *vbOri, if (vbOri == NULL) return; - if (BlendShapes.size() == 0) + if (BlendShapes.empty()) return; nlassert(vbOri->getVertexFormat() == (CVertexBuffer::PositionFlag | CVertexBuffer::NormalFlag |CVertexBuffer::TexCoord0Flag) ); diff --git a/code/nel/src/3d/mesh_mrm.cpp b/code/nel/src/3d/mesh_mrm.cpp index e5b61c966..407d342b4 100644 --- a/code/nel/src/3d/mesh_mrm.cpp +++ b/code/nel/src/3d/mesh_mrm.cpp @@ -38,6 +38,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -935,7 +938,7 @@ void CMeshMRMGeom::render(IDriver *drv, CTransformShape *trans, float polygonCou skeleton = mi->getSkeletonModel(); // The mesh must not be skinned for render() nlassert(!(_Skinned && mi->isSkinned() && skeleton)); - bool bMorphApplied = _MeshMorpher.BlendShapes.size() > 0; + bool bMorphApplied = !_MeshMorpher.BlendShapes.empty(); bool useTangentSpace = _MeshVertexProgram && _MeshVertexProgram->needTangentSpace(); @@ -1143,7 +1146,7 @@ void CMeshMRMGeom::renderSkin(CTransformShape *trans, float alphaMRM) skeleton = mi->getSkeletonModel(); // must be skinned for renderSkin() nlassert(_Skinned && mi->isSkinned() && skeleton); - bool bMorphApplied = _MeshMorpher.BlendShapes.size() > 0; + bool bMorphApplied = !_MeshMorpher.BlendShapes.empty(); bool useNormal= (_VBufferFinal.getVertexFormat() & CVertexBuffer::NormalFlag)!=0; bool useTangentSpace = _MeshVertexProgram && _MeshVertexProgram->needTangentSpace(); @@ -1309,7 +1312,7 @@ sint CMeshMRMGeom::renderSkinGroupGeom(CMeshMRMInstance *mi, float alphaMRM, uin skeleton = mi->getSkeletonModel(); // must be skinned for renderSkin() nlassert(_Skinned && mi->isSkinned() && skeleton); - bool bMorphApplied = _MeshMorpher.BlendShapes.size() > 0; + bool bMorphApplied = !_MeshMorpher.BlendShapes.empty(); bool useNormal= (_VBufferFinal.getVertexFormat() & CVertexBuffer::NormalFlag)!=0; nlassert(useNormal); diff --git a/code/nel/src/3d/mesh_mrm_instance.cpp b/code/nel/src/3d/mesh_mrm_instance.cpp index d97de135f..94acd1fe8 100644 --- a/code/nel/src/3d/mesh_mrm_instance.cpp +++ b/code/nel/src/3d/mesh_mrm_instance.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/mesh_mrm_skin_template.cpp b/code/nel/src/3d/mesh_mrm_skin_template.cpp index 63a0b67e8..792b8c5dc 100644 --- a/code/nel/src/3d/mesh_mrm_skin_template.cpp +++ b/code/nel/src/3d/mesh_mrm_skin_template.cpp @@ -20,6 +20,10 @@ #include "std3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // ace: before including this, #define this define to use it // the goal is to be able to compile every .cpp file with no // special case (GNU/Linux needs) diff --git a/code/nel/src/3d/mesh_mrm_skinned.cpp b/code/nel/src/3d/mesh_mrm_skinned.cpp index 11a1b41fc..a9d51a591 100644 --- a/code/nel/src/3d/mesh_mrm_skinned.cpp +++ b/code/nel/src/3d/mesh_mrm_skinned.cpp @@ -39,6 +39,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -301,7 +304,7 @@ void CMeshMRMSkinnedGeom::build(CMesh::CMeshBuild &m, // No Blend Shapes //================================================ - nlassert (meshBuildMRM.BlendShapes.size() == 0); + nlassert (meshBuildMRM.BlendShapes.empty()); // Compact bone id and build a bone id names //================================================ diff --git a/code/nel/src/3d/mesh_mrm_skinned_instance.cpp b/code/nel/src/3d/mesh_mrm_skinned_instance.cpp index a07cb5875..02c277571 100644 --- a/code/nel/src/3d/mesh_mrm_skinned_instance.cpp +++ b/code/nel/src/3d/mesh_mrm_skinned_instance.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/mesh_mrm_skinned_template.cpp b/code/nel/src/3d/mesh_mrm_skinned_template.cpp index 5d1b2f582..c6d25810e 100644 --- a/code/nel/src/3d/mesh_mrm_skinned_template.cpp +++ b/code/nel/src/3d/mesh_mrm_skinned_template.cpp @@ -20,6 +20,10 @@ #include "std3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // *************************************************************************** // *************************************************************************** // Raw "Vertex/Normal only" ApplySkin methods. diff --git a/code/nel/src/3d/mesh_multi_lod.cpp b/code/nel/src/3d/mesh_multi_lod.cpp index e26632f6e..f200e2bc6 100644 --- a/code/nel/src/3d/mesh_multi_lod.cpp +++ b/code/nel/src/3d/mesh_multi_lod.cpp @@ -35,6 +35,9 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mesh_multi_lod_instance.cpp b/code/nel/src/3d/mesh_multi_lod_instance.cpp index c6c8fa237..cf7805788 100644 --- a/code/nel/src/3d/mesh_multi_lod_instance.cpp +++ b/code/nel/src/3d/mesh_multi_lod_instance.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/mesh_vertex_program.cpp b/code/nel/src/3d/mesh_vertex_program.cpp deleted file mode 100644 index 6c46cec5f..000000000 --- a/code/nel/src/3d/mesh_vertex_program.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/mesh_vertex_program.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/meshvp_per_pixel_light.cpp b/code/nel/src/3d/meshvp_per_pixel_light.cpp index 9c5285bbd..6bbcec5c6 100644 --- a/code/nel/src/3d/meshvp_per_pixel_light.cpp +++ b/code/nel/src/3d/meshvp_per_pixel_light.cpp @@ -29,6 +29,9 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/meshvp_wind_tree.cpp b/code/nel/src/3d/meshvp_wind_tree.cpp index 1e3d215a3..1b81af721 100644 --- a/code/nel/src/3d/meshvp_wind_tree.cpp +++ b/code/nel/src/3d/meshvp_wind_tree.cpp @@ -28,6 +28,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mini_col.cpp b/code/nel/src/3d/mini_col.cpp index 8b847afbf..e2c266349 100644 --- a/code/nel/src/3d/mini_col.cpp +++ b/code/nel/src/3d/mini_col.cpp @@ -19,9 +19,13 @@ #include "nel/3d/mini_col.h" #include "nel/misc/aabbox.h" #include "nel/3d/quad_grid.h" + using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/motion_blur.cpp b/code/nel/src/3d/motion_blur.cpp index e9fe1fdab..410ac8610 100644 --- a/code/nel/src/3d/motion_blur.cpp +++ b/code/nel/src/3d/motion_blur.cpp @@ -23,6 +23,9 @@ #include "nel/3d/texture_blank.h" #include "nel/3d/material.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mrm_builder.cpp b/code/nel/src/3d/mrm_builder.cpp index 3035aa78b..b035cae88 100644 --- a/code/nel/src/3d/mrm_builder.cpp +++ b/code/nel/src/3d/mrm_builder.cpp @@ -18,9 +18,13 @@ #include "nel/3d/mrm_builder.h" #include "nel/3d/mrm_parameters.h" + using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mrm_internal.cpp b/code/nel/src/3d/mrm_internal.cpp index b524fcf08..75a83874d 100644 --- a/code/nel/src/3d/mrm_internal.cpp +++ b/code/nel/src/3d/mrm_internal.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mrm_level_detail.cpp b/code/nel/src/3d/mrm_level_detail.cpp index 3314ec76e..4943b6e09 100644 --- a/code/nel/src/3d/mrm_level_detail.cpp +++ b/code/nel/src/3d/mrm_level_detail.cpp @@ -19,6 +19,9 @@ #include "nel/3d/mrm_level_detail.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/mrm_mesh.cpp b/code/nel/src/3d/mrm_mesh.cpp index 0ad2f127f..03cdebeee 100644 --- a/code/nel/src/3d/mrm_mesh.cpp +++ b/code/nel/src/3d/mrm_mesh.cpp @@ -21,6 +21,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/mrm_parameters.cpp b/code/nel/src/3d/mrm_parameters.cpp deleted file mode 100644 index 8210475a5..000000000 --- a/code/nel/src/3d/mrm_parameters.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/mrm_parameters.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/nelu.cpp b/code/nel/src/3d/nelu.cpp index 6417e5abc..8cb6e0968 100644 --- a/code/nel/src/3d/nelu.cpp +++ b/code/nel/src/3d/nelu.cpp @@ -30,6 +30,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/noise_3d.cpp b/code/nel/src/3d/noise_3d.cpp index 5900e4750..3c5257c49 100644 --- a/code/nel/src/3d/noise_3d.cpp +++ b/code/nel/src/3d/noise_3d.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/packed_world.cpp b/code/nel/src/3d/packed_world.cpp index 15d59c724..f1ad22ab2 100644 --- a/code/nel/src/3d/packed_world.cpp +++ b/code/nel/src/3d/packed_world.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/packed_zone.cpp b/code/nel/src/3d/packed_zone.cpp index 1c6bf4817..dbc9b2d1d 100644 --- a/code/nel/src/3d/packed_zone.cpp +++ b/code/nel/src/3d/packed_zone.cpp @@ -35,6 +35,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/particle_system.cpp b/code/nel/src/3d/particle_system.cpp index 34b75d427..477739e98 100644 --- a/code/nel/src/3d/particle_system.cpp +++ b/code/nel/src/3d/particle_system.cpp @@ -45,6 +45,9 @@ #define CHECK_INTEGRITY #endif +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif @@ -317,7 +320,7 @@ void CParticleSystem::setViewMat(const NLMISC::CMatrix &m) } ///======================================================================================= -bool CParticleSystem::hasEmitters(void) const +bool CParticleSystem::hasEmitters() const { NL_PS_FUNC_MAIN(CParticleSystem_hasEmitters) for (TProcessVect::const_iterator it = _ProcessVect.begin(); it != _ProcessVect.end(); ++it) diff --git a/code/nel/src/3d/particle_system_manager.cpp b/code/nel/src/3d/particle_system_manager.cpp index e2e0eed8d..5778b2898 100644 --- a/code/nel/src/3d/particle_system_manager.cpp +++ b/code/nel/src/3d/particle_system_manager.cpp @@ -21,6 +21,9 @@ #include "nel/3d/scene.h" #include "nel/3d/skeleton_model.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/particle_system_model.cpp b/code/nel/src/3d/particle_system_model.cpp index 8b7f7d142..7736b7233 100644 --- a/code/nel/src/3d/particle_system_model.cpp +++ b/code/nel/src/3d/particle_system_model.cpp @@ -32,6 +32,9 @@ +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/particle_system_process.cpp b/code/nel/src/3d/particle_system_process.cpp index b0340ea0b..8150d56d1 100644 --- a/code/nel/src/3d/particle_system_process.cpp +++ b/code/nel/src/3d/particle_system_process.cpp @@ -19,6 +19,10 @@ #include "nel/3d/particle_system_process.h" #include "nel/3d/particle_system.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + uint PSEnterLeaveDepth = 0; uint PSEnterLeaveMaxDepth = 1; std::string PSCurrName; diff --git a/code/nel/src/3d/particle_system_shape.cpp b/code/nel/src/3d/particle_system_shape.cpp index 7acbea6d4..94851c3eb 100644 --- a/code/nel/src/3d/particle_system_shape.cpp +++ b/code/nel/src/3d/particle_system_shape.cpp @@ -33,6 +33,10 @@ #include "nel/3d/ps_face_look_at.h" #include "nel/3d/ps_force.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/particle_system_sound_user.cpp b/code/nel/src/3d/particle_system_sound_user.cpp index b2ea9587e..5916bc964 100644 --- a/code/nel/src/3d/particle_system_sound_user.cpp +++ b/code/nel/src/3d/particle_system_sound_user.cpp @@ -23,6 +23,9 @@ #include "nel/3d/u_ps_sound_interface.h" #include "nel/3d/u_ps_sound_impl.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/patch.cpp b/code/nel/src/3d/patch.cpp index 4b0253ead..29f960a28 100644 --- a/code/nel/src/3d/patch.cpp +++ b/code/nel/src/3d/patch.cpp @@ -38,6 +38,10 @@ using namespace NLMISC; // Define this to remove user color (debug) // #define NEL_FORCE_NO_USER_COLOR +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/patch_lightmap.cpp b/code/nel/src/3d/patch_lightmap.cpp index bc14c7917..7a47085dd 100644 --- a/code/nel/src/3d/patch_lightmap.cpp +++ b/code/nel/src/3d/patch_lightmap.cpp @@ -30,9 +30,13 @@ #include "nel/misc/fast_floor.h" #include "nel/3d/light_influence_interpolator.h" #include "nel/3d/patchdlm_context.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/patch_noise.cpp b/code/nel/src/3d/patch_noise.cpp index ed87f2fe0..f0a491346 100644 --- a/code/nel/src/3d/patch_noise.cpp +++ b/code/nel/src/3d/patch_noise.cpp @@ -26,9 +26,13 @@ #include "nel/misc/common.h" #include "nel/3d/tile_noise_map.h" #include "nel/3d/patchuv_locator.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/patch_rdr_pass.cpp b/code/nel/src/3d/patch_rdr_pass.cpp index ada89ce35..607d8b4cf 100644 --- a/code/nel/src/3d/patch_rdr_pass.cpp +++ b/code/nel/src/3d/patch_rdr_pass.cpp @@ -19,6 +19,9 @@ #include "nel/3d/patch_rdr_pass.h" #include "nel/3d/index_buffer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/patch_render.cpp b/code/nel/src/3d/patch_render.cpp index ee916a3fe..de5d0b4ec 100644 --- a/code/nel/src/3d/patch_render.cpp +++ b/code/nel/src/3d/patch_render.cpp @@ -24,11 +24,17 @@ #include "nel/3d/landscape.h" #include "nel/3d/landscape_profile.h" #include "nel/3d/patchdlm_context.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/vector.h" #include "nel/misc/common.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/patch_vegetable.cpp b/code/nel/src/3d/patch_vegetable.cpp index 6729d3625..385b6f615 100644 --- a/code/nel/src/3d/patch_vegetable.cpp +++ b/code/nel/src/3d/patch_vegetable.cpp @@ -33,6 +33,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/patchdlm_context.cpp b/code/nel/src/3d/patchdlm_context.cpp index f7d2236e8..54a34dd92 100644 --- a/code/nel/src/3d/patchdlm_context.cpp +++ b/code/nel/src/3d/patchdlm_context.cpp @@ -31,6 +31,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/patchuv_locator.cpp b/code/nel/src/3d/patchuv_locator.cpp index 697ccfb72..b4743c4c1 100644 --- a/code/nel/src/3d/patchuv_locator.cpp +++ b/code/nel/src/3d/patchuv_locator.cpp @@ -21,6 +21,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/pixel_program.cpp b/code/nel/src/3d/pixel_program.cpp index 120e7def6..a11344055 100644 --- a/code/nel/src/3d/pixel_program.cpp +++ b/code/nel/src/3d/pixel_program.cpp @@ -27,6 +27,10 @@ #include "nel/3d/driver.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/play_list_manager.cpp b/code/nel/src/3d/play_list_manager.cpp index 636336cf3..0648984c5 100644 --- a/code/nel/src/3d/play_list_manager.cpp +++ b/code/nel/src/3d/play_list_manager.cpp @@ -18,6 +18,9 @@ #include "nel/3d/play_list_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/play_list_manager_user.cpp b/code/nel/src/3d/play_list_manager_user.cpp index c6991e914..4248a753f 100644 --- a/code/nel/src/3d/play_list_manager_user.cpp +++ b/code/nel/src/3d/play_list_manager_user.cpp @@ -21,6 +21,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/play_list_user.cpp b/code/nel/src/3d/play_list_user.cpp index 0a80a1076..6f2a2773d 100644 --- a/code/nel/src/3d/play_list_user.cpp +++ b/code/nel/src/3d/play_list_user.cpp @@ -19,12 +19,17 @@ #include "nel/3d/play_list_user.h" #include "nel/3d/animation_set_user.h" #include "nel/3d/u_transform.h" -#include "nel/misc/hierarchical_timer.h" +#include "nel/3d/transform.h" +#include "nel/misc/hierarchical_timer.h" #include "nel/misc/debug.h" using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/point_light.cpp b/code/nel/src/3d/point_light.cpp index e441e198e..ff0527689 100644 --- a/code/nel/src/3d/point_light.cpp +++ b/code/nel/src/3d/point_light.cpp @@ -24,6 +24,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/point_light_model.cpp b/code/nel/src/3d/point_light_model.cpp index df7e38234..17bb18619 100644 --- a/code/nel/src/3d/point_light_model.cpp +++ b/code/nel/src/3d/point_light_model.cpp @@ -25,6 +25,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/point_light_named.cpp b/code/nel/src/3d/point_light_named.cpp index ffee29eb8..f4a6a9cac 100644 --- a/code/nel/src/3d/point_light_named.cpp +++ b/code/nel/src/3d/point_light_named.cpp @@ -18,6 +18,9 @@ #include "nel/3d/point_light_named.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/point_light_named_array.cpp b/code/nel/src/3d/point_light_named_array.cpp index 0b91d7c46..0c6c34cc9 100644 --- a/code/nel/src/3d/point_light_named_array.cpp +++ b/code/nel/src/3d/point_light_named_array.cpp @@ -23,6 +23,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -92,7 +96,7 @@ void CPointLightNamedArray::build(const std::vector &pointLi // Regroup. // --------- _PointLightGroupMap.clear(); - if(_PointLights.size() > 0 ) + if (!_PointLights.empty()) { bool first= true; string precName; diff --git a/code/nel/src/3d/portal.cpp b/code/nel/src/3d/portal.cpp index deb80c5c5..096dcd129 100644 --- a/code/nel/src/3d/portal.cpp +++ b/code/nel/src/3d/portal.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -242,11 +246,11 @@ void CPortal::serial (NLMISC::IStream& f) { std::string occName = CStringMapper::unmap(_OcclusionModelId); if (occName == "no occlusion") - occName = ""; + occName.clear(); f.serial(occName); occName = CStringMapper::unmap(_OpenOcclusionModelId); if (occName == "no occlusion") - occName = ""; + occName.clear(); f.serial(occName); } } diff --git a/code/nel/src/3d/primitive_profile.cpp b/code/nel/src/3d/primitive_profile.cpp index ea23dbe1d..06b0c3bae 100644 --- a/code/nel/src/3d/primitive_profile.cpp +++ b/code/nel/src/3d/primitive_profile.cpp @@ -18,6 +18,9 @@ #include "nel/3d/primitive_profile.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/program.cpp b/code/nel/src/3d/program.cpp index 738b57550..7758feec6 100644 --- a/code/nel/src/3d/program.cpp +++ b/code/nel/src/3d/program.cpp @@ -42,6 +42,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // *************************************************************************** diff --git a/code/nel/src/3d/ps_allocator.cpp b/code/nel/src/3d/ps_allocator.cpp index dd79c750f..eb01e4754 100644 --- a/code/nel/src/3d/ps_allocator.cpp +++ b/code/nel/src/3d/ps_allocator.cpp @@ -18,6 +18,10 @@ #include "nel/3d/particle_system_process.h" #include "nel/3d/ps_allocator.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { #ifdef PS_FAST_ALLOC diff --git a/code/nel/src/3d/ps_attrib_maker_bin_op.cpp b/code/nel/src/3d/ps_attrib_maker_bin_op.cpp index 8c029e407..a4e91163d 100644 --- a/code/nel/src/3d/ps_attrib_maker_bin_op.cpp +++ b/code/nel/src/3d/ps_attrib_maker_bin_op.cpp @@ -18,6 +18,9 @@ #include "nel/3d/ps_attrib_maker_bin_op.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_attrib_maker_helper.cpp b/code/nel/src/3d/ps_attrib_maker_helper.cpp index da1b96f94..56dd0ec84 100644 --- a/code/nel/src/3d/ps_attrib_maker_helper.cpp +++ b/code/nel/src/3d/ps_attrib_maker_helper.cpp @@ -17,6 +17,10 @@ #include "std3d.h" #include "nel/3d/ps_attrib_maker_helper.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ps_attrib_maker_template.cpp b/code/nel/src/3d/ps_attrib_maker_template.cpp index 7790b8052..66fe5912d 100644 --- a/code/nel/src/3d/ps_attrib_maker_template.cpp +++ b/code/nel/src/3d/ps_attrib_maker_template.cpp @@ -18,6 +18,9 @@ #include "nel/3d/ps_attrib_maker_template.h" #include "nel/misc/system_info.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_color.cpp b/code/nel/src/3d/ps_color.cpp index f8014fe67..4fbda508a 100644 --- a/code/nel/src/3d/ps_color.cpp +++ b/code/nel/src/3d/ps_color.cpp @@ -19,6 +19,9 @@ #include "nel/3d/ps_color.h" #include "nel/3d/ps_register_color_attribs.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_dot.cpp b/code/nel/src/3d/ps_dot.cpp index 516cac8f1..bf1f51b4d 100644 --- a/code/nel/src/3d/ps_dot.cpp +++ b/code/nel/src/3d/ps_dot.cpp @@ -21,8 +21,14 @@ #include "nel/3d/ps_iterator.h" #include "nel/3d/driver.h" #include "nel/3d/particle_system.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/fast_mem.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ps_emitter.cpp b/code/nel/src/3d/ps_emitter.cpp index c9806722f..7fb5a6516 100644 --- a/code/nel/src/3d/ps_emitter.cpp +++ b/code/nel/src/3d/ps_emitter.cpp @@ -22,6 +22,10 @@ #include "nel/3d/dru.h" #include "nel/3d/particle_system.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -1901,9 +1905,9 @@ void CPSEmitter::resize(uint32 size) } ///========================================================================== -void CPSEmitter::bounceOccured(uint32 index, TAnimationTime timeToNextSimStep) +void CPSEmitter::bounceOccurred(uint32 index, TAnimationTime timeToNextSimStep) { - NL_PS_FUNC(CPSEmitter_bounceOccured) + NL_PS_FUNC(CPSEmitter_bounceOccurred) // TODO : avoid duplication with deleteElement if (_EmittedType && _EmissionType == CPSEmitter::onBounce) { @@ -2797,7 +2801,7 @@ void CPSEmitter::doEmitOnce(uint firstInstanceIndex) startPos = _Owner->getParametricInfos()[k].Pos; } float currTime = _Owner->getTime()[k]; - _Owner->getTime()[k] = 0.f; // when emit occured, time was 0 + _Owner->getTime()[k] = 0.f; // when emit occurred, time was 0 sint32 nbToGenerate = (sint32) (emitLOD * *numToEmitPtr); if (nbToGenerate > 0) { @@ -2830,7 +2834,7 @@ void CPSEmitter::doEmitOnce(uint firstInstanceIndex) startPos = _Owner->getParametricInfos()[k].Pos; } float currTime = _Owner->getTime()[k]; - _Owner->getTime()[k] = 0.f; // when emit occured, time was 0 + _Owner->getTime()[k] = 0.f; // when emit occurred, time was 0 processEmitConsistent(startPos, k, nbToGenerate, _Owner->getAgeInSeconds(k) / CParticleSystem::RealEllapsedTimeRatio); // restore time & pos _Owner->getTime()[k] = currTime; diff --git a/code/nel/src/3d/ps_face.cpp b/code/nel/src/3d/ps_face.cpp index e87459acf..0d3ce6482 100644 --- a/code/nel/src/3d/ps_face.cpp +++ b/code/nel/src/3d/ps_face.cpp @@ -21,9 +21,13 @@ #include "nel/3d/driver.h" #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/quat.h" - +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_face_look_at.cpp b/code/nel/src/3d/ps_face_look_at.cpp index 5b06f6eb5..d6ac0ec0f 100644 --- a/code/nel/src/3d/ps_face_look_at.cpp +++ b/code/nel/src/3d/ps_face_look_at.cpp @@ -21,8 +21,13 @@ #include "nel/3d/driver.h" #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/fast_floor.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_fan_light.cpp b/code/nel/src/3d/ps_fan_light.cpp index 055826749..6296373b6 100644 --- a/code/nel/src/3d/ps_fan_light.cpp +++ b/code/nel/src/3d/ps_fan_light.cpp @@ -22,8 +22,12 @@ #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" #include "nel/3d/driver.h" +#include "nel/3d/debug_vb.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_float.cpp b/code/nel/src/3d/ps_float.cpp index 079b98e43..f4f0a7226 100644 --- a/code/nel/src/3d/ps_float.cpp +++ b/code/nel/src/3d/ps_float.cpp @@ -20,6 +20,10 @@ #include "nel/3d/ps_register_float_attribs.h" #include "nel/misc/fast_floor.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ps_force.cpp b/code/nel/src/3d/ps_force.cpp index bbef28663..bf0ca662d 100644 --- a/code/nel/src/3d/ps_force.cpp +++ b/code/nel/src/3d/ps_force.cpp @@ -28,6 +28,10 @@ #include "nel/3d/ps_util.h" #include "nel/3d/ps_misc.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ps_int.cpp b/code/nel/src/3d/ps_int.cpp index 8c19bb0c0..ff1f3cc4a 100644 --- a/code/nel/src/3d/ps_int.cpp +++ b/code/nel/src/3d/ps_int.cpp @@ -19,6 +19,9 @@ #include "nel/3d/ps_int.h" #include "nel/3d/ps_register_int_attribs.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_light.cpp b/code/nel/src/3d/ps_light.cpp index 3cbe644be..034a5bfcb 100644 --- a/code/nel/src/3d/ps_light.cpp +++ b/code/nel/src/3d/ps_light.cpp @@ -25,6 +25,10 @@ #include "nel/misc/matrix.h" #include "nel/misc/vector.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ps_located.cpp b/code/nel/src/3d/ps_located.cpp index 5409f3480..8dbe2d823 100644 --- a/code/nel/src/3d/ps_located.cpp +++ b/code/nel/src/3d/ps_located.cpp @@ -48,6 +48,10 @@ #define CHECK_PS_INTEGRITY #endif +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -235,7 +239,7 @@ void CPSLocated::releaseAllRef() // If this happen, you can register with the registerDTorObserver // (observer pattern) // and override notifyTargetRemove to call releaseCollisionInfo - nlassert(_IntegrableForces.size() == 0); + nlassert(_IntegrableForces.empty()); nlassert(_NonIntegrableForceNbRefs == 0); CHECK_PS_INTEGRITY } @@ -476,7 +480,7 @@ uint CPSLocated::querryMaxWantedNumFaces(void) /// *************************************************************************************** /// tells whether there are alive entities / particles in the system -bool CPSLocated::hasParticles(void) const +bool CPSLocated::hasParticles() const { NL_PS_FUNC(CPSLocated_hasParticles) CHECK_PS_INTEGRITY @@ -490,7 +494,7 @@ bool CPSLocated::hasParticles(void) const /// *************************************************************************************** /// tells whether there are alive emitters -bool CPSLocated::hasEmitters(void) const +bool CPSLocated::hasEmitters() const { NL_PS_FUNC(CPSLocated_hasEmitters) CHECK_PS_INTEGRITY @@ -835,7 +839,7 @@ CPSLocated::~CPSLocated() // If this happen, you can register with the registerDTorObserver // (observer pattern) // and override notifyTargetRemove to call releaseCollisionInfo - nlassert(_IntegrableForces.size() == 0); + nlassert(_IntegrableForces.empty()); nlassert(_NonIntegrableForceNbRefs == 0); // delete all bindable @@ -1004,7 +1008,7 @@ void CPSLocated::postNewElement(const NLMISC::CVector &pos, const CPSCollisionInfo &ci = _Collisions[indexInEmitter]; if (ci.Dist != -1.f) { - // a collision occured, check time from collision to next time step + // a collision occurred, check time from collision to next time step if ((emitterLocated.getPos()[indexInEmitter] - ci.NewPos) * (pos - ci.NewPos) > 0.f) return; // discard emit that are farther than the collision } } @@ -1839,10 +1843,10 @@ void CPSLocated::updateCollisions() { _Pos[currCollision->Index] = currCollision->NewPos; std::swap(_Speed[currCollision->Index], currCollision->NewSpeed); // keep speed because may be needed when removing particles - // notify each located bindable that a bounce occured ... + // notify each located bindable that a bounce occurred ... for (TLocatedBoundCont::iterator it = _LocatedBoundCont.begin(); it != _LocatedBoundCont.end(); ++it) { - (*it)->bounceOccured(currCollision->Index, computeDateFromCollisionToNextSimStep(currCollision->Index, getAgeInSeconds(currCollision->Index))); + (*it)->bounceOccurred(currCollision->Index, computeDateFromCollisionToNextSimStep(currCollision->Index, getAgeInSeconds(currCollision->Index))); } if (currCollision->CollisionZone->getCollisionBehaviour() == CPSZone::destroy) { @@ -1878,13 +1882,13 @@ void CPSLocated::updateCollisions() // if particle is too old, check whether it died before the collision _Pos[currCollision->Index] = currCollision->NewPos; std::swap(_Speed[currCollision->Index], currCollision->NewSpeed); - // notify each located bindable that a bounce occured ... + // notify each located bindable that a bounce occurred ... if (!_LocatedBoundCont.empty()) { TAnimationTime timeFromcollisionToNextSimStep = computeDateFromCollisionToNextSimStep(currCollision->Index, getAgeInSeconds(currCollision->Index)); for (TLocatedBoundCont::iterator it = _LocatedBoundCont.begin(); it != _LocatedBoundCont.end(); ++it) { - (*it)->bounceOccured(currCollision->Index, timeFromcollisionToNextSimStep); + (*it)->bounceOccurred(currCollision->Index, timeFromcollisionToNextSimStep); } } if (currCollision->CollisionZone->getCollisionBehaviour() == CPSZone::destroy) @@ -2190,7 +2194,7 @@ void CPSLocated::removeOldParticles() TAnimationTime timeUntilNextSimStep; if (_Collisions[*it].Dist == -1.f) { - // no collision occured + // no collision occurred if (_Time[*it] > 1.f) { @@ -2213,18 +2217,18 @@ void CPSLocated::removeOldParticles() } else { - // a collision occured before particle died, so pos is already good + // a collision occurred before particle died, so pos is already good if (_LifeScheme) { timeUntilNextSimStep = computeDateFromCollisionToNextSimStep(*it, _Time[*it] / _TimeIncrement[*it]); - // compute age of particle when collision occured + // compute age of particle when collision occurred _Time[*it] -= timeUntilNextSimStep * _TimeIncrement[*it]; NLMISC::clamp(_Time[*it], 0.f, 1.f); // avoid imprecisions } else { timeUntilNextSimStep = computeDateFromCollisionToNextSimStep(*it, _Time[*it] * _InitialLife); - // compute age of particle when collision occured + // compute age of particle when collision occurred _Time[*it] -= timeUntilNextSimStep / (_InitialLife == 0.f ? 1.f : _InitialLife); NLMISC::clamp(_Time[*it], 0.f, 1.f); // avoid imprecisions } diff --git a/code/nel/src/3d/ps_mesh.cpp b/code/nel/src/3d/ps_mesh.cpp index 5002f0054..3331ac315 100644 --- a/code/nel/src/3d/ps_mesh.cpp +++ b/code/nel/src/3d/ps_mesh.cpp @@ -29,11 +29,14 @@ #include "nel/3d/particle_system_shape.h" #include "nel/3d/particle_system_model.h" #include "nel/3d/ps_iterator.h" +#include "nel/3d/debug_vb.h" + #include "nel/misc/stream.h" #include "nel/misc/path.h" - - +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -1113,11 +1116,13 @@ void CPSConstraintMesh::getShapesNames(std::string *shapesNames) const { const_cast(this)->update(); } +#ifdef NL_COMP_VC14 + std::copy(_MeshShapeFileName.begin(), _MeshShapeFileName.end(), stdext::make_unchecked_array_iterator(shapesNames)); +#else std::copy(_MeshShapeFileName.begin(), _MeshShapeFileName.end(), shapesNames); +#endif } - - //==================================================================================== void CPSConstraintMesh::setShape(uint index, const std::string &shapeName) { @@ -1128,7 +1133,6 @@ void CPSConstraintMesh::setShape(uint index, const std::string &shapeName) _ValidBuild = 0; } - //==================================================================================== const std::string &CPSConstraintMesh::getShape(uint index) const { @@ -1230,7 +1234,7 @@ bool CPSConstraintMesh::update(std::vector *numVertsVect /*= NULL*/) uint numVerts = 0; uint8 uvRouting[CVertexBuffer::MaxStage]; - if (_MeshShapeFileName.size() == 0) + if (_MeshShapeFileName.empty()) { _MeshShapeFileName.resize(1); _MeshShapeFileName[0] = DummyShapeName; @@ -1382,7 +1386,7 @@ bool CPSConstraintMesh::update(std::vector *numVertsVect /*= NULL*/) _GlobalAnimDate = _Owner->getOwner()->getSystemDate(); _Touched = 0; _ValidBuild = ok ? 1 : 0; - nlassert(_Meshes.size() > 0); + nlassert(!_Meshes.empty()); return ok; @@ -1487,7 +1491,7 @@ void CPSConstraintMesh::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { if (!f.isReading()) { - if (_MeshShapeFileName.size() > 0) + if (!_MeshShapeFileName.empty()) { f.serial(_MeshShapeFileName[0]); } @@ -1533,7 +1537,7 @@ void CPSConstraintMesh::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { PGlobalTexAnims newPtr(new CGlobalTexAnims); // create new //std::swap(_GlobalTexAnims, newPtr); // replace old - _GlobalTexAnims = newPtr; + _GlobalTexAnims = CUniquePtrMove(newPtr); f.serial(*_GlobalTexAnims); } @@ -1747,7 +1751,7 @@ void CPSConstraintMesh::draw(bool opaque) _Owner->incrementNbDrawnParticles(numToProcess); // for benchmark purpose - if (_PrecompBasis.size() == 0) /// do we deal with prerotated meshs ? + if (_PrecompBasis.empty()) /// do we deal with prerotated meshs ? { if (step == (1 << 16)) { @@ -2352,7 +2356,7 @@ void CPSConstraintMesh::setTexAnimType(TTexAnimType type) { PGlobalTexAnims newPtr(new CGlobalTexAnims); //std::swap(_GlobalTexAnims, newPtr); - _GlobalTexAnims = newPtr; + _GlobalTexAnims = CUniquePtrMove(newPtr); _GlobalAnimationEnabled = 1; } break; diff --git a/code/nel/src/3d/ps_particle.cpp b/code/nel/src/3d/ps_particle.cpp deleted file mode 100644 index fcab19f48..000000000 --- a/code/nel/src/3d/ps_particle.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/ps_particle.h" - -namespace NL3D -{ - /// NOTE : implementation of particles rendering has now been split accross vrious files... - -} // NL3D diff --git a/code/nel/src/3d/ps_particle2.cpp b/code/nel/src/3d/ps_particle2.cpp deleted file mode 100644 index 22e374620..000000000 --- a/code/nel/src/3d/ps_particle2.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/ps_particle2.h" - -namespace NL3D -{ - -} // NL3D diff --git a/code/nel/src/3d/ps_particle_basic.cpp b/code/nel/src/3d/ps_particle_basic.cpp index c2d6b6357..42e4d31c6 100644 --- a/code/nel/src/3d/ps_particle_basic.cpp +++ b/code/nel/src/3d/ps_particle_basic.cpp @@ -25,6 +25,9 @@ #include "nel/3d/particle_system.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_plane_basis_maker.cpp b/code/nel/src/3d/ps_plane_basis_maker.cpp index f1ca718b9..bdc99cd18 100644 --- a/code/nel/src/3d/ps_plane_basis_maker.cpp +++ b/code/nel/src/3d/ps_plane_basis_maker.cpp @@ -20,6 +20,10 @@ #include "nel/3d/ps_plane_basis_maker.h" #include "nel/3d/ps_register_plane_basis_attribs.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ps_quad.cpp b/code/nel/src/3d/ps_quad.cpp index c517063e0..295c31c93 100644 --- a/code/nel/src/3d/ps_quad.cpp +++ b/code/nel/src/3d/ps_quad.cpp @@ -24,6 +24,10 @@ #include "nel/3d/particle_system.h" #include "nel/3d/ps_iterator.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ps_register_attribs.cpp b/code/nel/src/3d/ps_register_attribs.cpp index 184c2f467..7fb616178 100644 --- a/code/nel/src/3d/ps_register_attribs.cpp +++ b/code/nel/src/3d/ps_register_attribs.cpp @@ -25,7 +25,9 @@ #include "nel/3d/ps_register_plane_basis_attribs.h" - +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_register_emitters.cpp b/code/nel/src/3d/ps_register_emitters.cpp index f5c0def3a..e2793f388 100644 --- a/code/nel/src/3d/ps_register_emitters.cpp +++ b/code/nel/src/3d/ps_register_emitters.cpp @@ -21,6 +21,9 @@ #include "nel/3d/ps_emitter.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_register_forces.cpp b/code/nel/src/3d/ps_register_forces.cpp index cb41f1fb8..7d9b1bcff 100644 --- a/code/nel/src/3d/ps_register_forces.cpp +++ b/code/nel/src/3d/ps_register_forces.cpp @@ -19,6 +19,10 @@ #include "nel/3d/ps_util.h" #include "nel/3d/ps_force.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { void CPSUtil::registerForces() diff --git a/code/nel/src/3d/ps_register_particles.cpp b/code/nel/src/3d/ps_register_particles.cpp index 6809d8c66..adbce5d36 100644 --- a/code/nel/src/3d/ps_register_particles.cpp +++ b/code/nel/src/3d/ps_register_particles.cpp @@ -22,6 +22,9 @@ #include "nel/3d/ps_particle2.h" #include "nel/3d/ps_mesh.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_register_zones.cpp b/code/nel/src/3d/ps_register_zones.cpp index 8996eaf99..73b28c0fb 100644 --- a/code/nel/src/3d/ps_register_zones.cpp +++ b/code/nel/src/3d/ps_register_zones.cpp @@ -21,6 +21,9 @@ #include "nel/3d/ps_zone.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_ribbon.cpp b/code/nel/src/3d/ps_ribbon.cpp index af907313f..06bb08787 100644 --- a/code/nel/src/3d/ps_ribbon.cpp +++ b/code/nel/src/3d/ps_ribbon.cpp @@ -24,6 +24,10 @@ #include "nel/3d/texture_mem.h" #include "nel/misc/matrix.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -36,7 +40,7 @@ CPSRibbon::TVBMap CPSRibbon::_VBMaps[16]; static ITexture *CreateGradientTexture() { NL_PS_FUNC(CreateGradientTexture) - std::auto_ptr tex(new CTextureMem((uint8 *) &GradientB2W, + CUniquePtr tex(new CTextureMem((uint8 *) &GradientB2W, sizeof(GradientB2W), false, /* dont delete */ false, /* not a file */ @@ -1463,8 +1467,13 @@ void CPSRibbon::setShape(const CVector *shape, uint32 nbPointsInShape, bool brac ///================================================================================================================== void CPSRibbon::getShape(CVector *shape) const { - NL_PS_FUNC(CPSRibbon_getShape) + NL_PS_FUNC(CPSRibbon_getShape); + +#ifdef NL_COMP_VC14 + std::copy(_Shape.begin(), _Shape.end(), stdext::make_unchecked_array_iterator(shape)); +#else std::copy(_Shape.begin(), _Shape.end(), shape); +#endif } ///================================================================================================================== diff --git a/code/nel/src/3d/ps_ribbon_base.cpp b/code/nel/src/3d/ps_ribbon_base.cpp index 8f2a64932..a3f70253b 100644 --- a/code/nel/src/3d/ps_ribbon_base.cpp +++ b/code/nel/src/3d/ps_ribbon_base.cpp @@ -20,6 +20,12 @@ #include "nel/3d/ps_ribbon_base.h" #include "nel/3d/particle_system.h" +using namespace NLMISC; + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ps_ribbon_look_at.cpp b/code/nel/src/3d/ps_ribbon_look_at.cpp index 966e5a5b1..2e03acaf6 100644 --- a/code/nel/src/3d/ps_ribbon_look_at.cpp +++ b/code/nel/src/3d/ps_ribbon_look_at.cpp @@ -20,6 +20,11 @@ #include "nel/3d/particle_system.h" #include "nel/3d/ps_macro.h" #include "nel/3d/driver.h" +#include "nel/3d/debug_vb.h" + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_shockwave.cpp b/code/nel/src/3d/ps_shockwave.cpp index 20069e175..dc94f5f96 100644 --- a/code/nel/src/3d/ps_shockwave.cpp +++ b/code/nel/src/3d/ps_shockwave.cpp @@ -22,7 +22,11 @@ #include "nel/3d/texture_grouped.h" #include "nel/3d/ps_iterator.h" #include "nel/3d/particle_system.h" +#include "nel/3d/debug_vb.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_sound.cpp b/code/nel/src/3d/ps_sound.cpp index a5ae6ad26..873b3ed34 100644 --- a/code/nel/src/3d/ps_sound.cpp +++ b/code/nel/src/3d/ps_sound.cpp @@ -21,6 +21,12 @@ #include "nel/3d/u_ps_sound_interface.h" #include "nel/3d/ps_attrib_maker.h" +using namespace NLMISC; + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ps_tail_dot.cpp b/code/nel/src/3d/ps_tail_dot.cpp index 075c9a598..69caa8f71 100644 --- a/code/nel/src/3d/ps_tail_dot.cpp +++ b/code/nel/src/3d/ps_tail_dot.cpp @@ -25,6 +25,10 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { static NLMISC::CRGBA GradientB2W[] = {NLMISC::CRGBA(0, 0, 0, 0), NLMISC::CRGBA(255, 255, 255, 255) }; @@ -33,7 +37,7 @@ static NLMISC::CRGBA GradientB2W[] = {NLMISC::CRGBA(0, 0, 0, 0), NLMISC::CRGBA(2 static ITexture *CreateGradientTexture() { NL_PS_FUNC(CreateGradientTexture) - std::auto_ptr tex(new CTextureMem((uint8 *) &GradientB2W, + CUniquePtr tex(new CTextureMem((uint8 *) &GradientB2W, sizeof(GradientB2W), false, /* dont delete */ false, /* not a file */ diff --git a/code/nel/src/3d/ps_util.cpp b/code/nel/src/3d/ps_util.cpp index 94d67c777..b25f10e10 100644 --- a/code/nel/src/3d/ps_util.cpp +++ b/code/nel/src/3d/ps_util.cpp @@ -39,6 +39,9 @@ #include "nel/3d/particle_system_shape.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/ps_zone.cpp b/code/nel/src/3d/ps_zone.cpp index 30349906f..55a65d68f 100644 --- a/code/nel/src/3d/ps_zone.cpp +++ b/code/nel/src/3d/ps_zone.cpp @@ -32,6 +32,10 @@ #include #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ptr_set.cpp b/code/nel/src/3d/ptr_set.cpp deleted file mode 100644 index 57abfeaab..000000000 --- a/code/nel/src/3d/ptr_set.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/ptr_set.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/quad_effect.cpp b/code/nel/src/3d/quad_effect.cpp index a6c75c99d..63fd0565c 100644 --- a/code/nel/src/3d/quad_effect.cpp +++ b/code/nel/src/3d/quad_effect.cpp @@ -20,6 +20,10 @@ #include #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/quad_grid.cpp b/code/nel/src/3d/quad_grid.cpp index fca3ab95e..0240b4d0f 100644 --- a/code/nel/src/3d/quad_grid.cpp +++ b/code/nel/src/3d/quad_grid.cpp @@ -17,6 +17,10 @@ #include "std3d.h" #include "nel/3d/quad_grid.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { NLMISC::CPolygon2D CQuadGridBase::_ScaledPoly; diff --git a/code/nel/src/3d/quad_grid_clip_cluster.cpp b/code/nel/src/3d/quad_grid_clip_cluster.cpp index a6ab799c8..dd52ed111 100644 --- a/code/nel/src/3d/quad_grid_clip_cluster.cpp +++ b/code/nel/src/3d/quad_grid_clip_cluster.cpp @@ -25,6 +25,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/quad_grid_clip_manager.cpp b/code/nel/src/3d/quad_grid_clip_manager.cpp index 02c4fed62..0fe69e46e 100644 --- a/code/nel/src/3d/quad_grid_clip_manager.cpp +++ b/code/nel/src/3d/quad_grid_clip_manager.cpp @@ -28,6 +28,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/radix_sort.cpp b/code/nel/src/3d/radix_sort.cpp deleted file mode 100644 index 1143305c1..000000000 --- a/code/nel/src/3d/radix_sort.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/radix_sort.h" - - -namespace NL3D { - - -// To test compiling. -/*struct Pipo -{ - uint32 a; - uint32 getRadixKey() const {return a;} -}; - - -CRadixSort PipoSort; - -static void pipo() -{ - PipoSort.sort(NULL, NULL, 30); -}*/ - - -} // NL3D diff --git a/code/nel/src/3d/raw_skin.cpp b/code/nel/src/3d/raw_skin.cpp index 5ed069d50..e6788aa71 100644 --- a/code/nel/src/3d/raw_skin.cpp +++ b/code/nel/src/3d/raw_skin.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/raw_skinned.cpp b/code/nel/src/3d/raw_skinned.cpp index 3625ea928..5f05d5fb2 100644 --- a/code/nel/src/3d/raw_skinned.cpp +++ b/code/nel/src/3d/raw_skinned.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/ray_mesh.cpp b/code/nel/src/3d/ray_mesh.cpp index b315979b1..3ba3461ee 100644 --- a/code/nel/src/3d/ray_mesh.cpp +++ b/code/nel/src/3d/ray_mesh.cpp @@ -19,11 +19,17 @@ #include "nel/3d/ray_mesh.h" #include "nel/misc/vector_2f.h" #include "nel/misc/fast_mem.h" +#include "nel/misc/plane.h" + #include "nel/3d/matrix_3x4.h" using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/register_3d.cpp b/code/nel/src/3d/register_3d.cpp index 2e9edbf41..82ac4502e 100644 --- a/code/nel/src/3d/register_3d.cpp +++ b/code/nel/src/3d/register_3d.cpp @@ -45,6 +45,9 @@ #include "nel/3d/packed_zone.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/render_target_manager.cpp b/code/nel/src/3d/render_target_manager.cpp index 4b552c62e..6012eeb8e 100644 --- a/code/nel/src/3d/render_target_manager.cpp +++ b/code/nel/src/3d/render_target_manager.cpp @@ -46,6 +46,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { struct CRenderTargetDescInt @@ -146,6 +150,7 @@ void CRenderTargetManager::cleanup() desc->TextureUser = NULL; desc->TextureInterface = NULL; // CSmartPtr m_RenderTargets.erase(m_RenderTargets.begin() + i); + delete desc; --i; } else diff --git a/code/nel/src/3d/render_trav.cpp b/code/nel/src/3d/render_trav.cpp index 0a9aa7a5f..cab2e3c00 100644 --- a/code/nel/src/3d/render_trav.cpp +++ b/code/nel/src/3d/render_trav.cpp @@ -39,6 +39,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/root_model.cpp b/code/nel/src/3d/root_model.cpp index cf6d68876..b1ff66cc8 100644 --- a/code/nel/src/3d/root_model.cpp +++ b/code/nel/src/3d/root_model.cpp @@ -19,6 +19,9 @@ #include "nel/3d/root_model.h" #include "nel/3d/scene.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/scene.cpp b/code/nel/src/3d/scene.cpp index 7c552efd4..25d9695c0 100644 --- a/code/nel/src/3d/scene.cpp +++ b/code/nel/src/3d/scene.cpp @@ -66,6 +66,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + #define NL3D_SCENE_COARSE_MANAGER_TEXTURE "nel_coarse_texture.tga" diff --git a/code/nel/src/3d/scene_group.cpp b/code/nel/src/3d/scene_group.cpp index c5f6f24dc..50e1f0171 100644 --- a/code/nel/src/3d/scene_group.cpp +++ b/code/nel/src/3d/scene_group.cpp @@ -36,6 +36,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -749,7 +753,7 @@ bool CInstanceGroup::addToSceneWhenAllShapesLoaded (CScene& scene, IDriver *driv for (i = 0; i < _Instances.size(); ++i) if (_Instances[i] != NULL && !_InstancesInfos[i].DontAddToScene) { - if (_InstancesInfos[i].Clusters.size() > 0) + if (!_InstancesInfos[i].Clusters.empty()) { _Instances[i]->clipUnlinkFromAll(); for (j = 0; j < _InstancesInfos[i].Clusters.size(); ++j) @@ -808,7 +812,7 @@ bool CInstanceGroup::addToSceneWhenAllShapesLoaded (CScene& scene, IDriver *driv // Register the instanceGroup for light animation // ----------------- // If some PointLight to animate - if(_PointLightArray.getPointLights().size() > 0) + if(!_PointLightArray.getPointLights().empty()) scene.addInstanceGroupForLightAnimation(this); _AddToSceneState = StateAdded; @@ -1036,7 +1040,7 @@ bool CInstanceGroup::removeFromScene (CScene& scene) // UnRegister the instanceGroup for light animation // ----------------- // If some PointLight to animate - if(_PointLightArray.getPointLights().size() > 0) + if(!_PointLightArray.getPointLights().empty()) scene.removeInstanceGroupForLightAnimation(this); if (_AddRemoveInstance) @@ -1113,7 +1117,7 @@ void CInstanceGroup::setClusterSystemForInstances(CInstanceGroup *pIG) { _ClusterSystemForInstances = pIG; for (uint32 i = 0; i < _Instances.size(); ++i) - if (_Instances[i] && _InstancesInfos[i].Clusters.size() == 0) + if (_Instances[i] && _InstancesInfos[i].Clusters.empty()) _Instances[i]->setClusterSystem (_ClusterSystemForInstances); } diff --git a/code/nel/src/3d/scene_user.cpp b/code/nel/src/3d/scene_user.cpp index 0df2439de..c581c5c68 100644 --- a/code/nel/src/3d/scene_user.cpp +++ b/code/nel/src/3d/scene_user.cpp @@ -34,6 +34,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/scissor.cpp b/code/nel/src/3d/scissor.cpp deleted file mode 100644 index 99b39389f..000000000 --- a/code/nel/src/3d/scissor.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/scissor.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/seg_remanence.cpp b/code/nel/src/3d/seg_remanence.cpp index e0f9a52ae..be0b0d0cf 100644 --- a/code/nel/src/3d/seg_remanence.cpp +++ b/code/nel/src/3d/seg_remanence.cpp @@ -29,7 +29,9 @@ - +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/seg_remanence_shape.cpp b/code/nel/src/3d/seg_remanence_shape.cpp index cb70f8baa..f31b2c0b2 100644 --- a/code/nel/src/3d/seg_remanence_shape.cpp +++ b/code/nel/src/3d/seg_remanence_shape.cpp @@ -24,6 +24,9 @@ #include "nel/misc/bsphere.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/shadow_map.cpp b/code/nel/src/3d/shadow_map.cpp index 15f9b28e4..a9cad0496 100644 --- a/code/nel/src/3d/shadow_map.cpp +++ b/code/nel/src/3d/shadow_map.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/shadow_map_manager.cpp b/code/nel/src/3d/shadow_map_manager.cpp index e3f8fde99..c592b5a07 100644 --- a/code/nel/src/3d/shadow_map_manager.cpp +++ b/code/nel/src/3d/shadow_map_manager.cpp @@ -31,6 +31,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/shadow_poly_receiver.cpp b/code/nel/src/3d/shadow_poly_receiver.cpp index 3c832209e..7091310f7 100644 --- a/code/nel/src/3d/shadow_poly_receiver.cpp +++ b/code/nel/src/3d/shadow_poly_receiver.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/shadow_skin.cpp b/code/nel/src/3d/shadow_skin.cpp index 717d81f74..204e39d91 100644 --- a/code/nel/src/3d/shadow_skin.cpp +++ b/code/nel/src/3d/shadow_skin.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/shape.cpp b/code/nel/src/3d/shape.cpp index cf61185cd..6b0db63b8 100644 --- a/code/nel/src/3d/shape.cpp +++ b/code/nel/src/3d/shape.cpp @@ -25,6 +25,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/shape_bank.cpp b/code/nel/src/3d/shape_bank.cpp index 08eb867b5..61a65c423 100644 --- a/code/nel/src/3d/shape_bank.cpp +++ b/code/nel/src/3d/shape_bank.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -585,10 +589,7 @@ void CShapeBank::cancelLoadAsync (const std::string &shapeNameNotLwr) bool CShapeBank::isShapeWaiting () { - if (WaitingShapes.size() == 0) - return false; - else - return true; + return !WaitingShapes.empty(); } // *************************************************************************** diff --git a/code/nel/src/3d/shape_bank_user.cpp b/code/nel/src/3d/shape_bank_user.cpp index eb059d51b..5ded42d0d 100644 --- a/code/nel/src/3d/shape_bank_user.cpp +++ b/code/nel/src/3d/shape_bank_user.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/shape_info.cpp b/code/nel/src/3d/shape_info.cpp index 8a4d9cf80..d3a8a4df3 100644 --- a/code/nel/src/3d/shape_info.cpp +++ b/code/nel/src/3d/shape_info.cpp @@ -28,6 +28,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/shifted_triangle_cache.cpp b/code/nel/src/3d/shifted_triangle_cache.cpp index c98c5b103..85cf1313a 100644 --- a/code/nel/src/3d/shifted_triangle_cache.cpp +++ b/code/nel/src/3d/shifted_triangle_cache.cpp @@ -17,6 +17,9 @@ #include "std3d.h" #include "nel/3d/shifted_triangle_cache.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/skeleton_model.cpp b/code/nel/src/3d/skeleton_model.cpp index 8fbab5568..94b6fb896 100644 --- a/code/nel/src/3d/skeleton_model.cpp +++ b/code/nel/src/3d/skeleton_model.cpp @@ -36,6 +36,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/skeleton_shape.cpp b/code/nel/src/3d/skeleton_shape.cpp index 386b9ad1f..230915407 100644 --- a/code/nel/src/3d/skeleton_shape.cpp +++ b/code/nel/src/3d/skeleton_shape.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/skeleton_spawn_script.cpp b/code/nel/src/3d/skeleton_spawn_script.cpp index b77d044fc..d950b43a3 100644 --- a/code/nel/src/3d/skeleton_spawn_script.cpp +++ b/code/nel/src/3d/skeleton_spawn_script.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/skeleton_weight.cpp b/code/nel/src/3d/skeleton_weight.cpp index ba037236a..2f9c412c1 100644 --- a/code/nel/src/3d/skeleton_weight.cpp +++ b/code/nel/src/3d/skeleton_weight.cpp @@ -19,6 +19,9 @@ #include "nel/3d/skeleton_weight.h" #include "nel/misc/stream.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/static_quad_grid.cpp b/code/nel/src/3d/static_quad_grid.cpp deleted file mode 100644 index e45fca011..000000000 --- a/code/nel/src/3d/static_quad_grid.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/static_quad_grid.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/std3d.h b/code/nel/src/3d/std3d.h index 3fc5b55d6..d41f281ec 100644 --- a/code/nel/src/3d/std3d.h +++ b/code/nel/src/3d/std3d.h @@ -14,7 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "nel/misc/types_nl.h" +#ifndef NL_STD3D_H +#define NL_STD3D_H + +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif #include #include @@ -34,6 +42,9 @@ #include #include #include +#include + +#include "nel/misc/types_nl.h" #include "nel/misc/rgba.h" #include "nel/misc/debug.h" @@ -44,7 +55,4 @@ #include "nel/misc/matrix.h" #include "nel/misc/time_nl.h" -#include "nel/3d/debug_vb.h" -#include "nel/3d/transform.h" -#include "nel/3d/quad_grid.h" - +#endif diff --git a/code/nel/src/3d/stereo_debugger.cpp b/code/nel/src/3d/stereo_debugger.cpp index 138f8e3ae..c0c36eb74 100644 --- a/code/nel/src/3d/stereo_debugger.cpp +++ b/code/nel/src/3d/stereo_debugger.cpp @@ -47,6 +47,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { namespace { diff --git a/code/nel/src/3d/stereo_display.cpp b/code/nel/src/3d/stereo_display.cpp index dede3fbf6..6ff13b54c 100644 --- a/code/nel/src/3d/stereo_display.cpp +++ b/code/nel/src/3d/stereo_display.cpp @@ -42,6 +42,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { IStereoDisplay::IStereoDisplay() diff --git a/code/nel/src/3d/stereo_hmd.cpp b/code/nel/src/3d/stereo_hmd.cpp index 207965636..d5f29d107 100644 --- a/code/nel/src/3d/stereo_hmd.cpp +++ b/code/nel/src/3d/stereo_hmd.cpp @@ -38,6 +38,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { IStereoHMD::IStereoHMD() diff --git a/code/nel/src/3d/stereo_libvr.cpp b/code/nel/src/3d/stereo_libvr.cpp index 2f31beac4..d8c843dbf 100644 --- a/code/nel/src/3d/stereo_libvr.cpp +++ b/code/nel/src/3d/stereo_libvr.cpp @@ -54,6 +54,10 @@ extern "C" { using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { extern const char *g_StereoOVR_fp40; //TODO: what? diff --git a/code/nel/src/3d/stereo_ovr.cpp b/code/nel/src/3d/stereo_ovr.cpp index 103b44696..69a2b0db0 100644 --- a/code/nel/src/3d/stereo_ovr.cpp +++ b/code/nel/src/3d/stereo_ovr.cpp @@ -68,6 +68,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { extern const char *g_StereoOVR_fp40; diff --git a/code/nel/src/3d/stereo_ovr_04.cpp b/code/nel/src/3d/stereo_ovr_04.cpp index fcccc2f6b..2f382a176 100644 --- a/code/nel/src/3d/stereo_ovr_04.cpp +++ b/code/nel/src/3d/stereo_ovr_04.cpp @@ -68,6 +68,10 @@ using namespace std; // using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { namespace { diff --git a/code/nel/src/3d/stereo_ovr_fp.cpp b/code/nel/src/3d/stereo_ovr_fp.cpp index 84a74598e..c9ca3c1cc 100644 --- a/code/nel/src/3d/stereo_ovr_fp.cpp +++ b/code/nel/src/3d/stereo_ovr_fp.cpp @@ -23,6 +23,10 @@ limitations under the License. #include "std3d.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { const char *g_StereoOVR_fp40 = "!!ARBfp1.0\n" diff --git a/code/nel/src/3d/stripifier.cpp b/code/nel/src/3d/stripifier.cpp index 96ac4e211..6453cbd1b 100644 --- a/code/nel/src/3d/stripifier.cpp +++ b/code/nel/src/3d/stripifier.cpp @@ -25,6 +25,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/surface_light_grid.cpp b/code/nel/src/3d/surface_light_grid.cpp index 9a4731c00..deec090a4 100644 --- a/code/nel/src/3d/surface_light_grid.cpp +++ b/code/nel/src/3d/surface_light_grid.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/tangent_space_build.cpp b/code/nel/src/3d/tangent_space_build.cpp index 8a1b1100a..f99a7537b 100644 --- a/code/nel/src/3d/tangent_space_build.cpp +++ b/code/nel/src/3d/tangent_space_build.cpp @@ -23,6 +23,9 @@ #include "nel/misc/triangle.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/target_anim_ctrl.cpp b/code/nel/src/3d/target_anim_ctrl.cpp index ea1eeeca0..8145fdb93 100644 --- a/code/nel/src/3d/target_anim_ctrl.cpp +++ b/code/nel/src/3d/target_anim_ctrl.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/tess_block.cpp b/code/nel/src/3d/tess_block.cpp index 3b3c7ec92..917e06a23 100644 --- a/code/nel/src/3d/tess_block.cpp +++ b/code/nel/src/3d/tess_block.cpp @@ -20,6 +20,9 @@ #include "nel/3d/patch_rdr_pass.h" #include "nel/3d/landscape_face_vector_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/tess_face_priority_list.cpp b/code/nel/src/3d/tess_face_priority_list.cpp index 8746a4791..a49c9af75 100644 --- a/code/nel/src/3d/tess_face_priority_list.cpp +++ b/code/nel/src/3d/tess_face_priority_list.cpp @@ -26,6 +26,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/tess_list.cpp b/code/nel/src/3d/tess_list.cpp deleted file mode 100644 index f5b8dc2b5..000000000 --- a/code/nel/src/3d/tess_list.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/tess_list.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/tessellation.cpp b/code/nel/src/3d/tessellation.cpp index 58171c40f..451e1013b 100644 --- a/code/nel/src/3d/tessellation.cpp +++ b/code/nel/src/3d/tessellation.cpp @@ -23,9 +23,13 @@ #include "nel/3d/landscape_profile.h" #include "nel/3d/landscape.h" #include "nel/3d/patchdlm_context.h" + using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -2530,7 +2534,7 @@ void CTessFace::refreshTesselationGeometry() // *************************************************************************** bool CTessFace::updateBindEdge(CTessFace *&edgeFace, bool &splitWanted) { - // Return true, when the bind should be Ok, or if a split has occured. + // Return true, when the bind should be Ok, or if a split has occurred. // Return false only if pointers are updated, without splits. if(edgeFace==NULL) diff --git a/code/nel/src/3d/text_context.cpp b/code/nel/src/3d/text_context.cpp index 1cca5145a..8cee144ca 100644 --- a/code/nel/src/3d/text_context.cpp +++ b/code/nel/src/3d/text_context.cpp @@ -19,6 +19,10 @@ #include "nel/3d/text_context.h" #include "nel/3d/font_generator.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // ------------------------------------------------------------------------------------------------ @@ -74,7 +78,7 @@ uint32 CTextContext::textPush (const char *format, ...) CComputedString csTmp; _CacheStrings.push_back (csTmp); - if (_CacheFreePlaces.size() == 0) + if (_CacheFreePlaces.empty()) _CacheFreePlaces.resize (1); _CacheFreePlaces[0] = (uint32)_CacheStrings.size()-1; _CacheNbFreePlaces = 1; @@ -100,7 +104,7 @@ uint32 CTextContext::textPush (const ucstring &str) CComputedString csTmp; _CacheStrings.push_back (csTmp); - if (_CacheFreePlaces.size() == 0) + if (_CacheFreePlaces.empty()) _CacheFreePlaces.resize (1); _CacheFreePlaces[0] = (uint32)_CacheStrings.size()-1; _CacheNbFreePlaces = 1; diff --git a/code/nel/src/3d/text_context_user.cpp b/code/nel/src/3d/text_context_user.cpp index 441d463f5..1834a93ce 100644 --- a/code/nel/src/3d/text_context_user.cpp +++ b/code/nel/src/3d/text_context_user.cpp @@ -19,6 +19,9 @@ #include "nel/3d/text_context_user.h" #include "nel/misc/hierarchical_timer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture.cpp b/code/nel/src/3d/texture.cpp index bd01f7650..3e248e521 100644 --- a/code/nel/src/3d/texture.cpp +++ b/code/nel/src/3d/texture.cpp @@ -20,6 +20,9 @@ #include "nel/3d/driver.h" #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture_blank.cpp b/code/nel/src/3d/texture_blank.cpp index f9b2b1210..febf30079 100644 --- a/code/nel/src/3d/texture_blank.cpp +++ b/code/nel/src/3d/texture_blank.cpp @@ -18,6 +18,9 @@ #include "nel/3d/texture_blank.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture_blend.cpp b/code/nel/src/3d/texture_blend.cpp index 765766119..0d85664d6 100644 --- a/code/nel/src/3d/texture_blend.cpp +++ b/code/nel/src/3d/texture_blend.cpp @@ -19,6 +19,10 @@ #include "nel/3d/texture_blend.h" #include "nel/misc/common.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/texture_bloom.cpp b/code/nel/src/3d/texture_bloom.cpp deleted file mode 100644 index 52b0ce61c..000000000 --- a/code/nel/src/3d/texture_bloom.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/texture_bloom.h" - - -namespace NL3D { - - -} // NL3D diff --git a/code/nel/src/3d/texture_bump.cpp b/code/nel/src/3d/texture_bump.cpp index 887167de6..adc425c37 100644 --- a/code/nel/src/3d/texture_bump.cpp +++ b/code/nel/src/3d/texture_bump.cpp @@ -20,6 +20,9 @@ +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture_cube.cpp b/code/nel/src/3d/texture_cube.cpp index fbcd425f9..f754aa2a0 100644 --- a/code/nel/src/3d/texture_cube.cpp +++ b/code/nel/src/3d/texture_cube.cpp @@ -25,6 +25,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -193,7 +196,7 @@ bool CTextureCube::isSelectable() const ITexture *CTextureCube::buildNonSelectableVersion(uint index) { if (!isSelectable()) return this; - std::auto_ptr tc(new CTextureCube); + CUniquePtr tc(new CTextureCube); // copy basic texture parameters (ITexture &) *tc.get() = (ITexture &) *this; // invoke ITexture = op for basics parameters diff --git a/code/nel/src/3d/texture_dlm.cpp b/code/nel/src/3d/texture_dlm.cpp index 3e7695936..ab7168827 100644 --- a/code/nel/src/3d/texture_dlm.cpp +++ b/code/nel/src/3d/texture_dlm.cpp @@ -24,6 +24,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture_emboss.cpp b/code/nel/src/3d/texture_emboss.cpp index 414f93093..1c9733bda 100644 --- a/code/nel/src/3d/texture_emboss.cpp +++ b/code/nel/src/3d/texture_emboss.cpp @@ -17,6 +17,12 @@ #include "std3d.h" #include "nel/3d/texture_emboss.h" +using namespace NLMISC; + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { // *********************************************************************************************************** diff --git a/code/nel/src/3d/texture_far.cpp b/code/nel/src/3d/texture_far.cpp index d51d8fe43..594a79131 100644 --- a/code/nel/src/3d/texture_far.cpp +++ b/code/nel/src/3d/texture_far.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; using namespace NL3D; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { CRGBA CTextureFar::_LightmapExpanded[NL_NUM_PIXELS_ON_FAR_TILE_EDGE*NL_MAX_TILES_BY_PATCH_EDGE*NL_NUM_PIXELS_ON_FAR_TILE_EDGE*NL_MAX_TILES_BY_PATCH_EDGE]; diff --git a/code/nel/src/3d/texture_file.cpp b/code/nel/src/3d/texture_file.cpp index bed3b36d7..a30b21bb1 100644 --- a/code/nel/src/3d/texture_file.cpp +++ b/code/nel/src/3d/texture_file.cpp @@ -21,9 +21,13 @@ #include "nel/misc/path.h" #include "nel/misc/debug.h" #include "nel/misc/hierarchical_timer.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture_font.cpp b/code/nel/src/3d/texture_font.cpp index 4e9e3a0a4..cf46d025d 100644 --- a/code/nel/src/3d/texture_font.cpp +++ b/code/nel/src/3d/texture_font.cpp @@ -28,6 +28,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/texture_grouped.cpp b/code/nel/src/3d/texture_grouped.cpp index 1df0c7c7d..b6d42f3b1 100644 --- a/code/nel/src/3d/texture_grouped.cpp +++ b/code/nel/src/3d/texture_grouped.cpp @@ -23,6 +23,10 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { std::map CTextureGrouped::_NameToSize; diff --git a/code/nel/src/3d/texture_mem.cpp b/code/nel/src/3d/texture_mem.cpp index 9a51bd9ab..e2881e88e 100644 --- a/code/nel/src/3d/texture_mem.cpp +++ b/code/nel/src/3d/texture_mem.cpp @@ -21,6 +21,9 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture_multi_file.cpp b/code/nel/src/3d/texture_multi_file.cpp index 5968df550..b2316cc73 100644 --- a/code/nel/src/3d/texture_multi_file.cpp +++ b/code/nel/src/3d/texture_multi_file.cpp @@ -19,6 +19,9 @@ #include "nel/3d/texture_multi_file.h" #include "nel/3d/texture_file.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/texture_near.cpp b/code/nel/src/3d/texture_near.cpp index 6c430f74e..e39279dd1 100644 --- a/code/nel/src/3d/texture_near.cpp +++ b/code/nel/src/3d/texture_near.cpp @@ -15,11 +15,14 @@ // along with this program. If not, see . #include "std3d.h" - - #include "nel/3d/texture_near.h" + using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/texture_user.cpp b/code/nel/src/3d/texture_user.cpp deleted file mode 100644 index 730becc22..000000000 --- a/code/nel/src/3d/texture_user.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/texture_user.h" - - -namespace NL3D -{ - - -void dummyToAvoidStupidCompilerWarning_texture_user_cpp() -{ -} - - -} // NL3D diff --git a/code/nel/src/3d/tile_bank.cpp b/code/nel/src/3d/tile_bank.cpp index 0f05b3df6..1260f3972 100644 --- a/code/nel/src/3d/tile_bank.cpp +++ b/code/nel/src/3d/tile_bank.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { @@ -134,7 +138,7 @@ void CTileBank::serial(NLMISC::IStream &f) throw(NLMISC::EStream) nlassert (f.isReading()); // Reset _AbsPath - _AbsPath=""; + _AbsPath.clear(); // Remove diffuse and additive in transition uint tileCount=(uint)getTileCount (); @@ -243,7 +247,7 @@ void CTileBank::freeTile (int tileIndex) nlassert (tileIndex<(sint)_TileVector.size()); // Free - _TileVector[tileIndex].free(); + _TileVector[tileIndex].freeBlock(); // Resize tile table int i; @@ -437,7 +441,7 @@ void CTileBank::cleanUnusedData () // *************************************************************************** CTileNoiseMap *CTileBank::getTileNoiseMap (uint tileNumber, uint tileSubNoise) { - if (_DisplacementMap.size() == 0) + if (_DisplacementMap.empty()) { // it happens when serial a tile bank with version < 4 return NULL; @@ -782,7 +786,7 @@ void CTile::serial(NLMISC::IStream &f) throw(NLMISC::EStream) _Flags=0; // Initialize alpha name - _BitmapName[alpha]=""; + _BitmapName[alpha].clear(); // Read free flag f.serial (tmp); @@ -804,7 +808,7 @@ void CTile::serial(NLMISC::IStream &f) throw(NLMISC::EStream) // *************************************************************************** void CTile::clearTile (CTile::TBitmap type) { - _BitmapName[type]=""; + _BitmapName[type].clear(); } @@ -1521,7 +1525,7 @@ void CTileSet::setDisplacement (TDisplacement displacement, const std::string& f // *************************************************************************** void CTileSet::cleanUnusedData () { - _Name=""; + _Name.clear(); _ChildName.clear(); _Border128[0].reset (); _Border128[1].reset (); @@ -1853,14 +1857,12 @@ CTileNoise::CTileNoise () { // Not loaded _TileNoiseMap=NULL; - _FileName=""; } // *************************************************************************** CTileNoise::CTileNoise (const CTileNoise &src) { // Default ctor _TileNoiseMap=NULL; - _FileName=""; // Copy *this=src; @@ -1932,7 +1934,7 @@ void CTileNoise::reset() } // Erase filename - _FileName=""; + _FileName.clear(); } // *************************************************************************** diff --git a/code/nel/src/3d/tile_color.cpp b/code/nel/src/3d/tile_color.cpp deleted file mode 100644 index 41ee6d0c3..000000000 --- a/code/nel/src/3d/tile_color.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/tile_color.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/tile_element.cpp b/code/nel/src/3d/tile_element.cpp index 52216749e..6f89abf61 100644 --- a/code/nel/src/3d/tile_element.cpp +++ b/code/nel/src/3d/tile_element.cpp @@ -19,6 +19,9 @@ #include "nel/3d/tile_element.h" #include "nel/misc/debug.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/tile_far_bank.cpp b/code/nel/src/3d/tile_far_bank.cpp index e62903904..d8eceb21e 100644 --- a/code/nel/src/3d/tile_far_bank.cpp +++ b/code/nel/src/3d/tile_far_bank.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; // Define this to force white far texture (debug) // #define NEL_FORCE_WHITE_FAR_TEXTURE +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/tile_light_influence.cpp b/code/nel/src/3d/tile_light_influence.cpp index 55a44af66..53bc2e096 100644 --- a/code/nel/src/3d/tile_light_influence.cpp +++ b/code/nel/src/3d/tile_light_influence.cpp @@ -19,6 +19,9 @@ #include "nel/3d/tile_light_influence.h" #include "nel/misc/debug.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/tile_lumel.cpp b/code/nel/src/3d/tile_lumel.cpp index 41f770b6e..7eaa80199 100644 --- a/code/nel/src/3d/tile_lumel.cpp +++ b/code/nel/src/3d/tile_lumel.cpp @@ -20,6 +20,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/tile_noise_map.cpp b/code/nel/src/3d/tile_noise_map.cpp index 7d68d6a71..7b0d22dda 100644 --- a/code/nel/src/3d/tile_noise_map.cpp +++ b/code/nel/src/3d/tile_noise_map.cpp @@ -18,6 +18,9 @@ #include "nel/3d/tile_noise_map.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/tile_vegetable_desc.cpp b/code/nel/src/3d/tile_vegetable_desc.cpp index bad4ed517..849f19503 100644 --- a/code/nel/src/3d/tile_vegetable_desc.cpp +++ b/code/nel/src/3d/tile_vegetable_desc.cpp @@ -24,6 +24,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/track.cpp b/code/nel/src/3d/track.cpp index bf4dcddf5..a73186525 100644 --- a/code/nel/src/3d/track.cpp +++ b/code/nel/src/3d/track.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/track_keyframer.cpp b/code/nel/src/3d/track_keyframer.cpp index a3af79f1a..d3b5f6fb4 100644 --- a/code/nel/src/3d/track_keyframer.cpp +++ b/code/nel/src/3d/track_keyframer.cpp @@ -18,6 +18,9 @@ #include "nel/3d/track_keyframer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/track_sampled_common.cpp b/code/nel/src/3d/track_sampled_common.cpp index 372cf4f45..2fb7fc132 100644 --- a/code/nel/src/3d/track_sampled_common.cpp +++ b/code/nel/src/3d/track_sampled_common.cpp @@ -25,6 +25,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/track_sampled_quat.cpp b/code/nel/src/3d/track_sampled_quat.cpp index 1ef4e35b8..d49d63aa7 100644 --- a/code/nel/src/3d/track_sampled_quat.cpp +++ b/code/nel/src/3d/track_sampled_quat.cpp @@ -24,6 +24,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/track_sampled_quat_small_header.cpp b/code/nel/src/3d/track_sampled_quat_small_header.cpp index c9826d423..cb0a28f3b 100644 --- a/code/nel/src/3d/track_sampled_quat_small_header.cpp +++ b/code/nel/src/3d/track_sampled_quat_small_header.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/track_sampled_vector.cpp b/code/nel/src/3d/track_sampled_vector.cpp index 2e52764d2..3e19cac64 100644 --- a/code/nel/src/3d/track_sampled_vector.cpp +++ b/code/nel/src/3d/track_sampled_vector.cpp @@ -22,6 +22,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/transform.cpp b/code/nel/src/3d/transform.cpp index 0ec65360d..559a3c355 100644 --- a/code/nel/src/3d/transform.cpp +++ b/code/nel/src/3d/transform.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/transform_shape.cpp b/code/nel/src/3d/transform_shape.cpp index 5c9f730b7..014e997ab 100644 --- a/code/nel/src/3d/transform_shape.cpp +++ b/code/nel/src/3d/transform_shape.cpp @@ -31,6 +31,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/transformable.cpp b/code/nel/src/3d/transformable.cpp index 0061975bf..30ef19e36 100644 --- a/code/nel/src/3d/transformable.cpp +++ b/code/nel/src/3d/transformable.cpp @@ -19,6 +19,9 @@ #include "nel/3d/transformable.h" #include "nel/3d/channel_mixer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/trav_scene.cpp b/code/nel/src/3d/trav_scene.cpp deleted file mode 100644 index b909493cb..000000000 --- a/code/nel/src/3d/trav_scene.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/trav_scene.h" -#include "nel/3d/scene.h" - - - -namespace NL3D -{ - - -} // NL3D - - - - -/* End of trav_scene.cpp */ diff --git a/code/nel/src/3d/u_bone.cpp b/code/nel/src/3d/u_bone.cpp index 680411af7..1f0369929 100644 --- a/code/nel/src/3d/u_bone.cpp +++ b/code/nel/src/3d/u_bone.cpp @@ -19,6 +19,9 @@ #include "nel/3d/bone.h" #include "nel/3d/u_bone.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_camera.cpp b/code/nel/src/3d/u_camera.cpp index ec1a88eda..0a052205f 100644 --- a/code/nel/src/3d/u_camera.cpp +++ b/code/nel/src/3d/u_camera.cpp @@ -19,6 +19,9 @@ #include "nel/3d/u_camera.h" #include "nel/3d/camera.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_instance.cpp b/code/nel/src/3d/u_instance.cpp index 08ecb9933..cb2a273ed 100644 --- a/code/nel/src/3d/u_instance.cpp +++ b/code/nel/src/3d/u_instance.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/u_instance_material.cpp b/code/nel/src/3d/u_instance_material.cpp index b22cd5301..ba870a7fe 100644 --- a/code/nel/src/3d/u_instance_material.cpp +++ b/code/nel/src/3d/u_instance_material.cpp @@ -23,6 +23,9 @@ #include "nel/3d/texture_mem.h" #include "nel/3d/texture_file.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_material.cpp b/code/nel/src/3d/u_material.cpp index e881bbada..b6b9dccc4 100644 --- a/code/nel/src/3d/u_material.cpp +++ b/code/nel/src/3d/u_material.cpp @@ -22,6 +22,9 @@ #include "nel/3d/texture_user.h" #include "nel/3d/driver_user.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_particle_system_instance.cpp b/code/nel/src/3d/u_particle_system_instance.cpp index 77dee0ded..ea5794b19 100644 --- a/code/nel/src/3d/u_particle_system_instance.cpp +++ b/code/nel/src/3d/u_particle_system_instance.cpp @@ -22,6 +22,9 @@ #include "nel/3d/ps_emitter.h" #include "nel/3d/particle_system_model.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_point_light.cpp b/code/nel/src/3d/u_point_light.cpp index 8643a1ae0..5f4d8da97 100644 --- a/code/nel/src/3d/u_point_light.cpp +++ b/code/nel/src/3d/u_point_light.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/u_shape.cpp b/code/nel/src/3d/u_shape.cpp index 9f746dad0..eb179375e 100644 --- a/code/nel/src/3d/u_shape.cpp +++ b/code/nel/src/3d/u_shape.cpp @@ -25,6 +25,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_skeleton.cpp b/code/nel/src/3d/u_skeleton.cpp index b470f879c..e5dd29f4d 100644 --- a/code/nel/src/3d/u_skeleton.cpp +++ b/code/nel/src/3d/u_skeleton.cpp @@ -27,6 +27,9 @@ #include "nel/3d/scene.h" #include "nel/3d/shape_bank.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_transform.cpp b/code/nel/src/3d/u_transform.cpp index 8466c1e38..141986782 100644 --- a/code/nel/src/3d/u_transform.cpp +++ b/code/nel/src/3d/u_transform.cpp @@ -30,6 +30,10 @@ H_AUTO_DECL( NL3D_Transform_Set_Cluster_System ) using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/u_transformable.cpp b/code/nel/src/3d/u_transformable.cpp index 26f84c746..4561cce32 100644 --- a/code/nel/src/3d/u_transformable.cpp +++ b/code/nel/src/3d/u_transformable.cpp @@ -19,6 +19,9 @@ #include "nel/3d/u_transformable.h" #include "nel/3d/transformable.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_visual_collision_mesh.cpp b/code/nel/src/3d/u_visual_collision_mesh.cpp index 92f8d4af6..e51c89105 100644 --- a/code/nel/src/3d/u_visual_collision_mesh.cpp +++ b/code/nel/src/3d/u_visual_collision_mesh.cpp @@ -19,6 +19,9 @@ #include "nel/3d/u_visual_collision_mesh.h" #include "nel/3d/visual_collision_mesh.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/u_water.cpp b/code/nel/src/3d/u_water.cpp index 138a1f340..69326c87c 100644 --- a/code/nel/src/3d/u_water.cpp +++ b/code/nel/src/3d/u_water.cpp @@ -22,6 +22,9 @@ #include "nel/3d/water_model.h" #include "nel/3d/driver_user.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable.cpp b/code/nel/src/3d/vegetable.cpp index b1c708900..b6acf831f 100644 --- a/code/nel/src/3d/vegetable.cpp +++ b/code/nel/src/3d/vegetable.cpp @@ -25,6 +25,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable_blend_layer_model.cpp b/code/nel/src/3d/vegetable_blend_layer_model.cpp index 44754add2..9c3b9dd54 100644 --- a/code/nel/src/3d/vegetable_blend_layer_model.cpp +++ b/code/nel/src/3d/vegetable_blend_layer_model.cpp @@ -28,6 +28,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/vegetable_clip_block.cpp b/code/nel/src/3d/vegetable_clip_block.cpp index cf0d60e59..87d7b7535 100644 --- a/code/nel/src/3d/vegetable_clip_block.cpp +++ b/code/nel/src/3d/vegetable_clip_block.cpp @@ -18,6 +18,9 @@ #include "nel/3d/vegetable_clip_block.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable_def.cpp b/code/nel/src/3d/vegetable_def.cpp deleted file mode 100644 index 74182b413..000000000 --- a/code/nel/src/3d/vegetable_def.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/vegetable_def.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/vegetable_instance_group.cpp b/code/nel/src/3d/vegetable_instance_group.cpp index debd78763..2e48f740a 100644 --- a/code/nel/src/3d/vegetable_instance_group.cpp +++ b/code/nel/src/3d/vegetable_instance_group.cpp @@ -18,6 +18,9 @@ #include "nel/3d/vegetable_instance_group.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable_light_ex.cpp b/code/nel/src/3d/vegetable_light_ex.cpp index e663bddda..dc2109e96 100644 --- a/code/nel/src/3d/vegetable_light_ex.cpp +++ b/code/nel/src/3d/vegetable_light_ex.cpp @@ -19,6 +19,9 @@ #include "nel/3d/vegetable_light_ex.h" #include "nel/3d/point_light_named.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable_manager.cpp b/code/nel/src/3d/vegetable_manager.cpp index e479a5e62..8946bc67b 100644 --- a/code/nel/src/3d/vegetable_manager.cpp +++ b/code/nel/src/3d/vegetable_manager.cpp @@ -35,6 +35,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -747,7 +750,7 @@ void CVegetableManager::deleteClipBlock(CVegetableClipBlock *clipBlock) _EmptyClipBlockList.remove(clipBlock); // delete - _ClipBlockMemory.free(clipBlock); + _ClipBlockMemory.freeBlock(clipBlock); } @@ -782,7 +785,7 @@ void CVegetableManager::deleteSortBlock(CVegetableSortBlock *sortBlock) sortBlock->_Owner->_SortBlockList.remove(sortBlock); // delete - _SortBlockMemory.free(sortBlock); + _SortBlockMemory.freeBlock(sortBlock); } @@ -878,7 +881,7 @@ void CVegetableManager::deleteIg(CVegetableInstanceGroup *ig) // unlink from sortBlock, and delete. sortBlock->_InstanceGroupList.remove(ig); - _InstanceGroupMemory.free(ig); + _InstanceGroupMemory.freeBlock(ig); // decRef the clipBlock diff --git a/code/nel/src/3d/vegetable_quadrant.cpp b/code/nel/src/3d/vegetable_quadrant.cpp index 1246a1a0c..ac83e0a99 100644 --- a/code/nel/src/3d/vegetable_quadrant.cpp +++ b/code/nel/src/3d/vegetable_quadrant.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/vegetable_shape.cpp b/code/nel/src/3d/vegetable_shape.cpp index 7d9991b65..3e4c2b7f0 100644 --- a/code/nel/src/3d/vegetable_shape.cpp +++ b/code/nel/src/3d/vegetable_shape.cpp @@ -24,6 +24,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vegetable_sort_block.cpp b/code/nel/src/3d/vegetable_sort_block.cpp index cbd82aa2b..1ba562cda 100644 --- a/code/nel/src/3d/vegetable_sort_block.cpp +++ b/code/nel/src/3d/vegetable_sort_block.cpp @@ -25,6 +25,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/vegetable_uv8.cpp b/code/nel/src/3d/vegetable_uv8.cpp deleted file mode 100644 index a1d1fec32..000000000 --- a/code/nel/src/3d/vegetable_uv8.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/vegetable_uv8.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/vegetablevb_allocator.cpp b/code/nel/src/3d/vegetablevb_allocator.cpp index f5c833d8a..ff5dc293f 100644 --- a/code/nel/src/3d/vegetablevb_allocator.cpp +++ b/code/nel/src/3d/vegetablevb_allocator.cpp @@ -19,11 +19,16 @@ #include "nel/3d/vegetablevb_allocator.h" #include "nel/3d/vegetable_def.h" +#include "nel/3d/debug_vb.h" using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/vertex_buffer.cpp b/code/nel/src/3d/vertex_buffer.cpp index fc09dc956..bdc9d495f 100644 --- a/code/nel/src/3d/vertex_buffer.cpp +++ b/code/nel/src/3d/vertex_buffer.cpp @@ -20,8 +20,12 @@ #include "nel/misc/vector.h" #include "nel/misc/fast_mem.h" #include "nel/3d/driver.h" + using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -885,7 +889,7 @@ void CVertexBuffer::serialHeader(NLMISC::IStream &f) if(f.isReading()) { _PreferredMemory = RAMPreferred; - _Name = ""; + _Name.clear(); } } } diff --git a/code/nel/src/3d/vertex_buffer_heap.cpp b/code/nel/src/3d/vertex_buffer_heap.cpp index 178efc9a8..e33a6757c 100644 --- a/code/nel/src/3d/vertex_buffer_heap.cpp +++ b/code/nel/src/3d/vertex_buffer_heap.cpp @@ -21,6 +21,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // This code is not used actually and doesn't compile // just preproc comment it #if 0 diff --git a/code/nel/src/3d/vertex_program.cpp b/code/nel/src/3d/vertex_program.cpp index d0c0cfb79..dc717b825 100644 --- a/code/nel/src/3d/vertex_program.cpp +++ b/code/nel/src/3d/vertex_program.cpp @@ -20,6 +20,9 @@ #include "nel/3d/driver.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/vertex_program_parse.cpp b/code/nel/src/3d/vertex_program_parse.cpp index 0e144d54f..f4598659b 100644 --- a/code/nel/src/3d/vertex_program_parse.cpp +++ b/code/nel/src/3d/vertex_program_parse.cpp @@ -17,6 +17,10 @@ #include "std3d.h" #include "nel/3d/vertex_program_parse.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + enum TArguments { #ifdef NL_LITTLE_ENDIAN @@ -1110,7 +1114,7 @@ static void dumpWriteMask(uint mask, std::string &out) { if (mask == 0xf) { - out = ""; + out.clear(); return; } out = "."; @@ -1125,7 +1129,7 @@ static void dumpSwizzle(const CVPSwizzle &swz, std::string &out) { if (swz.isIdentity()) { - out = ""; + out.clear(); return; } out = "."; diff --git a/code/nel/src/3d/vertex_stream_manager.cpp b/code/nel/src/3d/vertex_stream_manager.cpp index 0acb54144..74d2727dd 100644 --- a/code/nel/src/3d/vertex_stream_manager.cpp +++ b/code/nel/src/3d/vertex_stream_manager.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/viewport.cpp b/code/nel/src/3d/viewport.cpp index b84d1d713..6eccdeaca 100644 --- a/code/nel/src/3d/viewport.cpp +++ b/code/nel/src/3d/viewport.cpp @@ -21,6 +21,9 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/visual_collision_entity.cpp b/code/nel/src/3d/visual_collision_entity.cpp index dcae15aef..8f3b97e68 100644 --- a/code/nel/src/3d/visual_collision_entity.cpp +++ b/code/nel/src/3d/visual_collision_entity.cpp @@ -29,6 +29,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/visual_collision_entity_user.cpp b/code/nel/src/3d/visual_collision_entity_user.cpp index 89b44f22f..d13ca57c2 100644 --- a/code/nel/src/3d/visual_collision_entity_user.cpp +++ b/code/nel/src/3d/visual_collision_entity_user.cpp @@ -20,6 +20,9 @@ #include "nel/3d/driver_user.h" #include "nel/misc/hierarchical_timer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/visual_collision_manager.cpp b/code/nel/src/3d/visual_collision_manager.cpp index cafc9948e..6d914464f 100644 --- a/code/nel/src/3d/visual_collision_manager.cpp +++ b/code/nel/src/3d/visual_collision_manager.cpp @@ -28,6 +28,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -98,7 +101,7 @@ CVisualTileDescNode *CVisualCollisionManager::newVisualTileDescNode() // *************************************************************************** void CVisualCollisionManager::deleteVisualTileDescNode(CVisualTileDescNode *ptr) { - _TileDescNodeAllocator.free(ptr); + _TileDescNodeAllocator.freeBlock(ptr); } // *************************************************************************** @@ -110,7 +113,7 @@ CPatchQuadBlock *CVisualCollisionManager::newPatchQuadBlock() // *************************************************************************** void CVisualCollisionManager::deletePatchQuadBlock(CPatchQuadBlock *ptr) { - _PatchQuadBlockAllocator.free(ptr); + _PatchQuadBlockAllocator.freeBlock(ptr); } diff --git a/code/nel/src/3d/visual_collision_manager_user.cpp b/code/nel/src/3d/visual_collision_manager_user.cpp index 800080706..b1ae7923d 100644 --- a/code/nel/src/3d/visual_collision_manager_user.cpp +++ b/code/nel/src/3d/visual_collision_manager_user.cpp @@ -19,6 +19,9 @@ #include "nel/3d/visual_collision_manager_user.h" #include "nel/3d/u_visual_collision_mesh.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/visual_collision_mesh.cpp b/code/nel/src/3d/visual_collision_mesh.cpp index 3217a560f..8de722a2b 100644 --- a/code/nel/src/3d/visual_collision_mesh.cpp +++ b/code/nel/src/3d/visual_collision_mesh.cpp @@ -26,6 +26,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif // TestYoyo. external debug flag bool TESTYOYO_VCM_RedShadow= false; diff --git a/code/nel/src/3d/water_env_map.cpp b/code/nel/src/3d/water_env_map.cpp index a1b954764..9592f2948 100644 --- a/code/nel/src/3d/water_env_map.cpp +++ b/code/nel/src/3d/water_env_map.cpp @@ -24,6 +24,10 @@ #include "nel/misc/common.h" #include "nel/3d/viewport.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/water_env_map_user.cpp b/code/nel/src/3d/water_env_map_user.cpp index d1f9e9961..446ade3b8 100644 --- a/code/nel/src/3d/water_env_map_user.cpp +++ b/code/nel/src/3d/water_env_map_user.cpp @@ -19,6 +19,10 @@ #include "nel/3d/u_scene.h" #include "nel/3d/u_camera.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { ////////////////////// diff --git a/code/nel/src/3d/water_height_map.cpp b/code/nel/src/3d/water_height_map.cpp index 9ab5a31f3..3348ffd05 100644 --- a/code/nel/src/3d/water_height_map.cpp +++ b/code/nel/src/3d/water_height_map.cpp @@ -24,6 +24,9 @@ #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -73,7 +76,7 @@ void CWaterHeightMap::updateUserPos() nlassert(_Size != 0); if ((uint) x == _X && (uint) y == _Y) return; - if ((uint) abs((long int)(x - _X)) < _Size && (uint) abs((long int)(y - _Y)) < _Size) // are there common pixels with the previous location? + if ((uint) std::abs((sint)(x - _X)) < _Size && (uint) std::abs((sint)(y - _Y)) < _Size) // are there common pixels with the previous location? { // compute zone @@ -305,7 +308,11 @@ void CWaterHeightMap::makeCpy(uint buffer, uint dX, uint dY, uint sX, uint sY, { if (dest < src) { +#ifdef NL_COMP_VC14 + std::copy(src, src + width, stdext::make_unchecked_array_iterator(dest)); +#else std::copy(src, src + width, dest); +#endif } else { diff --git a/code/nel/src/3d/water_model.cpp b/code/nel/src/3d/water_model.cpp index e6ae132e1..d65ad582d 100644 --- a/code/nel/src/3d/water_model.cpp +++ b/code/nel/src/3d/water_model.cpp @@ -36,6 +36,9 @@ using NLMISC::CVector2f; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/water_pool_manager.cpp b/code/nel/src/3d/water_pool_manager.cpp index c377ff1f3..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/water_shape.cpp b/code/nel/src/3d/water_shape.cpp index f5e26b8d7..df5e6dadf 100644 --- a/code/nel/src/3d/water_shape.cpp +++ b/code/nel/src/3d/water_shape.cpp @@ -26,6 +26,9 @@ #include "nel/3d/water_height_map.h" #include +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/zone.cpp b/code/nel/src/3d/zone.cpp index 263c61539..029f6da81 100644 --- a/code/nel/src/3d/zone.cpp +++ b/code/nel/src/3d/zone.cpp @@ -30,6 +30,9 @@ using namespace std; // define it only for debug bind. //#define NL3D_DEBUG_DONT_BIND_PATCH +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/zone_corner_smoother.cpp b/code/nel/src/3d/zone_corner_smoother.cpp index 430c6929f..568d4c6a3 100644 --- a/code/nel/src/3d/zone_corner_smoother.cpp +++ b/code/nel/src/3d/zone_corner_smoother.cpp @@ -19,6 +19,9 @@ #include "nel/3d/zone_corner_smoother.h" #include "nel/3d/patchuv_locator.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/zone_lighter.cpp b/code/nel/src/3d/zone_lighter.cpp index c70ad0ba2..fc48be6d5 100644 --- a/code/nel/src/3d/zone_lighter.cpp +++ b/code/nel/src/3d/zone_lighter.cpp @@ -51,6 +51,10 @@ using namespace std; // Define this to render the zbuffers into a bitmap zbuffer and save it into a jpeg // #define SAVE_ZBUFFER "c:/temp" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + #define DEFAULT_JITTER 0.4f #define DEFAULT_ZBUFFER_LANDSCAPE_SIZE 32768 #define DEFAULT_ZBUFFER_OBJECT_SIZE (32768*3) @@ -2847,7 +2851,7 @@ bool CZoneLighter::isLightableShape(IShape &shape) void CZoneLighter::lightShapes(uint zoneID, const CLightDesc& description) { /// compute light for the lightable shapes in the given zone - if (_LightableShapes.size() == 0) return; + if (_LightableShapes.empty()) return; uint numShapePerThread = 1 + ((uint)_LightableShapes.size() / _ProcessCount); uint currShapeIndex = 0; @@ -3781,7 +3785,9 @@ uint CZoneLighter::getAPatch (uint process) nlassert(index < _PatchInfo.size()); - if (access.value().size() == 0) + nlassert(index < _PatchInfo.size()); + + if (access.value().empty()) // no more patches return 0xffffffff; diff --git a/code/nel/src/3d/zone_manager.cpp b/code/nel/src/3d/zone_manager.cpp index efa36fa66..1ba32806d 100644 --- a/code/nel/src/3d/zone_manager.cpp +++ b/code/nel/src/3d/zone_manager.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -170,7 +173,7 @@ bool CZoneManager::isWorkComplete (CZoneManager::SZoneManagerWork &rWork) rWork.NameZoneAdded = ite->ZoneToAddName; rWork.ZoneRemoved = false; rWork.IdZoneToRemove = 0; - rWork.NameZoneRemoved = ""; + rWork.NameZoneRemoved.clear(); rWork.Zone = const_cast(ite->Zone); _LoadedZones.push_back (ite->ZoneToAddId); @@ -187,7 +190,7 @@ bool CZoneManager::isWorkComplete (CZoneManager::SZoneManagerWork &rWork) { _RemovingZone = false; rWork.ZoneAdded = false; - rWork.NameZoneAdded = ""; + rWork.NameZoneAdded.clear(); rWork.ZoneRemoved = true; rWork.IdZoneToRemove = _IdZoneToRemove; rWork.NameZoneRemoved = getZoneNameFromId(_IdZoneToRemove); @@ -211,7 +214,7 @@ bool CZoneManager::isWorkComplete (CZoneManager::SZoneManagerWork &rWork) // ------------------------------------------------------------------------------------------------ void CZoneManager::clear() { - nlassert(_LoadingZones.size() == 0); + nlassert(_LoadingZones.empty()); _LoadedZones.clear(); _RemovingZone = false; } diff --git a/code/nel/src/3d/zone_search.cpp b/code/nel/src/3d/zone_search.cpp index f850d4377..71704d37f 100644 --- a/code/nel/src/3d/zone_search.cpp +++ b/code/nel/src/3d/zone_search.cpp @@ -23,6 +23,9 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { @@ -58,8 +61,6 @@ CZoneSearch::CZoneSearch() */ pair CZoneSearch::getZoneName(uint x, uint y, uint cx, uint cy) { - char name[13]; - uint zoneY = y / _SizeZoneY + 1; uint zoneX = x / _SizeZoneX; @@ -71,9 +72,7 @@ pair CZoneSearch::getZoneName(uint x, uint y, uint cx, uint cy) char firstLetter = zoneX / 26 + 'A'; char secondLetter = zoneX % 26 + 'A'; - sprintf(name, "%d_%c%c.zonel", zoneY, firstLetter, secondLetter); - - return std::pair(string(name), distance); + return std::pair(NLMISC::toString("%u_%c%c.zonel", zoneY, firstLetter, secondLetter), distance); } @@ -211,12 +210,9 @@ void CZoneSearch::getListZoneId (uint x, uint y, uint sizeArea, vector & std::string CZoneSearch::getZoneNameFromId (uint16 zoneid) { - char name[16]; - sint x = zoneid & 255; sint y = zoneid >> 8; - sprintf (name, "%d_%c%c.zonel", y+1, (char)('A'+(x/26)), (char)('A'+(x%26))); - return string(name); + return NLMISC::toString("%d_%c%c.zonel", y + 1, (char)('A' + (x / 26)), (char)('A' + (x % 26))); } diff --git a/code/nel/src/3d/zone_smoother.cpp b/code/nel/src/3d/zone_smoother.cpp index 2ae360933..6fd108ac7 100644 --- a/code/nel/src/3d/zone_smoother.cpp +++ b/code/nel/src/3d/zone_smoother.cpp @@ -18,6 +18,9 @@ #include "nel/3d/zone_smoother.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NL3D { diff --git a/code/nel/src/3d/zone_symmetrisation.cpp b/code/nel/src/3d/zone_symmetrisation.cpp index a12daa972..51b00b3f3 100644 --- a/code/nel/src/3d/zone_symmetrisation.cpp +++ b/code/nel/src/3d/zone_symmetrisation.cpp @@ -22,6 +22,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/3d/zone_tgt_smoother.cpp b/code/nel/src/3d/zone_tgt_smoother.cpp index 865d72609..1a4902203 100644 --- a/code/nel/src/3d/zone_tgt_smoother.cpp +++ b/code/nel/src/3d/zone_tgt_smoother.cpp @@ -18,9 +18,14 @@ #include "nel/3d/zone_tgt_smoother.h" #include "nel/misc/plane.h" + using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NL3D { diff --git a/code/nel/src/georges/form.cpp b/code/nel/src/georges/form.cpp index 5a23441ee..22ed15a2e 100644 --- a/code/nel/src/georges/form.cpp +++ b/code/nel/src/georges/form.cpp @@ -104,10 +104,10 @@ CForm::~CForm () // *************************************************************************** -void CForm::write (xmlDocPtr doc, const char *filename) +void CForm::write (xmlDocPtr doc, const std::string &filename) { // Save the filename - if (filename) + if (!filename.empty()) _Filename = CFile::getFilename (filename); // Create the first node @@ -176,7 +176,7 @@ void CForm::readParent (const char *parent, CFormLoader &loader) // *************************************************************************** -void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const char *filename) +void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const std::string &filename) { // Save the filename _Filename = CFile::getFilename (filename); @@ -188,8 +188,8 @@ void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const cha if ( ((const char*)node->name == NULL) || (strcmp ((const char*)node->name, "FORM") != 0) ) { // Make an error message - warning (true, "read", "XML Syntax error in block line %p, node (%s) should be FORM.", - node->content, node->name); + warning (true, "read", "XML Syntax error in block line %d, node (%s) should be FORM.", + (sint)node->line, node->name); } // Get first struct node @@ -197,8 +197,8 @@ void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const cha if (child == NULL) { // Throw exception - warning (true, "read", "Syntax error in block line %p, node (%s) should have a STRUCT child node.", - node->content, node->name); + warning (true, "read", "Syntax error in block line %d, node (%s) should have a STRUCT child node.", + (sint)node->line, node->name); } // Read the struct @@ -271,7 +271,7 @@ void CForm::write (class NLMISC::IStream &stream) // *************************************************************************** -bool CForm::insertParent (uint before, const char *filename, CForm *parent) +bool CForm::insertParent (uint before, const std::string &filename, CForm *parent) { // Set or reset ? nlassert (parent); @@ -289,7 +289,7 @@ bool CForm::insertParent (uint before, const char *filename, CForm *parent) else { // Output an error - warning (false, "insertParent", "Can't insert parent form (%s) that has not the same DFN.", filename); + warning (false, "insertParent", "Can't insert parent form (%s) that has not the same DFN.", filename.c_str()); } return false; @@ -346,7 +346,7 @@ const std::string &CForm::getFilename () const // *************************************************************************** -void CForm::warning (bool exception, const char *function, const char *format, ... ) const +void CForm::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -356,7 +356,7 @@ void CForm::warning (bool exception, const char *function, const char *format, . va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CForm::%s) in form (%s) : %s", function, _Filename.c_str (), buffer); + NLGEORGES::warning (exception, "(CForm::%s) in form (%s) : %s", function.c_str(), _Filename.c_str (), buffer); } // *************************************************************************** diff --git a/code/nel/src/georges/form_dfn.cpp b/code/nel/src/georges/form_dfn.cpp index 16ee74d5b..3f271b976 100644 --- a/code/nel/src/georges/form_dfn.cpp +++ b/code/nel/src/georges/form_dfn.cpp @@ -56,7 +56,7 @@ void CFormDfn::removeEntry( uint idx ) // *************************************************************************** -void CFormDfn::write (xmlDocPtr doc, const char *filename) +void CFormDfn::write (xmlDocPtr doc, const std::string &filename) { // Save filename _Filename = CFile::getFilename (filename); @@ -121,7 +121,7 @@ void CFormDfn::write (xmlDocPtr doc, const char *filename) // *************************************************************************** -void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const char *filename) +void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const std::string &filename) { // Save filename _Filename = CFile::getFilename (filename); @@ -130,7 +130,7 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const if ( ((const char*)root->name == NULL) || (strcmp ((const char*)root->name, "DFN") != 0) ) { // Throw exception - warning (true, "read", "XML Syntax error in block line %p, node (%s) should be DFN.", root->content, root->name); + warning (true, "read", "XML Syntax error in block line %d, node (%s) should be DFN.", (sint)root->line, root->name); } // Count the parent @@ -162,8 +162,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, aguments Name not found.", - parent->name, parent->content); + warning (true, "read", "XML Syntax error in block (%s) line %d, aguments Name not found.", + parent->name, (sint)parent->line); } // Next parent @@ -245,8 +245,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const if ((Entries[childNumber].Type == NULL) && !forceLoad) { // Throw exception - warning (true, "read", "In XML block (%s) line %p, file not found %s.", - child->name, child->content, Entries[childNumber].Filename.c_str ()); + warning (true, "read", "In XML block (%s) line %d, file not found %s.", + child->name, (sint)child->line, Entries[childNumber].Filename.c_str ()); } // Read the default value @@ -262,8 +262,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML In block (%s) line %p, no filename found for the .typ file.", - child->name, child->content); + warning (true, "read", "XML In block (%s) line %d, no filename found for the .typ file.", + child->name, (sint)child->line); } } else if (stricmp (typeName, "Dfn") == 0) @@ -279,15 +279,15 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const if ((Entries[childNumber].Dfn == NULL) && !forceLoad) { // Throw exception - warning (true, "read", "XML In block (%s) line %p, file not found %s.", - child->name, child->content, Entries[childNumber].Filename.c_str ()); + warning (true, "read", "XML In block (%s) line %d, file not found %s.", + child->name, (sint)child->line, Entries[childNumber].Filename.c_str ()); } } else { // Throw exception - warning (true, "read", "XML In block (%s) line %p, no filename found for the .typ file.", - child->name, child->content); + warning (true, "read", "XML In block (%s) line %d, no filename found for the .typ file.", + child->name, (sint)child->line); } } else if (stricmp (typeName, "DfnPointer") == 0) @@ -297,8 +297,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, element has not a valid type name attribut \"Type = %s\".", - child->name, child->content, typeName); + warning (true, "read", "XML Syntax error in block (%s) line %d, element has not a valid type name attribut \"Type = %s\".", + child->name, (sint)child->line, typeName); } // Delete the value @@ -307,8 +307,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, element has no type name attribut \"Type = [Type][Dfn][DfnPointer]\".", - child->name, child->content); + warning (true, "read", "XML Syntax error in block (%s) line %d, element has no type name attribut \"Type = [Type][Dfn][DfnPointer]\".", + child->name, (sint)child->line); } // Get the array attrib @@ -325,8 +325,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, aguments Name not found.", - root->name, root->content); + warning (true, "read", "XML Syntax error in block (%s) line %d, aguments Name not found.", + root->name, (sint)root->line); } // Next child @@ -459,9 +459,9 @@ void CFormDfn::setNumParent (uint size) // *************************************************************************** -void CFormDfn::setParent (uint parent, CFormLoader &loader, const char *filename) +void CFormDfn::setParent (uint parent, CFormLoader &loader, const std::string &filename) { - if (strcmp (filename, "")==0) + if (filename.empty()) Parents[parent].Parent = NULL; else Parents[parent].Parent = loader.loadFormDfn (filename, false); @@ -470,7 +470,7 @@ void CFormDfn::setParent (uint parent, CFormLoader &loader, const char *filename // *************************************************************************** -void CFormDfn::CEntry::setType (CFormLoader &loader, const char *filename) +void CFormDfn::CEntry::setType (CFormLoader &loader, const std::string &filename) { TypeElement = EntryType; Dfn = NULL; @@ -485,7 +485,7 @@ void CFormDfn::CEntry::setType( TEntryType type ) // *************************************************************************** -void CFormDfn::CEntry::setDfn (CFormLoader &loader, const char *filename) +void CFormDfn::CEntry::setDfn (CFormLoader &loader, const std::string &filename) { TypeElement = EntryDfn; Filename = filename; @@ -498,7 +498,7 @@ void CFormDfn::CEntry::setDfn (CFormLoader &loader, const char *filename) void CFormDfn::CEntry::setDfnPointer () { TypeElement = EntryVirtualDfn; - Filename = ""; + Filename.clear(); Type = NULL; Dfn = NULL; } @@ -512,7 +512,7 @@ const std::string &CFormDfn::CEntry::getName () const // *************************************************************************** -void CFormDfn::CEntry::setName (const char *name) +void CFormDfn::CEntry::setName (const std::string &name) { Name = name; } @@ -526,7 +526,7 @@ const std::string &CFormDfn::CEntry::getDefault () const // *************************************************************************** -void CFormDfn::CEntry::setDefault (const char *def) +void CFormDfn::CEntry::setDefault (const std::string &def) { Default = def; } @@ -561,7 +561,7 @@ const std::string &CFormDfn::CEntry::getFilename() const // *************************************************************************** -void CFormDfn::CEntry::setFilename (const char *def) +void CFormDfn::CEntry::setFilename (const std::string &def) { Filename = def; } @@ -849,14 +849,14 @@ const std::string &CFormDfn::CEntry::getFilenameExt() const // *************************************************************************** -void CFormDfn::CEntry::setFilenameExt (const char *ext) +void CFormDfn::CEntry::setFilenameExt (const std::string &ext) { FilenameExt = ext; } // *************************************************************************** -void CFormDfn::warning (bool exception, const char *function, const char *format, ... ) const +void CFormDfn::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -866,7 +866,7 @@ void CFormDfn::warning (bool exception, const char *function, const char *format va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CFormDfn::%s) in form DFN (%s) : %s", function, _Filename.c_str (), buffer); + NLGEORGES::warning (exception, "(CFormDfn::%s) in form DFN (%s) : %s", function.c_str(), _Filename.c_str (), buffer); } // *************************************************************************** diff --git a/code/nel/src/georges/form_elm.cpp b/code/nel/src/georges/form_elm.cpp index 01e4010e2..a28fe2e9c 100644 --- a/code/nel/src/georges/form_elm.cpp +++ b/code/nel/src/georges/form_elm.cpp @@ -356,7 +356,7 @@ CForm *CFormElm::getForm () const // *************************************************************************** -bool CFormElm::getNodeByName (UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round) +bool CFormElm::getNodeByName (UFormElm **result, const std::string &name, TWhereIsNode *where, bool verbose, uint32 round) { const UFormElm *resultConst = NULL; if (((const UFormElm*)this)->getNodeByName (&resultConst, name, where, verbose, round)) @@ -369,7 +369,7 @@ bool CFormElm::getNodeByName (UFormElm **result, const char *name, TWhereIsNode // *************************************************************************** -bool CFormElm::getNodeByName (const UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round) const +bool CFormElm::getNodeByName (const UFormElm **result, const std::string &name, TWhereIsNode *where, bool verbose, uint32 round) const { // The parent Dfn const CFormDfn *parentDfn; @@ -402,7 +402,7 @@ bool CFormElm::getNodeByName (const UFormElm **result, const char *name, TWhereI // *************************************************************************** -bool CFormElm::getValueByName (string& result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (string& result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // The parent Dfn const CFormDfn *parentDfn; @@ -430,13 +430,13 @@ bool CFormElm::getValueByName (string& result, const char *name, TEval evaluate, else { // Error message - warning (false, "getValueByName", "The node (%s) is not an atom element. Can't return a value.", name); + warning (false, "getValueByName", "The node (%s) is not an atom element. Can't return a value.", name.c_str()); } } else { // Error message - warning (false, "getValueByName", "Can't find the node (%s).", name); + warning (false, "getValueByName", "Can't find the node (%s).", name.c_str()); } // Error @@ -445,13 +445,13 @@ bool CFormElm::getValueByName (string& result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (sint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (sint8 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -459,13 +459,13 @@ bool CFormElm::getValueByName (sint8 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (uint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (uint8 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -473,13 +473,13 @@ bool CFormElm::getValueByName (uint8 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (sint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (sint16 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -487,13 +487,13 @@ bool CFormElm::getValueByName (sint16 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (uint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (uint16 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -501,13 +501,13 @@ bool CFormElm::getValueByName (uint16 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (sint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (sint32 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -515,13 +515,13 @@ bool CFormElm::getValueByName (sint32 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (uint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (uint32 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -529,13 +529,13 @@ bool CFormElm::getValueByName (uint32 &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (float &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (float &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -543,13 +543,13 @@ bool CFormElm::getValueByName (float &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (double &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName(double &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -557,13 +557,13 @@ bool CFormElm::getValueByName (double &result, const char *name, TEval evaluate, // *************************************************************************** -bool CFormElm::getValueByName (bool &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (bool &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -571,13 +571,13 @@ bool CFormElm::getValueByName (bool &result, const char *name, TEval evaluate, T // *************************************************************************** -bool CFormElm::getValueByName (NLMISC::CRGBA &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round) const +bool CFormElm::getValueByName (NLMISC::CRGBA &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round) const { // Get the string value string value; if (getValueByName (value, name, evaluate, where, round)) { - return convertValue (result, value.c_str ()); + return convertValue (result, value); } return false; @@ -592,7 +592,7 @@ UFormElm *CFormElm::getParent () const // *************************************************************************** -bool CFormElm::createNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, +bool CFormElm::createNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool &created) @@ -608,7 +608,7 @@ bool CFormElm::createNodeByName (const char *name, const CFormDfn **parentDfn, u // *************************************************************************** -bool CFormElm::deleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, +bool CFormElm::deleteNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array) @@ -625,7 +625,7 @@ bool CFormElm::deleteNodeByName (const char *name, const CFormDfn **parentDfn, u // *************************************************************************** -bool CFormElm::getNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, +bool CFormElm::getNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool &parentVDfnArray, bool verbose, uint32 round) const @@ -641,7 +641,7 @@ bool CFormElm::getNodeByName (const char *name, const CFormDfn **parentDfn, uint // *************************************************************************** -bool CFormElm::arrayInsertNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, +bool CFormElm::arrayInsertNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool verbose, uint arrayIndex) const @@ -715,7 +715,7 @@ bool CFormElm::arrayInsertNodeByName (const char *name, const CFormDfn **parentD // *************************************************************************** -bool CFormElm::arrayDeleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, +bool CFormElm::arrayDeleteNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool verbose, uint arrayIndex) const @@ -760,7 +760,7 @@ bool CFormElm::arrayDeleteNodeByName (const char *name, const CFormDfn **parentD // *************************************************************************** -bool CFormElm::getInternalNodeByName (CForm *form, const char *name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, TNodeAction action, bool &created, bool &parentVDfnArray, bool verbose, uint32 round) +bool CFormElm::getInternalNodeByName (CForm *form, const std::string &name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, TNodeAction action, bool &created, bool &parentVDfnArray, bool verbose, uint32 round) { // *** Init output variables created = false; @@ -815,7 +815,7 @@ bool CFormElm::getInternalNodeByName (CForm *form, const char *name, const CForm // *** Parsing variables // Current token start and end - const char *startToken = name; + const char *startToken = name.c_str(); const char *endToken; // Current token start @@ -836,7 +836,7 @@ bool CFormElm::getInternalNodeByName (CForm *form, const char *name, const CForm bool inArrayIndex = false; // Index in the array - uint arrayIndex; + uint arrayIndex = 0; // Bool next token must be an array index bool wantArrayIndex = false; @@ -909,7 +909,7 @@ bool CFormElm::getInternalNodeByName (CForm *form, const char *name, const CForm // Get the virtual node by name UFormElm *uelm; - if (parentPtr->getRootNode ().getNodeByName (&uelm, formName.c_str (), NULL, verbose, round+1) && uelm) + if (parentPtr->getRootNode ().getNodeByName (&uelm, formName, NULL, verbose, round+1) && uelm) { // Value node ? if (uelm->isVirtualStruct ()) @@ -1134,7 +1134,7 @@ bool CFormElm::getInternalNodeByName (CForm *form, const char *name, const CForm case TokenString: { // To int - if (sscanf (token.c_str(), "%d", &arrayIndex)!=1) + if (!fromString(token, arrayIndex)) { // Error message smprintf (error, 512, "Keyword (%s) is not an array index.", token.c_str()); @@ -1406,7 +1406,7 @@ exit:; bool arrayParent; bool createdParent; bool parentVDfnArray; - if (getInternalNodeByName (parentPtr, formName.c_str (), &parentDfnParent, indexDfnParent, &nodeDfnParent, &nodeTypeParent, &nodeParent, typeParent, arrayParent, action, createdParent, parentVDfnArray, false, round+1)) + if (getInternalNodeByName (parentPtr, formName, &parentDfnParent, indexDfnParent, &nodeDfnParent, &nodeTypeParent, &nodeParent, typeParent, arrayParent, action, createdParent, parentVDfnArray, false, round+1)) { // Node found ? if (nodeParent) @@ -1466,7 +1466,7 @@ exit:; // Turn around.. string formName; (*node)->getFormName (formName); - warning (false, formName.c_str (), form->getFilename ().c_str(), "getInternalNodeByName", "Recursive call on the same node (%s), look for loop references or inheritances.", name); + warning (false, formName, form->getFilename (), "getInternalNodeByName", "Recursive call on the same node (%s), look for loop references or inheritances.", name.c_str()); return false; } } @@ -1476,7 +1476,7 @@ exit:; nlassert (*error); // Get the best form name - warning (false, currentName.c_str (), form->getFilename ().c_str(), "getInternalNodeByName", "Getting the node (%s) : %s", name, error); + warning (false, currentName, form->getFilename (), "getInternalNodeByName", "Getting the node (%s) : %s", name.c_str(), error); } return !errorAppend; @@ -1512,7 +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 @@ -1534,7 +1534,7 @@ void CFormElm::unlink (CFormElm * /* child */) // *************************************************************************** -bool CFormElm::setValueByName (const char *value, const char *name, bool *created) +bool CFormElm::setValueByName(const std::string &value, const std::string &name, bool *created) { // The parent Dfn const CFormDfn *parentDfn; @@ -1567,13 +1567,13 @@ bool CFormElm::setValueByName (const char *value, const char *name, bool *create else { // Error message - warning (false, "setValueByName", "The node (%s) is not an atom element. Can't set the value.", name); + warning (false, "setValueByName", "The node (%s) is not an atom element. Can't set the value.", name.c_str()); } } else { // Error message - warning (false, "setValueByName", "Can't created / set the node (%s).", name); + warning (false, "setValueByName", "Can't created / set the node (%s).", name.c_str()); // Created flag if (created) @@ -1586,79 +1586,79 @@ bool CFormElm::setValueByName (const char *value, const char *name, bool *create // *************************************************************************** -bool CFormElm::setValueByName (sint8 value, const char *name, bool *created) +bool CFormElm::setValueByName (sint8 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (uint8 value, const char *name, bool *created) +bool CFormElm::setValueByName (uint8 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (sint16 value, const char *name, bool *created) +bool CFormElm::setValueByName (sint16 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (uint16 value, const char *name, bool *created) +bool CFormElm::setValueByName (uint16 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (sint32 value, const char *name, bool *created) +bool CFormElm::setValueByName(sint32 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (uint32 value, const char *name, bool *created) +bool CFormElm::setValueByName (uint32 value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (float value, const char *name, bool *created) +bool CFormElm::setValueByName (float value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (double value, const char *name, bool *created) +bool CFormElm::setValueByName (double value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (bool value, const char *name, bool *created) +bool CFormElm::setValueByName (bool value, const std::string &name, bool *created) { - return setValueByName (toString (value).c_str (), name, created); + return setValueByName (toString (value), name, created); } // *************************************************************************** -bool CFormElm::setValueByName (NLMISC::CRGBA value, const char *name, bool *created) +bool CFormElm::setValueByName (NLMISC::CRGBA value, const std::string &name, bool *created) { char tmp[512]; smprintf (tmp, 512, "%d,%d,%d", value.R, value.G, value.B); - return setValueByName (tmp, name, created); + return setValueByName(std::string(tmp), name, created); } // *************************************************************************** -void CFormElm::warning (bool exception, const char *formName, const char *formFileName, const char *function, const char *format, ... ) +void CFormElm::warning (bool exception, const std::string &formName, const std::string &formFileName, const std::string &function, const char *format, ... ) { // Make a buffer string va_list args; @@ -1668,19 +1668,19 @@ void CFormElm::warning (bool exception, const char *formName, const char *formFi va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CFormElm::%s) on node (%s) in form (%s) : %s", function, formName, formFileName, buffer); + NLGEORGES::warning (exception, "(CFormElm::%s) on node (%s) in form (%s) : %s", function.c_str(), formName.c_str(), formFileName.c_str(), buffer); } // *************************************************************************** -void CFormElm::warning (bool exception, const char *function, const char *format, ... ) const +void CFormElm::warning (bool exception, const std::string &function, const char *format, ... ) const { va_list args; va_start( args, format ); string formName; getFormName (formName); - warning (exception, formName.c_str (), getForm ()->getFilename ().c_str (), function, format, args); + warning (exception, formName, getForm ()->getFilename (), function, format, args); va_end( args ); } @@ -1741,7 +1741,7 @@ bool CFormElmStruct::getStructNodeName (uint element, string &result) const } else { - warning (false, "getStructNodeName", "Index (%d) out of bound (%d).", element, Elements.size() ); + warning (false, "getStructNodeName", "Index (%u) out of bound (%u).", element, (uint)Elements.size() ); return false; } } @@ -1757,7 +1757,7 @@ bool CFormElmStruct::getStructNode (uint element, const UFormElm **result) const } else { - warning (false, "getStructNode", "Index (%d) out of bound (%d).", element, Elements.size() ); + warning (false, "getStructNode", "Index (%u) out of bound (%u).", element, (uint)Elements.size() ); return false; } } @@ -1780,14 +1780,14 @@ bool CFormElmStruct::getStructNode (uint element, UFormElm **result) } else { - warning (false, "getStructNode", "Index (%d) out of bound (%d).", element, Elements.size() ); + warning (false, "getStructNode", "Index (%u) out of bound (%u).", element, (uint)Elements.size() ); return false; } } // *************************************************************************** -xmlNodePtr CFormElmStruct::write (xmlNodePtr root, const CForm *form, const char *structName, bool forceWrite) const +xmlNodePtr CFormElmStruct::write (xmlNodePtr root, const CForm *form, const std::string &structName, bool forceWrite) const { // Is used ? if (isUsed (form) || forceWrite) @@ -1796,10 +1796,10 @@ xmlNodePtr CFormElmStruct::write (xmlNodePtr root, const CForm *form, const cha xmlNodePtr node = xmlNewChild ( root, NULL, (const xmlChar*)"STRUCT", NULL); // Element name - if (structName != NULL) + if (!structName.empty()) { // Struct name - xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName); + xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName.c_str()); } // For each elements of the structure @@ -1808,7 +1808,7 @@ xmlNodePtr CFormElmStruct::write (xmlNodePtr root, const CForm *form, const cha { // Create a node if it exist if (Elements[elm].Element) - Elements[elm].Element->write (node, form, Elements[elm].Name.c_str()); + Elements[elm].Element->write (node, form, Elements[elm].Name); } // Return the new node @@ -1905,8 +1905,8 @@ void CFormElmStruct::read (xmlNodePtr node, CFormLoader &loader, const CFormDfn else { // Make a warning message - warning (false, "read", "In block line %p, node (%s) type in DFN have changed.", - child->content, child->name); + warning (false, "read", "In block line %u, node (%s) type in DFN have changed.", + (uint)child->line, child->name); } } else @@ -1918,8 +1918,8 @@ void CFormElmStruct::read (xmlNodePtr node, CFormLoader &loader, const CFormDfn } // Throw exception - warning (true, "read", "XML Syntax error in block line %p, node (%s) name should be STRUCT, ATOM or ARRAY.", - child->content, child->name); + warning (true, "read", "XML Syntax error in block line %u, node (%s) name should be STRUCT, ATOM or ARRAY.", + (uint)child->line, child->name); } } @@ -2066,7 +2066,7 @@ void CFormElmStruct::getFormName (std::string &result, const CFormElm *child) co // Reset the result if (child == NULL) { - result = ""; + result.clear(); result.reserve (50); } @@ -2101,7 +2101,7 @@ void CFormElmStruct::getFormName (std::string &result, const CFormElm *child) co // *************************************************************************** -void CFormElmStruct::warning (bool exception, const char *function, const char *format, ... ) const +void CFormElmStruct::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -2113,7 +2113,7 @@ void CFormElmStruct::warning (bool exception, const char *function, const char * // Set the warning string formName; getFormName (formName, NULL); - NLGEORGES::warning (exception, "(CFormElmStruct::%s) on node (%s) in form (%s) : %s", function, formName.c_str (), Form->getFilename ().c_str (), buffer); + NLGEORGES::warning (exception, "(CFormElmStruct::%s) on node (%s) in form (%s) : %s", function.c_str(), formName.c_str (), Form->getFilename ().c_str (), buffer); } // *************************************************************************** @@ -2142,7 +2142,7 @@ CFormElmVirtualStruct::CFormElmVirtualStruct (CForm *form, CFormElm *parentNode, // *************************************************************************** -xmlNodePtr CFormElmVirtualStruct::write (xmlNodePtr root, const CForm *form, const char *structName, bool forceWrite) const +xmlNodePtr CFormElmVirtualStruct::write (xmlNodePtr root, const CForm *form, const std::string &structName, bool forceWrite) const { // Is used ? if (isUsed (form) || forceWrite) @@ -2154,10 +2154,10 @@ xmlNodePtr CFormElmVirtualStruct::write (xmlNodePtr root, const CForm *form, co xmlSetProp (node, (const xmlChar*)"DfnName", (const xmlChar*)DfnFilename.c_str()); // Element name - if (structName != NULL) + if (!structName.empty()) { // Struct name - xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName); + xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName.c_str()); } // For each elements of the structure @@ -2166,7 +2166,7 @@ xmlNodePtr CFormElmVirtualStruct::write (xmlNodePtr root, const CForm *form, co { // Create a node if it exist if (Elements[elm].Element) - Elements[elm].Element->write (node, form, Elements[elm].Name.c_str()); + Elements[elm].Element->write (node, form, Elements[elm].Name); } // Return the new node @@ -2190,7 +2190,7 @@ void CFormElmVirtualStruct::read (xmlNodePtr node, CFormLoader &loader, CForm *f xmlFree ((void*)filename); // Load the dfn - FormDfn = loader.loadFormDfn (DfnFilename.c_str (), false); + FormDfn = loader.loadFormDfn (DfnFilename, false); if (!FormDfn) { // Throw exception @@ -2200,8 +2200,8 @@ void CFormElmVirtualStruct::read (xmlNodePtr node, CFormLoader &loader, CForm *f else { // Throw exception - warning (true, "read", "XML Syntax error in virtual struct in block line %p, should have a DfnName property.", - node->content); + warning (true, "read", "XML Syntax error in virtual struct in block line %u, should have a DfnName property.", + (uint)node->line); } // Read the parent @@ -2232,7 +2232,7 @@ bool CFormElmVirtualStruct::isUsed (const CForm * /* form */) const // *************************************************************************** -void CFormElmVirtualStruct::warning (bool exception, const char *function, const char *format, ... ) const +void CFormElmVirtualStruct::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -2244,7 +2244,7 @@ void CFormElmVirtualStruct::warning (bool exception, const char *function, const // Set the warning string formName; getFormName (formName, NULL); - NLGEORGES::warning (exception, "(CFormElmVirtualStruct::%s) on node (%s) in form (%s) : %s", function, formName.c_str (), Form->getFilename ().c_str (), buffer); + NLGEORGES::warning (exception, "(CFormElmVirtualStruct::%s) on node (%s) in form (%s) : %s", function.c_str(), formName.c_str (), Form->getFilename ().c_str (), buffer); } // *************************************************************************** @@ -2304,7 +2304,7 @@ bool CFormElmArray::getArrayNode (const UFormElm **result, uint arrayIndex) cons } else { - warning (false, "getArrayNode", "Index (%d) out of bound (%d).", arrayIndex, Elements.size() ); + warning (false, "getArrayNode", "Index (%u) out of bound (%u).", arrayIndex, (uint)Elements.size() ); return false; } } @@ -2323,7 +2323,7 @@ bool CFormElmArray::getArrayNodeName (std::string &result, uint arrayIndex) cons } else { - warning (false, "getArrayNodeName", "Index (%d) out of bound (%d).", arrayIndex, Elements.size() ); + warning (false, "getArrayNodeName", "Index (%u) out of bound (%u).", arrayIndex, (uint)Elements.size() ); return false; } } @@ -2339,7 +2339,7 @@ bool CFormElmArray::getArrayNode (UFormElm **result, uint arrayIndex) } else { - warning (false, "getArrayNode", "Index (%d) out of bound (%d).", arrayIndex, Elements.size() ); + warning (false, "getArrayNode", "Index (%u) out of bound (%u).", arrayIndex, (uint)Elements.size() ); return false; } } @@ -2351,11 +2351,11 @@ bool CFormElmArray::getArrayValue (std::string &result, uint arrayIndex, TEval e { if (arrayIndex >= Elements.size()) { - warning (false, "getArrayValue", "Access out of bound, trying to access array index %u, array size is %u.", arrayIndex, Elements.size()); + warning (false, "getArrayValue", "Access out of bound, trying to access array index %u, array size is %u.", arrayIndex, (uint)Elements.size()); } else if (Type) { - return (Type->getValue (result, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)); + return (Type->getValue (result, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")); } else { @@ -2372,9 +2372,9 @@ bool CFormElmArray::getArrayValue (sint8 &result, uint arrayIndex, TEval evaluat if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2392,9 +2392,9 @@ bool CFormElmArray::getArrayValue (uint8 &result, uint arrayIndex, TEval evaluat if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2412,9 +2412,9 @@ bool CFormElmArray::getArrayValue (sint16 &result, uint arrayIndex, TEval evalua if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2432,9 +2432,9 @@ bool CFormElmArray::getArrayValue (uint16 &result, uint arrayIndex, TEval evalua if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2452,9 +2452,9 @@ bool CFormElmArray::getArrayValue (sint32 &result, uint arrayIndex, TEval evalua if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2472,9 +2472,9 @@ bool CFormElmArray::getArrayValue (uint32 &result, uint arrayIndex, TEval evalua if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2492,9 +2492,9 @@ bool CFormElmArray::getArrayValue (float &result, uint arrayIndex, TEval evaluat if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2512,9 +2512,9 @@ bool CFormElmArray::getArrayValue (double &result, uint arrayIndex, TEval evalua if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2532,9 +2532,9 @@ bool CFormElmArray::getArrayValue (bool &result, uint arrayIndex, TEval evaluate if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2552,9 +2552,9 @@ bool CFormElmArray::getArrayValue (NLMISC::CRGBA &result, uint arrayIndex, TEval if (Type) { string str; - if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, NULL)) + if (Type->getValue (str, Form, safe_cast (Elements[arrayIndex].Element), *ParentDfn, ParentIndex, evaluate, (uint32*)where, NLGEORGES_FIRST_ROUND, "")) { - return convertValue (result, str.c_str ()); + return convertValue (result, str); } } else @@ -2567,7 +2567,7 @@ bool CFormElmArray::getArrayValue (NLMISC::CRGBA &result, uint arrayIndex, TEval // *************************************************************************** -xmlNodePtr CFormElmArray::write (xmlNodePtr root, const CForm *form, const char *structName, bool forceWrite) const +xmlNodePtr CFormElmArray::write (xmlNodePtr root, const CForm *form, const std::string &structName, bool forceWrite) const { // Arrau is used ? if (isUsed (form) || forceWrite) @@ -2576,10 +2576,10 @@ xmlNodePtr CFormElmArray::write (xmlNodePtr root, const CForm *form, const char xmlNodePtr node = xmlNewChild ( root, NULL, (const xmlChar*)"ARRAY", NULL); // Element name - if (structName != NULL) + if (!structName.empty()) { // Struct name - xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName); + xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName.c_str()); } // For each elements of the structure @@ -2588,7 +2588,7 @@ xmlNodePtr CFormElmArray::write (xmlNodePtr root, const CForm *form, const char { // Create a node if (Elements[elm].Element) - Elements[elm].Element->write (node, form, Elements[elm].Name.empty ()?NULL:Elements[elm].Name.c_str (), true); + Elements[elm].Element->write (node, form, Elements[elm].Name, true); } // Return the new node @@ -2723,7 +2723,7 @@ void CFormElmArray::getFormName (std::string &result, const CFormElm *child) con // Reset the result if (child == NULL) { - result = ""; + result.clear(); result.reserve (50); } @@ -2760,7 +2760,7 @@ void CFormElmArray::getFormName (std::string &result, const CFormElm *child) con // *************************************************************************** -void CFormElmArray::warning (bool exception, const char *function, const char *format, ... ) const +void CFormElmArray::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -2772,7 +2772,7 @@ void CFormElmArray::warning (bool exception, const char *function, const char *f // Set the warning string formName; getFormName (formName, NULL); - NLGEORGES::warning (exception, "(CFormElmArray::%s) on node (%s) in form (%s) : %s", function, formName.c_str (), Form->getFilename ().c_str (), buffer); + NLGEORGES::warning (exception, "(CFormElmArray::%s) on node (%s) in form (%s) : %s", function.c_str(), formName.c_str (), Form->getFilename ().c_str (), buffer); } // *************************************************************************** @@ -2979,7 +2979,7 @@ bool CFormElmAtom::getValue (NLMISC::CRGBA &result, TEval evaluate) const // *************************************************************************** -xmlNodePtr CFormElmAtom::write (xmlNodePtr root, const CForm *form, const char *structName, bool forceWrite) const +xmlNodePtr CFormElmAtom::write (xmlNodePtr root, const CForm *form, const std::string &structName, bool forceWrite) const { // Atom is used ? if (isUsed (form) || forceWrite) @@ -2988,16 +2988,16 @@ xmlNodePtr CFormElmAtom::write (xmlNodePtr root, const CForm *form, const char xmlNodePtr node = xmlNewChild ( root, NULL, (const xmlChar*)"ATOM", NULL); // Element name - if (structName != NULL) + if (!structName.empty()) { // Struct name - xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName); + xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName.c_str()); } // The value if (!Value.empty ()) { - if (COXml::isStringValidForProperties (Value.c_str ())) + if (COXml::isStringValidForProperties (Value)) xmlSetProp (node, (const xmlChar*)"Value", (const xmlChar*)Value.c_str()); else { @@ -3049,7 +3049,7 @@ void CFormElmAtom::read (xmlNodePtr node, CFormLoader &/* loader */, const CType // *************************************************************************** -void CFormElmAtom::setValue (const char *value) +void CFormElmAtom::setValue (const std::string &value) { Value = value; } @@ -3067,7 +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 @@ -3077,7 +3077,7 @@ void CFormElmAtom::getFormName (std::string &result, const CFormElm *child) cons // *************************************************************************** -void CFormElmAtom::warning (bool exception, const char *function, const char *format, ... ) const +void CFormElmAtom::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -3089,7 +3089,7 @@ void CFormElmAtom::warning (bool exception, const char *function, const char *fo // Set the warning string formName; getFormName (formName, NULL); - NLGEORGES::warning (exception, "(CFormElmAtom::%s) on node (%s) in form (%s) : %s", function, formName.c_str (), Form->getFilename ().c_str (), buffer); + NLGEORGES::warning (exception, "(CFormElmAtom::%s) on node (%s) in form (%s) : %s", function.c_str(), formName.c_str (), Form->getFilename ().c_str (), buffer); } // *************************************************************************** diff --git a/code/nel/src/georges/form_loader.cpp b/code/nel/src/georges/form_loader.cpp index dd0becf62..b56ed23ef 100644 --- a/code/nel/src/georges/form_loader.cpp +++ b/code/nel/src/georges/form_loader.cpp @@ -60,10 +60,10 @@ CFormLoader::~CFormLoader() { } -CType *CFormLoader::loadType (const char *filename) +CType *CFormLoader::loadType (const std::string &filename) { // Lower string filename - string lowerStr = toLower((string)filename); + string lowerStr = toLower(filename); lowerStr = CFile::getFilename (lowerStr); // Already in the map ? @@ -98,7 +98,7 @@ CType *CFormLoader::loadType (const char *filename) else { // Output error - warning (false, "loadType", "Can't open the form file (%s).", filename); + warning (false, "loadType", "Can't open the form file (%s).", filename.c_str()); // Delete the type delete type; @@ -108,7 +108,7 @@ CType *CFormLoader::loadType (const char *filename) catch (const Exception &e) { // Output error - warning (false, "loadType", "Error while loading the form (%s): %s", filename, e.what()); + warning (false, "loadType", "Error while loading the form (%s): %s", filename.c_str(), e.what()); // Delete the type delete type; @@ -130,10 +130,10 @@ CType *CFormLoader::loadType (const char *filename) // *************************************************************************** -CFormDfn *CFormLoader::loadFormDfn (const char *filename, bool forceLoad) +CFormDfn *CFormLoader::loadFormDfn (const std::string &filename, bool forceLoad) { // Lower string filename - string lowerStr = toLower((string)filename); + string lowerStr = toLower(filename); lowerStr = CFile::getFilename (lowerStr); // Already in the map ? @@ -171,7 +171,7 @@ CFormDfn *CFormLoader::loadFormDfn (const char *filename, bool forceLoad) else { // Output error - warning (false, "loadFormDfn", "Can't open the form file (%s).", filename); + warning (false, "loadFormDfn", "Can't open the form file (%s).", filename.c_str()); // Delete the formDfn delete formDfn; @@ -182,7 +182,7 @@ CFormDfn *CFormLoader::loadFormDfn (const char *filename, bool forceLoad) catch (const Exception &e) { // Output error - warning (false, "loadFormDfn", "Error while loading the form (%s): %s", filename, e.what()); + warning (false, "loadFormDfn", "Error while loading the form (%s): %s", filename.c_str(), e.what()); // Delete the formDfn delete formDfn; @@ -196,7 +196,7 @@ CFormDfn *CFormLoader::loadFormDfn (const char *filename, bool forceLoad) // *************************************************************************** -UForm *CFormLoader::loadForm (const char *filename) +UForm *CFormLoader::loadForm (const std::string &filename) { // Lower string filename string lowerStr = toLower((string)filename); @@ -237,7 +237,7 @@ UForm *CFormLoader::loadForm (const char *filename) name += ".dfn"; // Load the dfn - CFormDfn *dfn = loadFormDfn (name.c_str (), false); + CFormDfn *dfn = loadFormDfn (name, false); if (dfn) { // Open the file @@ -257,7 +257,7 @@ UForm *CFormLoader::loadForm (const char *filename) else { // Output error - warning (false, "loadForm", "Can't open the form file (%s).", filename); + warning (false, "loadForm", "Can't open the form file (%s).", filename.c_str()); // Delete the form delete form; @@ -279,7 +279,7 @@ UForm *CFormLoader::loadForm (const char *filename) catch (const Exception &e) { // Output error - warning (false, "loadForm", "Error while loading the form (%s): %s", filename, e.what()); + warning (false, "loadForm", "Error while loading the form (%s): %s", filename.c_str(), e.what()); // Delete the form delete form; @@ -293,21 +293,21 @@ UForm *CFormLoader::loadForm (const char *filename) // *************************************************************************** -UFormDfn *CFormLoader::loadFormDfn (const char *filename) +UFormDfn *CFormLoader::loadFormDfn (const std::string &filename) { return loadFormDfn (filename, false); } // *************************************************************************** -UType *CFormLoader::loadFormType (const char *filename) +UType *CFormLoader::loadFormType (const std::string &filename) { return loadType (filename); } // *************************************************************************** -void CFormLoader::warning (bool exception, const char *function, const char *format, ... ) const +void CFormLoader::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -317,7 +317,7 @@ void CFormLoader::warning (bool exception, const char *function, const char *for va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CFormLoader::%s) : %s", function, buffer); + NLGEORGES::warning (exception, "(CFormLoader::%s) : %s", function.c_str(), buffer); } // *************************************************************************** diff --git a/code/nel/src/georges/header.cpp b/code/nel/src/georges/header.cpp index ff92d60ea..f814d5802 100644 --- a/code/nel/src/georges/header.cpp +++ b/code/nel/src/georges/header.cpp @@ -76,7 +76,7 @@ void CFileHeader::write (xmlNodePtr node) const // *************************************************************************** -void CFileHeader::addLog (const char *log) +void CFileHeader::addLog (const std::string &log) { time_t t; time (&t); @@ -92,7 +92,7 @@ void CFileHeader::addLog (const char *log) // *************************************************************************** -void CFileHeader::setComments (const char *comments) +void CFileHeader::setComments (const std::string &comments) { Comments = comments; } @@ -112,8 +112,8 @@ void CFileHeader::read (xmlNodePtr root) xmlFree ((void*)value); // Throw exception - warning (true, "read", "XML Syntax error in TYPE block line %p, the Version argument is invalid.", - root->content); + warning (true, "read", "XML Syntax error in TYPE block line %d, the Version argument is invalid.", + (sint)root->line); } // Delete the value @@ -145,8 +145,8 @@ void CFileHeader::read (xmlNodePtr root) xmlFree ((void*)value); // Throw exception - warning (true, "read", "XML Syntax error in TYPE block line %p, the State argument is invalid.", - root->content); + warning (true, "read", "XML Syntax error in TYPE block line %d, the State argument is invalid.", + (sint)root->line); } // Delete the value @@ -159,7 +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) { @@ -215,7 +215,7 @@ const char *CFileHeader::getStateString (TState state) // *************************************************************************** -void CFileHeader::warning (bool exception, const char *function, const char *format, ... ) const +void CFileHeader::warning (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -225,7 +225,7 @@ void CFileHeader::warning (bool exception, const char *function, const char *for va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CFileHeader::%s) : %s", function, buffer); + NLGEORGES::warning (exception, "(CFileHeader::%s) : %s", function.c_str(), buffer); } // *************************************************************************** diff --git a/code/nel/src/georges/load_form.cpp b/code/nel/src/georges/load_form.cpp deleted file mode 100644 index e420b63ae..000000000 --- a/code/nel/src/georges/load_form.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdgeorges.h" diff --git a/code/nel/src/georges/type.cpp b/code/nel/src/georges/type.cpp index f401c7ee8..cc3c44d6e 100644 --- a/code/nel/src/georges/type.cpp +++ b/code/nel/src/georges/type.cpp @@ -109,8 +109,8 @@ void CType::read (xmlNodePtr root) if ( ((const char*)root->name == NULL) || (strcmp ((const char*)root->name, "TYPE") != 0) ) { // Throw exception - warning2 (true, "read", "XML Syntax error in block line %p, node (%s) should be TYPE.", - root->content, root->name); + warning2 (true, "read", "XML Syntax error in block line %d, node (%s) should be TYPE.", + (sint)root->line, root->name); } // Read the type @@ -137,8 +137,8 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); // Throw exception - warning2 (true, "read", "XML Syntax error in TYPE block line %p, the Type value is unknown (%s).", - root->content, valueStr.c_str ()); + warning2 (true, "read", "XML Syntax error in TYPE block line %d, the Type value is unknown (%s).", + (sint)root->line, valueStr.c_str ()); } // Delete the value @@ -147,8 +147,8 @@ void CType::read (xmlNodePtr root) else { // Throw exception - warning2 (true, "read", "XML Syntax error in TYPE block line %p, the Type argument was not found.", - root->content); + warning2 (true, "read", "XML Syntax error in TYPE block line %d, the Type argument was not found.", + (sint)root->line); } // Read the UI @@ -185,7 +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"); @@ -255,8 +255,8 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)label); // Throw exception - warning2 (true, "read", "XML Syntax error in DEFINITION block line %p, the Value argument was not found.", - childPtr->content); + warning2 (true, "read", "XML Syntax error in DEFINITION block line %d, the Value argument was not found.", + (sint)childPtr->line); } // Delete the value @@ -265,8 +265,8 @@ void CType::read (xmlNodePtr root) else { // Throw exception - warning2 (true, "read", "XML Syntax error in DEFINITION block line %p, the Label argument was not found.", - childPtr->content); + warning2 (true, "read", "XML Syntax error in DEFINITION block line %d, the Label argument was not found.", + (sint)childPtr->line); } // One more @@ -326,6 +326,7 @@ public: Type = type; Form = form; } + virtual CEvalNumExpr::TReturnState evalValue (const char *value, double &result, uint32 round) { // If a form is available @@ -412,7 +413,7 @@ public: result = res.empty ()?0:1; return CEvalNumExpr::NoError; } - else if (((const CFormElm&)Form->getRootNode ()).convertValue (result, res.c_str ())) + else if (((const CFormElm&)Form->getRootNode ()).convertValue (result, res)) { return CEvalNumExpr::NoError; } @@ -465,7 +466,7 @@ uint getNextToken (const char *startString, string &token, uint &offset) offset += 9; return NL_TOKEN_NAME; } - token = ""; + token.clear(); while (startString[offset]) { if (startString[offset] == '\\') @@ -535,7 +536,7 @@ void buildError (char *msg, uint offset) // *************************************************************************** -bool CType::getValue (string &result, const CForm *form, const CFormElmAtom *node, const CFormDfn &parentDfn, uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const char *formName) const +bool CType::getValue (string &result, const CForm *form, const CFormElmAtom *node, const CFormDfn &parentDfn, uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const std::string &formName) const { if (round > NLGEORGES_MAX_RECURSION) { @@ -721,7 +722,7 @@ bool CType::getValue (string &result, const CForm *form, const CFormElmAtom *nod UFormDfn::TEntryType type; // Search for the node - if (((const CFormElm&)form->getRootNode ()).getNodeByName (valueName.c_str (), &parentDfn, parentIndex, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, false, round+1)) + if (((const CFormElm&)form->getRootNode ()).getNodeByName (valueName, &parentDfn, parentIndex, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, false, round+1)) { // End, return the current index if (type == UFormDfn::EntryType) @@ -809,7 +810,7 @@ bool CType::uiCompatible (TType type, TUI ui) // *************************************************************************** -void CType::warning (bool exception, const char *formName, const char *formFilename, const char *function, const char *format, ... ) const +void CType::warning (bool exception, const std::string &formName, const std::string &formFilename, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -819,12 +820,12 @@ void CType::warning (bool exception, const char *formName, const char *formFilen va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CType::%s) In form (%s) in node (%s) : %s", function, formFilename, formName, buffer); + NLGEORGES::warning (exception, "(CType::%s) In form (%s) in node (%s) : %s", function.c_str(), formFilename.c_str(), formName.c_str(), buffer); } // *************************************************************************** -void CType::warning2 (bool exception, const char *function, const char *format, ... ) const +void CType::warning2 (bool exception, const std::string &function, const char *format, ... ) const { // Make a buffer string va_list args; @@ -834,7 +835,7 @@ void CType::warning2 (bool exception, const char *function, const char *format, va_end( args ); // Set the warning - NLGEORGES::warning (exception, "(CType::%s) : %s", function, buffer); + NLGEORGES::warning (exception, "(CType::%s) : %s", function.c_str(), buffer); } // *************************************************************************** diff --git a/code/nel/src/gui/action_handler.cpp b/code/nel/src/gui/action_handler.cpp index d7214ef06..2d2246937 100644 --- a/code/nel/src/gui/action_handler.cpp +++ b/code/nel/src/gui/action_handler.cpp @@ -23,10 +23,15 @@ #include "nel/gui/db_manager.h" #include "nel/gui/interface_link.h" #include "nel/gui/widget_manager.h" +#include "nel/gui/view_renderer.h" using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -65,7 +70,7 @@ namespace NLGUI string allparam = Params; skipBlankAtStart (allparam); string param = toLower (ParamName); - while (allparam.size() > 0) + while (!allparam.empty()) { std::string::size_type e = allparam.find('='); if (e == std::string::npos || e == 0) break; @@ -91,7 +96,7 @@ namespace NLGUI { string allparam = Params; skipBlankAtStart (allparam); - while (allparam.size() > 0) + while (!allparam.empty()) { std::string::size_type e = allparam.find('='); if (e == std::string::npos || e == 0) break; @@ -738,4 +743,14 @@ namespace NLGUI }; REGISTER_ACTION_HANDLER (CAHUnlockAllContainer, "unlock_all_container"); -} \ No newline at end of file + // ------------------------------------------------------------------------------------------------ + class CAHCopyToClipboard : public IActionHandler + { + virtual void execute (CCtrlBase *pCaller, const std::string ¶ms) + { + if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(params)) + nlwarning("Copy to clipboard failed: '%s'", params.c_str()); + } + }; + REGISTER_ACTION_HANDLER(CAHCopyToClipboard, "copy_to_clipboard"); +} diff --git a/code/nel/src/gui/ctrl_base.cpp b/code/nel/src/gui/ctrl_base.cpp index 475761e89..9fdeff8c2 100644 --- a/code/nel/src/gui/ctrl_base.cpp +++ b/code/nel/src/gui/ctrl_base.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { std::map< std::string, std::map< std::string, std::string > > CCtrlBase::AHCache; diff --git a/code/nel/src/gui/ctrl_base_button.cpp b/code/nel/src/gui/ctrl_base_button.cpp index 673ea906d..d60824295 100644 --- a/code/nel/src/gui/ctrl_base_button.cpp +++ b/code/nel/src/gui/ctrl_base_button.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace { const uint KEY_REPEAT_MIN = 100; diff --git a/code/nel/src/gui/ctrl_button.cpp b/code/nel/src/gui/ctrl_button.cpp index d689dd71c..457010859 100644 --- a/code/nel/src/gui/ctrl_button.cpp +++ b/code/nel/src/gui/ctrl_button.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlButton, std::string, "button"); namespace NLGUI @@ -442,6 +446,9 @@ namespace NLGUI // *************************************************************************** sint32 CCtrlButton::getMaxUsedW() const { + if (_Scale) + return _WReal; + sint32 txw, txh; CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh); diff --git a/code/nel/src/gui/ctrl_col_pick.cpp b/code/nel/src/gui/ctrl_col_pick.cpp index 2d62b6e74..4079388c2 100644 --- a/code/nel/src/gui/ctrl_col_pick.cpp +++ b/code/nel/src/gui/ctrl_col_pick.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlColPick, std::string, "colpick"); namespace NLGUI diff --git a/code/nel/src/gui/ctrl_draggable.cpp b/code/nel/src/gui/ctrl_draggable.cpp index 39872ab18..781585083 100644 --- a/code/nel/src/gui/ctrl_draggable.cpp +++ b/code/nel/src/gui/ctrl_draggable.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/ctrl_draggable.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/ctrl_polygon.cpp b/code/nel/src/gui/ctrl_polygon.cpp index 86059087d..c7ce984d2 100644 --- a/code/nel/src/gui/ctrl_polygon.cpp +++ b/code/nel/src/gui/ctrl_polygon.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/ctrl_quad.cpp b/code/nel/src/gui/ctrl_quad.cpp index 47346692c..22f4d4ae6 100644 --- a/code/nel/src/gui/ctrl_quad.cpp +++ b/code/nel/src/gui/ctrl_quad.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/ctrl_scroll.cpp b/code/nel/src/gui/ctrl_scroll.cpp index ad2ca14f5..9c9585fcc 100644 --- a/code/nel/src/gui/ctrl_scroll.cpp +++ b/code/nel/src/gui/ctrl_scroll.cpp @@ -28,6 +28,10 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlScroll, std::string, "scroll"); namespace NLGUI diff --git a/code/nel/src/gui/ctrl_scroll_base.cpp b/code/nel/src/gui/ctrl_scroll_base.cpp index f95cac5d7..2813b997a 100644 --- a/code/nel/src/gui/ctrl_scroll_base.cpp +++ b/code/nel/src/gui/ctrl_scroll_base.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/ctrl_scroll_base.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/ctrl_sheet_selection.cpp b/code/nel/src/gui/ctrl_sheet_selection.cpp index bdbe0e73d..d0202547f 100644 --- a/code/nel/src/gui/ctrl_sheet_selection.cpp +++ b/code/nel/src/gui/ctrl_sheet_selection.cpp @@ -23,6 +23,10 @@ #include "nel/gui/ctrl_sheet_selection.h" #include "nel/gui/view_renderer.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index c292d5473..81dfcc953 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -30,6 +30,9 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif NLMISC_REGISTER_OBJECT(CViewBase, CCtrlTextButton, std::string, "text_button"); diff --git a/code/nel/src/gui/ctrl_tooltip.cpp b/code/nel/src/gui/ctrl_tooltip.cpp index 8a0427751..da42084ac 100644 --- a/code/nel/src/gui/ctrl_tooltip.cpp +++ b/code/nel/src/gui/ctrl_tooltip.cpp @@ -23,6 +23,10 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlToolTip, std::string, "tooltip"); REGISTER_UI_CLASS(CCtrlToolTip) diff --git a/code/nel/src/gui/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..747ca454e 100644 --- a/code/nel/src/gui/group_frame.cpp +++ b/code/nel/src/gui/group_frame.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -145,7 +149,7 @@ namespace NLGUI } // The first type in display type struct is the default display type - if (_DispTypes.size() == 0) + if (_DispTypes.empty()) { SDisplayType dt; dt.Name = "default"; diff --git a/code/nel/src/gui/group_header.cpp b/code/nel/src/gui/group_header.cpp index 908aa183e..dbc990447 100644 --- a/code/nel/src/gui/group_header.cpp +++ b/code/nel/src/gui/group_header.cpp @@ -24,6 +24,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 3ea18a717..a3cfd514f 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) @@ -494,7 +497,11 @@ namespace NLGUI if (res != CURLE_OK) { - browseError(string("Connection failed with curl error " + string(curl_easy_strerror(res))).c_str()); + std::string err; + err = "Connection failed with cURL error: "; + err += curl_easy_strerror(res); + err += "\nURL '" + _CurlWWW->Url + "'"; + browseError(err.c_str()); } else if ((code >= 301 && code <= 303) || code == 307 || code == 308) @@ -510,7 +517,7 @@ namespace NLGUI // redirect, get the location and try browse again // we cant use curl redirection because 'addHTTPGetParams()' must be called on new destination std::string location(_CurlWWW->getLocationHeader()); - if (location.size() > 0) + if (!location.empty()) { #ifdef LOG_DL nlwarning("(%s) request (%d) redirected to (len %d) '%s'", _Id.c_str(), _RedirectsRemaining, location.size(), location.c_str()); @@ -538,7 +545,7 @@ namespace NLGUI if ( (code < 200 || code >= 300) ) { - browseError(string("Connection failed (curl code " + toString((sint32)res) + "), http code " + toString((sint32)code) + ") : " + _CurlWWW->Url).c_str()); + browseError(string("Connection failed (curl code " + toString((sint32)res) + ")\nhttp code " + toString((sint32)code) + ")\nURL '" + _CurlWWW->Url + "'").c_str()); } else { @@ -585,11 +592,25 @@ namespace NLGUI // second instance deletes first tmpfile and creates new file for itself. if (CFile::getFileSize(tmpfile) > 0) { - CFile::moveFile(it->dest, tmpfile); - for(uint i = 0; i < it->imgs.size(); i++) + try { - setImage(it->imgs[i].Image, it->dest); - setImageSize(it->imgs[i].Image, it->imgs[i].Style); + // verify that image is not corrupted + uint32 w, h; + CBitmap::loadSize(tmpfile, w, h); + if (w != 0 && h != 0) + { + CFile::moveFile(it->dest, tmpfile); + for(uint i = 0; i < it->imgs.size(); i++) + { + setImage(it->imgs[i].Image, it->dest); + setImageSize(it->imgs[i].Image, it->imgs[i].Style); + } + } + } + catch(const NLMISC::Exception &e) + { + // exception message has .tmp file name, so keep it for further analysis + nlwarning("Invalid image (%s): %s", it->url.c_str(), e.what()); } } } @@ -612,7 +633,7 @@ namespace NLGUI } RunningCurls = NewRunningCurls; #ifdef LOG_DL - if (RunningCurls > 0 || Curls.size() > 0) + if (RunningCurls > 0 || !Curls.empty()) nlwarning("(%s) RunningCurls %d, _Curls %d", _Id.c_str(), RunningCurls, Curls.size()); #endif } @@ -835,6 +856,7 @@ namespace NLGUI result.R = 255 * hueToRgb(m1, m2, h + 1.0f/3.0f); result.G = 255 * hueToRgb(m1, m2, h); result.B = 255 * hueToRgb(m1, m2, h - 1.0f/3.0f); + result.A = 255; } class CNameToCol @@ -1625,7 +1647,7 @@ namespace NLGUI // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=submit"; - if (text.size() > 0) + if (!text.empty()) { // escape AH param separator string tmp = text; @@ -1961,7 +1983,7 @@ namespace NLGUI // Table must fit the container size - addGroup (table, 0); + addHtmlGroup (table, 0); _Tables.push_back(table); @@ -2011,7 +2033,6 @@ namespace NLGUI it = styles.find("background-image"); if (it != styles.end()) { - nlinfo("found background-image %s", it->second.c_str()); string image = (*it).second; string::size_type texExt = toLower(image).find("url("); // Url image @@ -2089,10 +2110,10 @@ namespace NLGUI templateName = value[MY_HTML_TEXTAREA_Z_INPUT_TMPL]; // Get the string name - _TextAreaName = ""; + _TextAreaName.clear(); _TextAreaRow = 1; _TextAreaCols = 10; - _TextAreaContent = ""; + _TextAreaContent.clear(); _TextAreaMaxLength = 1024; if (present[MY_HTML_TEXTAREA_NAME] && value[MY_HTML_TEXTAREA_NAME]) _TextAreaName = value[MY_HTML_TEXTAREA_NAME]; @@ -2112,7 +2133,7 @@ namespace NLGUI if(!_TitlePrefix.empty()) _TitleString = _TitlePrefix + " - "; else - _TitleString = ""; + _TitleString.clear(); _Title = true; } break; @@ -2144,10 +2165,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]) @@ -2369,7 +2390,7 @@ namespace NLGUI { endParagraph(); } - _DivName = ""; + _DivName.clear(); popIfNotEmpty (_Divs); popIfNotEmpty (_BlockLevelElement); break; @@ -2444,6 +2465,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; @@ -2613,7 +2635,7 @@ namespace NLGUI { CLuaManager::getInstance().executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true); } - _ObjectScript = ""; + _ObjectScript.clear(); } } _Object = false; @@ -2631,7 +2653,7 @@ namespace NLGUI { // we receive an embeded lua script _ParsingLua = _TrustedDomain; // Only parse lua if TrustedDomain - _LuaScript = ""; + _LuaScript.clear(); } } @@ -2686,8 +2708,6 @@ namespace NLGUI _LI = false; _SelectOption = false; _GroupListAdaptor = NULL; - _DocumentUrl = ""; - _DocumentDomain = ""; _UrlFragment.clear(); _RefreshUrl.clear(); _NextRefreshTime = 0.0; @@ -2740,7 +2760,6 @@ namespace NLGUI DefaultCheckBoxBitmapOver = "checkbox_over.tga"; DefaultRadioButtonBitmapNormal = "w_radiobutton.png"; DefaultRadioButtonBitmapPushed = "w_radiobutton_pushed.png"; - DefaultRadioButtonBitmapOver = ""; DefaultBackgroundBitmapView = "bg"; clearContext(); @@ -3754,11 +3773,10 @@ namespace NLGUI CGroupParagraph *newParagraph = new CGroupParagraph(CViewBase::TCtorParam()); newParagraph->setResizeFromChildH(true); - newParagraph->setBrowseGroup (this); newParagraph->setIndent(_Indent); // Add to the group - addGroup (newParagraph, beginSpace); + addHtmlGroup (newParagraph, beginSpace); _Paragraph = newParagraph; paragraphChange (); @@ -3805,7 +3823,7 @@ namespace NLGUI CUrlParser uri(url); - if (uri.hash.size() > 0) + if (!uri.hash.empty()) { // Anchor to scroll after page has loaded _UrlFragment = uri.hash; @@ -3951,7 +3969,7 @@ namespace NLGUI void CGroupHTML::registerAnchor(CInterfaceElement* elm) { - if (_AnchorName.size() > 0) + if (!_AnchorName.empty()) { for(uint32 i=0; i < _AnchorName.size(); ++i) { @@ -4108,6 +4126,9 @@ namespace NLGUI if (!newLink->Link.empty()) { newLink->setHTMLView (this); + + newLink->setActionOnLeftClick("browse"); + newLink->setParamsOnLeftClick("name=" + getId() + "|url=" + newLink->Link); } } newLink->setText(tmpStr); @@ -4176,10 +4197,18 @@ namespace NLGUI if (!reloadImg && lookupLocalFile (finalUrl, image.c_str(), false)) { // don't display image that are not power of 2 - uint32 w, h; - CBitmap::loadSize (image, w, h); - if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures())) + try + { + uint32 w, h; + CBitmap::loadSize (image, w, h); + if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures())) + image = "web_del.tga"; + } + catch(const NLMISC::Exception &e) + { + nlwarning(e.what()); image = "web_del.tga"; + } } else { @@ -4375,10 +4404,18 @@ namespace NLGUI } else { - uint32 w, h; - CBitmap::loadSize(normal, w, h); - if (w == 0 || h == 0) + try + { + uint32 w, h; + CBitmap::loadSize(normal, w, h); + if (w == 0 || h == 0) + normal = "web_del.tga"; + } + catch(const NLMISC::Exception &e) + { + nlwarning(e.what()); normal = "web_del.tga"; + } } } } @@ -4544,7 +4581,7 @@ namespace NLGUI // *************************************************************************** - void CGroupHTML::addGroup (CInterfaceGroup *group, uint beginSpace) + void CGroupHTML::addHtmlGroup (CInterfaceGroup *group, uint beginSpace) { if (!group) return; @@ -4624,34 +4661,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()) @@ -5136,7 +5160,7 @@ namespace NLGUI #endif // create markup for image downloads - if (type.find("image/") == 0 && content.size() > 0) + if (type.find("image/") == 0 && !content.empty()) { try { @@ -5198,6 +5222,11 @@ namespace NLGUI void CGroupHTML::doBrowseAnchor(const std::string &anchor) { + if (_Anchors.count(anchor) == 0) + { + return; + } + CInterfaceElement *pIE = _Anchors.find(anchor)->second; if (pIE) { @@ -5824,7 +5853,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..216c8f682 100644 --- a/code/nel/src/gui/group_list.cpp +++ b/code/nel/src/gui/group_list.cpp @@ -30,6 +30,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CGroupList, std::string, "list"); namespace NLGUI @@ -363,7 +367,7 @@ namespace NLGUI uint32 i; if( fromString( value, i ) ) _TextId = i; - _HardText = ""; + _HardText.clear(); onTextChanged(); return; } @@ -736,13 +740,11 @@ namespace NLGUI CInterfaceGroup::updateCoords(); - sint32 nCurrentX = 0; // Current offset of an element - EAlign addElt = _AddElt; if ((addElt == Top) || (addElt == Bottom)) { // Calculate size - sint32 newH = 0, newW = 0; + sint32 newH = 0; bool bFirst = true; for (uint32 i = 0; i < _Elements.size(); ++i) @@ -752,10 +754,7 @@ namespace NLGUI if (!bFirst) newH += _Space; bFirst = false; - nCurrentX += _Elements[i].Element->getX(); - newW = max (newW, _Elements[i].Element->getW()+(sint32)abs(nCurrentX)); } - _W = max(newW, _MinW); _H = max(newH, _MinH); if (_DynamicDisplaySize) { @@ -763,10 +762,13 @@ namespace NLGUI _MaxH = _H; } if (_H < _MaxH) setOfsY(0); + + // if width is not from parent, then ensure minimum size + if ((_SizeRef & 1) == 0) _W = max(_W, _MinW); } else { - sint32 newW = 0, newH = 0; + sint32 newW = 0; bool bFirst = true; for (uint32 i = 0; i < _Elements.size(); ++i) @@ -776,16 +778,17 @@ namespace NLGUI if (!bFirst) newW += _Space; bFirst = false; - newH = max (newH, _Elements[i].Element->getH()); } _W = max(newW, _MinW); - _H = max(newH, _MinH); if (_DynamicDisplaySize) { _MaxW = _W; _MaxH = _H; } if (_W < _MaxW) setOfsX(0); + + // if height is not from parent, then ensure minimum size + if ((_SizeRef & 2) == 0) _H = max(_H, _MinH); } CInterfaceElement::updateCoords(); @@ -1059,7 +1062,7 @@ namespace NLGUI { // update the list size sint32 newH = _H + child->getH(); - if (_Elements.size() > 0) + if (!_Elements.empty()) newH += _Space; _H = newH; @@ -1073,7 +1076,7 @@ namespace NLGUI { // Update the list coords sint32 newW = _W + child->getW(); - if (_Elements.size() > 0) + if (!_Elements.empty()) newW += _Space; _W = newW; @@ -1408,7 +1411,7 @@ namespace NLGUI void CGroupList::onTextChanged() { - if( _Elements.size() == 0 ) + if( _Elements.empty() ) return; CElementInfo &e = _Elements[ 0 ]; diff --git a/code/nel/src/gui/group_menu.cpp b/code/nel/src/gui/group_menu.cpp index 7ab5db84c..d2e11a2c9 100644 --- a/code/nel/src/gui/group_menu.cpp +++ b/code/nel/src/gui/group_menu.cpp @@ -32,6 +32,9 @@ using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace { @@ -237,6 +240,7 @@ namespace NLGUI _GroupList->setY (4); _GroupList->setSpace (_GroupMenu->_Space); _GroupList->setSerializable( false ); + _GroupList->setResizeFromChildW(true); addGroup (_GroupList); } } @@ -266,7 +270,7 @@ namespace NLGUI else if (stricmp((char*)cur->name, "action") == 0) { - string strId, strAh, strParams, strCond, strTexture=""; + string strId, strAh, strParams, strCond, strTexture; ucstring ucstrName; if (id) strId = (const char*)id; @@ -381,6 +385,22 @@ namespace NLGUI return true; } + // ------------------------------------------------------------------------------------------------ + CViewBitmap *CGroupSubMenu::createIcon(CInterfaceElement *parentPos, const string &texture) + { + // Add an icon to the line + CViewBitmap *pVB = new CViewBitmap(CViewBase::TCtorParam()); + pVB->setSerializable( false ); + pVB->setParent (this); + pVB->setParentPos (parentPos); + pVB->setParentPosRef (Hotspot_ML); + pVB->setPosRef (Hotspot_MR); + pVB->setTexture(texture); + pVB->setModulateGlobalColor(false); + pVB->setX (-2); + addView (pVB); + return pVB; + } // ------------------------------------------------------------------------------------------------ CViewBitmap *CGroupSubMenu::createCheckBox(bool checked) @@ -1077,7 +1097,7 @@ namespace NLGUI for (uint32 i = 0; i < pCurGSM->_Lines.size(); ++i) if (sRest == pCurGSM->_Lines[i].Id) return pCurGSM->_Lines[i].ViewText; - sRest = ""; + sRest.clear(); } else // no a lot of token left { @@ -1226,13 +1246,22 @@ namespace NLGUI pV->setCheckBox(checkBox); } + CViewBitmap *icon = NULL; + if (!texture.empty()) + { + if (_GroupList->getNumChildren() == 1) + pV->setX(20); + icon = createIcon(pV, texture); + } + + tmp.ViewText = pV; tmp.Separator = NULL; tmp.AHName = ah; tmp.AHParams = params; tmp.Cond = cond; tmp.CheckBox = checkBox; - tmp.RightArrow = NULL; + tmp.RightArrow = icon; if (id.empty()) tmp.Id = NLMISC::toString (_Lines.size()); else @@ -1773,6 +1802,22 @@ namespace NLGUI return 0; } + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaAddIconLine(CLuaState &ls) + { + const char *funcName = "addIconLine"; + CLuaIHM::checkArgCount(ls, funcName, 5); + CLuaIHM::checkArgTypeUCString(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); + ucstring arg1; + nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); + addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5)); + return 0; + } + // ------------------------------------------------------------------------------------------------ int CGroupSubMenu::luaAddLineAtIndex(CLuaState &ls) { diff --git a/code/nel/src/gui/group_modal.cpp b/code/nel/src/gui/group_modal.cpp index fb4c6d129..95ca783eb 100644 --- a/code/nel/src/gui/group_modal.cpp +++ b/code/nel/src/gui/group_modal.cpp @@ -24,6 +24,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/group_paragraph.cpp b/code/nel/src/gui/group_paragraph.cpp index 9e065c878..b2635b52e 100644 --- a/code/nel/src/gui/group_paragraph.cpp +++ b/code/nel/src/gui/group_paragraph.cpp @@ -31,6 +31,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlLink, std::string, "button_link"); namespace NLGUI @@ -55,7 +59,6 @@ namespace NLGUI _TopSpace = 0; _Indent = 0; _FirstViewIndentView = false; - _BrowseGroup = NULL; _TextId = 0; } @@ -337,7 +340,7 @@ namespace NLGUI if( fromString( value, i ) ) { _TextId = i; - _HardText = ""; + _HardText.clear(); } onTextChanged(); return; @@ -864,11 +867,8 @@ namespace NLGUI ctrl->setParentPosRef (Hotspot_TL); ctrl->setPosRef (Hotspot_TL); ctrl->setActive(true); - if (_BrowseGroup) - { - ctrl->setActionOnLeftClick("browse"); - ctrl->setParamsOnLeftClick("name="+_BrowseGroup->getId()+"|url="+link.Link->Link); - } + ctrl->setActionOnLeftClick(link.Link->getActionOnLeftClick()); + ctrl->setParamsOnLeftClick(link.Link->getParamsOnLeftClick()); ctrl->setScale(true); addCtrl(ctrl); } @@ -1208,7 +1208,7 @@ namespace NLGUI { // update the list size sint32 newH = _H + child->getH(); - if (_Elements.size() > 0) + if (!_Elements.empty()) newH += _Space; _H = newH; @@ -1222,7 +1222,7 @@ namespace NLGUI { // Update the list coords sint32 newW = _W + child->getW(); - if (_Elements.size() > 0) + if (!_Elements.empty()) newW += _Space; _W = newW; @@ -1452,7 +1452,7 @@ namespace NLGUI void CGroupParagraph::onTextChanged() { - if( _Elements.size() == 0 ) + if( _Elements.empty() ) return; CElementInfo &e = _Elements[ 0 ]; diff --git a/code/nel/src/gui/group_scrolltext.cpp b/code/nel/src/gui/group_scrolltext.cpp index c82bd40bf..aff59e5c2 100644 --- a/code/nel/src/gui/group_scrolltext.cpp +++ b/code/nel/src/gui/group_scrolltext.cpp @@ -25,6 +25,10 @@ #include "nel/misc/i18n.h" #include "nel/gui/widget_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CGroupScrollText, std::string, "scroll_text"); namespace NLGUI diff --git a/code/nel/src/gui/group_submenu_base.cpp b/code/nel/src/gui/group_submenu_base.cpp index 1c98fe643..8b26a7d85 100644 --- a/code/nel/src/gui/group_submenu_base.cpp +++ b/code/nel/src/gui/group_submenu_base.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/group_submenu_base.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/group_tab.cpp b/code/nel/src/gui/group_tab.cpp index 69ccce046..d79efdad3 100644 --- a/code/nel/src/gui/group_tab.cpp +++ b/code/nel/src/gui/group_tab.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CGroupTab, std::string, "tab"); namespace NLGUI diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index a82ad5617..f3f009dfc 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -29,6 +29,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -336,7 +340,7 @@ namespace NLGUI } // ---------------------------------------------------------------------------- - bool CGroupCell::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex) + bool CGroupCell::parseCell(xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex) { CXMLAutoPtr ptr; ptr = (char*) xmlGetProp( cur, (xmlChar*)"id"); @@ -1558,7 +1562,7 @@ namespace NLGUI if (strcmp((char*)currCol->name,"TD") == 0) { CGroupCell *cell = new CGroupCell(CViewBase::TCtorParam()); - if (cell->parse(currCol, this, column, row)) + if (cell->parseCell(currCol, this, column, row)) { cell->NewLine = newLine; newLine = false; diff --git a/code/nel/src/gui/group_tree.cpp b/code/nel/src/gui/group_tree.cpp index 1b80ee84b..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..a2467809d 100644 --- a/code/nel/src/gui/interface_expr_user_fct.cpp +++ b/code/nel/src/gui/interface_expr_user_fct.cpp @@ -25,6 +25,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -206,7 +210,7 @@ namespace NLGUI static DECLARE_INTERFACE_USER_FCT(userFctIdentity) { - if (args.size() > 0) + if (!args.empty()) { result = args[0]; return true; @@ -350,9 +354,9 @@ namespace NLGUI static DECLARE_INTERFACE_USER_FCT(userFctStr) { - if (args.size() > 0) + if (!args.empty()) { - ucstring res(""); + ucstring res; for (uint32 i = 0; i < args.size(); ++i) { args[i].toString(); diff --git a/code/nel/src/gui/interface_factory.cpp b/code/nel/src/gui/interface_factory.cpp index ec914baa6..7f0fe76ee 100644 --- a/code/nel/src/gui/interface_factory.cpp +++ b/code/nel/src/gui/interface_factory.cpp @@ -18,6 +18,10 @@ #include "nel/gui/view_base.h" #include "nel/misc/factory.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { CViewBase* CInterfaceFactory::createClass( const std::string &name ) diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index 5f4366981..fc75ae0db 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -32,6 +32,10 @@ using namespace std; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + #define IG_UNIQUE_ID(this) ((void*)&((this)->_GroupSizeRef)) // NB nico : use some pointer *inside* CInterfaceGroup as a unique id for lua registry (any field but // the first), instead of using 'this'. 'this' is already used by // CLuaIHM::pushReflectableOnStack as unique id to CInterfaceElement's ref pointers @@ -999,7 +1003,7 @@ namespace NLGUI { string idTmp = id, lidTmp = lid; // bool isFound = true; - while (idTmp.size() > 0) + while (!idTmp.empty()) { string tokid, toklid; @@ -1031,12 +1035,12 @@ namespace NLGUI if (posid > 0) idTmp = idTmp.substr (0, posid); else - idTmp = ""; + idTmp.clear(); if (poslid > 0) lidTmp = lidTmp.substr (0, poslid); else - lidTmp = ""; + lidTmp.clear(); } return true; } @@ -1778,7 +1782,7 @@ namespace NLGUI { // bool bUnder = pChild->getViewsUnder (x, y, clipX, clipY, clipW, clipH, vVB); - // if (bUnder && (vICL.size() > 0)) + // if (bUnder && !vICL.empty()) // return true; } } @@ -1833,7 +1837,7 @@ namespace NLGUI { // bool bUnder = pChild->getCtrlsUnder (x, y, clipX, clipY, clipW, clipH, vICL); - // if (bUnder && (vICL.size() > 0)) + // if (bUnder && !vICL.empty()) // return true; } } @@ -1889,7 +1893,7 @@ namespace NLGUI { // bool bUnder = pChild->getGroupsUnder (x, y, clipX, clipY, clipW, clipH, vIGL); - // if (bUnder && (vICL.size() > 0)) + // if (bUnder && !vICL.empty()) // return true; } } diff --git a/code/nel/src/gui/interface_link.cpp b/code/nel/src/gui/interface_link.cpp index 282199ee7..4266797f4 100644 --- a/code/nel/src/gui/interface_link.cpp +++ b/code/nel/src/gui/interface_link.cpp @@ -33,6 +33,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -664,7 +668,7 @@ namespace NLGUI { std::vector vTargets; splitLinkTargets(Target, pIG, vTargets); - if ((vTargets.size() > 0) && (vTargets[0].Elem)) + if (!vTargets.empty() && (vTargets[0].Elem)) { vTargets[0].affect(val); } diff --git a/code/nel/src/gui/interface_options.cpp b/code/nel/src/gui/interface_options.cpp index 1daef83cb..9a71e3709 100644 --- a/code/nel/src/gui/interface_options.cpp +++ b/code/nel/src/gui/interface_options.cpp @@ -26,6 +26,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 068d827bf..63eb165e3 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -42,6 +42,11 @@ #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger #endif + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + const uint32 UI_CACHE_SERIAL_CHECK = NELID("IUG_"); using namespace NLMISC; @@ -665,10 +670,10 @@ namespace NLGUI if (strchr(ptr, '#') != NULL) { string LastProp = ptr.str(); - string NewProp =""; + string NewProp; string RepProp; - while (LastProp.size() > 0) + while (!LastProp.empty()) { string::size_type diesPos = LastProp.find("#"); if (diesPos != string::npos) @@ -709,7 +714,7 @@ namespace NLGUI else { NewProp += LastProp; - LastProp = ""; + LastProp.clear(); } } xmlSetProp(node,props->name, (const xmlChar*)NewProp.c_str()); diff --git a/code/nel/src/gui/interface_property.cpp b/code/nel/src/gui/interface_property.cpp index 694bd6c36..5b11c9b74 100644 --- a/code/nel/src/gui/interface_property.cpp +++ b/code/nel/src/gui/interface_property.cpp @@ -20,13 +20,17 @@ #include "nel/gui/interface_property.h" #include "nel/gui/interface_common.h" #include "nel/gui/db_manager.h" +#include "nel/misc/common.h" using namespace NLMISC; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { - bool CInterfaceProperty::link( CCDBNodeLeaf *dbNode ) { _VolatileValue = dbNode; @@ -66,6 +70,20 @@ namespace NLGUI } + void CInterfaceProperty::setDouble(double value) + { + C64BitsParts parts; + parts.d[0] = value; + setSInt64(parts.i64[0]); + } + + double CInterfaceProperty::getDouble() const + { + C64BitsParts parts; + parts.i64[0] = getSInt64(); + return parts.d[0]; + } + // ***************** // sint64 operations // ***************** @@ -104,10 +122,9 @@ namespace NLGUI if ( isdigit(*ptr) || *ptr=='-') { _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - double buf; - fromString(ptr, buf); - sint64 i = *(sint64*)&buf; - _VolatileValue->setValue64( i ); + C64BitsParts buf; + fromString(ptr, buf.d[0]); + _VolatileValue->setValue64(buf.i64[0]); } else { diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index 53cc9e403..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..fed1340a0 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -92,6 +92,10 @@ Compilation is VERY SLOW using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // declare ostream << operator for ucstring -> registration of ucstring iin luabind will build a 'tostring' function from it std::ostream &operator<<(std::ostream &str, const ucstring &value) { @@ -107,11 +111,11 @@ namespace NLGUI { return NLMISC::CPath::lookup(fileName, false); } - static void shellExecute(const char *operation, const char *fileName, const char *parameters) + static void shellExecute(const std::string &operation, const std::string &fileName, const std::string ¶meters) { #if !FINAL_VERSION #ifdef NL_OS_WINDOWS - ShellExecute(NULL, operation, fileName, parameters, NULL, SW_SHOWDEFAULT); + ShellExecuteW(NULL, utf8ToWide(operation), utf8ToWide(fileName), utf8ToWide(parameters), NULL, SW_SHOWDEFAULT); #endif #endif } @@ -1516,7 +1520,7 @@ namespace NLGUI CSString s = str; // Create table recursively (ex: 'game.TPVPClan' will check/create the table 'game' and 'game.TPVPClan') p = s.splitTo('.', true); - while (p.size() > 0) + while (!p.empty()) { if (path.empty() ) path = p; @@ -1701,8 +1705,20 @@ namespace NLGUI void *ptr= ls.newUserData(sizeof(CReflectableLuaRef)); nlassert(ptr); //ls.dumpStack(); - // initialize it, and copy the given element + +// disable memory leaks detection for placement new +#ifdef new + #undef new +#endif + + // initialize it, and copy the given element new (ptr) CReflectableLuaRef(pRPT); + +// reenable memory leaks detection for placement new +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + // Assign to this user data the __ui_metatable //ls.dumpStack(); ls.push(IHM_LUA_METATABLE); // userdata "__ui_metatable" 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 57581d6ec..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 { 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..b479cb889 100644 --- a/code/nel/src/gui/view_bitmap.cpp +++ b/code/nel/src/gui/view_bitmap.cpp @@ -26,6 +26,9 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif NLMISC_REGISTER_OBJECT(CViewBase, CViewBitmap, std::string, "bitmap"); REGISTER_UI_CLASS(CViewBitmap) @@ -508,6 +511,9 @@ namespace NLGUI // *************************************************************************** sint32 CViewBitmap::getMaxUsedW() const { + if (_Scale) + return _WReal; + sint32 txw, txh; CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.getTextureSizeFromId (_TextureId, txw, txh); diff --git a/code/nel/src/gui/view_bitmap_combo.cpp b/code/nel/src/gui/view_bitmap_combo.cpp index 3fc54c89a..8fbc7609c 100644 --- a/code/nel/src/gui/view_bitmap_combo.cpp +++ b/code/nel/src/gui/view_bitmap_combo.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -411,7 +415,7 @@ namespace NLGUI } } - if (_TexsId.size() == 0) + if (_TexsId.empty()) { for (i = 0; i < _Texs.size(); ++i) _TexsId.push_back(rVR.getTextureIdFromName(_Texs[i])); diff --git a/code/nel/src/gui/view_link.cpp b/code/nel/src/gui/view_link.cpp index 1db08f583..7de4e3a01 100644 --- a/code/nel/src/gui/view_link.cpp +++ b/code/nel/src/gui/view_link.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/view_pointer.cpp b/code/nel/src/gui/view_pointer.cpp index da8d730fc..aa5dff6d2 100644 --- a/code/nel/src/gui/view_pointer.cpp +++ b/code/nel/src/gui/view_pointer.cpp @@ -27,6 +27,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + NLMISC_REGISTER_OBJECT(CViewBase, CViewPointer, std::string, "generic_pointer"); namespace NLGUI diff --git a/code/nel/src/gui/view_pointer_base.cpp b/code/nel/src/gui/view_pointer_base.cpp index e29af7858..9589afd9c 100644 --- a/code/nel/src/gui/view_pointer_base.cpp +++ b/code/nel/src/gui/view_pointer_base.cpp @@ -18,6 +18,10 @@ #include "stdpch.h" #include "nel/gui/view_pointer_base.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { @@ -76,16 +80,39 @@ namespace NLGUI { _PointerDown = pd; - if (_PointerDown == true) + if (_PointerDown) { _PointerDownX = _PointerX; _PointerDownY = _PointerY; } - - if (_PointerDown == false) + else _PointerDrag = false; } + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::setPointerMiddleDown (bool pd) + { + _PointerMiddleDown = pd; + + if (_PointerMiddleDown) + { + _PointerMiddleDownX = _PointerX; + _PointerMiddleDownY = _PointerY; + } + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::setPointerRightDown (bool pd) + { + _PointerRightDown = pd; + + if (_PointerRightDown) + { + _PointerRightDownX = _PointerX; + _PointerRightDownY = _PointerY; + } + } + // -------------------------------------------------------------------------------------------------------------------- void CViewPointerBase::setPointerDownString (const std::string &s) { @@ -116,16 +143,30 @@ namespace NLGUI } // -------------------------------------------------------------------------------------------------------------------- - void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y) + bool CViewPointerBase::getPointerDown (sint32 &x, sint32 &y) { x = _PointerDownX; y = _PointerDownY; + + return _PointerDown; } // -------------------------------------------------------------------------------------------------------------------- - bool CViewPointerBase::getPointerDown () + bool CViewPointerBase::getPointerMiddleDown (sint32 &x, sint32 &y) { - return _PointerDown; + x = _PointerMiddleDownX; + y = _PointerMiddleDownY; + + return _PointerMiddleDown; + } + + // -------------------------------------------------------------------------------------------------------------------- + bool CViewPointerBase::getPointerRightDown (sint32 &x, sint32 &y) + { + x = _PointerRightDownX; + y = _PointerRightDownY; + + return _PointerRightDown; } // -------------------------------------------------------------------------------------------------------------------- diff --git a/code/nel/src/gui/view_polygon.cpp b/code/nel/src/gui/view_polygon.cpp index baacf94a0..f3fd8efa2 100644 --- a/code/nel/src/gui/view_polygon.cpp +++ b/code/nel/src/gui/view_polygon.cpp @@ -23,6 +23,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/view_quad.cpp b/code/nel/src/gui/view_quad.cpp index 426a19f08..2724fe3b3 100644 --- a/code/nel/src/gui/view_quad.cpp +++ b/code/nel/src/gui/view_quad.cpp @@ -22,6 +22,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLGUI { diff --git a/code/nel/src/gui/view_renderer.cpp b/code/nel/src/gui/view_renderer.cpp index 4c5d7c501..fc641d1cf 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 { @@ -237,7 +241,7 @@ namespace NLGUI // *************************************************************************** NL3D::UTextContext* CViewRenderer::getTextContext(const std::string &name) { - if (name.size() > 0 && fonts.count(name) > 0) + if (!name.empty() && fonts.count(name) > 0) return fonts[name]; return textcontext; @@ -253,7 +257,7 @@ namespace NLGUI driver->deleteTextContext(fonts[name]); std::string fontFile = CPath::lookup(font, false); - if (fontFile.size() == 0) + if (fontFile.empty()) { nlwarning("Font file '%s' not found", font.c_str()); return false; diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index a2975fc1a..e145db91c 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) @@ -894,7 +898,7 @@ namespace NLGUI if ((_MultiLine)&&(_Parent != NULL)) { // If never setuped, and if text is not empty - if (_Lines.size() == 0 && !_Text.empty()) + if (_Lines.empty() && !_Text.empty()) invalidateContent (); sint currentMaxW= getCurrentMultiLineMaxW(); @@ -982,7 +986,7 @@ namespace NLGUI // *** Draw multiline if ((_MultiLine)&&(_Parent != NULL)) { - if (_Lines.size() == 0) return; + if (_Lines.empty()) return; TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); @@ -1665,7 +1669,7 @@ namespace NLGUI { if (expandSpaces) { - nlassert(_Lines.size() > 0); + nlassert(!_Lines.empty()); nlassert(_Lines.back()->getNumWords() > 0); // Yoyo: if the line has tab, then don't justify @@ -1872,7 +1876,7 @@ namespace NLGUI } // Special case for multiline limited in number of lines - if ((_Lines.size() > 0) && (_MultiMaxLine > 0) && (_Lines.size() > _MultiMaxLine)) + if (!_Lines.empty() && (_MultiMaxLine > 0) && (_Lines.size() > _MultiMaxLine)) { while (_Lines.size() > _MultiMaxLine) { @@ -1901,7 +1905,7 @@ namespace NLGUI _H = std::max(_H, sint(_FontHeight * _MultiMinLine + (_MultiMinLine - 1) * _MultiLineSpace)); // Compute tooltips size - if (_Tooltips.size() > 0) + if (!_Tooltips.empty()) for (uint i=0 ; i<_Lines.size() ; ++i) { for (uint j=0 ; j<_Lines[i]->getNumWords() ; ++j) 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 d3888b68c..d256704cb 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(); @@ -462,7 +466,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ CInterfaceElement* CWidgetManager::getElementFromDefine( const std::string &defineId ) { - return getElementFromId( parser->getDefine( defineId ) ); + return getElementFromId( _Parser->getDefine( defineId ) ); } // ------------------------------------------------------------------------------------------------ @@ -1758,16 +1762,12 @@ namespace NLGUI // *** According to best matching hotspot, and new screen resolution, move the window // x - if(bestXHotSpot==Hotspot_xL) - x= x; - else if(bestXHotSpot==Hotspot_xM) + if(bestXHotSpot==Hotspot_xM) x= newScreenW/2 + posXToMiddle - w/2; else if(bestXHotSpot==Hotspot_xR) x= newScreenW - posXToRight - w; // y - if(bestYHotSpot==Hotspot_Bx) - y= y; - else if(bestYHotSpot==Hotspot_Mx) + if(bestYHotSpot==Hotspot_Mx) y= newScreenH/2 + posYToMiddle + h/2; else if(bestYHotSpot==Hotspot_Tx) y= newScreenH - posYToTop; @@ -2109,8 +2109,6 @@ namespace NLGUI bool handled = false; - CViewPointer *_Pointer = static_cast< CViewPointer* >( getPointer() ); - if( evnt.getType() == CEventDescriptor::system ) { handleSystemEvent( evnt ); @@ -3272,7 +3270,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 +3296,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 +3319,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; @@ -3332,7 +3330,7 @@ namespace NLGUI { const CProcAction &action = proc.Actions[i]; // test if the condition for the action is valid - if( action.CondBlocks.size() > 0 ) + if (!action.CondBlocks.empty()) { CInterfaceExprValue result; result.setBool( false ); @@ -3357,7 +3355,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 +3695,7 @@ namespace NLGUI CReflectableRegister::registerClasses(); - parser = IParser::createParser(); + _Parser = IParser::createParser(); _Pointer = NULL; curContextHelp = NULL; @@ -3739,6 +3737,9 @@ namespace NLGUI delete _MasterGroups[i].Group; } + delete _Parser; + _Parser = NULL; + _Pointer = NULL; curContextHelp = NULL; diff --git a/code/nel/src/ligo/ligo_config.cpp b/code/nel/src/ligo/ligo_config.cpp index f836c808e..d898e44ed 100644 --- a/code/nel/src/ligo/ligo_config.cpp +++ b/code/nel/src/ligo/ligo_config.cpp @@ -39,7 +39,7 @@ CLigoConfig::CLigoConfig() // *************************************************************************** -bool CLigoConfig::readConfigFile (const char *fileName, bool parsePrimitiveComboContent) +bool CLigoConfig::readConfigFile (const std::string &fileName, bool parsePrimitiveComboContent) { // The CF CConfigFile cf; @@ -73,7 +73,7 @@ bool CLigoConfig::readConfigFile (const char *fileName, bool parsePrimitiveCombo // *************************************************************************** -bool CLigoConfig::readPrimitiveClass (const char *_fileName, bool parsePrimitiveComboContent) +bool CLigoConfig::readPrimitiveClass (const std::string &_fileName, bool parsePrimitiveComboContent) { // File exist ? string filename = _fileName; @@ -508,13 +508,13 @@ bool CLigoConfig::canBeRoot (const NLLIGO::IPrimitive &child) // *************************************************************************** -bool CLigoConfig::getPropertyString (std::string &result, const char *filename, xmlNodePtr xmlNode, const char *propName) +bool CLigoConfig::getPropertyString(std::string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &propName) { // Call the CIXml version if (!CIXml::getPropertyString (result, xmlNode, propName)) { // Output a formated error - syntaxError (filename, xmlNode, "Missing XML node property (%s)", propName); + syntaxError (filename, xmlNode, "Missing XML node property (%s)", propName.c_str()); return false; } return true; @@ -522,7 +522,7 @@ bool CLigoConfig::getPropertyString (std::string &result, const char *filename, // *************************************************************************** -void CLigoConfig::syntaxError (const char *filename, xmlNodePtr xmlNode, const char *format, ...) +void CLigoConfig::syntaxError (const std::string &filename, xmlNodePtr xmlNode, const char *format, ...) { va_list args; va_start( args, format ); @@ -530,7 +530,7 @@ void CLigoConfig::syntaxError (const char *filename, xmlNodePtr xmlNode, const c vsnprintf( buffer, 1024, format, args ); va_end( args ); - errorMessage ("(%s), node (%s), line (%p) :\n%s", filename, xmlNode->name, xmlNode->content, buffer); + errorMessage ("(%s), node (%s), line (%d) :\n%s", filename.c_str(), xmlNode->name, (sint)xmlNode->line, buffer); } // *************************************************************************** @@ -589,7 +589,7 @@ const CPrimitiveClass *CLigoConfig::getPrimitiveClass (const IPrimitive &primiti // *************************************************************************** -const CPrimitiveClass *CLigoConfig::getPrimitiveClass (const char *className) const +const CPrimitiveClass *CLigoConfig::getPrimitiveClass(const std::string &className) const { std::map::const_iterator ite = _PrimitiveClasses.find (className); if (ite != _PrimitiveClasses.end ()) @@ -785,7 +785,7 @@ std::string CLigoConfig::aliasToString(uint32 fullAlias) } -uint32 CLigoConfig::aliasFromString(std::string fullAlias) +uint32 CLigoConfig::aliasFromString(const std::string &fullAlias) { uint32 staticPart; uint32 dynPart; diff --git a/code/nel/src/ligo/ligo_error.cpp b/code/nel/src/ligo/ligo_error.cpp index fdca7a2c2..30315b3e6 100644 --- a/code/nel/src/ligo/ligo_error.cpp +++ b/code/nel/src/ligo/ligo_error.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . #include "stdligo.h" -#include "ligo_error.h" +#include "nel/ligo/ligo_error.h" namespace NLLIGO { diff --git a/code/nel/src/ligo/ligo_material.cpp b/code/nel/src/ligo/ligo_material.cpp index c5e7541a3..2c46e6977 100644 --- a/code/nel/src/ligo/ligo_material.cpp +++ b/code/nel/src/ligo/ligo_material.cpp @@ -15,13 +15,17 @@ // along with this program. If not, see . #include "stdligo.h" -#include "ligo_material.h" +#include "nel/ligo/ligo_material.h" // Ligo include -#include "ligo_error.h" +#include "nel/ligo/ligo_error.h" //using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLLIGO { diff --git a/code/nel/src/ligo/primitive.cpp b/code/nel/src/ligo/primitive.cpp index 3fc97fdf5..cc6555222 100644 --- a/code/nel/src/ligo/primitive.cpp +++ b/code/nel/src/ligo/primitive.cpp @@ -28,6 +28,10 @@ using namespace std; const uint32 NLLIGO_PRIMITIVE_VERSION = 1; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLLIGO { @@ -38,7 +42,7 @@ CPrimitiveContext *CPrimitiveContext::_Instance = NULL; // XML helpers // *************************************************************************** -void Error (const char *filename, const char *format, ...) +void Error (const std::string &filename, const char *format, ...) { va_list args; va_start( args, format ); @@ -46,12 +50,12 @@ void Error (const char *filename, const char *format, ...) vsnprintf( buffer, 1024, format, args ); va_end( args ); - nlwarning ("In File (%s) %s", filename, buffer); + nlwarning ("In File (%s) %s", filename.c_str(), buffer); } // *************************************************************************** -void XMLError (xmlNodePtr xmlNode, const char *filename, const char *format, ... ) +void XMLError (xmlNodePtr xmlNode, const std::string &filename, const char *format, ... ) { va_list args; va_start( args, format ); @@ -59,32 +63,32 @@ void XMLError (xmlNodePtr xmlNode, const char *filename, const char *format, ... vsnprintf( buffer, 1024, format, args ); va_end( args ); - Error (filename, "node (%s), line (%p) : %s", xmlNode->name, xmlNode->content, buffer); + Error (filename, "node (%s), line (%d) : %s", xmlNode->name, xmlNode->line, buffer); } // *************************************************************************** -xmlNodePtr GetFirstChildNode (xmlNodePtr xmlNode, const char *filename, const char *childName) +xmlNodePtr GetFirstChildNode (xmlNodePtr xmlNode, const std::string &filename, const std::string &childName) { // Call the CIXml version xmlNodePtr result = CIXml::getFirstChildNode (xmlNode, childName); if (result) return result; // Output a formated error - XMLError (xmlNode, filename, "Can't find XML node named (%s)", childName); + XMLError (xmlNode, filename.c_str(), "Can't find XML node named (%s)", childName.c_str()); return NULL; } // *************************************************************************** -bool GetPropertyString (string &result, const char *filename, xmlNodePtr xmlNode, const char *propName) +bool GetPropertyString (string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &propName) { // Call the CIXml version if (!CIXml::getPropertyString (result, xmlNode, propName)) { // Output a formated error - XMLError (xmlNode, filename, "Can't find XML node property (%s)", propName); + XMLError (xmlNode, filename, "Can't find XML node property (%s)", propName.c_str()); return false; } return true; @@ -92,7 +96,7 @@ bool GetPropertyString (string &result, const char *filename, xmlNodePtr xmlNode // *************************************************************************** -bool ReadInt (const char *propName, int &result, const char *filename, xmlNodePtr xmlNode) +bool ReadInt (const std::string &propName, int &result, const std::string &filename, xmlNodePtr xmlNode) { string value; if (GetPropertyString (value, filename, xmlNode, propName)) @@ -105,15 +109,15 @@ bool ReadInt (const char *propName, int &result, const char *filename, xmlNodePt // *************************************************************************** -void WriteInt (const char *propName, int value, xmlNodePtr xmlNode) +void WriteInt (const std::string &propName, int value, xmlNodePtr xmlNode) { // Set properties - xmlSetProp (xmlNode, (const xmlChar*)propName, (const xmlChar*)(toString (value).c_str ())); + xmlSetProp (xmlNode, (const xmlChar*)propName.c_str(), (const xmlChar*)(toString (value).c_str ())); } // *************************************************************************** -bool ReadUInt (const char *propName, uint &result, const char *filename, xmlNodePtr xmlNode) +bool ReadUInt (const std::string &propName, uint &result, const std::string &filename, xmlNodePtr xmlNode) { string value; if (GetPropertyString (value, filename, xmlNode, propName)) @@ -126,15 +130,15 @@ bool ReadUInt (const char *propName, uint &result, const char *filename, xmlNode // *************************************************************************** -void WriteUInt (const char *propName, uint value, xmlNodePtr xmlNode) +void WriteUInt (const std::string &propName, uint value, xmlNodePtr xmlNode) { // Set properties - xmlSetProp (xmlNode, (const xmlChar*)propName, (const xmlChar*)(toString (value).c_str ())); + xmlSetProp (xmlNode, (const xmlChar*)propName.c_str(), (const xmlChar*)(toString (value).c_str ())); } // *************************************************************************** -bool ReadFloat (const char *propName, float &result, const char *filename, xmlNodePtr xmlNode) +bool ReadFloat (const std::string &propName, float &result, const std::string &filename, xmlNodePtr xmlNode) { string value; if (GetPropertyString (value, filename, xmlNode, propName)) @@ -147,15 +151,15 @@ bool ReadFloat (const char *propName, float &result, const char *filename, xmlNo // *************************************************************************** -void WriteFloat (const char *propName, float value, xmlNodePtr xmlNode) +void WriteFloat (const std::string &propName, float value, xmlNodePtr xmlNode) { // Set properties - xmlSetProp (xmlNode, (const xmlChar*)propName, (const xmlChar*)(toString (value).c_str ())); + xmlSetProp (xmlNode, (const xmlChar*)propName.c_str(), (const xmlChar*)(toString (value).c_str ())); } // *************************************************************************** -bool ReadVector (CPrimVector &point, const char *filename, xmlNodePtr xmlNode) +bool ReadVector (CPrimVector &point, const std::string &filename, xmlNodePtr xmlNode) { CPrimVector pos; if (ReadFloat ("X", pos.x, filename, xmlNode)) @@ -194,20 +198,20 @@ void WriteVector (const CPrimVector &point, xmlNodePtr xmlNode) // *************************************************************************** -bool GetNodeString (string &result, const char *filename, xmlNodePtr xmlNode, const char *nodeName) +bool GetNodeString (string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &nodeName) { // Look for the node xmlNodePtr node = CIXml::getFirstChildNode (xmlNode, nodeName); if (!node) { - XMLError (xmlNode, filename, "Can't find XML node named (%s)", nodeName); + XMLError (xmlNode, filename, "Can't find XML node named (%s)", nodeName.c_str()); return false; } // Get the node string if (!CIXml::getContentString (result, node)) { - XMLError (xmlNode, filename, "Can't find any text in the node named (%s)", nodeName); + XMLError (xmlNode, filename, "Can't find any text in the node named (%s)", nodeName.c_str()); return false; } @@ -216,7 +220,7 @@ bool GetNodeString (string &result, const char *filename, xmlNodePtr xmlNode, co // *************************************************************************** -bool GetContentString (string &result, const char *filename, xmlNodePtr xmlNode) +bool GetContentString (string &result, const std::string &filename, xmlNodePtr xmlNode) { // Get the node string if (!CIXml::getContentString (result, xmlNode)) @@ -232,11 +236,6 @@ bool GetContentString (string &result, const char *filename, xmlNodePtr xmlNode) // CPropertyString // *************************************************************************** -CPropertyString::CPropertyString (const char *str) -{ - String = str; -} - CPropertyString::CPropertyString (const std::string &str) { String = str; @@ -244,7 +243,7 @@ CPropertyString::CPropertyString (const std::string &str) // *************************************************************************** -CPropertyString::CPropertyString (const char *str, bool _default) +CPropertyString::CPropertyString (const std::string &str, bool _default) { String = str; Default = _default; @@ -386,7 +385,7 @@ bool CPrimZone::contains (const NLMISC::CVector &v, const std::vector::const_iterator ite = _Properties.find (property_name); @@ -1324,7 +1323,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, const IProperty * // *************************************************************************** -bool IPrimitive::getPropertyByName (const char *property_name, IProperty *&result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, IProperty *&result) const { // Look for the property std::map::const_iterator ite = _Properties.find (property_name); @@ -1338,7 +1337,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, IProperty *&resul // *************************************************************************** -bool IPrimitive::getPropertyByName (const char *property_name, std::string *&result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, std::string *&result) const { // Get the property IProperty *prop; @@ -1352,7 +1351,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string *&res } else { - nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); + nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name.c_str()); } } return false; @@ -1360,7 +1359,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string *&res // *************************************************************************** -bool IPrimitive::getPropertyByName (const char *property_name, std::string &result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, std::string &result) const { // Get the property const IProperty *prop; @@ -1374,7 +1373,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string &resu } else { - nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); + nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name.c_str()); } } return false; @@ -1382,7 +1381,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::string &resu // *************************************************************************** -bool IPrimitive::getPropertyByName (const char *property_name, std::vector *&result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, std::vector *&result) const { // Get the property IProperty *prop; @@ -1396,7 +1395,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, std::vector *&result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, const std::vector *&result) const { // Get the property IProperty *prop; @@ -1418,7 +1417,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, const std::vector } else { - nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); + nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name.c_str()); } } return false; @@ -1426,7 +1425,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, const std::vector // *************************************************************************** -bool IPrimitive::getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const +bool IPrimitive::getPropertyByName (const std::string &property_name, NLMISC::CRGBA &result) const { // Get the property IProperty *prop; @@ -1440,7 +1439,7 @@ bool IPrimitive::getPropertyByName (const char *property_name, NLMISC::CRGBA &re } else { - nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a color.", property_name); + nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a color.", property_name.c_str()); } } return false; @@ -1462,13 +1461,13 @@ bool IPrimitive::removeProperty (uint index) index--; ite ++; } - nlwarning ("NLLIGO::IPrimitive::removeProperty : invalid index (index : %d, size : %d).", index, _Properties.size ()); + nlwarning ("NLLIGO::IPrimitive::removeProperty : invalid index (index : %u, size : %u).", index, (uint)_Properties.size ()); return false; } // *************************************************************************** -bool IPrimitive::removePropertyByName (const char *property_name) +bool IPrimitive::removePropertyByName (const std::string &property_name) { // Look for the property std::map::iterator ite = _Properties.find (property_name); @@ -1504,7 +1503,7 @@ bool IPrimitive::getChild (const IPrimitive *&result, uint childId) const } else { - nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %d, size %d).", childId, _Children.size ()); + nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %u, size %u).", childId, (uint)_Children.size ()); } return false; } @@ -1520,7 +1519,7 @@ bool IPrimitive::getChild (IPrimitive *&result, uint childId) } else { - nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %d, size %d).", childId, _Children.size ()); + nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %u, size %u).", childId, (uint)_Children.size ()); } return false; } @@ -1554,7 +1553,7 @@ bool IPrimitive::removeChild (uint childId) } else { - nlwarning ("NLLIGO::IPrimitive::removeChild : invalid index (index : %d, size %d).", childId, _Children.size ()); + nlwarning ("NLLIGO::IPrimitive::removeChild : invalid index (index : %u, size %u).", childId, (uint)_Children.size ()); } return false; } @@ -1642,7 +1641,7 @@ bool IPrimitive::checkProperty(const std::string &property_name) const // *************************************************************************** -bool IPrimitive::addPropertyByName (const char *property_name, IProperty *result) +bool IPrimitive::addPropertyByName (const std::string &property_name, IProperty *result) { bool inserted = _Properties.insert (std::map::value_type (property_name, result)).second; if (inserted) @@ -1654,7 +1653,7 @@ bool IPrimitive::addPropertyByName (const char *property_name, IProperty *result // *************************************************************************** -bool IPrimitive::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) +bool IPrimitive::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config) { // Erase old properties _Properties.clear (); @@ -1664,7 +1663,7 @@ bool IPrimitive::read (xmlNodePtr xmlNode, const char *filename, uint version, C if (commentNode) { if (!CIXml::getContentString(_UnparsedProperties, commentNode)) - _UnparsedProperties = ""; + _UnparsedProperties.clear(); } // Read the expanded flag @@ -1915,7 +1914,7 @@ void IPrimitive::initDefaultValues (CLigoConfig &config) // *************************************************************************** -void IPrimitive::write (xmlNodePtr xmlNode, const char *filename) const +void IPrimitive::write (xmlNodePtr xmlNode, const std::string &filename) const { // Save the expanded flag // if (!Expanded) @@ -2112,7 +2111,7 @@ void CPrimAlias::regenAlias() // Read the primitive -bool CPrimAlias::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) +bool CPrimAlias::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config) { // Read alias xmlNodePtr ptNode = CIXml::getFirstChildNode (xmlNode, "ALIAS"); @@ -2146,7 +2145,7 @@ bool CPrimAlias::read (xmlNodePtr xmlNode, const char *filename, uint version, C return IPrimitive::read (xmlNode, filename, version, config); } // Write the primitive -void CPrimAlias::write (xmlNodePtr xmlNode, const char *filename) const +void CPrimAlias::write (xmlNodePtr xmlNode, const std::string &filename) const { // Write alias xmlNodePtr ptNode = xmlNewChild(xmlNode, NULL, (const xmlChar*)"ALIAS", NULL); @@ -2458,7 +2457,7 @@ CPrimitives& CPrimitives::operator= (const CPrimitives &other) // *************************************************************************** -bool CPrimitives::read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &config) +bool CPrimitives::read (xmlNodePtr xmlNode, const std::string &filename, CLigoConfig &config) { nlassert (xmlNode); @@ -2511,7 +2510,7 @@ bool CPrimitives::read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &c } else { - Error (filename, "CPrimitives::read : Unknown file version (%d)", version); + Error (filename, "CPrimitives::read : Unknown file version (%u)", version); return false; } } @@ -2531,7 +2530,7 @@ bool CPrimitives::read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &c // *************************************************************************** -void CPrimitives::write (xmlDocPtr doc, const char *filename) const +void CPrimitives::write (xmlDocPtr doc, const std::string &filename) const { nlassert (doc); @@ -2544,7 +2543,7 @@ void CPrimitives::write (xmlDocPtr doc, const char *filename) const // *************************************************************************** -void CPrimitives::write (xmlNodePtr root, const char *filename) const +void CPrimitives::write (xmlNodePtr root, const std::string &filename) const { nlassert (root); diff --git a/code/nel/src/ligo/primitive_class.cpp b/code/nel/src/ligo/primitive_class.cpp index 2b32cadec..02923285c 100644 --- a/code/nel/src/ligo/primitive_class.cpp +++ b/code/nel/src/ligo/primitive_class.cpp @@ -183,8 +183,8 @@ bool CPrimitiveClass::read (xmlNodePtr primitiveNode, // init default parameters AutoInit = false; Deletable = true; - FileExtension = ""; - FileType = ""; + FileExtension.clear(); + FileType.clear(); Collision = false; LinkBrothers = false; ShowArrow = true; @@ -351,16 +351,16 @@ bool CPrimitiveClass::read (xmlNodePtr primitiveNode, parameter.WidgetHeight = (uint)temp; // Read the file extension - parameter.FileExtension = ""; + parameter.FileExtension.clear(); CIXml::getPropertyString (parameter.FileExtension, paramNode, "FILE_EXTENSION"); parameter.FileExtension = toLower(parameter.FileExtension); // Autonaming preference - parameter.Autoname = ""; + parameter.Autoname.clear(); CIXml::getPropertyString (parameter.Autoname, paramNode, "AUTONAME"); // Read the file extension - parameter.Folder = ""; + parameter.Folder.clear(); CIXml::getPropertyString (parameter.Folder, paramNode, "FOLDER"); parameter.Folder = toLower(parameter.Folder); @@ -650,7 +650,7 @@ void CPrimitiveClass::CParameter::CConstStringValue::getPrimitivesForPrimPath (s bool CPrimitiveClass::CParameter::translateAutoname (std::string &result, const IPrimitive &primitive, const CPrimitiveClass &primitiveClass) const { - result = ""; + result.clear(); string::size_type strBegin = 0; string::size_type strEnd = 0; while (strBegin != Autoname.size()) @@ -745,7 +745,7 @@ bool CPrimitiveClass::CParameter::translateAutoname (std::string &result, const bool CPrimitiveClass::CParameter::getDefaultValue (std::string &result, const IPrimitive &primitive, const CPrimitiveClass &primitiveClass, std::string *fromWhere) const { - result = ""; + result.clear(); if (!Autoname.empty()) { if (fromWhere) diff --git a/code/nel/src/ligo/stdligo.h b/code/nel/src/ligo/stdligo.h index 85e7a2120..adc3887cf 100644 --- a/code/nel/src/ligo/stdligo.h +++ b/code/nel/src/ligo/stdligo.h @@ -14,7 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "nel/misc/types_nl.h" +#ifndef STDLIGO_H +#define STDLIGO_H + +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif #include #include @@ -44,6 +52,7 @@ // Include from libxml2 #include +#include "nel/misc/types_nl.h" #include "nel/misc/debug.h" #include "nel/misc/common.h" #include "nel/misc/fast_mem.h" @@ -67,3 +76,5 @@ #endif #include #endif + +#endif diff --git a/code/nel/src/ligo/transition.cpp b/code/nel/src/ligo/transition.cpp index ee6921c78..2a2e7b813 100644 --- a/code/nel/src/ligo/transition.cpp +++ b/code/nel/src/ligo/transition.cpp @@ -15,12 +15,16 @@ // along with this program. If not, see . #include "stdligo.h" -#include "transition.h" +#include "nel/ligo/transition.h" // Ligo include -#include "zone_template.h" -#include "ligo_error.h" -#include "ligo_material.h" +#include "nel/ligo/zone_template.h" +#include "nel/ligo/ligo_error.h" +#include "nel/ligo/ligo_material.h" + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLLIGO { diff --git a/code/nel/src/ligo/zone_bank.cpp b/code/nel/src/ligo/zone_bank.cpp index 6d5de79e8..e527e302f 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]; @@ -497,25 +500,20 @@ void CZoneBank::reset () // --------------------------------------------------------------------------- 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 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/logic_condition.cpp b/code/nel/src/logic/logic_condition.cpp index 2afe26ad6..f7d023d73 100644 --- a/code/nel/src/logic/logic_condition.cpp +++ b/code/nel/src/logic/logic_condition.cpp @@ -23,6 +23,8 @@ #include "nel/misc/o_xml.h" +#include "nel/misc/o_xml.h" + using namespace NLMISC; using namespace std; @@ -337,7 +339,7 @@ bool CLogicConditionNode::testLogic() } // if there's no subtree we assess the subtree is true - if( _Nodes.size() == 0 ) + if( _Nodes.empty() ) { return true; } diff --git a/code/nel/src/logic/stdlogic.h b/code/nel/src/logic/stdlogic.h index 67c7231c1..cdfe3f6f7 100644 --- a/code/nel/src/logic/stdlogic.h +++ b/code/nel/src/logic/stdlogic.h @@ -14,8 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#ifndef NL_STDMISC_H -#define NL_STDMISC_H +#ifndef NL_STDLOGIC_H +#define NL_STDLOGIC_H + +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif #include #include @@ -24,6 +31,12 @@ #include +#include "nel/misc/types_nl.h" +#include "nel/misc/entity_id.h" +#include "nel/misc/i_xml.h" +#include "nel/misc/o_xml.h" +#include "nel/misc/stream.h" + #ifdef NL_OS_WINDOWS # define WIN32_LEAN_AND_MEAN # define _WIN32_WINDOWS 0x0500 diff --git a/code/nel/src/misc/CMakeLists.txt b/code/nel/src/misc/CMakeLists.txt index 029d24323..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 diff --git a/code/nel/src/misc/app_context.cpp b/code/nel/src/misc/app_context.cpp index 5206681f9..a7381d026 100644 --- a/code/nel/src/misc/app_context.cpp +++ b/code/nel/src/misc/app_context.cpp @@ -124,6 +124,27 @@ CApplicationContext::CApplicationContext() contextReady(); } +CApplicationContext::~CApplicationContext() +{ +#ifdef NL_DEBUG + TSingletonRegistry::iterator it = _SingletonRegistry.begin(), iend = _SingletonRegistry.end(); + + while (it != iend) + { + // can't use nldebug there because it'll create new displayers + std::string message = toString("Instance '%s' still allocated at %p", it->first.c_str(), it->second); + +#ifdef NL_OS_WINDOWS + OutputDebugStringW(utf8ToWide(message)); +#else + printf("%s\n", message.c_str()); +#endif + + ++it; + } +#endif +} + void *CApplicationContext::getSingletonPointer(const std::string &singletonName) { TSingletonRegistry::iterator it(_SingletonRegistry.find(singletonName)); diff --git a/code/nel/src/misc/big_file.cpp b/code/nel/src/misc/big_file.cpp index a458b602d..9713610cb 100644 --- a/code/nel/src/misc/big_file.cpp +++ b/code/nel/src/misc/big_file.cpp @@ -45,8 +45,16 @@ void CBigFile::releaseInstance() // *************************************************************************** CBigFile::CThreadFileArray::CThreadFileArray() { - _CurrentId= 0; + _CurrentId = 0; } + +// *************************************************************************** +CBigFile::CThreadFileArray::~CThreadFileArray() +{ + vector *ptr = (vector*)_TDS.getPointer(); + if (ptr) delete ptr; +} + // *************************************************************************** uint32 CBigFile::CThreadFileArray::allocate() { @@ -186,11 +194,24 @@ void CBigFile::remove (const std::string &sBigFileName) fclose (handle.File); handle.File= NULL; } - delete [] rbnp.FileNames; + _BNPs.erase (it); } } +CBigFile::BNP::BNP() : FileNames(NULL), ThreadFileId(0), CacheFileOnOpen(false), AlwaysOpened(false), InternalUse(false), OffsetFromBeginning(0) +{ +} + +CBigFile::BNP::~BNP() +{ + if (FileNames) + { + delete[] FileNames; + FileNames = NULL; + } +} + //// *************************************************************************** bool CBigFile::BNP::readHeader() { @@ -318,6 +339,9 @@ bool CBigFile::BNP::readHeader(FILE *file) it++; } + if (FileNames) + delete[] FileNames; + FileNames = new char[nSize]; memset(FileNames, 0, nSize); Files.resize(nNb); @@ -629,7 +653,7 @@ bool CBigFile::getFileInternal (const std::string &sFileName, BNP *&zeBnp, BNPFi } BNP &rbnp = _BNPs.find (zeBigFileName)->second; - if (rbnp.Files.size() == 0) + if (rbnp.Files.empty()) { return false; } @@ -722,7 +746,7 @@ char *CBigFile::getFileNamePtr(const std::string &sFileName, const std::string & { BNP &rbnp = _BNPs.find (bigfilenamealone)->second; vector::iterator itNBPFile; - if (rbnp.Files.size() == 0) + if (rbnp.Files.empty()) return NULL; string lwrFileName = toLower(sFileName); diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index a996c8546..47bdf3886 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -136,7 +136,8 @@ uint8 CBitmap::load(NLMISC::IStream &f, uint mipMapSkip) } #ifdef USE_JPEG - if (fileType == JPG_HEADER) + // only compare fist word + if (memcmp(&fileType, &JPG_HEADER, 2) == 0) { #ifdef NEL_ALL_BITMAP_WHITE uint8 result = readJPG(f); @@ -4509,6 +4510,20 @@ CRGBA CBitmap::getPixelColor(sint x, sint y, uint32 numMipMap /*=0*/) const return CRGBA::Black; } +//----------------------------------------------- +void CBitmap::setPixelColor(sint x, sint y, CRGBA c, uint32 numMipMap) +{ + nlassert(PixelFormat == RGBA); + + uint w = getWidth(numMipMap); + uint h = getHeight(numMipMap); + + if (w == 0 || x < 0 || y < 0 || x >= (sint)w || y >= (sint)h) return; + + uint8 *pix = &getPixels(numMipMap)[(x + y * w) << 2]; + + memcpy(pix, &c, sizeof(CRGBA)); +} //----------------------------------------------- void CBitmap::swap(CBitmap &other) diff --git a/code/nel/src/misc/bitmap_gif.cpp b/code/nel/src/misc/bitmap_gif.cpp index 4ae9dd0cf..5b964998a 100644 --- a/code/nel/src/misc/bitmap_gif.cpp +++ b/code/nel/src/misc/bitmap_gif.cpp @@ -23,6 +23,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLMISC { @@ -61,7 +65,7 @@ static int readGIFData(GifFileType *gif, GifByteType *data, int length) } catch(...) { - nlwarning("error while reading JPEG image"); + nlwarning("error while reading GIF image"); return 0; } 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..a15eac930 100644 --- a/code/nel/src/misc/cdb_branch.cpp +++ b/code/nel/src/misc/cdb_branch.cpp @@ -56,6 +56,9 @@ using namespace std; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLMISC{ @@ -207,7 +210,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, } else { - if ( _Nodes.size() > 0 ) + if (!_Nodes.empty()) for ( _IdBits=1; _Nodes.size() > unsigned(1<<_IdBits) ; _IdBits++ ) {} else _IdBits = 0; diff --git a/code/nel/src/misc/cdb_branch_observing_handler.cpp b/code/nel/src/misc/cdb_branch_observing_handler.cpp index 8e6335533..b64862a18 100644 --- a/code/nel/src/misc/cdb_branch_observing_handler.cpp +++ b/code/nel/src/misc/cdb_branch_observing_handler.cpp @@ -17,6 +17,10 @@ #include "stdmisc.h" #include "nel/misc/cdb_branch_observing_handler.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLMISC{ CCDBBranchObservingHandler::CCDBBranchObservingHandler() { diff --git a/code/nel/src/misc/cdb_check_sum.cpp b/code/nel/src/misc/cdb_check_sum.cpp index d3619299d..7ec6614b2 100644 --- a/code/nel/src/misc/cdb_check_sum.cpp +++ b/code/nel/src/misc/cdb_check_sum.cpp @@ -17,6 +17,9 @@ #include "stdmisc.h" #include "nel/misc/cdb_check_sum.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLMISC{ diff --git a/code/nel/src/misc/cdb_leaf.cpp b/code/nel/src/misc/cdb_leaf.cpp index f74fb2d3d..c996b78f3 100644 --- a/code/nel/src/misc/cdb_leaf.cpp +++ b/code/nel/src/misc/cdb_leaf.cpp @@ -35,6 +35,10 @@ //////////////// using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLMISC{ diff --git a/code/nel/src/misc/cdb_manager.cpp b/code/nel/src/misc/cdb_manager.cpp index db743416d..1b19f4141 100644 --- a/code/nel/src/misc/cdb_manager.cpp +++ b/code/nel/src/misc/cdb_manager.cpp @@ -17,6 +17,10 @@ #include "stdmisc.h" #include "nel/misc/cdb_manager.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLMISC{ CCDBManager::CCDBManager( const char *rootNodeName, uint maxBanks ) : bankHandler( maxBanks ) diff --git a/code/nel/src/misc/check_fpu.cpp b/code/nel/src/misc/check_fpu.cpp index 0f2359eeb..0ceb3af2b 100644 --- a/code/nel/src/misc/check_fpu.cpp +++ b/code/nel/src/misc/check_fpu.cpp @@ -24,6 +24,9 @@ #pragma optimize("", off ) +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLMISC { diff --git a/code/nel/src/misc/co_task.cpp b/code/nel/src/misc/co_task.cpp index 97a9e1e23..f817e3a5f 100644 --- a/code/nel/src/misc/co_task.cpp +++ b/code/nel/src/misc/co_task.cpp @@ -213,6 +213,16 @@ namespace NLMISC return _ThreadMainFiber.getPointer(); } #endif + + static void releaseInstance() + { + if (_Instance) + { + NLMISC::INelContext::getInstance().releaseSingletonPointer("CCurrentCoTask", _Instance); + delete _Instance; + _Instance = NULL; + } + } }; NLMISC_SAFE_SINGLETON_IMPL(CCurrentCoTask); @@ -560,5 +570,10 @@ namespace NLMISC } } + void CCoTask::releaseInstance() + { + CCurrentCoTask::releaseInstance(); + } + } // namespace NLMISC diff --git a/code/nel/src/misc/command.cpp b/code/nel/src/misc/command.cpp index 30e3defe2..a3d9d79ed 100644 --- a/code/nel/src/misc/command.cpp +++ b/code/nel/src/misc/command.cpp @@ -666,7 +666,7 @@ NLMISC_CATEGORISED_COMMAND(nel,help,"display help on a specific variable/command CCommandRegistry &cr = CCommandRegistry::getInstance(); // treat the case where we have no parameters - if (args.size() == 0) + if (args.empty()) { // display a list of all command categories log.displayNL("Help commands:"); diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 5954ac9c9..31f289381 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -523,7 +523,7 @@ std::string timestampToHumanReadable(uint32 timestamp) uint32 fromHumanReadable (const std::string &str) { - if (str.size() == 0) + if (str.empty()) return 0; uint32 val; @@ -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/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 c9ac2f593..c6d10b700 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -23,7 +23,9 @@ # include # include # pragma comment(lib, "imagehlp.lib") -# define getcwd(_a, _b) (_getcwd(_a,_b)) +# ifndef getcwd +# define getcwd(_a, _b) (_getcwd(_a,_b)) +# endif # ifdef NL_OS_WIN64 # define DWORD_TYPE DWORD64 # else @@ -178,7 +180,7 @@ void nlFatalError (const char *format, ...) char *str; NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/); - INelContext::getInstance().setDebugNeedAssert( NLMISC::DefaultMsgBoxDisplayer==0 ); + INelContext::getInstance().setDebugNeedAssert( NLMISC::DefaultMsgBoxDisplayer == NULL ); NLMISC::ErrorLog->displayNL (str); @@ -197,7 +199,7 @@ void nlError (const char *format, ...) char *str; NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/); - INelContext::getInstance().setDebugNeedAssert( NLMISC::DefaultMsgBoxDisplayer==0 ); + INelContext::getInstance().setDebugNeedAssert( NLMISC::DefaultMsgBoxDisplayer == NULL ); NLMISC::ErrorLog->displayNL (str); @@ -453,7 +455,7 @@ public: string shortExc, longExc, subject; string addr, ext; ULONG_PTR skipNFirst = 0; - _Reason = ""; + _Reason.clear(); if (m_pexp == NULL) { @@ -491,25 +493,25 @@ public: case EXCEPTION_STACK_OVERFLOW : shortExc="Stack Overflow"; longExc="Stack overflow. Can occur during errant recursion, or when a function creates a particularly large array on the stack"; break; case EXCEPTION_INVALID_DISPOSITION : shortExc="Invalid Disposition"; longExc="Whatever number the exception filter returned, it wasn't a value the OS knows about"; break; case EXCEPTION_GUARD_PAGE : shortExc="Guard Page"; longExc="Memory Allocated as PAGE_GUARD by VirtualAlloc() has been accessed"; break; - case EXCEPTION_INVALID_HANDLE : shortExc="Invalid Handle"; longExc=""; break; + case EXCEPTION_INVALID_HANDLE : shortExc="Invalid Handle"; longExc.clear(); break; case CONTROL_C_EXIT : shortExc="Control-C"; longExc="Lets the debugger know the user hit Ctrl-C. Seemingly for console apps only"; break; case STATUS_NO_MEMORY : shortExc="No Memory"; longExc="Called by HeapAlloc() if you specify HEAP_GENERATE_EXCEPTIONS and there is no memory or heap corruption"; ext = ", unable to allocate "; ext += toString ("%d bytes", m_pexp->ExceptionRecord->ExceptionInformation [0]); break; - case STATUS_WAIT_0 : shortExc="Wait 0"; longExc=""; break; - case STATUS_ABANDONED_WAIT_0 : shortExc="Abandoned Wait 0"; longExc=""; break; + case STATUS_WAIT_0 : shortExc="Wait 0"; longExc.clear(); break; + case STATUS_ABANDONED_WAIT_0 : shortExc="Abandoned Wait 0"; longExc.clear(); break; case STATUS_USER_APC : shortExc="User APC"; longExc="A user APC was delivered to the current thread before the specified Timeout interval expired"; break; - case STATUS_TIMEOUT : shortExc="Timeout"; longExc=""; break; - case STATUS_PENDING : shortExc="Pending"; longExc=""; break; - case STATUS_SEGMENT_NOTIFICATION : shortExc="Segment Notification"; longExc=""; break; - case STATUS_FLOAT_MULTIPLE_FAULTS : shortExc="Float Multiple Faults"; longExc=""; break; - case STATUS_FLOAT_MULTIPLE_TRAPS : shortExc="Float Multiple Traps"; longExc=""; break; + case STATUS_TIMEOUT : shortExc="Timeout"; longExc.clear(); break; + case STATUS_PENDING : shortExc="Pending"; longExc.clear(); break; + case STATUS_SEGMENT_NOTIFICATION : shortExc="Segment Notification"; longExc.clear(); break; + case STATUS_FLOAT_MULTIPLE_FAULTS : shortExc="Float Multiple Faults"; longExc.clear(); break; + case STATUS_FLOAT_MULTIPLE_TRAPS : shortExc="Float Multiple Traps"; longExc.clear(); break; #ifdef NL_COMP_VC6 - case STATUS_ILLEGAL_VLM_REFERENCE : shortExc="Illegal VLM Reference"; longExc=""; break; + case STATUS_ILLEGAL_VLM_REFERENCE : shortExc="Illegal VLM Reference"; longExc.clear(); break; #endif case 0xE06D7363 : shortExc="Microsoft C++ Exception"; longExc="Microsoft C++ Exception"; break; // cpp exception - case 0xACE0ACE : shortExc=""; longExc=""; + case 0xACE0ACE : shortExc.clear(); longExc.clear(); if (m_pexp->ExceptionRecord->NumberParameters == 1) skipNFirst = m_pexp->ExceptionRecord->ExceptionInformation [0]; break; // just want the stack @@ -824,7 +826,7 @@ public: // replace param with the value of the stack for this param string parse = str; - str = ""; + str.clear(); uint pos2 = 0; sint stop = 0; @@ -943,7 +945,7 @@ public: str += tmp; } str += parse[i]; - type = ""; + type.clear(); } else { @@ -1442,7 +1444,7 @@ std::string formatErrorMessage(int errorCode) NULL ); - // empty buffer, an error occured + // empty buffer, an error occurred if (len == 0) return toString("FormatMessage returned error %d", getLastError()); // convert wchar_t* to std::string @@ -1502,7 +1504,7 @@ NLMISC_CATEGORISED_COMMAND(nel, displayMemlog, "displays the last N line of the { uint nbLines; - if (args.size() == 0) nbLines = 100; + if (args.empty()) nbLines = 100; else if (args.size() == 1) NLMISC::fromString(args[0], nbLines); else return false; @@ -1526,7 +1528,7 @@ NLMISC_CATEGORISED_COMMAND(nel, displayMemlog, "displays the last N line of the NLMISC_CATEGORISED_COMMAND(nel, resetFilters, "disable all filters on Nel loggers", "[debug|info|warning|error|assert]") { - if(args.size() == 0) + if(args.empty()) { DebugLog->resetFilters(); InfoLog->resetFilters(); @@ -1566,7 +1568,7 @@ NLMISC_CATEGORISED_COMMAND(nel, addNegativeFilterDebug, "add a negative filter o NLMISC_CATEGORISED_COMMAND(nel, removeFilterDebug, "remove a filter on DebugLog", "[]") { - if(args.size() == 0) + if(args.empty()) DebugLog->removeFilter(); else if(args.size() == 1) DebugLog->removeFilter( args[0].c_str() ); @@ -1576,7 +1578,7 @@ NLMISC_CATEGORISED_COMMAND(nel, removeFilterDebug, "remove a filter on DebugLog" NLMISC_CATEGORISED_COMMAND(nel, displayFilterDebug, "display filter on DebugLog", "") { - if(args.size() != 0) return false; + if(!args.empty()) return false; DebugLog->displayFilter(log); return true; } @@ -1597,7 +1599,7 @@ NLMISC_CATEGORISED_COMMAND(nel, addNegativeFilterInfo, "add a negative filter on NLMISC_CATEGORISED_COMMAND(nel, removeFilterInfo, "remove a filter on InfoLog", "[]") { - if(args.size() == 0) + if(args.empty()) InfoLog->removeFilter(); else if(args.size() == 1) InfoLog->removeFilter( args[0].c_str() ); @@ -1644,7 +1646,7 @@ NLMISC_CATEGORISED_COMMAND(nel, addNegativeFilterWarning, "add a negative filter NLMISC_CATEGORISED_COMMAND(nel, removeFilterWarning, "remove a filter on WarningLog", "[]") { - if(args.size() == 0) + if(args.empty()) WarningLog->removeFilter(); else if(args.size() == 1) WarningLog->removeFilter( args[0].c_str() ); @@ -1654,7 +1656,7 @@ NLMISC_CATEGORISED_COMMAND(nel, removeFilterWarning, "remove a filter on Warning NLMISC_CATEGORISED_COMMAND(nel, displayFilterWarning, "display filter on WarningLog", "") { - if(args.size() != 0) return false; + if(!args.empty()) return false; WarningLog->displayFilter(log); return true; } diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 798a4f80a..8feaa9358 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -495,15 +495,30 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes if (_NeedHeader) { const char *hs = HeaderString(); - fwrite (hs, strlen (hs), 1, _FilePointer); + + if (fwrite(hs, strlen(hs), 1, _FilePointer) != 1) + { + printf("Unable to write header: %s\n", hs); + } + _NeedHeader = false; } - if(!str.empty()) - fwrite (str.c_str(), str.size(), 1, _FilePointer); + if (!str.empty()) + { + if (fwrite(str.c_str(), str.size(), 1, _FilePointer) != 1) + { + printf("Unable to write string: %s\n", str.c_str()); + } + } - if(!args.CallstackAndLog.empty()) - fwrite (args.CallstackAndLog.c_str(), args.CallstackAndLog.size (), 1, _FilePointer); + if (!args.CallstackAndLog.empty()) + { + if (fwrite(args.CallstackAndLog.c_str(), args.CallstackAndLog.size(), 1, _FilePointer) != 1) + { + printf("Unable to write call stack: %s\n", args.CallstackAndLog.c_str()); + } + } fflush (_FilePointer); } diff --git a/code/nel/src/misc/dynloadlib.cpp b/code/nel/src/misc/dynloadlib.cpp index fadf2e249..66f774fa2 100644 --- a/code/nel/src/misc/dynloadlib.cpp +++ b/code/nel/src/misc/dynloadlib.cpp @@ -255,7 +255,7 @@ void CLibrary::freeLibrary() _PureNelLibrary = NULL; _LibHandle = NULL; _Ownership = false; - _LibFileName = ""; + _LibFileName.clear(); } } diff --git a/code/nel/src/misc/eid_translator.cpp b/code/nel/src/misc/eid_translator.cpp index 591b9db7a..0d126de50 100644 --- a/code/nel/src/misc/eid_translator.cpp +++ b/code/nel/src/misc/eid_translator.cpp @@ -587,10 +587,10 @@ void CEntityIdTranslator::getEntityIdInfo (const CEntityId &eid, ucstring &entit if (it == RegisteredEntities.end ()) { nlwarning ("EIT: %s is not registered in CEntityIdTranslator", reid.toString().c_str()); - entityName = ""; + entityName.clear(); entitySlot = -1; uid = std::numeric_limits::max(); - userName = ""; + userName.clear(); online = false; } else diff --git a/code/nel/src/misc/eval_num_expr.cpp b/code/nel/src/misc/eval_num_expr.cpp index 1bfad17eb..42298c1fa 100644 --- a/code/nel/src/misc/eval_num_expr.cpp +++ b/code/nel/src/misc/eval_num_expr.cpp @@ -632,6 +632,9 @@ CEvalNumExpr::TReturnState CEvalNumExpr::evalExpression (double &finalResult, TT TOperator resultUnaryOp[InternalOperator]; vector resultUnaryOpSup; + // init table + for (uint i = 0; i < (uint)InternalOperator; ++i) resultUnaryOp[i] = NotOperator; + // Current value double value; diff --git a/code/nel/src/misc/event_emitter.cpp b/code/nel/src/misc/event_emitter.cpp deleted file mode 100644 index 0cf3aad72..000000000 --- a/code/nel/src/misc/event_emitter.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -// remove stupid VC6 warnings -void foo_event_emitter_cpp() {} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - -} // NLMISC diff --git a/code/nel/src/misc/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 70fb98d9f..55eba958a 100644 --- a/code/nel/src/misc/hierarchical_timer.cpp +++ b/code/nel/src/misc/hierarchical_timer.cpp @@ -521,7 +521,7 @@ void CHTimer::displayByExecutionPath(CLog *log, TSortCriterion criterion, bool std::copy(currTimer->_Name, currTimer->_Name + (endIndex - startIndex), resultName.begin() + startIndex); } TNodeVect &execNodes = nodeMap[currTimer]; - if (execNodes.size() > 0) + if (!execNodes.empty()) { currNodeStats.buildFromNodes(&execNodes[0], (uint)execNodes.size(), _MsPerTick); currNodeStats.getStats(resultStats, displayEx, rootStats.TotalTime, _WantStandardDeviation); 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 b9a49b04b..45ed137b0 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1854,6 +1854,84 @@ std::string CFileContainer::getTemporaryDirectory() return path; } +std::string CPath::getApplicationDirectory(const std::string &appName, bool local) +{ + return getInstance()->_FileContainer.getApplicationDirectory(appName, local); +} + +std::string CFileContainer::getApplicationDirectory(const std::string &appName, bool local) +{ + static std::string appPaths[2]; + + std::string &appPath = appPaths[local ? 1 : 0]; + + if (appPath.empty()) + { +#ifdef NL_OS_WINDOWS + wchar_t buffer[MAX_PATH]; +#ifdef CSIDL_LOCAL_APPDATA + if (local) + { + SHGetSpecialFolderPathW(NULL, buffer, CSIDL_LOCAL_APPDATA, TRUE); + } + else +#endif + { + SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE); + } + appPath = CPath::standardizePath(wideToUtf8(buffer)); +#else + // get user home directory from HOME environment variable + const char* homePath = getenv("HOME"); + appPath = CPath::standardizePath(homePath ? homePath : "."); + +#if defined(NL_OS_MAC) + appPath += "Library/Application Support/"; +#else + // recommended for applications data that are owned by user + appPath += ".local/share/"; +#endif +#endif + } + + return CPath::standardizePath(appPath + appName); +} + +std::string CPath::getTemporaryDirectory() +{ + return getInstance()->_FileContainer.getTemporaryDirectory(); +} + +std::string CFileContainer::getTemporaryDirectory() +{ + static std::string path; + if (path.empty()) + { + const char *temp = getenv("TEMP"); + const char *tmp = getenv("TMP"); + + std::string tempDir; + + if (temp) + tempDir = temp; + + if (tempDir.empty() && tmp) + tempDir = tmp; + +#ifdef NL_OS_UNIX + if (tempDir.empty()) + tempDir = "/tmp"; +#else + if (tempDir.empty()) + tempDir = "."; +#endif + + path = CPath::standardizePath(tempDir); + } + + return path; +} + ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2523,7 +2601,7 @@ bool CFile::createDirectoryTree(const std::string &filename) return lastResult; } -bool CPath::makePathRelative (const char *basePath, std::string &relativePath) +bool CPath::makePathRelative (const std::string &basePath, std::string &relativePath) { // Standard path with final slash string tmp = standardizePath (basePath, true); diff --git a/code/nel/src/misc/polygon.cpp b/code/nel/src/misc/polygon.cpp index 9388dbd45..16575073f 100644 --- a/code/nel/src/misc/polygon.cpp +++ b/code/nel/src/misc/polygon.cpp @@ -1999,7 +1999,7 @@ float CPolygon2D::sumDPAgainstLine(float a, float b, float c) const // ******************************************************************************* bool CPolygon2D::getNonNullSeg(uint &index) const { - nlassert(Vertices.size() > 0); + nlassert(!Vertices.empty()); float bestLength = 0.f; sint bestIndex = -1; for (uint k = 0; k < Vertices.size() - 1; ++k) @@ -2046,7 +2046,7 @@ void CPolygon2D::getLineEquation(uint index, float &a, float &b, float &c) cons // ******************************************************************************* bool CPolygon2D::intersect(const CPolygon2D &other) const { - nlassert(other.Vertices.size() > 0); + nlassert(!other.Vertices.empty()); uint nonNullSegIndex; /// get the orientation of this poly if (getNonNullSeg(nonNullSegIndex)) diff --git a/code/nel/src/misc/quad.cpp b/code/nel/src/misc/quad.cpp deleted file mode 100644 index 8fced3318..000000000 --- a/code/nel/src/misc/quad.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/quad.h" - - -// leave not static else this workaround don't work -void dummyToAvoidStupidCompilerWarning_misc_quad_cpp() -{ -} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - - -} // NLMISC diff --git a/code/nel/src/misc/rgba.cpp b/code/nel/src/misc/rgba.cpp index 822ee1006..d053887c4 100644 --- a/code/nel/src/misc/rgba.cpp +++ b/code/nel/src/misc/rgba.cpp @@ -748,6 +748,17 @@ CRGBA CRGBA::stringToRGBA( const char *ptr ) return CRGBA( r,g,b,a ); } + + // we need at least 3 hexadecimal values to consider string is valid + if (sscanf(ptr, "#%02x%02x%02x%02x", &r, &g, &b, &a) >= 3) + { + clamp(r, 0, 255); + clamp(g, 0, 255); + clamp(b, 0, 255); + clamp(a, 0, 255); + + return CRGBA(r, g, b, a); + } } return NLMISC::CRGBA::White; diff --git a/code/nel/src/misc/smart_ptr.cpp b/code/nel/src/misc/smart_ptr.cpp index e5c31fcd7..73c3c0799 100644 --- a/code/nel/src/misc/smart_ptr.cpp +++ b/code/nel/src/misc/smart_ptr.cpp @@ -29,12 +29,5 @@ namespace NLMISC //CPtrInfo() {Ptr=NULL; RefCount=0x7FFFFFFF; IsNullPtrInfo=true;} CRefCount::CPtrInfoBase CRefCount::NullPtrInfo= {NULL, 0x7FFFFFFF, true}; - -// must not be static -void dummy_to_avoid_stupid_4768_smart_ptr_cpp() -{ -} - - } diff --git a/code/nel/src/misc/stdmisc.h b/code/nel/src/misc/stdmisc.h index 3ed96f900..d7a623465 100644 --- a/code/nel/src/misc/stdmisc.h +++ b/code/nel/src/misc/stdmisc.h @@ -17,6 +17,13 @@ #ifndef NL_STDMISC_H #define NL_STDMISC_H +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif + #include #include #include diff --git a/code/nel/src/misc/stl_block_allocator.cpp b/code/nel/src/misc/stl_block_allocator.cpp deleted file mode 100644 index f57d0c238..000000000 --- a/code/nel/src/misc/stl_block_allocator.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/stl_block_allocator.h" - -// remove stupid VC6 warnings -void foo_stl_block_allocator_cpp() {} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - - -} // NLMISC diff --git a/code/nel/src/misc/stl_block_list.cpp b/code/nel/src/misc/stl_block_list.cpp deleted file mode 100644 index 628b79371..000000000 --- a/code/nel/src/misc/stl_block_list.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/stl_block_list.h" - -// remove stupid VC6 warnings -void foo_stl_block_list_cpp() {} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - -} // NLMISC diff --git a/code/nel/src/misc/stop_watch.cpp b/code/nel/src/misc/stop_watch.cpp index 59b62150e..42783c383 100644 --- a/code/nel/src/misc/stop_watch.cpp +++ b/code/nel/src/misc/stop_watch.cpp @@ -24,6 +24,10 @@ using namespace std; #define new DEBUG_NEW #endif +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { @@ -136,7 +140,7 @@ TMsDuration CStopWatch::getDuration() const */ TMsDuration CStopWatch::getPartialAverage() const { - if (_Queue.size() == 0) + if (_Queue.empty()) return (TMsDuration)0; else return (TMsDuration)(CTime::ticksToSecond( accumulate( _Queue.begin(), _Queue.end(), 0 ) / _Queue.size() ) * 1000.0); diff --git a/code/nel/src/misc/string_common.cpp b/code/nel/src/misc/string_common.cpp index dd8d1fe96..9c9085e4e 100644 --- a/code/nel/src/misc/string_common.cpp +++ b/code/nel/src/misc/string_common.cpp @@ -27,7 +27,7 @@ using namespace std; namespace NLMISC { -string addSlashR (string str) +string addSlashR (const string &str) { string formatedStr; // replace \n with \r\n @@ -42,10 +42,10 @@ string addSlashR (string str) return formatedStr; } -string removeSlashR (string str) +string removeSlashR (const string &str) { string formatedStr; - // replace \n with \r\n + // remove \r for (uint i = 0; i < str.size(); i++) { if (str[i] != '\r') diff --git a/code/nel/src/misc/string_id_array.cpp b/code/nel/src/misc/string_id_array.cpp deleted file mode 100644 index b9489e3f9..000000000 --- a/code/nel/src/misc/string_id_array.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdmisc.h" - -#include "nel/misc/string_id_array.h" - - -// leave not static else this workaround don't work -void dummyToAvoidStupidCompilerWarning_misc_string_id_array_cpp() -{ -} - -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - -namespace NLMISC { - - -} // NLMISC diff --git a/code/nel/src/misc/string_mapper.cpp b/code/nel/src/misc/string_mapper.cpp index cf8a38e49..6e59f7bab 100644 --- a/code/nel/src/misc/string_mapper.cpp +++ b/code/nel/src/misc/string_mapper.cpp @@ -33,8 +33,7 @@ CStringMapper CStringMapper::_GlobalMapper; // **************************************************************************** CStringMapper::CStringMapper() { - _EmptyId = new string; - *_EmptyId = ""; + _EmptyId = new string(); } // **************************************************************************** @@ -46,7 +45,7 @@ CStringMapper *CStringMapper::createLocalMapper() // **************************************************************************** TStringId CStringMapper::localMap(const std::string &str) { - if (str.size() == 0) + if (str.empty()) return 0; CAutoFastMutex automutex(&_Mutex); diff --git a/code/nel/src/misc/system_info.cpp b/code/nel/src/misc/system_info.cpp index b78389064..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/win_displayer.cpp b/code/nel/src/misc/win_displayer.cpp index 37db08fbf..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') 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..bf945eb2e 100644 --- a/code/nel/src/misc/words_dictionary.cpp +++ b/code/nel/src/misc/words_dictionary.cpp @@ -23,6 +23,10 @@ using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + const string DefaultColTitle = "name"; #ifdef DEBUG_NEW 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/admin.cpp b/code/nel/src/net/admin.cpp index 89981a697..4389e0f34 100644 --- a/code/nel/src/net/admin.cpp +++ b/code/nel/src/net/admin.cpp @@ -381,7 +381,7 @@ void serviceGetView (uint32 rid, const string &rawvarpath, TAdminViewResult &ans if (CCommandRegistry::getInstance().isNamedCommandHandler(varpath.Destination[0].first)) { varpath.Destination[0].first += "."+varpath.Destination[0].second; - varpath.Destination[0].second = ""; + varpath.Destination[0].second.clear(); } if (varpath.isFinal()) @@ -782,13 +782,13 @@ void setInformation (const vector &alarms, const vector &graphup for (i = 0; i < alarms.size(); i+=3) { CVarPath shardvarpath (alarms[i]); - if(shardvarpath.Destination.size() == 0 || shardvarpath.Destination[0].second.empty()) + if(shardvarpath.Destination.empty() || shardvarpath.Destination[0].second.empty()) continue; CVarPath servervarpath (shardvarpath.Destination[0].second); - if(servervarpath.Destination.size() == 0 || servervarpath.Destination[0].second.empty()) + if(servervarpath.Destination.empty() || servervarpath.Destination[0].second.empty()) continue; CVarPath servicevarpath (servervarpath.Destination[0].second); - if(servicevarpath.Destination.size() == 0 || servicevarpath.Destination[0].second.empty()) + if(servicevarpath.Destination.empty() || servicevarpath.Destination[0].second.empty()) continue; string name = servicevarpath.Destination[0].second; @@ -817,13 +817,13 @@ void setInformation (const vector &alarms, const vector &graphup for (i = 0; i < graphupdate.size(); i+=2) { CVarPath shardvarpath (graphupdate[i]); - if(shardvarpath.Destination.size() == 0 || shardvarpath.Destination[0].second.empty()) + if(shardvarpath.Destination.empty() || shardvarpath.Destination[0].second.empty()) continue; CVarPath servervarpath (shardvarpath.Destination[0].second); - if(servervarpath.Destination.size() == 0 || servervarpath.Destination[0].second.empty()) + if(servervarpath.Destination.empty() || servervarpath.Destination[0].second.empty()) continue; CVarPath servicevarpath (servervarpath.Destination[0].second); - if(servicevarpath.Destination.size() == 0 || servicevarpath.Destination[0].second.empty()) + if(servicevarpath.Destination.empty() || servicevarpath.Destination[0].second.empty()) continue; string VarName = servicevarpath.Destination[0].second; diff --git a/code/nel/src/net/buf_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.cpp b/code/nel/src/net/module.cpp index b0e21308f..73a1c7867 100644 --- a/code/nel/src/net/module.cpp +++ b/code/nel/src/net/module.cpp @@ -879,7 +879,7 @@ namespace NLNET throw EModuleNotReachable(); } - _Gateway->sendModuleMessage(senderProx, this, message); + _Gateway->sendModuleProxyMessage(senderProx, this, message); } const TSecurityData *CModuleProxy::findSecurityData(uint8 dataTag) const diff --git a/code/nel/src/net/module_common.cpp b/code/nel/src/net/module_common.cpp index 0133343dd..aacf80a93 100644 --- a/code/nel/src/net/module_common.cpp +++ b/code/nel/src/net/module_common.cpp @@ -195,7 +195,7 @@ namespace NLNET vector parts; NLMISC::explode(name, string("."), parts); - if (name.size() > 0) + if (!name.empty()) { // at least one part in the name // check if sub ojbcct exist @@ -208,12 +208,12 @@ namespace NLNET sub = SubParams.back(); } - if (name.size() > 0) + if (!name.empty()) { // name is more deep, need to resurse parts.erase(parts.begin()); - CSString subName; - subName.join(reinterpret_cast(parts), "."); + std::string subName; + join(parts, ".", subName); sub->setParam(subName, value); } else diff --git a/code/nel/src/net/module_gateway.cpp b/code/nel/src/net/module_gateway.cpp index 074dd78cd..81ba76859 100644 --- a/code/nel/src/net/module_gateway.cpp +++ b/code/nel/src/net/module_gateway.cpp @@ -627,7 +627,7 @@ namespace NLNET if (from->NextMessageType != CModuleMessageHeaderCodec::mt_invalid) { // this message must be dispatched to a module - onReceiveModuleMessage(from, msgin); + onReceiveModuleMessageFromGateway(from, msgin); } // Not a module message, dispatch the gateway message else if (msgin.getName() == "MOD_OP") @@ -813,7 +813,7 @@ namespace NLNET /***********************************/ /** A gateway receive module operation */ - void onReceiveModuleMessage(CGatewayRoute *from, const CMessage &msgin) + void onReceiveModuleMessageFromGateway(CGatewayRoute *from, const CMessage &msgin) { H_AUTO(CModuleGetaway_onReceiveModuleMessage); // clean the message type now, any return path will be safe @@ -843,7 +843,7 @@ namespace NLNET addresseeProxy = it->second; // give the message to the gateway (either for local dispatch or for forwarding) - sendModuleMessage(senderProxy, addresseeProxy, msgin); + sendModuleProxyMessage(senderProxy, addresseeProxy, msgin); } // A gateway receive a module message header @@ -1293,7 +1293,7 @@ namespace NLNET } - virtual void sendModuleMessage(IModuleProxy *senderProxy, IModuleProxy *addresseeProxy, const NLNET::CMessage &message) + virtual void sendModuleProxyMessage(IModuleProxy *senderProxy, IModuleProxy *addresseeProxy, const NLNET::CMessage &message) { H_AUTO(CModuleGetaway_sendModuleMessage); // manage firewall @@ -1581,7 +1581,7 @@ namespace NLNET IModuleProxy *destProx = it2->second; - sendModuleMessage(senderProx, destProx, message); + sendModuleProxyMessage(senderProx, destProx, message); } virtual void _broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) diff --git a/code/nel/src/net/module_gateway_transport.cpp b/code/nel/src/net/module_gateway_transport.cpp index cda4e8e81..d9029285f 100644 --- a/code/nel/src/net/module_gateway_transport.cpp +++ b/code/nel/src/net/module_gateway_transport.cpp @@ -27,6 +27,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLNET @@ -69,7 +72,7 @@ namespace NLNET friend class CL3ServerRoute; public: /// The callback server that receive connection and dispatch message - auto_ptr _CallbackServer; + CUniquePtr _CallbackServer; /// A static mapper to retrieve transport from the CCallbackServer pointer typedef map TDispatcherIndex; @@ -221,7 +224,7 @@ namespace NLNET throw ETransportError("openServer : The server is already open"); // create a new callback server - auto_ptr cbs = auto_ptr (new CCallbackServer()); + CUniquePtr cbs(new CCallbackServer()); // register the callbacks cbs->setConnectionCallback(cbConnection, static_cast(this)); @@ -231,7 +234,7 @@ namespace NLNET // open the server cbs->init(port); - _CallbackServer = cbs; + _CallbackServer = CUniquePtrMove(cbs); // register it in the dispatcher _DispatcherIndex.insert(make_pair(_CallbackServer.get(), this)); @@ -670,7 +673,7 @@ namespace NLNET _FreeRoutesIds.pop_back(); } - auto_ptr route = auto_ptr(new CL3ClientRoute(this, addr, connId)); + CUniquePtr route(new CL3ClientRoute(this, addr, connId)); // set the callbacks route->CallbackClient.setDisconnectionCallback(cbDisconnection, static_cast(this)); diff --git a/code/nel/src/net/module_local_gateway.cpp b/code/nel/src/net/module_local_gateway.cpp index 3c66c5dcc..3446c0663 100644 --- a/code/nel/src/net/module_local_gateway.cpp +++ b/code/nel/src/net/module_local_gateway.cpp @@ -287,7 +287,7 @@ namespace NLNET // virtual void onReceiveModuleMessage(TModuleGatewayProxyPtr &senderGateway, TModuleMessagePtr &message) // { // } - virtual void sendModuleMessage(IModuleProxy * /* senderProxy */, IModuleProxy * /* addresseeProxy */, const CMessage &/* message */) + virtual void sendModuleProxyMessage(IModuleProxy * /* senderProxy */, IModuleProxy * /* addresseeProxy */, const CMessage &/* message */) { } virtual void dispatchModuleMessage(IModuleProxy * /* senderProxy */, IModuleProxy * /* addresseeProxy */, const CMessage &/* message */) diff --git a/code/nel/src/net/module_manager.cpp b/code/nel/src/net/module_manager.cpp index 0b17738b1..20c947d03 100644 --- a/code/nel/src/net/module_manager.cpp +++ b/code/nel/src/net/module_manager.cpp @@ -250,7 +250,7 @@ namespace NLNET // now, load the library string fullName = NLMISC::CPath::standardizePath(path)+CLibrary::makeLibName(shortName); - std::auto_ptr mli = auto_ptr(new TModuleLibraryInfo); + CUniquePtr mli(new TModuleLibraryInfo); if (!mli->LibraryHandler.loadLibrary(fullName, false, true, true)) { nlwarning("CModuleManager : failed to load the library '%s' in '%s'", @@ -399,7 +399,7 @@ namespace NLNET IModuleFactory *mf = it->second; // sanity check nlassert(mf->getModuleClassName() == className); - std::auto_ptr module = auto_ptr(mf->createModule()); + CUniquePtr module(mf->createModule()); if (module.get() == NULL) { nlwarning("createModule : factory failed to create a module instance for class '%s'", className.c_str()); @@ -623,7 +623,7 @@ namespace NLNET const std::string &moduleManifest, TModuleId foreignModuleId) { - std::auto_ptr modProx = auto_ptr(new CModuleProxy(localModule, ++_LastGeneratedId, moduleClassName, moduleFullyQualifiedName, moduleManifest)); + CUniquePtr modProx(new CModuleProxy(localModule, ++_LastGeneratedId, moduleClassName, moduleFullyQualifiedName, moduleManifest)); modProx->_Gateway = gateway; modProx->_Route = route; modProx->_Distance = distance; diff --git a/code/nel/src/net/naming_client.cpp b/code/nel/src/net/naming_client.cpp index a54fddaa0..7e2fd5ec9 100644 --- a/code/nel/src/net/naming_client.cpp +++ b/code/nel/src/net/naming_client.cpp @@ -128,7 +128,7 @@ void cbRegisterBroadcast (CMessage &msgin, TSockId /* from */, CCallbackNetBase std::vector addrs; CNamingClient::find (sid, addrs); - if (addrs.size() == 0) + if (addrs.empty()) { CNamingClient::RegisteredServicesMutex.enter (); CNamingClient::RegisteredServices.push_back (CNamingClient::CServiceEntry (name, sid, addr)); diff --git a/code/nel/src/net/service.cpp b/code/nel/src/net/service.cpp index 989f94d81..24064db55 100644 --- a/code/nel/src/net/service.cpp +++ b/code/nel/src/net/service.cpp @@ -1453,7 +1453,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName, } if (dispName.empty()) - str = ""; + str.clear(); else str = dispName + ": "; diff --git a/code/nel/src/net/sock.cpp b/code/nel/src/net/sock.cpp index 0e2329733..4b736e541 100644 --- a/code/nel/src/net/sock.cpp +++ b/code/nel/src/net/sock.cpp @@ -63,6 +63,10 @@ typedef int SOCKET; using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLNET { @@ -149,7 +153,7 @@ void CSock::releaseNetwork() } -/* Returns the code of the last error that has occured. +/* Returns the code of the last error that has occurred. * Note: This code is platform-dependant. On Unix, it is errno; on Windows it is the Winsock error code. * See also errorString() */ @@ -497,9 +501,9 @@ CSock::TSockResult CSock::receive( uint8 *buffer, uint32& len, bool throw_except if ( _NonBlocking ) { // Receive incoming message (only the received part) - TTicks before = CTime::getPerformanceTime(); - len = ::recv( _Sock, (char*)buffer, len, 0 ); + + sint retLen = ::recv( _Sock, (char*)buffer, len, 0 ); //nlinfo ("CSock::receive(): NBM Received %d bytes to %d res: %d (%d)", realLen, _Sock, len, ERROR_NUM); @@ -509,7 +513,8 @@ CSock::TSockResult CSock::receive( uint8 *buffer, uint32& len, bool throw_except } _MaxReceiveTime = max( (uint32)(CTime::ticksToSecond(CTime::getPerformanceTime()-before)*1000.0f), _MaxReceiveTime ); - switch ( len ) + + switch (retLen) { // Graceful disconnection case 0 : @@ -546,12 +551,14 @@ CSock::TSockResult CSock::receive( uint8 *buffer, uint32& len, bool throw_except } } } + + len = (uint32)retLen; } else // Blocking Mode { // Receive incoming message, waiting until a complete message has arrived uint total = 0; - uint brecvd; + sint brecvd; while ( total < len ) { diff --git a/code/nel/src/net/udp_sim_sock.cpp b/code/nel/src/net/udp_sim_sock.cpp index c9fb73e97..fabb037d3 100644 --- a/code/nel/src/net/udp_sim_sock.cpp +++ b/code/nel/src/net/udp_sim_sock.cpp @@ -116,7 +116,7 @@ void CUdpSimSock::sendUDP (const uint8 *buffer, uint32& len, const CInetAddress CBufferizedOutPacket *bp = new CBufferizedOutPacket (&UdpSock, buffer, len, lag, addr); // duplicate the packet - if ((float)rand()/(float)(RAND_MAX)*100.0f < _OutPacketDisordering && _BufferizedOutPackets.size() > 0) + if ((float)rand()/(float)(RAND_MAX)*100.0f < _OutPacketDisordering && !_BufferizedOutPackets.empty()) { CBufferizedOutPacket *bp2 = _BufferizedOutPackets.back(); diff --git a/code/nel/src/net/unified_network.cpp b/code/nel/src/net/unified_network.cpp index ee882f547..3a57b4b0d 100644 --- a/code/nel/src/net/unified_network.cpp +++ b/code/nel/src/net/unified_network.cpp @@ -828,17 +828,18 @@ void CUnifiedNetwork::addService(const string &name, const vector for (uint i = 0; i < addr.size(); i++) { // first we have to look if we have a network that can established the connection - + uint j = 0; + // it's loopback ip address, it's ok if (!addr[i].isLoopbackIPAddress()) { - // it's loopback ip address, it's ok for (j = 0; j < laddr.size (); j++) { if (laddr[j].internalNetAddress () == addr[i].internalNetAddress ()) { - break; // it's ok, we can try + // it's ok, we can try + break; } } @@ -1272,7 +1273,8 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid) uint8 connectionId = _IdCnx[sid.get()].DefaultNetwork; if (nid == 0xFF) - { // default network + { + // default network //nldebug ("HNETL5: nid %hu, will use the default connection %hu", (uint16)nid, (uint16)connectionId); } else if (nid >= _IdCnx[sid.get()].NetworkConnectionAssociations.size()) @@ -1293,7 +1295,6 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid) if (connectionId >= _IdCnx[sid.get()].Connections.size() || !_IdCnx[sid.get()].Connections[connectionId].valid() || !_IdCnx[sid.get()].Connections[connectionId].CbNetBase->connected()) { - if (nid != 0xFF) { // not a default network. There's a problem with the selected connectionID, so try to find a valid one diff --git a/code/nel/src/net/varpath.cpp b/code/nel/src/net/varpath.cpp index 729f52074..857af5c64 100644 --- a/code/nel/src/net/varpath.cpp +++ b/code/nel/src/net/varpath.cpp @@ -167,7 +167,7 @@ void CVarPath::decode () if (val == "=") { srv += val + RawVarPath.substr (TokenPos); - var = ""; + var.clear(); } else var = RawVarPath.substr (TokenPos); @@ -181,8 +181,8 @@ void CVarPath::decode () bool CVarPath::isFinal () { - if(Destination.size() == 0) return true; - if(Destination[0].second.size() == 0) return true; + if(Destination.empty()) return true; + if(Destination[0].second.empty()) return true; return false; } diff --git a/code/nel/src/pacs/build_indoor.cpp b/code/nel/src/pacs/build_indoor.cpp index b4bad19a6..ca14eb7cf 100644 --- a/code/nel/src/pacs/build_indoor.cpp +++ b/code/nel/src/pacs/build_indoor.cpp @@ -631,7 +631,7 @@ bool computeRetriever(CCollisionMeshBuild &cmb, CLocalRetriever &lr, CVector &tr { nlwarning("Edge issues reported !!"); uint i; - error = ""; + error.clear(); for (i=0; i 0) + if (edges[i].Link != -1 && !cd.empty()) { nlwarning ("In NLPACS::CEdgeQuad::build()"); nlwarning ("ERROR: exterior edge %d with interior link crosses some surfaces", i); diff --git a/code/nel/src/pacs/global_retriever.cpp b/code/nel/src/pacs/global_retriever.cpp index 6dfc3a712..73691e19d 100644 --- a/code/nel/src/pacs/global_retriever.cpp +++ b/code/nel/src/pacs/global_retriever.cpp @@ -313,7 +313,7 @@ void NLPACS::CGlobalRetriever::getBorders(const CAABBox &sbox, std::vector 0) + if (!retriever.getFullOrderedChains().empty()) { const COrderedChain3f &ochain = retriever.getFullOrderedChain(entry.OChainId); diff --git a/code/nel/src/pacs/move_container.cpp b/code/nel/src/pacs/move_container.cpp index 93e05794a..c302b53ab 100644 --- a/code/nel/src/pacs/move_container.cpp +++ b/code/nel/src/pacs/move_container.cpp @@ -43,7 +43,7 @@ Doc: // Collisionnable primitives Each primitive must be moved first with the move() method. Their moves are evaluate all at once. All the collisions found are time sorted in a time orderin table (_TimeOT). - While the table is not empty, the first collision occured in time is solved and + While the table is not empty, the first collision occurred in time is solved and If a collision is found, reaction() is called. @@ -1304,8 +1304,8 @@ void CMoveContainer::freeAllOTInfo () { H_AUTO (NLPACS_Free_All_OT_Info); - _AllocOTDynamicInfo.free (); - _AllocOTStaticInfo.free (); + _AllocOTDynamicInfo.freeBlock (); + _AllocOTStaticInfo.freeBlock (); } // *************************************************************************** diff --git a/code/nel/src/pacs/move_primitive.cpp b/code/nel/src/pacs/move_primitive.cpp index 08da7ac38..039fa0c7b 100644 --- a/code/nel/src/pacs/move_primitive.cpp +++ b/code/nel/src/pacs/move_primitive.cpp @@ -379,7 +379,7 @@ uint8 CMovePrimitive::getFirstWorldImageV () const uint8 CMovePrimitive::getNumWorldImageV () const { - return getNumWorldImageV (); + return getNumWorldImage (); } // *************************************************************************** diff --git a/code/nel/src/pacs/primitive_block_pacs.cpp b/code/nel/src/pacs/primitive_block_pacs.cpp index 1ee0615ea..c2f40c40c 100644 --- a/code/nel/src/pacs/primitive_block_pacs.cpp +++ b/code/nel/src/pacs/primitive_block_pacs.cpp @@ -103,7 +103,7 @@ UPrimitiveBlock *UPrimitiveBlock::createPrimitiveBlock(NLMISC::IStream &src) { nlassert(src.isReading()); - std::auto_ptr pb(new CPrimitiveBlock); + CUniquePtr pb(new CPrimitiveBlock); pb->serial(src); return pb.release(); } diff --git a/code/nel/src/pacs/primitive_world_image.cpp b/code/nel/src/pacs/primitive_world_image.cpp index e8d0378e6..22cf2cee2 100644 --- a/code/nel/src/pacs/primitive_world_image.cpp +++ b/code/nel/src/pacs/primitive_world_image.cpp @@ -1395,7 +1395,7 @@ void CPrimitiveWorldImage::reaction (const CCollisionSurfaceDesc& surfaceDesc, c void CPrimitiveWorldImage::setGlobalPosition (const UGlobalPosition& pos, CMoveContainer& container, CMovePrimitive &primitive, uint8 worldImage) { // Cast type - nlassert (dynamic_cast(&container)); + nlassert (dynamic_cast(&container) != NULL); const CMoveContainer *cont=(const CMoveContainer*)&container; if (!cont->getGlobalRetriever()) return; @@ -1421,7 +1421,7 @@ void CPrimitiveWorldImage::setGlobalPosition (const UGlobalPosition& pos, CMoveC void CPrimitiveWorldImage::setGlobalPosition (const NLMISC::CVectorD& pos, CMoveContainer& container, CMovePrimitive &primitive, uint8 worldImage, bool keepZ /*= false*/, UGlobalPosition::TType type /* =UGlobalPosition::Unspecified*/) { // Cast type - nlassert (dynamic_cast(&container)); + nlassert (dynamic_cast(&container) != NULL); const CMoveContainer *cont=(const CMoveContainer*)&container; // Get the retriever diff --git a/code/nel/src/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/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 4d86df788..5a21650e0 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()); @@ -2559,7 +2559,7 @@ void CAudioMixerUser::changeMaxTrack(uint maxTrack) else { vector non_erasable; - while (_Tracks.size() + non_erasable.size() > maxTrack && _Tracks.size() > 0) + while (_Tracks.size() + non_erasable.size() > maxTrack && !_Tracks.empty()) { CTrack *track = _Tracks.back(); _Tracks.pop_back(); @@ -2588,7 +2588,7 @@ void CAudioMixerUser::changeMaxTrack(uint maxTrack) non_erasable.push_back(track); } } - while (non_erasable.size() > 0) + while (!non_erasable.empty()) { // put non erasable back into track list _Tracks.push_back(non_erasable.back()); 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/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/sample_bank_manager.cpp b/code/nel/src/sound/sample_bank_manager.cpp index 9a7b397e5..996c59f1e 100644 --- a/code/nel/src/sound/sample_bank_manager.cpp +++ b/code/nel/src/sound/sample_bank_manager.cpp @@ -81,7 +81,7 @@ void CSampleBankManager::init(NLGEORGES::UFormElm *mixerConfig) { TFilteredBank fb; std::string bankName; - NLGEORGES::UFormElm *realBank; + NLGEORGES::UFormElm *realBank = NULL; realBank->getArrayNode(&realBank, j); realBank->getValueByName(bankName, ".SampleBank"); diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index a1c9fd595..6c204be10 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -92,7 +92,7 @@ CSound *CSound::createSound(const std::string &filename, NLGEORGES::UFormElm& fo } else { - nlassertex(false, ("SoundType unsuported : %s", dfnName.c_str())); + nlassertex(false, ("SoundType unsupported: %s", dfnName.c_str())); } } diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index 59330f3f8..ee00e1742 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -277,7 +277,7 @@ void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) maxShortId = first->second.Sound->getName().getShortId(); } ++maxShortId; // inc for size = last idx + 1 - if (container.size() == 0) + if (container.empty()) { nlwarning("NLSOUND: No sound sheets have been loaded, missing sound sheet directory or packed sound sheets file"); } diff --git a/code/nel/tools/3d/CMakeLists.txt b/code/nel/tools/3d/CMakeLists.txt index ff5c37db0..08fd9e776 100644 --- a/code/nel/tools/3d/CMakeLists.txt +++ b/code/nel/tools/3d/CMakeLists.txt @@ -36,6 +36,7 @@ IF(WITH_NEL_TOOLS) build_interface get_neighbors textures_optimizer + textures_tool tga_cut tga_resize) ENDIF() 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/cluster_viewer/view_cs.cpp b/code/nel/tools/3d/cluster_viewer/view_cs.cpp index 5e31543ca..fa5485ca0 100644 --- a/code/nel/tools/3d/cluster_viewer/view_cs.cpp +++ b/code/nel/tools/3d/cluster_viewer/view_cs.cpp @@ -161,21 +161,20 @@ void LoadSceneScript (const char *ScriptName, CScene* pScene, vector &D { if (nLastNbPlus >= nNbPlus) for (int i = 0; i < ((nLastNbPlus-nNbPlus)+1); ++i) - if (pile.size() > 0) + if (!pile.empty()) pile.pop_back(); nLastNbPlus = nNbPlus; CInstanceGroup *father = pScene->getGlobalInstanceGroup(); - if (pile.size() > 0) + if (!pile.empty()) father = pile.back(); CInstanceGroup *ITemp = LoadInstanceGroup (nameIG); if (ITemp != NULL) { SDispCS dcsTemp; - dcsTemp.Name = ""; for (sint32 i = 0; i < (1+nNbPlus); ++i) dcsTemp.Name += " "; dcsTemp.Name += nameIG; @@ -339,7 +338,7 @@ int main(int argc, char **argv) } ++itAcc; } - if ((vCluster.size() == 0) && (DispCS[0].pIG == pCurIG)) + if (vCluster.empty() && (DispCS[0].pIG == pCurIG)) { vCluster.push_back (pClipTrav->RootCluster); } diff --git a/code/nel/tools/3d/ig_lighter/ig_lighter.cpp b/code/nel/tools/3d/ig_lighter/ig_lighter.cpp index a243ad7bc..10cbb076d 100644 --- a/code/nel/tools/3d/ig_lighter/ig_lighter.cpp +++ b/code/nel/tools/3d/ig_lighter/ig_lighter.cpp @@ -227,7 +227,7 @@ int main(int argc, char* argv[]) CGlobalRetriever *globalRetriever= NULL; uint32 grFileDate= 0; uint32 rbankFileDate= 0; - if( grFile!="" && rbankFile!="" ) + if( !grFile.empty() && !rbankFile.empty()) { CIFile fin; // serial the retrieverBank. Exception if not found. diff --git a/code/nel/tools/3d/lightmap_optimizer/main.cpp b/code/nel/tools/3d/lightmap_optimizer/main.cpp index 077cc83b5..a84e797ad 100644 --- a/code/nel/tools/3d/lightmap_optimizer/main.cpp +++ b/code/nel/tools/3d/lightmap_optimizer/main.cpp @@ -644,7 +644,7 @@ int main(int nNbArg, char **ppArgs) } } - if (AllLightmapNames.size() == 0) + if (AllLightmapNames.empty()) continue; // Load all the lightmaps diff --git a/code/nel/tools/3d/ligo/plugin_max/CMakeLists.txt b/code/nel/tools/3d/ligo/plugin_max/CMakeLists.txt index 761537791..cd2539ee4 100644 --- a/code/nel/tools/3d/ligo/plugin_max/CMakeLists.txt +++ b/code/nel/tools/3d/ligo/plugin_max/CMakeLists.txt @@ -4,22 +4,24 @@ ADD_LIBRARY(ligoscape_utility SHARED ligoscape_utility.rc ${SRC} ligoscape_utili INCLUDE_DIRECTORIES(${MAXSDK_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES(ligoscape_utility - nelmisc +TARGET_LINK_LIBRARIES(ligoscape_utility + nelmisc nelligo nel3d nelpacs - ${MAXSDK_LIBRARIES} - nel_patch_lib + ${MAXSDK_LIBRARIES} + nel_patch_lib nel_mesh_lib nel_3dsmax_shared comctl32) - + SET_TARGET_PROPERTIES(ligoscape_utility PROPERTIES SUFFIX ".dlx") NL_DEFAULT_PROPS(ligoscape_utility "MAX Plugin: Ligoscape Utility") NL_ADD_RUNTIME_FLAGS(ligoscape_utility) NL_ADD_LIB_SUFFIX(ligoscape_utility) - + +ADD_DEFINITIONS(${MAXSDK_DEFINITIONS}) + INSTALL(TARGETS ligoscape_utility RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) INSTALL(FILES ligoscript.txt DESTINATION maxplugin/docs) INSTALL(DIRECTORY scripts/ diff --git a/code/nel/tools/3d/ligo/plugin_max/ligoscript.txt b/code/nel/tools/3d/ligo/plugin_max/ligoscript.txt index 072e3b06f..71fcf6174 100644 --- a/code/nel/tools/3d/ligo/plugin_max/ligoscript.txt +++ b/code/nel/tools/3d/ligo/plugin_max/ligoscript.txt @@ -46,7 +46,7 @@ NeLLigoGetErrorZoneTemplate code_array vertex_id_array message_array error_index Get the export errors after a call to NeLLigoExportZoneTemplate. code_array is an integer array with the error code. (2 for OpenedEdge, 4 for InvalidVertexList, 5 for NotInserted) -vertex_id_array is an integer array with the id of the vertex where an error occured. +vertex_id_array is an integer array with the id of the vertex where an error occurred. message_array is a string array with the error message for the vertices error_index is the id of the error buffer (1 ~ 9) diff --git a/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp b/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp index 6eb8d1301..44b43beed 100644 --- a/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp +++ b/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp @@ -33,9 +33,10 @@ #include "nel/misc/stream.h" // From ligo library -#include "nel/../../src/ligo/zone_template.h" +#include "nel/ligo/zone_template.h" #include "nel/ligo/ligo_config.h" -#include "nel/../../src/ligo/ligo_error.h" +#include "nel/ligo/ligo_error.h" +#include "nel/misc/path.h" using namespace std; using namespace NLMISC; @@ -124,27 +125,24 @@ bool CMaxToLigo::loadLigoConfigFile (CLigoConfig& config, Interface& it, bool di if (hModule) { // Get the path - char sModulePath[256]; + TCHAR sModulePath[256]; int res=GetModuleFileName(hModule, sModulePath, 256); // Success ? if (res) { // Path - char sDrive[256]; - char sDir[256]; - _splitpath (sModulePath, sDrive, sDir, NULL, NULL); - _makepath (sModulePath, sDrive, sDir, "ligoscape", ".cfg"); + std::string path = NLMISC::CFile::getPath(tStrToUtf8(sModulePath) + "ligoscape.cfg"); try { // Load the config file - config.readConfigFile (sModulePath, false); + config.readConfigFile (path, false); // ok return true; } - catch (Exception& e) + catch (const Exception& e) { // Print an error message char msg[512]; @@ -160,22 +158,22 @@ bool CMaxToLigo::loadLigoConfigFile (CLigoConfig& config, Interface& it, bool di // *************************************************************************** -void CMaxToLigo::errorMessage (const char *msg, const char *title, Interface& it, bool dialog) +void CMaxToLigo::errorMessage(const std::string &msg, const std::string &title, Interface& it, bool dialog) { // Text or dialog ? if (dialog) { // Dialog message - MessageBox (it.GetMAXHWnd(), msg, title, MB_OK|MB_ICONEXCLAMATION); + MessageBox (it.GetMAXHWnd(), utf8ToTStr(msg), utf8ToTStr(title), MB_OK|MB_ICONEXCLAMATION); } else { // Text message - mprintf ((string(msg) + "\n").c_str()); + mprintf (utf8ToTStr(msg + "\n")); } // Output in log - nlwarning ("LIGO ERROR : %s", msg); + nlwarning ("LIGO ERROR : %s", msg.c_str()); } // *************************************************************************** diff --git a/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.h b/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.h index 23bcfd0f2..e8b19073f 100644 --- a/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.h +++ b/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.h @@ -70,7 +70,7 @@ public: * \param it if a max interface * \param dialog is true to see the message in a dilog, false to see it in the script window. */ - static void errorMessage (const char *msg, const char *title, Interface& it, bool dialog); + static void errorMessage (const std::string &msg, const std::string &title, Interface& it, bool dialog); }; } diff --git a/code/nel/tools/3d/ligo/plugin_max/script.cpp b/code/nel/tools/3d/ligo/plugin_max/script.cpp index 8a88136c5..7083a22a7 100644 --- a/code/nel/tools/3d/ligo/plugin_max/script.cpp +++ b/code/nel/tools/3d/ligo/plugin_max/script.cpp @@ -80,11 +80,11 @@ namespace std #include "nel/misc/config_file.h" // From ligo library -#include "nel/../../src/ligo/zone_template.h" +#include "nel/ligo/zone_template.h" #include "nel/ligo/ligo_config.h" -#include "nel/../../src/ligo/ligo_error.h" -#include "nel/../../src/ligo/ligo_material.h" -#include "nel/../../src/ligo/transition.h" +#include "nel/ligo/ligo_error.h" +#include "nel/ligo/ligo_material.h" +#include "nel/ligo/transition.h" #include "nel/ligo/zone_bank.h" #include "max_to_ligo.h" @@ -94,6 +94,10 @@ using namespace NLMISC; using namespace NLLIGO; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // APP DATA #define NEL3D_APPDATA_LIGO_USE_BOUNDINGBOX ((uint32)1342141818) @@ -137,7 +141,7 @@ Value* export_material_cf (Value** arg_list, int count) check_arg_count(export_material, 4, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoExportMaterial [Object] [Filename] [CheckOnly] [Error in dialog]"; + TCHAR *message = _T("NeLLigoExportMaterial [Object] [Filename] [CheckOnly] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], String, message); type_check(arg_list[2], Boolean, message); @@ -151,7 +155,7 @@ Value* export_material_cf (Value** arg_list, int count) nlassert (node); // The second arg - const char *fileName = arg_list[1]->to_string(); + const std::string fileName = tStrToUtf8(arg_list[1]->to_string()); // The third arg bool checkOnly = (arg_list[2]->to_bool() != FALSE); @@ -204,12 +208,7 @@ Value* export_material_cf (Value** arg_list, int count) { // Make a name for the zone - char drive[512]; - char dir[512]; - char name[512]; - char path[512]; - _splitpath (fileName, drive, dir, name, NULL); - _makepath (path, drive, dir, name, ".zone"); + std::string path = CFile::getPath(fileName) + CFile::getFilenameWithoutExtension(fileName) + ".zone"; // Ok ? bool ok = true; @@ -255,7 +254,7 @@ Value* export_material_cf (Value** arg_list, int count) ok = false; } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; @@ -267,8 +266,8 @@ Value* export_material_cf (Value** arg_list, int count) // Remove the files if (!ok) { - remove (fileName); - remove (path); + CFile::deleteFile(fileName); + CFile::deleteFile(path); } } } @@ -306,7 +305,7 @@ Value* export_transition_cf (Value** arg_list, int count) check_arg_count(export_transition, 6, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoExportTransition [Object array (count=9)] [Output filename] [First material filename] [Second material filename] [CheckOnly] [Error in dialog]"; + TCHAR *message = _T("NeLLigoExportTransition [Object array (count=9)] [Output filename] [First material filename] [Second material filename] [CheckOnly] [Error in dialog]"); type_check(arg_list[0], Array, message); type_check(arg_list[1], String, message); type_check(arg_list[2], String, message); @@ -322,12 +321,12 @@ Value* export_transition_cf (Value** arg_list, int count) nlassert (is_array(nodes)); // The second arg - const char *fileName = arg_list[1]->to_string(); + std::string fileName = tStrToUtf8(arg_list[1]->to_string()); // The second arg string matFilename[2]; - matFilename[0] = arg_list[2]->to_string(); - matFilename[1] = arg_list[3]->to_string(); + matFilename[0] = tStrToUtf8(arg_list[2]->to_string()); + matFilename[1] = tStrToUtf8(arg_list[3]->to_string()); // The third arg bool checkOnly = (arg_list[4]->to_bool() != FALSE); @@ -427,7 +426,7 @@ Value* export_transition_cf (Value** arg_list, int count) // Serial materials[mat].serial (inputXml); } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[2048]; @@ -505,10 +504,7 @@ Value* export_transition_cf (Value** arg_list, int count) for (zone=0; zoneappend (Integer::intern (id+1)); // Append messages - messages->append (new String("[LIGO DEBUG] Opened edge")); + messages->append (new String(_T("[LIGO DEBUG] Opened edge"))); } // Return the main error message @@ -687,7 +683,7 @@ Value* check_zone_with_material_cf (Value** arg_list, int count) check_arg_count(check_zone_with_template, 3, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoCheckZoneWithMaterial [Object] [Material filename] [Error in dialog]"; + TCHAR *message = _T("NeLLigoCheckZoneWithMaterial [Object] [Material filename] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], String, message); type_check(arg_list[2], Boolean, message); @@ -700,7 +696,7 @@ Value* check_zone_with_material_cf (Value** arg_list, int count) nlassert (node); // The second arg - string fileName = arg_list[1]->to_string(); + string fileName = tStrToUtf8(arg_list[1]->to_string()); // The fourth arg bool errorInDialog = (arg_list[2]->to_bool() != FALSE); @@ -778,7 +774,7 @@ Value* check_zone_with_material_cf (Value** arg_list, int count) CMaxToLigo::errorMessage (tmp, "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; @@ -820,7 +816,7 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count) check_arg_count(check_zone_with_template, 4, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoCheckZoneWithTransition [Object] [Transition filename] [Transition number: 0~8] [Error in dialog]"; + TCHAR *message = _T("NeLLigoCheckZoneWithTransition [Object] [Transition filename] [Transition number: 0~8] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], String, message); type_check(arg_list[2], Integer, message); @@ -834,7 +830,7 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count) nlassert (node); // The second arg - string fileName = arg_list[1]->to_string(); + string fileName = tStrToUtf8(arg_list[1]->to_string()); // The second arg int transitionNumber = arg_list[2]->to_int(); @@ -901,7 +897,7 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count) CMaxToLigo::errorMessage (tmp, "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; @@ -987,7 +983,7 @@ Value* export_zone_cf (Value** arg_list, int count) check_arg_count(check_zone_with_template, 5, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoExportZone [Object] [Ligozone filename] [Category Array] [Error in dialog] [Snapshot]"; + TCHAR *message = _T("NeLLigoExportZone [Object] [Ligozone filename] [Category Array] [Error in dialog] [Snapshot]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], String, message); type_check(arg_list[2], Array, message); @@ -1002,7 +998,7 @@ Value* export_zone_cf (Value** arg_list, int count) nlassert (node); // The second arg - string fileName = arg_list[1]->to_string(); + string fileName = tStrToUtf8(arg_list[1]->to_string()); // The thrid arg Array *array = (Array*)arg_list[2]; @@ -1047,8 +1043,8 @@ Value* export_zone_cf (Value** arg_list, int count) type_check (cell->get(2), String, message); // Get the strings - categories[i].first = cell->get(1)->to_string(); - categories[i].second = cell->get(2)->to_string(); + categories[i].first = tStrToUtf8(cell->get(1)->to_string()); + categories[i].second = tStrToUtf8(cell->get(2)->to_string()); } // Get a Object pointer @@ -1072,30 +1068,17 @@ Value* export_zone_cf (Value** arg_list, int count) else { // Build a filename - char drive[512]; - char path[512]; - char finalpath[512]; - char name[512]; - char ext[512]; - _splitpath (fileName.c_str(), drive, path, name, ext); + std::string path = NLMISC::CFile::getPath(fileName); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName); // Build the zone filename - char outputFilenameZone[512]; - strcpy (finalpath, path); - strcat (finalpath, "zones\\"); - _makepath (outputFilenameZone, drive, finalpath, name, ".zone"); + std::string outputFilenameZone = path + "zones/" + name + ".zone"; // Build the snap shot filename - char outputFilenameSnapShot[512]; - strcpy (finalpath, path); - strcat (finalpath, "zoneBitmaps\\"); - _makepath (outputFilenameSnapShot, drive, finalpath, name, ".tga"); + std::string outputFilenameSnapShot = path + "zonesBitmaps/" + name + ".tga"; // Build the ligozone filename - char outputFilenameLigozone[512]; - strcpy (finalpath, path); - strcat (finalpath, "zoneLigos\\"); - _makepath (outputFilenameLigozone, drive, finalpath, name, ".ligozone"); + std::string outputFilenameLigozone = path + "zoneLigos/" + name + ".ligozone"; // Build the zone CZone zone; @@ -1179,12 +1162,12 @@ Value* export_zone_cf (Value** arg_list, int count) if (weWantToMakeASnapshot) { CIFile fileFarBank; - char drive[512]; - char path[512]; - char name[512]; - char farBankPathName[512]; - _splitpath (GetBankPathName ().c_str (), drive, path, name, NULL); - _makepath (farBankPathName, drive, path, name, "farbank"); + + std::string path = NLMISC::CFile::getPath(GetBankPathName()); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(GetBankPathName()); + + std::string farBankPathName = path + name + ".farbank"; + if (fileFarBank.open (farBankPathName)) { // Create an xml stream @@ -1313,7 +1296,7 @@ Value* export_zone_cf (Value** arg_list, int count) CMaxToLigo::errorMessage (tmp, "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; @@ -1324,7 +1307,7 @@ Value* export_zone_cf (Value** arg_list, int count) } } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; @@ -1362,14 +1345,14 @@ Value* get_error_string_cf (Value** arg_list, int count) check_arg_count(get_error_string, 1, count); // Checks arg - char *message = "NeLLigoGetErrorString [error code]"; + TCHAR *message = _T("NeLLigoGetErrorString [error code]"); type_check(arg_list[0], Integer, message); // The first arg int errorCode = arg_list[0]->to_int()-1; // Error code - return new String ((char*)CLigoError::getStringError ((CLigoError::TError)errorCode)); + return new String (utf8ToTStr(CLigoError::getStringError ((CLigoError::TError)errorCode))); } // *************************************************************************** @@ -1380,14 +1363,14 @@ Value* set_directory_cf (Value** arg_list, int count) check_arg_count(set_directory, 1, count); // Checks arg - char *message = "NeLLigoDirectory [path]"; + TCHAR *message = _T("NeLLigoDirectory [path]"); type_check(arg_list[0], String, message); // The first arg - const char *dir = arg_list[0]->to_string(); + const std::string dir = tStrToUtf8(arg_list[0]->to_string()); // Set the directory - return (chdir (dir)==0)?&true_value:&false_value; + return (chdir (dir.c_str())==0)?&true_value:&false_value; } // *************************************************************************** @@ -1398,7 +1381,7 @@ Value* get_zone_mask_cf (Value** arg_list, int count) check_arg_count(check_zone_with_template, 5, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoGetZoneMask [Object] [Mask Array] [Width Array] [Height Array] [Error in dialog]"; + TCHAR *message = _T("NeLLigoGetZoneMask [Object] [Mask Array] [Width Array] [Height Array] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], Array, message); type_check(arg_list[2], Array, message); @@ -1558,7 +1541,7 @@ Value* get_zone_size_cf (Value** arg_list, int count) check_arg_count(check_zone_with_template, 6, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoGetZoneMask [Object] [minx Array] [maxy Array] [miny Array] [maxy Array] [Error in dialog]"; + TCHAR *message = _T("NeLLigoGetZoneMask [Object] [minx Array] [maxy Array] [miny Array] [maxy Array] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], Array, message); type_check(arg_list[2], Array, message); @@ -1835,7 +1818,7 @@ bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, c CMaxToLigo::errorMessage ("Can't initialise opengl offscreen renderer", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } } - catch (Exception &e) + catch (const Exception &e) { // Error char tmp[512]; @@ -1859,7 +1842,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) check_arg_count(NeLLigoMakeSnapShot, 7, count); // Check to see if the arguments match up to what we expect - char *message = "NeLLigoMakeSnapShot [Object] [Snapshot filename] [xMin] [xMax] [yMin] [yMax] [Error in dialog]"; + TCHAR *message = _T("NeLLigoMakeSnapShot [Object] [Snapshot filename] [xMin] [xMax] [yMin] [yMax] [Error in dialog]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], String, message); type_check(arg_list[2], Integer, message); @@ -1876,7 +1859,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) nlassert (node); // The second arg - string fileName = arg_list[1]->to_string(); + string fileName = tStrToUtf8(arg_list[1]->to_string()); // The thrid arg int xMin = arg_list[2]->to_int(); @@ -1908,11 +1891,9 @@ Value* make_snapshot_cf (Value** arg_list, int count) else { // Build a filename - char drivetga[512]; - char pathtga[512]; - char nametga[512]; - char exttga[512]; - _splitpath (fileName.c_str(), drivetga, pathtga, nametga, exttga); + std::string nametga = CFile::getFilenameWithoutExtension(fileName); + std::string pathtga = CFile::getPath(fileName); + // Build the zone CZone zone; @@ -1956,12 +1937,9 @@ Value* make_snapshot_cf (Value** arg_list, int count) if (tileBank != NULL) { CIFile fileFarBank; - char drive[512]; - char path[512]; - char name[512]; - char farBankPathName[512]; - _splitpath (GetBankPathName ().c_str (), drive, path, name, NULL); - _makepath (farBankPathName, drive, path, name, "farbank"); + std::string name = CFile::getFilenameWithoutExtension(GetBankPathName()); + std::string farBankPathName = CFile::getPath(GetBankPathName()) + name + ".farbank"; + if (fileFarBank.open (farBankPathName)) { // Create an xml stream @@ -1974,8 +1952,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) if (MakeSnapShot (snapshot, *tileBank, *tileFarBank, xMin, xMax, yMin, yMax, config, errorInDialog)) { // Build the snap shot filename - char outputFilenameSnapShot[512]; - _makepath (outputFilenameSnapShot, drivetga, pathtga, nametga, ".tga"); + std::string outputFilenameSnapShot = pathtga + nametga + ".tga"; // Output the snap shot COFile outputSnapShot; @@ -2014,12 +1991,13 @@ Value* make_snapshot_cf (Value** arg_list, int count) bankElm.addCategory (strlwr (categories[j].first), strlwr (categories[j].second)); } + // Catch exception +#if 0 // Write the zone COFile outputLigoZone; - _makepath (outputFilenameSnapShot, drivetga, pathtga, nametga, ".ligozone"); + std::string outputFilenameSnapShot = pathtga + nametga + ".ligozone"; - // Catch exception - /*try + try { // Open the selected zone file if (outputLigoZone.open (outputFilenameSnapShot)) @@ -2042,13 +2020,14 @@ Value* make_snapshot_cf (Value** arg_list, int count) CMaxToLigo::errorMessage (tmp, "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; smprintf (tmp, 512, "Error while loading the file %s : %s", fileName, e.what()); CMaxToLigo::errorMessage (tmp, "NeL Ligo export zone", *MAXScript_interface, errorInDialog); - }*/ + } +#endif } else { @@ -2068,7 +2047,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) } } } - catch (Exception &e) + catch (const Exception &e) { // Error message char tmp[512]; diff --git a/code/nel/tools/3d/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..28806fc31 100644 --- a/code/nel/tools/3d/object_viewer/editable_range.cpp +++ b/code/nel/tools/3d/object_viewer/editable_range.cpp @@ -159,7 +159,7 @@ void CEditableRange::OnUpdateValue() void CEditableRange::emptyDialog(void) { - m_Value = CString(""); + m_Value.Empty(); m_SliderPos = 0; UpdateData(FALSE); } @@ -185,12 +185,12 @@ static void concatEdit2Lines(CEdit &edit) const uint lineLen= 1000; uint n; // retrieve the 2 lines. - char tmp0[2*lineLen]; - char tmp1[lineLen]; + TCHAR tmp0[2*lineLen]; + TCHAR tmp1[lineLen]; n= edit.GetLine(0, tmp0, lineLen); tmp0[n]= 0; n= edit.GetLine(1, tmp1, lineLen); tmp1[n]= 0; // concat and update the CEdit. - edit.SetWindowText(strcat(tmp0, tmp1)); + edit.SetWindowText(_tcscat(tmp0, tmp1)); } diff --git a/code/nel/tools/3d/object_viewer/editable_range.h b/code/nel/tools/3d/object_viewer/editable_range.h index 485f57659..5a4b6263c 100644 --- a/code/nel/tools/3d/object_viewer/editable_range.h +++ b/code/nel/tools/3d/object_viewer/editable_range.h @@ -133,7 +133,7 @@ public: // SPECIALIZE THAT. write value into the given CString static void value2CString(T value, CString &dest); // SPECIALIZE THAT. convert a CString into a value, return NULL if ok, or a pointer to an error message - static const char *string2value(const CString &value, T &result); + static const TCHAR *string2value(const CString &value, T &result); @@ -162,14 +162,13 @@ protected: void updateValueFromText(void) { T value; - const char *message = string2value(m_Value, value); + const TCHAR *message = string2value(m_Value, value); if (!message) { - const char *mess = validateUpperBound(value) - ,*mess2 = validateLowerBound(value); + const TCHAR *mess = validateUpperBound(value), *mess2 = validateLowerBound(value); if (mess || mess2) { - MessageBox(mess ? mess : mess2, "error"); + MessageBox(mess ? mess : mess2, _T("error")); return; } @@ -179,7 +178,7 @@ protected: return; } - MessageBox(message, "error"); + MessageBox(message, _T("error")); } void selectRange(void) @@ -249,24 +248,23 @@ protected: { T upT, loT; - const char *message = string2value(lo, loT); + const TCHAR *message = string2value(lo, loT); if (message) { - ::MessageBox(NULL, message, "Range selection error", MB_OK); + ::MessageBox(NULL, message, _T("Range selection error"), MB_OK); return false; } - const char *mess = validateUpperBound(loT) - ,*mess2 = validateLowerBound(loT); + const TCHAR *mess = validateUpperBound(loT), *mess2 = validateLowerBound(loT); if (mess || mess2) { - MessageBox(mess ? mess : mess2, "error"); + MessageBox(mess ? mess : mess2, _T("error")); return false; } message = string2value(up, upT); if (message) { - ::MessageBox(NULL, message, "Range selection error", MB_OK); + ::MessageBox(NULL, message, _T("Range selection error"), MB_OK); return false; } @@ -274,14 +272,14 @@ protected: mess2 = validateLowerBound(upT); if (mess || mess2) { - MessageBox(mess ? mess : mess2, "error"); + MessageBox(mess ? mess : mess2, _T("error")); return false; } if (upT <= loT) { - ::MessageBox(NULL, "upper bound must be strictly greater than lower bound", "Range selection error", MB_OK); + ::MessageBox(NULL, _T("upper bound must be strictly greater than lower bound"), _T("Range selection error"), MB_OK); return false; } @@ -314,18 +312,18 @@ CEditableRangeT::CEditableRangeT(const std::string &id, CParticleWorkspac inline void CEditableRangeT::value2CString(float value, CString &dest) { - dest.Format("%g", (double) value); + dest.Format(_T("%g"), (double) value); } -inline const char *CEditableRangeT::string2value(const CString &value, float &result) +inline const TCHAR *CEditableRangeT::string2value(const CString &value, float &result) { - if (sscanf((LPCTSTR) value, "%f", &result) == 1) + if (NLMISC::fromString(tStrToUtf8(value), result)) { return NULL; } else { - return "invalid value"; + return _T("invalid value"); } } @@ -340,17 +338,17 @@ CEditableRangeT::CEditableRangeT(const std::string &id, CParticleWorkspa inline void CEditableRangeT::value2CString(uint32 value, CString &dest) { - dest.Format("%d", value); + dest.Format(_T("%d"), value); } -inline const char *CEditableRangeT::string2value(const CString &value, uint32 &result) +inline const TCHAR *CEditableRangeT::string2value(const CString &value, uint32 &result) { - uint32 tmp; - if (sscanf((LPCTSTR) value, "%d", &tmp) == 1) + sint32 tmp; + if (NLMISC::fromString(tStrToUtf8(value), tmp)) { - if (strchr((LPCTSTR) value, '-')) + if (value.Find(_T("-")) > -1) { - return "negative values not allowed"; + return _T("negative values not allowed"); } else { @@ -360,7 +358,7 @@ inline const char *CEditableRangeT::string2value(const CString &value, u } else { - return "invalid value"; + return _T("invalid value"); } } @@ -376,20 +374,20 @@ CEditableRangeT::CEditableRangeT(const std::string &id, CParticleWorkspa inline void CEditableRangeT::value2CString(sint32 value, CString &dest) { - dest.Format("%d", value); + dest.Format(_T("%d"), value); } -inline const char *CEditableRangeT::string2value(const CString &value, sint32 &result) +inline const TCHAR *CEditableRangeT::string2value(const CString &value, sint32 &result) { - uint32 tmp; - if (sscanf((LPCTSTR) value, "%d", &tmp) == 1) + sint32 tmp; + if (NLMISC::fromString(tStrToUtf8(value), tmp)) { result = tmp; return NULL; } else { - return "invalid value"; + return _T("invalid value"); } } diff --git a/code/nel/tools/3d/object_viewer/emitter_dlg.cpp b/code/nel/tools/3d/object_viewer/emitter_dlg.cpp index 175756c6d..e4864cfe6 100644 --- a/code/nel/tools/3d/object_viewer/emitter_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/emitter_dlg.cpp @@ -85,7 +85,7 @@ void CEmitterDlg::initEmittedType() NL3D::CPSLocated *loc = dynamic_cast(ps->getProcess(k)); if (loc) // is this a located { - m_EmittedTypeCtrl.AddString(loc->getName().c_str()); + m_EmittedTypeCtrl.AddString(utf8ToTStr(loc->getName())); _LocatedList.push_back(loc); if (loc == _Emitter->getEmittedType()) { @@ -129,11 +129,11 @@ void CEmitterDlg::OnSelchangeEmittedType() { if (_Emitter->getOwner()->getOwner()->getBehaviourType() == NL3D::CParticleSystem::SpellFX || _Emitter->getOwner()->getOwner()->getBypassMaxNumIntegrationSteps()) { - MessageBox("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', and thus, should have a finite duration. This operation create a loop in the system, and so is forbidden.", "Error", MB_ICONEXCLAMATION); + MessageBox(_T("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', and thus, should have a finite duration. This operation create a loop in the system, and so is forbidden."), _T("Error"), MB_ICONEXCLAMATION); } else { - MessageBox("Loops with emitters are forbidden.", "Error", MB_ICONEXCLAMATION); + MessageBox(_T("Loops with emitters are forbidden."), _T("Error"), MB_ICONEXCLAMATION); } initEmittedType(); } @@ -267,7 +267,7 @@ BOOL CEmitterDlg::OnInitDialog() CStatic *s = new CStatic; pushWnd(s); - s->Create("Radius :", SS_LEFT, CRect(posX, posY + 10 , posX + 70, posY + 32), this); + s->Create(_T("Radius :"), SS_LEFT, CRect(posX, posY + 10 , posX + 70, posY + 32), this); s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); diff --git a/code/nel/tools/3d/object_viewer/global_wind_dlg.cpp b/code/nel/tools/3d/object_viewer/global_wind_dlg.cpp index 505f6c7b8..ef55408e1 100644 --- a/code/nel/tools/3d/object_viewer/global_wind_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/global_wind_dlg.cpp @@ -61,11 +61,11 @@ END_MESSAGE_MAP() void CGlobalWindDlg::updateView() { float a; - char str[256]; + TCHAR str[256]; // update Power. a= _ObjViewer->getGlobalWindPower(); - sprintf(str, "%.2f", a); + _stprintf(str, _T("%.2f"), a); StaticPower.SetWindowText(str); NLMISC::clamp(a, 0.f, 1.f); SliderPower.SetPos((sint)(a*NL_GLOBAL_WIND_SLIDER_RANGE)); @@ -113,11 +113,11 @@ void CGlobalWindDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) if( sliderCtrl==&SliderPower && nSBCode==SB_THUMBPOSITION || nSBCode==SB_THUMBTRACK) { float a; - char str[256]; + TCHAR str[256]; a= (float)nPos / NL_GLOBAL_WIND_SLIDER_RANGE; _ObjViewer->setGlobalWindPower(a); - sprintf(str, "%.2f", a); + _stprintf(str, _T("%.2f"), a); StaticPower.SetWindowText(str); } else diff --git a/code/nel/tools/3d/object_viewer/lb_extern_id_dlg.cpp b/code/nel/tools/3d/object_viewer/lb_extern_id_dlg.cpp index edf9f2547..9ea2d51a9 100644 --- a/code/nel/tools/3d/object_viewer/lb_extern_id_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/lb_extern_id_dlg.cpp @@ -55,32 +55,32 @@ END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CLBExternIDDlg message handlers -BOOL CLBExternIDDlg::OnInitDialog() +BOOL CLBExternIDDlg::OnInitDialog() { CDialog::OnInitDialog(); - + GetDlgItem(IDC_ID_VALUE)->EnableWindow(_ID != 0); ((CButton *) GetDlgItem(IDC_ENABLE_EXTERN_ID))->SetCheck(_ID != 0 ? 1 : 0); if (_ID) { - char val[5]; + TCHAR val[5]; for (uint k = 0; k < 4; ++k) { #ifdef NL_LITTLE_ENDIAN val[k] = (unsigned char) (_ID >> ((3 - k) << 3)); #else - val[k] = (unsigned char) (_ID >> (k << 3)); + val[k] = (unsigned char) (_ID >> (k << 3)); #endif } - val[4] = '\0'; + val[4] = '\0'; GetDlgItem(IDC_ID_VALUE)->SetWindowText(val); } else { _ID = 0; - } + } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } @@ -90,41 +90,41 @@ static uint32 StringToID(const char *buf) { uint32 id; #ifdef NL_LITTLE_ENDIAN - id = ((uint32) buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3]); + id = ((uint32) buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3]); #else - id = *(uint32 *) buf; + id = *(uint32 *) buf; #endif return id; } -void CLBExternIDDlg::OnEnableExternId() +void CLBExternIDDlg::OnEnableExternId() { if (_ID == 0) { GetDlgItem(IDC_ID_VALUE)->EnableWindow(TRUE); - _ID = StringToID("NONE"); - GetDlgItem(IDC_ID_VALUE)->SetWindowText("NONE"); + _ID = StringToID("NONE"); + GetDlgItem(IDC_ID_VALUE)->SetWindowText(_T("NONE")); } else { GetDlgItem(IDC_ID_VALUE)->EnableWindow(FALSE); - GetDlgItem(IDC_ID_VALUE)->SetWindowText(""); + GetDlgItem(IDC_ID_VALUE)->SetWindowText(_T("")); _ID = 0; - } + } } -void CLBExternIDDlg::OnChangeIdValue() -{ +void CLBExternIDDlg::OnChangeIdValue() +{ if (!((CButton *) GetDlgItem(IDC_ENABLE_EXTERN_ID))->GetCheck()) return; - char buf[6]; + TCHAR buf[6]; ::memset(buf, 0, 6); GetDlgItem(IDC_ID_VALUE)->GetWindowText(buf, 6); - _ID = StringToID(buf); + _ID = StringToID(tStrToUtf8(buf).c_str()); if (_ID) { GetDlgItem(IDOK)->EnableWindow(TRUE); - GetDlgItem(IDC_ENABLE_EXTERN_ID)->EnableWindow(TRUE); - if (::strlen(buf) > 4) + GetDlgItem(IDC_ENABLE_EXTERN_ID)->EnableWindow(TRUE); + if (::_tcslen(buf) > 4) { buf[4] = '\0'; GetDlgItem(IDC_ID_VALUE)->SetWindowText(buf); @@ -133,7 +133,7 @@ void CLBExternIDDlg::OnChangeIdValue() else { GetDlgItem(IDOK)->EnableWindow(FALSE); - GetDlgItem(IDC_ENABLE_EXTERN_ID)->EnableWindow(FALSE); + GetDlgItem(IDC_ENABLE_EXTERN_ID)->EnableWindow(FALSE); } } diff --git a/code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp b/code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp index 6472eb7c5..2242c0684 100644 --- a/code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp +++ b/code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp @@ -42,7 +42,7 @@ #include "ribbon_dlg.h" -using NL3D::CPSLocatedBindable; +using NL3D::CPSLocatedBindable; ///////////////////////////////////////////////////////////////////////////// @@ -55,7 +55,7 @@ CLocatedBindableDialog::CLocatedBindableDialog(CParticleWorkspace::CNode *ownerN { //{{AFX_DATA_INIT(CLocatedBindableDialog) m_IndependantSizes = FALSE; - //}}AFX_DATA_INIT + //}}AFX_DATA_INIT } /// dtor @@ -78,7 +78,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) NL3D::CParticleSystem *ps = _Bindable->getOwner()->getOwner(); if (ps->isSharingEnabled()) - { + { GetDlgItem(IDC_NO_AUTO_LOD)->ShowWindow(TRUE); if (ps->isAutoLODEnabled() == false) { @@ -111,10 +111,10 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) NL3D::CPSMaterial *material = dynamic_cast(_Bindable); // blending mode m_BlendingMode.SetCurSel((uint) material->getBlendingMode() ); - // z-test + // z-test ((CButton *) GetDlgItem(IDC_ZTEST))->SetCheck(material->isZTestEnabled() ? BST_CHECKED : BST_UNCHECKED); // z-bias - GetDlgItem(IDC_ZBIAS)->SetWindowText(NLMISC::toString("%.2f", -material->getZBias()).c_str()); + GetDlgItem(IDC_ZBIAS)->SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", -material->getZBias()))); } else { @@ -126,7 +126,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) } GetDlgItem(IDC_ALIGN_ON_MOTION)->ShowWindow(SW_HIDE); GetDlgItem(IDC_ZALIGN)->ShowWindow(SW_HIDE); - // enable disable z-test + // enable disable z-test // if (dynamic_cast(_Bindable)) { @@ -147,12 +147,12 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) // check support for color if (dynamic_cast(_Bindable)) { - + CAttribDlgRGBA *ad = new CAttribDlgRGBA("PARTICLE_COLOR", _Node); pushWnd(ad); - _ColorWrapper.S = dynamic_cast(_Bindable); - ad->setWrapper(&_ColorWrapper); + _ColorWrapper.S = dynamic_cast(_Bindable); + ad->setWrapper(&_ColorWrapper); ad->setSchemeWrapper(&_ColorWrapper); HBITMAP bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_PARTICLE_COLOR)); @@ -169,13 +169,13 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) // check support for angle 2D if (dynamic_cast(_Bindable)) { - + CAttribDlgFloat *ad = new CAttribDlgFloat("PARTICLE_ANGLE2D", _Node, 0.f, 256.f); pushWnd(ad); _Angle2DWrapper.S = dynamic_cast(_Bindable); - ad->setWrapper(&_Angle2DWrapper); - ad->setSchemeWrapper(&_Angle2DWrapper); + ad->setWrapper(&_Angle2DWrapper); + ad->setSchemeWrapper(&_Angle2DWrapper); HBITMAP bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_PARTICLE_ANGLE)); ad->init(bmh, xPos, yPos, this); @@ -183,7 +183,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) yPos += rect.bottom + 3; } - + CAttribDlgPlaneBasis *pb = NULL; @@ -199,7 +199,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) pb->init(bmh, xPos, yPos, this); pb->GetClientRect(&rect); yPos += rect.bottom + 3; - + } // check support for precomputed rotations @@ -225,8 +225,8 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) CStatic *s = new CStatic; pushWnd(s); _MotionBlurWnd.push_back(s); - s->Create("Fake motion blur coeff.", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->Create(_T("Fake motion blur coeff."), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); mbc->GetClientRect(&rect); yPos += rect.bottom + 3; @@ -236,14 +236,14 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) _MotionBlurThresholdWrapper.P = fla; mbc->setWrapper(&_MotionBlurThresholdWrapper); mbc->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); _MotionBlurWnd.push_back(s); - s->Create("Fake motion blur threshold.", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Fake motion blur threshold."), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); mbc->GetClientRect(&rect); - yPos += rect.bottom + 3; + yPos += rect.bottom + 3; GetDlgItem(IDC_ALIGN_ON_MOTION)->ShowWindow(SW_SHOW); GetDlgItem(IDC_ZALIGN)->ShowWindow(SW_SHOW); ((CButton *) GetDlgItem(IDC_ALIGN_ON_MOTION))->SetCheck(fla->getAlignOnMotion()); @@ -256,14 +256,14 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) { NL3D::CPSShockWave *sw = static_cast(_Bindable); CEditableRangeFloat *rc = new CEditableRangeFloat(std::string("RADIUS CUT"), _Node, 0, 1); - pushWnd(rc); + pushWnd(rc); _RadiusCutWrapper.S = sw; rc->setWrapper(&_RadiusCutWrapper); rc->init(xPos + 140, yPos, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Radius cut.", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->Create(_T("Radius cut."), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); @@ -277,9 +277,9 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) snbs->setWrapper(&_ShockWaveNbSegWrapper); snbs->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Nb segs", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Nb segs"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->ShowWindow(SW_SHOW); snbs->GetClientRect(&rect); @@ -291,13 +291,13 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) _ShockWaveUFactorWrapper.S = sw; uvd->setWrapper(&_ShockWaveUFactorWrapper); uvd->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Texture U factor :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Texture U factor :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->ShowWindow(SW_SHOW); uvd->GetClientRect(&rect); - yPos += rect.bottom + 3; - + yPos += rect.bottom + 3; + } // fanlight @@ -312,8 +312,8 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) nbf->init(xPos + 140, yPos, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Nb fan lights :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->Create(_T("Nb fan lights :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); nbf->GetClientRect(&rect); @@ -325,35 +325,35 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) _FanLightSmoothnessWrapper.P = static_cast(_Bindable); nbf->setWrapper(&_FanLightSmoothnessWrapper); nbf->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Phase smoothnes:", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Phase smoothnes:"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->ShowWindow(SW_SHOW); nbf->GetClientRect(&rect); yPos += rect.bottom + 3; CEditableRangeFloat *nbfp = new CEditableRangeFloat(std::string("FAN_LIGHT_PHASE"), _Node, 0, 4.f); - pushWnd(nbfp); + pushWnd(nbfp); _FanLightPhaseWrapper.P = static_cast(_Bindable); nbfp->setWrapper(&_FanLightPhaseWrapper); nbfp->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Fan light speed :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Fan light speed :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->ShowWindow(SW_SHOW); nbf->GetClientRect(&rect); yPos += rect.bottom + 3; nbfp = new CEditableRangeFloat(std::string("FAN_LIGHT_INTENSITY"), _Node, 0, 4.f); - pushWnd(nbfp); + pushWnd(nbfp); _FanLightIntensityWrapper.P = static_cast(_Bindable); nbfp->setWrapper(&_FanLightIntensityWrapper); nbfp->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Fan light intensity:", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Fan light intensity:"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->ShowWindow(SW_SHOW); nbf->GetClientRect(&rect); @@ -383,24 +383,24 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) { nbs->enableUpperBound(256, true); } - - + + _TailParticleWrapper.P = dynamic_cast(_Bindable); nbs->setWrapper(&_TailParticleWrapper); nbs->init(xPos + 140, yPos, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Nb segs :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); - s->ShowWindow(SW_SHOW); - + s->Create(_T("Nb segs :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->ShowWindow(SW_SHOW); + nbs->GetClientRect(&rect); yPos += rect.bottom + 3; CTailParticleDlg *tpd = new CTailParticleDlg(_Node, dynamic_cast(_Bindable)); pushWnd(tpd); tpd->init(this, xPos, yPos); - + tpd->GetClientRect(&rect); yPos += rect.bottom + 3; } @@ -429,7 +429,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) cmtd->GetClientRect(&rect); yPos += rect.bottom + 3; pushWnd(cmd); - pushWnd(cmtd); + pushWnd(cmtd); } @@ -440,9 +440,9 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) CTextureAnimDlg *td = new CTextureAnimDlg(_Node, dynamic_cast(_Bindable), dynamic_cast(_Bindable) - ); + ); pushWnd(td); - + td->init(xPos, yPos, this); td->GetClientRect(&rect); yPos += rect.bottom + 3; @@ -453,7 +453,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) { NL3D::CPSTexturedParticleNoAnim *tp = dynamic_cast(_Bindable); _TextureNoAnimWrapper.TP = tp; - CTextureChooser *tc = new CTextureChooser(dynamic_cast(_Bindable), _Node); + CTextureChooser *tc = new CTextureChooser(dynamic_cast(_Bindable), _Node); tc->enableRemoveButton(); tc->setWrapper(&_TextureNoAnimWrapper); pushWnd(tc); @@ -465,8 +465,8 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) // ribbon texture (doesn't support texture animation for now) if (dynamic_cast(_Bindable)) - { - + { + // add dialog for uv tuning with ribbon CEditableRangeFloat *uvd = new CEditableRangeFloat(std::string("RIBBON UFACTOR"), _Node, 0, 5); pushWnd(uvd); @@ -475,8 +475,8 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) uvd->init(xPos + 140, yPos, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Texture U factor :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->Create(_T("Texture U factor :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); uvd->GetClientRect(&rect); yPos += rect.bottom + 3; @@ -486,19 +486,19 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) _RibbonVFactorWrapper.R = static_cast(_Bindable); uvd->setWrapper(&_RibbonVFactorWrapper); uvd->init(xPos + 140, yPos, this); - s = new CStatic; + s = new CStatic; pushWnd(s); - s->Create("Texture V factor :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->Create(_T("Texture V factor :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); uvd->GetClientRect(&rect); yPos += rect.bottom + 3; - } + } if (dynamic_cast(_Bindable)) - { - + { + // add dialog for uv tuning with ribbon CEditableRangeFloat *sd = new CEditableRangeFloat(std::string("SEGMENT DURATION"), _Node, 0.05f, 0.5f); sd->enableLowerBound(0, true); @@ -508,19 +508,19 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) sd->init(xPos + 140, yPos, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Seg Duration :", SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); - s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); + s->Create(_T("Seg Duration :"), SS_LEFT, CRect(xPos, yPos + 16, xPos + 139, yPos + 48), this); + s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); sd->GetClientRect(&rect); yPos += rect.bottom + 3; } - + // 'look at' independant sizes - bool isLookAt = dynamic_cast(_Bindable) != NULL; + bool isLookAt = dynamic_cast(_Bindable) != NULL; GetDlgItem(IDC_INDE_SIZES)->ShowWindow(isLookAt ? SW_SHOW : SW_HIDE); GetDlgItem(IDC_SIZE_WIDTH)->ShowWindow(isLookAt ? SW_SHOW : SW_HIDE); GetDlgItem(IDC_SIZE_HEIGHT)->ShowWindow(isLookAt ? SW_SHOW : SW_HIDE); - GetDlgItem(IDC_WIDTH_HEIGHT_BOX)->ShowWindow(isLookAt ? SW_SHOW : SW_HIDE); + GetDlgItem(IDC_WIDTH_HEIGHT_BOX)->ShowWindow(isLookAt ? SW_SHOW : SW_HIDE); ((CButton *) GetDlgItem(IDC_SIZE_WIDTH))->SetCheck(1); if (isLookAt) { @@ -539,8 +539,8 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent) pushWnd(rd); rd->GetClientRect(&rect); yPos += rect.bottom + 3; - } - } + } + } UpdateData(); } @@ -580,7 +580,7 @@ END_MESSAGE_MAP() void CLocatedBindableDialog::touchPSState() { if (_Node && _Node->getPSModel()) - { + { _Node->getPSModel()->touchTransparencyState(); _Node->getPSModel()->touchLightableState(); } @@ -588,19 +588,19 @@ void CLocatedBindableDialog::touchPSState() //*********************************************************************************** -void CLocatedBindableDialog::OnSelchangeBlendingMode() +void CLocatedBindableDialog::OnSelchangeBlendingMode() { UpdateData(); NL3D::CPSMaterial *m = dynamic_cast(_Bindable); nlassert(m); - m->setBlendingMode( (NL3D::CPSMaterial::TBlendingMode) m_BlendingMode.GetCurSel()); - touchPSState(); + m->setBlendingMode( (NL3D::CPSMaterial::TBlendingMode) m_BlendingMode.GetCurSel()); + touchPSState(); updateModifiedFlag(); } //*********************************************************************************** -void CLocatedBindableDialog::updateIndependantSizes() +void CLocatedBindableDialog::updateIndependantSizes() { UpdateData(); // make sure we are dealing with 'LookAt' for now @@ -613,7 +613,7 @@ void CLocatedBindableDialog::updateIndependantSizes() //*********************************************************************************** // user asked for independant sizes -void CLocatedBindableDialog::OnIndeSizes() +void CLocatedBindableDialog::OnIndeSizes() { UpdateData(); // make sure we are dealing with 'LookAt' for now @@ -621,13 +621,13 @@ void CLocatedBindableDialog::OnIndeSizes() NL3D::CPSFaceLookAt *la = static_cast(_Bindable); la->setIndependantSizes(m_IndependantSizes ? true : false /* VCC warning*/); updateIndependantSizes(); - updateSizeControl(); + updateSizeControl(); updateModifiedFlag(); } //*********************************************************************************** uint CLocatedBindableDialog::updateSizeControl() -{ +{ HBITMAP bmh; if (!dynamic_cast(_Bindable)) return 0; // if a previous control was there, remove it @@ -645,7 +645,7 @@ uint CLocatedBindableDialog::updateSizeControl() int editWidth = (((CButton *) GetDlgItem(IDC_SIZE_WIDTH))->GetCheck()); _SizeCtrl = new CAttribDlgFloat(editWidth ? "PARTICLE_WIDTH" : "PARTICLE_HEIGHT", _Node, 0.f, 1.f); - + if (editWidth) // wrap to the wanted size { _SizeWrapper.S = fla; @@ -656,8 +656,8 @@ uint CLocatedBindableDialog::updateSizeControl() } _SizeCtrl->setWrapper(&_SizeWrapper); _SizeCtrl->setSchemeWrapper(&_SizeWrapper); - - bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(editWidth ? IDB_PARTICLE_WIDTH : IDB_PARTICLE_HEIGHT)); + + bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(editWidth ? IDB_PARTICLE_WIDTH : IDB_PARTICLE_HEIGHT)); } else // general case. Wrap to the size interface and the appropriate dialog { @@ -666,29 +666,29 @@ uint CLocatedBindableDialog::updateSizeControl() _SizeWrapper.S = dynamic_cast(_Bindable); _SizeCtrl->setWrapper(&_SizeWrapper); _SizeCtrl->setSchemeWrapper(&_SizeWrapper); - - bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_PARTICLE_SIZE)); + + bmh = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_PARTICLE_SIZE)); } RECT rect; _SizeCtrl->init(bmh, _SizeCtrlX, _SizeCtrlY, this); _SizeCtrl->GetClientRect(&rect); - return rect.bottom + 3; + return rect.bottom + 3; } //*********************************************************************************** -void CLocatedBindableDialog::OnSizeWidth() +void CLocatedBindableDialog::OnSizeWidth() { - updateSizeControl(); + updateSizeControl(); } //*********************************************************************************** -void CLocatedBindableDialog::OnSizeHeight() +void CLocatedBindableDialog::OnSizeHeight() { - updateSizeControl(); + updateSizeControl(); } //*********************************************************************************** -void CLocatedBindableDialog::OnNoAutoLod() +void CLocatedBindableDialog::OnNoAutoLod() { NL3D::CPSParticle *p = NLMISC::safe_cast(_Bindable); p->disableAutoLOD(((CButton *) GetDlgItem(IDC_NO_AUTO_LOD))->GetCheck() != 0); @@ -696,8 +696,8 @@ void CLocatedBindableDialog::OnNoAutoLod() } //*********************************************************************************** -void CLocatedBindableDialog::OnGlobalColorLighting() -{ +void CLocatedBindableDialog::OnGlobalColorLighting() +{ NL3D::CPSParticle *p = NLMISC::safe_cast(_Bindable); p->enableGlobalColorLighting(((CButton *) GetDlgItem(ID_GLOBAL_COLOR_LIGHTING))->GetCheck() == 1); touchPSState(); @@ -705,12 +705,12 @@ void CLocatedBindableDialog::OnGlobalColorLighting() } //*********************************************************************************** -void CLocatedBindableDialog::OnAlignOnMotion() +void CLocatedBindableDialog::OnAlignOnMotion() { bool align = ((CButton *) GetDlgItem(IDC_ALIGN_ON_MOTION))->GetCheck() != 0; NL3D::CPSFaceLookAt *fla = NLMISC::safe_cast(_Bindable); fla->setAlignOnMotion(align); - updateValidWndForAlignOnMotion(align); + updateValidWndForAlignOnMotion(align); updateModifiedFlag(); } @@ -723,10 +723,10 @@ void CLocatedBindableDialog::updateValidWndForAlignOnMotion(bool align) CEditAttribDlg *ead = dynamic_cast(_MotionBlurWnd[k]); if (ead) { - ead->EnableWindow(enable); // enable window not virtual in CWnd ... + ead->EnableWindow(enable); // enable window not virtual in CWnd ... } else - { + { _MotionBlurWnd[k]->EnableWindow(enable); } } @@ -734,7 +734,7 @@ void CLocatedBindableDialog::updateValidWndForAlignOnMotion(bool align) } //*********************************************************************************** -void CLocatedBindableDialog::OnZtest() +void CLocatedBindableDialog::OnZtest() { UpdateData(); NL3D::CPSMaterial *mat = dynamic_cast(_Bindable); @@ -749,12 +749,12 @@ static void concatEdit2Lines(CEdit &edit) const uint lineLen= 1000; uint n; // retrieve the 2 lines. - char tmp0[2*lineLen]; - char tmp1[lineLen]; + TCHAR tmp0[2*lineLen]; + TCHAR tmp1[lineLen]; n= edit.GetLine(0, tmp0, lineLen); tmp0[n]= 0; n= edit.GetLine(1, tmp1, lineLen); tmp1[n]= 0; // concat and update the CEdit. - edit.SetWindowText(strcat(tmp0, tmp1)); + edit.SetWindowText(_tcscat(tmp0, tmp1)); } //*************************************************************************************************************************** @@ -762,9 +762,9 @@ void CLocatedBindableDialog::updateZBias() { CString value; m_ZBias.GetWindowText(value); - float zbias = 0.f; + float zbias = 0.f; int dummy; // to test if end of string as no not wanted extra characters - if (sscanf((LPCTSTR) (value + "\n0"), "%f\n%d", &zbias, &dummy) == 2) + if (_stscanf((LPCTSTR)(value + _T("\n0")), _T("%f\n%d"), &zbias, &dummy) == 2) { NLMISC::safe_cast(_Bindable)->setZBias(-zbias); } @@ -773,8 +773,8 @@ void CLocatedBindableDialog::updateZBias() CString caption; CString mess; caption.LoadString(IDS_CAPTION_ERROR); - mess.LoadString(IDS_BAD_ZBIAS); - m_ZBias.SetWindowText("0.00"); + mess.LoadString(IDS_BAD_ZBIAS); + m_ZBias.SetWindowText(_T("0.00")); MessageBox((LPCTSTR) mess, (LPCTSTR) caption, MB_ICONERROR); NLMISC::safe_cast(_Bindable)->setZBias(0); updateModifiedFlag(); @@ -782,28 +782,28 @@ void CLocatedBindableDialog::updateZBias() } //*************************************************************************************************************************** -void CLocatedBindableDialog::OnChangeZbias() +void CLocatedBindableDialog::OnChangeZbias() { - UpdateData(); + UpdateData(); // Trick to track "Enter" keypress: CEdit are multiline. If GetLineCount()>1, then // user has press enter. if(m_ZBias.GetLineCount()>1) { // must ccat 2 lines of the CEdit. - concatEdit2Lines(m_ZBias); - updateZBias(); + concatEdit2Lines(m_ZBias); + updateZBias(); } } //*************************************************************************************************************************** -void CLocatedBindableDialog::OnKillfocusZbias() +void CLocatedBindableDialog::OnKillfocusZbias() { - updateZBias(); + updateZBias(); } //*************************************************************************************************************************** -void CLocatedBindableDialog::OnZalign() -{ +void CLocatedBindableDialog::OnZalign() +{ bool align = ((CButton *) GetDlgItem(IDC_ZALIGN))->GetCheck() != 0; NL3D::CPSFaceLookAt *fla = NLMISC::safe_cast(_Bindable); fla->setAlignOnZAxis(align); diff --git a/code/nel/tools/3d/object_viewer/located_properties.cpp b/code/nel/tools/3d/object_viewer/located_properties.cpp index 27ff466e1..b270e9d7f 100644 --- a/code/nel/tools/3d/object_viewer/located_properties.cpp +++ b/code/nel/tools/3d/object_viewer/located_properties.cpp @@ -322,7 +322,7 @@ void CLocatedProperties::goPostRender() _MaxNbParticles->update(); } // in all cases, show the current number of particles being used - GetDlgItem(IDC_CURR_NUM_PARTS)->SetWindowText(NLMISC::toString(_Located->getSize()).c_str()); + GetDlgItem(IDC_CURR_NUM_PARTS)->SetWindowText(utf8ToTStr(NLMISC::toString(_Located->getSize()))); } //**************************************************************************************************************** diff --git a/code/nel/tools/3d/object_viewer/located_target_dlg.cpp b/code/nel/tools/3d/object_viewer/located_target_dlg.cpp index 9cb9fced1..03fcb226c 100644 --- a/code/nel/tools/3d/object_viewer/located_target_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/located_target_dlg.cpp @@ -112,8 +112,8 @@ void CLocatedTargetDlg::OnAddTarget() nlassert(loc); _LBTarget->attachTarget(loc); m_AvailableTargets.DeleteString(indexs[k] - k); - int l = m_Targets.AddString(loc->getName().c_str()); - m_Targets.SetItemData(l, (DWORD) loc); + int l = m_Targets.AddString(utf8ToTStr(loc->getName())); + m_Targets.SetItemData(l, (DWORD_PTR) loc); } UpdateData(FALSE); // @@ -135,9 +135,9 @@ void CLocatedTargetDlg::OnRemoveTarget() nlassert(loc); _LBTarget->detachTarget(loc); m_Targets.DeleteString(indexs[k] - k); - int l = m_AvailableTargets.AddString(loc->getName().c_str()); + int l = m_AvailableTargets.AddString(utf8ToTStr(loc->getName())); - m_AvailableTargets.SetItemData(l, (DWORD) loc); + m_AvailableTargets.SetItemData(l, (DWORD_PTR) loc); } UpdateData(FALSE); updateModifiedFlag(); @@ -159,8 +159,8 @@ BOOL CLocatedTargetDlg::OnInitDialog() // fill the box thta tells us what the target are for(k = 0; k < nbTarg; ++k) { - m_Targets.AddString(_LBTarget->getTarget(k)->getName().c_str() ); - m_Targets.SetItemData(k, (DWORD) _LBTarget->getTarget(k) ); + m_Targets.AddString(utf8ToTStr(_LBTarget->getTarget(k)->getName())); + m_Targets.SetItemData(k, (DWORD_PTR) _LBTarget->getTarget(k)); targetSet.insert(_LBTarget->getTarget(k)); }; @@ -179,13 +179,12 @@ BOOL CLocatedTargetDlg::OnInitDialog() { if (targetSet.find(loc) == targetSet.end()) { - int l = m_AvailableTargets.AddString(loc->getName().c_str() ); - m_AvailableTargets.SetItemData(l, (DWORD) loc ); + int l = m_AvailableTargets.AddString(utf8ToTStr(loc->getName())); + m_AvailableTargets.SetItemData(l, (DWORD_PTR) loc); } } } - const sint posX = 5; sint posY = 180; @@ -227,7 +226,7 @@ BOOL CLocatedTargetDlg::OnInitDialog() rv->init(posX + 140, posY, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Radial viscosity : ", SS_LEFT, CRect(posX, posY, posX + 139, posY + 32), this); + s->Create(_T("Radial viscosity : "), SS_LEFT, CRect(posX, posY, posX + 139, posY + 32), this); s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); @@ -243,7 +242,7 @@ BOOL CLocatedTargetDlg::OnInitDialog() s = new CStatic; pushWnd(s); - s->Create("Tangential Viscosity : ", SS_LEFT, CRect(posX, posY, posX + 139, posY + 32), this); + s->Create(_T("Tangential Viscosity : "), SS_LEFT, CRect(posX, posY, posX + 139, posY + 32), this); s->ShowWindow(SW_SHOW); tv->GetClientRect(&r); @@ -273,7 +272,7 @@ BOOL CLocatedTargetDlg::OnInitDialog() rv->init(posX + 140, posY, this); CStatic *s = new CStatic; pushWnd(s); - s->Create("Parametric factor : ", SS_LEFT, CRect(posX, posY, posX + 139, posY + 40), this); + s->Create(_T("Parametric factor : "), SS_LEFT, CRect(posX, posY, posX + 139, posY + 40), this); s->SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); s->ShowWindow(SW_SHOW); diff --git a/code/nel/tools/3d/object_viewer/main_frame.cpp b/code/nel/tools/3d/object_viewer/main_frame.cpp index d063e202d..aa24efa36 100644 --- a/code/nel/tools/3d/object_viewer/main_frame.cpp +++ b/code/nel/tools/3d/object_viewer/main_frame.cpp @@ -293,41 +293,41 @@ void CMainFrame::registerValue (bool read) DWORD len=sizeof (BOOL); DWORD type; NLMISC::CRGBA bgCol ; - RegQueryValueEx (hKey, "ViewAnimation", 0, &type, (LPBYTE)&AnimationWindow, &len); + RegQueryValueEx (hKey, _T("ViewAnimation"), 0, &type, (LPBYTE)&AnimationWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewAnimationSet", 0, &type, (LPBYTE)&AnimationSetWindow, &len); + RegQueryValueEx (hKey, _T("ViewAnimationSet"), 0, &type, (LPBYTE)&AnimationSetWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewSlots", 0, &type, (LPBYTE)&MixerSlotsWindow, &len); + RegQueryValueEx (hKey, _T("ViewSlots"), 0, &type, (LPBYTE)&MixerSlotsWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewParticles", 0, &type, (LPBYTE)&ParticlesWindow, &len); + RegQueryValueEx (hKey, _T("ViewParticles"), 0, &type, (LPBYTE)&ParticlesWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewDayNight", 0, &type, (LPBYTE)&DayNightWindow, &len); + RegQueryValueEx (hKey, _T("ViewDayNight"), 0, &type, (LPBYTE)&DayNightWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewWaterPool", 0, &type, (LPBYTE)&WaterPoolWindow, &len); + RegQueryValueEx (hKey, _T("ViewWaterPool"), 0, &type, (LPBYTE)&WaterPoolWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewVegetable", 0, &type, (LPBYTE)&VegetableWindow, &len); + RegQueryValueEx (hKey, _T("ViewVegetable"), 0, &type, (LPBYTE)&VegetableWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewGlobalWind", 0, &type, (LPBYTE)&GlobalWindWindow, &len); + RegQueryValueEx (hKey, _T("ViewGlobalWind"), 0, &type, (LPBYTE)&GlobalWindWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewSoundAnimWind", 0, &type, (LPBYTE)&GlobalWindWindow, &len); + RegQueryValueEx (hKey, _T("ViewSoundAnimWind"), 0, &type, (LPBYTE)&GlobalWindWindow, &len); len=sizeof (float); - RegQueryValueEx (hKey, "MoveSpeed", 0, &type, (LPBYTE)&MoveSpeed, &len); + RegQueryValueEx (hKey, _T("MoveSpeed"), 0, &type, (LPBYTE)&MoveSpeed, &len); len=sizeof (uint); - RegQueryValueEx (hKey, "ObjectMode", 0, &type, (LPBYTE)&MoveMode, &len); + RegQueryValueEx (hKey, _T("ObjectMode"), 0, &type, (LPBYTE)&MoveMode, &len); len=sizeof(NLMISC::CRGBA) ; - RegQueryValueEx (hKey, "BackGroundColor", 0, &type, (LPBYTE)&BgColor, &len); + RegQueryValueEx (hKey, _T("BackGroundColor"), 0, &type, (LPBYTE)&BgColor, &len); len=sizeof (float); - RegQueryValueEx (hKey, "GlobalWindPower", 0, &type, (LPBYTE)&GlobalWindPower, &len); + RegQueryValueEx (hKey, _T("GlobalWindPower"), 0, &type, (LPBYTE)&GlobalWindPower, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewChooseFrameDelay", 0, &type, (LPBYTE)&ChooseFrameDelayWindow, &len); + RegQueryValueEx (hKey, _T("ViewChooseFrameDelay"), 0, &type, (LPBYTE)&ChooseFrameDelayWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewChooseBGColor", 0, &type, (LPBYTE)&ChooseBGColorWindow, &len); + RegQueryValueEx (hKey, _T("ViewChooseBGColor"), 0, &type, (LPBYTE)&ChooseBGColorWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewChooseSunColor", 0, &type, (LPBYTE)&ChooseSunColorWindow, &len); + RegQueryValueEx (hKey, _T("ViewChooseSunColor"), 0, &type, (LPBYTE)&ChooseSunColorWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewSkeletonScaleWindow", 0, &type, (LPBYTE)&SkeletonScaleWindow, &len); + RegQueryValueEx (hKey, _T("ViewSkeletonScaleWindow"), 0, &type, (LPBYTE)&SkeletonScaleWindow, &len); len=sizeof (BOOL); - RegQueryValueEx (hKey, "ViewTuneMRMWindow", 0, &type, (LPBYTE)&TuneMRMWindow, &len); + RegQueryValueEx (hKey, _T("ViewTuneMRMWindow"), 0, &type, (LPBYTE)&TuneMRMWindow, &len); } } else @@ -335,26 +335,26 @@ void CMainFrame::registerValue (bool read) HKEY hKey; if (RegCreateKey(HKEY_CURRENT_USER, REGKEY_OBJ_VIEW_SCENE_DLG, &hKey)==ERROR_SUCCESS) { - RegSetValueEx(hKey, "ViewAnimation", 0, REG_BINARY, (LPBYTE)&AnimationWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewAnimationSet", 0, REG_BINARY, (LPBYTE)&AnimationSetWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewSlots", 0, REG_BINARY, (LPBYTE)&MixerSlotsWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewParticles", 0, REG_BINARY, (LPBYTE)&ParticlesWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewDayNight", 0, REG_BINARY, (LPBYTE)&DayNightWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewWaterPool", 0, REG_BINARY, (LPBYTE)&WaterPoolWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewDayNight", 0, REG_BINARY, (LPBYTE)&DayNightWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewVegetable", 0, REG_BINARY, (LPBYTE)&VegetableWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewGlobalWind", 0, REG_BINARY, (LPBYTE)&GlobalWindWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewSoundAnimWind", 0, REG_BINARY, (LPBYTE)&SoundAnimWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewLightGroupWind", 0, REG_BINARY, (LPBYTE)&LightGroupWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewChooseFrameDelay", 0, REG_BINARY, (LPBYTE)&ChooseFrameDelayWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewChooseBGColor", 0, REG_BINARY, (LPBYTE)&ChooseBGColorWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewChooseSunColor", 0, REG_BINARY, (LPBYTE)&ChooseSunColorWindow, sizeof(bool)); - RegSetValueEx(hKey, "MoveSpeed", 0, REG_BINARY, (LPBYTE)&MoveSpeed, sizeof(float)); - RegSetValueEx(hKey, "ObjectMode", 0, REG_BINARY, (LPBYTE)&MoveMode, sizeof(uint)); - RegSetValueEx(hKey, "BackGroundColor", 0, REG_BINARY, (LPBYTE)&BgColor, sizeof(NLMISC::CRGBA)); - RegSetValueEx(hKey, "GlobalWindPower", 0, REG_BINARY, (LPBYTE)&GlobalWindPower, sizeof(float)); - RegSetValueEx(hKey, "ViewSkeletonScaleWindow", 0, REG_BINARY, (LPBYTE)&SkeletonScaleWindow, sizeof(bool)); - RegSetValueEx(hKey, "ViewTuneMRMWindow", 0, REG_BINARY, (LPBYTE)&TuneMRMWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewAnimation"), 0, REG_BINARY, (LPBYTE)&AnimationWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewAnimationSet"), 0, REG_BINARY, (LPBYTE)&AnimationSetWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewSlots"), 0, REG_BINARY, (LPBYTE)&MixerSlotsWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewParticles"), 0, REG_BINARY, (LPBYTE)&ParticlesWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewDayNight"), 0, REG_BINARY, (LPBYTE)&DayNightWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewWaterPool"), 0, REG_BINARY, (LPBYTE)&WaterPoolWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewDayNight"), 0, REG_BINARY, (LPBYTE)&DayNightWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewVegetable"), 0, REG_BINARY, (LPBYTE)&VegetableWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewGlobalWind"), 0, REG_BINARY, (LPBYTE)&GlobalWindWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewSoundAnimWind"), 0, REG_BINARY, (LPBYTE)&SoundAnimWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewLightGroupWind"), 0, REG_BINARY, (LPBYTE)&LightGroupWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewChooseFrameDelay"), 0, REG_BINARY, (LPBYTE)&ChooseFrameDelayWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewChooseBGColor"), 0, REG_BINARY, (LPBYTE)&ChooseBGColorWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewChooseSunColor"), 0, REG_BINARY, (LPBYTE)&ChooseSunColorWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("MoveSpeed"), 0, REG_BINARY, (LPBYTE)&MoveSpeed, sizeof(float)); + RegSetValueEx(hKey, _T("ObjectMode"), 0, REG_BINARY, (LPBYTE)&MoveMode, sizeof(uint)); + RegSetValueEx(hKey, _T("BackGroundColor"), 0, REG_BINARY, (LPBYTE)&BgColor, sizeof(NLMISC::CRGBA)); + RegSetValueEx(hKey, _T("GlobalWindPower"), 0, REG_BINARY, (LPBYTE)&GlobalWindPower, sizeof(float)); + RegSetValueEx(hKey, _T("ViewSkeletonScaleWindow"), 0, REG_BINARY, (LPBYTE)&SkeletonScaleWindow, sizeof(bool)); + RegSetValueEx(hKey, _T("ViewTuneMRMWindow"), 0, REG_BINARY, (LPBYTE)&TuneMRMWindow, sizeof(bool)); } } } @@ -568,13 +568,13 @@ void CMainFrame::OnFileLoadconfig() update (); // Create a dialog - static char BASED_CODE szFilter[] = "NeL Object viewer config (*.ovcgf)|*.ovcgf|All Files (*.*)|*.*||"; - CFileDialog fileDlg( TRUE, ".ovcgf", "*.ovcgf", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("NeL Object viewer config (*.ovcgf)|*.ovcgf|All Files (*.*)|*.*||"); + CFileDialog fileDlg( TRUE, _T(".ovcgf"), _T("*.ovcgf"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal()==IDOK) { // Open the file CIFile file; - if (file.open ((const char*)fileDlg.GetPathName())) + if (file.open(tStrToUtf8(fileDlg.GetPathName()))) { try { @@ -590,17 +590,17 @@ void CMainFrame::OnFileLoadconfig() } } } - catch (Exception& e) + catch (const Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", (const char*)fileDlg.GetPathName()); - MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + CString msg; + msg.Format(_T("Can't open the file %s for reading."), (LPCTSTR)fileDlg.GetPathName()); + MessageBox (msg, _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -613,15 +613,15 @@ void CMainFrame::OnFileOpen() update (); // Create a dialog - static char BASED_CODE szFilter[] = - "All NeL Files (*.shape;*.ps;*.ig)\0*.shape;*.ps;*.ig\0" - "NeL Shape Files (*.shape)\0*.shape\0" - "NeL Particule System Files (*.ps)\0*.ps\0" - "NeL Instance Group Files (*.ig)\0*.ig\0" - "All Files (*.*)\0*.*\0\0"; + static TCHAR BASED_CODE szFilter[] = + _T("All NeL Files (*.shape;*.ps;*.ig)\0*.shape;*.ps;*.ig\0") + _T("NeL Shape Files (*.shape)\0*.shape\0") + _T("NeL Particule System Files (*.ps)\0*.ps\0") + _T("NeL Instance Group Files (*.ig)\0*.ig\0") + _T("All Files (*.*)\0*.*\0\0"); // Filename buffer - char buffer[65535]; + TCHAR buffer[65535]; buffer[0]=0; OPENFILENAME openFile; @@ -633,7 +633,7 @@ void CMainFrame::OnFileOpen() openFile.lpstrFile = buffer; openFile.nMaxFile = 65535; openFile.Flags = OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT|OFN_ENABLESIZING|OFN_EXPLORER; - openFile.lpstrDefExt = "*.shape;*.ig;*.ps"; + openFile.lpstrDefExt = _T("*.shape;*.ig;*.ps"); if (GetOpenFileName(&openFile)) @@ -642,7 +642,7 @@ void CMainFrame::OnFileOpen() std::vector meshFilename; // Filename pointer - char *c=buffer; + TCHAR *c=buffer; // Read the path CString path = buffer; @@ -652,7 +652,7 @@ void CMainFrame::OnFileOpen() c[path.GetLength()+1]=0; // Path is empty - path = ""; + path.Empty(); } else { @@ -682,10 +682,10 @@ void CMainFrame::OnFileOpen() CString name = path + filename; // file is an ig ? - if (name.Find(".ig") != -1) + if (name.Find(_T(".ig")) != -1) { // Load the instance group - if (ObjView->loadInstanceGroup (name)) + if (ObjView->loadInstanceGroup (tStrToUtf8(name))) { // Reset the camera OnResetCamera(); @@ -697,7 +697,7 @@ void CMainFrame::OnFileOpen() else { // Add it in the array - meshFilename.push_back ((const char*)name); + meshFilename.push_back (tStrToUtf8(name)); } } @@ -705,12 +705,12 @@ void CMainFrame::OnFileOpen() if ( !meshFilename.empty() ) { // Create a dialog for the skel - static char BASED_CODE szFilter2[] = "NeL Skeleton Files (*.skel)|*.skel|All Files (*.*)|*.*||"; - CFileDialog fileDlg2 ( TRUE, ".skel", "*.skel", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter2); + static TCHAR BASED_CODE szFilter2[] = _T("NeL Skeleton Files (*.skel)|*.skel|All Files (*.*)|*.*||"); + CFileDialog fileDlg2 ( TRUE, _T(".skel"), _T("*.skel"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter2); if (fileDlg2.DoModal()==IDOK) { // Load the shape with a skeleton - if (ObjView->loadMesh (meshFilename, fileDlg2.GetPathName())) + if (ObjView->loadMesh (meshFilename, tStrToUtf8(fileDlg2.GetPathName()))) { // Reset the camera OnResetCamera(); @@ -741,11 +741,11 @@ void CMainFrame::OnFileSaveconfig() update (); // Create a dialog - static char BASED_CODE szFilter[] = "NeL Object viewer config (*.ovcgf)|*.ovcgf|All Files (*.*)|*.*||"; - CFileDialog fileDlg( FALSE, ".ovcgf", "*.ovcgf", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("NeL Object viewer config (*.ovcgf)|*.ovcgf|All Files (*.*)|*.*||"); + CFileDialog fileDlg( FALSE, _T(".ovcgf"), _T("*.ovcgf"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal()==IDOK) { - ObjView->ParticleWorkspaceFilename = ""; + ObjView->ParticleWorkspaceFilename.clear(); CParticleWorkspace *pw = ObjView->getParticleDialog()->getParticleWorkspace(); if (pw && pw->getNumNode() != 0) { @@ -756,23 +756,23 @@ void CMainFrame::OnFileSaveconfig() } // Open the file COFile file; - if (file.open ((const char*)fileDlg.GetPathName())) + if (file.open (tStrToUtf8(fileDlg.GetPathName()))) { try { ObjView->serial(file); } - catch (Exception& e) + catch (const Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for writing", (const char*)fileDlg.GetPathName()); - MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + CString msg; + msg.Format(_T("Can't open the file %s for writing"), (LPCTSTR)fileDlg.GetPathName()); + MessageBox (msg, _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -832,7 +832,7 @@ void CMainFrame::OnViewSetmovespeed() if (valueDlg.DoModal ()==IDOK) { // Get deflaut value - sscanf ((const char*)valueDlg.Value, "%f", &MoveSpeed); + NLMISC::fromString(tStrToUtf8(valueDlg.Value), MoveSpeed); } } @@ -1154,7 +1154,7 @@ void CMainFrame::OnHelpAboutobjectviewer() ///=========================================================================================== void CMainFrame::OnRemoveAllInstancesFromScene() { - if (MessageBox("Delete all instances from scene ?", "Object Viewer", MB_YESNO) == IDYES) + if (MessageBox(_T("Delete all instances from scene ?"), _T("Object Viewer"), MB_YESNO) == IDYES) { ObjView->removeAllInstancesFromScene(); @@ -1392,9 +1392,10 @@ void CMainFrame::OnViewSetSceneRotation() if (sceneRotDlg.DoModal() == IDOK) { // read value. - _LastSceneRotX= (float)atof(sceneRotDlg.RotX); - _LastSceneRotY= (float)atof(sceneRotDlg.RotY); - _LastSceneRotZ= (float)atof(sceneRotDlg.RotZ); + NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotX), _LastSceneRotX); + NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotY), _LastSceneRotY); + NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotZ), _LastSceneRotZ); + float rotx= degToRad(_LastSceneRotX); float roty= degToRad(_LastSceneRotY); float rotz= degToRad(_LastSceneRotZ); @@ -1441,11 +1442,12 @@ void CMainFrame::OnUpdateSceneCamera(CCmdUI* pCmdUI) { CInstanceInfo *instance = ObjView->getInstance (ObjView->getCameraInstance (pCmdUI->m_nID - ID_SCENE_CAMERA_FIRST)); nlassert (instance->Camera); - pCmdUI->SetText (("Camera "+instance->Saved.ShapeFilename).c_str ()); + std::string text = NLMISC::toString("Camera %s", instance->Saved.ShapeFilename.c_str()); + pCmdUI->SetText(utf8ToTStr(text)); } else { - pCmdUI->SetText ("No camera"); + pCmdUI->SetText (_T("No camera")); } } diff --git a/code/nel/tools/3d/object_viewer/mesh_dlg.cpp b/code/nel/tools/3d/object_viewer/mesh_dlg.cpp index f0d62bd41..a35b7fe71 100644 --- a/code/nel/tools/3d/object_viewer/mesh_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/mesh_dlg.cpp @@ -90,34 +90,31 @@ void CMeshDlg::touchPSState() void CMeshDlg::OnBrowseShape() { - CFileDialog fd(TRUE, ".shape", "*.shape", 0, NULL, this); + CFileDialog fd(TRUE, _T(".shape"), _T("*.shape"), 0, NULL, this); if (fd.DoModal() == IDOK) { // Add to the path - char drive[256]; - char dir[256]; - char path[256]; - char fname[256]; - char ext[256]; - + std::string fullPath = tStrToUtf8(fd.GetPathName()); + std::string fname = NLMISC::CFile::getFilenameWithoutExtension(fullPath); + std::string ext = NLMISC::CFile::getExtension(fullPath); // Add search path for the texture - _splitpath (fd.GetPathName(), drive, dir, fname, ext); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(fullPath)); try { - _ShapeParticle->setShape(std::string(fname) + ext); - m_ShapeName = (std::string(fname) + ext).c_str(); + _ShapeParticle->setShape(fname + "." + ext); + m_ShapeName = utf8ToTStr(fname + "." + ext); touchPSState(); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { - MessageBox(e.what(), "shape loading error"); + MessageBox(utf8ToTStr(e.what()), _T("shape loading error")); } + updateMeshErrorString(); } + UpdateData(FALSE); } @@ -162,11 +159,11 @@ void CMeshDlg::updateForMorph() GetDlgItem(IDC_SHAPE_NAME)->EnableWindow(!enable); if (!enable) { - m_ShapeName = cm->getShape().c_str(); + m_ShapeName = utf8ToTStr(cm->getShape()); } else { - m_ShapeName = ""; + m_ShapeName.Empty(); } } updateMeshErrorString(); @@ -238,7 +235,7 @@ BOOL CMeshDlg::EnableWindow( BOOL bEnable) ///================================================================== void CMeshDlg::updateMeshErrorString() { - GetDlgItem(IDC_MESH_ERROR)->SetWindowText(""); + GetDlgItem(IDC_MESH_ERROR)->SetWindowText(_T("")); NL3D::CPSConstraintMesh *cm = dynamic_cast(_ShapeParticle); if (!cm) return; std::vector numVerts; diff --git a/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp b/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp index d2d08e2cc..58d67bd0b 100644 --- a/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp @@ -165,30 +165,30 @@ void CMultiTexDlg::readValues(bool alternate) char buf[128]; if (!alternate) { - sprintf(buf, "%.3f", _MTP->getScrollSpeed(0).x); GetDlgItem(IDC_U_SPEED_1)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getScrollSpeed(0).y); GetDlgItem(IDC_V_SPEED_1)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getScrollSpeed(1).x); GetDlgItem(IDC_U_SPEED_2)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getScrollSpeed(1).y); GetDlgItem(IDC_V_SPEED_2)->SetWindowText(buf); + GetDlgItem(IDC_U_SPEED_1)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).x))); + GetDlgItem(IDC_V_SPEED_1)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).y))); + GetDlgItem(IDC_U_SPEED_2)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).x))); + GetDlgItem(IDC_V_SPEED_2)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).y))); } else { if (_MTP->isAlternateTexEnabled()) { - sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(0).x); GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(0).y); GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(1).x); GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(buf); - sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(1).y); GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(buf); + GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).x))); + GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).y))); + GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).x))); + GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).y))); } else { - GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(""); - GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(""); - GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(""); - GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(""); + GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(_T("")); + GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(_T("")); + GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(_T("")); + GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(_T("")); } } - sprintf(buf, "%.3f", _MTP->getBumpFactor()); GetDlgItem(IDC_BUMP_FACTOR)->SetWindowText(buf); + GetDlgItem(IDC_BUMP_FACTOR)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getBumpFactor()))); } @@ -204,10 +204,9 @@ void CMultiTexDlg::updateBumpFactorEnabled() //====================================================== void CMultiTexDlg::writeValues(bool alternate) { - char u1[10], u2[10], v1[10], v2[10]; + TCHAR u1[10], u2[10], v1[10], v2[10]; NLMISC::CVector2f vs1, vs2; - if (!alternate) { GetDlgItem(IDC_U_SPEED_1)->GetWindowText(u1, 10); @@ -215,10 +214,10 @@ void CMultiTexDlg::writeValues(bool alternate) GetDlgItem(IDC_U_SPEED_2)->GetWindowText(u2, 10); GetDlgItem(IDC_V_SPEED_2)->GetWindowText(v2, 10); - if (sscanf(u1, "%f", &vs1.x) == 1 && - sscanf(v1, "%f", &vs1.y) == 1 && - sscanf(u2, "%f", &vs2.x) == 1 && - sscanf(v2, "%f", &vs2.y) == 1) + if (_stscanf(u1, _T("%f"), &vs1.x) == 1 && + _stscanf(v1, _T("%f"), &vs1.y) == 1 && + _stscanf(u2, _T("%f"), &vs2.x) == 1 && + _stscanf(v2, _T("%f"), &vs2.y) == 1) { _MTP->setScrollSpeed(0, vs1); _MTP->setScrollSpeed(1, vs2); @@ -226,7 +225,7 @@ void CMultiTexDlg::writeValues(bool alternate) } else { - MessageBox("Invalid value(s)", "Error", MB_OK | MB_ICONEXCLAMATION); + MessageBox(_T("Invalid value(s)"), _T("Error"), MB_OK | MB_ICONEXCLAMATION); } } else @@ -237,10 +236,10 @@ void CMultiTexDlg::writeValues(bool alternate) GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->GetWindowText(v1, 10); GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->GetWindowText(u2, 10); GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->GetWindowText(v2, 10); - if (sscanf(u1, "%f", &vs1.x) == 1 && - sscanf(v1, "%f", &vs1.y) == 1 && - sscanf(u2, "%f", &vs2.x) == 1 && - sscanf(v2, "%f", &vs2.y) == 1) + if (_stscanf(u1, _T("%f"), &vs1.x) == 1 && + _stscanf(v1, _T("%f"), &vs1.y) == 1 && + _stscanf(u2, _T("%f"), &vs2.x) == 1 && + _stscanf(v2, _T("%f"), &vs2.y) == 1) { _MTP->setAlternateScrollSpeed(0, vs1); _MTP->setAlternateScrollSpeed(1, vs2); @@ -249,10 +248,10 @@ void CMultiTexDlg::writeValues(bool alternate) } } - char bumpFactorTxt[10]; + TCHAR bumpFactorTxt[10]; float bumpFactor; GetDlgItem(IDC_BUMP_FACTOR)->GetWindowText(bumpFactorTxt, 10); - if (sscanf(bumpFactorTxt, "%f", &bumpFactor) == 1) + if (_stscanf(bumpFactorTxt, _T("%f"), &bumpFactor) == 1) { _MTP->setBumpFactor(bumpFactor); updateModifiedFlag(); diff --git a/code/nel/tools/3d/object_viewer/object_viewer.cpp b/code/nel/tools/3d/object_viewer/object_viewer.cpp index c6f163146..2835b9b42 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer/object_viewer.cpp @@ -93,8 +93,7 @@ using namespace NLPACS; -static char SDrive[256]; -static char SDir[256]; +static std::string SPath; uint SkeletonUsedForSound = 0xFFFFFFFF; CSoundContext SoundContext; @@ -281,12 +280,13 @@ std::string CObjectViewer::getModulePath() const HMODULE hModule = AfxGetInstanceHandle(); nlassert(hModule); // shouldn't be null now anymore in any case nlassert(hModule != GetModuleHandle(NULL)); // if this is dll, the module handle can't be same as exe - char sModulePath[256]; + TCHAR sModulePath[256]; int res = GetModuleFileName(hModule, sModulePath, 256); nlassert(res); nldebug("Object viewer module path is '%s'", sModulePath); - _splitpath (sModulePath, SDrive, SDir, NULL, NULL); - _makepath (sModulePath, SDrive, SDir, "object_viewer", ".cfg"); - return sModulePath; + + SPath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)); + + return SPath + "object_viewer.cfg"; } @@ -317,7 +317,7 @@ void CObjectViewer::loadConfigFile() for (uint i=0; i<(uint)search_pathes.size(); i++) CPath::addSearchPath (search_pathes.asString(i)); } - catch(EUnknownVar &) + catch(const EUnknownVar &) {} try @@ -327,7 +327,7 @@ void CObjectViewer::loadConfigFile() for (uint i=0; i<(uint)recursive_search_pathes.size(); i++) CPath::addSearchPath (recursive_search_pathes.asString(i), true, false); } - catch(EUnknownVar &) + catch(const EUnknownVar &) {} // Add extension remapping @@ -344,7 +344,7 @@ void CObjectViewer::loadConfigFile() CPath::remapExtension(extensions_remapping.asString(i), extensions_remapping.asString(i+1), true); } } - catch (EUnknownVar &) + catch (const EUnknownVar &) { } @@ -381,7 +381,7 @@ void CObjectViewer::loadConfigFile() for (uint i=0; i<(uint)var.size(); i++) CSoundSystem::addSampleBank(var.asString(i).c_str());*/ } - catch (EUnknownVar &) + catch (const EUnknownVar &) { //::MessageBox(NULL, "warning : 'sample_path' or 'packed_sheet_path' variable not defined.\nSound will not work properly.", "Objectviewer.cfg", MB_OK|MB_ICONEXCLAMATION); } @@ -392,7 +392,7 @@ void CObjectViewer::loadConfigFile() CConfigFile::CVar &camera_focal = cf.getVar("camera_focal"); _CameraFocal = camera_focal.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { } @@ -403,7 +403,7 @@ void CObjectViewer::loadConfigFile() CConfigFile::CVar &var = cf.getVar("scene_light_enabled"); _SceneLightEnabled = var.asInt() !=0 ; } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _SceneLightEnabled= false; } @@ -414,7 +414,7 @@ void CObjectViewer::loadConfigFile() _SceneLightSunAmbiant.G = var.asInt(1); _SceneLightSunAmbiant.B = var.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _SceneLightSunAmbiant= NLMISC::CRGBA::Black; } @@ -425,7 +425,7 @@ void CObjectViewer::loadConfigFile() _SceneLightSunDiffuse.G = var.asInt(1); _SceneLightSunDiffuse.B = var.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _SceneLightSunDiffuse= NLMISC::CRGBA::White; } @@ -436,7 +436,7 @@ void CObjectViewer::loadConfigFile() _SceneLightSunSpecular.G = var.asInt(1); _SceneLightSunSpecular.B = var.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _SceneLightSunSpecular= NLMISC::CRGBA::White; } @@ -448,7 +448,7 @@ void CObjectViewer::loadConfigFile() _SceneLightSunDir.z = var.asFloat(2); _SceneLightSunDir.normalize(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _SceneLightSunDir.set(0, 1, -1); _SceneLightSunDir.normalize(); @@ -458,7 +458,7 @@ void CObjectViewer::loadConfigFile() CConfigFile::CVar &var = cf.getVar("object_light_test"); _ObjectLightTestShape= var.asString(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { } @@ -469,7 +469,7 @@ void CObjectViewer::loadConfigFile() try { CConfigFile::CVar &var = cf.getVar("automatic_animation_path"); - std::auto_ptr as(new CAnimationSet); + CUniquePtr as(new CAnimationSet); // bool loadingOk = as->loadFromFiles(var.asString(),true ,"anim",true); // @@ -480,7 +480,7 @@ void CObjectViewer::loadConfigFile() } CNELU::Scene->setAutomaticAnimationSet(as.release()); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { //::MessageBox(NULL, "No automatic animation path specified, please set 'automatic_animation_path'", "warning", MB_OK); nlwarning("No automatic animation path specified"); @@ -492,7 +492,7 @@ void CObjectViewer::loadConfigFile() CConfigFile::CVar &var = cf.getVar("character_scale_pos"); _CharacterScalePos= var.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { } @@ -533,9 +533,9 @@ void CObjectViewer::loadConfigFile() if (var = cf.getVarPtr("cloud_wind_speed")) _CSS.WindSpeed = var->asFloat(); } - catch (Exception& e) + catch (const Exception& e) { - ::MessageBox (NULL, e.what(), "Objectviewer.cfg", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox (NULL, utf8ToTStr(e.what()), _T("Objectviewer.cfg"), MB_OK|MB_ICONEXCLAMATION); } } @@ -615,14 +615,14 @@ bool CObjectViewer::initUI (HWND parent) // The windows path uint dSize = ::GetWindowsDirectory(NULL, 0); nlverify(dSize); - char *wd = new char[dSize]; + + TCHAR *wd = new TCHAR[dSize]; nlverify(::GetWindowsDirectory(wd, dSize)); - _FontPath=wd; - _FontPath+="\\fonts\\arial.ttf"; + _FontPath = tStrToUtf8(wd) + "\\fonts\\arial.ttf"; + delete[] wd; // The font generator _FontGenerator = NL3D::newCFontGenerator ( _FontPath ); - delete[] wd; // The viewport CViewport viewport; @@ -654,7 +654,7 @@ bool CObjectViewer::initUI (HWND parent) // Create the window _MainFrame->CFrameWnd::Create (AfxRegisterWndClass(0, 0, NULL, hIcon), - "NeL object viewer", 0x00cfc000, /*WS_OVERLAPPEDWINDOW,*/ CFrameWnd::rectDefault, parentWndPtr, + _T("NeL object viewer"), 0x00cfc000, /*WS_OVERLAPPEDWINDOW,*/ CFrameWnd::rectDefault, parentWndPtr, MAKEINTRESOURCE(IDR_OBJECT_VIEWER_MENU), 0x00000300 /*WS_EX_ACCEPTFILES*/ /*|WS_EX_CLIENTEDGE*/); // Detach the hwnd @@ -811,34 +811,36 @@ bool CObjectViewer::initUI (HWND parent) // Enable sum of vram CNELU::Driver->enableUsedTextureMemorySum (); - char sModulePath[256]; // load the scheme bank if one is present CIFile iF; - ::_makepath (sModulePath, SDrive, SDir, "default", ".scb"); - if (iF.open(sModulePath)) + std::string path = SPath + "default.scb"; + if (iF.open(path)) { try { iF.serial(SchemeManager); } - catch (NLMISC::EStream &e) + catch (const NLMISC::EStream &e) { - ::MessageBox(NULL, ("Unable to load the default scheme bank file : " + std::string(e.what())).c_str(), "Object Viewer", MB_ICONEXCLAMATION); + std::string msg = toString("Unable to load the default scheme bank file : %s", e.what()); + ::MessageBox(NULL, utf8ToTStr(msg), _T("Object Viewer"), MB_ICONEXCLAMATION); } } iF.close(); // try to load a default config file for the viewer (for anitmation and particle edition setup) - ::_makepath (sModulePath, SDrive, SDir, "default", ".ovcgf"); - if (iF.open (sModulePath)) + path = SPath + "default.ovcgf"; + + if (iF.open (path)) { try { serial (iF); } - catch (Exception& e) + catch (const Exception& e) { - ::MessageBox (NULL, (std::string("error while loading default.ovcgf : ") + e.what()).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = toString("Error while loading default.ovcgf : %s", e.what()); + ::MessageBox (NULL, utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } @@ -1286,7 +1288,6 @@ void CObjectViewer::go () sint64 timeDiff = newTime - lastTime; float fps = timeDiff > 0 ? (float)(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime)) : 1000.0f; lastTime=newTime; - char msgBar[1024]; uint nbPlayingSources, nbSources; if (CSoundSystem::getAudioMixer()) { @@ -1299,30 +1300,32 @@ void CObjectViewer::go () } // Display std info. - sprintf (msgBar, "%s - Nb tri: %d -Texture used (Mo): %5.2f - Texture allocated (Mo): %5.2f - Distance: %5.0f - Sounds: %d/%d - Fps: %03.1f", - _Direct3d?"Direct3d":"OpenGL", - in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips, (float)CNELU::Driver->getUsedTextureMemory () / (float)(1024*1024), - (float)CNELU::Driver->profileAllocatedTextureMemory () / (float)(1024*1024), - (_SceneCenter-CNELU::Camera->getMatrix().getPos()).norm(), - nbPlayingSources, - nbSources, - fps - ); + std::string msgBar = toString("%s - Nb tri: %u - Texture used (MiB): %5.2f - Texture allocated (MiB): %5.2f - Distance: %5.0f - Sounds: %u/%u - Fps: %03.1f", + _Direct3d ? "Direct3d":"OpenGL", + in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips, + (float)CNELU::Driver->getUsedTextureMemory () / (float)(1024*1024), + (float)CNELU::Driver->profileAllocatedTextureMemory () / (float)(1024*1024), + (_SceneCenter-CNELU::Camera->getMatrix().getPos()).norm(), + nbPlayingSources, + nbSources, + fps + ); + // Display - _MainFrame->StatusBar.SetWindowText (msgBar); + _MainFrame->StatusBar.SetWindowText (utf8ToTStr(msgBar)); // Display Vegetable info. if(_VegetableDlg!=NULL) { if(_VegetableLandscape != NULL) { - char vegetMsgBar[1024]; - sprintf (vegetMsgBar, "%d", _VegetableLandscape->Landscape.getNumVegetableFaceRendered()); + CString vegetMsgBar; + vegetMsgBar.Format(_T("%u"), _VegetableLandscape->Landscape.getNumVegetableFaceRendered()); _VegetableDlg->StaticPolyCount.SetWindowText(vegetMsgBar); } else { - _VegetableDlg->StaticPolyCount.SetWindowText("0"); + _VegetableDlg->StaticPolyCount.SetWindowText(_T("0")); } } @@ -1564,23 +1567,23 @@ void CObjectViewer::releaseUI () // *************************************************************************** -void setRegisterWindowState (const CWnd *pWnd, const char* keyName) +void setRegisterWindowState (const CWnd *pWnd, const TCHAR* keyName) { HKEY hKey; if (RegCreateKey(HKEY_CURRENT_USER, keyName, &hKey)==ERROR_SUCCESS) { RECT rect; pWnd->GetWindowRect (&rect); - RegSetValueEx(hKey, "Left", 0, REG_DWORD, (LPBYTE)&rect.left, 4); - RegSetValueEx(hKey, "Right", 0, REG_DWORD, (LPBYTE)&rect.right, 4); - RegSetValueEx(hKey, "Top", 0, REG_DWORD, (LPBYTE)&rect.top, 4); - RegSetValueEx(hKey, "Bottom", 0, REG_DWORD, (LPBYTE)&rect.bottom, 4); + RegSetValueEx(hKey, _T("Left"), 0, REG_DWORD, (LPBYTE)&rect.left, 4); + RegSetValueEx(hKey, _T("Right"), 0, REG_DWORD, (LPBYTE)&rect.right, 4); + RegSetValueEx(hKey, _T("Top"), 0, REG_DWORD, (LPBYTE)&rect.top, 4); + RegSetValueEx(hKey, _T("Bottom"), 0, REG_DWORD, (LPBYTE)&rect.bottom, 4); } } // *************************************************************************** -void getRegisterWindowState (CWnd *pWnd, const char* keyName, bool resize) +void getRegisterWindowState (CWnd *pWnd, const TCHAR* keyName, bool resize) { HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER, keyName, 0, KEY_READ, &hKey)==ERROR_SUCCESS) @@ -1588,10 +1591,10 @@ void getRegisterWindowState (CWnd *pWnd, const char* keyName, bool resize) DWORD len=4; DWORD type; RECT rect; - RegQueryValueEx (hKey, "Left", 0, &type, (LPBYTE)&rect.left, &len); - RegQueryValueEx (hKey, "Right", 0, &type, (LPBYTE)&rect.right, &len); - RegQueryValueEx (hKey, "Top", 0, &type, (LPBYTE)&rect.top, &len); - RegQueryValueEx (hKey, "Bottom", 0, &type, (LPBYTE)&rect.bottom, &len); + RegQueryValueEx (hKey, _T("Left"), 0, &type, (LPBYTE)&rect.left, &len); + RegQueryValueEx (hKey, _T("Right"), 0, &type, (LPBYTE)&rect.right, &len); + RegQueryValueEx (hKey, _T("Top"), 0, &type, (LPBYTE)&rect.top, &len); + RegQueryValueEx (hKey, _T("Bottom"), 0, &type, (LPBYTE)&rect.bottom, &len); // Set window pos pWnd->SetWindowPos (NULL, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_NOOWNERZORDER|SWP_NOZORDER| @@ -1619,7 +1622,7 @@ void CObjectViewer::resetSlots (uint instance) // Set no animation in slot UI for (uint j=0; jSaved.SlotInfo[j].Animation = ""; + _ListInstance[instance]->Saved.SlotInfo[j].Animation.clear(); // Reset the animation list _ListInstance[instance]->Saved.AnimationFileName.clear (); @@ -1739,7 +1742,7 @@ void CObjectViewer::serial (NLMISC::IStream& f) { if (ver <=3) { - ParticleWorkspaceFilename = ""; + ParticleWorkspaceFilename.clear(); } // First instance uint firstInstance = (uint)_ListInstance.size(); @@ -1782,17 +1785,16 @@ void CObjectViewer::serial (NLMISC::IStream& f) { // Add the mesh if (readed[i].SkeletonId != 0xffffffff) - instance = addMesh (serialShape.getShapePointer(), readed[i].ShapeFilename.c_str(), readed[i].SkeletonId + firstInstance, (readed[i].BindBoneName=="")?NULL:readed[i].BindBoneName.c_str()); + instance = addMesh (serialShape.getShapePointer(), readed[i].ShapeFilename.c_str(), readed[i].SkeletonId + firstInstance, (readed[i].BindBoneName.empty())?NULL:readed[i].BindBoneName.c_str()); else - instance = addMesh (serialShape.getShapePointer(), readed[i].ShapeFilename.c_str(), 0xffffffff, (readed[i].BindBoneName=="")?NULL:readed[i].BindBoneName.c_str()); + instance = addMesh (serialShape.getShapePointer(), readed[i].ShapeFilename.c_str(), 0xffffffff, (readed[i].BindBoneName.empty())?NULL:readed[i].BindBoneName.c_str()); } } else { // Error message - char message[512]; - smprintf (message, 512, "File not found %s", readed[i].ShapeFilename.c_str()); - _MainFrame->MessageBox (message, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string message = toString("File not found %s", readed[i].ShapeFilename.c_str()); + _MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); // Stop loading break; @@ -1823,12 +1825,11 @@ void CObjectViewer::serial (NLMISC::IStream& f) for (uint slot=0; slotSaved.SlotInfo[slot] = readed[i].SlotInfo[slot]; } - catch (Exception &e) + catch (const Exception &e) { // Error message - char message[512]; - smprintf (message, 512, "Error loading shape %s: %s", readed[i].ShapeFilename.c_str(), e.what()); - _MainFrame->MessageBox (message, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string message = toString("Error loading shape %s: %s", readed[i].ShapeFilename.c_str(), e.what()); + _MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); // Stop loading break; @@ -1872,27 +1873,19 @@ void CObjectViewer::serial (NLMISC::IStream& f) // *************************************************************************** -bool CObjectViewer::loadInstanceGroup(const char *igFilename) +bool CObjectViewer::loadInstanceGroup(const std::string &igFilename) { //AFX_MANAGE_STATE(AfxGetStaticModuleState()); - // Add to the path - char drive[256]; - char dir[256]; - char path[256]; - // Add search path for the mesh - _splitpath (igFilename, drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); - CPath::addSearchPath (path); - + CPath::addSearchPath (NLMISC::CFile::getPath(igFilename)); // Open a file CIFile file; if (file.open (igFilename)) { // Shape pointer - NL3D::CInstanceGroup *ig= new NL3D::CInstanceGroup; + NL3D::CInstanceGroup *ig = new NL3D::CInstanceGroup; try { @@ -1902,20 +1895,19 @@ bool CObjectViewer::loadInstanceGroup(const char *igFilename) // Append the ig. addInstanceGroup(ig); } - catch (Exception& e) + catch (const Exception& e) { // clean delete ig; - _MainFrame->MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + _MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); return false; } } else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", igFilename); - _MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = toString("Can't open the file %s for reading.", igFilename.c_str()); + _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); return false; } @@ -1928,21 +1920,16 @@ bool CObjectViewer::loadInstanceGroup(const char *igFilename) // *************************************************************************** -bool CObjectViewer::loadMesh (std::vector &meshFilename, const char* skeleton) +bool CObjectViewer::loadMesh (std::vector &meshFilename, const std::string &skeleton) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Add to the path - char drive[256]; - char dir[256]; - char path[256]; // Add search path for the skeleton - if (skeleton) + if (skeleton.empty()) { - _splitpath (skeleton, drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); - CPath::addSearchPath (path); + CPath::addSearchPath (NLMISC::CFile::getPath(skeleton)); } // Open a file @@ -1957,7 +1944,7 @@ bool CObjectViewer::loadMesh (std::vector &meshFilename, const char bool skelError=false; // Continue ? - if (skeleton&&(strcmp (skeleton, "")!=0)) + if (!skeleton.empty()) { // Open a file @@ -1973,9 +1960,9 @@ bool CObjectViewer::loadMesh (std::vector &meshFilename, const char // Add the shape shapeSkel=streamShape.getShapePointer(); } - catch (Exception& e) + catch (const Exception& e) { - _MainFrame->MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + _MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); // error skelError=true; @@ -1984,9 +1971,8 @@ bool CObjectViewer::loadMesh (std::vector &meshFilename, const char else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", meshFilename); - _MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("Can't open the file %s for reading.", skeleton.c_str()); + _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); // error skelError=true; @@ -2007,12 +1993,10 @@ bool CObjectViewer::loadMesh (std::vector &meshFilename, const char for (uint i=0; i &meshFilename, const char // Add the shape shapeMesh=streamShape.getShapePointer(); } - catch (Exception& e) + catch (const Exception& e) { - _MainFrame->MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + _MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); continue; } } else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", fileName); - _MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str()); + _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); continue; } @@ -2097,7 +2080,7 @@ void CObjectViewer::resetCamera () // *************************************************************************** -uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const char* meshName, uint skelIndex, const char* bindSkelName, bool createInstance) +uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const std::string &meshName, uint skelIndex, const char* bindSkelName, bool createInstance) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); @@ -2167,7 +2150,7 @@ uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const char* meshName, uin { // Bind bone name uint bindBone = 0xffffffff; - std::string boneName = ""; + std::string boneName; // Name is passed, look for bone if (bindSkelName) @@ -2195,8 +2178,7 @@ uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const char* meshName, uin listBones.push_back (transformSkel->Bones[bone].getBoneName()); // Get name of the mesh - char nameMesh[512]; - _splitpath (meshName, NULL, NULL, nameMesh, NULL); + std::string nameMesh = NLMISC::CFile::getFilenameWithoutExtension(meshName); // Select a bones std::string message = "Select a bone to stick " + string (nameMesh); @@ -2280,7 +2262,7 @@ bool CObjectViewer::isSkeletonPresent() const // *************************************************************************** -uint CObjectViewer::addCamera (const NL3D::CCameraInfo &cameraInfo, const char* cameraName) +uint CObjectViewer::addCamera (const NL3D::CCameraInfo &cameraInfo, const std::string &cameraName) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); @@ -2315,7 +2297,7 @@ uint CObjectViewer::addCamera (const NL3D::CCameraInfo &cameraInfo, const char* // *************************************************************************** -uint CObjectViewer::addSkel (NL3D::IShape* pSkelShape, const char* skelName) +uint CObjectViewer::addSkel (NL3D::IShape* pSkelShape, const std::string &skelName) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); @@ -2380,7 +2362,7 @@ IObjectViewer* IObjectViewer::getInterface (int version) // Check version number if (version!=OBJECT_VIEWER_VERSION) { - MessageBox (NULL, "Bad version of object_viewer.dll.", "NeL object viewer", MB_ICONEXCLAMATION|MB_OK); + MessageBox (NULL, _T("Bad version of object_viewer.dll."), _T("NeL object viewer"), MB_ICONEXCLAMATION|MB_OK); return NULL; } else @@ -2398,7 +2380,7 @@ void IObjectViewer::releaseInterface (IObjectViewer* view) // *************************************************************************** -void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const char* name, uint instance) +void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const std::string &name, uint instance) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); @@ -2408,7 +2390,7 @@ void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const char* nam _SelectedObject = instance; // Add the animation - addAnimation (pAnim, (name+std::string(".anim")).c_str(), name, instance); + addAnimation (pAnim, name + ".anim", name, instance); // Add the animation to the animationSet _AnimationSetDlg->UpdateData (TRUE); @@ -2417,7 +2399,7 @@ void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const char* nam // Set the animation in the first slot _ListInstance[instance]->Saved.SlotInfo[0].Animation = name; - _ListInstance[instance]->Saved.SlotInfo[0].Skeleton = ""; + _ListInstance[instance]->Saved.SlotInfo[0].Skeleton.clear(); _ListInstance[instance]->Saved.SlotInfo[0].Offset = 0; _ListInstance[instance]->Saved.SlotInfo[0].StartTime = (int)(pAnim->getBeginTime()*_AnimationDlg->Speed); _ListInstance[instance]->Saved.SlotInfo[0].EndTime = (int)(pAnim->getEndTime()*_AnimationDlg->Speed); @@ -2601,7 +2583,7 @@ void CObjectViewer::evalSoundTrack (float lastTime, float currentTime) for (uint i = 0; i < _ListInstance.size(); i++) { // Some animation in the list ? - if (_ListInstance[i]->Saved.PlayList.size() > 0) + if (!_ListInstance[i]->Saved.PlayList.empty()) { // Accumul time float startTime = 0; @@ -2628,9 +2610,9 @@ void CObjectViewer::evalSoundTrack (float lastTime, float currentTime) { CEdit *edit = (CEdit*) _SoundAnimDlg->GetDlgItem(tab[i]); nlassert(edit); - char str[1024]; + TCHAR str[1024]; edit->GetLine(0, str, 1024); - SoundContext.Args[i] = atoi (str); + SoundContext.Args[i] = _ttoi (str); } // get the position of the skel if a skel is available @@ -2866,7 +2848,7 @@ void CObjectViewer::enableDynamicObjectLightingTest(NLPACS::CGlobalRetriever *gl if (!_ObjectLightTestShape.empty()) { string str= string("Path not found for Light Test Shape: ") + _ObjectLightTestShape; - ::MessageBox(NULL, str.c_str(), "Dynamic Object Light Test", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(NULL, utf8ToTStr(str.c_str()), _T("Dynamic Object Light Test"), MB_OK|MB_ICONEXCLAMATION); } // disable. _ObjectLightTest= NULL; @@ -2916,7 +2898,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) for (uint i=0; i<(uint)zones.size(); i++) _VegetableLandscapeZoneNames.push_back(zones.asString(i).c_str()); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLandscapeTileBank.clear(); _VegetableLandscapeTileFarBank.clear(); @@ -2934,7 +2916,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) // clamp to avoid divide/0. _VegetableLandscapeThreshold= max(_VegetableLandscapeThreshold, 0.001f); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLandscapeThreshold= 0.003f; } @@ -2944,7 +2926,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &tileNear= cf.getVar("veget_landscape_tile_near"); _VegetableLandscapeTileNear= tileNear.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLandscapeTileNear= 50; } @@ -2956,7 +2938,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) _VegetableLandscapeAmbient.G= color.asInt(1); _VegetableLandscapeAmbient.B= color.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLandscapeAmbient.set(80, 80, 80); } @@ -2968,7 +2950,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) _VegetableLandscapeDiffuse.G= color.asInt(1); _VegetableLandscapeDiffuse.B= color.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLandscapeDiffuse.set(255, 255, 255); } @@ -2978,7 +2960,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &var= cf.getVar("veget_landscape_snap_height"); _VegetableSnapHeight= var.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableSnapHeight= 1.70f; } @@ -2993,9 +2975,9 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &var= cf.getVar("veget_texture"); _VegetableTexture= var.asString(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { - _VegetableTexture= ""; + _VegetableTexture.clear(); } // vegetable ambient @@ -3006,7 +2988,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) _VegetableAmbient.G= color.asInt(1); _VegetableAmbient.B= color.asInt(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableAmbient.set(80, 80, 80); } @@ -3019,7 +3001,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) sint G= color.asInt(1) - _VegetableAmbient.G; clamp(G, 0, 255); _VegetableDiffuse.G= G; sint B= color.asInt(2) - _VegetableAmbient.B; clamp(B, 0, 255); _VegetableDiffuse.B= B; } - catch (EUnknownVar &) + catch (const EUnknownVar &) { sint R= 255 - _VegetableAmbient.R; clamp(R, 0, 255); _VegetableDiffuse.R= R; sint G= 255 - _VegetableAmbient.G; clamp(G, 0, 255); _VegetableDiffuse.G= G; @@ -3034,7 +3016,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) _VegetableLightDir.z= var.asFloat(2); _VegetableLightDir.normalize(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableLightDir.set(0, 1, -1); _VegetableLightDir.normalize(); @@ -3048,7 +3030,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) _VegetableWindDir.y= var.asFloat(1); _VegetableWindDir.z= var.asFloat(2); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableWindDir.x= 0.5f; _VegetableWindDir.y= 0.5f; @@ -3060,7 +3042,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &var= cf.getVar("veget_wind_freq"); _VegetableWindFreq= var.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableWindFreq= 0.5; } @@ -3070,7 +3052,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &var= cf.getVar("veget_wind_power"); _VegetableWindPower= var.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableWindPower= 1; } @@ -3080,7 +3062,7 @@ void CObjectViewer::loadVegetableLandscapeCfg(NLMISC::CConfigFile &cf) CConfigFile::CVar &var= cf.getVar("veget_wind_bend_min"); _VegetableWindBendMin= var.asFloat(); } - catch (EUnknownVar &) + catch (const EUnknownVar &) { _VegetableWindBendMin= 0; } @@ -3105,7 +3087,7 @@ bool CObjectViewer::createVegetableLandscape() try { - if(_VegetableLandscapeTileBank=="") + if(_VegetableLandscapeTileBank.empty()) { throw Exception("Landscape CFG not fully defined"); } @@ -3113,7 +3095,7 @@ bool CObjectViewer::createVegetableLandscape() // Load The Bank files (copied from CLandscapeUser :) ). // ================ // progress - dlgProgress.ProgressText.SetWindowText("Loading TileBanks..."); + dlgProgress.ProgressText.SetWindowText(_T("Loading TileBanks...")); dlgProgress.ProgressBar.SetPos(0); // load CIFile bankFile(CPath::lookup(_VegetableLandscapeTileBank)); @@ -3140,7 +3122,7 @@ bool CObjectViewer::createVegetableLandscape() if(CNELU::Driver) { // progress - dlgProgress.ProgressText.SetWindowText("Loading Tiles..."); + dlgProgress.ProgressText.SetWindowText(_T("Loading Tiles...")); dlgProgress.ProgressBar.SetPos(0); // count nbText to load. @@ -3195,7 +3177,7 @@ bool CObjectViewer::createVegetableLandscape() bool zoneLoaded= false; CAABBox landscapeBBox; // progress - dlgProgress.ProgressText.SetWindowText("Loading Zones..."); + dlgProgress.ProgressText.SetWindowText(_T("Loading Zones...")); dlgProgress.ProgressBar.SetPos(0); uint nbZones= (uint)_VegetableLandscapeZoneNames.size(); for(uint i=0; isetLandscape(&_VegetableLandscape->Landscape); _VegetableCollisionEntity= _VegetableCollisionManager->createEntity(); } - catch (Exception &e) + catch (const Exception &e) { // close the progress dialog dlgProgress.DestroyWindow(); - MessageBox(_MainFrame->m_hWnd, e.what(), "Failed to Load landscape", MB_OK | MB_APPLMODAL); + MessageBox(_MainFrame->m_hWnd, utf8ToTStr(e.what()), _T("Failed to Load landscape"), MB_OK | MB_APPLMODAL); // remove first possibly created collisions objects. if(_VegetableCollisionEntity) @@ -3536,10 +3518,10 @@ void CObjectViewer::refreshAnimationListeners() } // *************************************************************************** -void CObjectViewer::addAnimation (NL3D::CAnimation* anim, const char* filename, const char* name, uint instance) +void CObjectViewer::addAnimation(NL3D::CAnimation* anim, const std::string &filename, const std::string &name, uint instance) { // Add an animation - uint id = _ListInstance[instance]->AnimationSet.addAnimation (name, anim); + uint id = _ListInstance[instance]->AnimationSet.addAnimation (name.c_str(), anim); _ListInstance[instance]->Saved.AnimationFileName.push_back (filename); // Rebuild the animationSet @@ -3553,15 +3535,14 @@ void CObjectViewer::addAnimation (NL3D::CAnimation* anim, const char* filename, } // *************************************************************************** -void CObjectViewer::loadAnimation (const char* fileName, uint instance) +void CObjectViewer::loadAnimation(const std::string &fileName, uint instance) { // Open the file CIFile file; if (file.open (fileName)) { // Get the animation name - char name[256]; - _splitpath (fileName, NULL, NULL, name, NULL); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName); // Make an animation CAnimation *anim=new CAnimation; @@ -3575,22 +3556,20 @@ void CObjectViewer::loadAnimation (const char* fileName, uint instance) else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", fileName); - _MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str()); + _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } // *************************************************************************** -void CObjectViewer::loadSWT (const char* fileName, uint instance) +void CObjectViewer::loadSWT (const std::string &fileName, uint instance) { // Open the file CIFile file; if (file.open (fileName)) { // Get the animation name - char name[256]; - _splitpath (fileName, NULL, NULL, name, NULL); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName); // Get the skeleton pointer CSkeletonWeight* skel=new CSkeletonWeight; @@ -3599,7 +3578,7 @@ void CObjectViewer::loadSWT (const char* fileName, uint instance) skel->serial (file); // Add an animation - _ListInstance[instance]->AnimationSet.addSkeletonWeight (name, skel); + _ListInstance[instance]->AnimationSet.addSkeletonWeight (name.c_str(), skel); // Add the filename in the list _ListInstance[instance]->Saved.SWTFileName.push_back (fileName); @@ -3607,9 +3586,8 @@ void CObjectViewer::loadSWT (const char* fileName, uint instance) else { // Create a message - char msg[512]; - _snprintf (msg, 512, "Can't open the file %s for reading.", fileName); - _MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str()); + _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } @@ -3688,8 +3666,8 @@ float CObjectViewer::getGlobalWindPower() const void CObjectViewer::shootScene() { - static const char BASED_CODE szFilter[] = "Targa Files (*.tga)|*.tga|Jpeg Files (*.jpg)|*.jpg|All Files (*.*)|*.*||"; - CFileDialog fileDlg ( FALSE, ".tga", "*.tga", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static const TCHAR BASED_CODE szFilter[] = _T("PNG Files (*.png)|*.png|Targa Files (*.tga)|*.tga|Jpeg Files (*.jpg)|*.jpg|All Files (*.*)|*.*||"); + CFileDialog fileDlg ( FALSE, _T(".tga"), _T("*.tga"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal () == IDOK) { // Choose the size @@ -3712,8 +3690,8 @@ void CObjectViewer::shootScene() CNELU::Driver->setupViewport (CViewport ()); // The file name - string filename = NLMISC::CFile::getFilenameWithoutExtension ((const char*)fileDlg.GetPathName ()); - string extension = NLMISC::CFile::getExtension ((const char*)fileDlg.GetPathName ()); + string filename = NLMISC::CFile::getFilenameWithoutExtension(tStrToUtf8(fileDlg.GetPathName())); + string extension = NLMISC::CFile::getExtension (tStrToUtf8(fileDlg.GetPathName())); // The file name without extension bool jpeg = toLower (extension) == "jpg"; @@ -3792,13 +3770,15 @@ void CObjectViewer::shootScene() } else { - _MainFrame->MessageBox (("Can't open the file "+filenamefinal+" for writing.").c_str (), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string message = toString("Can't open the file %s for writing.", filenamefinal.c_str()); + _MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); break; } } - catch (Exception &e) + catch (const Exception &e) { - _MainFrame->MessageBox (("Error during writing of the file "+filenamefinal+" : "+(string)e.what ()).c_str (), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + std::string message = toString("Error during writing of the file %s: %s", filenamefinal.c_str(), e.what()); + _MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); break; } } @@ -3815,7 +3795,7 @@ void CObjectViewer::drawFXUserMatrix() { CString fxUserMatrix; fxUserMatrix.LoadString(IDS_FX_USER_MATRIX); - fxUserMatrixStr = (LPCTSTR) fxUserMatrix; + fxUserMatrixStr = tStrToUtf8(fxUserMatrix); stringRetrieved = true; } nlassert(_ParticleDlg); @@ -3830,7 +3810,7 @@ void CObjectViewer::drawFXMatrix() { CString fx; fx.LoadString(IDS_FX_MATRIX); - fxStr = (LPCTSTR) fx; + fxStr = tStrToUtf8(fx); stringRetrieved = true; } drawNamedMatrix(_ParticleDlg->getPSWorldMatrix(), fxStr, NLMISC::CRGBA::Blue, -0.2f, 10.f); @@ -3844,7 +3824,7 @@ void CObjectViewer::drawSceneMatrix() { CString sceneMatrix; sceneMatrix.LoadString(IDS_SCENE_MATRIX); - sceneMatrixStr = (LPCTSTR) sceneMatrix; + sceneMatrixStr = tStrToUtf8(sceneMatrix); stringRetrieved = true; } drawNamedMatrix(_SceneRoot->getMatrix(), sceneMatrixStr, NLMISC::CRGBA::White, 0.f, 10.f); @@ -3882,7 +3862,6 @@ uint CObjectViewer::getNumCamera () const int localizedMessageBox(HWND parentWindow, int messageStringID, int captionStringID, UINT nType) { - CString caption; CString mess; caption.LoadString(captionStringID); @@ -3891,7 +3870,7 @@ int localizedMessageBox(HWND parentWindow, int messageStringID, int captionStrin // TODO : replace older call to ::MessageBox in the object viewer with that function } -int localizedMessageBox(HWND parentWindow, const char *message, int captionStringID, UINT nType) +int localizedMessageBox(HWND parentWindow, const TCHAR *message, int captionStringID, UINT nType) { CString caption; caption.LoadString(captionStringID); @@ -3907,7 +3886,7 @@ CString getStrRsc(uint stringID) bool browseFolder(const CString &caption, CString &destFolder, HWND parent) { - char chosenPath[MAX_PATH]; + TCHAR chosenPath[MAX_PATH]; // browse folder BROWSEINFO bi; bi.hwndOwner = parent; 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..72591a4b4 100644 --- a/code/nel/tools/3d/object_viewer/sound_anim_view.cpp +++ b/code/nel/tools/3d/object_viewer/sound_anim_view.cpp @@ -67,7 +67,7 @@ bool CSoundAnimView::registerClass() _WndClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(WHITE_BRUSH)); // Do some additional initialization of static veriables - _Font.CreateFont(14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial"); + _Font.CreateFont(14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Arial")); _FillBrush.CreateSolidBrush(RGB(230, 245, 245)); _MarkerBrush.CreateSolidBrush(RGB(0, 0, 0)); _SelectBrush.CreateSolidBrush(RGB(0, 210, 210)); @@ -113,7 +113,7 @@ void CSoundAnimView::Create(CObjectViewer* objView, CAnimationDlg* animDlg, CSou } - CWnd::Create((LPCTSTR) _WndClass, "Sound Animation", WS_CHILD | WS_VISIBLE, rect, (CWnd*) sndDlg, ++_WndId); + CWnd::Create((LPCTSTR) _WndClass, _T("Sound Animation"), WS_CHILD | WS_VISIBLE, rect, (CWnd*) sndDlg, ++_WndId); } // ******************************************************** @@ -216,12 +216,12 @@ void CSoundAnimView::save() filename.append(anim->getName()).append(".sound_anim"); // Create a dialog - char BASED_CODE szFilter[] = "NeL Sound Animations (*.sound_anim)|*.sound_anim|All Files (*.*)|*.*||"; - CFileDialog fileDlg( FALSE, ".sound_anim", filename.c_str(), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + TCHAR BASED_CODE szFilter[] = _T("NeL Sound Animations (*.sound_anim)|*.sound_anim|All Files (*.*)|*.*||"); + CFileDialog fileDlg( FALSE, _T(".sound_anim"), utf8ToTStr(filename), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal() == IDOK) { - filename = (const char*) fileDlg.GetPathName(); + filename = tStrToUtf8(fileDlg.GetPathName()); } else { @@ -234,9 +234,9 @@ void CSoundAnimView::save() { CSoundAnimManager::instance()->saveAnimation(anim, filename); } - catch (Exception& e) + catch (const Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -298,7 +298,7 @@ void CSoundAnimView::refresh(BOOL update) CInstanceInfo *instanceInfo = _ObjView->getInstance(selected); // Some animation in the list ? - if (instanceInfo->Saved.PlayList.size() > 0) + if (!instanceInfo->Saved.PlayList.empty()) { // Accumul time float startTime = 0; @@ -328,7 +328,7 @@ void CSoundAnimView::refresh(BOOL update) else soundAnim = animManager->findAnimation(name); } - catch (exception& e) + catch (const exception& e) { nlwarning("Couldn't find sound animation <%s>: %s", name.c_str(), e.what()); needCreate = true; diff --git a/code/nel/tools/3d/object_viewer/sound_system.cpp b/code/nel/tools/3d/object_viewer/sound_system.cpp index 69e10ea18..5a79c3af3 100644 --- a/code/nel/tools/3d/object_viewer/sound_system.cpp +++ b/code/nel/tools/3d/object_viewer/sound_system.cpp @@ -67,7 +67,7 @@ void CSoundSystem::initSoundSystem () _AudioMixer->setPackedSheetOption(_PackedSheetPath, true); _AudioMixer->init(32, true, false, NULL, true); } - catch(NLMISC::Exception &e) + catch(const NLMISC::Exception &e) { // in case of exeption during mixer init, the mixer is destroyed ! string mess = string("Unable to init sound :") + e.what(); @@ -82,7 +82,7 @@ void CSoundSystem::initSoundSystem () // TODO : boris : Hum, as far as I know, throwing exeption in constructor is a very BAD idea... _AnimManager = new CSoundAnimManager(_AudioMixer); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { string mess = string("Unable to init sound :") + e.what(); nlwarning ("Init sound: %s", mess.c_str()); @@ -109,7 +109,7 @@ void CSoundSystem::initSoundSystem () //_AudioMixer->loadSampleBank(NLMISC::CPath::lookup(*it).c_str()); _AudioMixer->loadSampleBank(false, (*it1)); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { string mess = "Unable to load sound file :" + *it1 + "\n" + e.what(); @@ -126,7 +126,7 @@ void CSoundSystem::initSoundSystem () //_AudioMixer->loadSoundBank(NLMISC::CPath::lookup(*it).c_str()); _AudioMixer->loadSoundBank((*it2).c_str()); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { string mess = "Unable to load sound file :" + *it2 + "\n" + e.what(); @@ -178,7 +178,7 @@ void CSoundSystem::play(const string &soundName) } else { - MessageBox(NULL, "Can't play the sound (perhaps it's contextual sound)", "warning", MB_OK|MB_ICONWARNING ); + MessageBox(NULL, _T("Can't play the sound (perhaps it's contextual sound)"), _T("warning"), MB_OK|MB_ICONWARNING ); } } } @@ -198,7 +198,7 @@ USource *CSoundSystem::create(const std::string &soundName) } else { - MessageBox(NULL, "Can't play the sound (perhaps it's contextual sound)", "warning", MB_OK|MB_ICONWARNING ); + MessageBox(NULL, _T("Can't play the sound (perhaps it's contextual sound)"), _T("warning"), MB_OK|MB_ICONWARNING ); } return NULL; } return NULL; diff --git a/code/nel/tools/3d/object_viewer/start_stop_particle_system.cpp b/code/nel/tools/3d/object_viewer/start_stop_particle_system.cpp index 450b8b714..923c35ed1 100644 --- a/code/nel/tools/3d/object_viewer/start_stop_particle_system.cpp +++ b/code/nel/tools/3d/object_viewer/start_stop_particle_system.cpp @@ -210,7 +210,7 @@ void CStartStopParticleSystem::updateUIFromState() if (!getCurrPS()) { GetDlgItem(IDC_ACTIVE_PS)->SetWindowText(getStrRsc(IDS_NO_ACTIVE_PS)); - GetDlgItem(IDC_STICK_BONE)->SetWindowText(""); + GetDlgItem(IDC_STICK_BONE)->SetWindowText(_T("")); GetDlgItem(IDC_ENABLE_AUTO_COUNT)->EnableWindow(FALSE); GetDlgItem(IDC_RESET_COUNT)->EnableWindow(FALSE); ((CButton *) GetDlgItem(IDC_ENABLE_AUTO_COUNT))->SetCheck(0); @@ -225,19 +225,19 @@ void CStartStopParticleSystem::updateUIFromState() GetDlgItem(IDC_BROWSE_ANIM)->EnableWindow(FALSE); GetDlgItem(IDC_DISPLAY_HELPERS)->EnableWindow(FALSE); GetDlgItem(IDC_CLEAR_ANIM)->EnableWindow(FALSE); - m_TriggerAnim = ""; + m_TriggerAnim.Empty(); } else { if (!_ActiveNode->getParentSkelName().empty()) { - GetDlgItem(IDC_STICK_BONE)->SetWindowText((_ActiveNode->getParentBoneName() + "." + _ActiveNode->getParentBoneName()).c_str()); + GetDlgItem(IDC_STICK_BONE)->SetWindowText(utf8ToTStr(_ActiveNode->getParentBoneName() + "." + _ActiveNode->getParentBoneName())); } else { - GetDlgItem(IDC_STICK_BONE)->SetWindowText(""); + GetDlgItem(IDC_STICK_BONE)->SetWindowText(_T("")); } - GetDlgItem(IDC_ACTIVE_PS)->SetWindowText(_ActiveNode->getFilename().c_str()); + GetDlgItem(IDC_ACTIVE_PS)->SetWindowText(utf8ToTStr(_ActiveNode->getFilename())); GetDlgItem(IDC_ENABLE_AUTO_COUNT)->EnableWindow(TRUE); ((CButton *) GetDlgItem(IDC_ENABLE_AUTO_COUNT))->SetCheck(getCurrPS()->getAutoCountFlag() ? 1 : 0); GetDlgItem(IDC_RESET_COUNT)->EnableWindow((_ActiveNode->getPSPointer()->getAutoCountFlag() && !_ActiveNode->getResetAutoCountFlag()) ? TRUE : FALSE); @@ -844,7 +844,7 @@ void CStartStopParticleSystem::OnLinkToSkeleton() uint boneIndex; std::string parentSkelName; std::string parentBoneName; - if (ov->chooseBone((LPCTSTR) chooseBoneForPS, skel, boneIndex, &parentSkelName, &parentBoneName)) + if (ov->chooseBone(tStrToUtf8(chooseBoneForPS), skel, boneIndex, &parentSkelName, &parentBoneName)) { _ParticleDlg->stickPSToSkeleton(_ActiveNode, skel, boneIndex, parentSkelName, parentBoneName); } @@ -1017,11 +1017,11 @@ void CStartStopParticleSystem::OnBrowseAnim() } } std::vector animList(animSet.begin(), animSet.end()); - CSelectString st(animList, (LPCTSTR) getStrRsc(IDS_SELECT_ANIMATION), this, false); + CSelectString st(animList, tStrToUtf8(getStrRsc(IDS_SELECT_ANIMATION)), this, false); if (st.DoModal() == IDOK && st.Selection != -1) { m_TriggerAnim = animList[st.Selection].c_str(); - _ActiveNode->setTriggerAnim((LPCTSTR) m_TriggerAnim); + _ActiveNode->setTriggerAnim(tStrToUtf8(m_TriggerAnim)); GetDlgItem(IDC_CLEAR_ANIM)->EnableWindow(!_ActiveNode->getTriggerAnim().empty()); } _ParticleDlg->ParticleTreeCtrl->updateCaption(*_ActiveNode); @@ -1033,7 +1033,7 @@ void CStartStopParticleSystem::OnBrowseAnim() void CStartStopParticleSystem::OnClearAnim() { // TODO: Add your control notification handler code here - m_TriggerAnim = ""; + m_TriggerAnim.Empty(); _ActiveNode->setTriggerAnim(""); _ParticleDlg->ParticleTreeCtrl->updateCaption(*_ActiveNode); UpdateData(FALSE); diff --git a/code/nel/tools/3d/object_viewer/texture_anim_dlg.cpp b/code/nel/tools/3d/object_viewer/texture_anim_dlg.cpp index 31babe7b3..79a05ad8f 100644 --- a/code/nel/tools/3d/object_viewer/texture_anim_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/texture_anim_dlg.cpp @@ -332,13 +332,13 @@ void CTextureAnimDlg::CGradientInterface::CTextureWrapper::set(NL3D::ITexture *t if (t->getWidth() != tex->getWidth() || t->getHeight() != tex->getHeight()) { - ::MessageBox(NULL, "All textures must have the same size !", "error", MB_OK); + ::MessageBox(NULL, _T("All textures must have the same size !"), _T("error"), MB_OK); return; } if (t->PixelFormat != tex->PixelFormat) { - ::MessageBox(NULL, "All textures must have the same pixel format !", "error", MB_OK); + ::MessageBox(NULL, _T("All textures must have the same pixel format !"), _T("error"), MB_OK); return; } } diff --git a/code/nel/tools/3d/object_viewer/texture_chooser.cpp b/code/nel/tools/3d/object_viewer/texture_chooser.cpp index 65407aca1..70cc151b0 100644 --- a/code/nel/tools/3d/object_viewer/texture_chooser.cpp +++ b/code/nel/tools/3d/object_viewer/texture_chooser.cpp @@ -179,29 +179,22 @@ void CTextureChooser::OnBrowseTexture() { texName = (static_cast(_Wrapper->get()))->getFileName(); } - CFileDialog fd(TRUE, ".tga", texName.c_str(), 0, NULL, this); + CFileDialog fd(TRUE, _T(".tga"), utf8ToTStr(texName), 0, NULL, this); if (fd.DoModal() == IDOK) { - // Add to the path - char drive[256]; - char dir[256]; - char path[256]; - // Add search path for the texture - _splitpath (fd.GetPathName(), drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()))); try { - NL3D::CTextureFile *tf = new NL3D::CTextureFile(std::string(fd.GetFileName())); + NL3D::CTextureFile *tf = new NL3D::CTextureFile(tStrToUtf8(fd.GetFileName())); _Wrapper->setAndUpdateModifiedFlag(tf); _Texture = tf; textureToBitmap(); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { - MessageBox(e.what(), "error loading texture"); + MessageBox(utf8ToTStr(e.what()), _T("error loading texture")); } } diff --git a/code/nel/tools/3d/object_viewer/value_gradient_dlg.cpp b/code/nel/tools/3d/object_viewer/value_gradient_dlg.cpp index ccddc5833..5eff39642 100644 --- a/code/nel/tools/3d/object_viewer/value_gradient_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/value_gradient_dlg.cpp @@ -100,7 +100,7 @@ void CValueGradientDlg::OnAddValue() UpdateData(); ++_Size; _ClientInterface->modifyGradient(IValueGradientDlgClient::Add, 0); - m_GradientList.AddString("value"); + m_GradientList.AddString(_T("value")); m_RemoveCtrl.EnableWindow(TRUE); m_GradientList.SetCurSel(_Size - 1); @@ -116,7 +116,7 @@ void CValueGradientDlg::OnInsertValue() uint oldIndex = m_GradientList.GetCurSel(); ++_Size; _ClientInterface->modifyGradient(IValueGradientDlgClient::Insert, m_GradientList.GetCurSel()); - m_GradientList.InsertString(m_GradientList.GetCurSel(), "value"); + m_GradientList.InsertString(m_GradientList.GetCurSel(), _T("value")); m_GradientList.Invalidate(); m_GradientList.SetCurSel(oldIndex); OnSelchangeGradientList(); @@ -185,7 +185,7 @@ BOOL CValueGradientDlg::OnInitDialog() m_GradientList.InitStorage(_Size, 16); for (uint k = 0; k < _Size; ++k) { - m_GradientList.AddString("value"); + m_GradientList.AddString(_T("value")); } m_RemoveCtrl.EnableWindow(_Size > _MinSize ? TRUE : FALSE); m_GradientList.SetCurSel(0); diff --git a/code/nel/tools/3d/object_viewer/vegetable_copy_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_copy_dlg.cpp index 4e3162559..05e0ab1fd 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_copy_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_copy_dlg.cpp @@ -249,7 +249,7 @@ BOOL CVegetableCopyDlg::OnInitDialog() uint num= _VegetableDlg->getNumVegetables(); for(uint i=0; igetVegetableName(i).c_str()); + VegetableList.AddString(utf8ToTStr(_VegetableDlg->getVegetableName(i))); } @@ -289,7 +289,7 @@ void CVegetableCopyDlg::OnOK() } else { - MessageBox("Select a vegetable to copy first", "Error", MB_OK | MB_ICONWARNING); + MessageBox(_T("Select a vegetable to copy first"), _T("Error"), MB_OK | MB_ICONWARNING); } } diff --git a/code/nel/tools/3d/object_viewer/vegetable_density_page.cpp b/code/nel/tools/3d/object_viewer/vegetable_density_page.cpp index 2db682bcd..d8f9c2d75 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_density_page.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_density_page.cpp @@ -100,7 +100,7 @@ void CVegetableDensityPage::setVegetableToEdit(NL3D::CVegetable *vegetable) { // Init ShapeName // ---------- - StaticVegetableShape.SetWindowText(_Vegetable->ShapeName.c_str()); + StaticVegetableShape.SetWindowText(utf8ToTStr(_Vegetable->ShapeName)); // init Creation Distance. // ---------- @@ -198,8 +198,9 @@ void CVegetableDensityPage::updateViewAngleMin() sint pos= (sint)(angle/(NLMISC::Pi/2) * NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE); NLMISC::clamp(pos, -NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE, NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE); AngleMinSlider.SetPos(pos); - char stmp[256]; - sprintf(stmp, "%.2f", (double)(angle*180/NLMISC::Pi)); + + CString stmp; + stmp.Format(_T("%.2f"), (double)(angle*180/NLMISC::Pi)); AngleMinEdit.SetWindowText(stmp); } @@ -213,8 +214,9 @@ void CVegetableDensityPage::updateViewAngleMax() sint pos= (sint)(angle/(NLMISC::Pi/2) * NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE); NLMISC::clamp(pos, -NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE, NL_VEGETABLE_EDIT_ANGLE_SLIDER_SIZE); AngleMaxSlider.SetPos(pos); - char stmp[256]; - sprintf(stmp, "%.2f", (double)(angle*180/NLMISC::Pi)); + + CString stmp; + stmp.Format(_T("%.2f"), (double)(angle * 180 / NLMISC::Pi)); AngleMaxEdit.SetWindowText(stmp); } @@ -223,10 +225,10 @@ void CVegetableDensityPage::updateViewAngleMax() void CVegetableDensityPage::updateAngleMinFromEditText() { // get angles edited. - char stmp[256]; + TCHAR stmp[256]; AngleMinEdit.GetWindowText(stmp, 256); float angleMin; - NLMISC::fromString(stmp, angleMin); + NLMISC::fromString(tStrToUtf8(stmp), angleMin); NLMISC::clamp(angleMin, -90, 90); // make a sinus, because 90 => 1, and -90 =>-1 float cosAngleMin= (float)sin(angleMin*NLMISC::Pi/180.f); @@ -247,10 +249,10 @@ void CVegetableDensityPage::updateAngleMinFromEditText() void CVegetableDensityPage::updateAngleMaxFromEditText() { // get angles edited. - char stmp[256]; + TCHAR stmp[256]; AngleMaxEdit.GetWindowText(stmp, 256); float angleMax; - NLMISC::fromString(stmp, angleMax); + NLMISC::fromString(tStrToUtf8(stmp), angleMax); NLMISC::clamp(angleMax, -90, 90); // make a sinus, because 90 => 1, and -90 =>-1 float cosAngleMax= (float)sin(angleMax*NLMISC::Pi/180.f); @@ -320,7 +322,7 @@ BOOL CVegetableDensityPage::OnInitDialog() // Init ShapeName - StaticVegetableShape.SetWindowText(""); + StaticVegetableShape.SetWindowText(_T("")); return TRUE; // return TRUE unless you set the focus to a control @@ -477,12 +479,12 @@ static void concatEdit2Lines(CEdit &edit) const uint lineLen= 1000; uint n; // retrieve the 2 lines. - char tmp0[2*lineLen]; - char tmp1[lineLen]; + TCHAR tmp0[2*lineLen]; + TCHAR tmp1[lineLen]; n= edit.GetLine(0, tmp0, lineLen); tmp0[n]= 0; n= edit.GetLine(1, tmp1, lineLen); tmp1[n]= 0; // concat and update the CEdit. - edit.SetWindowText(strcat(tmp0, tmp1)); + edit.SetWindowText(_tcscat(tmp0, tmp1)); } void CVegetableDensityPage::OnChangeEditAngleMin() @@ -515,27 +517,25 @@ void CVegetableDensityPage::OnChangeEditAngleMax() // *************************************************************************** void CVegetableDensityPage::OnButtonVegetableBrowse() { - CFileDialog fd(TRUE, "veget", "*.veget", 0, NULL, this) ; - fd.m_ofn.lpstrTitle= "Open Vegetable Shape"; + CFileDialog fd(TRUE, _T("veget"), _T("*.veget"), 0, NULL, this) ; + fd.m_ofn.lpstrTitle = _T("Open Vegetable Shape"); + if (fd.DoModal() == IDOK) { // Add to the path - char drive[256]; - char dir[256]; - char path[256]; + std::string fileName = tStrToUtf8(fd.GetFileName()); // Add search path for the .veget - _splitpath (fd.GetPathName(), drive, dir, NULL, NULL); - _makepath (path, drive, dir, NULL, NULL); + std::string path = NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())); NLMISC::CPath::addSearchPath (path); try { // verify the file can be opened. - NLMISC::CPath::lookup((const char*)fd.GetFileName()); + NLMISC::CPath::lookup(fileName); // update shapeName and view - _Vegetable->ShapeName= std::string(fd.GetFileName()); + _Vegetable->ShapeName = fileName; StaticVegetableShape.SetWindowText(fd.GetFileName()); // update the name in the list-box @@ -544,9 +544,9 @@ void CVegetableDensityPage::OnButtonVegetableBrowse() // update 3D view _VegetableDlg->refreshVegetableDisplay(); } - catch (NLMISC::EPathNotFound &ep) + catch (const NLMISC::EPathNotFound &ep) { - MessageBox(ep.what(), "Can't open file"); + MessageBox(utf8ToTStr(ep.what()), _T("Can't open file")); } } } diff --git a/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp index 09aa67ea4..09a2079e5 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp @@ -196,7 +196,7 @@ void CVegetableDlg::updateCurSelVegetableName() _Vegetables[id].updateVegetableName(); // replace name in the listBox: must delete, and re-insert VegetableList.DeleteString(id); - VegetableList.InsertString(id, _Vegetables[id].VegetableName.c_str()); + VegetableList.InsertString(id, utf8ToTStr(_Vegetables[id].VegetableName)); VegetableList.SetCurSel(id); } } @@ -293,7 +293,7 @@ void CVegetableDlg::CVegetableDesc::initVegetable(const NL3D::CVegetable &veget void CVegetableDlg::CVegetableDesc::updateVegetableName() { // Build the vegetable Name according to the ShapeName - if(Vegetable->ShapeName=="") + if(Vegetable->ShapeName.empty()) { VegetableName= NL_DefaultVegetName; } @@ -336,38 +336,38 @@ void CVegetableDlg::clearVegetables() // *************************************************************************** -bool CVegetableDlg::loadVegetableSet(NL3D::CTileVegetableDesc &vegetSet, const char *title) +bool CVegetableDlg::loadVegetableSet(NL3D::CTileVegetableDesc &vegetSet, const TCHAR *title) { vegetSet.clear(); bool ok= false; - CFileDialog fd(TRUE, ".vegetset", "*.vegetset", 0, NULL, this) ; - fd.m_ofn.lpstrTitle= title; + CFileDialog fd(TRUE, _T(".vegetset"), _T("*.vegetset"), 0, NULL, this) ; + fd.m_ofn.lpstrTitle = title; if (fd.DoModal() == IDOK) { NLMISC::CIFile f; ok= true; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName()))) { try { // read the vegetable f.serial(vegetSet); // bkup fileName. - _LastVegetSetName= (const char*)fd.GetFileName(); + _LastVegetSetName = tStrToUtf8(fd.GetFileName()); } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { ok= false; - MessageBox("Failed to load file!"); + MessageBox(_T("Failed to load file!")); } } else { ok= false; - MessageBox("Failed to open file!"); + MessageBox(_T("Failed to open file!")); } } @@ -385,7 +385,7 @@ void CVegetableDlg::buildVegetableSet(NL3D::CTileVegetableDesc &vegetSet, bool for(uint i=0;i<_Vegetables.size();i++) { // if don't want to keep ShapeNames, skip them. - if(!keepDefaultShapeName && _Vegetables[i].Vegetable->ShapeName=="") + if(!keepDefaultShapeName && _Vegetables[i].Vegetable->ShapeName.empty()) continue; // if don't want to keep hiden vegetables, skip them. if(!keepHiden && !_Vegetables[i].Visible) @@ -439,7 +439,7 @@ void CVegetableDlg::appendVegetableSet(NL3D::CTileVegetableDesc &vegetSet) _Vegetables[id].initVegetable(veget); // update view - VegetableList.AddString(_Vegetables[id].VegetableName.c_str()); + VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName)); } } } @@ -529,7 +529,7 @@ void CVegetableDlg::OnButtonVegetableAdd() _Vegetables[id].initDefaultVegetable(); // update view - VegetableList.AddString(_Vegetables[id].VegetableName.c_str()); + VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName)); // update 3D view refreshVegetableDisplay(); @@ -540,7 +540,7 @@ void CVegetableDlg::OnButtonVegetableClear() if(_Vegetables.size()==0) return; - if( MessageBox("Clear all the list?", "Clear List", MB_OKCANCEL | MB_ICONWARNING | MB_APPLMODAL)==IDOK ) + if( MessageBox(_T("Clear all the list?"), _T("Clear List"), MB_OKCANCEL | MB_ICONWARNING | MB_APPLMODAL)==IDOK ) { clearVegetables(); @@ -559,7 +559,7 @@ void CVegetableDlg::OnButtonVegetableInsert() _Vegetables[id].initDefaultVegetable(); // update view - VegetableList.InsertString(id, _Vegetables[id].VegetableName.c_str()); + VegetableList.InsertString(id, utf8ToTStr(_Vegetables[id].VegetableName)); // update 3D view refreshVegetableDisplay(); @@ -605,13 +605,13 @@ void CVegetableDlg::OnButtonVegetableRemove() // *************************************************************************** void CVegetableDlg::OnButtonVegetableLoadDesc() { - CFileDialog fd(TRUE, ".vegetdesc", "*.vegetdesc", 0, NULL, this) ; - fd.m_ofn.lpstrTitle= "Open Vegetable Descriptor"; + CFileDialog fd(TRUE, _T(".vegetdesc"), _T("*.vegetdesc"), 0, NULL, this) ; + fd.m_ofn.lpstrTitle = _T("Open Vegetable Descriptor"); if (fd.DoModal() == IDOK) { NLMISC::CIFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { NL3D::CVegetable veget; try @@ -624,19 +624,19 @@ void CVegetableDlg::OnButtonVegetableLoadDesc() _Vegetables[id].initVegetable(veget); // update view - VegetableList.AddString(_Vegetables[id].VegetableName.c_str()); + VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName)); // update 3D view refreshVegetableDisplay(); } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { - MessageBox("Failed to load file!"); + MessageBox(_T("Failed to load file!")); } } else { - MessageBox("Failed to open file!"); + MessageBox(_T("Failed to open file!")); } } @@ -651,27 +651,27 @@ void CVegetableDlg::OnButtonVegetableSaveDesc() std::string fileName= _Vegetables[id].VegetableName + ".vegetdesc"; - CFileDialog fd(FALSE, "vegetdesc", fileName.c_str(), OFN_OVERWRITEPROMPT, "VegetDescFiles (*.vegetdesc)|*.vegetdesc|All Files (*.*)|*.*||", this) ; - fd.m_ofn.lpstrTitle= "Save Vegetable Descriptor"; + CFileDialog fd(FALSE, _T("vegetdesc"), utf8ToTStr(fileName), OFN_OVERWRITEPROMPT, _T("VegetDescFiles (*.vegetdesc)|*.vegetdesc|All Files (*.*)|*.*||"), this) ; + fd.m_ofn.lpstrTitle = _T("Save Vegetable Descriptor"); if (fd.DoModal() == IDOK) { NLMISC::COFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { try { // save the vegetable f.serial(veget); } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { - MessageBox("Failed to save file!"); + MessageBox(_T("Failed to save file!")); } } else { - MessageBox("Failed to open file for write!"); + MessageBox(_T("Failed to open file for write!")); } } } @@ -684,7 +684,7 @@ void CVegetableDlg::OnButtonVegetableLoadSet() { NL3D::CTileVegetableDesc vegetSet; // if succes to load the vegetSet - if(loadVegetableSet(vegetSet, "Load Vegetable Set")) + if(loadVegetableSet(vegetSet, _T("Load Vegetable Set"))) { // Delete all vegetables. clearVegetables(); @@ -702,7 +702,7 @@ void CVegetableDlg::OnButtonVegetableAppendSet() { NL3D::CTileVegetableDesc vegetSet; // if succes to load the vegetSet - if(loadVegetableSet(vegetSet, "Append Vegetable Set")) + if(loadVegetableSet(vegetSet, _T("Append Vegetable Set"))) { // Do not Delete any vegetables. // build them from list. @@ -722,27 +722,27 @@ void CVegetableDlg::OnButtonVegetableSaveSet() buildVegetableSet(vegetSet); // Then try to save it. - CFileDialog fd(FALSE, "vegetset", _LastVegetSetName.c_str(), OFN_OVERWRITEPROMPT, "VegetSetFiles (*.vegetset)|*.vegetset|All Files (*.*)|*.*||", this) ; - fd.m_ofn.lpstrTitle= "Save Vegetable Set"; + CFileDialog fd(FALSE, _T("vegetset"), utf8ToTStr(_LastVegetSetName), OFN_OVERWRITEPROMPT, _T("VegetSetFiles (*.vegetset)|*.vegetset|All Files (*.*)|*.*||"), this) ; + fd.m_ofn.lpstrTitle = _T("Save Vegetable Set"); if (fd.DoModal() == IDOK) { NLMISC::COFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { try { // save the vegetable set f.serial(vegetSet); } - catch(NLMISC::EStream &) + catch(const NLMISC::EStream &) { - MessageBox("Failed to save file!"); + MessageBox(_T("Failed to save file!")); } } else { - MessageBox("Failed to open file for write!"); + MessageBox(_T("Failed to open file for write!")); } } diff --git a/code/nel/tools/3d/object_viewer/vegetable_dlg.h b/code/nel/tools/3d/object_viewer/vegetable_dlg.h index 37a263630..72d588259 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_dlg.h +++ b/code/nel/tools/3d/object_viewer/vegetable_dlg.h @@ -144,10 +144,10 @@ protected: // clear all vegetables. void clearVegetables(); // load a vegetSet with a FileDialog - bool loadVegetableSet(NL3D::CTileVegetableDesc &vegetSet, const char *title); + bool loadVegetableSet(NL3D::CTileVegetableDesc &vegetSet, const TCHAR *title); /** build the vegetSet from the current _Vegetables * NB: transform Rotate Angle in Radians. - * \param keepDefaultShapeName if true, then vegetables with a ShapeName=="" are kept. + * \param keepDefaultShapeName if true, then vegetables with a ShapeName.empty() are kept. * \param keepHiden if true, then vegetables maked as hiden in ObjectViewer are kept. */ void buildVegetableSet(NL3D::CTileVegetableDesc &vegetSet, bool keepDefaultShapeName= true, bool keepHiden= true ); diff --git a/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp b/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp index 8d791a0fe..b0508cca9 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp @@ -33,7 +33,7 @@ void CDirectEditableRangeFloat::init(uint32 x, uint32 y, CWnd *pParent) CRect rect; rect.SetRect(x, y+10, x+dx, y+25); - _StaticText.Create(_Title.c_str(), WS_CHILD | WS_VISIBLE, rect, pParent); + _StaticText.Create(utf8ToTStr(_Title), WS_CHILD | WS_VISIBLE, rect, pParent); _StaticText.SetFont(pParent->GetFont()); } diff --git a/code/nel/tools/3d/object_viewer/vegetable_list_box.cpp b/code/nel/tools/3d/object_viewer/vegetable_list_box.cpp index f5c7a2372..41305b38c 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_list_box.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_list_box.cpp @@ -216,8 +216,7 @@ void CVegetableListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) dc.SetTextColor(::GetSysColor(COLOR_GRAYTEXT) ); } - dc.DrawText( - (const char*)str, + dc.DrawText(str, str.GetLength(), &lpDrawItemStruct->rcItem, DT_LEFT|DT_SINGLELINE|DT_VCENTER); diff --git a/code/nel/tools/3d/object_viewer/vegetable_list_color.cpp b/code/nel/tools/3d/object_viewer/vegetable_list_color.cpp index 4e272e7d3..ec27c7352 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_list_color.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_list_color.cpp @@ -134,7 +134,7 @@ void CVegetableListColor::clear() void CVegetableListColor::addValue(CRGBA color) { // Append a dummy string to the list box. - AddString(" "); + AddString(_T(" ")); // append a color to the array. _Colors.push_back(color); @@ -149,7 +149,7 @@ void CVegetableListColor::insertValueBeforeCurSel(CRGBA color) else { // insert a dummy string to the list box. - InsertString(id, " "); + InsertString(id, _T(" ")); // insert a color to the array. _Colors.insert(_Colors.begin()+id, color); diff --git a/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp index 0c04d33c8..12bfe4050 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp @@ -154,7 +154,7 @@ BOOL CVegetableNoiseValueDlg::OnInitDialog() // Set the name. - NoiseValueName.SetWindowText(_TitleName.c_str()); + NoiseValueName.SetWindowText(utf8ToTStr(_TitleName)); // if previously setuped, setup now the noiseValue. @@ -203,7 +203,7 @@ void CVegetableNoiseValueDlg::OnReleasedcaptureSliderVegetableScaleNoise(NMHDR* // And reset SliderNoiseValue.SetPos(NL_VEGETABLE_EDIT_SLIDER_NVS_SIZE/2); _EnteringScalerSlider= false; - StaticScaleMarker.SetWindowText("100%"); + StaticScaleMarker.SetWindowText(_T("100%")); // Must update display. _VegetableRefresh->refreshVegetableDisplay(); @@ -264,7 +264,5 @@ void CVegetableNoiseValueDlg::applyScaleSlider(sint scrollValue) _RandValue->updateValueFromReader(); // update marker text - char str[256]; - sprintf(str, "%d%%", (sint)(factor*100)); - StaticScaleMarker.SetWindowText(str); + StaticScaleMarker.SetWindowText(utf8ToTStr(NLMISC::toString("%d%%", (sint)(factor * 100)))); } diff --git a/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp index 51b4cdc5e..d7be7bcb3 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp @@ -63,7 +63,7 @@ BOOL CVegetableSelectDlg::OnInitDialog() uint num= _VegetableDlg->getNumVegetables(); for(uint i=0; igetVegetableName(i).c_str()); + VegetableList.AddString(utf8ToTStr(_VegetableDlg->getVegetableName(i))); } return TRUE; // return TRUE unless you set the focus to a control diff --git a/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp index 5c6657167..0b2084863 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp @@ -70,26 +70,22 @@ END_MESSAGE_MAP() void CVegetableWindDlg::updateView() { float a; - char str[256]; // update Power. a= _ObjViewer->getVegetableWindPower(); - sprintf(str, "%.2f", a); - StaticPower.SetWindowText(str); + StaticPower.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_POWER); SliderPower.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_POWER)); // update BendStart. a= _ObjViewer->getVegetableWindBendStart(); - sprintf(str, "%.2f", a); - StaticBendStart.SetWindowText(str); + StaticBendStart.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART); SliderBendStart.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART)); // update Frequency. a= _ObjViewer->getVegetableWindFrequency(); - sprintf(str, "%.2f", a); - StaticFrequency.SetWindowText(str); + StaticFrequency.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY); SliderFrequency.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY)); @@ -129,28 +125,24 @@ void CVegetableWindDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBa && nSBCode==SB_THUMBPOSITION || nSBCode==SB_THUMBTRACK) { float a; - char str[256]; if(sliderCtrl == &SliderPower) { a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_POWER / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE; _ObjViewer->setVegetableWindPower(a); - sprintf(str, "%.2f", a); - StaticPower.SetWindowText(str); + StaticPower.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); } else if(sliderCtrl == &SliderBendStart) { a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE; _ObjViewer->setVegetableWindBendStart(a); - sprintf(str, "%.2f", a); - StaticBendStart.SetWindowText(str); + StaticBendStart.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); } else if(sliderCtrl == &SliderFrequency) { a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE; _ObjViewer->setVegetableWindFrequency(a); - sprintf(str, "%.2f", a); - StaticFrequency.SetWindowText(str); + StaticFrequency.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); } } else diff --git a/code/nel/tools/3d/object_viewer/water_pool_editor.cpp b/code/nel/tools/3d/object_viewer/water_pool_editor.cpp index 601c5c907..bf6f461bf 100644 --- a/code/nel/tools/3d/object_viewer/water_pool_editor.cpp +++ b/code/nel/tools/3d/object_viewer/water_pool_editor.cpp @@ -165,9 +165,8 @@ BOOL CWaterPoolEditor::OnInitDialog() int CWaterPoolEditor::addPool(uint32 ID) { - char poolId[128]; - sprintf(poolId, "%d (%s)", ID, _Wpm->getPoolByID(ID).getName().c_str()); - int index = m_PoolList.AddString(poolId); + std::string poolId = NLMISC::toString("%d (%s)", ID, _Wpm->getPoolByID(ID).getName().c_str()); + int index = m_PoolList.AddString(utf8ToTStr(poolId)); nlassert(index != LB_ERR); m_PoolList.SetItemData(index, ID); return index; @@ -304,7 +303,7 @@ void CWaterPoolEditor::OnAddPool() { if (_Wpm->hasPool(cpi.PoolID) ) { - MessageBox("Pool already exists", "error"); + MessageBox(_T("Pool already exists"), _T("error")); } else { @@ -324,7 +323,7 @@ void CWaterPoolEditor::OnDeletePool() UpdateData(); if (m_PoolList.GetCount() == 1) { - MessageBox("Must have at least one water pool", "error"); + MessageBox(_T("Must have at least one water pool"), _T("error")); } else { @@ -350,15 +349,15 @@ void CWaterPoolEditor::OnSelchangeMapSize() void CWaterPoolEditor::OnLoadPool() { - static char BASED_CODE szFilter[] = "NeL Water Pool Files (*.wpf)|*.wpf||"; - CFileDialog fileDlg( TRUE, ".wpf", "*.wpf", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("NeL Water Pool Files (*.wpf)|*.wpf||"); + CFileDialog fileDlg( TRUE, _T(".wpf"), _T("*.wpf"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal()==IDOK) { try { NLMISC::CIXml iXml; NLMISC::CIFile iF; - if (iF.open((LPCTSTR) fileDlg.GetPathName())) + if (iF.open(tStrToUtf8(fileDlg.GetPathName()))) { if (iXml.init (iF)) { @@ -370,17 +369,17 @@ void CWaterPoolEditor::OnLoadPool() else { iF.close(); - MessageBox (("Unable to init xml stream from file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to init xml stream from file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } else { - MessageBox (("Unable to open file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to open file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } - catch (NLMISC::Exception& e) + catch (const NLMISC::Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -388,15 +387,15 @@ void CWaterPoolEditor::OnLoadPool() void CWaterPoolEditor::OnSavePool() { - static char BASED_CODE szFilter[] = "NeL Water Pool Files (*.wpf)|*.wpf||"; - CFileDialog fileDlg( TRUE, ".wpf", "*.wpf", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + static TCHAR BASED_CODE szFilter[] = _T("NeL Water Pool Files (*.wpf)|*.wpf||"); + CFileDialog fileDlg( TRUE, _T(".wpf"), _T("*.wpf"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal()==IDOK) { try { NLMISC::COXml oXml; NLMISC::COFile oF; - if (oF.open((LPCTSTR) fileDlg.GetPathName())) + if (oF.open(tStrToUtf8(fileDlg.GetPathName()))) { if (oXml.init (&oF)) { @@ -407,17 +406,17 @@ void CWaterPoolEditor::OnSavePool() else { oF.close(); - MessageBox (("Unable to init xml stream from file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to init xml stream from file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } else { - MessageBox (("Unable to open file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to open file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } - catch (NLMISC::Exception& e) + catch (const NLMISC::Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } diff --git a/code/nel/tools/3d/object_viewer_exe/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 a93decee5..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,7 +16,7 @@ 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) 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 4fb8b4455..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,6 +25,8 @@ 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() 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..f0de21376 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(); @@ -716,41 +713,41 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Get the nodes std::vector vectNode; theCNelExport.getSelectedNode (vectNode); - if (vectNode.size() == 0) + if (vectNode.empty()) { - ::MessageBox(hWnd, "No nodes selected", "Error", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(hWnd, _T("No nodes selected"), _T("Error"), MB_OK|MB_ICONEXCLAMATION); return ret; } - // create a mem displayer, that will receive errors + // create a mem displayer, that will receive errors try - { + { // test all nodes for(std::vector::iterator it = vectNode.begin(); it != vectNode.end(); ++it) { nlassert(theCNelExport._ExportNel); if (!theCNelExport._ExportNel->selectInterfaceVertices(**it, time)) { - ::MessageBox(NULL, "Unable to bind interface of mesh %s", (*it)->GetName(), MB_OK | MB_ICONEXCLAMATION); + ::MessageBox(NULL, _T("Unable to bind interface of mesh %s"), (*it)->GetName(), MB_OK | MB_ICONEXCLAMATION); break; - } - } + } + } theIP->RedrawViews(time); } - catch(std::exception &e) - { - ::MessageBox(hWnd, e.what(), "Error", MB_OK | MB_ICONEXCLAMATION); - } + catch(const std::exception &e) + { + ::MessageBox(hWnd, utf8ToTStr(e.what()), _T("Error"), MB_OK | MB_ICONEXCLAMATION); + } } } - break; + break; } - + break; case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MOUSEMOVE: - theCNelExport._Ip->RollupMouseMessage(hWnd,msg,wParam,lParam); + 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.def b/code/nel/tools/3d/plugin_max/nel_export/nel_export.def index cd87c4dc0..8e50aaeed 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export.def +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export.def @@ -1,4 +1,4 @@ -LIBRARY nelexport.dlu +;LIBRARY nelexport.dlu EXPORTS LibDescription @1 LibNumberClasses @2 diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export.h b/code/nel/tools/3d/plugin_max/nel_export/nel_export.h index f6f0b145a..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..8bfcf3e5d 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_collision.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_collision.cpp @@ -30,7 +30,7 @@ using namespace NLPACS; // -------------------------------------------------- -bool CNelExport::exportCollision (const char *sPath, std::vector &nodes, TimeValue time) +bool CNelExport::exportCollision (const std::string &sPath, std::vector &nodes, TimeValue time) { // get list of CMB froms nodes. std::vector > meshBuildList; @@ -43,7 +43,7 @@ bool CNelExport::exportCollision (const char *sPath, std::vector &nodes // ULONG SelectDir(HWND Parent, char* Title, char* Path); std::string path = std::string(sPath); - if (path.size() == 0 || path[path.size()-1] != '\\' && path[path.size()-1] != '/') + if (path.empty() || path[path.size()-1] != '\\' && path[path.size()-1] != '/') path.insert(path.end(), '/'); if (meshBuildList.empty()) return true; @@ -148,7 +148,7 @@ bool CNelExport::exportCollision (const char *sPath, INode& node, Interface& _Ip */ // -------------------------------------------------- -bool CNelExport::exportPACSPrimitives (const char *sPath, std::vector &nodes, TimeValue time) +bool CNelExport::exportPACSPrimitives (const std::string &sPath, std::vector &nodes, TimeValue time) { // Build the primitive block NLPACS::CPrimitiveBlock primitiveBlock; @@ -172,12 +172,12 @@ bool CNelExport::exportPACSPrimitives (const char *sPath, std::vector & } else { - nlwarning ("Can't init XML stream with file %s", sPath); + nlwarning ("Can't init XML stream with file %s", sPath.c_str()); } } else { - nlwarning ("Can't open the file %s for writing", sPath); + nlwarning ("Can't open the file %s for writing", sPath.c_str()); } } return false; diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp index 46d88757b..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..adfba5a98 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp @@ -102,24 +102,22 @@ void regsiterOVPath () //#ifdef NL_DEBUG_FAST // HMODULE hModule = GetModuleHandle("object_viewer_dll_df.dll"); #if defined (NL_DEBUG) - HMODULE hModule = GetModuleHandle("object_viewer_dll_d.dll"); + HMODULE hModule = GetModuleHandle(_T("object_viewer_dll_d.dll")); //#elif defined (NL_RELEASE_DEBUG) // HMODULE hModule = GetModuleHandle("object_viewer_dll_rd.dll"); #else - HMODULE hModule = GetModuleHandle("object_viewer_dll_r.dll"); + HMODULE hModule = GetModuleHandle(_T("object_viewer_dll_r.dll")); #endif - if (!hModule) { ::MessageBox(NULL, "'hModule' failed at '" __FUNCTION__ "' in file '" __FILE__ " on line " NL_MACRO_TO_STR(__LINE__), "NeL Export", MB_OK | MB_ICONERROR); return; } - char sModulePath[256]; + if (!hModule) { ::MessageBox(NULL, _T("'hModule' failed at '") __FUNCTION__ _T("' in file '") __FILE__ _T(" on line ") NL_MACRO_TO_STR(__LINE__), _T("NeL Export"), MB_OK | MB_ICONERROR); return; } + TCHAR sModulePath[256]; int res = GetModuleFileName(hModule, sModulePath, 256); - if (!res) { ::MessageBox(NULL, "'res' failed at '" __FUNCTION__ "' in file '" __FILE__ " on line " NL_MACRO_TO_STR(__LINE__), "NeL Export", MB_OK | MB_ICONERROR); return; } - char SDrive[512]; - char SDir[512]; - _splitpath (sModulePath, SDrive, SDir, NULL, NULL); - _makepath (sModulePath, SDrive, SDir, "object_viewer", ".cfg"); + if (!res) { ::MessageBox(NULL, _T("'res' failed at '") __FUNCTION__ _T("' in file '") __FILE__ _T(" on line ") NL_MACRO_TO_STR(__LINE__), _T("NeL Export"), MB_OK | MB_ICONERROR); return; } + + std::string modulePath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)) + "object_viewer.cfg"; // Load the config file CConfigFile cf; - cf.load (sModulePath); + cf.load (modulePath); try { @@ -128,7 +126,7 @@ void regsiterOVPath () for (uint i=0; i<(uint)search_pathes.size(); i++) CPath::addSearchPath (search_pathes.asString(i)); } - catch(EUnknownVar &) + catch(const EUnknownVar &) {} try @@ -138,7 +136,7 @@ void regsiterOVPath () for (uint i=0; i<(uint)recursive_search_pathes.size(); i++) CPath::addSearchPath (recursive_search_pathes.asString(i), true, false); } - catch(EUnknownVar &) + catch(const EUnknownVar &) {} // Add extension remapping @@ -155,7 +153,7 @@ void regsiterOVPath () CPath::remapExtension(extensions_remapping.asString(i), extensions_remapping.asString(i+1), true); } } - catch (EUnknownVar &) + catch (const EUnknownVar &) { } } @@ -176,7 +174,7 @@ void CNelExport::viewMesh (TimeValue time) // Check wether there's not an instance currently running if (view->isInstanceRunning()) { - ::MessageBox(NULL, "An instance of the viewer is currently running, please close it :)", "NeL Export", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(NULL, _T("An instance of the viewer is currently running, please close it :)"), _T("NeL Export"), MB_OK|MB_ICONEXCLAMATION); return; } @@ -193,7 +191,7 @@ void CNelExport::viewMesh (TimeValue time) // Init it if (!view->initUI()) { - ::MessageBox(NULL, "Failed to initialize object viewer ui, this may be a driver init issue, check your log.log files", "NeL Export", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(NULL, _T("Failed to initialize object viewer ui, this may be a driver init issue, check your log.log files"), _T("NeL Export"), MB_OK|MB_ICONEXCLAMATION); IObjectViewer::releaseInterface(view); return; } @@ -302,7 +300,7 @@ void CNelExport::viewMesh (TimeValue time) _ExportNel->buildSkeletonShape (*skelShape, *skeletonRoot, &(iteSkeleton->second), mapId, time); // Add the shape in the view - uint instance = view->addSkel (skelShape, skeletonRoot->GetName()); + uint instance = view->addSkel (skelShape, tStrToUtf8(skeletonRoot->GetName())); // Add tracks CAnimation *anim=new CAnimation; @@ -367,9 +365,9 @@ void CNelExport::viewMesh (TimeValue time) INode* pNode=_Ip->GetSelNode (nNode); string sTmp = "Object Name: "; - sTmp += pNode->GetName(); + sTmp += tStrToUtf8(pNode->GetName()); ProgBar.setLine (0, sTmp); - sTmp = ""; + sTmp.clear(); for (uint32 i = 1; i < 10; ++i) ProgBar.setLine (i, sTmp); sTmp = "Last Error"; @@ -412,7 +410,7 @@ void CNelExport::viewMesh (TimeValue time) if (pShape) { // Add the shape in the view - uint instance = view->addMesh (pShape, pNode->GetName(), iteSkelShape->second.SkeletonInstance); + uint instance = view->addMesh (pShape, tStrToUtf8(pNode->GetName()).c_str(), iteSkelShape->second.SkeletonInstance); // Add tracks CAnimation *anim=new CAnimation; @@ -582,8 +580,8 @@ void CNelExport::viewMesh (TimeValue time) NLMISC::clamp(slInfo.CellSurfaceLightSize, 0.001f, 1000000.f); slInfo.CellRaytraceDeltaZ= theExportSceneStruct.SurfaceLightingDeltaZ; // no more add any prefix to the colision identifier. - slInfo.ColIdentifierPrefix= ""; - slInfo.ColIdentifierSuffix= ""; + slInfo.ColIdentifierPrefix.clear(); + slInfo.ColIdentifierSuffix.clear(); // Build RetrieverBank and GlobalRetriever from collisions in scene _ExportNel->computeCollisionRetrieverFromScene(time, slInfo.RetrieverBank, slInfo.GlobalRetriever, slInfo.ColIdentifierPrefix.c_str(), slInfo.ColIdentifierSuffix.c_str(), slInfo.IgFileName); diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_zone.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_zone.cpp index e74e39dd0..334b56aff 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_zone.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_zone.cpp @@ -25,7 +25,7 @@ using namespace NLMISC; // -------------------------------------------------- -bool CNelExport::exportZone (const char *sPath, INode& node, TimeValue time) +bool CNelExport::exportZone (const std::string &sPath, INode& node, TimeValue time) { // Result to return bool bRet=false; diff --git a/code/nel/tools/3d/plugin_max/nel_export/progress.cpp b/code/nel/tools/3d/plugin_max/nel_export/progress.cpp index 167a4fc14..17b3fab2a 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/progress.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/progress.cpp @@ -52,24 +52,25 @@ INT_PTR CALLBACK CalculatingDialogCallback ( case WM_PAINT: { - char temp[256]; + TCHAR temp[256]; SendMessage( GetDlgItem( hwndDlg, IDC_PROGRESS1 ), PBM_SETPOS, (int)(pClass->rRatioCalculated*100), 0 ); if( pClass->rRatioCalculated > 0.0 ) { double TimeLeft = (TimeCurrent - pClass->rTimeBegin) * (1.0-pClass->rRatioCalculated); - sprintf( temp, "Time remaining : %02d h %02d m %02d s", ((uint32)TimeLeft)/3600, + _stprintf( temp, _T("Time remaining : %02d h %02d m %02d s"), ((uint32)TimeLeft)/3600, (((uint32)TimeLeft)/60)%60, (((uint32)TimeLeft))%60 ); if (pClass->bCancelCalculation) - strcpy (temp, "INTERRUPTED - Finishing current object..."); - SendMessage (GetDlgItem (hwndDlg, IDC_STATICTIMELEFT), WM_SETTEXT, 0, (long)temp); + _tcscpy_s (temp, 256, _T("INTERRUPTED - Finishing current object...")); + + SendMessage (GetDlgItem (hwndDlg, IDC_STATICTIMELEFT), WM_SETTEXT, 0, (LPARAM)temp); SendMessage (GetDlgItem (hwndDlg, IDC_BUTTONCANCEL), WM_PAINT, 0, 0); } - string all = ""; + string all; for (uint32 i = 0; i < 14; ++i) all += pClass->sInfoProgress[i] + "\n"; - SendMessage (GetDlgItem (hwndDlg, IDC_STATICINFO), WM_SETTEXT, 0, (long)all.c_str()); + SendMessage (GetDlgItem (hwndDlg, IDC_STATICINFO), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(all)); } break; @@ -119,7 +120,7 @@ void CProgressBar::initProgressBar( sint32 nNbMesh, Interface &ip) MAKEINTRESOURCE(IDD_CALCULATING), NULL,//ip.GetMAXHWnd(), CalculatingDialogCallback, - (long)this ); + (LPARAM)this ); } // ----------------------------------------------------------------------------------------------- diff --git a/code/nel/tools/3d/plugin_max/nel_export/std_afx.h b/code/nel/tools/3d/plugin_max/nel_export/std_afx.h index 9b4b18357..ba7b4b4c0 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/std_afx.h +++ b/code/nel/tools/3d/plugin_max/nel_export/std_afx.h @@ -71,5 +71,6 @@ namespace std #endif #include "nel/misc/bsphere.h" +#include "nel/misc/path.h" #endif diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/CMakeLists.txt b/code/nel/tools/3d/plugin_max/nel_mesh_lib/CMakeLists.txt index 3c96760a8..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,6 +8,8 @@ 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() diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp index d82e2a394..5ccc223f9 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp @@ -128,7 +128,7 @@ void SLightBuild::convertFromMaxLight (INode *node,TimeValue tvTime) if (maxLight->EvalLightState(tvTime, valid, &ls)!=REF_SUCCEED) return; - this->Name = node->GetName(); + this->Name = tStrToUtf8(node->GetName()); // Retrieve the correct light Group Name this->AnimatedLight = CExportNel::getAnimatedLight (node); @@ -295,7 +295,7 @@ void SLightBuild::convertFromMaxLight (INode *node,TimeValue tvTime) INode *exclNode = exclusionList[i]; if (exclNode) // Crashfix // FIXME: Why is this NULL? { - string tmp = exclNode->GetName(); + string tmp = tStrToUtf8(exclNode->GetName()); this->setExclusion.insert(tmp); } } @@ -1930,7 +1930,7 @@ void supprLightNoInteractOne( vector &vLights, CMesh::CMeshBuild* p { bool bInteract = false; - if( vLights[i].setExclusion.find( node.GetName() ) != vLights[i].setExclusion.end() ) + if( vLights[i].setExclusion.find(tStrToUtf8(node.GetName()) ) != vLights[i].setExclusion.end() ) { bInteract = false; } @@ -2005,7 +2005,7 @@ void CExportNel::deleteLM(INode& ZeNode) string sSaveName; sSaveName = _Options.sExportLighting; if( sSaveName[sSaveName.size()-1] != '\\' ) sSaveName += "\\"; - sSaveName += ZeNode.GetName(); + sSaveName += tStrToUtf8(ZeNode.GetName()); char tmp[32]; sprintf( tmp, "%d", i ); sSaveName += tmp; @@ -2063,7 +2063,7 @@ void sans_majuscule_au_debut_LinkToObjectAround (CMesh::CMeshBuild *pMB, CMeshBa } } - if (ivert.size() > 0) + if (!ivert.empty()) { // Get all faces that contains at least one shared vertex for (k = 0; k < wrt.vMB[i]->Faces.size(); ++k) @@ -2128,7 +2128,7 @@ void appendLightmapLog (COFile &outputLog, const char *lightmapName, const vecto outputLog.serialBuffer ((uint8*)text.c_str(), text.size()); } - catch (exception &e) + catch (const exception &e) { nlwarning ("Error writing the file : %s", e.what()); } @@ -2258,7 +2258,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB // Bubble sort pointer to the faces (Material sorting) ClearFaceWithNoLM( pMB, pMBB, AllFaces ); - if( AllFaces.size() == 0 ) + if( AllFaces.empty() ) { if (InfoLog) InfoLog->display("CalculateLM : %d ms\n", timeGetTime()-t); @@ -2276,7 +2276,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { string thetext; thetext = "Warning "; - thetext += ZeNode.GetName(); + thetext += tStrToUtf8(ZeNode.GetName()); thetext = "have all faces NOT mapped (UV2)"; if (gOptions.FeedBack != NULL) { @@ -2325,11 +2325,11 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { // Make an error message string sTmp = "Warning : "; - sTmp += ZeNode.GetName(); + sTmp += tStrToUtf8(ZeNode.GetName()); sTmp += " has mapping problem"; // Script trace - mprintf ((sTmp+"\n").c_str()); + mprintf (utf8ToTStr((sTmp+"\n"))); // Feedback is here ? if (gOptions.FeedBack != NULL) @@ -2436,7 +2436,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { string sTmp = "Placement"; gOptions.FeedBack->setLine (3, sTmp); - sTmp = ""; + sTmp.clear(); for(i=4;i<10;++i) gOptions.FeedBack->setLine (i, sTmp); gOptions.FeedBack->update (); @@ -2525,12 +2525,12 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB // Get the name of the max project char projectName[512]; - _splitpath (_Ip->GetCurFileName(), NULL, NULL, projectName, NULL); + _wsplitpath (_Ip->GetCurFileName(), NULL, NULL, utf8ToTStr(projectName), NULL); // Add lightmap information in the lightmap log COFile outputLog; if (outputLightmapLog) - createLightmapLog (outputLog, gOptions.sExportLighting.c_str(), projectName, ZeNode.GetName()); + createLightmapLog (outputLog, gOptions.sExportLighting.c_str(), projectName, tStrToUtf8(ZeNode.GetName()).c_str()); // Update UV coords to Texture space PutFaceUV1InTextureCoord( LightMap.w, LightMap.h, AllFaces.begin(), AllFaces.size() ); @@ -2559,7 +2559,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { CTextureFile *pLightMap = new CTextureFile(); //string sSaveName = AllMeshBuilds[nNode].second->GetName(); - string sSaveName = ZeNode.GetName(); + string sSaveName = tStrToUtf8(ZeNode.GetName()); char tmp[32]; sSaveName += "_"; sprintf( tmp, "%d", nLightMapNb ); @@ -2628,13 +2628,12 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB pLightMap->writeTGA (f, 32); } } - catch(Exception &e) + catch(const Exception &e) { if (gOptions.FeedBack != NULL) { - char message[512]; - sprintf (message, "Can't write the file %s : %s", sSaveName, e.what()); - mprintf (message); + std::string message = toString("Can't write the file %s : %s", sSaveName.c_str(), e.what()); + mprintf (utf8ToTStr(message)); } } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp index a0e6139b2..1a89c8d31 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp @@ -113,7 +113,7 @@ void CRTWorld::build (vector &AllLights, CVector &trans, bool bExcl pLAP->create( 64 ); // width of each grid in number of square for( j = 0; j < vMB.size(); ++j ) { - if (rLight.setExclusion.find (vINode[j]->GetName()) != rLight.setExclusion.end()) + if (rLight.setExclusion.find (tStrToUtf8(vINode[j]->GetName())) != rLight.setExclusion.end()) continue; for (k = 0; k < vMB[j]->Faces.size(); ++k) @@ -142,7 +142,7 @@ void CRTWorld::build (vector &AllLights, CVector &trans, bool bExcl pLAD->create (64, rLight.rDirRadius/64.0f, rLight.Direction); for( j = 0; j < vMB.size(); ++j ) { - if (rLight.setExclusion.find (vINode[j]->GetName()) != rLight.setExclusion.end()) + if (rLight.setExclusion.find (tStrToUtf8(vINode[j]->GetName())) != rLight.setExclusion.end()) continue; for (k = 0; k < vMB[j]->Faces.size(); ++k) @@ -246,7 +246,7 @@ CRGBAF CRTWorld::raytrace (NLMISC::CVector &vVertex, sint32 nLightNb, uint8& rtV RayOfLight.clip (t); - if (RayOfLight.Shapes.size() == 0) + if (RayOfLight.Shapes.empty()) return CRGBAF(0.0f, 0.0f, 0.0f, 0.0f); // Next selected element diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_anim.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_anim.cpp index 06e3c051d..d55312af6 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_anim.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_anim.cpp @@ -34,6 +34,10 @@ using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + static Class_ID DefNoteTrackClassID(NOTETRACK_CLASS_ID, 0); #define BOOL_CONTROL_CLASS_ID 0x984b8d27 @@ -185,7 +189,7 @@ void CExportNel::addSSSTrack(CSSSBuild &ssBuilder, INode& node) if(note) { CSSSBuild::CKey ks; - ks.Value = std::string(note->note); + ks.Value = note->note.ToUTF8(); ks.Time= CExportNel::convertTime (note->time); bs.Track.push_back(ks); } @@ -224,7 +228,7 @@ NL3D::CTrackKeyFramerConstString* CExportNel::buildFromNoteTrack(INode& node) { firstDate = CExportNel::convertTime (note->time); } - ks.Value = std::string(note->note); + ks.Value = note->note.ToUTF8(); lastDate = CExportNel::convertTime (note->time); st->addKey(ks , lastDate ); @@ -605,7 +609,7 @@ void CExportNel::addMorphTracks (NL3D::CAnimation& animation, INode& node, const if (pNode == NULL) continue; std::string name = parentName; - name += pNode->GetName(); + name += tStrToUtf8(pNode->GetName()); name += "MorphFactor"; IParamBlock *pb = (IParamBlock*)(pMorphMod->SubAnim (i+1)); @@ -1761,7 +1765,7 @@ ITrack* CExportNel::buildATrack (CAnimation& animation, Control& c, TNelValueTyp } else { - MessageBox (NULL, "Warning: no pos track exported!", "Tmp NEL", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, _T("Warning: no pos track exported!"), _T("Tmp NEL"), MB_OK|MB_ICONEXCLAMATION); } } } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp index 0a01a9fb8..d9657cd68 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp @@ -73,7 +73,7 @@ CCollisionMeshBuild* CExportNel::createCollisionMeshBuild(std::vector & { // get the mesh name uint meshId = rootMeshNames.size(); - rootMeshNames.push_back(nodes[node]->GetName()); + rootMeshNames.push_back(tStrToUtf8(nodes[node]->GetName())); bool collision = getScriptAppData (nodes[node], NEL3D_APPDATA_COLLISION, 0) != 0; bool exterior = getScriptAppData (nodes[node], NEL3D_APPDATA_COLLISION_EXTERIOR, 0) != 0; @@ -263,7 +263,7 @@ CCollisionMeshBuild* CExportNel::createCollisionMeshBuild(std::vector & // report warnings if (!warnings.empty()) { - string message = "Warning(s) occured during collision export\n(defective links may result) error"; + string message = "Warning(s) occurred during collision export\n(defective links may result) error"; for (i=0; i & // report warnings if (!errors.empty()) { - string message = "Error(s) occured during collision export\n(edge issues)"; + string message = "Error(s) occurred during collision export\n(edge issues)"; for (i=0; i & pCollisionMeshBuild = NULL; } - // Return the shape pointer or NULL if an error occured. + // Return the shape pointer or NULL if an error occurred. return pCollisionMeshBuild; } @@ -391,7 +391,7 @@ void CExportNel::computeCollisionRetrieverFromScene(TimeValue time, // Default: empty retrieverBank/globalRetriever retrieverBank= NULL; globalRetriever= NULL; - retIgName= ""; + retIgName.clear(); // get list of nodes from scene std::vector nodes; diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp index afe64907b..f7c8135ad 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp @@ -768,7 +768,7 @@ void CExportNel::buildAMaterial (NL3D::CMaterial& material, CMaxMaterialInfo& ma // Set material name TSTR name=mtl.GetName(); - materialInfo.MaterialName = (const char*)name; + materialInfo.MaterialName = name.ToUTF8(); } else { @@ -1120,7 +1120,7 @@ void CExportNel::buildAMaterial (NL3D::CMaterial& material, CMaxMaterialInfo& ma // Set material name TSTR name=mtl.GetName(); - materialInfo.MaterialName = (const char*)name; + materialInfo.MaterialName = name.ToUTF8(); } } @@ -1142,22 +1142,6 @@ int CExportNel::getVertMapChannel (Texmap& texmap, Matrix3& channelMatrix, TimeV // get the absolute or relative path from a texture filename static std::string ConvertTexFileName(const std::string &path, bool _AbsolutePath) { - /*// File name, maxlen 256 under windows - char sFileName[512]; - strcpy (sFileName, src); - - // Let absolute path ? - if (!_AbsolutePath) - { - // Decompose bitmap file name - char sName[256]; - char sExt[256]; - _splitpath (sFileName, NULL, NULL, sName, sExt); - - // Make the final path - _makepath (sFileName, NULL, NULL, sName, sExt); - } - return std::string(sFileName);*/ if (_AbsolutePath) { return path; @@ -1271,7 +1255,7 @@ ITexture* CExportNel::buildATexture (Texmap& texmap, CMaterialDesc &remap3dsTexC else // standard texture { srcTex = new CTextureFile; - std::string mapName = pBitmap->GetMapName(); + std::string mapName = tStrToUtf8(pBitmap->GetMapName()); static_cast(srcTex)->setFileName (ConvertTexFileName(mapName, _AbsolutePath)); } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh.cpp index bd48be1ea..d39020a64 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh.cpp @@ -116,7 +116,7 @@ CMesh::CMeshBuild* CExportNel::createMeshBuild(INode& node, TimeValue tvTime, CM } } - // Return the shape pointer or NULL if an error occured. + // Return the shape pointer or NULL if an error occurred. return pMeshBuild; } @@ -266,7 +266,7 @@ NL3D::IShape *CExportNel::buildShape (INode& node, TimeValue time, const TInodeP std::string nodeName=getScriptAppData (&node, NEL3D_APPDATA_LOD_NAME+lod, ""); // Get the node - INode *lodNode=_Ip->GetINodeByName(nodeName.c_str()); + INode *lodNode=_Ip->GetINodeByName(utf8ToTStr(nodeName)); if (lodNode) { // Index of the lod in the build structure @@ -467,7 +467,7 @@ NL3D::IShape *CExportNel::buildShape (INode& node, TimeValue time, const TInodeP retShape->setDistMax (distmax); } - // Return the shape pointer or NULL if an error occured. + // Return the shape pointer or NULL if an error occurred. return retShape; } @@ -611,7 +611,7 @@ void CExportNel::buildBaseMeshInterface (NL3D::CMeshBase::CMeshBaseBuild& buildM continue; // get factor here ! buildMesh.DefaultBSFactors.push_back(0.0f); - std::string sTemp = pNode->GetName(); + std::string sTemp = tStrToUtf8(pNode->GetName()); buildMesh.BSNames.push_back (sTemp); } @@ -1063,9 +1063,8 @@ void CExportNel::buildMeshInterface (TriObject &tri, CMesh::CMeshBuild& buildMes // Error code ? if (error!=NoError) { - char msg[512]; - sprintf (msg, "%s skin: %s", getName (node).c_str(), ErrorMessage[error]); - MessageBox (NULL, msg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string msg = toString("%s skin: %s", getName (node).c_str(), ErrorMessage[error]); + MessageBoxW (NULL, utf8ToTStr(msg), L"NeL export", MB_OK|MB_ICONEXCLAMATION); } else { @@ -1181,7 +1180,7 @@ void CExportNel::getBSMeshBuild (std::vector &bsList, INode convertMatrix(finalSpace, node.GetNodeTM(time)); CMeshBase::CMeshBaseBuild *dummyMBB = NULL; - std::auto_ptr baseMB(createMeshBuild (node, time, dummyMBB, finalSpace)); + CUniquePtr baseMB(createMeshBuild (node, time, dummyMBB, finalSpace)); delete dummyMBB; dummyMBB = NULL; if (baseMB.get() == NULL) return; @@ -1421,7 +1420,7 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP if (InfoLog) InfoLog->display("End of %s \n", node.GetName()); - // Return the shape pointer or NULL if an error occured. + // Return the shape pointer or NULL if an error occurred. return meshGeom; } @@ -1493,7 +1492,7 @@ void CExportNel::buildMeshMorph (CMesh::CMeshBuild& buildMesh, INode &node, Time continue; } - bs.Name = pNode->GetName(); + bs.Name = tStrToUtf8(pNode->GetName()); bool bIsDeltaPos = false; bs.deltaPos.resize (nNbVertVB, CVector::Null); diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp index 899c28a28..0cbd8fbe1 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp @@ -20,7 +20,7 @@ #include #include - +#include #include "nel/misc/line.h" #include "nel/misc/polygon.h" @@ -316,7 +316,7 @@ static void AddNodeToQuadGrid(const NLMISC::CAABBox &delimiter, TNodeFaceQG &des { if (delimiter.intersect(nodeBBox)) { - nldebug((std::string("Adding ") + node.GetName() + std::string(" to mesh interface quad grid")).c_str()); + nldebug("Adding %s to mesh interface quad grid", tStrToUtf8(node.GetName()).c_str()); // add this node tris ObjectState os = node.EvalWorldState(time); Object *obj = os.obj; @@ -579,9 +579,9 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetName (); + string originalName = (*lib)[i]->GetName ().ToUTF8(); renameMap.insert (map::value_type (newName, originalName)); - (*lib)[i]->SetName (newName.c_str ()); + (*lib)[i]->SetName (utf8ToTStr(newName)); } // Merge the interface project @@ -604,7 +604,7 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetName (); + string key = (*lib)[i]->GetName ().ToUTF8(); map::iterator ite = renameMap.find (key); // Not found ? This is a merged material @@ -612,9 +612,9 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetName (); + string originalName = (*lib)[i]->GetName ().ToUTF8(); renameMap.insert (map::value_type (newName, originalName)); - (*lib)[i]->SetName (newName.c_str ()); + (*lib)[i]->SetName (utf8ToTStr(newName)); } } @@ -622,12 +622,12 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetName (); + string key = (*lib)[i]->GetName ().ToUTF8(); map::iterator ite = renameMap.find (key); if (ite != renameMap.end ()) { // Rename the material with its original name - (*lib)[i]->SetName (ite->second.c_str ()); + (*lib)[i]->SetName (utf8ToTStr(ite->second)); } } @@ -648,7 +648,7 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetParamDef(id); // Good name? - if (strcmp (paramDef.int_name, sName)==0) + if (strcmp (tStrToUtf8(paramDef.int_name).c_str(), sName)==0) { // ok, return this subanim #if MAX_VERSION_MAJOR >= 14 @@ -288,7 +288,7 @@ Control* CExportNel::getControlerByName (Animatable& node, const char* sName) { // Sub anim name TSTR name=node.SubAnimName (s); - if (strcmp (name, sName)==0) + if (strcmp (name.ToUTF8(), sName)==0) { // Get the controller pointer of this sub anim Control* c=GetControlInterface (node.SubAnim(s)); @@ -332,7 +332,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName ParamDef& paramDef=param->GetParamDef(id); // Good name? - if (strcmp (paramDef.int_name, sName)==0) + if (strcmp (tStrToUtf8(paramDef.int_name).c_str(), sName)==0) { // Check this value is good type ParamType2 paramType = param->GetParameterType(id); @@ -372,7 +372,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName break; case TYPE_FILENAME: case TYPE_STRING: - *(std::string*)pValue = param->GetStr (id, tvTime); + *(std::string*)pValue = tStrToUtf8(param->GetStr (id, tvTime)); bRes = TRUE; break; case TYPE_FILENAME_TAB: @@ -382,7 +382,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName uint total = param->Count (id); rTab.resize(total); for( uint i = 0; i < total; ++i ) - rTab[i] = param->GetStr (id, tvTime, i); + rTab[i] = tStrToUtf8(param->GetStr (id, tvTime, i)); bRes = TRUE; } break; @@ -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..cd8fcb5b7 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_scene.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_scene.cpp @@ -93,7 +93,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v resultInstanceNode[nNumIG] = pNode; if (aIGArray[nNumIG].InstanceName == "") // no instance name was set, takes the node name instead { - aIGArray[nNumIG].InstanceName = pNode->GetName(); + aIGArray[nNumIG].InstanceName = tStrToUtf8(pNode->GetName()); } // Visible? always true, but if special flag for camera collision @@ -236,10 +236,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v pMB->Vertices[pMB->Faces[j].Corner[2].Vertex]) ) { // ERROR : The volume is not convex !!! - char tam[256]; - sprintf(tam,"ERROR: The cluster %s is not convex.",vectNode[i]->GetName()); - //MessageBox(NULL,tam,"Error",MB_OK|MB_ICONERROR); - nlwarning(tam); + nlwarning("ERROR: The cluster %s is not convex.", tStrToUtf8(vectNode[i]->GetName()).c_str()); } } @@ -247,7 +244,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v clusterTemp.VisibleFromFather = bVisibleFromFather; clusterTemp.FatherAudible = bFatherAudible; clusterTemp.AudibleFromFather = bAudibleFromFather; - clusterTemp.Name = pNode->GetName(); + clusterTemp.Name = tStrToUtf8(pNode->GetName()); vClusters.push_back (clusterTemp); delete pMB; pMB = NULL; @@ -336,10 +333,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (!portalTemp.setPoly (polyv)) { // ERROR : Poly not convex, or set of vertices not plane - char tam[256]; - sprintf(tam,"ERROR: The portal %s is not convex.",vectNode[i]->GetName()); - //MessageBox(NULL,tam,"Error",MB_OK|MB_ICONERROR); - nlwarning(tam); + nlwarning("ERROR: The portal %s is not convex.", tStrToUtf8(vectNode[i]->GetName()).c_str()); } if (nAccelType&16) // is dynamic portal ? @@ -348,7 +342,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (!InstanceName.empty()) portalTemp.setName (InstanceName); else - portalTemp.setName (string(pNode->GetName())); + portalTemp.setName (tStrToUtf8(pNode->GetName())); } // Check if portal has 2 cluster @@ -368,10 +362,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (nNbCluster != 2) { // ERROR - char tam[256]; - sprintf(tam,"ERROR: The portal %s has not 2 clusters but %d",vectNode[i]->GetName(), nNbCluster); - //MessageBox(NULL,tam,"Error",MB_OK|MB_ICONERROR); - nlwarning(tam); + nlwarning("ERROR: The portal %s has not 2 clusters but %d", tStrToUtf8(vectNode[i]->GetName()).c_str(), nNbCluster); } @@ -467,7 +458,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v delete ss.getShapePointer(); ss.setShapePointer(NULL); } - catch (NLMISC::Exception &e) + catch (const NLMISC::Exception &e) { nlwarning(e.what()); } @@ -510,13 +501,10 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v } // debug purpose : to remove - if (vClusters.size() > 0) - if (aIGArray[nNumIG].Clusters.size() == 0) + if (!vClusters.empty()) + if (aIGArray[nNumIG].Clusters.empty()) { - char tam[256]; - sprintf(tam,"ERROR: Object %s is not attached to any cluster\nbut his flag clusterize is set", pNode->GetName()); - //MessageBox(NULL, tam, "Warning", MB_OK); - nlwarning(tam); + nlwarning("ERROR: Object %s is not attached to any cluster\nbut his flag clusterize is set", tStrToUtf8(pNode->GetName()).c_str()); } // debug purpose : to remove @@ -712,10 +700,10 @@ void CExportNel::buildScene (NL3D::CScene &scene, NL3D::CShapeBank &shapeBank, I if ( (!pNode->IsHidden () || buildHidden) && (pNode->Selected () || !onlySelected) ) { string sTmp = "Object Name: "; - sTmp += pNode->GetName(); + sTmp += tStrToUtf8(pNode->GetName()); if (progress) progress->setLine (0, sTmp); - sTmp = ""; + sTmp.clear(); for (uint32 i = 1; i < 10; ++i) { if (progress) diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp index a0971d587..cf99e2c0c 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp @@ -36,11 +36,19 @@ bool CExportNel::scriptEvaluate (const char *script, void *out, TNelScriptValueT four_typed_value_locals(Parser* parser,Value* code,Value* result,StringStream* source); vl.parser = new Parser; - vl.source = new StringStream (const_cast(script)); + vl.source = new StringStream (utf8ToTStr(script)); vl.source->log_to(NULL); + +#if MAX_VERSION_MAJOR < 19 save_current_frames(); +#endif + try { +#if MAX_VERSION_MAJOR >= 19 + ScopedSaveCurrentFrames currentFrames; +#endif + vl.source->flush_whitespace(); vl.code = vl.parser->compile_all(vl.source); vl.result = vl.code->eval(); @@ -66,11 +74,16 @@ bool CExportNel::scriptEvaluate (const char *script, void *out, TNelScriptValueT } catch (...) { +#if MAX_VERSION_MAJOR < 19 restore_current_frames(); +#endif result=FALSE; vl.source->close(); } + +#if MAX_VERSION_MAJOR < 19 pop_value_locals(); +#endif return (result!=FALSE); } @@ -125,7 +138,7 @@ float CExportNel::getScriptAppData (Animatable *node, uint32 id, float def) // String to int float value = 0.f; - if (toFloatMax((const char*)ap->data, value)) + if (toFloatMax((const TCHAR*)ap->data, value)) return value; else return def; diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp index 3708a0906..d5030ee9d 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp @@ -114,7 +114,7 @@ INode *CExportNel::getNELScaleReferenceNode(INode &node) { std::string boneScaleName= getName(node) + boneScaleNameExt; // Get the reference node - referenceNode= _Ip->GetINodeByName(boneScaleName.c_str()); + referenceNode= _Ip->GetINodeByName(utf8ToTStr(boneScaleName)); } } @@ -455,7 +455,7 @@ uint CExportNel::buildSkinning (CMesh::CMeshBuild& buildMesh, const TInodePtrInt nlassert ((uint)ite->secondsecond] = ite->first->GetName(); + buildMesh.BonesNames[ite->second] = tStrToUtf8(ite->first->GetName()); // Next ite++; @@ -724,7 +724,7 @@ uint CExportNel::buildSkinning (CMesh::CMeshBuild& buildMesh, const TInodePtrInt nlassert (node); // Insert in the map - weightMap.insert (std::map::value_type (1, node)); + weightMap.insert (std::map::value_type (1.f, node)); } } @@ -1171,8 +1171,8 @@ void CExportNel::addSkeletonBindPos (INode& skinedNode, mapBoneBindPos& boneBind if (res != MATRIX_RETURNED) { - nlwarning("res != MATRIX_RETURNED; res = %i; boneIndex = %i / %i", res, boneIndex, count); - nlwarning("bone = %i", (uint32)(void *)bone); + nlwarning("res != MATRIX_RETURNED; res = %d; boneIndex = %u / %u", res, boneIndex, count); + nlwarning("bone = %p", bone); std::string boneName = getName (*bone); nlwarning("boneName = %s", boneName.c_str()); nlassert(false); @@ -1306,7 +1306,7 @@ static sint getBoneSide(INode *bone, std::string &mirrorName) { sint side= 0; sint pos; - mirrorName= bone->GetName(); + mirrorName = tStrToUtf8(bone->GetName()); if((pos= mirrorName.find(" R "))!=std::string::npos) { @@ -1335,7 +1335,7 @@ static INode *getMirrorBone(const std::vector &skeletonNodes, INode *bon // find for(uint i=0;iGetName()) + if(mirrorName == tStrToUtf8(skeletonNodes[i]->GetName())) return skeletonNodes[i]; } } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/CMakeLists.txt b/code/nel/tools/3d/plugin_max/nel_patch_converter/CMakeLists.txt index c173232b3..178e70f5d 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/CMakeLists.txt +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/CMakeLists.txt @@ -18,4 +18,6 @@ NL_DEFAULT_PROPS(nel_patch_converter "MAX Plugin: NeL Patch Converter") NL_ADD_RUNTIME_FLAGS(nel_patch_converter) NL_ADD_LIB_SUFFIX(nel_patch_converter) +ADD_DEFINITIONS(${MAXSDK_DEFINITIONS}) + INSTALL(TARGETS nel_patch_converter RUNTIME DESTINATION maxplugin/plugins LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/PO2RPO.h b/code/nel/tools/3d/plugin_max/nel_patch_converter/PO2RPO.h index d91777070..77c2c03ca 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/PO2RPO.h +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/PO2RPO.h @@ -50,7 +50,7 @@ class PO2RPO : public Modifier { HWND hRollup; // From Animatable - TCHAR *GetObjectName() { return GetString(IDS_CLASS_NAME); } + const MCHAR *GetObjectName() { return GetString(IDS_CLASS_NAME); } //From Modifier //TODO: Add the channels that the modifier needs to perform its modification @@ -87,8 +87,7 @@ class PO2RPO : public Modifier { void GetClassName(TSTR& s) {s = GetString(IDS_CLASS_NAME);} RefTargetHandle Clone( RemapDir &remap ); - RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, - PartID& partID, RefMessage message); + RefResult NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate); int NumSubs() { return 0; } TSTR SubAnimName(int i) { return GetString(IDS_PARAMS); } @@ -115,11 +114,11 @@ class PO2RPOClassDesc:public ClassDesc2 { return new PO2RPO(); } - const TCHAR * ClassName() {return "NeL Convert";} + const MCHAR * ClassName() {return _M("NeL Convert");} SClass_ID SuperClassID() {return OSM_CLASS_ID;} Class_ID ClassID() {return PO2RPO_CLASS_ID;} - const TCHAR* Category() {return "NeL Tools";} - const TCHAR* InternalName() { return _T("PatchObjectToNelPatchObject"); } // returns fixed parsable name (scripter-visible name) + const MCHAR* Category() {return _M("NeL Tools");} + const MCHAR* InternalName() { return _M("PatchObjectToNelPatchObject"); } // returns fixed parsable name (scripter-visible name) HINSTANCE HInstance() { return hInstance; } // returns owning module handle }; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/nel_patch_converter.cpp b/code/nel/tools/3d/plugin_max/nel_patch_converter/nel_patch_converter.cpp index 3bf145d6f..ee75bc152 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/nel_patch_converter.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/nel_patch_converter.cpp @@ -35,17 +35,17 @@ enum { po2rpo_params }; //TODO: Add enums for various parameters enum { pb_spin,}; -static ParamBlockDesc2 po2rpo_param_blk ( po2rpo_params, _T("params"), 0, &PO2RPODesc, - P_AUTO_CONSTRUCT + P_AUTO_UI, PBLOCK_REF, +static ParamBlockDesc2 po2rpo_param_blk ( po2rpo_params, _T("params"), 0, &PO2RPODesc, + P_AUTO_CONSTRUCT + P_AUTO_UI, PBLOCK_REF, //rollout IDD_PANEL, IDS_PARAMS, 0, 0, NULL, // params - pb_spin, _T("spin"), TYPE_FLOAT, P_ANIMATABLE, IDS_SPIN, - p_default, 0.1f, - p_range, 0.0f,1000.0f, - p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_EDIT, IDC_SPIN, 0.01f, - end, - end + pb_spin, _T("spin"), TYPE_FLOAT, P_ANIMATABLE, IDS_SPIN, + p_default, 0.1f, + p_range, 0.0f,1000.0f, + p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_EDIT, IDC_SPIN, 0.01f, + p_end, + p_end ); IObjParam *PO2RPO::ip = NULL; @@ -67,11 +67,11 @@ PO2RPO::~PO2RPO() Interval PO2RPO::LocalValidity(TimeValue t) { - // if being edited, return NEVER forces a cache to be built + // if being edited, return NEVER forces a cache to be built // after previous modifier. if (TestAFlag(A_MOD_BEING_EDITED)) { - return NEVER; + return NEVER; } //TODO: Return the validity interval of the modifier return NEVER; @@ -81,7 +81,7 @@ Interval PO2RPO::LocalValidity(TimeValue t) RefTargetHandle PO2RPO::Clone(RemapDir& remap) { - PO2RPO* newmod = new PO2RPO(); + PO2RPO* newmod = new PO2RPO(); //TODO: Add the cloning code here newmod->ReplaceReference(0,pblock->Clone(remap)); return(newmod); @@ -90,7 +90,7 @@ RefTargetHandle PO2RPO::Clone(RemapDir& remap) // ----------------------------------------------------------------------------------------------------------------------------------------------------------- static int done=0; -void PO2RPO::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *node) +void PO2RPO::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *node) { /* if (!done) @@ -121,19 +121,19 @@ void PO2RPO::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode * // ----------------------------------------------------------------------------------------------------------------------------------------------------------- extern HINSTANCE hInstance; -INT_PTR CALLBACK DlgProc_Panel(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DlgProc_Panel(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) + switch (message) { // ----- - case WM_INITDIALOG: + case WM_INITDIALOG: { // Get the module path HMODULE hModule = hInstance; if (hModule) { // Get module file name - char moduldeFileName[512]; + TCHAR moduldeFileName[512]; if (GetModuleFileName (hModule, moduldeFileName, 512)) { // Get version info size @@ -141,49 +141,49 @@ INT_PTR CALLBACK DlgProc_Panel(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP uint versionInfoSize=GetFileVersionInfoSize (moduldeFileName, &doomy); if (versionInfoSize) { - // Alloc the buffer - char *buffer=new char[versionInfoSize]; + // Alloc the buffer (size in bytes) + uint8_t *buffer = new uint8_t[versionInfoSize]; // Find the verion resource if (GetFileVersionInfo(moduldeFileName, 0, versionInfoSize, buffer)) { uint *versionTab; uint versionSize; - if (VerQueryValue (buffer, "\\", (void**)&versionTab, &versionSize)) + if (VerQueryValue (buffer, _T("\\"), (void**)&versionTab, &versionSize)) { // Get the pointer on the structure VS_FIXEDFILEINFO *info=(VS_FIXEDFILEINFO*)versionTab; if (info) { // Setup version number - char version[512]; - sprintf (version, "Version %d.%d.%d.%d", - info->dwFileVersionMS>>16, - info->dwFileVersionMS&0xffff, - info->dwFileVersionLS>>16, + TCHAR version[512]; + _stprintf (version, _T("Version %d.%d.%d.%d"), + info->dwFileVersionMS>>16, + info->dwFileVersionMS&0xffff, + info->dwFileVersionLS>>16, info->dwFileVersionLS&0xffff); SetWindowText (GetDlgItem (hWnd, IDC_VERSION), version); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "VS_FIXEDFILEINFO * is NULL"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("VS_FIXEDFILEINFO * is NULL")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "VerQueryValue failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("VerQueryValue failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetFileVersionInfo failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetFileVersionInfo failed")); // Free the buffer delete [] buffer; } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetFileVersionInfoSize failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetFileVersionInfoSize failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetModuleFileName failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetModuleFileName failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "hInstance NULL"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("hInstance NULL")); } // ----- @@ -214,14 +214,14 @@ void PO2RPO::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev ) void PO2RPO::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next) { //PO2RPODesc.EndEditParams(ip, this, flags, next); - ip->DeleteRollupPage(hRollup); + ip->DeleteRollupPage(hRollup); this->ip = NULL; } // ----------------------------------------------------------------------------------------------------------------------------------------------------------- -//From ReferenceMaker -RefResult PO2RPO::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget,PartID& partID, RefMessage message) +//From ReferenceMaker +RefResult PO2RPO::NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate) { //TODO: Add code to handle the various reference changed messages return REF_SUCCEED; @@ -230,21 +230,21 @@ RefResult PO2RPO::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget,P // ----------------------------------------------------------------------------------------------------------------------------------------------------------- //From Object -BOOL PO2RPO::HasUVW() -{ +BOOL PO2RPO::HasUVW() +{ //TODO: Return whether the object has UVW coordinates or not - return TRUE; + return TRUE; } // ----------------------------------------------------------------------------------------------------------------------------------------------------------- -void PO2RPO::SetGenUVW(BOOL sw) -{ - if (sw==HasUVW()) +void PO2RPO::SetGenUVW(BOOL sw) +{ + if (sw==HasUVW()) { return; } - //TODO: Set the plugin internal value to sw + //TODO: Set the plugin internal value to sw } // ----------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/rykolscript.txt b/code/nel/tools/3d/plugin_max/nel_patch_converter/rykolscript.txt index 1a73ba02f..526870762 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/rykolscript.txt +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/rykolscript.txt @@ -261,6 +261,6 @@ If file0 doesn't exist the function return true If date (file0) <= date (file1) the function return true If date (file0) > date (file1) the function return false If file1 doesn't exist the function return undefined -If an error occured, the function return undefined +If an error occurred, the function return undefined ********************************************** diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp b/code/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp index 80e715f21..7ce6c3068 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp @@ -157,7 +157,7 @@ def_visible_primitive( set_vertex_pos, "SetRykolVertexPos"); def_visible_primitive( get_vector_pos, "GetRykolVectorPos"); def_visible_primitive( set_vector_pos, "SetRykolVectorPos");*/ -void errorMessage (const char *msg, const char *title, Interface& it, bool dialog) +void errorMessage (const MCHAR *msg, const TCHAR *title, Interface& it, bool dialog) { // Text or dialog ? if (dialog) @@ -168,7 +168,8 @@ void errorMessage (const char *msg, const char *title, Interface& it, bool dialo else { // Text message - mprintf ((string(msg) + "\n").c_str()); + mprintf(msg); + mprintf(_M("\n")); } } @@ -180,7 +181,7 @@ export_zone_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "ExportRykolZone [Object]"); + type_check(arg_list[0], MAXNode, _M("ExportRykolZone [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -215,7 +216,7 @@ export_zone_cf (Value** arg_list, int count) if (tri->rpatch->exportZone (node, &tri->patch, zone, zoneSymmetry, nZone, 160, 1, false)) { // Export path - const char* sPath=arg_list[1]->to_string(); + const std::string sPath = tStrToUtf8(arg_list[1]->to_string()); COFile file; if (file.open (sPath)) @@ -237,7 +238,7 @@ Value* import_zone_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - char *help = "NeLImportZone filename dialogError"; + MCHAR *help = _M("NeLImportZone filename dialogError"); type_check (arg_list[0], String, help); type_check (arg_list[1], Boolean, help); @@ -245,7 +246,7 @@ Value* import_zone_cf (Value** arg_list, int count) Interface *ip = MAXScript_interface; // Get the filename - string filename = arg_list[0]->to_string(); + string filename = tStrToUtf8(arg_list[0]->to_string()); // Get the flip bool dialog = arg_list[1]->to_bool ()!=FALSE; @@ -284,16 +285,18 @@ Value* import_zone_cf (Value** arg_list, int count) // Redraw the viewports ip->RedrawViews(ip->GetTime()); } - catch (Exception& e) + catch (const Exception& e) { // Error message - errorMessage (("Error when loading file "+filename+": "+e.what()).c_str(), "NeL import zone", *ip, dialog); + std::string msg = toString("Error when loading file %s: %s", filename.c_str(), e.what()); + errorMessage (utf8ToTStr(msg), _T("NeL import zone"), *ip, dialog); } } else { // Error message - errorMessage (("Can't open the file "+filename+" for reading.").c_str(), "NeL import zone", *ip, dialog); + std::string msg = toString("Can't open the file %s for reading.", filename.c_str()); + errorMessage (utf8ToTStr(msg), _T("NeL import zone"), *ip, dialog); } return ret; @@ -307,7 +310,7 @@ get_selected_tile_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolSeltile [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolSeltile [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -354,7 +357,7 @@ get_selected_patch_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolSelPatch [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolSelPatch [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -401,7 +404,7 @@ get_selected_vertex_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolSelVertex [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolSelVertex [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -448,7 +451,7 @@ set_tile_mode_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolTileMode [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolTileMode [Object]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -498,7 +501,7 @@ set_compute_interior_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "RykolComputeInterior [Object]"); + type_check(arg_list[0], MAXNode, _M("RykolComputeInterior [Object]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -546,7 +549,7 @@ set_interior_mode_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolInteriorMode [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolInteriorMode [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -598,7 +601,7 @@ set_vertex_count_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolVertexCount [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolVertexCount [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -638,7 +641,7 @@ set_vector_count_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolVectorCount [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolVectorCount [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -678,7 +681,7 @@ set_vertex_pos_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolVertexPos [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolVertexPos [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -728,7 +731,7 @@ set_vector_pos_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolVectorPos [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolVectorPos [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -778,7 +781,7 @@ get_vertex_pos_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolVertexPos [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolVertexPos [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -822,7 +825,7 @@ get_vector_pos_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolVectorPos [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolVectorPos [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -867,7 +870,7 @@ get_edge_vect1_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolEdgesVect1 [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolEdgesVect1 [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -911,7 +914,7 @@ get_edge_vect2_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolEdgesVect2 [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolEdgesVect2 [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -955,7 +958,7 @@ get_edge_vert1_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolEdgesVert1 [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolEdgesVert1 [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1000,7 +1003,7 @@ get_edge_vert2_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolEdgesVert2 [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolEdgesVert2 [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1044,7 +1047,7 @@ get_sel_edge_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolSelEdges [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolSelEdges [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1092,7 +1095,7 @@ set_steps_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykolPatchSteps [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykolPatchSteps [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1155,7 +1158,7 @@ set_tile_steps_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "SetRykoltileSteps [Object]"); + type_check(arg_list[0], MAXNode, _M("SetRykoltileSteps [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1208,7 +1211,7 @@ get_tile_count_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolTileCount [Zone] [PatchNumber]"); + type_check(arg_list[0], MAXNode, _M("GetRykolTileCount [Zone] [PatchNumber]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1265,7 +1268,7 @@ Value* get_patch_vertex_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - char *message="NeLGetPatchVertex [NeLPatchMesh] [PatchId] [VertexId]"; + const MCHAR *message= _M("NeLGetPatchVertex [NeLPatchMesh] [PatchId] [VertexId]"); type_check(arg_list[0], MAXNode, message); type_check(arg_list[1], Integer, message); type_check(arg_list[2], Integer, message); @@ -1336,7 +1339,7 @@ get_patch_count_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "GetRykolPatchCount [Object]"); + type_check(arg_list[0], MAXNode, _M("GetRykolPatchCount [Object]")); //type_check(arg_list[1], Integer, "SetRykolPatchSteps [Object]"); // Get a good interface pointer @@ -1389,10 +1392,10 @@ get_tile_tile_number_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]"); - type_check(arg_list[1], Integer, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]"); - type_check(arg_list[2], Integer, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]"); - type_check(arg_list[3], Integer, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]"); + type_check(arg_list[0], MAXNode, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]")); + type_check(arg_list[1], Integer, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]")); + type_check(arg_list[2], Integer, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]")); + type_check(arg_list[3], Integer, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber] [Layer]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -1411,7 +1414,7 @@ get_tile_tile_number_cf(Value** arg_list, int count) uint layer=arg_list[3]->to_int()-1; if (layer>=3) { - mprintf ("Error: layer must be 1, 2, or 3\n"); + mprintf (_M("Error: layer must be 1, 2, or 3\n")); } else { @@ -1427,7 +1430,7 @@ get_tile_tile_number_cf(Value** arg_list, int count) uint nPatch=arg_list[1]->to_int()-1; if (nPatch>=tri->rpatch->getUIPatchSize()) { - mprintf ("Error: patch index is invalid.\n"); + mprintf (_M("Error: patch index is invalid.\n")); } else { @@ -1439,7 +1442,7 @@ get_tile_tile_number_cf(Value** arg_list, int count) uint tile=arg_list[2]->to_int()-1; if (tile>=nPatchCount) { - mprintf ("Error: tile index is invalid.\n"); + mprintf (_M("Error: tile index is invalid.\n")); } else { @@ -1475,9 +1478,9 @@ get_tile_noise_number_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]"); - type_check(arg_list[1], Integer, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]"); - type_check(arg_list[2], Integer, "NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]"); + type_check(arg_list[0], MAXNode, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]")); + type_check(arg_list[1], Integer, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]")); + type_check(arg_list[2], Integer, _M("NelGetTileTileNumber [Zone] [PatchNumber] [TileNumber]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -1504,7 +1507,7 @@ get_tile_noise_number_cf(Value** arg_list, int count) uint nPatch=arg_list[1]->to_int()-1; if (nPatch>=tri->rpatch->getUIPatchSize()) { - mprintf ("Error: patch index is invalid.\n"); + mprintf (_M("Error: patch index is invalid.\n")); } else { @@ -1516,7 +1519,7 @@ get_tile_noise_number_cf(Value** arg_list, int count) uint tile=arg_list[2]->to_int()-1; if (tile>=nPatchCount) { - mprintf ("Error: patch index is invalid.\n"); + mprintf (_M("Error: patch index is invalid.\n")); } else { @@ -1544,10 +1547,10 @@ set_tile_noise_number_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]"); - type_check(arg_list[1], Integer, "NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]"); - type_check(arg_list[2], Integer, "NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]"); - type_check(arg_list[3], Integer, "NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]"); + type_check(arg_list[0], MAXNode, _M("NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]")); + type_check(arg_list[1], Integer, _M("NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]")); + type_check(arg_list[2], Integer, _M("NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]")); + type_check(arg_list[3], Integer, _M("NelGetTileNoiseNumber [Zone] [PatchNumber] [TileNumber] [noise]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -1566,7 +1569,7 @@ set_tile_noise_number_cf(Value** arg_list, int count) uint noise=arg_list[3]->to_int()-1; if (noise>=16) { - mprintf ("Error: noise value must be 1~16\n"); + mprintf (_M("Error: noise value must be 1~16\n")); } else { @@ -1582,7 +1585,7 @@ set_tile_noise_number_cf(Value** arg_list, int count) uint nPatch=arg_list[1]->to_int()-1; if (nPatch>=tri->rpatch->getUIPatchSize()) { - mprintf ("Error: patch index is invalid.\n"); + mprintf (_M("Error: patch index is invalid.\n")); } else { @@ -1594,7 +1597,7 @@ set_tile_noise_number_cf(Value** arg_list, int count) uint tile=arg_list[2]->to_int()-1; if (tile>=nPatchCount) { - mprintf ("Error: patch index is invalid.\n"); + mprintf (_M("Error: patch index is invalid.\n")); } else { @@ -1627,7 +1630,7 @@ load_bank_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' std::string bankName = GetBankPathName (); - if (bankName!="") + if (!bankName.empty()) { try { @@ -1646,13 +1649,13 @@ load_bank_cf(Value** arg_list, int count) } else { - mprintf ("Error: can't open bank file %s\n", bankName.c_str()); + mprintf (_M("Error: can't open bank file %s\n"), bankName.c_str()); } } - catch (Exception& e) + catch (const Exception& e) { // Error message - mprintf ("Error: %s\n", e.what()); + mprintf (_M("Error: %s\n"), e.what()); } } @@ -1668,7 +1671,7 @@ get_tile_set_cf(Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], Integer, "NelGetTileSet [tileId]"); + type_check(arg_list[0], Integer, _M("NelGetTileSet [tileId]")); // ok ? int nRet=-1; @@ -1677,7 +1680,7 @@ get_tile_set_cf(Value** arg_list, int count) uint tile=arg_list[0]->to_int()-1; if (tile>=(uint)scriptedBank.getTileCount()) { - mprintf ("Error: tile number is wrong. (1 ~ %d)\n", scriptedBank.getTileCount()); + mprintf (_M("Error: tile number is wrong. (1 ~ %d)\n"), scriptedBank.getTileCount()); } else { @@ -1702,10 +1705,10 @@ Value* set_tile_bank_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], String, "NelSetTileBank [tile bank pathname]"); + type_check(arg_list[0], String, _M("NelSetTileBank [tile bank pathname]")); // ok ? - const char *pathname = arg_list[0]->to_string(); + const std::string pathname = tStrToUtf8(arg_list[0]->to_string()); // Get tile number SetBankPathName (pathname); @@ -1947,8 +1950,8 @@ attach_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "NeLAttachPatchMesh [RykolPatchMeshSrc] [RykolPatchMeshDest]"); - type_check(arg_list[1], MAXNode, "NeLAttachPatchMesh [RykolPatchMeshSrc] [RykolPatchMeshDest]"); + type_check(arg_list[0], MAXNode, _M("NeLAttachPatchMesh [RykolPatchMeshSrc] [RykolPatchMeshDest]")); + type_check(arg_list[1], MAXNode, _M("NeLAttachPatchMesh [RykolPatchMeshSrc] [RykolPatchMeshDest]")); // Get a good interface pointer Interface *ip = MAXScript_interface; @@ -2005,8 +2008,8 @@ weld_cf (Value** arg_list, int count) // Check to see if the arguments match up to what we expect // We want to use 'TurnAllTexturesOn ' - type_check(arg_list[0], MAXNode, "NeLWeldPatchMesh [RykolPatchMeshSrc] [threshold]"); - type_check(arg_list[1], Float, "NeLWeldPatchMesh [RykolPatchMeshSrc] [threshold]"); + type_check(arg_list[0], MAXNode, _M("NeLWeldPatchMesh [RykolPatchMeshSrc] [threshold]")); + type_check(arg_list[1], Float, _M("NeLWeldPatchMesh [RykolPatchMeshSrc] [threshold]")); // Get a good interface pointer Interface *ip = MAXScript_interface; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/CMakeLists.txt b/code/nel/tools/3d/plugin_max/nel_patch_edit/CMakeLists.txt index 20a3635e4..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,6 +18,8 @@ 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() 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..41000abc3 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(); @@ -280,6 +277,50 @@ void EditPatchMod::SelectSubPatch(int index) // ------------------------------------------------------------------------------------------------------------------------------------------------------ +void EditPatchMod::SelectSubPatch(int index) +{ + if (!ip) + return; + TimeValue t = ip->GetTime(); + + ip->ClearCurNamedSelSet(); + + ModContextList mcList; + INodeTab nodes; + ip->GetModContexts(mcList, nodes); + + for (int i = 0; i < mcList.Count(); i++) + { + EditPatchData *patchData =(EditPatchData*)mcList[i]->localData; + + if (!patchData) + return; + + RPatchMesh *rpatch; + PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch); + if (!patch) + return; + + patchData->BeginEdit(t); + if (theHold.Holding()) + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("SelectSubComponent"))); + + patch->patchSel.Set(index); + + patchData->UpdateChanges(patch, rpatch, FALSE); + if (patchData->tempData) + { + patchData->tempData->Invalidate(PART_SELECT); + } + } + PatchSelChanged(); + + UpdateSelectDisplay(); + NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------ + // Select a subcomponent within our object(s). WARNING! Because the HitRecord list can // indicate any of the objects contained within the group of patches being edited, we need // to watch for control breaks in the patchData pointer within the HitRecord! @@ -311,7 +352,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 +677,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 +785,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 +854,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 +1045,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 +1118,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..db84e3d7b 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 @@ -1,605 +1,605 @@ - -NEL3D_APPDATA_INTERFACE_FILE = 1423062700 - --- Allocate 20 Me for the script -heapSize += 15000000 - -nlErrorFilename = "W:/database/conversion.log" -nlErrorStream = openFile nlErrorFilename mode:"w" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Log a message -fn nllog message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - -include "nel_utility.ms" - -fn getAbsoluteSource t = -( - return (mapPaths.getFullFilePath ((getFilenameFile (filenameFromPath t)) + ".png")) -) - -fn getAbsoluteDestination t = -( - if ((findString t "\\\\Amiga") != undefined) then - ( - return ("W:\\" + (substring (getFilenamePath t) 11 -1) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png") - ) - else if ((findString t "\\\\amiga") != undefined) then - ( - return ("W:\\" + (substring (getFilenamePath t) 11 -1) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png") - ) - else if (((findString t "\\\\Database") != undefined) or ((findString t "\\\\database") != undefined)) and ((findString t "W:\\") == undefined) then - ( - return ("W:\\" + (getFilenamePath t) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png") - ) - else if ((findString t "W:\\") != undefined) then - ( - return ((getFilenamePath t) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png") - ) - else if ((findString t "E:\\Ryzom\\tryker") != undefined) then - ( - return "W:\\database\\Stuff\\Tryker\\Decors\\_textures\\Batiments\\" + (getFilenameFile (filenameFromPath t)) + ".png" - ) - else if ((findString t "\\tronc.") != undefined) then - ( - return "W:\\database\\database_proto\\stuff\\fyros\\objects\\tronc.png" - ) - else if ((findString t "\\trame.") != undefined) then - ( - return "W:\\database\\stuff\\lod_actors\\texture_lod\\trame.png" - ) - else if ((findString t "\\PR_MO_phytopsy_tete01_Boss.") != undefined) then - ( - return "W:\\database\\Stuff\\Tryker\\Agents\\_textures\\monster\\PR_MO_phytopsy_tete01_Boss.png" - ) - else - ( - return t - ) -) - -fn getMaxDestination mf = -( - if ((findString mf "\\\\Amiga") != undefined) then - ( - return ("W:\\" + (substring mf 11 -1)) - ) - else if ((findString mf "\\\\amiga") != undefined) then - ( - return ("W:\\" + (substring mf 11 -1)) - ) - else if (((findString mf "\\\\Database") != undefined) or ((findString mf "\\\\database") != undefined)) and ((findString mf "W:\\") == undefined) then - ( - return ("W:\\" + mf) - ) - else - ( - return mf - ) -) - -fn getFixedTexturePath t = -( - absoluteDestination = (getAbsoluteDestination t) - if (not (doesFileExist absoluteDestination)) and (((findString t "\\Stuff\\Fyros\\Decors\\_textures\\Batiments") != undefined) or ((findString t "\\Stuff\\Fyros\\Decors\\_textures\\Accessories\\Vv2\\") != undefined)) then - ( - testDestination = ("W:\\database\\stuff\\Fyros\\Agents\\_textures\\Accessories\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then - ( - return testDestination - ) - ) - if (not (doesFileExist absoluteDestination)) and (((findString t "\\Stuff\\Fyros\\Decors\\_textures\\Batiments") != undefined) or ((findString t "\\Stuff\\Fyros\\Decors\\_textures\\Accessories\\") != undefined)) then - ( - testDestination = ("W:\\database\\stuff\\Fyros\\Agents\\_textures\\Accessories\\Vv2\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then - ( - return testDestination - ) - ) - if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Fyros\\Decors\\_textures\\Accessories") != undefined) then - ( - testDestination = ("W:\\database\\stuff\\Fyros\\Agents\\_textures\\Batiments\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then - ( - return testDestination - ) - ) - if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Tryker\\Decors\\_textures\\batiments") != undefined) then - ( - testDestination = ("W:\\database\\Stuff\\Tryker\\Decors\\_textures\\batiments\\noutilise\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then - ( - return testDestination - ) - ) - if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Tryker\\Decors\\_textures\\batiments") != undefined) then - ( - testDestination = ("W:\\database\\Stuff\\Tryker\\Decors\\_textures\\batiments\\vv2\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then - ( - return testDestination - ) - ) - if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Tryker\\Decors\\_textures\\batiments") != undefined) then - ( - testDestination = ("W:\\database\\Stuff\\Tryker\\Decors\\_textures\\batiments\\tempautel\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then - ( - return testDestination - ) - ) - if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Tryker\\Decors\\_textures\\batiments") != undefined) then - ( - testDestination = ("W:\\database\\Stuff\\Tryker\\Decors\\_textures\\batiments\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then - ( - return testDestination - ) - ) - if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Fyros\\Decors\\_textures") != undefined) then - ( - testDestination = ("W:\\database\\Stuff\\Fyros\\Decors\\_textures\\Batiments\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then - ( - return testDestination - ) - ) - if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Fyros\\Decors\\_textures") != undefined) then - ( - testDestination = ("W:\\database\\Stuff\\Tryker\\Decors\\_textures\\Batiments\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then - ( - return testDestination - ) - ) - if (not (doesFileExist absoluteDestination)) and ((findString t "\\sky_V2\\textures\\textures") != undefined) then - ( - testDestination = ("W:\\database\\sky_V2\\textures\\textures\\nodds\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then (return testDestination) - testDestination = ("W:\\database\\sky_V2\\textures\\textures\\desert\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then (return testDestination) - testDestination = ("W:\\database\\sky_V2\\textures\\textures\\forest\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then (return testDestination) - testDestination = ("W:\\database\\sky_V2\\textures\\textures\\jungle\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then (return testDestination) - testDestination = ("W:\\database\\sky_V2\\textures\\textures\\lacustre\\" + (getFilenameFile (filenameFromPath t)) + ".png") - if (doesFileExist testDestination) then (return testDestination) - ) - return absoluteDestination -) - -fn renameTexture t = -( - try - ( - if (t != undefined) then - ( - if (classof t == NelBitmapTexture) then - ( - if (t.bitmap1FileName != "") then (t.bitmap1FileName = getFixedTexturePath t.bitmap1FileName) - if (t.bitmap2FileName != "") then (t.bitmap2FileName = getFixedTexturePath t.bitmap2FileName) - if (t.bitmap3FileName != "") then (t.bitmap3FileName = getFixedTexturePath t.bitmap3FileName) - if (t.bitmap4FileName != "") then (t.bitmap4FileName = getFixedTexturePath t.bitmap4FileName) - if (t.bitmap5FileName != "") then (t.bitmap5FileName = getFixedTexturePath t.bitmap5FileName) - if (t.bitmap6FileName != "") then (t.bitmap6FileName = getFixedTexturePath t.bitmap6FileName) - if (t.bitmap7FileName != "") then (t.bitmap7FileName = getFixedTexturePath t.bitmap7FileName) - if (t.bitmap8FileName != "") then (t.bitmap8FileName = getFixedTexturePath t.bitmap8FileName) - renameTexture t.bitmap - if (t.bitmap.fileName == undefined) then - ( - if (doesFileExist (mapPaths.getFullFilePath t.bitmap1FileName)) then (t.bitmap.fileName = t.bitmap1FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap2FileName)) then (t.bitmap.fileName = t.bitmap2FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap3FileName)) then (t.bitmap.fileName = t.bitmap3FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap4FileName)) then (t.bitmap.fileName = t.bitmap4FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap5FileName)) then (t.bitmap.fileName = t.bitmap5FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap6FileName)) then (t.bitmap.fileName = t.bitmap6FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap7FileName)) then (t.bitmap.fileName = t.bitmap7FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap8FileName)) then (t.bitmap.fileName = t.bitmap8FileName) - ) - else if not (doesFileExist (mapPaths.getFullFilePath t.bitmap.fileName)) then - ( - if (doesFileExist (mapPaths.getFullFilePath t.bitmap1FileName)) then (t.bitmap.fileName = t.bitmap1FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap2FileName)) then (t.bitmap.fileName = t.bitmap2FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap3FileName)) then (t.bitmap.fileName = t.bitmap3FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap4FileName)) then (t.bitmap.fileName = t.bitmap4FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap5FileName)) then (t.bitmap.fileName = t.bitmap5FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap6FileName)) then (t.bitmap.fileName = t.bitmap6FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap7FileName)) then (t.bitmap.fileName = t.bitmap7FileName) - else if (doesFileExist (mapPaths.getFullFilePath t.bitmap8FileName)) then (t.bitmap.fileName = t.bitmap8FileName) - ) - t.delegate.RGBOutput = 0 - t.delegate.monoOutput = 1 - t.delegate.alphasource = 2 - ) - else if (classof t == Reflect_Refract) then - ( - if (t.bitmapName[1] != undefined) then (t.bitmapName[1] = getFixedTexturePath t.bitmapName[1]) - if (t.bitmapName[2] != undefined) then (t.bitmapName[2] = getFixedTexturePath t.bitmapName[2]) - if (t.bitmapName[3] != undefined) then (t.bitmapName[3] = getFixedTexturePath t.bitmapName[3]) - if (t.bitmapName[4] != undefined) then (t.bitmapName[4] = getFixedTexturePath t.bitmapName[4]) - if (t.bitmapName[5] != undefined) then (t.bitmapName[5] = getFixedTexturePath t.bitmapName[5]) - if (t.bitmapName[6] != undefined) then (t.bitmapName[6] = getFixedTexturePath t.bitmapName[6]) - if (t.outputname != undefined) then (t.outputname = getFixedTexturePath t.outputname) - ) - else - ( - if (t.fileName != undefined) then (t.fileName = getFixedTexturePath t.fileName) - if (classof t == BitmapTexture) then - ( - t.RGBOutput = 0 - t.monoOutput = 1 - t.alphasource = 2 - ) - ) - ) - ) - catch - ( - - ) -) - - -rollout assets_png_rollout "Properties" -( - fn do_it = - ( - for m in getClassInstances BitmapTexture do - ( - renameTexture m - ) - - for m in getClassInstances NelBitmapTexture do - ( - renameTexture m - ) - - for m in getClassInstances NelMaterial do - ( - renameTexture m.tTexture_1 - renameTexture m.tTexture_2 - renameTexture m.tTexture_3 - renameTexture m.tTexture_4 - renameTexture m.tTexture_5 - renameTexture m.tTexture_6 - renameTexture m.tTexture_7 - renameTexture m.tTexture_8 - m.delegate.DiffuseMapEnable = m.bEnableSlot_1 - m.delegate.DiffuseMap = m.tTexture_1 - m.delegate.AmbientMapEnable = m.bEnableSlot_1 - m.delegate.AmbientMap = m.tTexture_1 - m.delegate.SpecularMapEnable = m.bEnableSlot_2 - m.delegate.SpecularMap = m.tTexture_2 - m.delegate.SelfIllumMap = undefined - m.delegate.OpacityMap = undefined - m.delegate.FilterMap = undefined - m.delegate.BumpMap = undefined - m.delegate.DisplacementMap = undefined - m.delegate.ReflectionMap = undefined - m.delegate.RefractionMap = undefined - ) - - max select none - - for node in geometry do - ( - itfMaxFile = getAppData node NEL3D_APPDATA_INTERFACE_FILE - if (itfMaxFile != undefined) then - ( - if (itfMaxFile != "") then - ( - itfMaxFile = getMaxDestination itfMaxFile - setAppData node NEL3D_APPDATA_INTERFACE_FILE itfMaxFile - ) - ) - ) - - actionMan.executeAction 0 "40021" -- Selection: Select All - actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected - actionMan.executeAction 0 "40807" -- Views: Activate All Maps - actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps - actionMan.executeAction 0 "40043" -- Selection: Select None - - max views redraw - - return 1 - ) - - -- This script is a base script to include to add multiple functionality to your script - - -- 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 - -- It the function returns <1, the project will not be overwritten - - Group "Running properties" - ( - RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left - - Label DirectoryLabel "Source directory" align:#left - EditText Directory "" width:500 align:#left enabled:false - Button BrowseDirectory "Browse..." align:#left enabled:false - - CheckBox Recurse "Look in subfolders" checked:true enabled:false - CheckBox Test "Test only, do not save" checked:false enabled:false - CheckBox BackupFiles "Backup files" checked:false enabled:false - CheckBox StopOnError "Stop on error" checked:false enabled:false - CheckBox UseTag "Use tag" checked:false enabled:false - - Label ProgressText width:500 align:#left - ProgressBar Progress width:500 align:#left - - Button GoButton "Go" width:500 align:#left - ) - - local countModifications - local countErrors - local fileModified - local fileParsed - - fn UpdateData = - ( - if SourceFiles.state == 2 then - isSourceDir = true - else - isSourceDir = false - if Test.checked == true then - isTest = true - else - isTest = false - - Directory.enabled = isSourceDir - BrowseDirectory.enabled = isSourceDir - Recurse.enabled = isSourceDir - Test.enabled = isSourceDir - BackupFiles.enabled = isSourceDir and (isTest == false) - StopOnError.enabled = isSourceDir - UseTag.enabled = isSourceDir - ) - - on SourceFiles changed state do - ( - UpdateData () - ) - - on Test changed state do - ( - UpdateData () - ) - - fn call_do_it = - ( - local result - - -- One more project - fileParsed = fileParsed + 1 - - -- Call it - result = do_it () - - -- Error ? - if result < 0 then - countErrors = countErrors + 1 - else - countModifications = countModifications + result - - -- Return result - return result - ) - - fn BackupFile file = - ( - local i - local newFilename - - i = 0 - while true do - ( - -- New file name - newFilename = file + ".backup_" + (i as string) - - -- File exist ? - if (fileExist newFilename) == false then - ( - if (copyFile file newFilename) == false then - return false - else - return true - ) - i = i + 1 - ) - ) - - fn RecurseFolder currentDirectory = - ( - resetMAXFile #noprompt - - local result - local file - local files - local origAnimStart - local origAnimEnd - local origFrameRate - - -- Parse files - files = getFiles (currentDirectory+"/*.max") - - -- For each files - for i = 1 to files.count do - ( - -- File name - file = files[i] - - -- Progress bar - ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" - Progress.value = i*100/files.count - - if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then - ( - resetMAXFile #noprompt - - nllog("CONVERT " + file) - - -- Open the max project - if loadMaxFile file quiet:true == true then - ( - origAnimStart = animationRange.start - origAnimEnd = animationRange.end - origFrameRate = frameRate - - resetMAXFile #noprompt - - animationRange = interval origAnimStart origAnimEnd - frameRate = origFrameRate - - -- Merge the max project - if mergeMaxFile file quiet:true == true then - ( - result = call_do_it () - - -- Error ? - if result < 0 then - ( - if StopOnError.checked == true then - Messagebox ("Error in file " + file) - ) - else - ( - -- Save the max project ? - if (Test.checked == false) and (result != 0) then - ( - -- Backup the max project ? - local ok - ok = true - if BackupFiles.checked == true then - ( - -- Backup the file - if (BackupFile file) == false then - ( - -- Don't save the file because backup has failed - ok = false - - if StopOnError.checked == true then - Messagebox ("Can't backup file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - - -- Save the max project ? - if ok == true then - ( - if (saveMaxFile file) == true then - ( - fileModified = fileModified + 1 - ) - else - ( - if StopOnError.checked == true then - Messagebox ("Can't write file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - ) - ) - ) - else - ( - if StopOnError.checked == true then - Messagebox ("Can't load file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - ) - else - ( - nllog("SKIP " + file + " by tag") - ) - ) - - -- Parse sub directory ? - if (Recurse.checked == true) then - ( - local directories - - -- Get the directories - directories = getDirectories (currentDirectory+"/*") - - -- For each directories - for dir in directories do - ( - RecurseFolder dir - ) - ) - ) - - on BrowseDirectory pressed do - ( - local dir - try - ( - dir = getSavePath () -- caption:"Select the projects directory" - if dir != undefined then - Directory.text = dir - ) - catch - ( - ) - ) - - on GoButton pressed do - ( - -- Reset count - countModifications = 0 - countErrors = 0 - fileModified = 0 - fileParsed = 0 - - -- Get files in the shape_source_directory - if SourceFiles.state == 2 then - ( - -- Should warning user ? - if (SourceFiles.state == 2) and (Test.checked == false) then - ( - -- Warning ! - if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then - RecurseFolder (adjustPathStringForScript Directory.text) - ) - else - ( - RecurseFolder (adjustPathStringForScript Directory.text) - ) - ) - else - ( - -- Just compute the current project - call_do_it () - ) - - -- Show errors - ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." - Progress.value = 100 - ) -) - -assets_png_floater = newRolloutFloater "NeL Assets PNG Database" 550 874 -addrollout assets_png_rollout assets_png_floater rolledUp:false - + +NEL3D_APPDATA_INTERFACE_FILE = 1423062700 + +-- Allocate 20 Me for the script +heapSize += 15000000 + +nlErrorFilename = "W:/database/conversion.log" +nlErrorStream = openFile nlErrorFilename mode:"w" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Log a message +fn nllog message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + +include "nel_utility.ms" + +fn getAbsoluteSource t = +( + return (mapPaths.getFullFilePath ((getFilenameFile (filenameFromPath t)) + ".png")) +) + +fn getAbsoluteDestination t = +( + if ((findString t "\\\\Amiga") != undefined) then + ( + return ("W:\\" + (substring (getFilenamePath t) 11 -1) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png") + ) + else if ((findString t "\\\\amiga") != undefined) then + ( + return ("W:\\" + (substring (getFilenamePath t) 11 -1) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png") + ) + else if (((findString t "\\\\Database") != undefined) or ((findString t "\\\\database") != undefined)) and ((findString t "W:\\") == undefined) then + ( + return ("W:\\" + (getFilenamePath t) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png") + ) + else if ((findString t "W:\\") != undefined) then + ( + return ((getFilenamePath t) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png") + ) + else if ((findString t "E:\\Ryzom\\tryker") != undefined) then + ( + return "W:\\database\\Stuff\\Tryker\\Decors\\_textures\\Batiments\\" + (getFilenameFile (filenameFromPath t)) + ".png" + ) + else if ((findString t "\\tronc.") != undefined) then + ( + return "W:\\database\\database_proto\\stuff\\fyros\\objects\\tronc.png" + ) + else if ((findString t "\\trame.") != undefined) then + ( + return "W:\\database\\stuff\\lod_actors\\texture_lod\\trame.png" + ) + else if ((findString t "\\PR_MO_phytopsy_tete01_Boss.") != undefined) then + ( + return "W:\\database\\Stuff\\Tryker\\Agents\\_textures\\monster\\PR_MO_phytopsy_tete01_Boss.png" + ) + else + ( + return t + ) +) + +fn getMaxDestination mf = +( + if ((findString mf "\\\\Amiga") != undefined) then + ( + return ("W:\\" + (substring mf 11 -1)) + ) + else if ((findString mf "\\\\amiga") != undefined) then + ( + return ("W:\\" + (substring mf 11 -1)) + ) + else if (((findString mf "\\\\Database") != undefined) or ((findString mf "\\\\database") != undefined)) and ((findString mf "W:\\") == undefined) then + ( + return ("W:\\" + mf) + ) + else + ( + return mf + ) +) + +fn getFixedTexturePath t = +( + absoluteDestination = (getAbsoluteDestination t) + if (not (doesFileExist absoluteDestination)) and (((findString t "\\Stuff\\Fyros\\Decors\\_textures\\Batiments") != undefined) or ((findString t "\\Stuff\\Fyros\\Decors\\_textures\\Accessories\\Vv2\\") != undefined)) then + ( + testDestination = ("W:\\database\\stuff\\Fyros\\Agents\\_textures\\Accessories\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then + ( + return testDestination + ) + ) + if (not (doesFileExist absoluteDestination)) and (((findString t "\\Stuff\\Fyros\\Decors\\_textures\\Batiments") != undefined) or ((findString t "\\Stuff\\Fyros\\Decors\\_textures\\Accessories\\") != undefined)) then + ( + testDestination = ("W:\\database\\stuff\\Fyros\\Agents\\_textures\\Accessories\\Vv2\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then + ( + return testDestination + ) + ) + if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Fyros\\Decors\\_textures\\Accessories") != undefined) then + ( + testDestination = ("W:\\database\\stuff\\Fyros\\Agents\\_textures\\Batiments\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then + ( + return testDestination + ) + ) + if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Tryker\\Decors\\_textures\\batiments") != undefined) then + ( + testDestination = ("W:\\database\\Stuff\\Tryker\\Decors\\_textures\\batiments\\noutilise\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then + ( + return testDestination + ) + ) + if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Tryker\\Decors\\_textures\\batiments") != undefined) then + ( + testDestination = ("W:\\database\\Stuff\\Tryker\\Decors\\_textures\\batiments\\vv2\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then + ( + return testDestination + ) + ) + if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Tryker\\Decors\\_textures\\batiments") != undefined) then + ( + testDestination = ("W:\\database\\Stuff\\Tryker\\Decors\\_textures\\batiments\\tempautel\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then + ( + return testDestination + ) + ) + if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Tryker\\Decors\\_textures\\batiments") != undefined) then + ( + testDestination = ("W:\\database\\Stuff\\Tryker\\Decors\\_textures\\batiments\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then + ( + return testDestination + ) + ) + if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Fyros\\Decors\\_textures") != undefined) then + ( + testDestination = ("W:\\database\\Stuff\\Fyros\\Decors\\_textures\\Batiments\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then + ( + return testDestination + ) + ) + if (not (doesFileExist absoluteDestination)) and ((findString t "\\Stuff\\Fyros\\Decors\\_textures") != undefined) then + ( + testDestination = ("W:\\database\\Stuff\\Tryker\\Decors\\_textures\\Batiments\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then + ( + return testDestination + ) + ) + if (not (doesFileExist absoluteDestination)) and ((findString t "\\sky_V2\\textures\\textures") != undefined) then + ( + testDestination = ("W:\\database\\sky_V2\\textures\\textures\\nodds\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then (return testDestination) + testDestination = ("W:\\database\\sky_V2\\textures\\textures\\desert\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then (return testDestination) + testDestination = ("W:\\database\\sky_V2\\textures\\textures\\forest\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then (return testDestination) + testDestination = ("W:\\database\\sky_V2\\textures\\textures\\jungle\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then (return testDestination) + testDestination = ("W:\\database\\sky_V2\\textures\\textures\\lacustre\\" + (getFilenameFile (filenameFromPath t)) + ".png") + if (doesFileExist testDestination) then (return testDestination) + ) + return absoluteDestination +) + +fn renameTexture t = +( + try + ( + if (t != undefined) then + ( + if (classof t == NelBitmapTexture) then + ( + if (t.bitmap1FileName != "") then (t.bitmap1FileName = getFixedTexturePath t.bitmap1FileName) + if (t.bitmap2FileName != "") then (t.bitmap2FileName = getFixedTexturePath t.bitmap2FileName) + if (t.bitmap3FileName != "") then (t.bitmap3FileName = getFixedTexturePath t.bitmap3FileName) + if (t.bitmap4FileName != "") then (t.bitmap4FileName = getFixedTexturePath t.bitmap4FileName) + if (t.bitmap5FileName != "") then (t.bitmap5FileName = getFixedTexturePath t.bitmap5FileName) + if (t.bitmap6FileName != "") then (t.bitmap6FileName = getFixedTexturePath t.bitmap6FileName) + if (t.bitmap7FileName != "") then (t.bitmap7FileName = getFixedTexturePath t.bitmap7FileName) + if (t.bitmap8FileName != "") then (t.bitmap8FileName = getFixedTexturePath t.bitmap8FileName) + renameTexture t.bitmap + if (t.bitmap.fileName == undefined) then + ( + if (doesFileExist (mapPaths.getFullFilePath t.bitmap1FileName)) then (t.bitmap.fileName = t.bitmap1FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap2FileName)) then (t.bitmap.fileName = t.bitmap2FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap3FileName)) then (t.bitmap.fileName = t.bitmap3FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap4FileName)) then (t.bitmap.fileName = t.bitmap4FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap5FileName)) then (t.bitmap.fileName = t.bitmap5FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap6FileName)) then (t.bitmap.fileName = t.bitmap6FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap7FileName)) then (t.bitmap.fileName = t.bitmap7FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap8FileName)) then (t.bitmap.fileName = t.bitmap8FileName) + ) + else if not (doesFileExist (mapPaths.getFullFilePath t.bitmap.fileName)) then + ( + if (doesFileExist (mapPaths.getFullFilePath t.bitmap1FileName)) then (t.bitmap.fileName = t.bitmap1FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap2FileName)) then (t.bitmap.fileName = t.bitmap2FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap3FileName)) then (t.bitmap.fileName = t.bitmap3FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap4FileName)) then (t.bitmap.fileName = t.bitmap4FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap5FileName)) then (t.bitmap.fileName = t.bitmap5FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap6FileName)) then (t.bitmap.fileName = t.bitmap6FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap7FileName)) then (t.bitmap.fileName = t.bitmap7FileName) + else if (doesFileExist (mapPaths.getFullFilePath t.bitmap8FileName)) then (t.bitmap.fileName = t.bitmap8FileName) + ) + t.delegate.RGBOutput = 0 + t.delegate.monoOutput = 1 + t.delegate.alphasource = 2 + ) + else if (classof t == Reflect_Refract) then + ( + if (t.bitmapName[1] != undefined) then (t.bitmapName[1] = getFixedTexturePath t.bitmapName[1]) + if (t.bitmapName[2] != undefined) then (t.bitmapName[2] = getFixedTexturePath t.bitmapName[2]) + if (t.bitmapName[3] != undefined) then (t.bitmapName[3] = getFixedTexturePath t.bitmapName[3]) + if (t.bitmapName[4] != undefined) then (t.bitmapName[4] = getFixedTexturePath t.bitmapName[4]) + if (t.bitmapName[5] != undefined) then (t.bitmapName[5] = getFixedTexturePath t.bitmapName[5]) + if (t.bitmapName[6] != undefined) then (t.bitmapName[6] = getFixedTexturePath t.bitmapName[6]) + if (t.outputname != undefined) then (t.outputname = getFixedTexturePath t.outputname) + ) + else + ( + if (t.fileName != undefined) then (t.fileName = getFixedTexturePath t.fileName) + if (classof t == BitmapTexture) then + ( + t.RGBOutput = 0 + t.monoOutput = 1 + t.alphasource = 2 + ) + ) + ) + ) + catch + ( + + ) +) + + +rollout assets_png_rollout "Properties" +( + fn do_it = + ( + for m in getClassInstances BitmapTexture do + ( + renameTexture m + ) + + for m in getClassInstances NelBitmapTexture do + ( + renameTexture m + ) + + for m in getClassInstances NelMaterial do + ( + renameTexture m.tTexture_1 + renameTexture m.tTexture_2 + renameTexture m.tTexture_3 + renameTexture m.tTexture_4 + renameTexture m.tTexture_5 + renameTexture m.tTexture_6 + renameTexture m.tTexture_7 + renameTexture m.tTexture_8 + m.delegate.DiffuseMapEnable = m.bEnableSlot_1 + m.delegate.DiffuseMap = m.tTexture_1 + m.delegate.AmbientMapEnable = m.bEnableSlot_1 + m.delegate.AmbientMap = m.tTexture_1 + m.delegate.SpecularMapEnable = m.bEnableSlot_2 + m.delegate.SpecularMap = m.tTexture_2 + m.delegate.SelfIllumMap = undefined + m.delegate.OpacityMap = undefined + m.delegate.FilterMap = undefined + m.delegate.BumpMap = undefined + m.delegate.DisplacementMap = undefined + m.delegate.ReflectionMap = undefined + m.delegate.RefractionMap = undefined + ) + + max select none + + for node in geometry do + ( + itfMaxFile = getAppData node NEL3D_APPDATA_INTERFACE_FILE + if (itfMaxFile != undefined) then + ( + if (itfMaxFile != "") then + ( + itfMaxFile = getMaxDestination itfMaxFile + setAppData node NEL3D_APPDATA_INTERFACE_FILE itfMaxFile + ) + ) + ) + + actionMan.executeAction 0 "40021" -- Selection: Select All + actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected + actionMan.executeAction 0 "40807" -- Views: Activate All Maps + actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps + actionMan.executeAction 0 "40043" -- Selection: Select None + + max views redraw + + return 1 + ) + + -- This script is a base script to include to add multiple functionality to your script + + -- 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 occurred, else the count of modification done + -- It the function returns <1, the project will not be overwritten + + Group "Running properties" + ( + RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left + + Label DirectoryLabel "Source directory" align:#left + EditText Directory "" width:500 align:#left enabled:false + Button BrowseDirectory "Browse..." align:#left enabled:false + + CheckBox Recurse "Look in subfolders" checked:true enabled:false + CheckBox Test "Test only, do not save" checked:false enabled:false + CheckBox BackupFiles "Backup files" checked:false enabled:false + CheckBox StopOnError "Stop on error" checked:false enabled:false + CheckBox UseTag "Use tag" checked:false enabled:false + + Label ProgressText width:500 align:#left + ProgressBar Progress width:500 align:#left + + Button GoButton "Go" width:500 align:#left + ) + + local countModifications + local countErrors + local fileModified + local fileParsed + + fn UpdateData = + ( + if SourceFiles.state == 2 then + isSourceDir = true + else + isSourceDir = false + if Test.checked == true then + isTest = true + else + isTest = false + + Directory.enabled = isSourceDir + BrowseDirectory.enabled = isSourceDir + Recurse.enabled = isSourceDir + Test.enabled = isSourceDir + BackupFiles.enabled = isSourceDir and (isTest == false) + StopOnError.enabled = isSourceDir + UseTag.enabled = isSourceDir + ) + + on SourceFiles changed state do + ( + UpdateData () + ) + + on Test changed state do + ( + UpdateData () + ) + + fn call_do_it = + ( + local result + + -- One more project + fileParsed = fileParsed + 1 + + -- Call it + result = do_it () + + -- Error ? + if result < 0 then + countErrors = countErrors + 1 + else + countModifications = countModifications + result + + -- Return result + return result + ) + + fn BackupFile file = + ( + local i + local newFilename + + i = 0 + while true do + ( + -- New file name + newFilename = file + ".backup_" + (i as string) + + -- File exist ? + if (fileExist newFilename) == false then + ( + if (copyFile file newFilename) == false then + return false + else + return true + ) + i = i + 1 + ) + ) + + fn RecurseFolder currentDirectory = + ( + resetMAXFile #noprompt + + local result + local file + local files + local origAnimStart + local origAnimEnd + local origFrameRate + + -- Parse files + files = getFiles (currentDirectory+"/*.max") + + -- For each files + for i = 1 to files.count do + ( + -- File name + file = files[i] + + -- Progress bar + ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" + Progress.value = i*100/files.count + + if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then + ( + resetMAXFile #noprompt + + nllog("CONVERT " + file) + + -- Open the max project + if loadMaxFile file quiet:true == true then + ( + origAnimStart = animationRange.start + origAnimEnd = animationRange.end + origFrameRate = frameRate + + resetMAXFile #noprompt + + animationRange = interval origAnimStart origAnimEnd + frameRate = origFrameRate + + -- Merge the max project + if mergeMaxFile file quiet:true == true then + ( + result = call_do_it () + + -- Error ? + if result < 0 then + ( + if StopOnError.checked == true then + Messagebox ("Error in file " + file) + ) + else + ( + -- Save the max project ? + if (Test.checked == false) and (result != 0) then + ( + -- Backup the max project ? + local ok + ok = true + if BackupFiles.checked == true then + ( + -- Backup the file + if (BackupFile file) == false then + ( + -- Don't save the file because backup has failed + ok = false + + if StopOnError.checked == true then + Messagebox ("Can't backup file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + + -- Save the max project ? + if ok == true then + ( + if (saveMaxFile file) == true then + ( + fileModified = fileModified + 1 + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't write file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + ) + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't load file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + else + ( + nllog("SKIP " + file + " by tag") + ) + ) + + -- Parse sub directory ? + if (Recurse.checked == true) then + ( + local directories + + -- Get the directories + directories = getDirectories (currentDirectory+"/*") + + -- For each directories + for dir in directories do + ( + RecurseFolder dir + ) + ) + ) + + on BrowseDirectory pressed do + ( + local dir + try + ( + dir = getSavePath () -- caption:"Select the projects directory" + if dir != undefined then + Directory.text = dir + ) + catch + ( + ) + ) + + on GoButton pressed do + ( + -- Reset count + countModifications = 0 + countErrors = 0 + fileModified = 0 + fileParsed = 0 + + -- Get files in the shape_source_directory + if SourceFiles.state == 2 then + ( + -- Should warning user ? + if (SourceFiles.state == 2) and (Test.checked == false) then + ( + -- Warning ! + if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then + RecurseFolder (adjustPathStringForScript Directory.text) + ) + else + ( + RecurseFolder (adjustPathStringForScript Directory.text) + ) + ) + else + ( + -- Just compute the current project + call_do_it () + ) + + -- Show errors + ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." + Progress.value = 100 + ) +) + +assets_png_floater = newRolloutFloater "NeL Assets PNG Database" 550 874 +addrollout assets_png_rollout assets_png_floater rolledUp:false + 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..0a214fbc5 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 @@ -1,378 +1,378 @@ - -NEL3D_APPDATA_INTERFACE_FILE = 1423062700 - --- Allocate 20 Me for the script -heapSize += 15000000 - -nlErrorFilename = "W:/database/conversion.log" -nlErrorStream = openFile nlErrorFilename mode:"w" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Log a message -fn nllog message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - -include "nel_utility.ms" - -fn findFile dir fileName = -( - if (doesFileExist (dir + "\\" + fileName)) then - ( - return (dir + "\\" + fileName) - ) - - dirArr = GetDirectories (dir + "\\*") - - for d in dirArr do - ( - local fileFound = findFile d fileName - if (fileFound != "") then - return fileFound - ) - - return "" -) - -fn getFixedPath ps = -( - if not (doesFileExist ps) then - ( - local fileName = filenameFromPath ps - local fileFound = findFile "W:\\database\\sfx" fileName - if (fileFound != "") then - return fileFound - else - return fileName - ) - else - ( - return ps - ) -) - -fn renameParticleSystem ps = -( - local newFileName = getFixedPath ps.ps_file_name - if (newFileName != ps.ps_file_name) then - ( - ps.ps_file_name = newFileName - return 1 - ) - else - ( - return 0 - ) -) - - -rollout assets_ps_rollout "Properties" -( - fn do_it = - ( - local result = 0 - - for m in getClassInstances nel_ps do - ( - if (renameParticleSystem m) == 1 then - result = 1 - ) - - max select none - - actionMan.executeAction 0 "40021" -- Selection: Select All - actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected - actionMan.executeAction 0 "40807" -- Views: Activate All Maps - actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps - actionMan.executeAction 0 "40043" -- Selection: Select None - - max views redraw - - return result - ) - - -- This script is a base script to include to add multiple functionality to your script - - -- 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 - -- It the function returns <1, the project will not be overwritten - - Group "Running properties" - ( - RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left - - Label DirectoryLabel "Source directory" align:#left - EditText Directory "" width:500 align:#left enabled:false - Button BrowseDirectory "Browse..." align:#left enabled:false - - CheckBox Recurse "Look in subfolders" checked:true enabled:false - CheckBox Test "Test only, do not save" checked:false enabled:false - CheckBox BackupFiles "Backup files" checked:false enabled:false - CheckBox StopOnError "Stop on error" checked:false enabled:false - CheckBox UseTag "Use tag" checked:false enabled:false - - Label ProgressText width:500 align:#left - ProgressBar Progress width:500 align:#left - - Button GoButton "Go" width:500 align:#left - ) - - local countModifications - local countErrors - local fileModified - local fileParsed - - fn UpdateData = - ( - if SourceFiles.state == 2 then - isSourceDir = true - else - isSourceDir = false - if Test.checked == true then - isTest = true - else - isTest = false - - Directory.enabled = isSourceDir - BrowseDirectory.enabled = isSourceDir - Recurse.enabled = isSourceDir - Test.enabled = isSourceDir - BackupFiles.enabled = isSourceDir and (isTest == false) - StopOnError.enabled = isSourceDir - UseTag.enabled = isSourceDir - ) - - on SourceFiles changed state do - ( - UpdateData () - ) - - on Test changed state do - ( - UpdateData () - ) - - fn call_do_it = - ( - local result - - -- One more project - fileParsed = fileParsed + 1 - - -- Call it - result = do_it () - - -- Error ? - if result < 0 then - countErrors = countErrors + 1 - else - countModifications = countModifications + result - - -- Return result - return result - ) - - fn BackupFile file = - ( - local i - local newFilename - - i = 0 - while true do - ( - -- New file name - newFilename = file + ".backup_" + (i as string) - - -- File exist ? - if (fileExist newFilename) == false then - ( - if (copyFile file newFilename) == false then - return false - else - return true - ) - i = i + 1 - ) - ) - - fn RecurseFolder currentDirectory = - ( - resetMAXFile #noprompt - - local result - local file - local files - local origAnimStart - local origAnimEnd - local origFrameRate - - -- Parse files - files = getFiles (currentDirectory+"/*.max") - - -- For each files - for i = 1 to files.count do - ( - -- File name - file = files[i] - - -- Progress bar - ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" - Progress.value = i*100/files.count - - if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then - ( - resetMAXFile #noprompt - - nllog("CONVERT " + file) - - -- Open the max project - if loadMaxFile file quiet:true == true then - ( - objXRefMgr.UpdateAllRecords() - - result = call_do_it () - - -- Error ? - if result < 0 then - ( - if StopOnError.checked == true then - Messagebox ("Error in file " + file) - ) - else - ( - -- Save the max project ? - if (Test.checked == false) and (result != 0) then - ( - -- Backup the max project ? - local ok - ok = true - if BackupFiles.checked == true then - ( - -- Backup the file - if (BackupFile file) == false then - ( - -- Don't save the file because backup has failed - ok = false - - if StopOnError.checked == true then - Messagebox ("Can't backup file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - - -- Save the max project ? - if ok == true then - ( - if (saveMaxFile file) == true then - ( - fileModified = fileModified + 1 - ) - else - ( - if StopOnError.checked == true then - Messagebox ("Can't write file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - ) - ) - ) - else - ( - if StopOnError.checked == true then - Messagebox ("Can't load file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - else - ( - nllog("SKIP " + file + " by tag") - ) - ) - - -- Parse sub directory ? - if (Recurse.checked == true) then - ( - local directories - - -- Get the directories - directories = getDirectories (currentDirectory+"/*") - - -- For each directories - for dir in directories do - ( - RecurseFolder dir - ) - ) - ) - - on BrowseDirectory pressed do - ( - local dir - try - ( - dir = getSavePath () -- caption:"Select the projects directory" - if dir != undefined then - Directory.text = dir - ) - catch - ( - ) - ) - - on GoButton pressed do - ( - -- Reset count - countModifications = 0 - countErrors = 0 - fileModified = 0 - fileParsed = 0 - - -- Get files in the shape_source_directory - if SourceFiles.state == 2 then - ( - -- Should warning user ? - if (SourceFiles.state == 2) and (Test.checked == false) then - ( - -- Warning ! - if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then - RecurseFolder (adjustPathStringForScript Directory.text) - ) - else - ( - RecurseFolder (adjustPathStringForScript Directory.text) - ) - ) - else - ( - -- Just compute the current project - call_do_it () - ) - - -- Show errors - ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." - Progress.value = 100 - ) -) - -assets_ps_floater = newRolloutFloater "NeL Assets PS Database" 550 400 -addrollout assets_ps_rollout assets_ps_floater rolledUp:false - - + +NEL3D_APPDATA_INTERFACE_FILE = 1423062700 + +-- Allocate 20 Me for the script +heapSize += 15000000 + +nlErrorFilename = "W:/database/conversion.log" +nlErrorStream = openFile nlErrorFilename mode:"w" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Log a message +fn nllog message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + +include "nel_utility.ms" + +fn findFile dir fileName = +( + if (doesFileExist (dir + "\\" + fileName)) then + ( + return (dir + "\\" + fileName) + ) + + dirArr = GetDirectories (dir + "\\*") + + for d in dirArr do + ( + local fileFound = findFile d fileName + if (fileFound != "") then + return fileFound + ) + + return "" +) + +fn getFixedPath ps = +( + if not (doesFileExist ps) then + ( + local fileName = filenameFromPath ps + local fileFound = findFile "W:\\database\\sfx" fileName + if (fileFound != "") then + return fileFound + else + return fileName + ) + else + ( + return ps + ) +) + +fn renameParticleSystem ps = +( + local newFileName = getFixedPath ps.ps_file_name + if (newFileName != ps.ps_file_name) then + ( + ps.ps_file_name = newFileName + return 1 + ) + else + ( + return 0 + ) +) + + +rollout assets_ps_rollout "Properties" +( + fn do_it = + ( + local result = 0 + + for m in getClassInstances nel_ps do + ( + if (renameParticleSystem m) == 1 then + result = 1 + ) + + max select none + + actionMan.executeAction 0 "40021" -- Selection: Select All + actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected + actionMan.executeAction 0 "40807" -- Views: Activate All Maps + actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps + actionMan.executeAction 0 "40043" -- Selection: Select None + + max views redraw + + return result + ) + + -- This script is a base script to include to add multiple functionality to your script + + -- 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 occurred, else the count of modification done + -- It the function returns <1, the project will not be overwritten + + Group "Running properties" + ( + RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left + + Label DirectoryLabel "Source directory" align:#left + EditText Directory "" width:500 align:#left enabled:false + Button BrowseDirectory "Browse..." align:#left enabled:false + + CheckBox Recurse "Look in subfolders" checked:true enabled:false + CheckBox Test "Test only, do not save" checked:false enabled:false + CheckBox BackupFiles "Backup files" checked:false enabled:false + CheckBox StopOnError "Stop on error" checked:false enabled:false + CheckBox UseTag "Use tag" checked:false enabled:false + + Label ProgressText width:500 align:#left + ProgressBar Progress width:500 align:#left + + Button GoButton "Go" width:500 align:#left + ) + + local countModifications + local countErrors + local fileModified + local fileParsed + + fn UpdateData = + ( + if SourceFiles.state == 2 then + isSourceDir = true + else + isSourceDir = false + if Test.checked == true then + isTest = true + else + isTest = false + + Directory.enabled = isSourceDir + BrowseDirectory.enabled = isSourceDir + Recurse.enabled = isSourceDir + Test.enabled = isSourceDir + BackupFiles.enabled = isSourceDir and (isTest == false) + StopOnError.enabled = isSourceDir + UseTag.enabled = isSourceDir + ) + + on SourceFiles changed state do + ( + UpdateData () + ) + + on Test changed state do + ( + UpdateData () + ) + + fn call_do_it = + ( + local result + + -- One more project + fileParsed = fileParsed + 1 + + -- Call it + result = do_it () + + -- Error ? + if result < 0 then + countErrors = countErrors + 1 + else + countModifications = countModifications + result + + -- Return result + return result + ) + + fn BackupFile file = + ( + local i + local newFilename + + i = 0 + while true do + ( + -- New file name + newFilename = file + ".backup_" + (i as string) + + -- File exist ? + if (fileExist newFilename) == false then + ( + if (copyFile file newFilename) == false then + return false + else + return true + ) + i = i + 1 + ) + ) + + fn RecurseFolder currentDirectory = + ( + resetMAXFile #noprompt + + local result + local file + local files + local origAnimStart + local origAnimEnd + local origFrameRate + + -- Parse files + files = getFiles (currentDirectory+"/*.max") + + -- For each files + for i = 1 to files.count do + ( + -- File name + file = files[i] + + -- Progress bar + ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" + Progress.value = i*100/files.count + + if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then + ( + resetMAXFile #noprompt + + nllog("CONVERT " + file) + + -- Open the max project + if loadMaxFile file quiet:true == true then + ( + objXRefMgr.UpdateAllRecords() + + result = call_do_it () + + -- Error ? + if result < 0 then + ( + if StopOnError.checked == true then + Messagebox ("Error in file " + file) + ) + else + ( + -- Save the max project ? + if (Test.checked == false) and (result != 0) then + ( + -- Backup the max project ? + local ok + ok = true + if BackupFiles.checked == true then + ( + -- Backup the file + if (BackupFile file) == false then + ( + -- Don't save the file because backup has failed + ok = false + + if StopOnError.checked == true then + Messagebox ("Can't backup file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + + -- Save the max project ? + if ok == true then + ( + if (saveMaxFile file) == true then + ( + fileModified = fileModified + 1 + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't write file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + ) + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't load file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + else + ( + nllog("SKIP " + file + " by tag") + ) + ) + + -- Parse sub directory ? + if (Recurse.checked == true) then + ( + local directories + + -- Get the directories + directories = getDirectories (currentDirectory+"/*") + + -- For each directories + for dir in directories do + ( + RecurseFolder dir + ) + ) + ) + + on BrowseDirectory pressed do + ( + local dir + try + ( + dir = getSavePath () -- caption:"Select the projects directory" + if dir != undefined then + Directory.text = dir + ) + catch + ( + ) + ) + + on GoButton pressed do + ( + -- Reset count + countModifications = 0 + countErrors = 0 + fileModified = 0 + fileParsed = 0 + + -- Get files in the shape_source_directory + if SourceFiles.state == 2 then + ( + -- Should warning user ? + if (SourceFiles.state == 2) and (Test.checked == false) then + ( + -- Warning ! + if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then + RecurseFolder (adjustPathStringForScript Directory.text) + ) + else + ( + RecurseFolder (adjustPathStringForScript Directory.text) + ) + ) + else + ( + -- Just compute the current project + call_do_it () + ) + + -- Show errors + ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." + Progress.value = 100 + ) +) + +assets_ps_floater = newRolloutFloater "NeL Assets PS Database" 550 400 +addrollout assets_ps_rollout assets_ps_floater rolledUp:false + + 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..5260de943 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 @@ -1,329 +1,329 @@ - -NEL3D_APPDATA_INTERFACE_FILE = 1423062700 - --- Allocate 20 Me for the script -heapSize += 15000000 - -nlErrorFilename = "W:/database/conversion.log" -nlErrorStream = openFile nlErrorFilename mode:"w" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Log a message -fn nllog message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - -include "nel_utility.ms" - -rollout assets_resave_rollout "Properties" -( - fn do_it = - ( - max select none - - actionMan.executeAction 0 "40021" -- Selection: Select All - actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected - actionMan.executeAction 0 "40807" -- Views: Activate All Maps - actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps - actionMan.executeAction 0 "40043" -- Selection: Select None - - max views redraw - - return 1 - ) - - -- This script is a base script to include to add multiple functionality to your script - - -- 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 - -- It the function returns <1, the project will not be overwritten - - Group "Running properties" - ( - RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left - - Label DirectoryLabel "Source directory" align:#left - EditText Directory "" width:500 align:#left enabled:false - Button BrowseDirectory "Browse..." align:#left enabled:false - - CheckBox Recurse "Look in subfolders" checked:true enabled:false - CheckBox Test "Test only, do not save" checked:false enabled:false - CheckBox BackupFiles "Backup files" checked:false enabled:false - CheckBox StopOnError "Stop on error" checked:false enabled:false - CheckBox UseTag "Use tag" checked:false enabled:false - - Label ProgressText width:500 align:#left - ProgressBar Progress width:500 align:#left - - Button GoButton "Go" width:500 align:#left - ) - - local countModifications - local countErrors - local fileModified - local fileParsed - - fn UpdateData = - ( - if SourceFiles.state == 2 then - isSourceDir = true - else - isSourceDir = false - if Test.checked == true then - isTest = true - else - isTest = false - - Directory.enabled = isSourceDir - BrowseDirectory.enabled = isSourceDir - Recurse.enabled = isSourceDir - Test.enabled = isSourceDir - BackupFiles.enabled = isSourceDir and (isTest == false) - StopOnError.enabled = isSourceDir - UseTag.enabled = isSourceDir - ) - - on SourceFiles changed state do - ( - UpdateData () - ) - - on Test changed state do - ( - UpdateData () - ) - - fn call_do_it = - ( - local result - - -- One more project - fileParsed = fileParsed + 1 - - -- Call it - result = do_it () - - -- Error ? - if result < 0 then - countErrors = countErrors + 1 - else - countModifications = countModifications + result - - -- Return result - return result - ) - - fn BackupFile file = - ( - local i - local newFilename - - i = 0 - while true do - ( - -- New file name - newFilename = file + ".backup_" + (i as string) - - -- File exist ? - if (fileExist newFilename) == false then - ( - if (copyFile file newFilename) == false then - return false - else - return true - ) - i = i + 1 - ) - ) - - fn RecurseFolder currentDirectory = - ( - resetMAXFile #noprompt - - local result - local file - local files - local origAnimStart - local origAnimEnd - local origFrameRate - - -- Parse files - files = getFiles (currentDirectory+"/*.max") - - -- For each files - for i = 1 to files.count do - ( - -- File name - file = files[i] - - -- Progress bar - ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" - Progress.value = i*100/files.count - - if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then - ( - resetMAXFile #noprompt - - nllog("CONVERT " + file) - - -- Open the max project - if loadMaxFile file quiet:true == true then - ( - origAnimStart = animationRange.start - origAnimEnd = animationRange.end - origFrameRate = frameRate - - resetMAXFile #noprompt - - animationRange = interval origAnimStart origAnimEnd - frameRate = origFrameRate - - -- Merge the max project - if mergeMaxFile file quiet:true == true then - ( - result = call_do_it () - - -- Error ? - if result < 0 then - ( - if StopOnError.checked == true then - Messagebox ("Error in file " + file) - ) - else - ( - -- Save the max project ? - if (Test.checked == false) and (result != 0) then - ( - -- Backup the max project ? - local ok - ok = true - if BackupFiles.checked == true then - ( - -- Backup the file - if (BackupFile file) == false then - ( - -- Don't save the file because backup has failed - ok = false - - if StopOnError.checked == true then - Messagebox ("Can't backup file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - - -- Save the max project ? - if ok == true then - ( - if (saveMaxFile file) == true then - ( - fileModified = fileModified + 1 - ) - else - ( - if StopOnError.checked == true then - Messagebox ("Can't write file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - ) - ) - ) - else - ( - if StopOnError.checked == true then - Messagebox ("Can't load file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - ) - else - ( - nllog("SKIP " + file + " by tag") - ) - ) - - -- Parse sub directory ? - if (Recurse.checked == true) then - ( - local directories - - -- Get the directories - directories = getDirectories (currentDirectory+"/*") - - -- For each directories - for dir in directories do - ( - RecurseFolder dir - ) - ) - ) - - on BrowseDirectory pressed do - ( - local dir - try - ( - dir = getSavePath () -- caption:"Select the projects directory" - if dir != undefined then - Directory.text = dir - ) - catch - ( - ) - ) - - on GoButton pressed do - ( - -- Reset count - countModifications = 0 - countErrors = 0 - fileModified = 0 - fileParsed = 0 - - -- Get files in the shape_source_directory - if SourceFiles.state == 2 then - ( - -- Should warning user ? - if (SourceFiles.state == 2) and (Test.checked == false) then - ( - -- Warning ! - if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then - RecurseFolder (adjustPathStringForScript Directory.text) - ) - else - ( - RecurseFolder (adjustPathStringForScript Directory.text) - ) - ) - else - ( - -- Just compute the current project - call_do_it () - ) - - -- Show errors - ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." - Progress.value = 100 - ) -) - -assets_resave_floater = newRolloutFloater "NeL Assets Resave Database" 550 874 -addrollout assets_resave_rollout assets_resave_floater rolledUp:false - + +NEL3D_APPDATA_INTERFACE_FILE = 1423062700 + +-- Allocate 20 Me for the script +heapSize += 15000000 + +nlErrorFilename = "W:/database/conversion.log" +nlErrorStream = openFile nlErrorFilename mode:"w" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Log a message +fn nllog message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + +include "nel_utility.ms" + +rollout assets_resave_rollout "Properties" +( + fn do_it = + ( + max select none + + actionMan.executeAction 0 "40021" -- Selection: Select All + actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected + actionMan.executeAction 0 "40807" -- Views: Activate All Maps + actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps + actionMan.executeAction 0 "40043" -- Selection: Select None + + max views redraw + + return 1 + ) + + -- This script is a base script to include to add multiple functionality to your script + + -- 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 occurred, else the count of modification done + -- It the function returns <1, the project will not be overwritten + + Group "Running properties" + ( + RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left + + Label DirectoryLabel "Source directory" align:#left + EditText Directory "" width:500 align:#left enabled:false + Button BrowseDirectory "Browse..." align:#left enabled:false + + CheckBox Recurse "Look in subfolders" checked:true enabled:false + CheckBox Test "Test only, do not save" checked:false enabled:false + CheckBox BackupFiles "Backup files" checked:false enabled:false + CheckBox StopOnError "Stop on error" checked:false enabled:false + CheckBox UseTag "Use tag" checked:false enabled:false + + Label ProgressText width:500 align:#left + ProgressBar Progress width:500 align:#left + + Button GoButton "Go" width:500 align:#left + ) + + local countModifications + local countErrors + local fileModified + local fileParsed + + fn UpdateData = + ( + if SourceFiles.state == 2 then + isSourceDir = true + else + isSourceDir = false + if Test.checked == true then + isTest = true + else + isTest = false + + Directory.enabled = isSourceDir + BrowseDirectory.enabled = isSourceDir + Recurse.enabled = isSourceDir + Test.enabled = isSourceDir + BackupFiles.enabled = isSourceDir and (isTest == false) + StopOnError.enabled = isSourceDir + UseTag.enabled = isSourceDir + ) + + on SourceFiles changed state do + ( + UpdateData () + ) + + on Test changed state do + ( + UpdateData () + ) + + fn call_do_it = + ( + local result + + -- One more project + fileParsed = fileParsed + 1 + + -- Call it + result = do_it () + + -- Error ? + if result < 0 then + countErrors = countErrors + 1 + else + countModifications = countModifications + result + + -- Return result + return result + ) + + fn BackupFile file = + ( + local i + local newFilename + + i = 0 + while true do + ( + -- New file name + newFilename = file + ".backup_" + (i as string) + + -- File exist ? + if (fileExist newFilename) == false then + ( + if (copyFile file newFilename) == false then + return false + else + return true + ) + i = i + 1 + ) + ) + + fn RecurseFolder currentDirectory = + ( + resetMAXFile #noprompt + + local result + local file + local files + local origAnimStart + local origAnimEnd + local origFrameRate + + -- Parse files + files = getFiles (currentDirectory+"/*.max") + + -- For each files + for i = 1 to files.count do + ( + -- File name + file = files[i] + + -- Progress bar + ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" + Progress.value = i*100/files.count + + if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then + ( + resetMAXFile #noprompt + + nllog("CONVERT " + file) + + -- Open the max project + if loadMaxFile file quiet:true == true then + ( + origAnimStart = animationRange.start + origAnimEnd = animationRange.end + origFrameRate = frameRate + + resetMAXFile #noprompt + + animationRange = interval origAnimStart origAnimEnd + frameRate = origFrameRate + + -- Merge the max project + if mergeMaxFile file quiet:true == true then + ( + result = call_do_it () + + -- Error ? + if result < 0 then + ( + if StopOnError.checked == true then + Messagebox ("Error in file " + file) + ) + else + ( + -- Save the max project ? + if (Test.checked == false) and (result != 0) then + ( + -- Backup the max project ? + local ok + ok = true + if BackupFiles.checked == true then + ( + -- Backup the file + if (BackupFile file) == false then + ( + -- Don't save the file because backup has failed + ok = false + + if StopOnError.checked == true then + Messagebox ("Can't backup file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + + -- Save the max project ? + if ok == true then + ( + if (saveMaxFile file) == true then + ( + fileModified = fileModified + 1 + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't write file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + ) + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't load file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + else + ( + nllog("SKIP " + file + " by tag") + ) + ) + + -- Parse sub directory ? + if (Recurse.checked == true) then + ( + local directories + + -- Get the directories + directories = getDirectories (currentDirectory+"/*") + + -- For each directories + for dir in directories do + ( + RecurseFolder dir + ) + ) + ) + + on BrowseDirectory pressed do + ( + local dir + try + ( + dir = getSavePath () -- caption:"Select the projects directory" + if dir != undefined then + Directory.text = dir + ) + catch + ( + ) + ) + + on GoButton pressed do + ( + -- Reset count + countModifications = 0 + countErrors = 0 + fileModified = 0 + fileParsed = 0 + + -- Get files in the shape_source_directory + if SourceFiles.state == 2 then + ( + -- Should warning user ? + if (SourceFiles.state == 2) and (Test.checked == false) then + ( + -- Warning ! + if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then + RecurseFolder (adjustPathStringForScript Directory.text) + ) + else + ( + RecurseFolder (adjustPathStringForScript Directory.text) + ) + ) + else + ( + -- Just compute the current project + call_do_it () + ) + + -- Show errors + ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." + Progress.value = 100 + ) +) + +assets_resave_floater = newRolloutFloater "NeL Assets Resave Database" 550 874 +addrollout assets_resave_rollout assets_resave_floater rolledUp:false + 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..bf5b7bb4b 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 @@ -1,316 +1,316 @@ - -NEL3D_APPDATA_INTERFACE_FILE = 1423062700 - --- Allocate 20 Me for the script -heapSize += 15000000 - -nlErrorFilename = "W:/database/conversion.log" -nlErrorStream = openFile nlErrorFilename mode:"w" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Log a message -fn nllog message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - -include "nel_utility.ms" - -rollout assets_resave_rollout "Properties" -( - fn do_it = - ( - max select none - - actionMan.executeAction 0 "40021" -- Selection: Select All - actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected - actionMan.executeAction 0 "40807" -- Views: Activate All Maps - actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps - actionMan.executeAction 0 "40043" -- Selection: Select None - - max views redraw - - return 1 - ) - - -- This script is a base script to include to add multiple functionality to your script - - -- 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 - -- It the function returns <1, the project will not be overwritten - - Group "Running properties" - ( - RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left - - Label DirectoryLabel "Source directory" align:#left - EditText Directory "" width:500 align:#left enabled:false - Button BrowseDirectory "Browse..." align:#left enabled:false - - CheckBox Recurse "Look in subfolders" checked:true enabled:false - CheckBox Test "Test only, do not save" checked:false enabled:false - CheckBox BackupFiles "Backup files" checked:false enabled:false - CheckBox StopOnError "Stop on error" checked:false enabled:false - CheckBox UseTag "Use tag" checked:false enabled:false - - Label ProgressText width:500 align:#left - ProgressBar Progress width:500 align:#left - - Button GoButton "Go" width:500 align:#left - ) - - local countModifications - local countErrors - local fileModified - local fileParsed - - fn UpdateData = - ( - if SourceFiles.state == 2 then - isSourceDir = true - else - isSourceDir = false - if Test.checked == true then - isTest = true - else - isTest = false - - Directory.enabled = isSourceDir - BrowseDirectory.enabled = isSourceDir - Recurse.enabled = isSourceDir - Test.enabled = isSourceDir - BackupFiles.enabled = isSourceDir and (isTest == false) - StopOnError.enabled = isSourceDir - UseTag.enabled = isSourceDir - ) - - on SourceFiles changed state do - ( - UpdateData () - ) - - on Test changed state do - ( - UpdateData () - ) - - fn call_do_it = - ( - local result - - -- One more project - fileParsed = fileParsed + 1 - - -- Call it - result = do_it () - - -- Error ? - if result < 0 then - countErrors = countErrors + 1 - else - countModifications = countModifications + result - - -- Return result - return result - ) - - fn BackupFile file = - ( - local i - local newFilename - - i = 0 - while true do - ( - -- New file name - newFilename = file + ".backup_" + (i as string) - - -- File exist ? - if (fileExist newFilename) == false then - ( - if (copyFile file newFilename) == false then - return false - else - return true - ) - i = i + 1 - ) - ) - - fn RecurseFolder currentDirectory = - ( - resetMAXFile #noprompt - - local result - local file - local files - local origAnimStart - local origAnimEnd - local origFrameRate - - -- Parse files - files = getFiles (currentDirectory+"/*.max") - - -- For each files - for i = 1 to files.count do - ( - -- File name - file = files[i] - - -- Progress bar - ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" - Progress.value = i*100/files.count - - if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then - ( - resetMAXFile #noprompt - - nllog("CONVERT " + file) - - -- Merge the max project - if mergeMaxFile file quiet:true == true then - ( - result = call_do_it () - - -- Error ? - if result < 0 then - ( - if StopOnError.checked == true then - Messagebox ("Error in file " + file) - ) - else - ( - -- Save the max project ? - if (Test.checked == false) and (result != 0) then - ( - -- Backup the max project ? - local ok - ok = true - if BackupFiles.checked == true then - ( - -- Backup the file - if (BackupFile file) == false then - ( - -- Don't save the file because backup has failed - ok = false - - if StopOnError.checked == true then - Messagebox ("Can't backup file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - - -- Save the max project ? - if ok == true then - ( - if (saveMaxFile file) == true then - ( - fileModified = fileModified + 1 - ) - else - ( - if StopOnError.checked == true then - Messagebox ("Can't write file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - ) - ) - ) - else - ( - if StopOnError.checked == true then - Messagebox ("Can't load file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - else - ( - nllog("SKIP " + file + " by tag") - ) - ) - - -- Parse sub directory ? - if (Recurse.checked == true) then - ( - local directories - - -- Get the directories - directories = getDirectories (currentDirectory+"/*") - - -- For each directories - for dir in directories do - ( - RecurseFolder dir - ) - ) - ) - - on BrowseDirectory pressed do - ( - local dir - try - ( - dir = getSavePath () -- caption:"Select the projects directory" - if dir != undefined then - Directory.text = dir - ) - catch - ( - ) - ) - - on GoButton pressed do - ( - -- Reset count - countModifications = 0 - countErrors = 0 - fileModified = 0 - fileParsed = 0 - - -- Get files in the shape_source_directory - if SourceFiles.state == 2 then - ( - -- Should warning user ? - if (SourceFiles.state == 2) and (Test.checked == false) then - ( - -- Warning ! - if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then - RecurseFolder (adjustPathStringForScript Directory.text) - ) - else - ( - RecurseFolder (adjustPathStringForScript Directory.text) - ) - ) - else - ( - -- Just compute the current project - call_do_it () - ) - - -- Show errors - ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." - Progress.value = 100 - ) -) - -assets_resave_floater = newRolloutFloater "NeL Assets Resave Database Hard" 550 874 -addrollout assets_resave_rollout assets_resave_floater rolledUp:false - + +NEL3D_APPDATA_INTERFACE_FILE = 1423062700 + +-- Allocate 20 Me for the script +heapSize += 15000000 + +nlErrorFilename = "W:/database/conversion.log" +nlErrorStream = openFile nlErrorFilename mode:"w" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Log a message +fn nllog message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + +include "nel_utility.ms" + +rollout assets_resave_rollout "Properties" +( + fn do_it = + ( + max select none + + actionMan.executeAction 0 "40021" -- Selection: Select All + actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected + actionMan.executeAction 0 "40807" -- Views: Activate All Maps + actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps + actionMan.executeAction 0 "40043" -- Selection: Select None + + max views redraw + + return 1 + ) + + -- This script is a base script to include to add multiple functionality to your script + + -- 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 occurred, else the count of modification done + -- It the function returns <1, the project will not be overwritten + + Group "Running properties" + ( + RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left + + Label DirectoryLabel "Source directory" align:#left + EditText Directory "" width:500 align:#left enabled:false + Button BrowseDirectory "Browse..." align:#left enabled:false + + CheckBox Recurse "Look in subfolders" checked:true enabled:false + CheckBox Test "Test only, do not save" checked:false enabled:false + CheckBox BackupFiles "Backup files" checked:false enabled:false + CheckBox StopOnError "Stop on error" checked:false enabled:false + CheckBox UseTag "Use tag" checked:false enabled:false + + Label ProgressText width:500 align:#left + ProgressBar Progress width:500 align:#left + + Button GoButton "Go" width:500 align:#left + ) + + local countModifications + local countErrors + local fileModified + local fileParsed + + fn UpdateData = + ( + if SourceFiles.state == 2 then + isSourceDir = true + else + isSourceDir = false + if Test.checked == true then + isTest = true + else + isTest = false + + Directory.enabled = isSourceDir + BrowseDirectory.enabled = isSourceDir + Recurse.enabled = isSourceDir + Test.enabled = isSourceDir + BackupFiles.enabled = isSourceDir and (isTest == false) + StopOnError.enabled = isSourceDir + UseTag.enabled = isSourceDir + ) + + on SourceFiles changed state do + ( + UpdateData () + ) + + on Test changed state do + ( + UpdateData () + ) + + fn call_do_it = + ( + local result + + -- One more project + fileParsed = fileParsed + 1 + + -- Call it + result = do_it () + + -- Error ? + if result < 0 then + countErrors = countErrors + 1 + else + countModifications = countModifications + result + + -- Return result + return result + ) + + fn BackupFile file = + ( + local i + local newFilename + + i = 0 + while true do + ( + -- New file name + newFilename = file + ".backup_" + (i as string) + + -- File exist ? + if (fileExist newFilename) == false then + ( + if (copyFile file newFilename) == false then + return false + else + return true + ) + i = i + 1 + ) + ) + + fn RecurseFolder currentDirectory = + ( + resetMAXFile #noprompt + + local result + local file + local files + local origAnimStart + local origAnimEnd + local origFrameRate + + -- Parse files + files = getFiles (currentDirectory+"/*.max") + + -- For each files + for i = 1 to files.count do + ( + -- File name + file = files[i] + + -- Progress bar + ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" + Progress.value = i*100/files.count + + if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then + ( + resetMAXFile #noprompt + + nllog("CONVERT " + file) + + -- Merge the max project + if mergeMaxFile file quiet:true == true then + ( + result = call_do_it () + + -- Error ? + if result < 0 then + ( + if StopOnError.checked == true then + Messagebox ("Error in file " + file) + ) + else + ( + -- Save the max project ? + if (Test.checked == false) and (result != 0) then + ( + -- Backup the max project ? + local ok + ok = true + if BackupFiles.checked == true then + ( + -- Backup the file + if (BackupFile file) == false then + ( + -- Don't save the file because backup has failed + ok = false + + if StopOnError.checked == true then + Messagebox ("Can't backup file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + + -- Save the max project ? + if ok == true then + ( + if (saveMaxFile file) == true then + ( + fileModified = fileModified + 1 + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't write file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + ) + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't load file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + else + ( + nllog("SKIP " + file + " by tag") + ) + ) + + -- Parse sub directory ? + if (Recurse.checked == true) then + ( + local directories + + -- Get the directories + directories = getDirectories (currentDirectory+"/*") + + -- For each directories + for dir in directories do + ( + RecurseFolder dir + ) + ) + ) + + on BrowseDirectory pressed do + ( + local dir + try + ( + dir = getSavePath () -- caption:"Select the projects directory" + if dir != undefined then + Directory.text = dir + ) + catch + ( + ) + ) + + on GoButton pressed do + ( + -- Reset count + countModifications = 0 + countErrors = 0 + fileModified = 0 + fileParsed = 0 + + -- Get files in the shape_source_directory + if SourceFiles.state == 2 then + ( + -- Should warning user ? + if (SourceFiles.state == 2) and (Test.checked == false) then + ( + -- Warning ! + if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then + RecurseFolder (adjustPathStringForScript Directory.text) + ) + else + ( + RecurseFolder (adjustPathStringForScript Directory.text) + ) + ) + else + ( + -- Just compute the current project + call_do_it () + ) + + -- Show errors + ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." + Progress.value = 100 + ) +) + +assets_resave_floater = newRolloutFloater "NeL Assets Resave Database Hard" 550 874 +addrollout assets_resave_rollout assets_resave_floater rolledUp:false + 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..8b724d9a9 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 @@ -1,251 +1,251 @@ --- This script is a base script to include to add multiple functionality to your script - --- 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 --- It the function returns <1, the project will not be overwritten - -Group "Running properties" -( - RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left - - Label DirectoryLabel "Source directory" align:#left - EditText Directory "" width:500 align:#left enabled:false - Button BrowseDirectory "Browse..." align:#left enabled:false - - CheckBox Recurse "Look in subfolders" checked:false enabled:false - CheckBox Test "Test only, do not save" checked:true enabled:false - CheckBox BackupFiles "Backup files" checked:true enabled:false - CheckBox StopOnError "Stop on error" checked:true enabled:false - - Label ProgressText width:500 align:#left - ProgressBar Progress width:500 align:#left - - Button GoButton "Go" width:500 align:#left -) - local countModifications - local countErrors - local fileModified - local fileParsed - - fn UpdateData = - ( - if SourceFiles.state == 2 then - isSourceDir = true - else - isSourceDir = false - if Test.checked == true then - isTest = true - else - isTest = false - - Directory.enabled = isSourceDir - BrowseDirectory.enabled = isSourceDir - Recurse.enabled = isSourceDir - Test.enabled = isSourceDir - BackupFiles.enabled = isSourceDir and (isTest == false) - StopOnError.enabled = isSourceDir - ) - - on SourceFiles changed state do - ( - UpdateData () - ) - - on Test changed state do - ( - UpdateData () - ) - - fn call_do_it = - ( - local result - - -- One more project - fileParsed = fileParsed + 1 - - -- Call it - result = do_it () - - -- Error ? - if result < 0 then - countErrors = countErrors + 1 - else - countModifications = countModifications + result - - -- Return result - return result - ) - - fn BackupFile file = - ( - local i - local newFilename - - i = 0 - while true do - ( - -- New file name - newFilename = file + ".backup_" + (i as string) - - -- File exist ? - if (fileExist newFilename) == false then - ( - if (copyFile file newFilename) == false then - return false - else - return true - ) - i = i + 1 - ) - ) - - fn RecurseFolder currentDirectory = - ( - local result - local file - local files - - -- Parse files - files = getFiles (currentDirectory+"/*.max") - - -- For each files - for i = 1 to files.count do - ( - -- File name - file = files[i] - - -- Progress bar - ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" - Progress.value = i*100/files.count - - resetMAXFile #noprompt - - -- Open the max project - if mergeMaxFile file quiet:true == true then - ( - result = call_do_it () - - -- Error ? - if result < 0 then - ( - if StopOnError.checked == true then - Messagebox ("Error in file " + file) - ) - else - ( - -- Save the max project ? - if (Test.checked == false) and (result != 0) then - ( - -- Backup the max project ? - local ok - ok = true - if BackupFiles.checked == true then - ( - -- Backup the file - if (BackupFile file) == false then - ( - -- Don't save the file because backup has failed - ok = false - - if StopOnError.checked == true then - Messagebox ("Can't backup file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - - -- Save the max project ? - if ok == true then - ( - if (saveMaxFile file) == true then - ( - fileModified = fileModified + 1 - ) - else - ( - if StopOnError.checked == true then - Messagebox ("Can't write file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - ) - ) - ) - else - ( - if StopOnError.checked == true then - Messagebox ("Can't load file " + file) - - -- One more error - countErrors = countErrors + 1 - ) - ) - - -- Parse sub directory ? - if (Recurse.checked == true) then - ( - local directories - - -- Get the directories - directories = getDirectories (currentDirectory+"/*") - - -- For each directories - for dir in directories do - ( - RecurseFolder dir - ) - ) - ) - - on BrowseDirectory pressed do - ( - local dir - try - ( - dir = getSavePath () -- caption:"Select the projects directory" - if dir != undefined then - Directory.text = dir - ) - catch - ( - ) - ) - - on GoButton pressed do - ( - -- Reset count - countModifications = 0 - countErrors = 0 - fileModified = 0 - fileParsed = 0 - - -- Get files in the shape_source_directory - if SourceFiles.state == 2 then - ( - -- Should warning user ? - if (SourceFiles.state == 2) and (Test.checked == false) then - ( - -- Warning ! - if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then - RecurseFolder (adjustPathStringForScript Directory.text) - ) - else - ( - RecurseFolder (adjustPathStringForScript Directory.text) - ) - ) - else - ( - -- Just compute the current project - call_do_it () - ) - - -- Show errors - ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." - Progress.value = 100 - ) +-- This script is a base script to include to add multiple functionality to your script + +-- 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 occurred, else the count of modification done +-- It the function returns <1, the project will not be overwritten + +Group "Running properties" +( + RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left + + Label DirectoryLabel "Source directory" align:#left + EditText Directory "" width:500 align:#left enabled:false + Button BrowseDirectory "Browse..." align:#left enabled:false + + CheckBox Recurse "Look in subfolders" checked:false enabled:false + CheckBox Test "Test only, do not save" checked:true enabled:false + CheckBox BackupFiles "Backup files" checked:true enabled:false + CheckBox StopOnError "Stop on error" checked:true enabled:false + + Label ProgressText width:500 align:#left + ProgressBar Progress width:500 align:#left + + Button GoButton "Go" width:500 align:#left +) + local countModifications + local countErrors + local fileModified + local fileParsed + + fn UpdateData = + ( + if SourceFiles.state == 2 then + isSourceDir = true + else + isSourceDir = false + if Test.checked == true then + isTest = true + else + isTest = false + + Directory.enabled = isSourceDir + BrowseDirectory.enabled = isSourceDir + Recurse.enabled = isSourceDir + Test.enabled = isSourceDir + BackupFiles.enabled = isSourceDir and (isTest == false) + StopOnError.enabled = isSourceDir + ) + + on SourceFiles changed state do + ( + UpdateData () + ) + + on Test changed state do + ( + UpdateData () + ) + + fn call_do_it = + ( + local result + + -- One more project + fileParsed = fileParsed + 1 + + -- Call it + result = do_it () + + -- Error ? + if result < 0 then + countErrors = countErrors + 1 + else + countModifications = countModifications + result + + -- Return result + return result + ) + + fn BackupFile file = + ( + local i + local newFilename + + i = 0 + while true do + ( + -- New file name + newFilename = file + ".backup_" + (i as string) + + -- File exist ? + if (fileExist newFilename) == false then + ( + if (copyFile file newFilename) == false then + return false + else + return true + ) + i = i + 1 + ) + ) + + fn RecurseFolder currentDirectory = + ( + local result + local file + local files + + -- Parse files + files = getFiles (currentDirectory+"/*.max") + + -- For each files + for i = 1 to files.count do + ( + -- File name + file = files[i] + + -- Progress bar + ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\"" + Progress.value = i*100/files.count + + resetMAXFile #noprompt + + -- Open the max project + if mergeMaxFile file quiet:true == true then + ( + result = call_do_it () + + -- Error ? + if result < 0 then + ( + if StopOnError.checked == true then + Messagebox ("Error in file " + file) + ) + else + ( + -- Save the max project ? + if (Test.checked == false) and (result != 0) then + ( + -- Backup the max project ? + local ok + ok = true + if BackupFiles.checked == true then + ( + -- Backup the file + if (BackupFile file) == false then + ( + -- Don't save the file because backup has failed + ok = false + + if StopOnError.checked == true then + Messagebox ("Can't backup file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + + -- Save the max project ? + if ok == true then + ( + if (saveMaxFile file) == true then + ( + fileModified = fileModified + 1 + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't write file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + ) + ) + ) + else + ( + if StopOnError.checked == true then + Messagebox ("Can't load file " + file) + + -- One more error + countErrors = countErrors + 1 + ) + ) + + -- Parse sub directory ? + if (Recurse.checked == true) then + ( + local directories + + -- Get the directories + directories = getDirectories (currentDirectory+"/*") + + -- For each directories + for dir in directories do + ( + RecurseFolder dir + ) + ) + ) + + on BrowseDirectory pressed do + ( + local dir + try + ( + dir = getSavePath () -- caption:"Select the projects directory" + if dir != undefined then + Directory.text = dir + ) + catch + ( + ) + ) + + on GoButton pressed do + ( + -- Reset count + countModifications = 0 + countErrors = 0 + fileModified = 0 + fileParsed = 0 + + -- Get files in the shape_source_directory + if SourceFiles.state == 2 then + ( + -- Should warning user ? + if (SourceFiles.state == 2) and (Test.checked == false) then + ( + -- Warning ! + if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then + RecurseFolder (adjustPathStringForScript Directory.text) + ) + else + ( + RecurseFolder (adjustPathStringForScript Directory.text) + ) + ) + else + ( + -- Just compute the current project + call_do_it () + ) + + -- Show errors + ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)." + Progress.value = 100 + ) 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/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/textures_tool/CMakeLists.txt b/code/nel/tools/3d/textures_tool/CMakeLists.txt new file mode 100644 index 000000000..203167162 --- /dev/null +++ b/code/nel/tools/3d/textures_tool/CMakeLists.txt @@ -0,0 +1,9 @@ +FILE(GLOB SRC *.cpp *.h) + +ADD_EXECUTABLE(textures_tool ${SRC}) + +TARGET_LINK_LIBRARIES(textures_tool nelmisc) +NL_DEFAULT_PROPS(textures_tool "NeL, Tools, 3D: Textures Tool") +NL_ADD_RUNTIME_FLAGS(textures_tool) + +INSTALL(TARGETS textures_tool RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d) diff --git a/code/nel/tools/3d/textures_tool/main.cpp b/code/nel/tools/3d/textures_tool/main.cpp new file mode 100644 index 000000000..cccb62bee --- /dev/null +++ b/code/nel/tools/3d/textures_tool/main.cpp @@ -0,0 +1,445 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "nel/misc/file.h" +#include "nel/misc/common.h" +#include "nel/misc/bitmap.h" +#include "nel/misc/path.h" +#include "nel/misc/cmd_args.h" +#include "nel/misc/vector_2d.h" +#include "nel/misc/uv.h" +#include "nel/misc/algo.h" + +struct CPoint +{ + CPoint(sint _x, sint _y) :x(_x), y(_y) + { + } + + CPoint operator + (const CPoint &p) const + { + return CPoint(x + p.x, y + p.y); + } + + sint x; + sint y; +}; + +const CPoint Up(0, -1); +const CPoint Down(0, 1); +const CPoint Left(-1, 0); +const CPoint Right(1, 0); + +uint TextureSize = 4096; + +const NLMISC::CRGBA DiscardColor = NLMISC::CRGBA::Red; +const NLMISC::CRGBA KeepColor = NLMISC::CRGBA::Blue; + +typedef std::vector CPoints; + +struct CFace +{ + std::vector indices; +}; + +struct CObject +{ + std::string name; + std::vector textureCoords; + std::vector faces; + + void display() + { + nlinfo("Object %s processed with %u vertices and %u faces", name.c_str(), (uint)textureCoords.size(), (uint)faces.size()); + } +}; + +bool fillPoint(NLMISC::CBitmap &bitmap, sint width, CPoints &points) +{ + if (points.empty()) return false; + + // take last point in queue + CPoint p(points.back()); + points.pop_back(); + + NLMISC::CRGBA c = bitmap.getPixelColor(p.x, p.y); + + if (c == NLMISC::CRGBA::White) + { + // white is used for background + + // replace with color we want to discard + bitmap.setPixelColor(p.x, p.y, DiscardColor); + + uint w = bitmap.getWidth(); + uint h = bitmap.getHeight(); + + // put adjacent pixels in queue to process later + if (p.y > 0) points.push_back(p + Up); + if (p.y < h-1) points.push_back(p + Down); + if (p.x > 0) points.push_back(p + Left); + if (p.x < w-1) points.push_back(p + Right); + } + else if (c == NLMISC::CRGBA::Black) + { + // black is used for vertices + + // increase them by border width + for (sint y = -width; y <= width; ++y) + { + for (sint x = -width; x <= width; ++x) + { + bitmap.setPixelColor(p.x + x, p.y + y, KeepColor); + } + } + } + + return true; +} + +void drawEdge(NLMISC::CBitmap &bitmap, const CObject &object, const CFace &face, uint index0, uint index1) +{ + NLMISC::CUV uv0 = object.textureCoords[face.indices[index0]]; + NLMISC::CUV uv1 = object.textureCoords[face.indices[index1]]; + + std::vector > pixels; + + // draw the triangle with vertices UV coordinates + NLMISC::drawFullLine(uv0.U, uv0.V, uv1.U, uv1.V, pixels); + + // for each pixels, set them to black + for (uint j = 0, jlen = pixels.size(); j < jlen; ++j) + { + bitmap.setPixelColor(pixels[j].first, pixels[j].second, NLMISC::CRGBA::Black); + } +} + +int main(int argc, char **argv) +{ + NLMISC::CApplicationContext applicationContext; + + // Parse Command Line. + //==================== + NLMISC::CCmdArgs args; + + args.setDescription("Textures tool"); + args.addArg("c", "colorize", "color", "Colorize textures using a color (in HTML hexdecimal format like #rrggbb)"); + args.addArg("f", "fill", "color or image", "Fill background part with color or image"); + args.addArg("u", "uvmap", "", "Generate a UV Map texture from OBJ file"); + args.addArg("w", "width", "width of border", "Width of the border to fill (default 0)"); + args.addArg("s", "size", "size of output bitmap", "Width and height of generated bitmap (default 4096)"); + args.addArg("b", "background", "background color", "Color to use to fill background"); + args.addArg("o", "output", "filename", "Output filename"); + args.addAdditionalArg("filename", "File to process", true, true); + + if (!args.parse(argc, argv)) return 1; + + std::string filename = args.getAdditionalArg("filename").front(); + + std::string output = args.haveArg("o") ? args.getArg("o").front() : ""; + + if (args.haveArg("s")) + { + // size of generated bitmap + NLMISC::fromString(args.getArg("s").front(), TextureSize); + } + + if (args.haveArg("c")) + { + // colorize + NLMISC::CIFile file; + + NLMISC::CRGBA color; + color.fromString(args.getArg("c").front()); + + if (file.open(filename)) + { + NLMISC::CBitmap bitmap; + + if (bitmap.load(file)) + { + NLMISC::CObjectVector &pixels = bitmap.getPixels(); + + NLMISC::CRGBA *pRGBA = (NLMISC::CRGBA*)&pixels[0]; + + uint32 size = bitmap.getSize(); + + for (uint j = 0; j < size; ++j) + { + pRGBA->modulateFromColorRGBOnly(*pRGBA, color); + ++pRGBA; + } + + NLMISC::COFile out; + + if (out.open(output)) + { + bitmap.writePNG(out, 24); + } + } + } + } + + if (args.haveArg("f")) + { + // fill areas in a bitmap with another texture or color + + // for example : + // textures_tool -f normal.png -w 2 -b #000000 uvmap.png -o test_normal.png + // will use a copy 1024x1024 texture map on a 4096x4096 UV Map preserving the different areas + + std::string foregroundColorOrFilename = args.getArg("f").front(); + + NLMISC::CRGBA foregroundColor = NLMISC::CRGBA::Black, backgroundColor = NLMISC::CRGBA::Black; + + NLMISC::CBitmap textureBitmap; + + bool useTexture = false; + + // f parameter is required + if (NLMISC::CFile::fileExists(foregroundColorOrFilename)) + { + // load texture + NLMISC::CIFile textureFile; + + if (!textureFile.open(foregroundColorOrFilename)) + { + nlwarning("Unable to open %s", foregroundColorOrFilename.c_str()); + return 1; + } + + // decode texture + if (!textureBitmap.load(textureFile)) + { + nlwarning("Unable to decode %s", foregroundColorOrFilename.c_str()); + return 1; + } + + useTexture = true; + } + else + { + // parse color from argument + foregroundColor.fromString(foregroundColorOrFilename); + } + + if (args.haveArg("b")) + { + // parse HTML color from argument + backgroundColor.fromString(args.getArg("b").front()); + } + + sint width = 0; + + if (args.haveArg("w")) + { + // parse width of borders + NLMISC::fromString(args.getArg("w").front(), width); + } + + // load bitmap + NLMISC::CIFile file; + + if (!file.open(filename)) + { + nlwarning("Unable to open %s", filename.c_str()); + return 1; + } + + // decode bitmap + NLMISC::CBitmap inBitmap; + + if (!inBitmap.load(file)) + { + nlwarning("Unable to decode %s", filename.c_str()); + return 1; + } + + CPoints Points; + + // we can't have more than width * height points, so allocate memory for all of them + Points.reserve(inBitmap.getWidth() * inBitmap.getHeight()); + + // first point to process + Points.push_back(CPoint(0, 0)); + + // process all points from 0, 0 + while(fillPoint(inBitmap, width, Points)) { } + + // create a new bitmap for output + NLMISC::CBitmap outBitmap; + outBitmap.resize(inBitmap.getWidth(), inBitmap.getHeight()); + + // copy points colors to new bitmap + for (sint y = 0, h = inBitmap.getHeight(); y < h; ++y) + { + for (sint x = 0, w = inBitmap.getWidth(); x < w; ++x) + { + if (inBitmap.getPixelColor(x, y) != DiscardColor) + { + // we copy this point, repeat texture image if using it + outBitmap.setPixelColor(x, y, useTexture ? textureBitmap.getPixelColor(x % textureBitmap.getWidth(), y % textureBitmap.getHeight()) : foregroundColor); + } + else + { + // put a background color + outBitmap.setPixelColor(x, y, backgroundColor); + } + } + } + + // save output bitmap + NLMISC::COFile outFile; + + if (outFile.open(output)) + { + outBitmap.writePNG(outFile, 24); + } + } + + if (args.haveArg("u")) + { + NLMISC::CIFile objFile; + + if (!objFile.open(filename)) + { + nlwarning("Unable to open %s", filename.c_str()); + return 1; + } + + CObject object; + + char buffer[1024]; + + while (!objFile.eof()) + { + objFile.getline(buffer, 1024); + buffer[1023] = '\0'; + + std::string line(buffer); + + if (line.size() > 1022) + { + nlwarning("More than 1022 bytes on a line!"); + return 1; + } + + if (line.size() < 3) continue; + + // texture coordinate + if (line.substr(0, 3) == "vt ") + { + // vertex texture + std::vector tokens; + NLMISC::explode(line, std::string(" "), tokens); + + if (tokens.size() == 3) + { + float u, v; + NLMISC::fromString(tokens[1], u); + NLMISC::fromString(tokens[2], v); + + // V coordinates are inverted + object.textureCoords.push_back(NLMISC::CUV(u * (float)TextureSize, (1.f - v) * (float)TextureSize)); + } + else + { + nlwarning("Not 3 arguments for VT"); + } + } + else if (line.substr(0, 2) == "f ") + { + // face + std::vector tokens; + NLMISC::explode(line, std::string(" "), tokens); + + CFace face; + face.indices.resize(tokens.size()-1); + + bool faceValid = true; + + for (uint i = 1, ilen = tokens.size(); i < ilen; ++i) + { + std::vector tokens2; + NLMISC::explode(tokens[i], std::string("/"), tokens2); + + if (tokens2.size() == 3) + { + if (NLMISC::fromString(tokens2[1], face.indices[i - 1])) + { + // we want indices start from 0 instead of 1 + --face.indices[i - 1]; + } + else + { + faceValid = false; + } + } + else + { + nlwarning("Not 3 arguments for indices"); + } + } + + if (faceValid) object.faces.push_back(face); + } + else if (line.substr(0, 2) == "o ") + { + // object + object.name = line.substr(2); + object.display(); + } + } + + object.display(); + + objFile.close(); + + // draw UV Map + // create a new bitmap for output + NLMISC::CBitmap outBitmap; + outBitmap.resize(TextureSize, TextureSize); + + // white background + memset(&outBitmap.getPixels()[0], 255, TextureSize * TextureSize * 4); + + // process all faces + for (uint i = 0, ilen = object.faces.size(); i < ilen; ++i) + { + const CFace &face = object.faces[i]; + + // pixels of a face + for (uint k = 1, klen = face.indices.size(); k < klen; ++k) + { + drawEdge(outBitmap, object, face, k - 1, k); + } + + // link last and fist pixels + drawEdge(outBitmap, object, face, face.indices.size()-1, 0); + } + + // save output bitmap + NLMISC::COFile outFile; + + if (outFile.open(output)) + { + outBitmap.writePNG(outFile, 24); + } + } + + return 0; +} diff --git a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp index 5f0ee4181..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,6 +310,7 @@ 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")) @@ -314,6 +319,9 @@ int main(int argc, char **argv) if (args.haveArg("m")) OptMipMap = true; + if (args.haveArg("g")) + OptGrayscale = true; + if (args.haveArg("a")) { std::string strAlgo = args.getArg("a").front(); @@ -362,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/SelectionTerritoire.cpp b/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp index f82eef8c2..400b388d7 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,12 +448,11 @@ 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); + Save (tStrToUtf8(sFile.GetPathName()).c_str(), tileBank); MainFileOk = 1; CButton *button = (CButton*)GetDlgItem(IDC_ADD_TERRITOIRE); button->EnableWindow(true); @@ -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..5427f5c2f 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; } @@ -240,7 +240,7 @@ int TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitma uint Height; if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height)) { - return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), _T("Can't load bitmap."), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } else { @@ -259,7 +259,7 @@ int TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitma char sTmp[512]; static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; sprintf (sTmp, "%s\nPixel: %d (%s)", CTileSet::getErrorMessage (error), pixel, comp[composante]); - return (int)(MessageBox (NULL, (std::string(sTmp)+"\nContinue ?").c_str(), "Can't add tile", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + return (int)(MessageBox (NULL, (std::string(sTmp)+"\nContinue ?").c_str(), _T("Can't add tile"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } else { @@ -288,7 +288,7 @@ int TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitma // Error: bitmap not in the absolute path.. char msg[512]; sprintf (msg, "The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); - return (int)(MessageBox (NULL, (std::string (msg)+"\nContinue ?").c_str(), "Load error", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + return (int)(MessageBox (NULL, (std::string (msg)+"\nContinue ?").c_str(), _T("Load error"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } return 1; @@ -305,7 +305,7 @@ int TileList::setTile256 (int tile, const std::string& name, NL3D::CTile::TBitma uint Height; if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height)) { - return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), _T("Can't load bitmap."), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } else { @@ -325,7 +325,7 @@ int TileList::setTile256 (int tile, const std::string& name, NL3D::CTile::TBitma char sTmp[512]; static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; sprintf (sTmp, "%s\nPixel: %d (%s)", CTileSet::getErrorMessage (error), pixel, comp[composante]); - return (int)(MessageBox (NULL, (std::string(sTmp)+"\nContinue ?").c_str(), "Can't add tile", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + return (int)(MessageBox (NULL, (std::string(sTmp)+"\nContinue ?").c_str(), _T("Can't add tile"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } else { @@ -351,7 +351,7 @@ int TileList::setTile256 (int tile, const std::string& name, NL3D::CTile::TBitma // Error: bitmap not in the absolute path.. char msg[512]; sprintf (msg, "The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); - return (int)(MessageBox (NULL, (std::string (msg)+"\nContinue ?").c_str(), "Load error", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + return (int)(MessageBox (NULL, (std::string (msg)+"\nContinue ?").c_str(), _T("Load error"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } return 1; @@ -371,7 +371,7 @@ int TileList::setTileTransition (int tile, const std::string& name, NL3D::CTile: uint Height; if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height)) { - return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES); + return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), _T("Can't load bitmap."), MB_YESNO|MB_ICONEXCLAMATION)==IDYES); } else { @@ -390,7 +390,7 @@ int TileList::setTileTransition (int tile, const std::string& name, NL3D::CTile: char sTmp[512]; static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; sprintf (sTmp, "%s\nPixel: %d (%s)", CTileSet::getErrorMessage (error), pixel, comp[composante]); - return MessageBox (NULL, (std::string(sTmp)+"\nContinue ?").c_str(), "Can't add tile", MB_YESNO|MB_ICONEXCLAMATION)==IDYES; + return MessageBox (NULL, (std::string(sTmp)+"\nContinue ?").c_str(), _T("Can't add tile"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES; } else { @@ -417,9 +417,8 @@ int TileList::setTileTransition (int tile, const std::string& name, NL3D::CTile: else { // Error: bitmap not in the absolute path.. - char msg[512]; - sprintf (msg, "The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); - MessageBox (NULL, msg, "Load error", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); + MessageBox (NULL, utf8ToTStr(msg), _T("Load error"), MB_OK|MB_ICONEXCLAMATION); } return 1; @@ -432,20 +431,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; @@ -484,7 +483,7 @@ int TileList::setTileTransitionAlpha (int tile, const std::string& name, int rot uint Height; if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height)) { - return MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES; + return MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), _T("Can't load bitmap."), MB_YESNO|MB_ICONEXCLAMATION)==IDYES; } else { @@ -522,7 +521,7 @@ int TileList::setTileTransitionAlpha (int tile, const std::string& name, int rot else sprintf (sMsg, "%s\nIncompatible filled tile", CTileSet::getErrorMessage (error)); - return MessageBox (NULL, (std::string(sMsg)+"\nContinue ?").c_str(), "Can't add tile", MB_YESNO|MB_ICONEXCLAMATION)==IDYES; + return MessageBox (NULL, (std::string(sMsg)+"\nContinue ?").c_str(), _T("Can't add tile"), MB_YESNO|MB_ICONEXCLAMATION)==IDYES; } else { @@ -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,33 +669,33 @@ const std::string& TileInfo::getRelativeFileName (CTile::TBitmap type, int index bool TileInfo::Load (int index, std::vector* Alpha) { bool bRes=true; - if (!loaded && getRelativeFileName (CTile::diffuse, index)!="") + if (!loaded && !getRelativeFileName (CTile::diffuse, index).empty()) { if (!_LoadBitmap(tileBank2.getAbsPath() + getRelativeFileName (CTile::diffuse, index), &BmpInfo, Bits, Alpha, 0)) { bRes=false; - MessageBox (NULL, (tileBank2.getAbsPath() + getRelativeFileName (CTile::diffuse, index)).c_str(), "Can't load file", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(tileBank2.getAbsPath() + getRelativeFileName (CTile::diffuse, index)), _T("Can't load file"), MB_OK|MB_ICONEXCLAMATION); } else loaded=1; } - if (!nightLoaded && getRelativeFileName (CTile::additive, index)!="") + if (!nightLoaded && !getRelativeFileName (CTile::additive, index).empty()) { if (!_LoadBitmap(tileBank2.getAbsPath() + getRelativeFileName (CTile::additive, index), &nightBmpInfo, nightBits, Alpha, 0)) { bRes=false; - MessageBox (NULL, (tileBank2.getAbsPath() + getRelativeFileName (CTile::additive, index)).c_str(), "Can't load file", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(tileBank2.getAbsPath() + getRelativeFileName (CTile::additive, index)), _T("Can't load file"), MB_OK|MB_ICONEXCLAMATION); } else nightLoaded=1; } - if (!alphaLoaded && getRelativeFileName (CTile::alpha, index)!="") + if (!alphaLoaded && !getRelativeFileName (CTile::alpha, index).empty()) { if (!_LoadBitmap(tileBank2.getAbsPath() + getRelativeFileName (CTile::alpha, index), &alphaBmpInfo, alphaBits, NULL, tileBank2.getTile (index)->getRotAlpha ())) { bRes=false; - MessageBox (NULL, (tileBank2.getAbsPath() + getRelativeFileName (CTile::alpha, index)).c_str(), "Can't load file", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(tileBank2.getAbsPath() + getRelativeFileName (CTile::alpha, index)), _T("Can't load file"), MB_OK|MB_ICONEXCLAMATION); } else alphaLoaded=1; @@ -754,7 +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 f7fa710aa..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 @@ -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; @@ -174,7 +174,7 @@ 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]; uint16 xPos, yPos; 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/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..ea3c6f43a 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 @@ -1,392 +1,392 @@ - - --- Some globals - -NEL3D_APPDATA_ACCEL = 1423062561 -- type of accelerator : "32" = is not an accelerator and IS clusterized - -- "0" = is not an accelerator and IS NOT clusterized (always visible) - -- "1" = is an accelerator type PORTAL - -- "2" = is an accelerator type CLUSTER - -- "6" = is an accelerator type CLUSTER FATHER-VISIBLE - -- "10" = is an accelerator type CLUSTER VISIBLE-FROM-FATHER - -- "14" = is an accelerator type CLUSTER FATHER-VISIBLE and VISIBLE-FROM-FATHER - -- "17" = is an accelerator type PORTAL DYNAMIC - -NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me - -- "0" = export me - -- "1" = DONT export me - -NEL3D_APPDATA_LOD_NAME_COUNT_MAX = 10 -NEL3D_APPDATA_LOD = 1423062537 -NEL3D_APPDATA_LOD_NAME_COUNT = NEL3D_APPDATA_LOD -NEL3D_APPDATA_LOD_NAME = NEL3D_APPDATA_LOD_NAME_COUNT+1 -NEL3D_APPDATA_LOD_BLEND_IN = NEL3D_APPDATA_LOD_NAME+NEL3D_APPDATA_LOD_NAME_COUNT_MAX -NEL3D_APPDATA_LOD_BLEND_OUT = NEL3D_APPDATA_LOD_BLEND_IN+1 -NEL3D_APPDATA_LOD_COARSE_MESH = NEL3D_APPDATA_LOD_BLEND_OUT+1 -NEL3D_APPDATA_COLLISION = 1423062613 -NEL3D_APPDATA_COLLISION_EXTERIOR = 1423062614 -NEL3D_APPDATA_AUTOMATIC_ANIMATION = 1423062617 - --- This node is n accelerator ? -fn isAccelerator node = -( - accel = getappdata node NEL3D_APPDATA_ACCEL - if (accel != undefined) then - ( - if (accel == "0") or (accel == "32") then - return false - else - return true - ) - return false -) - --- Must export this node ? -fn isToBeExported node = -( - if (isAccelerator node) == true then - return false - - if ((classof node) == RklPatch) then - return false - - if ((classof node) == nel_ps) then - return false - - if ((classof node) == nel_pacs_cylinder) then - return false - - if ((classof node) == nel_pacs_box) then - return false - - doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - doNotExport = getappdata node NEL3D_APPDATA_COLLISION - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - return true -) - --- Must export this node ? -fn isAnimToBeExported node = -( - automaticAnimation = getappdata node NEL3D_APPDATA_AUTOMATIC_ANIMATION - if (automaticAnimation == undefined) then - return false - if (automaticAnimation == "0") then - return false - - if (isAccelerator node) == true then - return false - - if ((classof node) == nel_pacs_cylinder) then - return false - - if ((classof node) == nel_pacs_box) then - return false - - doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - doNotExport = getappdata node NEL3D_APPDATA_COLLISION - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - return true -) - --- Cast shadow ? -fn isCastShadow node = -( - if (classof node == nel_ps) then - return false - - if (isAccelerator node) == true then - ( - return false - ) - else - ( - return true - ) -) - --- List the lod -lod_array = #() - --- is a lod ? -fn isLod node = -( - for i = 1 to lod_array.count do - ( - if (lod_array[i] == node) then - return true - ) - return false -) - --- have a coarse mesh ? -fn haveCoarseMesh node = -( - -- Get lod count - nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT - if (nodeCount != undefined) then - ( - -- For each lod - nodeCountNum = nodeCount as Integer - for lod = 1 to nodeCountNum do - ( - -- Get the lod - lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1) - - -- Exist ? - if (lod != undefined) then - ( - -- Select a node - nd = execute ("$'"+lod+"'") - - -- Node exist ? - if (nd != undefined) then - ( - -- Is a coarse mesh ? - if (getappdata nd NEL3D_APPDATA_LOD_COARSE_MESH == "1") then - return true - ) - ) - ) - ) - return false -) - -fn getRoot node = if isvalidnode node.parent then getRoot node.parent else node - -fn runNelMaxExportSub inputMaxFile retryCount = -( - tagThisFile = false - - -- Unhide category - unhidelayers() - unhidecategory() - - -- Unhide - max unhide all - - -- unselect - max select none - clearSelection() - - -- Exported object count - exported = 0 - - -- Add the lod - for node in geometry do - ( - -- Get lod count - nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT - if (nodeCount != undefined) then - ( - -- For each lod - nodeCountNum = nodeCount as Integer - for lod = 1 to nodeCountNum do - ( - -- Get the lod - lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1) - - -- Exist ? - if (lod != undefined) then - ( - -- Select a node - try - ( - nd = execute("$'"+lod+"'") - ) - catch - ( - nlerror("Error in Execute $'"+lod+"' from node "+node.name) - nd = undefined - ) - - -- Node exist ? - if (nd != undefined) then - ( - append lod_array nd - ) - ) - ) - ) - ) - - -- Select objects for shadows - for node in geometry do - ( - if (node.parent == undefined) then - ( - -- Cast shadow ? - if (isCastShadow node == true) then - ( - -- Select this node - selectmore node - ) - ) - ) - - -- Tag this file ? - tagThisFile = true - - -- Array of node to export - array_node = #() - - -- Add geometry - for node in geometry do - append array_node node - - -- Add shapes - for node in shapes do - append array_node node - - -- For each node - for node in array_node do - ( - -- Is not a skeleton ? - if (((substring node.name 1 3) != "Bip") and ((substring (getRoot node).name 1 3) != "Bip")) then - ( - -- Can be exported ? - if (isToBeExported node == true) then - ( - -- Not a lod ? - if ((isLod node) == false) then - ( - -- Output directory - if (haveCoarseMesh node) == true then - output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape") - else - output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape") - - -- Compare file date - if (NeLTestFileDate output inputMaxFile) == true then - ( - try - ( - -- Export the shape - if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then - ( - nlerror("OK "+output) - exported = exported +1 - ) - else - ( - -- Error - nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile) - tagThisFile = false - ) - ) - catch - ( - -- Error - nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile) - tagThisFile = false - ) - ) - else - ( - nlerror("SKIPPED " + output) - exported = exported + 1 - ) - ) - ) - ) - ) - - -- Export default animations - - for node in objects do - ( - -- Can export it ? - if (isAnimToBeExported node) == true then - ( - -- Anim output directory - output = ("%OutputDirectoryAnim%/" + (node.name) + ".anim") - - -- Export the animation - if (NelExportAnimation #(node) output false) == false then - ( - nlerror ("ERROR exporting animation " + output) - tagThisFile = false - ) - else - ( - nlerror("OK " + output) - ) - ) - ) - - -- Something exported - if exported == 0 then - ( - -- Error - nlerror("WARNING no shape exported from the file " + inputMaxFile) - if tagThisFile then - ( - if retryCount < 2 then - ( - nlerror("INFO retry this file") - - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - if (loadMaxFile inputMaxFile quiet:true) == true then - ( - tagThisFile = runNelMaxExportSub inputMaxFile (retryCount + 1) - ) - else - ( - -- Error - nlerror("ERROR exporting '%PreGenFileExtension%': can't open the file " + inputMaxFile) - nlerror("FAIL Mysterious error occured") - NelForceQuitRightNow() - ) - ) - ) - ) - - return tagThisFile -) - -fn runNelMaxExport inputMaxFile = -( - return runNelMaxExportSub inputMaxFile 0 -) - + + +-- Some globals + +NEL3D_APPDATA_ACCEL = 1423062561 -- type of accelerator : "32" = is not an accelerator and IS clusterized + -- "0" = is not an accelerator and IS NOT clusterized (always visible) + -- "1" = is an accelerator type PORTAL + -- "2" = is an accelerator type CLUSTER + -- "6" = is an accelerator type CLUSTER FATHER-VISIBLE + -- "10" = is an accelerator type CLUSTER VISIBLE-FROM-FATHER + -- "14" = is an accelerator type CLUSTER FATHER-VISIBLE and VISIBLE-FROM-FATHER + -- "17" = is an accelerator type PORTAL DYNAMIC + +NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me + -- "0" = export me + -- "1" = DONT export me + +NEL3D_APPDATA_LOD_NAME_COUNT_MAX = 10 +NEL3D_APPDATA_LOD = 1423062537 +NEL3D_APPDATA_LOD_NAME_COUNT = NEL3D_APPDATA_LOD +NEL3D_APPDATA_LOD_NAME = NEL3D_APPDATA_LOD_NAME_COUNT+1 +NEL3D_APPDATA_LOD_BLEND_IN = NEL3D_APPDATA_LOD_NAME+NEL3D_APPDATA_LOD_NAME_COUNT_MAX +NEL3D_APPDATA_LOD_BLEND_OUT = NEL3D_APPDATA_LOD_BLEND_IN+1 +NEL3D_APPDATA_LOD_COARSE_MESH = NEL3D_APPDATA_LOD_BLEND_OUT+1 +NEL3D_APPDATA_COLLISION = 1423062613 +NEL3D_APPDATA_COLLISION_EXTERIOR = 1423062614 +NEL3D_APPDATA_AUTOMATIC_ANIMATION = 1423062617 + +-- This node is n accelerator ? +fn isAccelerator node = +( + accel = getappdata node NEL3D_APPDATA_ACCEL + if (accel != undefined) then + ( + if (accel == "0") or (accel == "32") then + return false + else + return true + ) + return false +) + +-- Must export this node ? +fn isToBeExported node = +( + if (isAccelerator node) == true then + return false + + if ((classof node) == RklPatch) then + return false + + if ((classof node) == nel_ps) then + return false + + if ((classof node) == nel_pacs_cylinder) then + return false + + if ((classof node) == nel_pacs_box) then + return false + + doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + doNotExport = getappdata node NEL3D_APPDATA_COLLISION + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + return true +) + +-- Must export this node ? +fn isAnimToBeExported node = +( + automaticAnimation = getappdata node NEL3D_APPDATA_AUTOMATIC_ANIMATION + if (automaticAnimation == undefined) then + return false + if (automaticAnimation == "0") then + return false + + if (isAccelerator node) == true then + return false + + if ((classof node) == nel_pacs_cylinder) then + return false + + if ((classof node) == nel_pacs_box) then + return false + + doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + doNotExport = getappdata node NEL3D_APPDATA_COLLISION + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + return true +) + +-- Cast shadow ? +fn isCastShadow node = +( + if (classof node == nel_ps) then + return false + + if (isAccelerator node) == true then + ( + return false + ) + else + ( + return true + ) +) + +-- List the lod +lod_array = #() + +-- is a lod ? +fn isLod node = +( + for i = 1 to lod_array.count do + ( + if (lod_array[i] == node) then + return true + ) + return false +) + +-- have a coarse mesh ? +fn haveCoarseMesh node = +( + -- Get lod count + nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT + if (nodeCount != undefined) then + ( + -- For each lod + nodeCountNum = nodeCount as Integer + for lod = 1 to nodeCountNum do + ( + -- Get the lod + lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1) + + -- Exist ? + if (lod != undefined) then + ( + -- Select a node + nd = execute ("$'"+lod+"'") + + -- Node exist ? + if (nd != undefined) then + ( + -- Is a coarse mesh ? + if (getappdata nd NEL3D_APPDATA_LOD_COARSE_MESH == "1") then + return true + ) + ) + ) + ) + return false +) + +fn getRoot node = if isvalidnode node.parent then getRoot node.parent else node + +fn runNelMaxExportSub inputMaxFile retryCount = +( + tagThisFile = false + + -- Unhide category + unhidelayers() + unhidecategory() + + -- Unhide + max unhide all + + -- unselect + max select none + clearSelection() + + -- Exported object count + exported = 0 + + -- Add the lod + for node in geometry do + ( + -- Get lod count + nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT + if (nodeCount != undefined) then + ( + -- For each lod + nodeCountNum = nodeCount as Integer + for lod = 1 to nodeCountNum do + ( + -- Get the lod + lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1) + + -- Exist ? + if (lod != undefined) then + ( + -- Select a node + try + ( + nd = execute("$'"+lod+"'") + ) + catch + ( + nlerror("Error in Execute $'"+lod+"' from node "+node.name) + nd = undefined + ) + + -- Node exist ? + if (nd != undefined) then + ( + append lod_array nd + ) + ) + ) + ) + ) + + -- Select objects for shadows + for node in geometry do + ( + if (node.parent == undefined) then + ( + -- Cast shadow ? + if (isCastShadow node == true) then + ( + -- Select this node + selectmore node + ) + ) + ) + + -- Tag this file ? + tagThisFile = true + + -- Array of node to export + array_node = #() + + -- Add geometry + for node in geometry do + append array_node node + + -- Add shapes + for node in shapes do + append array_node node + + -- For each node + for node in array_node do + ( + -- Is not a skeleton ? + if (((substring node.name 1 3) != "Bip") and ((substring (getRoot node).name 1 3) != "Bip")) then + ( + -- Can be exported ? + if (isToBeExported node == true) then + ( + -- Not a lod ? + if ((isLod node) == false) then + ( + -- Output directory + if (haveCoarseMesh node) == true then + output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape") + else + output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape") + + -- Compare file date + if (NeLTestFileDate output inputMaxFile) == true then + ( + try + ( + -- Export the shape + if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then + ( + nlerror("OK "+output) + exported = exported +1 + ) + else + ( + -- Error + nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile) + tagThisFile = false + ) + ) + catch + ( + -- Error + nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile) + tagThisFile = false + ) + ) + else + ( + nlerror("SKIPPED " + output) + exported = exported + 1 + ) + ) + ) + ) + ) + + -- Export default animations + + for node in objects do + ( + -- Can export it ? + if (isAnimToBeExported node) == true then + ( + -- Anim output directory + output = ("%OutputDirectoryAnim%/" + (node.name) + ".anim") + + -- Export the animation + if (NelExportAnimation #(node) output false) == false then + ( + nlerror ("ERROR exporting animation " + output) + tagThisFile = false + ) + else + ( + nlerror("OK " + output) + ) + ) + ) + + -- Something exported + if exported == 0 then + ( + -- Error + nlerror("WARNING no shape exported from the file " + inputMaxFile) + if tagThisFile then + ( + if retryCount < 2 then + ( + nlerror("INFO retry this file") + + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExportSub inputMaxFile (retryCount + 1) + ) + else + ( + -- Error + nlerror("ERROR exporting '%PreGenFileExtension%': can't open the file " + inputMaxFile) + nlerror("FAIL Mysterious error occurred") + NelForceQuitRightNow() + ) + ) + ) + ) + + return tagThisFile +) + +fn runNelMaxExport inputMaxFile = +( + return runNelMaxExportSub inputMaxFile 0 +) + 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..3dacb0acf 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 @@ -1,127 +1,127 @@ - - -removeRunningTag = true - -try -( - undo off - ( - -- Get files in the %MaxSourceDirectory% directory - files = getFiles "%MaxSourceDirectory%/*.max" - gc() - - -- Sort files - sort files - gc() - - -- No file ? - if files.count != 0 then - ( - -- For each files - for i = 1 to files.count do - ( - inputMaxFile = files[i] - outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") - - --try - --( - -- Compare file date - if (NeLTestFileDate outputTagFile inputMaxFile) == true then - ( - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - -- Open the max project - nlerror("Scanning file " + inputMaxFile + " ...") - if (loadMaxFile inputMaxFile quiet:true) == true then - ( - tagThisFile = runNelMaxExport(inputMaxFile) - - -- Write a tag file - if tagThisFile == true then - ( - tagFile = createFile outputTagFile - if tagFile == undefined then - ( - nlerror("WARNING can't create tag file " + outputTagFile) - removeRunningTag = false - ) - else - ( - print "mukyu" to: tagFile - close tagFile - ) - ) - else - ( - removeRunningTag = false - ) - ) - else - ( - -- Error - nlerror("ERROR exporting '%PreGenFileExtension%': can't open the file " + inputMaxFile) - removeRunningTag = false - ) - ) - else - ( - nlerror("SKIPPED BY TAG " + inputMaxFile) - ) - --) - --catch - --( - -- -- Error - -- nlerror("ERROR error exporting '%PreGenFileExtension%' in file " + inputMaxFile) - -- removeRunningTag = false - --) - ) - ) - else - ( - nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") - ) - ) -) -catch -( - -- Error - nlerror("ERROR Fatal error exporting '%PreGenFileExtension%' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") - NelForceQuitRightNow() - removeRunningTag = false -) - -try -( - if (removeRunningTag) then - ( - resetMAXFile #noPrompt - ) -) -catch -( - nlerror("FAIL Last reset fails") - removeRunningTag = false -) - -if (removeRunningTag) then -( - nlerror("SUCCESS All .max files have been successfully exported") - deleteFile("%TagDirectory%/max_running.tag") -) -else -( - nlerror("FAIL One or more issues occured") - NelForceQuitRightNow() -) - --- Bye -nlerror("BYE") -quitMAX #noPrompt -quitMAX() #noPrompt - + + +removeRunningTag = true + +try +( + undo off + ( + -- Get files in the %MaxSourceDirectory% directory + files = getFiles "%MaxSourceDirectory%/*.max" + gc() + + -- Sort files + sort files + gc() + + -- No file ? + if files.count != 0 then + ( + -- For each files + for i = 1 to files.count do + ( + inputMaxFile = files[i] + outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") + + --try + --( + -- Compare file date + if (NeLTestFileDate outputTagFile inputMaxFile) == true then + ( + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + -- Open the max project + nlerror("Scanning file " + inputMaxFile + " ...") + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExport(inputMaxFile) + + -- Write a tag file + if tagThisFile == true then + ( + tagFile = createFile outputTagFile + if tagFile == undefined then + ( + nlerror("WARNING can't create tag file " + outputTagFile) + removeRunningTag = false + ) + else + ( + print "mukyu" to: tagFile + close tagFile + ) + ) + else + ( + removeRunningTag = false + ) + ) + else + ( + -- Error + nlerror("ERROR exporting '%PreGenFileExtension%': can't open the file " + inputMaxFile) + removeRunningTag = false + ) + ) + else + ( + nlerror("SKIPPED BY TAG " + inputMaxFile) + ) + --) + --catch + --( + -- -- Error + -- nlerror("ERROR error exporting '%PreGenFileExtension%' in file " + inputMaxFile) + -- removeRunningTag = false + --) + ) + ) + else + ( + nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + ) + ) +) +catch +( + -- Error + nlerror("ERROR Fatal error exporting '%PreGenFileExtension%' in folder %MaxSourceDirectory%") + nlerror("FAIL Fatal error occurred") + NelForceQuitRightNow() + removeRunningTag = false +) + +try +( + if (removeRunningTag) then + ( + resetMAXFile #noPrompt + ) +) +catch +( + nlerror("FAIL Last reset fails") + removeRunningTag = false +) + +if (removeRunningTag) then +( + nlerror("SUCCESS All .max files have been successfully exported") + deleteFile("%TagDirectory%/max_running.tag") +) +else +( + nlerror("FAIL One or more issues occurred") + NelForceQuitRightNow() +) + +-- Bye +nlerror("BYE") +quitMAX #noPrompt +quitMAX() #noPrompt + 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..871f6b0f7 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 @@ -1,271 +1,271 @@ - - --- ################################################################# --- ## WARNING : this is a generated file, don't change it ! --- ################################################################# - - --- Allocate 20 Me for the script -heapSize += 15000000 - --- In case of error just abort the app and don't show nel report window -NelForceQuitOnMsgDisplayer() - -nlErrorFilename = "%OutputLogfile%" -nlErrorStream = openFile nlErrorFilename mode:"a" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Unhide layers -fn unhidelayers = -( - for i = 0 to (LayerManager.count - 1) do - ( - layer = (LayerManager.getLayer i) - layer.ishidden = false - ) -) - --- Unhide category -fn unhidecategory = -( - if (geometry.count > 0) then - ( - unhide geometry[1] - if (geometry[1].ishidden == true) then - max hide object toggle - ) - if (shapes.count > 0) then - ( - unhide shapes[1] - if (shapes[1].ishidden == true) then - max hide shape toggle - ) - if (lights.count > 0) then - ( - unhide lights[1] - if (lights[1].ishidden == true) then - max hide light toggle - ) - if (cameras.count > 0) then - ( - unhide cameras[1] - if (cameras[1].ishidden == true) then - max hide camera toggle - ) - if (helpers.count > 0) then - ( - unhide helpers[1] - if (helpers[1].ishidden == true) then - max hide helper toggle - ) -) - --- Log a message -fn nlerror message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - - - -NEL3D_APPDATA_EXPORT_NODE_ANIMATION = 1423062800 - -fn runNelMaxExport inputMaxFile = -( - outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".anim") - tagThisFile = true - - -- Unhide category - unhidecategory() - - -- Select Bip01, not very smart - if $Bip01 != undefined then - ( - select $Bip01 - - -- Always uncheck triangle pelvis - if (classof $Bip01) == Biped_Object then - ( - $Bip01.controller.figureMode = true - $Bip01.controller.trianglepelvis = false - $Bip01.controller.figureMode = false - ) - ) - - -- For each node - for node in objects do - ( - exportNodeAnmation = getappdata node NEL3D_APPDATA_EXPORT_NODE_ANIMATION - if (exportNodeAnmation != undefined) then - ( - if (exportNodeAnmation == "1") then - ( - selectmore node - - -- Is it a biped ? - if (classof node.controller) == Vertical_Horizontal_Turn then - ( - -- Always uncheck triangle pelvis - node.controller.trianglepelvis = false - ) - ) - ) - ) - - if ((selection as array).count != 0) then - ( - -- Export the animation - if (NelExportAnimation (selection as array) outputNelFile false) == false then - ( - nlerror("ERROR exporting animation " + inputMaxFile) - tagThisFile = false - ) - else - ( - nlerror("OK " + outputNelFile) - ) - ) - else - ( - -- Error - nlerror("WARNING exporting animation: no node animated to export in file " + inputMaxFile) - ) - - return tagThisFile -) - - - -removeRunningTag = true - -try -( - undo off - ( - -- Get files in the %MaxSourceDirectory% directory - files = getFiles "%MaxSourceDirectory%/*.max" - gc() - - -- Sort files - sort files - gc() - - -- No file ? - if files.count != 0 then - ( - -- For each files - for i = 1 to files.count do - ( - inputMaxFile = files[i] - outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") - - --try - --( - -- Compare file date - if (NeLTestFileDate outputTagFile inputMaxFile) == true then - ( - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - -- Open the max project - nlerror("Scanning file " + inputMaxFile + " ...") - if (loadMaxFile inputMaxFile quiet:true) == true then - ( - tagThisFile = runNelMaxExport(inputMaxFile) - - -- Write a tag file - if tagThisFile == true then - ( - tagFile = createFile outputTagFile - if tagFile == undefined then - ( - nlerror("WARNING can't create tag file " + outputTagFile) - removeRunningTag = false - ) - else - ( - print "mukyu" to: tagFile - close tagFile - ) - ) - else - ( - removeRunningTag = false - ) - ) - else - ( - -- Error - nlerror("ERROR exporting 'anim': can't open the file " + inputMaxFile) - removeRunningTag = false - ) - ) - else - ( - nlerror("SKIPPED BY TAG " + inputMaxFile) - ) - --) - --catch - --( - -- -- Error - -- nlerror("ERROR error exporting 'anim' in file " + inputMaxFile) - -- removeRunningTag = false - --) - ) - ) - else - ( - nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") - ) - ) -) -catch -( - -- Error - nlerror("ERROR Fatal error exporting 'anim' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") - NelForceQuitRightNow() - removeRunningTag = false -) - -try -( - if (removeRunningTag) then - ( - resetMAXFile #noPrompt - ) -) -catch -( - nlerror("FAIL Last reset fails") - removeRunningTag = false -) - -if (removeRunningTag) then -( - nlerror("SUCCESS All .max files have been successfully exported") - deleteFile("%TagDirectory%/max_running.tag") -) -else -( - nlerror("FAIL One or more issues occured") - NelForceQuitRightNow() -) - --- Bye -nlerror("BYE") -quitMAX #noPrompt -quitMAX() #noPrompt - + + +-- ################################################################# +-- ## WARNING : this is a generated file, don't change it ! +-- ################################################################# + + +-- Allocate 20 Me for the script +heapSize += 15000000 + +-- In case of error just abort the app and don't show nel report window +NelForceQuitOnMsgDisplayer() + +nlErrorFilename = "%OutputLogfile%" +nlErrorStream = openFile nlErrorFilename mode:"a" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Unhide layers +fn unhidelayers = +( + for i = 0 to (LayerManager.count - 1) do + ( + layer = (LayerManager.getLayer i) + layer.ishidden = false + ) +) + +-- Unhide category +fn unhidecategory = +( + if (geometry.count > 0) then + ( + unhide geometry[1] + if (geometry[1].ishidden == true) then + max hide object toggle + ) + if (shapes.count > 0) then + ( + unhide shapes[1] + if (shapes[1].ishidden == true) then + max hide shape toggle + ) + if (lights.count > 0) then + ( + unhide lights[1] + if (lights[1].ishidden == true) then + max hide light toggle + ) + if (cameras.count > 0) then + ( + unhide cameras[1] + if (cameras[1].ishidden == true) then + max hide camera toggle + ) + if (helpers.count > 0) then + ( + unhide helpers[1] + if (helpers[1].ishidden == true) then + max hide helper toggle + ) +) + +-- Log a message +fn nlerror message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + + + +NEL3D_APPDATA_EXPORT_NODE_ANIMATION = 1423062800 + +fn runNelMaxExport inputMaxFile = +( + outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".anim") + tagThisFile = true + + -- Unhide category + unhidecategory() + + -- Select Bip01, not very smart + if $Bip01 != undefined then + ( + select $Bip01 + + -- Always uncheck triangle pelvis + if (classof $Bip01) == Biped_Object then + ( + $Bip01.controller.figureMode = true + $Bip01.controller.trianglepelvis = false + $Bip01.controller.figureMode = false + ) + ) + + -- For each node + for node in objects do + ( + exportNodeAnmation = getappdata node NEL3D_APPDATA_EXPORT_NODE_ANIMATION + if (exportNodeAnmation != undefined) then + ( + if (exportNodeAnmation == "1") then + ( + selectmore node + + -- Is it a biped ? + if (classof node.controller) == Vertical_Horizontal_Turn then + ( + -- Always uncheck triangle pelvis + node.controller.trianglepelvis = false + ) + ) + ) + ) + + if ((selection as array).count != 0) then + ( + -- Export the animation + if (NelExportAnimation (selection as array) outputNelFile false) == false then + ( + nlerror("ERROR exporting animation " + inputMaxFile) + tagThisFile = false + ) + else + ( + nlerror("OK " + outputNelFile) + ) + ) + else + ( + -- Error + nlerror("WARNING exporting animation: no node animated to export in file " + inputMaxFile) + ) + + return tagThisFile +) + + + +removeRunningTag = true + +try +( + undo off + ( + -- Get files in the %MaxSourceDirectory% directory + files = getFiles "%MaxSourceDirectory%/*.max" + gc() + + -- Sort files + sort files + gc() + + -- No file ? + if files.count != 0 then + ( + -- For each files + for i = 1 to files.count do + ( + inputMaxFile = files[i] + outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") + + --try + --( + -- Compare file date + if (NeLTestFileDate outputTagFile inputMaxFile) == true then + ( + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + -- Open the max project + nlerror("Scanning file " + inputMaxFile + " ...") + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExport(inputMaxFile) + + -- Write a tag file + if tagThisFile == true then + ( + tagFile = createFile outputTagFile + if tagFile == undefined then + ( + nlerror("WARNING can't create tag file " + outputTagFile) + removeRunningTag = false + ) + else + ( + print "mukyu" to: tagFile + close tagFile + ) + ) + else + ( + removeRunningTag = false + ) + ) + else + ( + -- Error + nlerror("ERROR exporting 'anim': can't open the file " + inputMaxFile) + removeRunningTag = false + ) + ) + else + ( + nlerror("SKIPPED BY TAG " + inputMaxFile) + ) + --) + --catch + --( + -- -- Error + -- nlerror("ERROR error exporting 'anim' in file " + inputMaxFile) + -- removeRunningTag = false + --) + ) + ) + else + ( + nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + ) + ) +) +catch +( + -- Error + nlerror("ERROR Fatal error exporting 'anim' in folder %MaxSourceDirectory%") + nlerror("FAIL Fatal error occurred") + NelForceQuitRightNow() + removeRunningTag = false +) + +try +( + if (removeRunningTag) then + ( + resetMAXFile #noPrompt + ) +) +catch +( + nlerror("FAIL Last reset fails") + removeRunningTag = false +) + +if (removeRunningTag) then +( + nlerror("SUCCESS All .max files have been successfully exported") + deleteFile("%TagDirectory%/max_running.tag") +) +else +( + nlerror("FAIL One or more issues occurred") + NelForceQuitRightNow() +) + +-- Bye +nlerror("BYE") +quitMAX #noPrompt +quitMAX() #noPrompt + 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..4764b0c2a 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 @@ -1,328 +1,328 @@ - - --- ################################################################# --- ## WARNING : this is a generated file, don't change it ! --- ################################################################# - - --- Allocate 20 Me for the script -heapSize += 15000000 - --- In case of error just abort the app and don't show nel report window -NelForceQuitOnMsgDisplayer() - -nlErrorFilename = "%OutputLogfile%" -nlErrorStream = openFile nlErrorFilename mode:"a" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Unhide layers -fn unhidelayers = -( - for i = 0 to (LayerManager.count - 1) do - ( - layer = (LayerManager.getLayer i) - layer.ishidden = false - ) -) - --- Unhide category -fn unhidecategory = -( - if (geometry.count > 0) then - ( - unhide geometry[1] - if (geometry[1].ishidden == true) then - max hide object toggle - ) - if (shapes.count > 0) then - ( - unhide shapes[1] - if (shapes[1].ishidden == true) then - max hide shape toggle - ) - if (lights.count > 0) then - ( - unhide lights[1] - if (lights[1].ishidden == true) then - max hide light toggle - ) - if (cameras.count > 0) then - ( - unhide cameras[1] - if (cameras[1].ishidden == true) then - max hide camera toggle - ) - if (helpers.count > 0) then - ( - unhide helpers[1] - if (helpers[1].ishidden == true) then - max hide helper toggle - ) -) - --- Log a message -fn nlerror message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - - - --- Some globals - -NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me - -- "0" = export me - -- "1" = DONT export me -NEL3D_APPDATA_CHARACTER_LOD = 1423062618 -- "1": I am a character lod if "1". "0" or undefined: I am not. - - --- Must export this node ? -fn isToBeExported node = -( - if ((classof node) == RklPatch) then - return false - - if ((classof node) == nel_ps) then - return false - - if ((classof node) == nel_pacs_cylinder) then - return false - - if ((classof node) == nel_pacs_box) then - return false - - doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - return true -) - - --- is this node flagged as a LodCharacter ?? -fn isLodCharacter node = -( - isCLod = getappdata node NEL3D_APPDATA_CHARACTER_LOD - if (isCLod == undefined) then - return false - if (isCLod == "1") then - return true - return false -) - -fn runNelMaxExport inputMaxFile = -( - tagThisFile = true - - -- Unhide category - unhidelayers() - unhidecategory() - - -- Unhide - max unhide all - - -- unselect - max select none - clearSelection() - - -- Exported object count - exported = 0 - - -- For each node - for node in geometry do - ( - -- It is root ? - if (node.parent == undefined) then - ( - -- Can be exported ? - if (isToBeExported node == true) then - ( - -- Is a Lod character? - if ((isLodCharacter node) == true) then - ( - -- Output directory - outputNelFile = ("%OutputDirectory%/" + (node.name) + ".clod") - - -- Compare file date - if (NeLTestFileDate outputNelFile inputMaxFile) == true then - ( - try - ( - -- Export the shape - if (NelExportLodCharacter node outputNelFile false) == true then - ( - nlerror("OK " + outputNelFile) - exported = exported+1 - ) - else - ( - -- Error - nlerror("ERROR exporting .clod " + node.name + " in file " + inputMaxFile) - tagThisFile = false - ) - ) - catch - ( - -- Error - nlerror("ERROR fatal error exporting .clod " + node.name + " in file " + inputMaxFile) - tagThisFile = false - ) - ) - else - ( - -- Error - nlerror("SKIPPED " + outputNelFile) - exported = exported + 1 - ) - ) - ) - ) - ) - - -- Something exported - if (exported == 0) then - ( - -- Error - nlerror ("WARNING no .clod exported from the file " + inputMaxFile) - ) - - return tagThisFile -) - - - -removeRunningTag = true - -try -( - undo off - ( - -- Get files in the %MaxSourceDirectory% directory - files = getFiles "%MaxSourceDirectory%/*.max" - gc() - - -- Sort files - sort files - gc() - - -- No file ? - if files.count != 0 then - ( - -- For each files - for i = 1 to files.count do - ( - inputMaxFile = files[i] - outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") - - --try - --( - -- Compare file date - if (NeLTestFileDate outputTagFile inputMaxFile) == true then - ( - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - -- Open the max project - nlerror("Scanning file " + inputMaxFile + " ...") - if (loadMaxFile inputMaxFile quiet:true) == true then - ( - tagThisFile = runNelMaxExport(inputMaxFile) - - -- Write a tag file - if tagThisFile == true then - ( - tagFile = createFile outputTagFile - if tagFile == undefined then - ( - nlerror("WARNING can't create tag file " + outputTagFile) - removeRunningTag = false - ) - else - ( - print "mukyu" to: tagFile - close tagFile - ) - ) - else - ( - removeRunningTag = false - ) - ) - else - ( - -- Error - nlerror("ERROR exporting 'clod': can't open the file " + inputMaxFile) - removeRunningTag = false - ) - ) - else - ( - nlerror("SKIPPED BY TAG " + inputMaxFile) - ) - --) - --catch - --( - -- -- Error - -- nlerror("ERROR error exporting 'clod' in file " + inputMaxFile) - -- removeRunningTag = false - --) - ) - ) - else - ( - nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") - ) - ) -) -catch -( - -- Error - nlerror("ERROR Fatal error exporting 'clod' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") - NelForceQuitRightNow() - removeRunningTag = false -) - -try -( - if (removeRunningTag) then - ( - resetMAXFile #noPrompt - ) -) -catch -( - nlerror("FAIL Last reset fails") - removeRunningTag = false -) - -if (removeRunningTag) then -( - nlerror("SUCCESS All .max files have been successfully exported") - deleteFile("%TagDirectory%/max_running.tag") -) -else -( - nlerror("FAIL One or more issues occured") - NelForceQuitRightNow() -) - --- Bye -nlerror("BYE") -quitMAX #noPrompt -quitMAX() #noPrompt - + + +-- ################################################################# +-- ## WARNING : this is a generated file, don't change it ! +-- ################################################################# + + +-- Allocate 20 Me for the script +heapSize += 15000000 + +-- In case of error just abort the app and don't show nel report window +NelForceQuitOnMsgDisplayer() + +nlErrorFilename = "%OutputLogfile%" +nlErrorStream = openFile nlErrorFilename mode:"a" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Unhide layers +fn unhidelayers = +( + for i = 0 to (LayerManager.count - 1) do + ( + layer = (LayerManager.getLayer i) + layer.ishidden = false + ) +) + +-- Unhide category +fn unhidecategory = +( + if (geometry.count > 0) then + ( + unhide geometry[1] + if (geometry[1].ishidden == true) then + max hide object toggle + ) + if (shapes.count > 0) then + ( + unhide shapes[1] + if (shapes[1].ishidden == true) then + max hide shape toggle + ) + if (lights.count > 0) then + ( + unhide lights[1] + if (lights[1].ishidden == true) then + max hide light toggle + ) + if (cameras.count > 0) then + ( + unhide cameras[1] + if (cameras[1].ishidden == true) then + max hide camera toggle + ) + if (helpers.count > 0) then + ( + unhide helpers[1] + if (helpers[1].ishidden == true) then + max hide helper toggle + ) +) + +-- Log a message +fn nlerror message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + + + +-- Some globals + +NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me + -- "0" = export me + -- "1" = DONT export me +NEL3D_APPDATA_CHARACTER_LOD = 1423062618 -- "1": I am a character lod if "1". "0" or undefined: I am not. + + +-- Must export this node ? +fn isToBeExported node = +( + if ((classof node) == RklPatch) then + return false + + if ((classof node) == nel_ps) then + return false + + if ((classof node) == nel_pacs_cylinder) then + return false + + if ((classof node) == nel_pacs_box) then + return false + + doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + return true +) + + +-- is this node flagged as a LodCharacter ?? +fn isLodCharacter node = +( + isCLod = getappdata node NEL3D_APPDATA_CHARACTER_LOD + if (isCLod == undefined) then + return false + if (isCLod == "1") then + return true + return false +) + +fn runNelMaxExport inputMaxFile = +( + tagThisFile = true + + -- Unhide category + unhidelayers() + unhidecategory() + + -- Unhide + max unhide all + + -- unselect + max select none + clearSelection() + + -- Exported object count + exported = 0 + + -- For each node + for node in geometry do + ( + -- It is root ? + if (node.parent == undefined) then + ( + -- Can be exported ? + if (isToBeExported node == true) then + ( + -- Is a Lod character? + if ((isLodCharacter node) == true) then + ( + -- Output directory + outputNelFile = ("%OutputDirectory%/" + (node.name) + ".clod") + + -- Compare file date + if (NeLTestFileDate outputNelFile inputMaxFile) == true then + ( + try + ( + -- Export the shape + if (NelExportLodCharacter node outputNelFile false) == true then + ( + nlerror("OK " + outputNelFile) + exported = exported+1 + ) + else + ( + -- Error + nlerror("ERROR exporting .clod " + node.name + " in file " + inputMaxFile) + tagThisFile = false + ) + ) + catch + ( + -- Error + nlerror("ERROR fatal error exporting .clod " + node.name + " in file " + inputMaxFile) + tagThisFile = false + ) + ) + else + ( + -- Error + nlerror("SKIPPED " + outputNelFile) + exported = exported + 1 + ) + ) + ) + ) + ) + + -- Something exported + if (exported == 0) then + ( + -- Error + nlerror ("WARNING no .clod exported from the file " + inputMaxFile) + ) + + return tagThisFile +) + + + +removeRunningTag = true + +try +( + undo off + ( + -- Get files in the %MaxSourceDirectory% directory + files = getFiles "%MaxSourceDirectory%/*.max" + gc() + + -- Sort files + sort files + gc() + + -- No file ? + if files.count != 0 then + ( + -- For each files + for i = 1 to files.count do + ( + inputMaxFile = files[i] + outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") + + --try + --( + -- Compare file date + if (NeLTestFileDate outputTagFile inputMaxFile) == true then + ( + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + -- Open the max project + nlerror("Scanning file " + inputMaxFile + " ...") + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExport(inputMaxFile) + + -- Write a tag file + if tagThisFile == true then + ( + tagFile = createFile outputTagFile + if tagFile == undefined then + ( + nlerror("WARNING can't create tag file " + outputTagFile) + removeRunningTag = false + ) + else + ( + print "mukyu" to: tagFile + close tagFile + ) + ) + else + ( + removeRunningTag = false + ) + ) + else + ( + -- Error + nlerror("ERROR exporting 'clod': can't open the file " + inputMaxFile) + removeRunningTag = false + ) + ) + else + ( + nlerror("SKIPPED BY TAG " + inputMaxFile) + ) + --) + --catch + --( + -- -- Error + -- nlerror("ERROR error exporting 'clod' in file " + inputMaxFile) + -- removeRunningTag = false + --) + ) + ) + else + ( + nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + ) + ) +) +catch +( + -- Error + nlerror("ERROR Fatal error exporting 'clod' in folder %MaxSourceDirectory%") + nlerror("FAIL Fatal error occurred") + NelForceQuitRightNow() + removeRunningTag = false +) + +try +( + if (removeRunningTag) then + ( + resetMAXFile #noPrompt + ) +) +catch +( + nlerror("FAIL Last reset fails") + removeRunningTag = false +) + +if (removeRunningTag) then +( + nlerror("SUCCESS All .max files have been successfully exported") + deleteFile("%TagDirectory%/max_running.tag") +) +else +( + nlerror("FAIL One or more issues occurred") + NelForceQuitRightNow() +) + +-- Bye +nlerror("BYE") +quitMAX #noPrompt +quitMAX() #noPrompt + 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..18eb227e8 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 @@ -1,378 +1,378 @@ - - --- ################################################################# --- ## WARNING : this is a generated file, don't change it ! --- ################################################################# - - --- Allocate 20 Me for the script -heapSize += 15000000 - --- In case of error just abort the app and don't show nel report window -NelForceQuitOnMsgDisplayer() - -nlErrorFilename = "%OutputLogfile%" -nlErrorStream = openFile nlErrorFilename mode:"a" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Unhide layers -fn unhidelayers = -( - for i = 0 to (LayerManager.count - 1) do - ( - layer = (LayerManager.getLayer i) - layer.ishidden = false - ) -) - --- Unhide category -fn unhidecategory = -( - if (geometry.count > 0) then - ( - unhide geometry[1] - if (geometry[1].ishidden == true) then - max hide object toggle - ) - if (shapes.count > 0) then - ( - unhide shapes[1] - if (shapes[1].ishidden == true) then - max hide shape toggle - ) - if (lights.count > 0) then - ( - unhide lights[1] - if (lights[1].ishidden == true) then - max hide light toggle - ) - if (cameras.count > 0) then - ( - unhide cameras[1] - if (cameras[1].ishidden == true) then - max hide camera toggle - ) - if (helpers.count > 0) then - ( - unhide helpers[1] - if (helpers[1].ishidden == true) then - max hide helper toggle - ) -) - --- Log a message -fn nlerror message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - - - --- Some globals - -NEL3D_APPDATA_ACCEL = 1423062561 -- type of accelerator : "32" = is not an accelerator and IS clusterized - -- "0" = is not an accelerator and IS NOT clusterized (always visible) - -- "1" = is an accelerator type PORTAL - -- "2" = is an accelerator type CLUSTER - -- "6" = is an accelerator type CLUSTER FATHER-VISIBLE - -- "10" = is an accelerator type CLUSTER VISIBLE-FROM-FATHER - -- "14" = is an accelerator type CLUSTER FATHER-VISIBLE and VISIBLE-FROM-FATHER - -- "17" = is an accelerator type PORTAL DYNAMIC - -NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me - -- "0" = export me - -- "1" = DONT export me - -NEL3D_APPDATA_IGNAME = 1423062564 -- string : name of the Instance Group - -NEL3D_APPDATA_LOD_NAME_COUNT_MAX = 10 -NEL3D_APPDATA_LOD = 1423062537 -NEL3D_APPDATA_LOD_NAME_COUNT = NEL3D_APPDATA_LOD -NEL3D_APPDATA_LOD_NAME = NEL3D_APPDATA_LOD_NAME_COUNT+1 -NEL3D_APPDATA_LOD_BLEND_IN = NEL3D_APPDATA_LOD_NAME+NEL3D_APPDATA_LOD_NAME_COUNT_MAX -NEL3D_APPDATA_LOD_BLEND_OUT = NEL3D_APPDATA_LOD_BLEND_IN+1 -NEL3D_APPDATA_LOD_COARSE_MESH = NEL3D_APPDATA_LOD_BLEND_OUT+1 - -NEL_OBJECT_NAME_DATA = 1970 - - --- This node is n accelerator ? -fn isAccelerator node = -( - accel = getappdata node NEL3D_APPDATA_ACCEL - if (accel != undefined) then - ( - if (accel == "0") or (accel == "32") then - return false - else - return true - ) - return false -) - --- Get the ig name of this object -fn getIg node = -( - return (getappdata node NEL3D_APPDATA_IGNAME) -) - - -fn runNelMaxExport inputMaxFile = -( - tagThisFile = true - - -- Unhide category - unhidelayers() - unhidecategory() - - -- Unhide - max unhide all - - -- unselect - max select none - clearSelection() - - -- Exported object count - exported = 0 - - -- Ig array - ig_array = #() - - -- Scan all the ig in this project - for node in objects do - ( - ig = getIg node - if ( (ig != undefined) and (ig != "") ) then - ( - -- Found ? - found = false - - -- Already found ? - for j = 1 to ig_array.count do - ( - if (ig_array[j]==ig) then - ( - found = true - exit - ) - ) - - -- Found ? - if (found == false) then - ( - append ig_array ig - ) - ) - ) - - -- Have some ig ? - if (ig_array.count != 0) then - ( - -- For each ig - for ig = 1 to ig_array.count do - ( - -- Output filename - outputNelFile = ("%OutputDirectory%/" + ig_array[ig] + ".ig") - - -- Check date - if (NeLTestFileDate outputNelFile inputMaxFile) == true then - ( - -- Select none - max select none - clearSelection() - - -- Select all node in this ig - for node in geometry do - ( - -- Select it if in the ig - if ((getIg node) == ig_array[ig]) then - selectmore node - ) - -- Select all lights in this ig - for node in lights do - ( - -- Select it if in the ig - if ((getIg node) == ig_array[ig]) then - selectmore node - ) - -- Select all lights in this ig - for node in helpers do - ( - -- Select it if in the ig - if ((getIg node) == ig_array[ig]) then - selectmore node - ) - - -- Check export - try - ( - -- Export the ig - instancegroup2export = $selection as array - if (NelExportInstanceGroup instancegroup2export outputNelFile) == true then - ( - nlerror("OK " + outputNelFile) - ) - else - ( - -- Error - nlerror("ERROR exporting ig " + ig_array[ig] + " in file " + inputMaxFile) - tagThisFile = false - ) - ) - catch - ( - -- Error - nlerror("ERROR fatal error exporting ig " + ig_array[ig] + " in file " + inputMaxFile) - tagThisFile = false - ) - ) - else - ( - nlerror("SKIPPED " + outputNelFile) - ) - ) - ) - else - ( - -- Error - nlerror("WARNING nothing exported from ig max file " + inputMaxFile) - ) - - return tagThisFile -) - - - -removeRunningTag = true - -try -( - undo off - ( - -- Get files in the %MaxSourceDirectory% directory - files = getFiles "%MaxSourceDirectory%/*.max" - gc() - - -- Sort files - sort files - gc() - - -- No file ? - if files.count != 0 then - ( - -- For each files - for i = 1 to files.count do - ( - inputMaxFile = files[i] - outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") - - --try - --( - -- Compare file date - if (NeLTestFileDate outputTagFile inputMaxFile) == true then - ( - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - -- Open the max project - nlerror("Scanning file " + inputMaxFile + " ...") - if (loadMaxFile inputMaxFile quiet:true) == true then - ( - tagThisFile = runNelMaxExport(inputMaxFile) - - -- Write a tag file - if tagThisFile == true then - ( - tagFile = createFile outputTagFile - if tagFile == undefined then - ( - nlerror("WARNING can't create tag file " + outputTagFile) - removeRunningTag = false - ) - else - ( - print "mukyu" to: tagFile - close tagFile - ) - ) - else - ( - removeRunningTag = false - ) - ) - else - ( - -- Error - nlerror("ERROR exporting 'ig': can't open the file " + inputMaxFile) - removeRunningTag = false - ) - ) - else - ( - nlerror("SKIPPED BY TAG " + inputMaxFile) - ) - --) - --catch - --( - -- -- Error - -- nlerror("ERROR error exporting 'ig' in file " + inputMaxFile) - -- removeRunningTag = false - --) - ) - ) - else - ( - nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") - ) - ) -) -catch -( - -- Error - nlerror("ERROR Fatal error exporting 'ig' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") - NelForceQuitRightNow() - removeRunningTag = false -) - -try -( - if (removeRunningTag) then - ( - resetMAXFile #noPrompt - ) -) -catch -( - nlerror("FAIL Last reset fails") - removeRunningTag = false -) - -if (removeRunningTag) then -( - nlerror("SUCCESS All .max files have been successfully exported") - deleteFile("%TagDirectory%/max_running.tag") -) -else -( - nlerror("FAIL One or more issues occured") - NelForceQuitRightNow() -) - --- Bye -nlerror("BYE") -quitMAX #noPrompt -quitMAX() #noPrompt - + + +-- ################################################################# +-- ## WARNING : this is a generated file, don't change it ! +-- ################################################################# + + +-- Allocate 20 Me for the script +heapSize += 15000000 + +-- In case of error just abort the app and don't show nel report window +NelForceQuitOnMsgDisplayer() + +nlErrorFilename = "%OutputLogfile%" +nlErrorStream = openFile nlErrorFilename mode:"a" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Unhide layers +fn unhidelayers = +( + for i = 0 to (LayerManager.count - 1) do + ( + layer = (LayerManager.getLayer i) + layer.ishidden = false + ) +) + +-- Unhide category +fn unhidecategory = +( + if (geometry.count > 0) then + ( + unhide geometry[1] + if (geometry[1].ishidden == true) then + max hide object toggle + ) + if (shapes.count > 0) then + ( + unhide shapes[1] + if (shapes[1].ishidden == true) then + max hide shape toggle + ) + if (lights.count > 0) then + ( + unhide lights[1] + if (lights[1].ishidden == true) then + max hide light toggle + ) + if (cameras.count > 0) then + ( + unhide cameras[1] + if (cameras[1].ishidden == true) then + max hide camera toggle + ) + if (helpers.count > 0) then + ( + unhide helpers[1] + if (helpers[1].ishidden == true) then + max hide helper toggle + ) +) + +-- Log a message +fn nlerror message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + + + +-- Some globals + +NEL3D_APPDATA_ACCEL = 1423062561 -- type of accelerator : "32" = is not an accelerator and IS clusterized + -- "0" = is not an accelerator and IS NOT clusterized (always visible) + -- "1" = is an accelerator type PORTAL + -- "2" = is an accelerator type CLUSTER + -- "6" = is an accelerator type CLUSTER FATHER-VISIBLE + -- "10" = is an accelerator type CLUSTER VISIBLE-FROM-FATHER + -- "14" = is an accelerator type CLUSTER FATHER-VISIBLE and VISIBLE-FROM-FATHER + -- "17" = is an accelerator type PORTAL DYNAMIC + +NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me + -- "0" = export me + -- "1" = DONT export me + +NEL3D_APPDATA_IGNAME = 1423062564 -- string : name of the Instance Group + +NEL3D_APPDATA_LOD_NAME_COUNT_MAX = 10 +NEL3D_APPDATA_LOD = 1423062537 +NEL3D_APPDATA_LOD_NAME_COUNT = NEL3D_APPDATA_LOD +NEL3D_APPDATA_LOD_NAME = NEL3D_APPDATA_LOD_NAME_COUNT+1 +NEL3D_APPDATA_LOD_BLEND_IN = NEL3D_APPDATA_LOD_NAME+NEL3D_APPDATA_LOD_NAME_COUNT_MAX +NEL3D_APPDATA_LOD_BLEND_OUT = NEL3D_APPDATA_LOD_BLEND_IN+1 +NEL3D_APPDATA_LOD_COARSE_MESH = NEL3D_APPDATA_LOD_BLEND_OUT+1 + +NEL_OBJECT_NAME_DATA = 1970 + + +-- This node is n accelerator ? +fn isAccelerator node = +( + accel = getappdata node NEL3D_APPDATA_ACCEL + if (accel != undefined) then + ( + if (accel == "0") or (accel == "32") then + return false + else + return true + ) + return false +) + +-- Get the ig name of this object +fn getIg node = +( + return (getappdata node NEL3D_APPDATA_IGNAME) +) + + +fn runNelMaxExport inputMaxFile = +( + tagThisFile = true + + -- Unhide category + unhidelayers() + unhidecategory() + + -- Unhide + max unhide all + + -- unselect + max select none + clearSelection() + + -- Exported object count + exported = 0 + + -- Ig array + ig_array = #() + + -- Scan all the ig in this project + for node in objects do + ( + ig = getIg node + if ( (ig != undefined) and (ig != "") ) then + ( + -- Found ? + found = false + + -- Already found ? + for j = 1 to ig_array.count do + ( + if (ig_array[j]==ig) then + ( + found = true + exit + ) + ) + + -- Found ? + if (found == false) then + ( + append ig_array ig + ) + ) + ) + + -- Have some ig ? + if (ig_array.count != 0) then + ( + -- For each ig + for ig = 1 to ig_array.count do + ( + -- Output filename + outputNelFile = ("%OutputDirectory%/" + ig_array[ig] + ".ig") + + -- Check date + if (NeLTestFileDate outputNelFile inputMaxFile) == true then + ( + -- Select none + max select none + clearSelection() + + -- Select all node in this ig + for node in geometry do + ( + -- Select it if in the ig + if ((getIg node) == ig_array[ig]) then + selectmore node + ) + -- Select all lights in this ig + for node in lights do + ( + -- Select it if in the ig + if ((getIg node) == ig_array[ig]) then + selectmore node + ) + -- Select all lights in this ig + for node in helpers do + ( + -- Select it if in the ig + if ((getIg node) == ig_array[ig]) then + selectmore node + ) + + -- Check export + try + ( + -- Export the ig + instancegroup2export = $selection as array + if (NelExportInstanceGroup instancegroup2export outputNelFile) == true then + ( + nlerror("OK " + outputNelFile) + ) + else + ( + -- Error + nlerror("ERROR exporting ig " + ig_array[ig] + " in file " + inputMaxFile) + tagThisFile = false + ) + ) + catch + ( + -- Error + nlerror("ERROR fatal error exporting ig " + ig_array[ig] + " in file " + inputMaxFile) + tagThisFile = false + ) + ) + else + ( + nlerror("SKIPPED " + outputNelFile) + ) + ) + ) + else + ( + -- Error + nlerror("WARNING nothing exported from ig max file " + inputMaxFile) + ) + + return tagThisFile +) + + + +removeRunningTag = true + +try +( + undo off + ( + -- Get files in the %MaxSourceDirectory% directory + files = getFiles "%MaxSourceDirectory%/*.max" + gc() + + -- Sort files + sort files + gc() + + -- No file ? + if files.count != 0 then + ( + -- For each files + for i = 1 to files.count do + ( + inputMaxFile = files[i] + outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") + + --try + --( + -- Compare file date + if (NeLTestFileDate outputTagFile inputMaxFile) == true then + ( + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + -- Open the max project + nlerror("Scanning file " + inputMaxFile + " ...") + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExport(inputMaxFile) + + -- Write a tag file + if tagThisFile == true then + ( + tagFile = createFile outputTagFile + if tagFile == undefined then + ( + nlerror("WARNING can't create tag file " + outputTagFile) + removeRunningTag = false + ) + else + ( + print "mukyu" to: tagFile + close tagFile + ) + ) + else + ( + removeRunningTag = false + ) + ) + else + ( + -- Error + nlerror("ERROR exporting 'ig': can't open the file " + inputMaxFile) + removeRunningTag = false + ) + ) + else + ( + nlerror("SKIPPED BY TAG " + inputMaxFile) + ) + --) + --catch + --( + -- -- Error + -- nlerror("ERROR error exporting 'ig' in file " + inputMaxFile) + -- removeRunningTag = false + --) + ) + ) + else + ( + nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + ) + ) +) +catch +( + -- Error + nlerror("ERROR Fatal error exporting 'ig' in folder %MaxSourceDirectory%") + nlerror("FAIL Fatal error occurred") + NelForceQuitRightNow() + removeRunningTag = false +) + +try +( + if (removeRunningTag) then + ( + resetMAXFile #noPrompt + ) +) +catch +( + nlerror("FAIL Last reset fails") + removeRunningTag = false +) + +if (removeRunningTag) then +( + nlerror("SUCCESS All .max files have been successfully exported") + deleteFile("%TagDirectory%/max_running.tag") +) +else +( + nlerror("FAIL One or more issues occurred") + NelForceQuitRightNow() +) + +-- Bye +nlerror("BYE") +quitMAX #noPrompt +quitMAX() #noPrompt + 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..f586f0e03 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 @@ -1,251 +1,251 @@ - - --- ################################################################# --- ## WARNING : this is a generated file, don't change it ! --- ################################################################# - - --- Allocate 20 Me for the script -heapSize += 15000000 - --- In case of error just abort the app and don't show nel report window -NelForceQuitOnMsgDisplayer() - -nlErrorFilename = "%OutputLogfile%" -nlErrorStream = openFile nlErrorFilename mode:"a" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Unhide layers -fn unhidelayers = -( - for i = 0 to (LayerManager.count - 1) do - ( - layer = (LayerManager.getLayer i) - layer.ishidden = false - ) -) - --- Unhide category -fn unhidecategory = -( - if (geometry.count > 0) then - ( - unhide geometry[1] - if (geometry[1].ishidden == true) then - max hide object toggle - ) - if (shapes.count > 0) then - ( - unhide shapes[1] - if (shapes[1].ishidden == true) then - max hide shape toggle - ) - if (lights.count > 0) then - ( - unhide lights[1] - if (lights[1].ishidden == true) then - max hide light toggle - ) - if (cameras.count > 0) then - ( - unhide cameras[1] - if (cameras[1].ishidden == true) then - max hide camera toggle - ) - if (helpers.count > 0) then - ( - unhide helpers[1] - if (helpers[1].ishidden == true) then - max hide helper toggle - ) -) - --- Log a message -fn nlerror message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - - - -fn runNelMaxExport inputMaxFile = -( - outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".pacs_prim") - tagThisFile = false - - -- Unhide category - unhidecategory() - - -- Select none - max select none - clearSelection() - - -- Select all PACS primitives - for i in geometry do - ( - if ((classof i) == nel_pacs_cylinder) or ((classof i) == nel_pacs_box) then - selectmore i - ) - - -- Array of node - arrayNode = selection as array - - -- Something to export ? - if (arrayNode.count != 0) then - ( - -- Export the collision - if (NelExportPACSPrimitives arrayNode outputNelFile) == false then - ( - nlerror("ERROR exporting PACS primitives in file " + inputMaxFile) - tagThisFile = false - ) - else - ( - nlerror("OK PACS primitives in file " + inputMaxFile) - tagThisFile = true - ) - ) - else - ( - nlerror("WARNING no PACS primitives in file " + inputMaxFile) - tagThisFile = true - ) - - return tagThisFile -) - - - -removeRunningTag = true - -try -( - undo off - ( - -- Get files in the %MaxSourceDirectory% directory - files = getFiles "%MaxSourceDirectory%/*.max" - gc() - - -- Sort files - sort files - gc() - - -- No file ? - if files.count != 0 then - ( - -- For each files - for i = 1 to files.count do - ( - inputMaxFile = files[i] - outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") - - --try - --( - -- Compare file date - if (NeLTestFileDate outputTagFile inputMaxFile) == true then - ( - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - -- Open the max project - nlerror("Scanning file " + inputMaxFile + " ...") - if (loadMaxFile inputMaxFile quiet:true) == true then - ( - tagThisFile = runNelMaxExport(inputMaxFile) - - -- Write a tag file - if tagThisFile == true then - ( - tagFile = createFile outputTagFile - if tagFile == undefined then - ( - nlerror("WARNING can't create tag file " + outputTagFile) - removeRunningTag = false - ) - else - ( - print "mukyu" to: tagFile - close tagFile - ) - ) - else - ( - removeRunningTag = false - ) - ) - else - ( - -- Error - nlerror("ERROR exporting 'pacs_prim': can't open the file " + inputMaxFile) - removeRunningTag = false - ) - ) - else - ( - nlerror("SKIPPED BY TAG " + inputMaxFile) - ) - --) - --catch - --( - -- -- Error - -- nlerror("ERROR error exporting 'pacs_prim' in file " + inputMaxFile) - -- removeRunningTag = false - --) - ) - ) - else - ( - nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") - ) - ) -) -catch -( - -- Error - nlerror("ERROR Fatal error exporting 'pacs_prim' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") - NelForceQuitRightNow() - removeRunningTag = false -) - -try -( - if (removeRunningTag) then - ( - resetMAXFile #noPrompt - ) -) -catch -( - nlerror("FAIL Last reset fails") - removeRunningTag = false -) - -if (removeRunningTag) then -( - nlerror("SUCCESS All .max files have been successfully exported") - deleteFile("%TagDirectory%/max_running.tag") -) -else -( - nlerror("FAIL One or more issues occured") - NelForceQuitRightNow() -) - --- Bye -nlerror("BYE") -quitMAX #noPrompt -quitMAX() #noPrompt - + + +-- ################################################################# +-- ## WARNING : this is a generated file, don't change it ! +-- ################################################################# + + +-- Allocate 20 Me for the script +heapSize += 15000000 + +-- In case of error just abort the app and don't show nel report window +NelForceQuitOnMsgDisplayer() + +nlErrorFilename = "%OutputLogfile%" +nlErrorStream = openFile nlErrorFilename mode:"a" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Unhide layers +fn unhidelayers = +( + for i = 0 to (LayerManager.count - 1) do + ( + layer = (LayerManager.getLayer i) + layer.ishidden = false + ) +) + +-- Unhide category +fn unhidecategory = +( + if (geometry.count > 0) then + ( + unhide geometry[1] + if (geometry[1].ishidden == true) then + max hide object toggle + ) + if (shapes.count > 0) then + ( + unhide shapes[1] + if (shapes[1].ishidden == true) then + max hide shape toggle + ) + if (lights.count > 0) then + ( + unhide lights[1] + if (lights[1].ishidden == true) then + max hide light toggle + ) + if (cameras.count > 0) then + ( + unhide cameras[1] + if (cameras[1].ishidden == true) then + max hide camera toggle + ) + if (helpers.count > 0) then + ( + unhide helpers[1] + if (helpers[1].ishidden == true) then + max hide helper toggle + ) +) + +-- Log a message +fn nlerror message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + + + +fn runNelMaxExport inputMaxFile = +( + outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".pacs_prim") + tagThisFile = false + + -- Unhide category + unhidecategory() + + -- Select none + max select none + clearSelection() + + -- Select all PACS primitives + for i in geometry do + ( + if ((classof i) == nel_pacs_cylinder) or ((classof i) == nel_pacs_box) then + selectmore i + ) + + -- Array of node + arrayNode = selection as array + + -- Something to export ? + if (arrayNode.count != 0) then + ( + -- Export the collision + if (NelExportPACSPrimitives arrayNode outputNelFile) == false then + ( + nlerror("ERROR exporting PACS primitives in file " + inputMaxFile) + tagThisFile = false + ) + else + ( + nlerror("OK PACS primitives in file " + inputMaxFile) + tagThisFile = true + ) + ) + else + ( + nlerror("WARNING no PACS primitives in file " + inputMaxFile) + tagThisFile = true + ) + + return tagThisFile +) + + + +removeRunningTag = true + +try +( + undo off + ( + -- Get files in the %MaxSourceDirectory% directory + files = getFiles "%MaxSourceDirectory%/*.max" + gc() + + -- Sort files + sort files + gc() + + -- No file ? + if files.count != 0 then + ( + -- For each files + for i = 1 to files.count do + ( + inputMaxFile = files[i] + outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") + + --try + --( + -- Compare file date + if (NeLTestFileDate outputTagFile inputMaxFile) == true then + ( + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + -- Open the max project + nlerror("Scanning file " + inputMaxFile + " ...") + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExport(inputMaxFile) + + -- Write a tag file + if tagThisFile == true then + ( + tagFile = createFile outputTagFile + if tagFile == undefined then + ( + nlerror("WARNING can't create tag file " + outputTagFile) + removeRunningTag = false + ) + else + ( + print "mukyu" to: tagFile + close tagFile + ) + ) + else + ( + removeRunningTag = false + ) + ) + else + ( + -- Error + nlerror("ERROR exporting 'pacs_prim': can't open the file " + inputMaxFile) + removeRunningTag = false + ) + ) + else + ( + nlerror("SKIPPED BY TAG " + inputMaxFile) + ) + --) + --catch + --( + -- -- Error + -- nlerror("ERROR error exporting 'pacs_prim' in file " + inputMaxFile) + -- removeRunningTag = false + --) + ) + ) + else + ( + nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + ) + ) +) +catch +( + -- Error + nlerror("ERROR Fatal error exporting 'pacs_prim' in folder %MaxSourceDirectory%") + nlerror("FAIL Fatal error occurred") + NelForceQuitRightNow() + removeRunningTag = false +) + +try +( + if (removeRunningTag) then + ( + resetMAXFile #noPrompt + ) +) +catch +( + nlerror("FAIL Last reset fails") + removeRunningTag = false +) + +if (removeRunningTag) then +( + nlerror("SUCCESS All .max files have been successfully exported") + deleteFile("%TagDirectory%/max_running.tag") +) +else +( + nlerror("FAIL One or more issues occurred") + NelForceQuitRightNow() +) + +-- Bye +nlerror("BYE") +quitMAX #noPrompt +quitMAX() #noPrompt + 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..00bfa90c3 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 @@ -1,263 +1,263 @@ - - --- ################################################################# --- ## WARNING : this is a generated file, don't change it ! --- ################################################################# - - --- Allocate 20 Me for the script -heapSize += 15000000 - --- In case of error just abort the app and don't show nel report window -NelForceQuitOnMsgDisplayer() - -nlErrorFilename = "%OutputLogfile%" -nlErrorStream = openFile nlErrorFilename mode:"a" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Unhide layers -fn unhidelayers = -( - for i = 0 to (LayerManager.count - 1) do - ( - layer = (LayerManager.getLayer i) - layer.ishidden = false - ) -) - --- Unhide category -fn unhidecategory = -( - if (geometry.count > 0) then - ( - unhide geometry[1] - if (geometry[1].ishidden == true) then - max hide object toggle - ) - if (shapes.count > 0) then - ( - unhide shapes[1] - if (shapes[1].ishidden == true) then - max hide shape toggle - ) - if (lights.count > 0) then - ( - unhide lights[1] - if (lights[1].ishidden == true) then - max hide light toggle - ) - if (cameras.count > 0) then - ( - unhide cameras[1] - if (cameras[1].ishidden == true) then - max hide camera toggle - ) - if (helpers.count > 0) then - ( - unhide helpers[1] - if (helpers[1].ishidden == true) then - max hide helper toggle - ) -) - --- Log a message -fn nlerror message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - - - -NEL3D_APPDATA_COLLISION = 1423062613 -NEL3D_APPDATA_COLLISION_EXTERIOR = 1423062614 - - --- Must export this node ? -fn isToBeExported node = -( - doNotExport = getappdata node NEL3D_APPDATA_COLLISION - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return true - ) - - doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return true - ) - - return false -) - -fn runNelMaxExport inputMaxFile = -( - outputNelDir = "%OutputDirectory%" - - -- Tag this file ? - tagThisFile = true - - -- Unhide category - unhidecategory() - - -- Select all collision mesh - max select none - clearSelection() - for m in geometry do - ( - if (isToBeExported m) == true then - selectmore m - ) - - -- Export the collision - if (NelExportCollision ($selection as array) outputNelDir) == false then - ( - nlerror("ERROR exporting collision " + inputMaxFile) - tagThisFile = false - ) - else - ( - nlerror("OK collision in folder " + outputNelDir) - ) - - return tagThisFile -) - - - - -removeRunningTag = true - -try -( - undo off - ( - -- Get files in the %MaxSourceDirectory% directory - files = getFiles "%MaxSourceDirectory%/*.max" - gc() - - -- Sort files - sort files - gc() - - -- No file ? - if files.count != 0 then - ( - -- For each files - for i = 1 to files.count do - ( - inputMaxFile = files[i] - outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") - - --try - --( - -- Compare file date - if (NeLTestFileDate outputTagFile inputMaxFile) == true then - ( - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - -- Open the max project - nlerror("Scanning file " + inputMaxFile + " ...") - if (loadMaxFile inputMaxFile quiet:true) == true then - ( - tagThisFile = runNelMaxExport(inputMaxFile) - - -- Write a tag file - if tagThisFile == true then - ( - tagFile = createFile outputTagFile - if tagFile == undefined then - ( - nlerror("WARNING can't create tag file " + outputTagFile) - removeRunningTag = false - ) - else - ( - print "mukyu" to: tagFile - close tagFile - ) - ) - else - ( - removeRunningTag = false - ) - ) - else - ( - -- Error - nlerror("ERROR exporting 'cmb': can't open the file " + inputMaxFile) - removeRunningTag = false - ) - ) - else - ( - nlerror("SKIPPED BY TAG " + inputMaxFile) - ) - --) - --catch - --( - -- -- Error - -- nlerror("ERROR error exporting 'cmb' in file " + inputMaxFile) - -- removeRunningTag = false - --) - ) - ) - else - ( - nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") - ) - ) -) -catch -( - -- Error - nlerror("ERROR Fatal error exporting 'cmb' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") - NelForceQuitRightNow() - removeRunningTag = false -) - -try -( - if (removeRunningTag) then - ( - resetMAXFile #noPrompt - ) -) -catch -( - nlerror("FAIL Last reset fails") - removeRunningTag = false -) - -if (removeRunningTag) then -( - nlerror("SUCCESS All .max files have been successfully exported") - deleteFile("%TagDirectory%/max_running.tag") -) -else -( - nlerror("FAIL One or more issues occured") - NelForceQuitRightNow() -) - --- Bye -nlerror("BYE") -quitMAX #noPrompt -quitMAX() #noPrompt - + + +-- ################################################################# +-- ## WARNING : this is a generated file, don't change it ! +-- ################################################################# + + +-- Allocate 20 Me for the script +heapSize += 15000000 + +-- In case of error just abort the app and don't show nel report window +NelForceQuitOnMsgDisplayer() + +nlErrorFilename = "%OutputLogfile%" +nlErrorStream = openFile nlErrorFilename mode:"a" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Unhide layers +fn unhidelayers = +( + for i = 0 to (LayerManager.count - 1) do + ( + layer = (LayerManager.getLayer i) + layer.ishidden = false + ) +) + +-- Unhide category +fn unhidecategory = +( + if (geometry.count > 0) then + ( + unhide geometry[1] + if (geometry[1].ishidden == true) then + max hide object toggle + ) + if (shapes.count > 0) then + ( + unhide shapes[1] + if (shapes[1].ishidden == true) then + max hide shape toggle + ) + if (lights.count > 0) then + ( + unhide lights[1] + if (lights[1].ishidden == true) then + max hide light toggle + ) + if (cameras.count > 0) then + ( + unhide cameras[1] + if (cameras[1].ishidden == true) then + max hide camera toggle + ) + if (helpers.count > 0) then + ( + unhide helpers[1] + if (helpers[1].ishidden == true) then + max hide helper toggle + ) +) + +-- Log a message +fn nlerror message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + + + +NEL3D_APPDATA_COLLISION = 1423062613 +NEL3D_APPDATA_COLLISION_EXTERIOR = 1423062614 + + +-- Must export this node ? +fn isToBeExported node = +( + doNotExport = getappdata node NEL3D_APPDATA_COLLISION + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return true + ) + + doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return true + ) + + return false +) + +fn runNelMaxExport inputMaxFile = +( + outputNelDir = "%OutputDirectory%" + + -- Tag this file ? + tagThisFile = true + + -- Unhide category + unhidecategory() + + -- Select all collision mesh + max select none + clearSelection() + for m in geometry do + ( + if (isToBeExported m) == true then + selectmore m + ) + + -- Export the collision + if (NelExportCollision ($selection as array) outputNelDir) == false then + ( + nlerror("ERROR exporting collision " + inputMaxFile) + tagThisFile = false + ) + else + ( + nlerror("OK collision in folder " + outputNelDir) + ) + + return tagThisFile +) + + + + +removeRunningTag = true + +try +( + undo off + ( + -- Get files in the %MaxSourceDirectory% directory + files = getFiles "%MaxSourceDirectory%/*.max" + gc() + + -- Sort files + sort files + gc() + + -- No file ? + if files.count != 0 then + ( + -- For each files + for i = 1 to files.count do + ( + inputMaxFile = files[i] + outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") + + --try + --( + -- Compare file date + if (NeLTestFileDate outputTagFile inputMaxFile) == true then + ( + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + -- Open the max project + nlerror("Scanning file " + inputMaxFile + " ...") + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExport(inputMaxFile) + + -- Write a tag file + if tagThisFile == true then + ( + tagFile = createFile outputTagFile + if tagFile == undefined then + ( + nlerror("WARNING can't create tag file " + outputTagFile) + removeRunningTag = false + ) + else + ( + print "mukyu" to: tagFile + close tagFile + ) + ) + else + ( + removeRunningTag = false + ) + ) + else + ( + -- Error + nlerror("ERROR exporting 'cmb': can't open the file " + inputMaxFile) + removeRunningTag = false + ) + ) + else + ( + nlerror("SKIPPED BY TAG " + inputMaxFile) + ) + --) + --catch + --( + -- -- Error + -- nlerror("ERROR error exporting 'cmb' in file " + inputMaxFile) + -- removeRunningTag = false + --) + ) + ) + else + ( + nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + ) + ) +) +catch +( + -- Error + nlerror("ERROR Fatal error exporting 'cmb' in folder %MaxSourceDirectory%") + nlerror("FAIL Fatal error occurred") + NelForceQuitRightNow() + removeRunningTag = false +) + +try +( + if (removeRunningTag) then + ( + resetMAXFile #noPrompt + ) +) +catch +( + nlerror("FAIL Last reset fails") + removeRunningTag = false +) + +if (removeRunningTag) then +( + nlerror("SUCCESS All .max files have been successfully exported") + deleteFile("%TagDirectory%/max_running.tag") +) +else +( + nlerror("FAIL One or more issues occurred") + NelForceQuitRightNow() +) + +-- Bye +nlerror("BYE") +quitMAX #noPrompt +quitMAX() #noPrompt + 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..bb205d9fb 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 @@ -1,595 +1,595 @@ - - --- ################################################################# --- ## WARNING : this is a generated file, don't change it ! --- ################################################################# - - --- Allocate 20 Me for the script -heapSize += 15000000 - --- In case of error just abort the app and don't show nel report window -NelForceQuitOnMsgDisplayer() - -nlErrorFilename = "%OutputLogfile%" -nlErrorStream = openFile nlErrorFilename mode:"a" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Unhide layers -fn unhidelayers = -( - for i = 0 to (LayerManager.count - 1) do - ( - layer = (LayerManager.getLayer i) - layer.ishidden = false - ) -) - --- Unhide category -fn unhidecategory = -( - if (geometry.count > 0) then - ( - unhide geometry[1] - if (geometry[1].ishidden == true) then - max hide object toggle - ) - if (shapes.count > 0) then - ( - unhide shapes[1] - if (shapes[1].ishidden == true) then - max hide shape toggle - ) - if (lights.count > 0) then - ( - unhide lights[1] - if (lights[1].ishidden == true) then - max hide light toggle - ) - if (cameras.count > 0) then - ( - unhide cameras[1] - if (cameras[1].ishidden == true) then - max hide camera toggle - ) - if (helpers.count > 0) then - ( - unhide helpers[1] - if (helpers[1].ishidden == true) then - max hide helper toggle - ) -) - --- Log a message -fn nlerror message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - - - --- Some globals - -NEL3D_APPDATA_ACCEL = 1423062561 -- type of accelerator : "32" = is not an accelerator and IS clusterized - -- "0" = is not an accelerator and IS NOT clusterized (always visible) - -- "1" = is an accelerator type PORTAL - -- "2" = is an accelerator type CLUSTER - -- "6" = is an accelerator type CLUSTER FATHER-VISIBLE - -- "10" = is an accelerator type CLUSTER VISIBLE-FROM-FATHER - -- "14" = is an accelerator type CLUSTER FATHER-VISIBLE and VISIBLE-FROM-FATHER - -- "17" = is an accelerator type PORTAL DYNAMIC - -NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me - -- "0" = export me - -- "1" = DONT export me - -NEL3D_APPDATA_LOD_NAME_COUNT_MAX = 10 -NEL3D_APPDATA_LOD = 1423062537 -NEL3D_APPDATA_LOD_NAME_COUNT = NEL3D_APPDATA_LOD -NEL3D_APPDATA_LOD_NAME = NEL3D_APPDATA_LOD_NAME_COUNT+1 -NEL3D_APPDATA_LOD_BLEND_IN = NEL3D_APPDATA_LOD_NAME+NEL3D_APPDATA_LOD_NAME_COUNT_MAX -NEL3D_APPDATA_LOD_BLEND_OUT = NEL3D_APPDATA_LOD_BLEND_IN+1 -NEL3D_APPDATA_LOD_COARSE_MESH = NEL3D_APPDATA_LOD_BLEND_OUT+1 -NEL3D_APPDATA_COLLISION = 1423062613 -NEL3D_APPDATA_COLLISION_EXTERIOR = 1423062614 -NEL3D_APPDATA_AUTOMATIC_ANIMATION = 1423062617 - --- This node is n accelerator ? -fn isAccelerator node = -( - accel = getappdata node NEL3D_APPDATA_ACCEL - if (accel != undefined) then - ( - if (accel == "0") or (accel == "32") then - return false - else - return true - ) - return false -) - --- Must export this node ? -fn isToBeExported node = -( - if (isAccelerator node) == true then - return false - - if ((classof node) == RklPatch) then - return false - - if ((classof node) == nel_ps) then - return false - - if ((classof node) == nel_pacs_cylinder) then - return false - - if ((classof node) == nel_pacs_box) then - return false - - doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - doNotExport = getappdata node NEL3D_APPDATA_COLLISION - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - return true -) - --- Must export this node ? -fn isAnimToBeExported node = -( - automaticAnimation = getappdata node NEL3D_APPDATA_AUTOMATIC_ANIMATION - if (automaticAnimation == undefined) then - return false - if (automaticAnimation == "0") then - return false - - if (isAccelerator node) == true then - return false - - if ((classof node) == nel_pacs_cylinder) then - return false - - if ((classof node) == nel_pacs_box) then - return false - - doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - doNotExport = getappdata node NEL3D_APPDATA_COLLISION - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - return true -) - --- Cast shadow ? -fn isCastShadow node = -( - if (classof node == nel_ps) then - return false - - if (isAccelerator node) == true then - ( - return false - ) - else - ( - return true - ) -) - --- List the lod -lod_array = #() - --- is a lod ? -fn isLod node = -( - for i = 1 to lod_array.count do - ( - if (lod_array[i] == node) then - return true - ) - return false -) - --- have a coarse mesh ? -fn haveCoarseMesh node = -( - -- Get lod count - nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT - if (nodeCount != undefined) then - ( - -- For each lod - nodeCountNum = nodeCount as Integer - for lod = 1 to nodeCountNum do - ( - -- Get the lod - lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1) - - -- Exist ? - if (lod != undefined) then - ( - -- Select a node - nd = execute ("$'"+lod+"'") - - -- Node exist ? - if (nd != undefined) then - ( - -- Is a coarse mesh ? - if (getappdata nd NEL3D_APPDATA_LOD_COARSE_MESH == "1") then - return true - ) - ) - ) - ) - return false -) - -fn getRoot node = if isvalidnode node.parent then getRoot node.parent else node - -fn runNelMaxExportSub inputMaxFile retryCount = -( - tagThisFile = false - - -- Unhide category - unhidelayers() - unhidecategory() - - -- Unhide - max unhide all - - -- unselect - max select none - clearSelection() - - -- Exported object count - exported = 0 - - -- Add the lod - for node in geometry do - ( - -- Get lod count - nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT - if (nodeCount != undefined) then - ( - -- For each lod - nodeCountNum = nodeCount as Integer - for lod = 1 to nodeCountNum do - ( - -- Get the lod - lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1) - - -- Exist ? - if (lod != undefined) then - ( - -- Select a node - try - ( - nd = execute("$'"+lod+"'") - ) - catch - ( - nlerror("Error in Execute $'"+lod+"' from node "+node.name) - nd = undefined - ) - - -- Node exist ? - if (nd != undefined) then - ( - append lod_array nd - ) - ) - ) - ) - ) - - -- Select objects for shadows - for node in geometry do - ( - if (node.parent == undefined) then - ( - -- Cast shadow ? - if (isCastShadow node == true) then - ( - -- Select this node - selectmore node - ) - ) - ) - - -- Tag this file ? - tagThisFile = true - - -- Array of node to export - array_node = #() - - -- Add geometry - for node in geometry do - append array_node node - - -- Add shapes - for node in shapes do - append array_node node - - -- For each node - for node in array_node do - ( - -- Is not a skeleton ? - if (((substring node.name 1 3) != "Bip") and ((substring (getRoot node).name 1 3) != "Bip")) then - ( - -- Can be exported ? - if (isToBeExported node == true) then - ( - -- Not a lod ? - if ((isLod node) == false) then - ( - -- Output directory - if (haveCoarseMesh node) == true then - output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape") - else - output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape") - - -- Compare file date - if (NeLTestFileDate output inputMaxFile) == true then - ( - try - ( - -- Export the shape - if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then - ( - nlerror("OK "+output) - exported = exported +1 - ) - else - ( - -- Error - nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile) - tagThisFile = false - ) - ) - catch - ( - -- Error - nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile) - tagThisFile = false - ) - ) - else - ( - nlerror("SKIPPED " + output) - exported = exported + 1 - ) - ) - ) - ) - ) - - -- Export default animations - - for node in objects do - ( - -- Can export it ? - if (isAnimToBeExported node) == true then - ( - -- Anim output directory - output = ("%OutputDirectoryAnim%/" + (node.name) + ".anim") - - -- Export the animation - if (NelExportAnimation #(node) output false) == false then - ( - nlerror ("ERROR exporting animation " + output) - tagThisFile = false - ) - else - ( - nlerror("OK " + output) - ) - ) - ) - - -- Something exported - if exported == 0 then - ( - -- Error - nlerror("WARNING no shape exported from the file " + inputMaxFile) - if tagThisFile then - ( - if retryCount < 2 then - ( - nlerror("INFO retry this file") - - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - if (loadMaxFile inputMaxFile quiet:true) == true then - ( - tagThisFile = runNelMaxExportSub inputMaxFile (retryCount + 1) - ) - else - ( - -- Error - nlerror("ERROR exporting 'shape': can't open the file " + inputMaxFile) - nlerror("FAIL Mysterious error occured") - NelForceQuitRightNow() - ) - ) - ) - ) - - return tagThisFile -) - -fn runNelMaxExport inputMaxFile = -( - return runNelMaxExportSub inputMaxFile 0 -) - - - -removeRunningTag = true - -try -( - undo off - ( - -- Get files in the %MaxSourceDirectory% directory - files = getFiles "%MaxSourceDirectory%/*.max" - gc() - - -- Sort files - sort files - gc() - - -- No file ? - if files.count != 0 then - ( - -- For each files - for i = 1 to files.count do - ( - inputMaxFile = files[i] - outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") - - --try - --( - -- Compare file date - if (NeLTestFileDate outputTagFile inputMaxFile) == true then - ( - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - -- Open the max project - nlerror("Scanning file " + inputMaxFile + " ...") - if (loadMaxFile inputMaxFile quiet:true) == true then - ( - tagThisFile = runNelMaxExport(inputMaxFile) - - -- Write a tag file - if tagThisFile == true then - ( - tagFile = createFile outputTagFile - if tagFile == undefined then - ( - nlerror("WARNING can't create tag file " + outputTagFile) - removeRunningTag = false - ) - else - ( - print "mukyu" to: tagFile - close tagFile - ) - ) - else - ( - removeRunningTag = false - ) - ) - else - ( - -- Error - nlerror("ERROR exporting 'shape': can't open the file " + inputMaxFile) - removeRunningTag = false - ) - ) - else - ( - nlerror("SKIPPED BY TAG " + inputMaxFile) - ) - --) - --catch - --( - -- -- Error - -- nlerror("ERROR error exporting 'shape' in file " + inputMaxFile) - -- removeRunningTag = false - --) - ) - ) - else - ( - nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") - ) - ) -) -catch -( - -- Error - nlerror("ERROR Fatal error exporting 'shape' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") - NelForceQuitRightNow() - removeRunningTag = false -) - -try -( - if (removeRunningTag) then - ( - resetMAXFile #noPrompt - ) -) -catch -( - nlerror("FAIL Last reset fails") - removeRunningTag = false -) - -if (removeRunningTag) then -( - nlerror("SUCCESS All .max files have been successfully exported") - deleteFile("%TagDirectory%/max_running.tag") -) -else -( - nlerror("FAIL One or more issues occured") - NelForceQuitRightNow() -) - --- Bye -nlerror("BYE") -quitMAX #noPrompt -quitMAX() #noPrompt - + + +-- ################################################################# +-- ## WARNING : this is a generated file, don't change it ! +-- ################################################################# + + +-- Allocate 20 Me for the script +heapSize += 15000000 + +-- In case of error just abort the app and don't show nel report window +NelForceQuitOnMsgDisplayer() + +nlErrorFilename = "%OutputLogfile%" +nlErrorStream = openFile nlErrorFilename mode:"a" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Unhide layers +fn unhidelayers = +( + for i = 0 to (LayerManager.count - 1) do + ( + layer = (LayerManager.getLayer i) + layer.ishidden = false + ) +) + +-- Unhide category +fn unhidecategory = +( + if (geometry.count > 0) then + ( + unhide geometry[1] + if (geometry[1].ishidden == true) then + max hide object toggle + ) + if (shapes.count > 0) then + ( + unhide shapes[1] + if (shapes[1].ishidden == true) then + max hide shape toggle + ) + if (lights.count > 0) then + ( + unhide lights[1] + if (lights[1].ishidden == true) then + max hide light toggle + ) + if (cameras.count > 0) then + ( + unhide cameras[1] + if (cameras[1].ishidden == true) then + max hide camera toggle + ) + if (helpers.count > 0) then + ( + unhide helpers[1] + if (helpers[1].ishidden == true) then + max hide helper toggle + ) +) + +-- Log a message +fn nlerror message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + + + +-- Some globals + +NEL3D_APPDATA_ACCEL = 1423062561 -- type of accelerator : "32" = is not an accelerator and IS clusterized + -- "0" = is not an accelerator and IS NOT clusterized (always visible) + -- "1" = is an accelerator type PORTAL + -- "2" = is an accelerator type CLUSTER + -- "6" = is an accelerator type CLUSTER FATHER-VISIBLE + -- "10" = is an accelerator type CLUSTER VISIBLE-FROM-FATHER + -- "14" = is an accelerator type CLUSTER FATHER-VISIBLE and VISIBLE-FROM-FATHER + -- "17" = is an accelerator type PORTAL DYNAMIC + +NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me + -- "0" = export me + -- "1" = DONT export me + +NEL3D_APPDATA_LOD_NAME_COUNT_MAX = 10 +NEL3D_APPDATA_LOD = 1423062537 +NEL3D_APPDATA_LOD_NAME_COUNT = NEL3D_APPDATA_LOD +NEL3D_APPDATA_LOD_NAME = NEL3D_APPDATA_LOD_NAME_COUNT+1 +NEL3D_APPDATA_LOD_BLEND_IN = NEL3D_APPDATA_LOD_NAME+NEL3D_APPDATA_LOD_NAME_COUNT_MAX +NEL3D_APPDATA_LOD_BLEND_OUT = NEL3D_APPDATA_LOD_BLEND_IN+1 +NEL3D_APPDATA_LOD_COARSE_MESH = NEL3D_APPDATA_LOD_BLEND_OUT+1 +NEL3D_APPDATA_COLLISION = 1423062613 +NEL3D_APPDATA_COLLISION_EXTERIOR = 1423062614 +NEL3D_APPDATA_AUTOMATIC_ANIMATION = 1423062617 + +-- This node is n accelerator ? +fn isAccelerator node = +( + accel = getappdata node NEL3D_APPDATA_ACCEL + if (accel != undefined) then + ( + if (accel == "0") or (accel == "32") then + return false + else + return true + ) + return false +) + +-- Must export this node ? +fn isToBeExported node = +( + if (isAccelerator node) == true then + return false + + if ((classof node) == RklPatch) then + return false + + if ((classof node) == nel_ps) then + return false + + if ((classof node) == nel_pacs_cylinder) then + return false + + if ((classof node) == nel_pacs_box) then + return false + + doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + doNotExport = getappdata node NEL3D_APPDATA_COLLISION + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + return true +) + +-- Must export this node ? +fn isAnimToBeExported node = +( + automaticAnimation = getappdata node NEL3D_APPDATA_AUTOMATIC_ANIMATION + if (automaticAnimation == undefined) then + return false + if (automaticAnimation == "0") then + return false + + if (isAccelerator node) == true then + return false + + if ((classof node) == nel_pacs_cylinder) then + return false + + if ((classof node) == nel_pacs_box) then + return false + + doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + doNotExport = getappdata node NEL3D_APPDATA_COLLISION + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + return true +) + +-- Cast shadow ? +fn isCastShadow node = +( + if (classof node == nel_ps) then + return false + + if (isAccelerator node) == true then + ( + return false + ) + else + ( + return true + ) +) + +-- List the lod +lod_array = #() + +-- is a lod ? +fn isLod node = +( + for i = 1 to lod_array.count do + ( + if (lod_array[i] == node) then + return true + ) + return false +) + +-- have a coarse mesh ? +fn haveCoarseMesh node = +( + -- Get lod count + nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT + if (nodeCount != undefined) then + ( + -- For each lod + nodeCountNum = nodeCount as Integer + for lod = 1 to nodeCountNum do + ( + -- Get the lod + lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1) + + -- Exist ? + if (lod != undefined) then + ( + -- Select a node + nd = execute ("$'"+lod+"'") + + -- Node exist ? + if (nd != undefined) then + ( + -- Is a coarse mesh ? + if (getappdata nd NEL3D_APPDATA_LOD_COARSE_MESH == "1") then + return true + ) + ) + ) + ) + return false +) + +fn getRoot node = if isvalidnode node.parent then getRoot node.parent else node + +fn runNelMaxExportSub inputMaxFile retryCount = +( + tagThisFile = false + + -- Unhide category + unhidelayers() + unhidecategory() + + -- Unhide + max unhide all + + -- unselect + max select none + clearSelection() + + -- Exported object count + exported = 0 + + -- Add the lod + for node in geometry do + ( + -- Get lod count + nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT + if (nodeCount != undefined) then + ( + -- For each lod + nodeCountNum = nodeCount as Integer + for lod = 1 to nodeCountNum do + ( + -- Get the lod + lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1) + + -- Exist ? + if (lod != undefined) then + ( + -- Select a node + try + ( + nd = execute("$'"+lod+"'") + ) + catch + ( + nlerror("Error in Execute $'"+lod+"' from node "+node.name) + nd = undefined + ) + + -- Node exist ? + if (nd != undefined) then + ( + append lod_array nd + ) + ) + ) + ) + ) + + -- Select objects for shadows + for node in geometry do + ( + if (node.parent == undefined) then + ( + -- Cast shadow ? + if (isCastShadow node == true) then + ( + -- Select this node + selectmore node + ) + ) + ) + + -- Tag this file ? + tagThisFile = true + + -- Array of node to export + array_node = #() + + -- Add geometry + for node in geometry do + append array_node node + + -- Add shapes + for node in shapes do + append array_node node + + -- For each node + for node in array_node do + ( + -- Is not a skeleton ? + if (((substring node.name 1 3) != "Bip") and ((substring (getRoot node).name 1 3) != "Bip")) then + ( + -- Can be exported ? + if (isToBeExported node == true) then + ( + -- Not a lod ? + if ((isLod node) == false) then + ( + -- Output directory + if (haveCoarseMesh node) == true then + output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape") + else + output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape") + + -- Compare file date + if (NeLTestFileDate output inputMaxFile) == true then + ( + try + ( + -- Export the shape + if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then + ( + nlerror("OK "+output) + exported = exported +1 + ) + else + ( + -- Error + nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile) + tagThisFile = false + ) + ) + catch + ( + -- Error + nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile) + tagThisFile = false + ) + ) + else + ( + nlerror("SKIPPED " + output) + exported = exported + 1 + ) + ) + ) + ) + ) + + -- Export default animations + + for node in objects do + ( + -- Can export it ? + if (isAnimToBeExported node) == true then + ( + -- Anim output directory + output = ("%OutputDirectoryAnim%/" + (node.name) + ".anim") + + -- Export the animation + if (NelExportAnimation #(node) output false) == false then + ( + nlerror ("ERROR exporting animation " + output) + tagThisFile = false + ) + else + ( + nlerror("OK " + output) + ) + ) + ) + + -- Something exported + if exported == 0 then + ( + -- Error + nlerror("WARNING no shape exported from the file " + inputMaxFile) + if tagThisFile then + ( + if retryCount < 2 then + ( + nlerror("INFO retry this file") + + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExportSub inputMaxFile (retryCount + 1) + ) + else + ( + -- Error + nlerror("ERROR exporting 'shape': can't open the file " + inputMaxFile) + nlerror("FAIL Mysterious error occurred") + NelForceQuitRightNow() + ) + ) + ) + ) + + return tagThisFile +) + +fn runNelMaxExport inputMaxFile = +( + return runNelMaxExportSub inputMaxFile 0 +) + + + +removeRunningTag = true + +try +( + undo off + ( + -- Get files in the %MaxSourceDirectory% directory + files = getFiles "%MaxSourceDirectory%/*.max" + gc() + + -- Sort files + sort files + gc() + + -- No file ? + if files.count != 0 then + ( + -- For each files + for i = 1 to files.count do + ( + inputMaxFile = files[i] + outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") + + --try + --( + -- Compare file date + if (NeLTestFileDate outputTagFile inputMaxFile) == true then + ( + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + -- Open the max project + nlerror("Scanning file " + inputMaxFile + " ...") + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExport(inputMaxFile) + + -- Write a tag file + if tagThisFile == true then + ( + tagFile = createFile outputTagFile + if tagFile == undefined then + ( + nlerror("WARNING can't create tag file " + outputTagFile) + removeRunningTag = false + ) + else + ( + print "mukyu" to: tagFile + close tagFile + ) + ) + else + ( + removeRunningTag = false + ) + ) + else + ( + -- Error + nlerror("ERROR exporting 'shape': can't open the file " + inputMaxFile) + removeRunningTag = false + ) + ) + else + ( + nlerror("SKIPPED BY TAG " + inputMaxFile) + ) + --) + --catch + --( + -- -- Error + -- nlerror("ERROR error exporting 'shape' in file " + inputMaxFile) + -- removeRunningTag = false + --) + ) + ) + else + ( + nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + ) + ) +) +catch +( + -- Error + nlerror("ERROR Fatal error exporting 'shape' in folder %MaxSourceDirectory%") + nlerror("FAIL Fatal error occurred") + NelForceQuitRightNow() + removeRunningTag = false +) + +try +( + if (removeRunningTag) then + ( + resetMAXFile #noPrompt + ) +) +catch +( + nlerror("FAIL Last reset fails") + removeRunningTag = false +) + +if (removeRunningTag) then +( + nlerror("SUCCESS All .max files have been successfully exported") + deleteFile("%TagDirectory%/max_running.tag") +) +else +( + nlerror("FAIL One or more issues occurred") + NelForceQuitRightNow() +) + +-- Bye +nlerror("BYE") +quitMAX #noPrompt +quitMAX() #noPrompt + 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..419fe3e2b 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 @@ -1,318 +1,318 @@ - - --- ################################################################# --- ## WARNING : this is a generated file, don't change it ! --- ################################################################# - - --- Allocate 20 Me for the script -heapSize += 15000000 - --- In case of error just abort the app and don't show nel report window -NelForceQuitOnMsgDisplayer() - -nlErrorFilename = "%OutputLogfile%" -nlErrorStream = openFile nlErrorFilename mode:"a" -if nlErrorStream == undefined then - nlErrorStream = createFile nlErrorFilename - --- Unhide layers -fn unhidelayers = -( - for i = 0 to (LayerManager.count - 1) do - ( - layer = (LayerManager.getLayer i) - layer.ishidden = false - ) -) - --- Unhide category -fn unhidecategory = -( - if (geometry.count > 0) then - ( - unhide geometry[1] - if (geometry[1].ishidden == true) then - max hide object toggle - ) - if (shapes.count > 0) then - ( - unhide shapes[1] - if (shapes[1].ishidden == true) then - max hide shape toggle - ) - if (lights.count > 0) then - ( - unhide lights[1] - if (lights[1].ishidden == true) then - max hide light toggle - ) - if (cameras.count > 0) then - ( - unhide cameras[1] - if (cameras[1].ishidden == true) then - max hide camera toggle - ) - if (helpers.count > 0) then - ( - unhide helpers[1] - if (helpers[1].ishidden == true) then - max hide helper toggle - ) -) - --- Log a message -fn nlerror message = -( - if nlErrorStream != undefined then - ( - format "%\n" message to:nlErrorStream - flush nlErrorStream - ) - - -- To the console - print message -) - - - --- Some globals - -NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me - -- "0" = export me - -- "1" = DONT export me - -NEL3D_APPDATA_VEGETABLE = 1423062580 -- "undefined" = not vegetable - -- "0" = not vegetable - -- "1" = vegetable - - --- Must export this node ? -fn isToBeExported node = -( - if (classof node == nel_ps) then - return false - - doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT - if (doNotExport != undefined) then - ( - if (doNotExport == "1") then - return false - ) - - vegetable = getappdata node NEL3D_APPDATA_VEGETABLE - if (vegetable != undefined) then - if (vegetable == "1") then - return true - - -- Do not export - return false -) - - -fn runNelMaxExport inputMaxFile = -( - tagThisFile = true - - -- Unhide category - unhidelayers() - unhidecategory() - - -- Unhide - max unhide all - - -- unselect - max select none - clearSelection() - - -- Exported object count - exported = 0 - - -- For each node - for node in geometry do - ( - -- It is root ? - if (node.parent == undefined) then - ( - -- Is not a skeleton ? - if (node.name != "Bip01") then - ( - -- Can be exported ? - if (isToBeExported node == true) then - ( - -- Output directory - outputNelFile = ("%OutputDirectory%/" + (node.name) + ".veget") - - -- Compare file date - if (NeLTestFileDate outputNelFile inputMaxFile) == true then - ( - try - ( - -- Export the veget - if (NelExportVegetable node outputNelFile false) == true then - ( - nlerror("OK "+outputNelFile) - exported = exported+1 - ) - else - ( - -- Error - nlerror("ERROR exporting veget " + node.name + " in file " + inputMaxFile) - tagThisFile = false - ) - ) - catch - ( - -- Error - nlerror("ERROR fata error exporting veget " + node.name + " in file " + inputMaxFile) - tagThisFile = false - ) - ) - else - ( - -- Error - nlerror("SKIPPED " + outputNelFile) - exported = exported + 1 - ) - ) - ) - ) - ) - - -- Something exported - if exported == 0 then - ( - -- Error - nlerror("WARNING no veget exported from the file " + inputMaxFile) - ) - - return tagThisFile -) - - - -removeRunningTag = true - -try -( - undo off - ( - -- Get files in the %MaxSourceDirectory% directory - files = getFiles "%MaxSourceDirectory%/*.max" - gc() - - -- Sort files - sort files - gc() - - -- No file ? - if files.count != 0 then - ( - -- For each files - for i = 1 to files.count do - ( - inputMaxFile = files[i] - outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") - - --try - --( - -- Compare file date - if (NeLTestFileDate outputTagFile inputMaxFile) == true then - ( - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - -- Open the max project - nlerror("Scanning file " + inputMaxFile + " ...") - if (loadMaxFile inputMaxFile quiet:true) == true then - ( - tagThisFile = runNelMaxExport(inputMaxFile) - - -- Write a tag file - if tagThisFile == true then - ( - tagFile = createFile outputTagFile - if tagFile == undefined then - ( - nlerror("WARNING can't create tag file " + outputTagFile) - removeRunningTag = false - ) - else - ( - print "mukyu" to: tagFile - close tagFile - ) - ) - else - ( - removeRunningTag = false - ) - ) - else - ( - -- Error - nlerror("ERROR exporting 'veget': can't open the file " + inputMaxFile) - removeRunningTag = false - ) - ) - else - ( - nlerror("SKIPPED BY TAG " + inputMaxFile) - ) - --) - --catch - --( - -- -- Error - -- nlerror("ERROR error exporting 'veget' in file " + inputMaxFile) - -- removeRunningTag = false - --) - ) - ) - else - ( - nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") - ) - ) -) -catch -( - -- Error - nlerror("ERROR Fatal error exporting 'veget' in folder %MaxSourceDirectory%") - nlerror("FAIL Fatal error occured") - NelForceQuitRightNow() - removeRunningTag = false -) - -try -( - if (removeRunningTag) then - ( - resetMAXFile #noPrompt - ) -) -catch -( - nlerror("FAIL Last reset fails") - removeRunningTag = false -) - -if (removeRunningTag) then -( - nlerror("SUCCESS All .max files have been successfully exported") - deleteFile("%TagDirectory%/max_running.tag") -) -else -( - nlerror("FAIL One or more issues occured") - NelForceQuitRightNow() -) - --- Bye -nlerror("BYE") -quitMAX #noPrompt -quitMAX() #noPrompt - + + +-- ################################################################# +-- ## WARNING : this is a generated file, don't change it ! +-- ################################################################# + + +-- Allocate 20 Me for the script +heapSize += 15000000 + +-- In case of error just abort the app and don't show nel report window +NelForceQuitOnMsgDisplayer() + +nlErrorFilename = "%OutputLogfile%" +nlErrorStream = openFile nlErrorFilename mode:"a" +if nlErrorStream == undefined then + nlErrorStream = createFile nlErrorFilename + +-- Unhide layers +fn unhidelayers = +( + for i = 0 to (LayerManager.count - 1) do + ( + layer = (LayerManager.getLayer i) + layer.ishidden = false + ) +) + +-- Unhide category +fn unhidecategory = +( + if (geometry.count > 0) then + ( + unhide geometry[1] + if (geometry[1].ishidden == true) then + max hide object toggle + ) + if (shapes.count > 0) then + ( + unhide shapes[1] + if (shapes[1].ishidden == true) then + max hide shape toggle + ) + if (lights.count > 0) then + ( + unhide lights[1] + if (lights[1].ishidden == true) then + max hide light toggle + ) + if (cameras.count > 0) then + ( + unhide cameras[1] + if (cameras[1].ishidden == true) then + max hide camera toggle + ) + if (helpers.count > 0) then + ( + unhide helpers[1] + if (helpers[1].ishidden == true) then + max hide helper toggle + ) +) + +-- Log a message +fn nlerror message = +( + if nlErrorStream != undefined then + ( + format "%\n" message to:nlErrorStream + flush nlErrorStream + ) + + -- To the console + print message +) + + + +-- Some globals + +NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me + -- "0" = export me + -- "1" = DONT export me + +NEL3D_APPDATA_VEGETABLE = 1423062580 -- "undefined" = not vegetable + -- "0" = not vegetable + -- "1" = vegetable + + +-- Must export this node ? +fn isToBeExported node = +( + if (classof node == nel_ps) then + return false + + doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT + if (doNotExport != undefined) then + ( + if (doNotExport == "1") then + return false + ) + + vegetable = getappdata node NEL3D_APPDATA_VEGETABLE + if (vegetable != undefined) then + if (vegetable == "1") then + return true + + -- Do not export + return false +) + + +fn runNelMaxExport inputMaxFile = +( + tagThisFile = true + + -- Unhide category + unhidelayers() + unhidecategory() + + -- Unhide + max unhide all + + -- unselect + max select none + clearSelection() + + -- Exported object count + exported = 0 + + -- For each node + for node in geometry do + ( + -- It is root ? + if (node.parent == undefined) then + ( + -- Is not a skeleton ? + if (node.name != "Bip01") then + ( + -- Can be exported ? + if (isToBeExported node == true) then + ( + -- Output directory + outputNelFile = ("%OutputDirectory%/" + (node.name) + ".veget") + + -- Compare file date + if (NeLTestFileDate outputNelFile inputMaxFile) == true then + ( + try + ( + -- Export the veget + if (NelExportVegetable node outputNelFile false) == true then + ( + nlerror("OK "+outputNelFile) + exported = exported+1 + ) + else + ( + -- Error + nlerror("ERROR exporting veget " + node.name + " in file " + inputMaxFile) + tagThisFile = false + ) + ) + catch + ( + -- Error + nlerror("ERROR fata error exporting veget " + node.name + " in file " + inputMaxFile) + tagThisFile = false + ) + ) + else + ( + -- Error + nlerror("SKIPPED " + outputNelFile) + exported = exported + 1 + ) + ) + ) + ) + ) + + -- Something exported + if exported == 0 then + ( + -- Error + nlerror("WARNING no veget exported from the file " + inputMaxFile) + ) + + return tagThisFile +) + + + +removeRunningTag = true + +try +( + undo off + ( + -- Get files in the %MaxSourceDirectory% directory + files = getFiles "%MaxSourceDirectory%/*.max" + gc() + + -- Sort files + sort files + gc() + + -- No file ? + if files.count != 0 then + ( + -- For each files + for i = 1 to files.count do + ( + inputMaxFile = files[i] + outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") + + --try + --( + -- Compare file date + if (NeLTestFileDate outputTagFile inputMaxFile) == true then + ( + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + -- Open the max project + nlerror("Scanning file " + inputMaxFile + " ...") + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExport(inputMaxFile) + + -- Write a tag file + if tagThisFile == true then + ( + tagFile = createFile outputTagFile + if tagFile == undefined then + ( + nlerror("WARNING can't create tag file " + outputTagFile) + removeRunningTag = false + ) + else + ( + print "mukyu" to: tagFile + close tagFile + ) + ) + else + ( + removeRunningTag = false + ) + ) + else + ( + -- Error + nlerror("ERROR exporting 'veget': can't open the file " + inputMaxFile) + removeRunningTag = false + ) + ) + else + ( + nlerror("SKIPPED BY TAG " + inputMaxFile) + ) + --) + --catch + --( + -- -- Error + -- nlerror("ERROR error exporting 'veget' in file " + inputMaxFile) + -- removeRunningTag = false + --) + ) + ) + else + ( + nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + ) + ) +) +catch +( + -- Error + nlerror("ERROR Fatal error exporting 'veget' in folder %MaxSourceDirectory%") + nlerror("FAIL Fatal error occurred") + NelForceQuitRightNow() + removeRunningTag = false +) + +try +( + if (removeRunningTag) then + ( + resetMAXFile #noPrompt + ) +) +catch +( + nlerror("FAIL Last reset fails") + removeRunningTag = false +) + +if (removeRunningTag) then +( + nlerror("SUCCESS All .max files have been successfully exported") + deleteFile("%TagDirectory%/max_running.tag") +) +else +( + nlerror("FAIL One or more issues occurred") + NelForceQuitRightNow() +) + +-- Bye +nlerror("BYE") +quitMAX #noPrompt +quitMAX() #noPrompt + diff --git a/code/nel/tools/georges/georges2csv/georges2csv.cpp b/code/nel/tools/georges/georges2csv/georges2csv.cpp index 99dd920ef..3e1207308 100644 --- a/code/nel/tools/georges/georges2csv/georges2csv.cpp +++ b/code/nel/tools/georges/georges2csv/georges2csv.cpp @@ -179,7 +179,7 @@ void setOutputFile(const CSString &filename) { if (Outf!=NULL) fclose(Outf); - Outf=fopen(filename.c_str(), "wt"); + Outf = nlfopen(filename.c_str(), "wt"); if (Outf == NULL) { fprintf(stderr, "Can't open output file '%s' ! aborting.", filename.c_str()); @@ -382,7 +382,7 @@ void scanFiles(const CSString &filespec) UFormElm *fieldForm=NULL; std::string valueString; - form->getRootNode ().getNodeByName(&fieldForm, fields[i]._name.c_str()); + form->getRootNode ().getNodeByName(&fieldForm, fields[i]._name); if (fieldForm) { @@ -405,7 +405,7 @@ void scanFiles(const CSString &filespec) } else { - if (form->getRootNode ().getValueByName(valueString,fields[i]._name.c_str(),fields[i]._evaluated,&where)) //fieldForm->getValue(valueString,fields[i]._evaluated)) + if (form->getRootNode ().getValueByName(valueString,fields[i]._name, fields[i]._evaluated, &where)) //fieldForm->getValue(valueString,fields[i]._evaluated)) ;//addQuotesRoundString (valueString); else setErrorString (valueString, fields[i]._evaluated, where); @@ -422,7 +422,7 @@ void scanFiles(const CSString &filespec) // UFormElm::TWhereIsValue where; // -// bool result=form->getRootNode ().getValueByName(s,fields[i]._name.c_str(),fields[i]._evaluated,&where); +// bool result=form->getRootNode ().getValueByName(s,fields[i]._name, fields[i]._evaluated,&where); // if (!result) // { // if (fields[i]._evaluated) @@ -933,7 +933,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType if ( idm==dirmapDirs.end() ) { nlinfo( "Directory mapping not found for %s (index %u)", filebase.c_str(), letterIndex ); - dirbase = ""; // put into root + dirbase.clear(); // put into root } } else @@ -953,7 +953,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType { // Load sheet (skip if failed) - dirbase = ""; + dirbase.clear(); filename = (*it).second; // whole path form = (CForm*)formLoader->loadForm( filename.c_str() ); if (form == NULL) @@ -1026,7 +1026,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType const UFormElm *fieldForm=NULL; - if (rootForm.getNodeByName(&fieldForm, var.c_str())) + if (rootForm.getNodeByName(&fieldForm, var)) { UFormDfn *dfnForm=const_cast(rootForm).getStructDfn(); nlassert(dfnForm); @@ -1122,8 +1122,8 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType } //nldebug( "%s: %s '%s'", args[0].c_str(), var.c_str(), memberVal.c_str() ); // need to put the value at the correct index. - const std::string fieldName=NLMISC::toString("%s[%d]", var.c_str(), currentMemberIndex).c_str(); - const_cast(rootForm).setValueByName(memberVal.c_str(), fieldName.c_str()); + const std::string fieldName=NLMISC::toString("%s[%u]", var.c_str(), currentMemberIndex).c_str(); + const_cast(rootForm).setValueByName(memberVal, fieldName); isModified=true; displayed = true; } @@ -1132,7 +1132,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType if (!isNewSheet) { string test; - if ( rootForm.getValueByName(test,var.c_str()) + if ( rootForm.getValueByName(test, var) && test==memberVal ) { continue; @@ -1140,7 +1140,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType } //nldebug( "%s: %s '%s'", args[0].c_str(), var.c_str(), memberVal.c_str() ); - const_cast(rootForm).setValueByName(memberVal.c_str(), var.c_str()); + const_cast(rootForm).setValueByName(memberVal, var); isModified=true; displayed = true; } diff --git a/code/nel/tools/logic/logic_editor_dll/Condition.cpp b/code/nel/tools/logic/logic_editor_dll/Condition.cpp index cc395562e..ba248a80d 100644 --- a/code/nel/tools/logic/logic_editor_dll/Condition.cpp +++ b/code/nel/tools/logic/logic_editor_dll/Condition.cpp @@ -80,7 +80,7 @@ const CString & CConditionNode::getNodeAsString() const m_sNodeString = m_sConditionName; else // comparison { - m_sNodeString.Format("%s %s %g",LPCTSTR(m_sVariableName),LPCTSTR(m_sOperator), m_dComparand ); + m_sNodeString.Format(_T("%s %s %g"),LPCTSTR(m_sVariableName),LPCTSTR(m_sOperator), m_dComparand ); } return m_sNodeString; @@ -260,8 +260,8 @@ void cConditionNodeToCLogicConditionNode(CConditionNode * conditionNode, CLogicC { logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::COMPARISON; - logicConditionNode->LogicBlock.ComparisonBlock.VariableName = string( (LPCSTR)conditionNode->m_sVariableName ); - logicConditionNode->LogicBlock.ComparisonBlock.Operator = string( (LPCSTR)conditionNode->m_sOperator ); + logicConditionNode->LogicBlock.ComparisonBlock.VariableName = tStrToUtf8(conditionNode->m_sVariableName); + logicConditionNode->LogicBlock.ComparisonBlock.Operator = tStrToUtf8(conditionNode->m_sOperator); logicConditionNode->LogicBlock.ComparisonBlock.Comparand = (sint64)conditionNode->m_dComparand; } break; @@ -270,7 +270,7 @@ void cConditionNodeToCLogicConditionNode(CConditionNode * conditionNode, CLogicC { logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::SUB_CONDITION; - logicConditionNode->LogicBlock.SubCondition = string( (LPCSTR)conditionNode->m_sConditionName ); + logicConditionNode->LogicBlock.SubCondition = tStrToUtf8(conditionNode->m_sConditionName); } break; } @@ -298,7 +298,7 @@ void cConditionNodeToCLogicConditionNode(CConditionNode * conditionNode, CLogicC void cConditionToCLogicCondition( CCondition& condition, CLogicCondition& logicCondition ) { // condition name - logicCondition.setName( string( (LPCSTR)condition.m_sName ) ); + logicCondition.setName(tStrToUtf8(condition.m_sName)); // nodes POSITION pos; diff --git a/code/nel/tools/logic/logic_editor_dll/Condition.cpp.BACKUP.7900.cpp b/code/nel/tools/logic/logic_editor_dll/Condition.cpp.BACKUP.7900.cpp new file mode 100644 index 000000000..88bd6bdcf --- /dev/null +++ b/code/nel/tools/logic/logic_editor_dll/Condition.cpp.BACKUP.7900.cpp @@ -0,0 +1,430 @@ +// Condition.cpp: implementation of the CCondition class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "logic_editor.h" +#include "condition.h" +#include "nel/logic/logic_condition.h" + +#include + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +using namespace std; +using namespace NLLOGIC; + +////////////////////////////////////////////////////////////////////// +// CConditionNode implementation +////////////////////////////////////////////////////////////////////// + +CConditionNode::CConditionNode(const CConditionNode &node) +{ + this->m_dComparand = node.m_dComparand; + this->m_pParentNode = node.m_pParentNode; + this->m_sConditionName = node.m_sConditionName; + this->m_sOperator = node.m_sOperator; + this->m_sVariableName = node.m_sVariableName; + this->m_type = node.m_type; + + // copy sub condition node tree + CConditionNode *pNode, *newNode; + POSITION pos = node.m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + newNode = new CConditionNode( *pNode ); + this->m_ctSubTree.AddTail( newNode ); + newNode->m_pParentNode = this; + } + } + +} + + + +CConditionNode::~CConditionNode() +{ + CConditionNode *pNode = NULL; + + // delete all sub nodes + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + delete pNode; + pNode = NULL; + } + } +} + +const CString & CConditionNode::getNodeAsString() const +{ + m_sNodeString.Empty(); + + if (m_type == NOT) + m_sNodeString = "NOT"; + else if (m_type == TERMINATOR) + m_sNodeString = "term"; + else if (m_type == SUB_CONDITION) + m_sNodeString = m_sConditionName; + else // comparison + { +<<<<<<< HEAD + m_sNodeString.Format("%s %s %g",LPCTSTR(m_sVariableName),LPCTSTR(m_sOperator), m_dComparand ); +======= + m_sNodeString.Format(_T("%s %s %g"),LPCTSTR(m_sVariableName),LPCTSTR(m_sOperator), m_dComparand ); +>>>>>>> ryzomcore + } + + return m_sNodeString; +} + + + +void CConditionNode::changeConditionName( const CString &old, const CString &newName) +{ + CConditionNode *pNode = NULL; + + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + pNode->changeConditionName(old, newName); + } + } + + // + if ( m_sConditionName == old) + m_sConditionName = newName; +} + +void CConditionNode::conditionDeleted( const CString &name) +{ + CConditionNode *pNode = NULL; + + POSITION oldpos; + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + oldpos = pos; + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + if ( pNode->m_sConditionName != name) + pNode->conditionDeleted(name); + else + { + this->m_ctSubTree.RemoveAt( oldpos ); + delete pNode; + pNode = NULL; + } + } + } +} + + + + + +////////////////////////////////////////////////////////////////////// +// CCondition implementation +////////////////////////////////////////////////////////////////////// +CCondition::CCondition() +{ +} + + +CCondition::CCondition( const CCondition &cond) +{ + this->m_sName = cond.m_sName; + + // copy sub condition node tree + CConditionNode *pNode, *newNode; + POSITION pos = cond.m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + newNode = new CConditionNode( *pNode ); + this->m_ctConditionTree.AddTail( newNode ); + } + } + +} + + +CCondition::~CCondition() +{ + CConditionNode *pNode = NULL; + + // delete all sub nodes + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + delete pNode; + pNode = NULL; + } + } +} + + + +void CCondition::changeConditionName( CString old, const CString &newName) const +{ + CConditionNode *pNode = NULL; + + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + pNode->changeConditionName( old, newName); + } + } +} + + +void CCondition::conditionDeleted( CString name) +{ + CConditionNode *pNode = NULL; + + POSITION oldpos; + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + oldpos = pos; + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + if ( pNode->m_sConditionName != name) + pNode->conditionDeleted(name); + else + { + this->m_ctConditionTree.RemoveAt( oldpos ); + delete pNode; + pNode = NULL; + } + } + } +} + + + +//----------------------------------------------------- +// cConditionNodeToCLogicConditionNode (Editor --> Service) +// +//----------------------------------------------------- +void cConditionNodeToCLogicConditionNode(CConditionNode * conditionNode, CLogicConditionNode * logicConditionNode ) +{ + // if this node is a terminator node + if( conditionNode->m_type == CConditionNode::TERMINATOR ) + { + logicConditionNode->Type = CLogicConditionNode::TERMINATOR; + } + else + // this node is a logic node + { + logicConditionNode->Type = CLogicConditionNode::LOGIC_NODE; + + // part 1 : a logic block(not/comparison/subcondition) + switch( conditionNode->m_type ) + { + case CConditionNode::NOT : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::NOT; + + } + break; + + case CConditionNode::COMPARISON : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::COMPARISON; + +<<<<<<< HEAD + logicConditionNode->LogicBlock.ComparisonBlock.VariableName = string( (LPCSTR)conditionNode->m_sVariableName ); + logicConditionNode->LogicBlock.ComparisonBlock.Operator = string( (LPCSTR)conditionNode->m_sOperator ); +======= + logicConditionNode->LogicBlock.ComparisonBlock.VariableName = tStrToUtf8(conditionNode->m_sVariableName); + logicConditionNode->LogicBlock.ComparisonBlock.Operator = tStrToUtf8(conditionNode->m_sOperator); +>>>>>>> ryzomcore + logicConditionNode->LogicBlock.ComparisonBlock.Comparand = (sint64)conditionNode->m_dComparand; + } + break; + + case CConditionNode::SUB_CONDITION : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::SUB_CONDITION; + +<<<<<<< HEAD + logicConditionNode->LogicBlock.SubCondition = string( (LPCSTR)conditionNode->m_sConditionName ); +======= + logicConditionNode->LogicBlock.SubCondition = tStrToUtf8(conditionNode->m_sConditionName); +>>>>>>> ryzomcore + } + break; + } + + // part 2 : a condition sub tree + POSITION pos; + for( pos = conditionNode->m_ctSubTree.GetHeadPosition(); pos != NULL; ) + { + CConditionNode * pConditionNode = conditionNode->m_ctSubTree.GetNext( pos ); + CLogicConditionNode * logicConditionNodeTmp = new CLogicConditionNode(); + cConditionNodeToCLogicConditionNode( pConditionNode, logicConditionNodeTmp ); + logicConditionNode->addNode( logicConditionNodeTmp ); + } + } + +} // cConditionNodeToCLogicConditionNode // + + + + +//----------------------------------------------------- +// cConditionToCLogicCondition (Editor --> Service) +// +//----------------------------------------------------- +void cConditionToCLogicCondition( CCondition& condition, CLogicCondition& logicCondition ) +{ + // condition name +<<<<<<< HEAD + logicCondition.setName( string( (LPCSTR)condition.m_sName ) ); +======= + logicCondition.setName(tStrToUtf8(condition.m_sName)); +>>>>>>> ryzomcore + + // nodes + POSITION pos; + for( pos = condition.m_ctConditionTree.GetHeadPosition(); pos != NULL; ) + { + // get the node + CConditionNode * pConditionNode = condition.m_ctConditionTree.GetNext( pos ); + + // convert the node + CLogicConditionNode * logicConditionNode = new CLogicConditionNode(); + cConditionNodeToCLogicConditionNode( pConditionNode, logicConditionNode ); + + // add the node + logicCondition.addNode( *logicConditionNode ); + } + +} // cConditionToCLogicCondition // + + + + + + +//----------------------------------------------------- +// cLogicConditionNodeToCConditionNode (Service --> Editor) +// +//----------------------------------------------------- +void cLogicConditionNodeToCConditionNode( const CLogicConditionNode * logicConditionNode, CConditionNode * node ) +{ + // terminator node + if(logicConditionNode->Type == CLogicConditionNode::TERMINATOR) + { + node->m_type = CConditionNode::TERMINATOR; + } + // logic block with condition sub tree + else + { + // part 1 : a logic block(not/comparison/subcondition) + switch( logicConditionNode->LogicBlock.Type ) + { + case CLogicConditionLogicBlock::NOT : + { + node->m_type = CConditionNode::NOT; + }; + break; + + case CLogicConditionLogicBlock::COMPARISON : + { + node->m_type = CConditionNode::COMPARISON; + + node->m_sVariableName = CString(logicConditionNode->LogicBlock.ComparisonBlock.VariableName.c_str()); + node->m_sOperator = CString(logicConditionNode->LogicBlock.ComparisonBlock.Operator.c_str()); + node->m_dComparand = (double)logicConditionNode->LogicBlock.ComparisonBlock.Comparand; + + }; + break; + + case CLogicConditionLogicBlock::SUB_CONDITION : + { + node->m_type = CConditionNode::SUB_CONDITION; + node->m_sConditionName = CString(logicConditionNode->LogicBlock.SubCondition.c_str()); + }; + break; + + default : + { + node->m_type = CConditionNode::TERMINATOR; + } + + } + + // part 2 : a condition sub tree + vector::const_iterator itNode; + for( itNode = logicConditionNode->_Nodes.begin(); itNode != logicConditionNode->_Nodes.end(); ++itNode ) + { + CConditionNode * nodeTmp = new CConditionNode(); + cLogicConditionNodeToCConditionNode( *itNode, nodeTmp ); + nodeTmp->m_pParentNode = node; + node->m_ctSubTree.AddTail( nodeTmp ); + } + + } + +} // cLogicConditionNodeToCConditionNode // + + + + +//----------------------------------------------- +// cLogicConditionToCCondition +// +//----------------------------------------------- +void cLogicConditionToCCondition( const CLogicCondition& logicCondition, CCondition& condition ) +{ + // condition name + condition.m_sName = CString( logicCondition.getName().c_str() ); + + // condition tree + vector::const_iterator itNode; + for( itNode = logicCondition.Nodes.begin(); itNode != logicCondition.Nodes.end(); ++itNode ) + { + // convert the node + CConditionNode * node = new CConditionNode(); + cLogicConditionNodeToCConditionNode( &(*itNode), node ); + + // add the node + condition.m_ctConditionTree.AddTail( node ); + } + +} // cLogicConditionToCCondition // + + diff --git a/code/nel/tools/logic/logic_editor_dll/Condition.cpp.BASE.7900.cpp b/code/nel/tools/logic/logic_editor_dll/Condition.cpp.BASE.7900.cpp new file mode 100644 index 000000000..656adece2 --- /dev/null +++ b/code/nel/tools/logic/logic_editor_dll/Condition.cpp.BASE.7900.cpp @@ -0,0 +1,413 @@ +// Condition.cpp: implementation of the CCondition class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "logic_editor.h" +#include "condition.h" +#include "nel/logic/logic_condition.h" + +#include + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +using namespace std; +using namespace NLLOGIC; + +////////////////////////////////////////////////////////////////////// +// CConditionNode implementation +////////////////////////////////////////////////////////////////////// + +CConditionNode::CConditionNode(const CConditionNode &node) +{ + this->m_dComparand = node.m_dComparand; + this->m_pParentNode = node.m_pParentNode; + this->m_sConditionName = node.m_sConditionName; + this->m_sOperator = node.m_sOperator; + this->m_sVariableName = node.m_sVariableName; + this->m_type = node.m_type; + + // copy sub condition node tree + CConditionNode *pNode, *newNode; + POSITION pos = node.m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + newNode = new CConditionNode( *pNode ); + this->m_ctSubTree.AddTail( newNode ); + newNode->m_pParentNode = this; + } + } + +} + + + +CConditionNode::~CConditionNode() +{ + CConditionNode *pNode = NULL; + + // delete all sub nodes + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + delete pNode; + pNode = NULL; + } + } +} + +const CString & CConditionNode::getNodeAsString() const +{ + m_sNodeString.Empty(); + + if (m_type == NOT) + m_sNodeString = "NOT"; + else if (m_type == TERMINATOR) + m_sNodeString = "term"; + else if (m_type == SUB_CONDITION) + m_sNodeString = m_sConditionName; + else // comparison + { + m_sNodeString.Format("%s %s %g",LPCTSTR(m_sVariableName),LPCTSTR(m_sOperator), m_dComparand ); + } + + return m_sNodeString; +} + + + +void CConditionNode::changeConditionName( const CString &old, const CString &newName) +{ + CConditionNode *pNode = NULL; + + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + pNode->changeConditionName(old, newName); + } + } + + // + if ( m_sConditionName == old) + m_sConditionName = newName; +} + +void CConditionNode::conditionDeleted( const CString &name) +{ + CConditionNode *pNode = NULL; + + POSITION oldpos; + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + oldpos = pos; + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + if ( pNode->m_sConditionName != name) + pNode->conditionDeleted(name); + else + { + this->m_ctSubTree.RemoveAt( oldpos ); + delete pNode; + pNode = NULL; + } + } + } +} + + + + + +////////////////////////////////////////////////////////////////////// +// CCondition implementation +////////////////////////////////////////////////////////////////////// +CCondition::CCondition() +{ +} + + +CCondition::CCondition( const CCondition &cond) +{ + this->m_sName = cond.m_sName; + + // copy sub condition node tree + CConditionNode *pNode, *newNode; + POSITION pos = cond.m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + newNode = new CConditionNode( *pNode ); + this->m_ctConditionTree.AddTail( newNode ); + } + } + +} + + +CCondition::~CCondition() +{ + CConditionNode *pNode = NULL; + + // delete all sub nodes + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + delete pNode; + pNode = NULL; + } + } +} + + + +void CCondition::changeConditionName( CString old, const CString &newName) const +{ + CConditionNode *pNode = NULL; + + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + pNode->changeConditionName( old, newName); + } + } +} + + +void CCondition::conditionDeleted( CString name) +{ + CConditionNode *pNode = NULL; + + POSITION oldpos; + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + oldpos = pos; + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + if ( pNode->m_sConditionName != name) + pNode->conditionDeleted(name); + else + { + this->m_ctConditionTree.RemoveAt( oldpos ); + delete pNode; + pNode = NULL; + } + } + } +} + + + +//----------------------------------------------------- +// cConditionNodeToCLogicConditionNode (Editor --> Service) +// +//----------------------------------------------------- +void cConditionNodeToCLogicConditionNode(CConditionNode * conditionNode, CLogicConditionNode * logicConditionNode ) +{ + // if this node is a terminator node + if( conditionNode->m_type == CConditionNode::TERMINATOR ) + { + logicConditionNode->Type = CLogicConditionNode::TERMINATOR; + } + else + // this node is a logic node + { + logicConditionNode->Type = CLogicConditionNode::LOGIC_NODE; + + // part 1 : a logic block(not/comparison/subcondition) + switch( conditionNode->m_type ) + { + case CConditionNode::NOT : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::NOT; + + } + break; + + case CConditionNode::COMPARISON : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::COMPARISON; + + logicConditionNode->LogicBlock.ComparisonBlock.VariableName = string( (LPCSTR)conditionNode->m_sVariableName ); + logicConditionNode->LogicBlock.ComparisonBlock.Operator = string( (LPCSTR)conditionNode->m_sOperator ); + logicConditionNode->LogicBlock.ComparisonBlock.Comparand = (sint64)conditionNode->m_dComparand; + } + break; + + case CConditionNode::SUB_CONDITION : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::SUB_CONDITION; + + logicConditionNode->LogicBlock.SubCondition = string( (LPCSTR)conditionNode->m_sConditionName ); + } + break; + } + + // part 2 : a condition sub tree + POSITION pos; + for( pos = conditionNode->m_ctSubTree.GetHeadPosition(); pos != NULL; ) + { + CConditionNode * pConditionNode = conditionNode->m_ctSubTree.GetNext( pos ); + CLogicConditionNode * logicConditionNodeTmp = new CLogicConditionNode(); + cConditionNodeToCLogicConditionNode( pConditionNode, logicConditionNodeTmp ); + logicConditionNode->addNode( logicConditionNodeTmp ); + } + } + +} // cConditionNodeToCLogicConditionNode // + + + + +//----------------------------------------------------- +// cConditionToCLogicCondition (Editor --> Service) +// +//----------------------------------------------------- +void cConditionToCLogicCondition( CCondition& condition, CLogicCondition& logicCondition ) +{ + // condition name + logicCondition.setName( string( (LPCSTR)condition.m_sName ) ); + + // nodes + POSITION pos; + for( pos = condition.m_ctConditionTree.GetHeadPosition(); pos != NULL; ) + { + // get the node + CConditionNode * pConditionNode = condition.m_ctConditionTree.GetNext( pos ); + + // convert the node + CLogicConditionNode * logicConditionNode = new CLogicConditionNode(); + cConditionNodeToCLogicConditionNode( pConditionNode, logicConditionNode ); + + // add the node + logicCondition.addNode( *logicConditionNode ); + } + +} // cConditionToCLogicCondition // + + + + + + +//----------------------------------------------------- +// cLogicConditionNodeToCConditionNode (Service --> Editor) +// +//----------------------------------------------------- +void cLogicConditionNodeToCConditionNode( const CLogicConditionNode * logicConditionNode, CConditionNode * node ) +{ + // terminator node + if(logicConditionNode->Type == CLogicConditionNode::TERMINATOR) + { + node->m_type = CConditionNode::TERMINATOR; + } + // logic block with condition sub tree + else + { + // part 1 : a logic block(not/comparison/subcondition) + switch( logicConditionNode->LogicBlock.Type ) + { + case CLogicConditionLogicBlock::NOT : + { + node->m_type = CConditionNode::NOT; + }; + break; + + case CLogicConditionLogicBlock::COMPARISON : + { + node->m_type = CConditionNode::COMPARISON; + + node->m_sVariableName = CString(logicConditionNode->LogicBlock.ComparisonBlock.VariableName.c_str()); + node->m_sOperator = CString(logicConditionNode->LogicBlock.ComparisonBlock.Operator.c_str()); + node->m_dComparand = (double)logicConditionNode->LogicBlock.ComparisonBlock.Comparand; + + }; + break; + + case CLogicConditionLogicBlock::SUB_CONDITION : + { + node->m_type = CConditionNode::SUB_CONDITION; + node->m_sConditionName = CString(logicConditionNode->LogicBlock.SubCondition.c_str()); + }; + break; + + default : + { + node->m_type = CConditionNode::TERMINATOR; + } + + } + + // part 2 : a condition sub tree + vector::const_iterator itNode; + for( itNode = logicConditionNode->_Nodes.begin(); itNode != logicConditionNode->_Nodes.end(); ++itNode ) + { + CConditionNode * nodeTmp = new CConditionNode(); + cLogicConditionNodeToCConditionNode( *itNode, nodeTmp ); + nodeTmp->m_pParentNode = node; + node->m_ctSubTree.AddTail( nodeTmp ); + } + + } + +} // cLogicConditionNodeToCConditionNode // + + + + +//----------------------------------------------- +// cLogicConditionToCCondition +// +//----------------------------------------------- +void cLogicConditionToCCondition( const CLogicCondition& logicCondition, CCondition& condition ) +{ + // condition name + condition.m_sName = CString( logicCondition.getName().c_str() ); + + // condition tree + vector::const_iterator itNode; + for( itNode = logicCondition.Nodes.begin(); itNode != logicCondition.Nodes.end(); ++itNode ) + { + // convert the node + CConditionNode * node = new CConditionNode(); + cLogicConditionNodeToCConditionNode( &(*itNode), node ); + + // add the node + condition.m_ctConditionTree.AddTail( node ); + } + +} // cLogicConditionToCCondition // + + diff --git a/code/nel/tools/logic/logic_editor_dll/Condition.cpp.LOCAL.7900.cpp b/code/nel/tools/logic/logic_editor_dll/Condition.cpp.LOCAL.7900.cpp new file mode 100644 index 000000000..cc395562e --- /dev/null +++ b/code/nel/tools/logic/logic_editor_dll/Condition.cpp.LOCAL.7900.cpp @@ -0,0 +1,413 @@ +// Condition.cpp: implementation of the CCondition class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "logic_editor.h" +#include "condition.h" +#include "nel/logic/logic_condition.h" + +#include + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +using namespace std; +using namespace NLLOGIC; + +////////////////////////////////////////////////////////////////////// +// CConditionNode implementation +////////////////////////////////////////////////////////////////////// + +CConditionNode::CConditionNode(const CConditionNode &node) +{ + this->m_dComparand = node.m_dComparand; + this->m_pParentNode = node.m_pParentNode; + this->m_sConditionName = node.m_sConditionName; + this->m_sOperator = node.m_sOperator; + this->m_sVariableName = node.m_sVariableName; + this->m_type = node.m_type; + + // copy sub condition node tree + CConditionNode *pNode, *newNode; + POSITION pos = node.m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + newNode = new CConditionNode( *pNode ); + this->m_ctSubTree.AddTail( newNode ); + newNode->m_pParentNode = this; + } + } + +} + + + +CConditionNode::~CConditionNode() +{ + CConditionNode *pNode = NULL; + + // delete all sub nodes + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + delete pNode; + pNode = NULL; + } + } +} + +const CString & CConditionNode::getNodeAsString() const +{ + m_sNodeString.Empty(); + + if (m_type == NOT) + m_sNodeString = "NOT"; + else if (m_type == TERMINATOR) + m_sNodeString = "term"; + else if (m_type == SUB_CONDITION) + m_sNodeString = m_sConditionName; + else // comparison + { + m_sNodeString.Format("%s %s %g",LPCTSTR(m_sVariableName),LPCTSTR(m_sOperator), m_dComparand ); + } + + return m_sNodeString; +} + + + +void CConditionNode::changeConditionName( const CString &old, const CString &newName) +{ + CConditionNode *pNode = NULL; + + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + pNode->changeConditionName(old, newName); + } + } + + // + if ( m_sConditionName == old) + m_sConditionName = newName; +} + +void CConditionNode::conditionDeleted( const CString &name) +{ + CConditionNode *pNode = NULL; + + POSITION oldpos; + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + oldpos = pos; + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + if ( pNode->m_sConditionName != name) + pNode->conditionDeleted(name); + else + { + this->m_ctSubTree.RemoveAt( oldpos ); + delete pNode; + pNode = NULL; + } + } + } +} + + + + + +////////////////////////////////////////////////////////////////////// +// CCondition implementation +////////////////////////////////////////////////////////////////////// +CCondition::CCondition() +{ +} + + +CCondition::CCondition( const CCondition &cond) +{ + this->m_sName = cond.m_sName; + + // copy sub condition node tree + CConditionNode *pNode, *newNode; + POSITION pos = cond.m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + newNode = new CConditionNode( *pNode ); + this->m_ctConditionTree.AddTail( newNode ); + } + } + +} + + +CCondition::~CCondition() +{ + CConditionNode *pNode = NULL; + + // delete all sub nodes + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + delete pNode; + pNode = NULL; + } + } +} + + + +void CCondition::changeConditionName( CString old, const CString &newName) const +{ + CConditionNode *pNode = NULL; + + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + pNode->changeConditionName( old, newName); + } + } +} + + +void CCondition::conditionDeleted( CString name) +{ + CConditionNode *pNode = NULL; + + POSITION oldpos; + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + oldpos = pos; + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + if ( pNode->m_sConditionName != name) + pNode->conditionDeleted(name); + else + { + this->m_ctConditionTree.RemoveAt( oldpos ); + delete pNode; + pNode = NULL; + } + } + } +} + + + +//----------------------------------------------------- +// cConditionNodeToCLogicConditionNode (Editor --> Service) +// +//----------------------------------------------------- +void cConditionNodeToCLogicConditionNode(CConditionNode * conditionNode, CLogicConditionNode * logicConditionNode ) +{ + // if this node is a terminator node + if( conditionNode->m_type == CConditionNode::TERMINATOR ) + { + logicConditionNode->Type = CLogicConditionNode::TERMINATOR; + } + else + // this node is a logic node + { + logicConditionNode->Type = CLogicConditionNode::LOGIC_NODE; + + // part 1 : a logic block(not/comparison/subcondition) + switch( conditionNode->m_type ) + { + case CConditionNode::NOT : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::NOT; + + } + break; + + case CConditionNode::COMPARISON : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::COMPARISON; + + logicConditionNode->LogicBlock.ComparisonBlock.VariableName = string( (LPCSTR)conditionNode->m_sVariableName ); + logicConditionNode->LogicBlock.ComparisonBlock.Operator = string( (LPCSTR)conditionNode->m_sOperator ); + logicConditionNode->LogicBlock.ComparisonBlock.Comparand = (sint64)conditionNode->m_dComparand; + } + break; + + case CConditionNode::SUB_CONDITION : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::SUB_CONDITION; + + logicConditionNode->LogicBlock.SubCondition = string( (LPCSTR)conditionNode->m_sConditionName ); + } + break; + } + + // part 2 : a condition sub tree + POSITION pos; + for( pos = conditionNode->m_ctSubTree.GetHeadPosition(); pos != NULL; ) + { + CConditionNode * pConditionNode = conditionNode->m_ctSubTree.GetNext( pos ); + CLogicConditionNode * logicConditionNodeTmp = new CLogicConditionNode(); + cConditionNodeToCLogicConditionNode( pConditionNode, logicConditionNodeTmp ); + logicConditionNode->addNode( logicConditionNodeTmp ); + } + } + +} // cConditionNodeToCLogicConditionNode // + + + + +//----------------------------------------------------- +// cConditionToCLogicCondition (Editor --> Service) +// +//----------------------------------------------------- +void cConditionToCLogicCondition( CCondition& condition, CLogicCondition& logicCondition ) +{ + // condition name + logicCondition.setName( string( (LPCSTR)condition.m_sName ) ); + + // nodes + POSITION pos; + for( pos = condition.m_ctConditionTree.GetHeadPosition(); pos != NULL; ) + { + // get the node + CConditionNode * pConditionNode = condition.m_ctConditionTree.GetNext( pos ); + + // convert the node + CLogicConditionNode * logicConditionNode = new CLogicConditionNode(); + cConditionNodeToCLogicConditionNode( pConditionNode, logicConditionNode ); + + // add the node + logicCondition.addNode( *logicConditionNode ); + } + +} // cConditionToCLogicCondition // + + + + + + +//----------------------------------------------------- +// cLogicConditionNodeToCConditionNode (Service --> Editor) +// +//----------------------------------------------------- +void cLogicConditionNodeToCConditionNode( const CLogicConditionNode * logicConditionNode, CConditionNode * node ) +{ + // terminator node + if(logicConditionNode->Type == CLogicConditionNode::TERMINATOR) + { + node->m_type = CConditionNode::TERMINATOR; + } + // logic block with condition sub tree + else + { + // part 1 : a logic block(not/comparison/subcondition) + switch( logicConditionNode->LogicBlock.Type ) + { + case CLogicConditionLogicBlock::NOT : + { + node->m_type = CConditionNode::NOT; + }; + break; + + case CLogicConditionLogicBlock::COMPARISON : + { + node->m_type = CConditionNode::COMPARISON; + + node->m_sVariableName = CString(logicConditionNode->LogicBlock.ComparisonBlock.VariableName.c_str()); + node->m_sOperator = CString(logicConditionNode->LogicBlock.ComparisonBlock.Operator.c_str()); + node->m_dComparand = (double)logicConditionNode->LogicBlock.ComparisonBlock.Comparand; + + }; + break; + + case CLogicConditionLogicBlock::SUB_CONDITION : + { + node->m_type = CConditionNode::SUB_CONDITION; + node->m_sConditionName = CString(logicConditionNode->LogicBlock.SubCondition.c_str()); + }; + break; + + default : + { + node->m_type = CConditionNode::TERMINATOR; + } + + } + + // part 2 : a condition sub tree + vector::const_iterator itNode; + for( itNode = logicConditionNode->_Nodes.begin(); itNode != logicConditionNode->_Nodes.end(); ++itNode ) + { + CConditionNode * nodeTmp = new CConditionNode(); + cLogicConditionNodeToCConditionNode( *itNode, nodeTmp ); + nodeTmp->m_pParentNode = node; + node->m_ctSubTree.AddTail( nodeTmp ); + } + + } + +} // cLogicConditionNodeToCConditionNode // + + + + +//----------------------------------------------- +// cLogicConditionToCCondition +// +//----------------------------------------------- +void cLogicConditionToCCondition( const CLogicCondition& logicCondition, CCondition& condition ) +{ + // condition name + condition.m_sName = CString( logicCondition.getName().c_str() ); + + // condition tree + vector::const_iterator itNode; + for( itNode = logicCondition.Nodes.begin(); itNode != logicCondition.Nodes.end(); ++itNode ) + { + // convert the node + CConditionNode * node = new CConditionNode(); + cLogicConditionNodeToCConditionNode( &(*itNode), node ); + + // add the node + condition.m_ctConditionTree.AddTail( node ); + } + +} // cLogicConditionToCCondition // + + diff --git a/code/nel/tools/logic/logic_editor_dll/Condition.cpp.REMOTE.7900.cpp b/code/nel/tools/logic/logic_editor_dll/Condition.cpp.REMOTE.7900.cpp new file mode 100644 index 000000000..ba248a80d --- /dev/null +++ b/code/nel/tools/logic/logic_editor_dll/Condition.cpp.REMOTE.7900.cpp @@ -0,0 +1,413 @@ +// Condition.cpp: implementation of the CCondition class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "logic_editor.h" +#include "condition.h" +#include "nel/logic/logic_condition.h" + +#include + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +using namespace std; +using namespace NLLOGIC; + +////////////////////////////////////////////////////////////////////// +// CConditionNode implementation +////////////////////////////////////////////////////////////////////// + +CConditionNode::CConditionNode(const CConditionNode &node) +{ + this->m_dComparand = node.m_dComparand; + this->m_pParentNode = node.m_pParentNode; + this->m_sConditionName = node.m_sConditionName; + this->m_sOperator = node.m_sOperator; + this->m_sVariableName = node.m_sVariableName; + this->m_type = node.m_type; + + // copy sub condition node tree + CConditionNode *pNode, *newNode; + POSITION pos = node.m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + newNode = new CConditionNode( *pNode ); + this->m_ctSubTree.AddTail( newNode ); + newNode->m_pParentNode = this; + } + } + +} + + + +CConditionNode::~CConditionNode() +{ + CConditionNode *pNode = NULL; + + // delete all sub nodes + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + delete pNode; + pNode = NULL; + } + } +} + +const CString & CConditionNode::getNodeAsString() const +{ + m_sNodeString.Empty(); + + if (m_type == NOT) + m_sNodeString = "NOT"; + else if (m_type == TERMINATOR) + m_sNodeString = "term"; + else if (m_type == SUB_CONDITION) + m_sNodeString = m_sConditionName; + else // comparison + { + m_sNodeString.Format(_T("%s %s %g"),LPCTSTR(m_sVariableName),LPCTSTR(m_sOperator), m_dComparand ); + } + + return m_sNodeString; +} + + + +void CConditionNode::changeConditionName( const CString &old, const CString &newName) +{ + CConditionNode *pNode = NULL; + + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + pNode->changeConditionName(old, newName); + } + } + + // + if ( m_sConditionName == old) + m_sConditionName = newName; +} + +void CConditionNode::conditionDeleted( const CString &name) +{ + CConditionNode *pNode = NULL; + + POSITION oldpos; + POSITION pos = m_ctSubTree.GetHeadPosition(); + while (pos != NULL) + { + oldpos = pos; + pNode = m_ctSubTree.GetNext( pos ); + + if (pNode != NULL) + { + if ( pNode->m_sConditionName != name) + pNode->conditionDeleted(name); + else + { + this->m_ctSubTree.RemoveAt( oldpos ); + delete pNode; + pNode = NULL; + } + } + } +} + + + + + +////////////////////////////////////////////////////////////////////// +// CCondition implementation +////////////////////////////////////////////////////////////////////// +CCondition::CCondition() +{ +} + + +CCondition::CCondition( const CCondition &cond) +{ + this->m_sName = cond.m_sName; + + // copy sub condition node tree + CConditionNode *pNode, *newNode; + POSITION pos = cond.m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + newNode = new CConditionNode( *pNode ); + this->m_ctConditionTree.AddTail( newNode ); + } + } + +} + + +CCondition::~CCondition() +{ + CConditionNode *pNode = NULL; + + // delete all sub nodes + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + delete pNode; + pNode = NULL; + } + } +} + + + +void CCondition::changeConditionName( CString old, const CString &newName) const +{ + CConditionNode *pNode = NULL; + + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + pNode->changeConditionName( old, newName); + } + } +} + + +void CCondition::conditionDeleted( CString name) +{ + CConditionNode *pNode = NULL; + + POSITION oldpos; + POSITION pos = m_ctConditionTree.GetHeadPosition(); + while (pos != NULL) + { + oldpos = pos; + pNode = m_ctConditionTree.GetNext( pos ); + + if (pNode != NULL) + { + if ( pNode->m_sConditionName != name) + pNode->conditionDeleted(name); + else + { + this->m_ctConditionTree.RemoveAt( oldpos ); + delete pNode; + pNode = NULL; + } + } + } +} + + + +//----------------------------------------------------- +// cConditionNodeToCLogicConditionNode (Editor --> Service) +// +//----------------------------------------------------- +void cConditionNodeToCLogicConditionNode(CConditionNode * conditionNode, CLogicConditionNode * logicConditionNode ) +{ + // if this node is a terminator node + if( conditionNode->m_type == CConditionNode::TERMINATOR ) + { + logicConditionNode->Type = CLogicConditionNode::TERMINATOR; + } + else + // this node is a logic node + { + logicConditionNode->Type = CLogicConditionNode::LOGIC_NODE; + + // part 1 : a logic block(not/comparison/subcondition) + switch( conditionNode->m_type ) + { + case CConditionNode::NOT : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::NOT; + + } + break; + + case CConditionNode::COMPARISON : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::COMPARISON; + + logicConditionNode->LogicBlock.ComparisonBlock.VariableName = tStrToUtf8(conditionNode->m_sVariableName); + logicConditionNode->LogicBlock.ComparisonBlock.Operator = tStrToUtf8(conditionNode->m_sOperator); + logicConditionNode->LogicBlock.ComparisonBlock.Comparand = (sint64)conditionNode->m_dComparand; + } + break; + + case CConditionNode::SUB_CONDITION : + { + logicConditionNode->LogicBlock.Type = CLogicConditionLogicBlock::SUB_CONDITION; + + logicConditionNode->LogicBlock.SubCondition = tStrToUtf8(conditionNode->m_sConditionName); + } + break; + } + + // part 2 : a condition sub tree + POSITION pos; + for( pos = conditionNode->m_ctSubTree.GetHeadPosition(); pos != NULL; ) + { + CConditionNode * pConditionNode = conditionNode->m_ctSubTree.GetNext( pos ); + CLogicConditionNode * logicConditionNodeTmp = new CLogicConditionNode(); + cConditionNodeToCLogicConditionNode( pConditionNode, logicConditionNodeTmp ); + logicConditionNode->addNode( logicConditionNodeTmp ); + } + } + +} // cConditionNodeToCLogicConditionNode // + + + + +//----------------------------------------------------- +// cConditionToCLogicCondition (Editor --> Service) +// +//----------------------------------------------------- +void cConditionToCLogicCondition( CCondition& condition, CLogicCondition& logicCondition ) +{ + // condition name + logicCondition.setName(tStrToUtf8(condition.m_sName)); + + // nodes + POSITION pos; + for( pos = condition.m_ctConditionTree.GetHeadPosition(); pos != NULL; ) + { + // get the node + CConditionNode * pConditionNode = condition.m_ctConditionTree.GetNext( pos ); + + // convert the node + CLogicConditionNode * logicConditionNode = new CLogicConditionNode(); + cConditionNodeToCLogicConditionNode( pConditionNode, logicConditionNode ); + + // add the node + logicCondition.addNode( *logicConditionNode ); + } + +} // cConditionToCLogicCondition // + + + + + + +//----------------------------------------------------- +// cLogicConditionNodeToCConditionNode (Service --> Editor) +// +//----------------------------------------------------- +void cLogicConditionNodeToCConditionNode( const CLogicConditionNode * logicConditionNode, CConditionNode * node ) +{ + // terminator node + if(logicConditionNode->Type == CLogicConditionNode::TERMINATOR) + { + node->m_type = CConditionNode::TERMINATOR; + } + // logic block with condition sub tree + else + { + // part 1 : a logic block(not/comparison/subcondition) + switch( logicConditionNode->LogicBlock.Type ) + { + case CLogicConditionLogicBlock::NOT : + { + node->m_type = CConditionNode::NOT; + }; + break; + + case CLogicConditionLogicBlock::COMPARISON : + { + node->m_type = CConditionNode::COMPARISON; + + node->m_sVariableName = CString(logicConditionNode->LogicBlock.ComparisonBlock.VariableName.c_str()); + node->m_sOperator = CString(logicConditionNode->LogicBlock.ComparisonBlock.Operator.c_str()); + node->m_dComparand = (double)logicConditionNode->LogicBlock.ComparisonBlock.Comparand; + + }; + break; + + case CLogicConditionLogicBlock::SUB_CONDITION : + { + node->m_type = CConditionNode::SUB_CONDITION; + node->m_sConditionName = CString(logicConditionNode->LogicBlock.SubCondition.c_str()); + }; + break; + + default : + { + node->m_type = CConditionNode::TERMINATOR; + } + + } + + // part 2 : a condition sub tree + vector::const_iterator itNode; + for( itNode = logicConditionNode->_Nodes.begin(); itNode != logicConditionNode->_Nodes.end(); ++itNode ) + { + CConditionNode * nodeTmp = new CConditionNode(); + cLogicConditionNodeToCConditionNode( *itNode, nodeTmp ); + nodeTmp->m_pParentNode = node; + node->m_ctSubTree.AddTail( nodeTmp ); + } + + } + +} // cLogicConditionNodeToCConditionNode // + + + + +//----------------------------------------------- +// cLogicConditionToCCondition +// +//----------------------------------------------- +void cLogicConditionToCCondition( const CLogicCondition& logicCondition, CCondition& condition ) +{ + // condition name + condition.m_sName = CString( logicCondition.getName().c_str() ); + + // condition tree + vector::const_iterator itNode; + for( itNode = logicCondition.Nodes.begin(); itNode != logicCondition.Nodes.end(); ++itNode ) + { + // convert the node + CConditionNode * node = new CConditionNode(); + cLogicConditionNodeToCConditionNode( &(*itNode), node ); + + // add the node + condition.m_ctConditionTree.AddTail( node ); + } + +} // cLogicConditionToCCondition // + + diff --git a/code/nel/tools/logic/logic_editor_dll/ConditionPage.cpp b/code/nel/tools/logic/logic_editor_dll/ConditionPage.cpp index 60beeec25..e7a4b1567 100644 --- a/code/nel/tools/logic/logic_editor_dll/ConditionPage.cpp +++ b/code/nel/tools/logic/logic_editor_dll/ConditionPage.cpp @@ -272,7 +272,7 @@ void CConditionPage::addCondition( CLogic_editorDoc *pDoc, CCondition * conditio CCondition *pCondition; if (pDoc->m_conditions.Lookup( condition->m_sName, (void*&)pCondition)) { - AfxMessageBox("A condition with this name already exist..."); + AfxMessageBox(_T("A condition with this name already exist...")); return; } @@ -296,7 +296,7 @@ void CConditionPage::OnButtonAddCondition() if (m_sConditionName.IsEmpty()) { - AfxMessageBox("Condition Name cannot be empty, please choose a name"); + AfxMessageBox(_T("Condition Name cannot be empty, please choose a name")); return; } @@ -326,7 +326,7 @@ void CConditionPage::OnButtonAddNode() // check that data are valid if ( checkNodeValidity() == FALSE) { - AfxMessageBox("Invalid node datas - cannot add node"); + AfxMessageBox(_T("Invalid node datas - cannot add node")); return; } @@ -426,7 +426,7 @@ void CConditionPage::OnButtonCondApply() if (m_sConditionName.IsEmpty()) { - AfxMessageBox("Condition Name cannot be empty, please choose a name"); + AfxMessageBox(_T("Condition Name cannot be empty, please choose a name")); return; } @@ -442,7 +442,7 @@ void CConditionPage::OnButtonCondApply() } else { - AfxMessageBox( "No condition selected ! Choose a condition first" ); + AfxMessageBox(_T("No condition selected ! Choose a condition first")); } } @@ -466,7 +466,7 @@ void CConditionPage::OnButtonDeleteCondition() } else { - AfxMessageBox( "No condition selected ! Choose a condition first" ); + AfxMessageBox(_T("No condition selected ! Choose a condition first")); } } @@ -477,7 +477,7 @@ void CConditionPage::OnButtonNodeApply() // check that data are valid if ( checkNodeValidity() == FALSE) { - AfxMessageBox("Invalid node datas - cancel node modification"); + AfxMessageBox(_T("Invalid node datas - cancel node modification")); return; } @@ -517,7 +517,7 @@ void CConditionPage::OnButtonNodeApply() } else { - AfxMessageBox( "No condition node selected ! Choose a node first" ); + AfxMessageBox(_T("No condition node selected ! Choose a node first")); } } @@ -553,6 +553,6 @@ void CConditionPage::OnButtonDeleteNode() } else { - AfxMessageBox( "No condition node selected ! Choose a node first" ); + AfxMessageBox(_T("No condition node selected ! Choose a node first")); } } diff --git a/code/nel/tools/logic/logic_editor_dll/ConditionsView.cpp b/code/nel/tools/logic/logic_editor_dll/ConditionsView.cpp index 5cab8c7ff..a9750d456 100644 --- a/code/nel/tools/logic/logic_editor_dll/ConditionsView.cpp +++ b/code/nel/tools/logic/logic_editor_dll/ConditionsView.cpp @@ -246,7 +246,7 @@ void CConditionsView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) TPositionList heap; - HTREEITEM hItem = m_tree.InsertItem( "Conditions",0,0); + HTREEITEM hItem = m_tree.InsertItem(_T("Conditions"), 0, 0); // get the states map CCondition *pCondition; @@ -645,7 +645,7 @@ void CConditionsView::OnMoveAsChild() } else { - AfxMessageBox("Error : root condition not found"); + AfxMessageBox(_T("Error : root condition not found")); delete pDragNode; } } @@ -722,7 +722,7 @@ void CConditionsView::OnCopyAsChild() } else { - AfxMessageBox("Error : root condition not found"); + AfxMessageBox(_T("Error : root condition not found")); delete pNewNode; } } diff --git a/code/nel/tools/logic/logic_editor_dll/Counter.cpp b/code/nel/tools/logic/logic_editor_dll/Counter.cpp index a7f62823f..52537ea08 100644 --- a/code/nel/tools/logic/logic_editor_dll/Counter.cpp +++ b/code/nel/tools/logic/logic_editor_dll/Counter.cpp @@ -45,7 +45,7 @@ CCounter::~CCounter() void cCounterToCLogicCounter( CCounter& counter, CLogicCounter& logicCounter ) { // counter name - logicCounter.setName( string((LPCSTR)counter.m_sName) ); + logicCounter.setName(tStrToUtf8(counter.m_sName)); // running mode if( counter.m_sMode == "Shuttle" ) diff --git a/code/nel/tools/logic/logic_editor_dll/CounterPage.cpp b/code/nel/tools/logic/logic_editor_dll/CounterPage.cpp index c706114b5..8ca41516d 100644 --- a/code/nel/tools/logic/logic_editor_dll/CounterPage.cpp +++ b/code/nel/tools/logic/logic_editor_dll/CounterPage.cpp @@ -194,7 +194,7 @@ void CCounterPage::OnButtonCounterRemove() } else { - AfxMessageBox( "No counter selected ! Choose a counter first"); + AfxMessageBox(_T("No counter selected ! Choose a counter first")); } } @@ -237,7 +237,7 @@ void CCounterPage::OnButtonCounterApply() } else { - AfxMessageBox( "No counter selected ! Choose a counter first"); + AfxMessageBox(_T("No counter selected ! Choose a counter first")); } } diff --git a/code/nel/tools/logic/logic_editor_dll/EditorFormView.cpp b/code/nel/tools/logic/logic_editor_dll/EditorFormView.cpp index 1fea05476..8380ad163 100644 --- a/code/nel/tools/logic/logic_editor_dll/EditorFormView.cpp +++ b/code/nel/tools/logic/logic_editor_dll/EditorFormView.cpp @@ -76,7 +76,7 @@ void CEditorFormView::OnInitialUpdate() CRect rectPlaceholder; GetWindowRect(rectPlaceholder); - m_pPropertySheet = new CEditorPropertySheet("",this); + m_pPropertySheet = new CEditorPropertySheet(_T(""),this); if (!m_pPropertySheet->Create(this,WS_CHILD | WS_VISIBLE, 0) ) { diff --git a/code/nel/tools/logic/logic_editor_dll/MainFrm.cpp b/code/nel/tools/logic/logic_editor_dll/MainFrm.cpp index 3c4b57729..1f3751265 100644 --- a/code/nel/tools/logic/logic_editor_dll/MainFrm.cpp +++ b/code/nel/tools/logic/logic_editor_dll/MainFrm.cpp @@ -114,7 +114,7 @@ void CMainFrame::OnClose() // load // //----------------------------------------------- -void CMainFrame::load( const char * fileName ) +void CMainFrame::load( const TCHAR * fileName ) { // child frame CChildFrame *pChild = (CChildFrame *) GetActiveFrame(); diff --git a/code/nel/tools/logic/logic_editor_dll/MainFrm.h b/code/nel/tools/logic/logic_editor_dll/MainFrm.h index bafe828c7..966bda122 100644 --- a/code/nel/tools/logic/logic_editor_dll/MainFrm.h +++ b/code/nel/tools/logic/logic_editor_dll/MainFrm.h @@ -36,7 +36,7 @@ public: /** * load a logic state machine */ - void load( const char * fileName ); + void load( const TCHAR *fileName ); #ifdef _DEBUG virtual void AssertValid() const; diff --git a/code/nel/tools/logic/logic_editor_dll/State.cpp b/code/nel/tools/logic/logic_editor_dll/State.cpp index 1cf6065cf..fbfdebb2d 100644 --- a/code/nel/tools/logic/logic_editor_dll/State.cpp +++ b/code/nel/tools/logic/logic_editor_dll/State.cpp @@ -70,7 +70,7 @@ bool operator==( const CEvent &ev1, const CEvent &ev2) void cEventToCLogicEvent( CEvent& event, CLogicEvent& logicEvent ) { /// condition name - logicEvent.ConditionName = string( (LPCSTR)event.m_sConditionName ); + logicEvent.ConditionName = tStrToUtf8(event.m_sConditionName); /// event action logicEvent.EventAction.IsStateChange = !event.m_bActionIsMessage; @@ -78,18 +78,18 @@ void cEventToCLogicEvent( CEvent& event, CLogicEvent& logicEvent ) if( logicEvent.EventAction.IsStateChange ) { /// state name for state change - logicEvent.EventAction.StateChange = string( (LPCSTR)event.m_sStateChange ); + logicEvent.EventAction.StateChange = tStrToUtf8(event.m_sStateChange); } else { /// message destination - logicEvent.EventAction.EventMessage.Destination = string( (LPCSTR)event.m_sMessageDestination ); + logicEvent.EventAction.EventMessage.Destination = tStrToUtf8(event.m_sMessageDestination); /// message id logicEvent.EventAction.EventMessage.MessageId = "LOGIC"; //string( (LPCSTR)event.m_sMessageID ); //TEMP!!! /// message arguments - logicEvent.EventAction.EventMessage.Arguments = string( (LPCSTR)event.m_sArguments ); + logicEvent.EventAction.EventMessage.Arguments = tStrToUtf8(event.m_sArguments); } } // cEventToCLogicEvent // @@ -176,7 +176,7 @@ BOOL CState::removeEvent( CEvent *event) void cStateToCLogicState( CState& state, CLogicState& logicState ) { /// state name - logicState.setName( string( (LPCSTR)state.m_sName ) ); + logicState.setName(tStrToUtf8(state.m_sName)); POSITION pos; for( pos = state.m_evEvents.GetHeadPosition(); pos != NULL; ) diff --git a/code/nel/tools/logic/logic_editor_dll/StatePage.cpp b/code/nel/tools/logic/logic_editor_dll/StatePage.cpp index f3a414b0a..9135f274f 100644 --- a/code/nel/tools/logic/logic_editor_dll/StatePage.cpp +++ b/code/nel/tools/logic/logic_editor_dll/StatePage.cpp @@ -251,7 +251,7 @@ void CStatePage::OnButtonAddState() if (m_sStateName.IsEmpty()) { - AfxMessageBox("State name cannot be empty, please enter a valid name"); + AfxMessageBox(_T("State name cannot be empty, please enter a valid name")); return; } @@ -366,7 +366,7 @@ void CStatePage::OnButtonStateRemove() // get selected state if (m_pSelectedState != NULL) { - if (AfxMessageBox("Your are about to permanently delete this state.\nDoing so will invalidate all references to this state.\nDo you want to continue anyway ?" ,MB_OKCANCEL|MB_DEFBUTTON2) == IDOK) + if (AfxMessageBox(_T("Your are about to permanently delete this state.\nDoing so will invalidate all references to this state.\nDo you want to continue anyway ?") ,MB_OKCANCEL|MB_DEFBUTTON2) == IDOK) { CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; CChildFrame *pChild = (CChildFrame *) pFrame->GetActiveFrame(); @@ -384,7 +384,7 @@ void CStatePage::OnButtonStateRemove() } else { - AfxMessageBox( "No state selected ! Choose a state first" ); + AfxMessageBox(_T("No state selected ! Choose a state first")); } } @@ -399,11 +399,11 @@ void CStatePage::OnButtonStateApply() { if (m_sStateName.IsEmpty()) { - AfxMessageBox("State name cannot be empty, please enter a valid name"); + AfxMessageBox(_T("State name cannot be empty, please enter a valid name")); return; } - if (AfxMessageBox("Your are about to change this state name.\nDoing so will change all occurence of the old name to the new one.\nDo you want to continue anyway ?" ,MB_OKCANCEL|MB_DEFBUTTON2) == IDOK) + if (AfxMessageBox(_T("Your are about to change this state name.\nDoing so will change all occurence of the old name to the new one.\nDo you want to continue anyway ?") ,MB_OKCANCEL|MB_DEFBUTTON2) == IDOK) { CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; CChildFrame *pChild = (CChildFrame *) pFrame->GetActiveFrame(); @@ -418,14 +418,14 @@ void CStatePage::OnButtonStateApply() } else { - AfxMessageBox( "No state selected ! Choose a state first" ); + AfxMessageBox(_T("No state selected ! Choose a state first")); } } void CStatePage::OnButtonEventApply() { // TODO: Add your control notification handler code here - AfxMessageBox( "Features not implemented" ); + AfxMessageBox(_T("Features not implemented")); } void CStatePage::OnButtonEventRemove() @@ -447,6 +447,6 @@ void CStatePage::OnButtonEventRemove() } else { - AfxMessageBox( "No event selected ! Choose a event first" ); + AfxMessageBox(_T("No event selected ! Choose a event first")); } } diff --git a/code/nel/tools/logic/logic_editor_dll/StatesView.cpp b/code/nel/tools/logic/logic_editor_dll/StatesView.cpp index 4aa74c48d..e466b99d8 100644 --- a/code/nel/tools/logic/logic_editor_dll/StatesView.cpp +++ b/code/nel/tools/logic/logic_editor_dll/StatesView.cpp @@ -131,7 +131,7 @@ void CStatesView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) m_tree.DeleteAllItems(); m_mapItemToEvent.RemoveAll(); - m_tree.InsertItem( "States"); + m_tree.InsertItem(_T("States")); // get the states map CState *pState; diff --git a/code/nel/tools/logic/logic_editor_dll/VariablePage.cpp b/code/nel/tools/logic/logic_editor_dll/VariablePage.cpp index da9ad6991..ef87443b6 100644 --- a/code/nel/tools/logic/logic_editor_dll/VariablePage.cpp +++ b/code/nel/tools/logic/logic_editor_dll/VariablePage.cpp @@ -145,7 +145,7 @@ void CVariablePage::OnButtonVarDelete() } else { - AfxMessageBox( "No variable selected ! Choose a variable first" ); + AfxMessageBox(_T("No variable selected ! Choose a variable first")); } } @@ -178,7 +178,7 @@ void CVariablePage::OnButtonVarApply() } else { - AfxMessageBox( "No variable selected ! Choose a variable first" ); + AfxMessageBox(_T("No variable selected ! Choose a variable first")); } } diff --git a/code/nel/tools/logic/logic_editor_dll/logic_editor.cpp b/code/nel/tools/logic/logic_editor_dll/logic_editor.cpp index cd0c591b2..52e25fd7a 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editor.cpp +++ b/code/nel/tools/logic/logic_editor_dll/logic_editor.cpp @@ -321,7 +321,7 @@ void CLogicEditor::go() // loadFile // //--------------------------------------------- -void CLogicEditor::loadFile( const char * fileName ) +void CLogicEditor::loadFile( const TCHAR * fileName ) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); @@ -337,7 +337,7 @@ void CLogicEditor::loadFile( const char * fileName ) // create a default file // //--------------------------------------------- -void CLogicEditor::createDefaultFile( const char * fileName ) +void CLogicEditor::createDefaultFile( const TCHAR * fileName ) { // create an empty doc CLogic_editorDoc * pDoc = CLogic_editorDoc::getNewDoc(); @@ -402,7 +402,7 @@ ILogicEditor * ILogicEditor::getInterface( int version ) // Check version number if( version != LOGIC_EDITOR_VERSION ) { - MessageBox( NULL, "Bad version of logic_editor.dll.", "Logic Editor", MB_ICONEXCLAMATION|MB_OK); + MessageBox( NULL, _T("Bad version of logic_editor.dll."), _T("Logic Editor"), MB_ICONEXCLAMATION|MB_OK); return NULL; } else diff --git a/code/nel/tools/logic/logic_editor_dll/logic_editor.h b/code/nel/tools/logic/logic_editor_dll/logic_editor.h index 42dc19ee0..80b6e981b 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editor.h +++ b/code/nel/tools/logic/logic_editor_dll/logic_editor.h @@ -88,12 +88,12 @@ public: /** * load file */ - virtual void loadFile( const char * fileName ); + virtual void loadFile( const TCHAR * fileName ); /** * create a default file */ - virtual void createDefaultFile( const char * filename = "logic.logic "); + virtual void createDefaultFile( const TCHAR * filename = _T("logic.logic ")); /** diff --git a/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp b/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp index 0b91c41f4..de2e75e23 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp +++ b/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.cpp @@ -488,7 +488,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) { variable = m_variables.GetNext( pos ); CLogicVariable logicVariable; - logicVariable.setName( string((LPCSTR)variable) ); + logicVariable.setName(tStrToUtf8(variable)); logicStateMachine.addVariable( logicVariable ); } @@ -502,7 +502,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) CLogicCounter logicCounter; cCounterToCLogicCounter( *pCounter, logicCounter ); // set the logic counter name - logicCounter.setName( (LPCSTR)eltName ); + logicCounter.setName(tStrToUtf8(eltName)); // add the logic counter logicStateMachine.addCounter( logicCounter ); } @@ -517,7 +517,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) CLogicCondition logicCondition; cConditionToCLogicCondition( *pCondition, logicCondition ); // set the logic condition name - logicCondition.setName( (LPCSTR)eltName ); + logicCondition.setName(tStrToUtf8(eltName)); // add the logic condition logicStateMachine.addCondition( logicCondition ); } @@ -532,7 +532,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) CLogicState logicState; cStateToCLogicState( *pState, logicState ); // set the logic state's name - logicState.setName( (LPCSTR)eltName ); + logicState.setName(tStrToUtf8(eltName)); // add the logic state logicStateMachine.addState( logicState ); } @@ -542,14 +542,14 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) if(pos != NULL) { m_states.GetNextAssoc( pos, eltName, (void*&)pState ); - logicStateMachine.setCurrentState( string((LPCSTR)eltName) ); + logicStateMachine.setCurrentState(tStrToUtf8(eltName)); } else { - logicStateMachine.setCurrentState( string("") ); + logicStateMachine.setCurrentState(""); } // set the name of the state machine - logicStateMachine.setName( string(fileName) ); + logicStateMachine.setName(tStrToUtf8(fileName)); // Check exceptions @@ -559,7 +559,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) COFile file; // Open the file - file.open (fileName); + file.open (tStrToUtf8(fileName)); // Create the XML stream COXml output; @@ -578,7 +578,7 @@ BOOL CLogic_editorDoc::OnSaveDocument( LPCTSTR fileName ) // Close the file file.close (); } - catch (Exception &) + catch (const Exception &) { } @@ -625,7 +625,7 @@ BOOL CLogic_editorDoc::load( LPCTSTR fileName ) CIFile file; // Open the file - file.open (fileName); + file.open (tStrToUtf8(fileName)); // Create the XML stream CIXml xmlfileIn; @@ -646,7 +646,7 @@ BOOL CLogic_editorDoc::load( LPCTSTR fileName ) // Close the file file.close (); } - catch (Exception &) + catch (const Exception &) { } diff --git a/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.h b/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.h index 39fd90d7e..1fa9156a0 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.h +++ b/code/nel/tools/logic/logic_editor_dll/logic_editorDoc.h @@ -53,7 +53,7 @@ public: * change a variable name (all it's occurence) * \param CString old the old name of the var (not a reference because we may delete the string when deleting the variable !!) * \param CString &newName the new name of the var - * \return BOOL TRUE if the change has been made, FALSE if an error occured + * \return BOOL TRUE if the change has been made, FALSE if an error occurred */ BOOL changeVarName( CString old, const CString &newName); @@ -67,7 +67,7 @@ public: * change a counter name (all it's occurence) * \param CString old the old name of the counter * \param CString &newName the new name of the counter - * \return BOOL TRUE if the change has been made, FALSE if an error occured + * \return BOOL TRUE if the change has been made, FALSE if an error occurred */ BOOL changeCounterName( CString old, const CString &newName); @@ -82,7 +82,7 @@ public: * change a condition name (all it's occurence) * \param CString old the old name of the condition * \param CString &newName the new name of the condition - * \return BOOL TRUE if the change has been made, FALSE if an error occured + * \return BOOL TRUE if the change has been made, FALSE if an error occurred */ BOOL changeConditionName( CString old, const CString &newName); @@ -97,7 +97,7 @@ public: * change a state name (all it's occurence) * \param CString old the old name of the state * \param CString &newName the new name of the state - * \return BOOL TRUE if the change has been made, FALSE if an error occured + * \return BOOL TRUE if the change has been made, FALSE if an error occurred */ BOOL changeStateName( CString old, const CString &newName); diff --git a/code/nel/tools/logic/logic_editor_dll/logic_editor_interface.h b/code/nel/tools/logic/logic_editor_dll/logic_editor_interface.h index 4e48ceb6f..f2ac7c13a 100644 --- a/code/nel/tools/logic/logic_editor_dll/logic_editor_interface.h +++ b/code/nel/tools/logic/logic_editor_dll/logic_editor_interface.h @@ -54,10 +54,10 @@ public: virtual void*getMainFrame ()=0; // load a logic file - virtual void loadFile( const char * fileName ) = 0; + virtual void loadFile( const TCHAR * fileName ) = 0; // create a default file - virtual void createDefaultFile( const char * filename = "logic.logic ") = 0; + virtual void createDefaultFile( const TCHAR * filename = _T("logic.logic ")) = 0; // Get instance static LOGIC_EDITOR_EXPORT ILogicEditor * getInterface( int version = LOGIC_EDITOR_VERSION ); diff --git a/code/nel/tools/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..c27111935 100644 --- a/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp +++ b/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp @@ -92,14 +92,14 @@ BOOL CBranch_patcherDlg::OnInitDialog() SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon - + // Extra initialization here RECT cltRect; - GetClientRect( &cltRect ), - m_Display = new CRichEditCtrl(); - m_Display->Create( WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|ES_AUTOHSCROLL|ES_AUTOVSCROLL|ES_MULTILINE, - CRect( 20, 180, cltRect.right-20, cltRect.bottom-20 ), this, 1 ); + GetClientRect(&cltRect), + m_Display = new CRichEditCtrl(); + m_Display->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, + CRect(20, 180, cltRect.right - 20, cltRect.bottom - 20), this, 1); // Initialize directories loadConfiguration(); @@ -109,8 +109,8 @@ BOOL CBranch_patcherDlg::OnInitDialog() EnteringTokens = false; m_SrcDirLabel = "Source Dir"; m_TargetDirLabel = "Target Dir"; - UpdateData( false ); - ((CButton*)GetDlgItem( IDC_DoPatch ))->EnableWindow( FALSE ); + UpdateData(false); + ((CButton*)GetDlgItem(IDC_DoPatch))->EnableWindow(FALSE); return TRUE; // return TRUE unless you set the focus to a control } @@ -119,13 +119,13 @@ BOOL CBranch_patcherDlg::OnInitDialog() // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. -void CBranch_patcherDlg::OnPaint() +void CBranch_patcherDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); + SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); @@ -146,38 +146,38 @@ void CBranch_patcherDlg::OnPaint() HCURSOR CBranch_patcherDlg::OnQueryDragIcon() { - return (HCURSOR) m_hIcon; + return (HCURSOR)m_hIcon; } -void CBranch_patcherDlg::setSrcDirectory( const CString& s ) +void CBranch_patcherDlg::setSrcDirectory(const CString& s) { m_SrcDir = s; - UpdateData( false ); + UpdateData(false); } -void CBranch_patcherDlg::setDestDirectory( const CString& s ) +void CBranch_patcherDlg::setDestDirectory(const CString& s) { m_DestDir = s; - UpdateData( false ); + UpdateData(false); } -void CBranch_patcherDlg::OnButtonSetSrcDir() +void CBranch_patcherDlg::OnButtonSetSrcDir() { DirDialog.m_strTitle = "Please choose the SOURCE directory"; - if ( DirDialog.DoBrowse() == TRUE ) + if (DirDialog.DoBrowse() == TRUE) { - setSrcDirectory( DirDialog.m_strPath ); + setSrcDirectory(DirDialog.m_strPath); guessDestDirectory(); } } -void CBranch_patcherDlg::OnButtonSetDestDir() +void CBranch_patcherDlg::OnButtonSetDestDir() { DirDialog.m_strTitle = "Please choose the TARGET directory"; - if ( DirDialog.DoBrowse() == TRUE ) + if (DirDialog.DoBrowse() == TRUE) { - setDestDirectory( DirDialog.m_strPath ); + setDestDirectory(DirDialog.m_strPath); } } @@ -198,80 +198,86 @@ CDirDialog::~CDirDialog() } -int CDirDialog::DoBrowse () +int CDirDialog::DoBrowse() {///////////////////////////////////////// - LPMALLOC pMalloc; - if (SHGetMalloc (&pMalloc)!= NOERROR) - { - return 0; - } + LPMALLOC pMalloc; + if (SHGetMalloc(&pMalloc) != NOERROR) + { + return 0; + } - BROWSEINFO bInfo; - LPITEMIDLIST pidl; - ZeroMemory ( (PVOID) &bInfo,sizeof (BROWSEINFO)); + BROWSEINFO bInfo; + LPITEMIDLIST pidl; + ZeroMemory((PVOID)&bInfo, sizeof(BROWSEINFO)); - if (!m_strInitDir.IsEmpty ()) - { - OLECHAR olePath[MAX_PATH]; - ULONG chEaten; - ULONG dwAttributes; - HRESULT hr; - LPSHELLFOLDER pDesktopFolder; - // // Get a pointer to the Desktop's IShellFolder interface. // - if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder))) - { + if (!m_strInitDir.IsEmpty()) + { + OLECHAR olePath[MAX_PATH]; + ULONG chEaten; + ULONG dwAttributes; + HRESULT hr; + LPSHELLFOLDER pDesktopFolder; + // // Get a pointer to the Desktop's IShellFolder interface. // + if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder))) + { +#ifndef _UNICODE + // + // IShellFolder::ParseDisplayName requires the file name be in Unicode. + // + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, m_strInitDir.GetBuffer(MAX_PATH), -1, olePath, MAX_PATH); - // - // IShellFolder::ParseDisplayName requires the file name be in Unicode. - // - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, m_strInitDir.GetBuffer (MAX_PATH), -1, - olePath, MAX_PATH); + m_strInitDir.ReleaseBuffer(-1); +#else + wcscpy(olePath, (LPCTSTR)m_strInitDir); +#endif + // + // Convert the path to an ITEMIDLIST. + // + hr = pDesktopFolder->ParseDisplayName(NULL, + NULL, + olePath, + &chEaten, + &pidl, + &dwAttributes); - m_strInitDir.ReleaseBuffer (-1); - // - // Convert the path to an ITEMIDLIST. - // - hr = pDesktopFolder->ParseDisplayName(NULL, - NULL, - olePath, - &chEaten, - &pidl, - &dwAttributes); - if (FAILED(hr)) - { - pMalloc ->Free (pidl); - pMalloc ->Release (); - return 0; - } - bInfo.pidlRoot = pidl; - } - } - bInfo.hwndOwner = NULL; - bInfo.pszDisplayName = m_strPath.GetBuffer (MAX_PATH); - bInfo.lpszTitle = (m_strTitle.IsEmpty()) ? "Open":m_strTitle; - bInfo.ulFlags = BIF_RETURNFSANCESTORS|BIF_RETURNONLYFSDIRS; + if (FAILED(hr)) + { + pMalloc->Free(pidl); + pMalloc->Release(); + return 0; + } + bInfo.pidlRoot = pidl; - if ((pidl = ::SHBrowseForFolder (&bInfo)) == NULL) - { - return 0; - } - m_strPath.ReleaseBuffer (); - m_iImageIndex = bInfo.iImage; + } + } - if (::SHGetPathFromIDList(pidl,m_strPath.GetBuffer (MAX_PATH)) == FALSE) - { - pMalloc ->Free (pidl); - pMalloc ->Release (); - return 0; - } + bInfo.hwndOwner = NULL; + bInfo.pszDisplayName = m_strPath.GetBuffer(MAX_PATH); + bInfo.lpszTitle = (m_strTitle.IsEmpty()) ? "Open" : m_strTitle; + bInfo.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; - m_strPath.ReleaseBuffer (); + if ((pidl = ::SHBrowseForFolder(&bInfo)) == NULL) + { + return 0; + } - pMalloc ->Free (pidl); - pMalloc ->Release (); - return 1; + m_strPath.ReleaseBuffer(); + m_iImageIndex = bInfo.iImage; + + if (::SHGetPathFromIDList(pidl, m_strPath.GetBuffer(MAX_PATH)) == FALSE) + { + pMalloc->Free(pidl); + pMalloc->Release(); + return 0; + } + + m_strPath.ReleaseBuffer(); + + pMalloc->Free(pidl); + pMalloc->Release(); + return 1; } @@ -280,87 +286,87 @@ int CDirDialog::DoBrowse () */ BOOL SendTextToClipboard(CString source) { - // Return value is TRUE if the text was sent - // Return value is FALSE if something went wrong - if(OpenClipboard(NULL)) - { - HGLOBAL clipbuffer; - char* buffer; + // Return value is TRUE if the text was sent + // Return value is FALSE if something went wrong + if (OpenClipboard(NULL)) + { + HGLOBAL clipbuffer; + char* buffer; - EmptyClipboard(); // Empty whatever's already there + EmptyClipboard(); // Empty whatever's already there - clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1); - buffer = (char*)GlobalLock(clipbuffer); - strcpy(buffer, LPCSTR(source)); - GlobalUnlock(clipbuffer); + clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength() + 1); + buffer = (char*)GlobalLock(clipbuffer); + strcpy(buffer, LPCSTR(source)); + GlobalUnlock(clipbuffer); - SetClipboardData(CF_TEXT, clipbuffer); // Send the data + SetClipboardData(CF_TEXT, clipbuffer); // Send the data - CloseClipboard(); // VERY IMPORTANT - return TRUE; - } - return FALSE; + CloseClipboard(); // VERY IMPORTANT + return TRUE; + } + return FALSE; } -void CBranch_patcherDlg::displayMessage( const CString& msg, bool insertAtTop ) +void CBranch_patcherDlg::displayMessage(const CString& msg, bool insertAtTop) { - if ( insertAtTop ) - m_Display->SetSel( 0, 0 ); + if (insertAtTop) + m_Display->SetSel(0, 0); else - m_Display->SetSel( 0, -1 ); - m_Display->ReplaceSel( msg ); + m_Display->SetSel(0, -1); + m_Display->ReplaceSel(msg); SaveDiff = false; } -void CBranch_patcherDlg::OnButtonPatch() +void CBranch_patcherDlg::OnButtonPatch() { - UpdateData( true ); + UpdateData(true); CString diffCmdLine; - diffCmdLine.Format( "cvs.exe diff -c > %s 2> %s", TEMP_DIFF_FILE, DIFF_ERRORS ); // needs a valid cvs login before! and cvs.exe in the path + diffCmdLine.Format(_T("cvs.exe diff -c > %s 2> %s"), TEMP_DIFF_FILE, DIFF_ERRORS); // needs a valid cvs login before! and cvs.exe in the path CString text; - text.Format( "Get diff from directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s", m_SrcDir, diffCmdLine ); + text.Format(_T("Get diff from directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s"), m_SrcDir, diffCmdLine); int result; - if ( (result = ::MessageBox( m_hWnd, text, "Confirmation", MB_YESNOCANCEL | MB_ICONQUESTION )) == IDYES ) + if ((result = ::MessageBox(m_hWnd, text, "Confirmation", MB_YESNOCANCEL | MB_ICONQUESTION)) == IDYES) { - if ( _chdir( m_SrcDir ) == 0 ) + if (_chdir(m_SrcDir) == 0) { - system( diffCmdLine ); - displayFile( TEMP_DIFF_FILE ); + system(diffCmdLine); + displayFile(TEMP_DIFF_FILE); SaveDiff = true; colorizeDiff(); - m_Display->LineScroll( 0 ); - ((CButton*)GetDlgItem( IDC_DoPatch ))->EnableWindow( TRUE ); + m_Display->LineScroll(0); + ((CButton*)GetDlgItem(IDC_DoPatch))->EnableWindow(TRUE); - if ( (m_Display->GetLineCount() == 0) || - (m_Display->GetLineCount() == 1 && m_Display->LineLength(0)<2) ) + if ((m_Display->GetLineCount() == 0) || + (m_Display->GetLineCount() == 1 && m_Display->LineLength(0) < 2)) { - displayFile( DIFF_ERRORS ); - displayMessage( "Diff is empty.\r\nIf this is not the expected result:\r\n- check if the source directory is part of a CVS tree\r\n- check if cvs.exe is in your PATH\r\n- check if you are logged to the cvs server with 'cvs login' (set your home cvs directory in the HOME environment variable if needed)\r\n- check if C:\\ has enough free space and access rights to write a file.\n\nHere is the log:\n\n", true ); + displayFile(DIFF_ERRORS); + displayMessage("Diff is empty.\r\nIf this is not the expected result:\r\n- check if the source directory is part of a CVS tree\r\n- check if cvs.exe is in your PATH\r\n- check if you are logged to the cvs server with 'cvs login' (set your home cvs directory in the HOME environment variable if needed)\r\n- check if C:\\ has enough free space and access rights to write a file.\n\nHere is the log:\n\n", true); } else { m_Filename = TEMP_DIFF_FILE + ":"; - UpdateData( false ); + UpdateData(false); } } else { - displayMessage( "Source directory not found" ); + displayMessage("Source directory not found"); } } - else if ( result == IDNO ) + else if (result == IDNO) { - SendTextToClipboard( diffCmdLine ); + SendTextToClipboard(diffCmdLine); } } static unsigned long CALLBACK MyStreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { - CFile* pFile = (CFile*) dwCookie; + CFile* pFile = (CFile*)dwCookie; *pcb = pFile->Read(pbBuff, cb); return 0; } @@ -368,144 +374,144 @@ static unsigned long CALLBACK MyStreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBu static unsigned long CALLBACK MyStreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { - CFile* pFile = (CFile*) dwCookie; + CFile* pFile = (CFile*)dwCookie; pFile->Write(pbBuff, cb); *pcb = cb; return 0; } -void CBranch_patcherDlg::displayFile( const CString& filename ) +void CBranch_patcherDlg::displayFile(const CString& filename) { - CFile cFile( filename, CFile::modeRead ); + CFile cFile(filename, CFile::modeRead); EDITSTREAM es; - es.dwCookie = (DWORD_PTR) &cFile; + es.dwCookie = (DWORD_PTR)&cFile; es.pfnCallback = MyStreamInCallback; - m_Display->StreamIn( SF_TEXT, es ); + m_Display->StreamIn(SF_TEXT, es); } -void CBranch_patcherDlg::saveFile( const CString& filename ) +void CBranch_patcherDlg::saveFile(const CString& filename) { - CFile cFile( filename, CFile::modeCreate | CFile::modeWrite ); + CFile cFile(filename, CFile::modeCreate | CFile::modeWrite); EDITSTREAM es; - es.dwCookie = (DWORD_PTR) &cFile; - es.pfnCallback = MyStreamOutCallback; - m_Display->StreamOut( SF_TEXT, es ); + es.dwCookie = (DWORD_PTR)&cFile; + es.pfnCallback = MyStreamOutCallback; + m_Display->StreamOut(SF_TEXT, es); } void CBranch_patcherDlg::colorizeDiff() { CHARFORMAT blue; - ZeroMemory( &blue, sizeof(blue) ); + ZeroMemory(&blue, sizeof(blue)); blue.cbSize = sizeof(blue); blue.dwMask = CFM_COLOR; - blue.crTextColor = RGB(0,0,0xFF); + blue.crTextColor = RGB(0, 0, 0xFF); CHARFORMAT red; - ZeroMemory( &red, sizeof(red) ); + ZeroMemory(&red, sizeof(red)); red.cbSize = sizeof(red); red.dwMask = CFM_COLOR; - red.crTextColor = RGB(0xFF,0,0); + red.crTextColor = RGB(0xFF, 0, 0); CHARFORMAT green; - ZeroMemory( &green, sizeof(green) ); + ZeroMemory(&green, sizeof(green)); green.cbSize = sizeof(green); green.dwMask = CFM_COLOR; - green.crTextColor = RGB(0,0x7F,0); - for ( int i=0; i!=m_Display->GetLineCount(); ++i ) + green.crTextColor = RGB(0, 0x7F, 0); + for (int i = 0; i != m_Display->GetLineCount(); ++i) { - int c = m_Display->LineIndex( i ); - int l = m_Display->LineLength( c ); - m_Display->SetSel( c, c+l ); + int c = m_Display->LineIndex(i); + int l = m_Display->LineLength(c); + m_Display->SetSel(c, c + l); CString s = m_Display->GetSelText(); - if ( ! s.IsEmpty() ) + if (!s.IsEmpty()) { - if ( s.Left(2) == "+ " ) + if (s.Left(2) == "+ ") { - m_Display->SetSelectionCharFormat( blue ); + m_Display->SetSelectionCharFormat(blue); } - else if ( s.Left(2) == "- " ) + else if (s.Left(2) == "- ") { - m_Display->SetSelectionCharFormat( red ); + m_Display->SetSelectionCharFormat(red); } - else if ( s.Left(2) == "! " ) + else if (s.Left(2) == "! ") { - m_Display->SetSelectionCharFormat( green ); + m_Display->SetSelectionCharFormat(green); } } } } -void CBranch_patcherDlg::OnDoPatch() +void CBranch_patcherDlg::OnDoPatch() { - UpdateData( true ); - - if ( SaveDiff ) + UpdateData(true); + + if (SaveDiff) { // Save the diff from the richedit - saveFile( TEMP_DIFF_FILE ); + saveFile(TEMP_DIFF_FILE); } // Apply the patch CString patchCmdLine, concatOutput, delPatchErrors; - patchCmdLine.Format( "%spatch.exe -c -p%u --verbose < %s > %s 2> %s", PatchExeDir, CvsDiffDirLevel, TEMP_DIFF_FILE, PATCH_RESULT, PATCH_ERRORS ); // needs patch.exe in the path - concatOutput.Format( "copy %s+%s %s", PATCH_RESULT, PATCH_ERRORS, PATCH_RESULT ); - delPatchErrors.Format( "del %s", PATCH_ERRORS ); + patchCmdLine.Format(_T("%spatch.exe -c -p%u --verbose < %s > %s 2> %s"), PatchExeDir, CvsDiffDirLevel, TEMP_DIFF_FILE, PATCH_RESULT, PATCH_ERRORS); // needs patch.exe in the path + concatOutput.Format(_T("copy %s+%s %s"), PATCH_RESULT, PATCH_ERRORS, PATCH_RESULT); + delPatchErrors.Format(_T("del %s"), PATCH_ERRORS); CString text; - text.Format( "Patch diff to directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s", m_DestDir, patchCmdLine ); + text.Format(_T("Patch diff to directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s"), (LPCTSTR)m_DestDir, (LPCTSTR)patchCmdLine); int result; - if ( (result = ::MessageBox( m_hWnd, text, "Confirmation", MB_YESNOCANCEL | MB_ICONQUESTION )) == IDYES ) + if ((result = ::MessageBox(m_hWnd, text, _T("Confirmation"), MB_YESNOCANCEL | MB_ICONQUESTION)) == IDYES) { - if ( _chdir( m_DestDir ) == 0 ) + if (_chdir(m_DestDir) == 0) { - system( patchCmdLine ); - system( concatOutput ); - system( delPatchErrors ); - displayFile( PATCH_RESULT ); + system(patchCmdLine); + system(concatOutput); + system(delPatchErrors); + displayFile(PATCH_RESULT); SaveDiff = false; - m_Display->LineScroll( 0 ); + m_Display->LineScroll(0); - if ( (m_Display->GetLineCount() == 0) || - (m_Display->GetLineCount() == 1 && m_Display->LineLength(0)<2) ) + if ((m_Display->GetLineCount() == 0) || + (m_Display->GetLineCount() == 1 && m_Display->LineLength(0) < 2)) { CString s; - s.Format( "Nothing was patched.\r\nIf this is not the expected result:\r\n- check if the good patch.exe is in %s\r\n- check if %s exists (generated by previous diff)\r\n- check if C:\\ has enough free space and access rights to write a file.", TEMP_DIFF_FILE ); - displayMessage( s ); + s.Format(_T("Nothing was patched.\r\nIf this is not the expected result:\r\n- check if the good patch.exe is in %s\r\n- check if %s exists (generated by previous diff)\r\n- check if C:\\ has enough free space and access rights to write a file."), TEMP_DIFF_FILE); + displayMessage(s); } else { m_Filename = PATCH_RESULT + ":"; - UpdateData( false ); + UpdateData(false); } } else { - displayMessage( "Target directory not found" ); + displayMessage("Target directory not found"); } } - else if ( result == IDNO ) + else if (result == IDNO) { - SendTextToClipboard( patchCmdLine ); + SendTextToClipboard(patchCmdLine); } } -void CBranch_patcherDlg::OnSize(UINT nType, int cx, int cy) +void CBranch_patcherDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); - - if ( m_Display ) + + if (m_Display) { RECT cltRect; - GetClientRect( &cltRect ); + GetClientRect(&cltRect); CRect dispRect; - m_Display->MoveWindow( 20, 180, cltRect.right-40, cltRect.bottom-200, true ); + m_Display->MoveWindow(20, 180, cltRect.right - 40, cltRect.bottom - 200, true); } } -void CBranch_patcherDlg::OnClose() +void CBranch_patcherDlg::OnClose() { saveConfiguration(); @@ -516,10 +522,10 @@ void CBranch_patcherDlg::OnClose() void CBranch_patcherDlg::processCommandLine() { CString cmdLine = theApp.m_lpCmdLine; - - if ( ! cmdLine.IsEmpty() ) + + if (!cmdLine.IsEmpty()) { - setSrcDirectory( cmdLine ); + setSrcDirectory(cmdLine); guessDestDirectory(); } } @@ -527,18 +533,18 @@ void CBranch_patcherDlg::processCommandLine() void CBranch_patcherDlg::guessDestDirectory() { - if ( hasTokens() ) + if (hasTokens()) { CString dir = m_SrcDir; - if ( dir.Find( "\\"+Token1+"\\", 0 ) != -1 ) + if (dir.Find("\\" + Token1 + "\\", 0) != -1) { - dir.Replace( "\\"+Token1+"\\", "\\"+Token2+"\\" ); - setDestDirectory( dir ); + dir.Replace("\\" + Token1 + "\\", "\\" + Token2 + "\\"); + setDestDirectory(dir); } - else if ( dir.Find( "\\"+Token2+"\\", 0 ) != -1 ) + else if (dir.Find("\\" + Token2 + "\\", 0) != -1) { - dir.Replace( "\\"+Token2+"\\", "\\"+Token1+"\\" ); - setDestDirectory( dir ); + dir.Replace("\\" + Token2 + "\\", "\\" + Token1 + "\\"); + setDestDirectory(dir); } } } @@ -548,51 +554,51 @@ void CBranch_patcherDlg::extractDirTokens() { int beginOfToken1, beginOfToken2, endOfToken1, endOfToken2; CString text; - UpdateData( true ); + UpdateData(true); // Search backward from the end until a different substring is found - int c1 = m_SrcDir.GetLength()-1; - int c2 = m_DestDir.GetLength()-1; - while ( (c1 >= 0) && (c2 >= 0) && (m_SrcDir[c1] == m_DestDir[c2]) ) + int c1 = m_SrcDir.GetLength() - 1; + int c2 = m_DestDir.GetLength() - 1; + while ((c1 >= 0) && (c2 >= 0) && (m_SrcDir[c1] == m_DestDir[c2])) { --c1; --c2; } - + // Test if both strings are identical - if ( (c1 < 0) || (c2 < 0) ) + if ((c1 < 0) || (c2 < 0)) { Token1 = m_SrcDir; Token2 = m_DestDir; return; } - endOfToken1 = c1+1; - endOfToken2 = c2+1; + endOfToken1 = c1 + 1; + endOfToken2 = c2 + 1; // Search forward from the beginning until a different substring is found c1 = 0; c2 = 0; - while ( (c1 < m_SrcDir.GetLength()) && (c2 < m_DestDir.GetLength()) && (m_SrcDir[c1] == m_DestDir[c2]) ) + while ((c1 < m_SrcDir.GetLength()) && (c2 < m_DestDir.GetLength()) && (m_SrcDir[c1] == m_DestDir[c2])) { ++c1; ++c2; } - if ( (c1 == m_SrcDir.GetLength()) || (c2 == m_DestDir.GetLength()) ) + if ((c1 == m_SrcDir.GetLength()) || (c2 == m_DestDir.GetLength())) { return; // both strings are identical (should not occur again) } // If one of the token is empty, expand both downto the closest backslash - if ( (c1 == endOfToken1) || (c2 == endOfToken2) ) + if ((c1 == endOfToken1) || (c2 == endOfToken2)) { --c1; - while ( (c1 >= 0) && (m_SrcDir[c1] != '\\') ) + while ((c1 >= 0) && (m_SrcDir[c1] != '\\')) { --c1; } ++c1; --c2; - while ( (c2 >= 0) && (m_DestDir[c2] != '\\') ) + while ((c2 >= 0) && (m_DestDir[c2] != '\\')) { --c2; } @@ -601,67 +607,67 @@ void CBranch_patcherDlg::extractDirTokens() beginOfToken1 = c1; beginOfToken2 = c2; - Token1 = m_SrcDir.Mid( beginOfToken1, endOfToken1-beginOfToken1 ); - Token2 = m_DestDir.Mid( beginOfToken2, endOfToken2-beginOfToken2 ); + Token1 = m_SrcDir.Mid(beginOfToken1, endOfToken1 - beginOfToken1); + Token2 = m_DestDir.Mid(beginOfToken2, endOfToken2 - beginOfToken2); -//endExtract: - /*if ( hasTokens() ) - { - text.Format( "The two branch tokens '%s' and '%s' are now stored", Token1, Token2 ); - ::MessageBox( m_hWnd, text, "Tokens found", MB_OK | MB_ICONINFORMATION ); - return; - }*/ -//notfound: - //::MessageBox( m_hWnd, "Tokens not found in the directories", "Extracting tokens", MB_OK | MB_ICONEXCLAMATION ); + //endExtract: + /*if ( hasTokens() ) + { + text.Format( "The two branch tokens '%s' and '%s' are now stored", Token1, Token2 ); + ::MessageBox( m_hWnd, text, "Tokens found", MB_OK | MB_ICONINFORMATION ); + return; + }*/ + //notfound: + //::MessageBox( m_hWnd, "Tokens not found in the directories", "Extracting tokens", MB_OK | MB_ICONEXCLAMATION ); } void CBranch_patcherDlg::loadConfiguration() { // Read the dest directory from the registry - free( (void*)theApp.m_pszRegistryKey ); - theApp.m_pszRegistryKey = _tcsdup( _T("Nevrax") ); + free((void*)theApp.m_pszRegistryKey); + theApp.m_pszRegistryKey = _tcsdup(_T("Nevrax")); CString savedSrcDir, savedTargetDir, token1, token2; - if ( m_SrcDir.IsEmpty() ) + if (m_SrcDir.IsEmpty()) { - savedSrcDir = theApp.GetProfileString( _T(""), _T("SourceDir") ); - if ( ! savedSrcDir.IsEmpty() ) + savedSrcDir = theApp.GetProfileString(_T(""), _T("SourceDir")); + if (!savedSrcDir.IsEmpty()) { - setSrcDirectory( savedSrcDir ); + setSrcDirectory(savedSrcDir); } } - savedTargetDir = theApp.GetProfileString( _T(""), _T("TargetDir") ); - if ( ! savedTargetDir.IsEmpty() ) + savedTargetDir = theApp.GetProfileString(_T(""), _T("TargetDir")); + if (!savedTargetDir.IsEmpty()) { - setDestDirectory( savedTargetDir ); + setDestDirectory(savedTargetDir); } - Token1 = theApp.GetProfileString( _T(""), _T("Token1") ); - Token2 = theApp.GetProfileString( _T(""), _T("Token2") ); - PatchExeDir = theApp.GetProfileString( _T(""), _T("PatchExeDir") ); - CvsDiffDirLevel = theApp.GetProfileInt( _T(""), _T("CvsDiffDirLevel"), 1 ); // 0 for old version of CVS, 1 for new version of CVS + Token1 = theApp.GetProfileString(_T(""), _T("Token1")); + Token2 = theApp.GetProfileString(_T(""), _T("Token2")); + PatchExeDir = theApp.GetProfileString(_T(""), _T("PatchExeDir")); + CvsDiffDirLevel = theApp.GetProfileInt(_T(""), _T("CvsDiffDirLevel"), 1); // 0 for old version of CVS, 1 for new version of CVS } void CBranch_patcherDlg::saveConfiguration() { - UpdateData( true ); - if ( ! EnteringTokens ) + UpdateData(true); + if (!EnteringTokens) { - theApp.WriteProfileString( _T(""), _T("SourceDir"), m_SrcDir ); - theApp.WriteProfileString( _T(""), _T("TargetDir"), m_DestDir ); + theApp.WriteProfileString(_T(""), _T("SourceDir"), m_SrcDir); + theApp.WriteProfileString(_T(""), _T("TargetDir"), m_DestDir); } - theApp.WriteProfileString( _T(""), _T("Token1"), Token1 ); - theApp.WriteProfileString( _T(""), _T("Token2"), Token2 ); + theApp.WriteProfileString(_T(""), _T("Token1"), Token1); + theApp.WriteProfileString(_T(""), _T("Token2"), Token2); } -void CBranch_patcherDlg::OnButtonExtractTokens() +void CBranch_patcherDlg::OnButtonExtractTokens() { - if ( ! EnteringTokens ) + if (!EnteringTokens) { EnteringTokens = true; - extractDirTokens(); + extractDirTokens(); SrcDirBackup = m_SrcDir; TargetDirBackup = m_DestDir; m_SrcDir = Token1; @@ -669,18 +675,18 @@ void CBranch_patcherDlg::OnButtonExtractTokens() m_SrcDirLabel = "Enter Token 1"; m_TargetDirLabel = "Enter Token 2"; m_Filename = "The tokens above were extracted from the directories."; - ((CButton*)GetDlgItem( IDC_ButtonExtractTokens ))->SetWindowText( "Store Tokens" ); - GetDlgItem( IDC_TopText )->ShowWindow( SW_HIDE ); - GetDlgItem( IDC_ButtonClearTokens )->EnableWindow( FALSE ); - GetDlgItem( IDC_ButtonPatch )->ShowWindow( SW_HIDE ); - GetDlgItem( IDC_ButtonPatch )->EnableWindow( FALSE ); - GetDlgItem( IDC_DoPatch )->ShowWindow( SW_HIDE ); - GetDlgItem( IDC_Group )->ShowWindow( SW_HIDE ); - UpdateData( false ); + ((CButton*)GetDlgItem(IDC_ButtonExtractTokens))->SetWindowText(_T("Store Tokens")); + GetDlgItem(IDC_TopText)->ShowWindow(SW_HIDE); + GetDlgItem(IDC_ButtonClearTokens)->EnableWindow(FALSE); + GetDlgItem(IDC_ButtonPatch)->ShowWindow(SW_HIDE); + GetDlgItem(IDC_ButtonPatch)->EnableWindow(FALSE); + GetDlgItem(IDC_DoPatch)->ShowWindow(SW_HIDE); + GetDlgItem(IDC_Group)->ShowWindow(SW_HIDE); + UpdateData(false); } else { - UpdateData( true ); + UpdateData(true); EnteringTokens = false; Token1 = m_SrcDir; Token2 = m_DestDir; @@ -688,37 +694,37 @@ void CBranch_patcherDlg::OnButtonExtractTokens() m_TargetDirLabel = "Target Dir"; m_SrcDir = SrcDirBackup; m_DestDir = TargetDirBackup; - m_Filename = ""; - ((CButton*)GetDlgItem( IDC_ButtonExtractTokens ))->SetWindowText( "Enter Tokens" ); - GetDlgItem( IDC_TopText )->ShowWindow( SW_SHOW ); - GetDlgItem( IDC_ButtonClearTokens )->EnableWindow( TRUE ); - GetDlgItem( IDC_ButtonPatch )->ShowWindow( SW_SHOW ); - GetDlgItem( IDC_ButtonPatch )->EnableWindow( TRUE ); - GetDlgItem( IDC_DoPatch )->ShowWindow( SW_SHOW ); - GetDlgItem( IDC_Group )->ShowWindow( SW_SHOW ); + m_Filename.Empty(); + ((CButton*)GetDlgItem(IDC_ButtonExtractTokens))->SetWindowText(_T("Enter Tokens")); + GetDlgItem(IDC_TopText)->ShowWindow(SW_SHOW); + GetDlgItem(IDC_ButtonClearTokens)->EnableWindow(TRUE); + GetDlgItem(IDC_ButtonPatch)->ShowWindow(SW_SHOW); + GetDlgItem(IDC_ButtonPatch)->EnableWindow(TRUE); + GetDlgItem(IDC_DoPatch)->ShowWindow(SW_SHOW); + GetDlgItem(IDC_Group)->ShowWindow(SW_SHOW); displayTokens(); } } -void CBranch_patcherDlg::OnButtonClearTokens() +void CBranch_patcherDlg::OnButtonClearTokens() { - Token1 = ""; - Token2 = ""; + Token1.Empty(); + Token2.Empty(); displayTokens(); } bool CBranch_patcherDlg::hasTokens() const { - return ! (Token1.IsEmpty() || Token2.IsEmpty()); + return !(Token1.IsEmpty() || Token2.IsEmpty()); } void CBranch_patcherDlg::displayTokens() { - ((CButton*)GetDlgItem( IDC_ButtonClearTokens ))->EnableWindow( hasTokens()?TRUE:FALSE ); - if ( hasTokens() ) + ((CButton*)GetDlgItem(IDC_ButtonClearTokens))->EnableWindow(hasTokens() ? TRUE : FALSE); + if (hasTokens()) { m_Tokens = "Tokens: '" + Token1 + "' and '" + Token2 + "'"; } @@ -726,5 +732,5 @@ void CBranch_patcherDlg::displayTokens() { m_Tokens = "No token"; } - UpdateData( false ); + UpdateData(false); } diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.ui b/code/nel/tools/misc/crash_report/crash_report_widget.ui index da1e38618..669514b04 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.ui +++ b/code/nel/tools/misc/crash_report/crash_report_widget.ui @@ -1,68 +1,68 @@ - - - CrashReportWidget - - - Qt::ApplicationModal - - - - 0 - 0 - 406 - 430 - - - - NeL report - - - - - - What were you doing when the crash occured? - - - - - - - Contents of the report ( automatically generated ) - - - - - - - - - - Email me if you have further questions, or updates on this issue - - - - - - - false - - - Enter your email address here - - - - - - - true - - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - + + + CrashReportWidget + + + Qt::ApplicationModal + + + + 0 + 0 + 406 + 430 + + + + NeL report + + + + + + What were you doing when the crash occurred? + + + + + + + Contents of the report ( automatically generated ) + + + + + + + + + + Email me if you have further questions, or updates on this issue + + + + + + + false + + + Enter your email address here + + + + + + + true + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + diff --git a/code/nel/tools/misc/data_mirror/data_mirror.cpp b/code/nel/tools/misc/data_mirror/data_mirror.cpp index 930e23873..99a87f547 100644 --- a/code/nel/tools/misc/data_mirror/data_mirror.cpp +++ b/code/nel/tools/misc/data_mirror/data_mirror.cpp @@ -198,7 +198,7 @@ BOOL CData_mirrorApp::InitInstance() } } } - catch (Exception &e) + catch (const Exception &e) { MessageBox (NULL, e.what (), "NeL Data Mirror", MB_OK|MB_ICONEXCLAMATION); } diff --git a/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp b/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp index 340655e36..4fb771d86 100644 --- a/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp +++ b/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp @@ -280,7 +280,7 @@ void CData_mirrorDlg::updateList () { // Add the items const CEntryFile &entry = *ite; - uint nItem = List.InsertItem (0, entry.Strings[CEntryFile::Path].c_str (), entry.Image); + uint nItem = List.InsertItem (0, utf8ToTStr(entry.Strings[CEntryFile::Path]), entry.Image); List.SetItemData (nItem, DWORD(new std::list::iterator (ite))); // Sub string @@ -289,25 +289,25 @@ void CData_mirrorDlg::updateList () // Add the sizes if (ModifiedFilter != Removed) { - List.SetItemText (nItem, subString++, entry.Strings[CEntryFile::NewSize].c_str ()); + List.SetItemText (nItem, subString++, utf8ToTStr(entry.Strings[CEntryFile::NewSize])); } if (ModifiedFilter != Added) { - List.SetItemText (nItem, subString++, entry.Strings[CEntryFile::OldSize].c_str ()); + List.SetItemText (nItem, subString++, utf8ToTStr(entry.Strings[CEntryFile::OldSize])); } // Add the dates if (ModifiedFilter != Removed) { - List.SetItemText (nItem, subString++, entry.Strings[CEntryFile::NewDate].c_str ()); + List.SetItemText (nItem, subString++, utf8ToTStr(entry.Strings[CEntryFile::NewDate])); } if (ModifiedFilter != Added) { - List.SetItemText (nItem, subString++, entry.Strings[CEntryFile::OldDate].c_str ()); + List.SetItemText (nItem, subString++, utf8ToTStr(entry.Strings[CEntryFile::OldDate])); } // Add the type - List.SetItemText (nItem, subString++, entry.Strings[CEntryFile::Type].c_str ()); + List.SetItemText (nItem, subString++, utf8ToTStr(entry.Strings[CEntryFile::Type])); // Next item ite++; @@ -382,7 +382,7 @@ void CData_mirrorDlg::OnIgnore() CString itemText = List.GetItemText (i, 0); // Add to ignore list - IgnoreFiles.insert ((const char*)itemText); + IgnoreFiles.insert (tStrToUtf8(itemText)); // Remove from the file list std::list::iterator *ite = (std::list::iterator *)List.GetItemData (i); @@ -408,9 +408,9 @@ void createDirectory (const string &dir) NLMISC::CFile::createDirectory (dir); } -bool setFileTime (const char *filename, const FILETIME &result) +bool setFileTime(const std::string &filename, const FILETIME &result) { - HANDLE handle = CreateFile (filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE handle = CreateFile (utf8ToTStr(filename), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (handle) { SetFileTime (handle, NULL, NULL, &result); @@ -460,7 +460,7 @@ void CData_mirrorDlg::OnOK() createDirectory (directory.c_str ()); if (!CopyFile (source.c_str (), dest.c_str (), FALSE)) { - MessageBox (("Can't copy file "+source+" in file "+dest).c_str (), "NeL Data Mirror", + MessageBox (("Can't copy file "+source+" in file "+dest).c_str (), _T("NeL Data Mirror"), MB_OK|MB_ICONEXCLAMATION); success = false; } @@ -499,7 +499,7 @@ void CData_mirrorDlg::OnOK() createDirectory (directory.c_str ()); if (!CopyFile (source.c_str (), dest.c_str (), FALSE)) { - MessageBox (("Can't copy file "+source+" in file "+dest).c_str (), "NeL Data Mirror", + MessageBox (("Can't copy file "+source+" in file "+dest).c_str (), _T("NeL Data Mirror"), MB_OK|MB_ICONEXCLAMATION); success = false; } @@ -534,7 +534,7 @@ void CData_mirrorDlg::OnOK() if (!DeleteFile (dest.c_str ())) { - MessageBox (("Can't delete the file "+dest).c_str (), "NeL Data Mirror", + MessageBox (("Can't delete the file "+dest).c_str (), _T("NeL Data Mirror"), MB_OK|MB_ICONEXCLAMATION); success = false; } @@ -594,9 +594,9 @@ void CData_mirrorDlg::OnSize(UINT nType, int cx, int cy) resize (); } -bool getFileTime (const char *filename, FILETIME &result) +bool getFileTime (const std::string &filename, FILETIME &result) { - HANDLE handle = CreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE handle = CreateFile (utf8ToTStr(filename), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (handle) { FILETIME res0; @@ -637,8 +637,8 @@ void CData_mirrorDlg::buildSourceFiles () { FILETIME time0; FILETIME time1; - getFileTime (mirrorFile.c_str (), time0); - getFileTime (mainFile.c_str (), time1); + getFileTime (mirrorFile, time0); + getFileTime (mainFile, time1); sint64 deltaInt = (((uint64)time1.dwHighDateTime)<<32|((uint64)time1.dwLowDateTime)) - (((uint64)time0.dwHighDateTime)<<32|((uint64)time0.dwLowDateTime)); double deltaInSec = (double)deltaInt; deltaInSec /= 10000000.0; @@ -688,8 +688,8 @@ void CData_mirrorDlg::buildSourceFiles () { // Update time stamp FILETIME fileTime; - getFileTime (mainFile.c_str (), fileTime); - setFileTime (mirrorFile.c_str(), fileTime); + getFileTime (mainFile, fileTime); + setFileTime (mirrorFile, fileTime); } } else @@ -699,8 +699,8 @@ void CData_mirrorDlg::buildSourceFiles () else { FILETIME time; - getFileTime (mainFile.c_str (), time); - addEntry (Added, str.c_str (), time, time); + getFileTime (mainFile, time); + addEntry (Added, str, time, time); } } } @@ -777,7 +777,7 @@ void CData_mirrorDlg::addEntry (uint where, const char *filename, FILETIME &newD file.Strings[CEntryFile::Path] = filename; file.NewDateST = newDate; file.OldDateST = oldDate; - const char *aFilename; + std::string aFilename; string mirrorFile = MirrorDirectory+filename; string mainFile = MainDirectory+filename; @@ -790,7 +790,7 @@ void CData_mirrorDlg::addEntry (uint where, const char *filename, FILETIME &newD // Date timeToString (file.Strings[CEntryFile::OldDate], oldDate); - aFilename = mirrorFile.c_str (); + aFilename = mirrorFile; } if (where != Removed) @@ -801,7 +801,7 @@ void CData_mirrorDlg::addEntry (uint where, const char *filename, FILETIME &newD // Date timeToString (file.Strings[CEntryFile::NewDate], newDate); - aFilename = mainFile.c_str (); + aFilename = mainFile; } // Get the extension @@ -811,19 +811,19 @@ void CData_mirrorDlg::addEntry (uint where, const char *filename, FILETIME &newD { // Get the image SHFILEINFO sfi; - char winName[512]; - strcpy (winName, aFilename); - char *ptr = winName; + TCHAR winName[512]; + _tcscpy (winName, utf8ToTStr(aFilename)); + TCHAR *ptr = winName; while (*ptr) { - if (*ptr=='/') - *ptr = '\\'; + if (*ptr==_T('/')) + *ptr = _T('\\'); ptr++; } SHGetFileInfo (winName, 0, &sfi, sizeof (SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_LINKOVERLAY | SHGFI_TYPENAME ); CExtension extension; - extension.Description = sfi.szTypeName; + extension.Description = tStrToUtf8(sfi.szTypeName); extension.Icon = sfi.iIcon; ite = MapExtensions.insert (std::map::value_type (ext, extension)).first; } @@ -883,7 +883,7 @@ void CData_mirrorDlg::OnUpdate() CString itemText = List.GetItemText (i, 0); // Add to ignore good list - entriesToUpdate.push_back ((const char*)itemText); + entriesToUpdate.push_back (tStrToUtf8(itemText)); // Remove from the file list std::list::iterator *ite = (std::list::iterator *)List.GetItemData (i); diff --git a/code/nel/tools/misc/log_analyser/FilterDialog.cpp b/code/nel/tools/misc/log_analyser/FilterDialog.cpp index 1e65b1e09..6eec719d7 100644 --- a/code/nel/tools/misc/log_analyser/FilterDialog.cpp +++ b/code/nel/tools/misc/log_analyser/FilterDialog.cpp @@ -71,7 +71,7 @@ BOOL CFilterDialog::OnInitDialog() if ( Trace ) { - GetDlgItem( IDC_PosFilterCap )->SetWindowText( "Service code" ); + GetDlgItem( IDC_PosFilterCap )->SetWindowText(_T("Service code")); GetDlgItem( IDC_NegFilterCap )->ShowWindow( SW_HIDE ); GetDlgItem( IDC_SepCap )->ShowWindow( SW_HIDE ); GetDlgItem( IDC_NegFilter )->ShowWindow( SW_HIDE ); @@ -79,11 +79,11 @@ BOOL CFilterDialog::OnInitDialog() } else { - GetDlgItem( IDC_PosFilterCap )->SetWindowText( "Positive filters (all lines must contain one of these substrings)" ); + GetDlgItem( IDC_PosFilterCap )->SetWindowText(_T("Positive filters (all lines must contain one of these substrings)")); GetDlgItem( IDC_NegFilterCap )->ShowWindow( SW_SHOW ); GetDlgItem( IDC_SepCap )->ShowWindow( SW_SHOW ); GetDlgItem( IDC_NegFilter )->ShowWindow( SW_SHOW ); - GetDlgItem( IDC_Sep )->SetWindowText( ";" ); + GetDlgItem( IDC_Sep )->SetWindowText(_T(";")); GetDlgItem( IDC_Sep )->ShowWindow( SW_SHOW ); } @@ -98,12 +98,12 @@ std::vector buildVectorFromString( const CString& str, const CString& s { std::vector vec; CString str2 = str; - char *token; - token = strtok( str2.GetBuffer( str2.GetLength() ), sep ); + TCHAR *token; + token = _tcstok( str2.GetBuffer( str2.GetLength() ), sep ); while ( token != NULL ) { vec.push_back( CString(token) ); - token = strtok( NULL, sep ); + token = _tcstok( NULL, sep ); } str2.ReleaseBuffer(); return vec; diff --git a/code/nel/tools/misc/log_analyser/PlugInSelector.cpp b/code/nel/tools/misc/log_analyser/PlugInSelector.cpp index 9a21a8df6..120ceacaf 100644 --- a/code/nel/tools/misc/log_analyser/PlugInSelector.cpp +++ b/code/nel/tools/misc/log_analyser/PlugInSelector.cpp @@ -87,7 +87,7 @@ BOOL CPlugInSelector::OnInitDialog() } -int getLastSeparator (const string &filename) +std::string::size_type getLastSeparator (const string &filename) { string::size_type pos = filename.find_last_of ('/'); if (pos == string::npos) @@ -131,10 +131,10 @@ void CPlugInSelector::OnSelchangeList1() if ( ! LibInst ) { CString s; - char msg [300]; + TCHAR msg [300]; FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), msg, 299, NULL ); - s.Format( "Can't load %s: %s", dllName, msg ); + s.Format(_T("Can't load %s: %s"), dllName, msg ); AfxMessageBox( s ); AnalyseFunc = NULL; return; @@ -144,17 +144,17 @@ void CPlugInSelector::OnSelchangeList1() TInfoFunc infoFunc = (TInfoFunc)GetProcAddress( LibInst, "getInfoString" ); if ( ! infoFunc ) { - AfxMessageBox( "Can't find function getInfoString in dll" ); + AfxMessageBox( _T("Can't find function getInfoString in dll") ); return; } - GetDlgItem( IDC_GROUP_INFO )->SetWindowText( getFilename( string(dllName)).c_str() ); - GetDlgItem( IDC_PLUGIN_INFO )->SetWindowText( infoFunc().c_str() ); + GetDlgItem( IDC_GROUP_INFO )->SetWindowText( utf8ToTStr(getFilename(tStrToUtf8(dllName))) ); + GetDlgItem( IDC_PLUGIN_INFO )->SetWindowText(utf8ToTStr(infoFunc()) ); // Prepare analyse func AnalyseFunc = (TAnalyseFunc)GetProcAddress( LibInst, "doAnalyse" ); if ( ! AnalyseFunc ) { - AfxMessageBox( "Can't find function doAnalyse in dll" ); + AfxMessageBox( _T("Can't find function doAnalyse in dll") ); return; } diff --git a/code/nel/tools/misc/log_analyser/StdAfx.h b/code/nel/tools/misc/log_analyser/StdAfx.h index 7fdcd1587..bd3d88df1 100644 --- a/code/nel/tools/misc/log_analyser/StdAfx.h +++ b/code/nel/tools/misc/log_analyser/StdAfx.h @@ -37,6 +37,9 @@ #include // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT +#include +#include +#include //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/code/nel/tools/misc/log_analyser/ViewDialog.cpp b/code/nel/tools/misc/log_analyser/ViewDialog.cpp index c750cbd83..cdc38ed08 100644 --- a/code/nel/tools/misc/log_analyser/ViewDialog.cpp +++ b/code/nel/tools/misc/log_analyser/ViewDialog.cpp @@ -301,14 +301,14 @@ void CViewDialog::reload() { SessionDatePassed = false; CWaitCursor wc; - if ( LogSessionStartDate.IsEmpty() || (LogSessionStartDate == "Beginning") ) + if ( LogSessionStartDate.IsEmpty() || (LogSessionStartDate == _T("Beginning")) ) { SessionDatePassed = true; } ((CButton*)GetDlgItem( IDC_BUTTON1 ))->ShowWindow( SW_SHOW ); ((CButton*)GetDlgItem( IDC_BUTTON2 ))->ShowWindow( SW_SHOW ); - m_Caption.Format( "%s (%u file%s) %u+ %u- (%s)", Seriesname, Filenames.size(), Filenames.size()>1?"s":"", PosFilter.size(), NegFilter.size(), LogSessionStartDate.IsEmpty()?"all":CString("session ")+LogSessionStartDate ); + m_Caption.Format( _T("%s (%u file%s) %u+ %u- (%s)"), Seriesname, Filenames.size(), Filenames.size()>1?"s":"", PosFilter.size(), NegFilter.size(), LogSessionStartDate.IsEmpty()?"all":CString("session ")+LogSessionStartDate ); UpdateData( false ); clear(); setRedraw( false ); @@ -356,17 +356,21 @@ void CViewDialog::getBookmarksAbsoluteLines( vector& bookmarksAbsoluteLine for ( unsigned int i=0; i!=Filenames.size(); ++i ) { CString& filename = Filenames[i]; - ifstream ifs( filename ); - if ( ! ifs.fail() ) + + NLMISC::CIFile ifs; + + if (ifs.open(tStrToUtf8(filename))) { char line [1024]; - while ( ! ifs.eof() ) + + while (!ifs.eof()) { - ifs.getline( line, 1024 ); + ifs.getline(line, 1024); + if ( SessionDatePassed ) { // Stop if the session is finished - if ( (! LogSessionStartDate.IsEmpty()) && (strstr( line, LogDateString )) ) + if ( (! LogSessionStartDate.IsEmpty()) && (strstr( line, tStrToUtf8(LogDateString).c_str())) ) { return; } @@ -390,7 +394,7 @@ void CViewDialog::getBookmarksAbsoluteLines( vector& bookmarksAbsoluteLine else { // Look for the session beginning - if ( strstr( line, LogSessionStartDate ) != NULL ) + if ( strstr( line, tStrToUtf8(LogSessionStartDate).c_str()) != NULL ) { SessionDatePassed = true; } @@ -457,15 +461,12 @@ std::string CViewDialog::corruptedLinesString( const std::vector& string res; if ( ! corruptedLines.empty() ) { - CString s; - s.Format( "%u", corruptedLines.size() ); - res = " -> " + string(s) + " corrupted lines:"; + res = NLMISC::toString(" -> %u corrupted lines:", (uint)corruptedLines.size()); vector::const_iterator ivc; for ( ivc=corruptedLines.begin(); ivc!=corruptedLines.end(); ++ivc ) { - s.Format( "%u", *ivc ); - res += "\r\n line " + string(s) + " : " + string(Buffer[*ivc].Left(20)) + "..."; + res += NLMISC::toString("\r\n line %u : %s...", *ivc, tStrToUtf8(Buffer[*ivc].Left(20)).c_str()); } HasCorruptedLines = true; } @@ -483,7 +484,7 @@ void CViewDialog::loadFileOrSeries( const vector& bookmarksAbsoluteLines ) if ( LogSessionStartDate.IsEmpty() ) actualFilenames += ":\r\n"; else - actualFilenames += " for Session of " + LogSessionStartDate + ":\r\n"; + actualFilenames += " for Session of " + tStrToUtf8(LogSessionStartDate) + ":\r\n"; bool corruptionDetectionEnabled = (((CButton*)(((CLog_analyserDlg*)GetParent())->GetDlgItem( IDC_DetectCorruptedLines )))->GetCheck() == 1); HasCorruptedLines = false; vector corruptedLines; diff --git a/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp b/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp index ae7c6ce00..e23fd2bd9 100644 --- a/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp +++ b/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp @@ -188,7 +188,7 @@ BOOL CLog_analyserDlg::OnInitDialog() cf.load( "log_analyser.cfg" ); LogDateString = cf.getVar( "LogDateString" ).asString().c_str(); } - catch ( EConfigFile& ) + catch (const EConfigFile& ) {*/ LogDateString = "Log Starting ["; AnalyseFunc = NULL; @@ -517,7 +517,7 @@ CViewDialog *CLog_analyserDlg::onAddCommon( const vector& filenames ) view->Filenames = filenames; } - view->LogSessionStartDate = ""; + view->LogSessionStartDate.Empty(); LogSessionsDialog.clear(); if ( ((CButton*)GetDlgItem( IDC_CheckSessions ))->GetCheck() == 1 ) @@ -620,7 +620,7 @@ void CLog_analyserDlg::getLogSeries( const CString& filenameStr, std::vector pl; - pl.push_back( "Analyse log" ); + pl.push_back(_T("Analyse log")); onAddCommon( pl ); Views.back()->addText( logstr.c_str() ); Views.back()->commitAddedLines(); @@ -1041,7 +1041,7 @@ void CLog_analyserDlg::OnAnalyse() if ( nEndChar != (int)resstr.size() ) { CString s; - s.Format( "Error: plug-in returned %u characters, only %d displayed", resstr.size(), nEndChar+1 ); + s.Format(_T("Error: plug-in returned %u characters, only %d displayed"), (uint)resstr.size(), nEndChar+1 ); AfxMessageBox( s ); } } diff --git a/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp b/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp index 5aefbcf4c..c6accc1cb 100644 --- a/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp +++ b/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp @@ -164,7 +164,9 @@ void readFormId( string& outputFileName ) map::iterator itFT = FileTypeToId.find(fileType); if( itFT == FileTypeToId.end() ) { - FileTypeToId.insert( std::pair(fileType,fid.FormIDInfos.Type) ); + uint8 type = (uint8)fid.FormIDInfos.Type; + + FileTypeToId.insert( std::pair(fileType, type) ); } } else @@ -529,9 +531,9 @@ int main( int argc, char ** argv ) readFormId( outputFileName ); // output path - sint lastSeparator = CFile::getLastSeparator(outputFileName); + std::string::size_type lastSeparator = CFile::getLastSeparator(outputFileName); string outputPath; - if( lastSeparator != -1 ) + if( lastSeparator != std::string::npos ) { outputPath = outputFileName.substr(0,lastSeparator+1); } diff --git a/code/nel/tools/misc/words_dic/words_dicDlg.cpp b/code/nel/tools/misc/words_dic/words_dicDlg.cpp index 8c28c2124..f161e22e5 100644 --- a/code/nel/tools/misc/words_dic/words_dicDlg.cpp +++ b/code/nel/tools/misc/words_dic/words_dicDlg.cpp @@ -87,12 +87,12 @@ BOOL CWords_dicDlg::OnInitDialog() SplashScreen->Create( IDD_SplashScreen, NULL ); SplashScreen->ShowWindow( SW_SHOW ); SplashScreen->SetWindowPos( &wndTop, 400, 300, 0,0, SWP_NOSIZE ); - SplashScreen->GetDlgItem( IDC_SplashText )->SetWindowText( "Please wait while loading dictionary..." ); + SplashScreen->GetDlgItem( IDC_SplashText )->SetWindowText( _T("Please wait while loading dictionary...") ); if ( ! Dico.init() ) - AfxMessageBox( "Can't init dictionary, see reason in log.log" ); + AfxMessageBox( _T("Can't init dictionary, see reason in log.log") ); SplashScreen->DestroyWindow(); delete SplashScreen; - GetDlgItem( IDC_Status )->SetWindowText( "Tip: ^ and $ can be used to represent the start and the end of string" ); + GetDlgItem( IDC_Status )->SetWindowText( _T("Tip: ^ and $ can be used to represent the start and the end of string") ); return TRUE; // return TRUE unless you set the focus to a control } @@ -157,13 +157,13 @@ void CWords_dicDlg::lookUp( const CString& inputStr ) { // Look up CVectorSString resultVec; - Dico.lookup( CSString(inputStr), resultVec ); + Dico.lookup( tStrToUtf8(inputStr), resultVec ); // Display results clear(); if ( resultVec.empty() ) { - m_Results.AddString( "" ); + m_Results.AddString(_T("")); return; } else @@ -176,14 +176,14 @@ void CWords_dicDlg::lookUp( const CString& inputStr ) const CSString& res = (*ivs); if ( showAll || (res.find( "lvl" ) == string::npos) ) { - m_Results.AddString( res.c_str() ); + m_Results.AddString( utf8ToTStr(res) ); } else lvlRemoved = true; } m_Results.SetRedraw( true ); CString s; - s.Format( "%u results found for \"%s\".%s", resultVec.size(), inputStr, lvlRemoved?" Results containing \"lvl\" not shown":"" ); + s.Format(_T("%u results found for \"%s\".%s"), resultVec.size(), inputStr, lvlRemoved? _T(" Results containing \"lvl\" not shown"): _T("") ); GetDlgItem( IDC_Status )->SetWindowText( s ); } } @@ -204,7 +204,7 @@ void CWords_dicDlg::OnBtnFind() */ void CWords_dicDlg::clear() { - GetDlgItem( IDC_Status )->SetWindowText( "" ); + GetDlgItem( IDC_Status )->SetWindowText(_T("")); m_Results.ResetContent(); } @@ -213,7 +213,7 @@ void CWords_dicDlg::clear() */ void CWords_dicDlg::OnBtnClear() { - m_LookUp.SetWindowText( "" ); + m_LookUp.SetWindowText(_T("")); clear(); } @@ -234,7 +234,7 @@ void CWords_dicDlg::OnFileList() const vector& fileList = Dico.getFileList(); for ( vector::const_iterator ifl=fileList.begin(); ifl!=fileList.end(); ++ifl ) { - m_Results.AddString( (*ifl).c_str() ); + m_Results.AddString( utf8ToTStr(*ifl) ); } } @@ -253,7 +253,7 @@ void CWords_dicDlg::OnSelchangeResultList() // Get selection CString resStr; m_Results.GetText( m_Results.GetCurSel(), resStr ); - CSString key = Dico.getWordsKey( CSString(resStr) ); + CSString key = Dico.getWordsKey( tStrToUtf8(resStr) ); // Copy the selection into the clipboard if ( OpenClipboard() ) @@ -271,13 +271,13 @@ void CWords_dicDlg::OnSelchangeResultList() if ( mem ) { CString s; - s.Format( "\"%s\" copied into the clipboard", key.c_str() ); + s.Format(_T("\"%s\" copied into the clipboard"), utf8ToTStr(key) ); GetDlgItem( IDC_Status )->SetWindowText( s ); } } else { - GetDlgItem( IDC_Status )->SetWindowText( "Cannot access the clipboard" ); + GetDlgItem( IDC_Status )->SetWindowText(_T("Cannot access the clipboard")); } } diff --git a/code/nel/tools/nel_unit_test/nel_unit_test.cpp b/code/nel/tools/nel_unit_test/nel_unit_test.cpp index 753dfd46a..d716fef98 100644 --- a/code/nel/tools/nel_unit_test/nel_unit_test.cpp +++ b/code/nel/tools/nel_unit_test/nel_unit_test.cpp @@ -67,7 +67,7 @@ static void usage() exit(0); } -static auto_ptr cmdline(int argc, char* argv[]) +static CUniquePtr cmdline(int argc, char* argv[]) { if (argc > 2) usage(); // will not return @@ -102,7 +102,7 @@ static auto_ptr cmdline(int argc, char* argv[]) } } - return auto_ptr(output); + return CUniquePtr(output); } // Main test program @@ -134,12 +134,12 @@ int main(int argc, char *argv[]) { Test::Suite ts; - ts.add(auto_ptr(new CUTMisc)); - ts.add(auto_ptr(new CUTNet)); - ts.add(auto_ptr(new CUTLigo)); + ts.add(std::auto_ptr(new CUTMisc)); + ts.add(std::auto_ptr(new CUTNet)); + ts.add(std::auto_ptr(new CUTLigo)); // Add a line here when adding a new test MODULE - auto_ptr output(cmdline(argc, argv)); + CUniquePtr output(cmdline(argc, argv)); noerrors = ts.run(*output); Test::HtmlOutput* const html = dynamic_cast(output.get()); diff --git a/code/nel/tools/nel_unit_test/ut_ligo.h b/code/nel/tools/nel_unit_test/ut_ligo.h index 6dba782d8..c41bc1463 100644 --- a/code/nel/tools/nel_unit_test/ut_ligo.h +++ b/code/nel/tools/nel_unit_test/ut_ligo.h @@ -26,7 +26,7 @@ struct CUTLigo : public Test::Suite { CUTLigo() { - add(auto_ptr(new CUTLigoPrimitive)); + add(std::auto_ptr(new CUTLigoPrimitive)); // Add a line here when adding a new test CLASS } }; diff --git a/code/nel/tools/nel_unit_test/ut_misc.h b/code/nel/tools/nel_unit_test/ut_misc.h index e7a3cc8c6..7f125f2f3 100644 --- a/code/nel/tools/nel_unit_test/ut_misc.h +++ b/code/nel/tools/nel_unit_test/ut_misc.h @@ -37,20 +37,20 @@ struct CUTMisc : public Test::Suite { CUTMisc() { - add(auto_ptr(new CUTMiscCoTask)); - add(auto_ptr(new CUTMiscCommand)); - add(auto_ptr(new CUTMiscCommon)); - add(auto_ptr(new CUTMiscConfigFile)); - add(auto_ptr(new CUTMiscDebug)); - add(auto_ptr(new CUTMiscDynLibLoad)); - add(auto_ptr(new CUTMiscFile)); - add(auto_ptr(new CUTMiscPackFile)); - add(auto_ptr(new CUTMiscSingleton)); - add(auto_ptr(new CUTMiscSString)); - add(auto_ptr(new CUTMiscStream)); - add(auto_ptr(new CUTMiscVariable)); - add(auto_ptr(new CUTMiscTypes)); - add(auto_ptr(new CUTMiscStringCommon)); + add(std::auto_ptr(new CUTMiscCoTask)); + add(std::auto_ptr(new CUTMiscCommand)); + add(std::auto_ptr(new CUTMiscCommon)); + add(std::auto_ptr(new CUTMiscConfigFile)); + add(std::auto_ptr(new CUTMiscDebug)); + add(std::auto_ptr(new CUTMiscDynLibLoad)); + add(std::auto_ptr(new CUTMiscFile)); + add(std::auto_ptr(new CUTMiscPackFile)); + add(std::auto_ptr(new CUTMiscSingleton)); + add(std::auto_ptr(new CUTMiscSString)); + add(std::auto_ptr(new CUTMiscStream)); + add(std::auto_ptr(new CUTMiscVariable)); + add(std::auto_ptr(new CUTMiscTypes)); + add(std::auto_ptr(new CUTMiscStringCommon)); // Add a line here when adding a new test CLASS } }; diff --git a/code/nel/tools/nel_unit_test/ut_net.h b/code/nel/tools/nel_unit_test/ut_net.h index bd43a0eee..cee3b01cb 100644 --- a/code/nel/tools/nel_unit_test/ut_net.h +++ b/code/nel/tools/nel_unit_test/ut_net.h @@ -28,9 +28,9 @@ struct CUTNet : public Test::Suite { CUTNet() { - add(auto_ptr(new CUTNetLayer3)); - add(auto_ptr(new CUTNetMessage)); - add(auto_ptr(new CUTNetModule)); + add(std::auto_ptr(new CUTNetLayer3)); + add(std::auto_ptr(new CUTNetMessage)); + add(std::auto_ptr(new CUTNetModule)); // Add a line here when adding a new test CLASS } }; diff --git a/code/nel/tools/pacs/build_rbank/build_surf.cpp b/code/nel/tools/pacs/build_rbank/build_surf.cpp index 10d4c6a19..7e873f15f 100644 --- a/code/nel/tools/pacs/build_rbank/build_surf.cpp +++ b/code/nel/tools/pacs/build_rbank/build_surf.cpp @@ -1420,7 +1420,7 @@ void NLPACS::CZoneTessellation::compile() bool force = false; - if (surf.Area < 30.0f && surf.Elements.size() > 0) + if (surf.Area < 30.0f && !surf.Elements.empty()) { uint i; CAABBox aabbox; @@ -1688,7 +1688,7 @@ CAABBox NLPACS::CZoneTessellation::computeBBox() const bool set = false; uint i; - if (_Vertices.size() == 0) + if (_Vertices.empty()) return zbox; zbox.setCenter(_Vertices[0]); diff --git a/code/ryzom/client/CMakeLists.txt b/code/ryzom/client/CMakeLists.txt index a17e216d6..43897c905 100644 --- a/code/ryzom/client/CMakeLists.txt +++ b/code/ryzom/client/CMakeLists.txt @@ -15,7 +15,11 @@ IF(WITH_RYZOM_CLIENT) IF(APPLE) INSTALL(FILES macosx/upgd_nl.sh DESTINATION ${RYZOM_GAMES_PREFIX}) ELSEIF(WIN32) - INSTALL(FILES windows/upgd_nl.bat DESTINATION ${RYZOM_GAMES_PREFIX}) + IF(MSVC10) + INSTALL(FILES windows/upgd_nl_msvc10.bat DESTINATION ${RYZOM_GAMES_PREFIX} RENAME upgd_nl.bat) + ELSEIF(MSVC12) + INSTALL(FILES windows/upgd_nl_msvc12.bat DESTINATION ${RYZOM_GAMES_PREFIX} RENAME upgd_nl.bat) + ENDIF() ELSE() INSTALL(FILES unix/upgd_nl.sh DESTINATION ${RYZOM_GAMES_PREFIX}) ENDIF() diff --git a/code/ryzom/client/client_default.cfg b/code/ryzom/client/client_default.cfg index 98083d32d..f907ec19f 100644 --- a/code/ryzom/client/client_default.cfg +++ b/code/ryzom/client/client_default.cfg @@ -1,594 +1,601 @@ -////////////////////////// -/// CLIENT CONFIG FILE /// -////////////////////////// -////////////////////////// - -////////////////////////// - -// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. -// You will loose all the comments and identation in this file. -SaveConfig = 1; - -/////////////////// -// WINDOW CONFIG // -/////////////////// - -Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" - // "Auto" will choose the best suited driver depending on hardware -FullScreen = 0; -Width = 0; -Height = 0; -PositionX = 0; -PositionY = 0; -Frequency = 0; -Depth = 32; -Sleep = -1; -ProcessPriority = 0; // -2 = idle, -1 = below normal, 0 = normal, 1 = above normal, 2 = high, 3 = real time -Contrast = 0.0; // -1.0 ~ 1.0 -Luminosity = 0.0; // -1.0 ~ 1.0 -Gamma = 0.0; // -1.0 ~ 1.0 -Contrast_min = -1.0; -Luminosity_min = -1.0; -Gamma_min = -1.0; -Contrast_max = 1.0; -Luminosity_max = 1.0; -Gamma_max = 1.0; - - -///////////// -// NETWORK // -///////////// - -Application = { "Lirria", "./client_ryzom_r.exe", "./" }; -BackgroundDownloader = 0; -PatchWanted = 1; -PatchUrl = "http://lirria.khaganat.net:43435"; -RingReleaseNotePath = "http://lirria.khaganat.net/patch/index.php"; -StartupHost = "lirria.khaganat.net:40916"; -StartupPage = "/login/r2_login.php"; -InstallStatsUrl = "http://lirria.khaganat.net:50000/stats/stats.php"; - -CreateAccountURL = "http://lirria.khaganat.net/ams/?page=register"; -EditAccountURL = "http://lirria.khaganat.net/"; -ForgetPwdURL = "http://lirria.khaganat.net/ams/index.php?page=forgot_password"; -//FreeTrialURL = "http://lirria.khaganat.net/"; -LoginSupportURL = "http://lirria.khaganat.net/"; -ConditionsTermsURL = "khaganat.net/wikhan/fr:charte"; - - - -//////////////// -// INTERFACES // -//////////////// - -// the language to use as in ISO 639-2 -LanguageCode = "fr"; // english - -XMLInputFile = "input_config_v3.xml"; - -XMLLoginInterfaceFiles = { - "login_config.xml", - "login_widgets.xml", - "login_main.xml", - "login_keys.xml", -}; - -XMLOutGameInterfaceFiles = { - "out_v2_config.xml", - "out_v2_widgets.xml", - "out_v2_connect.xml", - "out_v2_intro.xml", - "out_v2_select.xml", - "out_v2_appear.xml", - "out_v2_location.xml", - "out_v2_crash.xml", - "out_v2_hierarchy.xml", - "out_v2_keys.xml", -}; - - TexturesInterface = { - "interface_game_khaganat" - }; - TexturesLoginInterface = { - "interface_login_khaganat" - }; - TexturesOutGameInterface = { - "interface_outgame_khaganat" - }; - -// The ligo primitive class file -LigoPrimitiveClass = "world_editor_classes.xml"; - -VerboseLog = 1; - -/////////// -// MOUSE // -/////////// -HardwareCursor = 1; - -CursorSpeed = 1.0; // In pixels per mickey -CursorSpeed_min = 0.5; -CursorSpeed_max = 2.0; - -CursorAcceleration = 40; // Threshold in mickey -CursorAcceleration_min = 20; -CursorAcceleration_max = 80; - -FreeLookSpeed = 0.004; // In radian per mickey -FreeLookSpeed_min = 0.0001; -FreeLookSpeed_max = 0.01; - -FreeLookAcceleration = 40; // Threshold in mickey -FreeLookAcceleration_min = 20; -FreeLookAcceleration_max = 80; - -FreeLookInverted = 0; -AutomaticCamera = 0; -DblClickMode = 1; -AutoEquipTool = 1; - -/////////////////// -// RENDER CONFIG // -/////////////////// - -// NB: thoses variables configure also the InGameConfigurator: -// _min and _max define the bounds -// _step defines the step (NB: take care of _min and _max!!) -// _ps0 is the LOW preset, _ps1 is the MEDIUM preset, _ps2 is the NORMAL Preset, and _ps3 is the HIGH one - - -// *** LANDSCAPE -LandscapeTileNear = 50.000000; -LandscapeTileNear_min = 20.000000; -LandscapeTileNear_max = 100.000000; -LandscapeTileNear_step = 10.0; -LandscapeTileNear_ps0 = 20.0; -LandscapeTileNear_ps1 = 40.0; -LandscapeTileNear_ps2 = 50.0; -LandscapeTileNear_ps3 = 80.0; - -// NB: threshold is inverted ULandscape::setThreshold(), to be more intelligible -LandscapeThreshold = 1000.0; -LandscapeThreshold_min = 100.0; // Low quality => 0.01 threshold -LandscapeThreshold_max = 2000.0; // High quality => 0.0005 threshold -LandscapeThreshold_step = 100.0; -LandscapeThreshold_ps0 = 100.0; -LandscapeThreshold_ps1 = 500.0; -LandscapeThreshold_ps2 = 1000.0; -LandscapeThreshold_ps3 = 2000.0; - -Vision = 500.000000; -Vision_min = 200.000000; -Vision_max = 800.000000; -Vision_step = 100.000000; -Vision_ps0 = 200.0; -Vision_ps1 = 400.0; -Vision_ps2 = 500.0; -Vision_ps3 = 800.0; - -MicroVeget = 1; // Enable/Disable MicroVeget. -MicroVeget_ps0 = 0; -MicroVeget_ps1 = 1; -MicroVeget_ps2 = 1; -MicroVeget_ps3 = 1; - -MicroVegetDensity = 80.0; -MicroVegetDensity_min = 10.0; -MicroVegetDensity_max = 100.0; -MicroVegetDensity_step = 10.0; -MicroVegetDensity_ps0 = 10.0; // not used since disabled! -MicroVegetDensity_ps1 = 30.0; -MicroVegetDensity_ps2 = 80.0; -MicroVegetDensity_ps3 = 100.0; - - -// *** FX -FxNbMaxPoly = 20000; -FxNbMaxPoly_min = 2000; -FxNbMaxPoly_max = 50000; -FxNbMaxPoly_step= 2000; -FxNbMaxPoly_ps0 = 2000; -FxNbMaxPoly_ps1 = 10000; -FxNbMaxPoly_ps2 = 20000; -FxNbMaxPoly_ps3 = 50000; - -Cloud = 1; -Cloud_ps0 = 0 ; -Cloud_ps1 = 1 ; -Cloud_ps2 = 1 ; -Cloud_ps3 = 1 ; - -CloudQuality = 160.0; -CloudQuality_min = 80.0; -CloudQuality_max = 320.0; -CloudQuality_step = 20.0; -CloudQuality_ps0 = 80.0; // not used since disabled! -CloudQuality_ps1 = 80.0; -CloudQuality_ps2 = 160.0; -CloudQuality_ps3 = 320.0; - -CloudUpdate = 1; -CloudUpdate_min = 1; -CloudUpdate_max = 8; -CloudUpdate_step= 1; -CloudUpdate_ps0 = 1; // not used since disabled! -CloudUpdate_ps1 = 1; -CloudUpdate_ps2 = 1; -CloudUpdate_ps3 = 3; - -Shadows = 1; -Shadows_ps0 = 0; -Shadows_ps1 = 1; -Shadows_ps2 = 1; -Shadows_ps3 = 1; - -FXAA = 1; -FXAA_ps0 = 0; -FXAA_ps1 = 1; -FXAA_ps2 = 1; -FXAA_ps3 = 1; - -AnisotropicFilter = 0; - -Bloom = 1; -Bloom_ps0 = 0; -Bloom_ps1 = 1; -Bloom_ps2 = 1; -Bloom_ps3 = 1; - -SquareBloom = 1; -SquareBloom_ps0 = 0; -SquareBloom_ps1 = 1; -SquareBloom_ps2 = 1; -SquareBloom_ps3 = 1; - -DensityBloom = 255.0; -DensityBloom_min = 0.0; -DensityBloom_max = 255.0; -DensityBloom_step = 1.0; -DensityBloom_ps0 = 255.0; -DensityBloom_ps1 = 255.0; -DensityBloom_ps2 = 255.0; -DensityBloom_ps3 = 255.0; - - -// *** CHARACTERS -SkinNbMaxPoly = 100000; -SkinNbMaxPoly_min = 5000; -SkinNbMaxPoly_max = 250000; -SkinNbMaxPoly_step = 5000; -SkinNbMaxPoly_ps0 = 10000; -SkinNbMaxPoly_ps1 = 70000; -SkinNbMaxPoly_ps2 = 100000; -SkinNbMaxPoly_ps3 = 200000; - -NbMaxSkeletonNotCLod = 125; -NbMaxSkeletonNotCLod_min = 5; -NbMaxSkeletonNotCLod_max = 255; -NbMaxSkeletonNotCLod_step = 5; -NbMaxSkeletonNotCLod_ps0 = 10; -NbMaxSkeletonNotCLod_ps1 = 50; -NbMaxSkeletonNotCLod_ps2 = 125; -NbMaxSkeletonNotCLod_ps3 = 255; - -CharacterFarClip = 200.0; -CharacterFarClip_min = 50.0; -CharacterFarClip_max = 500.0; -CharacterFarClip_step = 10.0; -CharacterFarClip_ps0 = 50.0; -CharacterFarClip_ps1 = 100.0; -CharacterFarClip_ps2 = 200.0; -CharacterFarClip_ps3 = 500.0; - -EnableRacialAnimation = 1; - -// *** MISC -// This is the actual aspect ratio of your screen (no relation with the resolution!!). Set 1.7777 if you got a 16/9 screen for instance -ScreenAspectRatio = 0.0; -ForceDXTC = 1; // Enable/Disable DXTC. -DivideTextureSizeBy2= 0; // Divide texture size -DisableVtxProgram = 0; // Disable Hardware Vertex Program. -DisableVtxAGP = 0; // Disable Hardware Vertex AGP. -DisableTextureShdr = 0; // Disable Hardware Texture Shader. -HDEntityTexture = 1; -HDTextureInstalled = 1; -WaitVBL = 0; // 0 or 1 to wait Vertical Sync. - -////////////////// -// GAME OPTIONS // -////////////////// -SelectWithRClick = 1; -DisplayWeapons = 1; -RotKeySpeedMax = 2.0; -RotKeySpeedMax_min = 1.0; -RotKeySpeedMax_max = 4.0; -RotKeySpeedMin = 1.0; -RotKeySpeedMin_min = 0.5; -RotKeySpeedMin_max = 2.0; -RotAccel = 3.0; -FollowOnAtk = 0; -AtkOnSelect = 0; -ZCPacsPrim = "gen_bt_col_ext.pacs_prim"; - -///////////////// -// PREFERENCES // -///////////////// -FPV = 0; // FPV(First Person View) : default is false (Third Person View). -CameraHeight = 2.2; // Camera Height (in meter) from the ground (for the Third Person View). -CameraDistance = 3.0; // Camera Distance(in meter) from the user (for the Third Person View). -CameraDistStep = 1.0; -CameraDistMin = 1.0; -CameraDistMax = 25.0; -CameraAccel = 5.0; -CameraSpeedMin = 2.0; -CameraSpeedMax = 100.0; -CameraResetSpeed = 10.0; // Speed in radian/s - -////////////////// -// SOUND CONFIG // -////////////////// -SoundForceSoftwareBuffer= 1; -SoundOn = 1; -UseEax = 0; - -MaxTrack = 32; -MaxTrack_min = 4; -MaxTrack_max = 32; -MaxTrack_step = 4; - -// This is the volume for "InGame" sound FXs -SoundSFXVolume = 1.0; -SoundSFXVolume_min = 0.0; -SoundSFXVolume_max = 1.0; -SoundSFXVolume_step = 0.001; - -// This is volume for "InGame" music. Does not affect the MP3 player -SoundGameMusicVolume = 0.5; -SoundGameMusicVolume_min = 0.0; -SoundGameMusicVolume_max = 1.0; -SoundGameMusicVolume_step = 0.001; - -// MISC -PreDataPath = { "user", "data", "patch", "examples", }; -DataPath = { "data" }; -NeedComputeVS = 0; - -NegFiltersDebug = {"Update DB", "Reading:", "Read Value :", "impulseCallBack", "CLIMPD:", "LNET" }; -NegFiltersInfo = { "CLIMPD:", "CPath::lookup" , "LNET" }; -NegFiltersWarning = { "'basics.Equipment Slot'.", "_usercolor.tga", "PACS" }; - -// Big screen shot -ScreenShotWidth = 0; -ScreenShotHeight = 0; -ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots) - -// Read : "ID", "R G B A MODE [FX]" -SystemInfoColors = -{ -// OLD STUFF Here for compatibility -"RG", "0 0 0 255 normal", // Black to see when there is an error -"BC", "0 0 0 255 normal", // Black to see when there is an error -"JA", "0 0 0 255 normal", // Black to see when there is an error -"BL", "0 0 0 255 normal", // Black to see when there is an error -"VE", "0 0 0 255 normal", // Black to see when there is an error -"VI", "0 0 0 255 normal", // Black to see when there is an error - -// NEW System Info Categories -"SYS", "255 255 255 255 normal", // Default system messages -"BC", "255 255 255 255 centeraround", // Broadcast messages -"TAGBC", "255 255 255 255 centeraround", // Taged broadcast messages : color should remain white as some word are tagged -"XP", "255 255 64 255 over", // XP Gain -"SP", "255 255 64 255 over", // SP Gain -"TTL", "255 255 64 255 over", // Title -"TSK", "255 255 255 255 over", // Task -"ZON", "255 255 255 255 center", // Zone -"DG", "255 0 0 255 normal", // Damage to me -"DMG", "255 0 0 255 normal", // Damage to me -"DGP", "200 0 0 255 normal", // Damage to me from player -"DGM", "255 128 64 255 normal", // Damage from me -"MIS", "150 150 150 255 normal", // The opponent misses -"MISM", "255 255 255 255 normal", // I miss -"ITM", "0 200 0 255 over", // Item -"ITMO", "170 170 255 255 overonly", // Item other in group -"ITMF", "220 0 220 255 over", // Item failed -"SPL", "50 50 250 255 normal", // Spell to me -"SPLM", "50 150 250 255 normal", // Spell from me -"EMT", "255 150 150 255 normal", // Emote -"MTD", "255 255 0 255 over", // Message Of The Day -"FORLD","64 255 64 255 overonly", // Forage Locate Deposit -"CHK", "255 120 60 255 center", // Tous ce qui ne remplit pas une condition -"CHKCB","255 255 0 255 center", // Tous ce qui ne remplit pas une condition en combat (trop loin, cible invalide, pas assez de mana, etc.) -"PVPTM","255 120 60 255 overonly", // PVP timer -"THM", "255 255 64 255 over misc_levelup.ps", // Thema finished -"AMB", "255 255 64 255 center", // Ambiance -"ISE", "192 208 255 255 normal", // Item special effect -"ISE2", "192 208 255 255 center", // Item special effect with center text (for effects without flying text) -"OSM", "128 160 255 255 center", // Outpost state message -"AROUND","255 255 0 255 around", // Only in around channel -"R2_INVITE","0 255 0 255 around", // Ring invitation -}; - -PrintfCommands = { - "52", "15", "55 55 0 255", "28", "uiEon", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiEon", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", - "280", "255 255 255 255", "18", "" -}; - -PrintfCommandsFreeTrial = { - "52", "15", "55 55 0 255", "28", "uiEon", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiEon", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", - "280", "255 255 255 255", "18", "" -}; - -DisplayMissingAnimFile = 0; - -LoadingStringCount = 54; - - -// Some R2 parameters ... - -R2Mode = 1; -R2EDEnabled = 1; -R2EDExtendedDebug = 0; -R2EDLightPalette = 0; -R2ClientGw = "r2linux01"; -LoadLuaDebugger = 0; -CheckR2ScenarioMD5 = 1; -LevelDesignEnabled = 0; - -DmCameraDistMax = 25; -DmRun = 20; -DmWalk = 6; - -R2EDReloadFiles = { - "r2ed.xml", - "r2_basic_bricks.lua", - "r2_components.lua", - "r2_core.lua", - "r2_features_default.lua", - "r2_features_fauna.lua", - "r2_features_npc_groups.lua", - "r2_palette.lua", - "r2_scenario.lua", - "r2_ui.lua" -}; - -XMLInterfaceFiles = { - "config.xml", - "widgets.xml", - "webig_widgets.xml", - "player.xml", - "inventory.xml", - "interaction.xml", - "phrase.xml", - "harvest.xml", - "macros.xml", - "info_player.xml", - "outpost.xml", - "guild.xml", - "taskbar.xml", - "game_config.xml", - "game_context_menu.xml", - "player_trade.xml", - "bot_chat_v4.xml", - "compass.xml", - "map.xml", - "hierarchy.xml", - "reset.xml", - "actions.xml", - "help.xml", - "encyclopedia.xml", - "commands.xml", - "commands2.xml", - "ring_access_point_filter.xml", - "ring_window.xml", - "bg_downloader.xml" -}; - -XMLR2EDInterfaceFiles = -{ - "r2ed.xml", - "r2_triggers.xml", - "r2_logic_entities.xml", - "r2ed_acts.xml", - "r2ed_scenario.xml", - "r2ed_connect.xml" -}; - -FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth - - -// Hardware cursor textures -// These will be extracted from the corresponding packed ui .tga files when they are loaded -// * -// * individual .tga files for hardware cursor bitmap not looked for, and not supported yet -HardwareCursors = -{ - "curs_can_pan.tga", - "curs_can_pan_dup.tga", - "curs_create.tga", - "curs_create_multi.tga", - "curs_create_vertex_invalid.tga", - "curs_default.tga", - "curs_dup.tga", - "curs_L.tga", - "curs_M.tga", - "curs_pan.tga", - "curs_pan_dup.tga", - "curs_pick.tga", - "curs_pick_dup.tga", - "curs_R.tga", - "curs_resize_BL_TR.tga", - "curs_resize_BR_TL.tga", - "curs_resize_LR.tga", - "curs_resize_TB.tga", - "curs_rotate.tga", - "curs_scale.tga", - "curs_stop.tga", - "text_cursor.tga", - "r2_hand_can_pan.tga", - "r2_hand_pan.tga", - "r2ed_tool_can_pick.tga", - "r2ed_tool_can_rotate.tga", - "r2ed_tool_pick.tga", - "r2ed_tool_rotate.tga", - "r2ed_tool_rotating.tga" -}; - -Loading_BG = "new_loading_bg.tga"; // Default name for the loading background file. -Launch_BG = "new_launcher_bg.tga"; // Default name for the launch background file. -TeleportKami_BG = "new_teleport_kami_bg.tga"; -TeleportKaravan_BG = "new_teleport_caravan_bg.tga"; -Elevator_BG = "new_elevator_bg.tga"; // Default name for the loading background file. -ResurectKami_BG = "new_resurect_kami_bg.tga"; -ResurectKaravan_BG = "new_resurect_caravane_bg.tga"; -End_BG = "end_bg.tga"; // Default name for the last background file. - -ScenarioSavePath = "./my_scenarios/"; - -// list ofpredefined keyset -// name will be looked up in the translation file by searching 'uiCP_KeysetName_" + id -// tooltip will be looked up in the translation file by searching 'uiCP_KeysetTooltip_" + id -// 'bi.' stands for built-in -// note : we add a dot in the name to be sure that there cannot be a conflict with character keyset name -BuiltInKeySets = -{ - "", // default khanat keyboard layout - "bi.zqsd", // european keyboard fps displacement style (NB : don't change this layout name, ryzom will automatically select it if keyboard is french or belgian) - "bi.wasd", // english keyboard fps displacement style (NB : don't change this layout name, ryzom will automatically select it if keyboard is not french nor belgian) - "bi.wow_alike" // 'world of warcraft' like keyboard style. (NB : not available for ring) -}; - -// "Newbie Training", "Story Telling", "Mistery", "Hack & Slash", "Guild Training", "Other" -ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_slash","so_guild_training","so_other"}; - -ScenarioLanguages = {"fr","de","en","other_lang"}; - -// Map each language to a forum help page -HelpPages = -{ - "fr=http://www.khaganat.net/forum/index.php/board,31.0.html", - "en=http://www.khaganat.net/forum/index.php/board,31.0.html", - "wk=http://www.khaganat.net/forum/index.php/board,31.0.html", - "de=http://www.khaganat.net/forum/index.php/board,31.0.html", - "es=http://www.khaganat.net/forum/index.php/board,31.0.html", - "ru=http://www.khaganat.net/forum/index.php/board,31.0.html" -}; - -WebIgMainDomain = "app.lirria.khaganat.net"; -WebIgTrustedDomains = { - "api.lirria.khaganat.net", "app.lirria.khaganat.net", "lirria.khaganat.net" -}; -//PatchletUrl = ""; - -SelectedSlot = 0; - -BuildName = "RELEASE_HEAD"; +////////////////////////// +/// CLIENT CONFIG FILE /// +////////////////////////// +////////////////////////// + +////////////////////////// + +// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. +// You will loose all the comments and identation in this file. +SaveConfig = 1; + +/////////////////// +// WINDOW CONFIG // +/////////////////// + +Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" + // "Auto" will choose the best suited driver depending on hardware +FullScreen = 0; +Width = 0; +Height = 0; +PositionX = 0; +PositionY = 0; +Frequency = 0; +Depth = 32; +Sleep = -1; +ProcessPriority = 0; // -2 = idle, -1 = below normal, 0 = normal, 1 = above normal, 2 = high, 3 = real time +Contrast = 0.0; // -1.0 ~ 1.0 +Luminosity = 0.0; // -1.0 ~ 1.0 +Gamma = 0.0; // -1.0 ~ 1.0 +Contrast_min = -1.0; +Luminosity_min = -1.0; +Gamma_min = -1.0; +Contrast_max = 1.0; +Luminosity_max = 1.0; +Gamma_max = 1.0; + + +///////////// +// NETWORK // +///////////// + +Application = { "Lirria", "./client_ryzom_r.exe", "./" }; +BackgroundDownloader = 0; +PatchWanted = 1; +PatchUrl = "http://lirria.khaganat.net:43435"; +RingReleaseNotePath = "http://lirria.khaganat.net/patch/index.php"; +StartupHost = "lirria.khaganat.net:40916"; +StartupPage = "/login/r2_login.php"; +InstallStatsUrl = "http://lirria.khaganat.net:50000/stats/stats.php"; + +CreateAccountURL = "http://lirria.khaganat.net/ams/?page=register"; +EditAccountURL = "http://lirria.khaganat.net/"; +ForgetPwdURL = "http://lirria.khaganat.net/ams/index.php?page=forgot_password"; +//FreeTrialURL = "http://lirria.khaganat.net/"; +LoginSupportURL = "http://lirria.khaganat.net/"; +ConditionsTermsURL = "khaganat.net/wikhan/fr:charte"; + + + +//////////////// +// INTERFACES // +//////////////// + +// the language to use as in ISO 639-2 +LanguageCode = "fr"; // english + +XMLInputFile = "input_config_v3.xml"; + +XMLLoginInterfaceFiles = { + "login_config.xml", + "login_widgets.xml", + "login_main.xml", + "login_keys.xml", +}; + +XMLOutGameInterfaceFiles = { + "out_v2_config.xml", + "out_v2_widgets.xml", + "out_v2_connect.xml", + "out_v2_intro.xml", + "out_v2_select.xml", + "out_v2_appear.xml", + "out_v2_location.xml", + "out_v2_crash.xml", + "out_v2_hierarchy.xml", + "out_v2_keys.xml", +}; + + TexturesInterface = { + "interface_game_khaganat" + }; + TexturesLoginInterface = { + "interface_login_khaganat" + }; + TexturesOutGameInterface = { + "interface_outgame_khaganat" + }; +// The ligo primitive class file +LigoPrimitiveClass = "world_editor_classes.xml"; + +VerboseLog = 1; + +/////////// +// MOUSE // +/////////// +HardwareCursor = 1; + +CursorSpeed = 1.0; // In pixels per mickey +CursorSpeed_min = 0.5; +CursorSpeed_max = 2.0; + +CursorAcceleration = 40; // Threshold in mickey +CursorAcceleration_min = 20; +CursorAcceleration_max = 80; + +FreeLookSpeed = 0.004; // In radian per mickey +FreeLookSpeed_min = 0.0001; +FreeLookSpeed_max = 0.01; + +FreeLookAcceleration = 40; // Threshold in mickey +FreeLookAcceleration_min = 20; +FreeLookAcceleration_max = 80; + +FreeLookInverted = 0; +FreeLookTablet = 0; +AutomaticCamera = 0; +DblClickMode = 1; +AutoEquipTool = 1; + +/////////////////// +// RENDER CONFIG // +/////////////////// + +// NB: thoses variables configure also the InGameConfigurator: +// _min and _max define the bounds +// _step defines the step (NB: take care of _min and _max!!) +// _ps0 is the LOW preset, _ps1 is the MEDIUM preset, _ps2 is the NORMAL Preset, and _ps3 is the HIGH one + + +// *** LANDSCAPE +LandscapeTileNear = 50.000000; +LandscapeTileNear_min = 20.000000; +LandscapeTileNear_max = 100.000000; +LandscapeTileNear_step = 10.0; +LandscapeTileNear_ps0 = 20.0; +LandscapeTileNear_ps1 = 40.0; +LandscapeTileNear_ps2 = 50.0; +LandscapeTileNear_ps3 = 80.0; + +// NB: threshold is inverted ULandscape::setThreshold(), to be more intelligible +LandscapeThreshold = 1000.0; +LandscapeThreshold_min = 100.0; // Low quality => 0.01 threshold +LandscapeThreshold_max = 2000.0; // High quality => 0.0005 threshold +LandscapeThreshold_step = 100.0; +LandscapeThreshold_ps0 = 100.0; +LandscapeThreshold_ps1 = 500.0; +LandscapeThreshold_ps2 = 1000.0; +LandscapeThreshold_ps3 = 2000.0; + +Vision = 500.000000; +Vision_min = 200.000000; +Vision_max = 800.000000; +Vision_step = 100.000000; +Vision_ps0 = 200.0; +Vision_ps1 = 400.0; +Vision_ps2 = 500.0; +Vision_ps3 = 800.0; + +MicroVeget = 1; // Enable/Disable MicroVeget. +MicroVeget_ps0 = 0; +MicroVeget_ps1 = 1; +MicroVeget_ps2 = 1; +MicroVeget_ps3 = 1; + +MicroVegetDensity = 80.0; +MicroVegetDensity_min = 10.0; +MicroVegetDensity_max = 100.0; +MicroVegetDensity_step = 10.0; +MicroVegetDensity_ps0 = 10.0; // not used since disabled! +MicroVegetDensity_ps1 = 30.0; +MicroVegetDensity_ps2 = 80.0; +MicroVegetDensity_ps3 = 100.0; + + +// *** FX +FxNbMaxPoly = 20000; +FxNbMaxPoly_min = 2000; +FxNbMaxPoly_max = 50000; +FxNbMaxPoly_step= 2000; +FxNbMaxPoly_ps0 = 2000; +FxNbMaxPoly_ps1 = 10000; +FxNbMaxPoly_ps2 = 20000; +FxNbMaxPoly_ps3 = 50000; + +Cloud = 1; +Cloud_ps0 = 0 ; +Cloud_ps1 = 1 ; +Cloud_ps2 = 1 ; +Cloud_ps3 = 1 ; + +CloudQuality = 160.0; +CloudQuality_min = 80.0; +CloudQuality_max = 320.0; +CloudQuality_step = 20.0; +CloudQuality_ps0 = 80.0; // not used since disabled! +CloudQuality_ps1 = 80.0; +CloudQuality_ps2 = 160.0; +CloudQuality_ps3 = 320.0; + +CloudUpdate = 1; +CloudUpdate_min = 1; +CloudUpdate_max = 8; +CloudUpdate_step= 1; +CloudUpdate_ps0 = 1; // not used since disabled! +CloudUpdate_ps1 = 1; +CloudUpdate_ps2 = 1; +CloudUpdate_ps3 = 3; + +Shadows = 1; +Shadows_ps0 = 0; +Shadows_ps1 = 1; +Shadows_ps2 = 1; +Shadows_ps3 = 1; + +FXAA = 1; +FXAA_ps0 = 0; +FXAA_ps1 = 1; +FXAA_ps2 = 1; +FXAA_ps3 = 1; + +AnisotropicFilter = 0; + +Bloom = 1; +Bloom_ps0 = 0; +Bloom_ps1 = 1; +Bloom_ps2 = 1; +Bloom_ps3 = 1; + +SquareBloom = 1; +SquareBloom_ps0 = 0; +SquareBloom_ps1 = 1; +SquareBloom_ps2 = 1; +SquareBloom_ps3 = 1; + +DensityBloom = 255.0; +DensityBloom_min = 0.0; +DensityBloom_max = 255.0; +DensityBloom_step = 1.0; +DensityBloom_ps0 = 255.0; +DensityBloom_ps1 = 255.0; +DensityBloom_ps2 = 255.0; +DensityBloom_ps3 = 255.0; + + +// *** CHARACTERS +SkinNbMaxPoly = 100000; +SkinNbMaxPoly_min = 5000; +SkinNbMaxPoly_max = 250000; +SkinNbMaxPoly_step = 5000; +SkinNbMaxPoly_ps0 = 10000; +SkinNbMaxPoly_ps1 = 70000; +SkinNbMaxPoly_ps2 = 100000; +SkinNbMaxPoly_ps3 = 200000; + +NbMaxSkeletonNotCLod = 125; +NbMaxSkeletonNotCLod_min = 5; +NbMaxSkeletonNotCLod_max = 255; +NbMaxSkeletonNotCLod_step = 5; +NbMaxSkeletonNotCLod_ps0 = 10; +NbMaxSkeletonNotCLod_ps1 = 50; +NbMaxSkeletonNotCLod_ps2 = 125; +NbMaxSkeletonNotCLod_ps3 = 255; + +CharacterFarClip = 200.0; +CharacterFarClip_min = 50.0; +CharacterFarClip_max = 500.0; +CharacterFarClip_step = 10.0; +CharacterFarClip_ps0 = 50.0; +CharacterFarClip_ps1 = 100.0; +CharacterFarClip_ps2 = 200.0; +CharacterFarClip_ps3 = 500.0; + +EnableRacialAnimation = 1; + +// *** MISC +// This is the actual aspect ratio of your screen (no relation with the resolution!!). Set 1.7777 if you got a 16/9 screen for instance +ScreenAspectRatio = 0.0; +ForceDXTC = 1; // Enable/Disable DXTC. +DivideTextureSizeBy2= 0; // Divide texture size +DisableVtxProgram = 0; // Disable Hardware Vertex Program. +DisableVtxAGP = 0; // Disable Hardware Vertex AGP. +DisableTextureShdr = 0; // Disable Hardware Texture Shader. +HDEntityTexture = 1; +HDTextureInstalled = 1; +WaitVBL = 0; // 0 or 1 to wait Vertical Sync. + +////////////////// +// GAME OPTIONS // +////////////////// +SelectWithRClick = 1; +DisplayWeapons = 1; +RotKeySpeedMax = 2.0; +RotKeySpeedMax_min = 1.0; +RotKeySpeedMax_max = 4.0; +RotKeySpeedMin = 1.0; +RotKeySpeedMin_min = 0.5; +RotKeySpeedMin_max = 2.0; +RotAccel = 3.0; +FollowOnAtk = 0; +AtkOnSelect = 0; +ZCPacsPrim = "gen_bt_col_ext.pacs_prim"; + +///////////////// +// PREFERENCES // +///////////////// +FPV = 0; // FPV(First Person View) : default is false (Third Person View). +CameraHeight = 2.2; // Camera Height (in meter) from the ground (for the Third Person View). +CameraDistance = 3.0; // Camera Distance(in meter) from the user (for the Third Person View). +CameraDistStep = 1.0; +CameraDistMin = 1.0; +CameraDistMax = 25.0; +CameraAccel = 5.0; +CameraSpeedMin = 2.0; +CameraSpeedMax = 100.0; +CameraResetSpeed = 10.0; // Speed in radian/s + +////////////////// +// SOUND CONFIG // +////////////////// +SoundForceSoftwareBuffer= 1; +SoundOn = 1; +UseEax = 0; + +MaxTrack = 32; +MaxTrack_min = 4; +MaxTrack_max = 32; +MaxTrack_step = 4; + +// This is the volume for "InGame" sound FXs +SoundSFXVolume = 1.0; +SoundSFXVolume_min = 0.0; +SoundSFXVolume_max = 1.0; +SoundSFXVolume_step = 0.001; + +// This is volume for "InGame" music. Does not affect the MP3 player +SoundGameMusicVolume = 0.5; +SoundGameMusicVolume_min = 0.0; +SoundGameMusicVolume_max = 1.0; +SoundGameMusicVolume_step = 0.001; + +// MISC +PreDataPath = { "user", "data", "patch", "examples", }; +DataPath = { "data" }; +NeedComputeVS = 0; + +NegFiltersDebug = {"Update DB", "Reading:", "Read Value :", "impulseCallBack", "CLIMPD:", "LNET" }; +NegFiltersInfo = { "CLIMPD:", "CPath::lookup" , "LNET" }; +NegFiltersWarning = { "'basics.Equipment Slot'.", "_usercolor.tga", "PACS" }; + +// Big screen shot +ScreenShotWidth = 0; +ScreenShotHeight = 0; +ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots) + +// Read : "ID", "R G B A MODE [FX]" +SystemInfoColors = +{ +// OLD STUFF Here for compatibility +"RG", "0 0 0 255 normal", // Black to see when there is an error +"BC", "0 0 0 255 normal", // Black to see when there is an error +"JA", "0 0 0 255 normal", // Black to see when there is an error +"BL", "0 0 0 255 normal", // Black to see when there is an error +"VE", "0 0 0 255 normal", // Black to see when there is an error +"VI", "0 0 0 255 normal", // Black to see when there is an error + +// NEW System Info Categories +"SYS", "255 255 255 255 normal", // Default system messages +"BC", "255 255 255 255 centeraround", // Broadcast messages +"TAGBC", "255 255 255 255 centeraround", // Taged broadcast messages : color should remain white as some word are tagged +"XP", "255 255 64 255 over", // XP Gain +"SP", "255 255 64 255 over", // SP Gain +"TTL", "255 255 64 255 over", // Title +"TSK", "255 255 255 255 over", // Task +"ZON", "255 255 255 255 center", // Zone +"DG", "255 0 0 255 normal", // Damage to me +"DMG", "255 0 0 255 normal", // Damage to me +"DGP", "200 0 0 255 normal", // Damage to me from player +"DGM", "255 128 64 255 normal", // Damage from me +"MIS", "150 150 150 255 normal", // The opponent misses +"MISM", "255 255 255 255 normal", // I miss +"ITM", "0 200 0 255 over", // Item +"ITMO", "170 170 255 255 overonly", // Item other in group +"ITMF", "220 0 220 255 over", // Item failed +"SPL", "50 50 250 255 normal", // Spell to me +"SPLM", "50 150 250 255 normal", // Spell from me +"EMT", "255 150 150 255 normal", // Emote +"MTD", "255 255 0 255 over", // Message Of The Day +"FORLD","64 255 64 255 overonly", // Forage Locate Deposit +"CHK", "255 120 60 255 center", // Tous ce qui ne remplit pas une condition +"CHKCB","255 255 0 255 center", // Tous ce qui ne remplit pas une condition en combat (trop loin, cible invalide, pas assez de mana, etc.) +"PVPTM","255 120 60 255 overonly", // PVP timer +"THM", "255 255 64 255 over misc_levelup.ps", // Thema finished +"AMB", "255 255 64 255 center", // Ambiance +"ISE", "192 208 255 255 normal", // Item special effect +"ISE2", "192 208 255 255 center", // Item special effect with center text (for effects without flying text) +"OSM", "128 160 255 255 center", // Outpost state message +"AROUND","255 255 0 255 around", // Only in around channel +"R2_INVITE","0 255 0 255 around", // Ring invitation +}; + +PrintfCommands = { + "52", "15", "55 55 0 255", "28", "uiEon", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiEon", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", + "280", "255 255 255 255", "18", "" +}; + +PrintfCommandsFreeTrial = { + "52", "15", "55 55 0 255", "28", "uiEon", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiEon", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", + "280", "255 255 255 255", "18", "" +}; + +DisplayMissingAnimFile = 0; + +LoadingStringCount = 54; + + +// Some R2 parameters ... + +R2Mode = 1; +R2EDEnabled = 1; +R2EDExtendedDebug = 0; +R2EDLightPalette = 0; +R2ClientGw = "r2linux01"; +LoadLuaDebugger = 0; +CheckR2ScenarioMD5 = 1; +LevelDesignEnabled = 0; + +DmCameraDistMax = 25; +DmRun = 20; +DmWalk = 6; + +R2EDReloadFiles = { + "r2ed.xml", + "r2_basic_bricks.lua", + "r2_components.lua", + "r2_core.lua", + "r2_features_default.lua", + "r2_features_fauna.lua", + "r2_features_npc_groups.lua", + "r2_palette.lua", + "r2_scenario.lua", + "r2_ui.lua" +}; + +XMLInterfaceFiles = { + "config.xml", + "widgets.xml", + "webig_widgets.xml", + "appzone.xml", + "player.xml", + "inventory.xml", + "interaction.xml", + "phrase.xml", + "harvest.xml", + "macros.xml", + "info_player.xml", + "outpost.xml", + "guild.xml", + "taskbar.xml", + "game_config.xml", + "game_context_menu.xml", + "player_trade.xml", + "bot_chat_v4.xml", + "compass.xml", + "map.xml", + "hierarchy.xml", + "reset.xml", + "actions.xml", + "help.xml", + "encyclopedia.xml", + "commands.xml", + "commands2.xml", + "ring_access_point_filter.xml", + "ring_window.xml", + "bg_downloader.xml", + "ryzhome_toolbar.xml" +}; + +XMLR2EDInterfaceFiles = +{ + "r2ed.xml", + "r2_triggers.xml", + "r2_logic_entities.xml", + "r2ed_acts.xml", + "r2ed_scenario.xml", + "r2ed_connect.xml" +}; + +FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth + + +// Hardware cursor textures +// These will be extracted from the corresponding packed ui .tga files when they are loaded +// * +// * individual .tga files for hardware cursor bitmap not looked for, and not supported yet +HardwareCursors = +{ + "curs_can_pan.tga", + "curs_can_pan_dup.tga", + "curs_create.tga", + "curs_create_multi.tga", + "curs_create_vertex_invalid.tga", + "curs_default.tga", + "curs_dup.tga", + "curs_L.tga", + "curs_M.tga", + "curs_pan.tga", + "curs_pan_dup.tga", + "curs_pick.tga", + "curs_pick_dup.tga", + "curs_R.tga", + "curs_resize_BL_TR.tga", + "curs_resize_BR_TL.tga", + "curs_resize_LR.tga", + "curs_resize_TB.tga", + "curs_rotate.tga", + "curs_scale.tga", + "curs_stop.tga", + "text_cursor.tga", + "r2_hand_can_pan.tga", + "r2_hand_pan.tga", + "r2ed_tool_can_pick.tga", + "r2ed_tool_can_rotate.tga", + "r2ed_tool_pick.tga", + "r2ed_tool_rotate.tga", + "r2ed_tool_rotating.tga" +}; + +Loading_BG = "new_loading_bg.tga"; // Default name for the loading background file. +Launch_BG = "new_launcher_bg.tga"; // Default name for the launch background file. +TeleportKami_BG = "new_teleport_kami_bg.tga"; +TeleportKaravan_BG = "new_teleport_caravan_bg.tga"; +Elevator_BG = "new_elevator_bg.tga"; // Default name for the loading background file. +ResurectKami_BG = "new_resurect_kami_bg.tga"; +ResurectKaravan_BG = "new_resurect_caravane_bg.tga"; +End_BG = "end_bg.tga"; // Default name for the last background file. + +ScenarioSavePath = "./my_scenarios/"; + +// list ofpredefined keyset +// name will be looked up in the translation file by searching 'uiCP_KeysetName_" + id +// tooltip will be looked up in the translation file by searching 'uiCP_KeysetTooltip_" + id +// 'bi.' stands for built-in +// note : we add a dot in the name to be sure that there cannot be a conflict with character keyset name +BuiltInKeySets = +{ + "", // default khanat keyboard layout + "bi.zqsd", // european keyboard fps displacement style (NB : don't change this layout name, ryzom will automatically select it if keyboard is french or belgian) + "bi.wasd", // english keyboard fps displacement style (NB : don't change this layout name, ryzom will automatically select it if keyboard is not french nor belgian) + "bi.wow_alike" // 'world of warcraft' like keyboard style. (NB : not available for ring) +}; + +// "Newbie Training", "Story Telling", "Mistery", "Hack & Slash", "Guild Training", "Other" +ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_slash","so_guild_training","so_other"}; + +ScenarioLanguages = {"fr","de","en","other_lang"}; + +// Map each language to a forum help page +HelpPages = +{ + "fr=http://www.khaganat.net/forum/index.php/board,31.0.html", + "en=http://www.khaganat.net/forum/index.php/board,31.0.html", + "wk=http://www.khaganat.net/forum/index.php/board,31.0.html", + "de=http://www.khaganat.net/forum/index.php/board,31.0.html", + "es=http://www.khaganat.net/forum/index.php/board,31.0.html", + "ru=http://www.khaganat.net/forum/index.php/board,31.0.html" +}; + +WebIgMainDomain = "app.lirria.khaganat.net"; +WebIgTrustedDomains = { + "api.lirria.khaganat.net", "app.lirria.khaganat.net", "lirria.khaganat.net" +}; +//PatchletUrl = ""; +WebIgMainDomain = "app.ryzom.com"; +WebIgTrustedDomains = { + "api.ryzom.com", "app.ryzom.com" +}; +PatchletUrl = "http://app.ryzom.com/app_patchlet/index.php?patch=preload"; + +SelectedSlot = 0; + +BuildName = "RELEASE_HEAD"; diff --git a/code/ryzom/client/data/gamedev/fd.cmd b/code/ryzom/client/data/gamedev/fd.cmd index 9f9dec1a9..df7982dc5 100644 --- a/code/ryzom/client/data/gamedev/fd.cmd +++ b/code/ryzom/client/data/gamedev/fd.cmd @@ -1,696 +1,696 @@ - -db SERVER:INTERFACES:FLAGS 255 - - - -db SERVER:CHARACTER_INFO:SCORES:MaxChaScore1 100 -db SERVER:CHARACTER_INFO:SCORES:BaseChaScore1 120 -db SERVER:CHARACTER_INFO:SCORES:MaxChaScore2 120 -db SERVER:CHARACTER_INFO:SCORES:BaseChaScore2 100 -db SERVER:CHARACTER_INFO:SCORES:MaxChaScore3 100 -db SERVER:CHARACTER_INFO:SCORES:BaseChaScore3 100 -db SERVER:CHARACTER_INFO:SCORES:MaxChaScore4 100 -db SERVER:CHARACTER_INFO:SCORES:BaseChaScore4 100 - -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha1 33 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha1Reg 100 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha2 50 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha2Reg 30 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha3 30 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha3Reg 420 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha4 121 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha4Reg 654 - - -db SERVER:USER:SKILL_POINTS 1000 -db SERVER:TARGET:BARS:ChaScore1 80 -db SERVER:TARGET:BARS:ChaScore2 32 -db SERVER:TARGET:BARS:ChaScore3 69 -db SERVER:TARGET:BARS:ChaScore4 95 - - - -// Default Quantities -db SERVER:INVENTORY:BAG:0:QUANTITY 1 -db SERVER:INVENTORY:BAG:1:QUANTITY 1 -db SERVER:INVENTORY:BAG:2:QUANTITY 1 -db SERVER:INVENTORY:BAG:3:QUANTITY 1 -db SERVER:INVENTORY:BAG:4:QUANTITY 1 -db SERVER:INVENTORY:BAG:5:QUANTITY 1 -db SERVER:INVENTORY:BAG:6:QUANTITY 1 -db SERVER:INVENTORY:BAG:7:QUANTITY 1 -db SERVER:INVENTORY:BAG:8:QUANTITY 1 -db SERVER:INVENTORY:BAG:9:QUANTITY 1 -db SERVER:INVENTORY:BAG:10:QUANTITY 1 -db SERVER:INVENTORY:BAG:11:QUANTITY 1 -db SERVER:INVENTORY:BAG:12:QUANTITY 1 -db SERVER:INVENTORY:BAG:13:QUANTITY 1 -db SERVER:INVENTORY:BAG:14:QUANTITY 1 -db SERVER:INVENTORY:BAG:15:QUANTITY 1 -db SERVER:INVENTORY:BAG:16:QUANTITY 1 -db SERVER:INVENTORY:BAG:17:QUANTITY 1 -db SERVER:INVENTORY:BAG:18:QUANTITY 1 -db SERVER:INVENTORY:BAG:19:QUANTITY 1 -db SERVER:INVENTORY:BAG:20:QUANTITY 1 -db SERVER:INVENTORY:BAG:21:QUANTITY 1 -db SERVER:INVENTORY:BAG:22:QUANTITY 1 -db SERVER:INVENTORY:BAG:23:QUANTITY 1 -db SERVER:INVENTORY:BAG:24:QUANTITY 1 -db SERVER:INVENTORY:BAG:25:QUANTITY 1 -db SERVER:INVENTORY:BAG:26:QUANTITY 1 -db SERVER:INVENTORY:BAG:27:QUANTITY 1 -db SERVER:INVENTORY:BAG:28:QUANTITY 1 -db SERVER:INVENTORY:BAG:29:QUANTITY 1 -db SERVER:INVENTORY:BAG:30:QUANTITY 1 -db SERVER:INVENTORY:BAG:31:QUANTITY 1 -db SERVER:INVENTORY:BAG:32:QUANTITY 1 -db SERVER:INVENTORY:BAG:33:QUANTITY 1 -db SERVER:INVENTORY:BAG:34:QUANTITY 1 -db SERVER:INVENTORY:BAG:35:QUANTITY 1 -db SERVER:INVENTORY:BAG:36:QUANTITY 1 -db SERVER:INVENTORY:BAG:37:QUANTITY 1 -db SERVER:INVENTORY:BAG:38:QUANTITY 1 -db SERVER:INVENTORY:BAG:39:QUANTITY 1 -db SERVER:INVENTORY:BAG:40:QUANTITY 1 -db SERVER:INVENTORY:BAG:41:QUANTITY 1 -db SERVER:INVENTORY:BAG:42:QUANTITY 1 -db SERVER:INVENTORY:BAG:43:QUANTITY 1 -db SERVER:INVENTORY:BAG:44:QUANTITY 1 -db SERVER:INVENTORY:BAG:45:QUANTITY 1 -db SERVER:INVENTORY:BAG:46:QUANTITY 1 -db SERVER:INVENTORY:BAG:47:QUANTITY 1 -db SERVER:INVENTORY:BAG:48:QUANTITY 1 -db SERVER:INVENTORY:BAG:49:QUANTITY 1 -db SERVER:INVENTORY:BAG:50:QUANTITY 1 -db SERVER:INVENTORY:BAG:51:QUANTITY 1 -db SERVER:INVENTORY:BAG:52:QUANTITY 1 -db SERVER:INVENTORY:BAG:53:QUANTITY 1 -db SERVER:INVENTORY:BAG:54:QUANTITY 1 -db SERVER:INVENTORY:BAG:55:QUANTITY 1 -db SERVER:INVENTORY:BAG:56:QUANTITY 1 -db SERVER:INVENTORY:BAG:57:QUANTITY 1 -db SERVER:INVENTORY:BAG:58:QUANTITY 1 -db SERVER:INVENTORY:BAG:59:QUANTITY 1 - - - -db SERVER:INVENTORY:BAG:0:SHEET icmalp.sitem -db SERVER:INVENTORY:BAG:0:QUALITY 66 -db SERVER:INVENTORY:BAG:0:QUANTITY 1 -db SERVER:INVENTORY:BAG:0:USER_COLOR 2 -db SERVER:INVENTORY:BAG:0:LOCKED 0 -db SERVER:INVENTORY:BAG:0:WEIGHT 100 -db SERVER:INVENTORY:BAG:0:NAMEID 18 -db SERVER:INVENTORY:BAG:0:INFO_VERSION 11 -db SERVER:INVENTORY:BAG:0:ENCHANT 99 -db SERVER:INVENTORY:BAG:0:RM_CLASS_TYPE 3 -db SERVER:INVENTORY:BAG:0:RM_FABER_STAT_TYPE 5 - -db SERVER:INVENTORY:BAG:1:SHEET ictalp.sitem -db SERVER:INVENTORY:BAG:1:QUALITY 50 -db SERVER:INVENTORY:BAG:1:WEIGHT 50 - -db SERVER:INVENTORY:BAG:2:SHEET icfm1ss.sitem -db SERVER:INVENTORY:BAG:2:QUALITY 0 -db SERVER:INVENTORY:BAG:2:WEIGHT 35 -db SERVER:INVENTORY:BAG:2:RM_CLASS_TYPE 4 -db SERVER:INVENTORY:BAG:2:RM_FABER_STAT_TYPE 3 - -db SERVER:INVENTORY:BAG:3:SHEET icfm2pp.sitem -db SERVER:INVENTORY:BAG:3:QUALITY 50 -db SERVER:INVENTORY:BAG:3:WEIGHT 150 - -db SERVER:INVENTORY:BAG:4:SHEET icmm2bm.sitem -db SERVER:INVENTORY:BAG:4:QUALITY 50 -db SERVER:INVENTORY:BAG:4:WEIGHT 90 - -db SERVER:INVENTORY:BAG:5:SHEET icmp1bs.sitem -db SERVER:INVENTORY:BAG:5:QUALITY 50 -db SERVER:INVENTORY:BAG:5:WEIGHT 33 -db SERVER:INVENTORY:BAG:5:QUANTITY 12 - -db SERVER:INVENTORY:BAG:6:SHEET icmp2rp.sitem -db SERVER:INVENTORY:BAG:6:QUALITY 50 -db SERVER:INVENTORY:BAG:6:WEIGHT 77 -db SERVER:INVENTORY:BAG:6:QUANTITY 12 - -db SERVER:INVENTORY:BAG:7:SHEET icmja.sitem -db SERVER:INVENTORY:BAG:7:QUALITY 50 -db SERVER:INVENTORY:BAG:7:WEIGHT 161 - -db SERVER:INVENTORY:BAG:8:SHEET icmjp.sitem -db SERVER:INVENTORY:BAG:8:QUALITY 50 -db SERVER:INVENTORY:BAG:8:WEIGHT 88 - -db SERVER:INVENTORY:BAG:9:SHEET icmr2b.sitem -db SERVER:INVENTORY:BAG:9:QUALITY 50 -db SERVER:INVENTORY:BAG:9:WEIGHT 185 - -db SERVER:INVENTORY:BAG:10:SHEET icmm1sa.sitem -db SERVER:INVENTORY:BAG:10:QUALITY 50 -db SERVER:INVENTORY:BAG:10:WEIGHT 12 - -db SERVER:INVENTORY:BAG:11:SHEET icmm1pd.sitem -db SERVER:INVENTORY:BAG:11:QUALITY 50 -db SERVER:INVENTORY:BAG:11:WEIGHT 13 - -db SERVER:INVENTORY:BAG:12:SHEET iccm2ms.sitem -db SERVER:INVENTORY:BAG:12:QUALITY 50 -db SERVER:INVENTORY:BAG:12:WEIGHT 117 - -db SERVER:INVENTORY:BAG:15:SHEET iapj3.sitem -db SERVER:INVENTORY:BAG:15:QUALITY 50 -db SERVER:INVENTORY:BAG:15:WEIGHT 5 -db SERVER:INVENTORY:BAG:15:QUALITY 5 - -db SERVER:INVENTORY:BAG:24:SHEET itforage.sitem -db SERVER:INVENTORY:BAG:24:QUALITY 50 -db SERVER:INVENTORY:BAG:24:WEIGHT 35 - -db SERVER:INVENTORY:BAG:50:SHEET icfamp.sitem -db SERVER:INVENTORY:BAG:50:QUALITY 50 -db SERVER:INVENTORY:BAG:50:WEIGHT 35 - -db SERVER:INVENTORY:BAG:51:SHEET icfahp.sitem -db SERVER:INVENTORY:BAG:51:QUALITY 50 -db SERVER:INVENTORY:BAG:51:WEIGHT 35 - -db SERVER:INVENTORY:BAG:52:SHEET iccsb.sitem -db SERVER:INVENTORY:BAG:52:QUALITY 50 -db SERVER:INVENTORY:BAG:52:WEIGHT 35 - -db SERVER:INVENTORY:BAG:53:SHEET iccss.sitem -db SERVER:INVENTORY:BAG:53:QUALITY 50 -db SERVER:INVENTORY:BAG:53:WEIGHT 35 - -db SERVER:INVENTORY:BAG:54:SHEET iccm2ms.sitem -db SERVER:INVENTORY:BAG:54:QUALITY 50 -db SERVER:INVENTORY:BAG:54:WEIGHT 35 - - - -db SERVER:INVENTORY:MONEY 8532 - -// Faber -// Tool -db SERVER:INVENTORY:BAG:11:SHEET itmwea.sitem -db SERVER:INVENTORY:BAG:11:QUANTITY 1 -db SERVER:INVENTORY:BAG:11:QUALITY 5 -db SERVER:INVENTORY:BAG:12:SHEET itarmor.sitem -db SERVER:INVENTORY:BAG:12:QUANTITY 1 -db SERVER:INVENTORY:BAG:12:QUALITY 5 -db SERVER:INVENTORY:BAG:13:SHEET itrwea.sitem -db SERVER:INVENTORY:BAG:13:QUANTITY 1 -db SERVER:INVENTORY:BAG:13:QUALITY 5 -db SERVER:INVENTORY:BAG:14:SHEET itammo.sitem -db SERVER:INVENTORY:BAG:14:QUANTITY 1 -db SERVER:INVENTORY:BAG:14:QUALITY 10 -db SERVER:INVENTORY:BAG:54:SHEET itjewel.sitem -db SERVER:INVENTORY:BAG:54:QUANTITY 1 -db SERVER:INVENTORY:BAG:54:QUALITY 10 - - - -db SERVER:INVENTORY:BAG:16:SHEET m0741dxacc01.sitem -db SERVER:INVENTORY:BAG:16:QUANTITY 121 -db SERVER:INVENTORY:BAG:16:QUALITY 2 -// Mp-2 -db SERVER:INVENTORY:BAG:17:SHEET m0152chdca01.sitem -db SERVER:INVENTORY:BAG:17:QUANTITY 80 -db SERVER:INVENTORY:BAG:17:QUALITY 1 -db SERVER:INVENTORY:BAG:18:SHEET m0152chdca01.sitem -db SERVER:INVENTORY:BAG:18:QUANTITY 80 -db SERVER:INVENTORY:BAG:18:QUALITY 12 -db SERVER:INVENTORY:BAG:19:SHEET m0498chwdc01.sitem -db SERVER:INVENTORY:BAG:19:QUANTITY 20 -db SERVER:INVENTORY:BAG:19:QUALITY 1 -db SERVER:INVENTORY:BAG:20:SHEET m0498chwdd01.sitem -db SERVER:INVENTORY:BAG:20:QUANTITY 20 -db SERVER:INVENTORY:BAG:20:QUALITY 1 -db SERVER:INVENTORY:BAG:21:SHEET m0498chwfd01.sitem -db SERVER:INVENTORY:BAG:21:QUANTITY 20 -db SERVER:INVENTORY:BAG:21:QUALITY 3 -// Mp-3 -db SERVER:INVENTORY:BAG:22:SHEET m0367chnca01.sitem -db SERVER:INVENTORY:BAG:22:QUANTITY 20 -db SERVER:INVENTORY:BAG:22:QUALITY 20 -db SERVER:INVENTORY:BAG:23:SHEET m0556ccnca01.sitem -db SERVER:INVENTORY:BAG:23:QUANTITY 20 -db SERVER:INVENTORY:BAG:23:QUALITY 20 -db SERVER:INVENTORY:BAG:24:SHEET m0616chvca01.sitem -db SERVER:INVENTORY:BAG:24:QUANTITY 20 -db SERVER:INVENTORY:BAG:24:QUALITY 20 -db SERVER:INVENTORY:BAG:25:SHEET m0507chnca01.sitem -db SERVER:INVENTORY:BAG:25:QUANTITY 20 -db SERVER:INVENTORY:BAG:25:QUALITY 20 -db SERVER:INVENTORY:BAG:26:SHEET m0307cdald01.sitem -db SERVER:INVENTORY:BAG:26:QUANTITY 20 -db SERVER:INVENTORY:BAG:26:QUALITY 20 - -// MP Bark -db SERVER:INVENTORY:BAG:100:SHEET m0014dxacb01.sitem -db SERVER:INVENTORY:BAG:100:QUANTITY 10 -db SERVER:INVENTORY:BAG:100:QUALITY 20 -db SERVER:INVENTORY:BAG:101:SHEET m0101dxacb01.sitem -db SERVER:INVENTORY:BAG:101:QUANTITY 10 -db SERVER:INVENTORY:BAG:101:QUALITY 20 -db SERVER:INVENTORY:BAG:102:SHEET m0190dxacb01.sitem -db SERVER:INVENTORY:BAG:102:QUANTITY 10 -db SERVER:INVENTORY:BAG:102:QUALITY 20 -db SERVER:INVENTORY:BAG:103:SHEET m0191dxacb01.sitem -db SERVER:INVENTORY:BAG:103:QUANTITY 10 -db SERVER:INVENTORY:BAG:103:QUALITY 20 -db SERVER:INVENTORY:BAG:104:SHEET m0191dxacc01.sitem -db SERVER:INVENTORY:BAG:104:QUANTITY 10 -db SERVER:INVENTORY:BAG:104:QUALITY 20 -db SERVER:INVENTORY:BAG:105:SHEET m0191dxadd01.sitem -db SERVER:INVENTORY:BAG:105:QUANTITY 10 -db SERVER:INVENTORY:BAG:105:QUALITY 20 -db SERVER:INVENTORY:BAG:106:SHEET m0191dxade01.sitem -db SERVER:INVENTORY:BAG:106:QUANTITY 10 -db SERVER:INVENTORY:BAG:106:QUALITY 20 - -db SERVER:INVENTORY:BAG:107:SHEET m0043ccaca01.sitem -db SERVER:INVENTORY:BAG:107:QUANTITY 10 -db SERVER:INVENTORY:BAG:107:QUALITY 20 -db SERVER:INVENTORY:BAG:108:SHEET m0043ccacb01.sitem -db SERVER:INVENTORY:BAG:108:QUANTITY 10 -db SERVER:INVENTORY:BAG:108:QUALITY 20 -db SERVER:INVENTORY:BAG:109:SHEET m0106cceca01.sitem -db SERVER:INVENTORY:BAG:109:QUANTITY 10 -db SERVER:INVENTORY:BAG:109:QUALITY 20 -db SERVER:INVENTORY:BAG:110:SHEET m0134ccdca01.sitem -db SERVER:INVENTORY:BAG:110:QUANTITY 10 -db SERVER:INVENTORY:BAG:110:QUALITY 20 -db SERVER:INVENTORY:BAG:111:SHEET m0154ccica01.sitem -db SERVER:INVENTORY:BAG:111:QUANTITY 10 -db SERVER:INVENTORY:BAG:111:QUALITY 20 -db SERVER:INVENTORY:BAG:112:SHEET m0386ccoca01.sitem -db SERVER:INVENTORY:BAG:112:QUANTITY 10 -db SERVER:INVENTORY:BAG:112:QUALITY 20 -db SERVER:INVENTORY:BAG:113:SHEET m0467cclca01.sitem -db SERVER:INVENTORY:BAG:113:QUANTITY 10 -db SERVER:INVENTORY:BAG:113:QUALITY 20 -db SERVER:INVENTORY:BAG:114:SHEET m0468ccfca01.sitem -db SERVER:INVENTORY:BAG:114:QUANTITY 10 -db SERVER:INVENTORY:BAG:114:QUALITY 20 -db SERVER:INVENTORY:BAG:115:SHEET m0526checa01.sitem -db SERVER:INVENTORY:BAG:115:QUANTITY 10 -db SERVER:INVENTORY:BAG:115:QUALITY 20 -db SERVER:INVENTORY:BAG:116:SHEET m0577ccmca01.sitem -db SERVER:INVENTORY:BAG:116:QUANTITY 10 -db SERVER:INVENTORY:BAG:116:QUALITY 20 -db SERVER:INVENTORY:BAG:117:SHEET m0597ckeca01.sitem -db SERVER:INVENTORY:BAG:117:QUANTITY 10 -db SERVER:INVENTORY:BAG:117:QUALITY 20 -db SERVER:INVENTORY:BAG:118:SHEET m0671cchca01.sitem -db SERVER:INVENTORY:BAG:118:QUANTITY 10 -db SERVER:INVENTORY:BAG:118:QUALITY 20 -db SERVER:INVENTORY:BAG:119:SHEET m0339ccaca01.sitem -db SERVER:INVENTORY:BAG:119:QUANTITY 10 -db SERVER:INVENTORY:BAG:119:QUALITY 20 -db SERVER:INVENTORY:BAG:120:SHEET m0339ccacb01.sitem -db SERVER:INVENTORY:BAG:120:QUANTITY 10 -db SERVER:INVENTORY:BAG:120:QUALITY 20 -db SERVER:INVENTORY:BAG:121:SHEET m0339ccafc01.sitem -db SERVER:INVENTORY:BAG:121:QUANTITY 10 -db SERVER:INVENTORY:BAG:121:QUALITY 20 -db SERVER:INVENTORY:BAG:122:SHEET m0343cceca01.sitem -db SERVER:INVENTORY:BAG:122:QUANTITY 10 -db SERVER:INVENTORY:BAG:122:QUALITY 20 -db SERVER:INVENTORY:BAG:123:SHEET m0384cclcb01.sitem -db SERVER:INVENTORY:BAG:123:QUANTITY 10 -db SERVER:INVENTORY:BAG:123:QUALITY 20 -db SERVER:INVENTORY:BAG:123:SHEET m0312dxacf01.sitem -db SERVER:INVENTORY:BAG:123:QUANTITY 99 -db SERVER:INVENTORY:BAG:123:QUALITY 20 - - - -// enchantment -db SERVER:INVENTORY:BAG:27:SHEET crystalized_spell.sitem -db SERVER:INVENTORY:BAG:27:QUANTITY 1 -db SERVER:INVENTORY:BAG:27:QUALITY 3 -db SERVER:INVENTORY:BAG:28:SHEET item_sap_recharge.sitem -db SERVER:INVENTORY:BAG:28:QUANTITY 30 -db SERVER:INVENTORY:BAG:28:QUALITY 1 - -// pack animal -db SERVER:INVENTORY:BAG:29:SHEET iapd.sitem -db SERVER:INVENTORY:BAG:29:QUANTITY 1 -db SERVER:INVENTORY:BAG:29:QUALITY 1 - - -db SERVER:STATIC_DATA:BAG_BULK_MAX 400 - - -db SERVER:PACK_ANIMAL:BEAST0:STATUS 15 -db SERVER:PACK_ANIMAL:BEAST0:TYPE 2 -db SERVER:PACK_ANIMAL:BEAST0:UID 2 -db SERVER:PACK_ANIMAL:BEAST0:ChaScore1 40 -db SERVER:PACK_ANIMAL:BEAST0:BULK_MAX 200 - -db SERVER:PACK_ANIMAL:BEAST1:STATUS 15 -db SERVER:PACK_ANIMAL:BEAST1:TYPE 1 -db SERVER:PACK_ANIMAL:BEAST1:UID 3 -db SERVER:PACK_ANIMAL:BEAST1:ChaScore1 0 -db SERVER:PACK_ANIMAL:BEAST1:BULK_MAX 300 - -db SERVER:PACK_ANIMAL:BEAST2:STATUS 15 -db SERVER:PACK_ANIMAL:BEAST2:TYPE 2 -db SERVER:PACK_ANIMAL:BEAST2:UID 4 -db SERVER:PACK_ANIMAL:BEAST2:ChaScore1 0 -db SERVER:PACK_ANIMAL:BEAST2:BULK_MAX 300 - -db SERVER:PACK_ANIMAL:BEAST3:STATUS 15 -db SERVER:PACK_ANIMAL:BEAST3:TYPE 2 -db SERVER:PACK_ANIMAL:BEAST3:UID 1 -db SERVER:PACK_ANIMAL:BEAST3:ChaScore1 30 -db SERVER:PACK_ANIMAL:BEAST3:BULK_MAX 100 - - -db SERVER:INVENTORY:PACK_ANIMAL0:0:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:0:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL0:1:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:1:WEIGHT 50 -db SERVER:INVENTORY:PACK_ANIMAL0:2:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:2:WEIGHT 35 - -db SERVER:INVENTORY:PACK_ANIMAL1:0:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:0:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:1:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:1:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:2:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:2:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:3:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:3:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:4:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:4:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:5:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:5:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:6:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:6:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:7:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:7:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:8:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:8:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:9:SHEET icmalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:9:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:10:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:10:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:11:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:11:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:12:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:12:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:13:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:13:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:14:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:14:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:15:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:15:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:16:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:16:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:17:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:17:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:18:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:18:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:19:SHEET ictalp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:19:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:20:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:20:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:21:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:21:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:22:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:22:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:23:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:23:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:24:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:24:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:25:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:25:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:26:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:26:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:27:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:27:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:28:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:28:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:29:SHEET icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:29:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:30:SHEET icmp2rp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:30:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:31:SHEET icmp2rp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:31:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:32:SHEET icmp2rp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:32:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:33:SHEET icmp2rp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:33:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:34:SHEET icmp2rp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:34:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:35:SHEET icmp2rp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:35:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:36:SHEET icmp2rp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:36:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:37:SHEET icmp2rp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:37:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:38:SHEET icmp2rp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:38:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:39:SHEET icmp2rp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:39:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:40:SHEET icmjp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:40:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:41:SHEET icmjp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:41:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:42:SHEET icmjp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:42:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:43:SHEET icmjp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:43:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:44:SHEET icmjp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:44:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:45:SHEET icmjp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:45:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:46:SHEET icmjp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:46:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:47:SHEET icmjp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:47:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:48:SHEET icmjp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:48:WEIGHT 100 -db SERVER:INVENTORY:PACK_ANIMAL1:49:SHEET icmjp.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:49:WEIGHT 100 - - -// Mp-1 -// Mp-2 -db SERVER:INVENTORY:PACK_ANIMAL0:17:SHEET m0079dxacb01.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:17:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL0:17:QUALITY 41 -db SERVER:INVENTORY:PACK_ANIMAL0:18:SHEET m0024chcjc01.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:18:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL0:18:QUALITY 41 -db SERVER:INVENTORY:PACK_ANIMAL0:19:SHEET m0024chcpd01.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:19:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL0:19:QUALITY 41 -db SERVER:INVENTORY:PACK_ANIMAL0:20:SHEET m0079dxapf01.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:20:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL0:20:QUALITY 41 -db SERVER:INVENTORY:PACK_ANIMAL0:21:SHEET m0104cabpd01.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:21:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL0:21:QUALITY 41 -// Mp-3 -db SERVER:INVENTORY:PACK_ANIMAL0:22:SHEET m0046dxapc01.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:22:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL0:22:QUALITY 41 -db SERVER:INVENTORY:PACK_ANIMAL0:23:SHEET m0077dxapb01.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:23:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL0:23:QUALITY 41 -db SERVER:INVENTORY:PACK_ANIMAL0:24:SHEET m0046dxape01.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:24:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL0:24:QUALITY 41 -db SERVER:INVENTORY:PACK_ANIMAL0:25:SHEET m0142dxacc01.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:25:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL0:25:QUALITY 41 -db SERVER:INVENTORY:PACK_ANIMAL0:26:SHEET m0077dxapb01.sitem -db SERVER:INVENTORY:PACK_ANIMAL0:26:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL0:26:QUALITY 41 - -// Mp-4 -db SERVER:INVENTORY:PACK_ANIMAL1:50:SHEET m0046dxapc01.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:50:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL1:50:QUALITY 42 -db SERVER:INVENTORY:PACK_ANIMAL1:51:SHEET m0077dxapb01.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:51:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL1:51:QUALITY 42 -db SERVER:INVENTORY:PACK_ANIMAL1:52:SHEET m0046dxape01.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:52:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL1:52:QUALITY 42 -db SERVER:INVENTORY:PACK_ANIMAL1:53:SHEET m0142dxacc01.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:53:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL1:53:QUALITY 42 -db SERVER:INVENTORY:PACK_ANIMAL1:54:SHEET m0512chrca01.sitem -db SERVER:INVENTORY:PACK_ANIMAL1:54:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL1:54:QUALITY 42 - -// PackAnimal 2 -db SERVER:INVENTORY:PACK_ANIMAL2:0:SHEET system_mp.sitem -db SERVER:INVENTORY:PACK_ANIMAL2:0:QUANTITY 20 -db SERVER:INVENTORY:PACK_ANIMAL2:0:QUALITY 3 - -db SERVER:USER:DEATH_XP_MALUS 98 - -// BONUS MALUS -db SERVER:MODIFIERS:BONUS:0:DISABLED 1 -db SERVER:MODIFIERS:BONUS:0:SHEET bfpa01.sbrick -db SERVER:MODIFIERS:BONUS:1:SHEET bmpa01.sbrick -db SERVER:MODIFIERS:BONUS:2:SHEET bmpa02.sbrick -db SERVER:MODIFIERS:BONUS:3:SHEET bmpa03.sbrick -db SERVER:MODIFIERS:BONUS:4:SHEET bmpa04.sbrick -db SERVER:MODIFIERS:BONUS:5:SHEET bcpa01.sbrick -db SERVER:MODIFIERS:BONUS:6:SHEET bcpa02.sbrick -db SERVER:MODIFIERS:BONUS:7:SHEET bcpa03.sbrick -db SERVER:MODIFIERS:BONUS:8:SHEET bcpa04.sbrick -db SERVER:MODIFIERS:BONUS:9:SHEET bcpa05.sbrick -db SERVER:MODIFIERS:BONUS:10:SHEET bcpa06.sbrick -db SERVER:MODIFIERS:BONUS:11:SHEET bcpa07.sbrick -db SERVER:MODIFIERS:MALUS:0:SHEET bfpa01.sbrick - -db SERVER:MODIFIERS:BONUS:0:SHEET 0 -db SERVER:MODIFIERS:BONUS:1:SHEET 0 -db SERVER:MODIFIERS:BONUS:2:SHEET 0 -db SERVER:MODIFIERS:BONUS:3:SHEET 0 -//db SERVER:MODIFIERS:BONUS:4:SHEET 0 -//db SERVER:MODIFIERS:BONUS:5:SHEET 0 -db SERVER:MODIFIERS:BONUS:6:SHEET 0 -db SERVER:MODIFIERS:BONUS:7:SHEET 0 -db SERVER:MODIFIERS:BONUS:8:SHEET 0 -db SERVER:MODIFIERS:BONUS:9:SHEET 0 -db SERVER:MODIFIERS:BONUS:10:SHEET 0 -db SERVER:MODIFIERS:BONUS:11:SHEET 0 -//db SERVER:MODIFIERS:MALUS:0:SHEET 0 - -// Prices -db SERVER:INVENTORY:BAG:0:PRICE 0 -db SERVER:INVENTORY:BAG:1:PRICE 1 -db SERVER:INVENTORY:BAG:2:PRICE 2 -db SERVER:INVENTORY:BAG:3:PRICE 3 -db SERVER:INVENTORY:BAG:4:PRICE 4 -db SERVER:INVENTORY:BAG:5:PRICE 5 -db SERVER:INVENTORY:BAG:6:PRICE 6 -db SERVER:INVENTORY:BAG:7:PRICE 7 -db SERVER:INVENTORY:BAG:8:PRICE 8 -db SERVER:INVENTORY:BAG:9:PRICE 9 -db SERVER:INVENTORY:BAG:10:PRICE 10 -db SERVER:INVENTORY:BAG:11:PRICE 11 -db SERVER:INVENTORY:BAG:12:PRICE 12 -db SERVER:INVENTORY:BAG:13:PRICE 13 -db SERVER:INVENTORY:BAG:14:PRICE 14 -db SERVER:INVENTORY:BAG:15:PRICE 15 -db SERVER:INVENTORY:BAG:16:PRICE 16 -db SERVER:INVENTORY:BAG:17:PRICE 17 -db SERVER:INVENTORY:BAG:18:PRICE 18 -db SERVER:INVENTORY:BAG:19:PRICE 19 -db SERVER:INVENTORY:BAG:20:PRICE 20 -db SERVER:INVENTORY:BAG:21:PRICE 21 -db SERVER:INVENTORY:BAG:22:PRICE 22 -db SERVER:INVENTORY:BAG:23:PRICE 23 -db SERVER:INVENTORY:BAG:24:PRICE 24 -db SERVER:INVENTORY:BAG:25:PRICE 25 -db SERVER:INVENTORY:BAG:26:PRICE 26 -db SERVER:INVENTORY:BAG:27:PRICE 27 -db SERVER:INVENTORY:BAG:28:PRICE 28 -db SERVER:INVENTORY:BAG:29:PRICE 29 -db SERVER:INVENTORY:BAG:30:PRICE 30 -db SERVER:INVENTORY:BAG:31:PRICE 31 -db SERVER:INVENTORY:BAG:32:PRICE 32 -db SERVER:INVENTORY:BAG:33:PRICE 33 -db SERVER:INVENTORY:BAG:34:PRICE 34 -db SERVER:INVENTORY:BAG:35:PRICE 35 -db SERVER:INVENTORY:BAG:36:PRICE 36 -db SERVER:INVENTORY:BAG:37:PRICE 37 -db SERVER:INVENTORY:BAG:38:PRICE 38 -db SERVER:INVENTORY:BAG:39:PRICE 39 -db SERVER:INVENTORY:BAG:40:PRICE 40 -db SERVER:INVENTORY:BAG:41:PRICE 41 -db SERVER:INVENTORY:BAG:42:PRICE 42 -db SERVER:INVENTORY:BAG:43:PRICE 43 -db SERVER:INVENTORY:BAG:44:PRICE 44 -db SERVER:INVENTORY:BAG:45:PRICE 45 -db SERVER:INVENTORY:BAG:46:PRICE 46 -db SERVER:INVENTORY:BAG:47:PRICE 47 -db SERVER:INVENTORY:BAG:48:PRICE 48 -db SERVER:INVENTORY:BAG:49:PRICE 49 -db SERVER:INVENTORY:BAG:50:PRICE 50 -db SERVER:INVENTORY:BAG:51:PRICE 51 -db SERVER:INVENTORY:BAG:52:PRICE 52 -db SERVER:INVENTORY:BAG:53:PRICE 53 -db SERVER:INVENTORY:BAG:54:PRICE 54 -db SERVER:INVENTORY:BAG:55:PRICE 55 -db SERVER:INVENTORY:BAG:56:PRICE 56 -db SERVER:INVENTORY:BAG:57:PRICE 57 -db SERVER:INVENTORY:BAG:58:PRICE 58 -db SERVER:INVENTORY:BAG:59:PRICE 59 -db SERVER:TRADING:FAME_PRICE_FACTOR 1000 - - -learnPhrase abf01.sphrase -db SERVER:USER:SKILL_POINTS_0:VALUE 100 -db SERVER:USER:SKILL_POINTS_1:VALUE 200 -db SERVER:USER:SKILL_POINTS_2:VALUE 300 -db SERVER:USER:SKILL_POINTS_3:VALUE 400 - - -fillAllInfoVersion 1 - -fullFillInventory SERVER:INVENTORY:PACK_ANIMAL3 icfm1ss.sitem -db SERVER:INVENTORY:PACK_ANIMAL3:0:PRICE 50000 - - -// test team share -fullFillInventory SERVER:INVENTORY:SHARE m0001dxadd01.sitem -db SERVER:INVENTORY:SHARE:0:NB_MEMBER 3 -db SERVER:INVENTORY:SHARE:0:WANTED 1 -db SERVER:INVENTORY:SHARE:0:CHANCE 70 - - -fillAllItemPreReq SERVER:INVENTORY:BAG 1 -fillAllItemPreReq SERVER:INVENTORY:PACK_ANIMAL0 1 -fillAllItemPreReq SERVER:INVENTORY:PACK_ANIMAL1 1 -fillAllItemPreReq SERVER:INVENTORY:PACK_ANIMAL2 1 -fillAllItemPreReq SERVER:INVENTORY:PACK_ANIMAL3 1 -fillAllItemPreReq SERVER:INVENTORY:TEMP 1 -fillAllItemPreReq SERVER:INVENTORY:SHARE 1 -fillAllItemPreReq SERVER:INVENTORY:ROOM 1 -fillAllItemPreReq SERVER:EXCHANGE:GIVE 1 -fillAllItemPreReq SERVER:EXCHANGE:RECEIVE 1 - - -db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:MaxProtectionClampValue 75 -db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:MaxAbsorptionFactor 100 -db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Acid 15 -db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Cold 12 -db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Fire 75 -db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Rot 99 -db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Shockwave 33 -db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Poison 43 -db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Electricity 74 - -db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:MaxResistanceBonus 50 -db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:Desert 24 -db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:Forest 75 -db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:Lacustre 51 -db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:Jungle 20 -db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:PrimaryRoot 25 - -db SERVER:CHARACTER_INFO:XP_CATALYSER:Level 100 -db SERVER:CHARACTER_INFO:XP_CATALYSER:Count 145 - -db SERVER:TARGET:CONTEXT_MENU:PROGRAMMES 16777215 -db SERVER:TARGET:CONTEXT_MENU:WEB_PAGE_TITLE 25 -db SERVER:TARGET:CONTEXT_MENU:WEB_PAGE_URL 38 - -db SERVER:USER:FACTION_POINTS_0:VALUE 30 -db SERVER:USER:FACTION_POINTS_1:VALUE 40 -db SERVER:USER:FACTION_POINTS_2:VALUE 50 -db SERVER:USER:FACTION_POINTS_3:VALUE 60 -db SERVER:USER:FACTION_POINTS_4:VALUE 70 -db SERVER:USER:FACTION_POINTS_5:VALUE 80 - -db SERVER:GUILD:INVENTORY:MONEY 10000000 + +db SERVER:INTERFACES:FLAGS 255 + + + +db SERVER:CHARACTER_INFO:SCORES:MaxChaScore1 100 +db SERVER:CHARACTER_INFO:SCORES:BaseChaScore1 120 +db SERVER:CHARACTER_INFO:SCORES:MaxChaScore2 120 +db SERVER:CHARACTER_INFO:SCORES:BaseChaScore2 100 +db SERVER:CHARACTER_INFO:SCORES:MaxChaScore3 100 +db SERVER:CHARACTER_INFO:SCORES:BaseChaScore3 100 +db SERVER:CHARACTER_INFO:SCORES:MaxChaScore4 100 +db SERVER:CHARACTER_INFO:SCORES:BaseChaScore4 100 + +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha1 33 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha1Reg 100 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha2 50 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha2Reg 30 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha3 30 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha3Reg 420 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha4 121 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha4Reg 654 + + +db SERVER:USER:SKILL_POINTS 1000 +db SERVER:TARGET:BARS:ChaScore1 80 +db SERVER:TARGET:BARS:ChaScore2 32 +db SERVER:TARGET:BARS:ChaScore3 69 +db SERVER:TARGET:BARS:ChaScore4 95 + + + +// Default Quantities +db SERVER:INVENTORY:BAG:0:QUANTITY 1 +db SERVER:INVENTORY:BAG:1:QUANTITY 1 +db SERVER:INVENTORY:BAG:2:QUANTITY 1 +db SERVER:INVENTORY:BAG:3:QUANTITY 1 +db SERVER:INVENTORY:BAG:4:QUANTITY 1 +db SERVER:INVENTORY:BAG:5:QUANTITY 1 +db SERVER:INVENTORY:BAG:6:QUANTITY 1 +db SERVER:INVENTORY:BAG:7:QUANTITY 1 +db SERVER:INVENTORY:BAG:8:QUANTITY 1 +db SERVER:INVENTORY:BAG:9:QUANTITY 1 +db SERVER:INVENTORY:BAG:10:QUANTITY 1 +db SERVER:INVENTORY:BAG:11:QUANTITY 1 +db SERVER:INVENTORY:BAG:12:QUANTITY 1 +db SERVER:INVENTORY:BAG:13:QUANTITY 1 +db SERVER:INVENTORY:BAG:14:QUANTITY 1 +db SERVER:INVENTORY:BAG:15:QUANTITY 1 +db SERVER:INVENTORY:BAG:16:QUANTITY 1 +db SERVER:INVENTORY:BAG:17:QUANTITY 1 +db SERVER:INVENTORY:BAG:18:QUANTITY 1 +db SERVER:INVENTORY:BAG:19:QUANTITY 1 +db SERVER:INVENTORY:BAG:20:QUANTITY 1 +db SERVER:INVENTORY:BAG:21:QUANTITY 1 +db SERVER:INVENTORY:BAG:22:QUANTITY 1 +db SERVER:INVENTORY:BAG:23:QUANTITY 1 +db SERVER:INVENTORY:BAG:24:QUANTITY 1 +db SERVER:INVENTORY:BAG:25:QUANTITY 1 +db SERVER:INVENTORY:BAG:26:QUANTITY 1 +db SERVER:INVENTORY:BAG:27:QUANTITY 1 +db SERVER:INVENTORY:BAG:28:QUANTITY 1 +db SERVER:INVENTORY:BAG:29:QUANTITY 1 +db SERVER:INVENTORY:BAG:30:QUANTITY 1 +db SERVER:INVENTORY:BAG:31:QUANTITY 1 +db SERVER:INVENTORY:BAG:32:QUANTITY 1 +db SERVER:INVENTORY:BAG:33:QUANTITY 1 +db SERVER:INVENTORY:BAG:34:QUANTITY 1 +db SERVER:INVENTORY:BAG:35:QUANTITY 1 +db SERVER:INVENTORY:BAG:36:QUANTITY 1 +db SERVER:INVENTORY:BAG:37:QUANTITY 1 +db SERVER:INVENTORY:BAG:38:QUANTITY 1 +db SERVER:INVENTORY:BAG:39:QUANTITY 1 +db SERVER:INVENTORY:BAG:40:QUANTITY 1 +db SERVER:INVENTORY:BAG:41:QUANTITY 1 +db SERVER:INVENTORY:BAG:42:QUANTITY 1 +db SERVER:INVENTORY:BAG:43:QUANTITY 1 +db SERVER:INVENTORY:BAG:44:QUANTITY 1 +db SERVER:INVENTORY:BAG:45:QUANTITY 1 +db SERVER:INVENTORY:BAG:46:QUANTITY 1 +db SERVER:INVENTORY:BAG:47:QUANTITY 1 +db SERVER:INVENTORY:BAG:48:QUANTITY 1 +db SERVER:INVENTORY:BAG:49:QUANTITY 1 +db SERVER:INVENTORY:BAG:50:QUANTITY 1 +db SERVER:INVENTORY:BAG:51:QUANTITY 1 +db SERVER:INVENTORY:BAG:52:QUANTITY 1 +db SERVER:INVENTORY:BAG:53:QUANTITY 1 +db SERVER:INVENTORY:BAG:54:QUANTITY 1 +db SERVER:INVENTORY:BAG:55:QUANTITY 1 +db SERVER:INVENTORY:BAG:56:QUANTITY 1 +db SERVER:INVENTORY:BAG:57:QUANTITY 1 +db SERVER:INVENTORY:BAG:58:QUANTITY 1 +db SERVER:INVENTORY:BAG:59:QUANTITY 1 + + + +db SERVER:INVENTORY:BAG:0:SHEET icmalp.sitem +db SERVER:INVENTORY:BAG:0:QUALITY 66 +db SERVER:INVENTORY:BAG:0:QUANTITY 1 +db SERVER:INVENTORY:BAG:0:USER_COLOR 2 +db SERVER:INVENTORY:BAG:0:LOCKED 0 +db SERVER:INVENTORY:BAG:0:WEIGHT 100 +db SERVER:INVENTORY:BAG:0:NAMEID 18 +db SERVER:INVENTORY:BAG:0:INFO_VERSION 11 +db SERVER:INVENTORY:BAG:0:ENCHANT 99 +db SERVER:INVENTORY:BAG:0:RM_CLASS_TYPE 3 +db SERVER:INVENTORY:BAG:0:RM_FABER_STAT_TYPE 5 + +db SERVER:INVENTORY:BAG:1:SHEET ictalp.sitem +db SERVER:INVENTORY:BAG:1:QUALITY 50 +db SERVER:INVENTORY:BAG:1:WEIGHT 50 + +db SERVER:INVENTORY:BAG:2:SHEET icfm1ss.sitem +db SERVER:INVENTORY:BAG:2:QUALITY 0 +db SERVER:INVENTORY:BAG:2:WEIGHT 35 +db SERVER:INVENTORY:BAG:2:RM_CLASS_TYPE 4 +db SERVER:INVENTORY:BAG:2:RM_FABER_STAT_TYPE 3 + +db SERVER:INVENTORY:BAG:3:SHEET icfm2pp.sitem +db SERVER:INVENTORY:BAG:3:QUALITY 50 +db SERVER:INVENTORY:BAG:3:WEIGHT 150 + +db SERVER:INVENTORY:BAG:4:SHEET icmm2bm.sitem +db SERVER:INVENTORY:BAG:4:QUALITY 50 +db SERVER:INVENTORY:BAG:4:WEIGHT 90 + +db SERVER:INVENTORY:BAG:5:SHEET icmp1bs.sitem +db SERVER:INVENTORY:BAG:5:QUALITY 50 +db SERVER:INVENTORY:BAG:5:WEIGHT 33 +db SERVER:INVENTORY:BAG:5:QUANTITY 12 + +db SERVER:INVENTORY:BAG:6:SHEET icmp2rp.sitem +db SERVER:INVENTORY:BAG:6:QUALITY 50 +db SERVER:INVENTORY:BAG:6:WEIGHT 77 +db SERVER:INVENTORY:BAG:6:QUANTITY 12 + +db SERVER:INVENTORY:BAG:7:SHEET icmja.sitem +db SERVER:INVENTORY:BAG:7:QUALITY 50 +db SERVER:INVENTORY:BAG:7:WEIGHT 161 + +db SERVER:INVENTORY:BAG:8:SHEET icmjp.sitem +db SERVER:INVENTORY:BAG:8:QUALITY 50 +db SERVER:INVENTORY:BAG:8:WEIGHT 88 + +db SERVER:INVENTORY:BAG:9:SHEET icmr2b.sitem +db SERVER:INVENTORY:BAG:9:QUALITY 50 +db SERVER:INVENTORY:BAG:9:WEIGHT 185 + +db SERVER:INVENTORY:BAG:10:SHEET icmm1sa.sitem +db SERVER:INVENTORY:BAG:10:QUALITY 50 +db SERVER:INVENTORY:BAG:10:WEIGHT 12 + +db SERVER:INVENTORY:BAG:11:SHEET icmm1pd.sitem +db SERVER:INVENTORY:BAG:11:QUALITY 50 +db SERVER:INVENTORY:BAG:11:WEIGHT 13 + +db SERVER:INVENTORY:BAG:12:SHEET iccm2ms.sitem +db SERVER:INVENTORY:BAG:12:QUALITY 50 +db SERVER:INVENTORY:BAG:12:WEIGHT 117 + +db SERVER:INVENTORY:BAG:15:SHEET iapj3.sitem +db SERVER:INVENTORY:BAG:15:QUALITY 50 +db SERVER:INVENTORY:BAG:15:WEIGHT 5 +db SERVER:INVENTORY:BAG:15:QUALITY 5 + +db SERVER:INVENTORY:BAG:24:SHEET itforage.sitem +db SERVER:INVENTORY:BAG:24:QUALITY 50 +db SERVER:INVENTORY:BAG:24:WEIGHT 35 + +db SERVER:INVENTORY:BAG:50:SHEET icfamp.sitem +db SERVER:INVENTORY:BAG:50:QUALITY 50 +db SERVER:INVENTORY:BAG:50:WEIGHT 35 + +db SERVER:INVENTORY:BAG:51:SHEET icfahp.sitem +db SERVER:INVENTORY:BAG:51:QUALITY 50 +db SERVER:INVENTORY:BAG:51:WEIGHT 35 + +db SERVER:INVENTORY:BAG:52:SHEET iccsb.sitem +db SERVER:INVENTORY:BAG:52:QUALITY 50 +db SERVER:INVENTORY:BAG:52:WEIGHT 35 + +db SERVER:INVENTORY:BAG:53:SHEET iccss.sitem +db SERVER:INVENTORY:BAG:53:QUALITY 50 +db SERVER:INVENTORY:BAG:53:WEIGHT 35 + +db SERVER:INVENTORY:BAG:54:SHEET iccm2ms.sitem +db SERVER:INVENTORY:BAG:54:QUALITY 50 +db SERVER:INVENTORY:BAG:54:WEIGHT 35 + + + +db SERVER:INVENTORY:MONEY 8532 + +// Faber +// Tool +db SERVER:INVENTORY:BAG:11:SHEET itmwea.sitem +db SERVER:INVENTORY:BAG:11:QUANTITY 1 +db SERVER:INVENTORY:BAG:11:QUALITY 5 +db SERVER:INVENTORY:BAG:12:SHEET itarmor.sitem +db SERVER:INVENTORY:BAG:12:QUANTITY 1 +db SERVER:INVENTORY:BAG:12:QUALITY 5 +db SERVER:INVENTORY:BAG:13:SHEET itrwea.sitem +db SERVER:INVENTORY:BAG:13:QUANTITY 1 +db SERVER:INVENTORY:BAG:13:QUALITY 5 +db SERVER:INVENTORY:BAG:14:SHEET itammo.sitem +db SERVER:INVENTORY:BAG:14:QUANTITY 1 +db SERVER:INVENTORY:BAG:14:QUALITY 10 +db SERVER:INVENTORY:BAG:54:SHEET itjewel.sitem +db SERVER:INVENTORY:BAG:54:QUANTITY 1 +db SERVER:INVENTORY:BAG:54:QUALITY 10 + + + +db SERVER:INVENTORY:BAG:16:SHEET m0741dxacc01.sitem +db SERVER:INVENTORY:BAG:16:QUANTITY 121 +db SERVER:INVENTORY:BAG:16:QUALITY 2 +// Mp-2 +db SERVER:INVENTORY:BAG:17:SHEET m0152chdca01.sitem +db SERVER:INVENTORY:BAG:17:QUANTITY 80 +db SERVER:INVENTORY:BAG:17:QUALITY 1 +db SERVER:INVENTORY:BAG:18:SHEET m0152chdca01.sitem +db SERVER:INVENTORY:BAG:18:QUANTITY 80 +db SERVER:INVENTORY:BAG:18:QUALITY 12 +db SERVER:INVENTORY:BAG:19:SHEET m0498chwdc01.sitem +db SERVER:INVENTORY:BAG:19:QUANTITY 20 +db SERVER:INVENTORY:BAG:19:QUALITY 1 +db SERVER:INVENTORY:BAG:20:SHEET m0498chwdd01.sitem +db SERVER:INVENTORY:BAG:20:QUANTITY 20 +db SERVER:INVENTORY:BAG:20:QUALITY 1 +db SERVER:INVENTORY:BAG:21:SHEET m0498chwfd01.sitem +db SERVER:INVENTORY:BAG:21:QUANTITY 20 +db SERVER:INVENTORY:BAG:21:QUALITY 3 +// Mp-3 +db SERVER:INVENTORY:BAG:22:SHEET m0367chnca01.sitem +db SERVER:INVENTORY:BAG:22:QUANTITY 20 +db SERVER:INVENTORY:BAG:22:QUALITY 20 +db SERVER:INVENTORY:BAG:23:SHEET m0556ccnca01.sitem +db SERVER:INVENTORY:BAG:23:QUANTITY 20 +db SERVER:INVENTORY:BAG:23:QUALITY 20 +db SERVER:INVENTORY:BAG:24:SHEET m0616chvca01.sitem +db SERVER:INVENTORY:BAG:24:QUANTITY 20 +db SERVER:INVENTORY:BAG:24:QUALITY 20 +db SERVER:INVENTORY:BAG:25:SHEET m0507chnca01.sitem +db SERVER:INVENTORY:BAG:25:QUANTITY 20 +db SERVER:INVENTORY:BAG:25:QUALITY 20 +db SERVER:INVENTORY:BAG:26:SHEET m0307cdald01.sitem +db SERVER:INVENTORY:BAG:26:QUANTITY 20 +db SERVER:INVENTORY:BAG:26:QUALITY 20 + +// MP Bark +db SERVER:INVENTORY:BAG:100:SHEET m0014dxacb01.sitem +db SERVER:INVENTORY:BAG:100:QUANTITY 10 +db SERVER:INVENTORY:BAG:100:QUALITY 20 +db SERVER:INVENTORY:BAG:101:SHEET m0101dxacb01.sitem +db SERVER:INVENTORY:BAG:101:QUANTITY 10 +db SERVER:INVENTORY:BAG:101:QUALITY 20 +db SERVER:INVENTORY:BAG:102:SHEET m0190dxacb01.sitem +db SERVER:INVENTORY:BAG:102:QUANTITY 10 +db SERVER:INVENTORY:BAG:102:QUALITY 20 +db SERVER:INVENTORY:BAG:103:SHEET m0191dxacb01.sitem +db SERVER:INVENTORY:BAG:103:QUANTITY 10 +db SERVER:INVENTORY:BAG:103:QUALITY 20 +db SERVER:INVENTORY:BAG:104:SHEET m0191dxacc01.sitem +db SERVER:INVENTORY:BAG:104:QUANTITY 10 +db SERVER:INVENTORY:BAG:104:QUALITY 20 +db SERVER:INVENTORY:BAG:105:SHEET m0191dxadd01.sitem +db SERVER:INVENTORY:BAG:105:QUANTITY 10 +db SERVER:INVENTORY:BAG:105:QUALITY 20 +db SERVER:INVENTORY:BAG:106:SHEET m0191dxade01.sitem +db SERVER:INVENTORY:BAG:106:QUANTITY 10 +db SERVER:INVENTORY:BAG:106:QUALITY 20 + +db SERVER:INVENTORY:BAG:107:SHEET m0043ccaca01.sitem +db SERVER:INVENTORY:BAG:107:QUANTITY 10 +db SERVER:INVENTORY:BAG:107:QUALITY 20 +db SERVER:INVENTORY:BAG:108:SHEET m0043ccacb01.sitem +db SERVER:INVENTORY:BAG:108:QUANTITY 10 +db SERVER:INVENTORY:BAG:108:QUALITY 20 +db SERVER:INVENTORY:BAG:109:SHEET m0106cceca01.sitem +db SERVER:INVENTORY:BAG:109:QUANTITY 10 +db SERVER:INVENTORY:BAG:109:QUALITY 20 +db SERVER:INVENTORY:BAG:110:SHEET m0134ccdca01.sitem +db SERVER:INVENTORY:BAG:110:QUANTITY 10 +db SERVER:INVENTORY:BAG:110:QUALITY 20 +db SERVER:INVENTORY:BAG:111:SHEET m0154ccica01.sitem +db SERVER:INVENTORY:BAG:111:QUANTITY 10 +db SERVER:INVENTORY:BAG:111:QUALITY 20 +db SERVER:INVENTORY:BAG:112:SHEET m0386ccoca01.sitem +db SERVER:INVENTORY:BAG:112:QUANTITY 10 +db SERVER:INVENTORY:BAG:112:QUALITY 20 +db SERVER:INVENTORY:BAG:113:SHEET m0467cclca01.sitem +db SERVER:INVENTORY:BAG:113:QUANTITY 10 +db SERVER:INVENTORY:BAG:113:QUALITY 20 +db SERVER:INVENTORY:BAG:114:SHEET m0468ccfca01.sitem +db SERVER:INVENTORY:BAG:114:QUANTITY 10 +db SERVER:INVENTORY:BAG:114:QUALITY 20 +db SERVER:INVENTORY:BAG:115:SHEET m0526checa01.sitem +db SERVER:INVENTORY:BAG:115:QUANTITY 10 +db SERVER:INVENTORY:BAG:115:QUALITY 20 +db SERVER:INVENTORY:BAG:116:SHEET m0577ccmca01.sitem +db SERVER:INVENTORY:BAG:116:QUANTITY 10 +db SERVER:INVENTORY:BAG:116:QUALITY 20 +db SERVER:INVENTORY:BAG:117:SHEET m0597ckeca01.sitem +db SERVER:INVENTORY:BAG:117:QUANTITY 10 +db SERVER:INVENTORY:BAG:117:QUALITY 20 +db SERVER:INVENTORY:BAG:118:SHEET m0671cchca01.sitem +db SERVER:INVENTORY:BAG:118:QUANTITY 10 +db SERVER:INVENTORY:BAG:118:QUALITY 20 +db SERVER:INVENTORY:BAG:119:SHEET m0339ccaca01.sitem +db SERVER:INVENTORY:BAG:119:QUANTITY 10 +db SERVER:INVENTORY:BAG:119:QUALITY 20 +db SERVER:INVENTORY:BAG:120:SHEET m0339ccacb01.sitem +db SERVER:INVENTORY:BAG:120:QUANTITY 10 +db SERVER:INVENTORY:BAG:120:QUALITY 20 +db SERVER:INVENTORY:BAG:121:SHEET m0339ccafc01.sitem +db SERVER:INVENTORY:BAG:121:QUANTITY 10 +db SERVER:INVENTORY:BAG:121:QUALITY 20 +db SERVER:INVENTORY:BAG:122:SHEET m0343cceca01.sitem +db SERVER:INVENTORY:BAG:122:QUANTITY 10 +db SERVER:INVENTORY:BAG:122:QUALITY 20 +db SERVER:INVENTORY:BAG:123:SHEET m0384cclcb01.sitem +db SERVER:INVENTORY:BAG:123:QUANTITY 10 +db SERVER:INVENTORY:BAG:123:QUALITY 20 +db SERVER:INVENTORY:BAG:123:SHEET m0312dxacf01.sitem +db SERVER:INVENTORY:BAG:123:QUANTITY 99 +db SERVER:INVENTORY:BAG:123:QUALITY 20 + + + +// enchantment +db SERVER:INVENTORY:BAG:27:SHEET crystalized_spell.sitem +db SERVER:INVENTORY:BAG:27:QUANTITY 1 +db SERVER:INVENTORY:BAG:27:QUALITY 3 +db SERVER:INVENTORY:BAG:28:SHEET item_sap_recharge.sitem +db SERVER:INVENTORY:BAG:28:QUANTITY 30 +db SERVER:INVENTORY:BAG:28:QUALITY 1 + +// pack animal +db SERVER:INVENTORY:BAG:29:SHEET iapd.sitem +db SERVER:INVENTORY:BAG:29:QUANTITY 1 +db SERVER:INVENTORY:BAG:29:QUALITY 1 + + +db SERVER:STATIC_DATA:BAG_BULK_MAX 400 + + +db SERVER:PACK_ANIMAL:BEAST0:STATUS 15 +db SERVER:PACK_ANIMAL:BEAST0:TYPE 2 +db SERVER:PACK_ANIMAL:BEAST0:UID 2 +db SERVER:PACK_ANIMAL:BEAST0:ChaScore1 40 +db SERVER:PACK_ANIMAL:BEAST0:BULK_MAX 200 + +db SERVER:PACK_ANIMAL:BEAST1:STATUS 15 +db SERVER:PACK_ANIMAL:BEAST1:TYPE 1 +db SERVER:PACK_ANIMAL:BEAST1:UID 3 +db SERVER:PACK_ANIMAL:BEAST1:ChaScore1 0 +db SERVER:PACK_ANIMAL:BEAST1:BULK_MAX 300 + +db SERVER:PACK_ANIMAL:BEAST2:STATUS 15 +db SERVER:PACK_ANIMAL:BEAST2:TYPE 2 +db SERVER:PACK_ANIMAL:BEAST2:UID 4 +db SERVER:PACK_ANIMAL:BEAST2:ChaScore1 0 +db SERVER:PACK_ANIMAL:BEAST2:BULK_MAX 300 + +db SERVER:PACK_ANIMAL:BEAST3:STATUS 15 +db SERVER:PACK_ANIMAL:BEAST3:TYPE 2 +db SERVER:PACK_ANIMAL:BEAST3:UID 1 +db SERVER:PACK_ANIMAL:BEAST3:ChaScore1 30 +db SERVER:PACK_ANIMAL:BEAST3:BULK_MAX 100 + + +db SERVER:INVENTORY:PACK_ANIMAL0:0:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:0:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL0:1:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:1:WEIGHT 50 +db SERVER:INVENTORY:PACK_ANIMAL0:2:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:2:WEIGHT 35 + +db SERVER:INVENTORY:PACK_ANIMAL1:0:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:0:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:1:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:1:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:2:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:2:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:3:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:3:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:4:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:4:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:5:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:5:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:6:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:6:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:7:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:7:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:8:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:8:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:9:SHEET icmalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:9:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:10:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:10:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:11:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:11:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:12:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:12:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:13:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:13:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:14:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:14:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:15:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:15:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:16:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:16:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:17:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:17:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:18:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:18:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:19:SHEET ictalp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:19:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:20:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:20:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:21:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:21:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:22:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:22:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:23:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:23:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:24:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:24:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:25:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:25:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:26:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:26:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:27:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:27:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:28:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:28:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:29:SHEET icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:29:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:30:SHEET icmp2rp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:30:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:31:SHEET icmp2rp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:31:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:32:SHEET icmp2rp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:32:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:33:SHEET icmp2rp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:33:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:34:SHEET icmp2rp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:34:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:35:SHEET icmp2rp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:35:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:36:SHEET icmp2rp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:36:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:37:SHEET icmp2rp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:37:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:38:SHEET icmp2rp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:38:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:39:SHEET icmp2rp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:39:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:40:SHEET icmjp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:40:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:41:SHEET icmjp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:41:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:42:SHEET icmjp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:42:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:43:SHEET icmjp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:43:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:44:SHEET icmjp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:44:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:45:SHEET icmjp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:45:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:46:SHEET icmjp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:46:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:47:SHEET icmjp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:47:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:48:SHEET icmjp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:48:WEIGHT 100 +db SERVER:INVENTORY:PACK_ANIMAL1:49:SHEET icmjp.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:49:WEIGHT 100 + + +// Mp-1 +// Mp-2 +db SERVER:INVENTORY:PACK_ANIMAL0:17:SHEET m0079dxacb01.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:17:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL0:17:QUALITY 41 +db SERVER:INVENTORY:PACK_ANIMAL0:18:SHEET m0024chcjc01.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:18:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL0:18:QUALITY 41 +db SERVER:INVENTORY:PACK_ANIMAL0:19:SHEET m0024chcpd01.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:19:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL0:19:QUALITY 41 +db SERVER:INVENTORY:PACK_ANIMAL0:20:SHEET m0079dxapf01.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:20:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL0:20:QUALITY 41 +db SERVER:INVENTORY:PACK_ANIMAL0:21:SHEET m0104cabpd01.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:21:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL0:21:QUALITY 41 +// Mp-3 +db SERVER:INVENTORY:PACK_ANIMAL0:22:SHEET m0046dxapc01.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:22:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL0:22:QUALITY 41 +db SERVER:INVENTORY:PACK_ANIMAL0:23:SHEET m0077dxapb01.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:23:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL0:23:QUALITY 41 +db SERVER:INVENTORY:PACK_ANIMAL0:24:SHEET m0046dxape01.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:24:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL0:24:QUALITY 41 +db SERVER:INVENTORY:PACK_ANIMAL0:25:SHEET m0142dxacc01.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:25:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL0:25:QUALITY 41 +db SERVER:INVENTORY:PACK_ANIMAL0:26:SHEET m0077dxapb01.sitem +db SERVER:INVENTORY:PACK_ANIMAL0:26:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL0:26:QUALITY 41 + +// Mp-4 +db SERVER:INVENTORY:PACK_ANIMAL1:50:SHEET m0046dxapc01.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:50:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL1:50:QUALITY 42 +db SERVER:INVENTORY:PACK_ANIMAL1:51:SHEET m0077dxapb01.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:51:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL1:51:QUALITY 42 +db SERVER:INVENTORY:PACK_ANIMAL1:52:SHEET m0046dxape01.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:52:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL1:52:QUALITY 42 +db SERVER:INVENTORY:PACK_ANIMAL1:53:SHEET m0142dxacc01.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:53:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL1:53:QUALITY 42 +db SERVER:INVENTORY:PACK_ANIMAL1:54:SHEET m0512chrca01.sitem +db SERVER:INVENTORY:PACK_ANIMAL1:54:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL1:54:QUALITY 42 + +// PackAnimal 2 +db SERVER:INVENTORY:PACK_ANIMAL2:0:SHEET system_mp.sitem +db SERVER:INVENTORY:PACK_ANIMAL2:0:QUANTITY 20 +db SERVER:INVENTORY:PACK_ANIMAL2:0:QUALITY 3 + +db SERVER:USER:DEATH_XP_MALUS 98 + +// BONUS MALUS +db SERVER:MODIFIERS:BONUS:0:DISABLED 1 +db SERVER:MODIFIERS:BONUS:0:SHEET bfpa01.sbrick +db SERVER:MODIFIERS:BONUS:1:SHEET bmpa01.sbrick +db SERVER:MODIFIERS:BONUS:2:SHEET bmpa02.sbrick +db SERVER:MODIFIERS:BONUS:3:SHEET bmpa03.sbrick +db SERVER:MODIFIERS:BONUS:4:SHEET bmpa04.sbrick +db SERVER:MODIFIERS:BONUS:5:SHEET bcpa01.sbrick +db SERVER:MODIFIERS:BONUS:6:SHEET bcpa02.sbrick +db SERVER:MODIFIERS:BONUS:7:SHEET bcpa03.sbrick +db SERVER:MODIFIERS:BONUS:8:SHEET bcpa04.sbrick +db SERVER:MODIFIERS:BONUS:9:SHEET bcpa05.sbrick +db SERVER:MODIFIERS:BONUS:10:SHEET bcpa06.sbrick +db SERVER:MODIFIERS:BONUS:11:SHEET bcpa07.sbrick +db SERVER:MODIFIERS:MALUS:0:SHEET bfpa01.sbrick + +db SERVER:MODIFIERS:BONUS:0:SHEET 0 +db SERVER:MODIFIERS:BONUS:1:SHEET 0 +db SERVER:MODIFIERS:BONUS:2:SHEET 0 +db SERVER:MODIFIERS:BONUS:3:SHEET 0 +//db SERVER:MODIFIERS:BONUS:4:SHEET 0 +//db SERVER:MODIFIERS:BONUS:5:SHEET 0 +db SERVER:MODIFIERS:BONUS:6:SHEET 0 +db SERVER:MODIFIERS:BONUS:7:SHEET 0 +db SERVER:MODIFIERS:BONUS:8:SHEET 0 +db SERVER:MODIFIERS:BONUS:9:SHEET 0 +db SERVER:MODIFIERS:BONUS:10:SHEET 0 +db SERVER:MODIFIERS:BONUS:11:SHEET 0 +//db SERVER:MODIFIERS:MALUS:0:SHEET 0 + +// Prices +db SERVER:INVENTORY:BAG:0:PRICE 0 +db SERVER:INVENTORY:BAG:1:PRICE 1 +db SERVER:INVENTORY:BAG:2:PRICE 2 +db SERVER:INVENTORY:BAG:3:PRICE 3 +db SERVER:INVENTORY:BAG:4:PRICE 4 +db SERVER:INVENTORY:BAG:5:PRICE 5 +db SERVER:INVENTORY:BAG:6:PRICE 6 +db SERVER:INVENTORY:BAG:7:PRICE 7 +db SERVER:INVENTORY:BAG:8:PRICE 8 +db SERVER:INVENTORY:BAG:9:PRICE 9 +db SERVER:INVENTORY:BAG:10:PRICE 10 +db SERVER:INVENTORY:BAG:11:PRICE 11 +db SERVER:INVENTORY:BAG:12:PRICE 12 +db SERVER:INVENTORY:BAG:13:PRICE 13 +db SERVER:INVENTORY:BAG:14:PRICE 14 +db SERVER:INVENTORY:BAG:15:PRICE 15 +db SERVER:INVENTORY:BAG:16:PRICE 16 +db SERVER:INVENTORY:BAG:17:PRICE 17 +db SERVER:INVENTORY:BAG:18:PRICE 18 +db SERVER:INVENTORY:BAG:19:PRICE 19 +db SERVER:INVENTORY:BAG:20:PRICE 20 +db SERVER:INVENTORY:BAG:21:PRICE 21 +db SERVER:INVENTORY:BAG:22:PRICE 22 +db SERVER:INVENTORY:BAG:23:PRICE 23 +db SERVER:INVENTORY:BAG:24:PRICE 24 +db SERVER:INVENTORY:BAG:25:PRICE 25 +db SERVER:INVENTORY:BAG:26:PRICE 26 +db SERVER:INVENTORY:BAG:27:PRICE 27 +db SERVER:INVENTORY:BAG:28:PRICE 28 +db SERVER:INVENTORY:BAG:29:PRICE 29 +db SERVER:INVENTORY:BAG:30:PRICE 30 +db SERVER:INVENTORY:BAG:31:PRICE 31 +db SERVER:INVENTORY:BAG:32:PRICE 32 +db SERVER:INVENTORY:BAG:33:PRICE 33 +db SERVER:INVENTORY:BAG:34:PRICE 34 +db SERVER:INVENTORY:BAG:35:PRICE 35 +db SERVER:INVENTORY:BAG:36:PRICE 36 +db SERVER:INVENTORY:BAG:37:PRICE 37 +db SERVER:INVENTORY:BAG:38:PRICE 38 +db SERVER:INVENTORY:BAG:39:PRICE 39 +db SERVER:INVENTORY:BAG:40:PRICE 40 +db SERVER:INVENTORY:BAG:41:PRICE 41 +db SERVER:INVENTORY:BAG:42:PRICE 42 +db SERVER:INVENTORY:BAG:43:PRICE 43 +db SERVER:INVENTORY:BAG:44:PRICE 44 +db SERVER:INVENTORY:BAG:45:PRICE 45 +db SERVER:INVENTORY:BAG:46:PRICE 46 +db SERVER:INVENTORY:BAG:47:PRICE 47 +db SERVER:INVENTORY:BAG:48:PRICE 48 +db SERVER:INVENTORY:BAG:49:PRICE 49 +db SERVER:INVENTORY:BAG:50:PRICE 50 +db SERVER:INVENTORY:BAG:51:PRICE 51 +db SERVER:INVENTORY:BAG:52:PRICE 52 +db SERVER:INVENTORY:BAG:53:PRICE 53 +db SERVER:INVENTORY:BAG:54:PRICE 54 +db SERVER:INVENTORY:BAG:55:PRICE 55 +db SERVER:INVENTORY:BAG:56:PRICE 56 +db SERVER:INVENTORY:BAG:57:PRICE 57 +db SERVER:INVENTORY:BAG:58:PRICE 58 +db SERVER:INVENTORY:BAG:59:PRICE 59 +db SERVER:TRADING:FAME_PRICE_FACTOR 1000 + + +learnPhrase abf01.sphrase +db SERVER:USER:SKILL_POINTS_0:VALUE 100 +db SERVER:USER:SKILL_POINTS_1:VALUE 200 +db SERVER:USER:SKILL_POINTS_2:VALUE 300 +db SERVER:USER:SKILL_POINTS_3:VALUE 400 + + +fillAllInfoVersion 1 + +fullFillInventory SERVER:INVENTORY:PACK_ANIMAL3 icfm1ss.sitem +db SERVER:INVENTORY:PACK_ANIMAL3:0:PRICE 50000 + + +// test team share +fullFillInventory SERVER:INVENTORY:SHARE m0001dxadd01.sitem +db SERVER:INVENTORY:SHARE:0:NB_MEMBER 3 +db SERVER:INVENTORY:SHARE:0:WANTED 1 +db SERVER:INVENTORY:SHARE:0:CHANCE 70 + + +fillAllItemPreReq SERVER:INVENTORY:BAG 1 +fillAllItemPreReq SERVER:INVENTORY:PACK_ANIMAL0 1 +fillAllItemPreReq SERVER:INVENTORY:PACK_ANIMAL1 1 +fillAllItemPreReq SERVER:INVENTORY:PACK_ANIMAL2 1 +fillAllItemPreReq SERVER:INVENTORY:PACK_ANIMAL3 1 +fillAllItemPreReq SERVER:INVENTORY:TEMP 1 +fillAllItemPreReq SERVER:INVENTORY:SHARE 1 +fillAllItemPreReq SERVER:INVENTORY:ROOM 1 +fillAllItemPreReq SERVER:EXCHANGE:GIVE 1 +fillAllItemPreReq SERVER:EXCHANGE:RECEIVE 1 + + +db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:MaxProtectionClampValue 75 +db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:MaxAbsorptionFactor 100 +db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Acid 15 +db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Cold 12 +db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Fire 75 +db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Rot 99 +db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Shockwave 33 +db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Poison 43 +db SERVER:CHARACTER_INFO:MAGIC_PROTECTION:Electricity 74 + +db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:MaxResistanceBonus 50 +db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:Desert 24 +db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:Forest 75 +db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:Lacustre 51 +db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:Jungle 20 +db SERVER:CHARACTER_INFO:MAGIC_RESISTANCE:PrimaryRoot 25 + +db SERVER:CHARACTER_INFO:XP_CATALYSER:Level 100 +db SERVER:CHARACTER_INFO:XP_CATALYSER:Count 145 + +db SERVER:TARGET:CONTEXT_MENU:PROGRAMMES 16777215 +db SERVER:TARGET:CONTEXT_MENU:WEB_PAGE_TITLE 25 +db SERVER:TARGET:CONTEXT_MENU:WEB_PAGE_URL 38 + +db SERVER:USER:FACTION_POINTS_0:VALUE 30 +db SERVER:USER:FACTION_POINTS_1:VALUE 40 +db SERVER:USER:FACTION_POINTS_2:VALUE 50 +db SERVER:USER:FACTION_POINTS_3:VALUE 60 +db SERVER:USER:FACTION_POINTS_4:VALUE 70 +db SERVER:USER:FACTION_POINTS_5:VALUE 80 + +db SERVER:GUILD:INVENTORY:MONEY 10000000 diff --git a/code/ryzom/client/data/gamedev/fd2.cmd b/code/ryzom/client/data/gamedev/fd2.cmd index 75f186229..40817d7a1 100644 --- a/code/ryzom/client/data/gamedev/fd2.cmd +++ b/code/ryzom/client/data/gamedev/fd2.cmd @@ -1,98 +1,98 @@ -db SERVER:USER:ChaScore1_MAX 100 -db SERVER:USER:ChaScore1 45 -db SERVER:USER:ChaScore2_MAX 100 -db SERVER:USER:ChaScore2 70 -db SERVER:USER:ChaScore3_MAX 100 -db SERVER:USER:chaScore3 90 -db SERVER:USER:ACT_MAX 9 -db SERVER:USER:ACT 2 -db SERVER:TARGET:ChaScore1_MAX 100 -db SERVER:TARGET:ChaScore1 80 -db SERVER:TARGET:ChaScore2_MAX 100 -db SERVER:TARGET:ChaScore2 32 -db SERVER:TARGET:ChaScore3_MAX 100 -db SERVER:TARGET:ChaScore3 69 -// db SERVER:INVENTORY:1:0:SHEET 123648 -// db SERVER:INVENTORY:2:0:SHEET 137472 -// db SERVER:INVENTORY:2:1:SHEET 232960 -// db SERVER:INVENTORY:3:0:SHEET 197632 -// db SERVER:INVENTORY:4:0:SHEET 161024 -// db SERVER:INVENTORY:4:1:SHEET 231680 -db SERVER:INVENTORY:ACTIVE_SHEATH 1 -db SERVER:INVENTORY:NB_SHEATH 4 -db SERVER:INVENTORY:NB_BAG 3 - -// db SERVER:INVENTORY:9:0:SHEET 182272 -// db SERVER:INVENTORY:9:1:SHEET 271616 -// db SERVER:INVENTORY:9:1:QUANTITY 10 -// db SERVER:INVENTORY:9:2:SHEET 222208 -// db SERVER:INVENTORY:9:2:QUANTITY 1 -// db SERVER:INVENTORY:9:3:SHEET 222208 -// db SERVER:INVENTORY:9:3:QUANTITY 1 -// db SERVER:INVENTORY:9:4:SHEET 361728 -// db SERVER:INVENTORY:9:2:QUANTITY 1 -// db SERVER:INVENTORY:9:5:SHEET 361728 -// db SERVER:INVENTORY:9:6:SHEET 250624 -// db SERVER:INVENTORY:9:7:SHEET 230400 -db SERVER:INVENTORY:SEED:SMALL_SEED 945002 -db SERVER:INVENTORY:SEED:MEDIUM_SEED 3618 -db SERVER:INVENTORY:SEED:BIG_SEED 1276 -db SERVER:INVENTORY:SEED:VERY_BIG_SEED 45108 -// db SERVER:INVENTORY:8:1:SHEET 397056 -// db SERVER:INVENTORY:8:8:SHEET 399360 -// db SERVER:INVENTORY:8:9:SHEET 422656 - - -db SERVER:CHARACTER_INFO:CAREER0:JOB0:JOB_CAP 9 -db SERVER:CHARACTER_INFO:CAREER0:JOB1:JOB_CAP 10 -db SERVER:CHARACTER_INFO:CAREER0:JOB2:JOB_CAP 8 - -db SERVER:CHARACTER_INFO:CAREER1:JOB0:JOB_CAP16 -db SERVER:CHARACTER_INFO:CAREER1:JOB1:JOB_CAP 15 -db SERVER:CHARACTER_INFO:CAREER1:JOB2:JOB_CAP 13 -db SERVER:CHARACTER_INFO:CAREER1:JOB3:JOB_CAP 14 - -db SERVER:BRICK_FAMILY:7:BRICKS 255 -db SERVER:BRICK_FAMILY:9:BRICKS 255 -db SERVER:BRICK_FAMILY:8:BRICKS 255 - -// Jewelry - -db SERVER:INVENTORY:BAG:0:SHEET 104961 -db SERVER:INVENTORY:BAG:0:QUANTITY 1 -db SERVER:INVENTORY:BAG:0:QUALITY 10 - -db SERVER:INVENTORY:BAG:1:SHEET 105473 -db SERVER:INVENTORY:BAG:1:QUANTITY 1 -db SERVER:INVENTORY:BAG:1:QUALITY 10 - -db SERVER:INVENTORY:BAG:2:SHEET 112129 -db SERVER:INVENTORY:BAG:2:QUANTITY 1 -db SERVER:INVENTORY:BAG:2:QUALITY 10 - -db SERVER:INVENTORY:BAG:3:SHEET 111873 -db SERVER:INVENTORY:BAG:3:QUANTITY 1 -db SERVER:INVENTORY:BAG:3:QUALITY 10 - -// Traingningignningign tool -db SERVER:INVENTORY:9:4:SHEET 3134721 -db SERVER:INVENTORY:9:4:QUANTITY 1 -db SERVER:INVENTORY:9:5:SHEET 3132161 -db SERVER:INVENTORY:9:5:QUANTITY 1 -db SERVER:INVENTORY:9:6:SHEET 3140097 -db SERVER:INVENTORY:9:6:QUANTITY 1 -db SERVER:INVENTORY:9:7:SHEET 251649 -db SERVER:INVENTORY:9:7:QUANTITY 1 - -// Misc Skills -db SERVER:CHARACTER_INFO:SKILLS:0:BaseSKILL 20 -db SERVER:CHARACTER_INFO:SKILLS:0:SKILL 20 -db SERVER:CHARACTER_INFO:SKILLS:1:BaseSKILL 50 -db SERVER:CHARACTER_INFO:SKILLS:1:SKILL 50 -db SERVER:CHARACTER_INFO:SKILLS:2:BaseSKILL 100 -db SERVER:CHARACTER_INFO:SKILLS:2:SKILL 100 -db SERVER:CHARACTER_INFO:SKILLS:3:BaseSKILL 150 -db SERVER:CHARACTER_INFO:SKILLS:3:SKILL 150 -db SERVER:CHARACTER_INFO:SKILLS:4:PROGRESS_BAR 96 -db SERVER:CHARACTER_INFO:SKILLS:4:BaseSKILL 198 -db SERVER:CHARACTER_INFO:SKILLS:4:SKILL 178 +db SERVER:USER:ChaScore1_MAX 100 +db SERVER:USER:ChaScore1 45 +db SERVER:USER:ChaScore2_MAX 100 +db SERVER:USER:ChaScore2 70 +db SERVER:USER:ChaScore3_MAX 100 +db SERVER:USER:chaScore3 90 +db SERVER:USER:ACT_MAX 9 +db SERVER:USER:ACT 2 +db SERVER:TARGET:ChaScore1_MAX 100 +db SERVER:TARGET:ChaScore1 80 +db SERVER:TARGET:ChaScore2_MAX 100 +db SERVER:TARGET:ChaScore2 32 +db SERVER:TARGET:ChaScore3_MAX 100 +db SERVER:TARGET:ChaScore3 69 +// db SERVER:INVENTORY:1:0:SHEET 123648 +// db SERVER:INVENTORY:2:0:SHEET 137472 +// db SERVER:INVENTORY:2:1:SHEET 232960 +// db SERVER:INVENTORY:3:0:SHEET 197632 +// db SERVER:INVENTORY:4:0:SHEET 161024 +// db SERVER:INVENTORY:4:1:SHEET 231680 +db SERVER:INVENTORY:ACTIVE_SHEATH 1 +db SERVER:INVENTORY:NB_SHEATH 4 +db SERVER:INVENTORY:NB_BAG 3 + +// db SERVER:INVENTORY:9:0:SHEET 182272 +// db SERVER:INVENTORY:9:1:SHEET 271616 +// db SERVER:INVENTORY:9:1:QUANTITY 10 +// db SERVER:INVENTORY:9:2:SHEET 222208 +// db SERVER:INVENTORY:9:2:QUANTITY 1 +// db SERVER:INVENTORY:9:3:SHEET 222208 +// db SERVER:INVENTORY:9:3:QUANTITY 1 +// db SERVER:INVENTORY:9:4:SHEET 361728 +// db SERVER:INVENTORY:9:2:QUANTITY 1 +// db SERVER:INVENTORY:9:5:SHEET 361728 +// db SERVER:INVENTORY:9:6:SHEET 250624 +// db SERVER:INVENTORY:9:7:SHEET 230400 +db SERVER:INVENTORY:SEED:SMALL_SEED 945002 +db SERVER:INVENTORY:SEED:MEDIUM_SEED 3618 +db SERVER:INVENTORY:SEED:BIG_SEED 1276 +db SERVER:INVENTORY:SEED:VERY_BIG_SEED 45108 +// db SERVER:INVENTORY:8:1:SHEET 397056 +// db SERVER:INVENTORY:8:8:SHEET 399360 +// db SERVER:INVENTORY:8:9:SHEET 422656 + + +db SERVER:CHARACTER_INFO:CAREER0:JOB0:JOB_CAP 9 +db SERVER:CHARACTER_INFO:CAREER0:JOB1:JOB_CAP 10 +db SERVER:CHARACTER_INFO:CAREER0:JOB2:JOB_CAP 8 + +db SERVER:CHARACTER_INFO:CAREER1:JOB0:JOB_CAP16 +db SERVER:CHARACTER_INFO:CAREER1:JOB1:JOB_CAP 15 +db SERVER:CHARACTER_INFO:CAREER1:JOB2:JOB_CAP 13 +db SERVER:CHARACTER_INFO:CAREER1:JOB3:JOB_CAP 14 + +db SERVER:BRICK_FAMILY:7:BRICKS 255 +db SERVER:BRICK_FAMILY:9:BRICKS 255 +db SERVER:BRICK_FAMILY:8:BRICKS 255 + +// Jewelry + +db SERVER:INVENTORY:BAG:0:SHEET 104961 +db SERVER:INVENTORY:BAG:0:QUANTITY 1 +db SERVER:INVENTORY:BAG:0:QUALITY 10 + +db SERVER:INVENTORY:BAG:1:SHEET 105473 +db SERVER:INVENTORY:BAG:1:QUANTITY 1 +db SERVER:INVENTORY:BAG:1:QUALITY 10 + +db SERVER:INVENTORY:BAG:2:SHEET 112129 +db SERVER:INVENTORY:BAG:2:QUANTITY 1 +db SERVER:INVENTORY:BAG:2:QUALITY 10 + +db SERVER:INVENTORY:BAG:3:SHEET 111873 +db SERVER:INVENTORY:BAG:3:QUANTITY 1 +db SERVER:INVENTORY:BAG:3:QUALITY 10 + +// Traingningignningign tool +db SERVER:INVENTORY:9:4:SHEET 3134721 +db SERVER:INVENTORY:9:4:QUANTITY 1 +db SERVER:INVENTORY:9:5:SHEET 3132161 +db SERVER:INVENTORY:9:5:QUANTITY 1 +db SERVER:INVENTORY:9:6:SHEET 3140097 +db SERVER:INVENTORY:9:6:QUANTITY 1 +db SERVER:INVENTORY:9:7:SHEET 251649 +db SERVER:INVENTORY:9:7:QUANTITY 1 + +// Misc Skills +db SERVER:CHARACTER_INFO:SKILLS:0:BaseSKILL 20 +db SERVER:CHARACTER_INFO:SKILLS:0:SKILL 20 +db SERVER:CHARACTER_INFO:SKILLS:1:BaseSKILL 50 +db SERVER:CHARACTER_INFO:SKILLS:1:SKILL 50 +db SERVER:CHARACTER_INFO:SKILLS:2:BaseSKILL 100 +db SERVER:CHARACTER_INFO:SKILLS:2:SKILL 100 +db SERVER:CHARACTER_INFO:SKILLS:3:BaseSKILL 150 +db SERVER:CHARACTER_INFO:SKILLS:3:SKILL 150 +db SERVER:CHARACTER_INFO:SKILLS:4:PROGRESS_BAR 96 +db SERVER:CHARACTER_INFO:SKILLS:4:BaseSKILL 198 +db SERVER:CHARACTER_INFO:SKILLS:4:SKILL 178 diff --git a/code/ryzom/client/data/gamedev/fd3.cmd b/code/ryzom/client/data/gamedev/fd3.cmd index 0ed00d4ce..51159aa84 100644 --- a/code/ryzom/client/data/gamedev/fd3.cmd +++ b/code/ryzom/client/data/gamedev/fd3.cmd @@ -1,114 +1,114 @@ -db UI:COLOR:R 159 -db UI:COLOR:G 174 -db UI:COLOR:B 113 -db UI:COLOR:A 255 - -db SERVER:MODIFIERS:BONUS:0:SHEET 1572 -db SERVER:MODIFIERS:BONUS:1:SHEET 1572 -db SERVER:MODIFIERS:BONUS:2:SHEET 1572 -db SERVER:MODIFIERS:BONUS:3:SHEET 1572 -db SERVER:MODIFIERS:BONUS:4:SHEET 1572 -db SERVER:MODIFIERS:BONUS:5:SHEET 1572 -db SERVER:MODIFIERS:BONUS:6:SHEET 1572 -db SERVER:MODIFIERS:BONUS:7:SHEET 1572 -db SERVER:MODIFIERS:MALUS:0:SHEET 1572 -db SERVER:MODIFIERS:MALUS:1:SHEET 1572 -db SERVER:MODIFIERS:MALUS:2:SHEET 1572 -db SERVER:CHARACTER_INFO:SCORES:ChaScore3 10 -db SERVER:CHARACTER_INFO:SCORES:MaxChaScore3 100 -db SERVER:CHARACTER_INFO:SCORES:MaxChaScore3Status 1 -db SERVER:CHARACTER_INFO:SCORES:ChaScore2 25 -db SERVER:CHARACTER_INFO:SCORES:MaxChaScore2 110 -db SERVER:CHARACTER_INFO:SCORES:MaxChaScore2Status 2 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha2 30 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxCha2Status 0 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha1 90 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxCha1Status 1 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Agility 60 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxAgilityStatus 2 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Will 45 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxWillStatus 0 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha2Reg 65 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxCha2RegStatus 2 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha3 33 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxCha3Status 0 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Charisme 10 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxCharismeStatus 1 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Empathie 62 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxEmpathieStatus 1 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:Perception 87 -db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxPerceptionStatus 0 -db SERVER:CHARACTER_INFO:SCORES:DiseaseResist 10 -db SERVER:CHARACTER_INFO:SCORES:MaxDiseaseResist 100 -db SERVER:CHARACTER_INFO:SCORES:MaxDiseaseResistStatus 0 -db SERVER:CHARACTER_INFO:SCORES:MagicResist 20 -db SERVER:CHARACTER_INFO:SCORES:MaxMagicResist 100 -db SERVER:CHARACTER_INFO:SCORES:MaxMagicResistStatus 1 -db SERVER:CHARACTER_INFO:SCORES:TechnoResist 30 -db SERVER:CHARACTER_INFO:SCORES:MaxTechnoResist 100 -db SERVER:CHARACTER_INFO:SCORES:MaxTechnoResistStatus 2 -db SERVER:CHARACTER_INFO:SCORES:ImpactResist 40 -db SERVER:CHARACTER_INFO:SCORES:MaxImpactResist 100 -db SERVER:CHARACTER_INFO:SCORES:MaxImpactResistStatus 0 -db SERVER:CHARACTER_INFO:SCORES:FearResist 50 -db SERVER:CHARACTER_INFO:SCORES:MaxFearResist 100 -db SERVER:CHARACTER_INFO:SCORES:MaxFearResistStatus 1 - -// Missions (icon == 0 pas de mission) - -db SERVER:MISSIONS:0:TITLE 50 -db SERVER:MISSIONS:0:DETAIL_TEXT 60 -db SERVER:MISSIONS:0:ICON generic_forage.mission_icon -db SERVER:MISSIONS:0:GOALS:0:TEXT 40 -db SERVER:MISSIONS:0:GOALS:1:TEXT 50 -db SERVER:MISSIONS:0:GOALS:2:TEXT 60 -db SERVER:MISSIONS:0:GOALS:3:TEXT 70 -db SERVER:MISSIONS:0:GOALS:4:TEXT 80 -db SERVER:MISSIONS:0:BEGIN_DATE 1200 -db SERVER:MISSIONS:0:END_DATE 1800 -db SERVER:MISSIONS:0:HISTO:0:TEXT 140 -db SERVER:MISSIONS:0:HISTO:1:TEXT 150 -db SERVER:MISSIONS:0:HISTO:2:TEXT 160 -db SERVER:MISSIONS:0:HISTO:3:TEXT 170 -db SERVER:MISSIONS:0:HISTO:4:TEXT 180 -db SERVER:MISSIONS:0:POS 0 - -db SERVER:MISSIONS:1:TITLE 30 -db SERVER:MISSIONS:1:DETAIL_TEXT 80 -db SERVER:MISSIONS:1:ICON generic_rite.mission_icon -db SERVER:MISSIONS:1:GOALS:0:TEXT 44 -db SERVER:MISSIONS:1:GOALS:1:TEXT 55 -db SERVER:MISSIONS:1:HISTO:0:TEXT 144 -db SERVER:MISSIONS:1:HISTO:1:TEXT 154 -db SERVER:MISSIONS:1:HISTO:2:TEXT 164 -db SERVER:MISSIONS:1:POS 1 - -db SERVER:MISSIONS:2:TITLE 90 -db SERVER:MISSIONS:2:DETAIL_TEXT 40 -db SERVER:MISSIONS:2:ICON generic_craft.mission_icon -db SERVER:MISSIONS:2:FINISHED 1 -db SERVER:MISSIONS:2:POS 2 - -db SERVER:MISSIONS:3:TITLE 465 -db SERVER:MISSIONS:3:DETAIL_TEXT 0 -db SERVER:MISSIONS:3:ICON generic_fight.mission_icon -db SERVER:MISSIONS:3:FINISHED 2 -db SERVER:MISSIONS:3:POS 3 - -db SERVER:MISSIONS:4:TITLE 123 -db SERVER:MISSIONS:4:DETAIL_TEXT 65 -db SERVER:MISSIONS:4:ICON generic_travel.mission_icon -db SERVER:MISSIONS:4:POS 4 - -db SERVER:MISSIONS:12:TITLE 12 -db SERVER:MISSIONS:12:DETAIL_TEXT 12 -db SERVER:MISSIONS:12:ICON generic_generic.mission_icon -db SERVER:MISSIONS:12:POS 12 - - - - - - - - +db UI:COLOR:R 159 +db UI:COLOR:G 174 +db UI:COLOR:B 113 +db UI:COLOR:A 255 + +db SERVER:MODIFIERS:BONUS:0:SHEET 1572 +db SERVER:MODIFIERS:BONUS:1:SHEET 1572 +db SERVER:MODIFIERS:BONUS:2:SHEET 1572 +db SERVER:MODIFIERS:BONUS:3:SHEET 1572 +db SERVER:MODIFIERS:BONUS:4:SHEET 1572 +db SERVER:MODIFIERS:BONUS:5:SHEET 1572 +db SERVER:MODIFIERS:BONUS:6:SHEET 1572 +db SERVER:MODIFIERS:BONUS:7:SHEET 1572 +db SERVER:MODIFIERS:MALUS:0:SHEET 1572 +db SERVER:MODIFIERS:MALUS:1:SHEET 1572 +db SERVER:MODIFIERS:MALUS:2:SHEET 1572 +db SERVER:CHARACTER_INFO:SCORES:ChaScore3 10 +db SERVER:CHARACTER_INFO:SCORES:MaxChaScore3 100 +db SERVER:CHARACTER_INFO:SCORES:MaxChaScore3Status 1 +db SERVER:CHARACTER_INFO:SCORES:ChaScore2 25 +db SERVER:CHARACTER_INFO:SCORES:MaxChaScore2 110 +db SERVER:CHARACTER_INFO:SCORES:MaxChaScore2Status 2 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha2 30 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxCha2Status 0 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha1 90 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxCha1Status 1 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Agility 60 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxAgilityStatus 2 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Will 45 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxWillStatus 0 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha2Reg 65 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxCha2RegStatus 2 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Cha3 33 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxCha3Status 0 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Charisme 10 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxCharismeStatus 1 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Empathie 62 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxEmpathieStatus 1 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:Perception 87 +db SERVER:CHARACTER_INFO:CHARACTERISTICS:MaxPerceptionStatus 0 +db SERVER:CHARACTER_INFO:SCORES:DiseaseResist 10 +db SERVER:CHARACTER_INFO:SCORES:MaxDiseaseResist 100 +db SERVER:CHARACTER_INFO:SCORES:MaxDiseaseResistStatus 0 +db SERVER:CHARACTER_INFO:SCORES:MagicResist 20 +db SERVER:CHARACTER_INFO:SCORES:MaxMagicResist 100 +db SERVER:CHARACTER_INFO:SCORES:MaxMagicResistStatus 1 +db SERVER:CHARACTER_INFO:SCORES:TechnoResist 30 +db SERVER:CHARACTER_INFO:SCORES:MaxTechnoResist 100 +db SERVER:CHARACTER_INFO:SCORES:MaxTechnoResistStatus 2 +db SERVER:CHARACTER_INFO:SCORES:ImpactResist 40 +db SERVER:CHARACTER_INFO:SCORES:MaxImpactResist 100 +db SERVER:CHARACTER_INFO:SCORES:MaxImpactResistStatus 0 +db SERVER:CHARACTER_INFO:SCORES:FearResist 50 +db SERVER:CHARACTER_INFO:SCORES:MaxFearResist 100 +db SERVER:CHARACTER_INFO:SCORES:MaxFearResistStatus 1 + +// Missions (icon == 0 pas de mission) + +db SERVER:MISSIONS:0:TITLE 50 +db SERVER:MISSIONS:0:DETAIL_TEXT 60 +db SERVER:MISSIONS:0:ICON generic_forage.mission_icon +db SERVER:MISSIONS:0:GOALS:0:TEXT 40 +db SERVER:MISSIONS:0:GOALS:1:TEXT 50 +db SERVER:MISSIONS:0:GOALS:2:TEXT 60 +db SERVER:MISSIONS:0:GOALS:3:TEXT 70 +db SERVER:MISSIONS:0:GOALS:4:TEXT 80 +db SERVER:MISSIONS:0:BEGIN_DATE 1200 +db SERVER:MISSIONS:0:END_DATE 1800 +db SERVER:MISSIONS:0:HISTO:0:TEXT 140 +db SERVER:MISSIONS:0:HISTO:1:TEXT 150 +db SERVER:MISSIONS:0:HISTO:2:TEXT 160 +db SERVER:MISSIONS:0:HISTO:3:TEXT 170 +db SERVER:MISSIONS:0:HISTO:4:TEXT 180 +db SERVER:MISSIONS:0:POS 0 + +db SERVER:MISSIONS:1:TITLE 30 +db SERVER:MISSIONS:1:DETAIL_TEXT 80 +db SERVER:MISSIONS:1:ICON generic_rite.mission_icon +db SERVER:MISSIONS:1:GOALS:0:TEXT 44 +db SERVER:MISSIONS:1:GOALS:1:TEXT 55 +db SERVER:MISSIONS:1:HISTO:0:TEXT 144 +db SERVER:MISSIONS:1:HISTO:1:TEXT 154 +db SERVER:MISSIONS:1:HISTO:2:TEXT 164 +db SERVER:MISSIONS:1:POS 1 + +db SERVER:MISSIONS:2:TITLE 90 +db SERVER:MISSIONS:2:DETAIL_TEXT 40 +db SERVER:MISSIONS:2:ICON generic_craft.mission_icon +db SERVER:MISSIONS:2:FINISHED 1 +db SERVER:MISSIONS:2:POS 2 + +db SERVER:MISSIONS:3:TITLE 465 +db SERVER:MISSIONS:3:DETAIL_TEXT 0 +db SERVER:MISSIONS:3:ICON generic_fight.mission_icon +db SERVER:MISSIONS:3:FINISHED 2 +db SERVER:MISSIONS:3:POS 3 + +db SERVER:MISSIONS:4:TITLE 123 +db SERVER:MISSIONS:4:DETAIL_TEXT 65 +db SERVER:MISSIONS:4:ICON generic_travel.mission_icon +db SERVER:MISSIONS:4:POS 4 + +db SERVER:MISSIONS:12:TITLE 12 +db SERVER:MISSIONS:12:DETAIL_TEXT 12 +db SERVER:MISSIONS:12:ICON generic_generic.mission_icon +db SERVER:MISSIONS:12:POS 12 + + + + + + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml b/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml index 5fb009adf..c9ef4cf73 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml @@ -171,6 +171,22 @@ + + + + + + + + + + + + + + + + @@ -213,8 +229,8 @@ - - + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml b/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml index 6fdb5d32a..d7aabccae 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml @@ -50,6 +50,24 @@ + + + + + + + + + + + + + + + + + + @@ -63,9 +81,15 @@ + + + + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/config.xml b/code/ryzom/client/data/gamedev/interfaces_v3/config.xml index ff606e678..8544de2fc 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/config.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/config.xml @@ -583,11 +583,11 @@ + value="-7" /> + value="-7" /> + value="-23" /> + value="-7" /> + value="-7" /> + value="-7" /> + value="-4" /> + value="-4" /> + value="-3" /> + value="-3" /> + value="-3" /> + value="-3" /> + value="-3" /> + value="-3" /> + value="-4" /> + value="-4" /> @@ -1698,11 +1698,11 @@ + value="0" /> + value="0" /> @@ -2767,6 +2767,9 @@ This MUST follow the Enum MISSION_DESC::TIconId + @@ -2884,15 +2887,12 @@ This MUST follow the Enum MISSION_DESC::TIconId type="bool" value="true" /> - - - + + + @@ -3323,9 +3323,6 @@ This MUST follow the Enum MISSION_DESC::TIconId - @@ -3344,9 +3341,6 @@ This MUST follow the Enum MISSION_DESC::TIconId - - - - - - - - + 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 c417e3aa1..55849ef83 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" /> + + @@ -199,7 +199,7 @@ x="-15" y="10" posref="BM BM" - text_y="-0" + text_y="0" onclick_l="proc" params_l="active_hardware_cursor" hardtext="uiYes" /> @@ -208,7 +208,7 @@ y="0" posparent="active_ok" posref="BR BL" - text_y="-0" + text_y="0" onclick_l="proc" params_l="close_hardware_cursor" hardtext="uiNo" /> @@ -316,7 +316,7 @@ x="0" y="6" posref="BM BM" - text_y="-0" + text_y="0" onclick_l="proc" params_l="universe_chanel_warning_close" hardtext="uittOK" /> @@ -425,7 +425,7 @@ x="0" y="6" posref="BM BM" - text_y="-0" + text_y="0" onclick_l="proc" params_l="death_warning_close" hardtext="uittOK" /> @@ -532,7 +532,7 @@ x="0" y="6" posref="BM BM" - text_y="-0" + text_y="0" onclick_l="proc" params_l="night_warning_close" hardtext="uittOK" /> @@ -2889,21 +2889,21 @@ x="4" y="0" posref="TL TL" - text_y="-0" + text_y="0" onclick_l="proc" params_l="proc_stat_report_yes" hardtext="uiYes" /> self.WaitingPeriod then + if timeInSec - self.LastRefreshTime > self.WaitingPeriod then self.WaitingInfo = false self.LastRefreshTime = nltime.getLocalTime() / 1000 - else + else if not self.InfoReceived then --debugInfo("No received info") end end else - if timeInSec - self.LastRefreshTime > self.RefreshPeriod then + if timeInSec - self.LastRefreshTime > self.RefreshPeriod then self:refresh() else --debugInfo("pas de refresh") @@ -844,7 +844,7 @@ function RingPlayerInfo:updatePendingRefresh() if self.PendingRefresh then local currTime = nltime.getLocalTime() / 1000 - if currTime - self.LastRefreshQuerryTime > self.MinRefreshPeriod and game.getRingStats then + if currTime - self.LastRefreshQuerryTime > self.MinRefreshPeriod and game.getRingStats then self.LastRefreshQuerryTime = currTime self.PendingRefresh = false game.getRingStats() @@ -924,10 +924,10 @@ end -- function RingPlayerInfo:refresh() - self.PendingRefresh = true + self.PendingRefresh = true self.LastRefreshTime = nltime.getLocalTime() / 1000 self.WaitingInfo = true -end +end -------------------------------------------------------------------------------------------------------------- -- @@ -937,7 +937,7 @@ function RingPlayerInfo:tooltipEcosystemPoints(rp, maxRp, ttFormat) local fmt = i18n.get(ttFormat); fmt = findReplaceAll(fmt, "%n", rp ); fmt = findReplaceAll(fmt, "%p", maxRp ); - + -- Set tooltip return fmt; end @@ -954,8 +954,8 @@ function RingPlayerInfo:updateRRPSLevel(dbVal, tooltip) local ui= getUICaller(); local uiText= ui.val; - -- set the text - uiText.uc_hardtext= tostring(val) + -- set the text + uiText.uc_hardtext= tostring(val) self:tooltipRRPs(dbVal, tooltip) end @@ -970,7 +970,7 @@ function RingPlayerInfo:tooltipRRPs(dbBase, ttFormat) local fmt = i18n.get(ttFormat); local text = tostring(val) fmt = findReplaceAll(fmt, "%n", text ); - + -- Set tooltip setContextHelpText(fmt); end @@ -1013,7 +1013,7 @@ end -------------------------------------------------------------------------------------------------------------- -- function game:updateOrganization(path, uiOrgText, uiStatusText, uiPointsText) - + local org = getDbProp(path.."1:VALUE") getUICaller()[uiOrgText].uc_hardtext = i18n.get('uiOrganization_' .. org) @@ -1022,7 +1022,7 @@ function game:updateOrganization(path, uiOrgText, uiStatusText, uiPointsText) local points = getDbProp(path.."3:VALUE") getUICaller()[uiPointsText].uc_hardtext= points - + end ------------------------------------------------------------------------------------------------------------ @@ -1033,10 +1033,10 @@ end -------------------------------------------------------------------------------------------------------------- -function game:popMissionList() - local menu = getUI("ui:interface:mission_cb_menu") +function game:popMissionList() + local menu = getUI("ui:interface:mission_cb_menu") enableModalWindow(getUICaller(), "ui:interface:mission_cb_menu") - self:updateMissionMenuSize() + self:updateMissionMenuSize() end @@ -1053,12 +1053,12 @@ function game:getMissionDbPath(missionIndex) return "SERVER:GROUP:MISSIONS:" .. tostring(missionIndex - numMissions) else return "SERVER:MISSIONS:" .. tostring(missionIndex) - end + end end -------------------------------------------------------------------------------------------------------------- -function game:getCurrMissionIndex() - local result = getDbProp("UI:SAVE:MISSION_SELECTED") +function game:getCurrMissionIndex() + local result = getDbProp("UI:SAVE:MISSION_SELECTED") return result end @@ -1071,10 +1071,10 @@ end function game:updateCurrMissionComboBox() local numMissions = tonumber(getDefine("ipj_nb_mission")) local missionFound = false - local cb = getUI("ui:interface:info_player_journal:content:mission_combo") - local missionList = getUI("ui:interface:info_player_journal:content:mission_list") + local cb = getUI("ui:interface:info_player_journal:content:mission_combo") + local missionList = getUI("ui:interface:info_player_journal:content:mission_list") for i = 0, numMissions - 1 do - if getDbProp("SERVER:MISSIONS:" .. i .. ":TITLE") ~= 0 + if getDbProp("SERVER:MISSIONS:" .. i .. ":TITLE") ~= 0 or getDbProp("SERVER:GROUP:MISSIONS:" .. i .. ":TITLE") ~= 0 then missionFound = true break @@ -1095,20 +1095,20 @@ function game:updateCurrMissionComboBox() missionList.no_available_mission.active = false cb.arrow.active = true cb.select.active = true - local currMission = self:getCurrMissionIndex() + local currMission = self:getCurrMissionIndex() - local dbPath = self:getMissionDbPath(currMission) - -- - local selected = (currMission ~= -1) + local dbPath = self:getMissionDbPath(currMission) + -- + local selected = (currMission ~= -1) if selected then cb.mission_title.textid_dblink = dbPath .. ":TITLE" selected = (tile ~= 0) - end + end cb.mission_ico.active = selected cb.mission_title.active = selected cb.no_selected_mission.active = not selected missionList.no_selected_mission.active = not selected - if selected then + if selected then if getDbProp(dbPath .. ":FINISHED") == 0 then cb.mission_ico.texture = runExpr("getMissionSmallIcon(" .. tostring(getDbProp(dbPath .. ":ICON") .. ")")) elseif getDbProp(dbPath .. ":FINISHED") == 1 then @@ -1116,17 +1116,17 @@ function game:updateCurrMissionComboBox() else cb.mission_ico.texture = "Small_Task_Failed.tga" end - end + end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionSelected(index) +function game:onMissionSelected(index) disableModalWindow() self:updateCurrMissionComboBox() end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionSelected(index) +function game:onGroupMissionSelected(index) disableModalWindow() self:updateCurrMissionComboBox() end @@ -1138,33 +1138,33 @@ function game:onMissionDBIndexChanged() -- if selection was made from the list, update the other list if missionIndex >= self:getGroupMissionFirstIndex() then local groupMissionIndex = missionIndex - self:getGroupMissionFirstIndex() - getUI("ui:interface:info_player_journal:content:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true + getUI("ui:interface:info_player_journal:content:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true getUI("ui:interface:mission_cb_menu:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true else - getUI("ui:interface:info_player_journal:content:mission_list:b_title" .. tostring(missionIndex)).pushed = true + getUI("ui:interface:info_player_journal:content:mission_list:b_title" .. tostring(missionIndex)).pushed = true getUI("ui:interface:mission_cb_menu:mission_list:b_title" .. tostring(missionIndex)).pushed = true end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionTitleChanged(index) +function game:onMissionTitleChanged(index) -- if title is not nil then a new mission has been added -> if db initilization is over, then selected this new mission - if getDbProp(self:getMissionDbPath(index) .. ":TITLE") ~= 0 then - if game.InGameDbInitialized or config.Local then + if getDbProp(self:getMissionDbPath(index) .. ":TITLE") ~= 0 then + if game.InGameDbInitialized or config.Local then self:setCurrentMission(index) end - else + else self:updateCurrMissionComboBox() self:updateMissionMenuSize() end end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionTitleChanged(index) - if getDbProp(self:getMissionDbPath(index + 15) .. ":TITLE") ~= 0 then - if game.InGameDbInitialized or config.Local then +function game:onGroupMissionTitleChanged(index) + if getDbProp(self:getMissionDbPath(index + 15) .. ":TITLE") ~= 0 then + if game.InGameDbInitialized or config.Local then self:setCurrentMission(index + 15) end - else + else self:updateCurrMissionComboBox() self:updateMissionMenuSize() end @@ -1174,21 +1174,21 @@ end function game:updateMissionMenuSize() local parentCB = getUI("ui:interface:info_player_journal:content:mission_combo") local menu = getUI("ui:interface:mission_cb_menu") - if not menu.active then return end + if not menu.active then return end local maxNumMissions = 2 * self:getGroupMissionFirstIndex() - local missionCount = 0 + local missionCount = 0 for k = 0, maxNumMissions - 1 do if getDbProp(self:getMissionDbPath(k) .. ":TITLE") ~= 0 then - missionCount = missionCount + 1 + missionCount = missionCount + 1 end - end + end menu.h = 8 + missionCount * 18 menu.y = 0 menu:updateCoords() local y = parentCB.y_real - menu.h_real - 1 if y < 0 then y = parentCB.y_real + parentCB.h_real + 1 - end + end local scrW local scrH scrW, scrH = getWindowSize() @@ -1197,7 +1197,7 @@ function game:updateMissionMenuSize() end menu.w = parentCB.w_real menu.y = y - menu.x = parentCB.x_real + menu.x = parentCB.x_real menu.h = 8 + missionCount * 18 menu:invalidateCoords() end @@ -1205,7 +1205,7 @@ end -------------------------------------------------------------------------------------------------------------- --function game:updateMissionDescCloseButton(index) -- local dbPath = self:getMissionDbPath(index) --- if index == self:getCurrMissionIndex() then +-- if index == self:getCurrMissionIndex() then -- local closeText = getUI("ui:interface:info_player_journal:content:desc:close") -- local button = getUI("ui:interface:info_player_journal:content:desc:uppart:over_icon") -- local finished = getDbProp(dbPath .. ":FINISHED") @@ -1224,29 +1224,29 @@ end --end -------------------------------------------------------------------------------------------------------------- -function game:onMissionFinished(index) - self:updateCurrMissionComboBox() +function game:onMissionFinished(index) + self:updateCurrMissionComboBox() --self:updateMissionDescCloseButton(index) end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionFinished(index) +function game:onGroupMissionFinished(index) self:updateCurrMissionComboBox() --self:updateMissionDescCloseButton(index + game:getGroupMissionFirstIndex()) end -------------------------------------------------------------------------------------------------------------- -function game:expandMissionList() - local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") +function game:expandMissionList() + local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") missionCB.active = not missionCB.active self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -function game:updateMissionWindowLayout() +function game:updateMissionWindowLayout() if not isInRingMode() then local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") - local missionList = getUI("ui:interface:info_player_journal:content:mission_list") + local missionList = getUI("ui:interface:info_player_journal:content:mission_list") local fake = getUI("ui:interface:info_player_journal:content:fake") local sepBis = getUI("ui:interface:info_player_journal:content:separator_bis") local desc = getUI("ui:interface:info_player_journal:content:desc") @@ -1254,18 +1254,18 @@ function game:updateMissionWindowLayout() local popMinH local win = getUI("ui:interface:info_player_journal") - if missionCB.active then - sepBis.active = false + if missionCB.active then + sepBis.active = false missionList.active = false fake.sizeref="" fake.y = -32 fake.h = 0 - expanded = 0 + expanded = 0 desc.max_sizeref ="wh" desc.max_h= -42 win.pop_min_h = 152 - win.content_y_offset - else - sepBis.active = true + else + sepBis.active = true missionList.active = true fake.sizeref="wh5" fake.y = -8 @@ -1274,23 +1274,23 @@ function game:updateMissionWindowLayout() desc.max_sizeref ="wh5" desc.max_h=16 win.pop_min_h = 152 - win.content_y_offset - end + end - local fixedEntry = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") + local fixedEntry = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") fixedEntry:updateCoords() desc.max_h = desc.max_h - fixedEntry.h setDbProp("UI:SAVE:EXPAND_MISSION_LIST", expanded) - getUI("ui:interface:info_player_journal"):invalidateCoords() + getUI("ui:interface:info_player_journal"):invalidateCoords() end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionJournalOpened() +function game:onMissionJournalOpened() local missionDesc = getUI("ui:interface:info_player_journal:content:desc") - missionDesc.active = getDbProp("UI:SAVE:MISSION_SELECTED") ~= -1 + missionDesc.active = getDbProp("UI:SAVE:MISSION_SELECTED") ~= -1 - local expandList = getDbProp("UI:SAVE:EXPAND_MISSION_LIST") + local expandList = getDbProp("UI:SAVE:EXPAND_MISSION_LIST") self:updateMissionJournalMode() if not isInRingMode() then @@ -1304,9 +1304,9 @@ function game:onMissionJournalOpened() self:updateMissionJournalHeader() self:updateMissionWindowLayout() - self:updateMissionJournalFixedEntry() + self:updateMissionJournalFixedEntry() + - end @@ -1315,12 +1315,12 @@ function game:updateMissionJournalHeader() local win = getUI("ui:interface:info_player_journal") local headerActive = getDbProp("UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE") ~= 0 win.header_active = headerActive - win.right_button_enabled = headerActive + win.right_button_enabled = headerActive if headerActive then - win.uc_title_opened = i18n.get("uiJournalTitle") + win.uc_title_opened = i18n.get("uiJournalTitle") win.content_y_offset = 0 else - win.uc_title_opened = ucstring("") + win.uc_title_opened = ucstring("") win.content_y_offset = win.header_opened.h_real + 3 end end @@ -1329,13 +1329,13 @@ end -------------------------------------------------------------------------------------------------------------- function game:updateMissionJournalFixedEntry() -- update fixed entry text - - local fixedEntryRing = getUI("ui:interface:info_player_journal:no_available_missions:main:mission_fixed_entry") + + local fixedEntryRing = getUI("ui:interface:info_player_journal:no_available_missions:main:mission_fixed_entry") local fixedEntryMain = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") - + fixedEntryRing.active = game.InGameDbInitialized and isInRingMode() - fixedEntryMain.active = game.InGameDbInitialized and not isInRingMode() - + fixedEntryMain.active = game.InGameDbInitialized and not isInRingMode() + local id = "uiFixedMissionEntry" @@ -1346,22 +1346,22 @@ function game:updateMissionJournalFixedEntry() end if isPlayerFreeTrial() then id = id .. "_Trial" - end + end else - if isInRingMode() then - id = id .. "_R2" - else + if isInRingMode() then + id = id .. "_R2" + else id = id .. "_Mainland_" .. getUserRace() end - end + end fixedEntryMain.uc_hardtext = i18n.get(id) fixedEntryRing.uc_hardtext = i18n.get(id) - + self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -function game:setCurrentMission(index) +function game:setCurrentMission(index) mw = getMissionWindow() mw.active = game.InGameDbInitialized if index < self:getGroupMissionFirstIndex() then @@ -1372,7 +1372,7 @@ function game:setCurrentMission(index) end -------------------------------------------------------------------------------------------------------------- -function game:onMissionComboWheelUp() +function game:onMissionComboWheelUp() local currMissionIndex = self:getCurrMissionIndex() while currMissionIndex > 0 do currMissionIndex = currMissionIndex - 1 @@ -1384,7 +1384,7 @@ function game:onMissionComboWheelUp() end -------------------------------------------------------------------------------------------------------------- -function game:onMissionComboWheelDown() +function game:onMissionComboWheelDown() local currMissionIndex = self:getCurrMissionIndex() local maxNumMission = 2 * self:getGroupMissionFirstIndex() while currMissionIndex < (maxNumMission - 1) do @@ -1399,37 +1399,37 @@ end -------------------------------------------------------------------------------------------------------------- -function game:toggleMissionJournalCaption() - local dbPath = "UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE" +function game:toggleMissionJournalCaption() + local dbPath = "UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE" setDbProp(dbPath, 1 - getDbProp(dbPath)) - local win = getUI("ui:interface:info_player_journal") + local win = getUI("ui:interface:info_player_journal") self:updateMissionJournalHeader() self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -- handler called by C++ to tell that the main loop is about to begin -function game:onMainLoopBegin() - game.InGameDbInitialized = false +function game:onMainLoopBegin() + game.InGameDbInitialized = false game.PrevSessionMission = getDbProp("UI:VARIABLES:MISSION_SELECTED_PREV_SESSION") - + debugInfo("onMainLoopBegin()") end -------------------------------------------------------------------------------------------------------------- -- handler called by C++ to tell that all initial value have been set in the db -function game:onInGameDbInitialized() +function game:onInGameDbInitialized() game.InGameDbInitialized = true - -- if the journal is opened, force an update for the fixed entry text + -- if the journal is opened, force an update for the fixed entry text -- (says if we're in start island, paying account ...) need DB flags like -- IS_NEWBIE & IS_TRIAL to be received - game:updateMissionJournalFixedEntry() - -- If a mission was previously selected, restore it + game:updateMissionJournalFixedEntry() + -- If a mission was previously selected, restore it if game.PrevSessionMission ~= -1 then - self:setCurrentMission(game.PrevSessionMission) + self:setCurrentMission(game.PrevSessionMission) end - + game:setInfoPlayerCharacterRace() end @@ -1437,7 +1437,7 @@ function game:onWebIgReady() -- Call init webig getUI("ui:interface:web_transactions:content:html"):browse("home") getUI("ui:interface:webig:content:html"):browse("home") - + end -------------------------------------------------------------------------------------------------------------- @@ -1464,7 +1464,7 @@ end -------------------------------------------------------------------------------------------------------------- -- ring journal on / off -function game:setMissionJournalRingMode(isRing) +function game:setMissionJournalRingMode(isRing) local journal = getUI("ui:interface:info_player_journal") if isRing then journal.content.expand_mission_list.active = false @@ -1480,7 +1480,7 @@ function game:setMissionJournalRingMode(isRing) journal.no_available_missions.active = true else journal.content.expand_mission_list.active = true - journal.no_available_missions.active = false; + journal.no_available_missions.active = false; journal.content.active = true; --journal.content.mission_list.active = true; journal.content.sv.active = true; @@ -1494,8 +1494,8 @@ end -------------------------------------------------------------------------------------------------------------- -- update mission journal depending on wether we're in the ring or not function game:updateMissionJournalMode() - --local isRing = r2~=nil and r2.Mode~=nil and r2.Mode=='r2ed_anim_test' - game:setMissionJournalRingMode(isInRingMode()) + --local isRing = r2~=nil and r2.Mode~=nil and r2.Mode=='r2ed_anim_test' + game:setMissionJournalRingMode(isInRingMode()) end @@ -1521,22 +1521,22 @@ function game:onNewMissionStepAdded(stepIndex) end -- debugInfo("New Step") - if missionIndex < 15 then + if missionIndex < 15 then dbPath = "SERVER:MISSIONS:" .. tostring(missionIndex) .. ":GOALS:" .. tostring(stepIndex) .. ":TEXT" - else + else dbPath = "SERVER:GROUP:MISSIONS:" .. tostring(missionIndex - 15) .. ":GOALS:" .. tostring(stepIndex) .. ":TEXT" - end + end local stringID = getDbProp(dbPath) if stringID ~= 0 then -- debugInfo(tostring(stringID)) table.insert(remainingMissionTextIDs, stringID) - setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility0()") - else + setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility0()") + else end end function game:ensureLastMissionStepVisibility0() - + local missing = false for k, v in pairs(remainingMissionTextIDs) do if not isDynStringAvailable(v) then @@ -1545,54 +1545,54 @@ function game:ensureLastMissionStepVisibility0() end end local missionWnd = getMissionWindow() - if not missing then + if not missing then remainingMissionTextIDs = {} - -- delay real update to newt frame - setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility1()") + -- delay real update to newt frame + setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility1()") else - -- for debug : dump the list of remaining "dyn string" + -- for debug : dump the list of remaining "dyn string" --local stringList = "{" --for k, v in remainingMissionTextIDs do - -- if not isDynStringAvailable(v) then + -- if not isDynStringAvailable(v) then -- stringList = stringList .. " " .. tostring(v) -- end --end - --stringList = stringList .. "}" + --stringList = stringList .. "}" end end -function game:ensureLastMissionStepVisibility1() +function game:ensureLastMissionStepVisibility1() local missionWnd = getMissionWindow() - local scrollBar = missionWnd:find("sv_desc") - --scrollBar.trackPos = 20000 -- move upward + local scrollBar = missionWnd:find("sv_desc") + --scrollBar.trackPos = 20000 -- move upward --scrollBar:updateCoords() - --setOnDraw(missionWnd, "") - local descWnd = missionWnd:find("desc") + --setOnDraw(missionWnd, "") + local descWnd = missionWnd:find("desc") local maxNumSteps = getDefine("ipj_nb_goal") local topStep - for stepIndex = 0, maxNumSteps -1 do + for stepIndex = 0, maxNumSteps -1 do local currStep = descWnd["step" .. tostring(stepIndex)] if currStep.active then topStep = currStep end end -- debugInfo("Found step : " .. topStep.hardtext) - if topStep == nil then + if topStep == nil then return - end + end scrollBar:ensureVisible(topStep, "M", "M") - + --local wantedY = topStep.h_real / 2 - (descWnd.y_real - topStep.y_real) - --local wantedY = descWnd.y_real + descWnd.h_real - topStep.y_real - --local offsetY = wantedY - descWnd.max_h_real / 2 - --if offsetY < 0 then offsetY = 0 end + --local wantedY = descWnd.y_real + descWnd.h_real - topStep.y_real + --local offsetY = wantedY - descWnd.max_h_real / 2 + --if offsetY < 0 then offsetY = 0 end --descWnd.ofsy = offsetY --descWnd:invalidateCoords() --descWnd:updateCoords() - setOnDraw(missionWnd, "") - + setOnDraw(missionWnd, "") + end -------------------------------------------------------------------------------------------------------------- @@ -1618,16 +1618,16 @@ function game:addRpJob(jobtype, id, value, rpjobs) group.active = false else group.active = true - + local echelon_value = rpjobs[sitem][1] local quantity = rpjobs[sitem][2] - + local maxlevel = (echelon_value*6)-30 - + if (quantity > maxlevel) then quantity = maxlevel end - + local base = getUI(base_path..":t") base.hardtext = i18n.get(name):toUtf8() local ui = getUI(base_path..":icon") @@ -1657,7 +1657,7 @@ function game:getRPJobs() rpjobs_elementary = {} rpjobs_roleplay = {} rpjobs = {} - + for i = 0, 499, 1 do local sheet = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":SHEET") if (sheet ~= 0) then @@ -1665,7 +1665,7 @@ function game:getRPJobs() if (string.sub(name, 0, 6) == "rpjob_") then local quality = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":QUALITY") local quantity = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":QUANTITY") - + if (name == "rpjob_advanced.sitem") then table.insert(rpjobs_advanced, quality) else @@ -1688,7 +1688,7 @@ function game:getRPJobs() end end end - + for id=1,2,1 do game:addRpJob("advanced", id, rpjobs_advanced[id], rpjobs) end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua index 489484ee8..9f672e961 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua @@ -537,3 +537,17 @@ function game:openWebIGBrowserHeader() ui.w = ui_webig_browser_w; end end + +------------------------------------------------------------------------------------------------------------ +local SavedUrl = ""; +function game:chatUrl(url) + SavedUrl = url + runAH(nil, "active_menu", "menu=ui:interface:chat_uri_action_menu"); +end +function game:chatUrlCopy() + runAH(nil, "copy_to_clipboard", SavedUrl) +end +function game:chatUrlBrowse() + runAH(nil, "browse", "name=ui:interface:webig:content:html|url=" .. SavedUrl) +end + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml index 778aa43a4..fecfe5905 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.xml @@ -110,7 +110,7 @@ posparent="jauges" posref="TL TL" x="0" - y="-1" + y="0" sizeref="wh3" w="0" h="0" /> @@ -246,7 +246,7 @@ posref="MM MM" posparent="slot_force" x="0" - y="-2" + y="0" color="255 255 255 255" fontsize="10" shadow="true" @@ -364,7 +364,7 @@ id="b_life" posref="TL TL" x="0" - y="-2" + y="0" texture="slot_jauge.tga" inherit_gc_alpha="false" /> @@ -1078,7 +1077,7 @@ tooltip_parent="win" /> - @@ -1136,7 +1124,7 @@ target="tab1:active" /> + target="tab6:active" /> @@ -1148,9 +1136,6 @@ target="tab4:active" /> - - - + case_mode="%case_normal" /> + + usergroup_params_l="chat_db=DYNAMIC_CHAT6" /> - + @@ -3060,13 +3036,6 @@ --> - - - - - - @@ -3127,7 +3096,7 @@ + + + + + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/json.lua b/code/ryzom/client/data/gamedev/interfaces_v3/json.lua new file mode 100644 index 000000000..70d8c4413 --- /dev/null +++ b/code/ryzom/client/data/gamedev/interfaces_v3/json.lua @@ -0,0 +1,376 @@ +-- +-- json.lua +-- +-- Copyright (c) 2015 rxi +-- +-- This library is free software; you can redistribute it and/or modify it +-- under the terms of the MIT license. See LICENSE for details. +-- + +Json = { _version = "0.1.0" } + +------------------------------------------------------------------------------- +-- Encode +------------------------------------------------------------------------------- + +local encode + +local escape_char_map = { + [ "\\" ] = "\\\\", + [ "\"" ] = "\\\"", + [ "\b" ] = "\\b", + [ "\f" ] = "\\f", + [ "\n" ] = "\\n", + [ "\r" ] = "\\r", + [ "\t" ] = "\\t", +} + +local escape_char_map_inv = { [ "\\/" ] = "/" } +for k, v in pairs(escape_char_map) do + escape_char_map_inv[v] = k +end + + +local function escape_char(c) + return escape_char_map[c] or string.format("\\u%04x", c:byte()) +end + + +local function encode_nil(val) + return "null" +end + + +local function encode_table(val, stack) + local res = {} + stack = stack or {} + + -- Circular reference? + if stack[val] then error("circular reference") end + + stack[val] = true + + if val[1] ~= nil or next(val) == nil then + -- Treat as array -- check keys are valid and it is not sparse + local n = 0 + for k in pairs(val) do + if type(k) ~= "number" then + error("invalid table: mixed or invalid key types") + end + n = n + 1 + end + if n ~= #val then + error("invalid table: sparse array") + end + -- Encode + for i, v in ipairs(val) do + table.insert(res, encode(v, stack)) + end + stack[val] = nil + return "[" .. table.concat(res, ",") .. "]" + + else + -- Treat as an object + for k, v in pairs(val) do + if type(k) ~= "string" then + error("invalid table: mixed or invalid key types") + end + table.insert(res, encode(k, stack) .. ":" .. encode(v, stack)) + end + stack[val] = nil + return "{" .. table.concat(res, ",") .. "}" + end +end + + +local function encode_string(val) + return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"' +end + + +local function encode_number(val) + -- Check for NaN, -inf and inf + if val ~= val or val <= -math.huge or val >= math.huge then + error("unexpected number value '" .. tostring(val) .. "'") + end + return string.format("%.3f", val) +end + +local type_func_map = { + [ "nil" ] = encode_nil, + [ "table" ] = encode_table, + [ "string" ] = encode_string, + [ "number" ] = encode_number, + [ "boolean" ] = tostring, +} + + +encode = function(val, stack) + local t = type(val) + local f = type_func_map[t] + if f then + return f(val, stack) + end + error("unexpected type '" .. t .. "'") +end + + +function Json.encode(val) + return ( encode(val) ) +end + + +------------------------------------------------------------------------------- +-- Decode +------------------------------------------------------------------------------- + +local parse + +local function create_set(...) + local res = {} + for i = 1, select("#", ...) do + res[ select(i, ...) ] = true + end + return res +end + +local space_chars = create_set(" ", "\t", "\r", "\n") +local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",") +local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u") +local literals = create_set("true", "false", "null") + +local literal_map = { + [ "true" ] = true, + [ "false" ] = false, + [ "null" ] = nil, +} + + +local function next_char(str, idx, set, negate) + for i = idx, #str do + if set[str:sub(i, i)] ~= negate then + return i + end + end + return #str + 1 +end + + +local function decode_error(str, idx, msg) + local line_count = 1 + local col_count = 1 + for i = 1, idx - 1 do + col_count = col_count + 1 + if str:sub(i, i) == "\n" then + line_count = line_count + 1 + col_count = 1 + end + end + error( string.format("%s at line %d col %d", msg, line_count, col_count) ) +end + + +local function codepoint_to_utf8(n) + -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa + local f = math.floor + if n <= 0x7f then + return string.char(n) + elseif n <= 0x7ff then + return string.char(f(n / 64) + 192, n % 64 + 128) + elseif n <= 0xffff then + return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128) + elseif n <= 0x10ffff then + return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128, + f(n % 4096 / 64) + 128, n % 64 + 128) + end + error( string.format("invalid unicode codepoint '%x'", n) ) +end + + +local function parse_unicode_escape(s) + local n1 = tonumber( s:sub(3, 6), 16 ) + local n2 = tonumber( s:sub(9, 12), 16 ) + -- Surrogate pair? + if n2 then + return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000) + else + return codepoint_to_utf8(n1) + end +end + + +local function parse_string(str, i) + local has_unicode_escape = false + local has_surrogate_escape = false + local has_escape = false + local last + for j = i + 1, #str do + local x = str:byte(j) + + if x < 32 then + decode_error(str, j, "control character in string") + end + + if last == 92 then -- "\\" (escape char) + if x == 117 then -- "u" (unicode escape sequence) + local hex = str:sub(j + 1, j + 5) + if not hex:find("%x%x%x%x") then + decode_error(str, j, "invalid unicode escape in string") + end + if hex:find("^[dD][89aAbB]") then + has_surrogate_escape = true + else + has_unicode_escape = true + end + else + local c = string.char(x) + if not escape_chars[c] then + decode_error(str, j, "invalid escape char '" .. c .. "' in string") + end + has_escape = true + end + last = nil + + elseif x == 34 then -- '"' (end of string) + local s = str:sub(i + 1, j - 1) + if has_surrogate_escape then + s = s:gsub("\\u[dD][89aAbB]..\\u....", parse_unicode_escape) + end + if has_unicode_escape then + s = s:gsub("\\u....", parse_unicode_escape) + end + if has_escape then + s = s:gsub("\\.", escape_char_map_inv) + end + return s, j + 1 + + else + last = x + end + end + decode_error(str, i, "expected closing quote for string") +end + + +local function parse_number(str, i) + local x = next_char(str, i, delim_chars) + local s = str:sub(i, x - 1) + local n = tonumber(s) + if not n then + decode_error(str, i, "invalid number '" .. s .. "'") + end + return n, x +end + + +local function parse_literal(str, i) + local x = next_char(str, i, delim_chars) + local word = str:sub(i, x - 1) + if not literals[word] then + decode_error(str, i, "invalid literal '" .. word .. "'") + end + return literal_map[word], x +end + + +local function parse_array(str, i) + local res = {} + local n = 1 + i = i + 1 + while 1 do + local x + i = next_char(str, i, space_chars, true) + -- Empty / end of array? + if str:sub(i, i) == "]" then + i = i + 1 + break + end + -- Read token + x, i = parse(str, i) + res[n] = x + n = n + 1 + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "]" then break end + if chr ~= "," then decode_error(str, i, "expected ']' or ','") end + end + return res, i +end + + +local function parse_object(str, i) + local res = {} + i = i + 1 + while 1 do + local key, val + i = next_char(str, i, space_chars, true) + -- Empty / end of object? + if str:sub(i, i) == "}" then + i = i + 1 + break + end + -- Read key + if str:sub(i, i) ~= '"' then + decode_error(str, i, "expected string for key") + end + key, i = parse(str, i) + -- Read ':' delimiter + i = next_char(str, i, space_chars, true) + if str:sub(i, i) ~= ":" then + decode_error(str, i, "expected ':' after key") + end + i = next_char(str, i + 1, space_chars, true) + -- Read value + val, i = parse(str, i) + -- Set + res[key] = val + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "}" then break end + if chr ~= "," then decode_error(str, i, "expected '}' or ','") end + end + return res, i +end + + +local char_func_map = { + [ '"' ] = parse_string, + [ "0" ] = parse_number, + [ "1" ] = parse_number, + [ "2" ] = parse_number, + [ "3" ] = parse_number, + [ "4" ] = parse_number, + [ "5" ] = parse_number, + [ "6" ] = parse_number, + [ "7" ] = parse_number, + [ "8" ] = parse_number, + [ "9" ] = parse_number, + [ "-" ] = parse_number, + [ "t" ] = parse_literal, + [ "f" ] = parse_literal, + [ "n" ] = parse_literal, + [ "[" ] = parse_array, + [ "{" ] = parse_object, +} + + +parse = function(str, idx) + local chr = str:sub(idx, idx) + local f = char_func_map[chr] + if f then + return f(str, idx) + end + decode_error(str, idx, "unexpected character '" .. chr .. "'") +end + + +function Json.decode(str) + if type(str) ~= "string" then + error("expected argument of type string, got " .. type(str)) + end + return ( parse(str, next_char(str, 1, space_chars, true)) ) +end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml b/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml index 9b9eff8d8..f534eee34 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml @@ -1,913 +1,913 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -