From 80e357ffeebeeda01f281e607cb5394aab9f45e4 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 9 Dec 2016 13:47:15 +0100 Subject: [PATCH 01/39] Changed: Define _USING_V110_SDK71_ if targeting XP with VC++ 2012, 2013 and 2015 --HG-- branch : develop --- code/CMakeModules/FindWindowsSDK.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/CMakeModules/FindWindowsSDK.cmake b/code/CMakeModules/FindWindowsSDK.cmake index 43864c6a6..de00fcd80 100644 --- a/code/CMakeModules/FindWindowsSDK.cmake +++ b/code/CMakeModules/FindWindowsSDK.cmake @@ -441,8 +441,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() From 22a8a61a758a63f3524473c162edf465eb303df2 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 9 Dec 2016 13:47:43 +0100 Subject: [PATCH 02/39] Changed: VC++ 2005 (even if not supported...) --HG-- branch : develop --- code/CMakeModules/FindWindowsSDK.cmake | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/CMakeModules/FindWindowsSDK.cmake b/code/CMakeModules/FindWindowsSDK.cmake index de00fcd80..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() From e2b74b77c606ae05ab16b309ab399c6b281496a5 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 9 Dec 2016 13:51:09 +0100 Subject: [PATCH 03/39] Changed: Memory leaks detection --HG-- branch : develop --- code/nel/src/3d/animatable.cpp | 3 +++ code/nel/src/3d/animated_lightmap.cpp | 4 ++++ code/nel/src/3d/animated_material.cpp | 4 ++++ code/nel/src/3d/animated_morph.cpp | 4 ++++ code/nel/src/3d/animation_playlist.cpp | 4 ++++ code/nel/src/3d/animation_set.cpp | 4 ++++ code/nel/src/3d/async_file_manager_3d.cpp | 3 +++ code/nel/src/3d/vertex_buffer_heap.cpp | 4 ++++ code/nel/src/ligo/ligo_material.cpp | 4 ++++ code/nel/src/ligo/primitive.cpp | 4 ++++ code/nel/src/ligo/stdligo.h | 13 ++++++++++++- code/nel/src/ligo/transition.cpp | 4 ++++ code/nel/src/ligo/zone_bank.cpp | 3 +++ code/nel/src/ligo/zone_edge.cpp | 4 ++++ code/nel/src/logic/stdlogic.h | 17 +++++++++++++++-- code/nel/src/net/module_gateway_transport.cpp | 3 +++ code/nel/src/net/sock.cpp | 4 ++++ code/nel/tools/3d/ligo/plugin_max/script.cpp | 4 ++++ .../3d/plugin_max/nel_mesh_lib/export_anim.cpp | 4 ++++ .../plugin_max/nel_patch_edit/np_epm_tess.cpp | 4 ++++ .../3d/plugin_max/nel_patch_paint/DllEntry.cpp | 4 ++++ code/nel/tools/3d/tga_2_dds/tga2dds.cpp | 3 +++ code/ryzom/client/src/character_cl.cpp | 3 +++ code/ryzom/client/src/client.cpp | 4 ++++ code/ryzom/client/src/cursor_functions.cpp | 4 ++++ code/ryzom/client/src/decal.cpp | 4 ++++ code/ryzom/client/src/entities.cpp | 3 +++ .../src/interface_v3/action_handler_item.cpp | 4 ++++ .../client/src/interface_v3/macrocmd_key.cpp | 4 ++++ .../client/src/interface_v3/view_radar.cpp | 4 ++++ code/ryzom/client/src/login.cpp | 4 ++++ code/ryzom/client/src/main_loop.cpp | 3 +++ code/ryzom/client/src/r2/instance_map_deco.cpp | 4 ++++ code/ryzom/client/src/release.cpp | 4 ++++ .../common/src/game_share/mirrored_data_set.cpp | 3 +++ .../world_editor/dialog_properties.cpp | 4 ++++ .../world_editor/editor_primitive.cpp | 4 ++++ .../world_editor/external_editor.cpp | 4 ++++ .../world_editor/find_primitive_dlg.cpp | 4 ++++ .../world_editor/world_editor/generate_dlg.cpp | 4 ++++ .../world_editor/world_editor/imagelist_ex.cpp | 4 ++++ .../world_editor/world_editor/my_list_box.cpp | 4 ++++ .../world_editor/world_editor/name_dlg.cpp | 3 +++ .../world_editor/world_editor/pacs.cpp | 4 ++++ .../primitive_configuration_dlg.cpp | 4 ++++ 45 files changed, 189 insertions(+), 3 deletions(-) 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/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 8048bcd0a..5f4f351f6 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 { 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/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/ligo/ligo_material.cpp b/code/nel/src/ligo/ligo_material.cpp index 66212d5aa..2c46e6977 100644 --- a/code/nel/src/ligo/ligo_material.cpp +++ b/code/nel/src/ligo/ligo_material.cpp @@ -22,6 +22,10 @@ //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 c94c1609e..6e995eafc 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 { 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 2dfa770d4..2a2e7b813 100644 --- a/code/nel/src/ligo/transition.cpp +++ b/code/nel/src/ligo/transition.cpp @@ -22,6 +22,10 @@ #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 095410582..b1c6b73c6 100644 --- a/code/nel/src/ligo/zone_bank.cpp +++ b/code/nel/src/ligo/zone_bank.cpp @@ -28,6 +28,9 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif namespace NLLIGO { diff --git a/code/nel/src/ligo/zone_edge.cpp b/code/nel/src/ligo/zone_edge.cpp index 457812cd9..f34d43cd1 100644 --- a/code/nel/src/ligo/zone_edge.cpp +++ b/code/nel/src/ligo/zone_edge.cpp @@ -25,6 +25,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace NLLIGO { 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/net/module_gateway_transport.cpp b/code/nel/src/net/module_gateway_transport.cpp index dbdd091e6..57ba9eeb4 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 diff --git a/code/nel/src/net/sock.cpp b/code/nel/src/net/sock.cpp index 4a6b57e95..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 { diff --git a/code/nel/tools/3d/ligo/plugin_max/script.cpp b/code/nel/tools/3d/ligo/plugin_max/script.cpp index 0fce6bbab..7083a22a7 100644 --- a/code/nel/tools/3d/ligo/plugin_max/script.cpp +++ b/code/nel/tools/3d/ligo/plugin_max/script.cpp @@ -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) 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 0ebf0161a..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 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 9cfe2ff95..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 diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp index 549c033ae..8abb9b531 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp @@ -11,6 +11,10 @@ int controlsInit = FALSE; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + /** public functions **/ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { diff --git a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp index 5f0ee4181..6c53b7ec9 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 diff --git a/code/ryzom/client/src/character_cl.cpp b/code/ryzom/client/src/character_cl.cpp index 3698ea80d..dcb75e95d 100644 --- a/code/ryzom/client/src/character_cl.cpp +++ b/code/ryzom/client/src/character_cl.cpp @@ -137,6 +137,9 @@ using namespace std; using namespace MBEHAV; using namespace CLFECOMMON; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif //////////// // EXTERN // diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index 00ec3ced7..f1aa40224 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -65,6 +65,10 @@ using namespace NLNET; // Macros // +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // // RYZOM_TRY and RYZOM_CATCH aim is to catch differently in dev and final version // In final version, we catch everything and nlerror the problem to display a NeL message box diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index f318784a6..163d04ea3 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -46,6 +46,10 @@ using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + //////////// // GLOBAL // diff --git a/code/ryzom/client/src/decal.cpp b/code/ryzom/client/src/decal.cpp index ec8063d87..aa705abea 100644 --- a/code/ryzom/client/src/decal.cpp +++ b/code/ryzom/client/src/decal.cpp @@ -41,6 +41,10 @@ using namespace NL3D; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + CDecalRenderList DecalRenderList; extern uint SkipFrame; diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index 516232108..e49761e01 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -72,6 +72,9 @@ using namespace NLMISC; using namespace NL3D; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif //////////// // EXTERN // diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index 79e0999e7..30a13bbea 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -50,6 +50,10 @@ extern NLMISC::CLog g_log; using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + CInterfaceItemEdition *CInterfaceItemEdition::_Instance = NULL; // ******************************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index e639338df..fb35d3de5 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -39,6 +39,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // *************************************************************************** // *************************************************************************** // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/view_radar.cpp b/code/ryzom/client/src/interface_v3/view_radar.cpp index 718e2430a..62e921690 100644 --- a/code/ryzom/client/src/interface_v3/view_radar.cpp +++ b/code/ryzom/client/src/interface_v3/view_radar.cpp @@ -35,6 +35,10 @@ using namespace std; using namespace NLMISC; using namespace NL3D; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + extern NL3D::UCamera MainCam; NLMISC_REGISTER_OBJECT(CViewBase, CViewRadar, std::string, "radar"); diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index bef90af95..eee07722c 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -71,6 +71,10 @@ using namespace NLNET; using namespace NL3D; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // *************************************************************************** extern bool SetMousePosFirstTime; diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 194c6a819..cf3368726 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -159,6 +159,9 @@ using namespace NLPACS; using namespace NLNET; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif diff --git a/code/ryzom/client/src/r2/instance_map_deco.cpp b/code/ryzom/client/src/r2/instance_map_deco.cpp index add9e36c6..179af48b3 100644 --- a/code/ryzom/client/src/r2/instance_map_deco.cpp +++ b/code/ryzom/client/src/r2/instance_map_deco.cpp @@ -29,6 +29,10 @@ using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + namespace R2 { diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index eafc8ae86..742a82edb 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -101,6 +101,10 @@ using namespace NL3D; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + //////////// // EXTERN // //////////// diff --git a/code/ryzom/common/src/game_share/mirrored_data_set.cpp b/code/ryzom/common/src/game_share/mirrored_data_set.cpp index b30df0f1c..9b5613425 100644 --- a/code/ryzom/common/src/game_share/mirrored_data_set.cpp +++ b/code/ryzom/common/src/game_share/mirrored_data_set.cpp @@ -32,6 +32,9 @@ using namespace NLNET; using namespace NLGEORGES; using namespace std; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif NLMISC::CMemDisplayer *TmpDebugDisplayer = NULL; //NLMISC::CLog *TmpDebugLogger = NULL; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp index bbd84578b..fe6f56a57 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp @@ -33,6 +33,10 @@ using namespace std; using namespace NLLIGO; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // *************************************************************************** #define SCROLLING_STEPS 2 // parameter to finetune the scroller diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp index 232d405c7..ff40cf290 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp @@ -27,6 +27,10 @@ using namespace NLLIGO; using namespace NL3D; using namespace NLGEORGES; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // *************************************************************************** /* diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp index 42598a6a2..e17165349 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp @@ -24,6 +24,10 @@ using namespace std; using namespace NLLIGO; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // *************************************************************************** bool EditExternalText (const std::string &editor, std::string &text, const std::string &ext) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/find_primitive_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/find_primitive_dlg.cpp index 2cea6d8d8..f120874fa 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/find_primitive_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/find_primitive_dlg.cpp @@ -26,6 +26,10 @@ using namespace NLLIGO; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + CString CFindPrimitiveDlg::Property = _T(""); CString CFindPrimitiveDlg::Value = _T(""); CString CFindPrimitiveDlg::ReplaceText = _T(""); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp index 71e2465f9..3e6cd4d57 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp @@ -22,6 +22,10 @@ #include "resource.h" #include "generate_dlg.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + ///////////////////////////////////////////////////////////////////////////// // CGenerateDlg dialog diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp index 90a917225..436b8d27d 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp @@ -25,6 +25,10 @@ using namespace std; using namespace NLMISC; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + #pragma warning (disable : 4786) BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCSTR lpszType, LPCSTR lpszName, WORD wIDLanguage, diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp index e75c5d712..c3df01c12 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp @@ -21,6 +21,10 @@ #include "world_editor.h" #include "my_list_box.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + #define COMBO_REAL_HEIGHT 300 // *************************************************************************** diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp index 1ef76d077..69864affd 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp @@ -25,6 +25,9 @@ #include "nel/misc/path.h" #include "nel/misc/config_file.h" +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif ///////////////////////////////////////////////////////////////////////////// // CNameDlg dialog diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/pacs.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/pacs.cpp index 43cd7a8c7..351773cb6 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/pacs.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/pacs.cpp @@ -27,6 +27,10 @@ using namespace NLMISC; using namespace NLLIGO; using namespace NLPACS; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // *************************************************************************** CPacsManager PacsManager; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/primitive_configuration_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/primitive_configuration_dlg.cpp index 5ef186f7e..b913a11f8 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/primitive_configuration_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/primitive_configuration_dlg.cpp @@ -25,6 +25,10 @@ using namespace NLLIGO; +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif + // *************************************************************************** // CPrimitiveConfigurationDlg dialog // *************************************************************************** From 0b171001d1c3f9515e5e2c0f5cc368dcb3116b46 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 9 Dec 2016 13:51:52 +0100 Subject: [PATCH 04/39] Removed: Empty cpp files --HG-- branch : develop --- code/nel/src/3d/anim_ctrl.cpp | 27 ---------------- code/nel/src/3d/animated_value.cpp | 36 ---------------------- code/nel/src/3d/animation_time.cpp | 26 ---------------- code/nel/src/3d/async_texture_block.cpp | 27 ---------------- code/nel/src/3d/cube_grid.cpp | 25 --------------- code/nel/src/3d/matrix_3x4.cpp | 26 ---------------- code/nel/src/3d/mesh_vertex_program.cpp | 26 ---------------- code/nel/src/3d/mrm_parameters.cpp | 26 ---------------- code/nel/src/3d/ps_particle.cpp | 25 --------------- code/nel/src/3d/ps_particle2.cpp | 24 --------------- code/nel/src/3d/ptr_set.cpp | 27 ---------------- code/nel/src/3d/radix_sort.cpp | 41 ------------------------- code/nel/src/3d/scissor.cpp | 27 ---------------- code/nel/src/3d/static_quad_grid.cpp | 27 ---------------- code/nel/src/3d/tess_list.cpp | 27 ---------------- code/nel/src/3d/texture_bloom.cpp | 25 --------------- code/nel/src/3d/texture_user.cpp | 31 ------------------- code/nel/src/3d/tile_color.cpp | 26 ---------------- code/nel/src/3d/trav_scene.cpp | 33 -------------------- code/nel/src/3d/vegetable_def.cpp | 27 ---------------- code/nel/src/3d/vegetable_uv8.cpp | 26 ---------------- code/nel/src/georges/load_form.cpp | 17 ---------- 22 files changed, 602 deletions(-) delete mode 100644 code/nel/src/3d/anim_ctrl.cpp delete mode 100644 code/nel/src/3d/animated_value.cpp delete mode 100644 code/nel/src/3d/animation_time.cpp delete mode 100644 code/nel/src/3d/async_texture_block.cpp delete mode 100644 code/nel/src/3d/cube_grid.cpp delete mode 100644 code/nel/src/3d/matrix_3x4.cpp delete mode 100644 code/nel/src/3d/mesh_vertex_program.cpp delete mode 100644 code/nel/src/3d/mrm_parameters.cpp delete mode 100644 code/nel/src/3d/ps_particle.cpp delete mode 100644 code/nel/src/3d/ps_particle2.cpp delete mode 100644 code/nel/src/3d/ptr_set.cpp delete mode 100644 code/nel/src/3d/radix_sort.cpp delete mode 100644 code/nel/src/3d/scissor.cpp delete mode 100644 code/nel/src/3d/static_quad_grid.cpp delete mode 100644 code/nel/src/3d/tess_list.cpp delete mode 100644 code/nel/src/3d/texture_bloom.cpp delete mode 100644 code/nel/src/3d/texture_user.cpp delete mode 100644 code/nel/src/3d/tile_color.cpp delete mode 100644 code/nel/src/3d/trav_scene.cpp delete mode 100644 code/nel/src/3d/vegetable_def.cpp delete mode 100644 code/nel/src/3d/vegetable_uv8.cpp delete mode 100644 code/nel/src/georges/load_form.cpp 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/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_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_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/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/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_vertex_program.cpp b/code/nel/src/3d/mesh_vertex_program.cpp deleted file mode 100644 index 6c46cec5f..000000000 --- a/code/nel/src/3d/mesh_vertex_program.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/mesh_vertex_program.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/mrm_parameters.cpp b/code/nel/src/3d/mrm_parameters.cpp deleted file mode 100644 index 8210475a5..000000000 --- a/code/nel/src/3d/mrm_parameters.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/mrm_parameters.h" - - -namespace NL3D -{ - - -} // NL3D diff --git a/code/nel/src/3d/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/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/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/scissor.cpp b/code/nel/src/3d/scissor.cpp deleted file mode 100644 index 99b39389f..000000000 --- a/code/nel/src/3d/scissor.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/scissor.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/static_quad_grid.cpp b/code/nel/src/3d/static_quad_grid.cpp deleted file mode 100644 index e45fca011..000000000 --- a/code/nel/src/3d/static_quad_grid.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/static_quad_grid.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/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/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_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_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/trav_scene.cpp b/code/nel/src/3d/trav_scene.cpp deleted file mode 100644 index b909493cb..000000000 --- a/code/nel/src/3d/trav_scene.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/trav_scene.h" -#include "nel/3d/scene.h" - - - -namespace NL3D -{ - - -} // NL3D - - - - -/* End of trav_scene.cpp */ diff --git a/code/nel/src/3d/vegetable_def.cpp b/code/nel/src/3d/vegetable_def.cpp deleted file mode 100644 index 74182b413..000000000 --- a/code/nel/src/3d/vegetable_def.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "std3d.h" - -#include "nel/3d/vegetable_def.h" - - -namespace NL3D -{ - - - -} // NL3D diff --git a/code/nel/src/3d/vegetable_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/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" From 9e0b38e6e0f42aa69db3710027ad4ae6551c9e1c Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 9 Dec 2016 13:53:43 +0100 Subject: [PATCH 05/39] Changed: New tga2dds option -g to force grayscale image instead of alpha --HG-- branch : develop --- code/nel/tools/3d/tga_2_dds/tga2dds.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp index 6c53b7ec9..d7158c045 100644 --- a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp +++ b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp @@ -300,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); @@ -309,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")) @@ -317,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(); @@ -365,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) { From b66b85cefde10ee9f6bc9a206e88787933cf3674 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 9 Dec 2016 16:04:26 +0100 Subject: [PATCH 06/39] Changed: Unicode MFC support --HG-- branch : develop --- .../world_editor/dialog_properties.cpp | 65 ++++++++++--------- .../world_editor/find_primitive_dlg.cpp | 20 +++--- .../world_editor/generate_dlg.cpp | 6 +- .../world_editor/imagelist_ex.cpp | 4 +- .../world_editor/world_editor/my_list_box.cpp | 2 +- .../world_editor/world_editor/name_dlg.cpp | 18 ++--- .../world_editor/world_editor/pacs.cpp | 2 +- .../primitive_configuration_dlg.cpp | 4 +- 8 files changed, 63 insertions(+), 58 deletions(-) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp index fe6f56a57..3462928db 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp @@ -53,8 +53,8 @@ using namespace NLMISC; #define STRING_SELECT_COMBOBOX_ID 9 -#define DIFFERENT_VALUE_STRING _T("") -#define DIFFERENT_VALUE_MULTI_STRING _T("") +#define DIFFERENT_VALUE_STRING "" +#define DIFFERENT_VALUE_MULTI_STRING "" //CDialogProperties PropertyDialog; std::list PropertiesDialogs; @@ -352,7 +352,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, string Name = widget.Parameter.Name; // Create a check box - nlverify (widget.CheckBox.Create (Name.c_str (), BS_3STATE|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), widgetPos, &m_PropertyCont, id)); + nlverify (widget.CheckBox.Create (utf8ToTStr(Name), BS_3STATE|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), widgetPos, &m_PropertyCont, id)); widget.CheckBox.SetFont (GetFont ()); } else if (widget.Parameter.Type == CPrimitiveClass::CParameter::ConstString) @@ -522,7 +522,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, for (vector::iterator it=PathList.begin(), itEnd=PathList.end(); it!=itEnd; ++it) { - widget.ListEditBox.StringSelectComboBox.InsertString( -1, it->c_str ()); + widget.ListEditBox.StringSelectComboBox.InsertString( -1, utf8ToTStr(*it)); } } @@ -549,7 +549,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, for (vector::iterator it=PathList.begin(), itEnd=PathList.end(); it!=itEnd; ++it) { - widget.ListEditBox.StringSelectComboBox.InsertString( -1, it->c_str ()); + widget.ListEditBox.StringSelectComboBox.InsertString( -1, utf8ToTStr(*it)); } } } @@ -887,16 +887,16 @@ bool CDialogProperties::CWidget::fromParameter (const IProperty *property, const case CPrimitiveClass::CParameter::ConstString: // Set as uninitialized if (!Parameter.SortEntries) - ComboBox.InsertString (-1, DIFFERENT_VALUE_STRING); + ComboBox.InsertString (-1, _T(DIFFERENT_VALUE_STRING)); else - ComboBox.AddString( DIFFERENT_VALUE_STRING); - ComboBox.SelectString(-1 ,DIFFERENT_VALUE_STRING); + ComboBox.AddString( _T(DIFFERENT_VALUE_STRING)); + ComboBox.SelectString(-1 , _T(DIFFERENT_VALUE_STRING)); OriginalString = DIFFERENT_VALUE_STRING; updateCombo (); break; case CPrimitiveClass::CParameter::String: // Set as uninitialized - EditBox.SetWindowText (DIFFERENT_VALUE_STRING); + EditBox.SetWindowText (_T(DIFFERENT_VALUE_STRING)); break; } MultipleValues = true; @@ -1631,8 +1631,8 @@ BOOL CDialogProperties::OnCommand(WPARAM wParam, LPARAM lParam) /* todo hulud remove CString oldValue; widget->EditBox.GetWindowText (oldValue);*/ - CFileDialogEx dialog (BASE_REGISTRY_KEY, "default", TRUE, widget->Parameter.FileExtension.c_str (), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, - (widget->Parameter.FileExtension+" (*."+widget->Parameter.FileExtension+")|*."+widget->Parameter.FileExtension+"|All Files (*.*)|*.*||").c_str (), getMainFrame ()); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("default"), TRUE, widget->Parameter.FileExtension.c_str (), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, + utf8ToTStr(widget->Parameter.FileExtension+" (*."+widget->Parameter.FileExtension+")|*."+widget->Parameter.FileExtension+"|All Files (*.*)|*.*||"), getMainFrame ()); if (widget->Parameter.Folder != "") { dialog.m_ofn.lpstrInitialDir = widget->Parameter.Folder.c_str(); @@ -1738,7 +1738,7 @@ BOOL CDialogProperties::OnCommand(WPARAM wParam, LPARAM lParam) nlassert (widget->Parameter.Type == CPrimitiveClass::CParameter::ConstString); // Remove - int index = widget->ComboBox.FindString (-1, DIFFERENT_VALUE_STRING); + int index = widget->ComboBox.FindString (-1, _T(DIFFERENT_VALUE_STRING)); if (index != CB_ERR) widget->ComboBox.DeleteString(index); @@ -2309,7 +2309,7 @@ void CDialogProperties::rebuildDialog () m_ScrollBar.MoveWindow(&scrollRect, TRUE); // set the name of the dlg according to displayed class - SetWindowText( ( std::string( "Properties for : " ) + windowName ).c_str() ); + SetWindowText( CString(_T("Properties for : ")) + utf8ToTStr(windowName) ); // // JC: added scrolling properties // ::CRect clientRect; @@ -2751,19 +2751,19 @@ void CDialogProperties::ApplyAutoname() } else if (ite->Parameter.Type == CPrimitiveClass::CParameter::ConstString) { - ite->ComboBox.SelectString(-1 , ""); + ite->ComboBox.SelectString(-1 , _T("")); ite->updateCombo (); } else if (ite->Parameter.Type == CPrimitiveClass::CParameter::String) { ite->Initializing = true; - ite->EditBox.SetWindowText(""); + ite->EditBox.SetWindowText(_T("")); ite->Initializing = false; } else if (ite->Parameter.Type == CPrimitiveClass::CParameter::StringArray) { ite->Initializing = true; - ite->MultiLineEditBox.SetWindowText(""); + ite->MultiLineEditBox.SetWindowText(_T("")); ite->Initializing = false; // ite->MultiLineEditBox.LoadText(CString()); ite->updateMultiline (); @@ -2771,7 +2771,7 @@ void CDialogProperties::ApplyAutoname() else if (ite->Parameter.Type == CPrimitiveClass::CParameter::ConstStringArray) { ite->Initializing = true; - ite->ListEditBox.SetWindowText(""); + ite->ListEditBox.SetWindowText(_T("")); ite->Initializing = false; ite->updateList (); } @@ -2986,16 +2986,13 @@ void CDialogProperties::SelectFolder(CWidget *widget) LPITEMIDLIST pidlRoot = NULL; LPSHELLFOLDER desktop; - OLECHAR olePath[_MAX_PATH + 1]; ULONG ulDummy; SHGetDesktopFolder (&desktop); if (widget->Parameter.Folder != "") { - LPTSTR szPath = (char *)widget->Parameter.Folder.c_str(); - MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, szPath, -1, olePath, _MAX_PATH); - desktop->ParseDisplayName (NULL, NULL, olePath, &ulDummy, &pidlRoot, &ulDummy); + desktop->ParseDisplayName (NULL, NULL, utf8ToTStr(widget->Parameter.Folder), &ulDummy, &pidlRoot, &ulDummy); } bi.pidlRoot = pidlRoot; @@ -3007,10 +3004,10 @@ void CDialogProperties::SelectFolder(CWidget *widget) if (pIIL != NULL) { TCHAR szInitialDir[_MAX_PATH]; - BOOL bRet = ::SHGetPathFromIDList(pIIL, (char*)&szInitialDir); + BOOL bRet = ::SHGetPathFromIDList(pIIL, szInitialDir); if (bRet) { - int s = strlen(szInitialDir); + int s = _tcslen(szInitialDir); while (s) { --s; @@ -3023,7 +3020,7 @@ void CDialogProperties::SelectFolder(CWidget *widget) std::vector tempArray; widget->getValue (tempArray); - tempArray.push_back (szInitialDir+s); + tempArray.push_back (tStrToUtf8(szInitialDir+s)); setEditTextMultiLine (widget->MultiLineEditBox, tempArray); widget->updateMultiline (); @@ -3459,9 +3456,9 @@ void CMyComboBox::reloadData() if(n != CB_ERR) GetLBText(n, s); ResetContent(); SetRedraw(FALSE); - InsertString(-1, ""); + InsertString(-1, _T("")); for (vector::iterator it=_data.begin(), itEnd=_data.end(); it!=itEnd; ++it) - InsertString(-1, it->c_str()); + InsertString(-1, utf8ToTStr(*it)); loaded = true; SetRedraw(TRUE); if(n != CB_ERR) SelectString(-1, s); @@ -3504,18 +3501,26 @@ BOOL CMyComboBox::PreTranslateMessage( MSG* pMsg ) { CString rString; GetLBText (curSel, rString); - dataToClipboard (this, CF_TEXT, (void*)(const char*)rString, rString.GetLength()+1); +#ifdef _UNICODE + dataToClipboard(this, CF_UNICODETEXT, (void*)(LPCTSTR)rString, (rString.GetLength() + 1)*2); +#else + dataToClipboard (this, CF_TEXT, (void*)(LPCTSTR)rString, rString.GetLength()+1); +#endif } } // Paste ? else if ((pMsg->message == WM_KEYDOWN) && ('V' == (int) pMsg->wParam) && (GetAsyncKeyState (VK_CONTROL) & 0x8000)) { - char text[512]; + TCHAR text[512]; +#ifdef _UNICODE + if (dataFromClipboard(this, CF_UNICODETEXT, text, 511*2)) +#else if (dataFromClipboard (this, CF_TEXT, text, 511)) +#endif { // 0 final text[511] = 0; - _LastString = text; + _LastString = tStrToUtf8(text); search = true; } } @@ -3535,7 +3540,7 @@ BOOL CMyComboBox::PreTranslateMessage( MSG* pMsg ) { CString rString; GetLBText (i, rString); - string tmp = strlwr ((const char*)rString); + string tmp = toLower(tStrToUtf8(rString)); uint size = std::min (_LastString.size(), tmp.size()); if (size > matchSize) { diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/find_primitive_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/find_primitive_dlg.cpp index f120874fa..9cf7e2dee 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/find_primitive_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/find_primitive_dlg.cpp @@ -112,7 +112,7 @@ void CFindPrimitiveDlg::OnFindNext() // || ( _Locator.Primitive->getPropertyByName ("selected", property) || ( getPrimitiveEditor(_Locator.Primitive)->getSelected())) // && property) ) - && _Locator.Primitive->getPropertyByName ((const char*)Property, property) + && _Locator.Primitive->getPropertyByName (tStrToUtf8(Property), property) && property) { // Kind of primitive ? @@ -120,7 +120,7 @@ void CFindPrimitiveDlg::OnFindNext() if (propString) { // Good value ? - if (propString->String.find(Value)!=std::string::npos) + if (propString->String.find(tStrToUtf8(Value))!=std::string::npos) { found = true; } @@ -135,7 +135,7 @@ void CFindPrimitiveDlg::OnFindNext() uint i; for (i=0; iStringArray.size (); i++) { - if (propStringArray->StringArray[i].find(Value)!=std::string::npos) + if (propStringArray->StringArray[i].find(tStrToUtf8(Value))!=std::string::npos) { found = true; } @@ -230,7 +230,7 @@ void CFindPrimitiveDlg::replace(bool all) // || ( _Locator.Primitive->getPropertyByName ("selected", property) || ( getPrimitiveEditor(_Locator.Primitive)->getSelected())) // && property) ) - && _Locator.Primitive->getPropertyByName ((const char*)Property, property) + && _Locator.Primitive->getPropertyByName (tStrToUtf8(Property), property) && property ) { // Kind of primitive ? @@ -238,14 +238,14 @@ void CFindPrimitiveDlg::replace(bool all) if (propString) { // Good value ? - if (propString->String.find(Value)!=std::string::npos) + if (propString->String.find(tStrToUtf8(Value))!=std::string::npos) { if (!firstTime && !all) break; CString tmp(propString->String.c_str()); tmp.Replace(Value, ReplaceText); - doc->addModification (new CActionSetPrimitivePropertyString (_Locator,(const char*)Property,(const char*)tmp,false)); + doc->addModification (new CActionSetPrimitivePropertyString (_Locator, tStrToUtf8(Property), tStrToUtf8(tmp), false)); doc->addModification (new CActionSelect (_Locator)); firstTime=false; @@ -265,7 +265,7 @@ void CFindPrimitiveDlg::replace(bool all) for (i=0; iStringArray.size (); i++) { // todo. - if (propStringArray->StringArray[i].find(Value)!=std::string::npos) + if (propStringArray->StringArray[i].find(tStrToUtf8(Value))!=std::string::npos) { if ( !firstTime && !all) @@ -281,7 +281,7 @@ void CFindPrimitiveDlg::replace(bool all) newStrings=propStringArray->StringArray; firstChange=false; } - newStrings[i]=std::string((const char*)tmp); + newStrings[i] = tStrToUtf8(tmp); } firstTime=false; } @@ -290,7 +290,7 @@ void CFindPrimitiveDlg::replace(bool all) if (!firstChange) // have to make a change { - doc->addModification (new CActionSetPrimitivePropertyStringArray (_Locator,(const char*)Property,newStrings,false)); + doc->addModification (new CActionSetPrimitivePropertyStringArray (_Locator, tStrToUtf8(Property), newStrings, false)); doc->addModification (new CActionSelect (_Locator)); } @@ -321,7 +321,7 @@ void CFindPrimitiveDlg::replace(bool all) if (_End) { - MessageBox ("End of the document", "Find a primitive...", MB_OK|MB_ICONEXCLAMATION); + MessageBox (_T("End of the document"), _T("Find a primitive..."), MB_OK|MB_ICONEXCLAMATION); _Locator.getRoot (0); } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp index 3e6cd4d57..e4c5d0d8e 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp @@ -75,7 +75,7 @@ BOOL CGenerateDlg::OnInitDialog() // TODO: Add extra initialization here for (uint32 i = 0; i < AllMaterials.size(); ++i) - ComboMaterial.InsertString(-1, AllMaterials[i].c_str()); + ComboMaterial.InsertString(-1, utf8ToTStr(AllMaterials[i])); ComboMaterial.SetCurSel (0); @@ -90,12 +90,12 @@ void CGenerateDlg::OnOK() if (MinX > MaxX) { - MessageBox ("MinX > MaxX", "Error", MB_OK|MB_ICONSTOP); + MessageBox (_T("MinX > MaxX"), _T("Error"), MB_OK|MB_ICONSTOP); return; } if (MinY > MaxY) { - MessageBox ("MinY > MaxY", "Error", MB_OK|MB_ICONSTOP); + MessageBox (_T("MinY > MaxY"), _T("Error"), MB_OK|MB_ICONSTOP); return; } CDialog::OnOK(); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp index 436b8d27d..a24ef1c07 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp @@ -31,7 +31,7 @@ using namespace NLMISC; #pragma warning (disable : 4786) -BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCSTR lpszType, LPCSTR lpszName, WORD wIDLanguage, +BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam) { set *iconNames = (set*)lParam; @@ -100,7 +100,7 @@ void CImageListEx::addResourceIcon (const char *filename) int height = imageInfo.rcImage.bottom - imageInfo.rcImage.top; // Load the icon - HICON handle = (HICON) LoadImage (NULL, filename, IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE); + HICON handle = (HICON) LoadImage (NULL, utf8ToTStr(filename), IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE); if (handle) { // Copy the icon diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp index c3df01c12..3d39ae236 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp @@ -124,7 +124,7 @@ void CMyListBox::OnLButtonDblClk(UINT nFlags, CPoint point) _SelectAfter = GetCurSel(); if ((_EditingItem == LB_ERR) || bOutside) { - _EditingItem = InsertString (-1, ""); + _EditingItem = InsertString (-1, _T("")); _DeleteItIfCancel = true; } else diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp index 69864affd..bfa978ee4 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp @@ -88,7 +88,7 @@ BOOL CNameDlg::OnInitDialog() // print the data directory CWnd* pWnd = GetDlgItem(IDC_NAME_DIR); - pWnd->SetWindowText(("Data directory: " + m_dataDir).c_str()); + pWnd->SetWindowText(CString(_T("Data directory: ")) + utf8ToTStr(m_dataDir)); // tab stops to simulate multi-columns edit boxes int tab_stop1[1] = {160}; @@ -156,18 +156,18 @@ void CNameDlg::updateSearchList() { // no filter m_listToName.insert(std::make_pair(j, i)); - m_searchList.InsertString(j++, s.c_str()); + m_searchList.InsertString(j++, utf8ToTStr(s)); } else { - std::string filter(m_nameFilter.LockBuffer()); + std::string filter(tStrToUtf8(m_nameFilter.LockBuffer())); m_nameFilter.UnlockBuffer(); // filter if (NLMISC::toLower(ig).find(NLMISC::toLower(filter)) != std::string::npos) { m_listToName.insert(std::make_pair(j, i)); - m_searchList.InsertString(j++, s.c_str()); + m_searchList.InsertString(j++, utf8ToTStr(s)); } } } @@ -214,7 +214,7 @@ void CNameDlg::updateSelectList() m_listToId.insert(std::make_pair(i, row)); } - m_idList.InsertString(i++, s.c_str()); + m_idList.InsertString(i++, utf8ToTStr(s)); } } @@ -359,19 +359,19 @@ void CNameDlg::checkNewGn() { // print a message if a new gn will be added to the list CWnd* pWnd = GetDlgItem(IDC_NAME_NEWGN); - std::string s = m_assignGn; + std::string s = tStrToUtf8(m_assignGn); uint rowIndex; if (s == "") { - pWnd->SetWindowText(" "); + pWnd->SetWindowText(_T(" ")); } else if (!m_fcts.findRow(0, s, rowIndex)) { - pWnd->SetWindowText("new gn !"); + pWnd->SetWindowText(_T("new gn !")); } else { - pWnd->SetWindowText(" "); + pWnd->SetWindowText(_T(" ")); // auto-fill ig field m_assignIg = m_fcts.getData(rowIndex, 1).toString().c_str(); } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/pacs.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/pacs.cpp index 351773cb6..08c5b7ac3 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/pacs.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/pacs.cpp @@ -51,7 +51,7 @@ void CPacsManager::loadPacs() string currentPath = CPath::getCurrentPath(); // "Path" can be relative to the doc path so we have to be first in the doc path - string s2 = NLMISC::CFile::getPath ((LPCTSTR)getMainFrame()->getDocument()->GetPathName()); + string s2 = NLMISC::CFile::getPath (tStrToUtf8(getMainFrame()->getDocument()->GetPathName())); CPath::setCurrentPath(s2.c_str()); string ss = CPath::getFullPath(path); CPath::setCurrentPath (ss.c_str()); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/primitive_configuration_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/primitive_configuration_dlg.cpp index b913a11f8..91346f6e7 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/primitive_configuration_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/primitive_configuration_dlg.cpp @@ -106,7 +106,7 @@ BOOL CPrimitiveConfigurationDlg::OnInitDialog() ListView_SetExtendedListViewStyle (ListCtrl, LVS_EX_CHECKBOXES); // Add the list column - ListCtrl.InsertColumn (0, "Configuration name"); + ListCtrl.InsertColumn (0, _T("Configuration name")); ListCtrl.SetColumnWidth (0, 350); // Add configurations @@ -114,7 +114,7 @@ BOOL CPrimitiveConfigurationDlg::OnInitDialog() uint i; for (i=0; i Date: Fri, 9 Dec 2016 16:04:50 +0100 Subject: [PATCH 07/39] Changed: Unimplemented functions --HG-- branch : develop --- code/ryzom/client/src/interface_v3/action_handler_item.cpp | 2 -- .../world_editor/world_editor/dialog_properties.cpp | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index 30a13bbea..f3192a9ee 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -429,8 +429,6 @@ static CDBCtrlSheet *CurrentStackDst= NULL; static TStackMode CurrentStackMode; -static void putStackableInventoryItemToExchange(CDBCtrlSheet *src, CDBCtrlSheet *dest, uint quantity); -static void putStackableExchangedItemToInventory(CDBCtrlSheet *src, CDBCtrlSheet *dest, uint quantity); static void validateStackItem(CDBCtrlSheet *src, CDBCtrlSheet *dest, sint32 quantity, TStackMode stackMode); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp index 3462928db..91b3d292d 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp @@ -1671,8 +1671,9 @@ BOOL CDialogProperties::OnCommand(WPARAM wParam, LPARAM lParam) text += "\n"; } CConfigFile::CVar *var = getMainFrame ()->getConfigFile().getVarPtr ("TextEditor"); - char windows[512]; - GetWindowsDirectory (windows, sizeof (windows)); + + std::string windows = CPath::getWindowsDirectory(); + if (EditExternalText (var?var->asString():windows+string ("/notepad.exe"), text, widget->Parameter.FileExtension.c_str ())) { widget->Default = false; From 06cc0ddec8b331eb9b23eefe15196615f2aefe02 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 9 Dec 2016 16:05:13 +0100 Subject: [PATCH 08/39] Changed: Delete filenames before allocating new ones --HG-- branch : develop --- code/nel/src/misc/big_file.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/nel/src/misc/big_file.cpp b/code/nel/src/misc/big_file.cpp index fc247b07b..100bc4d07 100644 --- a/code/nel/src/misc/big_file.cpp +++ b/code/nel/src/misc/big_file.cpp @@ -339,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); From eabfcbf7081cbbcaff9ab46c14efa9af23819597 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 9 Dec 2016 16:14:16 +0100 Subject: [PATCH 09/39] Fixed: Release CCurrentCoTask singleton --HG-- branch : develop --- code/nel/include/nel/misc/co_task.h | 4 +++- code/nel/src/misc/co_task.cpp | 15 +++++++++++++++ code/ryzom/client/src/release.cpp | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) 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/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/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index 742a82edb..aac29d590 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -669,6 +669,7 @@ void release() CWidgetManager::release(); CViewRenderer::release(); CIXml::releaseLibXml(); + CCoTask::releaseInstance(); #if FINAL_VERSION // openURL ("http://www.ryzomcore.org/exit/"); From 0f6ae5e23986d58370fb6c6925e37ec0e87ecdf1 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 9 Dec 2016 16:15:18 +0100 Subject: [PATCH 10/39] Changed: Release all memory when leaving in login screen --HG-- branch : develop --- code/ryzom/client/src/client.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index f1aa40224..10a3e1b40 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -309,6 +309,16 @@ int main(int argc, char **argv) //ICommand::execute("iFileAccessLogStop",*NLMISC::InfoLog); //ICommand::execute("iFileAccessLogClear",*NLMISC::InfoLog); #endif + + release(); + + // delete all logs and displayers when we're not using logs macros anymore + destroyDebug(); + CLog::releaseProcessName(); + + // delete the Nel context + delete appContext; + return EXIT_SUCCESS; } } From ab44d7e8099825697fbb2e3880b30e983432cf60 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 12:05:29 +0100 Subject: [PATCH 11/39] Changed: Use a CUniquePtr macro since std::unique_ptr doesn't exist on all (yet) supported platforms --HG-- branch : develop --- code/nel/include/nel/3d/animation_set_user.h | 4 +- code/nel/include/nel/3d/material.h | 2 +- .../nel/3d/ps_attrib_maker_bin_op_inline.h | 2 +- .../include/nel/3d/ps_attrib_maker_helper.h | 2 +- code/nel/include/nel/3d/ps_mesh.h | 2 +- code/nel/include/nel/misc/types_nl.h | 24 ++++++++---- code/nel/src/3d/animation.cpp | 2 +- code/nel/src/3d/animation_set.cpp | 2 +- code/nel/src/3d/cube_map_builder.cpp | 4 +- code/nel/src/3d/material.cpp | 8 ++-- code/nel/src/3d/ps_mesh.cpp | 4 +- code/nel/src/3d/ps_ribbon.cpp | 2 +- code/nel/src/3d/ps_tail_dot.cpp | 2 +- code/nel/src/3d/texture_cube.cpp | 2 +- code/nel/src/misc/inter_window_msg_queue.cpp | 6 +-- code/nel/src/net/module_gateway_transport.cpp | 8 ++-- code/nel/src/net/module_manager.cpp | 6 +-- code/nel/src/pacs/primitive_block_pacs.cpp | 2 +- code/nel/tools/3d/object_viewer/dup_ps.cpp | 6 +-- .../tools/3d/object_viewer/object_viewer.cpp | 2 +- .../tools/3d/object_viewer/particle_dlg.cpp | 2 +- .../3d/object_viewer/particle_tree_ctrl.cpp | 2 +- .../3d/object_viewer/particle_tree_ctrl.h | 4 +- .../3d/object_viewer/particle_workspace.cpp | 4 +- .../3d/object_viewer/snapshot_tool_dlg.cpp | 4 +- .../plugin_max/nel_mesh_lib/export_mesh.cpp | 2 +- .../nel_mesh_lib/export_remanence.cpp | 2 +- .../3d/zone_check_bind/zone_check_bind.cpp | 4 +- .../tools/3d/zone_lighter/zone_lighter.cpp | 2 +- .../nel/tools/nel_unit_test/nel_unit_test.cpp | 12 +++--- code/nel/tools/nel_unit_test/ut_ligo.h | 2 +- code/nel/tools/nel_unit_test/ut_misc.h | 28 +++++++------- code/nel/tools/nel_unit_test/ut_net.h | 6 +-- code/ryzom/client/src/door_manager.cpp | 2 +- code/ryzom/client/src/pacs_client.cpp | 2 +- code/ryzom/client/src/r2/auto_group.cpp | 2 +- .../src/r2/dmc/client_edition_module.cpp | 14 +++---- .../client/src/r2/dmc/client_edition_module.h | 2 +- .../client/src/r2/tool_create_entity.cpp | 2 +- code/ryzom/client/src/r2/tool_select_move.cpp | 2 +- code/ryzom/client/src/seven_zip/seven_zip.cpp | 12 +++--- code/ryzom/client/src/sky.cpp | 2 +- .../src/game_share/ring_session_manager_itf.h | 12 +++--- .../game_share/server_animation_module.cpp | 2 +- .../src/game_share/server_edition_module.cpp | 4 +- .../src/game_share/server_edition_module.h | 4 +- .../src/admin_modules/admin_modules_itf.h | 12 +++--- .../server/src/logger_service/log_query.cpp | 2 +- .../server/src/logger_service/log_query.h | 2 +- .../src/server_share/continent_container.cpp | 2 +- .../src/server_share/login_service_itf.h | 12 +++--- .../server/src/server_share/mail_forum_itf.h | 12 +++--- .../server/src/server_share/mysql_wrapper.cpp | 8 ++-- .../server/src/server_share/mysql_wrapper.h | 4 +- .../session_browser_server.cpp | 26 ++++++------- .../shard_unifier_service/character_sync.cpp | 4 +- .../database_mapping.cpp | 38 +++++++++---------- .../shard_unifier_service/login_service.cpp | 2 +- .../mail_forum_notfier_fwd.cpp | 4 +- .../shard_unifier_service/name_manager.cpp | 4 +- .../ring_session_manager.cpp | 22 +++++------ .../simulated_ring_session_manager.cpp | 4 +- .../mission_compiler_lib/steps.cpp | 2 +- .../object_viewer/particle_system/dup_ps.cpp | 6 +-- .../particle_system/particle_editor.cpp | 2 +- .../particle_system/particle_node.cpp | 4 +- .../particle_workspace_dialog.h | 4 +- 67 files changed, 207 insertions(+), 197 deletions(-) diff --git a/code/nel/include/nel/3d/animation_set_user.h b/code/nel/include/nel/3d/animation_set_user.h index d5376f6df..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::unique_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::unique_ptr skeletonWeight (new CSkeletonWeight); + CUniquePtr skeletonWeight (new CSkeletonWeight); // Read it NLMISC::CIFile file; diff --git a/code/nel/include/nel/3d/material.h b/code/nel/include/nel/3d/material.h index f8736b08b..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::unique_ptr _TexUserMat; // user texture matrix + CUniquePtr _TexUserMat; // user texture matrix public: // Private. For Driver only. 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 2814d8dc0..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::unique_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 2bd309f55..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::unique_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_mesh.h b/code/nel/include/nel/3d/ps_mesh.h index bd9b9e504..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::unique_ptr PGlobalTexAnims; + typedef CUniquePtr PGlobalTexAnims; PGlobalTexAnims _GlobalTexAnims; float _GlobalAnimDate; diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 4f9302260..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 @@ -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/src/3d/animation.cpp b/code/nel/src/3d/animation.cpp index 5434c783d..157ca5427 100644 --- a/code/nel/src/3d/animation.cpp +++ b/code/nel/src/3d/animation.cpp @@ -318,7 +318,7 @@ UAnimation* UAnimation::createAnimation (const char* sPath) NL3D_HAUTO_UI_ANIMATION; // Allocate an animation - std::unique_ptr anim (new CAnimation); + CUniquePtr anim (new CAnimation); // Read it NLMISC::CIFile file; diff --git a/code/nel/src/3d/animation_set.cpp b/code/nel/src/3d/animation_set.cpp index 5f4f351f6..0b4c096c0 100644 --- a/code/nel/src/3d/animation_set.cpp +++ b/code/nel/src/3d/animation_set.cpp @@ -225,7 +225,7 @@ bool CAnimationSet::loadFromFiles(const std::string &path, bool recurse /* = tru { NLMISC::CIFile iFile; iFile.open(anims[k]); - std::unique_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/cube_map_builder.cpp b/code/nel/src/3d/cube_map_builder.cpp index ec28cc258..6e319b59e 100644 --- a/code/nel/src/3d/cube_map_builder.cpp +++ b/code/nel/src/3d/cube_map_builder.cpp @@ -89,8 +89,8 @@ static uint8 *BuildCubeMapTexLuminance(const NLMISC::CVector &start, CTextureCube *BuildCubeMap(sint mapSize, ICubeMapFunctor &f, bool luminanceOnly /* = false*/, const std::string &shareName /* = "" */) { - std::unique_ptr cubeMap(new CTextureCube); - std::unique_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/material.cpp b/code/nel/src/3d/material.cpp index f3a0c6e75..3204a620d 100644 --- a/code/nel/src/3d/material.cpp +++ b/code/nel/src/3d/material.cpp @@ -105,9 +105,9 @@ CMaterial &CMaterial::operator=(const CMaterial &mat) // copy texture matrix if there. if (mat._TexUserMat.get()) { - std::unique_ptr texMatClone( new CUserTexMat(*(mat._TexUserMat))); // make cpy + CUniquePtr texMatClone(new CUserTexMat(*(mat._TexUserMat))); // make cpy //std::swap(texMatClone, _TexUserMat); // swap with old - _TexUserMat = std::move(texMatClone); + _TexUserMat = CUniquePtrMove(texMatClone); } else { @@ -265,9 +265,9 @@ void CMaterial::serial(NLMISC::IStream &f) if ((_Flags & IDRV_MAT_USER_TEX_MAT_ALL)) // are there user textrue coordinates matrix ? { - std::unique_ptr newPtr(new CUserTexMat); // create new + CUniquePtr newPtr(new CUserTexMat); // create new //std::swap(_TexUserMat, newPtr); // replace old - _TexUserMat = std::move(newPtr); + _TexUserMat = CUniquePtrMove(newPtr); } } diff --git a/code/nel/src/3d/ps_mesh.cpp b/code/nel/src/3d/ps_mesh.cpp index 02c859d76..655534c6c 100644 --- a/code/nel/src/3d/ps_mesh.cpp +++ b/code/nel/src/3d/ps_mesh.cpp @@ -1533,7 +1533,7 @@ void CPSConstraintMesh::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { PGlobalTexAnims newPtr(new CGlobalTexAnims); // create new //std::swap(_GlobalTexAnims, newPtr); // replace old - _GlobalTexAnims = std::move(newPtr); + _GlobalTexAnims = CUniquePtrMove(newPtr); f.serial(*_GlobalTexAnims); } @@ -2352,7 +2352,7 @@ void CPSConstraintMesh::setTexAnimType(TTexAnimType type) { PGlobalTexAnims newPtr(new CGlobalTexAnims); //std::swap(_GlobalTexAnims, newPtr); - _GlobalTexAnims = std::move(newPtr); + _GlobalTexAnims = CUniquePtrMove(newPtr); _GlobalAnimationEnabled = 1; } break; diff --git a/code/nel/src/3d/ps_ribbon.cpp b/code/nel/src/3d/ps_ribbon.cpp index 87ba44669..00a3d1310 100644 --- a/code/nel/src/3d/ps_ribbon.cpp +++ b/code/nel/src/3d/ps_ribbon.cpp @@ -36,7 +36,7 @@ CPSRibbon::TVBMap CPSRibbon::_VBMaps[16]; static ITexture *CreateGradientTexture() { NL_PS_FUNC(CreateGradientTexture) - std::unique_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_tail_dot.cpp b/code/nel/src/3d/ps_tail_dot.cpp index 5e1e25043..cf9baa016 100644 --- a/code/nel/src/3d/ps_tail_dot.cpp +++ b/code/nel/src/3d/ps_tail_dot.cpp @@ -33,7 +33,7 @@ static NLMISC::CRGBA GradientB2W[] = {NLMISC::CRGBA(0, 0, 0, 0), NLMISC::CRGBA(2 static ITexture *CreateGradientTexture() { NL_PS_FUNC(CreateGradientTexture) - std::unique_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/texture_cube.cpp b/code/nel/src/3d/texture_cube.cpp index 47038df78..809bff5fa 100644 --- a/code/nel/src/3d/texture_cube.cpp +++ b/code/nel/src/3d/texture_cube.cpp @@ -193,7 +193,7 @@ bool CTextureCube::isSelectable() const ITexture *CTextureCube::buildNonSelectableVersion(uint index) { if (!isSelectable()) return this; - std::unique_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/misc/inter_window_msg_queue.cpp b/code/nel/src/misc/inter_window_msg_queue.cpp index d63ae1128..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::unique_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::unique_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::unique_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/net/module_gateway_transport.cpp b/code/nel/src/net/module_gateway_transport.cpp index 57ba9eeb4..d9029285f 100644 --- a/code/nel/src/net/module_gateway_transport.cpp +++ b/code/nel/src/net/module_gateway_transport.cpp @@ -72,7 +72,7 @@ namespace NLNET friend class CL3ServerRoute; public: /// The callback server that receive connection and dispatch message - unique_ptr _CallbackServer; + CUniquePtr _CallbackServer; /// A static mapper to retrieve transport from the CCallbackServer pointer typedef map TDispatcherIndex; @@ -224,7 +224,7 @@ namespace NLNET throw ETransportError("openServer : The server is already open"); // create a new callback server - unique_ptr cbs(new CCallbackServer()); + CUniquePtr cbs(new CCallbackServer()); // register the callbacks cbs->setConnectionCallback(cbConnection, static_cast(this)); @@ -234,7 +234,7 @@ namespace NLNET // open the server cbs->init(port); - _CallbackServer = std::move(cbs); + _CallbackServer = CUniquePtrMove(cbs); // register it in the dispatcher _DispatcherIndex.insert(make_pair(_CallbackServer.get(), this)); @@ -673,7 +673,7 @@ namespace NLNET _FreeRoutesIds.pop_back(); } - unique_ptr route(new CL3ClientRoute(this, addr, connId)); + CUniquePtr route(new CL3ClientRoute(this, addr, connId)); // set the callbacks route->CallbackClient.setDisconnectionCallback(cbDisconnection, static_cast(this)); diff --git a/code/nel/src/net/module_manager.cpp b/code/nel/src/net/module_manager.cpp index 2c32c13a7..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::unique_ptr mli(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::unique_ptr module(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::unique_ptr modProx(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/pacs/primitive_block_pacs.cpp b/code/nel/src/pacs/primitive_block_pacs.cpp index 39a91a214..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::unique_ptr pb(new CPrimitiveBlock); + CUniquePtr pb(new CPrimitiveBlock); pb->serial(src); return pb.release(); } diff --git a/code/nel/tools/3d/object_viewer/dup_ps.cpp b/code/nel/tools/3d/object_viewer/dup_ps.cpp index 537de77af..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::unique_ptr newObj(new T); + CUniquePtr newObj(new T); newObj->serialPtr(dest); delete obj; obj = newObj.release(); @@ -112,7 +112,7 @@ 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::unique_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); @@ -142,7 +142,7 @@ NL3D::CPSLocatedBindable *DupPSLocatedBindable(CPSLocatedBindable *in) else { CParticleSystem *srcPS = in->getOwner()->getOwner(); - std::unique_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()); // diff --git a/code/nel/tools/3d/object_viewer/object_viewer.cpp b/code/nel/tools/3d/object_viewer/object_viewer.cpp index b5d5f7109..207404635 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer/object_viewer.cpp @@ -469,7 +469,7 @@ void CObjectViewer::loadConfigFile() try { CConfigFile::CVar &var = cf.getVar("automatic_animation_path"); - std::unique_ptr as(new CAnimationSet); + CUniquePtr as(new CAnimationSet); // bool loadingOk = as->loadFromFiles(var.asString(),true ,"anim",true); // diff --git a/code/nel/tools/3d/object_viewer/particle_dlg.cpp b/code/nel/tools/3d/object_viewer/particle_dlg.cpp index 4fd9f359d..f50fe53a2 100644 --- a/code/nel/tools/3d/object_viewer/particle_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/particle_dlg.cpp @@ -574,7 +574,7 @@ void CParticleDlg::OnLoadPSWorkspace() void CParticleDlg::loadWorkspace(const std::string &fullPath) { // Add to the path - std::unique_ptr newPW(new CParticleWorkspace); + CUniquePtr newPW(new CParticleWorkspace); newPW->init(_ObjView, fullPath, _ObjView->getFontManager(), _ObjView->getFontGenerator()); newPW->setModificationCallback(ParticleTreeCtrl); // save empty workspace 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 973278a89..49eede1c9 100644 --- a/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp +++ b/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp @@ -1006,7 +1006,7 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA // Add search path for the texture NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()))); - std::unique_ptr sb(new NL3D::CShapeBank); + CUniquePtr sb(new NL3D::CShapeBank); CParticleSystemModel *psm = NULL; try { 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 9f699938c..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::unique_ptr _LocatedCopy; - std::unique_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 89fb31991..66efb5783 100644 --- a/code/nel/tools/3d/object_viewer/particle_workspace.cpp +++ b/code/nel/tools/3d/object_viewer/particle_workspace.cpp @@ -202,7 +202,7 @@ void CParticleWorkspace::CNode::createEmptyPS() NL3D::CParticleSystem emptyPS; NL3D::CParticleSystemShape *pss = new NL3D::CParticleSystemShape; pss->buildFromPS(emptyPS); - std::unique_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(); @@ -298,7 +298,7 @@ bool CParticleWorkspace::CNode::loadPS() // collapse name inputFile.open(getFullPath()); ss.serial(inputFile); - std::unique_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(); 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 f02eef04d..b4874ff29 100644 --- a/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp @@ -121,7 +121,7 @@ void CSnapshotToolDlg::stringFromRegistry(HKEY hKey, const TCHAR *name, CString return; } - std::unique_ptr tmpDest(new TCHAR[size]); + CUniquePtr tmpDest(new TCHAR[size]); result = RegQueryValueEx(hKey, name, NULL, &type, (BYTE*)tmpDest.get(), &size); if (result != ERROR_SUCCESS) @@ -130,7 +130,7 @@ void CSnapshotToolDlg::stringFromRegistry(HKEY hKey, const TCHAR *name, CString return; } - dest = *tmpDest; + dest = tmpDest.get(); } 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 0b5f14a36..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 @@ -1180,7 +1180,7 @@ void CExportNel::getBSMeshBuild (std::vector &bsList, INode convertMatrix(finalSpace, node.GetNodeTM(time)); CMeshBase::CMeshBaseBuild *dummyMBB = NULL; - std::unique_ptr baseMB(createMeshBuild (node, time, dummyMBB, finalSpace)); + CUniquePtr baseMB(createMeshBuild (node, time, dummyMBB, finalSpace)); delete dummyMBB; dummyMBB = NULL; if (baseMB.get() == NULL) return; diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_remanence.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_remanence.cpp index 9a629a987..8ca48893b 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_remanence.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_remanence.cpp @@ -39,7 +39,7 @@ static void buildRemanenceError(CExportNel *en, INode &node, const char *mess) //============================================================================================= NL3D::IShape *CExportNel::buildRemanence(INode& node, TimeValue time) { - std::unique_ptr 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/zone_check_bind/zone_check_bind.cpp b/code/nel/tools/3d/zone_check_bind/zone_check_bind.cpp index 8d529936f..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 @@ -95,7 +95,7 @@ static CZone *LoadZone(uint16 xPos, uint16 yPos, std::string zoneExt) { std::string zoneName; ::getZoneNameByCoord(xPos, yPos, zoneName); - std::unique_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::unique_ptr zones[9]; + CUniquePtr zones[9]; std::string zoneNames[9]; CZoneInfo zoneInfos[9]; uint16 xPos, yPos; diff --git a/code/nel/tools/3d/zone_lighter/zone_lighter.cpp b/code/nel/tools/3d/zone_lighter/zone_lighter.cpp index e45f01f5f..04c165a01 100644 --- a/code/nel/tools/3d/zone_lighter/zone_lighter.cpp +++ b/code/nel/tools/3d/zone_lighter/zone_lighter.cpp @@ -153,7 +153,7 @@ static void loadIGFromVillage(const NLGEORGES::UFormElm *villageItem, const std: if (inputFile.open (nameLookup)) { // New ig - std::unique_ptr group(new CInstanceGroup); + CUniquePtr group(new CInstanceGroup); try { group->serial (inputFile); 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 17c161afd..ede52b006 100644 --- a/code/nel/tools/nel_unit_test/nel_unit_test.cpp +++ b/code/nel/tools/nel_unit_test/nel_unit_test.cpp @@ -67,7 +67,7 @@ static void usage() exit(0); } -static unique_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 unique_ptr cmdline(int argc, char* argv[]) } } - return unique_ptr(output); + return CUniquePtr(output); } // Main test program @@ -134,12 +134,12 @@ int main(int argc, char *argv[]) { Test::Suite ts; - ts.add(unique_ptr(new CUTMisc)); - ts.add(unique_ptr(new CUTNet)); - ts.add(unique_ptr(new CUTLigo)); + ts.add(CUniquePtr(new CUTMisc)); + ts.add(CUniquePtr(new CUTNet)); + ts.add(CUniquePtr(new CUTLigo)); // Add a line here when adding a new test MODULE - unique_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 87eadde35..338ffada0 100644 --- a/code/nel/tools/nel_unit_test/ut_ligo.h +++ b/code/nel/tools/nel_unit_test/ut_ligo.h @@ -26,7 +26,7 @@ struct CUTLigo : public Test::Suite { CUTLigo() { - add(unique_ptr(new CUTLigoPrimitive)); + add(CUniquePtr(new CUTLigoPrimitive)); // Add a line here when adding a new test CLASS } }; diff --git a/code/nel/tools/nel_unit_test/ut_misc.h b/code/nel/tools/nel_unit_test/ut_misc.h index 410f1304e..900273260 100644 --- a/code/nel/tools/nel_unit_test/ut_misc.h +++ b/code/nel/tools/nel_unit_test/ut_misc.h @@ -37,20 +37,20 @@ struct CUTMisc : public Test::Suite { CUTMisc() { - add(unique_ptr(new CUTMiscCoTask)); - add(unique_ptr(new CUTMiscCommand)); - add(unique_ptr(new CUTMiscCommon)); - add(unique_ptr(new CUTMiscConfigFile)); - add(unique_ptr(new CUTMiscDebug)); - add(unique_ptr(new CUTMiscDynLibLoad)); - add(unique_ptr(new CUTMiscFile)); - add(unique_ptr(new CUTMiscPackFile)); - add(unique_ptr(new CUTMiscSingleton)); - add(unique_ptr(new CUTMiscSString)); - add(unique_ptr(new CUTMiscStream)); - add(unique_ptr(new CUTMiscVariable)); - add(unique_ptr(new CUTMiscTypes)); - add(unique_ptr(new CUTMiscStringCommon)); + add(CUniquePtr(new CUTMiscCoTask)); + add(CUniquePtr(new CUTMiscCommand)); + add(CUniquePtr(new CUTMiscCommon)); + add(CUniquePtr(new CUTMiscConfigFile)); + add(CUniquePtr(new CUTMiscDebug)); + add(CUniquePtr(new CUTMiscDynLibLoad)); + add(CUniquePtr(new CUTMiscFile)); + add(CUniquePtr(new CUTMiscPackFile)); + add(CUniquePtr(new CUTMiscSingleton)); + add(CUniquePtr(new CUTMiscSString)); + add(CUniquePtr(new CUTMiscStream)); + add(CUniquePtr(new CUTMiscVariable)); + add(CUniquePtr(new CUTMiscTypes)); + add(CUniquePtr(new CUTMiscStringCommon)); // Add a line here when adding a new test CLASS } }; diff --git a/code/nel/tools/nel_unit_test/ut_net.h b/code/nel/tools/nel_unit_test/ut_net.h index 396285700..64678f828 100644 --- a/code/nel/tools/nel_unit_test/ut_net.h +++ b/code/nel/tools/nel_unit_test/ut_net.h @@ -28,9 +28,9 @@ struct CUTNet : public Test::Suite { CUTNet() { - add(unique_ptr(new CUTNetLayer3)); - add(unique_ptr(new CUTNetMessage)); - add(unique_ptr(new CUTNetModule)); + add(CUniquePtr(new CUTNetLayer3)); + add(CUniquePtr(new CUTNetMessage)); + add(CUniquePtr(new CUTNetModule)); // Add a line here when adding a new test CLASS } }; diff --git a/code/ryzom/client/src/door_manager.cpp b/code/ryzom/client/src/door_manager.cpp index ba0678dc0..14c4e889e 100644 --- a/code/ryzom/client/src/door_manager.cpp +++ b/code/ryzom/client/src/door_manager.cpp @@ -273,7 +273,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig) sShapeName = CPath::lookup(sShapeName,false); if (!sShapeName.empty()) { - std::unique_ptr pb(NLPACS::UPrimitiveBlock::createPrimitiveBlockFromFile(sShapeName)); + CUniquePtr pb(NLPACS::UPrimitiveBlock::createPrimitiveBlockFromFile(sShapeName)); NLPACS::UPrimitiveBlock *pPB = pb.release(); bool bDoorDetectPresent = false; diff --git a/code/ryzom/client/src/pacs_client.cpp b/code/ryzom/client/src/pacs_client.cpp index f50531bb7..8e622d410 100644 --- a/code/ryzom/client/src/pacs_client.cpp +++ b/code/ryzom/client/src/pacs_client.cpp @@ -194,7 +194,7 @@ void addPacsPrim(const std::string &fileName) nlwarning(("Pacs primitive " + ppName + " already has been inserted").c_str()); return; } - std::unique_ptr pb(NLPACS::UPrimitiveBlock::createPrimitiveBlockFromFile(fileName)); + CUniquePtr pb(NLPACS::UPrimitiveBlock::createPrimitiveBlockFromFile(fileName)); PacsPrims[ppName] = pb.release(); } diff --git a/code/ryzom/client/src/r2/auto_group.cpp b/code/ryzom/client/src/r2/auto_group.cpp index 0da724d4b..eeefbd7de 100644 --- a/code/ryzom/client/src/r2/auto_group.cpp +++ b/code/ryzom/client/src/r2/auto_group.cpp @@ -264,7 +264,7 @@ void CAutoGroup::group(CObject *newEntityDesc, const NLMISC::CVectorD &createPos else { // other is a standalone entity -> create a new group - std::unique_ptr newGroup(getEditor().getDMC().newComponent("NpcGrpFeature")); + CUniquePtr newGroup(getEditor().getDMC().newComponent("NpcGrpFeature")); if (!newGroup.get()) { nlwarning("Syntax error in r2_features_npc_group.lua."); diff --git a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp index 98c10afb6..37caebc3e 100644 --- a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -132,7 +132,7 @@ namespace R2 { client->onScenarioUploaded(server, _Value.get()); } private: - std::unique_ptr _Value; + CUniquePtr _Value; }; class CServerAnswerMsgSet: public IServerAnswerMsg @@ -148,7 +148,7 @@ namespace R2 { private: std::string _InstanceId; std::string _AttrName; - std::unique_ptr _Value; + CUniquePtr _Value; }; class CServerAnswerMsgInserted: public IServerAnswerMsg @@ -166,7 +166,7 @@ namespace R2 { std::string _AttrName; sint32 _Position; std::string _Key; - std::unique_ptr _Value; + CUniquePtr _Value; }; class CServerAnswerMsgErased: public IServerAnswerMsg @@ -1140,7 +1140,7 @@ void CClientEditionModule::startingScenario(class NLNET::IModuleProxy * /* serve _Factory->setMaxId("RtEntryText", 0); _Factory->setMaxId("RtPlotItem", 0); - std::unique_ptr rtDataPtr( _Client->getComLuaModule().translateFeatures(hlScenario , errorMsg) ); + CUniquePtr rtDataPtr( _Client->getComLuaModule().translateFeatures(hlScenario , errorMsg) ); rtData.setData(rtDataPtr.get()); if (rtDataPtr.get()) @@ -2351,7 +2351,7 @@ void CClientEditionModule::loadUserComponentFileAccepted(NLNET::IModuleProxy * / return; } - unique_ptr userComponentToLoad(found->second); + CUniquePtr userComponentToLoad(found->second); _UserComponentToLoad.erase(found); if (!ok) @@ -2383,7 +2383,7 @@ void CClientEditionModule::saveScenarioFileAccepted(NLNET::IModuleProxy *senderM return; } - unique_ptr scenarioToSave(found->second); + CUniquePtr scenarioToSave(found->second); _ScenarioToSave.erase(found); if (ok) @@ -2498,7 +2498,7 @@ void CClientEditionModule::loadScenarioFileAccepted(NLNET::IModuleProxy * /* sen return; } - unique_ptr scenarioToLoad(found->second); + CUniquePtr scenarioToLoad(found->second); _ScenarioToLoad.erase(found); if (!ok) diff --git a/code/ryzom/client/src/r2/dmc/client_edition_module.h b/code/ryzom/client/src/r2/dmc/client_edition_module.h index 3668f6ae6..662dddeb6 100644 --- a/code/ryzom/client/src/r2/dmc/client_edition_module.h +++ b/code/ryzom/client/src/r2/dmc/client_edition_module.h @@ -1169,7 +1169,7 @@ private: uint32 _MaxNpcs; uint32 _MaxStaticObjects; - std::unique_ptr _Emotes; + CUniquePtr _Emotes; CEditorConfig* _ClientEditorConfig; diff --git a/code/ryzom/client/src/r2/tool_create_entity.cpp b/code/ryzom/client/src/r2/tool_create_entity.cpp index 479e9b495..c29209b43 100644 --- a/code/ryzom/client/src/r2/tool_create_entity.cpp +++ b/code/ryzom/client/src/r2/tool_create_entity.cpp @@ -227,7 +227,7 @@ std::string CToolCreateEntity::cloneEntityIntoScenario(CEntityCL *clonee, getDMC().newAction(NLMISC::CI18N::get("uiR2EDCreateAction") + readableName); } // send network commands to create entity on server - std::unique_ptr desc(getDMC().newComponent(className)); + CUniquePtr desc(getDMC().newComponent(className)); if (desc.get()) { diff --git a/code/ryzom/client/src/r2/tool_select_move.cpp b/code/ryzom/client/src/r2/tool_select_move.cpp index c2433a1a3..261e8b49a 100644 --- a/code/ryzom/client/src/r2/tool_select_move.cpp +++ b/code/ryzom/client/src/r2/tool_select_move.cpp @@ -377,7 +377,7 @@ void CToolSelectMove::commitAction(CInstance &instance) if (_AutoGroup.getGroupingCandidate()) { newCopy.push(); - std::unique_ptr desc(CComLuaModule::getObjectFromLua(ls.getStatePointer())); + CUniquePtr desc(CComLuaModule::getObjectFromLua(ls.getStatePointer())); _AutoGroup.group(desc.get(), _FinalPos); } else diff --git a/code/ryzom/client/src/seven_zip/seven_zip.cpp b/code/ryzom/client/src/seven_zip/seven_zip.cpp index f9022b59d..7899e7380 100644 --- a/code/ryzom/client/src/seven_zip/seven_zip.cpp +++ b/code/ryzom/client/src/seven_zip/seven_zip.cpp @@ -196,13 +196,13 @@ bool unpackLZMA(const std::string &lzmaFile, const std::string &destFileName) } // allocate input buffer for props - unique_ptr propsBuffer(new uint8[LZMA_PROPS_SIZE]); + CUniquePtr propsBuffer(new uint8[LZMA_PROPS_SIZE]); // size of LZMA content inSize -= LZMA_PROPS_SIZE + 8; // allocate input buffer for lzma data - unique_ptr inBuffer(new uint8[inSize]); + CUniquePtr inBuffer(new uint8[inSize]); uint64 fileSize = 0; @@ -224,7 +224,7 @@ bool unpackLZMA(const std::string &lzmaFile, const std::string &destFileName) } // allocate the output buffer - unique_ptr outBuffer(new uint8[fileSize]); + CUniquePtr outBuffer(new uint8[fileSize]); // in and out file sizes SizeT outProcessed = (SizeT)fileSize; @@ -273,7 +273,7 @@ bool packLZMA(const std::string &srcFileName, const std::string &lzmaFileName) } // allocate input buffer - unique_ptr inBuffer(new uint8[inSize]); + CUniquePtr inBuffer(new uint8[inSize]); try { @@ -288,11 +288,11 @@ bool packLZMA(const std::string &srcFileName, const std::string &lzmaFileName) // allocate output buffer size_t outSize = (11 * inSize / 10) + 65536; // worst case = 1.1 * size + 64K - unique_ptr outBuffer(new uint8[outSize]); + CUniquePtr outBuffer(new uint8[outSize]); // allocate buffer for props size_t outPropsSize = LZMA_PROPS_SIZE; - unique_ptr outProps(new uint8[outPropsSize]); + CUniquePtr outProps(new uint8[outPropsSize]); // compress with best compression and other default settings sint res = LzmaCompress(outBuffer.get(), &outSize, inBuffer.get(), inSize, outProps.get(), &outPropsSize, 9, 1 << 27, -1, -1, -1, -1, 1); diff --git a/code/ryzom/client/src/sky.cpp b/code/ryzom/client/src/sky.cpp index 696d67251..9b3474ada 100644 --- a/code/ryzom/client/src/sky.cpp +++ b/code/ryzom/client/src/sky.cpp @@ -294,7 +294,7 @@ CBitmap *buildSharedBitmap(const std::string &filename, // load the bitmap std::string path = CPath::lookup(filename, false); if (path.empty()) return NULL; - std::unique_ptr bm(new CBitmap); + CUniquePtr bm(new CBitmap); try { CIFile f; diff --git a/code/ryzom/common/src/game_share/ring_session_manager_itf.h b/code/ryzom/common/src/game_share/ring_session_manager_itf.h index 832903ad1..0921a228c 100644 --- a/code/ryzom/common/src/game_share/ring_session_manager_itf.h +++ b/code/ryzom/common/src/game_share/ring_session_manager_itf.h @@ -2393,7 +2393,7 @@ namespace RSMGR protected: /// the callback server adaptor - std::unique_ptr _CallbackServer; + CUniquePtr _CallbackServer; void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) { @@ -2464,12 +2464,12 @@ namespace RSMGR if (replacementAdaptor == NULL) { // use default callback server - _CallbackServer = std::unique_ptr(new CNelCallbackServerAdaptor(this)); + _CallbackServer = CUniquePtr(new CNelCallbackServerAdaptor(this)); } else { // use the replacement one - _CallbackServer = std::unique_ptr(replacementAdaptor); + _CallbackServer = CUniquePtr(replacementAdaptor); } } @@ -3858,7 +3858,7 @@ namespace RSMGR protected: /// the callback client adaptor - std::unique_ptr < ICallbackClientAdaptor > _CallbackClient; + CUniquePtr < ICallbackClientAdaptor > _CallbackClient; void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) @@ -3922,12 +3922,12 @@ namespace RSMGR if (adaptorReplacement == NULL) { // use the default Nel adaptor - _CallbackClient = std::unique_ptr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); + _CallbackClient = CUniquePtr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); } else { // use the replacement one - _CallbackClient = std::unique_ptr < ICallbackClientAdaptor >(adaptorReplacement); + _CallbackClient = CUniquePtr < ICallbackClientAdaptor >(adaptorReplacement); } } diff --git a/code/ryzom/common/src/game_share/server_animation_module.cpp b/code/ryzom/common/src/game_share/server_animation_module.cpp index 19446abc1..0f0c90bb0 100644 --- a/code/ryzom/common/src/game_share/server_animation_module.cpp +++ b/code/ryzom/common/src/game_share/server_animation_module.cpp @@ -362,7 +362,7 @@ public: typedef std::map TCharacterInfos; public: - std::unique_ptr RtData; + CUniquePtr RtData; TScenarioHeaderSerializer ScenarioHeader; TSessionId SessionId; //vector diff --git a/code/ryzom/common/src/game_share/server_edition_module.cpp b/code/ryzom/common/src/game_share/server_edition_module.cpp index 6ddbe8931..8670716b0 100644 --- a/code/ryzom/common/src/game_share/server_edition_module.cpp +++ b/code/ryzom/common/src/game_share/server_edition_module.cpp @@ -2215,7 +2215,7 @@ void CServerEditionModule::onNodeSetAsked(NLNET::IModuleProxy *senderModuleProxy value2.uncompress(); CObject* value = value2.getData(); - std::unique_ptr autoDelete(value); + CUniquePtr autoDelete(value); bool ok = checkSecurityInfo(senderModuleProxy, charId, clientEid, userPriv, extendedPriv); @@ -5116,7 +5116,7 @@ bool CServerEditionModule::wakeUpSession(TSessionId sessionId, TCharId ownerChar void CServerEditionModule::wakeUpSessionImpl(CEditionSession* session) { - std::unique_ptr sessionPtr(session); + CUniquePtr sessionPtr(session); TSessionId sessionId = sessionPtr->SessionId; TSessions::iterator found = _Sessions.find(sessionId); diff --git a/code/ryzom/common/src/game_share/server_edition_module.h b/code/ryzom/common/src/game_share/server_edition_module.h index d5f565dc7..9a5b90b88 100644 --- a/code/ryzom/common/src/game_share/server_edition_module.h +++ b/code/ryzom/common/src/game_share/server_edition_module.h @@ -541,7 +541,7 @@ namespace R2 private: std::set _Sessions; - std::unique_ptr _Component; + CUniquePtr _Component; }; struct CHashKeyMD5Less : public std::binary_function @@ -637,7 +637,7 @@ namespace R2 CTaskList _RingAccessTasks; // Remove people that do not belong here TOverrideRingAccess _OverrideRingAccess; //Ring access for dev bool _MustUpdateOverrideRingAcess; - std::unique_ptr _IdRecycle; + CUniquePtr _IdRecycle; TKicked _Kicked; // diff --git a/code/ryzom/server/src/admin_modules/admin_modules_itf.h b/code/ryzom/server/src/admin_modules/admin_modules_itf.h index a77d52935..8c25790e7 100644 --- a/code/ryzom/server/src/admin_modules/admin_modules_itf.h +++ b/code/ryzom/server/src/admin_modules/admin_modules_itf.h @@ -55,7 +55,7 @@ namespace ADMIN protected: /// the callback server adaptor - std::unique_ptr _CallbackServer; + CUniquePtr _CallbackServer; void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) { @@ -102,12 +102,12 @@ namespace ADMIN if (replacementAdaptor == NULL) { // use default callback server - _CallbackServer = std::unique_ptr(new CNelCallbackServerAdaptor(this)); + _CallbackServer = CUniquePtr(new CNelCallbackServerAdaptor(this)); } else { // use the replacement one - _CallbackServer = std::unique_ptr(replacementAdaptor); + _CallbackServer = CUniquePtr(replacementAdaptor); } } @@ -439,7 +439,7 @@ namespace ADMIN protected: /// the callback client adaptor - std::unique_ptr < ICallbackClientAdaptor > _CallbackClient; + CUniquePtr < ICallbackClientAdaptor > _CallbackClient; void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) @@ -493,12 +493,12 @@ namespace ADMIN if (adaptorReplacement == NULL) { // use the default Nel adaptor - _CallbackClient = std::unique_ptr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); + _CallbackClient = CUniquePtr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); } else { // use the replacement one - _CallbackClient = std::unique_ptr < ICallbackClientAdaptor >(adaptorReplacement); + _CallbackClient = CUniquePtr < ICallbackClientAdaptor >(adaptorReplacement); } } diff --git a/code/ryzom/server/src/logger_service/log_query.cpp b/code/ryzom/server/src/logger_service/log_query.cpp index 9c3d093c0..9a53856a6 100644 --- a/code/ryzom/server/src/logger_service/log_query.cpp +++ b/code/ryzom/server/src/logger_service/log_query.cpp @@ -145,7 +145,7 @@ CQueryParser::TParserResult CQueryParser::parseQuery(const std::string &queryStr return pr; } - unique_ptr rootNode(parseExpr(first, queryStr.end())); + CUniquePtr rootNode(parseExpr(first, queryStr.end())); // make sure we have consumed all the stream iterator rew = first; diff --git a/code/ryzom/server/src/logger_service/log_query.h b/code/ryzom/server/src/logger_service/log_query.h index 0e046fdfb..ba10d7602 100644 --- a/code/ryzom/server/src/logger_service/log_query.h +++ b/code/ryzom/server/src/logger_service/log_query.h @@ -1190,7 +1190,7 @@ public: struct TParserResult { /// The query tree - mutable std::unique_ptr QueryTree; + mutable CUniquePtr QueryTree; /// Option to extract full context with selected logs bool FullContext; diff --git a/code/ryzom/server/src/server_share/continent_container.cpp b/code/ryzom/server/src/server_share/continent_container.cpp index d44604052..9babc998b 100644 --- a/code/ryzom/server/src/server_share/continent_container.cpp +++ b/code/ryzom/server/src/server_share/continent_container.cpp @@ -293,7 +293,7 @@ void CContinentContainer::initPacsPrim(const string &path) if (_PacsPrimMap.find(ppName) != _PacsPrimMap.end()) continue; - std::unique_ptr pb(UPrimitiveBlock::createPrimitiveBlockFromFile(CPath::lookup(fileNames[k], false))); + CUniquePtr pb(UPrimitiveBlock::createPrimitiveBlockFromFile(CPath::lookup(fileNames[k], false))); UPrimitiveBlock* ptr = pb.release(); if (ptr != NULL) { diff --git a/code/ryzom/server/src/server_share/login_service_itf.h b/code/ryzom/server/src/server_share/login_service_itf.h index a032cb5b6..ef7eba0a8 100644 --- a/code/ryzom/server/src/server_share/login_service_itf.h +++ b/code/ryzom/server/src/server_share/login_service_itf.h @@ -43,7 +43,7 @@ namespace LS protected: /// the callback server adaptor - std::unique_ptr _CallbackServer; + CUniquePtr _CallbackServer; void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) { @@ -85,12 +85,12 @@ namespace LS if (replacementAdaptor == NULL) { // use default callback server - _CallbackServer = std::unique_ptr(new CNelCallbackServerAdaptor(this)); + _CallbackServer = CUniquePtr(new CNelCallbackServerAdaptor(this)); } else { // use the replacement one - _CallbackServer = std::unique_ptr(replacementAdaptor); + _CallbackServer = CUniquePtr(replacementAdaptor); } } @@ -259,7 +259,7 @@ namespace LS protected: /// the callback client adaptor - std::unique_ptr < ICallbackClientAdaptor > _CallbackClient; + CUniquePtr < ICallbackClientAdaptor > _CallbackClient; void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) @@ -315,12 +315,12 @@ namespace LS if (adaptorReplacement == NULL) { // use the default Nel adaptor - _CallbackClient = std::unique_ptr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); + _CallbackClient = CUniquePtr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); } else { // use the replacement one - _CallbackClient = std::unique_ptr < ICallbackClientAdaptor >(adaptorReplacement); + _CallbackClient = CUniquePtr < ICallbackClientAdaptor >(adaptorReplacement); } } diff --git a/code/ryzom/server/src/server_share/mail_forum_itf.h b/code/ryzom/server/src/server_share/mail_forum_itf.h index 6d85e4606..ff23eb210 100644 --- a/code/ryzom/server/src/server_share/mail_forum_itf.h +++ b/code/ryzom/server/src/server_share/mail_forum_itf.h @@ -168,7 +168,7 @@ namespace MFS protected: /// the callback server adaptor - std::unique_ptr _CallbackServer; + CUniquePtr _CallbackServer; void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) { @@ -210,12 +210,12 @@ namespace MFS if (replacementAdaptor == NULL) { // use default callback server - _CallbackServer = std::unique_ptr(new CNelCallbackServerAdaptor(this)); + _CallbackServer = CUniquePtr(new CNelCallbackServerAdaptor(this)); } else { // use the replacement one - _CallbackServer = std::unique_ptr(replacementAdaptor); + _CallbackServer = CUniquePtr(replacementAdaptor); } } @@ -351,7 +351,7 @@ namespace MFS protected: /// the callback client adaptor - std::unique_ptr < ICallbackClientAdaptor > _CallbackClient; + CUniquePtr < ICallbackClientAdaptor > _CallbackClient; void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) @@ -405,12 +405,12 @@ namespace MFS if (adaptorReplacement == NULL) { // use the default Nel adaptor - _CallbackClient = std::unique_ptr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); + _CallbackClient = CUniquePtr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); } else { // use the replacement one - _CallbackClient = std::unique_ptr < ICallbackClientAdaptor >(adaptorReplacement); + _CallbackClient = CUniquePtr < ICallbackClientAdaptor >(adaptorReplacement); } } diff --git a/code/ryzom/server/src/server_share/mysql_wrapper.cpp b/code/ryzom/server/src/server_share/mysql_wrapper.cpp index 285b88429..5f289aceb 100644 --- a/code/ryzom/server/src/server_share/mysql_wrapper.cpp +++ b/code/ryzom/server/src/server_share/mysql_wrapper.cpp @@ -237,22 +237,22 @@ namespace MSW } - std::unique_ptr CConnection::storeResult() + CUniquePtr CConnection::storeResult() { H_AUTO(CConnection_storeResult); MYSQL_RES *res = mysql_store_result(_MysqlContext); - std::unique_ptr sr(new CStoreResult(res)); + CUniquePtr sr(new CStoreResult(res)); return sr; } - std::unique_ptr CConnection::useResult() + CUniquePtr CConnection::useResult() { H_AUTO(CConnection_useResult); MYSQL_RES *res = mysql_use_result(_MysqlContext); - std::unique_ptr sr(new CUseResult(res)); + CUniquePtr sr(new CUseResult(res)); return sr; } diff --git a/code/ryzom/server/src/server_share/mysql_wrapper.h b/code/ryzom/server/src/server_share/mysql_wrapper.h index 2af472f3a..14e7b58b1 100644 --- a/code/ryzom/server/src/server_share/mysql_wrapper.h +++ b/code/ryzom/server/src/server_share/mysql_wrapper.h @@ -108,8 +108,8 @@ namespace MSW return uint32(mysql_affected_rows(_MysqlContext)); } - std::unique_ptr storeResult(); - std::unique_ptr useResult(); + CUniquePtr storeResult(); + CUniquePtr useResult(); }; diff --git a/code/ryzom/server/src/session_browser_server/session_browser_server.cpp b/code/ryzom/server/src/session_browser_server/session_browser_server.cpp index a8ae1d9be..8c05ee95a 100644 --- a/code/ryzom/server/src/session_browser_server/session_browser_server.cpp +++ b/code/ryzom/server/src/session_browser_server/session_browser_server.cpp @@ -642,7 +642,7 @@ public: return; } - unique_ptr result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); if (result->getNumRows() != 1) { nlinfo("Client from '%s' submited auth cookie '%s' for user %u, but DB return %u row instead of 1", @@ -726,7 +726,7 @@ public: query << "SELECT session_id, kicked"; query << " FROM session_participant WHERE char_id = "<< charId; BOMB_IF(!_RingDB.query(query), "error", CSessionBrowserServerWebItf::_CallbackServer->disconnect(from); return); - unique_ptr result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); uint32 row = result->getNumRows(); uint32 index = 0; @@ -757,7 +757,7 @@ public: query << " FROM characters WHERE char_id = "<disconnect(from); return); - unique_ptr result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); BOMB_IF(result->getNumRows() != 1, "error", CSessionBrowserServerWebItf::_CallbackServer->disconnect(from); return); result->fetchRow(); uint32 guildId; @@ -831,7 +831,7 @@ public: BOMB_IF(!_RingDB.query(query), "error", CSessionBrowserServerWebItf::_CallbackServer->disconnect(from); return); - unique_ptr result2(_RingDB.storeResult()); + CUniquePtr result2(_RingDB.storeResult()); // BOMB_IF(result->getNumFields() != 1, "error", CSessionBrowserServerWebItf::_CallbackServer->disconnect(from); return); // parse the result set and build the return vector @@ -917,7 +917,7 @@ public: query << " WHERE current_status='cs_online'"; query << " AND current_session="<< sd.getSessionId(); BOMB_IF(!_RingDB.query(query), "error", CSessionBrowserServerWebItf::_CallbackServer->disconnect(from); return); - unique_ptr result3(_RingDB.storeResult()); + CUniquePtr result3(_RingDB.storeResult()); BOMB_IF(result2->getNumRows()<1,"Expected 1 result from SQL nbPlayers request but retrieved none",return); uint32 nbPlayers; result3->fetchRow(); @@ -960,7 +960,7 @@ public: query << " AND ring_users.user_id = characters.user_id"; BOMB_IF(!_RingDB.query(query), "getCharList : error executing request in database", charList(from, charId, sessionId, vector ()); return); - unique_ptr result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); vector charDescs; charDescs.resize(result->getNumRows()); @@ -1044,7 +1044,7 @@ public: CSString query; query << "SELECT home_mainland_session_id, current_session FROM characters WHERE char_id = "<> 4, 103, "Database request failed"); return); - unique_ptr result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); BOMB_IF (result->getNumRows() == 0, "invitedCharacterByName : can't find char "<> 4, 100, "Owner requester character"); return); result->fetchRow(); @@ -1064,7 +1064,7 @@ public: query << "SELECT char_id FROM characters WHERE char_name = '"<> 4, 103, "Database request failed"); return); - result = unique_ptr(_RingDB.storeResult()); + result = CUniquePtr(_RingDB.storeResult()); BOMB_IF (result->getNumRows() == 0, "invitedCharacterByName : can't find invited char '"<> 4, 104, "Invited char not found"); return); result->fetchRow(); @@ -1097,7 +1097,7 @@ public: query << " WHERE char_id = "< result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); if (result->getNumRows() == 0) { @@ -1133,7 +1133,7 @@ public: query << " GROUP BY session_log.id"; BOMB_IF(!_RingDB.query(query), "getScessionAverageScores : failed request in database", sessionAverageScores(from, false, 0,0,0,0,0, 0); return); - unique_ptr result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); if (result->getNumRows() == 0) { @@ -1178,7 +1178,7 @@ public: query << " GROUP BY scenario.id"; BOMB_IF(!_RingDB.query(query), "getScenarioAverageScores : failed request in database", scenarioAverageScores(from, false, 0,0,0,0,0,0); return); - unique_ptr result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); if (result->getNumRows() == 0) { @@ -1219,7 +1219,7 @@ public: CSString query; query << "SELECT rrp_am, rrp_masterless, rrp_author FROM characters WHERE char_id = "< result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); BOMB_IF (result->getNumRows() == 0, "getRingRatings : can't find char "<fetchRow(); @@ -1240,7 +1240,7 @@ public: CSString query; query << "SELECT ring_access FROM characters WHERE char_id = "< result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); BOMB_IF (result->getNumRows() == 0, "on_getRingPoints : can't find char "<fetchRow(); diff --git a/code/ryzom/server/src/shard_unifier_service/character_sync.cpp b/code/ryzom/server/src/shard_unifier_service/character_sync.cpp index dccfd236b..5be9c7fe5 100644 --- a/code/ryzom/server/src/shard_unifier_service/character_sync.cpp +++ b/code/ryzom/server/src/shard_unifier_service/character_sync.cpp @@ -1307,7 +1307,7 @@ namespace CHARSYNC query << " AND session_type = 'st_edit'"; if (_RingDB.query(query) ) { - std::unique_ptr result(_RingDB.storeResult()); + CUniquePtr result(_RingDB.storeResult()); bool sessionClosed = false; if (!result->getNumRows() == 0) @@ -1389,7 +1389,7 @@ namespace CHARSYNC // return true; // } // -// std::unique_ptr result(_RingDB.storeResult()); +// CUniquePtr result(_RingDB.storeResult()); // // result->fetchRow(); // result->getField(0, dstUserId); diff --git a/code/ryzom/server/src/shard_unifier_service/database_mapping.cpp b/code/ryzom/server/src/shard_unifier_service/database_mapping.cpp index 93ac5eda1..5433f44eb 100644 --- a/code/ryzom/server/src/shard_unifier_service/database_mapping.cpp +++ b/code/ryzom/server/src/shard_unifier_service/database_mapping.cpp @@ -578,7 +578,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -638,7 +638,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -1230,7 +1230,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -1288,7 +1288,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -1992,7 +1992,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -2082,7 +2082,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -3940,7 +3940,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -4092,7 +4092,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -5435,7 +5435,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -6105,7 +6105,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -6155,7 +6155,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -6748,7 +6748,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -6808,7 +6808,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -7378,7 +7378,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -7965,7 +7965,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -8637,7 +8637,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -8687,7 +8687,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -9909,7 +9909,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); for (uint i=0; igetNumRows(); ++i) { @@ -10453,7 +10453,7 @@ namespace RSMGR return false; } - std::unique_ptr result(connection.storeResult()); + CUniquePtr result(connection.storeResult()); // check that the data description is consistent with database content nlassert(result->getNumRows() <= 1); diff --git a/code/ryzom/server/src/shard_unifier_service/login_service.cpp b/code/ryzom/server/src/shard_unifier_service/login_service.cpp index 75c547ec7..6344fbb66 100644 --- a/code/ryzom/server/src/shard_unifier_service/login_service.cpp +++ b/code/ryzom/server/src/shard_unifier_service/login_service.cpp @@ -382,7 +382,7 @@ namespace LS CSString query; query << "SELECT UId FROM user WHERE GMId = "< result(_NelDb.storeResult()); + CUniquePtr result(_NelDb.storeResult()); for (uint32 i=0; i!=result->getNumRows(); ++i) { result->fetchRow(); diff --git a/code/ryzom/server/src/shard_unifier_service/mail_forum_notfier_fwd.cpp b/code/ryzom/server/src/shard_unifier_service/mail_forum_notfier_fwd.cpp index f794c6d84..f308e59ff 100644 --- a/code/ryzom/server/src/shard_unifier_service/mail_forum_notfier_fwd.cpp +++ b/code/ryzom/server/src/shard_unifier_service/mail_forum_notfier_fwd.cpp @@ -207,7 +207,7 @@ namespace MFS BOMB_IF(!_RingDb.query(query), ("Database error, no guild forum notification"), break;); - unique_ptr result(_RingDb.storeResult()); + CUniquePtr result(_RingDb.storeResult()); BOMB_IF(result->getNumRows() != 1, ("Database error, no guild forum notification"), break;); @@ -229,7 +229,7 @@ namespace MFS string query = "SELECT COUNT(*) FROM mfs_mail WHERE date > '"+MSW::encodeDate(lastDisconnectionDate)+"' AND status = 'ms_new' AND erase_series = 0"; BOMB_IF(!_RingDb.query(query), ("Database error, no mail notification"), return;); - unique_ptr result(_RingDb.storeResult()); + CUniquePtr result(_RingDb.storeResult()); BOMB_IF(result->getNumRows() != 1, ("Database error, no mail notification"), return;); diff --git a/code/ryzom/server/src/shard_unifier_service/name_manager.cpp b/code/ryzom/server/src/shard_unifier_service/name_manager.cpp index 4087ef9d0..c1dd19dd6 100644 --- a/code/ryzom/server/src/shard_unifier_service/name_manager.cpp +++ b/code/ryzom/server/src/shard_unifier_service/name_manager.cpp @@ -789,7 +789,7 @@ bool CNameManager::loadAccountNamesFromDatabase() query << "SELECT user_id, user_name FROM ring_users"; BOMB_IF(!_Database->query(query), "Failed to load account names from the database", return false); - unique_ptr result(_Database->useResult()); + CUniquePtr result(_Database->useResult()); while (result->fetchRow()) { @@ -986,7 +986,7 @@ bool CNameManager::loadCharacterNamesFromDatabase() query << "SELECT char_id, char_name, home_mainland_session_id FROM characters"; BOMB_IF(!_Database->query(query), "Failed to load character names from the database", return false); - unique_ptr result(_Database->useResult()); + CUniquePtr result(_Database->useResult()); while (result->fetchRow()) { diff --git a/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp b/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp index 685700e71..7393aec96 100644 --- a/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp +++ b/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp @@ -299,7 +299,7 @@ namespace RSMGR list sessionIds; { // scope the result to make it destroyed at scope end - unique_ptr result(_RingDb.useResult()); + CUniquePtr result(_RingDb.useResult()); // for each open session, put it in the locked state while (result->fetchRow()) @@ -627,7 +627,7 @@ namespace RSMGR // query << " AND ShardId = " << shardId; // // BOMB_IF(!_NelDb.query(query), "registerWS : Failed to request into the NeL database", return CNelShardPtr()); -// unique_ptr result(_NelDb.storeResult()); +// CUniquePtr result(_NelDb.storeResult()); // BOMB_IF(result.get() == NULL, "registerWS : Failed to retrieve request result", return CNelShardPtr()); // // if (result->getNumRows() == 0) @@ -656,7 +656,7 @@ namespace RSMGR // joinSessionResult(from, charId>>4, 0, 12, "failed to request for access permission", TSessionPartStatus::invalid_val); return false; } - unique_ptr result(_NelDb.storeResult()); + CUniquePtr result(_NelDb.storeResult()); if (result->getNumRows() == 0) { return false; @@ -1008,7 +1008,7 @@ restartLoop: CSString query; query << "SELECT id FROM scenario WHERE md5 = '"< result(_RingDb.storeResult()); + CUniquePtr result(_RingDb.storeResult()); if (result->getNumRows() != 0) { result->fetchRow(); @@ -1139,7 +1139,7 @@ restartLoop: CSString query; query << "SELECT id FROM scenario WHERE md5 = '"< result(_RingDb.storeResult()); + CUniquePtr result(_RingDb.storeResult()); if (result->getNumRows() != 0) { result->fetchRow(); @@ -1918,7 +1918,7 @@ endOfWelcomeUserResult: CSString query; query << "SELECT COUNT(*) FROM sessions WHERE owner = "<>4, 5, "Database failure"); return); - unique_ptr result(_RingDb.storeResult()); + CUniquePtr result(_RingDb.storeResult()); result->fetchRow(); uint32 nbSession; @@ -2114,7 +2114,7 @@ endOfWelcomeUserResult: query << " AND session_type = 'st_edit'"; BOMB_IF(!_RingDb.query(query), "Error in database request", invokeResult(from, userId, 2, "Error in database request"); return); - unique_ptr result(_RingDb.storeResult()); + CUniquePtr result(_RingDb.storeResult()); bool sessionClosed = false; if (result->getNumRows() == 0) @@ -2196,7 +2196,7 @@ endOfWelcomeUserResult: query << "SELECT session_id FROM sessions"; query << " WHERE owner = "<>4, 1, "Database error"); return); - unique_ptr result(_RingDb.storeResult()); + CUniquePtr result(_RingDb.storeResult()); // 1.1 : if no session so no need to hibernate (not an error) if (result->getNumRows() != 0) @@ -2243,7 +2243,7 @@ endOfWelcomeUserResult: query << "SELECT session_id FROM sessions"; query << " WHERE owner = "<>4, 1, "Database error"); return); - unique_ptr result(_RingDb.storeResult()); + CUniquePtr result(_RingDb.storeResult()); // 1.1 : if no session so no need to hibernate (not an error) if (result->getNumRows() > 1) @@ -3546,7 +3546,7 @@ endOfWelcomeUserResult: query << "SELECT session_id FROM sessions"; query << " WHERE owner = "<>4, TSessionId(0), 11, "Database error", TSessionPartStatus::invalid_val); return); - unique_ptr result(_RingDb.storeResult()); + CUniquePtr result(_RingDb.storeResult()); // 1.1 : if no session found, return an error to the client if (result->getNumRows() == 0) @@ -4387,7 +4387,7 @@ endOfWelcomeUserResult: set sessionToClose; - unique_ptr result = _RingDb.useResult(); + CUniquePtr result = _RingDb.useResult(); while (result->fetchRow()) { diff --git a/code/ryzom/server/src/simulation_service/simulated_ring_session_manager.cpp b/code/ryzom/server/src/simulation_service/simulated_ring_session_manager.cpp index eaaa549a5..e64cbbf57 100644 --- a/code/ryzom/server/src/simulation_service/simulated_ring_session_manager.cpp +++ b/code/ryzom/server/src/simulation_service/simulated_ring_session_manager.cpp @@ -114,7 +114,7 @@ namespace RSMGR list sessionIds; { // scope the result to make it destroyed at scope end - unique_ptr result(_RingDb.useResult()); + CUniquePtr result(_RingDb.useResult()); // for each open session, put it in the locked state while (result->fetchRow()) @@ -1313,7 +1313,7 @@ namespace RSMGR set sessionToClose; - unique_ptr result(_RingDb.useResult()); + CUniquePtr result(_RingDb.useResult()); while (result->fetchRow()) { diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp b/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp index 9e9e03559..7ada1d1a8 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp @@ -741,7 +741,7 @@ public: // _TalkToMenu.initPhrase(md, prim, temp); _TalkToObjective = NULL; - std::unique_ptr talkToObjective; // next calls could throw exceptions, so take care... + CUniquePtr talkToObjective; // next calls could throw exceptions, so take care... if (!temp.empty()) { talkToObjective.reset(new CStepDynChatTalkTo(md, prim, "talk_to_")); diff --git a/code/studio/src/plugins/object_viewer/particle_system/dup_ps.cpp b/code/studio/src/plugins/object_viewer/particle_system/dup_ps.cpp index 3b2e6d69f..086607fac 100644 --- a/code/studio/src/plugins/object_viewer/particle_system/dup_ps.cpp +++ b/code/studio/src/plugins/object_viewer/particle_system/dup_ps.cpp @@ -66,7 +66,7 @@ struct CDupObjPolicy dest.serialPtr(obj); /*if (dest.isReading()) { - std::unique_ptr newObj(new T); + CUniquePtr newObj(new T); newObj->serialPtr(dest); delete obj; obj = newObj.release(); @@ -111,7 +111,7 @@ 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::unique_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); @@ -141,7 +141,7 @@ NL3D::CPSLocatedBindable *DupPSLocatedBindable(CPSLocatedBindable *in) else { CParticleSystem *srcPS = in->getOwner()->getOwner(); - std::unique_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()); // diff --git a/code/studio/src/plugins/object_viewer/particle_system/particle_editor.cpp b/code/studio/src/plugins/object_viewer/particle_system/particle_editor.cpp index 38b46d439..9940dc350 100644 --- a/code/studio/src/plugins/object_viewer/particle_system/particle_editor.cpp +++ b/code/studio/src/plugins/object_viewer/particle_system/particle_editor.cpp @@ -105,7 +105,7 @@ NL3D::CParticleSystemModel *CParticleEditor::getModelFromPS(NL3D::CParticleSyste void CParticleEditor::loadWorkspace(const std::string &fullPath) { // Add to the path - std::unique_ptr newPW(new CParticleWorkspace); + CUniquePtr newPW(new CParticleWorkspace); newPW->init(fullPath); // save empty workspace diff --git a/code/studio/src/plugins/object_viewer/particle_system/particle_node.cpp b/code/studio/src/plugins/object_viewer/particle_system/particle_node.cpp index c85e2e4b6..084358f52 100644 --- a/code/studio/src/plugins/object_viewer/particle_system/particle_node.cpp +++ b/code/studio/src/plugins/object_viewer/particle_system/particle_node.cpp @@ -193,7 +193,7 @@ void CWorkspaceNode::createEmptyPS() NL3D::CParticleSystem emptyPS; NL3D::CParticleSystemShape *pss = new NL3D::CParticleSystemShape; pss->buildFromPS(emptyPS); - std::unique_ptr sb(new NL3D::CShapeBank); + CUniquePtr sb(new NL3D::CShapeBank); std::string shapeName = NLMISC::CFile::getFilename(_RelativePath); sb->add(shapeName, pss); NL3D::CShapeBank *oldSB = Modules::psEdit().getScene()->getShapeBank(); @@ -272,7 +272,7 @@ bool CWorkspaceNode::loadPS() throw(NLMISC::EStream) // collapse name inputFile.open(getFullPath()); ss.serial(inputFile); - std::unique_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 = Modules::psEdit().getScene()->getShapeBank(); diff --git a/code/studio/src/plugins/object_viewer/particle_system/particle_workspace_dialog.h b/code/studio/src/plugins/object_viewer/particle_system/particle_workspace_dialog.h index 7dfc4e781..92afb02e3 100644 --- a/code/studio/src/plugins/object_viewer/particle_system/particle_workspace_dialog.h +++ b/code/studio/src/plugins/object_viewer/particle_system/particle_workspace_dialog.h @@ -123,8 +123,8 @@ private: QAction *_lod2Action; QAction *_externIDAction; - std::unique_ptr _LocatedCopy; - std::unique_ptr _LocatedBindableCopy; + CUniquePtr _LocatedCopy; + CUniquePtr _LocatedBindableCopy; CParticleTreeItem *_currentItem; From dbba511ee7ddbb298385194a22fcfdc17f016552 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 12:30:57 +0100 Subject: [PATCH 12/39] Changed: Replace a lot of const char* by std::string parameters --HG-- branch : develop --- code/nel/include/nel/ligo/primitive.h | 49 +++++---- code/nel/include/nel/misc/i_xml.h | 20 ++-- code/nel/include/nel/misc/o_xml.h | 12 +-- code/nel/include/nel/misc/stream.h | 22 ++--- code/nel/src/ligo/primitive.cpp | 99 +++++++++---------- code/nel/src/misc/i_xml.cpp | 34 +++---- code/nel/src/misc/o_xml.cpp | 35 +++---- .../world_editor/world_editor/action.h | 4 +- .../world_editor/editor_primitive.cpp | 20 ++-- .../world_editor/editor_primitive.h | 20 ++-- 10 files changed, 152 insertions(+), 163 deletions(-) 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/misc/i_xml.h b/code/nel/include/nel/misc/i_xml.h index 50fdddd04..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 @@ -198,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/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/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/src/ligo/primitive.cpp b/code/nel/src/ligo/primitive.cpp index 6e995eafc..c244a5092 100644 --- a/code/nel/src/ligo/primitive.cpp +++ b/code/nel/src/ligo/primitive.cpp @@ -42,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 ); @@ -50,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 ); @@ -69,20 +69,20 @@ void XMLError (xmlNodePtr xmlNode, const char *filename, const char *format, ... // *************************************************************************** -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); 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)) @@ -96,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)) @@ -109,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)) @@ -130,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)) @@ -151,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)) @@ -198,7 +198,7 @@ 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); @@ -220,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)) @@ -236,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; @@ -248,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; @@ -390,7 +385,7 @@ bool CPrimZone::contains (const NLMISC::CVector &v, const std::vector::const_iterator ite = _Properties.find (property_name); @@ -1328,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); @@ -1342,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; @@ -1356,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; @@ -1364,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; @@ -1378,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; @@ -1386,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; @@ -1400,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; @@ -1422,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; @@ -1430,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; @@ -1444,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; @@ -1472,7 +1467,7 @@ bool IPrimitive::removeProperty (uint index) // *************************************************************************** -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); @@ -1646,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) @@ -1658,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 (); @@ -1919,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) @@ -2116,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"); @@ -2150,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); @@ -2462,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); @@ -2535,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); @@ -2548,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/misc/i_xml.cpp b/code/nel/src/misc/i_xml.cpp index 719d5f359..e3d6f19a6 100644 --- a/code/nel/src/misc/i_xml.cpp +++ b/code/nel/src/misc/i_xml.cpp @@ -715,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() ); @@ -744,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); } } @@ -769,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; @@ -789,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); } @@ -902,7 +902,7 @@ bool CIXml::xmlPopInternal () // *************************************************************************** -bool CIXml::xmlSetAttribInternal (const char *attribName) +bool CIXml::xmlSetAttribInternal (const std::string &attribName) { nlassert( isReading() ); @@ -951,7 +951,7 @@ bool CIXml::xmlBreakLineInternal () // *************************************************************************** -bool CIXml::xmlCommentInternal (const char * /* comment */) +bool CIXml::xmlCommentInternal (const std::string &/* comment */) { // Ok return true; @@ -959,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; } @@ -973,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; } @@ -1015,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); @@ -1053,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 @@ -1073,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; @@ -1095,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; @@ -1109,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; diff --git a/code/nel/src/misc/o_xml.cpp b/code/nel/src/misc/o_xml.cpp index ec121b2b5..2228b24dc 100644 --- a/code/nel/src/misc/o_xml.cpp +++ b/code/nel/src/misc/o_xml.cpp @@ -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(); @@ -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/ryzom/tools/leveldesign/world_editor/world_editor/action.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h index 2e5fdb9a9..6752add5c 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h @@ -645,7 +645,7 @@ class CActionSetPrimitivePropertyString : public IAction public: // Constructor - CActionSetPrimitivePropertyString (const CDatabaseLocatorPointer &locator, const char *propertyName, const char *newValue, bool _default); + CActionSetPrimitivePropertyString (const CDatabaseLocatorPointer &locator, const std::string &propertyName, const std::string &newValue, bool _default); private: @@ -668,7 +668,7 @@ class CActionSetPrimitivePropertyStringArray : public IAction public: // Constructor - CActionSetPrimitivePropertyStringArray (const CDatabaseLocatorPointer &locator, const char *propertyName, const std::vector &newValue, bool _default); + CActionSetPrimitivePropertyStringArray (const CDatabaseLocatorPointer &locator, const std::string &propertyName, const std::vector &newValue, bool _default); private: diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp index ff40cf290..7ce3ae65e 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp @@ -742,14 +742,14 @@ IPrimitive *CPrimNodeEditor::copy () const return new CPrimNodeEditor (*this); } -bool CPrimNodeEditor::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) +bool CPrimNodeEditor::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config) { bool ret = CPrimNode::read(xmlNode, filename, version, config); IPrimitiveEditor::postReadCallback(this); return ret; } -void CPrimNodeEditor::write (xmlNodePtr xmlNode, const char *filename) const +void CPrimNodeEditor::write (xmlNodePtr xmlNode, const std::string &filename) const { IPrimitiveEditor::preWriteCallback(this); CPrimNode::write(xmlNode, filename); @@ -770,14 +770,14 @@ IPrimitive *CPrimPointEditor::copy () const return new CPrimPointEditor (*this); } -bool CPrimPointEditor::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) +bool CPrimPointEditor::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config) { bool ret = CPrimPoint::read(xmlNode, filename, version, config); IPrimitiveEditor::postReadCallback(this); return ret; } -void CPrimPointEditor::write (xmlNodePtr xmlNode, const char *filename) const +void CPrimPointEditor::write (xmlNodePtr xmlNode, const std::string &filename) const { IPrimitiveEditor::preWriteCallback(this); CPrimPoint::write(xmlNode, filename); @@ -797,14 +797,14 @@ IPrimitive *CPrimPathEditor::copy () const return new CPrimPathEditor (*this); } -bool CPrimPathEditor::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) +bool CPrimPathEditor::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config) { bool ret = CPrimPath::read(xmlNode, filename, version, config); IPrimitiveEditor::postReadCallback(this); return ret; } -void CPrimPathEditor::write (xmlNodePtr xmlNode, const char *filename) const +void CPrimPathEditor::write (xmlNodePtr xmlNode, const std::string &filename) const { IPrimitiveEditor::preWriteCallback(this); CPrimPath::write(xmlNode, filename); @@ -825,14 +825,14 @@ IPrimitive *CPrimZoneEditor::copy () const return new CPrimZoneEditor (*this); } -bool CPrimZoneEditor::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) +bool CPrimZoneEditor::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config) { bool ret = CPrimZone::read(xmlNode, filename, version, config); IPrimitiveEditor::postReadCallback(this); return ret; } -void CPrimZoneEditor::write (xmlNodePtr xmlNode, const char *filename) const +void CPrimZoneEditor::write (xmlNodePtr xmlNode, const std::string &filename) const { IPrimitiveEditor::preWriteCallback(this); CPrimZone::write(xmlNode, filename); @@ -857,14 +857,14 @@ NLLIGO::IPrimitive *CPrimAliasEditor::copy () const return new CPrimAliasEditor(*this); } -bool CPrimAliasEditor::read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) +bool CPrimAliasEditor::read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config) { bool ret = CPrimAlias::read(xmlNode, filename, version, config); IPrimitiveEditor::postReadCallback(this); return ret; } -void CPrimAliasEditor::write (xmlNodePtr xmlNode, const char *filename) const +void CPrimAliasEditor::write (xmlNodePtr xmlNode, const std::string &filename) const { IPrimitiveEditor::preWriteCallback(this); CPrimAlias::write(xmlNode, filename); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.h index 5939a0ece..e5c2d5f88 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.h @@ -248,9 +248,9 @@ public: // From IPrimitive virtual NLLIGO::IPrimitive *copy () const; // Read the primitive, to post call the CPrimitiveEditor load method - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, NLLIGO::CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, NLLIGO::CLigoConfig &config); // Write the primitive, to pre call the CPrimitiveEditor load method - virtual void write (xmlNodePtr xmlNode, const char *filename) const; + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; // Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const; @@ -293,9 +293,9 @@ public: // From IClassable virtual NLLIGO::IPrimitive *copy () const; // Read the primitive, to post call the CPrimitiveEditor load method - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, NLLIGO::CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, NLLIGO::CLigoConfig &config); // Write the primitive, to pre call the CPrimitiveEditor load method - virtual void write (xmlNodePtr xmlNode, const char *filename) const; + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; // Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const; @@ -338,9 +338,9 @@ public: // From IPrimitive virtual NLLIGO::IPrimitive *copy () const; // Read the primitive, to post call the CPrimitiveEditor load method - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, NLLIGO::CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, NLLIGO::CLigoConfig &config); // Write the primitive, to pre call the CPrimitiveEditor load method - virtual void write (xmlNodePtr xmlNode, const char *filename) const; + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; // Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const; @@ -385,9 +385,9 @@ public: // From IPrimitive virtual NLLIGO::IPrimitive *copy () const; // Read the primitive, to post call the CPrimitiveEditor load method - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, NLLIGO::CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, NLLIGO::CLigoConfig &config); // Write the primitive, to pre call the CPrimitiveEditor load method - virtual void write (xmlNodePtr xmlNode, const char *filename) const; + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; // Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const; @@ -430,9 +430,9 @@ public: // From IPrimitive virtual NLLIGO::IPrimitive *copy () const; // Read the primitive, to post call the CPrimitiveEditor load method - virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, NLLIGO::CLigoConfig &config); + virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, NLLIGO::CLigoConfig &config); // Write the primitive, to pre call the CPrimitiveEditor load method - virtual void write (xmlNodePtr xmlNode, const char *filename) const; + virtual void write (xmlNodePtr xmlNode, const std::string &filename) const; // Callback called when the primitive is updated, giving a chance to track the primitive's modifications during the loading virtual void onModifyPrimitive (NLLIGO::CPrimitives &primitives) const; From c716c48fdbd903355b50bdedf6b7dd15493068c8 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 12:33:44 +0100 Subject: [PATCH 13/39] Fixed: Compilation --HG-- branch : develop --- code/nel/src/misc/common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 3f39ab86a..1ae3f44fb 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -1535,7 +1535,7 @@ static bool openDocWithExtension (const std::string &document, const std::string if (command.empty()) { - nlwarning("Unable to open %s", document); + nlwarning("Unable to open %s", document.c_str()); return false; } From 22de830c2639f1e03b27373f1fb44910188e3ca8 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 12:36:04 +0100 Subject: [PATCH 14/39] Changed: Check return code of WaitForSingleObject and log error --HG-- branch : develop --- code/nel/src/misc/common.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 1ae3f44fb..ee9e84512 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -1012,20 +1012,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 From 5658cad02e9bba95acadd0cdb43055db974639aa Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 13:01:27 +0100 Subject: [PATCH 15/39] Changed: Convert std::string <> TCHAR --HG-- branch : develop --- .../3d/object_viewer/particle_tree_ctrl.cpp | 3 ++- .../3d/plugin_max/nel_export/progress.cpp | 3 ++- .../georges_dll/edit_list_ctrl.cpp | 2 +- .../world_editor/file_dialog_ex.cpp | 25 ++++++++++++++++--- .../DialogFlags.cpp | 12 ++++++--- .../world_editor_sound_plugin/DialogFlags.cpp | 18 +++++++------ 6 files changed, 44 insertions(+), 19 deletions(-) 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 49eede1c9..332a5163e 100644 --- a/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp +++ b/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp @@ -1528,7 +1528,8 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws) CFileDialog fd(TRUE, _T(".ps"), _T("*.ps"), OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST, szFilter, this); const uint MAX_NUM_CHAR = 65536; TCHAR filenamesBuf[MAX_NUM_CHAR]; - _tcscpy(filenamesBuf, _T("*.ps")); + _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) 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 8a8973154..17b3fab2a 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/progress.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/progress.cpp @@ -62,7 +62,8 @@ INT_PTR CALLBACK CalculatingDialogCallback ( (((uint32)TimeLeft)/60)%60, (((uint32)TimeLeft))%60 ); if (pClass->bCancelCalculation) - _tcscpy (temp, _T("INTERRUPTED - Finishing current object...")); + _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); } diff --git a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp index 4efdf0c16..0b16abd4f 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp @@ -312,7 +312,7 @@ LRESULT CMyListCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) Ctrl->getBrowseInfo (Ctrl->Item, Ctrl->SubItem, defExt, defFilename, defDir, filter); TCHAR buffer[MAX_PATH]; - _tcscpy(buffer, utf8ToTStr(defDir)); + _tcscpy_s(buffer, MAX_PATH, utf8ToTStr(defDir)); CFileDialog dlgFile (TRUE, utf8ToTStr(defExt), utf8ToTStr(defFilename), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, utf8ToTStr(filter), theApp.m_pMainWnd); dlgFile.m_ofn.lpstrInitialDir = buffer; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp index 706c4053e..aa23e4013 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp @@ -73,9 +73,19 @@ INT_PTR CFileDialogEx::DoModal () if ((result = CFileDialog::DoModal ()) == IDOK) { // Update the path - std::string newPath = tStrToUtf8(GetPathName ()); - newPath = NLMISC::CFile::getPath (newPath); - RegSetValueEx (hKey, utf8ToTStr(_FileType), 0, REG_SZ, (LPBYTE)newPath.c_str (), newPath.size ()+1); + std::string newPath = NLMISC::CFile::getPath (tStrToUtf8(GetPathName())); + +#ifdef _UNICODE + ucstring tmp; + tmp.fromUtf8(newPath); + const uint cs = 2; +#else + std::stringg tmp = newPath; + const uint cs = 1; +#endif + uint length = (tmp.length() + 1) * cs; + + RegSetValueEx (hKey, utf8ToTStr(_FileType), 0, REG_SZ, (LPBYTE)tmp.c_str(), length); // Update the path list set oldPath; @@ -91,7 +101,14 @@ INT_PTR CFileDialogEx::DoModal () uint index = 0; while (ite != oldPath.end ()) { - RegSetValueEx (hKey, utf8ToTStr(toString(index)), 0, REG_SZ, (LPBYTE)ite->c_str (), ite->size ()+1); +#ifdef _UNICODE + tmp.fromUtf8(*ite); +#else + tmp = *ite; +#endif + length = (tmp.length() + 1) * cs; + + RegSetValueEx (hKey, utf8ToTStr(toString(index)), 0, REG_SZ, (LPBYTE)tmp.c_str (), length); ite++; index++; } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/DialogFlags.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/DialogFlags.cpp index 54184c45a..12c3d9b88 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/DialogFlags.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/DialogFlags.cpp @@ -318,7 +318,7 @@ void CDialogFlags::loadEntityDisplayInfoToRegistry(TEntityDisplayInfoVect &infos if (infos[k].Value == value) { int r, g, b, visible; - if (sscanf((const char *) dataStr, "%d, %d, %d, visible = %d", &r, &g, &b, &visible) == 4) + if (_stscanf((const TCHAR *) dataStr, _T("%d, %d, %d, visible = %d"), &r, &g, &b, &visible) == 4) { infos[k].Color = CRGBA(r, g, b); infos[k].Visible = visible != 0; @@ -342,10 +342,14 @@ void CDialogFlags::saveEntityDisplayInfoToRegistry(const TEntityDisplayInfoVect { for(uint k = 0; k < infos.size(); ++k) { - char colorStr[128]; CRGBA color = infos[k].Color; - sprintf(colorStr, "%d, %d, %d, visible = %d", (int) color.R, (int) color.G, (int) color.B, (int) (infos[k].Visible ? 1 : 0)); - LONG result = RegSetValueEx(hKey, utf8ToTStr(toString(infos[k].Value)), 0, REG_SZ, (const BYTE *) colorStr, strlen(colorStr)); + + TCHAR colorStr[32]; + _stprintf_s(colorStr, 32, _T("%d, %d, %d, visible = %d"), (int) color.R, (int) color.G, (int) color.B, (int) (infos[k].Visible ? 1 : 0)); + + TCHAR id[16]; + + LONG result = RegSetValueEx(hKey, _itot(infos[k].Value, id, 10), 0, REG_SZ, (const BYTE *)colorStr, (_tcslen(colorStr) + 1)*sizeof(TCHAR)); if (result != ERROR_SUCCESS) { nlwarning("Couldn't write registry key for entity % color", infos[k].Name); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/DialogFlags.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/DialogFlags.cpp index a83578c9f..55cbbd25c 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/DialogFlags.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/DialogFlags.cpp @@ -225,7 +225,11 @@ void CDialogFlags::OnTimer(UINT_PTR nIDEvent) c = _SbList.GetItemCount(); for (i=0; i Date: Sat, 10 Dec 2016 13:02:26 +0100 Subject: [PATCH 16/39] Changed: NeL helpers to launch an external editor --HG-- branch : develop --- .../world_editor/external_editor.cpp | 57 +++++++++---------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp index e17165349..8e20608e6 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp @@ -34,19 +34,23 @@ bool EditExternalText (const std::string &editor, std::string &text, const std:: { bool status = false; // Create a temporary file - char dir[512]; - if (getcwd (dir, 512)) + std::string dir = CPath::getCurrentPath(); + + if (!dir.empty()) { // Build a temporary filename string tempFilename; uint i = 0; + do - tempFilename = string(dir)+"/~tmp"+toString (i++)+"."+ext; + { + tempFilename = string(dir) + "/~tmp" + toString(i++) + "." + ext; + } while (NLMISC::CFile::isExists(tempFilename)); // Fill the temp file bool saved = false; - FILE *file = fopen (tempFilename.c_str(), "w"); + FILE *file = nlfopen (tempFilename, "w"); if (file) { saved = fputs (text.c_str(), file) != EOF; @@ -54,41 +58,32 @@ bool EditExternalText (const std::string &editor, std::string &text, const std:: } // Hide the file - SetFileAttributes (tempFilename.c_str(), FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM); + SetFileAttributes (utf8ToTStr(tempFilename), FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM); // Open the temp file with a text editor if (saved) { - STARTUPINFO si; - PROCESS_INFORMATION pi; - memset(&si, 0, sizeof(si)); - memset(&pi, 0, sizeof(pi)); - si.cb = sizeof(si); - char cmdLine[1024]; - strncpy (cmdLine, ("\""+editor+"\" \""+tempFilename+"\"").c_str(), sizeof(cmdLine)-1); - if (CreateProcess(editor.c_str (), cmdLine, NULL, NULL, FALSE, 0, NULL, dir, &si, &pi)) + if (launchProgramAndWaitForResult(editor, tempFilename)) { - if (WaitForSingleObject (pi.hProcess, INFINITE) == WAIT_OBJECT_0) + // Open the file.. + std::string tempText; + FILE *file = nlfopen (tempFilename.c_str(), "r"); + if (file) { - // Open the file.. - std::string tempText; - FILE *file = fopen (tempFilename.c_str(), "r"); - if (file) + // Read the new file + char buffer[513]; + int red; + while (red=fread (buffer, 1, 512, file)) { - // Read the new file - char buffer[513]; - int red; - while (red=fread (buffer, 1, 512, file)) - { - buffer[red] = 0; - tempText += buffer; - } - fclose (file); - - // Return the text - text = tempText; - status = true; + buffer[red] = 0; + tempText += buffer; } + + fclose (file); + + // Return the text + text = tempText; + status = true; } } } From 699680ac4a1b93e12d4936b38ee8d97da6639f42 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 13:08:39 +0100 Subject: [PATCH 17/39] Changed: Use addSlashR to replace \n by \r\n --HG-- branch : develop --- .../leveldesign/georges_dll/base_dialog.cpp | 16 ++-------------- .../tools/leveldesign/georges_dll/base_dialog.h | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp index a2cf3c559..de8ccdf68 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp @@ -230,21 +230,9 @@ BOOL CBaseDialog::PreTranslateMessage(MSG* pMsg) return CDialog::PreTranslateMessage(pMsg); } -void CBaseDialog::setEditTextMultiLine (CEdit &edit, const char *text) +void CBaseDialog::setEditTextMultiLine (CEdit &edit, const std::string &text) { - string temp; - uint size = strlen (text); - temp.reserve (2*size); - bool previousR=false; - for (uint c=0; c Date: Sat, 10 Dec 2016 13:09:16 +0100 Subject: [PATCH 18/39] Changed: Already a std::string --HG-- branch : develop --- code/ryzom/client/src/entities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index e49761e01..5deeb437c 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -1766,7 +1766,7 @@ void CEntityManager::dumpXML(class NLMISC::IStream &f) // Add a comment // f.xmlComment();//toString("Describ the entity in the slot %d.", i).c_str()); // Start the opening of a new node named Identity - f.xmlPush(toString("Entity%d", i).c_str()); + f.xmlPush(toString("Entity%d", i)); if(_Entities[i]) { From f0c5b7ea40dcefd1f660aed2c1fd4487511cca16 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 13:43:00 +0100 Subject: [PATCH 19/39] Changed: Use TCHAR functions --HG-- branch : develop --- code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp | 2 +- code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 73337e3a5..2242c0684 100644 --- a/code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp +++ b/code/nel/tools/3d/object_viewer/located_bindable_dialog.cpp @@ -764,7 +764,7 @@ void CLocatedBindableDialog::updateZBias() m_ZBias.GetWindowText(value); 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); } 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 332a5163e..bf382f1e4 100644 --- a/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp +++ b/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp @@ -1147,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); From 94bf8fd54e4874c5ae854d87e1c66e99b3a54116 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 14:21:20 +0100 Subject: [PATCH 20/39] Changed: Use TCHAR functions --HG-- branch : develop --- .../3d/object_viewer/particle_tree_ctrl.cpp | 1 + .../3d/object_viewer/snapshot_tool_dlg.cpp | 6 ++--- .../object_viewer_exe/object_viewer_exe.cpp | 22 +++++++++---------- .../nel_patch_lib/nel_patch_mesh.cpp | 5 ++++- .../world_editor/world_editor/export_dlg.cpp | 2 +- .../world_editor/file_dialog_ex.cpp | 22 +++++-------------- 6 files changed, 25 insertions(+), 33 deletions(-) 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 bf382f1e4..daad7864a 100644 --- a/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp +++ b/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp @@ -1526,6 +1526,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws) { 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; TCHAR filenamesBuf[MAX_NUM_CHAR]; _tcscpy_s(filenamesBuf, MAX_NUM_CHAR, _T("*.ps")); 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 b4874ff29..64b88c6fe 100644 --- a/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp @@ -210,8 +210,8 @@ void CSnapshotToolDlg::toRegistry() HKEY hKey; if (RegCreateKey(HKEY_CURRENT_USER, NEL_OV_SNAPSHOT_TOOL_REGKEY, &hKey)==ERROR_SUCCESS) { - RegSetValueEx(hKey, _T("InputPath"), 0, REG_SZ, (BYTE*) (LPCTSTR) m_InputPath, m_InputPath.GetLength() + 1); - RegSetValueEx(hKey, _T("OutputPath"), 0, REG_SZ, (BYTE*) (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) { @@ -221,7 +221,7 @@ void CSnapshotToolDlg::toRegistry() filters += filter; } - RegSetValueEx(hKey, _T("Filters"), 0, REG_SZ, (BYTE*) (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 width = (DWORD) m_OutputWidth; 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/plugin_max/nel_patch_lib/nel_patch_mesh.cpp b/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.cpp index 4aae66304..436dd45ea 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 @@ -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); } } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/export_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/export_dlg.cpp index 6460dc3f1..7f290b784 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/export_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/export_dlg.cpp @@ -176,7 +176,7 @@ bool CExportDlg::callChoosePathDlg(CString &dest) const bi.lpfn = expBrowseCallbackProc; TCHAR sDir[512]; - _tcscpy(sDir, (LPCTSTR)RefZoneDir); + _tcscpy_s(sDir, 512, (LPCTSTR)RefZoneDir); bi.lParam = (LPARAM)sDir; bi.iImage = 0; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp index aa23e4013..47128cdb5 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp @@ -75,17 +75,10 @@ INT_PTR CFileDialogEx::DoModal () // Update the path std::string newPath = NLMISC::CFile::getPath (tStrToUtf8(GetPathName())); -#ifdef _UNICODE - ucstring tmp; - tmp.fromUtf8(newPath); - const uint cs = 2; -#else - std::stringg tmp = newPath; - const uint cs = 1; -#endif - uint length = (tmp.length() + 1) * cs; + TCHAR buffer[MAX_PATH]; + _tcscpy_s(buffer, MAX_PATH, utf8ToTStr(newPath)); - RegSetValueEx (hKey, utf8ToTStr(_FileType), 0, REG_SZ, (LPBYTE)tmp.c_str(), length); + RegSetValueEx (hKey, utf8ToTStr(_FileType), 0, REG_SZ, (LPBYTE)buffer, (_tcslen(buffer) + 1) * sizeof(TCHAR)); // Update the path list set oldPath; @@ -101,14 +94,9 @@ INT_PTR CFileDialogEx::DoModal () uint index = 0; while (ite != oldPath.end ()) { -#ifdef _UNICODE - tmp.fromUtf8(*ite); -#else - tmp = *ite; -#endif - length = (tmp.length() + 1) * cs; + _tcscpy_s(buffer, MAX_PATH, utf8ToTStr(*ite)); - RegSetValueEx (hKey, utf8ToTStr(toString(index)), 0, REG_SZ, (LPBYTE)tmp.c_str (), length); + RegSetValueEx (hKey, utf8ToTStr(toString(index)), 0, REG_SZ, (LPBYTE)buffer, (_tcslen(buffer) + 1) * sizeof(TCHAR)); ite++; index++; } From 5d35bb8717b0e2da12ccfa9fd0ca9a82adf1298d Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 10 Dec 2016 18:56:44 +0200 Subject: [PATCH 21/39] Fixed: Protocol-less url in windows --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 35 +++++++++++---------------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index a67c8b8e8..f370813b0 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -4625,34 +4625,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()) From fe72e1c8d31e1447814bc79ad66eb891a7840d08 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 18:15:01 +0100 Subject: [PATCH 22/39] Fixed: Compilation of World Editor in Unicode --HG-- branch : develop --- .../world_editor/world_editor/action.cpp | 14 +- .../world_editor/world_editor/action.h | 8 +- .../world_editor/builder_zone.cpp | 4 +- .../world_editor/world_editor/builder_zone.h | 4 +- .../world_editor/dialog_properties.cpp | 79 ++++----- .../world_editor/world_editor/display.cpp | 4 +- .../world_editor/editor_primitive.cpp | 6 +- .../world_editor/editor_primitive.h | 2 +- .../world_editor/world_editor/main_frm.cpp | 156 +++++++++-------- .../world_editor/world_editor/main_frm.h | 14 +- .../world_editor/world_editor/my_list_box.cpp | 4 +- .../world_editor/plugin_interface.h | 6 +- .../world_editor/project_settings.cpp | 18 +- .../world_editor/world_editor/tools_logic.cpp | 50 +++--- .../world_editor/world_editor/tools_logic.h | 2 +- .../world_editor/world_editor/tools_zone.cpp | 50 +++--- .../world_editor/type_manager_dlg.cpp | 10 +- .../world_editor/type_sel_dlg.cpp | 4 +- .../world_editor/world_editor.cpp | 161 ++++-------------- .../world_editor/world_editor/world_editor.h | 28 ++- .../world_editor/world_editor_doc.cpp | 50 +++--- .../world_editor/world_editor_doc.h | 10 +- 22 files changed, 288 insertions(+), 396 deletions(-) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/action.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/action.cpp index b288f9f0c..5b6b45716 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/action.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/action.cpp @@ -233,7 +233,7 @@ bool CActionLigoResize::redo () // CActionImportPrimitive // *************************************************************************** -CActionImportPrimitive::CActionImportPrimitive (const char *oldPrimFile) +CActionImportPrimitive::CActionImportPrimitive (const std::string &oldPrimFile) { _Filename = oldPrimFile; _FirstLoad = true; @@ -549,7 +549,7 @@ bool CActionImportPrimitive::redo () // CActionLoadPrimitive // *************************************************************************** -CActionLoadPrimitive::CActionLoadPrimitive (const char *oldPrimFile) +CActionLoadPrimitive::CActionLoadPrimitive(const std::string &oldPrimFile) { _Filename = oldPrimFile; _FirstLoad = true; @@ -2156,7 +2156,7 @@ bool CActionDelete::redo () // CActionSetPrimitivePropertyString // *************************************************************************** -CActionSetPrimitivePropertyString::CActionSetPrimitivePropertyString (const CDatabaseLocatorPointer &locator, const char *propertyName, const char *newValue, bool _default) +CActionSetPrimitivePropertyString::CActionSetPrimitivePropertyString(const CDatabaseLocatorPointer &locator, const std::string &propertyName, const std::string &newValue, bool _default) { _PropertyName = propertyName; _PropertyNewValue = newValue; @@ -2238,7 +2238,7 @@ bool CActionSetPrimitivePropertyString::redo () // CActionSetPrimitivePropertyStringArray // *************************************************************************** -CActionSetPrimitivePropertyStringArray::CActionSetPrimitivePropertyStringArray (const CDatabaseLocatorPointer &locator, const char *propertyName, const std::vector &newValue, bool _default) +CActionSetPrimitivePropertyStringArray::CActionSetPrimitivePropertyStringArray (const CDatabaseLocatorPointer &locator, const std::string &propertyName, const std::vector &newValue, bool _default) { _PropertyName = propertyName; _PropertyNewValue = newValue; @@ -2312,7 +2312,7 @@ bool CActionSetPrimitivePropertyStringArray::redo () // CActionAddPrimitiveByClass // *************************************************************************** -CActionAddPrimitiveByClass::CActionAddPrimitiveByClass (const CDatabaseLocator &locator, const char *className, +CActionAddPrimitiveByClass::CActionAddPrimitiveByClass (const CDatabaseLocator &locator, const std::string &className, const NLMISC::CVector &initPos, float deltaPos, const std::vector initParameters) { @@ -2424,7 +2424,7 @@ bool CActionAddPrimitiveByClass::redo () // CActionAddLandscape // *************************************************************************** -CActionAddLandscape::CActionAddLandscape (const char *filename) +CActionAddLandscape::CActionAddLandscape (const std::string &filename) { _FirstTime = true; _Filename = filename; @@ -2469,7 +2469,7 @@ bool CActionAddLandscape::redo () if (_FirstTime) { // Load the file - getMainFrame ()->launchLoadingDialog (string("loading land ") + _Filename); + getMainFrame ()->launchLoadingDialog ("loading land " + _Filename); try { diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h index 6752add5c..55bebe5f6 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h @@ -54,7 +54,7 @@ class CActionAddLandscape : public IAction { public: // Landscape name - CActionAddLandscape (const char *name); + CActionAddLandscape (const std::string &name); private: @@ -150,7 +150,7 @@ class CActionImportPrimitive : public IAction public: // Constructor - CActionImportPrimitive (const char *oldPrimFile); + CActionImportPrimitive (const std::string &oldPrimFile); private: @@ -169,7 +169,7 @@ class CActionLoadPrimitive : public IAction public: // Constructor - CActionLoadPrimitive (const char *oldPrimFile); + CActionLoadPrimitive (const std::string &oldPrimFile); private: @@ -622,7 +622,7 @@ class CActionAddPrimitiveByClass : public IAction public: // Constructor - CActionAddPrimitiveByClass (const CDatabaseLocator &locator, const char *className, const NLMISC::CVector &initPos, float deltaPos, + CActionAddPrimitiveByClass (const CDatabaseLocator &locator, const std::string &className, const NLMISC::CVector &initPos, float deltaPos, const std::vector initParameters); private: diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.cpp index 63b1d545f..23a91a2cd 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.cpp @@ -698,7 +698,7 @@ uint32 CBuilderZone::countZones () } // --------------------------------------------------------------------------- -void CBuilderZone::snapshot (const char *fileName, uint sizeSource, bool grayscale) +void CBuilderZone::snapshot (const std::string &fileName, uint sizeSource, bool grayscale) { const CZoneRegion *pBZR = &(getDocument ()->getZoneRegion (_ZoneRegionSelected)); sint32 nMinX = pBZR->getMinX(); @@ -712,7 +712,7 @@ void CBuilderZone::snapshot (const char *fileName, uint sizeSource, bool graysca } // --------------------------------------------------------------------------- -void CBuilderZone::snapshotCustom (const char *fileName, uint width, uint height, bool keepRatio, uint sizeSource, bool grayscale) +void CBuilderZone::snapshotCustom (const std::string &fileName, uint width, uint height, bool keepRatio, uint sizeSource, bool grayscale) { if (_ZoneRegions.size() == 0) return; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.h index 105f40a94..aa3cf6c12 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.h @@ -176,8 +176,8 @@ public: void unload (uint32 i); void move (sint32 x, sint32 y); uint32 countZones (); - void snapshot (const char *fileName, uint sizeSource, bool grayscale); - void snapshotCustom (const char *fileName, uint width, uint height, bool keepRatio, uint sizeSource, bool grayscale); + void snapshot (const std::string &fileName, uint sizeSource, bool grayscale); + void snapshotCustom(const std::string &fileName, uint width, uint height, bool keepRatio, uint sizeSource, bool grayscale); void add (const NLMISC::CVector &worldPos); void addTransition (const NLMISC::CVector &worldPos); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp index 91b3d292d..2b0a88527 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp @@ -915,11 +915,11 @@ bool CDialogProperties::CWidget::fromParameter (const IProperty *property, const updateBoolean (); break; case CPrimitiveClass::CParameter::ConstString: - if (Parameter.Editable || ComboBox.SelectString(-1 ,propString->String.c_str ()) == CB_ERR) + if (Parameter.Editable || ComboBox.SelectString(-1, utf8ToTStr(propString->String)) == CB_ERR) { - ComboBox.SetWindowText(propString->String.c_str ()); - ComboBox.InsertString( -1, propString->String.c_str()); - ComboBox.SelectString(-1 ,propString->String.c_str ()); + ComboBox.SetWindowText(utf8ToTStr(propString->String)); + ComboBox.InsertString( -1, utf8ToTStr(propString->String)); + ComboBox.SelectString(-1, utf8ToTStr(propString->String)); } OriginalString = propString->String.c_str(); updateCombo (); @@ -953,7 +953,7 @@ bool CDialogProperties::CWidget::fromParameter (const IProperty *property, const updateBoolean (); break; case CPrimitiveClass::CParameter::ConstString: - ComboBox.SelectString(-1 ,result.c_str ()); + ComboBox.SelectString(-1, utf8ToTStr(result)); OriginalString = result.c_str(); updateCombo (); break; @@ -1159,18 +1159,14 @@ void CDialogProperties::CWidget::getValue (std::string &result) const else if (Parameter.Type == CPrimitiveClass::CParameter::ConstString) { // Get the text - CString str; - getWindowTextUTF8 (ComboBox, str); - result = (const char*)str; + getWindowTextUTF8 (ComboBox, result); } else { nlassert (Parameter.Type == CPrimitiveClass::CParameter::String); // Get the text - CString str; - getWindowTextUTF8 (EditBox, str); - result = (const char*)str; + getWindowTextUTF8 (EditBox, result); } } @@ -1183,29 +1179,23 @@ void CDialogProperties::CWidget::getValue (std::vector &result) con // Get the string result.clear (); - CString str; if (Parameter.Type == CPrimitiveClass::CParameter::StringArray) { - getWindowTextUTF8 (MultiLineEditBox, str); + std::string temp; + getWindowTextUTF8 (MultiLineEditBox, temp); // MultiLineEditBox.UnloadText(str); - const char *strP = str; - string dst; - while (*strP) + + // remove \r + temp = removeSlashR(temp); + + // append each line to result + explode(temp, std::string("\n"), result); + + // remove the last line if empty + if (!result.empty() && result.back().empty()) { - // New line ? - if (*strP == '\n') - { - result.push_back (dst); - dst.clear(); - } - else if (*strP != '\r') - { - dst += *strP; - } - strP++; + result.resize(result.size() - 1); } - if (!dst.empty()) - result.push_back (dst); } else { @@ -1216,7 +1206,7 @@ void CDialogProperties::CWidget::getValue (std::vector &result) con { CString str; ListEditBox.GetText( i, str); - result[i] = (const char*)str; + result[i] = tStrToUtf8(str); } } } @@ -1292,7 +1282,7 @@ void CDialogProperties::CWidget::updateCombo () DialogProperties->setDefaultValue (this, value); if (value != "") { - int index = ComboBox.FindString (-1, value.c_str()); + int index = ComboBox.FindString (-1, utf8ToTStr(value)); if (index != CB_ERR) ComboBox.SetCurSel (index); } @@ -1370,9 +1360,9 @@ bool CDialogProperties::isModified() // special case for editable combo box if ((*iteWid).Parameter.Type == CPrimitiveClass::CParameter::ConstString) { - CString text; + std::string text; getWindowTextUTF8 ((*iteWid).ComboBox, text); - if ((*iteWid).OriginalString.c_str() != text) + if ((*iteWid).OriginalString != text) { return true; } @@ -1631,17 +1621,22 @@ BOOL CDialogProperties::OnCommand(WPARAM wParam, LPARAM lParam) /* todo hulud remove CString oldValue; widget->EditBox.GetWindowText (oldValue);*/ - CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("default"), TRUE, widget->Parameter.FileExtension.c_str (), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("default"), TRUE, utf8ToTStr(widget->Parameter.FileExtension), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, utf8ToTStr(widget->Parameter.FileExtension+" (*."+widget->Parameter.FileExtension+")|*."+widget->Parameter.FileExtension+"|All Files (*.*)|*.*||"), getMainFrame ()); - if (widget->Parameter.Folder != "") + + TCHAR temp[MAX_PATH]; + + if (!widget->Parameter.Folder.empty()) { - dialog.m_ofn.lpstrInitialDir = widget->Parameter.Folder.c_str(); + _tcscpy_s(temp, MAX_PATH, utf8ToTStr(widget->Parameter.Folder)); + dialog.m_ofn.lpstrInitialDir = temp; } + if (dialog.DoModal() == IDOK) { CString str; str = dialog.GetFileTitle(); - setWindowTextUTF8 (widget->EditBox, str); + setWindowTextUTF8 (widget->EditBox, tStrToUtf8(str)); /* todo hulud remove if ((const char*)oldValue != str) @@ -1708,15 +1703,15 @@ BOOL CDialogProperties::OnCommand(WPARAM wParam, LPARAM lParam) if (!filename.empty ()) { // Open the file - if (!openFile (filename.c_str ())) + if (!openDoc (filename)) // Error - theApp.errorMessage ("Can't open the file %s", filename.c_str ()); + theApp.errorMessage ("Can't open the file %s", filename.c_str()); } else { // Error widget->getFilename (filename); - theApp.errorMessage ("Can't find the file %s", filename.c_str ()); + theApp.errorMessage ("Can't find the file %s", filename.c_str()); } } } @@ -1772,9 +1767,9 @@ BOOL CDialogProperties::OnCommand(WPARAM wParam, LPARAM lParam) widget->EditBox.GetWindowText (oldValue);*/ // String NULL ? - CString text; + std::string text; getWindowTextUTF8 (widget->EditBox, text); - widget->Default = (text == ""); + widget->Default = text.empty(); // Default ? if (widget->Default) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/display.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/display.cpp index e25addbae..5f149f01e 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/display.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/display.cpp @@ -318,7 +318,7 @@ void CDisplay::init (CMainFrame *pMF) } } - SetCurrentDirectory (pMF->_ExeDir.c_str()); + SetCurrentDirectory (utf8ToTStr(pMF->_ExeDir)); } // *************************************************************************** @@ -3554,7 +3554,7 @@ void CDisplay::DrawCollisionTexture(sint32 count, float x1, float y1) string dir = getDocument ()->getDataDir (); if (dir.empty()) dir = _MainFrame->_ExeDir; dir += "\\collisionmap\\"; - SetCurrentDirectory (dir.c_str()); + SetCurrentDirectory (utf8ToTStr(dir)); if(NLMISC::CFile::fileExists(Name+".tga") || NLMISC::CFile::fileExists(Name+".png")) { diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp index 7ce3ae65e..90d99b6d6 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.cpp @@ -886,7 +886,7 @@ CPrimBitmap::CPrimBitmap () // *************************************************************************** -void CPrimBitmap::init (const char *filename) +void CPrimBitmap::init (const std::string &filename) { // Set the name removePropertyByName ("filename"); @@ -926,12 +926,12 @@ NL3D::CTextureBlank *CPrimBitmap::getTexture () const } else { - theApp.errorMessage ("Can't read bitmap %s", filename.c_str ()); + theApp.errorMessage ("Can't read bitmap %s", filename.c_str()); } } catch (const Exception &e) { - theApp.errorMessage ("Error reading bitmap %s : %s", filename.c_str (), e.what ()); + theApp.errorMessage ("Error reading bitmap %s : %s", filename.c_str(), e.what ()); } } } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.h index e5c2d5f88..f3152a501 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/editor_primitive.h @@ -452,7 +452,7 @@ public: CPrimBitmap (); // Init - void init (const char *filename); + void init (const std::string &filename); // \name From IClassable NLMISC_DECLARE_CLASS (CPrimBitmap) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.cpp index 24096f690..a791e54ae 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.cpp @@ -569,12 +569,10 @@ void CMainFrame::stopPositionControl(IPluginCallback *plugin) } // *************************************************************************** -void CMainFrame::setExeDir (const char* str) +void CMainFrame::setExeDir (const std::string &str) { // AFX_MANAGE_STATE (AfxGetStaticModuleState()); - _ExeDir = str; - if ((str[strlen(str)-1] != '\\') || (str[strlen(str)-1] != '/')) - _ExeDir += "\\"; + _ExeDir = CPath::standardizePath(str); } // *************************************************************************** @@ -761,11 +759,11 @@ void CMainFrame::displayStatusBarInfo () string text; if (dispWnd->getActionHelp (text)) { - m_wndStatusBar.SetPaneText (0, text.c_str()); + m_wndStatusBar.SetPaneText (0, utf8ToTStr(text)); } else { - m_wndStatusBar.SetPaneText (0, sTmp.c_str()); + m_wndStatusBar.SetPaneText (0, utf8ToTStr(sTmp)); } //for (uint32 i = sTmp.size(); i < 10; ++i) // sTmp += " "; @@ -773,12 +771,12 @@ void CMainFrame::displayStatusBarInfo () // Write zone reference name if (dispWnd->getActionText (text)) { - m_wndStatusBar.SetPaneText (1, text.c_str()); + m_wndStatusBar.SetPaneText (1, utf8ToTStr(text)); } else { sTmp = _ZoneBuilder->getZoneName (x, y); - m_wndStatusBar.SetPaneText (1, sTmp.c_str()); + m_wndStatusBar.SetPaneText (1, utf8ToTStr(sTmp)); } // Write coordinates @@ -786,15 +784,15 @@ void CMainFrame::displayStatusBarInfo () sprintf(temp, "(%.3f , %.3f)", v.x, v.y); sTmp = temp; // sTmp = "( " + toString(v.x) + " , " + toString(v.y) + " )"; - m_wndStatusBar.SetPaneText (2, sTmp.c_str()); + m_wndStatusBar.SetPaneText (2, utf8ToTStr(sTmp)); // Write rot sTmp = "Rot(" + toString(_ZoneBuilder->getRot(x, y)) + ")"; - m_wndStatusBar.SetPaneText (3, sTmp.c_str()); + m_wndStatusBar.SetPaneText (3, utf8ToTStr(sTmp)); // Write flip sTmp = "Flip(" + toString(_ZoneBuilder->getFlip(x, y)) + ")"; - m_wndStatusBar.SetPaneText (4, sTmp.c_str()); + m_wndStatusBar.SetPaneText (4, utf8ToTStr(sTmp)); // Write selection if (Selection.size ()) @@ -806,7 +804,7 @@ void CMainFrame::displayStatusBarInfo () } else sTmp = "No selected primitive"; - m_wndStatusBar.SetPaneText (5, sTmp.c_str()); + m_wndStatusBar.SetPaneText (5, utf8ToTStr(sTmp)); // Write path of selected primitive if (Selection.size()) @@ -814,14 +812,14 @@ void CMainFrame::displayStatusBarInfo () else sTmp.clear(); - m_wndStatusBar.SetPaneText (6, sTmp.c_str()); + m_wndStatusBar.SetPaneText (6, utf8ToTStr(sTmp)); } // *************************************************************************** -void CMainFrame::displayInfo (const char *info) +void CMainFrame::displayInfo (const std::string &info) { - m_wndStatusBar.SetPaneText (6, info); + m_wndStatusBar.SetPaneText (6, utf8ToTStr(info)); } // *************************************************************************** @@ -860,7 +858,7 @@ void CMainFrame::uninit () } catch (const Exception& e) { - MessageBox (e.what(), "Warning"); + MessageBox (utf8ToTStr(e.what()), _T("Warning")); } } @@ -871,10 +869,10 @@ void CMainFrame::uninit () // *************************************************************************** void CMainFrame::onMenuFileOpenLogic () { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "prim", TRUE, "prim", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Primitives Files (*.prim)|*.prim||", this); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("prim"), TRUE, _T("prim"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("Primitives Files (*.prim)|*.prim||"), this); if (dialog.DoModal() == IDOK) { - launchLoadingDialog(string("loading prim zone ") + (LPCSTR)dialog.GetFileName()); + launchLoadingDialog(string("loading prim zone ") + tStrToUtf8(dialog.GetFileName())); // todo primitive load primZoneModified (); terminateLoadingDialog(); @@ -1453,7 +1451,7 @@ struct CViewerConfig if(f==NULL) { - fprintf(stderr,"can't open file '%s'\n",configFileName); + fprintf(stderr,"can't open file '%s'\n",configFileName.c_str()); } fprintf(f,"FullScreen = %d;\n",this->Windowed?0:1); @@ -1495,17 +1493,17 @@ struct CViewerConfig fprintf(f,"Zones = {\n"); for (i = 0; i < Zones.size(); ++i) if (i < (Zones.size()-1)) - fprintf(f,"\"%s\",\n", Zones[i]); + fprintf(f,"\"%s\",\n", Zones[i].c_str()); else - fprintf(f,"\"%s\"\n", Zones[i]); + fprintf(f,"\"%s\"\n", Zones[i].c_str()); fprintf(f,"};\n"); fprintf(f,"Ig = {\n"); for (i = 0; i < Igs.size(); ++i) if (i < (Igs.size()-1)) - fprintf(f,"\"%s\",\n", Igs[i]); + fprintf(f,"\"%s\",\n", Igs[i].c_str()); else - fprintf(f,"\"%s\"\n", Igs[i]); + fprintf(f,"\"%s\"\n", Igs[i].c_str()); fprintf(f,"};\n"); fclose(f); @@ -1618,12 +1616,12 @@ void CMainFrame::viewLand(bool withIgs) void CMainFrame::onProjectAddlandscape() { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "land", TRUE, "land", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "NeL Ligo Landscape Files (*.land)|*.land|All Files (*.*)|*.*||", this); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("land"), TRUE, _T("land"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("NeL Ligo Landscape Files (*.land)|*.land|All Files (*.*)|*.*||"), this); if (dialog.DoModal() == IDOK) { // Add the landscape in the project getDocument ()->beginModification (); - getDocument ()->addModification (new CActionAddLandscape (dialog.GetPathName())); + getDocument ()->addModification (new CActionAddLandscape (tStrToUtf8(dialog.GetPathName()))); getDocument ()->endModification (); // Update data @@ -1633,7 +1631,7 @@ void CMainFrame::onProjectAddlandscape() if (getDocument()->getDataDir() != "") return; - string path = dialog.GetPathName(); + string path = tStrToUtf8(dialog.GetPathName()); uint pos = path.rfind("\\"); if (pos == string::npos) @@ -1750,9 +1748,9 @@ void CMainFrame::onProjectSettings() // Get the new data path std::string oldDataDir = standardizePath (getDocument ()->getDataDir ().c_str ()); - std::string newDataDir = standardizePath (projectSettings.DataDirectory); + std::string newDataDir = standardizePath (tStrToUtf8(projectSettings.DataDirectory)); initLandscape |= (oldDataDir != newDataDir); - getDocument ()->setDataDir (projectSettings.DataDirectory); + getDocument ()->setDataDir (tStrToUtf8(projectSettings.DataDirectory)); // Init the landscape if (initLandscape) @@ -1802,12 +1800,12 @@ void CMainFrame::OnUpdateEditLogic(CCmdUI* pCmdUI) void CMainFrame::OnProjectImportPrim() { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "prim", TRUE, "prim", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Old NeL Ligo Prim Files (*.prim)|*.prim|All Files (*.*)|*.*||", this); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("prim"), TRUE, _T("prim"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("Old NeL Ligo Prim Files (*.prim)|*.prim|All Files (*.*)|*.*||"), this); if (dialog.DoModal() == IDOK) { // Add the landscape in the project getDocument ()->beginModification (); - getDocument ()->addModification (new CActionImportPrimitive (dialog.GetPathName())); + getDocument ()->addModification (new CActionImportPrimitive (tStrToUtf8(dialog.GetPathName()))); getDocument ()->endModification (); // Update data @@ -1819,8 +1817,8 @@ void CMainFrame::OnProjectImportPrim() void CMainFrame::OnProjectAddPrimitive() { - static char buffer[32000]; - CFileDialogEx dialog (BASE_REGISTRY_KEY, "primitive", TRUE, "primitive", NULL, OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "NeL Ligo Primitive Files (*.primitive)|*.primitive|All Files (*.*)|*.*||", this); + static TCHAR buffer[32000]; + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("primitive"), TRUE, _T("primitive"), NULL, OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("NeL Ligo Primitive Files (*.primitive)|*.primitive|All Files (*.*)|*.*||"), this); // increase result buffer size (for multi select) memset(buffer, 0, 32000); dialog.m_ofn.lpstrFile = buffer; @@ -1835,7 +1833,7 @@ void CMainFrame::OnProjectAddPrimitive() while (pos!=NULL) { - string path = dialog.GetNextPathName(pos); + string path = tStrToUtf8(dialog.GetNextPathName(pos)); if (!getDocument()->isPrimitiveLoaded(path)) getDocument ()->addModification (new CActionLoadPrimitive (path.c_str())); else @@ -2209,7 +2207,7 @@ void CMainFrame::setTransformMode (TTransformMode mode) // *************************************************************************** -void CMainFrame::deletePrimitive (bool subDelete, const char *actionName) +void CMainFrame::deletePrimitive (bool subDelete, const std::string &actionName) { list oldSelection; @@ -2629,7 +2627,7 @@ void CMainFrame::OnOpenFile (UINT nID) nlassert (nIDAppendMenu (MF_STRING, ID_EDIT_SELECT, "&Select\tF5"); - pMenu->AppendMenu (MF_STRING, ID_EDIT_TRANSLATE, "&Move\tF6"); - pMenu->AppendMenu (MF_STRING, ID_EDIT_ROTATE, "&Rotate\tF7"); - pMenu->AppendMenu (MF_STRING, ID_EDIT_TURN, "&Turn\tF8"); - pMenu->AppendMenu (MF_STRING, ID_EDIT_SCALE, "&Scale\tF9"); - pMenu->AppendMenu (MF_STRING, ID_EDIT_RADIUS, "&Radius\tF10"); + pMenu->AppendMenu (MF_STRING, ID_EDIT_SELECT, _T("&Select\tF5")); + pMenu->AppendMenu (MF_STRING, ID_EDIT_TRANSLATE, _T("&Move\tF6")); + pMenu->AppendMenu (MF_STRING, ID_EDIT_ROTATE, _T("&Rotate\tF7")); + pMenu->AppendMenu (MF_STRING, ID_EDIT_TURN, _T("&Turn\tF8")); + pMenu->AppendMenu (MF_STRING, ID_EDIT_SCALE, _T("&Scale\tF9")); + pMenu->AppendMenu (MF_STRING, ID_EDIT_RADIUS, _T("&Radius\tF10")); if (isSelectionLocked ()) - pMenu->AppendMenu (MF_STRING, ID_EDIT_ADD_POINT, "&Add points\tF11"); + pMenu->AppendMenu (MF_STRING, ID_EDIT_ADD_POINT, _T("&Add points\tF11")); // Check the good one pMenu->CheckMenuRadioItem (ID_EDIT_SELECT, isSelectionLocked ()?ID_EDIT_ADD_POINT:ID_EDIT_SCALE, ID_EDIT_SELECT+getTransformMode (), @@ -2666,35 +2664,35 @@ void CMainFrame::createContextMenu (CWnd *parent, const CPoint &point, bool tran } // Always a delete menu - pMenu->AppendMenu (MF_STRING, ID_EDIT_DELETE, "&Delete\tDel"); + pMenu->AppendMenu (MF_STRING, ID_EDIT_DELETE, _T("&Delete\tDel")); // Add properties menu - pMenu->AppendMenu (MF_STRING, ID_EDIT_PROPERTIES, "&Properties\tAlt+Enter"); + pMenu->AppendMenu (MF_STRING, ID_EDIT_PROPERTIES, _T("&Properties\tAlt+Enter")); // Select Children - pMenu->AppendMenu (MF_STRING, ID_EDIT_SELECT_CHILDREN, "&Select Children\tC"); + pMenu->AppendMenu (MF_STRING, ID_EDIT_SELECT_CHILDREN, _T("&Select Children\tC")); // Tree help - pMenu->AppendMenu (MF_STRING, ID_HELP_FINDER, "&Help\tF1"); + pMenu->AppendMenu (MF_STRING, ID_HELP_FINDER, _T("&Help\tF1")); // Add separator pMenu->AppendMenu (MF_SEPARATOR); - pMenu->AppendMenu (MF_STRING, ID_RENAME_SELECTED, "&Rename All Selected"); - pMenu->AppendMenu (MF_STRING, ID_REPAIR_SELECTED, "&Repair All Selected"); + pMenu->AppendMenu (MF_STRING, ID_RENAME_SELECTED, _T("&Rename All Selected")); + pMenu->AppendMenu (MF_STRING, ID_REPAIR_SELECTED, _T("&Repair All Selected")); // Add separator pMenu->AppendMenu (MF_SEPARATOR); // Add properties menu - pMenu->AppendMenu (MF_STRING, ID_VIEW_SHOW, "&Show\tS"); - pMenu->AppendMenu (MF_STRING, ID_VIEW_HIDE, "&Hide\tH"); + pMenu->AppendMenu (MF_STRING, ID_VIEW_SHOW, _T("&Show\tS")); + pMenu->AppendMenu (MF_STRING, ID_VIEW_HIDE, _T("&Hide\tH")); // Add separator pMenu->AppendMenu (MF_SEPARATOR); // Add expand / collapse menu - pMenu->AppendMenu (MF_STRING, ID_EDIT_EXPAND, "&Expand\tE"); - pMenu->AppendMenu (MF_STRING, ID_EDIT_COLLAPSE, "&Collapse\tR"); + pMenu->AppendMenu (MF_STRING, ID_EDIT_EXPAND, _T("&Expand\tE")); + pMenu->AppendMenu (MF_STRING, ID_EDIT_COLLAPSE, _T("&Collapse\tR")); // Only one selection ? if (Selection.size () == 1) @@ -2712,7 +2710,7 @@ void CMainFrame::createContextMenu (CWnd *parent, const CPoint &point, bool tran // For each child, add a create method for (uint i=0; iDynamicChildren.size (); i++) { - pMenu->AppendMenu (MF_STRING, ID_EDIT_CREATE_BEGIN+i, ("Add "+primClass->DynamicChildren[i].ClassName).c_str ()); + pMenu->AppendMenu (MF_STRING, ID_EDIT_CREATE_BEGIN+i, utf8ToTStr("Add " + primClass->DynamicChildren[i].ClassName)); } } @@ -2725,7 +2723,7 @@ void CMainFrame::createContextMenu (CWnd *parent, const CPoint &point, bool tran // For each child, add a create method for (uint i=0; iGeneratedChildren.size (); i++) { - pMenu->AppendMenu (MF_STRING, ID_EDIT_GENERATE_BEGIN+i, ("Generate "+primClass->GeneratedChildren[i].ClassName).c_str ()); + pMenu->AppendMenu (MF_STRING, ID_EDIT_GENERATE_BEGIN+i, utf8ToTStr("Generate "+primClass->GeneratedChildren[i].ClassName)); } } @@ -2749,7 +2747,7 @@ void CMainFrame::createContextMenu (CWnd *parent, const CPoint &point, bool tran for (i=0; iAppendMenu (MF_STRING, ID_EDIT_OPEN_FILE_BEGIN+i, ("Open "+NLMISC::CFile::getFilename (filenames[i])).c_str ()); + pMenu->AppendMenu (MF_STRING, ID_EDIT_OPEN_FILE_BEGIN+i, utf8ToTStr("Open " + NLMISC::CFile::getFilename (filenames[i]))); } } } @@ -3375,9 +3373,9 @@ void CMainFrame::OnHelpFinder() { //string filename = theApp.ExePath+"doc/"+className+".html"; string filename = theApp.DocPath+"/"+className+".html"; - if (!NLMISC::CFile::fileExists(filename) || !openFile (filename.c_str ())) + if (!NLMISC::CFile::fileExists(filename) || !openDoc (filename)) { - //openFile ((theApp.ExePath+"world_editor.html").c_str ()); + //openDoc (theApp.ExePath+"world_editor.html"); theApp.errorMessage ("Can't open the file %s", filename.c_str ()); } } @@ -3385,7 +3383,7 @@ void CMainFrame::OnHelpFinder() } else { - openFile ((theApp.ExePath+"world_editor.html").c_str ()); + openDoc((theApp.ExePath+"world_editor.html")); } } @@ -3719,7 +3717,7 @@ void CMainFrame::OnProjectForceiduniqueness() // End modifications doc->endModification (); - AfxMessageBox(NLMISC::toString("%u ids checked, %u non unique ID regenerated", ids.size()+nonUnique.size(), nonUnique.size()).c_str(), MB_OK); + AfxMessageBox(utf8ToTStr(NLMISC::toString("%u ids checked, %u non unique ID regenerated", ids.size()+nonUnique.size(), nonUnique.size())), MB_OK); } // *************************************************************************** @@ -3795,7 +3793,7 @@ void CMainFrame::OnViewCollisions() // *************************************************************************** // routines for the plugin -NLLIGO::IPrimitive *CMainFrame::createRootPluginPrimitive (const char *name) +NLLIGO::IPrimitive *CMainFrame::createRootPluginPrimitive (const std::string &name) { AFX_MANAGE_STATE(AfxGetAppModuleState()); @@ -3861,8 +3859,8 @@ void CMainFrame::getAllRootPluginPrimitive (std::vector &pr const NLLIGO::IPrimitive *CMainFrame::createPluginPrimitive ( - const char *className, - const char *primName, + const std::string &className, + const std::string &primName, const NLMISC::CVector &initPos, float deltaPos, const std::vector &initParameters, @@ -3982,7 +3980,7 @@ void CMainFrame::getWindowCoordinates(NLMISC::CVector &vmin, NLMISC::CVector &vm void CMainFrame::OnHelpHistory() { string filename = theApp.ExePath+"history.txt"; - if (!openFile (filename.c_str())) + if (!openDoc(filename)) { theApp.errorMessage ("Can't open the file %s", filename.c_str ()); } @@ -3995,13 +3993,13 @@ void CMainFrame::OnExportSnapshot() CCustomSnapshot snapShot (this); if (snapShot.DoModal () == IDOK) { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "image", FALSE, "tga", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Targa Files (*.tga)|*.tga|All Files (*.*)|*.*||", this); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("image"), FALSE, _T("tga"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("Targa Files (*.tga)|*.tga|All Files (*.*)|*.*||"), this); if (dialog.DoModal() == IDOK) { if (snapShot.FixedSize == 0) - _ZoneBuilder->snapshot (dialog.GetPathName(), (uint)theApp.Config.CellSize, snapShot.OutputRGB == 1); + _ZoneBuilder->snapshot (tStrToUtf8(dialog.GetPathName()), (uint)theApp.Config.CellSize, snapShot.OutputRGB == 1); else - _ZoneBuilder->snapshotCustom (dialog.GetPathName(), snapShot.Width, snapShot.Height, snapShot.KeepRatio != FALSE, + _ZoneBuilder->snapshotCustom (tStrToUtf8(dialog.GetPathName()), snapShot.Width, snapShot.Height, snapShot.KeepRatio != FALSE, (uint)theApp.Config.CellSize, snapShot.OutputRGB == 1); } } @@ -4241,14 +4239,14 @@ void CMainFrame::OnSavePosition() x = (sint32)floor(v.x / dispWnd->_CellSize); y = (sint32)floor(v.y / dispWnd->_CellSize); - str.Format( "[%s] X = %.3f, Y = %.3f\r\n", t.Format( "%m/%d/%y, %H:%M:%S" ), v.x, v.y ); + str.Format( _T("[%s] X = %.3f, Y = %.3f\r\n"), t.Format( "%m/%d/%y, %H:%M:%S" ), v.x, v.y ); - file.Open( "position.txt", ::CFile::modeCreate|::CFile::modeNoTruncate|::CFile::modeWrite|::CFile::typeText ); + file.Open( _T("position.txt"), ::CFile::modeCreate|::CFile::modeNoTruncate|::CFile::modeWrite|::CFile::typeText ); file.SeekToEnd(); file.WriteString( str ); file.Close(); - MessageBox( "Current coordinates saved in file position.txt", "Position saved", MB_OK ); + MessageBox( _T("Current coordinates saved in file position.txt"), _T("Position saved"), MB_OK ); } // *************************************************************************** @@ -4266,9 +4264,9 @@ void CMainFrame::OnDropFiles(HDROP hDropInfo) for (uint i=0 ; i 0) { // use system temp directory - char tmpPath[MAX_PATH]; - GetEnvironmentVariable("TMP", tmpPath, MAX_PATH); - strcat(tmpPath, "\\tmptool.txt"); + TCHAR tmpPath[MAX_PATH]; + GetEnvironmentVariable(_T("TMP"), tmpPath, MAX_PATH); + _tcscat(tmpPath, _T("\\tmptool.txt")); - FILE *f = nlfopen(tmpPath, "w"); + FILE *f = nlfopen(tStrToUtf8(tmpPath), "w"); if (f==NULL) infoMessage("Can't open file for writing !\n%s", tmpPath); @@ -4352,8 +4350,8 @@ void CMainFrame::OnMissionCompiler() return; } - char path[MAX_PATH]; - strcpy(path, var->asString().c_str()); + TCHAR path[MAX_PATH]; + _tcscpy(path, utf8ToTStr(var->asString())); SHELLEXECUTEINFO ExecuteInfo; memset(&ExecuteInfo, 0, sizeof(ExecuteInfo)); @@ -4361,8 +4359,8 @@ void CMainFrame::OnMissionCompiler() ExecuteInfo.cbSize = sizeof(ExecuteInfo); ExecuteInfo.fMask = 0; ExecuteInfo.hwnd = 0; - ExecuteInfo.lpVerb = "open"; - ExecuteInfo.lpFile = "mission_compiler_fe_r.exe"; + ExecuteInfo.lpVerb = _T("open"); + ExecuteInfo.lpFile = _T("mission_compiler_fe_r.exe"); ExecuteInfo.lpParameters = 0; ExecuteInfo.lpDirectory = path; ExecuteInfo.nShow = SW_SHOW; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.h index 97bda4584..427c82c06 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.h @@ -207,13 +207,13 @@ public: void setSelectionLocked (bool lock); // Delete selected primitives - void deletePrimitive (bool subDelete, const char *actionName); + void deletePrimitive (bool subDelete, const std::string &actionName); // Create a context menu for selection void createContextMenu (CWnd *parent, const CPoint &point, bool transformMode); // Display info in the status bar - void displayInfo (const char *info); + void displayInfo (const std::string &info); // Disactive / enable interaction void interaction (bool enable); @@ -258,8 +258,8 @@ public: /// The controled position NLMISC::CVector _PositionControl; - void setExeDir (const char* str); - void setDataDir (const char* str); + void setExeDir (const std::string &str); + void setDataDir (const std::string &str); void uninitTools(); void initTools(); void invalidateLandscape (); @@ -293,7 +293,7 @@ public: void startPositionControl(IPluginCallback *plugin, const NLMISC::CVector &initPos); void stopPositionControl(IPluginCallback *plugin); // functions to create/remove the Root Primitive for server actions - virtual NLLIGO::IPrimitive *createRootPluginPrimitive (const char *name); + virtual NLLIGO::IPrimitive *createRootPluginPrimitive (const std::string &name); virtual void deleteRootPluginPrimitive (void); virtual void getAllRootPluginPrimitive (std::vector &prims); /* @@ -302,8 +302,8 @@ public: */ // Create a plugin primitive const NLLIGO::IPrimitive *createPluginPrimitive ( - const char *className, - const char *primName, + const std::string &className, + const std::string &primName, const NLMISC::CVector &initPos, float deltaPos, const std::vector &initParameters, diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp index 3d39ae236..a071a4836 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp @@ -66,10 +66,10 @@ BOOL CMyListBox::OnCommand(WPARAM wParam, LPARAM lParam) { case CBN_SELENDOK: { - CString str; + std::string str; getWindowTextUTF8 (StringSelectComboBox, str); DeleteString(_EditingItem); - InsertString(_EditingItem, str); + InsertString(_EditingItem, utf8ToTStr(str)); SetCurSel (_SelectAfter); _EditingItem = LB_ERR; notifyParent (); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/plugin_interface.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/plugin_interface.h index 836285241..46000c798 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/plugin_interface.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/plugin_interface.h @@ -85,7 +85,7 @@ public: /* Functions to create/remove the Root Primitive for server actions Returns the id of the root primitive */ - virtual NLLIGO::IPrimitive *createRootPluginPrimitive (const char *name) = 0; + virtual NLLIGO::IPrimitive *createRootPluginPrimitive (const std::string &name) = 0; virtual void deleteRootPluginPrimitive (void) = 0; /// get all the current root primitve in the world editor. only the editable one are returned virtual void getAllRootPluginPrimitive (std::vector &prims) = 0; @@ -95,8 +95,8 @@ public: */ // Create a plugin primitive virtual const NLLIGO::IPrimitive *createPluginPrimitive ( - const char *className, - const char *primName, + const std::string &className, + const std::string &primName, const NLMISC::CVector &initPos, float deltaPos, const std::vector &initParameters, diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/project_settings.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/project_settings.cpp index 6bae07195..e2ada5702 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/project_settings.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/project_settings.cpp @@ -76,20 +76,20 @@ void CProjectSettings::OnBrowse() UpdateData (); BROWSEINFO bi; - char str[MAX_PATH]; + TCHAR str[MAX_PATH]; ITEMIDLIST* pidl; - char sTemp[1024]; + TCHAR sTemp[1024]; bi.hwndOwner = this->m_hWnd; bi.pidlRoot = NULL; bi.pidlRoot = NULL; bi.pszDisplayName = sTemp; - bi.lpszTitle = "Choose the data directory for this project"; + bi.lpszTitle = _T("Choose the data directory for this project"); bi.ulFlags = 0; bi.lpfn = dataDirBrowseCallbackProc; - char sDir[512]; - strcpy(sDir, DataDirectory); + TCHAR sDir[512]; + _tcscpy(sDir, DataDirectory); bi.lParam = (LPARAM)sDir; bi.iImage = 0; @@ -114,9 +114,9 @@ void CProjectSettings::OnOK() // Get the document CWorldEditorDoc *doc = getDocument (); - CString str; + std::string str; getWindowTextUTF8 (Context, str); - doc->setContext ((const char*)str); + doc->setContext (str); } // *************************************************************************** @@ -133,11 +133,11 @@ BOOL CProjectSettings::OnInitDialog() for (uint i=0; igetContext ().c_str ()); + Context.SelectString (-1, utf8ToTStr(doc->getContext ())); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.cpp index 16fe17089..7a5c25553 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.cpp @@ -681,9 +681,9 @@ void CToolsLogicTree::OnMenuGroupCreatePoint() dialog.MainFrame = _MainFrame; if (dialog.DoModal () == IDOK) - if (strlen(dialog.Name) > 0) + if (_tcslen(dialog.Name) > 0) { - HTREEITEM newItem = insertItemUTF8 (*this, dialog.Name, 2, 2, itemGroup); + HTREEITEM newItem = insertItemUTF8 (*this, tStrToUtf8(dialog.Name), 2, 2, itemGroup); Expand (itemGroup, TVE_EXPAND); // Create the newItem for (i = 0; i < _RegionsInfo.size(); ++i) @@ -715,9 +715,9 @@ void CToolsLogicTree::OnMenuGroupCreatePath() dialog.MainFrame = _MainFrame; if (dialog.DoModal () == IDOK) - if (strlen(dialog.Name) > 0) + if (_tcslen(dialog.Name) > 0) { - HTREEITEM newItem = insertItemUTF8 (*this, dialog.Name, 4, 4, itemGroup); + HTREEITEM newItem = insertItemUTF8 (*this, tStrToUtf8(dialog.Name), 4, 4, itemGroup); Expand (itemGroup, TVE_EXPAND); // Create the newItem for (i = 0; i < _RegionsInfo.size(); ++i) @@ -749,9 +749,9 @@ void CToolsLogicTree::OnMenuGroupCreateZone() dialog.MainFrame = _MainFrame; if (dialog.DoModal () == IDOK) - if (strlen(dialog.Name) > 0) + if (_tcslen(dialog.Name) > 0) { - HTREEITEM newItem = insertItemUTF8 (*this, dialog.Name, 6, 6, itemGroup); + HTREEITEM newItem = insertItemUTF8 (*this, tStrToUtf8(dialog.Name), 6, 6, itemGroup); Expand (itemGroup, TVE_EXPAND); // Create the newItem for (i = 0; i < _RegionsInfo.size(); ++i) @@ -814,7 +814,7 @@ void CToolsLogicTree::OnMenuGroupProperties() es.Name = GetItemText (hItem); if (es.DoModal() == IDOK) { - setItemTextUTF8 (*this, hItem, es.Name); + setItemTextUTF8 (*this, hItem, tStrToUtf8(es.Name)); HTREEITEM hChildItem = GetChildItem(hItem); while (hChildItem != NULL) @@ -878,7 +878,7 @@ void CToolsLogicTree::OnMenuGroupTransfertAppend () { HTREEITEM hNextItem = GetNextItem (hChildItem, TVGN_NEXT); - vTemp.push_back((LPCSTR)GetItemText(hChildItem)); + vTemp.push_back(tStrToUtf8(GetItemText(hChildItem))); hChildItem = hNextItem; } @@ -898,7 +898,7 @@ void CToolsLogicTree::OnMenuGroupTransfertReplace () { HTREEITEM hNextItem = GetNextItem (hChildItem, TVGN_NEXT); - vTemp.push_back((LPCSTR)GetItemText(hChildItem)); + vTemp.push_back(tStrToUtf8(GetItemText(hChildItem))); hChildItem = hNextItem; } @@ -1198,9 +1198,9 @@ void CToolsLogic::OnNewGroup () void CToolsLogic::OnNewPatat () { CComboBox *pCB = (CComboBox*)GetDlgItem(IDC_TYPE); - CString str; + std::string str; getWindowTextUTF8 (*pCB, str); - string sStr = (LPCSTR)str; + // TODO: what to do with str? } // *************************************************************************** @@ -1231,7 +1231,7 @@ BOOL CCreateDialog::OnInitDialog () for (uint32 i = 0; i < TypesForInit->size(); ++i) { - ComboType.InsertString (-1, TypesForInit->operator[](i).Name.c_str()); + ComboType.InsertString (-1, utf8ToTStr(TypesForInit->operator[](i).Name)); } if (TypesForInit->size()>0) @@ -1239,7 +1239,7 @@ BOOL CCreateDialog::OnInitDialog () if (ComboType.SelectString (0, LayerName) == CB_ERR) ComboType.SetCurSel (0); UpdateData(); - if (strlen(Name) == 0) + if (_tcslen(Name) == 0) OnSelChange(); } @@ -1264,16 +1264,16 @@ void CCreateDialog::OnOK() UpdateData (); // If the "region_" do not exist add it - if (strncmp(RegionPost.c_str(), Name, strlen(RegionPost.c_str())) != 0) + if (_tcsnccmp(utf8ToTStr(RegionPost), Name, strlen(RegionPost.c_str())) != 0) { - char sTmp[128]; - strcpy (sTmp, RegionPost.c_str()); - strcat (sTmp, Name); - strcpy (Name, sTmp); + TCHAR sTmp[128]; + _tcscpy (sTmp, utf8ToTStr(RegionPost)); + _tcscat (sTmp, Name); + _tcscpy (Name, sTmp); UpdateData (false); } - if (strcmp(PropName.c_str(), Name) == 0) + if (PropName == tStrToUtf8(Name)) CDialog::OnOK(); CDialog::OnOK(); @@ -1301,15 +1301,15 @@ void CCreateDialog::OnSelChange () CString sTmp; ComboType.GetLBText (cs, sTmp); - if (PropType == (LPCSTR)sTmp) + if (PropType == tStrToUtf8(sTmp)) { - strcpy (Name, PropName.c_str()); + _tcscpy (Name, utf8ToTStr(PropName)); } else { - strcpy (Name, RegionPost.c_str()); - strcat (Name, (LPCSTR)sTmp); - strcat (Name, "-"); + _tcscpy(Name, utf8ToTStr(RegionPost)); + _tcscat (Name, (LPCTSTR)sTmp); + _tcscat (Name, _T("-")); } UpdateData (false); @@ -1617,7 +1617,7 @@ HTREEITEM CToolsLogic::addPrimitive (HTREEITEM parentItem, HTREEITEM lastBrother const NLLIGO::CPrimitives *primitives = &(doc->getDatabaseElements (locator.getDatabaseIndex ())); // Set the item data - _Tree->SetItemData (treeItem, (DWORD)new CPrimitiveTreeData (primitives, locator.Primitive)); + _Tree->SetItemData (treeItem, (DWORD_PTR)new CPrimitiveTreeData (primitives, locator.Primitive)); // Expand parent ? if (parentItem != TVI_ROOT) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.h index 16cc4f4e6..4a875fc7f 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.h @@ -196,7 +196,7 @@ class CCreateDialog : public CDialog public: - char Name[128], + TCHAR Name[128], LayerName[128]; std::vector *TypesForInit; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_zone.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_zone.cpp index bca5672d6..231e57d28 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_zone.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_zone.cpp @@ -105,7 +105,7 @@ void CToolsZoneList::reset() void CToolsZoneList::addItem (const string &itemName) { _ItemNames.push_back (itemName); - InsertString (-1, itemName.c_str()); + InsertString (-1, utf8ToTStr(itemName)); } // --------------------------------------------------------------------------- @@ -168,7 +168,7 @@ void CToolsZoneList::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct) } // Draw the text. - dc.DrawText (lpszText, strlen(lpszText), &rectLeft, DT_CENTER|DT_SINGLELINE|DT_VCENTER); + dc.DrawText (lpszText, _tcslen(lpszText), &rectLeft, DT_CENTER|DT_SINGLELINE|DT_VCENTER); // Reset the background color and the text color back to their original values. dc.SetTextColor (crOldTextColor); @@ -261,13 +261,13 @@ void CToolsZone::addToAllCatTypeCB (const string &Name) { CComboBox* pCB; pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE1); - pCB->AddString (Name.c_str()); + pCB->AddString (utf8ToTStr(Name)); pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE2); - pCB->AddString (Name.c_str()); + pCB->AddString (utf8ToTStr(Name)); pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE3); - pCB->AddString (Name.c_str()); + pCB->AddString (utf8ToTStr(Name)); pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE4); - pCB->AddString (Name.c_str()); + pCB->AddString (utf8ToTStr(Name)); } // --------------------------------------------------------------------------- @@ -285,26 +285,26 @@ void CToolsZone::init (CMainFrame *pMF) // Select right category types CComboBox* pCB; pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE1); - pCB->SelectString (-1, _MainFrame->_ZoneBuilder->_FilterType1.c_str()); + pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType1)); pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE2); - pCB->SelectString (-1, _MainFrame->_ZoneBuilder->_FilterType2.c_str()); + pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType2)); pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE3); - pCB->SelectString (-1, _MainFrame->_ZoneBuilder->_FilterType3.c_str()); + pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType3)); pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE4); - pCB->SelectString (-1, _MainFrame->_ZoneBuilder->_FilterType4.c_str()); + pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType4)); updateComboPairAndFilter (IDC_CATTYPE1, IDC_CATVALUE1, &_MainFrame->_ZoneBuilder->_FilterType1); pCB = (CComboBox*)GetDlgItem (IDC_CATVALUE1); - pCB->SelectString (-1, _MainFrame->_ZoneBuilder->_FilterValue1.c_str()); + pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue1)); updateComboPairAndFilter (IDC_CATTYPE2, IDC_CATVALUE2, &_MainFrame->_ZoneBuilder->_FilterType2); pCB = (CComboBox*)GetDlgItem (IDC_CATVALUE2); - pCB->SelectString (-1, _MainFrame->_ZoneBuilder->_FilterValue2.c_str()); + pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue2)); updateComboPairAndFilter (IDC_CATTYPE3, IDC_CATVALUE3, &_MainFrame->_ZoneBuilder->_FilterType3); pCB = (CComboBox*)GetDlgItem (IDC_CATVALUE3); - pCB->SelectString (-1, _MainFrame->_ZoneBuilder->_FilterValue3.c_str()); + pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue3)); updateComboPairAndFilter (IDC_CATTYPE4, IDC_CATVALUE4, &_MainFrame->_ZoneBuilder->_FilterType4); pCB = (CComboBox*)GetDlgItem (IDC_CATVALUE4); - pCB->SelectString (-1, _MainFrame->_ZoneBuilder->_FilterValue4.c_str()); + pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue4)); // Select right operators CButton *pButAnd, *pButOr; @@ -432,11 +432,11 @@ void CToolsZone::OnPaint() void CToolsZone::updateComboPairAndFilter (int CatTypeId, int CatValueId, string *pFilterType) { uint32 i; - char sTmp[256]; + TCHAR sTmp[256]; CComboBox *pCBType, *pCBValue; pCBType = (CComboBox*)GetDlgItem (CatTypeId); pCBType->GetLBText (pCBType->GetCurSel(), sTmp); - *pFilterType = sTmp; + *pFilterType = tStrToUtf8(sTmp); pCBValue = (CComboBox*)GetDlgItem (CatValueId); pCBValue->ResetContent (); @@ -446,7 +446,7 @@ void CToolsZone::updateComboPairAndFilter (int CatTypeId, int CatValueId, string vector allCategoryValues; _MainFrame->_ZoneBuilder->getZoneBank().getCategoryValues (*pFilterType, allCategoryValues); for(i = 0; i < allCategoryValues.size(); ++i) - pCBValue->AddString (allCategoryValues[i].c_str()); + pCBValue->AddString (utf8ToTStr(allCategoryValues[i])); pCBValue->SetCurSel (0); } @@ -485,40 +485,40 @@ void CToolsZone::OnSelectCatType4 () // --------------------------------------------------------------------------- void CToolsZone::OnSelectCatValue1() { - char sTmp[256]; + TCHAR sTmp[256]; CComboBox *pCBValue = (CComboBox*)GetDlgItem (IDC_CATVALUE1); pCBValue->GetLBText (pCBValue->GetCurSel(), sTmp); - _MainFrame->_ZoneBuilder->_FilterValue1 = sTmp; + _MainFrame->_ZoneBuilder->_FilterValue1 = tStrToUtf8(sTmp); _MainFrame->_ZoneBuilder->updateToolsZone (); } // --------------------------------------------------------------------------- void CToolsZone::OnSelectCatValue2() { - char sTmp[256]; + TCHAR sTmp[256]; CComboBox *pCBValue = (CComboBox*)GetDlgItem (IDC_CATVALUE2); pCBValue->GetLBText (pCBValue->GetCurSel(), sTmp); - _MainFrame->_ZoneBuilder->_FilterValue2 = sTmp; + _MainFrame->_ZoneBuilder->_FilterValue2 = tStrToUtf8(sTmp); _MainFrame->_ZoneBuilder->updateToolsZone (); } // --------------------------------------------------------------------------- void CToolsZone::OnSelectCatValue3() { - char sTmp[256]; + TCHAR sTmp[256]; CComboBox *pCBValue = (CComboBox*)GetDlgItem (IDC_CATVALUE3); pCBValue->GetLBText (pCBValue->GetCurSel(), sTmp); - _MainFrame->_ZoneBuilder->_FilterValue3 = sTmp; + _MainFrame->_ZoneBuilder->_FilterValue3 = tStrToUtf8(sTmp); _MainFrame->_ZoneBuilder->updateToolsZone (); } // --------------------------------------------------------------------------- void CToolsZone::OnSelectCatValue4() { - char sTmp[256]; + TCHAR sTmp[256]; CComboBox *pCBValue = (CComboBox*)GetDlgItem (IDC_CATVALUE4); pCBValue->GetLBText (pCBValue->GetCurSel(), sTmp); - _MainFrame->_ZoneBuilder->_FilterValue4 = sTmp; + _MainFrame->_ZoneBuilder->_FilterValue4 = tStrToUtf8(sTmp); _MainFrame->_ZoneBuilder->updateToolsZone (); } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/type_manager_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/type_manager_dlg.cpp index 6a48d20a5..ed39bda8e 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/type_manager_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/type_manager_dlg.cpp @@ -77,7 +77,7 @@ void CTypeManagerDlg::OnAddtype() if (typeDlg.DoModal() == IDOK) { SType typeTmp; - typeTmp.Name = (LPCSTR)typeDlg.EditName; + typeTmp.Name = tStrToUtf8(typeDlg.EditName); typeTmp.Color = typeDlg.ButtonColorValue; // Check if the name of the new type is the same as an existing one bool bFound = false; @@ -91,7 +91,7 @@ void CTypeManagerDlg::OnAddtype() if (!bFound) { LocalTypes.push_back (typeTmp); - ListType.InsertString(-1, typeTmp.Name.c_str()); + ListType.InsertString(-1, utf8ToTStr(typeTmp.Name)); } } } @@ -111,11 +111,11 @@ void CTypeManagerDlg::OnEdittype() if (typeDlg.DoModal() == IDOK) { SType typeTmp; - typeTmp.Name = (LPCSTR)typeDlg.EditName; + typeTmp.Name = tStrToUtf8(typeDlg.EditName); typeTmp.Color = typeDlg.ButtonColorValue; LocalTypes[cursel] = typeTmp; ListType.DeleteString (ListType.GetCurSel()); - ListType.InsertString (cursel, typeTmp.Name.c_str()); + ListType.InsertString (cursel, utf8ToTStr(typeTmp.Name)); } } @@ -138,7 +138,7 @@ BOOL CTypeManagerDlg::OnInitDialog() // TODO: Add extra initialization here for (uint32 i = 0; i < LocalTypes.size(); ++i) { - ListType.InsertString(-1, LocalTypes[i].Name.c_str()); + ListType.InsertString(-1, utf8ToTStr(LocalTypes[i].Name)); } return TRUE; // return TRUE unless you set the focus to a control diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/type_sel_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/type_sel_dlg.cpp index 67940b654..347fc72ad 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/type_sel_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/type_sel_dlg.cpp @@ -60,7 +60,7 @@ void CTypeSelDlg::OnOK() CString sTmp; TypeList.GetText(TypeList.GetCurSel(), sTmp); - _TypeSelected = (LPCSTR)sTmp; + _TypeSelected = tStrToUtf8(sTmp); CDialog::OnOK(); } @@ -72,7 +72,7 @@ BOOL CTypeSelDlg::OnInitDialog() // TODO: Add extra initialization here for (uint32 i = 0; i < _TypesInit->size(); ++i) { - TypeList.InsertString(-1, _TypesInit->operator[](i).Name.c_str()); + TypeList.InsertString(-1, utf8ToTStr(_TypesInit->operator[](i).Name)); } return TRUE; // return TRUE unless you set the focus to a control diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp index 9029f7dfd..1b3f96d04 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp @@ -128,7 +128,7 @@ BOOL CWorldEditorApp::InitInstance() splashScreen.addLine(string("Exe path")); // Exe path - ExePath = GetCommandLine (); + ExePath = tStrToUtf8(GetCommandLine ()); if (ExePath.size()>0) { if (ExePath[0] == '\"') @@ -170,7 +170,7 @@ BOOL CWorldEditorApp::InitInstance() } catch (const Exception& e) { - ::MessageBox (NULL, e.what(), "Warning", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox (NULL, utf8ToTStr(e.what()), _T("Warning"), MB_OK|MB_ICONEXCLAMATION); // Can't found the module put some default values Config.CellSize = 160.0f; @@ -218,7 +218,7 @@ BOOL CWorldEditorApp::InitInstance() // Enable DDE Execute open EnableShellOpen(); - RegDeleteKey (HKEY_CLASSES_ROOT, "Worldeditor.Document\\DefaultIcon"); + RegDeleteKey (HKEY_CLASSES_ROOT, _T("Worldeditor.Document\\DefaultIcon")); RegisterShellFileTypes(TRUE); // Parse command line for standard shell commands, DDE, file open @@ -286,13 +286,13 @@ BOOL CWorldEditorApp::InitInstance() CMenu* menu = new CMenu(); menu->CreatePopupMenu(); - dynamic_menu->InsertMenu(6, MF_BYPOSITION | MF_POPUP, (UINT)menu->GetSafeHmenu(), "Plugins"); + dynamic_menu->InsertMenu(6, MF_BYPOSITION | MF_POPUP, (UINT_PTR)menu->GetSafeHmenu(), _T("Plugins")); for(uint k=0;kgetName(); - menu->InsertMenu( k, MF_BYPOSITION | MF_POPUP, ID_WINDOWS_PLUGINS+1 + k, retest.c_str() ); + menu->InsertMenu( k, MF_BYPOSITION | MF_POPUP, ID_WINDOWS_PLUGINS+1 + k, utf8ToTStr(retest) ); menu->CheckMenuItem(ID_WINDOWS_PLUGINS+1 +k, MF_CHECKED); } @@ -444,7 +444,7 @@ bool CWorldEditorApp::yesNoMessage (const char *format, ... ) strcpy(buffer, "Unknown error"); } - return MessageBox (m_pMainWnd?m_pMainWnd->m_hWnd:NULL, buffer, "NeL World Editor", MB_YESNO|MB_ICONQUESTION) == IDYES; + return MessageBox (m_pMainWnd?m_pMainWnd->m_hWnd:NULL, utf8ToTStr(buffer), _T("NeL World Editor"), MB_YESNO|MB_ICONQUESTION) == IDYES; } void CWorldEditorApp::errorMessage (const char *format, ... ) @@ -463,7 +463,7 @@ void CWorldEditorApp::errorMessage (const char *format, ... ) strcpy(buffer, "Unknown error"); } - MessageBox (m_pMainWnd?m_pMainWnd->m_hWnd:NULL, buffer, "NeL World Editor", MB_OK|MB_ICONEXCLAMATION); + MessageBox (m_pMainWnd?m_pMainWnd->m_hWnd:NULL, utf8ToTStr(buffer), _T("NeL World Editor"), MB_OK|MB_ICONEXCLAMATION); } void CWorldEditorApp::infoMessage (const char *format, ... ) @@ -482,10 +482,10 @@ void CWorldEditorApp::infoMessage (const char *format, ... ) strcpy(buffer, "Unknown error"); } - MessageBox (m_pMainWnd?m_pMainWnd->m_hWnd:NULL, buffer, "NeL World Editor", MB_OK|MB_ICONINFORMATION); + MessageBox (m_pMainWnd?m_pMainWnd->m_hWnd:NULL, utf8ToTStr(buffer), _T("NeL World Editor"), MB_OK|MB_ICONINFORMATION); } -void CWorldEditorApp::syntaxError (const char *filename, xmlNodePtr xmlNode, const char *format, ...) +void CWorldEditorApp::syntaxError (const std::string &filename, xmlNodePtr xmlNode, const char *format, ...) { char buffer[1024]; @@ -501,10 +501,10 @@ void CWorldEditorApp::syntaxError (const char *filename, xmlNodePtr xmlNode, con strcpy(buffer, "Unknown error"); } - errorMessage ("(%s), node (%s), line (%d) :\n%s", filename, xmlNode->name, (int)xmlNode->content, buffer); + errorMessage ("(%s), node (%s), line (%d) :\n%s", filename.c_str(), xmlNode->name, (int)xmlNode->line, buffer); } -bool CWorldEditorApp::getPropertyString (std::string &result, const char *filename, xmlNodePtr xmlNode, const char *propName) +bool CWorldEditorApp::getPropertyString (std::string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &propName) { // Call the CIXml version if (!CIXml::getPropertyString (result, xmlNode, propName)) @@ -516,7 +516,7 @@ bool CWorldEditorApp::getPropertyString (std::string &result, const char *filena return true; } -bool CWorldEditorApp::initPath (const char *filename, CSplashScreen &splashScreen) +bool CWorldEditorApp::initPath (const std::string &filename, CSplashScreen &splashScreen) { // The context strings set contextStrings; @@ -630,16 +630,16 @@ class CMainFrame *getMainFrame () // *************************************************************************** -std::string standardizePath (const char *str) +std::string standardizePath (const std::string &str) { - return NLMISC::strlwr (NLMISC::CPath::standardizePath (str, true)); + return NLMISC::toLower(NLMISC::CPath::standardizePath (str, true)); } // *************************************************************************** -std::string formatString (const char *str) +std::string formatString (const std::string &str) { - string copy = NLMISC::strlwr (str); + string copy = NLMISC::toLower(str); return copy; } @@ -679,9 +679,9 @@ void invalidateLeftView () // *************************************************************************** -std::string numberize (const char *oldString, uint value) +std::string numberize (const std::string &oldString, uint value) { - int i=strlen (oldString)-1; + int i = oldString.length()-1; while ((i>=0) && (((oldString[i]<='9') && (oldString[i]>='0')) || (oldString[i]==' '))) { // again @@ -723,52 +723,6 @@ bool getZoneNameFromXY (sint32 x, sint32 y, std::string &zoneName) return true; } -// *************************************************************************** - -bool openFile (const char *filename) -{ - char key[MAX_PATH + MAX_PATH]; - - // Extension - string extension = NLMISC::CFile::getExtension (filename); - - // First try ShellExecute() - HINSTANCE result = ShellExecute(NULL, "open", filename, NULL,NULL, SW_SHOW); - - // If it failed, get the .htm regkey and lookup the program - if ((UINT)result <= HINSTANCE_ERROR) - { - - if (getRegKey(HKEY_CLASSES_ROOT, ("."+extension).c_str (), key) == ERROR_SUCCESS) - { - lstrcat(key, "\\shell\\open\\command"); - - if (getRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) - { - char *pos; - pos = strstr(key, "\"%1\""); - if (pos == NULL) - { // No quotes found - pos = strstr(key, "%1"); // Check for %1, without quotes - if (pos == NULL) // No parameter at all... - pos = key+lstrlen(key)-1; - else - *pos = '\0'; // Remove the parameter - } - else - *pos = '\0'; // Remove the parameter - - lstrcat(pos, " "); - lstrcat(pos, filename); - result = (HINSTANCE) WinExec(key, SW_SHOW); - return ((UINT)result) >= 31; - } - } - } - else - return true; - return false; -} // *************************************************************************** @@ -780,7 +734,7 @@ uint getRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata) if (retval == ERROR_SUCCESS) { long datasize = MAX_PATH; - char data[MAX_PATH]; + TCHAR data[MAX_PATH]; RegQueryValue(hkey, NULL, data, &datasize); lstrcpy(retdata,data); RegCloseKey(hkey); @@ -832,21 +786,9 @@ void CMyLigoConfig::errorMessage (const char *format, ... ) // *************************************************************************** -void setEditTextMultiLine (CEdit &edit, const char *text) +void setEditTextMultiLine (CEdit &edit, const std::string &text) { - string temp; - uint size = strlen (text); - temp.reserve (2*size); - bool previousR=false; - for (uint c=0; c &vect) setEditTextMultiLine (edit, temp.c_str()); } -/* -void setEditTextMultiLine (ColorEditWnd &edit, const char *text) -{ - string temp; - uint size = strlen (text); - temp.reserve (2*size); - bool previousR=false; - for (uint c=0; c &vect) -{ - string temp; - uint i; - for (i=0; i &vect) @@ -910,12 +813,12 @@ void setEditTextMultiLine (CListBox &listBox, const std::vector &ve listBox.ResetContent(); uint i; for (i=0; i &vect); -//void setEditTextMultiLine (ColorEditWnd &edit, const char *text); -//void setEditTextMultiLine (ColorEditWnd &edit, const std::vector &vect); -//void setEditTextMultiLine (CListBox &listBox, const char *text); void setEditTextMultiLine (CListBox &listBox, const std::vector &vect); -bool setWindowTextUTF8 (HWND hwnd, const char *textUtf8); -bool getWindowTextUTF8 (HWND hwnd, CString &textUtf8); -HTREEITEM insertItemUTF8 (HWND hwnd, const char *textUtf8, HTREEITEM hParent = TVI_ROOT, HTREEITEM hInsertAfter = TVI_LAST); -HTREEITEM insertItemUTF8 (HWND hwnd, const char *textUtf8, int nImage, int nSelectedImage, HTREEITEM hParent = TVI_ROOT, HTREEITEM hInsertAfter = TVI_LAST); -bool setItemTextUTF8 ( HWND hwnd, HTREEITEM hItem, LPCTSTR lpszItem ); +bool setWindowTextUTF8 (HWND hwnd, const std::string &textUtf8); +bool getWindowTextUTF8 (HWND hwnd, std::string &textUtf8); +HTREEITEM insertItemUTF8 (HWND hwnd, const std::string &textUtf8, HTREEITEM hParent = TVI_ROOT, HTREEITEM hInsertAfter = TVI_LAST); +HTREEITEM insertItemUTF8 (HWND hwnd, const std::string &textUtf8, int nImage, int nSelectedImage, HTREEITEM hParent = TVI_ROOT, HTREEITEM hInsertAfter = TVI_LAST); +bool setItemTextUTF8 ( HWND hwnd, HTREEITEM hItem, const std::string &item ); bool isPrimitiveVisible (const NLLIGO::IPrimitive *primitive); std::string getTextureFile(const std::string &filename); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.cpp index 6153027cc..2f85d6c01 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.cpp @@ -172,7 +172,7 @@ BOOL CWorldEditorDoc::OnOpenDocument(LPCTSTR lpszPathName) // Result newDocument (); - bool res = loadDocument (lpszPathName) ? TRUE : FALSE; + bool res = loadDocument (tStrToUtf8(lpszPathName)) ? TRUE : FALSE; // Timer enabled ? getMainFrame ()->TimerEnabled = true; @@ -182,7 +182,7 @@ BOOL CWorldEditorDoc::OnOpenDocument(LPCTSTR lpszPathName) // *************************************************************************** -bool CWorldEditorDoc::loadDocument (const char *filename) +bool CWorldEditorDoc::loadDocument (const std::string &filename) { bool result = true; @@ -346,7 +346,7 @@ bool CWorldEditorDoc::loadDocument (const char *filename) // Not modified _DataHierarchy[i].Modified = false; - getMainFrame()->launchLoadingDialog(toString("loading %s", _DataHierarchy[i].Filename.c_str()).c_str()); + getMainFrame()->launchLoadingDialog("loading " + _DataHierarchy[i].Filename); getMainFrame()->progressLoadingDialog(float(i+0.0001f)/_DataHierarchy.size()); // Landscape ? if (_DataHierarchy[i].Type == CDatabaseElement::Landscape) @@ -504,7 +504,7 @@ BOOL CWorldEditorDoc::OnSaveDocument(LPCTSTR lpszPathName) BOOL result = TRUE; // Get path name - string path = NLMISC::CFile::getPath (lpszPathName); + string path = NLMISC::CFile::getPath (tStrToUtf8(lpszPathName)); // Backup current path string backupPath = CPath::getCurrentPath (); @@ -522,7 +522,7 @@ BOOL CWorldEditorDoc::OnSaveDocument(LPCTSTR lpszPathName) { // Make path relative string relativeFileName = _DataHierarchy[i].Filename; - CPath::makePathRelative (NLMISC::CFile::getPath (lpszPathName).c_str (), relativeFileName); + CPath::makePathRelative (NLMISC::CFile::getPath (tStrToUtf8(lpszPathName)), relativeFileName); if (relativeFileName != _DataHierarchy[i].Filename) { _DataHierarchy[i].Filename = relativeFileName; @@ -541,10 +541,10 @@ BOOL CWorldEditorDoc::OnSaveDocument(LPCTSTR lpszPathName) // Got a filename ? if (_DataHierarchy[i].Filename.empty ()) { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "land", FALSE, "land", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "NeL Ligo Landscape Files (*.land)|*.land|All Files (*.*)|*.*||", getMainFrame ()); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("land"), FALSE, _T("land"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("NeL Ligo Landscape Files (*.land)|*.land|All Files (*.*)|*.*||"), getMainFrame ()); if (dialog.DoModal() == IDOK) { - _DataHierarchy[i].Filename = dialog.GetPathName(); + _DataHierarchy[i].Filename = tStrToUtf8(dialog.GetPathName()); } else { @@ -594,10 +594,10 @@ BOOL CWorldEditorDoc::OnSaveDocument(LPCTSTR lpszPathName) // Got a filename ? if (_DataHierarchy[i].Filename.empty ()) { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "primitive", FALSE, "primitive", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "NeL Ligo Primitive Files (*.primitive)|*.primitive|All Files (*.*)|*.*||", getMainFrame ()); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("primitive"), FALSE, _T("primitive"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("NeL Ligo Primitive Files (*.primitive)|*.primitive|All Files (*.*)|*.*||"), getMainFrame ()); if (dialog.DoModal() == IDOK) { - string pathFromDialog = dialog.GetPathName(); + string pathFromDialog = tStrToUtf8(dialog.GetPathName()); // Remove uppercase in filename string::size_type pos = pathFromDialog.rfind ("\\", 0); @@ -665,7 +665,7 @@ BOOL CWorldEditorDoc::OnSaveDocument(LPCTSTR lpszPathName) { // Save the document COFile file; - if (file.open (lpszPathName, false, false, true)) + if (file.open (tStrToUtf8(lpszPathName), false, false, true)) { try { @@ -708,7 +708,7 @@ BOOL CWorldEditorDoc::OnSaveDocument(LPCTSTR lpszPathName) if (landscape) { node = xmlNewChild ( node, NULL, (const xmlChar*)"PRIMITIVES", NULL); - _DataHierarchy[i].Primitives.write (node, lpszPathName); + _DataHierarchy[i].Primitives.write (node, tStrToUtf8(lpszPathName)); } } } @@ -732,7 +732,7 @@ BOOL CWorldEditorDoc::OnSaveDocument(LPCTSTR lpszPathName) result = FALSE; } - _LastModifedTime = NLMISC::CFile::getFileModificationDate (lpszPathName); + _LastModifedTime = NLMISC::CFile::getFileModificationDate (tStrToUtf8(lpszPathName)); } // No modification is for this level of undo @@ -826,11 +826,11 @@ void CWorldEditorDoc::updateModifiedState () } else { - string title = (const char*)GetTitle (); + string title = tStrToUtf8(GetTitle ()); if ( (title.size ()>=2) && (title[title.size()-1] == '*') && (title[title.size()-2] == ' ') ) { title.resize (title.size () - 2); - SetTitle (title.c_str()); + SetTitle (utf8ToTStr(title)); } } } @@ -912,12 +912,12 @@ const string &CWorldEditorDoc::getDataDir () const void CWorldEditorDoc::getFilePath(uint primIndex,string & relativeFileName) { relativeFileName=_DataHierarchy[primIndex].Filename; - CPath::makePathRelative ((NLMISC::CFile::getPath ((LPCTSTR)CWorldEditorDoc::GetPathName())).c_str(), relativeFileName); + CPath::makePathRelative (NLMISC::CFile::getPath (tStrToUtf8(CWorldEditorDoc::GetPathName())), relativeFileName); } // *************************************************************************** -void CWorldEditorDoc::setDataDir (const char *dir) +void CWorldEditorDoc::setDataDir (const std::string &dir) { _DataDir = dir; @@ -1444,7 +1444,7 @@ void CWorldEditorDoc::initPrimitiveParameters (const CPrimitiveClass &primClass, // *************************************************************************** -const NLLIGO::IPrimitive *CWorldEditorDoc::createPrimitive (const CDatabaseLocator &locator, const char *className, const char *primName, +const NLLIGO::IPrimitive *CWorldEditorDoc::createPrimitive (const CDatabaseLocator &locator, const std::string &className, const std::string &primName, const CVector &initPos, float deltaPos, const std::vector &initParameters) { @@ -1532,12 +1532,12 @@ const NLLIGO::IPrimitive *CWorldEditorDoc::createPrimitive (const CDatabaseLocat if (primClass->Type == CPrimitiveClass::Bitmap) { // Create a dialog file - CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("image"), TRUE, primClass->FileExtension.c_str (), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, - (primClass->FileType+" (*."+primClass->FileExtension+")|*."+primClass->FileExtension+"|All Files (*.*)|*.*||").c_str (), getMainFrame ()); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("image"), TRUE, utf8ToTStr(primClass->FileExtension), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, + utf8ToTStr(toString("%s (*.%s)|*.%s|All Files (*.*)|*.*||", primClass->FileType.c_str(), primClass->FileExtension.c_str(), primClass->FileExtension.c_str())), getMainFrame ()); if (dialog.DoModal() == IDOK) { // Save filename - static_cast(primitive)->init (dialog.GetPathName ()); + static_cast(primitive)->init (tStrToUtf8(dialog.GetPathName ())); } } @@ -1728,25 +1728,25 @@ void CWorldEditorDoc::updateFiles () } // Check date - if (!checkFileDate (GetPathName (), _LastModifedTime)) + if (!checkFileDate (tStrToUtf8(GetPathName ()), _LastModifedTime)) { // Ask for reloading - if (theApp.yesNoMessage ("The file \"%s\" has been modified.\nReload it ?", (const char*)GetPathName ())) + if (theApp.yesNoMessage ("The file \"%s\" has been modified.\nReload it ?", tStrToUtf8(GetPathName ()).c_str())) { newDocument (); - loadDocument (GetPathName ()); + loadDocument (tStrToUtf8(GetPathName ())); } else { // Get the new date - _LastModifedTime = NLMISC::CFile::getFileModificationDate ((const char*)GetPathName ()); + _LastModifedTime = NLMISC::CFile::getFileModificationDate (tStrToUtf8(GetPathName())); } } } // *************************************************************************** -bool CWorldEditorDoc::checkFileDate (const char *filename, uint32 date) +bool CWorldEditorDoc::checkFileDate (const std::string &filename, uint32 date) { // File exist ? if (!NLMISC::CFile::fileExists (filename)) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.h index 4d124eeab..2e9f07fe2 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.h @@ -158,7 +158,7 @@ public: void getFilePath(uint primIndex,std::string&); // Set the data directory - void setDataDir (const char *dir); + void setDataDir (const std::string &dir); // Get the path of selected primitive const std::string &getPathOfSelectedPrimitive() const; @@ -263,7 +263,7 @@ private: void insertPrimitive (const CDatabaseLocator &locator, NLLIGO::IPrimitive *primitive); // Create a primitive, for actions only - const NLLIGO::IPrimitive *createPrimitive (const CDatabaseLocator &locator, const char *className, const char *primName, + const NLLIGO::IPrimitive *createPrimitive (const CDatabaseLocator &locator, const std::string &className, const std::string &primName, const NLMISC::CVector &initPos, float deltaPos, const std::vector &initParameters); // Init a primitive parameters @@ -279,7 +279,7 @@ public: // *** File modification void updateFiles (); - static bool checkFileDate (const char *filename, uint32 date); + static bool checkFileDate(const std::string &filename, uint32 date); /* // Get ligo data at a specific locator void getLigoData (CLigoData &data, const CDatabaseLocator &locator); @@ -294,7 +294,7 @@ public: } // Get document context - void setContext (const char *context) + void setContext (const std::string &context) { _Context = context; } @@ -441,7 +441,7 @@ public: private: bool newDocument (); - bool loadDocument (const char *filename); + bool loadDocument (const std::string &filename); // Implementation public: From 6bbe0ad774081238d5491f89416909b68502545f Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 18:38:46 +0100 Subject: [PATCH 23/39] Changed: Some warnings are specific to clang --HG-- branch : develop --- code/CMakeModules/nel.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 03228fe2e..dec01fe62 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -887,7 +887,11 @@ MACRO(NL_SETUP_BUILD) ENDIF() # never display these warnings because they are minor - ADD_PLATFORM_FLAGS("-Wno-unused-parameter -Wno-unused-private-field -Wno-unused-local-typedef -Wno-unused-variable") + ADD_PLATFORM_FLAGS("-Wno-unused-parameter -Wno-unused-variable -Wunused-function -Wunused-value") + + IF(CLANG) + ADD_PLATFORM_FLAGS("-Wno-unused-private-field -Wno-unused-local-typedef") + ENDIF() IF(ANDROID) ADD_PLATFORM_FLAGS("--sysroot=${PLATFORM_ROOT}") From 27b272f012af7a654756073667a12a72c48ec18f Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 18:40:03 +0100 Subject: [PATCH 24/39] Changed: Replace a lot of const char* by std::string parameters --HG-- branch : develop --- code/nel/include/nel/ligo/ligo_config.h | 8 ++++---- code/nel/include/nel/misc/path.h | 4 ++-- code/nel/src/ligo/ligo_config.cpp | 10 +++++----- code/nel/src/misc/path.cpp | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/code/nel/include/nel/ligo/ligo_config.h b/code/nel/include/nel/ligo/ligo_config.h index 4d93843e5..092f6caba 100644 --- a/code/nel/include/nel/ligo/ligo_config.h +++ b/code/nel/include/nel/ligo/ligo_config.h @@ -107,7 +107,7 @@ public: 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/include/nel/misc/path.h b/code/nel/include/nel/misc/path.h index a16b03f15..f42acc91b 100644 --- a/code/nel/include/nel/misc/path.h +++ b/code/nel/include/nel/misc/path.h @@ -209,7 +209,7 @@ public: * \param relativePath is the path to make relative to basePath. * return true if relativePath as been done relative to basePath, false is relativePath has not been changed. */ - bool makePathRelative (const char *basePath, std::string &relativePath); + bool makePathRelative (const std::string &basePath, std::string &relativePath); /** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning. */ @@ -505,7 +505,7 @@ public: * \param relativePath is the path to make relative to basePath. * return true if relativePath as been done relative to basePath, false is relativePath has not been changed. */ - static bool makePathRelative (const char *basePath, std::string &relativePath); + static bool makePathRelative(const std::string &basePath, std::string &relativePath); /** Make path absolute * \param relativePath - The relative path diff --git a/code/nel/src/ligo/ligo_config.cpp b/code/nel/src/ligo/ligo_config.cpp index 7139221e6..0025d4290 100644 --- a/code/nel/src/ligo/ligo_config.cpp +++ b/code/nel/src/ligo/ligo_config.cpp @@ -508,13 +508,13 @@ bool CLigoConfig::canBeRoot (const NLLIGO::IPrimitive &child) // *************************************************************************** -bool CLigoConfig::getPropertyString (std::string &result, const char *filename, xmlNodePtr xmlNode, const char *propName) +bool CLigoConfig::getPropertyString(std::string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &propName) { // Call the CIXml version if (!CIXml::getPropertyString (result, xmlNode, propName)) { // Output a formated error - syntaxError (filename, xmlNode, "Missing XML node property (%s)", propName); + syntaxError (filename, xmlNode, "Missing XML node property (%s)", propName.c_str()); return false; } return true; @@ -522,7 +522,7 @@ bool CLigoConfig::getPropertyString (std::string &result, const char *filename, // *************************************************************************** -void CLigoConfig::syntaxError (const char *filename, xmlNodePtr xmlNode, const char *format, ...) +void CLigoConfig::syntaxError (const std::string &filename, xmlNodePtr xmlNode, const char *format, ...) { va_list args; va_start( args, format ); @@ -530,7 +530,7 @@ void CLigoConfig::syntaxError (const char *filename, xmlNodePtr xmlNode, const c vsnprintf( buffer, 1024, format, args ); va_end( args ); - errorMessage ("(%s), node (%s), line (%p) :\n%s", filename, xmlNode->name, xmlNode->content, buffer); + errorMessage ("(%s), node (%s), line (%p) :\n%s", filename.c_str(), xmlNode->name, xmlNode->content, buffer); } // *************************************************************************** @@ -589,7 +589,7 @@ const CPrimitiveClass *CLigoConfig::getPrimitiveClass (const IPrimitive &primiti // *************************************************************************** -const CPrimitiveClass *CLigoConfig::getPrimitiveClass (const char *className) const +const CPrimitiveClass *CLigoConfig::getPrimitiveClass(const std::string &className) const { std::map::const_iterator ite = _PrimitiveClasses.find (className); if (ite != _PrimitiveClasses.end ()) diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index b9a49b04b..c6f9786f4 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -2523,7 +2523,7 @@ bool CFile::createDirectoryTree(const std::string &filename) return lastResult; } -bool CPath::makePathRelative (const char *basePath, std::string &relativePath) +bool CPath::makePathRelative (const std::string &basePath, std::string &relativePath) { // Standard path with final slash string tmp = standardizePath (basePath, true); From bbcd14cecb54aeb6e4f5d5a092b4b71d317ed172 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 18:40:17 +0100 Subject: [PATCH 25/39] Removed: Empty cpp files --HG-- branch : develop --- .../common/src/game_share/msg_ais_egs_gen.cpp | 28 ------------------- .../common/src/game_share/season_file_ext.cpp | 18 ------------ .../src/game_share/user_connection_mgr.cpp | 27 ------------------ 3 files changed, 73 deletions(-) delete mode 100644 code/ryzom/common/src/game_share/msg_ais_egs_gen.cpp delete mode 100644 code/ryzom/common/src/game_share/season_file_ext.cpp delete mode 100644 code/ryzom/common/src/game_share/user_connection_mgr.cpp diff --git a/code/ryzom/common/src/game_share/msg_ais_egs_gen.cpp b/code/ryzom/common/src/game_share/msg_ais_egs_gen.cpp deleted file mode 100644 index 29d9e754c..000000000 --- a/code/ryzom/common/src/game_share/msg_ais_egs_gen.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -///////////////////////////////////////////////////////////////// -// WARNING : this is a generated file, don't change it ! -///////////////////////////////////////////////////////////////// - -#include "stdpch.h" - -#include "msg_ais_egs_gen.h" - -namespace RYMSG -{ - -} diff --git a/code/ryzom/common/src/game_share/season_file_ext.cpp b/code/ryzom/common/src/game_share/season_file_ext.cpp deleted file mode 100644 index 40ba23aca..000000000 --- a/code/ryzom/common/src/game_share/season_file_ext.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdpch.h" -#include "season_file_ext.h" diff --git a/code/ryzom/common/src/game_share/user_connection_mgr.cpp b/code/ryzom/common/src/game_share/user_connection_mgr.cpp deleted file mode 100644 index 6d8210946..000000000 --- a/code/ryzom/common/src/game_share/user_connection_mgr.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -//----------------------------------------------------------------------------- -// includes -//----------------------------------------------------------------------------- - -#include "stdpch.h" - -#include "user_connection_mgr.h" - -using namespace R2; - - From ba35109fe42ce254539941d6a9ad4498e49ce80d Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 18:48:53 +0100 Subject: [PATCH 26/39] Changed: Destructor for CApplicationContext to display singletons still in memory --HG-- branch : develop --- code/nel/include/nel/misc/app_context.h | 1 + code/nel/src/misc/app_context.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) 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/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)); From 3c568ce8a3b6e448e27a1128beca82be99d3b787 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 18:50:01 +0100 Subject: [PATCH 27/39] Changed: New "new" definitions for NEW_DEBUG macro defined by MFC --HG-- branch : develop --- code/nel/include/nel/misc/object_arena_allocator.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/misc/object_arena_allocator.h b/code/nel/include/nel/misc/object_arena_allocator.h index 929721a64..09216aada 100644 --- a/code/nel/include/nel/misc/object_arena_allocator.h +++ b/code/nel/include/nel/misc/object_arena_allocator.h @@ -83,8 +83,10 @@ private: # define NL_USES_DEFAULT_ARENA_OBJECT_ALLOCATOR \ void *operator new(size_t size) { return NLMISC::CObjectArenaAllocator::getDefaultAllocator().alloc((uint) size); }\ 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, 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); } } From 50b6af6d3dbb0a4ae070383902b058bf3ba7a7af Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 18:55:31 +0100 Subject: [PATCH 28/39] Fixed: Strict aliasing warnings --HG-- branch : develop --- code/nel/include/nel/misc/resource_ptr.h | 2 +- .../include/nel/misc/resource_ptr_inline.h | 16 ++++++------- code/nel/include/nel/misc/smart_ptr.h | 16 +++++++------ code/nel/include/nel/misc/smart_ptr_inline.h | 24 +++++++++---------- 4 files changed, 30 insertions(+), 28 deletions(-) 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..3a7087a3e 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); + pinf o= &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/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. From 9a6b3c91b71a6d01f7c07a79e8e2f87b4f00cb4c Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 18:58:13 +0100 Subject: [PATCH 29/39] Changed: Minor changes --HG-- branch : develop --- .../3d/driver/opengl/driver_opengl_window.cpp | 10 ++++----- code/nel/src/misc/common.cpp | 3 ++- code/nel/src/misc/config_file/cf_lexical.cpp | 2 +- code/ryzom/client/src/client.cpp | 3 +-- code/ryzom/client/src/release.cpp | 22 +++++++++---------- 5 files changed, 20 insertions(+), 20 deletions(-) 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 171214384..a7eb6e62a 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -477,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"); } } diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index ee9e84512..2194a89db 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -765,7 +765,8 @@ static bool createProcess(const std::string &programName, const std::string &arg 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) { diff --git a/code/nel/src/misc/config_file/cf_lexical.cpp b/code/nel/src/misc/config_file/cf_lexical.cpp index d132f4df8..fd43a03ce 100644 --- a/code/nel/src/misc/config_file/cf_lexical.cpp +++ b/code/nel/src/misc/config_file/cf_lexical.cpp @@ -3221,7 +3221,7 @@ static void *yy_flex_alloc( size ) yy_size_t size; #endif { - return (void *) malloc( size ); // TODO: delete + return (void *) malloc( size ); } #ifdef YY_USE_PROTOS diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index 10a3e1b40..a487bf8dd 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -183,14 +183,13 @@ int main(int argc, char **argv) Args.addArg("", "release", "", "Crash client after init"); #endif // TEST_CRASH_COUNTER + // extract the 2 or 3 first param (argv[1], argv[2] and argv[3]) it must be [shardId] #ifdef NL_OS_WINDOWS if (!Args.parse(cmdline)) return 1; #else if (!Args.parse(argc, argv)) return 1; #endif - // extract the 2 or 3 first param (argv[1], argv[2] and argv[3]) it must be [shardId] - // no shard id in ring mode std::string sLoginShardId; diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index aac29d590..6ad8396e2 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -569,13 +569,13 @@ void release() releaseCommands(); // Exit config file stuff - ClientCfg.release (); + ClientCfg.release(); // Disconnect the client from the server. NetMngr.disconnect(); // delete the sound manager - if(SoundMngr) + if (SoundMngr) { delete SoundMngr; SoundMngr = NULL; @@ -583,16 +583,16 @@ void release() // Release the Entities Animation Manager CEntityAnimationManager::delInstance(); - EAM= NULL; + EAM = NULL; nldebug("VR [C]: VR Shutting down"); releaseStereoDisplayDevice(); // Delete the driver. - if(Driver) + if (Driver) { // Release the prim - PrimFiles.release (*Driver); + PrimFiles.release(*Driver); if (TextContext != NULL) Driver->deleteTextContext(TextContext); @@ -617,13 +617,13 @@ void release() EventsListener.removeFromServer(CInputHandlerManager::getInstance()->FilteredEventServer); IDisplayer *clientLogDisplayer = ErrorLog->getDisplayer("CLIENT.LOG"); - if( clientLogDisplayer ) + if (clientLogDisplayer) { - DebugLog->removeDisplayer (clientLogDisplayer); - InfoLog->removeDisplayer (clientLogDisplayer); - WarningLog->removeDisplayer (clientLogDisplayer); - ErrorLog->removeDisplayer (clientLogDisplayer); - AssertLog->removeDisplayer (clientLogDisplayer); + DebugLog->removeDisplayer(clientLogDisplayer); + InfoLog->removeDisplayer(clientLogDisplayer); + WarningLog->removeDisplayer(clientLogDisplayer); + ErrorLog->removeDisplayer(clientLogDisplayer); + AssertLog->removeDisplayer(clientLogDisplayer); delete clientLogDisplayer; } From d37a1e032cda1fc8c45d4cdeda6f361ef8172e6e Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 19:01:34 +0100 Subject: [PATCH 30/39] Fixed: Don't call CCoTask::releaseInstance() because allocated on heap --HG-- branch : develop --- code/ryzom/client/src/release.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index 6ad8396e2..297b4ccc3 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -669,7 +669,6 @@ void release() CWidgetManager::release(); CViewRenderer::release(); CIXml::releaseLibXml(); - CCoTask::releaseInstance(); #if FINAL_VERSION // openURL ("http://www.ryzomcore.org/exit/"); From faecd5b952fd71333d2b98e034870e4592b051e5 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 19:02:06 +0100 Subject: [PATCH 31/39] Changed: extern keyword useless there --HG-- branch : develop --- code/ryzom/client/src/micro_life_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/client/src/micro_life_manager.cpp b/code/ryzom/client/src/micro_life_manager.cpp index 0fab8aa15..0d56b5d61 100644 --- a/code/ryzom/client/src/micro_life_manager.cpp +++ b/code/ryzom/client/src/micro_life_manager.cpp @@ -58,7 +58,7 @@ extern NL3D::UMaterial GenericMat; #endif #ifdef NL_DEBUG - extern bool DisplayMicroLifeActiveTiles = false; + bool DisplayMicroLifeActiveTiles = false; #endif H_AUTO_DECL(RZ_MicroLifeManager) From dbf443beb7cd4b81f75f324c3c08289c91be929e Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 19:04:29 +0100 Subject: [PATCH 32/39] Fixed: C++11 forbids to throw exception in destructor --HG-- branch : develop --- code/nel/src/misc/p_thread.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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."); + } } }; From 829092aa8c8968e70d3c96fb04d145790de1ea09 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 19:05:05 +0100 Subject: [PATCH 33/39] Fixed: Compilation with 3dsmax 2017 SDK --HG-- branch : develop --- code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 436dd45ea..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 @@ -1975,7 +1975,7 @@ IOResult RPatchMesh::Load(ILoad *iload) for (i=0; iWrite(&bBinded, sizeof (bool), &nb); From 8ef8b60ab828647c503097c48e85b8ff2c84f36c Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 19:05:24 +0100 Subject: [PATCH 34/39] Fixed: Warning on 64 bits --HG-- branch : develop --- code/nel/tools/3d/plugin_max/nel_patch_lib/rpo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3f2363a16..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 @@ -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; From 30b40568ede05a5848d8af1d7931b9e7c26621d1 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 19:07:15 +0100 Subject: [PATCH 35/39] Changed: Use 3dsmax SDK definitions --HG-- branch : develop --- code/nel/tools/3d/plugin_max/tile_utility/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) 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) From 083f44ec32c30e1ba36e7e52f82d7cb71c8d63a7 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 19:36:41 +0100 Subject: [PATCH 36/39] Fixed: Compilation --HG-- branch : develop --- code/nel/include/nel/misc/resource_ptr_inline.h | 2 +- .../tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/misc/resource_ptr_inline.h b/code/nel/include/nel/misc/resource_ptr_inline.h index 3a7087a3e..a2309e5a6 100644 --- a/code/nel/include/nel/misc/resource_ptr_inline.h +++ b/code/nel/include/nel/misc/resource_ptr_inline.h @@ -74,7 +74,7 @@ template SMART_INLINE void CReso // Cons - dest. template inline CResourcePtr::CResourcePtr() { - pinf o= &CRefCount::NullPtrInfo; + pinfo = &CRefCount::NullPtrInfo; Ptr= NULL; REF_TRACE("Smart()"); 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 6d0744dee..82eb42484 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp @@ -20,7 +20,7 @@ #include #include - +#include #include "nel/misc/line.h" #include "nel/misc/polygon.h" From a1baec9de2be99c74210cb8167709645a43b68af Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 19:39:39 +0100 Subject: [PATCH 37/39] Changed: Use _T macro --HG-- branch : develop --- code/nel/tools/3d/plugin_max/tile_utility/rgbadd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 db1f22b39..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); From 3d36a4bfb55b73176a42d1bd0a54097790742ffa Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Dec 2016 19:42:02 +0100 Subject: [PATCH 38/39] Changed: Removed unused methods and used TCHARs --HG-- branch : develop --- .../nel_export/nel_export_filetools.cpp | 298 +++--------------- 1 file changed, 38 insertions(+), 260 deletions(-) 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 Date: Sat, 10 Dec 2016 19:46:51 +0100 Subject: [PATCH 39/39] Changed: Replace Win32 calls by NeL methods --HG-- branch : develop --- .../3d/object_viewer/particle_workspace.cpp | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/code/nel/tools/3d/object_viewer/particle_workspace.cpp b/code/nel/tools/3d/object_viewer/particle_workspace.cpp index 66efb5783..54df32400 100644 --- a/code/nel/tools/3d/object_viewer/particle_workspace.cpp +++ b/code/nel/tools/3d/object_viewer/particle_workspace.cpp @@ -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); } //*********************************************************************************************** @@ -374,17 +365,19 @@ 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)