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++; }